Commits

Yuya Nishihara  committed 74bab20 Merge

Merge with stable

  • Participants
  • Parent commits ca56001, 3990e5a

Comments (0)

Files changed (4)

File tests/graph_test.py

     setup_straightenedbyrevset()
     setup_bulkgraft()
     setup_commonedge()
+    setup_manyheads()
 
 def openrepo(name):
     return hg.repository(ui.ui(), os.path.join(_tmpdir, name))
     path = os.path.join(_tmpdir, name)
     helpers.buildgraph(path, graphtext)
 
-def buildlinecolortable(grapher):
-    table = {}  # rev: [linecolor, ...]
+def buildlinetable(grapher, predicate):
+    table = {}  # rev: [predicate(edge), ...
     for node in grapher:
         if not node:
             continue
         # draw overlapped lines in the same way as HgRepoListModel
-        ct = dict((p, e.color) for p, e
+        lt = dict((p, predicate(p, e)) for p, e
                   in sorted(node.bottomlines, key=lambda pe: pe[1].importance))
         # and sort them in (start, end) order
-        colors = [c for p, c in sorted(ct.iteritems(), key=lambda pc: pc[0])]
-        table[node.rev] = colors
+        lines = [l for p, l in sorted(lt.iteritems(), key=lambda pl: pl[0])]
+        table[node.rev] = lines
     return table
 
+def buildlinecolortable(grapher):
+    return buildlinetable(grapher, lambda p, e: e.color)
+
+def buildlinecolumntable(grapher):
+    linktypetags = {
+        graph.LINE_TYPE_PARENT: '',
+        graph.LINE_TYPE_GRAFT: 'G',
+        graph.LINE_TYPE_OBSOLETE: 'O',
+    }
+    def predicate(p, e):
+        return '%d-%d%s' % (p[0], p[1], linktypetags[e.linktype])
+    return buildlinetable(grapher, predicate)
+
 def setup_namedbranch():
     buildrepo('named-branch', r"""
         8
     5 [source=1]
     4
     | 3
-    | 2
+    | 2 [branch=foo]
     | 1
     |/
     0
         0: [],
         }
     assert_equal(expectedtable, actualtable)
+
+def setup_manyheads():
+    buildrepo('manyheads', r"""
+    7
+    |\  6
+    | |/
+    | 5 [branch=foo]
+    |/| 4 [branch=foo]
+    3 |/
+    | 2
+    |/
+    1
+    0
+    """)
+
+def test_grapher_noopt():
+    repo = openrepo('manyheads')
+    grapher = graph.revision_grapher(repo, {})
+    actualtable = buildlinecolumntable(grapher)
+    expectedtable = {
+                                        # wt
+        None : ['0-0'],                 # |
+                                        # 7
+        7 : ['0-0', '0-1'],             # |\
+                                        # | | 6
+        6 : ['0-0', '1-1', '2-1'],      # | |/
+                                        # | 5
+        5 : ['0-0', '1-0', '1-1'],      # |/|
+                                        # | | 4
+        4 : ['0-0', '1-1', '2-1'],      # | |/
+                                        # 3 |
+        3 : ['0-0', '1-1'],             # | |
+                                        # | 2
+        2 : ['0-0', '1-0'],             # |/
+                                        # 1
+        1 : ['0-0'],                    # |
+                                        # 0
+        0 : [],
+        }
+    assert_equal(expectedtable, actualtable)
+
+def test_grapher_branch_1():
+    repo = openrepo('manyheads')
+    grapher = graph.revision_grapher(repo, {'branch': 'default'})
+    actualtable = buildlinecolumntable(grapher)
+    expectedtable = {
+                                # wt
+        None: ['0-0'],          # |
+                                # 7
+        7: ['0-0'],             # |
+                                # 3
+        3: ['0-0'],             # |
+                                # | 2
+        2: ['0-0', '1-0'],      # |/
+                                # 1
+        1: ['0-0'],             # |
+                                # 0
+        0: [],
+        }
+    assert_equal(expectedtable, actualtable)
+
+def test_grapher_branch_2():
+    repo = openrepo('manyheads')
+    grapher = graph.revision_grapher(repo, {'branch': 'foo'})
+    actualtable = buildlinecolumntable(grapher)
+    expectedtable = {
+                        # 6
+        6 :['0-0'],     # |
+                        # 5
+        5 :[],          #
+                        # 4
+        4 :[],          #
+        }
+    assert_equal(expectedtable, actualtable)
+
+def test_grapher_branch_allparents_1():
+    repo = openrepo('manyheads')
+    grapher = graph.revision_grapher(
+            repo, {'branch': 'default', 'allparents': True})
+    actualtable = buildlinecolumntable(grapher)
+    expectedtable = {
+                                     # wt
+        None: ['0-0'],               # |
+                                     # 7
+        7: ['0-0', '0-1'],           # |\
+                                     # | 5
+        5: ['0-0', '1-0', '1-1'],    # |/|
+                                     # 3 |
+        3: ['0-0', '1-1'],           # | |
+                                     # | 2
+        2: ['0-0', '1-0'],           # |/
+                                     # 1
+        1: ['0-0'],                  # |
+                                     # 0
+        0: [],
+        }
+    assert_equal(expectedtable, actualtable)
+
+def test_grapher_branch_allparents_2():
+    repo = openrepo('manyheads')
+    grapher = graph.revision_grapher(
+            repo, {'branch': 'foo', 'allparents': True})
+    actualtable = buildlinecolumntable(grapher)
+    expectedtable = {
+                                     # 6
+        6: ['0-0'],                  # |
+                                     # 5
+        5: ['0-0', '0-1'],           # |\
+                                     # +---4
+        4: ['0-0', '1-1', '2-0'],    # | |
+                                     # | 3
+        3: ['0-0', '1-1'],           # | |
+                                     # 2 |
+        2: ['0-0', '1-0'],           # |/
+                                     # 1
+        1: ['0-0'],                  # |
+                                     # 0
+        0: [],
+        }
+    assert_equal(expectedtable, actualtable)
+
+def test_grapher_revset_1():
+    repo = openrepo('manyheads')
+    revset = set([7, 6, 5, 4, 3])
+    grapher = graph.revision_grapher(repo, {'revset': revset})
+    actualtable = buildlinecolumntable(grapher)
+    expectedtable = {
+                                    # 7
+        7: ['0-0', '0-1'],          # |\
+                                    # | | 6
+        6: ['0-0', '1-1', '2-1'],   # | |/
+                                    # | 5
+        5: ['0-0', '1-0'],          # |/
+                                    # | 4
+        4: ['0-0'],                 # |
+                                    # 3
+        3: [],
+        }
+    assert_equal(expectedtable, actualtable)
+
+def test_grapher_revset_2():
+    repo = openrepo('manyheads')
+    revset = set([5, 4, 3, 2, 1])
+    grapher = graph.revision_grapher(repo, {'revset': revset})
+    actualtable = buildlinecolumntable(grapher)
+    expectedtable = {
+                                    # 5
+        5: ['0-0', '0-1'],          # |\
+                                    # +---4
+        4: ['0-0', '1-1', '2-0'],   # | |
+                                    # | 3
+        3: ['0-0', '1-1'],          # | |
+                                    # 2 |
+        2: ['0-0', '1-0'],          # |/
+                                    # 1
+        1: [],
+        }
+    assert_equal(expectedtable, actualtable)
+
+def test_grapher_revset_3():
+    repo = openrepo('manyheads')
+    revset = set([7, 5, 3])
+    grapher = graph.revision_grapher(repo, {'revset': revset})
+    actualtable = buildlinecolumntable(grapher)
+    expectedtable = {
+                                    # 7
+        7: ['0-0', '0-1'],          # |\
+                                    # | 5
+        5: ['0-0', '1-0'],          # |/
+                                    # 3
+        3: [],                      #
+        }
+    assert_equal(expectedtable, actualtable)
+
+def test_grapher_showgraftsource():
+    repo = openrepo('bulkgraft')
+    grapher = graph.revision_grapher(repo, {"showgraftsource": True})
+    actualtable = buildlinecolumntable(grapher)
+    expectedtable = {
+                                            # wt
+        None: ['0-0'],                      # |
+                                            # 7
+        7: ['0-0', '0-1G'],                 # |\
+                                            # 6 .
+        6: ['0-0', '0-1G', '1-2G'],         # |\ \
+                                            # 5 . .
+        5: ['0-0', '0-1G', '1-2G', '2-3G'], # |\ \ \
+                                            # 4 : : :
+        4: ['0-0', '1-1G', '2-2G', '3-3G'], # | : : :
+                                            # | : : 3
+        3: ['0-0', '1-1G', '2-2G', '3-2'],  # | : :/
+                                            # | : 2
+        2: ['0-0', '1-1G', '2-1'],          # | :/
+                                            # | 1
+        1: ['0-0', '1-0'],                  # |/
+                                            # 0
+        0: [],
+    }
+    assert_equal(expectedtable, actualtable)
+
+def test_grapher_showgraftsource_with_branch():
+    repo = openrepo('bulkgraft')
+    grapher = graph.revision_grapher(
+        repo, {"showgraftsource": True, "branch": "default"})
+    actualtable = buildlinecolumntable(grapher)
+    expectedtable = {
+                            # wt
+        None: ['0-0'],      # |
+                            # 7
+        7: ['0-0'],         # |
+                            # 6
+        6: ['0-0'],         # |
+                            # 5
+        5: ['0-0', '0-1G'], # |\
+                            # 4 :
+        4: ['0-0', '1-1G'], # | :
+                            # | 1
+        1: ['0-0', '1-0'],  # |/
+                            # 0
+        0: [],
+    }
+    assert_equal(expectedtable, actualtable)
+
+def test_grapher_hidegraftsource():
+    repo = openrepo('bulkgraft')
+    grapher = graph.revision_grapher(repo, {})
+    actualtable = buildlinecolumntable(grapher)
+    expectedtable = {
+                            # wt
+        None: ['0-0'],      # |
+                            # 7
+        7: ['0-0'],         # |
+                            # 6
+        6: ['0-0'],         # |
+                            # 5
+        5: ['0-0'],         # |
+                            # 4
+        4: ['0-0'],         # |
+                            # | 3
+        3: ['0-0', '1-1'],  # | |
+                            # | 2
+        2: ['0-0', '1-1'],  # | |
+                            # | 1
+        1: ['0-0', '1-0'],  # |/
+                            # 0
+        0: [],
+    }
+    assert_equal(expectedtable, actualtable)

File tortoisehg/hgqt/commit.py

         linkmandatory = self.repo.ui.configbool('tortoisehg',
                                                 'issue.linkmandatory', False)
         if linkmandatory:
-            issueregex = self.repo.ui.config('tortoisehg', 'issue.regex')
+            issueregex = None
+            s = self.repo.ui.config('tortoisehg', 'issue.regex')
+            if s:
+                try:
+                    issueregex = re.compile(s)
+                except re.error:
+                    pass
             if issueregex:
-                m = re.search(issueregex, msg)
+                m = issueregex.search(msg)
                 if not m:
                     qtlib.WarningMsgBox(_('Nothing Committed'),
                                         _('No issue link was found in the '

File tortoisehg/hgqt/graph.py

     activeedges = []  # order is not important
 
     if opts.get('allparents') or not branch:
-        def getparents(ctx):
-            return [x for x in ctx.parents() if x]
+        def hiddenctx(ctx):
+            return not ctx
     else:
-        def getparents(ctx):
-            return [x for x in ctx.parents()
-                    if x and x.branch() == branch]
+        def hiddenctx(ctx):
+            return not ctx or ctx.branch() != branch
+
+    def getparents(ctx):
+        return [x for x in ctx.parents() if not hiddenctx(x)]
 
     rev_color = RevColorPalette(getparents)
 
             if src_rev_str is not None and src_rev_str in repo:
                 src = repo[src_rev_str]
                 src_rev = src.rev()
-                if stop_rev <= src_rev < curr_rev and not hidden(src_rev):
+                if stop_rev <= src_rev < curr_rev and \
+                        not hidden(src_rev) and not hiddenctx(src):
                     parents.append((src, LINE_TYPE_GRAFT, False))
             for octx in obsoleteutil.first_known_precursors(ctx):
                 src_rev = octx.rev()
-                if stop_rev <= src_rev < curr_rev and not hidden(src_rev):
+                if stop_rev <= src_rev < curr_rev and \
+                        not hidden(src_rev) and not hiddenctx(octx):
                     parents.append((octx, LINE_TYPE_OBSOLETE, False))
         parents_to_add = []
         for pctx, link_type, is_p1 in parents:

File tortoisehg/util/hgversion.py

 
 def checkhgversion(v):
     """range check the Mercurial version"""
-    reqver = ['3', '0']
+    reqver = ['2', '9']
     v = v.split('+')[0]
     if not v or v == 'unknown' or len(v) >= 12:
         # can't make any intelligent decisions about unknown or hashes