mercurial/graphmod.py
changeset 51699 ca7bde5dbafb
parent 51696 7f0cb9ee0534
child 51725 278af66e6595
equal deleted inserted replaced
51698:b0a4de6c14f8 51699:ca7bde5dbafb
   131             lambda rev: config.get(repo[rev].branch(), {})
   131             lambda rev: config.get(repo[rev].branch(), {})
   132         )
   132         )
   133     else:
   133     else:
   134         getconf = lambda rev: {}
   134         getconf = lambda rev: {}
   135 
   135 
   136     for (cur, type, data, parents) in dag:
   136     for cur, type, data, parents in dag:
   137 
       
   138         # Compute seen and next
   137         # Compute seen and next
   139         if cur not in seen:
   138         if cur not in seen:
   140             seen.append(cur)  # new head
   139             seen.append(cur)  # new head
   141             colors[cur] = newcolor
   140             colors[cur] = newcolor
   142             newcolor += 1
   141             newcolor += 1
   242     state.edges.pop(rev, None)
   241     state.edges.pop(rev, None)
   243     yield (type, char, width, (nodeidx, edges, ncols, nmorecols))
   242     yield (type, char, width, (nodeidx, edges, ncols, nmorecols))
   244 
   243 
   245 
   244 
   246 def _fixlongrightedges(edges):
   245 def _fixlongrightedges(edges):
   247     for (i, (start, end)) in enumerate(edges):
   246     for i, (start, end) in enumerate(edges):
   248         if end > start:
   247         if end > start:
   249             edges[i] = (start, end + 1)
   248             edges[i] = (start, end + 1)
   250 
   249 
   251 
   250 
   252 def _getnodelineedgestail(echars, idx, pidx, ncols, coldiff, pdiff, fix_tail):
   251 def _getnodelineedgestail(echars, idx, pidx, ncols, coldiff, pdiff, fix_tail):
   263         remainder = ncols - idx - 1
   262         remainder = ncols - idx - 1
   264         return echars[-(remainder * 2) :] if remainder > 0 else []
   263         return echars[-(remainder * 2) :] if remainder > 0 else []
   265 
   264 
   266 
   265 
   267 def _drawedges(echars, edges, nodeline, interline):
   266 def _drawedges(echars, edges, nodeline, interline):
   268     for (start, end) in edges:
   267     for start, end in edges:
   269         if start == end + 1:
   268         if start == end + 1:
   270             interline[2 * end + 1] = b"/"
   269             interline[2 * end + 1] = b"/"
   271         elif start == end - 1:
   270         elif start == end - 1:
   272             interline[2 * start + 1] = b"\\"
   271             interline[2 * start + 1] = b"\\"
   273         elif start == end:
   272         elif start == end:
   379     - graph data: list of { graph nodes/edges, text }
   378     - graph data: list of { graph nodes/edges, text }
   380 
   379 
   381     this function can be monkey-patched by extensions to alter graph display
   380     this function can be monkey-patched by extensions to alter graph display
   382     without needing to mimic all of the edge-fixup logic in ascii()
   381     without needing to mimic all of the edge-fixup logic in ascii()
   383     """
   382     """
   384     for (ln, logstr) in graph:
   383     for ln, logstr in graph:
   385         ui.write((ln + logstr).rstrip() + b"\n")
   384         ui.write((ln + logstr).rstrip() + b"\n")
   386 
   385 
   387 
   386 
   388 def ascii(ui, state, type, char, text, coldata):
   387 def ascii(ui, state, type, char, text, coldata):
   389     """prints an ASCII graph of the DAG
   388     """prints an ASCII graph of the DAG