Mercurial > evolve
diff hgext3rd/evolve/obshistory.py @ 2484:262d684851dc
obshistory: add the all option to obslog to show the while obs tree
Add a --all option to obslog in order to display also the successors of each
obs markers. It has the effect of showing a more comprehensive graph when a
split or a divergence happened.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Tue, 23 May 2017 19:48:04 +0200 |
parents | 08c552a5eb37 |
children | 1bdbe8f55339 |
line wrap: on
line diff
--- a/hgext3rd/evolve/obshistory.py Fri May 26 16:12:07 2017 +0200 +++ b/hgext3rd/evolve/obshistory.py Tue May 23 19:48:04 2017 +0200 @@ -28,7 +28,8 @@ @eh.command( 'obslog|olog', [('G', 'graph', True, _("show the revision DAG")), - ('r', 'rev', [], _('show the specified revision or revset'), _('REV')) + ('r', 'rev', [], _('show the specified revision or revset'), _('REV')), + ('a', 'all', False, _('show all related changesets, not only precursors')) ] + commands.formatteropts, _('hg olog [OPTION]... [REV]')) def cmdobshistory(ui, repo, *revs, **opts): @@ -158,14 +159,14 @@ stack.pop() return False -def _obshistorywalker(repo, revs): +def _obshistorywalker(repo, revs, walksuccessors=False): """ Directly inspired by graphmod.dagwalker, walk the obs marker tree and yield (id, CHANGESET, ctx, [parentinfo]) tuples """ # Get the list of nodes and links between them - candidates, nodesucc, nodeprec = _obshistorywalker_links(repo, revs) + candidates, nodesucc, nodeprec = _obshistorywalker_links(repo, revs, walksuccessors) # Shown, set of nodes presents in items shown = set() @@ -216,15 +217,19 @@ childrens = [(graphmod.PARENT, x) for x in nodeprec.get(cand, ())] yield (cand, 'M', changectx, childrens) -def _obshistorywalker_links(repo, revs): +def _obshistorywalker_links(repo, revs, walksuccessors=False): """ Iterate the obs history tree starting from revs, traversing each revision precursors recursively. + If walksuccessors is True, also check that every successor has been + walked, which ends up walking on all connected obs markers. It helps + getting a better view with splits and divergences. Return a tuple of: - The list of node crossed - The dictionnary of each node successors, values are a set - The dictionnary of each node precursors, values are a list """ precursors = repo.obsstore.precursors + successors = repo.obsstore.successors nodec = repo.changelog.node # Parents, set of parents nodes seen during walking the graph for node @@ -257,12 +262,21 @@ seen.add(precnode) nodes.append(precnode) + # Also walk on successors if the option is enabled + if walksuccessors: + for successor in successors.get(node, ()): + for succnodeid in successor[1]: + if succnodeid not in seen: + seen.add(succnodeid) + nodes.append(succnodeid) + return sorted(seen), nodesucc, nodeprec def _debugobshistorygraph(ui, repo, revs, opts): displayer = obsmarker_printer(ui, repo.unfiltered(), None, opts, buffered=True) edges = graphmod.asciiedges - cmdutil.displaygraph(ui, repo, _obshistorywalker(repo.unfiltered(), revs), displayer, edges) + walker = _obshistorywalker(repo.unfiltered(), revs, opts.get('all', False)) + cmdutil.displaygraph(ui, repo, walker, displayer, edges) def _debugobshistorysingle(fm, repo, revs): """ Display the obsolescence history for a single revision