diff options
| author | Eric S. Raymond | 2007-07-18 12:43:37 +0000 |
|---|---|---|
| committer | Eric S. Raymond | 2007-07-18 12:43:37 +0000 |
| commit | e4d2689288ec97ffa42f582fd3481612e88303d2 (patch) | |
| tree | 1696f8aae4b25f95108d087fe1806fa235872da6 | |
| parent | 3eaf40f78c51ea950ba0a75b0ebb31128f67a707 (diff) | |
| download | emacs-e4d2689288ec97ffa42f582fd3481612e88303d2.tar.gz emacs-e4d2689288ec97ffa42f582fd3481612e88303d2.zip | |
Generalize stay-local-p to operatre on lists of files.
Change two keybindings to point to new function names.
| -rw-r--r-- | lisp/vc-hooks.el | 101 | ||||
| -rw-r--r-- | lisp/vc.el | 18 |
2 files changed, 64 insertions, 55 deletions
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el index 38ddb35c976..809b49a4d0e 100644 --- a/lisp/vc-hooks.el +++ b/lisp/vc-hooks.el | |||
| @@ -160,31 +160,33 @@ by these regular expressions." | |||
| 160 | (defun vc-stay-local-p (file) | 160 | (defun vc-stay-local-p (file) |
| 161 | "Return non-nil if VC should stay local when handling FILE. | 161 | "Return non-nil if VC should stay local when handling FILE. |
| 162 | This uses the `repository-hostname' backend operation." | 162 | This uses the `repository-hostname' backend operation." |
| 163 | (let* ((backend (vc-backend file)) | 163 | (if (listp file) |
| 164 | (sym (vc-make-backend-sym backend 'stay-local)) | 164 | (if (remove-if-not (lambda (x) (not (vc-stay-local-p x))) file) 'no 'yes) |
| 165 | (stay-local (if (boundp sym) (symbol-value sym) t))) | 165 | (let* ((backend (vc-backend file)) |
| 166 | (if (eq stay-local t) (setq stay-local vc-stay-local)) | 166 | (sym (vc-make-backend-sym backend 'stay-local)) |
| 167 | (if (symbolp stay-local) stay-local | 167 | (stay-local (if (boundp sym) (symbol-value sym) t))) |
| 168 | (let ((dirname (if (file-directory-p file) | 168 | (if (eq stay-local t) (setq stay-local vc-stay-local)) |
| 169 | (directory-file-name file) | 169 | (if (symbolp stay-local) stay-local |
| 170 | (file-name-directory file)))) | 170 | (let ((dirname (if (file-directory-p file) |
| 171 | (eq 'yes | 171 | (directory-file-name file) |
| 172 | (or (vc-file-getprop dirname 'vc-stay-local-p) | 172 | (file-name-directory file)))) |
| 173 | (vc-file-setprop | 173 | (eq 'yes |
| 174 | dirname 'vc-stay-local-p | 174 | (or (vc-file-getprop dirname 'vc-stay-local-p) |
| 175 | (let ((hostname (vc-call-backend | 175 | (vc-file-setprop |
| 176 | backend 'repository-hostname dirname))) | 176 | dirname 'vc-stay-local-p |
| 177 | (if (not hostname) | 177 | (let ((hostname (vc-call-backend |
| 178 | 'no | 178 | backend 'repository-hostname dirname))) |
| 179 | (let ((default t)) | 179 | (if (not hostname) |
| 180 | (if (eq (car-safe stay-local) 'except) | 180 | 'no |
| 181 | (setq default nil stay-local (cdr stay-local))) | 181 | (let ((default t)) |
| 182 | (when (consp stay-local) | 182 | (if (eq (car-safe stay-local) 'except) |
| 183 | (setq stay-local | 183 | (setq default nil stay-local (cdr stay-local))) |
| 184 | (mapconcat 'identity stay-local "\\|"))) | 184 | (when (consp stay-local) |
| 185 | (if (if (string-match stay-local hostname) | 185 | (setq stay-local |
| 186 | default (not default)) | 186 | (mapconcat 'identity stay-local "\\|"))) |
| 187 | 'yes 'no))))))))))) | 187 | (if (if (string-match stay-local hostname) |
| 188 | default (not default)) | ||
| 189 | 'yes 'no)))))))))))) | ||
| 188 | 190 | ||
| 189 | ;;; This is handled specially now. | 191 | ;;; This is handled specially now. |
| 190 | ;; Tell Emacs about this new kind of minor mode | 192 | ;; Tell Emacs about this new kind of minor mode |
| @@ -373,20 +375,26 @@ backend is tried first." | |||
| 373 | (vc-file-setprop file 'vc-backend 'none) | 375 | (vc-file-setprop file 'vc-backend 'none) |
| 374 | nil))))) | 376 | nil))))) |
| 375 | 377 | ||
| 376 | (defun vc-backend (file) | 378 | (defun vc-backend (file-or-list) |
| 377 | "Return the version control type of FILE, nil if it is not registered." | 379 | "Return the version control type of FILE-OR-LIST, nil if it's not registered. |
| 380 | If the argument is a list, the files must all have the same back end." | ||
| 378 | ;; `file' can be nil in several places (typically due to the use of | 381 | ;; `file' can be nil in several places (typically due to the use of |
| 379 | ;; code like (vc-backend buffer-file-name)). | 382 | ;; code like (vc-backend buffer-file-name)). |
| 380 | (when (stringp file) | 383 | (cond ((stringp file-or-list) |
| 381 | (let ((property (vc-file-getprop file 'vc-backend))) | 384 | (let ((property (vc-file-getprop file-or-list 'vc-backend))) |
| 382 | ;; Note that internally, Emacs remembers unregistered | 385 | ;; Note that internally, Emacs remembers unregistered |
| 383 | ;; files by setting the property to `none'. | 386 | ;; files by setting the property to `none'. |
| 384 | (cond ((eq property 'none) nil) | 387 | (cond ((eq property 'none) nil) |
| 385 | (property) | 388 | (property) |
| 386 | ;; vc-registered sets the vc-backend property | 389 | ;; vc-registered sets the vc-backend property |
| 387 | (t (if (vc-registered file) | 390 | (t (if (vc-registered file-or-list) |
| 388 | (vc-file-getprop file 'vc-backend) | 391 | (vc-file-getprop file-or-list 'vc-backend) |
| 389 | nil)))))) | 392 | nil))))) |
| 393 | ((and file-or-list (listp file-or-list)) | ||
| 394 | (vc-backend (car file-or-list))) | ||
| 395 | (t | ||
| 396 | nil))) | ||
| 397 | |||
| 390 | 398 | ||
| 391 | (defun vc-backend-subdirectory-name (file) | 399 | (defun vc-backend-subdirectory-name (file) |
| 392 | "Return where the master and lock FILEs for the current directory are kept." | 400 | "Return where the master and lock FILEs for the current directory are kept." |
| @@ -480,7 +488,7 @@ For registered files, the value returned is one of: | |||
| 480 | ;; - `removed' | 488 | ;; - `removed' |
| 481 | ;; - `copied' and `moved' (might be handled by `removed' and `added') | 489 | ;; - `copied' and `moved' (might be handled by `removed' and `added') |
| 482 | (or (vc-file-getprop file 'vc-state) | 490 | (or (vc-file-getprop file 'vc-state) |
| 483 | (if (vc-backend file) | 491 | (if (and (> (length file) 0) (vc-backend file)) |
| 484 | (vc-file-setprop file 'vc-state | 492 | (vc-file-setprop file 'vc-state |
| 485 | (vc-call state-heuristic file))))) | 493 | (vc-call state-heuristic file))))) |
| 486 | 494 | ||
| @@ -532,7 +540,7 @@ Return non-nil if FILE is unchanged." | |||
| 532 | (vc-call diff file)))))) | 540 | (vc-call diff file)))))) |
| 533 | 541 | ||
| 534 | (defun vc-workfile-version (file) | 542 | (defun vc-workfile-version (file) |
| 535 | "Return the version level of the current workfile FILE. | 543 | "Return the repository version from which FILE was checked out. |
| 536 | If FILE is not registered, this function always returns nil." | 544 | If FILE is not registered, this function always returns nil." |
| 537 | (or (vc-file-getprop file 'vc-workfile-version) | 545 | (or (vc-file-getprop file 'vc-workfile-version) |
| 538 | (if (vc-backend file) | 546 | (if (vc-backend file) |
| @@ -873,7 +881,7 @@ Used in `find-file-not-found-functions'." | |||
| 873 | (let ((map (make-sparse-keymap))) | 881 | (let ((map (make-sparse-keymap))) |
| 874 | (define-key map "a" 'vc-update-change-log) | 882 | (define-key map "a" 'vc-update-change-log) |
| 875 | (define-key map "b" 'vc-switch-backend) | 883 | (define-key map "b" 'vc-switch-backend) |
| 876 | (define-key map "c" 'vc-cancel-version) | 884 | (define-key map "c" 'vc-rollback) |
| 877 | (define-key map "d" 'vc-directory) | 885 | (define-key map "d" 'vc-directory) |
| 878 | (define-key map "g" 'vc-annotate) | 886 | (define-key map "g" 'vc-annotate) |
| 879 | (define-key map "h" 'vc-insert-headers) | 887 | (define-key map "h" 'vc-insert-headers) |
| @@ -882,8 +890,9 @@ Used in `find-file-not-found-functions'." | |||
| 882 | (define-key map "m" 'vc-merge) | 890 | (define-key map "m" 'vc-merge) |
| 883 | (define-key map "r" 'vc-retrieve-snapshot) | 891 | (define-key map "r" 'vc-retrieve-snapshot) |
| 884 | (define-key map "s" 'vc-create-snapshot) | 892 | (define-key map "s" 'vc-create-snapshot) |
| 885 | (define-key map "u" 'vc-revert-buffer) | 893 | (define-key map "u" 'vc-revert) |
| 886 | (define-key map "v" 'vc-next-action) | 894 | (define-key map "v" 'vc-next-action) |
| 895 | (define-key map "+" 'vc-update) | ||
| 887 | (define-key map "=" 'vc-diff) | 896 | (define-key map "=" 'vc-diff) |
| 888 | (define-key map "~" 'vc-version-other-window) | 897 | (define-key map "~" 'vc-version-other-window) |
| 889 | map)) | 898 | map)) |
| @@ -913,9 +922,9 @@ Used in `find-file-not-found-functions'." | |||
| 913 | (define-key vc-menu-map [separator2] '("----")) | 922 | (define-key vc-menu-map [separator2] '("----")) |
| 914 | (define-key vc-menu-map [vc-insert-header] | 923 | (define-key vc-menu-map [vc-insert-header] |
| 915 | '("Insert Header" . vc-insert-headers)) | 924 | '("Insert Header" . vc-insert-headers)) |
| 916 | (define-key vc-menu-map [undo] '("Undo Last Check-In" . vc-cancel-version)) | 925 | (define-key vc-menu-map [undo] '("Undo Last Check-In" . vc-rollback)) |
| 917 | (define-key vc-menu-map [vc-revert-buffer] | 926 | (define-key vc-menu-map [vc-revert] |
| 918 | '("Revert to Base Version" . vc-revert-buffer)) | 927 | '("Revert to Base Version" . vc-revert)) |
| 919 | (define-key vc-menu-map [vc-update] | 928 | (define-key vc-menu-map [vc-update] |
| 920 | '("Update to Latest Version" . vc-update)) | 929 | '("Update to Latest Version" . vc-update)) |
| 921 | (define-key vc-menu-map [vc-next-action] '("Check In/Out" . vc-next-action)) | 930 | (define-key vc-menu-map [vc-next-action] '("Check In/Out" . vc-next-action)) |
| @@ -932,8 +941,8 @@ Used in `find-file-not-found-functions'." | |||
| 932 | ;;(put 'vc-update-change-log 'menu-enable | 941 | ;;(put 'vc-update-change-log 'menu-enable |
| 933 | ;; '(member (vc-buffer-backend) '(RCS CVS))) | 942 | ;; '(member (vc-buffer-backend) '(RCS CVS))) |
| 934 | ;;(put 'vc-print-log 'menu-enable 'vc-mode) | 943 | ;;(put 'vc-print-log 'menu-enable 'vc-mode) |
| 935 | ;;(put 'vc-cancel-version 'menu-enable 'vc-mode) | 944 | ;;(put 'vc-rollback 'menu-enable 'vc-mode) |
| 936 | ;;(put 'vc-revert-buffer 'menu-enable 'vc-mode) | 945 | ;;(put 'vc-revert 'menu-enable 'vc-mode) |
| 937 | ;;(put 'vc-insert-headers 'menu-enable 'vc-mode) | 946 | ;;(put 'vc-insert-headers 'menu-enable 'vc-mode) |
| 938 | ;;(put 'vc-next-action 'menu-enable 'vc-mode) | 947 | ;;(put 'vc-next-action 'menu-enable 'vc-mode) |
| 939 | ;;(put 'vc-register 'menu-enable '(and buffer-file-name (not vc-mode))) | 948 | ;;(put 'vc-register 'menu-enable '(and buffer-file-name (not vc-mode))) |
diff --git a/lisp/vc.el b/lisp/vc.el index a147f7e4dd0..9377c9b8026 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -242,7 +242,7 @@ | |||
| 242 | ;; already been reverted from a version backup, and this function | 242 | ;; already been reverted from a version backup, and this function |
| 243 | ;; only needs to update the status of FILE within the backend. | 243 | ;; only needs to update the status of FILE within the backend. |
| 244 | ;; | 244 | ;; |
| 245 | ;; - cancel-version (file editable) | 245 | ;; - rollback (file editable) |
| 246 | ;; | 246 | ;; |
| 247 | ;; Cancel the current workfile version of FILE, i.e. remove it from the | 247 | ;; Cancel the current workfile version of FILE, i.e. remove it from the |
| 248 | ;; master. EDITABLE non-nil means that FILE should be writable | 248 | ;; master. EDITABLE non-nil means that FILE should be writable |
| @@ -588,7 +588,7 @@ to use -L and sets this variable to remember whether it worked." | |||
| 588 | :group 'vc) | 588 | :group 'vc) |
| 589 | 589 | ||
| 590 | (defcustom vc-allow-async-revert nil | 590 | (defcustom vc-allow-async-revert nil |
| 591 | "Specifies whether the diff during \\[vc-revert-buffer] may be asynchronous. | 591 | "Specifies whether the diff during \\[vc-revert] may be asynchronous. |
| 592 | Enabling this option means that you can confirm a revert operation even | 592 | Enabling this option means that you can confirm a revert operation even |
| 593 | if the local changes in the file have not been found and displayed yet." | 593 | if the local changes in the file have not been found and displayed yet." |
| 594 | :type '(choice (const :tag "No" nil) | 594 | :type '(choice (const :tag "No" nil) |
| @@ -1274,7 +1274,7 @@ If VERBOSE is non-nil, query the user rather than using default parameters." | |||
| 1274 | ;; DO NOT revert the file without asking the user! | 1274 | ;; DO NOT revert the file without asking the user! |
| 1275 | (if (not visited) (find-file-other-window file)) | 1275 | (if (not visited) (find-file-other-window file)) |
| 1276 | (if (yes-or-no-p "Revert to master version? ") | 1276 | (if (yes-or-no-p "Revert to master version? ") |
| 1277 | (vc-revert-buffer))) | 1277 | (vc-revert))) |
| 1278 | (t ;; normal action | 1278 | (t ;; normal action |
| 1279 | (if (not verbose) | 1279 | (if (not verbose) |
| 1280 | (vc-checkin file nil comment) | 1280 | (vc-checkin file nil comment) |
| @@ -2534,7 +2534,7 @@ it if their logs are not in RCS format." | |||
| 2534 | (delete-region (match-beginning 0) (match-end 0))))) | 2534 | (delete-region (match-beginning 0) (match-end 0))))) |
| 2535 | 2535 | ||
| 2536 | ;;;###autoload | 2536 | ;;;###autoload |
| 2537 | (defun vc-revert-buffer () | 2537 | (defun vc-revert () |
| 2538 | "Revert the current buffer's file to the version it was based on. | 2538 | "Revert the current buffer's file to the version it was based on. |
| 2539 | This asks for confirmation if the buffer contents are not identical | 2539 | This asks for confirmation if the buffer contents are not identical |
| 2540 | to that version. This function does not automatically pick up newer | 2540 | to that version. This function does not automatically pick up newer |
| @@ -2593,7 +2593,7 @@ the current branch are merged into the working file." | |||
| 2593 | (if (eq (vc-state file) 'edited) | 2593 | (if (eq (vc-state file) 'edited) |
| 2594 | (error | 2594 | (error |
| 2595 | (substitute-command-keys | 2595 | (substitute-command-keys |
| 2596 | "File is locked--type \\[vc-revert-buffer] to discard changes")) | 2596 | "File is locked--type \\[vc-revert] to discard changes")) |
| 2597 | (error | 2597 | (error |
| 2598 | (substitute-command-keys | 2598 | (substitute-command-keys |
| 2599 | "Unexpected file state (%s)--type \\[vc-next-action] to correct") | 2599 | "Unexpected file state (%s)--type \\[vc-next-action] to correct") |
| @@ -2659,7 +2659,7 @@ return its name; otherwise return nil." | |||
| 2659 | (vc-resynch-buffer file t t)) | 2659 | (vc-resynch-buffer file t t)) |
| 2660 | 2660 | ||
| 2661 | ;;;###autoload | 2661 | ;;;###autoload |
| 2662 | (defun vc-cancel-version (norevert) | 2662 | (defun vc-rollback (norevert) |
| 2663 | "Get rid of most recently checked in version of this file. | 2663 | "Get rid of most recently checked in version of this file. |
| 2664 | A prefix argument NOREVERT means do not revert the buffer afterwards." | 2664 | A prefix argument NOREVERT means do not revert the buffer afterwards." |
| 2665 | (interactive "P") | 2665 | (interactive "P") |
| @@ -2668,12 +2668,12 @@ A prefix argument NOREVERT means do not revert the buffer afterwards." | |||
| 2668 | (backend (vc-backend file)) | 2668 | (backend (vc-backend file)) |
| 2669 | (target (vc-workfile-version file))) | 2669 | (target (vc-workfile-version file))) |
| 2670 | (cond | 2670 | (cond |
| 2671 | ((not (vc-find-backend-function backend 'cancel-version)) | 2671 | ((not (vc-find-backend-function backend 'rollback)) |
| 2672 | (error "Sorry, canceling versions is not supported under %s" backend)) | 2672 | (error "Sorry, canceling versions is not supported under %s" backend)) |
| 2673 | ((not (vc-call latest-on-branch-p file)) | 2673 | ((not (vc-call latest-on-branch-p file)) |
| 2674 | (error "This is not the latest version; VC cannot cancel it")) | 2674 | (error "This is not the latest version; VC cannot cancel it")) |
| 2675 | ((not (vc-up-to-date-p file)) | 2675 | ((not (vc-up-to-date-p file)) |
| 2676 | (error "%s" (substitute-command-keys "File is not up to date; use \\[vc-revert-buffer] to discard changes")))) | 2676 | (error "%s" (substitute-command-keys "File is not up to date; use \\[vc-revert] to discard changes")))) |
| 2677 | (if (null (yes-or-no-p (format "Remove version %s from master? " target))) | 2677 | (if (null (yes-or-no-p (format "Remove version %s from master? " target))) |
| 2678 | (error "Aborted") | 2678 | (error "Aborted") |
| 2679 | (setq norevert (or norevert (not | 2679 | (setq norevert (or norevert (not |
| @@ -2682,7 +2682,7 @@ A prefix argument NOREVERT means do not revert the buffer afterwards." | |||
| 2682 | (message "Removing last change from %s..." file) | 2682 | (message "Removing last change from %s..." file) |
| 2683 | (with-vc-properties | 2683 | (with-vc-properties |
| 2684 | file | 2684 | file |
| 2685 | (vc-call cancel-version file norevert) | 2685 | (vc-call rollback file norevert) |
| 2686 | `((vc-state . ,(if norevert 'edited 'up-to-date)) | 2686 | `((vc-state . ,(if norevert 'edited 'up-to-date)) |
| 2687 | (vc-checkout-time . ,(if norevert | 2687 | (vc-checkout-time . ,(if norevert |
| 2688 | 0 | 2688 | 0 |