comparison mercurial/revset.py @ 25341:9d6cc87bd507

revset: make internal _list() expression remove duplicated revisions This allows us to optimize chained 'or' operations to _list() expression. Unlike _intlist() or _hexlist(), it's difficult to remove duplicates by the caller of _list() because different symbols can point to the same revision. If the caller knows all symbols are unique, that probably means revisions or nodes are known, therefore, _intlist() or _hexlist() should be used instead. So, it makes sense to check duplicates by _list() function. '%ls' is no longer used in core, this won't cause performance regression.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 24 May 2015 14:49:41 +0900
parents b333ca94403d
children 5dde117269b6
comparison
equal deleted inserted replaced
25340:28800ab40395 25341:9d6cc87bd507
1918 # for internal use 1918 # for internal use
1919 def _list(repo, subset, x): 1919 def _list(repo, subset, x):
1920 s = getstring(x, "internal error") 1920 s = getstring(x, "internal error")
1921 if not s: 1921 if not s:
1922 return baseset() 1922 return baseset()
1923 ls = [repo[r].rev() for r in s.split('\0')] 1923 # remove duplicates here. it's difficult for caller to deduplicate sets
1924 s = subset 1924 # because different symbols can point to the same rev.
1925 return baseset([r for r in ls if r in s]) 1925 ls = []
1926 seen = set()
1927 for t in s.split('\0'):
1928 r = repo[t].rev()
1929 if r in seen:
1930 continue
1931 if r in subset:
1932 ls.append(r)
1933 seen.add(r)
1934 return baseset(ls)
1926 1935
1927 # for internal use 1936 # for internal use
1928 def _intlist(repo, subset, x): 1937 def _intlist(repo, subset, x):
1929 s = getstring(x, "internal error") 1938 s = getstring(x, "internal error")
1930 if not s: 1939 if not s: