SourceForge: tortoisehg/tortoisehg: changeset 4072:90fed6e8135a
logview: Support branch selection on compact graph
authorPeer Sommerlund <peso@users.sourceforge.net>
Thu Sep 17 22:54:38 2009 +0200 (2 months ago)
changeset 407290fed6e8135a
parent 40717b886e2e4fec
child 407366a4b72d3cbb
logview: Support branch selection on compact graph
tortoisehg/hgtk/logview/revgraph.py
tortoisehg/hgtk/logview/treeview.py
     1.1 --- a/tortoisehg/hgtk/logview/revgraph.py	Thu Sep 17 19:56:16 2009 +0200
     1.2 +++ b/tortoisehg/hgtk/logview/revgraph.py	Thu Sep 17 22:54:38 2009 +0200
     1.3 @@ -157,10 +157,11 @@
     1.4      two branches.
     1.5      """
     1.6      
     1.7 -    def __init__(self, repo, start_rev, stop_rev, branch_color):
     1.8 +    def __init__(self, repo, start_rev, stop_rev, branch_filter, branch_color):
     1.9          ''' 
    1.10          start_rev - first (newest) changeset to cover
    1.11          stop_rev - last (oldest) changeset to cover
    1.12 +        branch_filter - if not None, show this branch and all its ancestors
    1.13          branch_color - true if branch name determines colours
    1.14          '''
    1.15          assert start_rev >= stop_rev
    1.16 @@ -210,6 +211,9 @@
    1.17          # Next colour used. for branches
    1.18          self.nextcolor = 0
    1.19          
    1.20 +        # If set, show only this branch and all descendants.
    1.21 +        self.branch_filter = branch_filter
    1.22 +        
    1.23          # Flag to indicate if coloring is done pr micro-branch or pr named branch
    1.24          self.branch_color = branch_color
    1.25  
    1.26 @@ -319,11 +323,23 @@
    1.27          """Perform one iteration of the branch grapher"""
    1.28          
    1.29          # Compute revision (on CUR branch row)
    1.30 -        rev = self.curr_rev
    1.31 -        rev_branch = self._get_rev_branch(rev)
    1.32 -        if rev_branch not in self.curr_branches:
    1.33 -            # New head
    1.34 -            self.curr_branches.append(rev_branch)
    1.35 +        while self.more():
    1.36 +            rev = self.curr_rev
    1.37 +            rev_branch = self._get_rev_branch(rev)
    1.38 +            if rev_branch in self.curr_branches:
    1.39 +                # Follow parent from known child
    1.40 +                break
    1.41 +            elif self.branch_filter is None:
    1.42 +                # New head - no branch name filter
    1.43 +                self.curr_branches.append(rev_branch)
    1.44 +                break
    1.45 +            elif self._branch_name(rev) == self.branch_filter:
    1.46 +                # New head - matches branch name filter
    1.47 +                self.curr_branches.append(rev_branch)
    1.48 +                break
    1.49 +            else:
    1.50 +                # Skip this revision
    1.51 +                self.curr_rev -= 1
    1.52          
    1.53          # Compute parents (indicates the branches on NEXT branch row that curr_rev links to)
    1.54          parents = self._get_parents(rev)
    1.55 @@ -345,8 +361,8 @@
    1.56          # Return result
    1.57          return (rev, node, lines, None)
    1.58      
    1.59 -def branch_grapher(repo, start_rev, stop_rev, branch_color=False):
    1.60 -    grapher = BranchGrapher(repo, start_rev, stop_rev, branch_color)
    1.61 +def branch_grapher(repo, start_rev, stop_rev, branch=None, branch_color=False):
    1.62 +    grapher = BranchGrapher(repo, start_rev, stop_rev, branch, branch_color)
    1.63      while grapher.more():
    1.64          yield grapher.next()            
    1.65  
     2.1 --- a/tortoisehg/hgtk/logview/treeview.py	Thu Sep 17 19:56:16 2009 +0200
     2.2 +++ b/tortoisehg/hgtk/logview/treeview.py	Thu Sep 17 22:54:38 2009 +0200
     2.3 @@ -165,7 +165,7 @@
     2.4              noheads = opts.get('noheads', False)
     2.5              if opts.get('branch-view', False):
     2.6                  self.grapher = branch_grapher(self.repo, start, end, 
     2.7 -                    self.branch_color)
     2.8 +                    pats, self.branch_color)
     2.9              else:
    2.10                  self.grapher = revision_grapher(self.repo, start, end, pats,
    2.11                          noheads, self.branch_color)