[PATCH 5 of 6] hg: add updatetotally skipupdate to examine destination before actual update

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Fri Mar 11 14:41:10 EST 2016


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1457724942 -32400
#      Sat Mar 12 04:35:42 2016 +0900
# Node ID 4ec341fd8f85ca07dc6f99d82c155e9d559be390
# Parent  231ea15298afd3e1a4347791d4eb904742bf8243
hg: add updatetotally skipupdate to examine destination before actual update

This is useful for client, which wants to show any message before
(abortion of) actual updating, for example.

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -698,7 +698,8 @@ def clean(repo, node, show_stats=True, q
 # naming conflict in updatetotally()
 _clean = clean
 
-def updatetotally(ui, repo, checkout, brev, clean=False, check=False):
+def updatetotally(ui, repo, checkout, brev, clean=False, check=False,
+                 skipupdate=None):
     """Update the working directory with extra care for non-file components
 
     This takes care of non-file components below:
@@ -711,6 +712,7 @@ def updatetotally(ui, repo, checkout, br
     :brev: a name, which might be a bookmark to be activated after updating
     :clean: whether changes in the working directory can be discarded
     :check: whether changes in the working directory should be checked
+    :skipupdate: func(destrev), which returns True if skip actual updating
 
     This returns whether conflict is detected at updating or not.
     """
@@ -720,6 +722,8 @@ def updatetotally(ui, repo, checkout, br
         if checkout is None:
             updata = destutil.destupdate(repo, clean=clean, check=check)
             checkout, movemarkfrom, brev = updata
+            if skipupdate and skipupdate(checkout):
+                return False
             warndest = True
 
         if clean:


More information about the Mercurial-devel mailing list