mercurial/graphmod.py
changeset 16132 41fc1e078d68
parent 16131 6f236c8bdc01
child 16138 6e4de55a41a4
equal deleted inserted replaced
16131:6f236c8bdc01 16132:41fc1e078d68
    16 context of the graph returned. Type is a constant specifying the node type.
    16 context of the graph returned. Type is a constant specifying the node type.
    17 Data depends on type.
    17 Data depends on type.
    18 """
    18 """
    19 
    19 
    20 from mercurial.node import nullrev
    20 from mercurial.node import nullrev
       
    21 import util
    21 
    22 
    22 CHANGESET = 'C'
    23 CHANGESET = 'C'
    23 
    24 
    24 def dagwalker(repo, revs):
    25 def dagwalker(repo, revs):
    25     """cset DAG generator yielding (id, CHANGESET, ctx, [parentids]) tuples
    26     """cset DAG generator yielding (id, CHANGESET, ctx, [parentids]) tuples
    92             if setting == "width" and val.isdigit():
    93             if setting == "width" and val.isdigit():
    93                 config.setdefault(branch, {})[setting] = val
    94                 config.setdefault(branch, {})[setting] = val
    94             elif setting == "color" and val.isalnum():
    95             elif setting == "color" and val.isalnum():
    95                 config.setdefault(branch, {})[setting] = val
    96                 config.setdefault(branch, {})[setting] = val
    96 
    97 
       
    98     if config:
       
    99         getconf = util.lrucachefunc(lambda rev: config.get(repo[rev].branch()))
       
   100     else:
       
   101         getconf = lambda rev: None
    97 
   102 
    98     for (cur, type, data, parents) in dag:
   103     for (cur, type, data, parents) in dag:
    99 
   104 
   100         # Compute seen and next
   105         # Compute seen and next
   101         if cur not in seen:
   106         if cur not in seen:
   123         edges = []
   128         edges = []
   124         for ecol, eid in enumerate(seen):
   129         for ecol, eid in enumerate(seen):
   125             if eid in next:
   130             if eid in next:
   126                 edges.append((
   131                 edges.append((
   127                     ecol, next.index(eid), colors[eid],
   132                     ecol, next.index(eid), colors[eid],
   128                     config.get(repo[eid].branch(), None)))
   133                     getconf(eid)))
   129             elif eid == cur:
   134             elif eid == cur:
   130                 for p in parents:
   135                 for p in parents:
   131                     edges.append((
   136                     edges.append((
   132                         ecol, next.index(p), color,
   137                         ecol, next.index(p), color,
   133                         config.get(repo[p].branch(), None)))
   138                         getconf(p)))
   134 
   139 
   135         # Yield and move on
   140         # Yield and move on
   136         yield (cur, type, data, (col, color), edges)
   141         yield (cur, type, data, (col, color), edges)
   137         seen = next
   142         seen = next
   138 
   143