Comments
Patch
@@ -22,18 +22,16 @@ import util
import heapq
CHANGESET = 'C'
-def topoiter(revs, parentsfunc):
+def topoiter(revs, parentsfunc, firstbranch=()):
"""topologically iter over a set of revision, one branch at a time.
Currently consider every changeset under a merge to be on the same branch
using revision number to sort them.
- Could be easily extend to give priority to an initial branch.
-
The revision are emitted heads to roots."""
### Quick summary of the algorithm
#
# This function is based around a "retention" principle. We keep revision
# in memory until we are ready to emit a whole branch that immediately
@@ -59,14 +57,20 @@ def topoiter(revs, parentsfunc):
#
# To bootstrap the algorithm, we display the first revision we saw.
revs.sort(reverse=True)
- # set of parents of revision that have been yield. They can be considered
- # unblocked as the graph generator is already aware of them so there is no
- # need to delay the one that reference them.
- unblocked = set()
+ # set of revision whose children should be considered read to be outputed:
+ #
+ # This is filled with the set of parents of revision that have been yield.
+ # They can be considered unblocked as the graph generator is already aware
+ # of them so there is no need to delay the one that reference them.
+ #
+ # if someone wants to prioritize a branch over the others, pre-filling this
+ # set will force all other branch to wait until this branch is ready to be
+ # outputed.
+ unblocked = set(firstbranch)
# list of group waiting to be displayed, each group is defined by:
#
# (revs: lists of revs waiting to be displayed,
# blocked: set of that cannot be displayed before those in the sets)
@@ -212,11 +216,16 @@ def dagwalker(repo, revs):
cl = repo.changelog
lowestrev = revs.min()
gpcache = {}
if repo.ui.configbool('experimental', 'graph-topological', False):
- revs = list(topoiter(revs, repo.changelog.parentrevs))
+ firstbranch = ()
+ firstbranchrevset = repo.ui.config('experimental',
+ 'graph-topological.firstbranch', '')
+ if firstbranchrevset:
+ firstbranch = repo.revs(firstbranchrevset)
+ revs = list(topoiter(revs, repo.changelog.parentrevs, firstbranch))
for rev in revs:
ctx = repo[rev]
parents = sorted(set([p.rev() for p in ctx.parents()
if p.rev() in revs]))
@@ -76,5 +76,26 @@ later.
| o 4
|/
o 0
+(begin) from the other branch
+
+ $ hg --config experimental.graph-topological=1 --config experimental.graph-topological.firstbranch=5 log -G
+ o 7
+ |
+ o 6
+ |
+ o 5
+ |
+ o 4
+ |
+ | o 8
+ | |
+ | o 3
+ | |
+ | o 2
+ | |
+ | o 1
+ |/
+ o 0
+