Mercurial > emacs
comparison 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 |
comparison
equal
deleted
inserted
replaced
99129:477b24ba46d7 | 99130:e152a404d947 |
---|---|
50 (defvar vc-header-alist ()) | 50 (defvar vc-header-alist ()) |
51 (make-obsolete-variable 'vc-header-alist 'vc-BACKEND-header "21.1") | 51 (make-obsolete-variable 'vc-header-alist 'vc-BACKEND-header "21.1") |
52 | 52 |
53 (defcustom vc-ignore-dir-regexp | 53 (defcustom vc-ignore-dir-regexp |
54 ;; Stop SMB, automounter, AFS, and DFS host lookups. | 54 ;; Stop SMB, automounter, AFS, and DFS host lookups. |
55 "\\`\\(?:[\\/][\\/]\\|/\\(?:net\\|afs\\|\\.\\\.\\.\\)/\\)\\'" | 55 locate-dominating-stop-dir-regexp |
56 "Regexp matching directory names that are not under VC's control. | 56 "Regexp matching directory names that are not under VC's control. |
57 The default regexp prevents fruitless and time-consuming attempts | 57 The default regexp prevents fruitless and time-consuming attempts |
58 to determine the VC status in directories in which filenames are | 58 to determine the VC status in directories in which filenames are |
59 interpreted as hostnames." | 59 interpreted as hostnames." |
60 :type 'regexp | 60 :type 'regexp |
329 | 329 |
330 (defun vc-find-root (file witness) | 330 (defun vc-find-root (file witness) |
331 "Find the root of a checked out project. | 331 "Find the root of a checked out project. |
332 The function walks up the directory tree from FILE looking for WITNESS. | 332 The function walks up the directory tree from FILE looking for WITNESS. |
333 If WITNESS if not found, return nil, otherwise return the root." | 333 If WITNESS if not found, return nil, otherwise return the root." |
334 ;; Represent /home/luser/foo as ~/foo so that we don't try to look for | 334 (let ((locate-dominating-stop-dir-regexp |
335 ;; witnesses in /home or in /. | 335 (or vc-ignore-dir-regexp locate-dominating-stop-dir-regexp))) |
336 (setq file (abbreviate-file-name file)) | 336 (locate-dominating-file file witness))) |
337 (let ((root nil) | 337 |
338 (prev-file file) | 338 (define-obsolete-function-alias 'vc-find-root 'locate-dominating-file "23.1") |
339 ;; `user' is not initialized outside the loop because | |
340 ;; `file' may not exist, so we may have to walk up part of the | |
341 ;; hierarchy before we find the "initial UID". | |
342 (user nil) | |
343 try) | |
344 (while (not (or root | |
345 (null file) | |
346 ;; As a heuristic, we stop looking up the hierarchy of | |
347 ;; directories as soon as we find a directory belonging | |
348 ;; to another user. This should save us from looking in | |
349 ;; things like /net and /afs. This assumes that all the | |
350 ;; files inside a project belong to the same user. | |
351 (let ((prev-user user)) | |
352 (setq user (nth 2 (file-attributes file))) | |
353 (and prev-user (not (equal user prev-user)))) | |
354 (string-match vc-ignore-dir-regexp file))) | |
355 (setq try (file-exists-p (expand-file-name witness file))) | |
356 (cond (try (setq root file)) | |
357 ((equal file (setq prev-file file | |
358 file (file-name-directory | |
359 (directory-file-name file)))) | |
360 (setq file nil)))) | |
361 root)) | |
362 | 339 |
363 ;; Access functions to file properties | 340 ;; Access functions to file properties |
364 ;; (Properties should be _set_ using vc-file-setprop, but | 341 ;; (Properties should be _set_ using vc-file-setprop, but |
365 ;; _retrieved_ only through these functions, which decide | 342 ;; _retrieved_ only through these functions, which decide |
366 ;; if the property is already known or not. A property should | 343 ;; if the property is already known or not. A property should |
376 on the result of a previous call, use `vc-backend' instead. If the | 353 on the result of a previous call, use `vc-backend' instead. If the |
377 file was previously registered under a certain backend, then that | 354 file was previously registered under a certain backend, then that |
378 backend is tried first." | 355 backend is tried first." |
379 (let (handler) | 356 (let (handler) |
380 (cond | 357 (cond |
381 ((and (file-name-directory file) (string-match vc-ignore-dir-regexp (file-name-directory file))) | 358 ((and (file-name-directory file) |
359 (string-match vc-ignore-dir-regexp (file-name-directory file))) | |
382 nil) | 360 nil) |
383 ((and (boundp 'file-name-handler-alist) | 361 ((and (boundp 'file-name-handler-alist) |
384 (setq handler (find-file-name-handler file 'vc-registered))) | 362 (setq handler (find-file-name-handler file 'vc-registered))) |
385 ;; handler should set vc-backend and return t if registered | 363 ;; handler should set vc-backend and return t if registered |
386 (funcall handler 'vc-registered file)) | 364 (funcall handler 'vc-registered file)) |