mercurial/revset.py
branchstable
changeset 21217 2195ac506c6a
parent 21215 717ba2c3c9da
child 21283 b7f49b765241
equal deleted inserted replaced
21216:6d632cf8a811 21217:2195ac506c6a
   281 
   281 
   282 def dagrange(repo, subset, x, y):
   282 def dagrange(repo, subset, x, y):
   283     r = spanset(repo)
   283     r = spanset(repo)
   284     xs = _revsbetween(repo, getset(repo, r, x), getset(repo, r, y))
   284     xs = _revsbetween(repo, getset(repo, r, x), getset(repo, r, y))
   285     s = subset.set()
   285     s = subset.set()
   286     return xs.filter(lambda r: r in s)
   286     return xs.filter(s.__contains__)
   287 
   287 
   288 def andset(repo, subset, x, y):
   288 def andset(repo, subset, x, y):
   289     return getset(repo, getset(repo, subset, x), y)
   289     return getset(repo, getset(repo, subset, x), y)
   290 
   290 
   291 def orset(repo, subset, x, y):
   291 def orset(repo, subset, x, y):
   346 def _ancestors(repo, subset, x, followfirst=False):
   346 def _ancestors(repo, subset, x, followfirst=False):
   347     args = getset(repo, spanset(repo), x)
   347     args = getset(repo, spanset(repo), x)
   348     if not args:
   348     if not args:
   349         return baseset([])
   349         return baseset([])
   350     s = _revancestors(repo, args, followfirst)
   350     s = _revancestors(repo, args, followfirst)
   351     return subset.filter(lambda r: r in s)
   351     return subset.filter(s.__contains__)
   352 
   352 
   353 def ancestors(repo, subset, x):
   353 def ancestors(repo, subset, x):
   354     """``ancestors(set)``
   354     """``ancestors(set)``
   355     Changesets that are ancestors of a changeset in set.
   355     Changesets that are ancestors of a changeset in set.
   356     """
   356     """
   374     cl = repo.changelog
   374     cl = repo.changelog
   375     for r in getset(repo, baseset(cl), x):
   375     for r in getset(repo, baseset(cl), x):
   376         for i in range(n):
   376         for i in range(n):
   377             r = cl.parentrevs(r)[0]
   377             r = cl.parentrevs(r)[0]
   378         ps.add(r)
   378         ps.add(r)
   379     return subset.filter(lambda r: r in ps)
   379     return subset.filter(ps.__contains__)
   380 
   380 
   381 def author(repo, subset, x):
   381 def author(repo, subset, x):
   382     """``author(string)``
   382     """``author(string)``
   383     Alias for ``user(string)``.
   383     Alias for ``user(string)``.
   384     """
   384     """
   404             if not rev in descendants and not rev in include]
   404             if not rev in descendants and not rev in include]
   405     else:
   405     else:
   406         exclude = getset(repo, spanset(repo), args[1])
   406         exclude = getset(repo, spanset(repo), args[1])
   407 
   407 
   408     results = set(ancestormod.missingancestors(include, exclude, cl.parentrevs))
   408     results = set(ancestormod.missingancestors(include, exclude, cl.parentrevs))
   409     return lazyset(subset, lambda x: x in results)
   409     return lazyset(subset, results.__contains__)
   410 
   410 
   411 def bisect(repo, subset, x):
   411 def bisect(repo, subset, x):
   412     """``bisect(string)``
   412     """``bisect(string)``
   413     Changesets marked in the specified bisect status:
   413     Changesets marked in the specified bisect status:
   414 
   414 
   421     - ``current``            : the cset currently being bisected
   421     - ``current``            : the cset currently being bisected
   422     """
   422     """
   423     # i18n: "bisect" is a keyword
   423     # i18n: "bisect" is a keyword
   424     status = getstring(x, _("bisect requires a string")).lower()
   424     status = getstring(x, _("bisect requires a string")).lower()
   425     state = set(hbisect.get(repo, status))
   425     state = set(hbisect.get(repo, status))
   426     return subset.filter(lambda r: r in state)
   426     return subset.filter(state.__contains__)
   427 
   427 
   428 # Backward-compatibility
   428 # Backward-compatibility
   429 # - no help entry so that we do not advertise it any more
   429 # - no help entry so that we do not advertise it any more
   430 def bisected(repo, subset, x):
   430 def bisected(repo, subset, x):
   431     return bisect(repo, subset, x)
   431     return bisect(repo, subset, x)
   464                 bmrevs.add(repo[bmrev].rev())
   464                 bmrevs.add(repo[bmrev].rev())
   465             return subset & bmrevs
   465             return subset & bmrevs
   466 
   466 
   467     bms = set([repo[r].rev()
   467     bms = set([repo[r].rev()
   468                for r in repo._bookmarks.values()])
   468                for r in repo._bookmarks.values()])
   469     return subset.filter(lambda r: r in bms)
   469     return subset.filter(bms.__contains__)
   470 
   470 
   471 def branch(repo, subset, x):
   471 def branch(repo, subset, x):
   472     """``branch(string or set)``
   472     """``branch(string or set)``
   473     All changesets belonging to the given branch or the branches of the given
   473     All changesets belonging to the given branch or the branches of the given
   474     changesets.
   474     changesets.
   723                 break
   723                 break
   724 
   724 
   725             r = src
   725             r = src
   726             src = _getrevsource(repo, r)
   726             src = _getrevsource(repo, r)
   727 
   727 
   728     return subset.filter(lambda r: r in dests)
   728     return subset.filter(dests.__contains__)
   729 
   729 
   730 def divergent(repo, subset, x):
   730 def divergent(repo, subset, x):
   731     """``divergent()``
   731     """``divergent()``
   732     Final successors of changesets with an alternative set of final successors.
   732     Final successors of changesets with an alternative set of final successors.
   733     """
   733     """
   734     # i18n: "divergent" is a keyword
   734     # i18n: "divergent" is a keyword
   735     getargs(x, 0, 0, _("divergent takes no arguments"))
   735     getargs(x, 0, 0, _("divergent takes no arguments"))
   736     divergent = obsmod.getrevs(repo, 'divergent')
   736     divergent = obsmod.getrevs(repo, 'divergent')
   737     return subset.filter(lambda r: r in divergent)
   737     return subset.filter(divergent.__contains__)
   738 
   738 
   739 def draft(repo, subset, x):
   739 def draft(repo, subset, x):
   740     """``draft()``
   740     """``draft()``
   741     Changeset in draft phase."""
   741     Changeset in draft phase."""
   742     # i18n: "draft" is a keyword
   742     # i18n: "draft" is a keyword
   809             if m(f):
   809             if m(f):
   810                 fl = repo.file(f)
   810                 fl = repo.file(f)
   811                 for fr in fl:
   811                 for fr in fl:
   812                     s.add(fl.linkrev(fr))
   812                     s.add(fl.linkrev(fr))
   813 
   813 
   814     return subset.filter(lambda r: r in s)
   814     return subset.filter(s.__contains__)
   815 
   815 
   816 def first(repo, subset, x):
   816 def first(repo, subset, x):
   817     """``first(set, [n])``
   817     """``first(set, [n])``
   818     An alias for limit().
   818     An alias for limit().
   819     """
   819     """
   832         else:
   832         else:
   833             return baseset([])
   833             return baseset([])
   834     else:
   834     else:
   835         s = _revancestors(repo, baseset([c.rev()]), followfirst)
   835         s = _revancestors(repo, baseset([c.rev()]), followfirst)
   836 
   836 
   837     return subset.filter(lambda r: r in s)
   837     return subset.filter(s.__contains__)
   838 
   838 
   839 def follow(repo, subset, x):
   839 def follow(repo, subset, x):
   840     """``follow([file])``
   840     """``follow([file])``
   841     An alias for ``::.`` (ancestors of the working copy's first parent).
   841     An alias for ``::.`` (ancestors of the working copy's first parent).
   842     If a filename is specified, the history of the given file is followed,
   842     If a filename is specified, the history of the given file is followed,
  1174             if prev is None:
  1174             if prev is None:
  1175                 return src
  1175                 return src
  1176             src = prev
  1176             src = prev
  1177 
  1177 
  1178     o = set([_firstsrc(r) for r in args])
  1178     o = set([_firstsrc(r) for r in args])
  1179     return subset.filter(lambda r: r in o)
  1179     return subset.filter(o.__contains__)
  1180 
  1180 
  1181 def outgoing(repo, subset, x):
  1181 def outgoing(repo, subset, x):
  1182     """``outgoing([path])``
  1182     """``outgoing([path])``
  1183     Changesets not found in the specified destination repository, or the
  1183     Changesets not found in the specified destination repository, or the
  1184     default push location.
  1184     default push location.
  1197     repo.ui.pushbuffer()
  1197     repo.ui.pushbuffer()
  1198     outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs)
  1198     outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs)
  1199     repo.ui.popbuffer()
  1199     repo.ui.popbuffer()
  1200     cl = repo.changelog
  1200     cl = repo.changelog
  1201     o = set([cl.rev(r) for r in outgoing.missing])
  1201     o = set([cl.rev(r) for r in outgoing.missing])
  1202     return subset.filter(lambda r: r in o)
  1202     return subset.filter(o.__contains__)
  1203 
  1203 
  1204 def p1(repo, subset, x):
  1204 def p1(repo, subset, x):
  1205     """``p1([set])``
  1205     """``p1([set])``
  1206     First parent of changesets in set, or the working directory.
  1206     First parent of changesets in set, or the working directory.
  1207     """
  1207     """