Mercurial > hg
annotate mercurial/graphmod.py @ 8188:f3abe032fc89
add cmdutil.remoteui
remoteui sorts out the issues of getting ssh config options from the
local repo into the remote one while not copying other options like hooks.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 26 Apr 2009 16:50:43 -0500 |
parents | 4a4c7f6a5912 |
children | 46293a0c7e9f |
rev | line source |
---|---|
6691 | 1 # Revision graph generator for Mercurial |
2 # | |
3 # Copyright 2008 Dirkjan Ochtman <dirkjan@ochtman.nl> | |
4 # Copyright 2007 Joel Rosdahl <joel@rosdahl.net> | |
5 # | |
6 # This software may be used and distributed according to the terms of | |
7 # the GNU General Public License, incorporated herein by reference. | |
8 | |
7873
4a4c7f6a5912
cleanup: drop unused imports
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7565
diff
changeset
|
9 from node import nullrev |
6691 | 10 |
11 def graph(repo, start_rev, stop_rev): | |
12 """incremental revision grapher | |
13 | |
14 This generator function walks through the revision history from | |
15 revision start_rev to revision stop_rev (which must be less than | |
16 or equal to start_rev) and for each revision emits tuples with the | |
17 following elements: | |
18 | |
19 - Current node | |
20 - Column and color for the current node | |
21 - Edges; a list of (col, next_col, color) indicating the edges between | |
22 the current node and its parents. | |
23 - First line of the changeset description | |
24 - The changeset author | |
25 - The changeset date/time | |
26 """ | |
27 | |
7565
5f162f61e479
hgweb: fix problems with empty repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7280
diff
changeset
|
28 if start_rev == nullrev and not stop_rev: |
5f162f61e479
hgweb: fix problems with empty repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7280
diff
changeset
|
29 return |
5f162f61e479
hgweb: fix problems with empty repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7280
diff
changeset
|
30 |
6691 | 31 assert start_rev >= stop_rev |
7030
20a5dd5d6dd9
hgweb: let the web graph cope with low revisions/new repositories (issue1293)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6747
diff
changeset
|
32 assert stop_rev >= 0 |
6691 | 33 curr_rev = start_rev |
34 revs = [] | |
35 cl = repo.changelog | |
36 colors = {} | |
37 new_color = 1 | |
38 | |
39 while curr_rev >= stop_rev: | |
40 # Compute revs and next_revs | |
41 if curr_rev not in revs: | |
42 revs.append(curr_rev) # new head | |
43 colors[curr_rev] = new_color | |
44 new_color += 1 | |
45 | |
46 idx = revs.index(curr_rev) | |
47 color = colors.pop(curr_rev) | |
48 next = revs[:] | |
49 | |
50 # Add parents to next_revs | |
51 parents = [x for x in cl.parentrevs(curr_rev) if x != nullrev] | |
52 addparents = [p for p in parents if p not in next] | |
53 next[idx:idx + 1] = addparents | |
54 | |
55 # Set colors for the parents | |
56 for i, p in enumerate(addparents): | |
57 if not i: | |
58 colors[p] = color | |
59 else: | |
60 colors[p] = new_color | |
61 new_color += 1 | |
62 | |
63 # Add edges to the graph | |
64 edges = [] | |
65 for col, r in enumerate(revs): | |
66 if r in next: | |
67 edges.append((col, next.index(r), colors[r])) | |
68 elif r == curr_rev: | |
69 for p in parents: | |
70 edges.append((col, next.index(p), colors[p])) | |
71 | |
72 # Yield and move on | |
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6691
diff
changeset
|
73 yield (repo[curr_rev], (idx, color), edges) |
6691 | 74 revs = next |
75 curr_rev -= 1 |