Patchwork D9067: merge: delete hg.updaterepo() and use merge.update() instead (API)

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

Comments

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/histedit.py
  hgext/rebase.py
  hgext/sparse.py
  mercurial/hg.py
  mercurial/shelve.py
  mercurial/subrepo.py
  relnotes/next

CHANGE DETAILS




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

Patch

diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -24,3 +24,6 @@ 
    the higher-level functions available in the same module cover your
    use cases.
 
+ * `hg.updaterepo()` has been deleted. Use `merge.update()` or
+   `merge.clean_update()` instead.
+
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -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):
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -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
 
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -1043,25 +1043,9 @@ 
     )
 
 
-def updaterepo(repo, node, overwrite, updatecheck=None):
-    """Update the working directory to node.
-
-    When overwrite is set, changes are clobbered, merged else
-
-    returns stats (see pydoc mercurial.merge.applyupdates)"""
-    return mergemod._update(
-        repo,
-        node,
-        branchmerge=False,
-        force=overwrite,
-        labels=[b'working copy', b'destination'],
-        updatecheck=updatecheck,
-    )
-
-
 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"))
diff --git a/hgext/sparse.py b/hgext/sparse.py
--- a/hgext/sparse.py
+++ b/hgext/sparse.py
@@ -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)
 
 
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -728,7 +728,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:
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -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: