diff lisp/vc-hooks.el @ 99130:e152a404d947

* files.el (locate-dominating-stop-dir-regexp): New var. (locate-dominating-file): Change arg from a regexp to a file name. Rewrite using the vc-find-root code to avoid directory-files which is too slow. Obey locate-dominating-stop-dir-regexp. Don't pay attention to changes in owner. (project-find-settings-file): Adjust call to locate-dominating-file. * progmodes/flymake.el (flymake-find-buildfile): Adjust call to locate-dominating-file. * vc-hooks.el (vc-find-root): Use locate-dominating-file. (vc-ignore-dir-regexp): Use locate-dominating-stop-dir-regexp.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sat, 25 Oct 2008 15:18:53 +0000
parents 2cae4bd13e67
children c0bf1f652024
line wrap: on
line diff
--- a/lisp/vc-hooks.el	Sat Oct 25 10:09:42 2008 +0000
+++ b/lisp/vc-hooks.el	Sat Oct 25 15:18:53 2008 +0000
@@ -52,7 +52,7 @@
 
 (defcustom vc-ignore-dir-regexp
   ;; Stop SMB, automounter, AFS, and DFS host lookups.
-  "\\`\\(?:[\\/][\\/]\\|/\\(?:net\\|afs\\|\\.\\\.\\.\\)/\\)\\'"
+  locate-dominating-stop-dir-regexp
   "Regexp matching directory names that are not under VC's control.
 The default regexp prevents fruitless and time-consuming attempts
 to determine the VC status in directories in which filenames are
@@ -331,34 +331,11 @@
   "Find the root of a checked out project.
 The function walks up the directory tree from FILE looking for WITNESS.
 If WITNESS if not found, return nil, otherwise return the root."
-  ;; Represent /home/luser/foo as ~/foo so that we don't try to look for
-  ;; witnesses in /home or in /.
-  (setq file (abbreviate-file-name file))
-  (let ((root nil)
-        (prev-file file)
-        ;; `user' is not initialized outside the loop because
-        ;; `file' may not exist, so we may have to walk up part of the
-        ;; hierarchy before we find the "initial UID".
-        (user nil)
-        try)
-    (while (not (or root
-                    (null file)
-                    ;; As a heuristic, we stop looking up the hierarchy of
-                    ;; directories as soon as we find a directory belonging
-                    ;; to another user.  This should save us from looking in
-                    ;; things like /net and /afs.  This assumes that all the
-                    ;; files inside a project belong to the same user.
-                    (let ((prev-user user))
-                      (setq user (nth 2 (file-attributes file)))
-                      (and prev-user (not (equal user prev-user))))
-                    (string-match vc-ignore-dir-regexp file)))
-      (setq try (file-exists-p (expand-file-name witness file)))
-      (cond (try (setq root file))
-            ((equal file (setq prev-file file
-                               file (file-name-directory
-                                     (directory-file-name file))))
-             (setq file nil))))
-    root))
+  (let ((locate-dominating-stop-dir-regexp
+         (or vc-ignore-dir-regexp locate-dominating-stop-dir-regexp)))
+    (locate-dominating-file file witness)))
+    
+(define-obsolete-function-alias 'vc-find-root 'locate-dominating-file "23.1")
 
 ;; Access functions to file properties
 ;; (Properties should be _set_ using vc-file-setprop, but
@@ -378,7 +355,8 @@
 backend is tried first."
   (let (handler)
     (cond
-     ((and (file-name-directory file) (string-match vc-ignore-dir-regexp (file-name-directory file)))
+     ((and (file-name-directory file)
+           (string-match vc-ignore-dir-regexp (file-name-directory file)))
       nil)
      ((and (boundp 'file-name-handler-alist)
           (setq handler (find-file-name-handler file 'vc-registered)))