##// END OF EJS Templates
revset: add inspection data to all filter() calls...
Yuya Nishihara -
r28424:534f968d default
parent child Browse files
Show More
@@ -600,7 +600,8 b' def author(repo, subset, x):'
600 600 # i18n: "author" is a keyword
601 601 n = encoding.lower(getstring(x, _("author requires a string")))
602 602 kind, pattern, matcher = _substringmatcher(n)
603 return subset.filter(lambda x: matcher(encoding.lower(repo[x].user())))
603 return subset.filter(lambda x: matcher(encoding.lower(repo[x].user())),
604 condrepr=('<user %r>', n))
604 605
605 606 @predicate('bisect(string)', safe=True)
606 607 def bisect(repo, subset, x):
@@ -686,19 +687,22 b' def branch(repo, subset, x):'
686 687 # note: falls through to the revspec case if no branch with
687 688 # this name exists and pattern kind is not specified explicitly
688 689 if pattern in repo.branchmap():
689 return subset.filter(lambda r: matcher(getbi(r)[0]))
690 return subset.filter(lambda r: matcher(getbi(r)[0]),
691 condrepr=('<branch %r>', b))
690 692 if b.startswith('literal:'):
691 693 raise error.RepoLookupError(_("branch '%s' does not exist")
692 694 % pattern)
693 695 else:
694 return subset.filter(lambda r: matcher(getbi(r)[0]))
696 return subset.filter(lambda r: matcher(getbi(r)[0]),
697 condrepr=('<branch %r>', b))
695 698
696 699 s = getset(repo, fullreposet(repo), x)
697 700 b = set()
698 701 for r in s:
699 702 b.add(getbi(r)[0])
700 703 c = s.__contains__
701 return subset.filter(lambda r: c(r) or getbi(r)[0] in b)
704 return subset.filter(lambda r: c(r) or getbi(r)[0] in b,
705 condrepr=lambda: '<branch %r>' % sorted(b))
702 706
703 707 @predicate('bumped()', safe=True)
704 708 def bumped(repo, subset, x):
@@ -753,7 +757,7 b' def checkstatus(repo, subset, pat, field'
753 757 if m(f):
754 758 return True
755 759
756 return subset.filter(matches)
760 return subset.filter(matches, condrepr=('<status[%r] %r>', field, pat))
757 761
758 762 def _children(repo, narrow, parentset):
759 763 if not parentset:
@@ -785,7 +789,8 b' def closed(repo, subset, x):'
785 789 """
786 790 # i18n: "closed" is a keyword
787 791 getargs(x, 0, 0, _("closed takes no arguments"))
788 return subset.filter(lambda r: repo[r].closesbranch())
792 return subset.filter(lambda r: repo[r].closesbranch(),
793 condrepr='<branch closed>')
789 794
790 795 @predicate('contains(pattern)')
791 796 def contains(repo, subset, x):
@@ -812,7 +817,7 b' def contains(repo, subset, x):'
812 817 return True
813 818 return False
814 819
815 return subset.filter(matches)
820 return subset.filter(matches, condrepr=('<contains %r>', pat))
816 821
817 822 @predicate('converted([id])', safe=True)
818 823 def converted(repo, subset, x):
@@ -834,7 +839,8 b' def converted(repo, subset, x):'
834 839 source = repo[r].extra().get('convert_revision', None)
835 840 return source is not None and (rev is None or source.startswith(rev))
836 841
837 return subset.filter(lambda r: _matchvalue(r))
842 return subset.filter(lambda r: _matchvalue(r),
843 condrepr=('<converted %r>', rev))
838 844
839 845 @predicate('date(interval)', safe=True)
840 846 def date(repo, subset, x):
@@ -843,7 +849,8 b' def date(repo, subset, x):'
843 849 # i18n: "date" is a keyword
844 850 ds = getstring(x, _("date requires a string"))
845 851 dm = util.matchdate(ds)
846 return subset.filter(lambda x: dm(repo[x].date()[0]))
852 return subset.filter(lambda x: dm(repo[x].date()[0]),
853 condrepr=('<date %r>', ds))
847 854
848 855 @predicate('desc(string)', safe=True)
849 856 def desc(repo, subset, x):
@@ -856,7 +863,7 b' def desc(repo, subset, x):'
856 863 c = repo[x]
857 864 return ds in encoding.lower(c.description())
858 865
859 return subset.filter(matches)
866 return subset.filter(matches, condrepr=('<desc %r>', ds))
860 867
861 868 def _descendants(repo, subset, x, followfirst=False):
862 869 roots = getset(repo, fullreposet(repo), x)
@@ -931,7 +938,8 b' def destination(repo, subset, x):'
931 938 r = src
932 939 src = _getrevsource(repo, r)
933 940
934 return subset.filter(dests.__contains__)
941 return subset.filter(dests.__contains__,
942 condrepr=lambda: '<destination %r>' % sorted(dests))
935 943
936 944 @predicate('divergent()', safe=True)
937 945 def divergent(repo, subset, x):
@@ -980,7 +988,8 b' def extra(repo, subset, x):'
980 988 extra = repo[r].extra()
981 989 return label in extra and (value is None or matcher(extra[label]))
982 990
983 return subset.filter(lambda r: _matchvalue(r))
991 return subset.filter(lambda r: _matchvalue(r),
992 condrepr=('<extra[%r] %r>', label, value))
984 993
985 994 @predicate('filelog(pattern)', safe=True)
986 995 def filelog(repo, subset, x):
@@ -1118,7 +1127,7 b' def grep(repo, subset, x):'
1118 1127 return True
1119 1128 return False
1120 1129
1121 return subset.filter(matches)
1130 return subset.filter(matches, condrepr=('<grep %r>', gr.pattern))
1122 1131
1123 1132 @predicate('_matchfiles', safe=True)
1124 1133 def _matchfiles(repo, subset, x):
@@ -1179,7 +1188,10 b' def _matchfiles(repo, subset, x):'
1179 1188 return True
1180 1189 return False
1181 1190
1182 return subset.filter(matches)
1191 return subset.filter(matches,
1192 condrepr=('<matchfiles patterns=%r, include=%r '
1193 'exclude=%r, default=%r, rev=%r>',
1194 pats, inc, exc, default, rev))
1183 1195
1184 1196 @predicate('file(pattern)', safe=True)
1185 1197 def hasfile(repo, subset, x):
@@ -1240,7 +1252,7 b' def keyword(repo, subset, x):'
1240 1252 return any(kw in encoding.lower(t)
1241 1253 for t in c.files() + [c.user(), c.description()])
1242 1254
1243 return subset.filter(matches)
1255 return subset.filter(matches, condrepr=('<keyword %r>', kw))
1244 1256
1245 1257 @predicate('limit(set[, n[, offset]])', safe=True)
1246 1258 def limit(repo, subset, x):
@@ -1326,7 +1338,8 b' def merge(repo, subset, x):'
1326 1338 # i18n: "merge" is a keyword
1327 1339 getargs(x, 0, 0, _("merge takes no arguments"))
1328 1340 cl = repo.changelog
1329 return subset.filter(lambda r: cl.parentrevs(r)[1] != -1)
1341 return subset.filter(lambda r: cl.parentrevs(r)[1] != -1,
1342 condrepr='<merge>')
1330 1343
1331 1344 @predicate('branchpoint()', safe=True)
1332 1345 def branchpoint(repo, subset, x):
@@ -1345,7 +1358,8 b' def branchpoint(repo, subset, x):'
1345 1358 for p in cl.parentrevs(r):
1346 1359 if p >= baserev:
1347 1360 parentscount[p - baserev] += 1
1348 return subset.filter(lambda r: parentscount[r - baserev] > 1)
1361 return subset.filter(lambda r: parentscount[r - baserev] > 1,
1362 condrepr='<branchpoint>')
1349 1363
1350 1364 @predicate('min(set)', safe=True)
1351 1365 def minrev(repo, subset, x):
@@ -1602,7 +1616,8 b' def _phase(repo, subset, target):'
1602 1616 else:
1603 1617 phase = repo._phasecache.phase
1604 1618 condition = lambda r: phase(repo, r) == target
1605 return subset.filter(condition, cache=False)
1619 return subset.filter(condition, condrepr=('<phase %r>', target),
1620 cache=False)
1606 1621
1607 1622 @predicate('draft()', safe=True)
1608 1623 def draft(repo, subset, x):
@@ -1675,7 +1690,8 b' def _notpublic(repo, subset, x):'
1675 1690 phase = repo._phasecache.phase
1676 1691 target = phases.public
1677 1692 condition = lambda r: phase(repo, r) != target
1678 return subset.filter(condition, cache=False)
1693 return subset.filter(condition, condrepr=('<phase %r>', target),
1694 cache=False)
1679 1695
1680 1696 @predicate('public()', safe=True)
1681 1697 def public(repo, subset, x):
@@ -1685,7 +1701,8 b' def public(repo, subset, x):'
1685 1701 phase = repo._phasecache.phase
1686 1702 target = phases.public
1687 1703 condition = lambda r: phase(repo, r) == target
1688 return subset.filter(condition, cache=False)
1704 return subset.filter(condition, condrepr=('<phase %r>', target),
1705 cache=False)
1689 1706
1690 1707 @predicate('remote([id [,path]])', safe=True)
1691 1708 def remote(repo, subset, x):
@@ -1860,7 +1877,7 b' def matching(repo, subset, x):'
1860 1877 return True
1861 1878 return False
1862 1879
1863 return subset.filter(matches)
1880 return subset.filter(matches, condrepr=('<matching%r %r>', fields, revs))
1864 1881
1865 1882 @predicate('reverse(set)', safe=True)
1866 1883 def reverse(repo, subset, x):
@@ -1881,7 +1898,7 b' def roots(repo, subset, x):'
1881 1898 if 0 <= p and p in s:
1882 1899 return False
1883 1900 return True
1884 return subset & s.filter(filter)
1901 return subset & s.filter(filter, condrepr='<roots>')
1885 1902
1886 1903 @predicate('sort(set[, [-]key...])', safe=True)
1887 1904 def sort(repo, subset, x):
@@ -1988,7 +2005,7 b' def subrepo(repo, subset, x):'
1988 2005
1989 2006 return False
1990 2007
1991 return subset.filter(matches)
2008 return subset.filter(matches, condrepr=('<subrepo %r>', pat))
1992 2009
1993 2010 def _substringmatcher(pattern):
1994 2011 kind, pattern, matcher = util.stringmatcher(pattern)
@@ -545,14 +545,16 b' test ancestors'
545 545 ('string', '\x08issue\\d+'))
546 546 * set:
547 547 <filteredset
548 <fullreposet+ 0:9>>
548 <fullreposet+ 0:9>,
549 <grep '\x08issue\\d+'>>
549 550 $ try 'grep(r"\bissue\d+")'
550 551 (func
551 552 ('symbol', 'grep')
552 553 ('string', '\\bissue\\d+'))
553 554 * set:
554 555 <filteredset
555 <fullreposet+ 0:9>>
556 <fullreposet+ 0:9>,
557 <grep '\\bissue\\d+'>>
556 558 6
557 559 $ try 'grep(r"\")'
558 560 hg: parse error at 7: unterminated string
@@ -1593,7 +1595,8 b' aliases:'
1593 1595 None)
1594 1596 * set:
1595 1597 <filteredset
1596 <fullreposet+ 0:9>>
1598 <fullreposet+ 0:9>,
1599 <merge>>
1597 1600 6
1598 1601
1599 1602 $ HGPLAIN=1
@@ -1612,7 +1615,8 b' aliases:'
1612 1615 None)
1613 1616 * set:
1614 1617 <filteredset
1615 <fullreposet+ 0:9>>
1618 <fullreposet+ 0:9>,
1619 <merge>>
1616 1620 6
1617 1621
1618 1622 $ unset HGPLAIN
@@ -1666,7 +1670,8 b' test alias recursion'
1666 1670 * set:
1667 1671 <addset+
1668 1672 <filteredset
1669 <fullreposet+ 0:9>>,
1673 <fullreposet+ 0:9>,
1674 <merge>>,
1670 1675 <generatorset+>>
1671 1676 6
1672 1677 7
@@ -1830,7 +1835,8 b' far away.'
1830 1835 <addset
1831 1836 <baseset [9]>,
1832 1837 <filteredset
1833 <fullreposet+ 0:9>>>
1838 <fullreposet+ 0:9>,
1839 <desc '$1'>>>
1834 1840 9
1835 1841
1836 1842 $ try 'd(2:5)'
General Comments 0
You need to be logged in to leave comments. Login now