1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-28 07:45:00 +00:00

Address an edge case in vc-diff. This is an experimental fix and may change.

This commit is contained in:
Eric S. Raymond 2007-10-11 15:13:29 +00:00
parent 7c8d4ebbc0
commit 727c4443eb
2 changed files with 34 additions and 14 deletions

View File

@ -6,6 +6,9 @@
2007-10-11 Eric S. Raymond <esr@snark.thyrsus.com> 2007-10-11 Eric S. Raymond <esr@snark.thyrsus.com>
* vc.el: Address an edge case in vc-diff pointed out by
Juanma Barranquero. This is an experimental fix and may change.
* vc-hooks.el (vc-registered): Robustify this function a bit * vc-hooks.el (vc-registered): Robustify this function a bit
against filenames with no directory component. against filenames with no directory component.

View File

@ -1985,24 +1985,41 @@ returns t if the buffer had changes, nil otherwise."
(error "Not a valid revision range.")) (error "Not a valid revision range."))
(vc-diff-internal backend t files rev1 rev2 (interactive-p))) (vc-diff-internal backend t files rev1 rev2 (interactive-p)))
(defun vc-contains-version-controlled-file (dir)
"Return t if DIR contains a version-controlled file, nil otherwise."
(catch 'found
(mapc (lambda (f) (and (not (file-directory-p f)) (vc-backend f) (throw 'found 't))) (directory-files dir))
nil))
;;;###autoload ;;;###autoload
(defun vc-diff (historic) (defun vc-diff (historic)
"Display diffs between file revisions. "Display diffs between file revisions.
Normally this compares the current file and buffer with the most Normally this compares the currently selected fileset with their
recent checked in revision of that file. This uses no arguments. With working revisions. With a prefix argument HISTORIC, it reads two revision
a prefix argument HISTORIC, it reads the file name to use and two designators specifying which revisions to compare.
revision designators specifying which revisions to compare."
If no current fileset is available (that is, we are not in
VC-Dired mode and the visited file of the current buffer is not
under version control) behave specially; if there are
version-controlled files in the current directory, treat all
version-controlled files recursively beneath the current
directory as the selected fileset.
"
(interactive "P") (interactive "P")
(if historic (cond ((not (vc-contains-version-controlled-file default-directory))
(call-interactively 'vc-history-diff) (error "No version-controlled files directly beneath default directory"))
(let* ((files (vc-deduce-fileset t)) (historic
(first (car files)) (call-interactively 'vc-history-diff))
(backend (t
(cond ((file-directory-p first) (let* ((files (vc-deduce-fileset t))
(vc-responsible-backend first)) (first (car files))
(t (backend
(vc-backend first))))) (cond ((file-directory-p first)
(vc-diff-internal backend t files nil nil (interactive-p))))) (vc-responsible-backend first))
(t
(vc-backend first)))))
(vc-diff-internal backend t files nil nil (interactive-p))))))
;;;###autoload ;;;###autoload
(defun vc-revision-other-window (rev) (defun vc-revision-other-window (rev)