##// END OF EJS Templates
revset: make balanced addsets by orset() without using _combinesets()...
Yuya Nishihara -
r25929:28914911 default
parent child Browse files
Show More
@@ -406,8 +406,13 b' def andset(repo, subset, x, y):'
406 return getset(repo, getset(repo, subset, x), y)
406 return getset(repo, getset(repo, subset, x), y)
407
407
408 def orset(repo, subset, *xs):
408 def orset(repo, subset, *xs):
409 rs = [getset(repo, subset, x) for x in xs]
409 assert xs
410 return _combinesets(rs)
410 if len(xs) == 1:
411 return getset(repo, subset, xs[0])
412 p = len(xs) // 2
413 a = orset(repo, subset, *xs[:p])
414 b = orset(repo, subset, *xs[p:])
415 return a + b
411
416
412 def notset(repo, subset, x):
417 def notset(repo, subset, x):
413 return subset - getset(repo, subset, x)
418 return subset - getset(repo, subset, x)
@@ -3107,20 +3112,6 b' class filteredset(abstractsmartset):'
3107 def __repr__(self):
3112 def __repr__(self):
3108 return '<%s %r>' % (type(self).__name__, self._subset)
3113 return '<%s %r>' % (type(self).__name__, self._subset)
3109
3114
3110 # this function will be removed, or merged to addset or orset, when
3111 # - scmutil.revrange() can be rewritten to not combine calculated smartsets
3112 # - or addset can handle more than two sets without balanced tree
3113 def _combinesets(subsets):
3114 """Create balanced tree of addsets representing union of given sets"""
3115 if not subsets:
3116 return baseset()
3117 if len(subsets) == 1:
3118 return subsets[0]
3119 p = len(subsets) // 2
3120 xs = _combinesets(subsets[:p])
3121 ys = _combinesets(subsets[p:])
3122 return addset(xs, ys)
3123
3124 def _iterordered(ascending, iter1, iter2):
3115 def _iterordered(ascending, iter1, iter2):
3125 """produce an ordered iteration from two iterators with the same order
3116 """produce an ordered iteration from two iterators with the same order
3126
3117
General Comments 0
You need to be logged in to leave comments. Login now