author | Patrick Mezard <patrick@mezard.eu> |
Wed, 11 Jul 2012 17:13:39 +0200 | |
changeset 17179 | 0849d725e2f9 |
parent 17164 | 8299a9ad48dd |
child 17180 | ae0629161090 |
permissions | -rw-r--r-- |
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 |
|
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14311
diff
changeset
|
15 |
from mercurial.cmdutil import show_changeset |
4344 | 16 |
from mercurial.i18n import _ |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14311
diff
changeset
|
17 |
from mercurial import cmdutil, commands, extensions, scmutil |
16412
1a10bee86e33
graphlog: cleanup before code move
Patrick Mezard <patrick@mezard.eu>
parents:
16411
diff
changeset
|
18 |
from mercurial import hg, util, graphmod, templatekw, revset |
5938
9ed100559851
graphlog: add filelog revision grapher
Steve Borho <steve@borho.org>
parents:
4735
diff
changeset
|
19 |
|
14311
9bbac962f4dd
graphlog: use cmdutil.command decorator
Adrian Buehlmann <adrian@cadifra.com>
parents:
14139
diff
changeset
|
20 |
cmdtable = {} |
9bbac962f4dd
graphlog: use cmdutil.command decorator
Adrian Buehlmann <adrian@cadifra.com>
parents:
14139
diff
changeset
|
21 |
command = cmdutil.command(cmdtable) |
16743
38caf405d010
hgext: mark all first-party extensions as such
Augie Fackler <raf@durin42.com>
parents:
16434
diff
changeset
|
22 |
testedwith = 'internal' |
14311
9bbac962f4dd
graphlog: use cmdutil.command decorator
Adrian Buehlmann <adrian@cadifra.com>
parents:
14139
diff
changeset
|
23 |
|
17163
4c5d7124661a
graphlog: make functions private, fix names
Patrick Mezard <patrick@mezard.eu>
parents:
17162
diff
changeset
|
24 |
def _checkunsupportedflags(pats, opts): |
16180
46a96cc830c2
graphlog: implement --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
25 |
for op in ["newest_first"]: |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
26 |
if op in opts and opts[op]: |
14043
1c1e1232abdc
graphlog: make use of graphmod's revset support
Alexander Solovyov <alexander@solovyov.net>
parents:
14042
diff
changeset
|
27 |
raise util.Abort(_("-G/--graph option is incompatible with --%s") |
10097
ffa6f2eb934e
glog: fix "incompatible option" error message.
Greg Ward <greg-hg@gerg.ca>
parents:
10084
diff
changeset
|
28 |
% op.replace("_", "-")) |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
29 |
|
16412
1a10bee86e33
graphlog: cleanup before code move
Patrick Mezard <patrick@mezard.eu>
parents:
16411
diff
changeset
|
30 |
def _makefilematcher(repo, pats, followfirst): |
16186
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
31 |
# When displaying a revision with --patch --follow FILE, we have |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
32 |
# to know which file of the revision must be diffed. With |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
33 |
# --follow, we want the names of the ancestors of FILE in the |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
34 |
# revision, stored in "fcache". "fcache" is populated by |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
35 |
# reproducing the graph traversal already done by --follow revset |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
36 |
# and relating linkrevs to file names (which is not "correct" but |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
37 |
# good enough). |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
38 |
fcache = {} |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
39 |
fcacheready = [False] |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
40 |
pctx = repo['.'] |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
41 |
wctx = repo[None] |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
42 |
|
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
43 |
def populate(): |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
44 |
for fn in pats: |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
45 |
for i in ((pctx[fn],), pctx[fn].ancestors(followfirst=followfirst)): |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
46 |
for c in i: |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
47 |
fcache.setdefault(c.linkrev(), set()).add(c.path()) |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
48 |
|
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
49 |
def filematcher(rev): |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
50 |
if not fcacheready[0]: |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
51 |
# Lazy initialization |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
52 |
fcacheready[0] = True |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
53 |
populate() |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
54 |
return scmutil.match(wctx, fcache.get(rev, []), default='path') |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
55 |
|
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
56 |
return filematcher |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
57 |
|
16405
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
58 |
def _makelogrevset(repo, pats, opts, revs): |
16186
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
59 |
"""Return (expr, filematcher) where expr is a revset string built |
16405
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
60 |
from log options and file patterns or None. If --stat or --patch |
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
61 |
are not passed filematcher is None. Otherwise it is a callable |
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
62 |
taking a revision number and returning a match objects filtering |
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
63 |
the files to be detailed when displaying the revision. |
14043
1c1e1232abdc
graphlog: make use of graphmod's revset support
Alexander Solovyov <alexander@solovyov.net>
parents:
14042
diff
changeset
|
64 |
""" |
14085
4852753dae36
graphlog: unify log -G revset translation
Patrick Mezard <pmezard@gmail.com>
parents:
14084
diff
changeset
|
65 |
opt2revset = { |
16174
0a73c4bd9f47
graphlog: implement --follow-first
Patrick Mezard <patrick@mezard.eu>
parents:
16173
diff
changeset
|
66 |
'no_merges': ('not merge()', None), |
0a73c4bd9f47
graphlog: implement --follow-first
Patrick Mezard <patrick@mezard.eu>
parents:
16173
diff
changeset
|
67 |
'only_merges': ('merge()', None), |
16408
d74099ac2ac1
graphlog: fix --follow --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16407
diff
changeset
|
68 |
'_ancestors': ('ancestors(%(val)s)', None), |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16408
diff
changeset
|
69 |
'_fancestors': ('_firstancestors(%(val)s)', None), |
16408
d74099ac2ac1
graphlog: fix --follow --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16407
diff
changeset
|
70 |
'_descendants': ('descendants(%(val)s)', None), |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16408
diff
changeset
|
71 |
'_fdescendants': ('_firstdescendants(%(val)s)', None), |
16316
0f1e621d3d3b
graphlog: handle old-style --rev values
Patrick Mezard <patrick@mezard.eu>
parents:
16314
diff
changeset
|
72 |
'_matchfiles': ('_matchfiles(%(val)s)', None), |
16174
0a73c4bd9f47
graphlog: implement --follow-first
Patrick Mezard <patrick@mezard.eu>
parents:
16173
diff
changeset
|
73 |
'date': ('date(%(val)r)', None), |
0a73c4bd9f47
graphlog: implement --follow-first
Patrick Mezard <patrick@mezard.eu>
parents:
16173
diff
changeset
|
74 |
'branch': ('branch(%(val)r)', ' or '), |
0a73c4bd9f47
graphlog: implement --follow-first
Patrick Mezard <patrick@mezard.eu>
parents:
16173
diff
changeset
|
75 |
'_patslog': ('filelog(%(val)r)', ' or '), |
0a73c4bd9f47
graphlog: implement --follow-first
Patrick Mezard <patrick@mezard.eu>
parents:
16173
diff
changeset
|
76 |
'_patsfollow': ('follow(%(val)r)', ' or '), |
0a73c4bd9f47
graphlog: implement --follow-first
Patrick Mezard <patrick@mezard.eu>
parents:
16173
diff
changeset
|
77 |
'_patsfollowfirst': ('_followfirst(%(val)r)', ' or '), |
0a73c4bd9f47
graphlog: implement --follow-first
Patrick Mezard <patrick@mezard.eu>
parents:
16173
diff
changeset
|
78 |
'keyword': ('keyword(%(val)r)', ' or '), |
0a73c4bd9f47
graphlog: implement --follow-first
Patrick Mezard <patrick@mezard.eu>
parents:
16173
diff
changeset
|
79 |
'prune': ('not (%(val)r or ancestors(%(val)r))', ' and '), |
0a73c4bd9f47
graphlog: implement --follow-first
Patrick Mezard <patrick@mezard.eu>
parents:
16173
diff
changeset
|
80 |
'user': ('user(%(val)r)', ' or '), |
14085
4852753dae36
graphlog: unify log -G revset translation
Patrick Mezard <pmezard@gmail.com>
parents:
14084
diff
changeset
|
81 |
} |
16157
4a828d3bc04a
graphlog: --branch and --only-branch are the same
Patrick Mezard <patrick@mezard.eu>
parents:
16150
diff
changeset
|
82 |
|
16159
ec33539b61f6
graphlog: paths arguments must be or'ed
Patrick Mezard <patrick@mezard.eu>
parents:
16158
diff
changeset
|
83 |
opts = dict(opts) |
16405
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
84 |
# follow or not follow? |
16174
0a73c4bd9f47
graphlog: implement --follow-first
Patrick Mezard <patrick@mezard.eu>
parents:
16173
diff
changeset
|
85 |
follow = opts.get('follow') or opts.get('follow_first') |
16433
e38b29937118
graphlog: reduce duplication in --follow code
Patrick Mezard <patrick@mezard.eu>
parents:
16432
diff
changeset
|
86 |
followfirst = opts.get('follow_first') and 1 or 0 |
16408
d74099ac2ac1
graphlog: fix --follow --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16407
diff
changeset
|
87 |
# --follow with FILE behaviour depends on revs... |
d74099ac2ac1
graphlog: fix --follow --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16407
diff
changeset
|
88 |
startrev = revs[0] |
16433
e38b29937118
graphlog: reduce duplication in --follow code
Patrick Mezard <patrick@mezard.eu>
parents:
16432
diff
changeset
|
89 |
followdescendants = (len(revs) > 1 and revs[0] < revs[1]) and 1 or 0 |
16405
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
90 |
|
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
91 |
# branch and only_branch are really aliases and must be handled at |
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
92 |
# the same time |
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
93 |
opts['branch'] = opts.get('branch', []) + opts.get('only_branch', []) |
16407
49ef1c382965
graphlog: support changeset identifiers in --branch
Patrick Mezard <patrick@mezard.eu>
parents:
16406
diff
changeset
|
94 |
opts['branch'] = [repo.lookupbranch(b) for b in opts['branch']] |
16171
336e61875335
graphlog: restore FILE glob expansion on Windows
Patrick Mezard <patrick@mezard.eu>
parents:
16161
diff
changeset
|
95 |
# pats/include/exclude are passed to match.match() directly in |
336e61875335
graphlog: restore FILE glob expansion on Windows
Patrick Mezard <patrick@mezard.eu>
parents:
16161
diff
changeset
|
96 |
# _matchfile() revset but walkchangerevs() builds its matcher with |
336e61875335
graphlog: restore FILE glob expansion on Windows
Patrick Mezard <patrick@mezard.eu>
parents:
16161
diff
changeset
|
97 |
# scmutil.match(). The difference is input pats are globbed on |
336e61875335
graphlog: restore FILE glob expansion on Windows
Patrick Mezard <patrick@mezard.eu>
parents:
16161
diff
changeset
|
98 |
# platforms without shell expansion (windows). |
16173
9178d284b880
graphlog: implement --follow with file arguments
Patrick Mezard <patrick@mezard.eu>
parents:
16171
diff
changeset
|
99 |
pctx = repo[None] |
9178d284b880
graphlog: implement --follow with file arguments
Patrick Mezard <patrick@mezard.eu>
parents:
16171
diff
changeset
|
100 |
match, pats = scmutil.matchandpats(pctx, pats, opts) |
16160
1bfc7ba8b404
graphlog: imitate log slowpath when inputs are explicit files
Patrick Mezard <patrick@mezard.eu>
parents:
16159
diff
changeset
|
101 |
slowpath = match.anypats() or (match.files() and opts.get('removed')) |
1bfc7ba8b404
graphlog: imitate log slowpath when inputs are explicit files
Patrick Mezard <patrick@mezard.eu>
parents:
16159
diff
changeset
|
102 |
if not slowpath: |
1bfc7ba8b404
graphlog: imitate log slowpath when inputs are explicit files
Patrick Mezard <patrick@mezard.eu>
parents:
16159
diff
changeset
|
103 |
for f in match.files(): |
16173
9178d284b880
graphlog: implement --follow with file arguments
Patrick Mezard <patrick@mezard.eu>
parents:
16171
diff
changeset
|
104 |
if follow and f not in pctx: |
9178d284b880
graphlog: implement --follow with file arguments
Patrick Mezard <patrick@mezard.eu>
parents:
16171
diff
changeset
|
105 |
raise util.Abort(_('cannot follow file not in parent ' |
9178d284b880
graphlog: implement --follow with file arguments
Patrick Mezard <patrick@mezard.eu>
parents:
16171
diff
changeset
|
106 |
'revision: "%s"') % f) |
16160
1bfc7ba8b404
graphlog: imitate log slowpath when inputs are explicit files
Patrick Mezard <patrick@mezard.eu>
parents:
16159
diff
changeset
|
107 |
filelog = repo.file(f) |
1bfc7ba8b404
graphlog: imitate log slowpath when inputs are explicit files
Patrick Mezard <patrick@mezard.eu>
parents:
16159
diff
changeset
|
108 |
if not len(filelog): |
1bfc7ba8b404
graphlog: imitate log slowpath when inputs are explicit files
Patrick Mezard <patrick@mezard.eu>
parents:
16159
diff
changeset
|
109 |
# A zero count may be a directory or deleted file, so |
1bfc7ba8b404
graphlog: imitate log slowpath when inputs are explicit files
Patrick Mezard <patrick@mezard.eu>
parents:
16159
diff
changeset
|
110 |
# try to find matching entries on the slow path. |
16173
9178d284b880
graphlog: implement --follow with file arguments
Patrick Mezard <patrick@mezard.eu>
parents:
16171
diff
changeset
|
111 |
if follow: |
9178d284b880
graphlog: implement --follow with file arguments
Patrick Mezard <patrick@mezard.eu>
parents:
16171
diff
changeset
|
112 |
raise util.Abort( |
9178d284b880
graphlog: implement --follow with file arguments
Patrick Mezard <patrick@mezard.eu>
parents:
16171
diff
changeset
|
113 |
_('cannot follow nonexistent file: "%s"') % f) |
16160
1bfc7ba8b404
graphlog: imitate log slowpath when inputs are explicit files
Patrick Mezard <patrick@mezard.eu>
parents:
16159
diff
changeset
|
114 |
slowpath = True |
1bfc7ba8b404
graphlog: imitate log slowpath when inputs are explicit files
Patrick Mezard <patrick@mezard.eu>
parents:
16159
diff
changeset
|
115 |
if slowpath: |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16160
diff
changeset
|
116 |
# See cmdutil.walkchangerevs() slow path. |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16160
diff
changeset
|
117 |
# |
16173
9178d284b880
graphlog: implement --follow with file arguments
Patrick Mezard <patrick@mezard.eu>
parents:
16171
diff
changeset
|
118 |
if follow: |
9178d284b880
graphlog: implement --follow with file arguments
Patrick Mezard <patrick@mezard.eu>
parents:
16171
diff
changeset
|
119 |
raise util.Abort(_('can only follow copies/renames for explicit ' |
9178d284b880
graphlog: implement --follow with file arguments
Patrick Mezard <patrick@mezard.eu>
parents:
16171
diff
changeset
|
120 |
'filenames')) |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16160
diff
changeset
|
121 |
# pats/include/exclude cannot be represented as separate |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16160
diff
changeset
|
122 |
# revset expressions as their filtering logic applies at file |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16160
diff
changeset
|
123 |
# level. For instance "-I a -X a" matches a revision touching |
16181
1fd352aa08fc
graphlog: evaluate FILE/-I/-X filesets on the working dir
Patrick Mezard <patrick@mezard.eu>
parents:
16180
diff
changeset
|
124 |
# "a" and "b" while "file(a) and not file(b)" does |
1fd352aa08fc
graphlog: evaluate FILE/-I/-X filesets on the working dir
Patrick Mezard <patrick@mezard.eu>
parents:
16180
diff
changeset
|
125 |
# not. Besides, filesets are evaluated against the working |
1fd352aa08fc
graphlog: evaluate FILE/-I/-X filesets on the working dir
Patrick Mezard <patrick@mezard.eu>
parents:
16180
diff
changeset
|
126 |
# directory. |
16411
4c2edcd84175
graphlog: correctly handle calls in subdirectories
Patrick Mezard <patrick@mezard.eu>
parents:
16409
diff
changeset
|
127 |
matchargs = ['r:', 'd:relpath'] |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16160
diff
changeset
|
128 |
for p in pats: |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16160
diff
changeset
|
129 |
matchargs.append('p:' + p) |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16160
diff
changeset
|
130 |
for p in opts.get('include', []): |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16160
diff
changeset
|
131 |
matchargs.append('i:' + p) |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16160
diff
changeset
|
132 |
for p in opts.get('exclude', []): |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16160
diff
changeset
|
133 |
matchargs.append('x:' + p) |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16160
diff
changeset
|
134 |
matchargs = ','.join(('%r' % p) for p in matchargs) |
16316
0f1e621d3d3b
graphlog: handle old-style --rev values
Patrick Mezard <patrick@mezard.eu>
parents:
16314
diff
changeset
|
135 |
opts['_matchfiles'] = matchargs |
16160
1bfc7ba8b404
graphlog: imitate log slowpath when inputs are explicit files
Patrick Mezard <patrick@mezard.eu>
parents:
16159
diff
changeset
|
136 |
else: |
16173
9178d284b880
graphlog: implement --follow with file arguments
Patrick Mezard <patrick@mezard.eu>
parents:
16171
diff
changeset
|
137 |
if follow: |
16433
e38b29937118
graphlog: reduce duplication in --follow code
Patrick Mezard <patrick@mezard.eu>
parents:
16432
diff
changeset
|
138 |
fpats = ('_patsfollow', '_patsfollowfirst') |
e38b29937118
graphlog: reduce duplication in --follow code
Patrick Mezard <patrick@mezard.eu>
parents:
16432
diff
changeset
|
139 |
fnopats = (('_ancestors', '_fancestors'), |
e38b29937118
graphlog: reduce duplication in --follow code
Patrick Mezard <patrick@mezard.eu>
parents:
16432
diff
changeset
|
140 |
('_descendants', '_fdescendants')) |
e38b29937118
graphlog: reduce duplication in --follow code
Patrick Mezard <patrick@mezard.eu>
parents:
16432
diff
changeset
|
141 |
if pats: |
16434
8b62a77d0895
graphlog: fix --follow FILE and relative paths
Patrick Mezard <patrick@mezard.eu>
parents:
16433
diff
changeset
|
142 |
# follow() revset inteprets its file argument as a |
8b62a77d0895
graphlog: fix --follow FILE and relative paths
Patrick Mezard <patrick@mezard.eu>
parents:
16433
diff
changeset
|
143 |
# manifest entry, so use match.files(), not pats. |
8b62a77d0895
graphlog: fix --follow FILE and relative paths
Patrick Mezard <patrick@mezard.eu>
parents:
16433
diff
changeset
|
144 |
opts[fpats[followfirst]] = list(match.files()) |
16173
9178d284b880
graphlog: implement --follow with file arguments
Patrick Mezard <patrick@mezard.eu>
parents:
16171
diff
changeset
|
145 |
else: |
16433
e38b29937118
graphlog: reduce duplication in --follow code
Patrick Mezard <patrick@mezard.eu>
parents:
16432
diff
changeset
|
146 |
opts[fnopats[followdescendants][followfirst]] = str(startrev) |
16173
9178d284b880
graphlog: implement --follow with file arguments
Patrick Mezard <patrick@mezard.eu>
parents:
16171
diff
changeset
|
147 |
else: |
9178d284b880
graphlog: implement --follow with file arguments
Patrick Mezard <patrick@mezard.eu>
parents:
16171
diff
changeset
|
148 |
opts['_patslog'] = list(pats) |
16157
4a828d3bc04a
graphlog: --branch and --only-branch are the same
Patrick Mezard <patrick@mezard.eu>
parents:
16150
diff
changeset
|
149 |
|
16186
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
150 |
filematcher = None |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
151 |
if opts.get('patch') or opts.get('stat'): |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
152 |
if follow: |
16412
1a10bee86e33
graphlog: cleanup before code move
Patrick Mezard <patrick@mezard.eu>
parents:
16411
diff
changeset
|
153 |
filematcher = _makefilematcher(repo, pats, followfirst) |
16186
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
154 |
else: |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
155 |
filematcher = lambda rev: match |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
156 |
|
16412
1a10bee86e33
graphlog: cleanup before code move
Patrick Mezard <patrick@mezard.eu>
parents:
16411
diff
changeset
|
157 |
expr = [] |
14043
1c1e1232abdc
graphlog: make use of graphmod's revset support
Alexander Solovyov <alexander@solovyov.net>
parents:
14042
diff
changeset
|
158 |
for op, val in opts.iteritems(): |
1c1e1232abdc
graphlog: make use of graphmod's revset support
Alexander Solovyov <alexander@solovyov.net>
parents:
14042
diff
changeset
|
159 |
if not val: |
1c1e1232abdc
graphlog: make use of graphmod's revset support
Alexander Solovyov <alexander@solovyov.net>
parents:
14042
diff
changeset
|
160 |
continue |
14085
4852753dae36
graphlog: unify log -G revset translation
Patrick Mezard <pmezard@gmail.com>
parents:
14084
diff
changeset
|
161 |
if op not in opt2revset: |
4852753dae36
graphlog: unify log -G revset translation
Patrick Mezard <pmezard@gmail.com>
parents:
14084
diff
changeset
|
162 |
continue |
16147
5607d829bf17
graphlog: explicitely join multivalue parameters
Patrick Mezard <patrick@mezard.eu>
parents:
15032
diff
changeset
|
163 |
revop, andor = opt2revset[op] |
16158
e04cc21b01b2
graphlog: rewrite --rev like all other options
Patrick Mezard <patrick@mezard.eu>
parents:
16157
diff
changeset
|
164 |
if '%(val)' not in revop: |
16412
1a10bee86e33
graphlog: cleanup before code move
Patrick Mezard <patrick@mezard.eu>
parents:
16411
diff
changeset
|
165 |
expr.append(revop) |
14085
4852753dae36
graphlog: unify log -G revset translation
Patrick Mezard <pmezard@gmail.com>
parents:
14084
diff
changeset
|
166 |
else: |
16147
5607d829bf17
graphlog: explicitely join multivalue parameters
Patrick Mezard <patrick@mezard.eu>
parents:
15032
diff
changeset
|
167 |
if not isinstance(val, list): |
16412
1a10bee86e33
graphlog: cleanup before code move
Patrick Mezard <patrick@mezard.eu>
parents:
16411
diff
changeset
|
168 |
e = revop % {'val': val} |
16147
5607d829bf17
graphlog: explicitely join multivalue parameters
Patrick Mezard <patrick@mezard.eu>
parents:
15032
diff
changeset
|
169 |
else: |
16412
1a10bee86e33
graphlog: cleanup before code move
Patrick Mezard <patrick@mezard.eu>
parents:
16411
diff
changeset
|
170 |
e = '(' + andor.join((revop % {'val': v}) for v in val) + ')' |
1a10bee86e33
graphlog: cleanup before code move
Patrick Mezard <patrick@mezard.eu>
parents:
16411
diff
changeset
|
171 |
expr.append(e) |
14043
1c1e1232abdc
graphlog: make use of graphmod's revset support
Alexander Solovyov <alexander@solovyov.net>
parents:
14042
diff
changeset
|
172 |
|
16412
1a10bee86e33
graphlog: cleanup before code move
Patrick Mezard <patrick@mezard.eu>
parents:
16411
diff
changeset
|
173 |
if expr: |
1a10bee86e33
graphlog: cleanup before code move
Patrick Mezard <patrick@mezard.eu>
parents:
16411
diff
changeset
|
174 |
expr = '(' + ' and '.join(expr) + ')' |
14132
7d3bd0640262
graphlog: take the union of --rev specs instead of the intersection
Patrick Mezard <pmezard@gmail.com>
parents:
14130
diff
changeset
|
175 |
else: |
16412
1a10bee86e33
graphlog: cleanup before code move
Patrick Mezard <patrick@mezard.eu>
parents:
16411
diff
changeset
|
176 |
expr = None |
1a10bee86e33
graphlog: cleanup before code move
Patrick Mezard <patrick@mezard.eu>
parents:
16411
diff
changeset
|
177 |
return expr, filematcher |
14043
1c1e1232abdc
graphlog: make use of graphmod's revset support
Alexander Solovyov <alexander@solovyov.net>
parents:
14042
diff
changeset
|
178 |
|
16405
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
179 |
def getlogrevs(repo, pats, opts): |
16777
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
180 |
"""Return (revs, expr, filematcher) where revs is an iterable of |
16405
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
181 |
revision numbers, expr is a revset string built from log options |
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
182 |
and file patterns or None, and used to filter 'revs'. If --stat or |
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
183 |
--patch are not passed filematcher is None. Otherwise it is a |
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
184 |
callable taking a revision number and returning a match objects |
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
185 |
filtering the files to be detailed when displaying the revision. |
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
186 |
""" |
16777
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
187 |
def increasingrevs(repo, revs, matcher): |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
188 |
# The sorted input rev sequence is chopped in sub-sequences |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
189 |
# which are sorted in ascending order and passed to the |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
190 |
# matcher. The filtered revs are sorted again as they were in |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
191 |
# the original sub-sequence. This achieve several things: |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
192 |
# |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
193 |
# - getlogrevs() now returns a generator which behaviour is |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
194 |
# adapted to log need. First results come fast, last ones |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
195 |
# are batched for performances. |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
196 |
# |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
197 |
# - revset matchers often operate faster on revision in |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
198 |
# changelog order, because most filters deal with the |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
199 |
# changelog. |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
200 |
# |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
201 |
# - revset matchers can reorder revisions. "A or B" typically |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
202 |
# returns returns the revision matching A then the revision |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
203 |
# matching B. We want to hide this internal implementation |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
204 |
# detail from the caller, and sorting the filtered revision |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
205 |
# again achieves this. |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
206 |
for i, window in cmdutil.increasingwindows(0, len(revs), windowsize=1): |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
207 |
orevs = revs[i:i + window] |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
208 |
nrevs = set(matcher(repo, sorted(orevs))) |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
209 |
for rev in orevs: |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
210 |
if rev in nrevs: |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
211 |
yield rev |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
212 |
|
16405
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
213 |
if not len(repo): |
16777
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
214 |
return iter([]), None, None |
16408
d74099ac2ac1
graphlog: fix --follow --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16407
diff
changeset
|
215 |
# Default --rev value depends on --follow but --follow behaviour |
d74099ac2ac1
graphlog: fix --follow --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16407
diff
changeset
|
216 |
# depends on revisions resolved from --rev... |
d74099ac2ac1
graphlog: fix --follow --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16407
diff
changeset
|
217 |
follow = opts.get('follow') or opts.get('follow_first') |
16405
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
218 |
if opts.get('rev'): |
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
219 |
revs = scmutil.revrange(repo, opts['rev']) |
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
220 |
else: |
16408
d74099ac2ac1
graphlog: fix --follow --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16407
diff
changeset
|
221 |
if follow and len(repo) > 0: |
d74099ac2ac1
graphlog: fix --follow --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16407
diff
changeset
|
222 |
revs = scmutil.revrange(repo, ['.:0']) |
d74099ac2ac1
graphlog: fix --follow --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16407
diff
changeset
|
223 |
else: |
d74099ac2ac1
graphlog: fix --follow --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16407
diff
changeset
|
224 |
revs = range(len(repo) - 1, -1, -1) |
16405
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
225 |
if not revs: |
16777
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
226 |
return iter([]), None, None |
16405
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
227 |
expr, filematcher = _makelogrevset(repo, pats, opts, revs) |
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
228 |
if expr: |
16777
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
229 |
matcher = revset.match(repo.ui, expr) |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
230 |
revs = increasingrevs(repo, revs, matcher) |
16431
c85098cdd7df
graphlog: implement --hidden
Patrick Mezard <patrick@mezard.eu>
parents:
16412
diff
changeset
|
231 |
if not opts.get('hidden'): |
c85098cdd7df
graphlog: implement --hidden
Patrick Mezard <patrick@mezard.eu>
parents:
16412
diff
changeset
|
232 |
# --hidden is still experimental and not worth a dedicated revset |
c85098cdd7df
graphlog: implement --hidden
Patrick Mezard <patrick@mezard.eu>
parents:
16412
diff
changeset
|
233 |
# yet. Fortunately, filtering revision number is fast. |
16777
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
234 |
revs = (r for r in revs if r not in repo.changelog.hiddenrevs) |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
235 |
else: |
058e14da7044
graphlog: turn getlogrevs() into a generator
Patrick Mezard <patrick@mezard.eu>
parents:
16743
diff
changeset
|
236 |
revs = iter(revs) |
16405
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
237 |
return revs, expr, filematcher |
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
238 |
|
16186
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
239 |
def generate(ui, dag, displayer, showparents, edgefn, getrenamed=None, |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
240 |
filematcher=None): |
17179
0849d725e2f9
graphlog: extract ascii drawing code into graphmod
Patrick Mezard <patrick@mezard.eu>
parents:
17164
diff
changeset
|
241 |
seen, state = [], graphmod.asciistate() |
9369
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
242 |
for rev, type, ctx, parents in dag: |
17119
2e13c1bd34dc
graphlog: display obsolete changeset as "x"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16777
diff
changeset
|
243 |
char = 'o' |
2e13c1bd34dc
graphlog: display obsolete changeset as "x"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16777
diff
changeset
|
244 |
if ctx.node() in showparents: |
2e13c1bd34dc
graphlog: display obsolete changeset as "x"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16777
diff
changeset
|
245 |
char = '@' |
2e13c1bd34dc
graphlog: display obsolete changeset as "x"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16777
diff
changeset
|
246 |
elif ctx.obsolete(): |
2e13c1bd34dc
graphlog: display obsolete changeset as "x"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16777
diff
changeset
|
247 |
char = 'x' |
16180
46a96cc830c2
graphlog: implement --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
248 |
copies = None |
46a96cc830c2
graphlog: implement --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
249 |
if getrenamed and ctx.rev(): |
46a96cc830c2
graphlog: implement --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
250 |
copies = [] |
46a96cc830c2
graphlog: implement --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
251 |
for fn in ctx.files(): |
46a96cc830c2
graphlog: implement --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
252 |
rename = getrenamed(fn, ctx.rev()) |
46a96cc830c2
graphlog: implement --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
253 |
if rename: |
46a96cc830c2
graphlog: implement --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
254 |
copies.append((fn, rename[0])) |
16186
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
255 |
revmatchfn = None |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
256 |
if filematcher is not None: |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
257 |
revmatchfn = filematcher(ctx.rev()) |
af3e67354beb
graphlog: apply file filters --patch/--stat output
Patrick Mezard <patrick@mezard.eu>
parents:
16184
diff
changeset
|
258 |
displayer.show(ctx, copies=copies, matchfn=revmatchfn) |
17120
01d847e0fdc9
graphlog: don't truncate template value at last \n
Mads Kiilerich <mads@kiilerich.com>
parents:
17119
diff
changeset
|
259 |
lines = displayer.hunk.pop(rev).split('\n') |
01d847e0fdc9
graphlog: don't truncate template value at last \n
Mads Kiilerich <mads@kiilerich.com>
parents:
17119
diff
changeset
|
260 |
if not lines[-1]: |
01d847e0fdc9
graphlog: don't truncate template value at last \n
Mads Kiilerich <mads@kiilerich.com>
parents:
17119
diff
changeset
|
261 |
del lines[-1] |
12579
aa1faedeac5a
graphlog: style with header and footer (issue2395)
Mads Kiilerich <mads@kiilerich.com>
parents:
11776
diff
changeset
|
262 |
displayer.flush(rev) |
14130
5e4ec4119485
graphlog: display nodes with more than 2 predecessors
Patrick Mezard <pmezard@gmail.com>
parents:
14086
diff
changeset
|
263 |
edges = edgefn(type, char, lines, seen, rev, parents) |
5e4ec4119485
graphlog: display nodes with more than 2 predecessors
Patrick Mezard <pmezard@gmail.com>
parents:
14086
diff
changeset
|
264 |
for type, char, lines, coldata in edges: |
17179
0849d725e2f9
graphlog: extract ascii drawing code into graphmod
Patrick Mezard <patrick@mezard.eu>
parents:
17164
diff
changeset
|
265 |
graphmod.ascii(ui, state, type, char, lines, coldata) |
12579
aa1faedeac5a
graphlog: style with header and footer (issue2395)
Mads Kiilerich <mads@kiilerich.com>
parents:
11776
diff
changeset
|
266 |
displayer.close() |
9369
20140c249e63
graphlog: move common code into function again, change function types
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9368
diff
changeset
|
267 |
|
14311
9bbac962f4dd
graphlog: use cmdutil.command decorator
Adrian Buehlmann <adrian@cadifra.com>
parents:
14139
diff
changeset
|
268 |
@command('glog', |
16432
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
269 |
[('f', 'follow', None, |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
270 |
_('follow changeset history, or file history across copies and renames')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
271 |
('', 'follow-first', None, |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
272 |
_('only follow the first parent of merge changesets (DEPRECATED)')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
273 |
('d', 'date', '', _('show revisions matching date spec'), _('DATE')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
274 |
('C', 'copies', None, _('show copied files')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
275 |
('k', 'keyword', [], |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
276 |
_('do case-insensitive search for a given text'), _('TEXT')), |
14311
9bbac962f4dd
graphlog: use cmdutil.command decorator
Adrian Buehlmann <adrian@cadifra.com>
parents:
14139
diff
changeset
|
277 |
('r', 'rev', [], _('show the specified revision or range'), _('REV')), |
16432
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
278 |
('', 'removed', None, _('include revisions where files were removed')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
279 |
('m', 'only-merges', None, _('show only merges (DEPRECATED)')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
280 |
('u', 'user', [], _('revisions committed by user'), _('USER')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
281 |
('', 'only-branch', [], |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
282 |
_('show only changesets within the given named branch (DEPRECATED)'), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
283 |
_('BRANCH')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
284 |
('b', 'branch', [], |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
285 |
_('show changesets within the given named branch'), _('BRANCH')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
286 |
('P', 'prune', [], |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
287 |
_('do not display revision or any of its ancestors'), _('REV')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
288 |
('', 'hidden', False, _('show hidden changesets (DEPRECATED)')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
289 |
] + commands.logopts + commands.walkopts, |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
290 |
_('[OPTION]... [FILE]')) |
14043
1c1e1232abdc
graphlog: make use of graphmod's revset support
Alexander Solovyov <alexander@solovyov.net>
parents:
14042
diff
changeset
|
291 |
def graphlog(ui, repo, *pats, **opts): |
7325
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
292 |
"""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
|
293 |
|
9259
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
294 |
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
|
295 |
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
|
296 |
|
9259
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
297 |
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
|
298 |
directory. |
7325
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
299 |
""" |
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
300 |
|
16405
17deb6bbfbab
graphlog: refactor revset() to return revisions
Patrick Mezard <patrick@mezard.eu>
parents:
16316
diff
changeset
|
301 |
revs, expr, filematcher = getlogrevs(repo, pats, opts) |
16316
0f1e621d3d3b
graphlog: handle old-style --rev values
Patrick Mezard <patrick@mezard.eu>
parents:
16314
diff
changeset
|
302 |
revs = sorted(revs, reverse=1) |
14133
28085b82f801
graphlog: always sort revisions topologically
Patrick Mezard <pmezard@gmail.com>
parents:
14132
diff
changeset
|
303 |
limit = cmdutil.loglimit(opts) |
28085b82f801
graphlog: always sort revisions topologically
Patrick Mezard <pmezard@gmail.com>
parents:
14132
diff
changeset
|
304 |
if limit is not None: |
28085b82f801
graphlog: always sort revisions topologically
Patrick Mezard <pmezard@gmail.com>
parents:
14132
diff
changeset
|
305 |
revs = revs[:limit] |
14043
1c1e1232abdc
graphlog: make use of graphmod's revset support
Alexander Solovyov <alexander@solovyov.net>
parents:
14042
diff
changeset
|
306 |
revdag = graphmod.dagwalker(repo, revs) |
7325
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
307 |
|
16180
46a96cc830c2
graphlog: implement --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
308 |
getrenamed = None |
46a96cc830c2
graphlog: implement --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
309 |
if opts.get('copies'): |
46a96cc830c2
graphlog: implement --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
310 |
endrev = None |
46a96cc830c2
graphlog: implement --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
311 |
if opts.get('rev'): |
46a96cc830c2
graphlog: implement --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
312 |
endrev = max(scmutil.revrange(repo, opts.get('rev'))) + 1 |
46a96cc830c2
graphlog: implement --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
313 |
getrenamed = templatekw.getrenamedfn(repo, endrev=endrev) |
9368
8a4773bcbaec
graphlog: extract some setup code out of common functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9259
diff
changeset
|
314 |
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
|
315 |
showparents = [ctx.node() for ctx in repo[None].parents()] |
17179
0849d725e2f9
graphlog: extract ascii drawing code into graphmod
Patrick Mezard <patrick@mezard.eu>
parents:
17164
diff
changeset
|
316 |
generate(ui, revdag, displayer, showparents, graphmod.asciiedges, |
0849d725e2f9
graphlog: extract ascii drawing code into graphmod
Patrick Mezard <patrick@mezard.eu>
parents:
17164
diff
changeset
|
317 |
getrenamed, filematcher) |
7716
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
318 |
|
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
319 |
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
|
320 |
limit = cmdutil.loglimit(opts) |
8837
d8e3a98018cb
graphmod/graphlog: extract nodelistwalk
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
8836
diff
changeset
|
321 |
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
|
322 |
if limit is not None: |
8837
d8e3a98018cb
graphmod/graphlog: extract nodelistwalk
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
8836
diff
changeset
|
323 |
nodes = nodes[:limit] |
d8e3a98018cb
graphmod/graphlog: extract nodelistwalk
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
8836
diff
changeset
|
324 |
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
|
325 |
|
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
326 |
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
|
327 |
"""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
|
328 |
|
7716
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
329 |
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
|
330 |
ASCII characters. |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
331 |
|
7716
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
332 |
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
|
333 |
directory. |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
334 |
""" |
7716
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
335 |
|
17163
4c5d7124661a
graphlog: make functions private, fix names
Patrick Mezard <patrick@mezard.eu>
parents:
17162
diff
changeset
|
336 |
_checkunsupportedflags([], opts) |
12735
8888e56ac417
outgoing: unify common graphlog.outgoing and hg.outgoing code
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12730
diff
changeset
|
337 |
o = hg._outgoing(ui, repo, dest, opts) |
8888e56ac417
outgoing: unify common graphlog.outgoing and hg.outgoing code
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12730
diff
changeset
|
338 |
if o is None: |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
339 |
return |
7716
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
340 |
|
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
341 |
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
|
342 |
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
|
343 |
showparents = [ctx.node() for ctx in repo[None].parents()] |
17179
0849d725e2f9
graphlog: extract ascii drawing code into graphmod
Patrick Mezard <patrick@mezard.eu>
parents:
17164
diff
changeset
|
344 |
generate(ui, revdag, displayer, showparents, graphmod.asciiedges) |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
345 |
|
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
346 |
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
|
347 |
"""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
|
348 |
|
9259
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
349 |
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
|
350 |
ASCII characters. |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
351 |
|
9259
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
352 |
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
|
353 |
directory. |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
354 |
""" |
12730
33e1fd2aeb3c
incoming: unify code for incoming and graphlog.incoming
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12579
diff
changeset
|
355 |
def subreporecurse(): |
33e1fd2aeb3c
incoming: unify code for incoming and graphlog.incoming
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12579
diff
changeset
|
356 |
return 1 |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
357 |
|
17163
4c5d7124661a
graphlog: make functions private, fix names
Patrick Mezard <patrick@mezard.eu>
parents:
17162
diff
changeset
|
358 |
_checkunsupportedflags([], opts) |
12730
33e1fd2aeb3c
incoming: unify code for incoming and graphlog.incoming
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12579
diff
changeset
|
359 |
def display(other, chlist, displayer): |
7716
4ad12930a459
graphlog: extract large parts of repeated code from incoming/outgoing
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7715
diff
changeset
|
360 |
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
|
361 |
showparents = [ctx.node() for ctx in repo[None].parents()] |
17179
0849d725e2f9
graphlog: extract ascii drawing code into graphmod
Patrick Mezard <patrick@mezard.eu>
parents:
17164
diff
changeset
|
362 |
generate(ui, revdag, displayer, showparents, graphmod.asciiedges) |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
363 |
|
12730
33e1fd2aeb3c
incoming: unify code for incoming and graphlog.incoming
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12579
diff
changeset
|
364 |
hg._incoming(display, subreporecurse, ui, repo, source, opts, buffered=True) |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
365 |
|
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
366 |
def uisetup(ui): |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
367 |
'''Initialize the extension.''' |
14416
253bda94372e
graphlog: remove unused arg from _wrapcmd
Idan Kamara <idankk86@gmail.com>
parents:
14319
diff
changeset
|
368 |
_wrapcmd('log', commands.table, graphlog) |
253bda94372e
graphlog: remove unused arg from _wrapcmd
Idan Kamara <idankk86@gmail.com>
parents:
14319
diff
changeset
|
369 |
_wrapcmd('incoming', commands.table, gincoming) |
253bda94372e
graphlog: remove unused arg from _wrapcmd
Idan Kamara <idankk86@gmail.com>
parents:
14319
diff
changeset
|
370 |
_wrapcmd('outgoing', commands.table, goutgoing) |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
371 |
|
14416
253bda94372e
graphlog: remove unused arg from _wrapcmd
Idan Kamara <idankk86@gmail.com>
parents:
14319
diff
changeset
|
372 |
def _wrapcmd(cmd, table, wrapfn): |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
373 |
'''wrap the command''' |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
374 |
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
|
375 |
if kwargs['graph']: |
14043
1c1e1232abdc
graphlog: make use of graphmod's revset support
Alexander Solovyov <alexander@solovyov.net>
parents:
14042
diff
changeset
|
376 |
return wrapfn(*args, **kwargs) |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
377 |
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
|
378 |
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
|
379 |
entry[1].append(('G', 'graph', None, _("show the revision DAG"))) |