Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 16174:0a73c4bd9f47
graphlog: implement --follow-first
log --graph --follow-first FILE cannot be compared with the regular version
because it never worked: --follow-first is not taken in account in
walkchangerevs() fast path and is explicitely bypassed in FILE case in
walkchangerevs() nested iterate() function.
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Sat, 25 Feb 2012 22:11:36 +0100 |
parents | 5a627b49b4d9 |
children | 1fd352aa08fc |
comparison
equal
deleted
inserted
replaced
16173:9178d284b880 | 16174:0a73c4bd9f47 |
---|---|
463 s = set(repo.changelog.ancestors(c.rev())) | 463 s = set(repo.changelog.ancestors(c.rev())) |
464 s.add(c.rev()) | 464 s.add(c.rev()) |
465 | 465 |
466 return [r for r in subset if r in s] | 466 return [r for r in subset if r in s] |
467 | 467 |
468 def _followfirst(repo, subset, x): | |
469 # ``followfirst([file])`` | |
470 # Like ``follow([file])`` but follows only the first parent of | |
471 # every revision or file revision. | |
472 # i18n: "_followfirst" is a keyword | |
473 l = getargs(x, 0, 1, _("_followfirst takes no arguments or a filename")) | |
474 c = repo['.'] | |
475 if l: | |
476 x = getstring(l[0], _("_followfirst expected a filename")) | |
477 if x not in c: | |
478 return [] | |
479 cx = c[x] | |
480 visit = {} | |
481 s = set([cx.linkrev()]) | |
482 while True: | |
483 for p in cx.parents()[:1]: | |
484 visit[(p.rev(), p.node())] = p | |
485 if not visit: | |
486 break | |
487 cx = visit.pop(max(visit)) | |
488 s.add(cx.rev()) | |
489 else: | |
490 cl = repo.changelog | |
491 s = set() | |
492 visit = [c.rev()] | |
493 while visit: | |
494 for prev in cl.parentrevs(visit.pop(0))[:1]: | |
495 if prev not in s and prev != nodemod.nullrev: | |
496 visit.append(prev) | |
497 s.add(prev) | |
498 s.add(c.rev()) | |
499 | |
500 return [r for r in subset if r in s] | |
501 | |
468 def getall(repo, subset, x): | 502 def getall(repo, subset, x): |
469 """``all()`` | 503 """``all()`` |
470 All changesets, the same as ``0:tip``. | 504 All changesets, the same as ``0:tip``. |
471 """ | 505 """ |
472 # i18n: "all" is a keyword | 506 # i18n: "all" is a keyword |
963 "draft": draft, | 997 "draft": draft, |
964 "file": hasfile, | 998 "file": hasfile, |
965 "filelog": filelog, | 999 "filelog": filelog, |
966 "first": first, | 1000 "first": first, |
967 "follow": follow, | 1001 "follow": follow, |
1002 "_followfirst": _followfirst, | |
968 "grep": grep, | 1003 "grep": grep, |
969 "head": head, | 1004 "head": head, |
970 "heads": heads, | 1005 "heads": heads, |
971 "id": node, | 1006 "id": node, |
972 "keyword": keyword, | 1007 "keyword": keyword, |