diff options
| author | Dan Nicolaescu | 2008-06-15 02:52:44 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2008-06-15 02:52:44 +0000 |
| commit | 39693840dca6eeccd01ba4e42da05662e6f66d91 (patch) | |
| tree | 429e7f954190655816db40a7cbad0a3afe59ffe5 | |
| parent | 611bee81fdd817dd07e1a4423fd6a042b48e7f43 (diff) | |
| download | emacs-39693840dca6eeccd01ba4e42da05662e6f66d91.tar.gz emacs-39693840dca6eeccd01ba4e42da05662e6f66d91.zip | |
(vc-deduce-fileset): Check if the buffer has a file.
(vc-register): Call the backend function only once, instead of
once for each file.
(vc-next-action): Update call to vc-register.
(vc-dir-register): Remove function.
(vc-dir): Bind vc-register instead of vc-dir-register.
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/vc.el | 108 |
2 files changed, 64 insertions, 53 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index fc0c5db4830..fd6246c5916 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2008-06-15 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * vc.el (vc-deduce-fileset): Check if the buffer has a file. | ||
| 4 | (vc-register): Call the backend function only once, instead of | ||
| 5 | once for each file. | ||
| 6 | (vc-next-action): Update call to vc-register. | ||
| 7 | (vc-dir-register): Remove function. | ||
| 8 | (vc-dir): Bind vc-register instead of vc-dir-register. | ||
| 9 | |||
| 1 | 2008-06-14 Glenn Morris <rgm@gnu.org> | 10 | 2008-06-14 Glenn Morris <rgm@gnu.org> |
| 2 | 11 | ||
| 3 | * Makefile.in (ELCFILES): Add net/newst-*.el. | 12 | * Makefile.in (ELCFILES): Add net/newst-*.el. |
diff --git a/lisp/vc.el b/lisp/vc.el index e9af02d7403..e149976d8db 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -1042,6 +1042,8 @@ Otherwise, throw an error." | |||
| 1042 | (progn | 1042 | (progn |
| 1043 | (set-buffer vc-parent-buffer) | 1043 | (set-buffer vc-parent-buffer) |
| 1044 | (vc-deduce-fileset))) | 1044 | (vc-deduce-fileset))) |
| 1045 | ((not buffer-file-name) | ||
| 1046 | (error "Buffer %s is not associated with a file" (buffer-name))) | ||
| 1045 | ((and allow-unregistered (not (vc-registered buffer-file-name))) | 1047 | ((and allow-unregistered (not (vc-registered buffer-file-name))) |
| 1046 | (list (vc-responsible-backend | 1048 | (list (vc-responsible-backend |
| 1047 | (file-name-directory (buffer-file-name))) | 1049 | (file-name-directory (buffer-file-name))) |
| @@ -1144,7 +1146,7 @@ merge in the changes into your working copy." | |||
| 1144 | ((eq state 'ignored) | 1146 | ((eq state 'ignored) |
| 1145 | (error "Fileset files are ignored by the version-control system.")) | 1147 | (error "Fileset files are ignored by the version-control system.")) |
| 1146 | ((or (null state) (eq state 'unregistered)) | 1148 | ((or (null state) (eq state 'unregistered)) |
| 1147 | (mapc (lambda (arg) (vc-register nil arg)) files)) | 1149 | (vc-register nil vc-fileset)) |
| 1148 | ;; Files are up-to-date, or need a merge and user specified a revision | 1150 | ;; Files are up-to-date, or need a merge and user specified a revision |
| 1149 | ((or (eq state 'up-to-date) (and verbose (eq state 'needs-update))) | 1151 | ((or (eq state 'up-to-date) (and verbose (eq state 'needs-update))) |
| 1150 | (cond | 1152 | (cond |
| @@ -1294,9 +1296,10 @@ merge in the changes into your working copy." | |||
| 1294 | (vc-call-backend backend 'create-repo)) | 1296 | (vc-call-backend backend 'create-repo)) |
| 1295 | 1297 | ||
| 1296 | ;;;###autoload | 1298 | ;;;###autoload |
| 1297 | (defun vc-register (&optional set-revision fname comment) | 1299 | (defun vc-register (&optional set-revision vc-fileset comment) |
| 1298 | "Register into a version control system. | 1300 | "Register into a version control system. |
| 1299 | If FNAME is given register that file, otherwise register the current file. | 1301 | If VC-FILESET is given, register the files in that fileset. |
| 1302 | Otherwise register the current file. | ||
| 1300 | With prefix argument SET-REVISION, allow user to specify initial revision | 1303 | With prefix argument SET-REVISION, allow user to specify initial revision |
| 1301 | level. If COMMENT is present, use that as an initial comment. | 1304 | level. If COMMENT is present, use that as an initial comment. |
| 1302 | 1305 | ||
| @@ -1307,45 +1310,51 @@ directory are already registered under that backend) will be used to | |||
| 1307 | register the file. If no backend declares itself responsible, the | 1310 | register the file. If no backend declares itself responsible, the |
| 1308 | first backend that could register the file is used." | 1311 | first backend that could register the file is used." |
| 1309 | (interactive "P") | 1312 | (interactive "P") |
| 1310 | (when (and (null fname) (null buffer-file-name)) (error "No visited file")) | 1313 | (let* ((fileset-arg (or vc-fileset (vc-deduce-fileset nil t))) |
| 1311 | 1314 | (backend (car fileset-arg)) | |
| 1312 | (let ((bname (if fname (get-file-buffer fname) (current-buffer)))) | 1315 | (files (nth 1 fileset-arg)) |
| 1313 | (unless fname (setq fname buffer-file-name)) | 1316 | (fileset-only-files (nth 2 fileset-arg))) |
| 1314 | (when (vc-backend fname) | 1317 | (dolist (fname fileset-only-files) |
| 1315 | (if (vc-registered fname) | 1318 | (let ((bname (get-file-buffer fname))) |
| 1316 | (error "This file is already registered") | 1319 | (unless fname (setq fname buffer-file-name)) |
| 1317 | (unless (y-or-n-p "Previous master file has vanished. Make a new one? ") | 1320 | (when (vc-backend fname) |
| 1318 | (error "Aborted")))) | 1321 | (if (vc-registered fname) |
| 1319 | ;; Watch out for new buffers of size 0: the corresponding file | 1322 | (error "This file is already registered") |
| 1320 | ;; does not exist yet, even though buffer-modified-p is nil. | 1323 | (unless (y-or-n-p "Previous master file has vanished. Make a new one? ") |
| 1321 | (when bname | 1324 | (error "Aborted")))) |
| 1322 | (with-current-buffer bname | 1325 | ;; Watch out for new buffers of size 0: the corresponding file |
| 1323 | (when (and (not (buffer-modified-p)) | 1326 | ;; does not exist yet, even though buffer-modified-p is nil. |
| 1324 | (zerop (buffer-size)) | 1327 | (when bname |
| 1325 | (not (file-exists-p buffer-file-name))) | 1328 | (with-current-buffer bname |
| 1326 | (set-buffer-modified-p t)) | 1329 | (when (and (not (buffer-modified-p)) |
| 1327 | (vc-buffer-sync))) | 1330 | (zerop (buffer-size)) |
| 1328 | (vc-start-logentry (list fname) | 1331 | (not (file-exists-p buffer-file-name))) |
| 1329 | (if set-revision | 1332 | (set-buffer-modified-p t)) |
| 1330 | (read-string (format "Initial revision level for %s: " | 1333 | (vc-buffer-sync))))) |
| 1331 | fname)) | 1334 | (lexical-let ((backend backend) |
| 1332 | (vc-call-backend (vc-responsible-backend fname) | 1335 | (files fileset-only-files)) |
| 1333 | 'init-revision)) | 1336 | (vc-start-logentry |
| 1334 | (or comment (not vc-initial-comment)) | 1337 | files |
| 1335 | nil | 1338 | (if set-revision |
| 1336 | "Enter initial comment." | 1339 | (read-string (format "Initial revision level for %s: " |
| 1337 | "*VC-log*" | 1340 | files)) |
| 1338 | (lambda (files rev comment) | 1341 | (vc-call-backend backend 'init-revision)) |
| 1339 | (dolist (file files) | 1342 | (or comment (not vc-initial-comment)) |
| 1340 | (message "Registering %s... " file) | 1343 | nil |
| 1341 | (let ((backend (vc-responsible-backend file t))) | 1344 | "Enter initial comment." |
| 1342 | (vc-file-clearprops file) | 1345 | "*VC-log*" |
| 1343 | (vc-call-backend backend 'register (list file) rev comment) | 1346 | (lambda (files rev comment) |
| 1344 | (vc-file-setprop file 'vc-backend backend) | 1347 | (message "Registering %s... " files) |
| 1345 | (unless vc-make-backup-files | 1348 | (dolist (file files) |
| 1346 | (make-local-variable 'backup-inhibited) | 1349 | (vc-file-clearprops file)) |
| 1347 | (setq backup-inhibited t))) | 1350 | (vc-call-backend backend 'register files rev comment) |
| 1348 | (message "Registering %s... done" file)))))) | 1351 | (dolist (file files) |
| 1352 | (vc-file-setprop file 'vc-backend backend) | ||
| 1353 | (unless vc-make-backup-files | ||
| 1354 | ;; FIXME: Is this code right? What is it supposed to do? | ||
| 1355 | (make-local-variable 'backup-inhibited) | ||
| 1356 | (setq backup-inhibited t))) | ||
| 1357 | (message "Registering %s... done" files)))))) | ||
| 1349 | 1358 | ||
| 1350 | (defun vc-register-with (backend) | 1359 | (defun vc-register-with (backend) |
| 1351 | "Register the current file with a specified back end." | 1360 | "Register the current file with a specified back end." |
| @@ -2000,13 +2009,6 @@ outside of VC) and one wants to do some operation on it." | |||
| 2000 | vc-ewoc | 2009 | vc-ewoc |
| 2001 | (lambda (crt) (not (eq (vc-dir-fileinfo->state crt) 'up-to-date))))) | 2010 | (lambda (crt) (not (eq (vc-dir-fileinfo->state crt) 'up-to-date))))) |
| 2002 | 2011 | ||
| 2003 | (defun vc-dir-register () | ||
| 2004 | "Register the marked files, or the current file if no marks." | ||
| 2005 | (interactive) | ||
| 2006 | ;; FIXME: Just pass the fileset to vc-register. | ||
| 2007 | (mapc (lambda (arg) (vc-register nil arg)) | ||
| 2008 | (or (vc-dir-marked-files) (list (vc-dir-current-file))))) | ||
| 2009 | |||
| 2010 | (defun vc-default-status-fileinfo-extra (backend file) | 2012 | (defun vc-default-status-fileinfo-extra (backend file) |
| 2011 | "Default absence of extra information returned for a file." | 2013 | "Default absence of extra information returned for a file." |
| 2012 | nil) | 2014 | nil) |
| @@ -2052,10 +2054,10 @@ outside of VC) and one wants to do some operation on it." | |||
| 2052 | ;; Add VC-specific keybindings | 2054 | ;; Add VC-specific keybindings |
| 2053 | (let ((map (current-local-map))) | 2055 | (let ((map (current-local-map))) |
| 2054 | (define-key map "v" 'vc-next-action) ;; C-x v v | 2056 | (define-key map "v" 'vc-next-action) ;; C-x v v |
| 2055 | (define-key map "=" 'vc-diff) ;; C-x v = | 2057 | (define-key map "=" 'vc-diff) ;; C-x v = |
| 2056 | (define-key map "i" 'vc-dir-register) ;; C-x v i | 2058 | (define-key map "i" 'vc-register) ;; C-x v i |
| 2057 | (define-key map "+" 'vc-update) ;; C-x v + | 2059 | (define-key map "+" 'vc-update) ;; C-x v + |
| 2058 | (define-key map "l" 'vc-print-log) ;; C-x v l | 2060 | (define-key map "l" 'vc-print-log) ;; C-x v l |
| 2059 | ;; More confusing than helpful, probably | 2061 | ;; More confusing than helpful, probably |
| 2060 | ;(define-key map "R" 'vc-revert) ;; u is taken by dispatcher unmark. | 2062 | ;(define-key map "R" 'vc-revert) ;; u is taken by dispatcher unmark. |
| 2061 | ;(define-key map "A" 'vc-annotate) ;; g is taken by dispatcher refresh | 2063 | ;(define-key map "A" 'vc-annotate) ;; g is taken by dispatcher refresh |