Mercurial > hg
comparison mercurial/revset.py @ 20569:0d4be103c734
revset: added _hexlist method to replace _list for %ln
Now %ln expression goes through _hexlist and doesn't do any unnecesary
processing anymore.
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Wed, 26 Feb 2014 17:15:55 -0800 |
parents | 98024950ade0 |
children | 2d52f37937b0 |
comparison
equal
deleted
inserted
replaced
20568:d7eb839535d1 | 20569:0d4be103c734 |
---|---|
1584 def _intlist(repo, subset, x): | 1584 def _intlist(repo, subset, x): |
1585 s = getstring(x, "internal error") | 1585 s = getstring(x, "internal error") |
1586 if not s: | 1586 if not s: |
1587 return baseset([]) | 1587 return baseset([]) |
1588 ls = [int(r) for r in s.split('\0')] | 1588 ls = [int(r) for r in s.split('\0')] |
1589 s = subset.set() | |
1590 return baseset([r for r in ls if r in s]) | |
1591 | |
1592 # for internal use | |
1593 def _hexlist(repo, subset, x): | |
1594 s = getstring(x, "internal error") | |
1595 if not s: | |
1596 return baseset([]) | |
1597 cl = repo.changelog | |
1598 ls = [cl.rev(node.bin(r)) for r in s.split('\0')] | |
1589 s = subset.set() | 1599 s = subset.set() |
1590 return baseset([r for r in ls if r in s]) | 1600 return baseset([r for r in ls if r in s]) |
1591 | 1601 |
1592 symbols = { | 1602 symbols = { |
1593 "adds": adds, | 1603 "adds": adds, |
1655 "tagged": tagged, | 1665 "tagged": tagged, |
1656 "user": user, | 1666 "user": user, |
1657 "unstable": unstable, | 1667 "unstable": unstable, |
1658 "_list": _list, | 1668 "_list": _list, |
1659 "_intlist": _intlist, | 1669 "_intlist": _intlist, |
1670 "_hexlist": _hexlist, | |
1660 } | 1671 } |
1661 | 1672 |
1662 # symbols which can't be used for a DoS attack for any given input | 1673 # symbols which can't be used for a DoS attack for any given input |
1663 # (e.g. those which accept regexes as plain strings shouldn't be included) | 1674 # (e.g. those which accept regexes as plain strings shouldn't be included) |
1664 # functions that just return a lot of changesets (like all) don't count here | 1675 # functions that just return a lot of changesets (like all) don't count here |
1726 "tagged", | 1737 "tagged", |
1727 "user", | 1738 "user", |
1728 "unstable", | 1739 "unstable", |
1729 "_list", | 1740 "_list", |
1730 "_intlist", | 1741 "_intlist", |
1742 "_hexlist", | |
1731 ]) | 1743 ]) |
1732 | 1744 |
1733 methods = { | 1745 methods = { |
1734 "range": rangeset, | 1746 "range": rangeset, |
1735 "dagrange": dagrange, | 1747 "dagrange": dagrange, |
2036 elif t == 'd': | 2048 elif t == 'd': |
2037 return "_intlist('%s')" % "\0".join(str(int(a)) for a in s) | 2049 return "_intlist('%s')" % "\0".join(str(int(a)) for a in s) |
2038 elif t == 's': | 2050 elif t == 's': |
2039 return "_list('%s')" % "\0".join(s) | 2051 return "_list('%s')" % "\0".join(s) |
2040 elif t == 'n': | 2052 elif t == 'n': |
2041 return "_list('%s')" % "\0".join(node.hex(a) for a in s) | 2053 return "_hexlist('%s')" % "\0".join(node.hex(a) for a in s) |
2042 elif t == 'b': | 2054 elif t == 'b': |
2043 return "_list('%s')" % "\0".join(a.branch() for a in s) | 2055 return "_list('%s')" % "\0".join(a.branch() for a in s) |
2044 | 2056 |
2045 m = l // 2 | 2057 m = l // 2 |
2046 return '(%s or %s)' % (listexp(s[:m], t), listexp(s[m:], t)) | 2058 return '(%s or %s)' % (listexp(s[:m], t), listexp(s[m:], t)) |