changeset 37251:7c0f40f4f7bf

scmutil: introduce deprecated alias for revpair() revsingle() returns a context object, revpair() returns nodeids, revrange() returns integer revisions (in a revset). I'm going to reduce this inconsistency by making revpair() return context objects. Changing the return type is not nice to extensions, so this patch introduces a nodeid-returning version of revpair() that they can detect and use. Update callers to the new function so we can change revpair() itself and then migrate them back one by one. Differential Revision: https://phab.mercurial-scm.org/D3005
author Martin von Zweigbergk <martinvonz@google.com>
date Sat, 31 Mar 2018 23:37:25 -0700
parents 9640ccf44ac0
children e9ee540af434
files hgext/extdiff.py mercurial/commands.py mercurial/fileset.py mercurial/scmutil.py tests/autodiff.py
diffstat 5 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/extdiff.py	Sat Mar 31 23:58:08 2018 -0400
+++ b/hgext/extdiff.py	Sat Mar 31 23:37:25 2018 -0700
@@ -171,7 +171,7 @@
         node2 = scmutil.revsingle(repo, change, None).node()
         node1a, node1b = repo.changelog.parents(node2)
     else:
-        node1a, node2 = scmutil.revpair(repo, revs)
+        node1a, node2 = scmutil.revpairnodes(repo, revs)
         if not revs:
             node1b = repo.dirstate.p2()
         else:
--- a/mercurial/commands.py	Sat Mar 31 23:58:08 2018 -0400
+++ b/mercurial/commands.py	Sat Mar 31 23:37:25 2018 -0700
@@ -1878,7 +1878,7 @@
         node1 = repo[node2].p1().node()
     else:
         repo = scmutil.unhidehashlikerevs(repo, revs, 'nowarn')
-        node1, node2 = scmutil.revpair(repo, revs)
+        node1, node2 = scmutil.revpairnodes(repo, revs)
 
     if reverse:
         node1, node2 = node2, node1
@@ -4880,7 +4880,7 @@
         node1 = repo[node2].p1().node()
     else:
         repo = scmutil.unhidehashlikerevs(repo, revs, 'nowarn')
-        node1, node2 = scmutil.revpair(repo, revs)
+        node1, node2 = scmutil.revpairnodes(repo, revs)
 
     if pats or ui.configbool('commands', 'status.relative'):
         cwd = repo.getcwd()
--- a/mercurial/fileset.py	Sat Mar 31 23:58:08 2018 -0400
+++ b/mercurial/fileset.py	Sat Mar 31 23:37:25 2018 -0700
@@ -513,7 +513,7 @@
     revspec = getstring(r, reverr)
     if not revspec:
         raise error.ParseError(reverr)
-    basenode, node = scmutil.revpair(repo, [baserevspec, revspec])
+    basenode, node = scmutil.revpairnodes(repo, [baserevspec, revspec])
     basectx = repo[basenode]
     ctx = repo[node]
     return getset(mctx.switch(ctx, _buildstatus(ctx, x, basectx=basectx)), x)
--- a/mercurial/scmutil.py	Sat Mar 31 23:58:08 2018 -0400
+++ b/mercurial/scmutil.py	Sat Mar 31 23:37:25 2018 -0700
@@ -446,6 +446,9 @@
     tree = revsetlang.parse(revspec)
     return tree and tree[0] in ('range', 'rangepre', 'rangepost', 'rangeall')
 
+def revpairnodes(repo, revs):
+    return revpair(repo, revs)
+
 def revpair(repo, revs):
     if not revs:
         return repo.dirstate.p1(), None
--- a/tests/autodiff.py	Sat Mar 31 23:58:08 2018 -0400
+++ b/tests/autodiff.py	Sat Mar 31 23:37:25 2018 -0700
@@ -40,7 +40,7 @@
     else:
         raise error.Abort(b'--git must be yes, no or auto')
 
-    node1, node2 = scmutil.revpair(repo, [])
+    node1, node2 = scmutil.revpairnodes(repo, [])
     m = scmutil.match(repo[node2], pats, opts)
     it = patch.diff(repo, node1, node2, match=m, opts=diffopts,
                     losedatafn=losedatafn)