mercurial/revset.py
changeset 22944 5aae3dea8044
parent 22891 5f5d6db79f31
child 22995 2587631c5f8a
equal deleted inserted replaced
22943:117e81871113 22944:5aae3dea8044
   341     if anc is not None and anc.rev() in subset:
   341     if anc is not None and anc.rev() in subset:
   342         return baseset([anc.rev()])
   342         return baseset([anc.rev()])
   343     return baseset()
   343     return baseset()
   344 
   344 
   345 def _ancestors(repo, subset, x, followfirst=False):
   345 def _ancestors(repo, subset, x, followfirst=False):
   346     args = getset(repo, spanset(repo), x)
   346     heads = getset(repo, spanset(repo), x)
   347     if not args:
   347     if not heads:
   348         return baseset()
   348         return baseset()
   349     s = _revancestors(repo, args, followfirst)
   349     s = _revancestors(repo, heads, followfirst)
   350     return subset.filter(s.__contains__)
   350     return subset.filter(s.__contains__)
   351 
   351 
   352 def ancestors(repo, subset, x):
   352 def ancestors(repo, subset, x):
   353     """``ancestors(set)``
   353     """``ancestors(set)``
   354     Changesets that are ancestors of a changeset in set.
   354     Changesets that are ancestors of a changeset in set.
   654         return ds in encoding.lower(c.description())
   654         return ds in encoding.lower(c.description())
   655 
   655 
   656     return subset.filter(matches)
   656     return subset.filter(matches)
   657 
   657 
   658 def _descendants(repo, subset, x, followfirst=False):
   658 def _descendants(repo, subset, x, followfirst=False):
   659     args = getset(repo, spanset(repo), x)
   659     roots = getset(repo, spanset(repo), x)
   660     if not args:
   660     if not roots:
   661         return baseset()
   661         return baseset()
   662     s = _revdescendants(repo, args, followfirst)
   662     s = _revdescendants(repo, roots, followfirst)
   663 
   663 
   664     # Both sets need to be ascending in order to lazily return the union
   664     # Both sets need to be ascending in order to lazily return the union
   665     # in the correct order.
   665     # in the correct order.
   666     base = subset & args
   666     base = subset & roots
   667     desc = subset & s
   667     desc = subset & s
   668     result = base + desc
   668     result = base + desc
   669     if subset.isascending():
   669     if subset.isascending():
   670         result.sort()
   670         result.sort()
   671     elif subset.isdescending():
   671     elif subset.isdescending():
   690     Changesets that were created by a graft, transplant or rebase operation,
   690     Changesets that were created by a graft, transplant or rebase operation,
   691     with the given revisions specified as the source.  Omitting the optional set
   691     with the given revisions specified as the source.  Omitting the optional set
   692     is the same as passing all().
   692     is the same as passing all().
   693     """
   693     """
   694     if x is not None:
   694     if x is not None:
   695         args = getset(repo, spanset(repo), x)
   695         sources = getset(repo, spanset(repo), x)
   696     else:
   696     else:
   697         args = getall(repo, spanset(repo), x)
   697         sources = getall(repo, spanset(repo), x)
   698 
   698 
   699     dests = set()
   699     dests = set()
   700 
   700 
   701     # subset contains all of the possible destinations that can be returned, so
   701     # subset contains all of the possible destinations that can be returned, so
   702     # iterate over them and see if their source(s) were provided in the args.
   702     # iterate over them and see if their source(s) were provided in the arg set.
   703     # Even if the immediate src of r is not in the args, src's source (or
   703     # Even if the immediate src of r is not in the arg set, src's source (or
   704     # further back) may be.  Scanning back further than the immediate src allows
   704     # further back) may be.  Scanning back further than the immediate src allows
   705     # transitive transplants and rebases to yield the same results as transitive
   705     # transitive transplants and rebases to yield the same results as transitive
   706     # grafts.
   706     # grafts.
   707     for r in subset:
   707     for r in subset:
   708         src = _getrevsource(repo, r)
   708         src = _getrevsource(repo, r)
   718             # set.  Since every candidate dest is visited by way of iterating
   718             # set.  Since every candidate dest is visited by way of iterating
   719             # subset, any dests further back in the lineage will be tested by a
   719             # subset, any dests further back in the lineage will be tested by a
   720             # different iteration over subset.  Likewise, if the src was already
   720             # different iteration over subset.  Likewise, if the src was already
   721             # selected, the current lineage can be selected without going back
   721             # selected, the current lineage can be selected without going back
   722             # further.
   722             # further.
   723             if src in args or src in dests:
   723             if src in sources or src in dests:
   724                 dests.update(lineage)
   724                 dests.update(lineage)
   725                 break
   725                 break
   726 
   726 
   727             r = src
   727             r = src
   728             src = _getrevsource(repo, r)
   728             src = _getrevsource(repo, r)
  1149     same as passing all().  If a changeset created by these operations is itself
  1149     same as passing all().  If a changeset created by these operations is itself
  1150     specified as a source for one of these operations, only the source changeset
  1150     specified as a source for one of these operations, only the source changeset
  1151     for the first operation is selected.
  1151     for the first operation is selected.
  1152     """
  1152     """
  1153     if x is not None:
  1153     if x is not None:
  1154         args = getset(repo, spanset(repo), x)
  1154         dests = getset(repo, spanset(repo), x)
  1155     else:
  1155     else:
  1156         args = getall(repo, spanset(repo), x)
  1156         dests = getall(repo, spanset(repo), x)
  1157 
  1157 
  1158     def _firstsrc(rev):
  1158     def _firstsrc(rev):
  1159         src = _getrevsource(repo, rev)
  1159         src = _getrevsource(repo, rev)
  1160         if src is None:
  1160         if src is None:
  1161             return None
  1161             return None
  1165 
  1165 
  1166             if prev is None:
  1166             if prev is None:
  1167                 return src
  1167                 return src
  1168             src = prev
  1168             src = prev
  1169 
  1169 
  1170     o = set([_firstsrc(r) for r in args])
  1170     o = set([_firstsrc(r) for r in dests])
  1171     o -= set([None])
  1171     o -= set([None])
  1172     return subset & o
  1172     return subset & o
  1173 
  1173 
  1174 def outgoing(repo, subset, x):
  1174 def outgoing(repo, subset, x):
  1175     """``outgoing([path])``
  1175     """``outgoing([path])``