1 |
;;; vc-hooks.el --- resident support for version-control |
;;; vc-hooks.el --- resident support for version-control |
2 |
|
|
3 |
;; Copyright (C) 1992,93,94,95,96,98,99,2000,03,2004 |
;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2003, 2004 |
4 |
;; Free Software Foundation, Inc. |
;; Free Software Foundation, Inc. |
5 |
|
|
6 |
;; Author: FSF (see vc.el for full credits) |
;; Author: FSF (see vc.el for full credits) |
52 |
(defvar vc-header-alist ()) |
(defvar vc-header-alist ()) |
53 |
(make-obsolete-variable 'vc-header-alist 'vc-BACKEND-header) |
(make-obsolete-variable 'vc-header-alist 'vc-BACKEND-header) |
54 |
|
|
55 |
|
(defvar vc-ignore-dir-regexp "\\`\\([\\/][\\/]\\|/net/\\|/afs/\\)\\'" |
56 |
|
"Regexp matching directory names that are not under VC's control. |
57 |
|
The default regexp prevents fruitless and time-consuming attempts |
58 |
|
to determine the VC status in directories in which filenames are |
59 |
|
interpreted as hostnames.") |
60 |
|
|
61 |
(defcustom vc-handled-backends '(RCS CVS SVN SCCS Arch MCVS) |
(defcustom vc-handled-backends '(RCS CVS SVN SCCS Arch MCVS) |
62 |
;; Arch and MCVS come last because they are per-tree rather than per-dir. |
;; Arch and MCVS come last because they are per-tree rather than per-dir. |
63 |
"*List of version control backends for which VC will be used. |
"*List of version control backends for which VC will be used. |
304 |
(set-buffer-modified-p nil) |
(set-buffer-modified-p nil) |
305 |
t)) |
t)) |
306 |
|
|
307 |
|
(defun vc-find-root (file witness) |
308 |
|
"Find the root of a checked out project. |
309 |
|
The function walks up the directory tree from FILE looking for WITNESS. |
310 |
|
If WITNESS if not found, return nil, otherwise return the root." |
311 |
|
(let ((root nil)) |
312 |
|
(while (not (or root |
313 |
|
(equal file (setq file (file-name-directory file))) |
314 |
|
(null file) |
315 |
|
(string-match vc-ignore-dir-regexp file))) |
316 |
|
(if (file-exists-p (expand-file-name witness file)) |
317 |
|
(setq root file) |
318 |
|
(setq file (directory-file-name file)))) |
319 |
|
root)) |
320 |
|
|
321 |
;; Access functions to file properties |
;; Access functions to file properties |
322 |
;; (Properties should be _set_ using vc-file-setprop, but |
;; (Properties should be _set_ using vc-file-setprop, but |
323 |
;; _retrieved_ only through these functions, which decide |
;; _retrieved_ only through these functions, which decide |
335 |
file was previously registered under a certain backend, then that |
file was previously registered under a certain backend, then that |
336 |
backend is tried first." |
backend is tried first." |
337 |
(let (handler) |
(let (handler) |
338 |
(if (boundp 'file-name-handler-alist) |
(cond |
339 |
(setq handler (find-file-name-handler file 'vc-registered))) |
((string-match vc-ignore-dir-regexp (file-name-directory file)) nil) |
340 |
(if handler |
((and (boundp 'file-name-handler-alist) |
341 |
;; handler should set vc-backend and return t if registered |
(setq handler (find-file-name-handler file 'vc-registered))) |
342 |
(funcall handler 'vc-registered file) |
;; handler should set vc-backend and return t if registered |
343 |
|
(funcall handler 'vc-registered file)) |
344 |
|
(t |
345 |
;; There is no file name handler. |
;; There is no file name handler. |
346 |
;; Try vc-BACKEND-registered for each handled BACKEND. |
;; Try vc-BACKEND-registered for each handled BACKEND. |
347 |
(catch 'found |
(catch 'found |
356 |
(cons backend vc-handled-backends)))) |
(cons backend vc-handled-backends)))) |
357 |
;; File is not registered. |
;; File is not registered. |
358 |
(vc-file-setprop file 'vc-backend 'none) |
(vc-file-setprop file 'vc-backend 'none) |
359 |
nil)))) |
nil))))) |
360 |
|
|
361 |
(defun vc-backend (file) |
(defun vc-backend (file) |
362 |
"Return the version control type of FILE, nil if it is not registered." |
"Return the version control type of FILE, nil if it is not registered." |
891 |
|
|
892 |
(provide 'vc-hooks) |
(provide 'vc-hooks) |
893 |
|
|
894 |
;;; arch-tag: 2e5a6fa7-1d30-48e2-8bd0-e3d335f04f32 |
;; arch-tag: 2e5a6fa7-1d30-48e2-8bd0-e3d335f04f32 |
895 |
;;; vc-hooks.el ends here |
;;; vc-hooks.el ends here |