aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2007-07-23 05:38:44 +0000
committerStefan Monnier2007-07-23 05:38:44 +0000
commit4127ed49c36b9df647d5278be28e1307d9b17cc9 (patch)
tree490fe84dd7b9422e63d9a032fc168ea4c430b21d
parent7d56ddc5764b329ff315706e7e2a7eba34e60201 (diff)
downloademacs-4127ed49c36b9df647d5278be28e1307d9b17cc9.tar.gz
emacs-4127ed49c36b9df647d5278be28e1307d9b17cc9.zip
(vc-find-root): Walk up the tree to find an existing
`file' from which to start the search and fix case where `file' is the current directory and the root as well.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/vc-hooks.el25
2 files changed, 18 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2e3f32ad25c..e6a15595af2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
12007-07-23 Stefan Monnier <monnier@iro.umontreal.ca> 12007-07-23 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * vc-hooks.el (vc-find-root): Walk up the tree to find an existing
4 `file' from which to start the search and fix case where `file' is the
5 current directory and the root as well.
6
3 * pcvs.el (cvs-mode-add-change-log-entry-other-window): Use a directory 7 * pcvs.el (cvs-mode-add-change-log-entry-other-window): Use a directory
4 name for buffer-file-name if it refers to a directory. 8 name for buffer-file-name if it refers to a directory.
5 9
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el
index 22935ab7f3b..29c827852fb 100644
--- a/lisp/vc-hooks.el
+++ b/lisp/vc-hooks.el
@@ -314,22 +314,25 @@ The function walks up the directory tree from FILE looking for WITNESS.
314If WITNESS if not found, return nil, otherwise return the root." 314If WITNESS if not found, return nil, otherwise return the root."
315 ;; Represent /home/luser/foo as ~/foo so that we don't try to look for 315 ;; Represent /home/luser/foo as ~/foo so that we don't try to look for
316 ;; witnesses in /home or in /. 316 ;; witnesses in /home or in /.
317 (while (not (file-directory-p file))
318 (setq file (file-name-directory (directory-file-name file))))
317 (setq file (abbreviate-file-name file)) 319 (setq file (abbreviate-file-name file))
318 (let ((root nil) 320 (let ((root nil)
319 (user (nth 2 (file-attributes file)))) 321 (user (nth 2 (file-attributes file))))
320 (while (not (or root 322 (while (not (or root
321 (equal file (setq file (file-name-directory file))) 323 (null file)
322 (null file) 324 ;; As a heuristic, we stop looking up the hierarchy of
323 ;; As a heuristic, we stop looking up the hierarchy of 325 ;; directories as soon as we find a directory belonging
324 ;; directories as soon as we find a directory belonging 326 ;; to another user. This should save us from looking in
325 ;; to another user. This should save us from looking in 327 ;; things like /net and /afs. This assumes that all the
326 ;; things like /net and /afs. This assumes that all the 328 ;; files inside a project belong to the same user.
327 ;; files inside a project belong to the same user. 329 (not (equal user (nth 2 (file-attributes file))))
328 (not (equal user (nth 2 (file-attributes file)))) 330 (string-match vc-ignore-dir-regexp file)))
329 (string-match vc-ignore-dir-regexp file)))
330 (if (file-exists-p (expand-file-name witness file)) 331 (if (file-exists-p (expand-file-name witness file))
331 (setq root file) 332 (setq root file)
332 (setq file (directory-file-name file)))) 333 (if (equal file
334 (setq file (file-name-directory (directory-file-name file))))
335 (setq file nil))))
333 root)) 336 root))
334 337
335;; Access functions to file properties 338;; Access functions to file properties