emacs-diffs
[Top][All Lists]
Advanced

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

master cfd4d45: Make 'C-x v v' on an unregistered file use the most spec


From: Lars Ingebrigtsen
Subject: master cfd4d45: Make 'C-x v v' on an unregistered file use the most specific backend
Date: Fri, 5 Nov 2021 20:13:59 -0400 (EDT)

branch: master
commit cfd4d45f1164fb86bdad306ed0d532150a88f7e7
Author: Manuel Giraud <manuel@ledu-giraud.fr>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Make 'C-x v v' on an unregistered file use the most specific backend
    
    * lisp/vc/vc.el (vc-next-action): Mention this.
    
    * lisp/vc/vc.el (vc-backend-for-registration): Choose the most
    specific backend (bug#50572).
---
 etc/NEWS      | 12 +++++++++++-
 lisp/vc/vc.el | 23 +++++++++++++++++------
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 9b4112a..78c8481 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -167,6 +167,16 @@ change the terminal used on a remote host.
 
 * Changes in Specialized Modes and Packages in Emacs 29.1
 
+** vc
+
+---
+*** 'C-x v v' on an unregistered file will now use the most specific backend.
+Previously, if you had an SVN-covered ~/ directory, and a Git-covered
+directory in ~/foo/bar, using 'C-x v v' on a new, unregistered file
+~/foo/bar/zot would register it in the SVN repository in ~/ instead of
+in the Git repository in ~/foo/bar.  This makes this command
+consistent with 'vc-responsible-backend'.
+
 ** Message
 
 ---
@@ -432,7 +442,7 @@ long lists and vectors.
 'pp' formats general Lisp sexps.  This function does much the same,
 but applies formatting rules appropriate for Emacs Lisp code.
 
-+++
++++,
 *** New function 'file-has-changed-p'.
 This convenience function is useful when writing code that parses
 files at run-time, and allows Lisp programs to re-parse files only
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index df8990c..c9500f4 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -937,11 +937,18 @@ repository, prompting for the directory and the VC 
backend to
 use."
   (catch 'found
     ;; First try: find a responsible backend, it must be a backend
-    ;; under which FILE is not yet registered.
-    (dolist (backend vc-handled-backends)
-      (and (not (vc-call-backend backend 'registered file))
-          (vc-call-backend backend 'responsible-p file)
-          (throw 'found backend)))
+    ;; under which FILE is not yet registered and with the most
+    ;; specific path to FILE.
+    (let ((max 0)
+          bk)
+      (dolist (backend vc-handled-backends)
+        (when (not (vc-call-backend backend 'registered file))
+          (let* ((path (vc-call-backend backend 'responsible-p file))
+                 (len (length path)))
+            (when (and len (> len max))
+              (setq max len bk backend)))))
+      (when bk
+        (throw 'found bk)))
     ;; no responsible backend
     (let* ((possible-backends
            (let (pos)
@@ -1188,7 +1195,11 @@ For old-style locking-based version control systems, 
like RCS:
    *vc-log* buffer to check in the changes.  Leave a
    read-only copy of each changed file after checking in.
   If every file is locked by you and unchanged, unlock them.
-  If every file is locked by someone else, offer to steal the lock."
+  If every file is locked by someone else, offer to steal the lock.
+
+When using this command to register a new file (or files), it
+will automatically deduce which VC repository to register it
+with, using the most specific one."
   (interactive "P")
   (let* ((vc-fileset (vc-deduce-fileset nil t 'state-model-only-files))
          (backend (car vc-fileset))



reply via email to

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