changeset 40366:b14fdf1fb615

update: clarify update() call sites by specifying argument names merge.update() takes a lot of parameters and I get confused all the time which is which. Differential Revision: https://phab.mercurial-scm.org/D5153
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 09 Feb 2017 09:17:40 -0800
parents 4f37af86d5d5
children 824b687ff6af
files hgext/histedit.py hgext/rebase.py hgext/shelve.py hgext/transplant.py mercurial/cmdutil.py mercurial/commands.py mercurial/hg.py tests/test-revlog-ancestry.py
diffstat 8 files changed, 19 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/histedit.py	Thu Oct 18 10:11:08 2018 -0700
+++ b/hgext/histedit.py	Thu Feb 09 09:17:40 2017 -0800
@@ -830,8 +830,7 @@
 
     def run(self):
         if self.repo['.'].node() != self.node:
-            mergemod.update(self.repo, self.node, False, True)
-            #                                     branchmerge, force)
+            mergemod.update(self.repo, self.node, branchmerge=False, force=True)
         return self.continueclean()
 
     def continuedirty(self):
--- a/hgext/rebase.py	Thu Oct 18 10:11:08 2018 -0700
+++ b/hgext/rebase.py	Thu Feb 09 09:17:40 2017 -0800
@@ -1188,7 +1188,7 @@
     else:
         if repo['.'].rev() != p1:
             repo.ui.debug(" update to %d:%s\n" % (p1, repo[p1]))
-            mergemod.update(repo, p1, False, True)
+            mergemod.update(repo, p1, branchmerge=False, force=True)
         else:
             repo.ui.debug(" already in destination\n")
         # This is, alas, necessary to invalidate workingctx's manifest cache,
@@ -1200,7 +1200,8 @@
         repo.ui.debug("   detach base %d:%s\n" % (base, repo[base]))
     # When collapsing in-place, the parent is the common ancestor, we
     # have to allow merging with it.
-    stats = mergemod.update(repo, rev, True, True, base, collapse,
+    stats = mergemod.update(repo, rev, branchmerge=True, force=True,
+                            ancestor=base, mergeancestor=collapse,
                             labels=['dest', 'source'], wc=wctx)
     if collapse:
         copies.duplicatecopies(repo, wctx, rev, dest)
@@ -1643,7 +1644,7 @@
 
             # Update away from the rebase if necessary
             if shouldupdate or needupdate(repo, state):
-                mergemod.update(repo, originalwd, False, True)
+                mergemod.update(repo, originalwd, branchmerge=False, force=True)
 
             # Strip from the first rebased revision
             if rebased:
--- a/hgext/shelve.py	Thu Oct 18 10:11:08 2018 -0700
+++ b/hgext/shelve.py	Thu Feb 09 09:17:40 2017 -0800
@@ -656,7 +656,7 @@
         try:
             checkparents(repo, state)
 
-            merge.update(repo, state.pendingctx, False, True)
+            merge.update(repo, state.pendingctx, branchmerge=False, force=True)
             if (state.activebookmark
                     and state.activebookmark in repo._bookmarks):
                 bookmarks.activate(repo, state.activebookmark)
--- a/hgext/transplant.py	Thu Oct 18 10:11:08 2018 -0700
+++ b/hgext/transplant.py	Thu Feb 09 09:17:40 2017 -0800
@@ -184,7 +184,8 @@
                     if pulls:
                         if source != repo:
                             exchange.pull(repo, source.peer(), heads=pulls)
-                        merge.update(repo, pulls[-1], False, False)
+                        merge.update(repo, pulls[-1], branchmerge=False,
+                                     force=False)
                         p1, p2 = repo.dirstate.parents()
                         pulls = []
 
@@ -249,7 +250,7 @@
             tr.close()
             if pulls:
                 exchange.pull(repo, source.peer(), heads=pulls)
-                merge.update(repo, pulls[-1], False, False)
+                merge.update(repo, pulls[-1], branchmerge=False, force=False)
         finally:
             self.saveseries(revmap, merges)
             self.transplants.write()
--- a/mercurial/cmdutil.py	Thu Oct 18 10:11:08 2018 -0700
+++ b/mercurial/cmdutil.py	Thu Feb 09 09:17:40 2017 -0800
@@ -365,8 +365,8 @@
             if backups:
                 # Equivalent to hg.revert
                 m = scmutil.matchfiles(repo, backups.keys())
-                mergemod.update(repo, repo.dirstate.p1(),
-                        False, True, matcher=m)
+                mergemod.update(repo, repo.dirstate.p1(), branchmerge=False,
+                                force=True, matcher=m)
 
             # 3b. (apply)
             if dopatch:
--- a/mercurial/commands.py	Thu Oct 18 10:11:08 2018 -0700
+++ b/mercurial/commands.py	Thu Feb 09 09:17:40 2017 -0800
@@ -643,7 +643,9 @@
         with dirstateguard.dirstateguard(repo, 'backout'):
             overrides = {('ui', 'forcemerge'): opts.get('tool', '')}
             with ui.configoverride(overrides, 'backout'):
-                stats = mergemod.update(repo, parent, True, True, node, False)
+                stats = mergemod.update(repo, parent, branchmerge=True,
+                                        force=True, ancestor=node,
+                                        mergeancestor=False)
             repo.setparents(op1, op2)
         hg._showstats(repo, stats)
         if stats.unresolvedcount:
--- a/mercurial/hg.py	Thu Oct 18 10:11:08 2018 -0700
+++ b/mercurial/hg.py	Thu Feb 09 09:17:40 2017 -0800
@@ -846,7 +846,7 @@
     When overwrite is set, changes are clobbered, merged else
 
     returns stats (see pydoc mercurial.merge.applyupdates)"""
-    return mergemod.update(repo, node, False, overwrite,
+    return mergemod.update(repo, node, branchmerge=False, force=overwrite,
                            labels=['working copy', 'destination'],
                            updatecheck=updatecheck)
 
@@ -949,8 +949,8 @@
     """Branch merge with node, resolving changes. Return true if any
     unresolved conflicts."""
     if not abort:
-        stats = mergemod.update(repo, node, True, force, mergeforce=mergeforce,
-                                labels=labels)
+        stats = mergemod.update(repo, node, branchmerge=True, force=force,
+                                mergeforce=mergeforce, labels=labels)
     else:
         ms = mergemod.mergestate.read(repo)
         if ms.active():
--- a/tests/test-revlog-ancestry.py	Thu Oct 18 10:11:08 2018 -0700
+++ b/tests/test-revlog-ancestry.py	Thu Feb 09 09:17:40 2017 -0800
@@ -22,10 +22,10 @@
     commit(name, time)
 
 def update(rev):
-    merge.update(repo, rev, False, True)
+    merge.update(repo, rev, branchmerge=False, force=True)
 
 def merge_(rev):
-    merge.update(repo, rev, True, False)
+    merge.update(repo, rev, branchmerge=True, force=False)
 
 if __name__ == '__main__':
     addcommit(b"A", 0)