D5153: update: clarify update() call sites by specifying argument names

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu Oct 18 17:44:04 UTC 2018


martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  merge.update() takes a lot of parameters and I get confused all the
  time which is which.

REPOSITORY
  rHG Mercurial

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

AFFECTED 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

CHANGE DETAILS

diff --git a/tests/test-revlog-ancestry.py b/tests/test-revlog-ancestry.py
--- a/tests/test-revlog-ancestry.py
+++ b/tests/test-revlog-ancestry.py
@@ -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)
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -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():
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -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:
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -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:
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -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()
diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -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)
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -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:
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -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):



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


More information about the Mercurial-devel mailing list