Mercurial > hg
diff mercurial/graphmod.py @ 23568:740ae54573a3
groupbranchiter: allow callers to select the first branch
Instead of just bootstrapping the algorithm with the first revision we
see, allow callers to pass revs that should be displayed first. All
branches are retained until we can display such revision.
Expected usage is to display the current working copy parent first.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 04 Sep 2014 19:28:17 +0200 |
parents | 1f080c9c6a35 |
children | 3ecbcffdeb0c |
line wrap: on
line diff
--- a/mercurial/graphmod.py Thu Sep 04 19:05:36 2014 +0200 +++ b/mercurial/graphmod.py Thu Sep 04 19:28:17 2014 +0200 @@ -24,7 +24,7 @@ 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 to be used by a graph generator that wishes to minimize @@ -44,8 +44,8 @@ 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 @@ -78,7 +78,11 @@ # 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: # @@ -224,7 +228,13 @@ 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]