Comments
Patch
@@ -22,11 +22,11 @@ import util
import heapq
CHANGESET = 'C'
-def groupbranchiter(revs, parentsfunc):
+def groupbranchiter(revs, parentsfunc, firstbranch=()):
"""yield revision from heads to roots one (topo) branch after the other.
This function aims at being used by graph generator that wish to minimise
the amount of parallel branches and their interleaving.
@@ -42,12 +42,12 @@ def groupbranchiter(revs, parentsfunc):
|/
o 0
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."""
### Quick summary of the algorithm
#
# This function is based around a "retention" principle. We keep revisions
# in memory until we are ready to emit a whole branch that immediately
# "merge" into an existing one. This reduce the number of branch "ongoing"
@@ -76,11 +76,15 @@ def groupbranchiter(revs, parentsfunc):
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()
+ #
+ # If someone wants to prioritize a branch over the others, pre-filling this
+ # set will force all other branches 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 'revs')
@@ -222,11 +226,17 @@ def dagwalker(repo, revs):
cl = repo.changelog
lowestrev = revs.min()
gpcache = {}
if repo.ui.configbool('experimental', 'graph-topological', False):
- revs = list(groupbranchiter(revs, repo.changelog.parentrevs))
+ firstbranch = ()
+ firstbranchrevset = repo.ui.config('experimental',
+ 'graph-topological.firstbranch', '')
+ if firstbranchrevset:
+ firstbranch = repo.revs(firstbranchrevset)
+ parentrevs = repo.changelog.parentrevs
+ revs = list(groupbranchiter(revs, 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
+