mercurial/revset.py
changeset 25929 289149111d46
parent 25927 44da63623fca
child 25971 e9cd028f2dff
equal deleted inserted replaced
25928:4ee4f7415095 25929:289149111d46
   404 
   404 
   405 def andset(repo, subset, x, y):
   405 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)
   414 
   419 
   415 def listset(repo, subset, a, b):
   420 def listset(repo, subset, a, b):
  3105             return x
  3110             return x
  3106 
  3111 
  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 
  3127     The ascending is used to indicated the iteration direction.
  3118     The ascending is used to indicated the iteration direction.
  3128     """
  3119     """