aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThien-Thi Nguyen2008-02-19 11:45:54 +0000
committerThien-Thi Nguyen2008-02-19 11:45:54 +0000
commitb038f9fb955989de99795504c8facfac21e5fbd9 (patch)
tree1d880d8100877acee98b18d5087794edb2176065
parent72c70417d339899b322f59c924e65fccb769d27d (diff)
downloademacs-b038f9fb955989de99795504c8facfac21e5fbd9.tar.gz
emacs-b038f9fb955989de99795504c8facfac21e5fbd9.zip
Make sure all backends support vc-BACKEND-root.
* vc-hooks.el (vc-find-root): Take optional arg INVERT. If non-nil, reverse the sense of the check. * vc-rcs.el (vc-rcs-root): New func. * vc-cvs.el (vc-cvs-root): New func. * vc-svn.el (vc-svn-root): New func.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/vc-cvs.el3
-rw-r--r--lisp/vc-hooks.el26
-rw-r--r--lisp/vc-rcs.el3
-rw-r--r--lisp/vc-svn.el3
5 files changed, 35 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f9b57457095..82f619341bd 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12008-02-19 Thien-Thi Nguyen <ttn@gnuvola.org>
2
3 * vc-hooks.el (vc-find-root): Take optional arg INVERT.
4 If non-nil, reverse the sense of the check.
5 * vc-rcs.el (vc-rcs-root): New func.
6 * vc-cvs.el (vc-cvs-root): New func.
7 * vc-svn.el (vc-svn-root): New func.
8
12008-02-18 Kenichi Handa <handa@ni.aist.go.jp> 92008-02-18 Kenichi Handa <handa@ni.aist.go.jp>
2 10
3 * language/japan-util.el (setup-japanese-environment-internal): 11 * language/japan-util.el (setup-japanese-environment-internal):
diff --git a/lisp/vc-cvs.el b/lisp/vc-cvs.el
index cc4cd47cfe7..717407d2cbd 100644
--- a/lisp/vc-cvs.el
+++ b/lisp/vc-cvs.el
@@ -733,6 +733,9 @@ If UPDATE is non-nil, then update (resynch) any affected buffers."
733;;; Internal functions 733;;; Internal functions
734;;; 734;;;
735 735
736(defun vc-cvs-root (dir)
737 (vc-find-root dir "CVS" t))
738
736(defun vc-cvs-command (buffer okstatus files &rest flags) 739(defun vc-cvs-command (buffer okstatus files &rest flags)
737 "A wrapper around `vc-do-command' for use in vc-cvs.el. 740 "A wrapper around `vc-do-command' for use in vc-cvs.el.
738The difference to vc-do-command is that this function always invokes `cvs', 741The difference to vc-do-command is that this function always invokes `cvs',
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el
index 5c0d839e24d..4f26a2e7e79 100644
--- a/lisp/vc-hooks.el
+++ b/lisp/vc-hooks.el
@@ -325,17 +325,21 @@ non-nil if FILE exists and its contents were successfully inserted."
325 (set-buffer-modified-p nil) 325 (set-buffer-modified-p nil)
326 t)) 326 t))
327 327
328(defun vc-find-root (file witness) 328(defun vc-find-root (file witness &optional invert)
329 "Find the root of a checked out project. 329 "Find the root of a checked out project.
330The function walks up the directory tree from FILE looking for WITNESS. 330The function walks up the directory tree from FILE looking for WITNESS.
331If WITNESS if not found, return nil, otherwise return the root." 331If WITNESS if not found, return nil, otherwise return the root.
332Optional arg INVERT non-nil reverses the sense of the check;
333the root is the last directory for which WITNESS *is* found."
332 ;; Represent /home/luser/foo as ~/foo so that we don't try to look for 334 ;; Represent /home/luser/foo as ~/foo so that we don't try to look for
333 ;; witnesses in /home or in /. 335 ;; witnesses in /home or in /.
334 (while (not (file-directory-p file)) 336 (while (not (file-directory-p file))
335 (setq file (file-name-directory (directory-file-name file)))) 337 (setq file (file-name-directory (directory-file-name file))))
336 (setq file (abbreviate-file-name file)) 338 (setq file (abbreviate-file-name file))
337 (let ((root nil) 339 (let ((root nil)
338 (user (nth 2 (file-attributes file)))) 340 (prev-file file)
341 (user (nth 2 (file-attributes file)))
342 try)
339 (while (not (or root 343 (while (not (or root
340 (null file) 344 (null file)
341 ;; As a heuristic, we stop looking up the hierarchy of 345 ;; As a heuristic, we stop looking up the hierarchy of
@@ -345,11 +349,17 @@ If WITNESS if not found, return nil, otherwise return the root."
345 ;; files inside a project belong to the same user. 349 ;; files inside a project belong to the same user.
346 (not (equal user (nth 2 (file-attributes file)))) 350 (not (equal user (nth 2 (file-attributes file))))
347 (string-match vc-ignore-dir-regexp file))) 351 (string-match vc-ignore-dir-regexp file)))
348 (if (file-exists-p (expand-file-name witness file)) 352 (setq try (file-exists-p (expand-file-name witness file)))
349 (setq root file) 353 (cond ((and invert (not try)) (setq root prev-file))
350 (if (equal file 354 ((and (not invert) try) (setq root file))
351 (setq file (file-name-directory (directory-file-name file)))) 355 ((equal file (setq prev-file file
352 (setq file nil)))) 356 file (file-name-directory
357 (directory-file-name file))))
358 (setq file nil))))
359 ;; Handle the case where ~/WITNESS exists and the original FILE is "~".
360 ;; (This occurs, for example, when placing dotfiles under RCS.)
361 (when (and (not root) invert prev-file)
362 (setq root prev-file))
353 root)) 363 root))
354 364
355;; Access functions to file properties 365;; Access functions to file properties
diff --git a/lisp/vc-rcs.el b/lisp/vc-rcs.el
index 9ba1226301f..0f2551d49a3 100644
--- a/lisp/vc-rcs.el
+++ b/lisp/vc-rcs.el
@@ -792,6 +792,9 @@ systime, or nil if there is none. Also, reposition point."
792;;; Internal functions 792;;; Internal functions
793;;; 793;;;
794 794
795(defun vc-rcs-root (dir)
796 (vc-find-root dir "RCS" t))
797
795(defun vc-rcs-workfile-is-newer (file) 798(defun vc-rcs-workfile-is-newer (file)
796 "Return non-nil if FILE is newer than its RCS master. 799 "Return non-nil if FILE is newer than its RCS master.
797This likely means that FILE has been changed with respect 800This likely means that FILE has been changed with respect
diff --git a/lisp/vc-svn.el b/lisp/vc-svn.el
index 868680375cb..92374be84fa 100644
--- a/lisp/vc-svn.el
+++ b/lisp/vc-svn.el
@@ -532,6 +532,9 @@ NAME is assumed to be a URL."
532 :type 'string 532 :type 'string
533 :group 'vc) 533 :group 'vc)
534 534
535(defun vc-svn-root (dir)
536 (vc-find-root dir vc-svn-admin-directory t))
537
535(defun vc-svn-command (buffer okstatus file-or-list &rest flags) 538(defun vc-svn-command (buffer okstatus file-or-list &rest flags)
536 "A wrapper around `vc-do-command' for use in vc-svn.el. 539 "A wrapper around `vc-do-command' for use in vc-svn.el.
537The difference to vc-do-command is that this function always invokes `svn', 540The difference to vc-do-command is that this function always invokes `svn',