##// END OF EJS Templates
templater: enable alias predicates to be used in "revset()" function...
FUJIWARA Katsunori -
r22304:5678b0e3 default
parent child Browse files
Show More
@@ -8,6 +8,7 b''
8 from i18n import _
8 from i18n import _
9 import sys, os, re
9 import sys, os, re
10 import util, config, templatefilters, templatekw, parser, error
10 import util, config, templatefilters, templatekw, parser, error
11 import revset as revsetmod
11 import types
12 import types
12 import minirst
13 import minirst
13
14
@@ -370,16 +371,20 b' def revset(context, mapping, args):'
370 ctx = mapping['ctx']
371 ctx = mapping['ctx']
371 repo = ctx._repo
372 repo = ctx._repo
372
373
374 def query(expr):
375 m = revsetmod.match(repo.ui, expr)
376 return m(repo, revsetmod.spanset(repo))
377
373 if len(args) > 1:
378 if len(args) > 1:
374 formatargs = list([a[0](context, mapping, a[1]) for a in args[1:]])
379 formatargs = list([a[0](context, mapping, a[1]) for a in args[1:]])
375 revs = repo.revs(raw, *formatargs)
380 revs = query(revsetmod.formatspec(raw, *formatargs))
376 revs = list([str(r) for r in revs])
381 revs = list([str(r) for r in revs])
377 else:
382 else:
378 revsetcache = mapping['cache'].setdefault("revsetcache", {})
383 revsetcache = mapping['cache'].setdefault("revsetcache", {})
379 if raw in revsetcache:
384 if raw in revsetcache:
380 revs = revsetcache[raw]
385 revs = revsetcache[raw]
381 else:
386 else:
382 revs = repo.revs(raw)
387 revs = query(raw)
383 revs = list([str(r) for r in revs])
388 revs = list([str(r) for r in revs])
384 revsetcache[raw] = revs
389 revsetcache[raw] = revs
385
390
@@ -1834,6 +1834,15 b' Test revset function'
1834 1 Parents: 0
1834 1 Parents: 0
1835 0 Parents:
1835 0 Parents:
1836
1836
1837 $ cat >> .hg/hgrc <<EOF
1838 > [revsetalias]
1839 > myparents(\$1) = parents(\$1)
1840 > EOF
1841 $ hg log --template '{rev} Parents: {revset("myparents(%s)", rev)}\n'
1842 2 Parents: 1
1843 1 Parents: 0
1844 0 Parents:
1845
1837 $ hg log --template 'Rev: {rev}\n{revset("::%s", rev) % "Ancestor: {revision}\n"}\n'
1846 $ hg log --template 'Rev: {rev}\n{revset("::%s", rev) % "Ancestor: {revision}\n"}\n'
1838 Rev: 2
1847 Rev: 2
1839 Ancestor: 0
1848 Ancestor: 0
General Comments 0
You need to be logged in to leave comments. Login now