Mercurial > hg
annotate hgext/graphlog.py @ 12193:927e1a677267
tests: unify test-git-*
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Fri, 03 Sep 2010 14:29:28 +0200 |
parents | 13921a1af02b |
children | aa1faedeac5a |
rev | line source |
---|---|
4344 | 1 # ASCII graph log extension for Mercurial |
2 # | |
3 # Copyright 2007 Joel Rosdahl <joel@rosdahl.net> | |
4516
96d8a56d4ef9
Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4509
diff
changeset
|
4 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8210
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
8228
eee2319c5895
add blank line after copyright notices and after header
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
7 |
8934
9dda4c73fc3b
extensions: change descriptions for extensions providing a few commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8932
diff
changeset
|
8 '''command to view revision graphs from a shell |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
9 |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
10 This extension adds a --graph option to the incoming, outgoing and log |
9259
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
11 commands. When this options is given, an ASCII representation of the |
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
12 revision graph is also shown. |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
13 ''' |
4344 | 14 |
10333
b9e44cc97355
graphlog: remove unused import
Christian Ebert <blacktrash@gmx.net>
parents:
10264
diff
changeset
|
15 import os |
4344 | 16 from mercurial.cmdutil import revrange, show_changeset |
7873
4a4c7f6a5912
cleanup: drop unused imports
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7763
diff
changeset
|
17 from mercurial.commands import templateopts |
4344 | 18 from mercurial.i18n import _ |
6212 | 19 from mercurial.node import nullrev |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
20 from mercurial import bundlerepo, changegroup, cmdutil, commands, extensions |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11273
diff
changeset
|
21 from mercurial import hg, url, util, graphmod, discovery |
5938
9ed100559851
graphlog: add filelog revision grapher
Steve Borho <steve@borho.org>
parents:
4735
diff
changeset
|
22 |
8840
d9acbe7b0049
graphmod/graphlog: make dag walks carry data as type, payload
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
8839
diff
changeset
|
23 ASCIIDATA = 'ASC' |
d9acbe7b0049
graphmod/graphlog: make dag walks carry data as type, payload
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
8839
diff
changeset
|
24 |
9369
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
25 def asciiedges(seen, rev, parents): |
8840
d9acbe7b0049
graphmod/graphlog: make dag walks carry data as type, payload
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
8839
diff
changeset
|
26 """adds edge info to changelog DAG walk suitable for ascii()""" |
9369
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
27 if rev not in seen: |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
28 seen.append(rev) |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
29 nodeidx = seen.index(rev) |
5938
9ed100559851
graphlog: add filelog revision grapher
Steve Borho <steve@borho.org>
parents:
4735
diff
changeset
|
30 |
9369
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
31 knownparents = [] |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
32 newparents = [] |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
33 for parent in parents: |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
34 if parent in seen: |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
35 knownparents.append(parent) |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
36 else: |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
37 newparents.append(parent) |
5938
9ed100559851
graphlog: add filelog revision grapher
Steve Borho <steve@borho.org>
parents:
4735
diff
changeset
|
38 |
9369
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
39 ncols = len(seen) |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
40 seen[nodeidx:nodeidx + 1] = newparents |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
41 edges = [(nodeidx, seen.index(p)) for p in knownparents] |
7370
7bc62ebe7693
graphlog: refactor common grapher code
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7369
diff
changeset
|
42 |
9369
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
43 if len(newparents) > 0: |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
44 edges.append((nodeidx, nodeidx)) |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
45 if len(newparents) > 1: |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
46 edges.append((nodeidx, nodeidx + 1)) |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
47 |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
48 nmorecols = len(seen) - ncols |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
49 return nodeidx, edges, ncols, nmorecols |
5938
9ed100559851
graphlog: add filelog revision grapher
Steve Borho <steve@borho.org>
parents:
4735
diff
changeset
|
50 |
4344 | 51 def fix_long_right_edges(edges): |
52 for (i, (start, end)) in enumerate(edges): | |
53 if end > start: | |
54 edges[i] = (start, end + 1) | |
55 | |
7326
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
56 def get_nodeline_edges_tail( |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
57 node_index, p_node_index, n_columns, n_columns_diff, p_diff, fix_tail): |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
58 if fix_tail and n_columns_diff == p_diff and n_columns_diff != 0: |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
59 # Still going in the same non-vertical direction. |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
60 if n_columns_diff == -1: |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
61 start = max(node_index + 1, p_node_index) |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
62 tail = ["|", " "] * (start - node_index - 1) |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
63 tail.extend(["/", " "] * (n_columns - start)) |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
64 return tail |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
65 else: |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
66 return ["\\", " "] * (n_columns - node_index - 1) |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
67 else: |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
68 return ["|", " "] * (n_columns - node_index - 1) |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
69 |
4344 | 70 def draw_edges(edges, nodeline, interline): |
71 for (start, end) in edges: | |
72 if start == end + 1: | |
73 interline[2 * end + 1] = "/" | |
74 elif start == end - 1: | |
75 interline[2 * start + 1] = "\\" | |
76 elif start == end: | |
77 interline[2 * start] = "|" | |
78 else: | |
79 nodeline[2 * end] = "+" | |
80 if start > end: | |
9198
061eeb602354
coding style: use a space after comma
Martin Geisler <mg@lazybytes.net>
parents:
9180
diff
changeset
|
81 (start, end) = (end, start) |
4344 | 82 for i in range(2 * start + 1, 2 * end): |
83 if nodeline[i] != "+": | |
84 nodeline[i] = "-" | |
85 | |
86 def get_padding_line(ni, n_columns, edges): | |
87 line = [] | |
88 line.extend(["|", " "] * ni) | |
89 if (ni, ni - 1) in edges or (ni, ni) in edges: | |
90 # (ni, ni - 1) (ni, ni) | |
91 # | | | | | | | | | |
92 # +---o | | o---+ | |
93 # | | c | | c | | | |
94 # | |/ / | |/ / | |
95 # | | | | | | | |
96 c = "|" | |
97 else: | |
98 c = " " | |
99 line.extend([c, " "]) | |
100 line.extend(["|", " "] * (n_columns - ni - 1)) | |
101 return line | |
102 | |
9631
1c34fca5d785
graphlog: hide internal state of ascii() from users
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
9371
diff
changeset
|
103 def asciistate(): |
1c34fca5d785
graphlog: hide internal state of ascii() from users
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
9371
diff
changeset
|
104 """returns the initial value for the "state" argument to ascii()""" |
1c34fca5d785
graphlog: hide internal state of ascii() from users
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
9371
diff
changeset
|
105 return [0, 0] |
1c34fca5d785
graphlog: hide internal state of ascii() from users
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
9371
diff
changeset
|
106 |
1c34fca5d785
graphlog: hide internal state of ascii() from users
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
9371
diff
changeset
|
107 def ascii(ui, state, type, char, text, coldata): |
8839
bbfa21b6f18a
graphlog: rename grapher to asciiedges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
8838
diff
changeset
|
108 """prints an ASCII graph of the DAG |
4344 | 109 |
9371
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
110 takes the following arguments (one call per node in the graph): |
4344 | 111 |
9371
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
112 - ui to write to |
9631
1c34fca5d785
graphlog: hide internal state of ascii() from users
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
9371
diff
changeset
|
113 - Somewhere to keep the needed state in (init to asciistate()) |
7325
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
114 - Column of the current node in the set of ongoing edges. |
8840
d9acbe7b0049
graphmod/graphlog: make dag walks carry data as type, payload
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
8839
diff
changeset
|
115 - Type indicator of node data == ASCIIDATA. |
d9acbe7b0049
graphmod/graphlog: make dag walks carry data as type, payload
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
8839
diff
changeset
|
116 - Payload: (char, lines): |
d9acbe7b0049
graphmod/graphlog: make dag walks carry data as type, payload
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
8839
diff
changeset
|
117 - Character to use as node's symbol. |
d9acbe7b0049
graphmod/graphlog: make dag walks carry data as type, payload
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
8839
diff
changeset
|
118 - List of lines to display as the node's text. |
7325
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
119 - Edges; a list of (col, next_col) indicating the edges between |
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
120 the current node and its parents. |
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
121 - Number of columns (ongoing edges) in the current revision. |
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
122 - The difference between the number of columns (ongoing edges) |
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
123 in the next revision and the number of columns (ongoing edges) |
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
124 in the current revision. That is: -1 means one column removed; |
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
125 0 means no columns added or removed; 1 means one column added. |
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
126 """ |
4344 | 127 |
9371
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
128 idx, edges, ncols, coldiff = coldata |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
129 assert -2 < coldiff < 2 |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
130 if coldiff == -1: |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
131 # Transform |
4344 | 132 # |
9371
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
133 # | | | | | | |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
134 # o | | into o---+ |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
135 # |X / |/ / |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
136 # | | | | |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
137 fix_long_right_edges(edges) |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
138 |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
139 # add_padding_line says whether to rewrite |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
140 # |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
141 # | | | | | | | | |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
142 # | o---+ into | o---+ |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
143 # | / / | | | # <--- padding line |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
144 # o | | | / / |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
145 # o | | |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
146 add_padding_line = (len(text) > 2 and coldiff == -1 and |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
147 [x for (x, y) in edges if x + 1 < y]) |
4344 | 148 |
9371
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
149 # fix_nodeline_tail says whether to rewrite |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
150 # |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
151 # | | o | | | | o | | |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
152 # | | |/ / | | |/ / |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
153 # | o | | into | o / / # <--- fixed nodeline tail |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
154 # | |/ / | |/ / |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
155 # o | | o | | |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
156 fix_nodeline_tail = len(text) <= 2 and not add_padding_line |
4344 | 157 |
9371
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
158 # nodeline is the line containing the node character (typically o) |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
159 nodeline = ["|", " "] * idx |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
160 nodeline.extend([char, " "]) |
4344 | 161 |
9371
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
162 nodeline.extend( |
9631
1c34fca5d785
graphlog: hide internal state of ascii() from users
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
9371
diff
changeset
|
163 get_nodeline_edges_tail(idx, state[1], ncols, coldiff, |
1c34fca5d785
graphlog: hide internal state of ascii() from users
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
9371
diff
changeset
|
164 state[0], fix_nodeline_tail)) |
4344 | 165 |
9371
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
166 # shift_interline is the line containing the non-vertical |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
167 # edges between this entry and the next |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
168 shift_interline = ["|", " "] * idx |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
169 if coldiff == -1: |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
170 n_spaces = 1 |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
171 edge_ch = "/" |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
172 elif coldiff == 0: |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
173 n_spaces = 2 |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
174 edge_ch = "|" |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
175 else: |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
176 n_spaces = 3 |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
177 edge_ch = "\\" |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
178 shift_interline.extend(n_spaces * [" "]) |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
179 shift_interline.extend([edge_ch, " "] * (ncols - idx - 1)) |
4344 | 180 |
9371
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
181 # draw edges from the current node to its parents |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
182 draw_edges(edges, nodeline, shift_interline) |
4344 | 183 |
9371
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
184 # lines is the list of all graph lines to print |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
185 lines = [nodeline] |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
186 if add_padding_line: |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
187 lines.append(get_padding_line(idx, ncols, edges)) |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
188 lines.append(shift_interline) |
4344 | 189 |
9371
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
190 # make sure that there are as many graph lines as there are |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
191 # log strings |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
192 while len(text) < len(lines): |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
193 text.append("") |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
194 if len(lines) < len(text): |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
195 extra_interline = ["|", " "] * (ncols + coldiff) |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
196 while len(lines) < len(text): |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
197 lines.append(extra_interline) |
4344 | 198 |
9371
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
199 # print lines |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
200 indentation_level = max(ncols, ncols + coldiff) |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
201 for (line, logstr) in zip(lines, text): |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
202 ln = "%-*s %s" % (2 * indentation_level, "".join(line), logstr) |
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
203 ui.write(ln.rstrip() + '\n') |
4344 | 204 |
9371
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
205 # ... and start over |
9631
1c34fca5d785
graphlog: hide internal state of ascii() from users
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
9371
diff
changeset
|
206 state[0] = coldiff |
1c34fca5d785
graphlog: hide internal state of ascii() from users
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
9371
diff
changeset
|
207 state[1] = idx |
4344 | 208 |
7326
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
209 def get_revs(repo, rev_opt): |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
210 if rev_opt: |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
211 revs = revrange(repo, rev_opt) |
11448
25430ff23cfa
glog: fix crash on empty revision range
Eric Eisner <ede@mit.edu>
parents:
11321
diff
changeset
|
212 if len(revs) == 0: |
25430ff23cfa
glog: fix crash on empty revision range
Eric Eisner <ede@mit.edu>
parents:
11321
diff
changeset
|
213 return (nullrev, nullrev) |
7326
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
214 return (max(revs), min(revs)) |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
215 else: |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
216 return (len(repo) - 1, 0) |
ba7ab8c4a577
graphlog: move functions around, eliminate helper function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7325
diff
changeset
|
217 |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
218 def check_unsupported_flags(opts): |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
219 for op in ["follow", "follow_first", "date", "copies", "keyword", "remove", |
11776
13921a1af02b
graphlog: mark --branch as incompatible with --graph
Martin Geisler <mg@aragost.com>
parents:
11448
diff
changeset
|
220 "only_merges", "user", "branch", "only_branch", "prune", |
13921a1af02b
graphlog: mark --branch as incompatible with --graph
Martin Geisler <mg@aragost.com>
parents:
11448
diff
changeset
|
221 "newest_first", "no_merges", "include", "exclude"]: |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
222 if op in opts and opts[op]: |
10097
ffa6f2eb934e
glog: fix "incompatible option" error message.
Greg Ward <greg-hg@gerg.ca>
parents:
10084
diff
changeset
|
223 raise util.Abort(_("--graph option is incompatible with --%s") |
ffa6f2eb934e
glog: fix "incompatible option" error message.
Greg Ward <greg-hg@gerg.ca>
parents:
10084
diff
changeset
|
224 % op.replace("_", "-")) |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
225 |
9371
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
226 def generate(ui, dag, displayer, showparents, edgefn): |
9631
1c34fca5d785
graphlog: hide internal state of ascii() from users
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
9371
diff
changeset
|
227 seen, state = [], asciistate() |
9369
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
228 for rev, type, ctx, parents in dag: |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
229 char = ctx.node() in showparents and '@' or 'o' |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
230 displayer.show(ctx) |
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
231 lines = displayer.hunk.pop(rev).split('\n')[:-1] |
9631
1c34fca5d785
graphlog: hide internal state of ascii() from users
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
9371
diff
changeset
|
232 ascii(ui, state, type, char, lines, edgefn(seen, rev, parents)) |
9369
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
233 |
7325
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
234 def graphlog(ui, repo, path=None, **opts): |
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
235 """show revision history alongside an ASCII revision graph |
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
236 |
9259
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
237 Print a revision history alongside a revision graph drawn with |
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
238 ASCII characters. |
7325
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
239 |
9259
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
240 Nodes printed as an @ character are parents of the working |
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
241 directory. |
7325
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
242 """ |
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
243 |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
244 check_unsupported_flags(opts) |
7715
fd3266287b40
graphlog: reuse cmdutil.loglimit() instead of redefining
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7713
diff
changeset
|
245 limit = cmdutil.loglimit(opts) |
7370
7bc62ebe7693
graphlog: refactor common grapher code
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7369
diff
changeset
|
246 start, stop = get_revs(repo, opts["rev"]) |
7bc62ebe7693
graphlog: refactor common grapher code
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7369
diff
changeset
|
247 if start == nullrev: |
7325
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
248 return |
7370
7bc62ebe7693
graphlog: refactor common grapher code
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7369
diff
changeset
|
249 |
7325
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
250 if path: |
7713
b8c4ba0fd7c4
graphlog: import util module rather than selected functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7435
diff
changeset
|
251 path = util.canonpath(repo.root, os.getcwd(), path) |
7370
7bc62ebe7693
graphlog: refactor common grapher code
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7369
diff
changeset
|
252 if path: # could be reset in canonpath |
10084
4c844f16bf39
graphlog: fix output when both a limit and a path are provided
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9631
diff
changeset
|
253 revdag = graphmod.filerevs(repo, path, start, stop, limit) |
7325
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
254 else: |
10111
27457d31ae3f
cmdutil: replace sys.maxint with None as default value in loglimit
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10097
diff
changeset
|
255 if limit is not None: |
27457d31ae3f
cmdutil: replace sys.maxint with None as default value in loglimit
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10097
diff
changeset
|
256 stop = max(stop, start - limit + 1) |
8836
11ff34956ee7
graphmod/graphlog: move log walks to graphmod
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
8667
diff
changeset
|
257 revdag = graphmod.revisions(repo, start, stop) |
7325
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
258 |
9368
8a4773bcbaec
graphlog: extract some setup code out of common functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9259
diff
changeset
|
259 displayer = show_changeset(ui, repo, opts, buffered=True) |
8a4773bcbaec
graphlog: extract some setup code out of common functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9259
diff
changeset
|
260 showparents = [ctx.node() for ctx in repo[None].parents()] |
9371
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
261 generate(ui, revdag, displayer, showparents, asciiedges) |
7716
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
262 |
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
263 def graphrevs(repo, nodes, opts): |
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
264 limit = cmdutil.loglimit(opts) |
8837
d8e3a98018cb
graphmod/graphlog: extract nodelistwalk
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
8836
diff
changeset
|
265 nodes.reverse() |
10111
27457d31ae3f
cmdutil: replace sys.maxint with None as default value in loglimit
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10097
diff
changeset
|
266 if limit is not None: |
8837
d8e3a98018cb
graphmod/graphlog: extract nodelistwalk
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
8836
diff
changeset
|
267 nodes = nodes[:limit] |
d8e3a98018cb
graphmod/graphlog: extract nodelistwalk
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
8836
diff
changeset
|
268 return graphmod.nodes(repo, nodes) |
7716
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
269 |
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
270 def goutgoing(ui, repo, dest=None, **opts): |
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
271 """show the outgoing changesets alongside an ASCII revision graph |
7325
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
272 |
7716
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
273 Print the outgoing changesets alongside a revision graph drawn with |
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
274 ASCII characters. |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
275 |
7716
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
276 Nodes printed as an @ character are parents of the working |
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
277 directory. |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
278 """ |
7716
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
279 |
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
280 check_unsupported_flags(opts) |
10365
d757bc0c7865
interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents:
10333
diff
changeset
|
281 dest = ui.expandpath(dest or 'default-push', dest or 'default') |
10379
a78bfaf988e1
add -b/--branch option to clone, bundle, incoming, outgoing, pull, push
Sune Foldager <cryo@cyanite.org>
parents:
10365
diff
changeset
|
282 dest, branches = hg.parseurl(dest, opts.get('branch')) |
10365
d757bc0c7865
interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents:
10333
diff
changeset
|
283 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) |
11273
d1908cb95a82
remoteui: move from cmdutil to hg
Matt Mackall <mpm@selenic.com>
parents:
10379
diff
changeset
|
284 other = hg.repository(hg.remoteui(ui, opts), dest) |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
285 if revs: |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
286 revs = [repo.lookup(rev) for rev in revs] |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
287 ui.status(_('comparing with %s\n') % url.hidepassword(dest)) |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11273
diff
changeset
|
288 o = discovery.findoutgoing(repo, other, force=opts.get('force')) |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
289 if not o: |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
290 ui.status(_("no changes found\n")) |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
291 return |
7716
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
292 |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
293 o = repo.changelog.nodesbetween(o, revs)[0] |
7716
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
294 revdag = graphrevs(repo, o, opts) |
9368
8a4773bcbaec
graphlog: extract some setup code out of common functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9259
diff
changeset
|
295 displayer = show_changeset(ui, repo, opts, buffered=True) |
8a4773bcbaec
graphlog: extract some setup code out of common functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9259
diff
changeset
|
296 showparents = [ctx.node() for ctx in repo[None].parents()] |
9371
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
297 generate(ui, revdag, displayer, showparents, asciiedges) |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
298 |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
299 def gincoming(ui, repo, source="default", **opts): |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
300 """show the incoming changesets alongside an ASCII revision graph |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
301 |
9259
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
302 Print the incoming changesets alongside a revision graph drawn with |
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
303 ASCII characters. |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
304 |
9259
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
305 Nodes printed as an @ character are parents of the working |
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
306 directory. |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
307 """ |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
308 |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
309 check_unsupported_flags(opts) |
10379
a78bfaf988e1
add -b/--branch option to clone, bundle, incoming, outgoing, pull, push
Sune Foldager <cryo@cyanite.org>
parents:
10365
diff
changeset
|
310 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) |
11273
d1908cb95a82
remoteui: move from cmdutil to hg
Matt Mackall <mpm@selenic.com>
parents:
10379
diff
changeset
|
311 other = hg.repository(hg.remoteui(repo, opts), source) |
10365
d757bc0c7865
interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents:
10333
diff
changeset
|
312 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
313 ui.status(_('comparing with %s\n') % url.hidepassword(source)) |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
314 if revs: |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
315 revs = [other.lookup(rev) for rev in revs] |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11273
diff
changeset
|
316 incoming = discovery.findincoming(repo, other, heads=revs, |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11273
diff
changeset
|
317 force=opts["force"]) |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
318 if not incoming: |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
319 try: |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
320 os.unlink(opts["bundle"]) |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
321 except: |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
322 pass |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
323 ui.status(_("no changes found\n")) |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
324 return |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
325 |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
326 cleanup = None |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
327 try: |
7716
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
328 |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
329 fname = opts["bundle"] |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
330 if fname or not other.local(): |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
331 # create a bundle (uncompressed if other repo is not local) |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
332 if revs is None: |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
333 cg = other.changegroup(incoming, "incoming") |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
334 else: |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
335 cg = other.changegroupsubset(incoming, revs, 'incoming') |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
336 bundletype = other.local() and "HG10BZ" or "HG10UN" |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
337 fname = cleanup = changegroup.writebundle(cg, fname, bundletype) |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
338 # keep written bundle? |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
339 if opts["bundle"]: |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
340 cleanup = None |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
341 if not other.local(): |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
342 # use the created uncompressed bundlerepo |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
343 other = bundlerepo.bundlerepository(ui, repo.root, fname) |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
344 |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
345 chlist = other.changelog.nodesbetween(incoming, revs)[0] |
7716
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
346 revdag = graphrevs(other, chlist, opts) |
9368
8a4773bcbaec
graphlog: extract some setup code out of common functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9259
diff
changeset
|
347 displayer = show_changeset(ui, other, opts, buffered=True) |
8a4773bcbaec
graphlog: extract some setup code out of common functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9259
diff
changeset
|
348 showparents = [ctx.node() for ctx in repo[None].parents()] |
9371
571a7acb4544
graphlog: simplify ascii drawing to process one cset at a time
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9370
diff
changeset
|
349 generate(ui, revdag, displayer, showparents, asciiedges) |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
350 |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
351 finally: |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
352 if hasattr(other, 'close'): |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
353 other.close() |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
354 if cleanup: |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
355 os.unlink(cleanup) |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
356 |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
357 def uisetup(ui): |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
358 '''Initialize the extension.''' |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
359 _wrapcmd(ui, 'log', commands.table, graphlog) |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
360 _wrapcmd(ui, 'incoming', commands.table, gincoming) |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
361 _wrapcmd(ui, 'outgoing', commands.table, goutgoing) |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
362 |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
363 def _wrapcmd(ui, cmd, table, wrapfn): |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
364 '''wrap the command''' |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
365 def graph(orig, *args, **kwargs): |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
366 if kwargs['graph']: |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
367 return wrapfn(*args, **kwargs) |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
368 return orig(*args, **kwargs) |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
369 entry = extensions.wrapcommand(table, cmd, graph) |
7763
cdc913e7fc5f
log-like commands now use -G for --graph, -g for --git
Jim Correia <jim.correia@pobox.com>
parents:
7716
diff
changeset
|
370 entry[1].append(('G', 'graph', None, _("show the revision DAG"))) |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
371 |
4344 | 372 cmdtable = { |
373 "glog": | |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4633
diff
changeset
|
374 (graphlog, |
11321
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11301
diff
changeset
|
375 [('l', 'limit', '', |
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11301
diff
changeset
|
376 _('limit number of changes displayed'), _('NUM')), |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4633
diff
changeset
|
377 ('p', 'patch', False, _('show patch')), |
11321
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11301
diff
changeset
|
378 ('r', 'rev', [], |
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11301
diff
changeset
|
379 _('show the specified revision or range'), _('REV')), |
6192
cd65a67aff31
Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5968
diff
changeset
|
380 ] + templateopts, |
5942
b75105de8573
glog shows at most one file: correct synopsis
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5940
diff
changeset
|
381 _('hg glog [OPTION]... [FILE]')), |
4344 | 382 } |