changeset 44286:cb8b67016110

graft: default `base` argument to common case of `ctx.p1()` I also updated the callers that wanted that, partly to simplify and partly to show that it works. Differential Revision: https://phab.mercurial-scm.org/D8027
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 28 Jan 2020 14:53:23 -0800
parents fc7175df6359
children 5323cdb8ae33
files hgext/histedit.py mercurial/merge.py mercurial/shelve.py
diffstat 3 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/histedit.py	Fri Jan 10 13:12:24 2020 -0800
+++ b/hgext/histedit.py	Tue Jan 28 14:53:23 2020 -0800
@@ -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
--- a/mercurial/merge.py	Fri Jan 10 13:12:24 2020 -0800
+++ b/mercurial/merge.py	Tue Jan 28 14:53:23 2020 -0800
@@ -2592,7 +2592,7 @@
 def graft(
     repo,
     ctx,
-    base,
+    base=None,
     labels=None,
     keepparent=False,
     keepconflictparent=False,
@@ -2607,7 +2607,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
@@ -2621,6 +2621,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(
--- a/mercurial/shelve.py	Fri Jan 10 13:12:24 2020 -0800
+++ b/mercurial/shelve.py	Tue Jan 28 14:53:23 2020 -0800
@@ -996,7 +996,6 @@
         stats = merge.graft(
             repo,
             shelvectx,
-            shelvectx.p1(),
             labels=[b'shelve', b'working-copy'],
             keepconflictparent=True,
         )