Patchwork [V2] graph: support the branch grouping experiment from mercurial core

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 22, 2014, 11:40 p.m.
Message ID <3e89da86b45922fd4c33.1419291651@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/7201/
State Not Applicable
Headers show

Comments

Pierre-Yves David - Dec. 22, 2014, 11:40 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1412190676 18000
#      Wed Oct 01 14:11:16 2014 -0500
# Node ID 3e89da86b45922fd4c338b902ae7b56b7c8112dc
# Parent  b31d00b4f989f8bce28c92c319e05e06c4024376
graph: support the branch grouping experiment from mercurial core

Mercurial now have some experimental feature to display node of the graph branch
by branch. This patch add the small logic necessary to honor the config option
to opt in this experiment.

I've been using it for two months without major bug (some issue with the
"source" graph, but nothing major).
Pierre-Yves David - Dec. 22, 2014, 11:43 p.m.
On 12/22/2014 03:40 PM, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1412190676 18000
> #      Wed Oct 01 14:11:16 2014 -0500
> # Node ID 3e89da86b45922fd4c338b902ae7b56b7c8112dc
> # Parent  b31d00b4f989f8bce28c92c319e05e06c4024376
> graph: support the branch grouping experiment from mercurial core

gah, meant for thg. The all version of the faulty alias have been 
definitely nuked.

Patch

diff --git a/tortoisehg/hgqt/graph.py b/tortoisehg/hgqt/graph.py
--- a/tortoisehg/hgqt/graph.py
+++ b/tortoisehg/hgqt/graph.py
@@ -217,10 +217,17 @@  import os
 import itertools
 import collections
 
 from mercurial import revset as revsetmod
 from mercurial import phases
+try:
+    from mercurial.graphmod import groupbranchiter
+except ImportError:
+    # for hg<3.3
+    def groupbranchiter(revs, *args, **kwargs):
+        """dummy function doing nothing for old version"""
+        return revs
 
 from tortoisehg.util import obsoleteutil
 
 LINE_TYPE_PARENT = 0
 LINE_TYPE_FAMILY = 1
@@ -279,11 +286,24 @@  class StandardDag(object):
         curr_rev = self.start_rev
         if curr_rev is None:
             if visiblerev(curr_rev):
                 yield repo[curr_rev]
             curr_rev = len(repo) - 1
-        for curr_rev in revsetmod.spanset(repo, curr_rev, stop_rev - 1):
+        revs = revsetmod.spanset(repo, curr_rev, stop_rev - 1)
+        # jump in the branch grouping graph experiment if the user subscribed
+        if repo.ui.configbool('experimental', 'graph-group-branches', False):
+            revs = list(groupbranchiter(revs, repo.changelog.parentrevs))
+            firstbranch = ()
+            firstbranchrevset = repo.ui.config('experimental',
+                                               'graph-group-branches.firstbranch',
+                                               '')
+            if firstbranchrevset:
+                firstbranch = repo.revs(firstbranchrevset)
+            parentrevs = repo.changelog.parentrevs
+            revs = list(groupbranchiter(revs, parentrevs, firstbranch))
+
+        for curr_rev in revs:
             if visiblerev(curr_rev):
                 yield repo[curr_rev]
 
     def _append_graft_source(self, ctx, parents):
         src_rev_str = ctx.extra().get('source')