compat: from compatibility layer for createmarkers
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 19 Apr 2018 16:07:23 +0200
changeset 3694 c0d5e0929f8b
parent 3693 105d2d2c6a2e
child 3695 3680f715c14f
compat: from compatibility layer for createmarkers We support down to 4.3 now. It supports operation.
hgext3rd/evolve/__init__.py
hgext3rd/evolve/cmdrewrite.py
hgext3rd/evolve/compat.py
hgext3rd/evolve/evolvecmd.py
hgext3rd/topic/compat.py
--- a/hgext3rd/evolve/__init__.py	Thu Apr 19 16:01:49 2018 +0200
+++ b/hgext3rd/evolve/__init__.py	Thu Apr 19 16:07:23 2018 +0200
@@ -1234,7 +1234,7 @@
                 oldbookmarks.extend(repo.nodebookmarks(old.node()))
                 markers.append((old, (new,)))
             if markers:
-                compat.createmarkers(repo, markers, operation="amend")
+                obsolete.createmarkers(repo, markers, operation="amend")
             bmchanges = []
             for book in oldbookmarks:
                 bmchanges.append((book, new.node()))
--- a/hgext3rd/evolve/cmdrewrite.py	Thu Apr 19 16:01:49 2018 +0200
+++ b/hgext3rd/evolve/cmdrewrite.py	Thu Apr 19 16:07:23 2018 +0200
@@ -178,8 +178,8 @@
         metadata = {}
         if opts.get('note'):
             metadata['note'] = opts['note']
-        compat.createmarkers(repo, [(old, (repo[newnode],))],
-                             metadata=metadata, operation='amend')
+        obsolete.createmarkers(repo, [(old, (repo[newnode],))],
+                               metadata=metadata, operation='amend')
         phases.retractboundary(repo, tr, old.phase(), [newnode])
         hg.updaterepo(repo, newnode, True)
         bookmarkupdater(newnode)
@@ -544,8 +544,8 @@
         if opts.get('note'):
             metadata['note'] = opts['note']
 
-        compat.createmarkers(repo, [(old, (repo[newid],))], metadata=metadata,
-                             operation="uncommit")
+        obsolete.createmarkers(repo, [(old, (repo[newid],))], metadata=metadata,
+                               operation="uncommit")
         phases.retractboundary(repo, tr, oldphase, [newid])
         if opts.get('revert'):
             hg.updaterepo(repo, newid, True)
@@ -583,7 +583,7 @@
     fp.seek(0)
     newnode = _patchtocommit(ui, repo, old, fp)
     # creating obs marker temp -> ()
-    compat.createmarkers(repo, [(repo[tempnode], ())], operation="uncommit")
+    obsolete.createmarkers(repo, [(repo[tempnode], ())], operation="uncommit")
     return newnode
 
 def _createtempcommit(ui, repo, old, match):
@@ -767,9 +767,9 @@
                                                          root.p2().node()],
                                                         commitopts=commitopts)
             phases.retractboundary(repo, tr, targetphase, [newid])
-            compat.createmarkers(repo, [(ctx, (repo[newid],))
-                                 for ctx in allctx], metadata=metadata,
-                                 operation="fold")
+            obsolete.createmarkers(repo, [(ctx, (repo[newid],))
+                                   for ctx in allctx], metadata=metadata,
+                                   operation="fold")
             # move bookmarks from old nodes to the new one
             # XXX: we should make rewriteutil.rewrite() handle such cases
             for ctx in allctx:
@@ -900,9 +900,9 @@
                     metadata['note'] = opts['note']
 
                 phases.retractboundary(repo, tr, targetphase, [newid])
-                compat.createmarkers(repo, [(ctx, (repo[newid],))
-                                            for ctx in allctx],
-                                     metadata=metadata, operation="metaedit")
+                obsolete.createmarkers(repo, [(ctx, (repo[newid],))
+                                              for ctx in allctx],
+                                       metadata=metadata, operation="metaedit")
             else:
                 ui.status(_("nothing changed\n"))
             tr.close()
@@ -1094,8 +1094,8 @@
             metadata['note'] = opts['note']
 
         # create markers
-        compat.createmarkers(repo, relations, metadata=metadata,
-                             operation="prune")
+        obsolete.createmarkers(repo, relations, metadata=metadata,
+                               operation="prune")
 
         # informs that changeset have been pruned
         ui.status(_('%i changesets pruned\n') % len(precs))
@@ -1208,8 +1208,8 @@
             metadata = {}
             if opts.get('note'):
                 metadata['note'] = opts['note']
-            compat.createmarkers(repo, [(repo[rev], newcommits)],
-                                 metadata=metadata, operation="split")
+            obsolete.createmarkers(repo, [(repo[rev], newcommits)],
+                                   metadata=metadata, operation="split")
         tr.close()
     finally:
         # Restore the old branch
@@ -1300,8 +1300,8 @@
                 metadata = {}
                 if opts.get('note'):
                     metadata['note'] = opts['note']
-                compat.createmarkers(repo, [(ctx, (repo[new],))],
-                                     metadata=metadata, operation="touch")
+                obsolete.createmarkers(repo, [(ctx, (repo[new],))],
+                                       metadata=metadata, operation="touch")
             phases.retractboundary(repo, tr, ctx.phase(), [new])
             if ctx in repo[None].parents():
                 with repo.dirstate.parentchange():
@@ -1392,7 +1392,7 @@
         if grabstate:
             grabstate.delete()
         newctx = repo[newnode] if newnode else pctx
-        compat.createmarkers(repo, [(origctx, (newctx,))], operation="grab")
+        obsolete.createmarkers(repo, [(origctx, (newctx,))], operation="grab")
 
         if newnode is None:
             ui.warn(_("note: grab of %d:%s created no changes to commit\n") %
--- a/hgext3rd/evolve/compat.py	Thu Apr 19 16:01:49 2018 +0200
+++ b/hgext3rd/evolve/compat.py	Thu Apr 19 16:07:23 2018 +0200
@@ -8,8 +8,6 @@
 
 import inspect
 
-import functools
-
 from mercurial import (
     copies,
     context,
@@ -41,19 +39,6 @@
 
 eh = exthelper.exthelper()
 
-# Wrap obsolete.creatmarkers and make it accept but ignore "operation" argument
-# for hg < 4.3
-originalcreatemarkers = obsolete.createmarkers
-while isinstance(originalcreatemarkers, functools.partial):
-    originalcreatemarkers = originalcreatemarkers.func
-if originalcreatemarkers.__code__.co_argcount < 6:
-    def createmarkers(repo, relations, flag=0, date=None, metadata=None,
-                      operation=None):
-        return obsolete.createmarkers(repo, relations, flag, date, metadata)
-else:
-    def createmarkers(*args, **kwargs):
-        return obsolete.createmarkers(*args, **kwargs)
-
 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	Thu Apr 19 16:01:49 2018 +0200
+++ b/hgext3rd/evolve/evolvecmd.py	Thu Apr 19 16:07:23 2018 +0200
@@ -242,8 +242,8 @@
                              category='phasedivergent')
             if tmpid is not None:
                 tmpctx = repo[tmpid]
-                compat.createmarkers(repo, [(bumped, (tmpctx,))],
-                                     operation='evolve')
+                obsolete.createmarkers(repo, [(bumped, (tmpctx,))],
+                                       operation='evolve')
         except MergeFailure:
             evolvestate['current'] = bumped.hex()
             evolvestate['precursor'] = prec.hex()
@@ -308,12 +308,12 @@
 
         newid = repo.commitctx(new)
     if newid is None:
-        compat.createmarkers(repo, [(tmpctx, ())], operation='evolve')
+        obsolete.createmarkers(repo, [(tmpctx, ())], operation='evolve')
         newid = prec.node()
     else:
         phases.retractboundary(repo, tr, bumped.phase(), [newid])
-        compat.createmarkers(repo, [(tmpctx, (repo[newid],))],
-                             flag=obsolete.bumpedfix, operation='evolve')
+        obsolete.createmarkers(repo, [(tmpctx, (repo[newid],))],
+                               flag=obsolete.bumpedfix, operation='evolve')
     bmupdate(newid)
     # if rebased happened, update bookmarks from there too
     if rebasedbmupdate:
@@ -438,7 +438,7 @@
             # no changes
         else:
             new = repo['.']
-        compat.createmarkers(repo, [(other, (new,))], operation='evolve')
+        obsolete.createmarkers(repo, [(other, (new,))], operation='evolve')
         phases.retractboundary(repo, tr, other.phase(), [new.node()])
         return (True, new.node())
     finally:
@@ -578,8 +578,8 @@
     bmchanges = []
 
     if nodenew is not None:
-        compat.createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))],
-                             operation='evolve')
+        obsolete.createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))],
+                               operation='evolve')
         for book in oldbookmarks:
             bmchanges.append((book, nodenew))
             evolvestate['bookmarkchanges'].append((book, nodesrc))
@@ -587,7 +587,7 @@
         if category == 'orphan':
             repo.ui.status(_("evolution of %d:%s created no changes "
                              "to commit\n") % (orig.rev(), orig))
-        compat.createmarkers(repo, [(repo[nodesrc], ())], operation='evolve')
+        obsolete.createmarkers(repo, [(repo[nodesrc], ())], operation='evolve')
         # Behave like rebase, move bookmarks to dest
         for book in oldbookmarks:
             evolvestate['bookmarkchanges'].append((book, nodesrc))
@@ -1382,7 +1382,7 @@
         # those cases
         ctx = repo[evolvestate['current']]
         newctx = repo[node] if node is not None else repo['.']
-        compat.createmarkers(repo, [(ctx, (newctx,))], operation='evolve')
+        obsolete.createmarkers(repo, [(ctx, (newctx,))], operation='evolve')
 
         # now continuing the phase-divergence resolution part
         prec = repo[evolvestate['precursor']]
@@ -1403,7 +1403,7 @@
         repo.ui.status(_("evolution of %d:%s created no changes"
                          " to commit\n") % (ctx.rev(), ctx))
     newctx = repo[node] if node is not None else repo['.']
-    compat.createmarkers(repo, [(ctx, (newctx,))], operation='evolve')
+    obsolete.createmarkers(repo, [(ctx, (newctx,))], operation='evolve')
 
     # make sure we are continuing evolve and not `hg next --evolve`
     if evolvestate['command'] == 'evolve':
--- a/hgext3rd/topic/compat.py	Thu Apr 19 16:01:49 2018 +0200
+++ b/hgext3rd/topic/compat.py	Thu Apr 19 16:07:23 2018 +0200
@@ -7,8 +7,6 @@
 """
 from __future__ import absolute_import
 
-import functools
-
 from mercurial import (
     obsolete,
     scmutil,
@@ -29,19 +27,6 @@
 if successorssets is None:
     successorssets = obsolete.successorssets
 
-# Wrap obsolete.creatmarkers and make it accept but ignore "operation" argument
-# for hg < 4.3
-originalcreatemarkers = obsolete.createmarkers
-while isinstance(originalcreatemarkers, functools.partial):
-    originalcreatemarkers = originalcreatemarkers.func
-if originalcreatemarkers.__code__.co_argcount < 6:
-    def createmarkers(repo, relations, flag=0, date=None, metadata=None,
-                      operation=None):
-        return obsolete.createmarkers(repo, relations, flag, date, metadata)
-else:
-    def createmarkers(*args, **kwargs):
-        return obsolete.createmarkers(*args, **kwargs)
-
 def startpager(ui, cmd):
     """function to start a pager in case ui.pager() exists"""
     try:
@@ -59,4 +44,4 @@
     else:
         relations = [(repo[o], tuple(repo[n] for n in new))
                      for (o, new) in replacements.iteritems()]
-        createmarkers(repo, relations, operation=operation)
+        obsolete.createmarkers(repo, relations, operation=operation)