comparison tests/test-command-template.t @ 22304:5678b0e3608f

templater: enable alias predicates to be used in "revset()" function Before this patch, predicates defined in "[revsetalias]" can't be used in the query specified to template function "revset()", because: - "revset()" uses "localrepository.revs()" to get query result, but - "localrepository.revs()" passes "None" as "ui" to "revset.match()", then - "revset.match()" can't recognize any alias predicates To enable alias predicates to be used in "revset()" function, this patch invokes "revset.match()" directly with "repo.ui". This patch doesn't make "localrepository.revs()" pass "self.ui" to "revset.match()", because this may be intentional implementation to prevent alias predicates from shadowing built-in ones and breaking functions internally using "localrepository.revs()". Even if it isn't intentional one, the check for shadowing should be implemented (maybe on default branch) before fixing it for safety.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sat, 23 Aug 2014 21:23:02 +0900
parents 0483ff40e326
children bd15932846a4
comparison
equal deleted inserted replaced
22300:35ab037de989 22304:5678b0e3608f
1832 $ hg log --template '{rev} Parents: {revset("parents(%s)", rev)}\n' 1832 $ hg log --template '{rev} Parents: {revset("parents(%s)", rev)}\n'
1833 2 Parents: 1 1833 2 Parents: 1
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
1840 Ancestor: 1 1849 Ancestor: 1
1841 Ancestor: 2 1850 Ancestor: 2