evolve: update code for not implicitly converting ctx to revision
authorBoris Feld <boris.feld@octobus.net>
Mon, 26 Feb 2018 13:59:30 +0100
changeset 3506 6b4272bbb65d
parent 3505 25155eb05f5f
child 3508 0b3ab8b6f39d
evolve: update code for not implicitly converting ctx to revision Mercurial core 38f480502043 removed the capacity to implicitly convert contexts to revisions using `int(ctx)`. Update Evolve code to explicitly call rev instead.
hgext3rd/evolve/cmdrewrite.py
hgext3rd/evolve/evolvecmd.py
hgext3rd/evolve/obshistory.py
hgext3rd/evolve/rewriteutil.py
--- a/hgext3rd/evolve/cmdrewrite.py	Fri Feb 23 11:02:59 2018 +0100
+++ b/hgext3rd/evolve/cmdrewrite.py	Mon Feb 26 13:59:30 2018 +0100
@@ -942,7 +942,8 @@
         # informs that changeset have been pruned
         ui.status(_('%i changesets pruned\n') % len(precs))
 
-        for ctx in repo.unfiltered().set('bookmark() and %ld', precs):
+        precrevs = (precursor.rev() for precursor in precs)
+        for ctx in repo.unfiltered().set('bookmark() and %ld', precrevs):
             # used to be:
             #
             #   ldest = list(repo.set('max((::%d) - obsolete())', ctx))
@@ -993,11 +994,11 @@
     try:
         wlock = repo.wlock()
         lock = repo.lock()
-        rev = scmutil.revsingle(repo, revarg[0])
+        ctx = scmutil.revsingle(repo, revarg[0])
+        rev = ctx.rev()
         cmdutil.bailifchanged(repo)
         rewriteutil.precheck(repo, [rev], action='split')
         tr = repo.transaction('split')
-        ctx = repo[rev]
 
         if len(ctx.parents()) > 1:
             raise error.Abort(_("cannot split merge commits"))
--- a/hgext3rd/evolve/evolvecmd.py	Fri Feb 23 11:02:59 2018 +0100
+++ b/hgext3rd/evolve/evolvecmd.py	Mon Feb 26 13:59:30 2018 +0100
@@ -182,7 +182,7 @@
         msg = _('skipping %s : we do not handle merge yet\n') % bumped
         ui.write_err(msg)
         return (False, '')
-    prec = repo.set('last(allprecursors(%d) and public())', bumped).next()
+    prec = repo.set('last(allprecursors(%d) and public())', bumped.rev()).next()
     # For now we deny target merge
     if len(prec.parents()) > 1:
         msg = _('skipping: %s: public version is a merge, '
@@ -214,7 +214,7 @@
     tr = repo.currenttransaction()
     assert tr is not None
     bmupdate = _bookmarksupdater(repo, bumped.node(), tr)
-    if not list(repo.set('parents(%d) and parents(%d)', bumped, prec)):
+    if not list(repo.set('parents(%d) and parents(%d)', bumped.rev(), prec.rev())):
         # Need to rebase the changeset at the right place
         repo.ui.status(
             _('rebasing to destination parent: %s\n') % prec.p1())
@@ -632,7 +632,7 @@
     XXX this woobly function won't survive XXX
     """
     repo = ctx._repo.unfiltered()
-    for base in repo.set('reverse(allprecursors(%d))', ctx):
+    for base in repo.set('reverse(allprecursors(%d))', ctx.rev()):
         newer = compat.successorssets(ctx._repo, base.node())
         # drop filter and solution including the original ctx
         newer = [n for n in newer if n and ctx.node() not in n]
--- a/hgext3rd/evolve/obshistory.py	Fri Feb 23 11:02:59 2018 +0100
+++ b/hgext3rd/evolve/obshistory.py	Mon Feb 26 13:59:30 2018 +0100
@@ -402,7 +402,7 @@
              label="evolve.node")
     fm.plain(' ')
 
-    fm.write('rev', '(%d)', int(ctx),
+    fm.write('rev', '(%d)', ctx.rev(),
              label="evolve.rev")
     fm.plain(' ')
 
--- a/hgext3rd/evolve/rewriteutil.py	Fri Feb 23 11:02:59 2018 +0100
+++ b/hgext3rd/evolve/rewriteutil.py	Mon Feb 26 13:59:30 2018 +0100
@@ -24,6 +24,7 @@
     phases,
     repair,
     revset,
+    util,
 )
 
 from mercurial.i18n import _
@@ -60,6 +61,10 @@
         msg = _("cannot %s the null revision") % (action)
         hint = _("no changeset checked out")
         raise error.Abort(msg, hint=hint)
+    if any(util.safehasattr(r, 'rev') for r in revs):
+        msg = "rewriteutil.precheck called with ctx not revs"
+        repo.ui.develwarn(msg)
+        revs = (r.rev() for r in revs)
     publicrevs = repo.revs('%ld and public()', revs)
     if publicrevs:
         summary = _formatrevs(repo, publicrevs)