changeset 45563:2c86b9587740

merge: make low-level update() private (API) We have very few callers left that call the low-level `merge.update()` function. I think it's time to make it private. I'll remove the remaining callers in coming patches, except for one call from the `rebase` module. I hope to eventually fix that too, but it's more complex because it requires teaching `merge.graft()` to work with a dirty working copy. Differential Revision: https://phab.mercurial-scm.org/D9065
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 21 Sep 2020 11:12:58 -0700
parents 03726f5b6092
children 80bf7b1ada15
files hgext/fsmonitor/__init__.py hgext/largefiles/overrides.py hgext/rebase.py hgext/transplant.py mercurial/hg.py mercurial/merge.py relnotes/next
diffstat 7 files changed, 17 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/fsmonitor/__init__.py	Mon Sep 21 10:09:39 2020 -0700
+++ b/hgext/fsmonitor/__init__.py	Mon Sep 21 11:12:58 2020 -0700
@@ -727,7 +727,7 @@
         # An assist for avoiding the dangling-symlink fsevents bug
         extensions.wrapfunction(os, b'symlink', wrapsymlink)
 
-    extensions.wrapfunction(merge, b'update', wrapupdate)
+    extensions.wrapfunction(merge, b'_update', wrapupdate)
 
 
 def wrapsymlink(orig, source, link_name):
--- a/hgext/largefiles/overrides.py	Mon Sep 21 10:09:39 2020 -0700
+++ b/hgext/largefiles/overrides.py	Mon Sep 21 11:12:58 2020 -0700
@@ -1717,7 +1717,7 @@
     return err
 
 
-@eh.wrapfunction(merge, b'update')
+@eh.wrapfunction(merge, b'_update')
 def mergeupdate(orig, repo, node, branchmerge, force, *args, **kwargs):
     matcher = kwargs.get('matcher', None)
     # note if this is a partial update
--- a/hgext/rebase.py	Mon Sep 21 10:09:39 2020 -0700
+++ b/hgext/rebase.py	Mon Sep 21 11:12:58 2020 -0700
@@ -642,7 +642,7 @@
                         cmdutil.bailifchanged(repo)
                         self.inmemory = False
                         self._assignworkingcopy()
-                        mergemod.update(
+                        mergemod._update(
                             repo,
                             p1,
                             branchmerge=False,
@@ -1517,7 +1517,7 @@
 
     # See explanation in merge.graft()
     mergeancestor = repo.changelog.isancestor(p1ctx.node(), ctx.node())
-    stats = mergemod.update(
+    stats = mergemod._update(
         repo,
         rev,
         branchmerge=True,
--- a/hgext/transplant.py	Mon Sep 21 10:09:39 2020 -0700
+++ b/hgext/transplant.py	Mon Sep 21 11:12:58 2020 -0700
@@ -198,7 +198,7 @@
                     if pulls:
                         if source != repo:
                             exchange.pull(repo, source.peer(), heads=pulls)
-                        merge.update(
+                        merge._update(
                             repo, pulls[-1], branchmerge=False, force=False
                         )
                         p1 = repo.dirstate.p1()
@@ -275,7 +275,7 @@
             tr.close()
             if pulls:
                 exchange.pull(repo, source.peer(), heads=pulls)
-                merge.update(repo, pulls[-1], branchmerge=False, force=False)
+                merge._update(repo, pulls[-1], branchmerge=False, force=False)
         finally:
             self.saveseries(revmap, merges)
             self.transplants.write()
--- a/mercurial/hg.py	Mon Sep 21 10:09:39 2020 -0700
+++ b/mercurial/hg.py	Mon Sep 21 11:12:58 2020 -0700
@@ -1049,7 +1049,7 @@
     When overwrite is set, changes are clobbered, merged else
 
     returns stats (see pydoc mercurial.merge.applyupdates)"""
-    return mergemod.update(
+    return mergemod._update(
         repo,
         node,
         branchmerge=False,
--- a/mercurial/merge.py	Mon Sep 21 10:09:39 2020 -0700
+++ b/mercurial/merge.py	Mon Sep 21 11:12:58 2020 -0700
@@ -1694,7 +1694,7 @@
 UPDATECHECK_NO_CONFLICT = b'noconflict'
 
 
-def update(
+def _update(
     repo,
     node,
     branchmerge,
@@ -2045,7 +2045,7 @@
     force = whether the merge was run with 'merge --force' (deprecated)
     """
 
-    return update(
+    return _update(
         ctx.repo(),
         ctx.rev(),
         labels=labels,
@@ -2062,7 +2062,7 @@
     This involves updating to the commit and discarding any changes in the
     working copy.
     """
-    return update(ctx.repo(), ctx.rev(), branchmerge=False, force=True, wc=wc)
+    return _update(ctx.repo(), ctx.rev(), branchmerge=False, force=True, wc=wc)
 
 
 def revert_to(ctx, matcher=None, wc=None):
@@ -2072,7 +2072,7 @@
     be the same as in the given commit.
     """
 
-    return update(
+    return _update(
         ctx.repo(),
         ctx.rev(),
         branchmerge=False,
@@ -2123,7 +2123,7 @@
         or pctx.rev() == base.rev()
     )
 
-    stats = update(
+    stats = _update(
         repo,
         ctx.node(),
         True,
@@ -2166,7 +2166,7 @@
                 b"must specify parent of merge commit to back out"
             )
         parent = ctx.p1()
-    return update(
+    return _update(
         ctx.repo(),
         parent,
         branchmerge=True,
--- a/relnotes/next	Mon Sep 21 10:09:39 2020 -0700
+++ b/relnotes/next	Mon Sep 21 11:12:58 2020 -0700
@@ -20,3 +20,7 @@
 
 == Internal API Changes ==
 
+ * `merge.update()` is now private (renamed to `_update()`). Hopefully
+   the higher-level functions available in the same module cover your
+   use cases.
+