emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 01/02: Revert "More movement of master-related code


From: Eric S. Raymond
Subject: [Emacs-diffs] master 01/02: Revert "More movement of master-related code to vc-filewise.el."
Date: Sat, 22 Nov 2014 11:35:16 +0000

branch: master
commit e9b190263439a1b3c9c41b70cc91d48a215e4be8
Author: Eric S. Raymond <address@hidden>
Date:   Sat Nov 22 06:03:57 2014 -0500

    Revert "More movement of master-related code to vc-filewise.el."
    
    Must unbreak the build.  Which is way too complicated...
---
 lisp/vc/vc-hooks.el |   38 ++++++++++++++++++++++++++++++++++++--
 lisp/vc/vc-rcs.el   |    4 ++--
 lisp/vc/vc-sccs.el  |    4 ++--
 lisp/vc/vc-src.el   |    4 ++--
 4 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index 6f55a14..8ce7ec8 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -627,8 +627,7 @@ If FILE is not registered, this function always returns 
nil."
    "`working-revision' not found: using the old `workfile-version' instead")
   (vc-call-backend backend 'workfile-version file))
 
-;;;autoload
-(defun vc-master-registered (backend file)
+(defun vc-default-registered (backend file)
   "Check if FILE is registered in BACKEND using vc-BACKEND-master-templates."
   (let ((sym (vc-make-backend-sym backend 'master-templates)))
     (unless (get backend 'vc-templates-grabbed)
@@ -638,6 +637,41 @@ If FILE is not registered, this function always returns 
nil."
          (vc-file-setprop file 'vc-master-name result)
        nil))))                         ; Not registered
 
+(defun vc-check-master-templates (file templates)
+  "Return non-nil if there is a master corresponding to FILE.
+
+TEMPLATES is a list of strings or functions.  If an element is a
+string, it must be a control string as required by `format', with two
+string placeholders, such as \"%sRCS/%s,v\".  The directory part of
+FILE is substituted for the first placeholder, the basename of FILE
+for the second.  If a file with the resulting name exists, it is taken
+as the master of FILE, and returned.
+
+If an element of TEMPLATES is a function, it is called with the
+directory part and the basename of FILE as arguments.  It should
+return non-nil if it finds a master; that value is then returned by
+this function."
+  (let ((dirname (or (file-name-directory file) ""))
+        (basename (file-name-nondirectory file)))
+    (catch 'found
+      (mapcar
+       (lambda (s)
+        (let ((trial (vc-possible-master s dirname basename)))
+          (when (and trial (file-exists-p trial)
+                     ;; Make sure the file we found with name
+                     ;; TRIAL is not the source file itself.
+                     ;; That can happen with RCS-style names if
+                     ;; the file name is truncated (e.g. to 14
+                     ;; chars).  See if either directory or
+                     ;; attributes differ.
+                     (or (not (string= dirname
+                                       (file-name-directory trial)))
+                         (not (equal (file-attributes file)
+                                     (file-attributes trial)))))
+              (throw 'found trial))))
+       templates))))
+
+
 ;; toggle-read-only is obsolete since 24.3, but since vc-t-r-o was made
 ;; obsolete earlier, it is ok for the latter to be an alias to the former,
 ;; since the latter will be removed first.  We can't just make it
diff --git a/lisp/vc/vc-rcs.el b/lisp/vc/vc-rcs.el
index 9901991..0b839a6 100644
--- a/lisp/vc/vc-rcs.el
+++ b/lisp/vc/vc-rcs.el
@@ -90,7 +90,7 @@ to use --brief and sets this variable to remember whether it 
worked."
   :group 'vc-rcs)
 
 ;; This needs to be autoloaded because vc-rcs-registered uses it (via
-;; vc-master-registered), and vc-hooks needs to be able to check
+;; vc-default-registered), and vc-hooks needs to be able to check
 ;; for a registered backend without loading every backend.
 ;;;###autoload
 (defcustom vc-rcs-master-templates
@@ -131,7 +131,7 @@ For a description of possible values, see 
`vc-check-master-templates'."
 ;; every file that is visited.
 ;;;###autoload
 (progn
-(defun vc-rcs-registered (f) (vc-master-registered 'RCS f)))
+(defun vc-rcs-registered (f) (vc-default-registered 'RCS f)))
 
 (defun vc-rcs-state (file)
   "Implementation of `vc-state' for RCS."
diff --git a/lisp/vc/vc-sccs.el b/lisp/vc/vc-sccs.el
index fc9c072..780efc4 100644
--- a/lisp/vc/vc-sccs.el
+++ b/lisp/vc/vc-sccs.el
@@ -75,7 +75,7 @@ If nil, use the value of `vc-diff-switches'.  If t, use no 
switches."
   :group 'vc-sccs)
 
 ;; This needs to be autoloaded because vc-sccs-registered uses it (via
-;; vc-master-registered), and vc-hooks needs to be able to check
+;; vc-default-registered), and vc-hooks needs to be able to check
 ;; for a registered backend without loading every backend.
 ;;;###autoload
 (defcustom vc-sccs-master-templates
@@ -112,7 +112,7 @@ For a description of possible values, see 
`vc-check-master-templates'."
 ;; every file that is visited.
 ;;;###autoload
 (progn
-(defun vc-sccs-registered (f) (vc-master-registered 'SCCS f)))
+(defun vc-sccs-registered (f) (vc-default-registered 'SCCS f)))
 
 (defun vc-sccs-state (file)
   "SCCS-specific function to compute the version control state."
diff --git a/lisp/vc/vc-src.el b/lisp/vc/vc-src.el
index 56af2a5..520708c 100644
--- a/lisp/vc/vc-src.el
+++ b/lisp/vc/vc-src.el
@@ -123,7 +123,7 @@ If nil, use the value of `vc-diff-switches'.  If t, use no 
switches."
   :group 'vc-src)
 
 ;; This needs to be autoloaded because vc-src-registered uses it (via
-;; vc-master-registered), and vc-hooks needs to be able to check
+;; vc-default-registered), and vc-hooks needs to be able to check
 ;; for a registered backend without loading every backend.
 ;;;###autoload
 (defcustom vc-src-master-templates
@@ -153,7 +153,7 @@ For a description of possible values, see 
`vc-check-master-templates'."
 ;; every file that is visited.
 ;;;###autoload
 (progn
-(defun vc-src-registered (f) (vc-master-registered 'src f)))
+(defun vc-src-registered (f) (vc-default-registered 'src f)))
 
 (defun vc-src-state (file)
   "SRC-specific version of `vc-state'."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]