Mercurial > hg
comparison mercurial/revset.py @ 17753:69d5078d760d
revsets: add branchpoint() function
The branchpoint() function returns changesets with more than one child.
Eventually I would like to be able to see only branch points and merge
points in a graphical log to see the topology of the repository.
author | Ivan Andrus <darthandrus@gmail.com> |
---|---|
date | Mon, 13 Aug 2012 21:50:45 +0200 |
parents | 8575f4a2126e |
children | ac5c9c8046f7 |
comparison
equal
deleted
inserted
replaced
17752:76b73ce0ffac | 17753:69d5078d760d |
---|---|
916 # i18n: "merge" is a keyword | 916 # i18n: "merge" is a keyword |
917 getargs(x, 0, 0, _("merge takes no arguments")) | 917 getargs(x, 0, 0, _("merge takes no arguments")) |
918 cl = repo.changelog | 918 cl = repo.changelog |
919 return [r for r in subset if cl.parentrevs(r)[1] != -1] | 919 return [r for r in subset if cl.parentrevs(r)[1] != -1] |
920 | 920 |
921 def branchpoint(repo, subset, x): | |
922 """``branchpoint()`` | |
923 Changesets with more than one child. | |
924 """ | |
925 # i18n: "branchpoint" is a keyword | |
926 getargs(x, 0, 0, _("branchpoint takes no arguments")) | |
927 cl = repo.changelog | |
928 if not subset: | |
929 return [] | |
930 baserev = min(subset) | |
931 parentscount = [0]*(len(repo) - baserev) | |
932 for r in xrange(baserev + 1, len(repo)): | |
933 for p in cl.parentrevs(r): | |
934 if p >= baserev: | |
935 parentscount[p - baserev] += 1 | |
936 branchpoints = set((baserev + i) for i in xrange(len(parentscount)) | |
937 if parentscount[i] > 1) | |
938 return [r for r in subset if r in branchpoints] | |
939 | |
921 def minrev(repo, subset, x): | 940 def minrev(repo, subset, x): |
922 """``min(set)`` | 941 """``min(set)`` |
923 Changeset with lowest revision number in set. | 942 Changeset with lowest revision number in set. |
924 """ | 943 """ |
925 os = getset(repo, list(repo), x) | 944 os = getset(repo, list(repo), x) |
1472 "author": author, | 1491 "author": author, |
1473 "bisect": bisect, | 1492 "bisect": bisect, |
1474 "bisected": bisected, | 1493 "bisected": bisected, |
1475 "bookmark": bookmark, | 1494 "bookmark": bookmark, |
1476 "branch": branch, | 1495 "branch": branch, |
1496 "branchpoint": branchpoint, | |
1477 "children": children, | 1497 "children": children, |
1478 "closed": closed, | 1498 "closed": closed, |
1479 "contains": contains, | 1499 "contains": contains, |
1480 "converted": converted, | 1500 "converted": converted, |
1481 "date": date, | 1501 "date": date, |