Patchwork D9063: merge: use merge.clean_update() when applicable

login
register
mail settings
Submitter phabricator
Date Sept. 21, 2020, 8:39 p.m.
Message ID <differential-rev-PHID-DREV-7psgxmrqwrgtqzctewj6-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47240/
State Superseded
Headers show

Comments

phabricator - Sept. 21, 2020, 8:39 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We have had this higher-level function (higher than `merge.update()`,
  that is) for a while. Let's simply some callers by using it. I don't
  know why I didn't do this when I introduced the function.
  
  After this patch, there are no remaining callers that pass
  `hg.updaterepo()` with `overwrite=True`. We'll clean that up soon.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9063

AFFECTED FILES
  hgext/rebase.py
  hgext/transplant.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/hg.py
  mercurial/subrepo.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -25,6 +25,7 @@ 
     exchange,
     logcmdutil,
     match as matchmod,
+    merge as merge,
     node,
     pathutil,
     phases,
@@ -783,7 +784,10 @@ 
                     % (revision[0:12], self._path)
                 )
                 repo = urepo
-        hg.updaterepo(repo, revision, overwrite)
+        if overwrite:
+            merge.clean_update(repo[revision])
+        else:
+            hg.updaterepo(repo, revision, False)
 
     @annotatesubrepoerror
     def merge(self, state):
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -1074,7 +1074,7 @@ 
 
 def clean(repo, node, show_stats=True, quietempty=False):
     """forcibly switch the working directory to node, clobbering changes"""
-    stats = updaterepo(repo, node, True)
+    stats = mergemod.clean_update(repo[node])
     assert stats.unresolvedcount == 0
     if show_stats:
         _showstats(repo, stats, quietempty)
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3253,7 +3253,7 @@ 
     if not graftstate.exists():
         raise error.Abort(_(b"no interrupted graft found"))
     pctx = repo[b'.']
-    hg.updaterepo(repo, pctx.node(), overwrite=True)
+    mergemod.clean_update(pctx)
     graftstate.delete()
     ui.status(_(b"stopped the interrupted graft\n"))
     ui.status(_(b"working directory is now at %s\n") % pctx.hex()[:12])
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -4183,7 +4183,7 @@ 
 
         if cleanup:
             with repo.wlock(), repo.lock():
-                hg.updaterepo(repo, startctx.node(), overwrite=True)
+                mergemod.clean_update(startctx)
                 # stripping the new nodes created
                 strippoints = [
                     c.node() for c in repo.set(b"roots(%ld)", newnodes)
@@ -4193,7 +4193,7 @@ 
     if not cleanup:
         # we don't update to the startnode if we can't strip
         startctx = repo[b'.']
-        hg.updaterepo(repo, startctx.node(), overwrite=True)
+        mergemod.clean_update(startctx)
 
     ui.status(_(b"graft aborted\n"))
     ui.status(_(b"working directory is now at %s\n") % startctx.hex()[:12])
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -476,7 +476,7 @@ 
         """logic to stop an interrupted transplant"""
         if self.canresume():
             startctx = repo[b'.']
-            hg.updaterepo(repo, startctx.node(), overwrite=True)
+            merge.clean_update(startctx)
             ui.status(_(b"stopped the interrupted transplant\n"))
             ui.status(
                 _(b"working directory is now at %s\n") % startctx.hex()[:12]
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1071,7 +1071,7 @@ 
                 )
             # update to the current working revision
             # to clear interrupted merge
-            hg.updaterepo(repo, rbsrt.originalwd, overwrite=True)
+            mergemod.clean_update(repo[rbsrt.originalwd])
             rbsrt._finishrebase()
             return 0
     elif inmemory: