diff options
| author | Chong Yidong <cyd@stupidchicken.com> | 2010-07-10 14:52:53 -0400 |
|---|---|---|
| committer | Chong Yidong <cyd@stupidchicken.com> | 2010-07-10 14:52:53 -0400 |
| commit | 2ec1b5ee3464999a18b8197101e8bf08a3c564a8 (patch) | |
| tree | 4837c369ac576fbfd063b1ff046a3daca372f082 /lisp/vc | |
| parent | c971758df75640c55e6f9d7ac7d9c6909519d0b4 (diff) | |
| parent | 7c33a0572280bdcf0583c5625cfda32f63fad56d (diff) | |
| download | emacs-2ec1b5ee3464999a18b8197101e8bf08a3c564a8.tar.gz | |
Merge changes from emacs-23 branch.
Diffstat (limited to 'lisp/vc')
| -rw-r--r-- | lisp/vc/vc-annotate.el | 13 | ||||
| -rw-r--r-- | lisp/vc/vc-dir.el | 36 | ||||
| -rw-r--r-- | lisp/vc/vc-git.el | 30 | ||||
| -rw-r--r-- | lisp/vc/vc.el | 9 |
4 files changed, 53 insertions, 35 deletions
diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el index d0951bdd404..c95fe54d04a 100644 --- a/lisp/vc/vc-annotate.el +++ b/lisp/vc/vc-annotate.el @@ -315,7 +315,7 @@ use; you may override this using the second optional arg MODE." vc-annotate-display-mode)))) ;;;###autoload -(defun vc-annotate (file rev &optional display-mode buf move-point-to) +(defun vc-annotate (file rev &optional display-mode buf move-point-to vc-bk) "Display the edit history of the current FILE using colors. This command creates a buffer that shows, for each line of the current @@ -336,6 +336,8 @@ age, and everything that is older than that is shown in blue. If MOVE-POINT-TO is given, move the point to that line. +If VC-BK is given used that VC backend. + Customization variables: `vc-annotate-menu-elements' customizes the menu elements of the @@ -376,7 +378,7 @@ mode-specific menu. `vc-annotate-color-map' and ;; In case it had to be uniquified. (setq temp-buffer-name (buffer-name)))) (with-output-to-temp-buffer temp-buffer-name - (let ((backend (vc-backend file)) + (let ((backend (or vc-bk (vc-backend file))) (coding-system-for-read buffer-file-coding-system)) (vc-call-backend backend 'annotate-command file (get-buffer temp-buffer-name) rev) @@ -462,7 +464,7 @@ Return a cons (REV . FILENAME)." (if (not rev-at-line) (message "Cannot extract revision number from the current line") (switch-to-buffer-other-window - (vc-find-revision (cdr rev-at-line) (car rev-at-line))))))) + (vc-find-revision (cdr rev-at-line) (car rev-at-line) vc-annotate-backend)))))) (defun vc-annotate-revision-previous-to-line () "Visit the annotation of the revision before the revision at line." @@ -527,7 +529,7 @@ the file in question, search for the log entry required and move point ." (message "Cannot extract revision number from the current line") (setq prev-rev (vc-call-backend vc-annotate-backend 'previous-revision - fname rev)) + (if filediff fname nil) rev)) (if (not prev-rev) (message "Cannot diff from any revision prior to %s" rev) (save-window-excursion @@ -597,7 +599,8 @@ describes a revision number, so warp to that revision." ;; place the point in the line. (min oldline (progn (goto-char (point-max)) (forward-line -1) - (line-number-at-pos)))))))) + (line-number-at-pos))) + vc-annotate-backend))))) (defun vc-annotate-compcar (threshold a-list) "Test successive cons cells of A-LIST against THRESHOLD. diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 161013fbae0..9cacef2f71b 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -412,22 +412,24 @@ If NOINSERT, ignore elements on ENTRIES which are not in the ewoc." (setq entry (car entries)) (setq node (ewoc-next vc-ewoc node))) (t - (ewoc-enter-before vc-ewoc node - (apply 'vc-dir-create-fileinfo entry)) + (unless noinsert + (ewoc-enter-before vc-ewoc node + (apply 'vc-dir-create-fileinfo entry))) (setq entries (cdr entries)) (setq entry (car entries)))))) (t - ;; We might need to insert a directory node if the - ;; previous node was in a different directory. - (let* ((rd (file-relative-name entrydir)) - (prev-node (ewoc-prev vc-ewoc node)) - (prev-dir (vc-dir-node-directory prev-node))) - (unless (string-equal entrydir prev-dir) - (ewoc-enter-before - vc-ewoc node (vc-dir-create-fileinfo rd nil nil nil entrydir)))) - ;; Now insert the node itself. - (ewoc-enter-before vc-ewoc node - (apply 'vc-dir-create-fileinfo entry)) + (unless noinsert + ;; We might need to insert a directory node if the + ;; previous node was in a different directory. + (let* ((rd (file-relative-name entrydir)) + (prev-node (ewoc-prev vc-ewoc node)) + (prev-dir (vc-dir-node-directory prev-node))) + (unless (string-equal entrydir prev-dir) + (ewoc-enter-before + vc-ewoc node (vc-dir-create-fileinfo rd nil nil nil entrydir)))) + ;; Now insert the node itself. + (ewoc-enter-before vc-ewoc node + (apply 'vc-dir-create-fileinfo entry))) (setq entries (cdr entries) entry (car entries)))))) ;; We're past the last node, all remaining entries go to the end. (unless (or node noinsert) @@ -902,10 +904,12 @@ If it is a file, return the corresponding cons for the file itself." (vc-dir-resync-directory-files file) (ewoc-set-hf vc-ewoc (vc-dir-headers vc-dir-backend default-directory) "")) - (let ((state (vc-dir-recompute-file-state file ddir))) + (let* ((complete-state (vc-dir-recompute-file-state file ddir)) + (state (cadr complete-state))) (vc-dir-update - (list state) - status-buf (eq (cadr state) 'up-to-date)))))))))) + (list complete-state) + status-buf (or (not state) + (eq state 'up-to-date))))))))))) ;; Remove out-of-date entries from vc-dir-buffers. (dolist (b drop) (setq vc-dir-buffers (delq b vc-dir-buffers))))) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 6129b21c324..cccccbdfd02 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -563,13 +563,18 @@ or an empty string if none." (let* (process-file-side-effects (coding-system-for-read 'binary) (coding-system-for-write 'binary) - (fullname (substring - (vc-git--run-command-string - file "ls-files" "-z" "--full-name" "--") - 0 -1))) + (fullname + (let ((fn (vc-git--run-command-string + file "ls-files" "-z" "--full-name" "--"))) + ;; ls-files does not return anything when looking for a + ;; revision of a file that has been renamed or removed. + (if (string= fn "") + (file-relative-name file (vc-git-root default-directory)) + (substring fn 0 -1))))) (vc-git-command buffer 0 - (concat (if rev rev "HEAD") ":" fullname) "cat-file" "blob"))) + nil + "cat-file" "blob" (concat (if rev rev "HEAD") ":" fullname)))) (defun vc-git-checkout (file &optional editable rev) (vc-git-command nil 0 file "checkout" (or rev "HEAD"))) @@ -723,7 +728,7 @@ or BRANCH^ (where \"^\" can be repeated)." (defun vc-git-annotate-command (file buf &optional rev) (let ((name (file-relative-name file))) - (vc-git-command buf 'async name "blame" "--date=iso" "-C" "-C" rev))) + (vc-git-command buf 'async nil "blame" "--date=iso" "-C" "-C" rev "--" name))) (declare-function vc-annotate-convert-time "vc-annotate" (time)) @@ -740,8 +745,12 @@ or BRANCH^ (where \"^\" can be repeated)." (when (looking-at "\\([0-9a-f^][0-9a-f]+\\) \\(\\([^(]+\\) \\)?") (let ((revision (match-string-no-properties 1))) (if (match-beginning 2) - (cons revision (expand-file-name (match-string-no-properties 3) - (vc-git-root default-directory))) + (let ((fname (match-string-no-properties 3))) + ;; Remove trailing whitespace from the file name. + (when (string-match " +\\'" fname) + (setq fname (substring fname 0 (match-beginning 0)))) + (cons revision + (expand-file-name fname (vc-git-root default-directory)))) revision))))) ;;; TAG SYSTEM @@ -765,11 +774,10 @@ or BRANCH^ (where \"^\" can be repeated)." (defun vc-git-previous-revision (file rev) "Git-specific version of `vc-previous-revision'." (if file - (let* ((default-directory (file-name-directory (expand-file-name file))) - (file (file-name-nondirectory file)) + (let* ((fname (file-relative-name file)) (prev-rev (with-temp-buffer (and - (vc-git--out-ok "rev-list" "-2" rev "--" file) + (vc-git--out-ok "rev-list" "-2" rev "--" fname) (goto-char (point-max)) (bolp) (zerop (forward-line -1)) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 23dd6f0f7ae..434c2a10e14 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1700,8 +1700,9 @@ If `F.~REV~' already exists, use it instead of checking it out again." rev))) (switch-to-buffer-other-window (vc-find-revision file revision)))) -(defun vc-find-revision (file revision) - "Read REVISION of FILE into a buffer and return the buffer." +(defun vc-find-revision (file revision &optional backend) + "Read REVISION of FILE into a buffer and return the buffer. +Use BACKEND as the VC backend if specified." (let ((automatic-backup (vc-version-backup-file-name file revision)) (filebuf (or (get-file-buffer file) (current-buffer))) (filename (vc-version-backup-file-name file revision 'manual))) @@ -1719,7 +1720,9 @@ If `F.~REV~' already exists, use it instead of checking it out again." ;; Change buffer to get local value of ;; vc-checkout-switches. (with-current-buffer filebuf - (vc-call find-revision file revision outbuf)))) + (if backend + (vc-call-backend backend 'find-revision file revision outbuf) + (vc-call find-revision file revision outbuf))))) (setq failed nil)) (when (and failed (file-exists-p filename)) (delete-file filename)))) |
