D8027: graft: default `base` argument to common case of `ctx.p1()`

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue Jan 28 23:53:40 UTC 2020


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

REVISION SUMMARY
  I also updated the callers that wanted that, partly to simplify and
  partly to show that it works.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/histedit.py
  mercurial/merge.py
  mercurial/shelve.py

CHANGE DETAILS

diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -996,7 +996,6 @@
         stats = merge.graft(
             repo,
             shelvectx,
-            shelvectx.p1(),
             labels=[b'shelve', b'working-copy'],
             keepconflictparent=True,
         )
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -2580,7 +2580,7 @@
 def graft(
     repo,
     ctx,
-    base,
+    base=None,
     labels=None,
     keepparent=False,
     keepconflictparent=False,
@@ -2595,7 +2595,7 @@
     renames/copies appropriately.
 
     ctx - changeset to rebase
-    base - merge base, usually ctx.p1()
+    base - merge base, or ctx.p1() if not specified
     labels - merge labels eg ['local', 'graft']
     keepparent - keep second parent if any
     keepconflictparent - if unresolved, keep parent used for the merge
@@ -2609,6 +2609,7 @@
     # which local deleted".
     wctx = wctx or repo[None]
     pctx = wctx.p1()
+    base = base or ctx.p1()
     mergeancestor = repo.changelog.isancestor(pctx.node(), ctx.node())
 
     stats = update(
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -649,7 +649,7 @@
             repo.ui.setconfig(
                 b'ui', b'forcemerge', opts.get(b'tool', b''), b'histedit'
             )
-            stats = mergemod.graft(repo, ctx, ctx.p1(), [b'local', b'histedit'])
+            stats = mergemod.graft(repo, ctx, labels=[b'local', b'histedit'])
         finally:
             repo.ui.setconfig(b'ui', b'forcemerge', b'', b'histedit')
     return stats



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


More information about the Mercurial-devel mailing list