]> git.eshelyaron.com Git - emacs.git/commitdiff
VC: Make incoming-revision backend function responsible for fetching
authorSean Whitton <spwhitton@spwhitton.name>
Thu, 3 Jul 2025 19:09:14 +0000 (20:09 +0100)
committerEshel Yaron <me@eshelyaron.com>
Wed, 23 Jul 2025 20:13:37 +0000 (22:13 +0200)
* lisp/vc/vc-hg.el (vc-hg-incoming-revision): Pull the incoming
revision if we don't have it.
(vc-hg-mergebase): Don't invoke 'hg pull'.
* lisp/vc/vc.el: Document that the incoming-revision backend
function, for distributed VCS, should fetch the incoming
revision into local storage.

(cherry picked from commit 37a9a9495e795f225b1736c56e37c3965de6c58c)

lisp/vc/vc-hg.el
lisp/vc/vc.el

index 1494fef67cb74d792373e027a8b8e0cb3e18d15d..d7f25fe6a391c46638b2ae7255928996c740f175 100644 (file)
@@ -1495,33 +1495,26 @@ This runs the command \"hg summary\"."
        "\n"))))
 
 (defun vc-hg-incoming-revision (remote-location)
-  ;; Use 'hg identify' like this, and not 'hg incoming', because this
-  ;; will give a sensible answer regardless of whether the incoming
-  ;; revision has been pulled yet.
-  (with-output-to-string
-    (vc-hg-command standard-output 0 nil "identify" "--id"
-                   (if (string-empty-p remote-location)
-                       "default"
-                     remote-location)
-                   "--template={node}")))
+  (let* ((remote-location (if (string-empty-p remote-location)
+                              "default"
+                            remote-location))
+         ;; Use 'hg identify' like this, and not 'hg incoming', because
+         ;; this will give a sensible answer regardless of whether the
+         ;; incoming revision has been pulled yet.
+         (rev (with-output-to-string
+                (vc-hg-command standard-output 0 nil "identify" "--id"
+                               remote-location "--template={node}"))))
+    (condition-case _ (vc-hg-command nil 0 nil "log" "-r" rev)
+      ;; We don't have the revision locally.  Pull it.
+      (error (vc-hg-command nil 0 nil "pull" remote-location)))
+    rev))
 
 (defun vc-hg-mergebase (rev1 &optional rev2)
-  (cl-flet
-      ((go ()
-         (with-output-to-string
-           (vc-hg-command standard-output 0 nil "log"
-                          (format "--rev=last(ancestors(%s) and ancestors(%s))"
-                                  rev1 (or rev2 "."))
-                          "--limit=1" "--template={node}"))))
-    ;; If the first attempt fails it may be because REV1 or REV2 has not
-    ;; yet been pulled, such as the case where REV1 is the incoming
-    ;; revision.  Unconditionally pull and try again because we can't
-    ;; distinguish a failure due to REV1 or REV2 having not yet been
-    ;; pulled from one where REV1 or REV2 don't exist at all.
-    (condition-case _ (go)
-      (error (vc-hg-command nil 0 nil "pull")
-             (condition-case _ (go)
-               (error (error "No common ancestor for merge base")))))))
+  (with-output-to-string
+    (vc-hg-command standard-output 0 nil "log"
+                   (format "--rev=last(ancestors(%s) and ancestors(%s))"
+                           rev1 (or rev2 "."))
+                   "--limit=1" "--template={node}")))
 
 (defvar vc-hg-error-regexp-alist
   '(("^M \\(.+\\)" 1 nil nil 0))
index 868f8e5d775cf107803656e15f0656481e087aba..d6c45b6f2150a74a5c5d11047efa25bd1cd2e788 100644 (file)
 ;;   Return revision at the head of the branch at REMOTE-LOCATION.
 ;;   If there is no such branch there, return nil.  (Should signal an
 ;;   error, not return nil, in the case that fetching data fails.)
+;;   For a distributed VCS, should also fetch that revision into local
+;;   storage for operating on by subsequent calls into the backend.
 ;;
 ;; - log-search (buffer pattern)
 ;;