compat: add wrapper for obsolete.createmarkers() that accepts "operation" arg
I want to start passing the operation argument, but hg < 4.3 does not
support it, so we need a compat wrapper. For older hg, the operation
is simply ignored.
--- a/hgext3rd/evolve/__init__.py Mon Mar 12 23:26:25 2018 -0700
+++ b/hgext3rd/evolve/__init__.py Fri Mar 16 10:22:27 2018 -0700
@@ -1225,7 +1225,7 @@
oldbookmarks.extend(repo.nodebookmarks(old.node()))
markers.append((old, (new,)))
if markers:
- obsolete.createmarkers(repo, markers)
+ compat.createmarkers(repo, markers)
bmchanges = []
for book in oldbookmarks:
bmchanges.append((book, new.node()))
--- a/hgext3rd/evolve/cmdrewrite.py Mon Mar 12 23:26:25 2018 -0700
+++ b/hgext3rd/evolve/cmdrewrite.py Fri Mar 16 10:22:27 2018 -0700
@@ -389,7 +389,7 @@
if opts.get('note'):
metadata['note'] = opts['note']
- obsolete.createmarkers(repo, [(old, (repo[newid],))], metadata=metadata)
+ compat.createmarkers(repo, [(old, (repo[newid],))], metadata=metadata)
phases.retractboundary(repo, tr, oldphase, [newid])
if opts.get('revert'):
hg.updaterepo(repo, newid, True)
@@ -427,7 +427,7 @@
fp.seek(0)
newnode = _patchtocommit(ui, repo, old, fp)
# creating obs marker temp -> ()
- obsolete.createmarkers(repo, [(repo[tempnode], ())])
+ compat.createmarkers(repo, [(repo[tempnode], ())])
return newnode
def _createtempcommit(ui, repo, old, match):
@@ -611,8 +611,8 @@
root.p2().node()],
commitopts=commitopts)
phases.retractboundary(repo, tr, targetphase, [newid])
- obsolete.createmarkers(repo, [(ctx, (repo[newid],))
- for ctx in allctx], metadata=metadata)
+ compat.createmarkers(repo, [(ctx, (repo[newid],))
+ for ctx in allctx], metadata=metadata)
# move bookmarks from old nodes to the new one
# XXX: we should make rewriteutil.rewrite() handle such cases
for ctx in allctx:
@@ -743,9 +743,9 @@
metadata['note'] = opts['note']
phases.retractboundary(repo, tr, targetphase, [newid])
- obsolete.createmarkers(repo, [(ctx, (repo[newid],))
- for ctx in allctx],
- metadata=metadata)
+ compat.createmarkers(repo, [(ctx, (repo[newid],))
+ for ctx in allctx],
+ metadata=metadata)
else:
ui.status(_("nothing changed\n"))
tr.close()
@@ -937,7 +937,7 @@
metadata['note'] = opts['note']
# create markers
- obsolete.createmarkers(repo, relations, metadata=metadata)
+ compat.createmarkers(repo, relations, metadata=metadata)
# informs that changeset have been pruned
ui.status(_('%i changesets pruned\n') % len(precs))
@@ -1050,8 +1050,8 @@
metadata = {}
if opts.get('note'):
metadata['note'] = opts['note']
- obsolete.createmarkers(repo, [(repo[rev], newcommits)],
- metadata=metadata)
+ compat.createmarkers(repo, [(repo[rev], newcommits)],
+ metadata=metadata)
tr.close()
finally:
# Restore the old branch
@@ -1142,8 +1142,8 @@
metadata = {}
if opts.get('note'):
metadata['note'] = opts['note']
- obsolete.createmarkers(repo, [(ctx, (repo[new],))],
- metadata=metadata)
+ compat.createmarkers(repo, [(ctx, (repo[new],))],
+ metadata=metadata)
phases.retractboundary(repo, tr, ctx.phase(), [new])
if ctx in repo[None].parents():
with repo.dirstate.parentchange():
@@ -1234,9 +1234,9 @@
if grabstate:
grabstate.delete()
if newnode:
- obsolete.createmarkers(repo, [(origctx, (repo[newnode],))])
+ compat.createmarkers(repo, [(origctx, (repo[newnode],))])
else:
- obsolete.createmarkers(repo, [(origctx, (pctx,))])
+ compat.createmarkers(repo, [(origctx, (pctx,))])
if newnode is None:
ui.warn(_("note: grab of %d:%s created no changes to commit\n") %
--- a/hgext3rd/evolve/compat.py Mon Mar 12 23:26:25 2018 -0700
+++ b/hgext3rd/evolve/compat.py Fri Mar 16 10:22:27 2018 -0700
@@ -51,6 +51,14 @@
eh = exthelper.exthelper()
+# Wrap obsolete.creatmarkers and make it accept but ignore "operation" argument
+# for hg < 4.3
+createmarkers = obsolete.createmarkers
+if obsolete.createmarkers.__code__.co_argcount < 6:
+ def createmarkers(repo, relations, flag=0, date=None, metadata=None,
+ operation=None):
+ return obsolete.createmarkers(repo, relations, flag, date, metadata)
+
if not util.safehasattr(hg, '_copycache'):
# exact copy of relevantmarkers as in Mercurial-176d1a0ce385
# this fixes relevant markers computation for version < hg-4.3
--- a/hgext3rd/evolve/evolvecmd.py Mon Mar 12 23:26:25 2018 -0700
+++ b/hgext3rd/evolve/evolvecmd.py Fri Mar 16 10:22:27 2018 -0700
@@ -235,7 +235,7 @@
tmpid = relocate(repo, bumped, prec.p1())
if tmpid is not None:
tmpctx = repo[tmpid]
- obsolete.createmarkers(repo, [(bumped, (tmpctx,))])
+ compat.createmarkers(repo, [(bumped, (tmpctx,))])
except MergeFailure:
repo.vfs.write('graftstate', bumped.hex() + '\n')
repo.ui.write_err(_('evolution failed!\n'))
@@ -280,12 +280,12 @@
newid = repo.commitctx(new)
if newid is None:
- obsolete.createmarkers(repo, [(tmpctx, ())])
+ compat.createmarkers(repo, [(tmpctx, ())])
newid = prec.node()
else:
phases.retractboundary(repo, tr, bumped.phase(), [newid])
- obsolete.createmarkers(repo, [(tmpctx, (repo[newid],))],
- flag=obsolete.bumpedfix)
+ compat.createmarkers(repo, [(tmpctx, (repo[newid],))],
+ flag=obsolete.bumpedfix)
bmupdate(newid)
repo.ui.status(_('committed as %s\n') % node.short(newid))
# reroute the working copy parent to the new changeset
@@ -408,7 +408,7 @@
# no changes
else:
new = repo['.']
- obsolete.createmarkers(repo, [(other, (new,))])
+ compat.createmarkers(repo, [(other, (new,))])
phases.retractboundary(repo, tr, other.phase(), [new.node()])
return (True, new.node())
finally:
@@ -546,11 +546,11 @@
bmchanges = []
if nodenew is not None:
- obsolete.createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))])
+ compat.createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))])
for book in oldbookmarks:
bmchanges.append((book, nodenew))
else:
- obsolete.createmarkers(repo, [(repo[nodesrc], ())])
+ compat.createmarkers(repo, [(repo[nodesrc], ())])
# Behave like rebase, move bookmarks to dest
for book in oldbookmarks:
bmchanges.append((book, dest.node()))
@@ -1222,9 +1222,9 @@
# resolving conflicts can lead to empty wdir and node can be None in
# those cases
if node is not None:
- obsolete.createmarkers(repo, [(ctx, (repo[node],))])
+ compat.createmarkers(repo, [(ctx, (repo[node],))])
else:
- obsolete.createmarkers(repo, [(ctx, (repo['.'],))])
+ compat.createmarkers(repo, [(ctx, (repo['.'],))])
# make sure we are continuing evolve and not `hg next --evolve`
if evolvestate['command'] == 'evolve':
--- a/hgext3rd/topic/compat.py Mon Mar 12 23:26:25 2018 -0700
+++ b/hgext3rd/topic/compat.py Fri Mar 16 10:22:27 2018 -0700
@@ -27,6 +27,14 @@
if successorssets is None:
successorssets = obsolete.successorssets
+# Wrap obsolete.creatmarkers and make it accept but ignore "operation" argument
+# for hg < 4.3
+createmarkers = obsolete.createmarkers
+if obsolete.createmarkers.__code__.co_argcount < 6:
+ def createmarkers(repo, relations, flag=0, date=None, metadata=None,
+ operation=None):
+ return obsolete.createmarkers(repo, relations, flag, date, metadata)
+
def startpager(ui, cmd):
"""function to start a pager in case ui.pager() exists"""
try:
@@ -44,4 +52,4 @@
else:
relations = [(repo[o], tuple(repo[n] for n in new))
for (o, new) in replacements.iteritems()]
- obsolete.createmarkers(repo, relations)
+ createmarkers(repo, relations)