1. Yuya Nishihara
  2. thg-qt-mq

Commits

Yuya Nishihara  committed 58bc304

fin

  • Participants
  • Parent commits 26c26c8
  • Branches default

Comments (0)

Files changed (4)

File graph-color-class.diff

  • Ignore whitespace
-# HG changeset patch
-# Date 1373196628 -32400
-# Parent 1f81c8657de61ce12696f82d28abe2d9944d6809
-graph: extract code to build color table into class (refs #2559)
-
-diff --git a/tortoisehg/hgqt/graph.py b/tortoisehg/hgqt/graph.py
---- a/tortoisehg/hgqt/graph.py
-+++ b/tortoisehg/hgqt/graph.py
-@@ -87,8 +87,6 @@ def revision_grapher(repo, **opts):
-     revs = []
-     children = [()]
-     links = [] # smallest link type that applies
--    rev_color = {}
--    nextcolor = 0
- 
-     if opts.get('allparents') or not branch:
-         def getparents(ctx):
-@@ -98,6 +96,8 @@ def revision_grapher(repo, **opts):
-             return [x for x in ctx.parents()
-                     if x and x.branch() == branch]
- 
-+    rev_color = RevColorPalette(getparents, stop_rev)
-+
-     while curr_rev is None or curr_rev >= stop_rev:
-         if hidden(curr_rev):
-             curr_rev -= 1
-@@ -120,17 +120,8 @@ def revision_grapher(repo, **opts):
-                 continue
-             revs.append(curr_rev)
-             links.append(LINE_TYPE_PARENT)
--            rev_color[curr_rev] = curcolor = nextcolor
-             children.append(())
--            nextcolor += 1
--            p_ctxs = getparents(ctx)
--            while p_ctxs:
--                ctx0 = p_ctxs[0]
--                rev0 = ctx0.rev()
--                if rev0 < stop_rev or rev0 in rev_color:
--                    break
--                rev_color[rev0] = curcolor
--                p_ctxs = getparents(ctx0)
-+            rev_color.addheadctx(ctx)
-         curcolor = rev_color[curr_rev]
-         rev_index = revs.index(curr_rev)
-         next_revs = revs[:]
-@@ -159,12 +150,8 @@ def revision_grapher(repo, **opts):
-                 links_to_add.append(link_type)
-                 children_to_add.append((curr_rev,))
-                 if parent not in rev_color:
--                    if preferred_color:
--                        rev_color[parent] = preferred_color
--                        preferred_color = None
--                    else:
--                        rev_color[parent] = nextcolor
--                        nextcolor += 1
-+                    rev_color.assigncolor(parent, preferred_color)
-+                    preferred_color = None
-             else:
-                 # Merging lines should have the most solid style
-                 #  (= lowest style value)
-@@ -281,6 +268,39 @@ def mq_patch_grapher(repo):
-     for patchname in reversed(repo.thgmqunappliedpatches):
-         yield GraphNode(patchname, 0, "", [], [])
- 
-+class RevColorPalette(object):
-+    """Assign node and line colors for each revision"""
-+
-+    def __init__(self, getparents, stoprev):
-+        self._getparents = getparents
-+        self._stoprev = stoprev
-+        self._knowncolors = {}
-+        self._nextcolor = 0
-+
-+    def addheadctx(self, ctx):
-+        self._knowncolors[ctx.rev()] = curcolor = self._nextcolor
-+        self._nextcolor += 1
-+        p_ctxs = self._getparents(ctx)
-+        while p_ctxs:
-+            ctx0 = p_ctxs[0]
-+            rev0 = ctx0.rev()
-+            if rev0 < self._stoprev or rev0 in self._knowncolors:
-+                break
-+            self._knowncolors[rev0] = curcolor
-+            p_ctxs = self._getparents(ctx0)
-+
-+    def assigncolor(self, rev, color=None):
-+        if color is None:
-+            color = self._nextcolor
-+            self._nextcolor += 1
-+        self._knowncolors[rev] = color
-+
-+    def __getitem__(self, rev):
-+        return self._knowncolors[rev]
-+
-+    def __contains__(self, rev):
-+        return rev in self._knowncolors
-+
- class GraphNode(object):
-     """
-     Simple class to encapsulate a hg node in the revision graph. Does

File graph-color-lazy.diff

  • Ignore whitespace
-# HG changeset patch
-# Date 1373196631 -32400
-# Parent 4cd8b0b1e158eabca8189f8dd1b19b6a66f1bbf7
-graph: build color table incrementally (fixes #2559)
-
-If branch filter is enabled, getparents() is very slow because it needs to
-read revlog entry. So revision_grapher should not look up all ancestors
-at once.
-
-Quick benchmark result:
-
-    # 301198 revisions in default branch
-    repo = hg.repository(ui.ui(), 'linux-2.6-hg')
-    grapher = graph.revision_grapher(repo, branch=...)
-    for i in xrange(100):
-        grapher.next()
-
-    branch=None (no filter):  2.6sec -> 0.6sec
-    branch='default'       : 10.9sec -> 0.7sec
-
-diff --git a/tortoisehg/hgqt/graph.py b/tortoisehg/hgqt/graph.py
---- a/tortoisehg/hgqt/graph.py
-+++ b/tortoisehg/hgqt/graph.py
-@@ -96,7 +96,7 @@ def revision_grapher(repo, **opts):
-             return [x for x in ctx.parents()
-                     if x and x.branch() == branch]
- 
--    rev_color = RevColorPalette(getparents, stop_rev)
-+    rev_color = RevColorPalette(getparents)
- 
-     while curr_rev is None or curr_rev >= stop_rev:
-         if hidden(curr_rev):
-@@ -271,34 +271,53 @@ def mq_patch_grapher(repo):
- class RevColorPalette(object):
-     """Assign node and line colors for each revision"""
- 
--    def __init__(self, getparents, stoprev):
-+    def __init__(self, getparents):
-         self._getparents = getparents
--        self._stoprev = stoprev
-+        self._pendingheads = []
-         self._knowncolors = {}
-         self._nextcolor = 0
- 
-     def addheadctx(self, ctx):
--        self._knowncolors[ctx.rev()] = curcolor = self._nextcolor
--        self._nextcolor += 1
-+        color = self.assigncolor(ctx.rev())
-         p_ctxs = self._getparents(ctx)
-+        self._pendingheads.append((p_ctxs, color))
-+
-+    def _fillpendingheads(self, stoprev):
-+        if stoprev is None:
-+            return  # avoid filling everything (int_rev < None is False)
-+
-+        nextpendingheads = []
-+        for p_ctxs, color in self._pendingheads:
-+            pending = self._fillancestors(p_ctxs, color, stoprev)
-+            if pending:
-+                nextpendingheads.append((pending, color))
-+        self._pendingheads = nextpendingheads
-+
-+    def _fillancestors(self, p_ctxs, curcolor, stoprev):
-         while p_ctxs:
-             ctx0 = p_ctxs[0]
-             rev0 = ctx0.rev()
--            if rev0 < self._stoprev or rev0 in self._knowncolors:
--                break
-+            if rev0 < stoprev:
-+                return p_ctxs
-+            if rev0 in self._knowncolors:
-+                return
-             self._knowncolors[rev0] = curcolor
-             p_ctxs = self._getparents(ctx0)
- 
-     def assigncolor(self, rev, color=None):
-+        self._fillpendingheads(rev)
-         if color is None:
-             color = self._nextcolor
-             self._nextcolor += 1
-         self._knowncolors[rev] = color
-+        return color
- 
-     def __getitem__(self, rev):
-+        self._fillpendingheads(rev)
-         return self._knowncolors[rev]
- 
-     def __contains__(self, rev):
-+        self._fillpendingheads(rev)
-         return rev in self._knowncolors
- 
- class GraphNode(object):

File graph-getparentsctx.diff

  • Ignore whitespace
-# HG changeset patch
-# Date 1373196625 -32400
-# Parent 5c3aceb889687fb535dbb513f75995e52d4d77db
-graph: make getparents return context object in place of integer revision
-
-This eliminates repo[rev0] lookup while building color table.
-
-diff --git a/tortoisehg/hgqt/graph.py b/tortoisehg/hgqt/graph.py
---- a/tortoisehg/hgqt/graph.py
-+++ b/tortoisehg/hgqt/graph.py
-@@ -92,10 +92,10 @@ def revision_grapher(repo, **opts):
- 
-     if opts.get('allparents') or not branch:
-         def getparents(ctx):
--            return [x.rev() for x in ctx.parents() if x]
-+            return [x for x in ctx.parents() if x]
-     else:
-         def getparents(ctx):
--            return [x.rev() for x in ctx.parents()
-+            return [x for x in ctx.parents()
-                     if x and x.branch() == branch]
- 
-     while curr_rev is None or curr_rev >= stop_rev:
-@@ -123,13 +123,14 @@ def revision_grapher(repo, **opts):
-             rev_color[curr_rev] = curcolor = nextcolor
-             children.append(())
-             nextcolor += 1
--            p_revs = getparents(ctx)
--            while p_revs:
--                rev0 = p_revs[0]
-+            p_ctxs = getparents(ctx)
-+            while p_ctxs:
-+                ctx0 = p_ctxs[0]
-+                rev0 = ctx0.rev()
-                 if rev0 < stop_rev or rev0 in rev_color:
-                     break
-                 rev_color[rev0] = curcolor
--                p_revs = getparents(repo[rev0])
-+                p_ctxs = getparents(ctx0)
-         curcolor = rev_color[curr_rev]
-         rev_index = revs.index(curr_rev)
-         next_revs = revs[:]
-@@ -137,8 +138,8 @@ def revision_grapher(repo, **opts):
-         next_children = children[:]
- 
-         # Add parents to next_revs.
--        parents = [(p, LINE_TYPE_PARENT) for p in getparents(ctx)
--                   if not hidden(p)]
-+        parents = [(p.rev(), LINE_TYPE_PARENT) for p in getparents(ctx)
-+                   if not hidden(p.rev())]
-         if 'source' in ctx.extra():
-             src_rev_str = ctx.extra()['source']
-             if src_rev_str in repo:

File series

View file
  • Ignore whitespace
 repoa-test-multiarg.diff
-graph-getparentsctx.diff
-graph-color-class.diff
-graph-color-lazy.diff
 commandbusy.diff
 console-inject.diff
 console-busyprompt.diff