Mercurial > hg
annotate mercurial/cmdutil.py @ 5880:b32a0596b2d7
convert: fix invalid svn.ra.check_path() call (issue 771)
The svn transport must be reparented to repository root before using
check_path() with full entrypaths.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sat, 19 Jan 2008 14:39:30 +0100 |
parents | 7a64931e2d76 |
children | 5a124ce4602a |
rev | line source |
---|---|
2957 | 1 # cmdutil.py - help for command processing in mercurial |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
2 # |
4635
63b9d2deed48
Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4633
diff
changeset
|
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
4 # |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
6 # of the GNU General Public License, incorporated herein by reference. |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
7 |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
8 from node import * |
3891 | 9 from i18n import _ |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5177
diff
changeset
|
10 import os, sys, bisect, stat |
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5177
diff
changeset
|
11 import mdiff, bdiff, util, templater, patch |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
12 |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
13 revrangesep = ':' |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
14 |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
15 class UnknownCommand(Exception): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
16 """Exception raised if command is not in the command table.""" |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
17 class AmbiguousCommand(Exception): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
18 """Exception raised if command shortcut matches more than one command.""" |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
19 |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5177
diff
changeset
|
20 def findpossible(ui, cmd, table): |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
21 """ |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
22 Return cmd -> (aliases, command table entry) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
23 for each matching command. |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
24 Return debug commands (or their aliases) only if no normal command matches. |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
25 """ |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
26 choice = {} |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
27 debugchoice = {} |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5177
diff
changeset
|
28 for e in table.keys(): |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
29 aliases = e.lstrip("^").split("|") |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
30 found = None |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
31 if cmd in aliases: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
32 found = cmd |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
33 elif not ui.config("ui", "strict"): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
34 for a in aliases: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
35 if a.startswith(cmd): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
36 found = a |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
37 break |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
38 if found is not None: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
39 if aliases[0].startswith("debug") or found.startswith("debug"): |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5177
diff
changeset
|
40 debugchoice[found] = (aliases, table[e]) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
41 else: |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5177
diff
changeset
|
42 choice[found] = (aliases, table[e]) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
43 |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
44 if not choice and debugchoice: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
45 choice = debugchoice |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
46 |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
47 return choice |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
48 |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5177
diff
changeset
|
49 def findcmd(ui, cmd, table): |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
50 """Return (aliases, command table entry) for command string.""" |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5177
diff
changeset
|
51 choice = findpossible(ui, cmd, table) |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
52 |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
53 if choice.has_key(cmd): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
54 return choice[cmd] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
55 |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
56 if len(choice) > 1: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
57 clist = choice.keys() |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
58 clist.sort() |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
59 raise AmbiguousCommand(cmd, clist) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
60 |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
61 if choice: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
62 return choice.values()[0] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
63 |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
64 raise UnknownCommand(cmd) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
65 |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
66 def bail_if_changed(repo): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
67 modified, added, removed, deleted = repo.status()[:4] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
68 if modified or added or removed or deleted: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
69 raise util.Abort(_("outstanding uncommitted changes")) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
70 |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
71 def logmessage(opts): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
72 """ get the log message according to -m and -l option """ |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
73 message = opts['message'] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
74 logfile = opts['logfile'] |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
75 |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
76 if message and logfile: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
77 raise util.Abort(_('options --message and --logfile are mutually ' |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
78 'exclusive')) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
79 if not message and logfile: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
80 try: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
81 if logfile == '-': |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
82 message = sys.stdin.read() |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
83 else: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
84 message = open(logfile).read() |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
85 except IOError, inst: |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
86 raise util.Abort(_("can't read commit message '%s': %s") % |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
87 (logfile, inst.strerror)) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
88 return message |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
89 |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
90 def setremoteconfig(ui, opts): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
91 "copy remote options to ui tree" |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
92 if opts.get('ssh'): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
93 ui.setconfig("ui", "ssh", opts['ssh']) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
94 if opts.get('remotecmd'): |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
95 ui.setconfig("ui", "remotecmd", opts['remotecmd']) |
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
4548
diff
changeset
|
96 |
3707
67f44b825784
Removed unused ui parameter from revpair/revrange and fix its users.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3673
diff
changeset
|
97 def revpair(repo, revs): |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
98 '''return pair of nodes, given list of revisions. second item can |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
99 be None, meaning use working dir.''' |
3525
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
100 |
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
101 def revfix(repo, val, defval): |
3825
000d122071b5
fix hg diff -r ''
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3814
diff
changeset
|
102 if not val and val != 0 and defval is not None: |
3525
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
103 val = defval |
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
104 return repo.lookup(val) |
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
105 |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
106 if not revs: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
107 return repo.dirstate.parents()[0], None |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
108 end = None |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
109 if len(revs) == 1: |
3525
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
110 if revrangesep in revs[0]: |
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
111 start, end = revs[0].split(revrangesep, 1) |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
112 start = revfix(repo, start, 0) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
113 end = revfix(repo, end, repo.changelog.count() - 1) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
114 else: |
3525
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
115 start = revfix(repo, revs[0], None) |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
116 elif len(revs) == 2: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
117 if revrangesep in revs[0] or revrangesep in revs[1]: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
118 raise util.Abort(_('too many revisions specified')) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
119 start = revfix(repo, revs[0], None) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
120 end = revfix(repo, revs[1], None) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
121 else: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
122 raise util.Abort(_('too many revisions specified')) |
3525
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
123 return start, end |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
124 |
3707
67f44b825784
Removed unused ui parameter from revpair/revrange and fix its users.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3673
diff
changeset
|
125 def revrange(repo, revs): |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
126 """Yield revision as strings from a list of revision specifications.""" |
3525
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
127 |
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
128 def revfix(repo, val, defval): |
3718
7db88b094b14
fix hg log -r ''
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3707
diff
changeset
|
129 if not val and val != 0 and defval is not None: |
3525
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
130 return defval |
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
131 return repo.changelog.rev(repo.lookup(val)) |
cf0f8d9256c7
simplify revrange and revpair
Matt Mackall <mpm@selenic.com>
parents:
3524
diff
changeset
|
132 |
3526
68341c06bc61
Make revrange return a list of ints so that callers don't have to convert
Matt Mackall <mpm@selenic.com>
parents:
3525
diff
changeset
|
133 seen, l = {}, [] |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
134 for spec in revs: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
135 if revrangesep in spec: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
136 start, end = spec.split(revrangesep, 1) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
137 start = revfix(repo, start, 0) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
138 end = revfix(repo, end, repo.changelog.count() - 1) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
139 step = start > end and -1 or 1 |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
140 for rev in xrange(start, end+step, step): |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
141 if rev in seen: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
142 continue |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
143 seen[rev] = 1 |
3526
68341c06bc61
Make revrange return a list of ints so that callers don't have to convert
Matt Mackall <mpm@selenic.com>
parents:
3525
diff
changeset
|
144 l.append(rev) |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
145 else: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
146 rev = revfix(repo, spec, None) |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
147 if rev in seen: |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
148 continue |
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
149 seen[rev] = 1 |
3526
68341c06bc61
Make revrange return a list of ints so that callers don't have to convert
Matt Mackall <mpm@selenic.com>
parents:
3525
diff
changeset
|
150 l.append(rev) |
68341c06bc61
Make revrange return a list of ints so that callers don't have to convert
Matt Mackall <mpm@selenic.com>
parents:
3525
diff
changeset
|
151 |
68341c06bc61
Make revrange return a list of ints so that callers don't have to convert
Matt Mackall <mpm@selenic.com>
parents:
3525
diff
changeset
|
152 return l |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3072
diff
changeset
|
153 |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
154 def make_filename(repo, pat, node, |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
155 total=None, seqno=None, revwidth=None, pathname=None): |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
156 node_expander = { |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
157 'H': lambda: hex(node), |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
158 'R': lambda: str(repo.changelog.rev(node)), |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
159 'h': lambda: short(node), |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
160 } |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
161 expander = { |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
162 '%': lambda: '%', |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
163 'b': lambda: os.path.basename(repo.root), |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
164 } |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
165 |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
166 try: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
167 if node: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
168 expander.update(node_expander) |
4836
0e2d0a78f81a
archive: make the %r escape work.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4825
diff
changeset
|
169 if node: |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
170 expander['r'] = (lambda: |
4836
0e2d0a78f81a
archive: make the %r escape work.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4825
diff
changeset
|
171 str(repo.changelog.rev(node)).zfill(revwidth or 0)) |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
172 if total is not None: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
173 expander['N'] = lambda: str(total) |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
174 if seqno is not None: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
175 expander['n'] = lambda: str(seqno) |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
176 if total is not None and seqno is not None: |
3673
eb0b4a2d70a9
white space and line break cleanups
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3657
diff
changeset
|
177 expander['n'] = lambda: str(seqno).zfill(len(str(total))) |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
178 if pathname is not None: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
179 expander['s'] = lambda: os.path.basename(pathname) |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
180 expander['d'] = lambda: os.path.dirname(pathname) or '.' |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
181 expander['p'] = lambda: pathname |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
182 |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
183 newname = [] |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
184 patlen = len(pat) |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
185 i = 0 |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
186 while i < patlen: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
187 c = pat[i] |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
188 if c == '%': |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
189 i += 1 |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
190 c = pat[i] |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
191 c = expander[c]() |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
192 newname.append(c) |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
193 i += 1 |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
194 return ''.join(newname) |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
195 except KeyError, inst: |
3072
bc3fe3b5b785
Never apply string formatting to generated errors with util.Abort.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2958
diff
changeset
|
196 raise util.Abort(_("invalid format spec '%%%s' in output file name") % |
bc3fe3b5b785
Never apply string formatting to generated errors with util.Abort.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2958
diff
changeset
|
197 inst.args[0]) |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
198 |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
199 def make_file(repo, pat, node=None, |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
200 total=None, seqno=None, revwidth=None, mode='wb', pathname=None): |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
201 if not pat or pat == '-': |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
202 return 'w' in mode and sys.stdout or sys.stdin |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
203 if hasattr(pat, 'write') and 'w' in mode: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
204 return pat |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
205 if hasattr(pat, 'read') and 'r' in mode: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
206 return pat |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
207 return open(make_filename(repo, pat, node, total, seqno, revwidth, |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
208 pathname), |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
209 mode) |
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2874
diff
changeset
|
210 |
4197
492d0d5b6976
remove unused "head" hack from util._matcher
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4195
diff
changeset
|
211 def matchpats(repo, pats=[], opts={}, globbed=False, default=None): |
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2874
diff
changeset
|
212 cwd = repo.getcwd() |
4186
08d31e43592a
Leave normalization of patterns to util._matcher
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4055
diff
changeset
|
213 return util.cmdmatcher(repo.root, cwd, pats or [], opts.get('include'), |
4197
492d0d5b6976
remove unused "head" hack from util._matcher
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4195
diff
changeset
|
214 opts.get('exclude'), globbed=globbed, |
4195
e8ee8fdeddb1
change locate to use relglobs by default
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4186
diff
changeset
|
215 default=default) |
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2874
diff
changeset
|
216 |
4197
492d0d5b6976
remove unused "head" hack from util._matcher
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4195
diff
changeset
|
217 def walk(repo, pats=[], opts={}, node=None, badmatch=None, globbed=False, |
492d0d5b6976
remove unused "head" hack from util._matcher
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4195
diff
changeset
|
218 default=None): |
492d0d5b6976
remove unused "head" hack from util._matcher
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4195
diff
changeset
|
219 files, matchfn, anypats = matchpats(repo, pats, opts, globbed=globbed, |
492d0d5b6976
remove unused "head" hack from util._matcher
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4195
diff
changeset
|
220 default=default) |
3531
730ca93ed788
convert dict(zip(x,x)) to dict.fromkeys(x)
Matt Mackall <mpm@selenic.com>
parents:
3528
diff
changeset
|
221 exact = dict.fromkeys(files) |
4525
78b6add1f966
Add dirstate.pathto and localrepo.pathto.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4522
diff
changeset
|
222 cwd = repo.getcwd() |
3528 | 223 for src, fn in repo.walk(node=node, files=files, match=matchfn, |
224 badmatch=badmatch): | |
4525
78b6add1f966
Add dirstate.pathto and localrepo.pathto.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4522
diff
changeset
|
225 yield src, fn, repo.pathto(fn, cwd), fn in exact |
2883
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
226 |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
227 def findrenames(repo, added=None, removed=None, threshold=0.5): |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
228 '''find renamed files -- yields (before, after, score) tuples''' |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
229 if added is None or removed is None: |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
230 added, removed = repo.status()[1:3] |
3971
68a0fa81ad28
cmdutil.py: use contexts in findrenames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3891
diff
changeset
|
231 ctx = repo.changectx() |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
232 for a in added: |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
233 aa = repo.wread(a) |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
234 bestname, bestscore = None, threshold |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
235 for r in removed: |
3971
68a0fa81ad28
cmdutil.py: use contexts in findrenames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3891
diff
changeset
|
236 rr = ctx.filectx(r).data() |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
237 |
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
238 # bdiff.blocks() returns blocks of matching lines |
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
239 # count the number of bytes in each |
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
240 equal = 0 |
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
241 alines = mdiff.splitnewlines(aa) |
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
242 matches = bdiff.blocks(aa, rr) |
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
243 for x1,x2,y1,y2 in matches: |
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
244 for line in alines[x1:x2]: |
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
245 equal += len(line) |
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
246 |
4472
736e49292809
addremove: comparing two empty files caused ZeroDivisionError
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4380
diff
changeset
|
247 lengths = len(aa) + len(rr) |
736e49292809
addremove: comparing two empty files caused ZeroDivisionError
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4380
diff
changeset
|
248 if lengths: |
736e49292809
addremove: comparing two empty files caused ZeroDivisionError
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4380
diff
changeset
|
249 myscore = equal*2.0 / lengths |
736e49292809
addremove: comparing two empty files caused ZeroDivisionError
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4380
diff
changeset
|
250 if myscore >= bestscore: |
736e49292809
addremove: comparing two empty files caused ZeroDivisionError
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4380
diff
changeset
|
251 bestname, bestscore = r, myscore |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
4059
diff
changeset
|
252 if bestname: |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
253 yield bestname, a, bestscore |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
254 |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
255 def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None): |
2883
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
256 if dry_run is None: |
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
257 dry_run = opts.get('dry_run') |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
258 if similarity is None: |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
259 similarity = float(opts.get('similarity') or 0) |
2883
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
260 add, remove = [], [] |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
261 mapping = {} |
2883
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
262 for src, abs, rel, exact in walk(repo, pats, opts): |
4522
591322269fed
Use absolute paths in addremove.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4478
diff
changeset
|
263 target = repo.wjoin(abs) |
4906
30847b8af7ca
dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents:
4836
diff
changeset
|
264 if src == 'f' and abs not in repo.dirstate: |
2883
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
265 add.append(abs) |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
266 mapping[abs] = rel, exact |
2883
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
267 if repo.ui.verbose or not exact: |
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
268 repo.ui.status(_('adding %s\n') % ((pats and rel) or abs)) |
5487
7a64931e2d76
Fix file-changed-to-dir and dir-to-file commits (issue660).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5248
diff
changeset
|
269 if repo.dirstate[abs] != 'r' and (not util.lexists(target) |
7a64931e2d76
Fix file-changed-to-dir and dir-to-file commits (issue660).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5248
diff
changeset
|
270 or (os.path.isdir(target) and not os.path.islink(target))): |
2883
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
271 remove.append(abs) |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
272 mapping[abs] = rel, exact |
2883
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
273 if repo.ui.verbose or not exact: |
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
274 repo.ui.status(_('removing %s\n') % ((pats and rel) or abs)) |
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
275 if not dry_run: |
5487
7a64931e2d76
Fix file-changed-to-dir and dir-to-file commits (issue660).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5248
diff
changeset
|
276 repo.remove(remove) |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
277 repo.add(add) |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
278 if similarity > 0: |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
279 for old, new, score in findrenames(repo, add, remove, similarity): |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
280 oldrel, oldexact = mapping[old] |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
281 newrel, newexact = mapping[new] |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
282 if repo.ui.verbose or not oldexact or not newexact: |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
283 repo.ui.status(_('recording removal of %s as rename to %s ' |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
284 '(%d%% similar)\n') % |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
285 (oldrel, newrel, score * 100)) |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2957
diff
changeset
|
286 if not dry_run: |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4906
diff
changeset
|
287 repo.copy(old, new) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
288 |
4380
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
289 def service(opts, parentfn=None, initfn=None, runfn=None): |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
290 '''Run a command as a service.''' |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
291 |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
292 if opts['daemon'] and not opts['daemon_pipefds']: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
293 rfd, wfd = os.pipe() |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
294 args = sys.argv[:] |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
295 args.append('--daemon-pipefds=%d,%d' % (rfd, wfd)) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
296 pid = os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0), |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
297 args[0], args) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
298 os.close(wfd) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
299 os.read(rfd, 1) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
300 if parentfn: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
301 return parentfn(pid) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
302 else: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
303 os._exit(0) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
304 |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
305 if initfn: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
306 initfn() |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
307 |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
308 if opts['pid_file']: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
309 fp = open(opts['pid_file'], 'w') |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
310 fp.write(str(os.getpid()) + '\n') |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
311 fp.close() |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
312 |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
313 if opts['daemon_pipefds']: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
314 rfd, wfd = [int(x) for x in opts['daemon_pipefds'].split(',')] |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
315 os.close(rfd) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
316 try: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
317 os.setsid() |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
318 except AttributeError: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
319 pass |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
320 os.write(wfd, 'y') |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
321 os.close(wfd) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
322 sys.stdout.flush() |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
323 sys.stderr.flush() |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
324 fd = os.open(util.nulldev, os.O_RDWR) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
325 if fd != 0: os.dup2(fd, 0) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
326 if fd != 1: os.dup2(fd, 1) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
327 if fd != 2: os.dup2(fd, 2) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
328 if fd not in (0, 1, 2): os.close(fd) |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
329 |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
330 if runfn: |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
331 return runfn() |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4355
diff
changeset
|
332 |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
333 class changeset_printer(object): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
334 '''show changeset information when templating not requested.''' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
335 |
3876
1e0b94cfba0e
Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents:
3838
diff
changeset
|
336 def __init__(self, ui, repo, patch, buffered): |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
337 self.ui = ui |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
338 self.repo = repo |
3645
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
339 self.buffered = buffered |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
340 self.patch = patch |
3738
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
341 self.header = {} |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
342 self.hunk = {} |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
343 self.lastheader = None |
3645
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
344 |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
345 def flush(self, rev): |
3738
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
346 if rev in self.header: |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
347 h = self.header[rev] |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
348 if h != self.lastheader: |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
349 self.lastheader = h |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
350 self.ui.write(h) |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
351 del self.header[rev] |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
352 if rev in self.hunk: |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
353 self.ui.write(self.hunk[rev]) |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
354 del self.hunk[rev] |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
355 return 1 |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
356 return 0 |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
357 |
4351
3380eb6d7c32
fix 'hg <not-log> -v --template foo' with revisions without copies
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4229
diff
changeset
|
358 def show(self, rev=0, changenode=None, copies=(), **props): |
3738
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
359 if self.buffered: |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
360 self.ui.pushbuffer() |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
361 self._show(rev, changenode, copies, props) |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
362 self.hunk[rev] = self.ui.popbuffer() |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
363 else: |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
364 self._show(rev, changenode, copies, props) |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
365 |
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
366 def _show(self, rev, changenode, copies, props): |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
367 '''show a single changeset or file revision''' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
368 log = self.repo.changelog |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
369 if changenode is None: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
370 changenode = log.node(rev) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
371 elif not rev: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
372 rev = log.rev(changenode) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
373 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
374 if self.ui.quiet: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
375 self.ui.write("%d:%s\n" % (rev, short(changenode))) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
376 return |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
377 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
378 changes = log.read(changenode) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
379 date = util.datestr(changes[2]) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
380 extra = changes[5] |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
381 branch = extra.get("branch") |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
382 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
383 hexfunc = self.ui.debugflag and hex or short |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
384 |
4825
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
385 parents = [(p, hexfunc(log.node(p))) |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
386 for p in self._meaningful_parentrevs(log, rev)] |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
387 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
388 self.ui.write(_("changeset: %d:%s\n") % (rev, hexfunc(changenode))) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
389 |
4176
f9bbcebcacea
"default" is the default branch name
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4055
diff
changeset
|
390 # don't show the default branch name |
f9bbcebcacea
"default" is the default branch name
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4055
diff
changeset
|
391 if branch != 'default': |
3827
3674ca805a5b
log: convert branch names to the local encoding
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3825
diff
changeset
|
392 branch = util.tolocal(branch) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
393 self.ui.write(_("branch: %s\n") % branch) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
394 for tag in self.repo.nodetags(changenode): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
395 self.ui.write(_("tag: %s\n") % tag) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
396 for parent in parents: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
397 self.ui.write(_("parent: %d:%s\n") % parent) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
398 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
399 if self.ui.debugflag: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
400 self.ui.write(_("manifest: %d:%s\n") % |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
401 (self.repo.manifest.rev(changes[0]), hex(changes[0]))) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
402 self.ui.write(_("user: %s\n") % changes[1]) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
403 self.ui.write(_("date: %s\n") % date) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
404 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
405 if self.ui.debugflag: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
406 files = self.repo.status(log.parents(changenode)[0], changenode)[:3] |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
407 for key, value in zip([_("files:"), _("files+:"), _("files-:")], |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
408 files): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
409 if value: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
410 self.ui.write("%-12s %s\n" % (key, " ".join(value))) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
411 elif changes[3] and self.ui.verbose: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
412 self.ui.write(_("files: %s\n") % " ".join(changes[3])) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
413 if copies and self.ui.verbose: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
414 copies = ['%s (%s)' % c for c in copies] |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
415 self.ui.write(_("copies: %s\n") % ' '.join(copies)) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
416 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
417 if extra and self.ui.debugflag: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
418 extraitems = extra.items() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
419 extraitems.sort() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
420 for key, value in extraitems: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
421 self.ui.write(_("extra: %s=%s\n") |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
422 % (key, value.encode('string_escape'))) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
423 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
424 description = changes[4].strip() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
425 if description: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
426 if self.ui.verbose: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
427 self.ui.write(_("description:\n")) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
428 self.ui.write(description) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
429 self.ui.write("\n\n") |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
430 else: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
431 self.ui.write(_("summary: %s\n") % |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
432 description.splitlines()[0]) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
433 self.ui.write("\n") |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
434 |
3645
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
435 self.showpatch(changenode) |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
436 |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
437 def showpatch(self, node): |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
438 if self.patch: |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
439 prev = self.repo.changelog.parents(node)[0] |
4714
a741293793f6
Make changeset_printer respect ui diffopts
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4686
diff
changeset
|
440 patch.diff(self.repo, prev, node, match=self.patch, fp=self.ui, |
a741293793f6
Make changeset_printer respect ui diffopts
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4686
diff
changeset
|
441 opts=patch.diffopts(self.ui)) |
3645
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
442 self.ui.write("\n") |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
443 |
4825
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
444 def _meaningful_parentrevs(self, log, rev): |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
445 """Return list of meaningful (or all if debug) parentrevs for rev. |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
446 |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
447 For merges (two non-nullrev revisions) both parents are meaningful. |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
448 Otherwise the first parent revision is considered meaningful if it |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
449 is not the preceding revision. |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
450 """ |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
451 parents = log.parentrevs(rev) |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
452 if not self.ui.debugflag and parents[1] == nullrev: |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
453 if parents[0] >= rev - 1: |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
454 parents = [] |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
455 else: |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
456 parents = [parents[0]] |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
457 return parents |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
458 |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
459 |
3645
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
460 class changeset_templater(changeset_printer): |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
461 '''format changeset information.''' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
462 |
3876
1e0b94cfba0e
Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents:
3838
diff
changeset
|
463 def __init__(self, ui, repo, patch, mapfile, buffered): |
1e0b94cfba0e
Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents:
3838
diff
changeset
|
464 changeset_printer.__init__(self, ui, repo, patch, buffered) |
4352
051fb8c2567c
command line templates: add formatnode filter
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4351
diff
changeset
|
465 filters = templater.common_filters.copy() |
051fb8c2567c
command line templates: add formatnode filter
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4351
diff
changeset
|
466 filters['formatnode'] = (ui.debugflag and (lambda x: x) |
051fb8c2567c
command line templates: add formatnode filter
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4351
diff
changeset
|
467 or (lambda x: x[:12])) |
051fb8c2567c
command line templates: add formatnode filter
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4351
diff
changeset
|
468 self.t = templater.templater(mapfile, filters, |
051fb8c2567c
command line templates: add formatnode filter
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4351
diff
changeset
|
469 cache={ |
051fb8c2567c
command line templates: add formatnode filter
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4351
diff
changeset
|
470 'parent': '{rev}:{node|formatnode} ', |
051fb8c2567c
command line templates: add formatnode filter
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4351
diff
changeset
|
471 'manifest': '{rev}:{node|formatnode}', |
051fb8c2567c
command line templates: add formatnode filter
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4351
diff
changeset
|
472 'filecopy': '{name} ({source})'}) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
473 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
474 def use_template(self, t): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
475 '''set template string to use''' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
476 self.t.cache['changeset'] = t |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
477 |
3738
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
478 def _show(self, rev, changenode, copies, props): |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
479 '''show a single changeset or file revision''' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
480 log = self.repo.changelog |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
481 if changenode is None: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
482 changenode = log.node(rev) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
483 elif not rev: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
484 rev = log.rev(changenode) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
485 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
486 changes = log.read(changenode) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
487 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
488 def showlist(name, values, plural=None, **args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
489 '''expand set of values. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
490 name is name of key in template map. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
491 values is list of strings or dicts. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
492 plural is plural of name, if not simply name + 's'. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
493 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
494 expansion works like this, given name 'foo'. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
495 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
496 if values is empty, expand 'no_foos'. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
497 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
498 if 'foo' not in template map, return values as a string, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
499 joined by space. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
500 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
501 expand 'start_foos'. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
502 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
503 for each value, expand 'foo'. if 'last_foo' in template |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
504 map, expand it instead of 'foo' for last key. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
505 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
506 expand 'end_foos'. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
507 ''' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
508 if plural: names = plural |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
509 else: names = name + 's' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
510 if not values: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
511 noname = 'no_' + names |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
512 if noname in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
513 yield self.t(noname, **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
514 return |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
515 if name not in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
516 if isinstance(values[0], str): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
517 yield ' '.join(values) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
518 else: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
519 for v in values: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
520 yield dict(v, **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
521 return |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
522 startname = 'start_' + names |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
523 if startname in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
524 yield self.t(startname, **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
525 vargs = args.copy() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
526 def one(v, tag=name): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
527 try: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
528 vargs.update(v) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
529 except (AttributeError, ValueError): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
530 try: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
531 for a, b in v: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
532 vargs[a] = b |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
533 except ValueError: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
534 vargs[name] = v |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
535 return self.t(tag, **vargs) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
536 lastname = 'last_' + name |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
537 if lastname in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
538 last = values.pop() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
539 else: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
540 last = None |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
541 for v in values: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
542 yield one(v) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
543 if last is not None: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
544 yield one(last, tag=lastname) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
545 endname = 'end_' + names |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
546 if endname in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
547 yield self.t(endname, **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
548 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
549 def showbranches(**args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
550 branch = changes[5].get("branch") |
4176
f9bbcebcacea
"default" is the default branch name
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4055
diff
changeset
|
551 if branch != 'default': |
3827
3674ca805a5b
log: convert branch names to the local encoding
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3825
diff
changeset
|
552 branch = util.tolocal(branch) |
3648
2801a3efc7c3
changeset templater: convert some unnecessary yields to returns
Matt Mackall <mpm@selenic.com>
parents:
3645
diff
changeset
|
553 return showlist('branch', [branch], plural='branches', **args) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
554 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
555 def showparents(**args): |
4825
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
556 parents = [[('rev', p), ('node', hex(log.node(p)))] |
3cf94964c56b
hg log: Move filtering implicit parents to own method and use it in templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4824
diff
changeset
|
557 for p in self._meaningful_parentrevs(log, rev)] |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
558 return showlist('parent', parents, **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
559 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
560 def showtags(**args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
561 return showlist('tag', self.repo.nodetags(changenode), **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
562 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
563 def showextras(**args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
564 extras = changes[5].items() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
565 extras.sort() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
566 for key, value in extras: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
567 args = args.copy() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
568 args.update(dict(key=key, value=value)) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
569 yield self.t('extra', **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
570 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
571 def showcopies(**args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
572 c = [{'name': x[0], 'source': x[1]} for x in copies] |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
573 return showlist('file_copy', c, plural='file_copies', **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
574 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
575 if self.ui.debugflag: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
576 files = self.repo.status(log.parents(changenode)[0], changenode)[:3] |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
577 def showfiles(**args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
578 return showlist('file', files[0], **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
579 def showadds(**args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
580 return showlist('file_add', files[1], **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
581 def showdels(**args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
582 return showlist('file_del', files[2], **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
583 def showmanifest(**args): |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
584 args = args.copy() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
585 args.update(dict(rev=self.repo.manifest.rev(changes[0]), |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
586 node=hex(changes[0]))) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
587 return self.t('manifest', **args) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
588 else: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
589 def showfiles(**args): |
3648
2801a3efc7c3
changeset templater: convert some unnecessary yields to returns
Matt Mackall <mpm@selenic.com>
parents:
3645
diff
changeset
|
590 return showlist('file', changes[3], **args) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
591 showadds = '' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
592 showdels = '' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
593 showmanifest = '' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
594 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
595 defprops = { |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
596 'author': changes[1], |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
597 'branches': showbranches, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
598 'date': changes[2], |
4824
f3f84d5cd268
Strip whitespace from changeset description in changeset_templater.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4734
diff
changeset
|
599 'desc': changes[4].strip(), |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
600 'file_adds': showadds, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
601 'file_dels': showdels, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
602 'files': showfiles, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
603 'file_copies': showcopies, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
604 'manifest': showmanifest, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
605 'node': hex(changenode), |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
606 'parents': showparents, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
607 'rev': rev, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
608 'tags': showtags, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
609 'extras': showextras, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
610 } |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
611 props = props.copy() |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
612 props.update(defprops) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
613 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
614 try: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
615 if self.ui.debugflag and 'header_debug' in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
616 key = 'header_debug' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
617 elif self.ui.quiet and 'header_quiet' in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
618 key = 'header_quiet' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
619 elif self.ui.verbose and 'header_verbose' in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
620 key = 'header_verbose' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
621 elif 'header' in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
622 key = 'header' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
623 else: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
624 key = '' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
625 if key: |
3645
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
626 h = templater.stringify(self.t(key, **props)) |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
627 if self.buffered: |
3738
cb48cd27d3f4
use ui buffering in changeset printer
Matt Mackall <mpm@selenic.com>
parents:
3718
diff
changeset
|
628 self.header[rev] = h |
3645
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
629 else: |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
630 self.ui.write(h) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
631 if self.ui.debugflag and 'changeset_debug' in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
632 key = 'changeset_debug' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
633 elif self.ui.quiet and 'changeset_quiet' in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
634 key = 'changeset_quiet' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
635 elif self.ui.verbose and 'changeset_verbose' in self.t: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
636 key = 'changeset_verbose' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
637 else: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
638 key = 'changeset' |
3645
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
639 self.ui.write(templater.stringify(self.t(key, **props))) |
b984dcb1df71
Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents:
3643
diff
changeset
|
640 self.showpatch(changenode) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
641 except KeyError, inst: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
642 raise util.Abort(_("%s: no key named '%s'") % (self.t.mapfile, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
643 inst.args[0])) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
644 except SyntaxError, inst: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
645 raise util.Abort(_('%s: %s') % (self.t.mapfile, inst.args[0])) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
646 |
3837
7df171ea50cd
Fix log regression where log -p file showed diffs for other files
Matt Mackall <mpm@selenic.com>
parents:
3827
diff
changeset
|
647 def show_changeset(ui, repo, opts, buffered=False, matchfn=False): |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
648 """show one changeset using template or regular display. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
649 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
650 Display format will be the first non-empty hit of: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
651 1. option 'template' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
652 2. option 'style' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
653 3. [ui] setting 'logtemplate' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
654 4. [ui] setting 'style' |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
655 If all of these values are either the unset or the empty string, |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
656 regular display via changeset_printer() is done. |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
657 """ |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
658 # options |
3837
7df171ea50cd
Fix log regression where log -p file showed diffs for other files
Matt Mackall <mpm@selenic.com>
parents:
3827
diff
changeset
|
659 patch = False |
7df171ea50cd
Fix log regression where log -p file showed diffs for other files
Matt Mackall <mpm@selenic.com>
parents:
3827
diff
changeset
|
660 if opts.get('patch'): |
3838
dec4eba7ccad
Use util.always instead of creating a new lambda function in show_changeset
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3837
diff
changeset
|
661 patch = matchfn or util.always |
3837
7df171ea50cd
Fix log regression where log -p file showed diffs for other files
Matt Mackall <mpm@selenic.com>
parents:
3827
diff
changeset
|
662 |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
663 tmpl = opts.get('template') |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
664 mapfile = None |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
665 if tmpl: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
666 tmpl = templater.parsestring(tmpl, quoted=False) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
667 else: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
668 mapfile = opts.get('style') |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
669 # ui settings |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
670 if not mapfile: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
671 tmpl = ui.config('ui', 'logtemplate') |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
672 if tmpl: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
673 tmpl = templater.parsestring(tmpl) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
674 else: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
675 mapfile = ui.config('ui', 'style') |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
676 |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
677 if tmpl or mapfile: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
678 if mapfile: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
679 if not os.path.split(mapfile)[0]: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
680 mapname = (templater.templatepath('map-cmdline.' + mapfile) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
681 or templater.templatepath(mapfile)) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
682 if mapname: mapfile = mapname |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
683 try: |
3876
1e0b94cfba0e
Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents:
3838
diff
changeset
|
684 t = changeset_templater(ui, repo, patch, mapfile, buffered) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
685 except SyntaxError, inst: |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
686 raise util.Abort(inst.args[0]) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
687 if tmpl: t.use_template(tmpl) |
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
688 return t |
3876
1e0b94cfba0e
Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents:
3838
diff
changeset
|
689 return changeset_printer(ui, repo, patch, buffered) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3531
diff
changeset
|
690 |
3814
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
691 def finddate(ui, repo, date): |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
692 """Find the tipmost changeset that matches the given date spec""" |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
693 df = util.matchdate(date + " to " + date) |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
694 get = util.cachefunc(lambda r: repo.changectx(r).changeset()) |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
695 changeiter, matchfn = walkchangerevs(ui, repo, [], get, {'rev':None}) |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
696 results = {} |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
697 for st, rev, fns in changeiter: |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
698 if st == 'add': |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
699 d = get(rev)[2] |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
700 if df(d[0]): |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
701 results[rev] = d |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
702 elif st == 'iter': |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
703 if rev in results: |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
704 ui.status("Found revision %s from %s\n" % |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
705 (rev, util.datestr(results[rev]))) |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
706 return str(rev) |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
707 |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
708 raise util.Abort(_("revision matching date not found")) |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3738
diff
changeset
|
709 |
3650
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
710 def walkchangerevs(ui, repo, pats, change, opts): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
711 '''Iterate over files and the revs they changed in. |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
712 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
713 Callers most commonly need to iterate backwards over the history |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
714 it is interested in. Doing so has awful (quadratic-looking) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
715 performance, so we use iterators in a "windowed" way. |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
716 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
717 We walk a window of revisions in the desired order. Within the |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
718 window, we first walk forwards to gather data, then in the desired |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
719 order (usually backwards) to display it. |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
720 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
721 This function returns an (iterator, matchfn) tuple. The iterator |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
722 yields 3-tuples. They will be of one of the following forms: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
723 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
724 "window", incrementing, lastrev: stepping through a window, |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
725 positive if walking forwards through revs, last rev in the |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
726 sequence iterated over - use to reset state for the current window |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
727 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
728 "add", rev, fns: out-of-order traversal of the given file names |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
729 fns, which changed during revision rev - use to gather data for |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
730 possible display |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
731 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
732 "iter", rev, None: in-order traversal of the revs earlier iterated |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
733 over with "add" - use to display data''' |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
734 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
735 def increasing_windows(start, end, windowsize=8, sizelimit=512): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
736 if start < end: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
737 while start < end: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
738 yield start, min(windowsize, end-start) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
739 start += windowsize |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
740 if windowsize < sizelimit: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
741 windowsize *= 2 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
742 else: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
743 while start > end: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
744 yield start, min(windowsize, start-end-1) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
745 start -= windowsize |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
746 if windowsize < sizelimit: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
747 windowsize *= 2 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
748 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
749 files, matchfn, anypats = matchpats(repo, pats, opts) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
750 follow = opts.get('follow') or opts.get('follow_first') |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
751 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
752 if repo.changelog.count() == 0: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
753 return [], matchfn |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
754 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
755 if follow: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
756 defrange = '%s:0' % repo.changectx().rev() |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
757 else: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
758 defrange = 'tip:0' |
3707
67f44b825784
Removed unused ui parameter from revpair/revrange and fix its users.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3673
diff
changeset
|
759 revs = revrange(repo, opts['rev'] or [defrange]) |
3650
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
760 wanted = {} |
3657 | 761 slowpath = anypats or opts.get('removed') |
3650
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
762 fncache = {} |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
763 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
764 if not slowpath and not files: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
765 # No files, no patterns. Display all revs. |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
766 wanted = dict.fromkeys(revs) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
767 copies = [] |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
768 if not slowpath: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
769 # Only files, no patterns. Check the history of each file. |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
770 def filerevgen(filelog, node): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
771 cl_count = repo.changelog.count() |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
772 if node is None: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
773 last = filelog.count() - 1 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
774 else: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
775 last = filelog.rev(node) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
776 for i, window in increasing_windows(last, nullrev): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
777 revs = [] |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
778 for j in xrange(i - window, i + 1): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
779 n = filelog.node(j) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
780 revs.append((filelog.linkrev(n), |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
781 follow and filelog.renamed(n))) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
782 revs.reverse() |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
783 for rev in revs: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
784 # only yield rev for which we have the changelog, it can |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
785 # happen while doing "hg log" during a pull or commit |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
786 if rev[0] < cl_count: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
787 yield rev |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
788 def iterfiles(): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
789 for filename in files: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
790 yield filename, None |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
791 for filename_node in copies: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
792 yield filename_node |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
793 minrev, maxrev = min(revs), max(revs) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
794 for file_, node in iterfiles(): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
795 filelog = repo.file(file_) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
796 # A zero count may be a directory or deleted file, so |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
797 # try to find matching entries on the slow path. |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
798 if filelog.count() == 0: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
799 slowpath = True |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
800 break |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
801 for rev, copied in filerevgen(filelog, node): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
802 if rev <= maxrev: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
803 if rev < minrev: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
804 break |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
805 fncache.setdefault(rev, []) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
806 fncache[rev].append(file_) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
807 wanted[rev] = 1 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
808 if follow and copied: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
809 copies.append(copied) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
810 if slowpath: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
811 if follow: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
812 raise util.Abort(_('can only follow copies/renames for explicit ' |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
813 'file names')) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
814 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
815 # The slow path checks files modified in every changeset. |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
816 def changerevgen(): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
817 for i, window in increasing_windows(repo.changelog.count()-1, |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
818 nullrev): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
819 for j in xrange(i - window, i + 1): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
820 yield j, change(j)[3] |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
821 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
822 for rev, changefiles in changerevgen(): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
823 matches = filter(matchfn, changefiles) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
824 if matches: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
825 fncache[rev] = matches |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
826 wanted[rev] = 1 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
827 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
828 class followfilter: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
829 def __init__(self, onlyfirst=False): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
830 self.startrev = nullrev |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
831 self.roots = [] |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
832 self.onlyfirst = onlyfirst |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
833 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
834 def match(self, rev): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
835 def realparents(rev): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
836 if self.onlyfirst: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
837 return repo.changelog.parentrevs(rev)[0:1] |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
838 else: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
839 return filter(lambda x: x != nullrev, |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
840 repo.changelog.parentrevs(rev)) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
841 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
842 if self.startrev == nullrev: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
843 self.startrev = rev |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
844 return True |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
845 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
846 if rev > self.startrev: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
847 # forward: all descendants |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
848 if not self.roots: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
849 self.roots.append(self.startrev) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
850 for parent in realparents(rev): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
851 if parent in self.roots: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
852 self.roots.append(rev) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
853 return True |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
854 else: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
855 # backwards: all parents |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
856 if not self.roots: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
857 self.roots.extend(realparents(self.startrev)) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
858 if rev in self.roots: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
859 self.roots.remove(rev) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
860 self.roots.extend(realparents(rev)) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
861 return True |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
862 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
863 return False |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
864 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
865 # it might be worthwhile to do this in the iterator if the rev range |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
866 # is descending and the prune args are all within that range |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
867 for rev in opts.get('prune', ()): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
868 rev = repo.changelog.rev(repo.lookup(rev)) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
869 ff = followfilter() |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
870 stop = min(revs[0], revs[-1]) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
871 for x in xrange(rev, stop-1, -1): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
872 if ff.match(x) and x in wanted: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
873 del wanted[x] |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
874 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
875 def iterate(): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
876 if follow and not files: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
877 ff = followfilter(onlyfirst=opts.get('follow_first')) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
878 def want(rev): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
879 if ff.match(rev) and rev in wanted: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
880 return True |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
881 return False |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
882 else: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
883 def want(rev): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
884 return rev in wanted |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
885 |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
886 for i, window in increasing_windows(0, len(revs)): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
887 yield 'window', revs[0] < revs[-1], revs[-1] |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
888 nrevs = [rev for rev in revs[i:i+window] if want(rev)] |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
889 srevs = list(nrevs) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
890 srevs.sort() |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
891 for rev in srevs: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
892 fns = fncache.get(rev) |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
893 if not fns: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
894 def fns_generator(): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
895 for f in change(rev)[3]: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
896 if matchfn(f): |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
897 yield f |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
898 fns = fns_generator() |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
899 yield 'add', rev, fns |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
900 for rev in nrevs: |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
901 yield 'iter', rev, None |
731e739b8659
move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3649
diff
changeset
|
902 return iterate(), matchfn |
5034
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
903 |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
904 def commit(ui, repo, commitfunc, pats, opts): |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
905 '''commit the specified files or all outstanding changes''' |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
906 message = logmessage(opts) |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
907 |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
908 if opts['addremove']: |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
909 addremove(repo, pats, opts) |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
910 fns, match, anypats = matchpats(repo, pats, opts) |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
911 if pats: |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
912 status = repo.status(files=fns, match=match) |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
913 modified, added, removed, deleted, unknown = status[:5] |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
914 files = modified + added + removed |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
915 slist = None |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
916 for f in fns: |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
917 if f == '.': |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
918 continue |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
919 if f not in files: |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
920 rf = repo.wjoin(f) |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
921 try: |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
922 mode = os.lstat(rf)[stat.ST_MODE] |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
923 except OSError: |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
924 raise util.Abort(_("file %s not found!") % rf) |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
925 if stat.S_ISDIR(mode): |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
926 name = f + '/' |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
927 if slist is None: |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
928 slist = list(files) |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
929 slist.sort() |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
930 i = bisect.bisect(slist, name) |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
931 if i >= len(slist) or not slist[i].startswith(name): |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
932 raise util.Abort(_("no match under directory %s!") |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
933 % rf) |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
934 elif not (stat.S_ISREG(mode) or stat.S_ISLNK(mode)): |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
935 raise util.Abort(_("can't commit %s: " |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
936 "unsupported file type!") % rf) |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
937 elif f not in repo.dirstate: |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
938 raise util.Abort(_("file %s not tracked!") % rf) |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
939 else: |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
940 files = [] |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
941 try: |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
942 return commitfunc(ui, repo, files, message, match, opts) |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
943 except ValueError, inst: |
c0417a319e39
commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents:
4965
diff
changeset
|
944 raise util.Abort(str(inst)) |