diff options
| author | Dan Nicolaescu | 2007-11-13 15:11:41 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2007-11-13 15:11:41 +0000 |
| commit | 30a308aa4b0a2136d6a9ff0427047f07dbfe9815 (patch) | |
| tree | b8ba6e3692ade3a3fef49c6bfe0adf7dc368cfeb | |
| parent | fb053a1f93201ace1251db95e33d4d4901d4db22 (diff) | |
| download | emacs-30a308aa4b0a2136d6a9ff0427047f07dbfe9815.tar.gz emacs-30a308aa4b0a2136d6a9ff0427047f07dbfe9815.zip | |
(vc-register): Allow registering a file passed as a
parameter instead of just the current buffer.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/vc.el | 77 |
2 files changed, 46 insertions, 36 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bcb93e8a19c..36776cf818f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2007-11-13 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * vc.el (vc-register): Allow registering a file passed as a | ||
| 4 | parameter instead of just the current buffer. | ||
| 5 | |||
| 1 | 2007-11-12 Michael Albinus <michael.albinus@gmx.de> | 6 | 2007-11-12 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 7 | ||
| 3 | * net/tramp.el (tramp-open-connection-setup-interactive-shell): Check | 8 | * net/tramp.el (tramp-open-connection-setup-interactive-shell): Check |
diff --git a/lisp/vc.el b/lisp/vc.el index 3661d6b8609..39bf68ac310 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -1535,8 +1535,9 @@ merge in the changes into your working copy." | |||
| 1535 | (vc-call-backend backend 'create-repo)) | 1535 | (vc-call-backend backend 'create-repo)) |
| 1536 | 1536 | ||
| 1537 | ;;;###autoload | 1537 | ;;;###autoload |
| 1538 | (defun vc-register (&optional set-revision comment) | 1538 | (defun vc-register (&optional fname set-revision comment) |
| 1539 | "Register the current file into a version control system. | 1539 | "Register into a version control system. |
| 1540 | If FNAME is given register that file, otherwise register the current file. | ||
| 1540 | With prefix argument SET-REVISION, allow user to specify initial revision | 1541 | With prefix argument SET-REVISION, allow user to specify initial revision |
| 1541 | level. If COMMENT is present, use that as an initial comment. | 1542 | level. If COMMENT is present, use that as an initial comment. |
| 1542 | 1543 | ||
| @@ -1547,40 +1548,44 @@ directory are already registered under that backend) will be used to | |||
| 1547 | register the file. If no backend declares itself responsible, the | 1548 | register the file. If no backend declares itself responsible, the |
| 1548 | first backend that could register the file is used." | 1549 | first backend that could register the file is used." |
| 1549 | (interactive "P") | 1550 | (interactive "P") |
| 1550 | (unless buffer-file-name (error "No visited file")) | 1551 | (when (and (null fname) (null buffer-file-name)) (error "No visited file")) |
| 1551 | (when (vc-backend buffer-file-name) | 1552 | |
| 1552 | (if (vc-registered buffer-file-name) | 1553 | (let ((bname (if fname (get-file-buffer fname) buffer-file-name))) |
| 1553 | (error "This file is already registered") | 1554 | (unless fname (setq fname buffer-file-name)) |
| 1554 | (unless (y-or-n-p "Previous master file has vanished. Make a new one? ") | 1555 | (when (vc-backend fname) |
| 1555 | (error "Aborted")))) | 1556 | (if (vc-registered fname) |
| 1556 | ;; Watch out for new buffers of size 0: the corresponding file | 1557 | (error "This file is already registered") |
| 1557 | ;; does not exist yet, even though buffer-modified-p is nil. | 1558 | (unless (y-or-n-p "Previous master file has vanished. Make a new one? ") |
| 1558 | (if (and (not (buffer-modified-p)) | 1559 | (error "Aborted")))) |
| 1559 | (zerop (buffer-size)) | 1560 | ;; Watch out for new buffers of size 0: the corresponding file |
| 1560 | (not (file-exists-p buffer-file-name))) | 1561 | ;; does not exist yet, even though buffer-modified-p is nil. |
| 1561 | (set-buffer-modified-p t)) | 1562 | (when bname |
| 1562 | (vc-buffer-sync) | 1563 | (with-current-buffer bname |
| 1563 | 1564 | (if (and (not (buffer-modified-p)) | |
| 1564 | (vc-start-entry (list buffer-file-name) | 1565 | (zerop (buffer-size)) |
| 1565 | (if set-revision | 1566 | (not (file-exists-p buffer-file-name))) |
| 1566 | (read-string (format "Initial revision level for %s: " | 1567 | (set-buffer-modified-p t)) |
| 1567 | (buffer-name))) | 1568 | (vc-buffer-sync))) |
| 1568 | (vc-call-backend (vc-responsible-backend buffer-file-name) | 1569 | (vc-start-entry (list fname) |
| 1569 | 'init-revision)) | 1570 | (if set-revision |
| 1570 | (or comment (not vc-initial-comment)) | 1571 | (read-string (format "Initial revision level for %s: " |
| 1571 | nil | 1572 | fname)) |
| 1572 | "Enter initial comment." | 1573 | (vc-call-backend (vc-responsible-backend fname) |
| 1573 | (lambda (files rev comment) | 1574 | 'init-revision)) |
| 1574 | (dolist (file files) | 1575 | (or comment (not vc-initial-comment)) |
| 1575 | (message "Registering %s... " file) | 1576 | nil |
| 1576 | (let ((backend (vc-responsible-backend file t))) | 1577 | "Enter initial comment." |
| 1577 | (vc-file-clearprops file) | 1578 | (lambda (files rev comment) |
| 1578 | (vc-call-backend backend 'register (list file) rev comment) | 1579 | (dolist (file files) |
| 1579 | (vc-file-setprop file 'vc-backend backend) | 1580 | (message "Registering %s... " file) |
| 1580 | (unless vc-make-backup-files | 1581 | (let ((backend (vc-responsible-backend file t))) |
| 1581 | (make-local-variable 'backup-inhibited) | 1582 | (vc-file-clearprops file) |
| 1582 | (setq backup-inhibited t))) | 1583 | (vc-call-backend backend 'register (list file) rev comment) |
| 1583 | (message "Registering %s... done" file))))) | 1584 | (vc-file-setprop file 'vc-backend backend) |
| 1585 | (unless vc-make-backup-files | ||
| 1586 | (make-local-variable 'backup-inhibited) | ||
| 1587 | (setq backup-inhibited t))) | ||
| 1588 | (message "Registering %s... done" file)))))) | ||
| 1584 | 1589 | ||
| 1585 | (defun vc-register-with (backend) | 1590 | (defun vc-register-with (backend) |
| 1586 | "Register the current file with a specified back end." | 1591 | "Register the current file with a specified back end." |