merge: replace calls to hg.updaterepo() by merge.update()
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 21 Sep 2020 11:53:44 -0700
changeset 45577 5c8230ca37f2
parent 45576 c1b603cdc95a
child 45578 f9a3edf2dee4
merge: replace calls to hg.updaterepo() by merge.update() The former no longer buys us anything. Differential Revision: https://phab.mercurial-scm.org/D9067
hgext/histedit.py
hgext/rebase.py
hgext/sparse.py
mercurial/hg.py
mercurial/shelve.py
mercurial/subrepo.py
--- a/hgext/histedit.py	Mon Sep 21 09:57:29 2020 -0700
+++ b/hgext/histedit.py	Mon Sep 21 11:53:44 2020 -0700
@@ -881,8 +881,7 @@
         return False
 
     def finishfold(self, ui, repo, ctx, oldctx, newnode, internalchanges):
-        parent = ctx.p1().node()
-        hg.updaterepo(repo, parent, overwrite=False)
+        mergemod.update(ctx.p1())
         ### prepare new commit data
         commitopts = {}
         commitopts[b'user'] = ctx.user()
@@ -926,7 +925,7 @@
             )
         if n is None:
             return ctx, []
-        hg.updaterepo(repo, n, overwrite=False)
+        mergemod.update(repo[n])
         replacements = [
             (oldctx.node(), (newnode,)),
             (ctx.node(), (n,)),
@@ -2050,7 +2049,7 @@
 
 def _finishhistedit(ui, repo, state, fm):
     """This action runs when histedit is finishing its session"""
-    hg.updaterepo(repo, state.parentctxnode, overwrite=False)
+    mergemod.update(repo[state.parentctxnode])
 
     mapping, tmpnodes, created, ntm = processreplacement(state)
     if mapping:
--- a/hgext/rebase.py	Mon Sep 21 09:57:29 2020 -0700
+++ b/hgext/rebase.py	Mon Sep 21 11:53:44 2020 -0700
@@ -34,7 +34,6 @@
     dirstateguard,
     error,
     extensions,
-    hg,
     merge as mergemod,
     mergestate as mergestatemod,
     mergeutil,
@@ -750,7 +749,7 @@
             newwd = self.originalwd
         if newwd not in [c.rev() for c in repo[None].parents()]:
             ui.note(_(b"update back to initial working directory parent\n"))
-            hg.updaterepo(repo, newwd, overwrite=False)
+            mergemod.update(repo[newwd])
 
         collapsedas = None
         if self.collapsef and not self.keepf:
--- a/hgext/sparse.py	Mon Sep 21 09:57:29 2020 -0700
+++ b/hgext/sparse.py	Mon Sep 21 11:53:44 2020 -0700
@@ -80,9 +80,9 @@
     dirstate,
     error,
     extensions,
-    hg,
     logcmdutil,
     match as matchmod,
+    merge as mergemod,
     pycompat,
     registrar,
     sparse,
@@ -173,9 +173,9 @@
     # clone
     if not narrow_pat and (include or exclude or enableprofile):
 
-        def clonesparse(orig, self, node, overwrite, *args, **kwargs):
+        def clonesparse(orig, ctx, *args, **kwargs):
             sparse.updateconfig(
-                self.unfiltered(),
+                ctx.repo().unfiltered(),
                 pat,
                 {},
                 include=include,
@@ -183,9 +183,9 @@
                 enableprofile=enableprofile,
                 usereporootpaths=True,
             )
-            return orig(self, node, overwrite, *args, **kwargs)
+            return orig(ctx, *args, **kwargs)
 
-        extensions.wrapfunction(hg, b'updaterepo', clonesparse)
+        extensions.wrapfunction(mergemod, b'update', clonesparse)
     return orig(ui, repo, *args, **opts)
 
 
--- a/mercurial/hg.py	Mon Sep 21 09:57:29 2020 -0700
+++ b/mercurial/hg.py	Mon Sep 21 11:53:44 2020 -0700
@@ -1061,7 +1061,7 @@
 
 def update(repo, node, quietempty=False, updatecheck=None):
     """update the working directory to node"""
-    stats = updaterepo(repo, node, False, updatecheck=updatecheck)
+    stats = mergemod.update(repo[node], updatecheck=updatecheck)
     _showstats(repo, stats, quietempty)
     if stats.unresolvedcount:
         repo.ui.status(_(b"use 'hg resolve' to retry unresolved file merges\n"))
--- a/mercurial/shelve.py	Mon Sep 21 09:57:29 2020 -0700
+++ b/mercurial/shelve.py	Mon Sep 21 11:53:44 2020 -0700
@@ -839,7 +839,7 @@
             state.nodestoremove.append(newnode)
             shelvectx = repo[newnode]
 
-        hg.updaterepo(repo, pendingctx.node(), overwrite=False)
+        merge.update(pendingctx)
         mergefiles(ui, repo, state.wctx, shelvectx)
         restorebranch(ui, repo, state.branchtorestore)
 
@@ -1031,7 +1031,7 @@
             ui.status(msg)
         else:
             shelvectx = repo[newnode]
-            hg.updaterepo(repo, tmpwctx.node(), False)
+            merge.update(tmpwctx)
 
     return shelvectx, ispartialunshelve
 
--- a/mercurial/subrepo.py	Mon Sep 21 09:57:29 2020 -0700
+++ b/mercurial/subrepo.py	Mon Sep 21 11:53:44 2020 -0700
@@ -787,7 +787,7 @@
         if overwrite:
             merge.clean_update(repo[revision])
         else:
-            hg.updaterepo(repo, revision, False)
+            merge.update(repo[revision])
 
     @annotatesubrepoerror
     def merge(self, state):