comparison mercurial/revset.py @ 20566:98024950ade0

revset: added _intlist method to replace _list for %ld Now %ld expression goes through _intlist and doesn't do any unnecesary processing anymore.
author Lucas Moscovicz <lmoscovicz@fb.com>
date Wed, 26 Feb 2014 12:36:36 -0800
parents 0e99a66eb7bc
children 0d4be103c734
comparison
equal deleted inserted replaced
20564:0ad353831461 20566:98024950ade0
1575 def _list(repo, subset, x): 1575 def _list(repo, subset, x):
1576 s = getstring(x, "internal error") 1576 s = getstring(x, "internal error")
1577 if not s: 1577 if not s:
1578 return baseset([]) 1578 return baseset([])
1579 ls = [repo[r].rev() for r in s.split('\0')] 1579 ls = [repo[r].rev() for r in s.split('\0')]
1580 s = subset.set()
1581 return baseset([r for r in ls if r in s])
1582
1583 # for internal use
1584 def _intlist(repo, subset, x):
1585 s = getstring(x, "internal error")
1586 if not s:
1587 return baseset([])
1588 ls = [int(r) for r in s.split('\0')]
1580 s = subset.set() 1589 s = subset.set()
1581 return baseset([r for r in ls if r in s]) 1590 return baseset([r for r in ls if r in s])
1582 1591
1583 symbols = { 1592 symbols = {
1584 "adds": adds, 1593 "adds": adds,
1645 "tag": tag, 1654 "tag": tag,
1646 "tagged": tagged, 1655 "tagged": tagged,
1647 "user": user, 1656 "user": user,
1648 "unstable": unstable, 1657 "unstable": unstable,
1649 "_list": _list, 1658 "_list": _list,
1659 "_intlist": _intlist,
1650 } 1660 }
1651 1661
1652 # symbols which can't be used for a DoS attack for any given input 1662 # symbols which can't be used for a DoS attack for any given input
1653 # (e.g. those which accept regexes as plain strings shouldn't be included) 1663 # (e.g. those which accept regexes as plain strings shouldn't be included)
1654 # functions that just return a lot of changesets (like all) don't count here 1664 # functions that just return a lot of changesets (like all) don't count here
1715 "tag", 1725 "tag",
1716 "tagged", 1726 "tagged",
1717 "user", 1727 "user",
1718 "unstable", 1728 "unstable",
1719 "_list", 1729 "_list",
1730 "_intlist",
1720 ]) 1731 ])
1721 1732
1722 methods = { 1733 methods = {
1723 "range": rangeset, 1734 "range": rangeset,
1724 "dagrange": dagrange, 1735 "dagrange": dagrange,
2021 if l == 0: 2032 if l == 0:
2022 return "_list('')" 2033 return "_list('')"
2023 elif l == 1: 2034 elif l == 1:
2024 return argtype(t, s[0]) 2035 return argtype(t, s[0])
2025 elif t == 'd': 2036 elif t == 'd':
2026 return "_list('%s')" % "\0".join(str(int(a)) for a in s) 2037 return "_intlist('%s')" % "\0".join(str(int(a)) for a in s)
2027 elif t == 's': 2038 elif t == 's':
2028 return "_list('%s')" % "\0".join(s) 2039 return "_list('%s')" % "\0".join(s)
2029 elif t == 'n': 2040 elif t == 'n':
2030 return "_list('%s')" % "\0".join(node.hex(a) for a in s) 2041 return "_list('%s')" % "\0".join(node.hex(a) for a in s)
2031 elif t == 'b': 2042 elif t == 'b':