[PATCH 2 of 2 STABLE] revset: handle old-style subset input by getset() function (issue4515)
Yuya Nishihara
yuya at tcha.org
Fri Jan 30 08:08:02 CST 2015
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1422624046 -32400
# Fri Jan 30 22:20:46 2015 +0900
# Branch stable
# Node ID 7fe084aeb4226dfe0f15a81cb36304f5194640ec
# Parent 03b6a2472e4e713f62e91549ee166c04e547adb2
revset: handle old-style subset input by getset() function (issue4515)
Old extensions may call revset.getset() with range(len(repo)) to evaluate
the argument set.
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -304,6 +304,8 @@ def getfuncargs(tree):
def getset(repo, subset, x):
if not x:
raise error.ParseError(_("missing argument"))
+ if not util.safehasattr(subset, 'isascending'):
+ subset = baseset(subset)
s = methods[x[0]](repo, subset, *x[1:])
if util.safehasattr(s, 'isascending'):
return s
@@ -2389,11 +2391,7 @@ def match(ui, spec, repo=None):
tree = foldconcat(tree)
weight, tree = optimize(tree, True)
def mfunc(repo, subset):
- if util.safehasattr(subset, 'isascending'):
- result = getset(repo, subset, tree)
- else:
- result = getset(repo, baseset(subset), tree)
- return result
+ return getset(repo, subset, tree)
return mfunc
def formatspec(expr, *args):
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -1284,8 +1284,12 @@ compatibility layer for old extension th
> def aslist(repo, subset, x):
> revset.getargs(x, 0, 0, 'aslist takes no argument')
> return list(subset)
+ > def xlist(repo, subset, x):
+ > s = revset.getset(repo, range(len(repo)), x)
+ > return [r for r in subset if r in s]
> def uisetup(ui):
> revset.symbols['aslist'] = aslist
+ > revset.symbols['xlist'] = xlist
> EOF
$ cd repo
@@ -1294,5 +1298,7 @@ compatibility layer for old extension th
9
$ hg --config extensions.lset=../lset.py debugrevspec 'min(aslist())'
0
+ $ hg --config extensions.lset=../lset.py debugrevspec 'xlist(p1())'
+ 9
$ cd ..
More information about the Mercurial-devel
mailing list