Advertisement
Guest User

mercurial graph style patch

a guest
Jan 4th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.79 KB | None | 0 0
  1. diff -r 371cff9610cd mercurial/graphmod.py
  2. --- a/mercurial/graphmod.py Tue Jan 03 17:13:03 2012 -0600
  3. +++ b/mercurial/graphmod.py Wed Jan 04 15:24:48 2012 +0700
  4. @@ -16,7 +16,6 @@
  5.  context of the graph returned. Type is a constant specifying the node type.
  6.  Data depends on type.
  7.  """
  8. -
  9.  from mercurial.node import nullrev
  10.  
  11.  CHANGESET = 'C'
  12. @@ -67,7 +66,7 @@
  13.          parents = set([p.rev() for p in ctx.parents() if p.node() in include])
  14.          yield (ctx.rev(), CHANGESET, ctx, sorted(parents))
  15.  
  16. -def colored(dag):
  17. +def colored(dag,repo):
  18.      """annotates a DAG with colored edge information
  19.  
  20.      For each DAG node this function emits tuples::
  21. @@ -83,6 +82,11 @@
  22.      seen = []
  23.      colors = {}
  24.      newcolor = 1
  25. +    defaults = {}
  26. +
  27. +    for (branch, style) in repo.ui.configitems('graph'):
  28. +        defaults[branch] = style.split()
  29. +
  30.      for (cur, type, data, parents) in dag:
  31.  
  32.          # Compute seen and next
  33. @@ -111,10 +115,10 @@
  34.          edges = []
  35.          for ecol, eid in enumerate(seen):
  36.              if eid in next:
  37. -                edges.append((ecol, next.index(eid), colors[eid]))
  38. +                edges.append((ecol, next.index(eid), colors[eid], defaults[repo[eid].branch()] if defaults.has_key(repo[eid].branch()) else None))
  39.              elif eid == cur:
  40.                  for p in parents:
  41. -                    edges.append((ecol, next.index(p), color))
  42. +                    edges.append((ecol, next.index(p), color, defaults[repo[p].branch()] if defaults.has_key(repo[eid].branch()) else None))
  43.  
  44.          # Yield and move on
  45.          yield (cur, type, data, (col, color), edges)
  46. diff -r 371cff9610cd mercurial/hgweb/webcommands.py
  47. --- a/mercurial/hgweb/webcommands.py    Tue Jan 03 17:13:03 2012 -0600
  48. +++ b/mercurial/hgweb/webcommands.py    Wed Jan 04 15:24:48 2012 +0700
  49. @@ -770,7 +770,7 @@
  50.          startrev = uprev
  51.  
  52.      dag = graphmod.dagwalker(web.repo, range(startrev, downrev - 1, -1))
  53. -    tree = list(graphmod.colored(dag))
  54. +    tree = list(graphmod.colored(dag,web.repo))
  55.      canvasheight = (len(tree) + 1) * bg_height - 27
  56.      data = []
  57.      for (id, type, ctx, vtx, edges) in tree:
  58. diff -r 371cff9610cd mercurial/templates/static/mercurial.js
  59. --- a/mercurial/templates/static/mercurial.js   Tue Jan 03 17:13:03 2012 -0600
  60. +++ b/mercurial/templates/static/mercurial.js   Wed Jan 04 15:24:48 2012 +0700
  61. @@ -113,8 +113,13 @@
  62.                 x1 = this.cell[0] + this.box_size * end + this.box_size / 2;
  63.                 y1 = this.bg[1] + this.bg_height / 2;
  64.                
  65. -               this.edge(x0, y0, x1, y1, color);
  66. -              
  67. +               if(line[3]){
  68. +                   this.ctx.lineWidth = line[3][0] ? line[3][0] : 3;
  69. +                   this.edge(x0, y0, x1, y1, color);
  70. +                   this.ctx.lineWidth = 1;
  71. +               }else{
  72. +                   this.edge(x0, y0, x1, y1, color);
  73. +               }
  74.             }
  75.            
  76.             // Draw the revision node in the right column
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement