author | Matt Mackall <mpm@selenic.com> |
Tue, 10 Oct 2006 00:07:46 -0500 | |
changeset 3305 | 0708bdb4987a |
parent 3284 | d89e98840b08 |
child 3317 | 399c04369a1b |
child 3318 | a225055b3b59 |
permissions | -rw-r--r-- |
249 | 1 |
# commands.py - command processing for mercurial |
2 |
# |
|
2859 | 3 |
# Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> |
249 | 4 |
# |
5 |
# This software may be used and distributed according to the terms |
|
6 |
# of the GNU General Public License, incorporated herein by reference. |
|
7 |
||
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
8 |
from demandload import demandload |
1092 | 9 |
from node import * |
1400
cf9a1233738a
i18n first part: make '_' available for files who need it
Benoit Boissinot <benoit.boissinot@ens-lyon.org
parents:
1395
diff
changeset
|
10 |
from i18n import gettext as _ |
3068
15526271eafb
allow shell-quoting in command defaults
TK Soh <teekaysoh@yahoo.com>
parents:
3029
diff
changeset
|
11 |
demandload(globals(), "os re sys signal shutil imp urllib pdb shlex") |
1944
fdf40c9b3306
incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1943
diff
changeset
|
12 |
demandload(globals(), "fancyopts ui hg util lock revlog templater bundlerepo") |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
13 |
demandload(globals(), "fnmatch difflib patch random signal tempfile time") |
1944
fdf40c9b3306
incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1943
diff
changeset
|
14 |
demandload(globals(), "traceback errno socket version struct atexit sets bz2") |
2866
2893e51407a4
commands.import: refactor patch parsing into patch.extract.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2865
diff
changeset
|
15 |
demandload(globals(), "archival cStringIO changegroup") |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
16 |
demandload(globals(), "cmdutil hgweb.server sshserver") |
209 | 17 |
|
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
18 |
class UnknownCommand(Exception): |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
19 |
"""Exception raised if command is not in the command table.""" |
1518
ac4ca6bf2383
Improved error message for ambiguous command shortcuts.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1517
diff
changeset
|
20 |
class AmbiguousCommand(Exception): |
ac4ca6bf2383
Improved error message for ambiguous command shortcuts.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1517
diff
changeset
|
21 |
"""Exception raised if command shortcut matches more than one command.""" |
209 | 22 |
|
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
23 |
def bail_if_changed(repo): |
2875
3d6efcbbd1c9
remove localrepository.changes.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2874
diff
changeset
|
24 |
modified, added, removed, deleted = repo.status()[:4] |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
25 |
if modified or added or removed or deleted: |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
26 |
raise util.Abort(_("outstanding uncommitted changes")) |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
27 |
|
209 | 28 |
def relpath(repo, args): |
628
8d7f6e68828a
Use repo.getcwd() in a few obvious places.
Bryan O'Sullivan <bos@serpentine.com>
parents:
627
diff
changeset
|
29 |
cwd = repo.getcwd() |
8d7f6e68828a
Use repo.getcwd() in a few obvious places.
Bryan O'Sullivan <bos@serpentine.com>
parents:
627
diff
changeset
|
30 |
if cwd: |
886
509de8ab6f31
Fix walk path handling on Windows
Bryan O'Sullivan <bos@serpentine.com>
parents:
884
diff
changeset
|
31 |
return [util.normpath(os.path.join(cwd, x)) for x in args] |
209 | 32 |
return args |
245 | 33 |
|
2799
bd8a9a94139f
commands.logmessage: simplify calling.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2789
diff
changeset
|
34 |
def logmessage(opts): |
2694
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
35 |
""" get the log message according to -m and -l option """ |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
36 |
message = opts['message'] |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
37 |
logfile = opts['logfile'] |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
38 |
|
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
39 |
if message and logfile: |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
40 |
raise util.Abort(_('options --message and --logfile are mutually ' |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
41 |
'exclusive')) |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
42 |
if not message and logfile: |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
43 |
try: |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
44 |
if logfile == '-': |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
45 |
message = sys.stdin.read() |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
46 |
else: |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
47 |
message = open(logfile).read() |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
48 |
except IOError, inst: |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
49 |
raise util.Abort(_("can't read commit message '%s': %s") % |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
50 |
(logfile, inst.strerror)) |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
51 |
return message |
0fb28dbf0dc7
MQ: uniformise message and logfile option.
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
2673
diff
changeset
|
52 |
|
1568
1d7d0c07e8f3
make all commands be repo-wide by default
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1567
diff
changeset
|
53 |
def walkchangerevs(ui, repo, pats, opts): |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
54 |
'''Iterate over files and the revs they changed in. |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
55 |
|
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
56 |
Callers most commonly need to iterate backwards over the history |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
57 |
it is interested in. Doing so has awful (quadratic-looking) |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
58 |
performance, so we use iterators in a "windowed" way. |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
59 |
|
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
60 |
We walk a window of revisions in the desired order. Within the |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
61 |
window, we first walk forwards to gather data, then in the desired |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
62 |
order (usually backwards) to display it. |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
63 |
|
1570
6a104941d56a
hg log -p should show file deletions
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1568
diff
changeset
|
64 |
This function returns an (iterator, getchange, matchfn) tuple. The |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
65 |
getchange function returns the changelog entry for a numeric |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
66 |
revision. The iterator yields 3-tuples. They will be of one of |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
67 |
the following forms: |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
68 |
|
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
69 |
"window", incrementing, lastrev: stepping through a window, |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
70 |
positive if walking forwards through revs, last rev in the |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
71 |
sequence iterated over - use to reset state for the current window |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
72 |
|
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
73 |
"add", rev, fns: out-of-order traversal of the given file names |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
74 |
fns, which changed during revision rev - use to gather data for |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
75 |
possible display |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
76 |
|
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
77 |
"iter", rev, None: in-order traversal of the revs earlier iterated |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
78 |
over with "add" - use to display data''' |
1337
d4b25df77a9e
Fix up some bugs for log and grep with empty repo
mpm@selenic.com
parents:
1331
diff
changeset
|
79 |
|
1799
b942f5cfd326
Replaced fixed window size for walkchangerevs with an increasing one. Window
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1782
diff
changeset
|
80 |
def increasing_windows(start, end, windowsize=8, sizelimit=512): |
b942f5cfd326
Replaced fixed window size for walkchangerevs with an increasing one. Window
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1782
diff
changeset
|
81 |
if start < end: |
b942f5cfd326
Replaced fixed window size for walkchangerevs with an increasing one. Window
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1782
diff
changeset
|
82 |
while start < end: |
b942f5cfd326
Replaced fixed window size for walkchangerevs with an increasing one. Window
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1782
diff
changeset
|
83 |
yield start, min(windowsize, end-start) |
b942f5cfd326
Replaced fixed window size for walkchangerevs with an increasing one. Window
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1782
diff
changeset
|
84 |
start += windowsize |
b942f5cfd326
Replaced fixed window size for walkchangerevs with an increasing one. Window
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1782
diff
changeset
|
85 |
if windowsize < sizelimit: |
b942f5cfd326
Replaced fixed window size for walkchangerevs with an increasing one. Window
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1782
diff
changeset
|
86 |
windowsize *= 2 |
b942f5cfd326
Replaced fixed window size for walkchangerevs with an increasing one. Window
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1782
diff
changeset
|
87 |
else: |
b942f5cfd326
Replaced fixed window size for walkchangerevs with an increasing one. Window
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1782
diff
changeset
|
88 |
while start > end: |
b942f5cfd326
Replaced fixed window size for walkchangerevs with an increasing one. Window
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1782
diff
changeset
|
89 |
yield start, min(windowsize, start-end-1) |
b942f5cfd326
Replaced fixed window size for walkchangerevs with an increasing one. Window
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1782
diff
changeset
|
90 |
start -= windowsize |
b942f5cfd326
Replaced fixed window size for walkchangerevs with an increasing one. Window
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1782
diff
changeset
|
91 |
if windowsize < sizelimit: |
b942f5cfd326
Replaced fixed window size for walkchangerevs with an increasing one. Window
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1782
diff
changeset
|
92 |
windowsize *= 2 |
b942f5cfd326
Replaced fixed window size for walkchangerevs with an increasing one. Window
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1782
diff
changeset
|
93 |
|
b942f5cfd326
Replaced fixed window size for walkchangerevs with an increasing one. Window
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1782
diff
changeset
|
94 |
|
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
95 |
files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts) |
2784
12a7bfcafd8f
Add log option --follow-first to follow only the first parent of
Brendan Cully <brendan@kublai.com>
parents:
2783
diff
changeset
|
96 |
follow = opts.get('follow') or opts.get('follow_first') |
1570
6a104941d56a
hg log -p should show file deletions
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1568
diff
changeset
|
97 |
|
1337
d4b25df77a9e
Fix up some bugs for log and grep with empty repo
mpm@selenic.com
parents:
1331
diff
changeset
|
98 |
if repo.changelog.count() == 0: |
1570
6a104941d56a
hg log -p should show file deletions
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1568
diff
changeset
|
99 |
return [], False, matchfn |
1337
d4b25df77a9e
Fix up some bugs for log and grep with empty repo
mpm@selenic.com
parents:
1331
diff
changeset
|
100 |
|
2783
2e0cd25fe4ac
Make log --follow revision range start default to working dir parent.
Brendan Cully <brendan@kublai.com>
parents:
2782
diff
changeset
|
101 |
if follow: |
3132
81da3c45aabd
Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents:
3095
diff
changeset
|
102 |
defrange = '%s:0' % repo.changectx().rev() |
2783
2e0cd25fe4ac
Make log --follow revision range start default to working dir parent.
Brendan Cully <brendan@kublai.com>
parents:
2782
diff
changeset
|
103 |
else: |
2e0cd25fe4ac
Make log --follow revision range start default to working dir parent.
Brendan Cully <brendan@kublai.com>
parents:
2782
diff
changeset
|
104 |
defrange = 'tip:0' |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3080
diff
changeset
|
105 |
revs = map(int, cmdutil.revrange(ui, repo, opts['rev'] or [defrange])) |
1057 | 106 |
wanted = {} |
107 |
slowpath = anypats |
|
108 |
fncache = {} |
|
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
109 |
|
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
110 |
chcache = {} |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
111 |
def getchange(rev): |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
112 |
ch = chcache.get(rev) |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
113 |
if ch is None: |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
114 |
chcache[rev] = ch = repo.changelog.read(repo.lookup(str(rev))) |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
115 |
return ch |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
116 |
|
1057 | 117 |
if not slowpath and not files: |
118 |
# No files, no patterns. Display all revs. |
|
119 |
wanted = dict(zip(revs, revs)) |
|
2741
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
120 |
copies = [] |
1057 | 121 |
if not slowpath: |
122 |
# Only files, no patterns. Check the history of each file. |
|
2741
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
123 |
def filerevgen(filelog, node): |
2626
f84e166eb0de
walkchangerevs: fix race in fast path
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2625
diff
changeset
|
124 |
cl_count = repo.changelog.count() |
2741
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
125 |
if node is None: |
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
126 |
last = filelog.count() - 1 |
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
127 |
else: |
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
128 |
last = filelog.rev(node) |
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
129 |
for i, window in increasing_windows(last, -1): |
1057 | 130 |
revs = [] |
1800
414e81ae971f
Removed now obsolete min/max check in walkchangerevs().
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1799
diff
changeset
|
131 |
for j in xrange(i - window, i + 1): |
2741
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
132 |
n = filelog.node(j) |
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
133 |
revs.append((filelog.linkrev(n), |
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
134 |
follow and filelog.renamed(n))) |
1057 | 135 |
revs.reverse() |
136 |
for rev in revs: |
|
2626
f84e166eb0de
walkchangerevs: fix race in fast path
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2625
diff
changeset
|
137 |
# only yield rev for which we have the changelog, it can |
f84e166eb0de
walkchangerevs: fix race in fast path
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2625
diff
changeset
|
138 |
# happen while doing "hg log" during a pull or commit |
2741
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
139 |
if rev[0] < cl_count: |
2626
f84e166eb0de
walkchangerevs: fix race in fast path
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2625
diff
changeset
|
140 |
yield rev |
2741
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
141 |
def iterfiles(): |
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
142 |
for filename in files: |
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
143 |
yield filename, None |
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
144 |
for filename_node in copies: |
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
145 |
yield filename_node |
1057 | 146 |
minrev, maxrev = min(revs), max(revs) |
2741
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
147 |
for file_, node in iterfiles(): |
1749
d457fec76ab0
fix warnings from pychecker (unused variables and shadowing)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1747
diff
changeset
|
148 |
filelog = repo.file(file_) |
1057 | 149 |
# A zero count may be a directory or deleted file, so |
150 |
# try to find matching entries on the slow path. |
|
151 |
if filelog.count() == 0: |
|
152 |
slowpath = True |
|
153 |
break |
|
2741
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
154 |
for rev, copied in filerevgen(filelog, node): |
1057 | 155 |
if rev <= maxrev: |
1065
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
156 |
if rev < minrev: |
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
157 |
break |
1057 | 158 |
fncache.setdefault(rev, []) |
1749
d457fec76ab0
fix warnings from pychecker (unused variables and shadowing)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1747
diff
changeset
|
159 |
fncache[rev].append(file_) |
1057 | 160 |
wanted[rev] = 1 |
2741
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
161 |
if follow and copied: |
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
162 |
copies.append(copied) |
1057 | 163 |
if slowpath: |
2741
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
164 |
if follow: |
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
165 |
raise util.Abort(_('can only follow copies/renames for explicit ' |
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
166 |
'file names')) |
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
167 |
|
1057 | 168 |
# The slow path checks files modified in every changeset. |
169 |
def changerevgen(): |
|
1799
b942f5cfd326
Replaced fixed window size for walkchangerevs with an increasing one. Window
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1782
diff
changeset
|
170 |
for i, window in increasing_windows(repo.changelog.count()-1, -1): |
1800
414e81ae971f
Removed now obsolete min/max check in walkchangerevs().
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1799
diff
changeset
|
171 |
for j in xrange(i - window, i + 1): |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
172 |
yield j, getchange(j)[3] |
1057 | 173 |
|
174 |
for rev, changefiles in changerevgen(): |
|
175 |
matches = filter(matchfn, changefiles) |
|
176 |
if matches: |
|
177 |
fncache[rev] = matches |
|
178 |
wanted[rev] = 1 |
|
179 |
||
2901 | 180 |
class followfilter: |
181 |
def __init__(self, onlyfirst=False): |
|
182 |
self.startrev = -1 |
|
183 |
self.roots = [] |
|
184 |
self.onlyfirst = onlyfirst |
|
185 |
||
186 |
def match(self, rev): |
|
187 |
def realparents(rev): |
|
188 |
if self.onlyfirst: |
|
189 |
return repo.changelog.parentrevs(rev)[0:1] |
|
190 |
else: |
|
191 |
return filter(lambda x: x != -1, repo.changelog.parentrevs(rev)) |
|
192 |
||
193 |
if self.startrev == -1: |
|
194 |
self.startrev = rev |
|
195 |
return True |
|
196 |
||
197 |
if rev > self.startrev: |
|
198 |
# forward: all descendants |
|
199 |
if not self.roots: |
|
200 |
self.roots.append(self.startrev) |
|
201 |
for parent in realparents(rev): |
|
202 |
if parent in self.roots: |
|
203 |
self.roots.append(rev) |
|
204 |
return True |
|
205 |
else: |
|
206 |
# backwards: all parents |
|
207 |
if not self.roots: |
|
208 |
self.roots.extend(realparents(self.startrev)) |
|
209 |
if rev in self.roots: |
|
210 |
self.roots.remove(rev) |
|
211 |
self.roots.extend(realparents(rev)) |
|
2782
21e571c21a6b
Make log --follow without a file list follow a single head.
Brendan Cully <brendan@kublai.com>
parents:
2764
diff
changeset
|
212 |
return True |
21e571c21a6b
Make log --follow without a file list follow a single head.
Brendan Cully <brendan@kublai.com>
parents:
2764
diff
changeset
|
213 |
|
2901 | 214 |
return False |
215 |
||
216 |
# it might be worthwhile to do this in the iterator if the rev range |
|
217 |
# is descending and the prune args are all within that range |
|
2911 | 218 |
for rev in opts.get('prune', ()): |
2901 | 219 |
rev = repo.changelog.rev(repo.lookup(rev)) |
220 |
ff = followfilter() |
|
221 |
stop = min(revs[0], revs[-1]) |
|
222 |
for x in range(rev, stop-1, -1): |
|
223 |
if ff.match(x) and wanted.has_key(x): |
|
224 |
del wanted[x] |
|
225 |
||
226 |
def iterate(): |
|
2782
21e571c21a6b
Make log --follow without a file list follow a single head.
Brendan Cully <brendan@kublai.com>
parents:
2764
diff
changeset
|
227 |
if follow and not files: |
2784
12a7bfcafd8f
Add log option --follow-first to follow only the first parent of
Brendan Cully <brendan@kublai.com>
parents:
2783
diff
changeset
|
228 |
ff = followfilter(onlyfirst=opts.get('follow_first')) |
2782
21e571c21a6b
Make log --follow without a file list follow a single head.
Brendan Cully <brendan@kublai.com>
parents:
2764
diff
changeset
|
229 |
def want(rev): |
2901 | 230 |
if ff.match(rev) and rev in wanted: |
231 |
return True |
|
232 |
return False |
|
2782
21e571c21a6b
Make log --follow without a file list follow a single head.
Brendan Cully <brendan@kublai.com>
parents:
2764
diff
changeset
|
233 |
else: |
21e571c21a6b
Make log --follow without a file list follow a single head.
Brendan Cully <brendan@kublai.com>
parents:
2764
diff
changeset
|
234 |
def want(rev): |
21e571c21a6b
Make log --follow without a file list follow a single head.
Brendan Cully <brendan@kublai.com>
parents:
2764
diff
changeset
|
235 |
return rev in wanted |
21e571c21a6b
Make log --follow without a file list follow a single head.
Brendan Cully <brendan@kublai.com>
parents:
2764
diff
changeset
|
236 |
|
1799
b942f5cfd326
Replaced fixed window size for walkchangerevs with an increasing one. Window
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1782
diff
changeset
|
237 |
for i, window in increasing_windows(0, len(revs)): |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
238 |
yield 'window', revs[0] < revs[-1], revs[-1] |
2782
21e571c21a6b
Make log --follow without a file list follow a single head.
Brendan Cully <brendan@kublai.com>
parents:
2764
diff
changeset
|
239 |
nrevs = [rev for rev in revs[i:i+window] if want(rev)] |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
240 |
srevs = list(nrevs) |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
241 |
srevs.sort() |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
242 |
for rev in srevs: |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
243 |
fns = fncache.get(rev) or filter(matchfn, getchange(rev)[3]) |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
244 |
yield 'add', rev, fns |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
245 |
for rev in nrevs: |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
246 |
yield 'iter', rev, None |
1570
6a104941d56a
hg log -p should show file deletions
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1568
diff
changeset
|
247 |
return iterate(), getchange, matchfn |
1057 | 248 |
|
1974
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
249 |
def write_bundle(cg, filename=None, compress=True): |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
250 |
"""Write a bundle file and return its filename. |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
251 |
|
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
252 |
Existing files will not be overwritten. |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
253 |
If no filename is specified, a temporary file is created. |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
254 |
bz2 compression can be turned off. |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
255 |
The bundle file will be deleted in case of errors. |
1972
ce127cb4ee6e
Documented behaviour of write_bundle regarding file handles.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1971
diff
changeset
|
256 |
""" |
1943
8198c60f7914
refactor the bundle writing code, since we will reuse it later
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1940
diff
changeset
|
257 |
class nocompress(object): |
8198c60f7914
refactor the bundle writing code, since we will reuse it later
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1940
diff
changeset
|
258 |
def compress(self, x): |
8198c60f7914
refactor the bundle writing code, since we will reuse it later
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1940
diff
changeset
|
259 |
return x |
8198c60f7914
refactor the bundle writing code, since we will reuse it later
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1940
diff
changeset
|
260 |
def flush(self): |
8198c60f7914
refactor the bundle writing code, since we will reuse it later
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1940
diff
changeset
|
261 |
return "" |
1974
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
262 |
|
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
263 |
fh = None |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
264 |
cleanup = None |
1943
8198c60f7914
refactor the bundle writing code, since we will reuse it later
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1940
diff
changeset
|
265 |
try: |
1974
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
266 |
if filename: |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
267 |
if os.path.exists(filename): |
3072
bc3fe3b5b785
Never apply string formatting to generated errors with util.Abort.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3071
diff
changeset
|
268 |
raise util.Abort(_("file '%s' already exists") % filename) |
1974
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
269 |
fh = open(filename, "wb") |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
270 |
else: |
2165
d821918e3bee
Use better names (hg-{usage}-{random}.{suffix}) for temporary files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2160
diff
changeset
|
271 |
fd, filename = tempfile.mkstemp(prefix="hg-bundle-", suffix=".hg") |
1974
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
272 |
fh = os.fdopen(fd, "wb") |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
273 |
cleanup = filename |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
274 |
|
1943
8198c60f7914
refactor the bundle writing code, since we will reuse it later
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1940
diff
changeset
|
275 |
if compress: |
8198c60f7914
refactor the bundle writing code, since we will reuse it later
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1940
diff
changeset
|
276 |
fh.write("HG10") |
8198c60f7914
refactor the bundle writing code, since we will reuse it later
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1940
diff
changeset
|
277 |
z = bz2.BZ2Compressor(9) |
8198c60f7914
refactor the bundle writing code, since we will reuse it later
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1940
diff
changeset
|
278 |
else: |
1980
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1979
diff
changeset
|
279 |
fh.write("HG10UN") |
1943
8198c60f7914
refactor the bundle writing code, since we will reuse it later
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1940
diff
changeset
|
280 |
z = nocompress() |
1981
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1980
diff
changeset
|
281 |
# parse the changegroup data, otherwise we will block |
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1980
diff
changeset
|
282 |
# in case of sshrepo because we don't know the end of the stream |
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1980
diff
changeset
|
283 |
|
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1980
diff
changeset
|
284 |
# an empty chunkiter is the end of the changegroup |
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1980
diff
changeset
|
285 |
empty = False |
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1980
diff
changeset
|
286 |
while not empty: |
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1980
diff
changeset
|
287 |
empty = True |
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1980
diff
changeset
|
288 |
for chunk in changegroup.chunkiter(cg): |
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1980
diff
changeset
|
289 |
empty = False |
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1980
diff
changeset
|
290 |
fh.write(z.compress(changegroup.genchunk(chunk))) |
736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1980
diff
changeset
|
291 |
fh.write(z.compress(changegroup.closechunk())) |
1943
8198c60f7914
refactor the bundle writing code, since we will reuse it later
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1940
diff
changeset
|
292 |
fh.write(z.flush()) |
1974
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
293 |
cleanup = None |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
294 |
return filename |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
295 |
finally: |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
296 |
if fh is not None: |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
297 |
fh.close() |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
298 |
if cleanup is not None: |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
299 |
os.unlink(cleanup) |
1943
8198c60f7914
refactor the bundle writing code, since we will reuse it later
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1940
diff
changeset
|
300 |
|
1147 | 301 |
def trimuser(ui, name, rev, revcache): |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
302 |
"""trim the name of the user who committed a change""" |
1147 | 303 |
user = revcache.get(rev) |
304 |
if user is None: |
|
305 |
user = revcache[rev] = ui.shortuser(name) |
|
306 |
return user |
|
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
307 |
|
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
308 |
class changeset_printer(object): |
1909
37b9f80a5fbb
add doc comments to template code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1908
diff
changeset
|
309 |
'''show changeset information when templating not requested.''' |
37b9f80a5fbb
add doc comments to template code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1908
diff
changeset
|
310 |
|
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
311 |
def __init__(self, ui, repo): |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
312 |
self.ui = ui |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
313 |
self.repo = repo |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
314 |
|
3197 | 315 |
def show(self, rev=0, changenode=None, brinfo=None, copies=None): |
1909
37b9f80a5fbb
add doc comments to template code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1908
diff
changeset
|
316 |
'''show a single changeset or file revision''' |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
317 |
log = self.repo.changelog |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
318 |
if changenode is None: |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
319 |
changenode = log.node(rev) |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
320 |
elif not rev: |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
321 |
rev = log.rev(changenode) |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
322 |
|
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
323 |
if self.ui.quiet: |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
324 |
self.ui.write("%d:%s\n" % (rev, short(changenode))) |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
325 |
return |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
326 |
|
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
327 |
changes = log.read(changenode) |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
328 |
date = util.datestr(changes[2]) |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
329 |
|
2966
fb493241d7f6
Only show long hashes with --debug, not --verbose
Matt Mackall <mpm@selenic.com>
parents:
2963
diff
changeset
|
330 |
hexfunc = self.ui.debugflag and hex or short |
fb493241d7f6
Only show long hashes with --debug, not --verbose
Matt Mackall <mpm@selenic.com>
parents:
2963
diff
changeset
|
331 |
|
fb493241d7f6
Only show long hashes with --debug, not --verbose
Matt Mackall <mpm@selenic.com>
parents:
2963
diff
changeset
|
332 |
parents = [(log.rev(p), hexfunc(p)) for p in log.parents(changenode) |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
333 |
if self.ui.debugflag or p != nullid] |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
334 |
if (not self.ui.debugflag and len(parents) == 1 and |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
335 |
parents[0][0] == rev-1): |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
336 |
parents = [] |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
337 |
|
2966
fb493241d7f6
Only show long hashes with --debug, not --verbose
Matt Mackall <mpm@selenic.com>
parents:
2963
diff
changeset
|
338 |
self.ui.write(_("changeset: %d:%s\n") % (rev, hexfunc(changenode))) |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
339 |
|
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
340 |
for tag in self.repo.nodetags(changenode): |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
341 |
self.ui.status(_("tag: %s\n") % tag) |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
342 |
for parent in parents: |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
343 |
self.ui.write(_("parent: %d:%s\n") % parent) |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
344 |
|
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
345 |
if brinfo and changenode in brinfo: |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
346 |
br = brinfo[changenode] |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
347 |
self.ui.write(_("branch: %s\n") % " ".join(br)) |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
348 |
|
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
349 |
self.ui.debug(_("manifest: %d:%s\n") % |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
350 |
(self.repo.manifest.rev(changes[0]), hex(changes[0]))) |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
351 |
self.ui.status(_("user: %s\n") % changes[1]) |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
352 |
self.ui.status(_("date: %s\n") % date) |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
353 |
|
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
354 |
if self.ui.debugflag: |
2875
3d6efcbbd1c9
remove localrepository.changes.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2874
diff
changeset
|
355 |
files = self.repo.status(log.parents(changenode)[0], changenode)[:3] |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
356 |
for key, value in zip([_("files:"), _("files+:"), _("files-:")], |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
357 |
files): |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
358 |
if value: |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
359 |
self.ui.note("%-12s %s\n" % (key, " ".join(value))) |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
360 |
else: |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
361 |
self.ui.note(_("files: %s\n") % " ".join(changes[3])) |
3197 | 362 |
if copies: |
363 |
copies = ['%s (%s)' % c for c in copies] |
|
364 |
self.ui.note(_("copies: %s\n") % ' '.join(copies)) |
|
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
365 |
|
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
366 |
description = changes[4].strip() |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
367 |
if description: |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
368 |
if self.ui.verbose: |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
369 |
self.ui.status(_("description:\n")) |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
370 |
self.ui.status(description) |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
371 |
self.ui.status("\n\n") |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
372 |
else: |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
373 |
self.ui.status(_("summary: %s\n") % |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
374 |
description.splitlines()[0]) |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
375 |
self.ui.status("\n") |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
376 |
|
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
377 |
def show_changeset(ui, repo, opts): |
3192
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
378 |
"""show one changeset using template or regular display. |
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
379 |
|
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
380 |
Display format will be the first non-empty hit of: |
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
381 |
1. option 'template' |
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
382 |
2. option 'style' |
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
383 |
3. [ui] setting 'logtemplate' |
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
384 |
4. [ui] setting 'style' |
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
385 |
If all of these values are either the unset or the empty string, |
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
386 |
regular display via changeset_printer() is done. |
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
387 |
""" |
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
388 |
# options |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
389 |
tmpl = opts.get('template') |
3192
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
390 |
mapfile = None |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
391 |
if tmpl: |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
392 |
tmpl = templater.parsestring(tmpl, quoted=False) |
778 | 393 |
else: |
3192
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
394 |
mapfile = opts.get('style') |
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
395 |
# ui settings |
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
396 |
if not mapfile: |
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
397 |
tmpl = ui.config('ui', 'logtemplate') |
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
398 |
if tmpl: |
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
399 |
tmpl = templater.parsestring(tmpl) |
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
400 |
else: |
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
401 |
mapfile = ui.config('ui', 'style') |
f2ed26736dfa
Clarify precedence for template/style in commands.show_changeset():
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
402 |
|
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
403 |
if tmpl or mapfile: |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
404 |
if mapfile: |
3193
a6d0cd63068c
Make "hg log --style=changelog > changelog" work (issue338)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3192
diff
changeset
|
405 |
if not os.path.split(mapfile)[0]: |
a6d0cd63068c
Make "hg log --style=changelog > changelog" work (issue338)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3192
diff
changeset
|
406 |
mapname = (templater.templatepath('map-cmdline.' + mapfile) |
a6d0cd63068c
Make "hg log --style=changelog > changelog" work (issue338)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3192
diff
changeset
|
407 |
or templater.templatepath(mapfile)) |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
408 |
if mapname: mapfile = mapname |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
409 |
try: |
2189
e3eba577a0ae
move changeset_templater into templater module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2184
diff
changeset
|
410 |
t = templater.changeset_templater(ui, repo, mapfile) |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
411 |
except SyntaxError, inst: |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
412 |
raise util.Abort(inst.args[0]) |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
413 |
if tmpl: t.use_template(tmpl) |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
414 |
return t |
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
415 |
return changeset_printer(ui, repo) |
329
67c19ad374a9
Use common output function show_changeset() for hg heads|history|log|tip.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
320
diff
changeset
|
416 |
|
2731
ad4155e757da
Kill ui.setconfig_remoteopts
Matt Mackall <mpm@selenic.com>
parents:
2718
diff
changeset
|
417 |
def setremoteconfig(ui, opts): |
ad4155e757da
Kill ui.setconfig_remoteopts
Matt Mackall <mpm@selenic.com>
parents:
2718
diff
changeset
|
418 |
"copy remote options to ui tree" |
ad4155e757da
Kill ui.setconfig_remoteopts
Matt Mackall <mpm@selenic.com>
parents:
2718
diff
changeset
|
419 |
if opts.get('ssh'): |
ad4155e757da
Kill ui.setconfig_remoteopts
Matt Mackall <mpm@selenic.com>
parents:
2718
diff
changeset
|
420 |
ui.setconfig("ui", "ssh", opts['ssh']) |
ad4155e757da
Kill ui.setconfig_remoteopts
Matt Mackall <mpm@selenic.com>
parents:
2718
diff
changeset
|
421 |
if opts.get('remotecmd'): |
ad4155e757da
Kill ui.setconfig_remoteopts
Matt Mackall <mpm@selenic.com>
parents:
2718
diff
changeset
|
422 |
ui.setconfig("ui", "remotecmd", opts['remotecmd']) |
ad4155e757da
Kill ui.setconfig_remoteopts
Matt Mackall <mpm@selenic.com>
parents:
2718
diff
changeset
|
423 |
|
470
0ab093b473c5
Fix up version module name and command conflict
mpm@selenic.com
parents:
468
diff
changeset
|
424 |
def show_version(ui): |
423
25afb21d97ba
Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
396
diff
changeset
|
425 |
"""output version and copyright information""" |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
426 |
ui.write(_("Mercurial Distributed SCM (version %s)\n") |
849
8933ef744325
Further help improvements:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
848
diff
changeset
|
427 |
% version.get_version()) |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
428 |
ui.status(_( |
2859 | 429 |
"\nCopyright (C) 2005, 2006 Matt Mackall <mpm@selenic.com>\n" |
423
25afb21d97ba
Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
396
diff
changeset
|
430 |
"This is free software; see the source for copying conditions. " |
25afb21d97ba
Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
396
diff
changeset
|
431 |
"There is NO\nwarranty; " |
25afb21d97ba
Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
396
diff
changeset
|
432 |
"not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
433 |
)) |
423
25afb21d97ba
Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
396
diff
changeset
|
434 |
|
2553
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
435 |
def help_(ui, name=None, with_version=False): |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
436 |
"""show help for a command, extension, or list of commands |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
437 |
|
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
438 |
With no arguments, print a list of commands and short help. |
2600
c4325f0a9b91
clean up trailing white space.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2598
diff
changeset
|
439 |
|
2553
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
440 |
Given a command name, print help for that command. |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
441 |
|
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
442 |
Given an extension name, print help for that extension, and the |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
443 |
commands it provides.""" |
1052
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
444 |
option_lists = [] |
2553
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
445 |
|
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
446 |
def helpcmd(name): |
1049
160a68cd393f
Allow --help and --version being used together.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1048
diff
changeset
|
447 |
if with_version: |
160a68cd393f
Allow --help and --version being used together.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1048
diff
changeset
|
448 |
show_version(ui) |
160a68cd393f
Allow --help and --version being used together.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1048
diff
changeset
|
449 |
ui.write('\n') |
2988
63c3a1921a67
Add ui.strict config item.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2983
diff
changeset
|
450 |
aliases, i = findcmd(ui, name) |
849
8933ef744325
Further help improvements:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
848
diff
changeset
|
451 |
# synopsis |
848
221628fe9b62
Always show short help when an unknown command is given.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
846
diff
changeset
|
452 |
ui.write("%s\n\n" % i[2]) |
293 | 453 |
|
849
8933ef744325
Further help improvements:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
848
diff
changeset
|
454 |
# description |
8933ef744325
Further help improvements:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
848
diff
changeset
|
455 |
doc = i[0].__doc__ |
1710
c65113f3627a
Show "(No help text available)" for commands without doc string.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1661
diff
changeset
|
456 |
if not doc: |
c65113f3627a
Show "(No help text available)" for commands without doc string.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1661
diff
changeset
|
457 |
doc = _("(No help text available)") |
849
8933ef744325
Further help improvements:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
848
diff
changeset
|
458 |
if ui.quiet: |
8933ef744325
Further help improvements:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
848
diff
changeset
|
459 |
doc = doc.splitlines(0)[0] |
8933ef744325
Further help improvements:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
848
diff
changeset
|
460 |
ui.write("%s\n" % doc.rstrip()) |
8933ef744325
Further help improvements:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
848
diff
changeset
|
461 |
|
8933ef744325
Further help improvements:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
848
diff
changeset
|
462 |
if not ui.quiet: |
1052
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
463 |
# aliases |
1517
b582dbc16165
Canonicalize command when using aliases or prefix matching.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1507
diff
changeset
|
464 |
if len(aliases) > 1: |
b582dbc16165
Canonicalize command when using aliases or prefix matching.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1507
diff
changeset
|
465 |
ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:])) |
849
8933ef744325
Further help improvements:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
848
diff
changeset
|
466 |
|
1052
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
467 |
# options |
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
468 |
if i[1]: |
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
469 |
option_lists.append(("options", i[1])) |
2600
c4325f0a9b91
clean up trailing white space.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2598
diff
changeset
|
470 |
|
2553
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
471 |
def helplist(select=None): |
255 | 472 |
h = {} |
844
5a717cfa7406
'hg help -v' mentions the alias of the commands
kreijack@inwind.REMOVEME.it
parents:
843
diff
changeset
|
473 |
cmds = {} |
479
7293cb91bf2a
Cleaned up command alias handling in help.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
477
diff
changeset
|
474 |
for c, e in table.items(): |
2553
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
475 |
f = c.split("|", 1)[0] |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
476 |
if select and not select(f): |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
477 |
continue |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
478 |
if name == "shortlist" and not f.startswith("^"): |
479
7293cb91bf2a
Cleaned up command alias handling in help.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
477
diff
changeset
|
479 |
continue |
849
8933ef744325
Further help improvements:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
848
diff
changeset
|
480 |
f = f.lstrip("^") |
593 | 481 |
if not ui.debugflag and f.startswith("debug"): |
482 |
continue |
|
1710
c65113f3627a
Show "(No help text available)" for commands without doc string.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1661
diff
changeset
|
483 |
doc = e[0].__doc__ |
c65113f3627a
Show "(No help text available)" for commands without doc string.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1661
diff
changeset
|
484 |
if not doc: |
c65113f3627a
Show "(No help text available)" for commands without doc string.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1661
diff
changeset
|
485 |
doc = _("(No help text available)") |
c65113f3627a
Show "(No help text available)" for commands without doc string.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1661
diff
changeset
|
486 |
h[f] = doc.splitlines(0)[0].rstrip() |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
487 |
cmds[f] = c.lstrip("^") |
255 | 488 |
|
489 |
fns = h.keys() |
|
490 |
fns.sort() |
|
491 |
m = max(map(len, fns)) |
|
492 |
for f in fns: |
|
844
5a717cfa7406
'hg help -v' mentions the alias of the commands
kreijack@inwind.REMOVEME.it
parents:
843
diff
changeset
|
493 |
if ui.verbose: |
5a717cfa7406
'hg help -v' mentions the alias of the commands
kreijack@inwind.REMOVEME.it
parents:
843
diff
changeset
|
494 |
commands = cmds[f].replace("|",", ") |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
495 |
ui.write(" %s:\n %s\n"%(commands, h[f])) |
844
5a717cfa7406
'hg help -v' mentions the alias of the commands
kreijack@inwind.REMOVEME.it
parents:
843
diff
changeset
|
496 |
else: |
5a717cfa7406
'hg help -v' mentions the alias of the commands
kreijack@inwind.REMOVEME.it
parents:
843
diff
changeset
|
497 |
ui.write(' %-*s %s\n' % (m, f, h[f])) |
255 | 498 |
|
2553
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
499 |
def helpext(name): |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
500 |
try: |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
501 |
mod = findext(name) |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
502 |
except KeyError: |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
503 |
raise UnknownCommand(name) |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
504 |
|
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
505 |
doc = (mod.__doc__ or _('No help text available')).splitlines(0) |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
506 |
ui.write(_('%s extension - %s\n') % (name.split('.')[-1], doc[0])) |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
507 |
for d in doc[1:]: |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
508 |
ui.write(d, '\n') |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
509 |
|
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
510 |
ui.status('\n') |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
511 |
if ui.verbose: |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
512 |
ui.status(_('list of commands:\n\n')) |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
513 |
else: |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
514 |
ui.status(_('list of commands (use "hg help -v %s" ' |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
515 |
'to show aliases and global options):\n\n') % name) |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
516 |
|
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
517 |
modcmds = dict.fromkeys([c.split('|', 1)[0] for c in mod.cmdtable]) |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
518 |
helplist(modcmds.has_key) |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
519 |
|
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
520 |
if name and name != 'shortlist': |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
521 |
try: |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
522 |
helpcmd(name) |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
523 |
except UnknownCommand: |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
524 |
helpext(name) |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
525 |
|
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
526 |
else: |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
527 |
# program name |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
528 |
if ui.verbose or with_version: |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
529 |
show_version(ui) |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
530 |
else: |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
531 |
ui.status(_("Mercurial Distributed SCM\n")) |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
532 |
ui.status('\n') |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
533 |
|
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
534 |
# list of commands |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
535 |
if name == "shortlist": |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
536 |
ui.status(_('basic commands (use "hg help" ' |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
537 |
'for the full list or option "-v" for details):\n\n')) |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
538 |
elif ui.verbose: |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
539 |
ui.status(_('list of commands:\n\n')) |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
540 |
else: |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
541 |
ui.status(_('list of commands (use "hg help -v" ' |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
542 |
'to show aliases and global options):\n\n')) |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
543 |
|
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
544 |
helplist() |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
545 |
|
849
8933ef744325
Further help improvements:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
848
diff
changeset
|
546 |
# global options |
8933ef744325
Further help improvements:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
848
diff
changeset
|
547 |
if ui.verbose: |
1052
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
548 |
option_lists.append(("global options", globalopts)) |
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
549 |
|
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
550 |
# list all option lists |
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
551 |
opt_output = [] |
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
552 |
for title, options in option_lists: |
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
553 |
opt_output.append(("\n%s:\n" % title, None)) |
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
554 |
for shortopt, longopt, default, desc in options: |
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
555 |
opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt, |
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
556 |
longopt and " --%s" % longopt), |
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
557 |
"%s%s" % (desc, |
1602
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
558 |
default |
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
559 |
and _(" (default: %s)") % default |
1052
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
560 |
or ""))) |
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
561 |
|
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
562 |
if opt_output: |
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
563 |
opts_len = max([len(line[0]) for line in opt_output if line[1]]) |
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
564 |
for first, second in opt_output: |
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
565 |
if second: |
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
566 |
ui.write(" %-*s %s\n" % (opts_len, first, second)) |
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
567 |
else: |
d8279ca39dc7
Adjust display and alignment of command options to match global options.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1051
diff
changeset
|
568 |
ui.write("%s\n" % first) |
849
8933ef744325
Further help improvements:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
848
diff
changeset
|
569 |
|
255 | 570 |
# Commands start here, listed alphabetically |
209 | 571 |
|
724
1c0c413cccdd
Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
723
diff
changeset
|
572 |
def add(ui, repo, *pats, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
573 |
"""add the specified files on the next commit |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
574 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
575 |
Schedule files to be version controlled and added to the repository. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
576 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
577 |
The files will be added to the repository at the next commit. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
578 |
|
1568
1d7d0c07e8f3
make all commands be repo-wide by default
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1567
diff
changeset
|
579 |
If no names are given, add all files in the repository. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
580 |
""" |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
581 |
|
724
1c0c413cccdd
Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
723
diff
changeset
|
582 |
names = [] |
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
583 |
for src, abs, rel, exact in cmdutil.walk(repo, pats, opts): |
942
7eb8cbcca7c4
Modify commands.walk to yield a 4-tuple.
Bryan O'Sullivan <bos@serpentine.com>
parents:
940
diff
changeset
|
584 |
if exact: |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
585 |
if ui.verbose: |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
586 |
ui.status(_('adding %s\n') % rel) |
724
1c0c413cccdd
Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
723
diff
changeset
|
587 |
names.append(abs) |
1c0c413cccdd
Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
723
diff
changeset
|
588 |
elif repo.dirstate.state(abs) == '?': |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
589 |
ui.status(_('adding %s\n') % rel) |
724
1c0c413cccdd
Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
723
diff
changeset
|
590 |
names.append(abs) |
2503
37655f10ced6
Don't require opts['dry_run'] to be set to fix external tools like tailor.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2494
diff
changeset
|
591 |
if not opts.get('dry_run'): |
2411
734df6333ca4
add: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2410
diff
changeset
|
592 |
repo.add(names) |
213 | 593 |
|
766
b444a7e053f1
Get addremove to use new walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
764
diff
changeset
|
594 |
def addremove(ui, repo, *pats, **opts): |
3181
3637d5d17cbc
Documentation fixes for addremove.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3172
diff
changeset
|
595 |
"""add all new files, delete all missing files |
2181
690da72b0b16
deprecate addremove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2179
diff
changeset
|
596 |
|
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
597 |
Add all new files and remove all missing files from the repository. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
598 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
599 |
New files are ignored if they match any of the patterns in .hgignore. As |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
600 |
with add, these changes take effect at the next commit. |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2956
diff
changeset
|
601 |
|
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2956
diff
changeset
|
602 |
Use the -s option to detect renamed files. With a parameter > 0, |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2956
diff
changeset
|
603 |
this compares every removed file with every added file and records |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2956
diff
changeset
|
604 |
those similar enough as renames. This option takes a percentage |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2956
diff
changeset
|
605 |
between 0 (disabled) and 100 (files must be identical) as its |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2956
diff
changeset
|
606 |
parameter. Detecting renamed files this way can be expensive. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
607 |
""" |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2956
diff
changeset
|
608 |
sim = float(opts.get('similarity') or 0) |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2956
diff
changeset
|
609 |
if sim < 0 or sim > 100: |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2956
diff
changeset
|
610 |
raise util.Abort(_('similarity must be between 0 and 100')) |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2956
diff
changeset
|
611 |
return cmdutil.addremove(repo, pats, opts, similarity=sim/100.) |
219
8ff4532376a4
hg checkout: refuse to checkout if there are outstanding changes
mpm@selenic.com
parents:
214
diff
changeset
|
612 |
|
733
1966c553f652
Convert annotate over to walk interface.
Bryan O'Sullivan <bos@serpentine.com>
parents:
732
diff
changeset
|
613 |
def annotate(ui, repo, *pats, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
614 |
"""show changeset information per file line |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
615 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
616 |
List changes in files, showing the revision id responsible for each line |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
617 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
618 |
This command is useful to discover who did a change or when a change took |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
619 |
place. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
620 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
621 |
Without the -a option, annotate will avoid processing files it |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
622 |
detects as binary. With -a, annotate will generate an annotation |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
623 |
anyway, probably with undesirable results. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
624 |
""" |
3146
e69a0cbe268e
filectx.annotate: return filectx for each line instead of rev
Brendan Cully <brendan@kublai.com>
parents:
3132
diff
changeset
|
625 |
getdate = util.cachefunc(lambda x: util.datestr(x.date())) |
1522 | 626 |
|
744 | 627 |
if not pats: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
628 |
raise util.Abort(_('at least one file name or pattern required')) |
744 | 629 |
|
3146
e69a0cbe268e
filectx.annotate: return filectx for each line instead of rev
Brendan Cully <brendan@kublai.com>
parents:
3132
diff
changeset
|
630 |
opmap = [['user', lambda x: ui.shortuser(x.user())], |
e69a0cbe268e
filectx.annotate: return filectx for each line instead of rev
Brendan Cully <brendan@kublai.com>
parents:
3132
diff
changeset
|
631 |
['number', lambda x: str(x.rev())], |
e69a0cbe268e
filectx.annotate: return filectx for each line instead of rev
Brendan Cully <brendan@kublai.com>
parents:
3132
diff
changeset
|
632 |
['changeset', lambda x: short(x.node())], |
3172
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3159
diff
changeset
|
633 |
['date', getdate], ['follow', lambda x: x.path()]] |
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3159
diff
changeset
|
634 |
if (not opts['user'] and not opts['changeset'] and not opts['date'] |
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3159
diff
changeset
|
635 |
and not opts['follow']): |
714
29fcd195e056
Some cleanups in commands.annotate().
Thomas Arendsen Hein <thomas@intevation.de>
parents:
712
diff
changeset
|
636 |
opts['number'] = 1 |
209 | 637 |
|
3132
81da3c45aabd
Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents:
3095
diff
changeset
|
638 |
ctx = repo.changectx(opts['rev']) |
1016 | 639 |
|
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
640 |
for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, |
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
641 |
node=ctx.node()): |
2566
d8560b458f76
Convert hg annotate to context api
Matt Mackall <mpm@selenic.com>
parents:
2565
diff
changeset
|
642 |
fctx = ctx.filectx(abs) |
d8560b458f76
Convert hg annotate to context api
Matt Mackall <mpm@selenic.com>
parents:
2565
diff
changeset
|
643 |
if not opts['text'] and util.binary(fctx.data()): |
1625
e1bcf7fa983f
correct the relative path when walking from a subdir
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1622
diff
changeset
|
644 |
ui.write(_("%s: binary file\n") % ((pats and rel) or abs)) |
1016 | 645 |
continue |
646 |
||
3172
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3159
diff
changeset
|
647 |
lines = fctx.annotate(follow=opts.get('follow')) |
209 | 648 |
pieces = [] |
649 |
||
650 |
for o, f in opmap: |
|
714
29fcd195e056
Some cleanups in commands.annotate().
Thomas Arendsen Hein <thomas@intevation.de>
parents:
712
diff
changeset
|
651 |
if opts[o]: |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
652 |
l = [f(n) for n, dummy in lines] |
771 | 653 |
if l: |
654 |
m = max(map(len, l)) |
|
655 |
pieces.append(["%*s" % (m, x) for x in l]) |
|
209 | 656 |
|
771 | 657 |
if pieces: |
658 |
for p, l in zip(zip(*pieces), lines): |
|
659 |
ui.write("%s: %s" % (" ".join(p), l[1])) |
|
209 | 660 |
|
2112
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
661 |
def archive(ui, repo, dest, **opts): |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
662 |
'''create unversioned archive of a repository revision |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
663 |
|
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
664 |
By default, the revision used is the parent of the working |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
665 |
directory; use "-r" to specify a different revision. |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
666 |
|
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
667 |
To specify the type of archive to create, use "-t". Valid |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
668 |
types are: |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
669 |
|
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
670 |
"files" (default): a directory full of files |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
671 |
"tar": tar archive, uncompressed |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
672 |
"tbz2": tar archive, compressed using bzip2 |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
673 |
"tgz": tar archive, compressed using gzip |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
674 |
"uzip": zip archive, uncompressed |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
675 |
"zip": zip archive, compressed using deflate |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
676 |
|
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
677 |
The exact name of the destination archive or directory is given |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
678 |
using a format string; see "hg help export" for details. |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
679 |
|
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
680 |
Each member added to an archive file has a directory prefix |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
681 |
prepended. Use "-p" to specify a format string for the prefix. |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
682 |
The default is the basename of the archive, with suffixes removed. |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
683 |
''' |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
684 |
|
3132
81da3c45aabd
Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents:
3095
diff
changeset
|
685 |
node = repo.changectx(opts['rev']).node() |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
686 |
dest = cmdutil.make_filename(repo, dest, node) |
2112
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
687 |
if os.path.realpath(dest) == repo.root: |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
688 |
raise util.Abort(_('repository root cannot be destination')) |
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
689 |
dummy, matchfn, dummy = cmdutil.matchpats(repo, [], opts) |
2476
0f7e4a39d9af
archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2473
diff
changeset
|
690 |
kind = opts.get('type') or 'files' |
0f7e4a39d9af
archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2473
diff
changeset
|
691 |
prefix = opts['prefix'] |
0f7e4a39d9af
archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2473
diff
changeset
|
692 |
if dest == '-': |
0f7e4a39d9af
archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2473
diff
changeset
|
693 |
if kind == 'files': |
0f7e4a39d9af
archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2473
diff
changeset
|
694 |
raise util.Abort(_('cannot archive plain files to stdout')) |
0f7e4a39d9af
archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2473
diff
changeset
|
695 |
dest = sys.stdout |
0f7e4a39d9af
archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2473
diff
changeset
|
696 |
if not prefix: prefix = os.path.basename(repo.root) + '-%h' |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
697 |
prefix = cmdutil.make_filename(repo, prefix, node) |
2476
0f7e4a39d9af
archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2473
diff
changeset
|
698 |
archival.archive(repo, dest, node, kind, not opts['no_decode'], |
0f7e4a39d9af
archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2473
diff
changeset
|
699 |
matchfn, prefix) |
2112
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
700 |
|
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
701 |
def backout(ui, repo, rev, **opts): |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
702 |
'''reverse effect of earlier changeset |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
703 |
|
2254
827fcfe88b14
backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2245
diff
changeset
|
704 |
Commit the backed out changes as a new changeset. The new |
827fcfe88b14
backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2245
diff
changeset
|
705 |
changeset is a child of the backed out changeset. |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
706 |
|
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
707 |
If you back out a changeset other than the tip, a new head is |
2254
827fcfe88b14
backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2245
diff
changeset
|
708 |
created. This head is the parent of the working directory. If |
827fcfe88b14
backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2245
diff
changeset
|
709 |
you back out an old changeset, your working directory will appear |
827fcfe88b14
backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2245
diff
changeset
|
710 |
old after the backout. You should merge the backout changeset |
827fcfe88b14
backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2245
diff
changeset
|
711 |
with another head. |
827fcfe88b14
backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2245
diff
changeset
|
712 |
|
827fcfe88b14
backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2245
diff
changeset
|
713 |
The --merge option remembers the parent of the working directory |
827fcfe88b14
backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2245
diff
changeset
|
714 |
before starting the backout, then merges the new head with that |
827fcfe88b14
backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2245
diff
changeset
|
715 |
changeset afterwards. This saves you from doing the merge by |
827fcfe88b14
backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2245
diff
changeset
|
716 |
hand. The result of this merge is not committed, as for a normal |
827fcfe88b14
backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2245
diff
changeset
|
717 |
merge.''' |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
718 |
|
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
719 |
bail_if_changed(repo) |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
720 |
op1, op2 = repo.dirstate.parents() |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
721 |
if op2 != nullid: |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
722 |
raise util.Abort(_('outstanding uncommitted merge')) |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
723 |
node = repo.lookup(rev) |
2614
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
724 |
p1, p2 = repo.changelog.parents(node) |
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
725 |
if p1 == nullid: |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
726 |
raise util.Abort(_('cannot back out a change with no parents')) |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
727 |
if p2 != nullid: |
2614
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
728 |
if not opts['parent']: |
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
729 |
raise util.Abort(_('cannot back out a merge changeset without ' |
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
730 |
'--parent')) |
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
731 |
p = repo.lookup(opts['parent']) |
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
732 |
if p not in (p1, p2): |
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
733 |
raise util.Abort(_('%s is not a parent of %s' % |
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
734 |
(short(p), short(node)))) |
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
735 |
parent = p |
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
736 |
else: |
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
737 |
if opts['parent']: |
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
738 |
raise util.Abort(_('cannot use --parent on non-merge changeset')) |
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
739 |
parent = p1 |
2808
30f59f4a327e
Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents:
2806
diff
changeset
|
740 |
hg.clean(repo, node, show_stats=False) |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
741 |
revert_opts = opts.copy() |
2982
890e285c52a1
revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2963
diff
changeset
|
742 |
revert_opts['all'] = True |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
743 |
revert_opts['rev'] = hex(parent) |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
744 |
revert(ui, repo, **revert_opts) |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
745 |
commit_opts = opts.copy() |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
746 |
commit_opts['addremove'] = False |
2159
5c34b98ad6b1
Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2158
diff
changeset
|
747 |
if not commit_opts['message'] and not commit_opts['logfile']: |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
748 |
commit_opts['message'] = _("Backed out changeset %s") % (hex(node)) |
2268
6c9305fbebaf
fix coding style of backout editor change.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2267
diff
changeset
|
749 |
commit_opts['force_editor'] = True |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
750 |
commit(ui, repo, **commit_opts) |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
751 |
def nice(node): |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
752 |
return '%d:%s' % (repo.changelog.rev(node), short(node)) |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
753 |
ui.status(_('changeset %s backs out changeset %s\n') % |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
754 |
(nice(repo.changelog.tip()), nice(node))) |
2493
9c660e691e90
print message after backout that tells that backout adds new head.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2482
diff
changeset
|
755 |
if op1 != node: |
9c660e691e90
print message after backout that tells that backout adds new head.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2482
diff
changeset
|
756 |
if opts['merge']: |
9c660e691e90
print message after backout that tells that backout adds new head.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2482
diff
changeset
|
757 |
ui.status(_('merging with changeset %s\n') % nice(op1)) |
2806
0bf22c109cc3
Factor doupdate into _lookup + hg.update
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
758 |
n = _lookup(repo, hex(op1)) |
2808
30f59f4a327e
Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents:
2806
diff
changeset
|
759 |
hg.merge(repo, n) |
2493
9c660e691e90
print message after backout that tells that backout adds new head.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2482
diff
changeset
|
760 |
else: |
9c660e691e90
print message after backout that tells that backout adds new head.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2482
diff
changeset
|
761 |
ui.status(_('the backout changeset is a new head - ' |
9c660e691e90
print message after backout that tells that backout adds new head.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2482
diff
changeset
|
762 |
'do not forget to merge\n')) |
2761
0aa458261901
fix hg backup option recommendation for auto-merge
Christian Ebert <blacktrash@gmx.net>
parents:
2760
diff
changeset
|
763 |
ui.status(_('(use "backout --merge" ' |
0aa458261901
fix hg backup option recommendation for auto-merge
Christian Ebert <blacktrash@gmx.net>
parents:
2760
diff
changeset
|
764 |
'if you want to auto-merge)\n')) |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
765 |
|
2494
73ac95671788
push, outgoing, bundle: fall back to "default" if "default-push" not defined
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2493
diff
changeset
|
766 |
def bundle(ui, repo, fname, dest=None, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
767 |
"""create a changegroup file |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
768 |
|
3284
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
769 |
Generate a compressed changegroup file collecting changesets. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
770 |
not found in the other repository. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
771 |
|
3284
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
772 |
If no destination repository is specified the destination is |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
773 |
assumed to have all the node specified by --base. |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
774 |
|
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
775 |
This file can then be transferred using conventional means and |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
776 |
applied to another repository with the unbundle command. This is |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
777 |
useful when native push and pull are not available or when |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
778 |
exporting an entire repository is undesirable. The standard file |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
779 |
extension is ".hg". |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
780 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
781 |
Unlike import/export, this exactly preserves all changeset |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
782 |
contents including permissions, rename data, and revision history. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
783 |
""" |
3284
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
784 |
revs = opts.get('rev') or None |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
785 |
if revs: |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
786 |
revs = [repo.lookup(rev) for rev in revs] |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
787 |
base = opts.get('base') |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
788 |
if base: |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
789 |
if dest: |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
790 |
raise util.Abort(_("--base is incompatible with specifiying " |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
791 |
"a destination")) |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
792 |
o = [] |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
793 |
for n in base: |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
794 |
o.extend(repo.changelog.children(repo.lookup(n))) |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
795 |
# add common ancestor |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
796 |
if revs: |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
797 |
all = o + revs |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
798 |
else: |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
799 |
all = o + repo.changelog.heads() |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
800 |
ancestor = reduce(lambda a, b: repo.changelog.ancestor(a, b), all) |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
801 |
o.append(ancestor) |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
802 |
else: |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
803 |
setremoteconfig(ui, opts) |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
804 |
dest = ui.expandpath(dest or 'default-push', dest or 'default') |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
805 |
other = hg.repository(ui, dest) |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
806 |
o = repo.findoutgoing(other, force=opts['force']) |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
807 |
|
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
808 |
if revs: |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
809 |
cg = repo.changegroupsubset(o, revs, 'bundle') |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
810 |
else: |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
811 |
cg = repo.changegroup(o, 'bundle') |
1943
8198c60f7914
refactor the bundle writing code, since we will reuse it later
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1940
diff
changeset
|
812 |
write_bundle(cg, fname) |
1218
cde6818e082a
Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents:
1215
diff
changeset
|
813 |
|
1254
e6560042b7b8
Switch cat command to use walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1253
diff
changeset
|
814 |
def cat(ui, repo, file1, *pats, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
815 |
"""output the latest or given revisions of files |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
816 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
817 |
Print the specified files as they were at the given revision. |
3095
25857e00af8e
cat: default to working dir parent instead of tip
Brendan Cully <brendan@kublai.com>
parents:
3090
diff
changeset
|
818 |
If no revision is given then working dir parent is used, or tip |
25857e00af8e
cat: default to working dir parent instead of tip
Brendan Cully <brendan@kublai.com>
parents:
3090
diff
changeset
|
819 |
if no revision is checked out. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
820 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
821 |
Output may be to a file, in which case the name of the file is |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
822 |
given using a format string. The formatting rules are the same as |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
823 |
for the export command, with the following additions: |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
824 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
825 |
%s basename of file being printed |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
826 |
%d dirname of file being printed, or '.' if in repo root |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
827 |
%p root-relative path name of file being printed |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
828 |
""" |
3132
81da3c45aabd
Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents:
3095
diff
changeset
|
829 |
ctx = repo.changectx(opts['rev']) |
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
830 |
for src, abs, rel, exact in cmdutil.walk(repo, (file1,) + pats, opts, |
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
831 |
ctx.node()): |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
832 |
fp = cmdutil.make_file(repo, opts['output'], ctx.node(), pathname=abs) |
2565
7f78ca2c7977
convert hg cat to new context api
Matt Mackall <mpm@selenic.com>
parents:
2562
diff
changeset
|
833 |
fp.write(ctx.filectx(abs).data()) |
248 | 834 |
|
698
df78d8ccac4c
Use python function instead of external 'cp' command when cloning repos.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
697
diff
changeset
|
835 |
def clone(ui, source, dest=None, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
836 |
"""make a copy of an existing repository |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
837 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
838 |
Create a copy of an existing repository in a new directory. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
839 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
840 |
If no destination directory name is specified, it defaults to the |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
841 |
basename of the source. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
842 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
843 |
The location of the source is added to the new repository's |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
844 |
.hg/hgrc file, as the default to be used for future pulls. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
845 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
846 |
For efficiency, hardlinks are used for cloning whenever the source |
2762
2df98f616645
Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents:
2761
diff
changeset
|
847 |
and destination are on the same filesystem (note this applies only |
2df98f616645
Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents:
2761
diff
changeset
|
848 |
to the repository data, not to the checked out files). Some |
2df98f616645
Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents:
2761
diff
changeset
|
849 |
filesystems, such as AFS, implement hardlinking incorrectly, but |
2df98f616645
Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents:
2761
diff
changeset
|
850 |
do not report errors. In these cases, use the --pull option to |
2df98f616645
Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents:
2761
diff
changeset
|
851 |
avoid hardlinking. |
2df98f616645
Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents:
2761
diff
changeset
|
852 |
|
2df98f616645
Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents:
2761
diff
changeset
|
853 |
You can safely clone repositories and checked out files using full |
2df98f616645
Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents:
2761
diff
changeset
|
854 |
hardlinks with |
2df98f616645
Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents:
2761
diff
changeset
|
855 |
|
2df98f616645
Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents:
2761
diff
changeset
|
856 |
$ cp -al REPO REPOCLONE |
2df98f616645
Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents:
2761
diff
changeset
|
857 |
|
2df98f616645
Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents:
2761
diff
changeset
|
858 |
which is the fastest way to clone. However, the operation is not |
2df98f616645
Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents:
2761
diff
changeset
|
859 |
atomic (making sure REPO is not modified during the operation is |
2df98f616645
Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents:
2761
diff
changeset
|
860 |
up to you) and you have to make sure your editor breaks hardlinks |
2df98f616645
Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents:
2761
diff
changeset
|
861 |
(Emacs and most Linux Kernel tools do so). |
1811
6cb548cffdf5
resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1804
diff
changeset
|
862 |
|
2764
71029a3247cb
clone: replace long help string of inaky with doc comment.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2763
diff
changeset
|
863 |
If you use the -r option to clone up to a specific revision, no |
71029a3247cb
clone: replace long help string of inaky with doc comment.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2763
diff
changeset
|
864 |
subsequent revisions will be present in the cloned repository. |
71029a3247cb
clone: replace long help string of inaky with doc comment.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2763
diff
changeset
|
865 |
This option implies --pull, even on local repositories. |
71029a3247cb
clone: replace long help string of inaky with doc comment.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2763
diff
changeset
|
866 |
|
1811
6cb548cffdf5
resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1804
diff
changeset
|
867 |
See pull for valid source format details. |
2590
911b56853fdd
Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2589
diff
changeset
|
868 |
|
911b56853fdd
Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2589
diff
changeset
|
869 |
It is possible to specify an ssh:// URL as the destination, but no |
911b56853fdd
Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2589
diff
changeset
|
870 |
.hg/hgrc will be created on the remote side. Look at the help text |
911b56853fdd
Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2589
diff
changeset
|
871 |
for the pull command for important details about ssh:// URLs. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
872 |
""" |
2731
ad4155e757da
Kill ui.setconfig_remoteopts
Matt Mackall <mpm@selenic.com>
parents:
2718
diff
changeset
|
873 |
setremoteconfig(ui, opts) |
2597
5ba8be56fa8f
clone: move code into hg module. make doc better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2590
diff
changeset
|
874 |
hg.clone(ui, ui.expandpath(source), dest, |
5ba8be56fa8f
clone: move code into hg module. make doc better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2590
diff
changeset
|
875 |
pull=opts['pull'], |
2620
de82749d3a71
clone: change name of --stream to --uncompressed.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2618
diff
changeset
|
876 |
stream=opts['uncompressed'], |
2597
5ba8be56fa8f
clone: move code into hg module. make doc better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2590
diff
changeset
|
877 |
rev=opts['rev'], |
5ba8be56fa8f
clone: move code into hg module. make doc better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2590
diff
changeset
|
878 |
update=not opts['noupdate']) |
515 | 879 |
|
813
80fd2958235a
Adapt commit to use file matching code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
812
diff
changeset
|
880 |
def commit(ui, repo, *pats, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
881 |
"""commit the specified files or all outstanding changes |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
882 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
883 |
Commit changes to the given files into the repository. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
884 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
885 |
If a list of files is omitted, all changes reported by "hg status" |
1995
2da2d46862fb
Spelling fix: "commited" -> "committed"
mcmillen@cs.cmu.edu
parents:
1994
diff
changeset
|
886 |
will be committed. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
887 |
|
1996
4c70b10f0418
Don't mention deprecated HGEDITOR variable in the help text of commit.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1995
diff
changeset
|
888 |
If no commit message is specified, the editor configured in your hgrc |
4c70b10f0418
Don't mention deprecated HGEDITOR variable in the help text of commit.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1995
diff
changeset
|
889 |
or in the EDITOR environment variable is started to enter a message. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
890 |
""" |
2799
bd8a9a94139f
commands.logmessage: simplify calling.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2789
diff
changeset
|
891 |
message = logmessage(opts) |
289 | 892 |
|
354 | 893 |
if opts['addremove']: |
2883
c2932ad5476a
move commands.addremove_lock to cmdutil.addremove
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2882
diff
changeset
|
894 |
cmdutil.addremove(repo, pats, opts) |
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
895 |
fns, match, anypats = cmdutil.matchpats(repo, pats, opts) |
813
80fd2958235a
Adapt commit to use file matching code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
812
diff
changeset
|
896 |
if pats: |
2875
3d6efcbbd1c9
remove localrepository.changes.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2874
diff
changeset
|
897 |
modified, added, removed = repo.status(files=fns, match=match)[:3] |
1619
1ba0d7041ac4
Distinguish removed and deleted files. Tests are not fixed yet.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1618
diff
changeset
|
898 |
files = modified + added + removed |
813
80fd2958235a
Adapt commit to use file matching code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
812
diff
changeset
|
899 |
else: |
80fd2958235a
Adapt commit to use file matching code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
812
diff
changeset
|
900 |
files = [] |
1202
71111d796e40
Commit date validation: more stringent checks, more useful error messages.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1194
diff
changeset
|
901 |
try: |
2267
d812d91c5a84
Force editor to appear for an 'hg backout' if a message or logfile aren't
john.levon@sun.com
parents:
2254
diff
changeset
|
902 |
repo.commit(files, message, opts['user'], opts['date'], match, |
2268
6c9305fbebaf
fix coding style of backout editor change.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2267
diff
changeset
|
903 |
force_editor=opts.get('force_editor')) |
1202
71111d796e40
Commit date validation: more stringent checks, more useful error messages.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1194
diff
changeset
|
904 |
except ValueError, inst: |
71111d796e40
Commit date validation: more stringent checks, more useful error messages.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1194
diff
changeset
|
905 |
raise util.Abort(str(inst)) |
245 | 906 |
|
1822
64df4220b349
copy/rename to a removed destination file
Robin Farine <robin.farine@terminus.org>
parents:
1812
diff
changeset
|
907 |
def docopy(ui, repo, pats, opts, wlock): |
64df4220b349
copy/rename to a removed destination file
Robin Farine <robin.farine@terminus.org>
parents:
1812
diff
changeset
|
908 |
# called with the repo lock held |
1512
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
909 |
cwd = repo.getcwd() |
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
910 |
errors = 0 |
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
911 |
copied = [] |
1514
faf46d810a85
avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents:
1513
diff
changeset
|
912 |
targets = {} |
1249
a5355fa5e33a
Fix up copy command to behave more like regular "cp".
Bryan O'Sullivan <bos@serpentine.com>
parents:
1247
diff
changeset
|
913 |
|
a5355fa5e33a
Fix up copy command to behave more like regular "cp".
Bryan O'Sullivan <bos@serpentine.com>
parents:
1247
diff
changeset
|
914 |
def okaytocopy(abs, rel, exact): |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
915 |
reasons = {'?': _('is not managed'), |
1634
f49f602fae92
copy & rename can ignore removed source files
Robin Farine <robin.farine@terminus.org>
parents:
1633
diff
changeset
|
916 |
'a': _('has been marked for add'), |
f49f602fae92
copy & rename can ignore removed source files
Robin Farine <robin.farine@terminus.org>
parents:
1633
diff
changeset
|
917 |
'r': _('has been marked for remove')} |
1747
91c56c427171
transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents:
1743
diff
changeset
|
918 |
state = repo.dirstate.state(abs) |
91c56c427171
transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents:
1743
diff
changeset
|
919 |
reason = reasons.get(state) |
1249
a5355fa5e33a
Fix up copy command to behave more like regular "cp".
Bryan O'Sullivan <bos@serpentine.com>
parents:
1247
diff
changeset
|
920 |
if reason: |
1747
91c56c427171
transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents:
1743
diff
changeset
|
921 |
if state == 'a': |
91c56c427171
transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents:
1743
diff
changeset
|
922 |
origsrc = repo.dirstate.copied(abs) |
91c56c427171
transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents:
1743
diff
changeset
|
923 |
if origsrc is not None: |
91c56c427171
transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents:
1743
diff
changeset
|
924 |
return origsrc |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
925 |
if exact: |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
926 |
ui.warn(_('%s: not copying - file %s\n') % (rel, reason)) |
1249
a5355fa5e33a
Fix up copy command to behave more like regular "cp".
Bryan O'Sullivan <bos@serpentine.com>
parents:
1247
diff
changeset
|
927 |
else: |
1747
91c56c427171
transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents:
1743
diff
changeset
|
928 |
return abs |
91c56c427171
transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents:
1743
diff
changeset
|
929 |
|
91c56c427171
transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents:
1743
diff
changeset
|
930 |
def copy(origsrc, abssrc, relsrc, target, exact): |
1512
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
931 |
abstarget = util.canonpath(repo.root, cwd, target) |
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
932 |
reltarget = util.pathto(cwd, abstarget) |
1514
faf46d810a85
avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents:
1513
diff
changeset
|
933 |
prevsrc = targets.get(abstarget) |
faf46d810a85
avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents:
1513
diff
changeset
|
934 |
if prevsrc is not None: |
faf46d810a85
avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents:
1513
diff
changeset
|
935 |
ui.warn(_('%s: not overwriting - %s collides with %s\n') % |
faf46d810a85
avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents:
1513
diff
changeset
|
936 |
(reltarget, abssrc, prevsrc)) |
faf46d810a85
avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents:
1513
diff
changeset
|
937 |
return |
1565
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
938 |
if (not opts['after'] and os.path.exists(reltarget) or |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
939 |
opts['after'] and repo.dirstate.state(abstarget) not in '?r'): |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
940 |
if not opts['force']: |
1513
5c3b93b244aa
copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents:
1512
diff
changeset
|
941 |
ui.warn(_('%s: not overwriting - file exists\n') % |
5c3b93b244aa
copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents:
1512
diff
changeset
|
942 |
reltarget) |
5c3b93b244aa
copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents:
1512
diff
changeset
|
943 |
return |
2503
37655f10ced6
Don't require opts['dry_run'] to be set to fix external tools like tailor.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2494
diff
changeset
|
944 |
if not opts['after'] and not opts.get('dry_run'): |
1565
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
945 |
os.unlink(reltarget) |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
946 |
if opts['after']: |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
947 |
if not os.path.exists(reltarget): |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
948 |
return |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
949 |
else: |
1512
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
950 |
targetdir = os.path.dirname(reltarget) or '.' |
2503
37655f10ced6
Don't require opts['dry_run'] to be set to fix external tools like tailor.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2494
diff
changeset
|
951 |
if not os.path.isdir(targetdir) and not opts.get('dry_run'): |
1512
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
952 |
os.makedirs(targetdir) |
1249
a5355fa5e33a
Fix up copy command to behave more like regular "cp".
Bryan O'Sullivan <bos@serpentine.com>
parents:
1247
diff
changeset
|
953 |
try: |
1822
64df4220b349
copy/rename to a removed destination file
Robin Farine <robin.farine@terminus.org>
parents:
1812
diff
changeset
|
954 |
restore = repo.dirstate.state(abstarget) == 'r' |
2503
37655f10ced6
Don't require opts['dry_run'] to be set to fix external tools like tailor.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2494
diff
changeset
|
955 |
if restore and not opts.get('dry_run'): |
1822
64df4220b349
copy/rename to a removed destination file
Robin Farine <robin.farine@terminus.org>
parents:
1812
diff
changeset
|
956 |
repo.undelete([abstarget], wlock) |
64df4220b349
copy/rename to a removed destination file
Robin Farine <robin.farine@terminus.org>
parents:
1812
diff
changeset
|
957 |
try: |
2503
37655f10ced6
Don't require opts['dry_run'] to be set to fix external tools like tailor.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2494
diff
changeset
|
958 |
if not opts.get('dry_run'): |
2414
86e07466bcfc
remove: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2413
diff
changeset
|
959 |
shutil.copyfile(relsrc, reltarget) |
86e07466bcfc
remove: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2413
diff
changeset
|
960 |
shutil.copymode(relsrc, reltarget) |
1822
64df4220b349
copy/rename to a removed destination file
Robin Farine <robin.farine@terminus.org>
parents:
1812
diff
changeset
|
961 |
restore = False |
64df4220b349
copy/rename to a removed destination file
Robin Farine <robin.farine@terminus.org>
parents:
1812
diff
changeset
|
962 |
finally: |
64df4220b349
copy/rename to a removed destination file
Robin Farine <robin.farine@terminus.org>
parents:
1812
diff
changeset
|
963 |
if restore: |
64df4220b349
copy/rename to a removed destination file
Robin Farine <robin.farine@terminus.org>
parents:
1812
diff
changeset
|
964 |
repo.remove([abstarget], wlock) |
1253
a45e717c61a8
Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1250
diff
changeset
|
965 |
except shutil.Error, inst: |
a45e717c61a8
Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1250
diff
changeset
|
966 |
raise util.Abort(str(inst)) |
1249
a5355fa5e33a
Fix up copy command to behave more like regular "cp".
Bryan O'Sullivan <bos@serpentine.com>
parents:
1247
diff
changeset
|
967 |
except IOError, inst: |
a5355fa5e33a
Fix up copy command to behave more like regular "cp".
Bryan O'Sullivan <bos@serpentine.com>
parents:
1247
diff
changeset
|
968 |
if inst.errno == errno.ENOENT: |
1512
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
969 |
ui.warn(_('%s: deleted in working copy\n') % relsrc) |
1249
a5355fa5e33a
Fix up copy command to behave more like regular "cp".
Bryan O'Sullivan <bos@serpentine.com>
parents:
1247
diff
changeset
|
970 |
else: |
1512
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
971 |
ui.warn(_('%s: cannot copy - %s\n') % |
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
972 |
(relsrc, inst.strerror)) |
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
973 |
errors += 1 |
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
974 |
return |
1565
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
975 |
if ui.verbose or not exact: |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
976 |
ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) |
1514
faf46d810a85
avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents:
1513
diff
changeset
|
977 |
targets[abstarget] = abssrc |
2503
37655f10ced6
Don't require opts['dry_run'] to be set to fix external tools like tailor.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2494
diff
changeset
|
978 |
if abstarget != origsrc and not opts.get('dry_run'): |
1822
64df4220b349
copy/rename to a removed destination file
Robin Farine <robin.farine@terminus.org>
parents:
1812
diff
changeset
|
979 |
repo.copy(origsrc, abstarget, wlock) |
1512
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
980 |
copied.append((abssrc, relsrc, exact)) |
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
981 |
|
1565
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
982 |
def targetpathfn(pat, dest, srcs): |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
983 |
if os.path.isdir(pat): |
1633
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
984 |
abspfx = util.canonpath(repo.root, cwd, pat) |
1565
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
985 |
if destdirexists: |
1633
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
986 |
striplen = len(os.path.split(abspfx)[0]) |
1565
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
987 |
else: |
1633
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
988 |
striplen = len(abspfx) |
1565
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
989 |
if striplen: |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
990 |
striplen += len(os.sep) |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
991 |
res = lambda p: os.path.join(dest, p[striplen:]) |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
992 |
elif destdirexists: |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
993 |
res = lambda p: os.path.join(dest, os.path.basename(p)) |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
994 |
else: |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
995 |
res = lambda p: dest |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
996 |
return res |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
997 |
|
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
998 |
def targetpathafterfn(pat, dest, srcs): |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
999 |
if util.patkind(pat, None)[0]: |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1000 |
# a mercurial pattern |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1001 |
res = lambda p: os.path.join(dest, os.path.basename(p)) |
1633
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1002 |
else: |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1003 |
abspfx = util.canonpath(repo.root, cwd, pat) |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1004 |
if len(abspfx) < len(srcs[0][0]): |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1005 |
# A directory. Either the target path contains the last |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1006 |
# component of the source path or it does not. |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1007 |
def evalpath(striplen): |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1008 |
score = 0 |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1009 |
for s in srcs: |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1010 |
t = os.path.join(dest, s[0][striplen:]) |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1011 |
if os.path.exists(t): |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1012 |
score += 1 |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1013 |
return score |
1565
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1014 |
|
1633
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1015 |
striplen = len(abspfx) |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1016 |
if striplen: |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1017 |
striplen += len(os.sep) |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1018 |
if os.path.isdir(os.path.join(dest, os.path.split(abspfx)[1])): |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1019 |
score = evalpath(striplen) |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1020 |
striplen1 = len(os.path.split(abspfx)[0]) |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1021 |
if striplen1: |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1022 |
striplen1 += len(os.sep) |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1023 |
if evalpath(striplen1) > score: |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1024 |
striplen = striplen1 |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1025 |
res = lambda p: os.path.join(dest, p[striplen:]) |
1565
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1026 |
else: |
1633
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1027 |
# a file |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1028 |
if destdirexists: |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1029 |
res = lambda p: os.path.join(dest, os.path.basename(p)) |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1030 |
else: |
94c179a92f4a
copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents:
1626
diff
changeset
|
1031 |
res = lambda p: dest |
1565
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1032 |
return res |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1033 |
|
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1034 |
|
1512
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
1035 |
pats = list(pats) |
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
1036 |
if not pats: |
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
1037 |
raise util.Abort(_('no source or destination specified')) |
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
1038 |
if len(pats) == 1: |
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
1039 |
raise util.Abort(_('no destination specified')) |
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
1040 |
dest = pats.pop() |
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
1041 |
destdirexists = os.path.isdir(dest) |
1565
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1042 |
if (len(pats) > 1 or util.patkind(pats[0], None)[0]) and not destdirexists: |
1512
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
1043 |
raise util.Abort(_('with multiple sources, destination must be an ' |
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
1044 |
'existing directory')) |
1565
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1045 |
if opts['after']: |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1046 |
tfn = targetpathafterfn |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1047 |
else: |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1048 |
tfn = targetpathfn |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1049 |
copylist = [] |
1512
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
1050 |
for pat in pats: |
1565
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1051 |
srcs = [] |
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
1052 |
for tag, abssrc, relsrc, exact in cmdutil.walk(repo, [pat], opts): |
1747
91c56c427171
transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents:
1743
diff
changeset
|
1053 |
origsrc = okaytocopy(abssrc, relsrc, exact) |
91c56c427171
transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents:
1743
diff
changeset
|
1054 |
if origsrc: |
91c56c427171
transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents:
1743
diff
changeset
|
1055 |
srcs.append((origsrc, abssrc, relsrc, exact)) |
1565
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1056 |
if not srcs: |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1057 |
continue |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1058 |
copylist.append((tfn(pat, dest, srcs), srcs)) |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1059 |
if not copylist: |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1060 |
raise util.Abort(_('no files to copy')) |
4bcbc126b80b
fix rename --after
Robin Farine <robin.farine@terminus.org>
parents:
1561
diff
changeset
|
1061 |
|
2414
86e07466bcfc
remove: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2413
diff
changeset
|
1062 |
for targetpath, srcs in copylist: |
86e07466bcfc
remove: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2413
diff
changeset
|
1063 |
for origsrc, abssrc, relsrc, exact in srcs: |
86e07466bcfc
remove: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2413
diff
changeset
|
1064 |
copy(origsrc, abssrc, relsrc, targetpath(abssrc), exact) |
1512
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
1065 |
|
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
1066 |
if errors: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
1067 |
ui.warn(_('(consider using --after)\n')) |
1512
53ad6ee6ede4
generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
1507
diff
changeset
|
1068 |
return errors, copied |
1253
a45e717c61a8
Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1250
diff
changeset
|
1069 |
|
a45e717c61a8
Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1250
diff
changeset
|
1070 |
def copy(ui, repo, *pats, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1071 |
"""mark files as copied for the next commit |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1072 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1073 |
Mark dest as having copies of source files. If dest is a |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1074 |
directory, copies are put in that directory. If dest is a file, |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1075 |
there can only be one source. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1076 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1077 |
By default, this command copies the contents of files as they |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1078 |
stand in the working directory. If invoked with --after, the |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1079 |
operation is recorded, but no copying is performed. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1080 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1081 |
This command takes effect in the next commit. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1082 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1083 |
NOTE: This command should be treated as experimental. While it |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1084 |
should properly record copied files, this information is not yet |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1085 |
fully used by merge, nor fully reported by log. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1086 |
""" |
2016
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
1087 |
wlock = repo.wlock(0) |
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
1088 |
errs, copied = docopy(ui, repo, pats, opts, wlock) |
1249
a5355fa5e33a
Fix up copy command to behave more like regular "cp".
Bryan O'Sullivan <bos@serpentine.com>
parents:
1247
diff
changeset
|
1089 |
return errs |
363 | 1090 |
|
1262 | 1091 |
def debugancestor(ui, index, rev1, rev2): |
1092 |
"""find the ancestor revision of two revisions in a given index""" |
|
2072 | 1093 |
r = revlog.revlog(util.opener(os.getcwd(), audit=False), index, "", 0) |
1262 | 1094 |
a = r.ancestor(r.lookup(rev1), r.lookup(rev2)) |
1095 |
ui.write("%d:%s\n" % (r.rev(a), hex(a))) |
|
1096 |
||
2034
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
1097 |
def debugcomplete(ui, cmd='', **opts): |
1887
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
1098 |
"""returns the completion list associated with the given command""" |
2034
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
1099 |
|
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
1100 |
if opts['options']: |
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
1101 |
options = [] |
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
1102 |
otables = [globalopts] |
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
1103 |
if cmd: |
2988
63c3a1921a67
Add ui.strict config item.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2983
diff
changeset
|
1104 |
aliases, entry = findcmd(ui, cmd) |
2034
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
1105 |
otables.append(entry[1]) |
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
1106 |
for t in otables: |
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
1107 |
for o in t: |
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
1108 |
if o[0]: |
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
1109 |
options.append('-%s' % o[0]) |
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
1110 |
options.append('--%s' % o[1]) |
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
1111 |
ui.write("%s\n" % "\n".join(options)) |
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
1112 |
return |
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
1113 |
|
2988
63c3a1921a67
Add ui.strict config item.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2983
diff
changeset
|
1114 |
clist = findpossible(ui, cmd).keys() |
1887
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
1115 |
clist.sort() |
2034
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
1116 |
ui.write("%s\n" % "\n".join(clist)) |
1887
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
1117 |
|
1755
a8f7791e3680
add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1754
diff
changeset
|
1118 |
def debugrebuildstate(ui, repo, rev=None): |
a8f7791e3680
add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1754
diff
changeset
|
1119 |
"""rebuild the dirstate as it would look like for the given revision""" |
a8f7791e3680
add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1754
diff
changeset
|
1120 |
if not rev: |
a8f7791e3680
add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1754
diff
changeset
|
1121 |
rev = repo.changelog.tip() |
a8f7791e3680
add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1754
diff
changeset
|
1122 |
else: |
a8f7791e3680
add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1754
diff
changeset
|
1123 |
rev = repo.lookup(rev) |
a8f7791e3680
add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1754
diff
changeset
|
1124 |
change = repo.changelog.read(rev) |
a8f7791e3680
add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1754
diff
changeset
|
1125 |
n = change[0] |
2840
046a8b03ea59
Change remaining users of manifest flags
Matt Mackall <mpm@selenic.com>
parents:
2836
diff
changeset
|
1126 |
files = repo.manifest.read(n) |
1760
13f8e068d13c
fix typo in debugrebuildstate
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1755
diff
changeset
|
1127 |
wlock = repo.wlock() |
2840
046a8b03ea59
Change remaining users of manifest flags
Matt Mackall <mpm@selenic.com>
parents:
2836
diff
changeset
|
1128 |
repo.dirstate.rebuild(rev, files) |
1755
a8f7791e3680
add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1754
diff
changeset
|
1129 |
|
596 | 1130 |
def debugcheckstate(ui, repo): |
1131 |
"""validate the correctness of the current dirstate""" |
|
460 | 1132 |
parent1, parent2 = repo.dirstate.parents() |
555 | 1133 |
repo.dirstate.read() |
1134 |
dc = repo.dirstate.map |
|
460 | 1135 |
keys = dc.keys() |
1136 |
keys.sort() |
|
1137 |
m1n = repo.changelog.read(parent1)[0] |
|
1138 |
m2n = repo.changelog.read(parent2)[0] |
|
1139 |
m1 = repo.manifest.read(m1n) |
|
1140 |
m2 = repo.manifest.read(m2n) |
|
1141 |
errors = 0 |
|
1142 |
for f in dc: |
|
1143 |
state = repo.dirstate.state(f) |
|
1144 |
if state in "nr" and f not in m1: |
|
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
1145 |
ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state)) |
460 | 1146 |
errors += 1 |
1147 |
if state in "a" and f in m1: |
|
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
1148 |
ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state)) |
460 | 1149 |
errors += 1 |
1150 |
if state in "m" and f not in m1 and f not in m2: |
|
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
1151 |
ui.warn(_("%s in state %s, but not in either manifest\n") % |
582 | 1152 |
(f, state)) |
460 | 1153 |
errors += 1 |
1154 |
for f in m1: |
|
1155 |
state = repo.dirstate.state(f) |
|
1156 |
if state not in "nrm": |
|
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
1157 |
ui.warn(_("%s in manifest1, but listed as state %s") % (f, state)) |
460 | 1158 |
errors += 1 |
1159 |
if errors: |
|
1602
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
1160 |
error = _(".hg/dirstate inconsistent with current parent's manifest") |
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
1161 |
raise util.Abort(error) |
460 | 1162 |
|
3268
bb057b6ce3cf
Un-debugify debugconfig to showconfig. (issue 317)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3250
diff
changeset
|
1163 |
def showconfig(ui, repo, *values): |
2410
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1164 |
"""show combined config settings from all hgrc files |
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1165 |
|
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1166 |
With no args, print names and values of all config items. |
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1167 |
|
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1168 |
With one arg of the form section.name, print just the value of |
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1169 |
that config item. |
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1170 |
|
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1171 |
With multiple args, print names and values of all config items |
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1172 |
with matching section names.""" |
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1173 |
|
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1174 |
if values: |
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1175 |
if len([v for v in values if '.' in v]) > 1: |
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1176 |
raise util.Abort(_('only one config item permitted')) |
1028
25e7ea0f2cff
Add commands.debugconfig.
Bryan O'Sullivan <bos@serpentine.com>
parents:
989
diff
changeset
|
1177 |
for section, name, value in ui.walkconfig(): |
2410
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1178 |
sectname = section + '.' + name |
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1179 |
if values: |
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1180 |
for v in values: |
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1181 |
if v == section: |
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1182 |
ui.write('%s=%s\n' % (sectname, value)) |
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1183 |
elif v == sectname: |
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1184 |
ui.write(value, '\n') |
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1185 |
else: |
1e80d47b8581
debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2407
diff
changeset
|
1186 |
ui.write('%s=%s\n' % (sectname, value)) |
1028
25e7ea0f2cff
Add commands.debugconfig.
Bryan O'Sullivan <bos@serpentine.com>
parents:
989
diff
changeset
|
1187 |
|
1395
c2eb204917f8
Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents:
1390
diff
changeset
|
1188 |
def debugsetparents(ui, repo, rev1, rev2=None): |
1470
fb9b84c91222
minor fix on command help docstrings
TK Soh <teekaysoh@yahoo.com>
parents:
1469
diff
changeset
|
1189 |
"""manually set the parents of the current working directory |
1395
c2eb204917f8
Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents:
1390
diff
changeset
|
1190 |
|
c2eb204917f8
Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents:
1390
diff
changeset
|
1191 |
This is useful for writing repository conversion tools, but should |
c2eb204917f8
Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents:
1390
diff
changeset
|
1192 |
be used with care. |
c2eb204917f8
Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents:
1390
diff
changeset
|
1193 |
""" |
c2eb204917f8
Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents:
1390
diff
changeset
|
1194 |
|
c2eb204917f8
Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents:
1390
diff
changeset
|
1195 |
if not rev2: |
c2eb204917f8
Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents:
1390
diff
changeset
|
1196 |
rev2 = hex(nullid) |
c2eb204917f8
Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents:
1390
diff
changeset
|
1197 |
|
c2eb204917f8
Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents:
1390
diff
changeset
|
1198 |
repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2)) |
c2eb204917f8
Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents:
1390
diff
changeset
|
1199 |
|
596 | 1200 |
def debugstate(ui, repo): |
1201 |
"""show the contents of the current dirstate""" |
|
555 | 1202 |
repo.dirstate.read() |
1203 |
dc = repo.dirstate.map |
|
460 | 1204 |
keys = dc.keys() |
1205 |
keys.sort() |
|
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
1206 |
for file_ in keys: |
791
040655ea0cc4
Show all dirstate info for 'hg debugstate'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
770
diff
changeset
|
1207 |
ui.write("%c %3o %10d %s %s\n" |
040655ea0cc4
Show all dirstate info for 'hg debugstate'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
770
diff
changeset
|
1208 |
% (dc[file_][0], dc[file_][1] & 0777, dc[file_][2], |
040655ea0cc4
Show all dirstate info for 'hg debugstate'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
770
diff
changeset
|
1209 |
time.strftime("%x %X", |
040655ea0cc4
Show all dirstate info for 'hg debugstate'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
770
diff
changeset
|
1210 |
time.localtime(dc[file_][3])), file_)) |
3159
e43fd1623fe1
fix users of dirstate.copies broken by b1f10d3223c1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3146
diff
changeset
|
1211 |
for f in repo.dirstate.copies(): |
e43fd1623fe1
fix users of dirstate.copies broken by b1f10d3223c1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3146
diff
changeset
|
1212 |
ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) |
460 | 1213 |
|
1039
4296754ba7b4
Add debugdata for dumping revlog revision data
mpm@selenic.com
parents:
1037
diff
changeset
|
1214 |
def debugdata(ui, file_, rev): |
4296754ba7b4
Add debugdata for dumping revlog revision data
mpm@selenic.com
parents:
1037
diff
changeset
|
1215 |
"""dump the contents of an data file revision""" |
1835
bdfb524d728a
Validate paths before reading or writing files in repository or working dir.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1833
diff
changeset
|
1216 |
r = revlog.revlog(util.opener(os.getcwd(), audit=False), |
2072 | 1217 |
file_[:-2] + ".i", file_, 0) |
1313
1cc7c0cbc30b
Fix traceback during invalid rev identifier for debugdata
Anupam Kapoor<anupam.kapoor@gmail.com>
parents:
1312
diff
changeset
|
1218 |
try: |
1cc7c0cbc30b
Fix traceback during invalid rev identifier for debugdata
Anupam Kapoor<anupam.kapoor@gmail.com>
parents:
1312
diff
changeset
|
1219 |
ui.write(r.revision(r.lookup(rev))) |
1cc7c0cbc30b
Fix traceback during invalid rev identifier for debugdata
Anupam Kapoor<anupam.kapoor@gmail.com>
parents:
1312
diff
changeset
|
1220 |
except KeyError: |
3072
bc3fe3b5b785
Never apply string formatting to generated errors with util.Abort.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3071
diff
changeset
|
1221 |
raise util.Abort(_('invalid revision identifier %s') % rev) |
1039
4296754ba7b4
Add debugdata for dumping revlog revision data
mpm@selenic.com
parents:
1037
diff
changeset
|
1222 |
|
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
1223 |
def debugindex(ui, file_): |
596 | 1224 |
"""dump the contents of an index file""" |
2072 | 1225 |
r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, "", 0) |
582 | 1226 |
ui.write(" rev offset length base linkrev" + |
989 | 1227 |
" nodeid p1 p2\n") |
248 | 1228 |
for i in range(r.count()): |
2072 | 1229 |
node = r.node(i) |
1230 |
pp = r.parents(node) |
|
989 | 1231 |
ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( |
2072 | 1232 |
i, r.start(i), r.length(i), r.base(i), r.linkrev(node), |
1233 |
short(node), short(pp[0]), short(pp[1]))) |
|
248 | 1234 |
|
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
1235 |
def debugindexdot(ui, file_): |
596 | 1236 |
"""dump an index DAG as a .dot file""" |
2072 | 1237 |
r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, "", 0) |
582 | 1238 |
ui.write("digraph G {\n") |
248 | 1239 |
for i in range(r.count()): |
2287
3f18d1eea370
Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents:
2283
diff
changeset
|
1240 |
node = r.node(i) |
3f18d1eea370
Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents:
2283
diff
changeset
|
1241 |
pp = r.parents(node) |
3f18d1eea370
Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents:
2283
diff
changeset
|
1242 |
ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) |
3f18d1eea370
Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents:
2283
diff
changeset
|
1243 |
if pp[1] != nullid: |
3f18d1eea370
Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents:
2283
diff
changeset
|
1244 |
ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) |
582 | 1245 |
ui.write("}\n") |
248 | 1246 |
|
1116 | 1247 |
def debugrename(ui, repo, file, rev=None): |
1194
c165cbf56bb1
Add doc string for debugrename.
bos@serpentine.internal.keyresearch.com
parents:
1193
diff
changeset
|
1248 |
"""dump rename information""" |
1116 | 1249 |
r = repo.file(relpath(repo, [file])[0]) |
1250 |
if rev: |
|
1251 |
try: |
|
1252 |
# assume all revision numbers are for changesets |
|
1253 |
n = repo.lookup(rev) |
|
1254 |
change = repo.changelog.read(n) |
|
1255 |
m = repo.manifest.read(change[0]) |
|
1256 |
n = m[relpath(repo, [file])[0]] |
|
1541
bf4e7ef08741
fixed some stuff pychecker shows, marked unclear/wrong stuff with XXX
twaldmann@thinkmo.de
parents:
1526
diff
changeset
|
1257 |
except (hg.RepoError, KeyError): |
1116 | 1258 |
n = r.lookup(rev) |
1259 |
else: |
|
1260 |
n = r.tip() |
|
1261 |
m = r.renamed(n) |
|
1262 |
if m: |
|
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
1263 |
ui.write(_("renamed from %s:%s\n") % (m[0], hex(m[1]))) |
1116 | 1264 |
else: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
1265 |
ui.write(_("not renamed\n")) |
1116 | 1266 |
|
820
89985a1b3427
Clean up walk and changes code to use normalised names properly.
Bryan O'Sullivan <bos@serpentine.com>
parents:
815
diff
changeset
|
1267 |
def debugwalk(ui, repo, *pats, **opts): |
1053
1539ca091d86
Added missing doc strings for two new debug commmands.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1052
diff
changeset
|
1268 |
"""show how files match on given patterns""" |
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
1269 |
items = list(cmdutil.walk(repo, pats, opts)) |
1065
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
1270 |
if not items: |
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
1271 |
return |
1309
332f225b835c
Make debugwalk strip trailing spaces and remove these from test-walk.out
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1285
diff
changeset
|
1272 |
fmt = '%%s %%-%ds %%-%ds %%s' % ( |
942
7eb8cbcca7c4
Modify commands.walk to yield a 4-tuple.
Bryan O'Sullivan <bos@serpentine.com>
parents:
940
diff
changeset
|
1273 |
max([len(abs) for (src, abs, rel, exact) in items]), |
7eb8cbcca7c4
Modify commands.walk to yield a 4-tuple.
Bryan O'Sullivan <bos@serpentine.com>
parents:
940
diff
changeset
|
1274 |
max([len(rel) for (src, abs, rel, exact) in items])) |
7eb8cbcca7c4
Modify commands.walk to yield a 4-tuple.
Bryan O'Sullivan <bos@serpentine.com>
parents:
940
diff
changeset
|
1275 |
for src, abs, rel, exact in items: |
1309
332f225b835c
Make debugwalk strip trailing spaces and remove these from test-walk.out
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1285
diff
changeset
|
1276 |
line = fmt % (src, abs, rel, exact and 'exact' or '') |
332f225b835c
Make debugwalk strip trailing spaces and remove these from test-walk.out
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1285
diff
changeset
|
1277 |
ui.write("%s\n" % line.rstrip()) |
820
89985a1b3427
Clean up walk and changes code to use normalised names properly.
Bryan O'Sullivan <bos@serpentine.com>
parents:
815
diff
changeset
|
1278 |
|
732
ba0b6d17a6de
Convert diff command over to using walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
731
diff
changeset
|
1279 |
def diff(ui, repo, *pats, **opts): |
1568
1d7d0c07e8f3
make all commands be repo-wide by default
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1567
diff
changeset
|
1280 |
"""diff repository (or selected files) |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1281 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1282 |
Show differences between revisions for the specified files. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1283 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1284 |
Differences between files are shown using the unified diff format. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1285 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1286 |
When two revision arguments are given, then changes are shown |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1287 |
between those revisions. If only one revision is specified then |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1288 |
that revision is compared to the working directory, and, when no |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1289 |
revisions are specified, the working directory files are compared |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1290 |
to its parent. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1291 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1292 |
Without the -a option, diff will avoid generating diffs of files |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1293 |
it detects as binary. With -a, diff will generate a diff anyway, |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1294 |
probably with undesirable results. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1295 |
""" |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3080
diff
changeset
|
1296 |
node1, node2 = cmdutil.revpair(ui, repo, opts['rev']) |
245 | 1297 |
|
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
1298 |
fns, matchfn, anypats = cmdutil.matchpats(repo, pats, opts) |
1014 | 1299 |
|
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
1300 |
patch.diff(repo, node1, node2, fns, match=matchfn, |
2888
3848488244fc
Move ui.diffopts to patch.diffopts where it belongs
Matt Mackall <mpm@selenic.com>
parents:
2883
diff
changeset
|
1301 |
opts=patch.diffopts(ui, opts)) |
396
8f8bb77d560e
Show revisions in diffs like CVS, based on a patch from Goffredo Baroncelli.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
395
diff
changeset
|
1302 |
|
580 | 1303 |
def export(ui, repo, *changesets, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1304 |
"""dump the header and diffs for one or more changesets |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1305 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1306 |
Print the changeset header and diffs for one or more revisions. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1307 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1308 |
The information shown in the changeset header is: author, |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1309 |
changeset hash, parent and commit comment. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1310 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1311 |
Output may be to a file, in which case the name of the file is |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1312 |
given using a format string. The formatting rules are as follows: |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1313 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1314 |
%% literal "%" character |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1315 |
%H changeset hash (40 bytes of hexadecimal) |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1316 |
%N number of patches being generated |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1317 |
%R changeset revision number |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1318 |
%b basename of the exporting repository |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1319 |
%h short-form changeset hash (12 bytes of hexadecimal) |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1320 |
%n zero-padded sequence number, starting at 1 |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1321 |
%r zero-padded changeset revision number |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1322 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1323 |
Without the -a option, export will avoid generating diffs of files |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1324 |
it detects as binary. With -a, export will generate a diff anyway, |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1325 |
probably with undesirable results. |
1571
bcdc030c59f8
add a --switch-parent option to export against the other parent
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1570
diff
changeset
|
1326 |
|
bcdc030c59f8
add a --switch-parent option to export against the other parent
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1570
diff
changeset
|
1327 |
With the --switch-parent option, the diff will be against the second |
bcdc030c59f8
add a --switch-parent option to export against the other parent
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1570
diff
changeset
|
1328 |
parent. It can be useful to review a merge. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1329 |
""" |
610
4c02464cb9f0
check export options for changeset before running
shaleh@speakeasy.net
parents:
609
diff
changeset
|
1330 |
if not changesets: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
1331 |
raise util.Abort(_("export requires at least one changeset")) |
3090
eeaf9bcdfa25
Move revision parsing into cmdutil.
Brendan Cully <brendan@kublai.com>
parents:
3080
diff
changeset
|
1332 |
revs = list(cmdutil.revrange(ui, repo, changesets)) |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
1333 |
if len(revs) > 1: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
1334 |
ui.note(_('exporting patches:\n')) |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
1335 |
else: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
1336 |
ui.note(_('exporting patch:\n')) |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
1337 |
patch.export(repo, map(repo.lookup, revs), template=opts['output'], |
2888
3848488244fc
Move ui.diffopts to patch.diffopts where it belongs
Matt Mackall <mpm@selenic.com>
parents:
2883
diff
changeset
|
1338 |
switch_parent=opts['switch_parent'], |
3848488244fc
Move ui.diffopts to patch.diffopts where it belongs
Matt Mackall <mpm@selenic.com>
parents:
2883
diff
changeset
|
1339 |
opts=patch.diffopts(ui, opts)) |
246
96cde50a746f
Migrate rawcommit, import, export, history, and merge
mpm@selenic.com
parents:
245
diff
changeset
|
1340 |
|
810
790a0ff306f2
Move commands.forget over to using new walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
809
diff
changeset
|
1341 |
def forget(ui, repo, *pats, **opts): |
2135
11ad47f22023
mark forget command as deprecated.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2134
diff
changeset
|
1342 |
"""don't add the specified files on the next commit (DEPRECATED) |
11ad47f22023
mark forget command as deprecated.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2134
diff
changeset
|
1343 |
|
11ad47f22023
mark forget command as deprecated.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2134
diff
changeset
|
1344 |
(DEPRECATED) |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1345 |
Undo an 'hg add' scheduled for the next commit. |
2135
11ad47f22023
mark forget command as deprecated.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2134
diff
changeset
|
1346 |
|
11ad47f22023
mark forget command as deprecated.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2134
diff
changeset
|
1347 |
This command is now deprecated and will be removed in a future |
11ad47f22023
mark forget command as deprecated.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2134
diff
changeset
|
1348 |
release. Please use revert instead. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1349 |
""" |
2135
11ad47f22023
mark forget command as deprecated.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2134
diff
changeset
|
1350 |
ui.warn(_("(the forget command is deprecated; use revert instead)\n")) |
810
790a0ff306f2
Move commands.forget over to using new walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
809
diff
changeset
|
1351 |
forget = [] |
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
1352 |
for src, abs, rel, exact in cmdutil.walk(repo, pats, opts): |
810
790a0ff306f2
Move commands.forget over to using new walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
809
diff
changeset
|
1353 |
if repo.dirstate.state(abs) == 'a': |
790a0ff306f2
Move commands.forget over to using new walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
809
diff
changeset
|
1354 |
forget.append(abs) |
1255
e825dfea3823
Get all commands that operate on files to honour --verbose and --quiet.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1254
diff
changeset
|
1355 |
if ui.verbose or not exact: |
1625
e1bcf7fa983f
correct the relative path when walking from a subdir
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1622
diff
changeset
|
1356 |
ui.status(_('forgetting %s\n') % ((pats and rel) or abs)) |
810
790a0ff306f2
Move commands.forget over to using new walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
809
diff
changeset
|
1357 |
repo.forget(forget) |
245 | 1358 |
|
1108
7a75d8fbbdaf
Remove some options from 'hg grep':
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1106
diff
changeset
|
1359 |
def grep(ui, repo, pattern, *pats, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1360 |
"""search for a pattern in specified files and revisions |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1361 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1362 |
Search revisions of files for a regular expression. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1363 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1364 |
This command behaves differently than Unix grep. It only accepts |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1365 |
Python/Perl regexps. It searches repository history, not the |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1366 |
working directory. It always prints the revision number in which |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1367 |
a match appears. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1368 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1369 |
By default, grep only prints output for the first revision of a |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1370 |
file in which it finds a match. To get it to print every revision |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1371 |
that contains a change in match status ("-" for a match that |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1372 |
becomes a non-match, or "+" for a non-match that becomes a match), |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1373 |
use the --all flag. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1374 |
""" |
1057 | 1375 |
reflags = 0 |
1065
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
1376 |
if opts['ignore_case']: |
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
1377 |
reflags |= re.I |
1057 | 1378 |
regexp = re.compile(pattern, reflags) |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
1379 |
sep, eol = ':', '\n' |
1108
7a75d8fbbdaf
Remove some options from 'hg grep':
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1106
diff
changeset
|
1380 |
if opts['print0']: |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
1381 |
sep = eol = '\0' |
1057 | 1382 |
|
1383 |
fcache = {} |
|
1384 |
def getfile(fn): |
|
1385 |
if fn not in fcache: |
|
1386 |
fcache[fn] = repo.file(fn) |
|
1387 |
return fcache[fn] |
|
1388 |
||
1389 |
def matchlines(body): |
|
1059
4eab07ef66e2
grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents:
1058
diff
changeset
|
1390 |
begin = 0 |
4eab07ef66e2
grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents:
1058
diff
changeset
|
1391 |
linenum = 0 |
4eab07ef66e2
grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents:
1058
diff
changeset
|
1392 |
while True: |
4eab07ef66e2
grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents:
1058
diff
changeset
|
1393 |
match = regexp.search(body, begin) |
1065
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
1394 |
if not match: |
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
1395 |
break |
1059
4eab07ef66e2
grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents:
1058
diff
changeset
|
1396 |
mstart, mend = match.span() |
4eab07ef66e2
grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents:
1058
diff
changeset
|
1397 |
linenum += body.count('\n', begin, mstart) + 1 |
4eab07ef66e2
grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents:
1058
diff
changeset
|
1398 |
lstart = body.rfind('\n', begin, mstart) + 1 or begin |
4eab07ef66e2
grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents:
1058
diff
changeset
|
1399 |
lend = body.find('\n', mend) |
4eab07ef66e2
grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents:
1058
diff
changeset
|
1400 |
yield linenum, mstart - lstart, mend - lstart, body[lstart:lend] |
4eab07ef66e2
grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents:
1058
diff
changeset
|
1401 |
begin = lend + 1 |
1057 | 1402 |
|
1559
59b3639df0a9
Convert all classes to new-style classes by deriving them from object.
Eric Hopper <hopper@omnifarious.org>
parents:
1552
diff
changeset
|
1403 |
class linestate(object): |
1057 | 1404 |
def __init__(self, line, linenum, colstart, colend): |
1405 |
self.line = line |
|
1406 |
self.linenum = linenum |
|
1407 |
self.colstart = colstart |
|
1408 |
self.colend = colend |
|
2869
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1409 |
|
1065
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
1410 |
def __eq__(self, other): |
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
1411 |
return self.line == other.line |
1057 | 1412 |
|
1413 |
matches = {} |
|
2870
8eaaf1321bfe
grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents:
2869
diff
changeset
|
1414 |
copies = {} |
1057 | 1415 |
def grepbody(fn, rev, body): |
2869
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1416 |
matches[rev].setdefault(fn, []) |
1057 | 1417 |
m = matches[rev][fn] |
1418 |
for lnum, cstart, cend, line in matchlines(body): |
|
1419 |
s = linestate(line, lnum, cstart, cend) |
|
2869
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1420 |
m.append(s) |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1421 |
|
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1422 |
def difflinestates(a, b): |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1423 |
sm = difflib.SequenceMatcher(None, a, b) |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1424 |
for tag, alo, ahi, blo, bhi in sm.get_opcodes(): |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1425 |
if tag == 'insert': |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1426 |
for i in range(blo, bhi): |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1427 |
yield ('+', b[i]) |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1428 |
elif tag == 'delete': |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1429 |
for i in range(alo, ahi): |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1430 |
yield ('-', a[i]) |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1431 |
elif tag == 'replace': |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1432 |
for i in range(alo, ahi): |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1433 |
yield ('-', a[i]) |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1434 |
for i in range(blo, bhi): |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1435 |
yield ('+', b[i]) |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1436 |
|
1057 | 1437 |
prev = {} |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
1438 |
ucache = {} |
1057 | 1439 |
def display(fn, rev, states, prevstates): |
1145
bd917e1a26dd
grep: change default to printing first matching rev.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1116
diff
changeset
|
1440 |
counts = {'-': 0, '+': 0} |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
1441 |
filerevmatches = {} |
2869
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1442 |
if incrementing or not opts['all']: |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1443 |
a, b = prevstates, states |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1444 |
else: |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1445 |
a, b = states, prevstates |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1446 |
for change, l in difflinestates(a, b): |
1212 | 1447 |
if incrementing or not opts['all']: |
1057 | 1448 |
r = rev |
1449 |
else: |
|
1450 |
r = prev[fn] |
|
2869
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1451 |
cols = [fn, str(r)] |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
1452 |
if opts['line_number']: |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
1453 |
cols.append(str(l.linenum)) |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
1454 |
if opts['all']: |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
1455 |
cols.append(change) |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
1456 |
if opts['user']: |
2869
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1457 |
cols.append(trimuser(ui, getchange(r)[1], rev, |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
1458 |
ucache)) |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
1459 |
if opts['files_with_matches']: |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
1460 |
c = (fn, rev) |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
1461 |
if c in filerevmatches: |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
1462 |
continue |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
1463 |
filerevmatches[c] = 1 |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
1464 |
else: |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
1465 |
cols.append(l.line) |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
1466 |
ui.write(sep.join(cols), eol) |
1145
bd917e1a26dd
grep: change default to printing first matching rev.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1116
diff
changeset
|
1467 |
counts[change] += 1 |
bd917e1a26dd
grep: change default to printing first matching rev.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1116
diff
changeset
|
1468 |
return counts['+'], counts['-'] |
1057 | 1469 |
|
1470 |
fstate = {} |
|
1145
bd917e1a26dd
grep: change default to printing first matching rev.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1116
diff
changeset
|
1471 |
skip = {} |
1570
6a104941d56a
hg log -p should show file deletions
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1568
diff
changeset
|
1472 |
changeiter, getchange, matchfn = walkchangerevs(ui, repo, pats, opts) |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
1473 |
count = 0 |
1337
d4b25df77a9e
Fix up some bugs for log and grep with empty repo
mpm@selenic.com
parents:
1331
diff
changeset
|
1474 |
incrementing = False |
2870
8eaaf1321bfe
grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents:
2869
diff
changeset
|
1475 |
follow = opts.get('follow') |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
1476 |
for st, rev, fns in changeiter: |
1057 | 1477 |
if st == 'window': |
1478 |
incrementing = rev |
|
1479 |
matches.clear() |
|
1480 |
elif st == 'add': |
|
1481 |
change = repo.changelog.read(repo.lookup(str(rev))) |
|
1482 |
mf = repo.manifest.read(change[0]) |
|
1483 |
matches[rev] = {} |
|
1484 |
for fn in fns: |
|
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
1485 |
if fn in skip: |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
1486 |
continue |
1057 | 1487 |
fstate.setdefault(fn, {}) |
1488 |
try: |
|
1489 |
grepbody(fn, rev, getfile(fn).read(mf[fn])) |
|
2870
8eaaf1321bfe
grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents:
2869
diff
changeset
|
1490 |
if follow: |
8eaaf1321bfe
grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents:
2869
diff
changeset
|
1491 |
copied = getfile(fn).renamed(mf[fn]) |
8eaaf1321bfe
grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents:
2869
diff
changeset
|
1492 |
if copied: |
2931 | 1493 |
copies.setdefault(rev, {})[fn] = copied[0] |
1057 | 1494 |
except KeyError: |
1495 |
pass |
|
1496 |
elif st == 'iter': |
|
1497 |
states = matches[rev].items() |
|
1498 |
states.sort() |
|
1499 |
for fn, m in states: |
|
2931 | 1500 |
copy = copies.get(rev, {}).get(fn) |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
1501 |
if fn in skip: |
2870
8eaaf1321bfe
grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents:
2869
diff
changeset
|
1502 |
if copy: |
8eaaf1321bfe
grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents:
2869
diff
changeset
|
1503 |
skip[copy] = True |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
1504 |
continue |
1212 | 1505 |
if incrementing or not opts['all'] or fstate[fn]: |
1145
bd917e1a26dd
grep: change default to printing first matching rev.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1116
diff
changeset
|
1506 |
pos, neg = display(fn, rev, m, fstate[fn]) |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
1507 |
count += pos + neg |
1212 | 1508 |
if pos and not opts['all']: |
1145
bd917e1a26dd
grep: change default to printing first matching rev.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1116
diff
changeset
|
1509 |
skip[fn] = True |
2870
8eaaf1321bfe
grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents:
2869
diff
changeset
|
1510 |
if copy: |
8eaaf1321bfe
grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents:
2869
diff
changeset
|
1511 |
skip[copy] = True |
1057 | 1512 |
fstate[fn] = m |
2870
8eaaf1321bfe
grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents:
2869
diff
changeset
|
1513 |
if copy: |
8eaaf1321bfe
grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents:
2869
diff
changeset
|
1514 |
fstate[copy] = m |
1057 | 1515 |
prev[fn] = rev |
1516 |
||
1517 |
if not incrementing: |
|
1518 |
fstate = fstate.items() |
|
1519 |
fstate.sort() |
|
1520 |
for fn, state in fstate: |
|
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
1521 |
if fn in skip: |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
1522 |
continue |
2931 | 1523 |
if fn not in copies.get(prev[fn], {}): |
2870
8eaaf1321bfe
grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents:
2869
diff
changeset
|
1524 |
display(fn, rev, {}, state) |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
1525 |
return (count == 0 and 1) or 0 |
1057 | 1526 |
|
898 | 1527 |
def heads(ui, repo, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1528 |
"""show current repository heads |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1529 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1530 |
Show all repository head changesets. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1531 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1532 |
Repository "heads" are changesets that don't have children |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1533 |
changesets. They are where development generally takes place and |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1534 |
are the usual targets for update and merge operations. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1535 |
""" |
1550
ccb9b62de892
add a -r/--rev option to heads to show only heads descendant from rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1547
diff
changeset
|
1536 |
if opts['rev']: |
1551
e793cbc8be00
Fixes to "hg heads -r FOO":
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1550
diff
changeset
|
1537 |
heads = repo.heads(repo.lookup(opts['rev'])) |
1550
ccb9b62de892
add a -r/--rev option to heads to show only heads descendant from rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1547
diff
changeset
|
1538 |
else: |
ccb9b62de892
add a -r/--rev option to heads to show only heads descendant from rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1547
diff
changeset
|
1539 |
heads = repo.heads() |
898 | 1540 |
br = None |
1541 |
if opts['branches']: |
|
1551
e793cbc8be00
Fixes to "hg heads -r FOO":
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1550
diff
changeset
|
1542 |
br = repo.branchlookup(heads) |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
1543 |
displayer = show_changeset(ui, repo, opts) |
1550
ccb9b62de892
add a -r/--rev option to heads to show only heads descendant from rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1547
diff
changeset
|
1544 |
for n in heads: |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
1545 |
displayer.show(changenode=n, brinfo=br) |
221 | 1546 |
|
339
a76fc9c4b67b
added hg identify|id (based on a patch from Andrew Thompson)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
338
diff
changeset
|
1547 |
def identify(ui, repo): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1548 |
"""print information about the working copy |
1470
fb9b84c91222
minor fix on command help docstrings
TK Soh <teekaysoh@yahoo.com>
parents:
1469
diff
changeset
|
1549 |
|
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1550 |
Print a short summary of the current state of the repo. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1551 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1552 |
This summary identifies the repository state using one or two parent |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1553 |
hash identifiers, followed by a "+" if there are uncommitted changes |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1554 |
in the working directory, followed by a list of tags for this revision. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1555 |
""" |
1092 | 1556 |
parents = [p for p in repo.dirstate.parents() if p != nullid] |
340
97a897d32dfc
Handle the case where the current working copy is not based on a checkout.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
339
diff
changeset
|
1557 |
if not parents: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
1558 |
ui.write(_("unknown\n")) |
340
97a897d32dfc
Handle the case where the current working copy is not based on a checkout.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
339
diff
changeset
|
1559 |
return |
97a897d32dfc
Handle the case where the current working copy is not based on a checkout.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
339
diff
changeset
|
1560 |
|
2966
fb493241d7f6
Only show long hashes with --debug, not --verbose
Matt Mackall <mpm@selenic.com>
parents:
2963
diff
changeset
|
1561 |
hexfunc = ui.debugflag and hex or short |
2875
3d6efcbbd1c9
remove localrepository.changes.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2874
diff
changeset
|
1562 |
modified, added, removed, deleted = repo.status()[:4] |
1619
1ba0d7041ac4
Distinguish removed and deleted files. Tests are not fixed yet.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1618
diff
changeset
|
1563 |
output = ["%s%s" % |
1ba0d7041ac4
Distinguish removed and deleted files. Tests are not fixed yet.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1618
diff
changeset
|
1564 |
('+'.join([hexfunc(parent) for parent in parents]), |
1ba0d7041ac4
Distinguish removed and deleted files. Tests are not fixed yet.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1618
diff
changeset
|
1565 |
(modified or added or removed or deleted) and "+" or "")] |
386
494c8e3f47f3
Improvements for hg identify:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
371
diff
changeset
|
1566 |
|
339
a76fc9c4b67b
added hg identify|id (based on a patch from Andrew Thompson)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
338
diff
changeset
|
1567 |
if not ui.quiet: |
386
494c8e3f47f3
Improvements for hg identify:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
371
diff
changeset
|
1568 |
# multiple tags for a single parent separated by '/' |
494c8e3f47f3
Improvements for hg identify:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
371
diff
changeset
|
1569 |
parenttags = ['/'.join(tags) |
494c8e3f47f3
Improvements for hg identify:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
371
diff
changeset
|
1570 |
for tags in map(repo.nodetags, parents) if tags] |
494c8e3f47f3
Improvements for hg identify:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
371
diff
changeset
|
1571 |
# tags for multiple parents separated by ' + ' |
758
c5db9581bfa6
There was an extra space after 'hg id' when there are no tags.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
757
diff
changeset
|
1572 |
if parenttags: |
c5db9581bfa6
There was an extra space after 'hg id' when there are no tags.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
757
diff
changeset
|
1573 |
output.append(' + '.join(parenttags)) |
339
a76fc9c4b67b
added hg identify|id (based on a patch from Andrew Thompson)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
338
diff
changeset
|
1574 |
|
386
494c8e3f47f3
Improvements for hg identify:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
371
diff
changeset
|
1575 |
ui.write("%s\n" % ' '.join(output)) |
339
a76fc9c4b67b
added hg identify|id (based on a patch from Andrew Thompson)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
338
diff
changeset
|
1576 |
|
437 | 1577 |
def import_(ui, repo, patch1, *patches, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1578 |
"""import an ordered set of patches |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1579 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1580 |
Import a list of patches and commit them individually. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1581 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1582 |
If there are outstanding changes in the working directory, import |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1583 |
will abort unless given the -f flag. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1584 |
|
2504
158d3d2ae070
import: parse email messages
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2494
diff
changeset
|
1585 |
You can import a patch straight from a mail message. Even patches |
158d3d2ae070
import: parse email messages
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2494
diff
changeset
|
1586 |
as attachments work (body part must be type text/plain or |
2515
a6700c222314
import: make help clearer. suggested by asak.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2513
diff
changeset
|
1587 |
text/x-patch to be used). From and Subject headers of email |
a6700c222314
import: make help clearer. suggested by asak.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2513
diff
changeset
|
1588 |
message are used as default committer and commit message. All |
a6700c222314
import: make help clearer. suggested by asak.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2513
diff
changeset
|
1589 |
text/plain body parts before first diff are added to commit |
a6700c222314
import: make help clearer. suggested by asak.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2513
diff
changeset
|
1590 |
message. |
2504
158d3d2ae070
import: parse email messages
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2494
diff
changeset
|
1591 |
|
158d3d2ae070
import: parse email messages
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2494
diff
changeset
|
1592 |
If imported patch was generated by hg export, user and description |
158d3d2ae070
import: parse email messages
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2494
diff
changeset
|
1593 |
from patch override values from message headers and body. Values |
158d3d2ae070
import: parse email messages
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2494
diff
changeset
|
1594 |
given on command line with -m and -u override these. |
2400
2e90024e1471
import: allow to import stdin with file name "-"
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2397
diff
changeset
|
1595 |
|
2e90024e1471
import: allow to import stdin with file name "-"
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2397
diff
changeset
|
1596 |
To read a patch from standard input, use patch name "-". |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1597 |
""" |
437 | 1598 |
patches = (patch1,) + patches |
500
ebc4714a7632
[PATCH] Clean up destination directory if a clone fails.
mpm@selenic.com
parents:
499
diff
changeset
|
1599 |
|
966
022bcc738389
hg import: abort with uncommitted changes, override with --force
mpm@selenic.com
parents:
965
diff
changeset
|
1600 |
if not opts['force']: |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
1601 |
bail_if_changed(repo) |
966
022bcc738389
hg import: abort with uncommitted changes, override with --force
mpm@selenic.com
parents:
965
diff
changeset
|
1602 |
|
437 | 1603 |
d = opts["base"] |
1604 |
strip = opts["strip"] |
|
1605 |
||
2854
7706fa503677
import: get lock and wlock one time
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2847
diff
changeset
|
1606 |
wlock = repo.wlock() |
7706fa503677
import: get lock and wlock one time
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2847
diff
changeset
|
1607 |
lock = repo.lock() |
7706fa503677
import: get lock and wlock one time
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2847
diff
changeset
|
1608 |
|
2861
0f08f2c042ec
Move patch-related code into its own module.
Brendan Cully <brendan@kublai.com>
parents:
2860
diff
changeset
|
1609 |
for p in patches: |
0f08f2c042ec
Move patch-related code into its own module.
Brendan Cully <brendan@kublai.com>
parents:
2860
diff
changeset
|
1610 |
pf = os.path.join(d, p) |
437 | 1611 |
|
2400
2e90024e1471
import: allow to import stdin with file name "-"
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2397
diff
changeset
|
1612 |
if pf == '-': |
2e90024e1471
import: allow to import stdin with file name "-"
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2397
diff
changeset
|
1613 |
ui.status(_("applying patch from stdin\n")) |
2866
2893e51407a4
commands.import: refactor patch parsing into patch.extract.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2865
diff
changeset
|
1614 |
tmpname, message, user, date = patch.extract(ui, sys.stdin) |
2400
2e90024e1471
import: allow to import stdin with file name "-"
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2397
diff
changeset
|
1615 |
else: |
2861
0f08f2c042ec
Move patch-related code into its own module.
Brendan Cully <brendan@kublai.com>
parents:
2860
diff
changeset
|
1616 |
ui.status(_("applying %s\n") % p) |
2866
2893e51407a4
commands.import: refactor patch parsing into patch.extract.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2865
diff
changeset
|
1617 |
tmpname, message, user, date = patch.extract(ui, file(pf)) |
2893e51407a4
commands.import: refactor patch parsing into patch.extract.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2865
diff
changeset
|
1618 |
|
2893e51407a4
commands.import: refactor patch parsing into patch.extract.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2865
diff
changeset
|
1619 |
if tmpname is None: |
2893e51407a4
commands.import: refactor patch parsing into patch.extract.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2865
diff
changeset
|
1620 |
raise util.Abort(_('no diffs found')) |
2893e51407a4
commands.import: refactor patch parsing into patch.extract.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2865
diff
changeset
|
1621 |
|
2400
2e90024e1471
import: allow to import stdin with file name "-"
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2397
diff
changeset
|
1622 |
try: |
2458
9dd93deef3c9
change log message creation when using 'hg import'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2428
diff
changeset
|
1623 |
if opts['message']: |
9dd93deef3c9
change log message creation when using 'hg import'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2428
diff
changeset
|
1624 |
# pickup the cmdline msg |
9dd93deef3c9
change log message creation when using 'hg import'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2428
diff
changeset
|
1625 |
message = opts['message'] |
9dd93deef3c9
change log message creation when using 'hg import'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2428
diff
changeset
|
1626 |
elif message: |
9dd93deef3c9
change log message creation when using 'hg import'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2428
diff
changeset
|
1627 |
# pickup the patch msg |
2504
158d3d2ae070
import: parse email messages
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2494
diff
changeset
|
1628 |
message = message.strip() |
2400
2e90024e1471
import: allow to import stdin with file name "-"
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2397
diff
changeset
|
1629 |
else: |
2458
9dd93deef3c9
change log message creation when using 'hg import'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2428
diff
changeset
|
1630 |
# launch the editor |
9dd93deef3c9
change log message creation when using 'hg import'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2428
diff
changeset
|
1631 |
message = None |
2400
2e90024e1471
import: allow to import stdin with file name "-"
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2397
diff
changeset
|
1632 |
ui.debug(_('message:\n%s\n') % message) |
2e90024e1471
import: allow to import stdin with file name "-"
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2397
diff
changeset
|
1633 |
|
2919
b70740aefa4d
Unify mq and hg patch invocation.
Brendan Cully <brendan@kublai.com>
parents:
2915
diff
changeset
|
1634 |
files, fuzz = patch.patch(tmpname, ui, strip=strip, cwd=repo.root) |
2933
439fd013360d
Move import's working dir update code into patch.updatedir
Brendan Cully <brendan@kublai.com>
parents:
2922
diff
changeset
|
1635 |
files = patch.updatedir(ui, repo, files, wlock=wlock) |
2854
7706fa503677
import: get lock and wlock one time
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2847
diff
changeset
|
1636 |
repo.commit(files, message, user, date, wlock=wlock, lock=lock) |
2400
2e90024e1471
import: allow to import stdin with file name "-"
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2397
diff
changeset
|
1637 |
finally: |
2504
158d3d2ae070
import: parse email messages
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2494
diff
changeset
|
1638 |
os.unlink(tmpname) |
437 | 1639 |
|
1192
6e165de907c5
Add -p to incoming and outgoing commands to show patch
TK Soh <teekaysoh@yahoo.com>
parents:
1191
diff
changeset
|
1640 |
def incoming(ui, repo, source="default", **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1641 |
"""show new changesets found in source |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1642 |
|
1979
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
1643 |
Show new changesets found in the specified path/URL or the default |
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
1644 |
pull location. These are the changesets that would be pulled if a pull |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1645 |
was requested. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1646 |
|
1944
fdf40c9b3306
incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1943
diff
changeset
|
1647 |
For remote repository, using --bundle avoids downloading the changesets |
fdf40c9b3306
incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1943
diff
changeset
|
1648 |
twice if the incoming is followed by a pull. |
1979
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
1649 |
|
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
1650 |
See pull for valid source format details. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1651 |
""" |
1893
6569651a4f1e
Read paths specified in .hg/hgrc relative to repo root, otherwise to home dir.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1892
diff
changeset
|
1652 |
source = ui.expandpath(source) |
2731
ad4155e757da
Kill ui.setconfig_remoteopts
Matt Mackall <mpm@selenic.com>
parents:
2718
diff
changeset
|
1653 |
setremoteconfig(ui, opts) |
1965
62aa1b90414f
add remotecmd/ssh option support to incoming/outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1959
diff
changeset
|
1654 |
|
927
5a830d7bea52
Add hg incoming command for local repositories
mpm@selenic.com
parents:
924
diff
changeset
|
1655 |
other = hg.repository(ui, source) |
1959
d53a18f592be
add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1948
diff
changeset
|
1656 |
incoming = repo.findincoming(other, force=opts["force"]) |
1944
fdf40c9b3306
incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1943
diff
changeset
|
1657 |
if not incoming: |
1993
fb6ca9801d04
show message if no changes found on incoming
TK Soh <teekaysoh@yahoo.com>
parents:
1981
diff
changeset
|
1658 |
ui.status(_("no changes found\n")) |
931 | 1659 |
return |
1944
fdf40c9b3306
incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1943
diff
changeset
|
1660 |
|
fdf40c9b3306
incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1943
diff
changeset
|
1661 |
cleanup = None |
1974
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1662 |
try: |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1663 |
fname = opts["bundle"] |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1664 |
if fname or not other.local(): |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1665 |
# create a bundle (uncompressed if other repo is not local) |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1666 |
cg = other.changegroup(incoming, "incoming") |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1667 |
fname = cleanup = write_bundle(cg, fname, compress=other.local()) |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1668 |
# keep written bundle? |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1669 |
if opts["bundle"]: |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1670 |
cleanup = None |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1671 |
if not other.local(): |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1672 |
# use the created uncompressed bundlerepo |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1673 |
other = bundlerepo.bundlerepository(ui, repo.root, fname) |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1674 |
|
2521
9cceb439048b
add -r/--rev arguments to incoming and outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2515
diff
changeset
|
1675 |
revs = None |
9cceb439048b
add -r/--rev arguments to incoming and outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2515
diff
changeset
|
1676 |
if opts['rev']: |
9cceb439048b
add -r/--rev arguments to incoming and outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2515
diff
changeset
|
1677 |
revs = [other.lookup(rev) for rev in opts['rev']] |
9cceb439048b
add -r/--rev arguments to incoming and outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2515
diff
changeset
|
1678 |
o = other.changelog.nodesbetween(incoming, revs)[0] |
1974
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1679 |
if opts['newest_first']: |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1680 |
o.reverse() |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1681 |
displayer = show_changeset(ui, other, opts) |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1682 |
for n in o: |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1683 |
parents = [p for p in other.changelog.parents(n) if p != nullid] |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1684 |
if opts['no_merges'] and len(parents) == 2: |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1685 |
continue |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1686 |
displayer.show(changenode=n) |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1687 |
if opts['patch']: |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1688 |
prev = (parents and parents[0]) or nullid |
2963
a8546e40070a
fix incoming -p
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2958
diff
changeset
|
1689 |
patch.diff(other, prev, n, fp=repo.ui) |
1974
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1690 |
ui.write("\n") |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1691 |
finally: |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1692 |
if hasattr(other, 'close'): |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1693 |
other.close() |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1694 |
if cleanup: |
0d54675cd566
Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1973
diff
changeset
|
1695 |
os.unlink(cleanup) |
1944
fdf40c9b3306
incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1943
diff
changeset
|
1696 |
|
2598
b898afee9d0d
Add ui method to set --ssh/--remotecmd, use it in init/clone/pull/push/in/out.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2597
diff
changeset
|
1697 |
def init(ui, dest=".", **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1698 |
"""create a new repository in the given directory |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1699 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1700 |
Initialize a new repository in the given directory. If the given |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1701 |
directory does not exist, it is created. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1702 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1703 |
If no directory is given, the current directory is used. |
2590
911b56853fdd
Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2589
diff
changeset
|
1704 |
|
911b56853fdd
Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2589
diff
changeset
|
1705 |
It is possible to specify an ssh:// URL as the destination. |
911b56853fdd
Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2589
diff
changeset
|
1706 |
Look at the help text for the pull command for important details |
911b56853fdd
Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2589
diff
changeset
|
1707 |
about ssh:// URLs. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1708 |
""" |
2731
ad4155e757da
Kill ui.setconfig_remoteopts
Matt Mackall <mpm@selenic.com>
parents:
2718
diff
changeset
|
1709 |
setremoteconfig(ui, opts) |
907
652507dc9fce
Modify init command to take an optional directory to set up.
Bryan O'Sullivan <bos@serpentine.com>
parents:
906
diff
changeset
|
1710 |
hg.repository(ui, dest, create=1) |
338 | 1711 |
|
627 | 1712 |
def locate(ui, repo, *pats, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1713 |
"""locate files matching specific patterns |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1714 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1715 |
Print all files under Mercurial control whose names match the |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1716 |
given patterns. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1717 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1718 |
This command searches the current directory and its |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1719 |
subdirectories. To search an entire repository, move to the root |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1720 |
of the repository. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1721 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1722 |
If no patterns are given to match, this command prints all file |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1723 |
names. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1724 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1725 |
If you want to feed the output of this command into the "xargs" |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1726 |
command, use the "-0" option to both this command and "xargs". |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1727 |
This will avoid the problem of "xargs" treating single filenames |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1728 |
that contain white space as multiple filenames. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1729 |
""" |
1065
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
1730 |
end = opts['print0'] and '\0' or '\n' |
1622
5e9168401a68
fix locate broken since 63799b01985c
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1619
diff
changeset
|
1731 |
rev = opts['rev'] |
5e9168401a68
fix locate broken since 63799b01985c
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1619
diff
changeset
|
1732 |
if rev: |
5e9168401a68
fix locate broken since 63799b01985c
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1619
diff
changeset
|
1733 |
node = repo.lookup(rev) |
5e9168401a68
fix locate broken since 63799b01985c
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1619
diff
changeset
|
1734 |
else: |
5e9168401a68
fix locate broken since 63799b01985c
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1619
diff
changeset
|
1735 |
node = None |
742 | 1736 |
|
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
1737 |
for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node, |
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
1738 |
head='(?:.*/|)'): |
1622
5e9168401a68
fix locate broken since 63799b01985c
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1619
diff
changeset
|
1739 |
if not node and repo.dirstate.state(abs) == '?': |
1065
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
1740 |
continue |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
1741 |
if opts['fullpath']: |
724
1c0c413cccdd
Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
723
diff
changeset
|
1742 |
ui.write(os.path.join(repo.root, abs), end) |
1c0c413cccdd
Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
723
diff
changeset
|
1743 |
else: |
1625
e1bcf7fa983f
correct the relative path when walking from a subdir
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1622
diff
changeset
|
1744 |
ui.write(((pats and rel) or abs), end) |
627 | 1745 |
|
1031
503aaf19a040
Rewrite log command. New version is faster and more featureful.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1030
diff
changeset
|
1746 |
def log(ui, repo, *pats, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1747 |
"""show revision history of entire repository or files |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1748 |
|
2741
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
1749 |
Print the revision history of the specified files or the entire |
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
1750 |
project. |
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
1751 |
|
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
1752 |
File history is shown without following rename or copy history of |
2782
21e571c21a6b
Make log --follow without a file list follow a single head.
Brendan Cully <brendan@kublai.com>
parents:
2764
diff
changeset
|
1753 |
files. Use -f/--follow with a file name to follow history across |
21e571c21a6b
Make log --follow without a file list follow a single head.
Brendan Cully <brendan@kublai.com>
parents:
2764
diff
changeset
|
1754 |
renames and copies. --follow without a file name will only show |
2784
12a7bfcafd8f
Add log option --follow-first to follow only the first parent of
Brendan Cully <brendan@kublai.com>
parents:
2783
diff
changeset
|
1755 |
ancestors or descendants of the starting revision. --follow-first |
12a7bfcafd8f
Add log option --follow-first to follow only the first parent of
Brendan Cully <brendan@kublai.com>
parents:
2783
diff
changeset
|
1756 |
only follows the first parent of merge revisions. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1757 |
|
2783
2e0cd25fe4ac
Make log --follow revision range start default to working dir parent.
Brendan Cully <brendan@kublai.com>
parents:
2782
diff
changeset
|
1758 |
If no revision range is specified, the default is tip:0 unless |
2e0cd25fe4ac
Make log --follow revision range start default to working dir parent.
Brendan Cully <brendan@kublai.com>
parents:
2782
diff
changeset
|
1759 |
--follow is set, in which case the working directory parent is |
2e0cd25fe4ac
Make log --follow revision range start default to working dir parent.
Brendan Cully <brendan@kublai.com>
parents:
2782
diff
changeset
|
1760 |
used as the starting revision. |
2e0cd25fe4ac
Make log --follow revision range start default to working dir parent.
Brendan Cully <brendan@kublai.com>
parents:
2782
diff
changeset
|
1761 |
|
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1762 |
By default this command outputs: changeset id and hash, tags, |
1557
f7d9823e65df
Updated help text for 'hg log'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1552
diff
changeset
|
1763 |
non-trivial parents, user, date and time, and a summary for each |
f7d9823e65df
Updated help text for 'hg log'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1552
diff
changeset
|
1764 |
commit. When the -v/--verbose switch is used, the list of changed |
f7d9823e65df
Updated help text for 'hg log'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1552
diff
changeset
|
1765 |
files and full commit message is shown. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1766 |
""" |
1559
59b3639df0a9
Convert all classes to new-style classes by deriving them from object.
Eric Hopper <hopper@omnifarious.org>
parents:
1552
diff
changeset
|
1767 |
class dui(object): |
1057 | 1768 |
# Implement and delegate some ui protocol. Save hunks of |
1769 |
# output for later display in the desired order. |
|
1770 |
def __init__(self, ui): |
|
1771 |
self.ui = ui |
|
1772 |
self.hunk = {} |
|
2033
e3280d350792
Group changes done by the same developer on the same with --style=changelog
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2029
diff
changeset
|
1773 |
self.header = {} |
1057 | 1774 |
def bump(self, rev): |
1775 |
self.rev = rev |
|
1776 |
self.hunk[rev] = [] |
|
2033
e3280d350792
Group changes done by the same developer on the same with --style=changelog
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2029
diff
changeset
|
1777 |
self.header[rev] = [] |
1057 | 1778 |
def note(self, *args): |
1065
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
1779 |
if self.verbose: |
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
1780 |
self.write(*args) |
1057 | 1781 |
def status(self, *args): |
1065
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
1782 |
if not self.quiet: |
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
1783 |
self.write(*args) |
1057 | 1784 |
def write(self, *args): |
1785 |
self.hunk[self.rev].append(args) |
|
2033
e3280d350792
Group changes done by the same developer on the same with --style=changelog
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2029
diff
changeset
|
1786 |
def write_header(self, *args): |
e3280d350792
Group changes done by the same developer on the same with --style=changelog
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2029
diff
changeset
|
1787 |
self.header[self.rev].append(args) |
1381
c29c36745c6e
log --debug: fix misplaced manifest field
TK Soh <teekaysoh@yahoo.com>
parents:
1380
diff
changeset
|
1788 |
def debug(self, *args): |
c29c36745c6e
log --debug: fix misplaced manifest field
TK Soh <teekaysoh@yahoo.com>
parents:
1380
diff
changeset
|
1789 |
if self.debugflag: |
c29c36745c6e
log --debug: fix misplaced manifest field
TK Soh <teekaysoh@yahoo.com>
parents:
1380
diff
changeset
|
1790 |
self.write(*args) |
1057 | 1791 |
def __getattr__(self, key): |
1792 |
return getattr(self.ui, key) |
|
1756
f29857aaa053
add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1747
diff
changeset
|
1793 |
|
1570
6a104941d56a
hg log -p should show file deletions
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1568
diff
changeset
|
1794 |
changeiter, getchange, matchfn = walkchangerevs(ui, repo, pats, opts) |
1756
f29857aaa053
add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1747
diff
changeset
|
1795 |
|
f29857aaa053
add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1747
diff
changeset
|
1796 |
if opts['limit']: |
f29857aaa053
add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1747
diff
changeset
|
1797 |
try: |
f29857aaa053
add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1747
diff
changeset
|
1798 |
limit = int(opts['limit']) |
f29857aaa053
add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1747
diff
changeset
|
1799 |
except ValueError: |
f29857aaa053
add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1747
diff
changeset
|
1800 |
raise util.Abort(_('limit must be a positive integer')) |
f29857aaa053
add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1747
diff
changeset
|
1801 |
if limit <= 0: raise util.Abort(_('limit must be positive')) |
f29857aaa053
add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1747
diff
changeset
|
1802 |
else: |
f29857aaa053
add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1747
diff
changeset
|
1803 |
limit = sys.maxint |
f29857aaa053
add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1747
diff
changeset
|
1804 |
count = 0 |
f29857aaa053
add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1747
diff
changeset
|
1805 |
|
3197 | 1806 |
if opts['copies'] and opts['rev']: |
1807 |
endrev = max([int(i) |
|
1808 |
for i in cmdutil.revrange(ui, repo, opts['rev'])]) + 1 |
|
1809 |
else: |
|
1810 |
endrev = repo.changelog.count() |
|
1811 |
rcache = {} |
|
1812 |
ncache = {} |
|
1813 |
dcache = [] |
|
1814 |
def getrenamed(fn, rev, man): |
|
1815 |
'''looks up all renames for a file (up to endrev) the first |
|
1816 |
time the file is given. It indexes on the changerev and only |
|
1817 |
parses the manifest if linkrev != changerev. |
|
1818 |
Returns rename info for fn at changerev rev.''' |
|
1819 |
if fn not in rcache: |
|
1820 |
rcache[fn] = {} |
|
1821 |
ncache[fn] = {} |
|
1822 |
fl = repo.file(fn) |
|
1823 |
for i in xrange(fl.count()): |
|
1824 |
node = fl.node(i) |
|
1825 |
lr = fl.linkrev(node) |
|
1826 |
renamed = fl.renamed(node) |
|
1827 |
rcache[fn][lr] = renamed |
|
1828 |
if renamed: |
|
1829 |
ncache[fn][node] = renamed |
|
1830 |
if lr >= endrev: |
|
1831 |
break |
|
1832 |
if rev in rcache[fn]: |
|
1833 |
return rcache[fn][rev] |
|
1834 |
if not dcache or dcache[0] != man: |
|
1835 |
dcache[:] = [man, repo.manifest.readdelta(man)] |
|
1836 |
if fn in dcache[1]: |
|
1837 |
return ncache[fn].get(dcache[1][fn]) |
|
1838 |
return None |
|
1839 |
||
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
1840 |
displayer = show_changeset(ui, repo, opts) |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
1841 |
for st, rev, fns in changeiter: |
1057 | 1842 |
if st == 'window': |
1031
503aaf19a040
Rewrite log command. New version is faster and more featureful.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1030
diff
changeset
|
1843 |
du = dui(ui) |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
1844 |
displayer.ui = du |
1057 | 1845 |
elif st == 'add': |
1846 |
du.bump(rev) |
|
1435
22b44fd9a166
add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1431
diff
changeset
|
1847 |
changenode = repo.changelog.node(rev) |
22b44fd9a166
add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1431
diff
changeset
|
1848 |
parents = [p for p in repo.changelog.parents(changenode) |
22b44fd9a166
add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1431
diff
changeset
|
1849 |
if p != nullid] |
22b44fd9a166
add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1431
diff
changeset
|
1850 |
if opts['no_merges'] and len(parents) == 2: |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
1851 |
continue |
1436
db6d7b4005ba
add --only-merges (-m) log
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1435
diff
changeset
|
1852 |
if opts['only_merges'] and len(parents) != 2: |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
1853 |
continue |
1435
22b44fd9a166
add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1431
diff
changeset
|
1854 |
|
1373
965d1db5c95d
hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents:
1366
diff
changeset
|
1855 |
if opts['keyword']: |
1570
6a104941d56a
hg log -p should show file deletions
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1568
diff
changeset
|
1856 |
changes = getchange(rev) |
1373
965d1db5c95d
hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents:
1366
diff
changeset
|
1857 |
miss = 0 |
1404
67e20e27d8df
log: make keyword search truly case-insensitive
TK Soh <teekaysoh@yahoo.com>
parents:
1402
diff
changeset
|
1858 |
for k in [kw.lower() for kw in opts['keyword']]: |
1373
965d1db5c95d
hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents:
1366
diff
changeset
|
1859 |
if not (k in changes[1].lower() or |
965d1db5c95d
hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents:
1366
diff
changeset
|
1860 |
k in changes[4].lower() or |
965d1db5c95d
hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents:
1366
diff
changeset
|
1861 |
k in " ".join(changes[3][:20]).lower()): |
965d1db5c95d
hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents:
1366
diff
changeset
|
1862 |
miss = 1 |
965d1db5c95d
hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents:
1366
diff
changeset
|
1863 |
break |
965d1db5c95d
hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents:
1366
diff
changeset
|
1864 |
if miss: |
965d1db5c95d
hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents:
1366
diff
changeset
|
1865 |
continue |
965d1db5c95d
hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents:
1366
diff
changeset
|
1866 |
|
1764
4671078dbfe7
Cleanup: Put initialization of br in front of --branches option handling.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1763
diff
changeset
|
1867 |
br = None |
1763
fa34a74efc40
Make option --branch vs. --branches more consistent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1762
diff
changeset
|
1868 |
if opts['branches']: |
1405
6fd6527f95eb
log: speedup keyword search when used with --branch
TK Soh <teekaysoh@yahoo.com>
parents:
1404
diff
changeset
|
1869 |
br = repo.branchlookup([repo.changelog.node(rev)]) |
6fd6527f95eb
log: speedup keyword search when used with --branch
TK Soh <teekaysoh@yahoo.com>
parents:
1404
diff
changeset
|
1870 |
|
3197 | 1871 |
copies = [] |
1872 |
if opts.get('copies') and rev: |
|
1873 |
mf = getchange(rev)[0] |
|
1874 |
for fn in getchange(rev)[3]: |
|
1875 |
rename = getrenamed(fn, rev, mf) |
|
1876 |
if rename: |
|
1877 |
copies.append((fn, rename[0])) |
|
1878 |
displayer.show(rev, brinfo=br, copies=copies) |
|
1057 | 1879 |
if opts['patch']: |
1435
22b44fd9a166
add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1431
diff
changeset
|
1880 |
prev = (parents and parents[0]) or nullid |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
1881 |
patch.diff(repo, prev, changenode, match=matchfn, fp=du) |
1057 | 1882 |
du.write("\n\n") |
1883 |
elif st == 'iter': |
|
1756
f29857aaa053
add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1747
diff
changeset
|
1884 |
if count == limit: break |
2033
e3280d350792
Group changes done by the same developer on the same with --style=changelog
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2029
diff
changeset
|
1885 |
if du.header[rev]: |
e3280d350792
Group changes done by the same developer on the same with --style=changelog
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2029
diff
changeset
|
1886 |
for args in du.header[rev]: |
e3280d350792
Group changes done by the same developer on the same with --style=changelog
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2029
diff
changeset
|
1887 |
ui.write_header(*args) |
1765
b9fac31f34c9
hg log --limit shouldn't count unprinted revisions (found by TK Soh)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1764
diff
changeset
|
1888 |
if du.hunk[rev]: |
b9fac31f34c9
hg log --limit shouldn't count unprinted revisions (found by TK Soh)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1764
diff
changeset
|
1889 |
count += 1 |
b9fac31f34c9
hg log --limit shouldn't count unprinted revisions (found by TK Soh)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1764
diff
changeset
|
1890 |
for args in du.hunk[rev]: |
b9fac31f34c9
hg log --limit shouldn't count unprinted revisions (found by TK Soh)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1764
diff
changeset
|
1891 |
ui.write(*args) |
255 | 1892 |
|
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
1893 |
def manifest(ui, repo, rev=None): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1894 |
"""output the latest or given revision of the project manifest |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1895 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1896 |
Print a list of version controlled files for the given revision. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1897 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1898 |
The manifest is the list of files being version controlled. If no revision |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1899 |
is given then the tip is used. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1900 |
""" |
255 | 1901 |
if rev: |
689 | 1902 |
try: |
1903 |
# assume all revision numbers are for changesets |
|
1904 |
n = repo.lookup(rev) |
|
1905 |
change = repo.changelog.read(n) |
|
1906 |
n = change[0] |
|
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
1907 |
except hg.RepoError: |
689 | 1908 |
n = repo.manifest.lookup(rev) |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
1909 |
else: |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
1910 |
n = repo.manifest.tip() |
255 | 1911 |
m = repo.manifest.read(n) |
1912 |
files = m.keys() |
|
1913 |
files.sort() |
|
1914 |
||
1915 |
for f in files: |
|
2832
e196aa1df169
Start using manifestflags methods
Matt Mackall <mpm@selenic.com>
parents:
2601
diff
changeset
|
1916 |
ui.write("%40s %3s %s\n" % (hex(m[f]), |
2840
046a8b03ea59
Change remaining users of manifest flags
Matt Mackall <mpm@selenic.com>
parents:
2836
diff
changeset
|
1917 |
m.execf(f) and "755" or "644", f)) |
255 | 1918 |
|
2806
0bf22c109cc3
Factor doupdate into _lookup + hg.update
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
1919 |
def merge(ui, repo, node=None, force=None, branch=None): |
2019
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
1920 |
"""Merge working directory with another revision |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
1921 |
|
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
1922 |
Merge the contents of the current working directory and the |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
1923 |
requested revision. Files that changed between either parent are |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
1924 |
marked as changed for the next commit and a commit must be |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
1925 |
performed before any further updates are allowed. |
2915
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1926 |
|
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1927 |
If no revision is specified, the working directory's parent is a |
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1928 |
head revision, and the repository contains exactly one other head, |
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1929 |
the other head is merged with by default. Otherwise, an explicit |
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1930 |
revision to merge with must be provided. |
2019
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
1931 |
""" |
2806
0bf22c109cc3
Factor doupdate into _lookup + hg.update
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
1932 |
|
3071
547d1a4aa105
hg merge: fix lookup of branch
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3068
diff
changeset
|
1933 |
if node or branch: |
2915
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1934 |
node = _lookup(repo, node, branch) |
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1935 |
else: |
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1936 |
heads = repo.heads() |
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1937 |
if len(heads) > 2: |
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1938 |
raise util.Abort(_('repo has %d heads - ' |
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1939 |
'please merge with an explicit rev') % |
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1940 |
len(heads)) |
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1941 |
if len(heads) == 1: |
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1942 |
raise util.Abort(_('there is nothing to merge - ' |
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1943 |
'use "hg update" instead')) |
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1944 |
parent = repo.dirstate.parents()[0] |
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1945 |
if parent not in heads: |
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1946 |
raise util.Abort(_('working dir not at a head rev - ' |
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1947 |
'use "hg update" or merge with an explicit rev')) |
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
1948 |
node = parent == heads[0] and heads[-1] or heads[0] |
2808
30f59f4a327e
Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents:
2806
diff
changeset
|
1949 |
return hg.merge(repo, node, force=force) |
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
1950 |
|
2494
73ac95671788
push, outgoing, bundle: fall back to "default" if "default-push" not defined
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2493
diff
changeset
|
1951 |
def outgoing(ui, repo, dest=None, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1952 |
"""show changesets not found in destination |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1953 |
|
1979
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
1954 |
Show changesets not found in the specified destination repository or |
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
1955 |
the default push location. These are the changesets that would be pushed |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1956 |
if a push was requested. |
1811
6cb548cffdf5
resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1804
diff
changeset
|
1957 |
|
1979
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
1958 |
See pull for valid destination format details. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1959 |
""" |
2494
73ac95671788
push, outgoing, bundle: fall back to "default" if "default-push" not defined
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2493
diff
changeset
|
1960 |
dest = ui.expandpath(dest or 'default-push', dest or 'default') |
2731
ad4155e757da
Kill ui.setconfig_remoteopts
Matt Mackall <mpm@selenic.com>
parents:
2718
diff
changeset
|
1961 |
setremoteconfig(ui, opts) |
2521
9cceb439048b
add -r/--rev arguments to incoming and outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2515
diff
changeset
|
1962 |
revs = None |
9cceb439048b
add -r/--rev arguments to incoming and outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2515
diff
changeset
|
1963 |
if opts['rev']: |
9cceb439048b
add -r/--rev arguments to incoming and outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2515
diff
changeset
|
1964 |
revs = [repo.lookup(rev) for rev in opts['rev']] |
1965
62aa1b90414f
add remotecmd/ssh option support to incoming/outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1959
diff
changeset
|
1965 |
|
920 | 1966 |
other = hg.repository(ui, dest) |
1959
d53a18f592be
add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1948
diff
changeset
|
1967 |
o = repo.findoutgoing(other, force=opts['force']) |
1994
78ef83c9e9e1
show message if no changes found on outgoing
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1993
diff
changeset
|
1968 |
if not o: |
78ef83c9e9e1
show message if no changes found on outgoing
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1993
diff
changeset
|
1969 |
ui.status(_("no changes found\n")) |
78ef83c9e9e1
show message if no changes found on outgoing
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1993
diff
changeset
|
1970 |
return |
2521
9cceb439048b
add -r/--rev arguments to incoming and outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2515
diff
changeset
|
1971 |
o = repo.changelog.nodesbetween(o, revs)[0] |
1439
65cbe22b03fa
allow 'hg out' / 'hg in' to show newest commit first
Michal Kvasnica <kvasnica@gmail.com>
parents:
1437
diff
changeset
|
1972 |
if opts['newest_first']: |
65cbe22b03fa
allow 'hg out' / 'hg in' to show newest commit first
Michal Kvasnica <kvasnica@gmail.com>
parents:
1437
diff
changeset
|
1973 |
o.reverse() |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
1974 |
displayer = show_changeset(ui, repo, opts) |
920 | 1975 |
for n in o: |
1435
22b44fd9a166
add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1431
diff
changeset
|
1976 |
parents = [p for p in repo.changelog.parents(n) if p != nullid] |
22b44fd9a166
add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1431
diff
changeset
|
1977 |
if opts['no_merges'] and len(parents) == 2: |
22b44fd9a166
add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1431
diff
changeset
|
1978 |
continue |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
1979 |
displayer.show(changenode=n) |
1192
6e165de907c5
Add -p to incoming and outgoing commands to show patch
TK Soh <teekaysoh@yahoo.com>
parents:
1191
diff
changeset
|
1980 |
if opts['patch']: |
1435
22b44fd9a166
add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1431
diff
changeset
|
1981 |
prev = (parents and parents[0]) or nullid |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
1982 |
patch.diff(repo, prev, n) |
1192
6e165de907c5
Add -p to incoming and outgoing commands to show patch
TK Soh <teekaysoh@yahoo.com>
parents:
1191
diff
changeset
|
1983 |
ui.write("\n") |
920 | 1984 |
|
2644
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
1985 |
def parents(ui, repo, file_=None, rev=None, branches=None, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1986 |
"""show the parents of the working dir or revision |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1987 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1988 |
Print the working directory's parent revisions. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1989 |
""" |
2644
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
1990 |
# legacy |
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
1991 |
if file_ and not rev: |
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
1992 |
try: |
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
1993 |
rev = repo.lookup(file_) |
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
1994 |
file_ = None |
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
1995 |
except hg.RepoError: |
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
1996 |
pass |
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
1997 |
else: |
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
1998 |
ui.warn(_("'hg parent REV' is deprecated, " |
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
1999 |
"please use 'hg parents -r REV instead\n")) |
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
2000 |
|
706
5107a7b6b14a
Make "hg parents REV" work (again?)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
705
diff
changeset
|
2001 |
if rev: |
2644
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
2002 |
if file_: |
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
2003 |
ctx = repo.filectx(file_, changeid=rev) |
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
2004 |
else: |
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
2005 |
ctx = repo.changectx(rev) |
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
2006 |
p = [cp.node() for cp in ctx.parents()] |
255 | 2007 |
else: |
2008 |
p = repo.dirstate.parents() |
|
2009 |
||
1724
5a36609f73a7
add a -b/--branch option to 'hg parents'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1720
diff
changeset
|
2010 |
br = None |
1763
fa34a74efc40
Make option --branch vs. --branches more consistent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1762
diff
changeset
|
2011 |
if branches is not None: |
1724
5a36609f73a7
add a -b/--branch option to 'hg parents'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1720
diff
changeset
|
2012 |
br = repo.branchlookup(p) |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
2013 |
displayer = show_changeset(ui, repo, opts) |
255 | 2014 |
for n in p: |
1092 | 2015 |
if n != nullid: |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
2016 |
displayer.show(changenode=n, brinfo=br) |
255 | 2017 |
|
1858
9fab6e903bae
Make hg paths and hg debugconfig work with -R/--repository option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1857
diff
changeset
|
2018 |
def paths(ui, repo, search=None): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2019 |
"""show definition of symbolic path names |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2020 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2021 |
Show definition of symbolic path name NAME. If no name is given, show |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2022 |
definition of available names. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2023 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2024 |
Path names are defined in the [paths] section of /etc/mercurial/hgrc |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2025 |
and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2026 |
""" |
779 | 2027 |
if search: |
2028 |
for name, path in ui.configitems("paths"): |
|
2029 |
if name == search: |
|
2030 |
ui.write("%s\n" % path) |
|
2031 |
return |
|
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2032 |
ui.warn(_("not found!\n")) |
779 | 2033 |
return 1 |
2034 |
else: |
|
2035 |
for name, path in ui.configitems("paths"): |
|
2036 |
ui.write("%s = %s\n" % (name, path)) |
|
2037 |
||
2019
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2038 |
def postincoming(ui, repo, modheads, optupdate): |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2039 |
if modheads == 0: |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2040 |
return |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2041 |
if optupdate: |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2042 |
if modheads == 1: |
2806
0bf22c109cc3
Factor doupdate into _lookup + hg.update
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
2043 |
return hg.update(repo, repo.changelog.tip()) # update |
2019
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2044 |
else: |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2045 |
ui.status(_("not updating, since new heads added\n")) |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2046 |
if modheads > 1: |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2047 |
ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n")) |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2048 |
else: |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2049 |
ui.status(_("(run 'hg update' to get a working copy)\n")) |
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2050 |
|
404 | 2051 |
def pull(ui, repo, source="default", **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2052 |
"""pull changes from the specified source |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2053 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2054 |
Pull changes from a remote repository to a local one. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2055 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2056 |
This finds all changes from the repository at the specified path |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2057 |
or URL and adds them to the local repository. By default, this |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2058 |
does not update the copy of the project in the working directory. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2059 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2060 |
Valid URLs are of the form: |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2061 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2062 |
local/filesystem/path |
2589
dc63db82b530
disambiguate help about url syntax
"Aurelien Jacobs <aurel@gnuage.org>"
parents:
2580
diff
changeset
|
2063 |
http://[user@]host[:port]/[path] |
dc63db82b530
disambiguate help about url syntax
"Aurelien Jacobs <aurel@gnuage.org>"
parents:
2580
diff
changeset
|
2064 |
https://[user@]host[:port]/[path] |
dc63db82b530
disambiguate help about url syntax
"Aurelien Jacobs <aurel@gnuage.org>"
parents:
2580
diff
changeset
|
2065 |
ssh://[user@]host[:port]/[path] |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2066 |
|
1979
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
2067 |
Some notes about using SSH with Mercurial: |
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
2068 |
- SSH requires an accessible shell account on the destination machine |
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
2069 |
and a copy of hg in the remote path or specified with as remotecmd. |
2589
dc63db82b530
disambiguate help about url syntax
"Aurelien Jacobs <aurel@gnuage.org>"
parents:
2580
diff
changeset
|
2070 |
- path is relative to the remote user's home directory by default. |
2590
911b56853fdd
Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2589
diff
changeset
|
2071 |
Use an extra slash at the start of a path to specify an absolute path: |
911b56853fdd
Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2589
diff
changeset
|
2072 |
ssh://example.com//tmp/repository |
1979
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
2073 |
- Mercurial doesn't use its own compression via SSH; the right thing |
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
2074 |
to do is to configure it in your ~/.ssh/ssh_config, e.g.: |
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
2075 |
Host *.mylocalnetwork.example.com |
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
2076 |
Compression off |
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
2077 |
Host * |
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
2078 |
Compression on |
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
2079 |
Alternatively specify "ssh -C" as your ssh command in your hgrc or |
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
2080 |
with the --ssh command line option. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2081 |
""" |
1893
6569651a4f1e
Read paths specified in .hg/hgrc relative to repo root, otherwise to home dir.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1892
diff
changeset
|
2082 |
source = ui.expandpath(source) |
2731
ad4155e757da
Kill ui.setconfig_remoteopts
Matt Mackall <mpm@selenic.com>
parents:
2718
diff
changeset
|
2083 |
setremoteconfig(ui, opts) |
963
84355e3e4493
Add -e and --remotecmd for clone and pull too
mpm@selenic.com
parents:
961
diff
changeset
|
2084 |
|
246
96cde50a746f
Migrate rawcommit, import, export, history, and merge
mpm@selenic.com
parents:
245
diff
changeset
|
2085 |
other = hg.repository(ui, source) |
2473
30c267cb4c2f
change some repo messages in small ways.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2461
diff
changeset
|
2086 |
ui.status(_('pulling from %s\n') % (source)) |
1465
be6b5ce60b7f
Implementing pull -r and changing clone -r. Both now support
Eric Hopper <hopper@omnifarious.org>
parents:
1461
diff
changeset
|
2087 |
revs = None |
be6b5ce60b7f
Implementing pull -r and changing clone -r. Both now support
Eric Hopper <hopper@omnifarious.org>
parents:
1461
diff
changeset
|
2088 |
if opts['rev'] and not other.local(): |
1607
d72d27ee72b9
add '_' to several strings
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1602
diff
changeset
|
2089 |
raise util.Abort(_("pull -r doesn't work for remote repositories yet")) |
1465
be6b5ce60b7f
Implementing pull -r and changing clone -r. Both now support
Eric Hopper <hopper@omnifarious.org>
parents:
1461
diff
changeset
|
2090 |
elif opts['rev']: |
be6b5ce60b7f
Implementing pull -r and changing clone -r. Both now support
Eric Hopper <hopper@omnifarious.org>
parents:
1461
diff
changeset
|
2091 |
revs = [other.lookup(rev) for rev in opts['rev']] |
2019
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2092 |
modheads = repo.pull(other, heads=revs, force=opts['force']) |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2093 |
return postincoming(ui, repo, modheads, opts['update']) |
246
96cde50a746f
Migrate rawcommit, import, export, history, and merge
mpm@selenic.com
parents:
245
diff
changeset
|
2094 |
|
2494
73ac95671788
push, outgoing, bundle: fall back to "default" if "default-push" not defined
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2493
diff
changeset
|
2095 |
def push(ui, repo, dest=None, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2096 |
"""push changes to the specified destination |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2097 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2098 |
Push changes from the local repository to the given destination. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2099 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2100 |
This is the symmetrical operation for pull. It helps to move |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2101 |
changes from the current repository to a different one. If the |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2102 |
destination is local this is identical to a pull in that directory |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2103 |
from the current one. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2104 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2105 |
By default, push will refuse to run if it detects the result would |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2106 |
increase the number of remote heads. This generally indicates the |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2107 |
the client has forgotten to sync and merge before pushing. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2108 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2109 |
Valid URLs are of the form: |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2110 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2111 |
local/filesystem/path |
2589
dc63db82b530
disambiguate help about url syntax
"Aurelien Jacobs <aurel@gnuage.org>"
parents:
2580
diff
changeset
|
2112 |
ssh://[user@]host[:port]/[path] |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2113 |
|
1979
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
2114 |
Look at the help text for the pull command for important details |
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
2115 |
about ssh:// URLs. |
2590
911b56853fdd
Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2589
diff
changeset
|
2116 |
|
911b56853fdd
Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2589
diff
changeset
|
2117 |
Pushing to http:// and https:// URLs is possible, too, if this |
911b56853fdd
Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2589
diff
changeset
|
2118 |
feature is enabled on the remote Mercurial server. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2119 |
""" |
2494
73ac95671788
push, outgoing, bundle: fall back to "default" if "default-push" not defined
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2493
diff
changeset
|
2120 |
dest = ui.expandpath(dest or 'default-push', dest or 'default') |
2731
ad4155e757da
Kill ui.setconfig_remoteopts
Matt Mackall <mpm@selenic.com>
parents:
2718
diff
changeset
|
2121 |
setremoteconfig(ui, opts) |
961 | 2122 |
|
640
b48b91d3fb4a
Switch push over to the new scheme
Matt Mackall <mpm@selenic.com>
parents:
639
diff
changeset
|
2123 |
other = hg.repository(ui, dest) |
2473
30c267cb4c2f
change some repo messages in small ways.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2461
diff
changeset
|
2124 |
ui.status('pushing to %s\n' % (dest)) |
1781
284fc722c342
add an optional argument to push only the specified revisions (push -r)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1712
diff
changeset
|
2125 |
revs = None |
284fc722c342
add an optional argument to push only the specified revisions (push -r)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1712
diff
changeset
|
2126 |
if opts['rev']: |
284fc722c342
add an optional argument to push only the specified revisions (push -r)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1712
diff
changeset
|
2127 |
revs = [repo.lookup(rev) for rev in opts['rev']] |
284fc722c342
add an optional argument to push only the specified revisions (push -r)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1712
diff
changeset
|
2128 |
r = repo.push(other, opts['force'], revs=revs) |
2019
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2129 |
return r == 0 |
319 | 2130 |
|
403 | 2131 |
def rawcommit(ui, repo, *flist, **rc): |
1812
a81f99dfaa2a
fix the synopsis of some commands, mark rawcommit as deprecated in short help
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1811
diff
changeset
|
2132 |
"""raw commit interface (DEPRECATED) |
1811
6cb548cffdf5
resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1804
diff
changeset
|
2133 |
|
6cb548cffdf5
resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1804
diff
changeset
|
2134 |
(DEPRECATED) |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2135 |
Lowlevel commit, for use in helper scripts. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2136 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2137 |
This command is not intended to be used by normal users, as it is |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2138 |
primarily useful for importing from other SCMs. |
1657
dbb8bba48510
deprecate the rawcommit command
Matt Mackall <mpm@selenic.com>
parents:
1654
diff
changeset
|
2139 |
|
dbb8bba48510
deprecate the rawcommit command
Matt Mackall <mpm@selenic.com>
parents:
1654
diff
changeset
|
2140 |
This command is now deprecated and will be removed in a future |
dbb8bba48510
deprecate the rawcommit command
Matt Mackall <mpm@selenic.com>
parents:
1654
diff
changeset
|
2141 |
release, please use debugsetparents and commit instead. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2142 |
""" |
1657
dbb8bba48510
deprecate the rawcommit command
Matt Mackall <mpm@selenic.com>
parents:
1654
diff
changeset
|
2143 |
|
dbb8bba48510
deprecate the rawcommit command
Matt Mackall <mpm@selenic.com>
parents:
1654
diff
changeset
|
2144 |
ui.warn(_("(the rawcommit command is deprecated)\n")) |
dbb8bba48510
deprecate the rawcommit command
Matt Mackall <mpm@selenic.com>
parents:
1654
diff
changeset
|
2145 |
|
1496
3cf287a03664
remove the deprecated --text (t) option to rawcommit and tag
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1490
diff
changeset
|
2146 |
message = rc['message'] |
762
312b4a10d862
Changed more occurances of 'text' to 'message'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
761
diff
changeset
|
2147 |
if not message and rc['logfile']: |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2148 |
try: |
762
312b4a10d862
Changed more occurances of 'text' to 'message'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
761
diff
changeset
|
2149 |
message = open(rc['logfile']).read() |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2150 |
except IOError: |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2151 |
pass |
762
312b4a10d862
Changed more occurances of 'text' to 'message'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
761
diff
changeset
|
2152 |
if not message and not rc['logfile']: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2153 |
raise util.Abort(_("missing commit message")) |
246
96cde50a746f
Migrate rawcommit, import, export, history, and merge
mpm@selenic.com
parents:
245
diff
changeset
|
2154 |
|
403 | 2155 |
files = relpath(repo, list(flist)) |
246
96cde50a746f
Migrate rawcommit, import, export, history, and merge
mpm@selenic.com
parents:
245
diff
changeset
|
2156 |
if rc['files']: |
96cde50a746f
Migrate rawcommit, import, export, history, and merge
mpm@selenic.com
parents:
245
diff
changeset
|
2157 |
files += open(rc['files']).read().splitlines() |
452
a1e91c24dab5
rawcommit: do lookup of parents at the appropriate layer
mpm@selenic.com
parents:
443
diff
changeset
|
2158 |
|
a1e91c24dab5
rawcommit: do lookup of parents at the appropriate layer
mpm@selenic.com
parents:
443
diff
changeset
|
2159 |
rc['parent'] = map(repo.lookup, rc['parent']) |
500
ebc4714a7632
[PATCH] Clean up destination directory if a clone fails.
mpm@selenic.com
parents:
499
diff
changeset
|
2160 |
|
1202
71111d796e40
Commit date validation: more stringent checks, more useful error messages.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1194
diff
changeset
|
2161 |
try: |
71111d796e40
Commit date validation: more stringent checks, more useful error messages.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1194
diff
changeset
|
2162 |
repo.rawcommit(files, message, rc['user'], rc['date'], *rc['parent']) |
71111d796e40
Commit date validation: more stringent checks, more useful error messages.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1194
diff
changeset
|
2163 |
except ValueError, inst: |
71111d796e40
Commit date validation: more stringent checks, more useful error messages.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1194
diff
changeset
|
2164 |
raise util.Abort(str(inst)) |
500
ebc4714a7632
[PATCH] Clean up destination directory if a clone fails.
mpm@selenic.com
parents:
499
diff
changeset
|
2165 |
|
245 | 2166 |
def recover(ui, repo): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2167 |
"""roll back an interrupted transaction |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2168 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2169 |
Recover from an interrupted commit or pull. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2170 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2171 |
This command tries to fix the repository status after an interrupted |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2172 |
operation. It should only be necessary when Mercurial suggests it. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2173 |
""" |
1516
0b1b029b4de3
Automatically run "verify" whenever we run "recover"
Matt Mackall <mpm@selenic.com>
parents:
1514
diff
changeset
|
2174 |
if repo.recover(): |
2778 | 2175 |
return hg.verify(repo) |
2057
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
2176 |
return 1 |
245 | 2177 |
|
2179
520dd3d28e9b
add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2175
diff
changeset
|
2178 |
def remove(ui, repo, *pats, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2179 |
"""remove the specified files on the next commit |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2180 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2181 |
Schedule the indicated files for removal from the repository. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2182 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2183 |
This command schedules the files to be removed at the next commit. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2184 |
This only removes files from the current branch, not from the |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2185 |
entire project history. If the files still exist in the working |
2179
520dd3d28e9b
add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2175
diff
changeset
|
2186 |
directory, they will be deleted from it. If invoked with --after, |
520dd3d28e9b
add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2175
diff
changeset
|
2187 |
files that have been manually deleted are marked as removed. |
2309
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2188 |
|
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2189 |
Modified files and added files are not removed by default. To |
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2190 |
remove them, use the -f/--force option. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2191 |
""" |
1188
b3ceb2d470fc
Fix up remove command to use walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1187
diff
changeset
|
2192 |
names = [] |
2179
520dd3d28e9b
add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2175
diff
changeset
|
2193 |
if not opts['after'] and not pats: |
520dd3d28e9b
add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2175
diff
changeset
|
2194 |
raise util.Abort(_('no files specified')) |
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
2195 |
files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts) |
2309
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2196 |
exact = dict.fromkeys(files) |
2875
3d6efcbbd1c9
remove localrepository.changes.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2874
diff
changeset
|
2197 |
mardu = map(dict.fromkeys, repo.status(files=files, match=matchfn))[:5] |
2309
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2198 |
modified, added, removed, deleted, unknown = mardu |
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2199 |
remove, forget = [], [] |
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
2200 |
for src, abs, rel, exact in cmdutil.walk(repo, pats, opts): |
1189
4cbcc54695b2
Make removal check more complete and informative.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1188
diff
changeset
|
2201 |
reason = None |
2309
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2202 |
if abs not in deleted and opts['after']: |
2179
520dd3d28e9b
add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2175
diff
changeset
|
2203 |
reason = _('is still present') |
2309
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2204 |
elif abs in modified and not opts['force']: |
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2205 |
reason = _('is modified (use -f to force removal)') |
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2206 |
elif abs in added: |
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2207 |
if opts['force']: |
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2208 |
forget.append(abs) |
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2209 |
continue |
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2210 |
reason = _('has been marked for add (use -f to force removal)') |
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2211 |
elif abs in unknown: |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2212 |
reason = _('is not managed') |
2309
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2213 |
elif abs in removed: |
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2214 |
continue |
1255
e825dfea3823
Get all commands that operate on files to honour --verbose and --quiet.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1254
diff
changeset
|
2215 |
if reason: |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2216 |
if exact: |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2217 |
ui.warn(_('not removing %s: file %s\n') % (rel, reason)) |
1189
4cbcc54695b2
Make removal check more complete and informative.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1188
diff
changeset
|
2218 |
else: |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2219 |
if ui.verbose or not exact: |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2220 |
ui.status(_('removing %s\n') % rel) |
2309
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2221 |
remove.append(abs) |
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2222 |
repo.forget(forget) |
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
2223 |
repo.remove(remove, unlink=not opts['after']) |
245 | 2224 |
|
1253
a45e717c61a8
Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1250
diff
changeset
|
2225 |
def rename(ui, repo, *pats, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2226 |
"""rename files; equivalent of copy + remove |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2227 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2228 |
Mark dest as copies of sources; mark sources for deletion. If |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2229 |
dest is a directory, copies are put in that directory. If dest is |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2230 |
a file, there can only be one source. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2231 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2232 |
By default, this command copies the contents of files as they |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2233 |
stand in the working directory. If invoked with --after, the |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2234 |
operation is recorded, but no copying is performed. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2235 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2236 |
This command takes effect in the next commit. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2237 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2238 |
NOTE: This command should be treated as experimental. While it |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2239 |
should properly record rename files, this information is not yet |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2240 |
fully used by merge, nor fully reported by log. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2241 |
""" |
2016
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2242 |
wlock = repo.wlock(0) |
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2243 |
errs, copied = docopy(ui, repo, pats, opts, wlock) |
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2244 |
names = [] |
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2245 |
for abs, rel, exact in copied: |
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2246 |
if ui.verbose or not exact: |
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2247 |
ui.status(_('removing %s\n') % rel) |
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2248 |
names.append(abs) |
2503
37655f10ced6
Don't require opts['dry_run'] to be set to fix external tools like tailor.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2494
diff
changeset
|
2249 |
if not opts.get('dry_run'): |
2414
86e07466bcfc
remove: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2413
diff
changeset
|
2250 |
repo.remove(names, True, wlock) |
1253
a45e717c61a8
Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1250
diff
changeset
|
2251 |
return errs |
a45e717c61a8
Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1250
diff
changeset
|
2252 |
|
1472
3c909a747d7f
make revert use standard matcher
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1470
diff
changeset
|
2253 |
def revert(ui, repo, *pats, **opts): |
2227
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2254 |
"""revert files or dirs to their states as of some revision |
2204
eb5fa83ffcfa
fix doc comments for revert command. people found them confusing.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2189
diff
changeset
|
2255 |
|
2212
8164e3f31638
revert: require explicit revision when working dir has two parents.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2204
diff
changeset
|
2256 |
With no revision specified, revert the named files or directories |
8164e3f31638
revert: require explicit revision when working dir has two parents.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2204
diff
changeset
|
2257 |
to the contents they had in the parent of the working directory. |
8164e3f31638
revert: require explicit revision when working dir has two parents.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2204
diff
changeset
|
2258 |
This restores the contents of the affected files to an unmodified |
8164e3f31638
revert: require explicit revision when working dir has two parents.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2204
diff
changeset
|
2259 |
state. If the working directory has two parents, you must |
8164e3f31638
revert: require explicit revision when working dir has two parents.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2204
diff
changeset
|
2260 |
explicitly specify the revision to revert to. |
1811
6cb548cffdf5
resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1804
diff
changeset
|
2261 |
|
2036
c9226bcc288d
Don't abort when backup files already exist. Don't allow alternative names.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2029
diff
changeset
|
2262 |
Modified files are saved with a .orig suffix before reverting. |
c9226bcc288d
Don't abort when backup files already exist. Don't allow alternative names.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2029
diff
changeset
|
2263 |
To disable these backups, use --no-backup. |
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2264 |
|
3016
2b255c3478dc
minor docstring fix for revert
TK Soh <teekaysoh@yahoo.com>
parents:
3014
diff
changeset
|
2265 |
Using the -r option, revert the given files or directories to their |
2b255c3478dc
minor docstring fix for revert
TK Soh <teekaysoh@yahoo.com>
parents:
3014
diff
changeset
|
2266 |
contents as of a specific revision. This can be helpful to "roll |
1811
6cb548cffdf5
resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1804
diff
changeset
|
2267 |
back" some or all of a change that should not have been committed. |
6cb548cffdf5
resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1804
diff
changeset
|
2268 |
|
6cb548cffdf5
resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1804
diff
changeset
|
2269 |
Revert modifies the working directory. It does not commit any |
2204
eb5fa83ffcfa
fix doc comments for revert command. people found them confusing.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2189
diff
changeset
|
2270 |
changes, or change the parent of the working directory. If you |
eb5fa83ffcfa
fix doc comments for revert command. people found them confusing.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2189
diff
changeset
|
2271 |
revert to a revision other than the parent of the working |
eb5fa83ffcfa
fix doc comments for revert command. people found them confusing.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2189
diff
changeset
|
2272 |
directory, the reverted files will thus appear modified |
eb5fa83ffcfa
fix doc comments for revert command. people found them confusing.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2189
diff
changeset
|
2273 |
afterwards. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2274 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2275 |
If a file has been deleted, it is recreated. If the executable |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2276 |
mode of a file was changed, it is reset. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2277 |
|
1472
3c909a747d7f
make revert use standard matcher
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1470
diff
changeset
|
2278 |
If names are given, all files matching the names are reverted. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2279 |
|
2982
890e285c52a1
revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2963
diff
changeset
|
2280 |
If no arguments are given, no files are reverted. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2281 |
""" |
2982
890e285c52a1
revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2963
diff
changeset
|
2282 |
|
890e285c52a1
revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2963
diff
changeset
|
2283 |
if not pats and not opts['all']: |
3020
ea2a9c13afc6
Add a hint for revert --all when aborting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3016
diff
changeset
|
2284 |
raise util.Abort(_('no files or directories specified; ' |
ea2a9c13afc6
Add a hint for revert --all when aborting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3016
diff
changeset
|
2285 |
'use --all to revert the whole repo')) |
2982
890e285c52a1
revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2963
diff
changeset
|
2286 |
|
2212
8164e3f31638
revert: require explicit revision when working dir has two parents.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2204
diff
changeset
|
2287 |
parent, p2 = repo.dirstate.parents() |
3132
81da3c45aabd
Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents:
3095
diff
changeset
|
2288 |
if not opts['rev'] and p2 != nullid: |
81da3c45aabd
Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents:
3095
diff
changeset
|
2289 |
raise util.Abort(_('uncommitted merge - please provide a ' |
81da3c45aabd
Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents:
3095
diff
changeset
|
2290 |
'specific revision')) |
81da3c45aabd
Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents:
3095
diff
changeset
|
2291 |
node = repo.changectx(opts['rev']).node() |
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2292 |
mf = repo.manifest.read(repo.changelog.read(node)[0]) |
2407
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2293 |
if node == parent: |
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2294 |
pmf = mf |
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2295 |
else: |
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2296 |
pmf = None |
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2297 |
|
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2298 |
wlock = repo.wlock() |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2299 |
|
2042
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2300 |
# need all matching names in dirstate and manifest of target rev, |
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2301 |
# so have to walk both. do not print errors if files exist in one |
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2302 |
# but not other. |
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2303 |
|
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2304 |
names = {} |
2042
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2305 |
target_only = {} |
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2306 |
|
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2307 |
# walk dirstate. |
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2308 |
|
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
2309 |
for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, |
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
2310 |
badmatch=mf.has_key): |
2042
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2311 |
names[abs] = (rel, exact) |
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2312 |
if src == 'b': |
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2313 |
target_only[abs] = True |
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2314 |
|
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2315 |
# walk target manifest. |
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2316 |
|
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
2317 |
for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node, |
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
2318 |
badmatch=names.has_key): |
2042
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2319 |
if abs in names: continue |
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2320 |
names[abs] = (rel, exact) |
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2321 |
target_only[abs] = True |
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2322 |
|
2875
3d6efcbbd1c9
remove localrepository.changes.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2874
diff
changeset
|
2323 |
changes = repo.status(match=names.has_key, wlock=wlock)[:5] |
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2324 |
modified, added, removed, deleted, unknown = map(dict.fromkeys, changes) |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2325 |
|
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2326 |
revert = ([], _('reverting %s\n')) |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2327 |
add = ([], _('adding %s\n')) |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2328 |
remove = ([], _('removing %s\n')) |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2329 |
forget = ([], _('forgetting %s\n')) |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2330 |
undelete = ([], _('undeleting %s\n')) |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2331 |
update = {} |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2332 |
|
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2333 |
disptable = ( |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2334 |
# dispatch table: |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2335 |
# file state |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2336 |
# action if in target manifest |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2337 |
# action if not in target manifest |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2338 |
# make backup if in target manifest |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2339 |
# make backup if not in target manifest |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2340 |
(modified, revert, remove, True, True), |
2043
968f036f93a4
Minor fix for revert: No need to make a backup when forgetting added files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2042
diff
changeset
|
2341 |
(added, revert, forget, True, False), |
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2342 |
(removed, undelete, None, False, False), |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2343 |
(deleted, revert, remove, False, False), |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2344 |
(unknown, add, None, True, False), |
2042
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2345 |
(target_only, add, None, False, False), |
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2346 |
) |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2347 |
|
2042
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2348 |
entries = names.items() |
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2349 |
entries.sort() |
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2350 |
|
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
2351 |
for abs, (rel, exact) in entries: |
2407
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2352 |
mfentry = mf.get(abs) |
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2353 |
def handle(xlist, dobackup): |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2354 |
xlist[0].append(abs) |
2407
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2355 |
update[abs] = 1 |
2036
c9226bcc288d
Don't abort when backup files already exist. Don't allow alternative names.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2029
diff
changeset
|
2356 |
if dobackup and not opts['no_backup'] and os.path.exists(rel): |
c9226bcc288d
Don't abort when backup files already exist. Don't allow alternative names.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2029
diff
changeset
|
2357 |
bakname = "%s.orig" % rel |
c9226bcc288d
Don't abort when backup files already exist. Don't allow alternative names.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2029
diff
changeset
|
2358 |
ui.note(_('saving current version of %s as %s\n') % |
c9226bcc288d
Don't abort when backup files already exist. Don't allow alternative names.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2029
diff
changeset
|
2359 |
(rel, bakname)) |
2415
dec79ed61ee1
revert: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2414
diff
changeset
|
2360 |
if not opts.get('dry_run'): |
dec79ed61ee1
revert: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2414
diff
changeset
|
2361 |
shutil.copyfile(rel, bakname) |
dec79ed61ee1
revert: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2414
diff
changeset
|
2362 |
shutil.copymode(rel, bakname) |
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2363 |
if ui.verbose or not exact: |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2364 |
ui.status(xlist[1] % rel) |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2365 |
for table, hitlist, misslist, backuphit, backupmiss in disptable: |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2366 |
if abs not in table: continue |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2367 |
# file has changed in dirstate |
2407
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2368 |
if mfentry: |
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2369 |
handle(hitlist, backuphit) |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2370 |
elif misslist is not None: |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2371 |
handle(misslist, backupmiss) |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2372 |
else: |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2373 |
if exact: ui.warn(_('file not managed: %s\n' % rel)) |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2374 |
break |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2375 |
else: |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2376 |
# file has not changed in dirstate |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2377 |
if node == parent: |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2378 |
if exact: ui.warn(_('no changes needed to %s\n' % rel)) |
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2379 |
continue |
2407
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2380 |
if pmf is None: |
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2381 |
# only need parent manifest in this unlikely case, |
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2382 |
# so do not read by default |
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2383 |
pmf = repo.manifest.read(repo.changelog.read(parent)[0]) |
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2384 |
if abs in pmf: |
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2385 |
if mfentry: |
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2386 |
# if version of file is same in parent and target |
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2387 |
# manifests, do nothing |
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2388 |
if pmf[abs] != mfentry: |
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2389 |
handle(revert, False) |
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
2390 |
else: |
2272
e9a0ed9ed4d9
revert: fix corner case found by faheem mitha.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2268
diff
changeset
|
2391 |
handle(remove, False) |
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
2392 |
|
2415
dec79ed61ee1
revert: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2414
diff
changeset
|
2393 |
if not opts.get('dry_run'): |
dec79ed61ee1
revert: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2414
diff
changeset
|
2394 |
repo.dirstate.forget(forget[0]) |
2812
3aeab7bb5adc
Refactor update locking slightly
Matt Mackall <mpm@selenic.com>
parents:
2808
diff
changeset
|
2395 |
r = hg.revert(repo, node, update.has_key, wlock) |
2415
dec79ed61ee1
revert: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2414
diff
changeset
|
2396 |
repo.dirstate.update(add[0], 'a') |
dec79ed61ee1
revert: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2414
diff
changeset
|
2397 |
repo.dirstate.update(undelete[0], 'n') |
dec79ed61ee1
revert: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2414
diff
changeset
|
2398 |
repo.dirstate.update(remove[0], 'r') |
dec79ed61ee1
revert: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2414
diff
changeset
|
2399 |
return r |
588 | 2400 |
|
2227
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2401 |
def rollback(ui, repo): |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2402 |
"""roll back the last transaction in this repository |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2403 |
|
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2404 |
Roll back the last transaction in this repository, restoring the |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2405 |
project to its state prior to the transaction. |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2406 |
|
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2407 |
Transactions are used to encapsulate the effects of all commands |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2408 |
that create new changesets or propagate existing changesets into a |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2409 |
repository. For example, the following commands are transactional, |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2410 |
and their effects can be rolled back: |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2411 |
|
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2412 |
commit |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2413 |
import |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2414 |
pull |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2415 |
push (with this repository as destination) |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2416 |
unbundle |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2417 |
|
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2418 |
This command should be used with care. There is only one level of |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2419 |
rollback, and there is no way to undo a rollback. |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2420 |
|
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2421 |
This command is not intended for use on public repositories. Once |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2422 |
changes are visible for pull by other users, rolling a transaction |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2423 |
back locally is ineffective (someone else may already have pulled |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2424 |
the changes). Furthermore, a race is possible with readers of the |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2425 |
repository; for example an in-progress pull from the repository |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2426 |
may fail if a rollback is performed. |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2427 |
""" |
2362
482d3fb47d80
Renamed localrepo.undo() to rollback() and talk about "rollback information".
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2356
diff
changeset
|
2428 |
repo.rollback() |
2227
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2429 |
|
468 | 2430 |
def root(ui, repo): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2431 |
"""print the root (top) of the current working dir |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2432 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2433 |
Print the root directory of the current repository. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2434 |
""" |
468 | 2435 |
ui.write(repo.root + "\n") |
2436 |
||
245 | 2437 |
def serve(ui, repo, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2438 |
"""export the repository via HTTP |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2439 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2440 |
Start a local HTTP repository browser and pull server. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2441 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2442 |
By default, the server logs accesses to stdout and errors to |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2443 |
stderr. Use the "-A" and "-E" options to log to files. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2444 |
""" |
624
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
618
diff
changeset
|
2445 |
|
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
618
diff
changeset
|
2446 |
if opts["stdio"]: |
2127
8a85dbbadddf
Allow 'hg serve --webdir-conf foo' to be run outside a repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2125
diff
changeset
|
2447 |
if repo is None: |
3079
4c9fcb5e3b82
If local repository is missing, make error message clearer.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3072
diff
changeset
|
2448 |
raise hg.RepoError(_("There is no Mercurial repository here" |
4c9fcb5e3b82
If local repository is missing, make error message clearer.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3072
diff
changeset
|
2449 |
" (.hg not found)")) |
2396
8d44649df03b
refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2392
diff
changeset
|
2450 |
s = sshserver.sshserver(ui, repo) |
8d44649df03b
refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2392
diff
changeset
|
2451 |
s.serve_forever() |
2363
fa4c11751367
Give a response to unknown SSH commands
Matt Mackall <mpm@selenic.com>
parents:
2362
diff
changeset
|
2452 |
|
2125
3610d9468b1e
Use string literal concatenation for optlist and import -p option
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2124
diff
changeset
|
2453 |
optlist = ("name templates style address port ipv6" |
3610d9468b1e
Use string literal concatenation for optlist and import -p option
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2124
diff
changeset
|
2454 |
" accesslog errorlog webdir_conf") |
987 | 2455 |
for o in optlist.split(): |
2456 |
if opts[o]: |
|
2457 |
ui.setconfig("web", o, opts[o]) |
|
2458 |
||
2127
8a85dbbadddf
Allow 'hg serve --webdir-conf foo' to be run outside a repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2125
diff
changeset
|
2459 |
if repo is None and not ui.config("web", "webdir_conf"): |
3079
4c9fcb5e3b82
If local repository is missing, make error message clearer.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3072
diff
changeset
|
2460 |
raise hg.RepoError(_("There is no Mercurial repository here" |
4c9fcb5e3b82
If local repository is missing, make error message clearer.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3072
diff
changeset
|
2461 |
" (.hg not found)")) |
2127
8a85dbbadddf
Allow 'hg serve --webdir-conf foo' to be run outside a repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2125
diff
changeset
|
2462 |
|
1741
9777298fed84
stop read end of pipe from staying open forever in child process.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1740
diff
changeset
|
2463 |
if opts['daemon'] and not opts['daemon_pipefds']: |
1740
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2464 |
rfd, wfd = os.pipe() |
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2465 |
args = sys.argv[:] |
1741
9777298fed84
stop read end of pipe from staying open forever in child process.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1740
diff
changeset
|
2466 |
args.append('--daemon-pipefds=%d,%d' % (rfd, wfd)) |
1740
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2467 |
pid = os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0), |
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2468 |
args[0], args) |
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2469 |
os.close(wfd) |
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2470 |
os.read(rfd, 1) |
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2471 |
os._exit(0) |
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2472 |
|
1177
862f53c1d0f9
hg serve: print a more useful error message if server can't start.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1147
diff
changeset
|
2473 |
try: |
2392
8238a3f039e6
Adjusting hgweb splitup to be a little cleaner.
Eric Hopper <hopper@omnifarious.org>
parents:
2362
diff
changeset
|
2474 |
httpd = hgweb.server.create_server(ui, repo) |
1177
862f53c1d0f9
hg serve: print a more useful error message if server can't start.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1147
diff
changeset
|
2475 |
except socket.error, inst: |
3072
bc3fe3b5b785
Never apply string formatting to generated errors with util.Abort.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3071
diff
changeset
|
2476 |
raise util.Abort(_('cannot start server: %s') % inst.args[1]) |
987 | 2477 |
|
603
bc5d058e65e9
[PATCH] Get "hg serve" to print the URL being served
mpm@selenic.com
parents:
596
diff
changeset
|
2478 |
if ui.verbose: |
bc5d058e65e9
[PATCH] Get "hg serve" to print the URL being served
mpm@selenic.com
parents:
596
diff
changeset
|
2479 |
addr, port = httpd.socket.getsockname() |
bc5d058e65e9
[PATCH] Get "hg serve" to print the URL being served
mpm@selenic.com
parents:
596
diff
changeset
|
2480 |
if addr == '0.0.0.0': |
bc5d058e65e9
[PATCH] Get "hg serve" to print the URL being served
mpm@selenic.com
parents:
596
diff
changeset
|
2481 |
addr = socket.gethostname() |
bc5d058e65e9
[PATCH] Get "hg serve" to print the URL being served
mpm@selenic.com
parents:
596
diff
changeset
|
2482 |
else: |
bc5d058e65e9
[PATCH] Get "hg serve" to print the URL being served
mpm@selenic.com
parents:
596
diff
changeset
|
2483 |
try: |
bc5d058e65e9
[PATCH] Get "hg serve" to print the URL being served
mpm@selenic.com
parents:
596
diff
changeset
|
2484 |
addr = socket.gethostbyaddr(addr)[0] |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2485 |
except socket.error: |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2486 |
pass |
603
bc5d058e65e9
[PATCH] Get "hg serve" to print the URL being served
mpm@selenic.com
parents:
596
diff
changeset
|
2487 |
if port != 80: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2488 |
ui.status(_('listening at http://%s:%d/\n') % (addr, port)) |
603
bc5d058e65e9
[PATCH] Get "hg serve" to print the URL being served
mpm@selenic.com
parents:
596
diff
changeset
|
2489 |
else: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2490 |
ui.status(_('listening at http://%s/\n') % addr) |
1740
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2491 |
|
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2492 |
if opts['pid_file']: |
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2493 |
fp = open(opts['pid_file'], 'w') |
2571
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2567
diff
changeset
|
2494 |
fp.write(str(os.getpid()) + '\n') |
1740
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2495 |
fp.close() |
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2496 |
|
1741
9777298fed84
stop read end of pipe from staying open forever in child process.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1740
diff
changeset
|
2497 |
if opts['daemon_pipefds']: |
9777298fed84
stop read end of pipe from staying open forever in child process.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1740
diff
changeset
|
2498 |
rfd, wfd = [int(x) for x in opts['daemon_pipefds'].split(',')] |
9777298fed84
stop read end of pipe from staying open forever in child process.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1740
diff
changeset
|
2499 |
os.close(rfd) |
1740
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2500 |
os.write(wfd, 'y') |
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2501 |
os.close(wfd) |
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2502 |
sys.stdout.flush() |
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2503 |
sys.stderr.flush() |
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2504 |
fd = os.open(util.nulldev, os.O_RDWR) |
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2505 |
if fd != 0: os.dup2(fd, 0) |
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2506 |
if fd != 1: os.dup2(fd, 1) |
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2507 |
if fd != 2: os.dup2(fd, 2) |
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2508 |
if fd not in (0, 1, 2): os.close(fd) |
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
2509 |
|
603
bc5d058e65e9
[PATCH] Get "hg serve" to print the URL being served
mpm@selenic.com
parents:
596
diff
changeset
|
2510 |
httpd.serve_forever() |
500
ebc4714a7632
[PATCH] Clean up destination directory if a clone fails.
mpm@selenic.com
parents:
499
diff
changeset
|
2511 |
|
731
91ca3afab8e8
Add name matching to status command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
729
diff
changeset
|
2512 |
def status(ui, repo, *pats, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2513 |
"""show changed files in the working directory |
213 | 2514 |
|
2661
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
2515 |
Show status of files in the repository. If names are given, only |
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
2516 |
files that match are shown. Files that are clean or ignored, are |
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
2517 |
not listed unless -c (clean), -i (ignored) or -A is given. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2518 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2519 |
The codes used to show the status of files are: |
746 | 2520 |
M = modified |
245 | 2521 |
A = added |
2522 |
R = removed |
|
2661
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
2523 |
C = clean |
1619
1ba0d7041ac4
Distinguish removed and deleted files. Tests are not fixed yet.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1618
diff
changeset
|
2524 |
! = deleted, but still tracked |
842
8fb488773063
Rewritten change type selection for hg status.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
841
diff
changeset
|
2525 |
? = not tracked |
2022
a59da8cc35e4
New option -i/--ignored for 'hg status' to show ignored files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2020
diff
changeset
|
2526 |
I = ignored (not shown by default) |
2639
001703ec311d
Add an option '-C|--copies' to hg status to show the source of copied files.
Brendan Cully <brendan@kublai.com>
parents:
2630
diff
changeset
|
2527 |
= the previous added file was copied from here |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2528 |
""" |
312 | 2529 |
|
2661
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
2530 |
all = opts['all'] |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3204
diff
changeset
|
2531 |
|
2882
cf98cd70d2c4
move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2878
diff
changeset
|
2532 |
files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts) |
1625
e1bcf7fa983f
correct the relative path when walking from a subdir
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1622
diff
changeset
|
2533 |
cwd = (pats and repo.getcwd()) or '' |
2661
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
2534 |
modified, added, removed, deleted, unknown, ignored, clean = [ |
1618
ff339dd21976
Renamed c, a, d, u to modified, added, removed, unknown for users of changes()
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1615
diff
changeset
|
2535 |
[util.pathto(cwd, x) for x in n] |
2661
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
2536 |
for n in repo.status(files=files, match=matchfn, |
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
2537 |
list_ignored=all or opts['ignored'], |
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
2538 |
list_clean=all or opts['clean'])] |
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
2539 |
|
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
2540 |
changetypes = (('modified', 'M', modified), |
1966
f8b0e73e320f
hg status cleanups: Don't translate long options, remove stray semicolon.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1965
diff
changeset
|
2541 |
('added', 'A', added), |
f8b0e73e320f
hg status cleanups: Don't translate long options, remove stray semicolon.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1965
diff
changeset
|
2542 |
('removed', 'R', removed), |
f8b0e73e320f
hg status cleanups: Don't translate long options, remove stray semicolon.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1965
diff
changeset
|
2543 |
('deleted', '!', deleted), |
2022
a59da8cc35e4
New option -i/--ignored for 'hg status' to show ignored files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2020
diff
changeset
|
2544 |
('unknown', '?', unknown), |
2661
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
2545 |
('ignored', 'I', ignored)) |
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
2546 |
|
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
2547 |
explicit_changetypes = changetypes + (('clean', 'C', clean),) |
842
8fb488773063
Rewritten change type selection for hg status.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
841
diff
changeset
|
2548 |
|
1085
6f94688b81b6
status: added option -p and -0 to assist xargs
TK Soh <teekaysoh@yahoo.com>
parents:
1081
diff
changeset
|
2549 |
end = opts['print0'] and '\0' or '\n' |
1106
95a044b73bd5
Whitespace cleanup.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1105
diff
changeset
|
2550 |
|
2661
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
2551 |
for opt, char, changes in ([ct for ct in explicit_changetypes |
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
2552 |
if all or opts[ct[0]]] |
842
8fb488773063
Rewritten change type selection for hg status.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
841
diff
changeset
|
2553 |
or changetypes): |
1105
a906b018eaef
Replaced hg status -p/--strip with -n/--no-status to not confuse with patch.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1085
diff
changeset
|
2554 |
if opts['no_status']: |
1085
6f94688b81b6
status: added option -p and -0 to assist xargs
TK Soh <teekaysoh@yahoo.com>
parents:
1081
diff
changeset
|
2555 |
format = "%%s%s" % end |
6f94688b81b6
status: added option -p and -0 to assist xargs
TK Soh <teekaysoh@yahoo.com>
parents:
1081
diff
changeset
|
2556 |
else: |
1966
f8b0e73e320f
hg status cleanups: Don't translate long options, remove stray semicolon.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1965
diff
changeset
|
2557 |
format = "%s %%s%s" % (char, end) |
1106
95a044b73bd5
Whitespace cleanup.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1105
diff
changeset
|
2558 |
|
842
8fb488773063
Rewritten change type selection for hg status.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
841
diff
changeset
|
2559 |
for f in changes: |
1085
6f94688b81b6
status: added option -p and -0 to assist xargs
TK Soh <teekaysoh@yahoo.com>
parents:
1081
diff
changeset
|
2560 |
ui.write(format % f) |
3250
7c114915fbdb
Make status -C work with merge+rename
Matt Mackall <mpm@selenic.com>
parents:
3223
diff
changeset
|
2561 |
if ((all or opts.get('copies')) and not opts.get('no_status')): |
3159
e43fd1623fe1
fix users of dirstate.copies broken by b1f10d3223c1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3146
diff
changeset
|
2562 |
copied = repo.dirstate.copied(f) |
e43fd1623fe1
fix users of dirstate.copies broken by b1f10d3223c1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3146
diff
changeset
|
2563 |
if copied: |
e43fd1623fe1
fix users of dirstate.copies broken by b1f10d3223c1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3146
diff
changeset
|
2564 |
ui.write(' %s%s' % (copied, end)) |
213 | 2565 |
|
1596
41366b7d6709
fix 'hg tag <tagname> <revision>
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1589
diff
changeset
|
2566 |
def tag(ui, repo, name, rev_=None, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2567 |
"""add a tag for the current tip or a given revision |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2568 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2569 |
Name a particular revision using <name>. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2570 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2571 |
Tags are used to name particular revisions of the repository and are |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2572 |
very useful to compare different revision, to go back to significant |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2573 |
earlier versions or to mark branch points as releases, etc. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2574 |
|
2647
46182568b4ce
change 'hg tag' to tag the parent rev instead of tip
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2639
diff
changeset
|
2575 |
If no revision is given, the parent of the working directory is used. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2576 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2577 |
To facilitate version control, distribution, and merging of tags, |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2578 |
they are stored as a file named ".hgtags" which is managed |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2579 |
similarly to other project files and can be hand-edited if |
1654
b7fc961507db
deprecate the use of 'hg tag NAME [REV]'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1648
diff
changeset
|
2580 |
necessary. The file '.hg/localtags' is used for local tags (not |
b7fc961507db
deprecate the use of 'hg tag NAME [REV]'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1648
diff
changeset
|
2581 |
shared among repositories). |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2582 |
""" |
2789
e3564699409c
Add '.' as a shortcut revision name for the working directory parent.
Brendan Cully <brendan@kublai.com>
parents:
2784
diff
changeset
|
2583 |
if name in ['tip', '.']: |
e3564699409c
Add '.' as a shortcut revision name for the working directory parent.
Brendan Cully <brendan@kublai.com>
parents:
2784
diff
changeset
|
2584 |
raise util.Abort(_("the name '%s' is reserved") % name) |
1654
b7fc961507db
deprecate the use of 'hg tag NAME [REV]'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1648
diff
changeset
|
2585 |
if rev_ is not None: |
b7fc961507db
deprecate the use of 'hg tag NAME [REV]'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1648
diff
changeset
|
2586 |
ui.warn(_("use of 'hg tag NAME [REV]' is deprecated, " |
1661
b11507d6d16d
Added missing quote in warning text.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1657
diff
changeset
|
2587 |
"please use 'hg tag [-r REV] NAME' instead\n")) |
1654
b7fc961507db
deprecate the use of 'hg tag NAME [REV]'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1648
diff
changeset
|
2588 |
if opts['rev']: |
b7fc961507db
deprecate the use of 'hg tag NAME [REV]'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1648
diff
changeset
|
2589 |
raise util.Abort(_("use only one form to specify the revision")) |
1596
41366b7d6709
fix 'hg tag <tagname> <revision>
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1589
diff
changeset
|
2590 |
if opts['rev']: |
41366b7d6709
fix 'hg tag <tagname> <revision>
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1589
diff
changeset
|
2591 |
rev_ = opts['rev'] |
3132
81da3c45aabd
Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents:
3095
diff
changeset
|
2592 |
if not rev_ and repo.dirstate.parents()[1] != nullid: |
81da3c45aabd
Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents:
3095
diff
changeset
|
2593 |
raise util.Abort(_('uncommitted merge - please provide a ' |
81da3c45aabd
Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents:
3095
diff
changeset
|
2594 |
'specific revision')) |
81da3c45aabd
Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents:
3095
diff
changeset
|
2595 |
r = repo.changectx(rev_).node() |
2967
eef469259745
tag: shorten hash in default commit message
Matt Mackall <mpm@selenic.com>
parents:
2966
diff
changeset
|
2596 |
|
eef469259745
tag: shorten hash in default commit message
Matt Mackall <mpm@selenic.com>
parents:
2966
diff
changeset
|
2597 |
message = opts['message'] |
eef469259745
tag: shorten hash in default commit message
Matt Mackall <mpm@selenic.com>
parents:
2966
diff
changeset
|
2598 |
if not message: |
eef469259745
tag: shorten hash in default commit message
Matt Mackall <mpm@selenic.com>
parents:
2966
diff
changeset
|
2599 |
message = _('Added tag %s for changeset %s') % (name, short(r)) |
eef469259745
tag: shorten hash in default commit message
Matt Mackall <mpm@selenic.com>
parents:
2966
diff
changeset
|
2600 |
|
eef469259745
tag: shorten hash in default commit message
Matt Mackall <mpm@selenic.com>
parents:
2966
diff
changeset
|
2601 |
repo.tag(name, r, message, opts['local'], opts['user'], opts['date']) |
401
af4848f83e68
From: Radoslaw Szkodzinski <astralstorm@gorzow.mm.pl>
mpm@selenic.com
parents:
396
diff
changeset
|
2602 |
|
248 | 2603 |
def tags(ui, repo): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2604 |
"""list repository tags |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2605 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2606 |
List the repository tags. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2607 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2608 |
This lists both regular and local tags. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2609 |
""" |
477
520540fd6b64
Handle errors in .hgtags or hgrc [tags] section more gracefully.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
470
diff
changeset
|
2610 |
|
343 | 2611 |
l = repo.tagslist() |
2612 |
l.reverse() |
|
2966
fb493241d7f6
Only show long hashes with --debug, not --verbose
Matt Mackall <mpm@selenic.com>
parents:
2963
diff
changeset
|
2613 |
hexfunc = ui.debugflag and hex or short |
477
520540fd6b64
Handle errors in .hgtags or hgrc [tags] section more gracefully.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
470
diff
changeset
|
2614 |
for t, n in l: |
248 | 2615 |
try: |
2966
fb493241d7f6
Only show long hashes with --debug, not --verbose
Matt Mackall <mpm@selenic.com>
parents:
2963
diff
changeset
|
2616 |
r = "%5d:%s" % (repo.changelog.rev(n), hexfunc(n)) |
248 | 2617 |
except KeyError: |
477
520540fd6b64
Handle errors in .hgtags or hgrc [tags] section more gracefully.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
470
diff
changeset
|
2618 |
r = " ?:?" |
2035
107dc72880f8
Make 'hg tags -q' only list tag names without revision numbers and hashes,
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2034
diff
changeset
|
2619 |
if ui.quiet: |
107dc72880f8
Make 'hg tags -q' only list tag names without revision numbers and hashes,
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2034
diff
changeset
|
2620 |
ui.write("%s\n" % t) |
107dc72880f8
Make 'hg tags -q' only list tag names without revision numbers and hashes,
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2034
diff
changeset
|
2621 |
else: |
107dc72880f8
Make 'hg tags -q' only list tag names without revision numbers and hashes,
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2034
diff
changeset
|
2622 |
ui.write("%-30s %s\n" % (t, r)) |
248 | 2623 |
|
1731
251729df9cc6
add -p option to tip. for issue 64.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1728
diff
changeset
|
2624 |
def tip(ui, repo, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2625 |
"""show the tip revision |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2626 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2627 |
Show the tip revision. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2628 |
""" |
245 | 2629 |
n = repo.changelog.tip() |
1762
8eaa8e06a364
Add option -b/--branch to hg tip (as done for hg parents).
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1761
diff
changeset
|
2630 |
br = None |
1763
fa34a74efc40
Make option --branch vs. --branches more consistent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1762
diff
changeset
|
2631 |
if opts['branches']: |
1762
8eaa8e06a364
Add option -b/--branch to hg tip (as done for hg parents).
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1761
diff
changeset
|
2632 |
br = repo.branchlookup([n]) |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
2633 |
show_changeset(ui, repo, opts).show(changenode=n, brinfo=br) |
1731
251729df9cc6
add -p option to tip. for issue 64.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1728
diff
changeset
|
2634 |
if opts['patch']: |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
2635 |
patch.diff(repo, repo.changelog.parents(n)[0], n) |
245 | 2636 |
|
1600
728fd9584993
add --update support to 'hg unbundle'
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1596
diff
changeset
|
2637 |
def unbundle(ui, repo, fname, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2638 |
"""apply a changegroup file |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2639 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2640 |
Apply a compressed changegroup file generated by the bundle |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2641 |
command. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2642 |
""" |
1218
cde6818e082a
Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents:
1215
diff
changeset
|
2643 |
f = urllib.urlopen(fname) |
cde6818e082a
Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents:
1215
diff
changeset
|
2644 |
|
1980
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1979
diff
changeset
|
2645 |
header = f.read(6) |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1979
diff
changeset
|
2646 |
if not header.startswith("HG"): |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1979
diff
changeset
|
2647 |
raise util.Abort(_("%s: not a Mercurial bundle file") % fname) |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1979
diff
changeset
|
2648 |
elif not header.startswith("HG10"): |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1979
diff
changeset
|
2649 |
raise util.Abort(_("%s: unknown bundle version") % fname) |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1979
diff
changeset
|
2650 |
elif header == "HG10BZ": |
1940
7ae177a70f54
add a new bundle type: uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1920
diff
changeset
|
2651 |
def generator(f): |
7ae177a70f54
add a new bundle type: uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1920
diff
changeset
|
2652 |
zd = bz2.BZ2Decompressor() |
1980
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1979
diff
changeset
|
2653 |
zd.decompress("BZ") |
1940
7ae177a70f54
add a new bundle type: uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1920
diff
changeset
|
2654 |
for chunk in f: |
7ae177a70f54
add a new bundle type: uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1920
diff
changeset
|
2655 |
yield zd.decompress(chunk) |
1980
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1979
diff
changeset
|
2656 |
elif header == "HG10UN": |
1940
7ae177a70f54
add a new bundle type: uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1920
diff
changeset
|
2657 |
def generator(f): |
7ae177a70f54
add a new bundle type: uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1920
diff
changeset
|
2658 |
for chunk in f: |
7ae177a70f54
add a new bundle type: uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1920
diff
changeset
|
2659 |
yield chunk |
7ae177a70f54
add a new bundle type: uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1920
diff
changeset
|
2660 |
else: |
1980
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1979
diff
changeset
|
2661 |
raise util.Abort(_("%s: unknown bundle compression type") |
dfb796786337
use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1979
diff
changeset
|
2662 |
% fname) |
1940
7ae177a70f54
add a new bundle type: uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1920
diff
changeset
|
2663 |
gen = generator(util.filechunkiter(f, 4096)) |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2662
diff
changeset
|
2664 |
modheads = repo.addchangegroup(util.chunkbuffer(gen), 'unbundle', |
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2662
diff
changeset
|
2665 |
'bundle:' + fname) |
2019
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2666 |
return postincoming(ui, repo, modheads, opts['update']) |
1218
cde6818e082a
Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents:
1215
diff
changeset
|
2667 |
|
212
48398a5353e3
commands: better argument processing, per-command help
mpm@selenic.com
parents:
211
diff
changeset
|
2668 |
def undo(ui, repo): |
2227
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2669 |
"""undo the last commit or pull (DEPRECATED) |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2670 |
|
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2671 |
(DEPRECATED) |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2672 |
This command is now deprecated and will be removed in a future |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2673 |
release. Please use the rollback command instead. For usage |
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
2674 |
instructions, see the rollback command. |
596 | 2675 |
""" |
2238
25af3f17ce95
undo: add "deprecated" message to output.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2230
diff
changeset
|
2676 |
ui.warn(_('(the undo command is deprecated; use rollback instead)\n')) |
2362
482d3fb47d80
Renamed localrepo.undo() to rollback() and talk about "rollback information".
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2356
diff
changeset
|
2677 |
repo.rollback() |
210 | 2678 |
|
1581
db10b7114de0
abort when merging two heads and repository has local changes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1571
diff
changeset
|
2679 |
def update(ui, repo, node=None, merge=False, clean=False, force=None, |
2776
557ea210fd9f
Remove **opts arg from commands.doupdate
Matt Mackall <mpm@selenic.com>
parents:
2775
diff
changeset
|
2680 |
branch=None): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2681 |
"""update or merge working directory |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2682 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2683 |
Update the working directory to the specified revision. |
254 | 2684 |
|
2685 |
If there are no outstanding changes in the working directory and |
|
2686 |
there is a linear relationship between the current version and the |
|
2687 |
requested version, the result is the requested version. |
|
2688 |
||
2283
e506c14382fd
deprecate 'update -m'. use 'merge' instead.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2272
diff
changeset
|
2689 |
To merge the working directory with another revision, use the |
e506c14382fd
deprecate 'update -m'. use 'merge' instead.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2272
diff
changeset
|
2690 |
merge command. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2691 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2692 |
By default, update will refuse to run if doing so would require |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2693 |
merging or discarding local changes. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2694 |
""" |
2808
30f59f4a327e
Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents:
2806
diff
changeset
|
2695 |
node = _lookup(repo, node, branch) |
2283
e506c14382fd
deprecate 'update -m'. use 'merge' instead.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2272
diff
changeset
|
2696 |
if merge: |
e506c14382fd
deprecate 'update -m'. use 'merge' instead.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2272
diff
changeset
|
2697 |
ui.warn(_('(the -m/--merge option is deprecated; ' |
e506c14382fd
deprecate 'update -m'. use 'merge' instead.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2272
diff
changeset
|
2698 |
'use the merge command instead)\n')) |
2808
30f59f4a327e
Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents:
2806
diff
changeset
|
2699 |
return hg.merge(repo, node, force=force) |
30f59f4a327e
Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents:
2806
diff
changeset
|
2700 |
elif clean: |
30f59f4a327e
Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents:
2806
diff
changeset
|
2701 |
return hg.clean(repo, node) |
30f59f4a327e
Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents:
2806
diff
changeset
|
2702 |
else: |
30f59f4a327e
Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents:
2806
diff
changeset
|
2703 |
return hg.update(repo, node) |
2806
0bf22c109cc3
Factor doupdate into _lookup + hg.update
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
2704 |
|
0bf22c109cc3
Factor doupdate into _lookup + hg.update
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
2705 |
def _lookup(repo, node, branch=None): |
898 | 2706 |
if branch: |
2707 |
br = repo.branchlookup(branch=branch) |
|
2708 |
found = [] |
|
2709 |
for x in br: |
|
2710 |
if branch in br[x]: |
|
2711 |
found.append(x) |
|
2712 |
if len(found) > 1: |
|
2806
0bf22c109cc3
Factor doupdate into _lookup + hg.update
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
2713 |
repo.ui.warn(_("Found multiple heads for %s\n") % branch) |
898 | 2714 |
for x in found: |
2776
557ea210fd9f
Remove **opts arg from commands.doupdate
Matt Mackall <mpm@selenic.com>
parents:
2775
diff
changeset
|
2715 |
show_changeset(ui, repo, {}).show(changenode=x, brinfo=br) |
2806
0bf22c109cc3
Factor doupdate into _lookup + hg.update
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
2716 |
raise util.Abort("") |
898 | 2717 |
if len(found) == 1: |
2718 |
node = found[0] |
|
2806
0bf22c109cc3
Factor doupdate into _lookup + hg.update
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
2719 |
repo.ui.warn(_("Using head %s for branch %s\n") |
0bf22c109cc3
Factor doupdate into _lookup + hg.update
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
2720 |
% (short(node), branch)) |
898 | 2721 |
else: |
3072
bc3fe3b5b785
Never apply string formatting to generated errors with util.Abort.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3071
diff
changeset
|
2722 |
raise util.Abort(_("branch %s not found") % branch) |
898 | 2723 |
else: |
2724 |
node = node and repo.lookup(node) or repo.changelog.tip() |
|
2806
0bf22c109cc3
Factor doupdate into _lookup + hg.update
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
2725 |
return node |
254 | 2726 |
|
247 | 2727 |
def verify(ui, repo): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2728 |
"""verify the integrity of the repository |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2729 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2730 |
Verify the integrity of the current repository. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2731 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2732 |
This will perform an extensive check of the repository's |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2733 |
integrity, validating the hashes and checksums of each entry in |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2734 |
the changelog, manifest, and tracked files, as well as the |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2735 |
integrity of their crosslinks and indices. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2736 |
""" |
2778 | 2737 |
return hg.verify(repo) |
247 | 2738 |
|
255 | 2739 |
# Command options and aliases are listed here, alphabetically |
2740 |
||
3187
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2741 |
globalopts = [ |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2742 |
('R', 'repository', '', |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2743 |
_('repository root directory or symbolic path name')), |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2744 |
('', 'cwd', '', _('change working directory')), |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2745 |
('y', 'noninteractive', None, |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2746 |
_('do not prompt, assume \'yes\' for any required answers')), |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2747 |
('q', 'quiet', None, _('suppress output')), |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2748 |
('v', 'verbose', None, _('enable additional output')), |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2749 |
('', 'config', [], _('set/override config option')), |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2750 |
('', 'debug', None, _('enable debugging output')), |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2751 |
('', 'debugger', None, _('start debugger')), |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2752 |
('', 'lsprof', None, _('print improved command execution profile')), |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2753 |
('', 'traceback', None, _('print traceback on exception')), |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2754 |
('', 'time', None, _('time how long the command takes')), |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2755 |
('', 'profile', None, _('print command execution profile')), |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2756 |
('', 'version', None, _('output version information and exit')), |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2757 |
('h', 'help', None, _('display help and exit')), |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2758 |
] |
fca5ddbaa12a
factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3181
diff
changeset
|
2759 |
|
3189
a73a785ea8e1
factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3188
diff
changeset
|
2760 |
dryrunopts = [('n', 'dry-run', None, |
a73a785ea8e1
factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3188
diff
changeset
|
2761 |
_('do not perform actions, just print output'))] |
a73a785ea8e1
factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3188
diff
changeset
|
2762 |
|
3190
37b53487c341
factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3189
diff
changeset
|
2763 |
remoteopts = [ |
37b53487c341
factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3189
diff
changeset
|
2764 |
('e', 'ssh', '', _('specify ssh command to use')), |
37b53487c341
factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3189
diff
changeset
|
2765 |
('', 'remotecmd', '', _('specify hg command to run on the remote side')), |
37b53487c341
factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3189
diff
changeset
|
2766 |
] |
37b53487c341
factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3189
diff
changeset
|
2767 |
|
3188
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
2768 |
walkopts = [ |
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
2769 |
('I', 'include', [], _('include names matching the given patterns')), |
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
2770 |
('X', 'exclude', [], _('exclude names matching the given patterns')), |
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
2771 |
] |
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
2772 |
|
209 | 2773 |
table = { |
841
03cc2ba291d1
Realigned command table again.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
840
diff
changeset
|
2774 |
"^add": |
03cc2ba291d1
Realigned command table again.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
840
diff
changeset
|
2775 |
(add, |
3189
a73a785ea8e1
factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3188
diff
changeset
|
2776 |
walkopts + dryrunopts, |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2777 |
_('hg add [OPTION]... [FILE]...')), |
2955
9d1c3529ebbc
addremove: do not deprecate.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
2778 |
"addremove": |
841
03cc2ba291d1
Realigned command table again.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
840
diff
changeset
|
2779 |
(addremove, |
3188
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
2780 |
[('s', 'similarity', '', |
3189
a73a785ea8e1
factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3188
diff
changeset
|
2781 |
_('guess renamed files by similarity (0<=s<=100)')), |
a73a785ea8e1
factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3188
diff
changeset
|
2782 |
] + walkopts + dryrunopts, |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2783 |
_('hg addremove [OPTION]... [FILE]...')), |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2784 |
"^annotate": |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2785 |
(annotate, |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2786 |
[('r', 'rev', '', _('annotate the specified revision')), |
3172
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3159
diff
changeset
|
2787 |
('f', 'follow', None, _('follow file copies and renames')), |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2788 |
('a', 'text', None, _('treat all files as text')), |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2789 |
('u', 'user', None, _('list the author')), |
1522 | 2790 |
('d', 'date', None, _('list the date')), |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2791 |
('n', 'number', None, _('list the revision number (default)')), |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2792 |
('c', 'changeset', None, _('list the changeset')), |
3188
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
2793 |
] + walkopts, |
1816
08f4398bdb1a
Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1812
diff
changeset
|
2794 |
_('hg annotate [-r REV] [-a] [-u] [-d] [-n] [-c] FILE...')), |
2160
858df1f354c1
Cleanup archive command: Don't overwrite gettext, quoting in cmd table entry.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2159
diff
changeset
|
2795 |
"archive": |
2112
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
2796 |
(archive, |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
2797 |
[('', 'no-decode', None, _('do not pass files through decoders')), |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
2798 |
('p', 'prefix', '', _('directory prefix for files in archive')), |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
2799 |
('r', 'rev', '', _('revision to distribute')), |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
2800 |
('t', 'type', '', _('type of distribution to create')), |
3188
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
2801 |
] + walkopts, |
2112
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
2802 |
_('hg archive [OPTION]... DEST')), |
2159
5c34b98ad6b1
Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2158
diff
changeset
|
2803 |
"backout": |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
2804 |
(backout, |
2159
5c34b98ad6b1
Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2158
diff
changeset
|
2805 |
[('', 'merge', None, |
5c34b98ad6b1
Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2158
diff
changeset
|
2806 |
_('merge with old dirstate parent after backout')), |
5c34b98ad6b1
Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2158
diff
changeset
|
2807 |
('m', 'message', '', _('use <text> as commit message')), |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
2808 |
('l', 'logfile', '', _('read commit message from <file>')), |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
2809 |
('d', 'date', '', _('record datecode as commit date')), |
2614
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
2810 |
('', 'parent', '', _('parent to choose when backing out merge')), |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
2811 |
('u', 'user', '', _('record user as committer')), |
3188
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
2812 |
] + walkopts, |
2159
5c34b98ad6b1
Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2158
diff
changeset
|
2813 |
_('hg backout [OPTION]... REV')), |
1218
cde6818e082a
Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents:
1215
diff
changeset
|
2814 |
"bundle": |
cde6818e082a
Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents:
1215
diff
changeset
|
2815 |
(bundle, |
1959
d53a18f592be
add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1948
diff
changeset
|
2816 |
[('f', 'force', None, |
3191
545b6d718593
add remoteopts to bundle command
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3190
diff
changeset
|
2817 |
_('run even when remote repository is unrelated')), |
3284
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
2818 |
('r', 'rev', [], |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
2819 |
_('a changeset you would like to bundle')), |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
2820 |
('', 'base', [], |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
2821 |
_('a base changeset to specify instead of a destination')), |
3191
545b6d718593
add remoteopts to bundle command
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3190
diff
changeset
|
2822 |
] + remoteopts, |
3284
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
2823 |
_('hg bundle [--base REV]... [--rev REV]... FILE [DEST]')), |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2824 |
"cat": |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2825 |
(cat, |
1816
08f4398bdb1a
Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1812
diff
changeset
|
2826 |
[('o', 'output', '', _('print output to file with formatted name')), |
08f4398bdb1a
Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1812
diff
changeset
|
2827 |
('r', 'rev', '', _('print the given revision')), |
3188
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
2828 |
] + walkopts, |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2829 |
_('hg cat [OPTION]... FILE...')), |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2830 |
"^clone": |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2831 |
(clone, |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2832 |
[('U', 'noupdate', None, _('do not update the new working directory')), |
1602
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
2833 |
('r', 'rev', [], |
2764
71029a3247cb
clone: replace long help string of inaky with doc comment.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2763
diff
changeset
|
2834 |
_('a changeset you would like to have after cloning')), |
1816
08f4398bdb1a
Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1812
diff
changeset
|
2835 |
('', 'pull', None, _('use pull protocol to copy metadata')), |
2620
de82749d3a71
clone: change name of --stream to --uncompressed.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2618
diff
changeset
|
2836 |
('', 'uncompressed', None, |
de82749d3a71
clone: change name of --stream to --uncompressed.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2618
diff
changeset
|
2837 |
_('use uncompressed transfer (fast over LAN)')), |
3190
37b53487c341
factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3189
diff
changeset
|
2838 |
] + remoteopts, |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2839 |
_('hg clone [OPTION]... SOURCE [DEST]')), |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2840 |
"^commit|ci": |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2841 |
(commit, |
2184
2477a7183a6f
Add debugaddremove alias to addremove, so it doesn't show up in 'hg help'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2181
diff
changeset
|
2842 |
[('A', 'addremove', None, |
2477a7183a6f
Add debugaddremove alias to addremove, so it doesn't show up in 'hg help'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2181
diff
changeset
|
2843 |
_('mark new/missing files as added/removed before committing')), |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2844 |
('m', 'message', '', _('use <text> as commit message')), |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2845 |
('l', 'logfile', '', _('read the commit message from <file>')), |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2846 |
('d', 'date', '', _('record datecode as commit date')), |
1816
08f4398bdb1a
Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1812
diff
changeset
|
2847 |
('u', 'user', '', _('record user as commiter')), |
3188
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
2848 |
] + walkopts, |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2849 |
_('hg commit [OPTION]... [FILE]...')), |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2850 |
"copy|cp": |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2851 |
(copy, |
1816
08f4398bdb1a
Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1812
diff
changeset
|
2852 |
[('A', 'after', None, _('record a copy that has already occurred')), |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2853 |
('f', 'force', None, |
1816
08f4398bdb1a
Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1812
diff
changeset
|
2854 |
_('forcibly copy over an existing managed file')), |
3189
a73a785ea8e1
factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3188
diff
changeset
|
2855 |
] + walkopts + dryrunopts, |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2856 |
_('hg copy [OPTION]... [SOURCE]... DEST')), |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2857 |
"debugancestor": (debugancestor, [], _('debugancestor INDEX REV1 REV2')), |
2034
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
2858 |
"debugcomplete": |
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
2859 |
(debugcomplete, |
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
2860 |
[('o', 'options', None, _('show the command options'))], |
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2033
diff
changeset
|
2861 |
_('debugcomplete [-o] CMD')), |
1755
a8f7791e3680
add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1754
diff
changeset
|
2862 |
"debugrebuildstate": |
a8f7791e3680
add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1754
diff
changeset
|
2863 |
(debugrebuildstate, |
1816
08f4398bdb1a
Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1812
diff
changeset
|
2864 |
[('r', 'rev', '', _('revision to rebuild to'))], |
1755
a8f7791e3680
add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1754
diff
changeset
|
2865 |
_('debugrebuildstate [-r REV] [REV]')), |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2866 |
"debugcheckstate": (debugcheckstate, [], _('debugcheckstate')), |
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2867 |
"debugsetparents": (debugsetparents, [], _('debugsetparents REV1 [REV2]')), |
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2868 |
"debugstate": (debugstate, [], _('debugstate')), |
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2869 |
"debugdata": (debugdata, [], _('debugdata FILE REV')), |
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2870 |
"debugindex": (debugindex, [], _('debugindex FILE')), |
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2871 |
"debugindexdot": (debugindexdot, [], _('debugindexdot FILE')), |
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2872 |
"debugrename": (debugrename, [], _('debugrename FILE [REV]')), |
841
03cc2ba291d1
Realigned command table again.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
840
diff
changeset
|
2873 |
"debugwalk": |
3188
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
2874 |
(debugwalk, walkopts, _('debugwalk [OPTION]... [FILE]...')), |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2875 |
"^diff": |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2876 |
(diff, |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2877 |
[('r', 'rev', [], _('revision')), |
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2878 |
('a', 'text', None, _('treat all files as text')), |
1728
9b92b71d5dd7
add -w and -p options to diff. this is for issue 126.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1720
diff
changeset
|
2879 |
('p', 'show-function', None, |
9b92b71d5dd7
add -w and -p options to diff. this is for issue 126.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1720
diff
changeset
|
2880 |
_('show which function each change is in')), |
2907 | 2881 |
('g', 'git', None, _('use git extended diff format')), |
3200
367a009c2acb
Remove single character equivalent of --nodates (was -D)
Stephen Darnell <stephen@darnell.plus.com>
parents:
3199
diff
changeset
|
2882 |
('', 'nodates', None, _("don't include dates in diff headers")), |
1728
9b92b71d5dd7
add -w and -p options to diff. this is for issue 126.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1720
diff
changeset
|
2883 |
('w', 'ignore-all-space', None, |
9b92b71d5dd7
add -w and -p options to diff. this is for issue 126.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1720
diff
changeset
|
2884 |
_('ignore white space when comparing lines')), |
2580
a20a1bb0c396
diff: add -b/-B options
Haakon Riiser <haakon.riiser@fys.uio.no>
parents:
2579
diff
changeset
|
2885 |
('b', 'ignore-space-change', None, |
a20a1bb0c396
diff: add -b/-B options
Haakon Riiser <haakon.riiser@fys.uio.no>
parents:
2579
diff
changeset
|
2886 |
_('ignore changes in the amount of white space')), |
a20a1bb0c396
diff: add -b/-B options
Haakon Riiser <haakon.riiser@fys.uio.no>
parents:
2579
diff
changeset
|
2887 |
('B', 'ignore-blank-lines', None, |
a20a1bb0c396
diff: add -b/-B options
Haakon Riiser <haakon.riiser@fys.uio.no>
parents:
2579
diff
changeset
|
2888 |
_('ignore changes whose lines are all blank')), |
3188
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
2889 |
] + walkopts, |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2890 |
_('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')), |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2891 |
"^export": |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2892 |
(export, |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2893 |
[('o', 'output', '', _('print output to file with formatted name')), |
1571
bcdc030c59f8
add a --switch-parent option to export against the other parent
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1570
diff
changeset
|
2894 |
('a', 'text', None, _('treat all files as text')), |
3029 | 2895 |
('g', 'git', None, _('use git extended diff format')), |
3200
367a009c2acb
Remove single character equivalent of --nodates (was -D)
Stephen Darnell <stephen@darnell.plus.com>
parents:
3199
diff
changeset
|
2896 |
('', 'nodates', None, _("don't include dates in diff headers")), |
1571
bcdc030c59f8
add a --switch-parent option to export against the other parent
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1570
diff
changeset
|
2897 |
('', 'switch-parent', None, _('diff against the second parent'))], |
1812
a81f99dfaa2a
fix the synopsis of some commands, mark rawcommit as deprecated in short help
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1811
diff
changeset
|
2898 |
_('hg export [-a] [-o OUTFILESPEC] REV...')), |
2140
6447a32aefce
Make the deprecated forget an alias of debugforget.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2135
diff
changeset
|
2899 |
"debugforget|forget": |
3188
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
2900 |
(forget, walkopts, _('hg forget [OPTION]... FILE...')), |
1065
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
2901 |
"grep": |
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
2902 |
(grep, |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2903 |
[('0', 'print0', None, _('end fields with NUL')), |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2904 |
('', 'all', None, _('print all revisions that match')), |
2870
8eaaf1321bfe
grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents:
2869
diff
changeset
|
2905 |
('f', 'follow', None, |
8eaaf1321bfe
grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents:
2869
diff
changeset
|
2906 |
_('follow changeset history, or file history across copies and renames')), |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2907 |
('i', 'ignore-case', None, _('ignore case when matching')), |
1602
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
2908 |
('l', 'files-with-matches', None, |
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
2909 |
_('print only filenames and revs that match')), |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2910 |
('n', 'line-number', None, _('print matching line numbers')), |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2911 |
('r', 'rev', [], _('search in given revision range')), |
1816
08f4398bdb1a
Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1812
diff
changeset
|
2912 |
('u', 'user', None, _('print user who committed change')), |
3188
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
2913 |
] + walkopts, |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2914 |
_('hg grep [OPTION]... PATTERN [FILE]...')), |
905
65763ff9fa53
Update online help of hg heads for new --branches option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
904
diff
changeset
|
2915 |
"heads": |
65763ff9fa53
Update online help of hg heads for new --branches option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
904
diff
changeset
|
2916 |
(heads, |
1763
fa34a74efc40
Make option --branch vs. --branches more consistent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1762
diff
changeset
|
2917 |
[('b', 'branches', None, _('show branches')), |
1913
74cf2b2f43d4
fix some things people wanted to be cleaner.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1910
diff
changeset
|
2918 |
('', 'style', '', _('display using template map file')), |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
2919 |
('r', 'rev', '', _('show only heads which are descendants of rev')), |
1913
74cf2b2f43d4
fix some things people wanted to be cleaner.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1910
diff
changeset
|
2920 |
('', 'template', '', _('display with template'))], |
1550
ccb9b62de892
add a -r/--rev option to heads to show only heads descendant from rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1547
diff
changeset
|
2921 |
_('hg heads [-b] [-r <rev>]')), |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2922 |
"help": (help_, [], _('hg help [COMMAND]')), |
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2923 |
"identify|id": (identify, [], _('hg identify')), |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2924 |
"import|patch": |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2925 |
(import_, |
1602
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
2926 |
[('p', 'strip', 1, |
2125
3610d9468b1e
Use string literal concatenation for optlist and import -p option
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2124
diff
changeset
|
2927 |
_('directory strip option for patch. This has the same\n' |
3610d9468b1e
Use string literal concatenation for optlist and import -p option
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2124
diff
changeset
|
2928 |
'meaning as the corresponding patch option')), |
2458
9dd93deef3c9
change log message creation when using 'hg import'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2428
diff
changeset
|
2929 |
('m', 'message', '', _('use <text> as commit message')), |
1816
08f4398bdb1a
Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1812
diff
changeset
|
2930 |
('b', 'base', '', _('base path')), |
1602
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
2931 |
('f', 'force', None, |
1816
08f4398bdb1a
Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1812
diff
changeset
|
2932 |
_('skip check for outstanding uncommitted changes'))], |
2458
9dd93deef3c9
change log message creation when using 'hg import'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2428
diff
changeset
|
2933 |
_('hg import [-p NUM] [-b BASE] [-m MESSAGE] [-f] PATCH...')), |
1253
a45e717c61a8
Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1250
diff
changeset
|
2934 |
"incoming|in": (incoming, |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2935 |
[('M', 'no-merges', None, _('do not show merges')), |
1959
d53a18f592be
add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1948
diff
changeset
|
2936 |
('f', 'force', None, |
d53a18f592be
add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1948
diff
changeset
|
2937 |
_('run even when remote repository is unrelated')), |
1913
74cf2b2f43d4
fix some things people wanted to be cleaner.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1910
diff
changeset
|
2938 |
('', 'style', '', _('display using template map file')), |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
2939 |
('n', 'newest-first', None, _('show newest record first')), |
1944
fdf40c9b3306
incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1943
diff
changeset
|
2940 |
('', 'bundle', '', _('file to store the bundles into')), |
1439
65cbe22b03fa
allow 'hg out' / 'hg in' to show newest commit first
Michal Kvasnica <kvasnica@gmail.com>
parents:
1437
diff
changeset
|
2941 |
('p', 'patch', None, _('show patch')), |
2878
982c3237c63d
Make clear that hg pull -r REV pulls "up to" a revision.
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
2875
diff
changeset
|
2942 |
('r', 'rev', [], _('a specific revision up to which you would like to pull')), |
1965
62aa1b90414f
add remotecmd/ssh option support to incoming/outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1959
diff
changeset
|
2943 |
('', 'template', '', _('display with template')), |
3190
37b53487c341
factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3189
diff
changeset
|
2944 |
] + remoteopts, |
2521
9cceb439048b
add -r/--rev arguments to incoming and outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2515
diff
changeset
|
2945 |
_('hg incoming [-p] [-n] [-M] [-r REV]...' |
2544
0ab63318bc36
Added missing space in continued string.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2521
diff
changeset
|
2946 |
' [--bundle FILENAME] [SOURCE]')), |
2598
b898afee9d0d
Add ui method to set --ssh/--remotecmd, use it in init/clone/pull/push/in/out.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2597
diff
changeset
|
2947 |
"^init": |
3190
37b53487c341
factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3189
diff
changeset
|
2948 |
(init, remoteopts, _('hg init [-e FILE] [--remotecmd FILE] [DEST]')), |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2949 |
"locate": |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2950 |
(locate, |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2951 |
[('r', 'rev', '', _('search the repository as it stood at rev')), |
1602
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
2952 |
('0', 'print0', None, |
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
2953 |
_('end filenames with NUL, for use with xargs')), |
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
2954 |
('f', 'fullpath', None, |
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
2955 |
_('print complete paths from the filesystem root')), |
3188
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
2956 |
] + walkopts, |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2957 |
_('hg locate [OPTION]... [PATTERN]...')), |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2958 |
"^log|history": |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
2959 |
(log, |
1816
08f4398bdb1a
Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1812
diff
changeset
|
2960 |
[('b', 'branches', None, _('show branches')), |
2741
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
2961 |
('f', 'follow', None, |
2782
21e571c21a6b
Make log --follow without a file list follow a single head.
Brendan Cully <brendan@kublai.com>
parents:
2764
diff
changeset
|
2962 |
_('follow changeset history, or file history across copies and renames')), |
2784
12a7bfcafd8f
Add log option --follow-first to follow only the first parent of
Brendan Cully <brendan@kublai.com>
parents:
2783
diff
changeset
|
2963 |
('', 'follow-first', None, |
12a7bfcafd8f
Add log option --follow-first to follow only the first parent of
Brendan Cully <brendan@kublai.com>
parents:
2783
diff
changeset
|
2964 |
_('only follow the first parent of merge changesets')), |
3197 | 2965 |
('C', 'copies', None, _('show copied files')), |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2966 |
('k', 'keyword', [], _('search for a keyword')), |
1756
f29857aaa053
add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1747
diff
changeset
|
2967 |
('l', 'limit', '', _('limit number of changes displayed')), |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2968 |
('r', 'rev', [], _('show the specified revision or range')), |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2969 |
('M', 'no-merges', None, _('do not show merges')), |
1913
74cf2b2f43d4
fix some things people wanted to be cleaner.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1910
diff
changeset
|
2970 |
('', 'style', '', _('display using template map file')), |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2971 |
('m', 'only-merges', None, _('show only merges')), |
1816
08f4398bdb1a
Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1812
diff
changeset
|
2972 |
('p', 'patch', None, _('show patch')), |
2901 | 2973 |
('P', 'prune', [], _('do not display revision or any of its ancestors')), |
1920 | 2974 |
('', 'template', '', _('display with template')), |
3188
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
2975 |
] + walkopts, |
1816
08f4398bdb1a
Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1812
diff
changeset
|
2976 |
_('hg log [OPTION]... [FILE]')), |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
2977 |
"manifest": (manifest, [], _('hg manifest [REV]')), |
2019
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
2978 |
"merge": |
2044
b343e7d454b4
Don't allow --style and --template for hg update and hg merge.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2043
diff
changeset
|
2979 |
(merge, |
b343e7d454b4
Don't allow --style and --template for hg update and hg merge.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2043
diff
changeset
|
2980 |
[('b', 'branch', '', _('merge with head of a specific branch')), |
b343e7d454b4
Don't allow --style and --template for hg update and hg merge.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2043
diff
changeset
|
2981 |
('f', 'force', None, _('force a merge with outstanding changes'))], |
b343e7d454b4
Don't allow --style and --template for hg update and hg merge.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2043
diff
changeset
|
2982 |
_('hg merge [-b TAG] [-f] [REV]')), |
1253
a45e717c61a8
Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1250
diff
changeset
|
2983 |
"outgoing|out": (outgoing, |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2984 |
[('M', 'no-merges', None, _('do not show merges')), |
1959
d53a18f592be
add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1948
diff
changeset
|
2985 |
('f', 'force', None, |
d53a18f592be
add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1948
diff
changeset
|
2986 |
_('run even when remote repository is unrelated')), |
1439
65cbe22b03fa
allow 'hg out' / 'hg in' to show newest commit first
Michal Kvasnica <kvasnica@gmail.com>
parents:
1437
diff
changeset
|
2987 |
('p', 'patch', None, _('show patch')), |
1913
74cf2b2f43d4
fix some things people wanted to be cleaner.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1910
diff
changeset
|
2988 |
('', 'style', '', _('display using template map file')), |
2521
9cceb439048b
add -r/--rev arguments to incoming and outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2515
diff
changeset
|
2989 |
('r', 'rev', [], _('a specific revision you would like to push')), |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
2990 |
('n', 'newest-first', None, _('show newest record first')), |
1965
62aa1b90414f
add remotecmd/ssh option support to incoming/outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1959
diff
changeset
|
2991 |
('', 'template', '', _('display with template')), |
3190
37b53487c341
factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3189
diff
changeset
|
2992 |
] + remoteopts, |
2521
9cceb439048b
add -r/--rev arguments to incoming and outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2515
diff
changeset
|
2993 |
_('hg outgoing [-M] [-p] [-n] [-r REV]... [DEST]')), |
1724
5a36609f73a7
add a -b/--branch option to 'hg parents'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1720
diff
changeset
|
2994 |
"^parents": |
5a36609f73a7
add a -b/--branch option to 'hg parents'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1720
diff
changeset
|
2995 |
(parents, |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
2996 |
[('b', 'branches', None, _('show branches')), |
2644
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
2997 |
('r', 'rev', '', _('show parents from the specified rev')), |
1913
74cf2b2f43d4
fix some things people wanted to be cleaner.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1910
diff
changeset
|
2998 |
('', 'style', '', _('display using template map file')), |
74cf2b2f43d4
fix some things people wanted to be cleaner.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1910
diff
changeset
|
2999 |
('', 'template', '', _('display with template'))], |
2644
b24efed24e8f
allow specifying a file to hg parents, change the syntax to use -r/--rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2626
diff
changeset
|
3000 |
_('hg parents [-b] [-r REV] [FILE]')), |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3001 |
"paths": (paths, [], _('hg paths [NAME]')), |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
3002 |
"^pull": |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
3003 |
(pull, |
1602
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
3004 |
[('u', 'update', None, |
3198
a32f65549b9e
Documentation clarification for --update option to pull and unbundle
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3197
diff
changeset
|
3005 |
_('update to new tip if changesets were pulled')), |
1959
d53a18f592be
add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1948
diff
changeset
|
3006 |
('f', 'force', None, |
d53a18f592be
add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1948
diff
changeset
|
3007 |
_('run even when remote repository is unrelated')), |
2878
982c3237c63d
Make clear that hg pull -r REV pulls "up to" a revision.
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
2875
diff
changeset
|
3008 |
('r', 'rev', [], _('a specific revision up to which you would like to pull')), |
3190
37b53487c341
factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3189
diff
changeset
|
3009 |
] + remoteopts, |
2598
b898afee9d0d
Add ui method to set --ssh/--remotecmd, use it in init/clone/pull/push/in/out.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2597
diff
changeset
|
3010 |
_('hg pull [-u] [-r REV]... [-e FILE] [--remotecmd FILE] [SOURCE]')), |
818 | 3011 |
"^push": |
3012 |
(push, |
|
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3013 |
[('f', 'force', None, _('force push')), |
1781
284fc722c342
add an optional argument to push only the specified revisions (push -r)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1712
diff
changeset
|
3014 |
('r', 'rev', [], _('a specific revision you would like to push')), |
3190
37b53487c341
factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3189
diff
changeset
|
3015 |
] + remoteopts, |
2598
b898afee9d0d
Add ui method to set --ssh/--remotecmd, use it in init/clone/pull/push/in/out.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2597
diff
changeset
|
3016 |
_('hg push [-f] [-r REV]... [-e FILE] [--remotecmd FILE] [DEST]')), |
1818
9bbc7b304c34
Make the deprecated rawcommit an alias of debugrawcommit.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1816
diff
changeset
|
3017 |
"debugrawcommit|rawcommit": |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
3018 |
(rawcommit, |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3019 |
[('p', 'parent', [], _('parent')), |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3020 |
('d', 'date', '', _('date code')), |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3021 |
('u', 'user', '', _('user')), |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3022 |
('F', 'files', '', _('file list')), |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3023 |
('m', 'message', '', _('commit message')), |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3024 |
('l', 'logfile', '', _('commit message file'))], |
1818
9bbc7b304c34
Make the deprecated rawcommit an alias of debugrawcommit.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1816
diff
changeset
|
3025 |
_('hg debugrawcommit [OPTION]... [FILE]...')), |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3026 |
"recover": (recover, [], _('hg recover')), |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3027 |
"^remove|rm": |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3028 |
(remove, |
2245
d2118a0926bd
Added -A as an alias for --after to hg remove, like for other commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2241
diff
changeset
|
3029 |
[('A', 'after', None, _('record remove that has already occurred')), |
2179
520dd3d28e9b
add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2175
diff
changeset
|
3030 |
('f', 'force', None, _('remove file even if modified')), |
3188
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
3031 |
] + walkopts, |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3032 |
_('hg remove [OPTION]... FILE...')), |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3033 |
"rename|mv": |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3034 |
(rename, |
1816
08f4398bdb1a
Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1812
diff
changeset
|
3035 |
[('A', 'after', None, _('record a rename that has already occurred')), |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3036 |
('f', 'force', None, |
1816
08f4398bdb1a
Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1812
diff
changeset
|
3037 |
_('forcibly copy over an existing managed file')), |
3189
a73a785ea8e1
factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3188
diff
changeset
|
3038 |
] + walkopts + dryrunopts, |
1869
42c76ec7a8d4
Reordered options for remove, fixed synopsis for rename.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1867
diff
changeset
|
3039 |
_('hg rename [OPTION]... SOURCE... DEST')), |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
3040 |
"^revert": |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
3041 |
(revert, |
2983
3b7626b861f8
revert: add -a as alias for --all
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2982
diff
changeset
|
3042 |
[('a', 'all', None, _('revert all changes when no arguments given')), |
2982
890e285c52a1
revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2963
diff
changeset
|
3043 |
('r', 'rev', '', _('revision to revert to')), |
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
3044 |
('', 'no-backup', None, _('do not save backup copies of files')), |
3189
a73a785ea8e1
factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3188
diff
changeset
|
3045 |
] + walkopts + dryrunopts, |
1816
08f4398bdb1a
Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1812
diff
changeset
|
3046 |
_('hg revert [-r REV] [NAME]...')), |
2227
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
3047 |
"rollback": (rollback, [], _('hg rollback')), |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3048 |
"root": (root, [], _('hg root')), |
3268
bb057b6ce3cf
Un-debugify debugconfig to showconfig. (issue 317)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3250
diff
changeset
|
3049 |
"showconfig|debugconfig": (showconfig, [], _('showconfig [NAME]...')), |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
3050 |
"^serve": |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
3051 |
(serve, |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3052 |
[('A', 'accesslog', '', _('name of access log file to write to')), |
1740
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
3053 |
('d', 'daemon', None, _('run server in background')), |
1742
1e5bb6c929cd
Added help string for --daemon-pipefds
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1741
diff
changeset
|
3054 |
('', 'daemon-pipefds', '', _('used internally by daemon mode')), |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3055 |
('E', 'errorlog', '', _('name of error log file to write to')), |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3056 |
('p', 'port', 0, _('port to use (default: 8000)')), |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3057 |
('a', 'address', '', _('address to use')), |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3058 |
('n', 'name', '', |
1602
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
3059 |
_('name to show in web pages (default: working dir)')), |
2124
27fd8b7a6c51
Cleaned trailing whitespace in hgweb.py, removed command line shortcut for webdir-conf.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
2122
diff
changeset
|
3060 |
('', 'webdir-conf', '', _('name of the webdir config file' |
27fd8b7a6c51
Cleaned trailing whitespace in hgweb.py, removed command line shortcut for webdir-conf.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
2122
diff
changeset
|
3061 |
' (serve more than one repo)')), |
1740
f95654385065
add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
3062 |
('', 'pid-file', '', _('name of file to write process ID to')), |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3063 |
('', 'stdio', None, _('for remote clients')), |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3064 |
('t', 'templates', '', _('web templates to use')), |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3065 |
('', 'style', '', _('template style to use')), |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3066 |
('6', 'ipv6', None, _('use IPv6 in addition to IPv4'))], |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3067 |
_('hg serve [OPTION]...')), |
1507
cd8fadd8c689
Add explicit 'st' alias for status
Matt Mackall <mpm@selenic.com>
parents:
1506
diff
changeset
|
3068 |
"^status|st": |
840
141744605b51
hg status: added options to select files by status.
tksoh@users.sourceforge.net
parents:
839
diff
changeset
|
3069 |
(status, |
2661
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
3070 |
[('A', 'all', None, _('show status of all files')), |
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
3071 |
('m', 'modified', None, _('show only modified files')), |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3072 |
('a', 'added', None, _('show only added files')), |
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3073 |
('r', 'removed', None, _('show only removed files')), |
1619
1ba0d7041ac4
Distinguish removed and deleted files. Tests are not fixed yet.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1618
diff
changeset
|
3074 |
('d', 'deleted', None, _('show only deleted (but tracked) files')), |
2661
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2639
diff
changeset
|
3075 |
('c', 'clean', None, _('show only files without changes')), |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3076 |
('u', 'unknown', None, _('show only unknown (not tracked) files')), |
2022
a59da8cc35e4
New option -i/--ignored for 'hg status' to show ignored files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2020
diff
changeset
|
3077 |
('i', 'ignored', None, _('show ignored files')), |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3078 |
('n', 'no-status', None, _('hide status prefix')), |
2639
001703ec311d
Add an option '-C|--copies' to hg status to show the source of copied files.
Brendan Cully <brendan@kublai.com>
parents:
2630
diff
changeset
|
3079 |
('C', 'copies', None, _('show source of copied files')), |
1602
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
3080 |
('0', 'print0', None, |
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
3081 |
_('end filenames with NUL, for use with xargs')), |
3188
725e3d3145d8
factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3187
diff
changeset
|
3082 |
] + walkopts, |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3083 |
_('hg status [OPTION]... [FILE]...')), |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
3084 |
"tag": |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
3085 |
(tag, |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3086 |
[('l', 'local', None, _('make the tag local')), |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3087 |
('m', 'message', '', _('message for tag commit log entry')), |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3088 |
('d', 'date', '', _('record datecode as commit date')), |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3089 |
('u', 'user', '', _('record user as commiter')), |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3090 |
('r', 'rev', '', _('revision to tag'))], |
1812
a81f99dfaa2a
fix the synopsis of some commands, mark rawcommit as deprecated in short help
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1811
diff
changeset
|
3091 |
_('hg tag [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME')), |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3092 |
"tags": (tags, [], _('hg tags')), |
1762
8eaa8e06a364
Add option -b/--branch to hg tip (as done for hg parents).
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1761
diff
changeset
|
3093 |
"tip": |
8eaa8e06a364
Add option -b/--branch to hg tip (as done for hg parents).
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1761
diff
changeset
|
3094 |
(tip, |
1763
fa34a74efc40
Make option --branch vs. --branches more consistent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1762
diff
changeset
|
3095 |
[('b', 'branches', None, _('show branches')), |
1913
74cf2b2f43d4
fix some things people wanted to be cleaner.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1910
diff
changeset
|
3096 |
('', 'style', '', _('display using template map file')), |
1907
7718885070b1
let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1800
diff
changeset
|
3097 |
('p', 'patch', None, _('show patch')), |
1913
74cf2b2f43d4
fix some things people wanted to be cleaner.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1910
diff
changeset
|
3098 |
('', 'template', '', _('display with template'))], |
1811
6cb548cffdf5
resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1804
diff
changeset
|
3099 |
_('hg tip [-b] [-p]')), |
1218
cde6818e082a
Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents:
1215
diff
changeset
|
3100 |
"unbundle": |
cde6818e082a
Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents:
1215
diff
changeset
|
3101 |
(unbundle, |
1601
a1b25fb2e764
Error handling for unbundle, fix option line wrapping
Matt Mackall <mpm@selenic.com>
parents:
1600
diff
changeset
|
3102 |
[('u', 'update', None, |
3198
a32f65549b9e
Documentation clarification for --update option to pull and unbundle
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3197
diff
changeset
|
3103 |
_('update to new tip if changesets were unbundled'))], |
1600
728fd9584993
add --update support to 'hg unbundle'
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1596
diff
changeset
|
3104 |
_('hg unbundle [-u] FILE')), |
2241
abd70a92e06f
hide deprecated undo command by making it an alias for debugundo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2238
diff
changeset
|
3105 |
"debugundo|undo": (undo, [], _('hg undo')), |
593 | 3106 |
"^update|up|checkout|co": |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
3107 |
(update, |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
3108 |
[('b', 'branch', '', _('checkout the head of a specific branch')), |
2283
e506c14382fd
deprecate 'update -m'. use 'merge' instead.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2272
diff
changeset
|
3109 |
('m', 'merge', None, _('allow merging of branches (DEPRECATED)')), |
1581
db10b7114de0
abort when merging two heads and repository has local changes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1571
diff
changeset
|
3110 |
('C', 'clean', None, _('overwrite locally modified files')), |
2044
b343e7d454b4
Don't allow --style and --template for hg update and hg merge.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2043
diff
changeset
|
3111 |
('f', 'force', None, _('force a merge with outstanding changes'))], |
1581
db10b7114de0
abort when merging two heads and repository has local changes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1571
diff
changeset
|
3112 |
_('hg update [-b TAG] [-m] [-C] [-f] [REV]')), |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3113 |
"verify": (verify, [], _('hg verify')), |
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3114 |
"version": (show_version, [], _('hg version')), |
1046
772507daaa17
Sort global options by topic: directories, ui, timing, other
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1044
diff
changeset
|
3115 |
} |
209 | 3116 |
|
1887
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
3117 |
norepo = ("clone init version help debugancestor debugcomplete debugdata" |
1858
9fab6e903bae
Make hg paths and hg debugconfig work with -R/--repository option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1857
diff
changeset
|
3118 |
" debugindex debugindexdot") |
3268
bb057b6ce3cf
Un-debugify debugconfig to showconfig. (issue 317)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3250
diff
changeset
|
3119 |
optionalrepo = ("paths serve showconfig") |
209 | 3120 |
|
2988
63c3a1921a67
Add ui.strict config item.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2983
diff
changeset
|
3121 |
def findpossible(ui, cmd): |
1887
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
3122 |
""" |
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
3123 |
Return cmd -> (aliases, command table entry) |
2049
f70952384ae7
Make completion for debugindex<tab><tab> show debugindexdot, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2045
diff
changeset
|
3124 |
for each matching command. |
f70952384ae7
Make completion for debugindex<tab><tab> show debugindexdot, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2045
diff
changeset
|
3125 |
Return debug commands (or their aliases) only if no normal command matches. |
1887
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
3126 |
""" |
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
3127 |
choice = {} |
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
3128 |
debugchoice = {} |
212
48398a5353e3
commands: better argument processing, per-command help
mpm@selenic.com
parents:
211
diff
changeset
|
3129 |
for e in table.keys(): |
1506
11c8b81f95fe
if unambigious command name are passed, use them
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1505
diff
changeset
|
3130 |
aliases = e.lstrip("^").split("|") |
2049
f70952384ae7
Make completion for debugindex<tab><tab> show debugindexdot, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2045
diff
changeset
|
3131 |
found = None |
1506
11c8b81f95fe
if unambigious command name are passed, use them
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1505
diff
changeset
|
3132 |
if cmd in aliases: |
2049
f70952384ae7
Make completion for debugindex<tab><tab> show debugindexdot, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2045
diff
changeset
|
3133 |
found = cmd |
2988
63c3a1921a67
Add ui.strict config item.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2983
diff
changeset
|
3134 |
elif not ui.config("ui", "strict"): |
2049
f70952384ae7
Make completion for debugindex<tab><tab> show debugindexdot, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2045
diff
changeset
|
3135 |
for a in aliases: |
f70952384ae7
Make completion for debugindex<tab><tab> show debugindexdot, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2045
diff
changeset
|
3136 |
if a.startswith(cmd): |
f70952384ae7
Make completion for debugindex<tab><tab> show debugindexdot, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2045
diff
changeset
|
3137 |
found = a |
f70952384ae7
Make completion for debugindex<tab><tab> show debugindexdot, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2045
diff
changeset
|
3138 |
break |
f70952384ae7
Make completion for debugindex<tab><tab> show debugindexdot, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2045
diff
changeset
|
3139 |
if found is not None: |
f70952384ae7
Make completion for debugindex<tab><tab> show debugindexdot, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2045
diff
changeset
|
3140 |
if aliases[0].startswith("debug"): |
f70952384ae7
Make completion for debugindex<tab><tab> show debugindexdot, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2045
diff
changeset
|
3141 |
debugchoice[found] = (aliases, table[e]) |
f70952384ae7
Make completion for debugindex<tab><tab> show debugindexdot, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2045
diff
changeset
|
3142 |
else: |
f70952384ae7
Make completion for debugindex<tab><tab> show debugindexdot, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2045
diff
changeset
|
3143 |
choice[found] = (aliases, table[e]) |
1739
57de7e1a81d2
AmbiguousCommand is raised too soon.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1736
diff
changeset
|
3144 |
|
1850
05f6c0d1bad8
Hide debug commands in ambiguous command list, unless no normal command matches.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1849
diff
changeset
|
3145 |
if not choice and debugchoice: |
05f6c0d1bad8
Hide debug commands in ambiguous command list, unless no normal command matches.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1849
diff
changeset
|
3146 |
choice = debugchoice |
05f6c0d1bad8
Hide debug commands in ambiguous command list, unless no normal command matches.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1849
diff
changeset
|
3147 |
|
1887
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
3148 |
return choice |
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
3149 |
|
2988
63c3a1921a67
Add ui.strict config item.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2983
diff
changeset
|
3150 |
def findcmd(ui, cmd): |
1887
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
3151 |
"""Return (aliases, command table entry) for command string.""" |
2988
63c3a1921a67
Add ui.strict config item.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2983
diff
changeset
|
3152 |
choice = findpossible(ui, cmd) |
1887
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
3153 |
|
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
3154 |
if choice.has_key(cmd): |
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
3155 |
return choice[cmd] |
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
3156 |
|
1848
bb70ffebe77b
show choices on ambiguous commands
TK Soh <teekaysoh@yahoo.com>
parents:
1840
diff
changeset
|
3157 |
if len(choice) > 1: |
1887
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
3158 |
clist = choice.keys() |
1849
360d0f8d9d6f
Show ambiguous aliases, if they are not simple abbreviations. Sort output.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1848
diff
changeset
|
3159 |
clist.sort() |
1848
bb70ffebe77b
show choices on ambiguous commands
TK Soh <teekaysoh@yahoo.com>
parents:
1840
diff
changeset
|
3160 |
raise AmbiguousCommand(cmd, clist) |
1739
57de7e1a81d2
AmbiguousCommand is raised too soon.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1736
diff
changeset
|
3161 |
|
1517
b582dbc16165
Canonicalize command when using aliases or prefix matching.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1507
diff
changeset
|
3162 |
if choice: |
1887
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1875
diff
changeset
|
3163 |
return choice.values()[0] |
212
48398a5353e3
commands: better argument processing, per-command help
mpm@selenic.com
parents:
211
diff
changeset
|
3164 |
|
48398a5353e3
commands: better argument processing, per-command help
mpm@selenic.com
parents:
211
diff
changeset
|
3165 |
raise UnknownCommand(cmd) |
48398a5353e3
commands: better argument processing, per-command help
mpm@selenic.com
parents:
211
diff
changeset
|
3166 |
|
214 | 3167 |
def catchterm(*args): |
2153
635653cd73ab
move SignalInterrupt class into util module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2140
diff
changeset
|
3168 |
raise util.SignalInterrupt |
214 | 3169 |
|
249 | 3170 |
def run(): |
3171 |
sys.exit(dispatch(sys.argv[1:])) |
|
3172 |
||
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
3173 |
class ParseError(Exception): |
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
3174 |
"""Exception raised on errors in parsing the command line.""" |
592 | 3175 |
|
1453
6fbb13b7a59f
get command defaults from hgrc
TK Soh <teekaysoh@yahoo.com>
parents:
1447
diff
changeset
|
3176 |
def parse(ui, args): |
209 | 3177 |
options = {} |
596 | 3178 |
cmdoptions = {} |
209 | 3179 |
|
592 | 3180 |
try: |
596 | 3181 |
args = fancyopts.fancyopts(args, globalopts, options) |
592 | 3182 |
except fancyopts.getopt.GetoptError, inst: |
618
4051b78c53c7
Handle unrecognised options correctly.
Bryan O'Sullivan <bos@serpentine.com>
parents:
617
diff
changeset
|
3183 |
raise ParseError(None, inst) |
209 | 3184 |
|
1047
a0538ea1ac50
Moved special handling of --version and no hg command from parse to dispatch.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1046
diff
changeset
|
3185 |
if args: |
a0538ea1ac50
Moved special handling of --version and no hg command from parse to dispatch.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1046
diff
changeset
|
3186 |
cmd, args = args[0], args[1:] |
2988
63c3a1921a67
Add ui.strict config item.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2983
diff
changeset
|
3187 |
aliases, i = findcmd(ui, cmd) |
1567
b4956bbbadc9
make command defaults works for aliases
TK Soh <teekaysoh@yahoo.com>
parents:
1565
diff
changeset
|
3188 |
cmd = aliases[0] |
1453
6fbb13b7a59f
get command defaults from hgrc
TK Soh <teekaysoh@yahoo.com>
parents:
1447
diff
changeset
|
3189 |
defaults = ui.config("defaults", cmd) |
6fbb13b7a59f
get command defaults from hgrc
TK Soh <teekaysoh@yahoo.com>
parents:
1447
diff
changeset
|
3190 |
if defaults: |
3068
15526271eafb
allow shell-quoting in command defaults
TK Soh <teekaysoh@yahoo.com>
parents:
3029
diff
changeset
|
3191 |
args = shlex.split(defaults) + args |
1047
a0538ea1ac50
Moved special handling of --version and no hg command from parse to dispatch.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1046
diff
changeset
|
3192 |
c = list(i[1]) |
209 | 3193 |
else: |
1047
a0538ea1ac50
Moved special handling of --version and no hg command from parse to dispatch.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1046
diff
changeset
|
3194 |
cmd = None |
a0538ea1ac50
Moved special handling of --version and no hg command from parse to dispatch.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1046
diff
changeset
|
3195 |
c = [] |
209 | 3196 |
|
592 | 3197 |
# combine global options into local |
596 | 3198 |
for o in globalopts: |
592 | 3199 |
c.append((o[0], o[1], options[o[1]], o[3])) |
214 | 3200 |
|
293 | 3201 |
try: |
596 | 3202 |
args = fancyopts.fancyopts(args, c, cmdoptions) |
293 | 3203 |
except fancyopts.getopt.GetoptError, inst: |
596 | 3204 |
raise ParseError(cmd, inst) |
209 | 3205 |
|
592 | 3206 |
# separate global options back out |
596 | 3207 |
for o in globalopts: |
592 | 3208 |
n = o[1] |
3209 |
options[n] = cmdoptions[n] |
|
3210 |
del cmdoptions[n] |
|
3211 |
||
1047
a0538ea1ac50
Moved special handling of --version and no hg command from parse to dispatch.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1046
diff
changeset
|
3212 |
return (cmd, cmd and i[0] or None, args, options, cmdoptions) |
596 | 3213 |
|
2553
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
3214 |
external = {} |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
3215 |
|
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
3216 |
def findext(name): |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
3217 |
'''return module with given extension name''' |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
3218 |
try: |
2573
b13a98bd078e
fix problems with external module handling. found by benoit boissinot.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2571
diff
changeset
|
3219 |
return sys.modules[external[name]] |
2553
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
3220 |
except KeyError: |
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
3221 |
for k, v in external.iteritems(): |
2755
6c2c10cedf7a
Check for parent/mod as well as parent.mod in findext.
Brendan Cully <brendan@kublai.com>
parents:
2743
diff
changeset
|
3222 |
if k.endswith('.' + name) or k.endswith('/' + name) or v == name: |
2573
b13a98bd078e
fix problems with external module handling. found by benoit boissinot.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2571
diff
changeset
|
3223 |
return sys.modules[v] |
2553
5b426676f616
help: make "hg help EXTENSION" work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2549
diff
changeset
|
3224 |
raise KeyError(name) |
2600
c4325f0a9b91
clean up trailing white space.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2598
diff
changeset
|
3225 |
|
2944
2efa9b8aed30
load extensions from every hgrc.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2943
diff
changeset
|
3226 |
def load_extensions(ui): |
2efa9b8aed30
load extensions from every hgrc.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2943
diff
changeset
|
3227 |
added = [] |
2efa9b8aed30
load extensions from every hgrc.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2943
diff
changeset
|
3228 |
for ext_name, load_from_name in ui.extensions(): |
2efa9b8aed30
load extensions from every hgrc.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2943
diff
changeset
|
3229 |
if ext_name in external: |
2efa9b8aed30
load extensions from every hgrc.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2943
diff
changeset
|
3230 |
continue |
2057
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3231 |
try: |
2573
b13a98bd078e
fix problems with external module handling. found by benoit boissinot.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2571
diff
changeset
|
3232 |
if load_from_name: |
2405
4593d09e534d
pick a non-conflicting module name when loading an extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2400
diff
changeset
|
3233 |
# the module will be loaded in sys.modules |
4593d09e534d
pick a non-conflicting module name when loading an extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2400
diff
changeset
|
3234 |
# choose an unique name so that it doesn't |
4593d09e534d
pick a non-conflicting module name when loading an extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2400
diff
changeset
|
3235 |
# conflicts with other modules |
2573
b13a98bd078e
fix problems with external module handling. found by benoit boissinot.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2571
diff
changeset
|
3236 |
module_name = "hgext_%s" % ext_name.replace('.', '_') |
b13a98bd078e
fix problems with external module handling. found by benoit boissinot.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2571
diff
changeset
|
3237 |
mod = imp.load_source(module_name, load_from_name) |
2057
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3238 |
else: |
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3239 |
def importh(name): |
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3240 |
mod = __import__(name) |
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3241 |
components = name.split('.') |
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3242 |
for comp in components[1:]: |
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3243 |
mod = getattr(mod, comp) |
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3244 |
return mod |
1889
468730910353
Try to import extensions from the hgext module first.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1887
diff
changeset
|
3245 |
try: |
2573
b13a98bd078e
fix problems with external module handling. found by benoit boissinot.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2571
diff
changeset
|
3246 |
mod = importh("hgext.%s" % ext_name) |
1889
468730910353
Try to import extensions from the hgext module first.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1887
diff
changeset
|
3247 |
except ImportError: |
2573
b13a98bd078e
fix problems with external module handling. found by benoit boissinot.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2571
diff
changeset
|
3248 |
mod = importh(ext_name) |
b13a98bd078e
fix problems with external module handling. found by benoit boissinot.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2571
diff
changeset
|
3249 |
external[ext_name] = mod.__name__ |
2944
2efa9b8aed30
load extensions from every hgrc.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2943
diff
changeset
|
3250 |
added.append((mod, ext_name)) |
2428
42b8a1ff46cf
honor signals during load of extensions.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2422
diff
changeset
|
3251 |
except (util.SignalInterrupt, KeyboardInterrupt): |
42b8a1ff46cf
honor signals during load of extensions.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2422
diff
changeset
|
3252 |
raise |
2057
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3253 |
except Exception, inst: |
2943
8e59010158ce
refactor extension loading.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2854
diff
changeset
|
3254 |
ui.warn(_("*** failed to import extension %s: %s\n") % |
8e59010158ce
refactor extension loading.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2854
diff
changeset
|
3255 |
(ext_name, inst)) |
8e59010158ce
refactor extension loading.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2854
diff
changeset
|
3256 |
if ui.print_exc(): |
2057
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3257 |
return 1 |
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3258 |
|
2944
2efa9b8aed30
load extensions from every hgrc.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2943
diff
changeset
|
3259 |
for mod, name in added: |
2573
b13a98bd078e
fix problems with external module handling. found by benoit boissinot.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2571
diff
changeset
|
3260 |
uisetup = getattr(mod, 'uisetup', None) |
2330
b30aa02c85e7
add 'uisetup' function to extension module protocol.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2309
diff
changeset
|
3261 |
if uisetup: |
2944
2efa9b8aed30
load extensions from every hgrc.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2943
diff
changeset
|
3262 |
uisetup(ui) |
2573
b13a98bd078e
fix problems with external module handling. found by benoit boissinot.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2571
diff
changeset
|
3263 |
cmdtable = getattr(mod, 'cmdtable', {}) |
1295
abcdf14449ea
Make contract with extensions optional.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1285
diff
changeset
|
3264 |
for t in cmdtable: |
1071 | 3265 |
if t in table: |
2943
8e59010158ce
refactor extension loading.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2854
diff
changeset
|
3266 |
ui.warn(_("module %s overrides %s\n") % (name, t)) |
1295
abcdf14449ea
Make contract with extensions optional.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1285
diff
changeset
|
3267 |
table.update(cmdtable) |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3204
diff
changeset
|
3268 |
|
2943
8e59010158ce
refactor extension loading.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2854
diff
changeset
|
3269 |
def dispatch(args): |
8e59010158ce
refactor extension loading.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2854
diff
changeset
|
3270 |
for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': |
8e59010158ce
refactor extension loading.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2854
diff
changeset
|
3271 |
num = getattr(signal, name, None) |
8e59010158ce
refactor extension loading.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2854
diff
changeset
|
3272 |
if num: signal.signal(num, catchterm) |
8e59010158ce
refactor extension loading.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2854
diff
changeset
|
3273 |
|
8e59010158ce
refactor extension loading.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2854
diff
changeset
|
3274 |
try: |
3014
01454af644b8
load extensions only after the ui object has been completely initialized
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2991
diff
changeset
|
3275 |
u = ui.ui(traceback='--traceback' in sys.argv[1:]) |
2943
8e59010158ce
refactor extension loading.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2854
diff
changeset
|
3276 |
except util.Abort, inst: |
8e59010158ce
refactor extension loading.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2854
diff
changeset
|
3277 |
sys.stderr.write(_("abort: %s\n") % inst) |
8e59010158ce
refactor extension loading.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2854
diff
changeset
|
3278 |
return -1 |
8e59010158ce
refactor extension loading.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2854
diff
changeset
|
3279 |
|
3014
01454af644b8
load extensions only after the ui object has been completely initialized
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2991
diff
changeset
|
3280 |
load_extensions(u) |
01454af644b8
load extensions only after the ui object has been completely initialized
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2991
diff
changeset
|
3281 |
u.addreadhook(load_extensions) |
01454af644b8
load extensions only after the ui object has been completely initialized
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2991
diff
changeset
|
3282 |
|
596 | 3283 |
try: |
1453
6fbb13b7a59f
get command defaults from hgrc
TK Soh <teekaysoh@yahoo.com>
parents:
1447
diff
changeset
|
3284 |
cmd, func, args, options, cmdoptions = parse(u, args) |
1875
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3285 |
if options["time"]: |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3286 |
def get_times(): |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3287 |
t = os.times() |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3288 |
if t[4] == 0.0: # Windows leaves this as zero, so use time.clock() |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3289 |
t = (t[0], t[1], t[2], t[3], time.clock()) |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3290 |
return t |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3291 |
s = get_times() |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3292 |
def print_time(): |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3293 |
t = get_times() |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3294 |
u.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") % |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3295 |
(t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3])) |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3296 |
atexit.register(print_time) |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3297 |
|
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3298 |
u.updateopts(options["verbose"], options["debug"], options["quiet"], |
2293
3dc6f2501dbc
add --config global option. allows to set hgrc option on command line.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2287
diff
changeset
|
3299 |
not options["noninteractive"], options["traceback"], |
3dc6f2501dbc
add --config global option. allows to set hgrc option on command line.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2287
diff
changeset
|
3300 |
options["config"]) |
1875
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3301 |
|
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3302 |
# enter the debugger before command execution |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3303 |
if options['debugger']: |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3304 |
pdb.set_trace() |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3305 |
|
527 | 3306 |
try: |
1859
39c46510ed25
Moved --cwd handling in front of -R handling again. Shorter code for initial -R.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1858
diff
changeset
|
3307 |
if options['cwd']: |
39c46510ed25
Moved --cwd handling in front of -R handling again. Shorter code for initial -R.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1858
diff
changeset
|
3308 |
try: |
39c46510ed25
Moved --cwd handling in front of -R handling again. Shorter code for initial -R.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1858
diff
changeset
|
3309 |
os.chdir(options['cwd']) |
39c46510ed25
Moved --cwd handling in front of -R handling again. Shorter code for initial -R.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1858
diff
changeset
|
3310 |
except OSError, inst: |
39c46510ed25
Moved --cwd handling in front of -R handling again. Shorter code for initial -R.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1858
diff
changeset
|
3311 |
raise util.Abort('%s: %s' % |
39c46510ed25
Moved --cwd handling in front of -R handling again. Shorter code for initial -R.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1858
diff
changeset
|
3312 |
(options['cwd'], inst.strerror)) |
39c46510ed25
Moved --cwd handling in front of -R handling again. Shorter code for initial -R.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1858
diff
changeset
|
3313 |
|
1894
4c53aaf2d153
Allow symbolic path names in global -R/--repository parameter.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1893
diff
changeset
|
3314 |
path = u.expandpath(options["repository"]) or "" |
1859
39c46510ed25
Moved --cwd handling in front of -R handling again. Shorter code for initial -R.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1858
diff
changeset
|
3315 |
repo = path and hg.repository(u, path=path) or None |
3278
23682d3e4111
disallow commands on non local repository
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3268
diff
changeset
|
3316 |
if repo and not repo.local(): |
23682d3e4111
disallow commands on non local repository
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3268
diff
changeset
|
3317 |
raise util.Abort(_("repository '%s' is not local") % path) |
1857
848152a2e67f
Always try to open the repository if -R/--repository is specified.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1851
diff
changeset
|
3318 |
|
1048
7fbb440b2e63
Added options -h/--help.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1047
diff
changeset
|
3319 |
if options['help']: |
2057
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3320 |
return help_(u, cmd, options['version']) |
1048
7fbb440b2e63
Added options -h/--help.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1047
diff
changeset
|
3321 |
elif options['version']: |
2057
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3322 |
return show_version(u) |
1047
a0538ea1ac50
Moved special handling of --version and no hg command from parse to dispatch.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1046
diff
changeset
|
3323 |
elif not cmd: |
2057
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3324 |
return help_(u, 'shortlist') |
1047
a0538ea1ac50
Moved special handling of --version and no hg command from parse to dispatch.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1046
diff
changeset
|
3325 |
|
527 | 3326 |
if cmd not in norepo.split(): |
1858
9fab6e903bae
Make hg paths and hg debugconfig work with -R/--repository option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1857
diff
changeset
|
3327 |
try: |
9fab6e903bae
Make hg paths and hg debugconfig work with -R/--repository option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1857
diff
changeset
|
3328 |
if not repo: |
9fab6e903bae
Make hg paths and hg debugconfig work with -R/--repository option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1857
diff
changeset
|
3329 |
repo = hg.repository(u, path=path) |
9fab6e903bae
Make hg paths and hg debugconfig work with -R/--repository option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1857
diff
changeset
|
3330 |
u = repo.ui |
2573
b13a98bd078e
fix problems with external module handling. found by benoit boissinot.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2571
diff
changeset
|
3331 |
for name in external.itervalues(): |
b13a98bd078e
fix problems with external module handling. found by benoit boissinot.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2571
diff
changeset
|
3332 |
mod = sys.modules[name] |
b13a98bd078e
fix problems with external module handling. found by benoit boissinot.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2571
diff
changeset
|
3333 |
if hasattr(mod, 'reposetup'): |
b13a98bd078e
fix problems with external module handling. found by benoit boissinot.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2571
diff
changeset
|
3334 |
mod.reposetup(u, repo) |
2847
2ff57e3113a4
call reposetup functions of extension modules whenever repo created
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2812
diff
changeset
|
3335 |
hg.repo_setup_hooks.append(mod.reposetup) |
1858
9fab6e903bae
Make hg paths and hg debugconfig work with -R/--repository option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1857
diff
changeset
|
3336 |
except hg.RepoError: |
9fab6e903bae
Make hg paths and hg debugconfig work with -R/--repository option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1857
diff
changeset
|
3337 |
if cmd not in optionalrepo.split(): |
9fab6e903bae
Make hg paths and hg debugconfig work with -R/--repository option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1857
diff
changeset
|
3338 |
raise |
596 | 3339 |
d = lambda: func(u, repo, *args, **cmdoptions) |
527 | 3340 |
else: |
596 | 3341 |
d = lambda: func(u, *args, **cmdoptions) |
209 | 3342 |
|
2716
4af4e1870fa0
reupdate the options after loading the repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2673
diff
changeset
|
3343 |
# reupdate the options, repo/.hg/hgrc may have changed them |
4af4e1870fa0
reupdate the options after loading the repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2673
diff
changeset
|
3344 |
u.updateopts(options["verbose"], options["debug"], options["quiet"], |
4af4e1870fa0
reupdate the options after loading the repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2673
diff
changeset
|
3345 |
not options["noninteractive"], options["traceback"], |
4af4e1870fa0
reupdate the options after loading the repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2673
diff
changeset
|
3346 |
options["config"]) |
4af4e1870fa0
reupdate the options after loading the repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2673
diff
changeset
|
3347 |
|
1837
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3348 |
try: |
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3349 |
if options['profile']: |
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3350 |
import hotshot, hotshot.stats |
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3351 |
prof = hotshot.Profile("hg.prof") |
1832
7a58bf789965
generate profile even when exception raised.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1823
diff
changeset
|
3352 |
try: |
7a58bf789965
generate profile even when exception raised.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1823
diff
changeset
|
3353 |
try: |
1837
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3354 |
return prof.runcall(d) |
1832
7a58bf789965
generate profile even when exception raised.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1823
diff
changeset
|
3355 |
except: |
1837
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3356 |
try: |
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3357 |
u.warn(_('exception raised - generating ' |
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3358 |
'profile anyway\n')) |
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3359 |
except: |
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3360 |
pass |
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3361 |
raise |
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3362 |
finally: |
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3363 |
prof.close() |
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3364 |
stats = hotshot.stats.load("hg.prof") |
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3365 |
stats.strip_dirs() |
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3366 |
stats.sort_stats('time', 'calls') |
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3367 |
stats.print_stats(40) |
2422
6aa75e77cafe
add --lsprof option. 3x faster than --profile, more useful output.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2417
diff
changeset
|
3368 |
elif options['lsprof']: |
6aa75e77cafe
add --lsprof option. 3x faster than --profile, more useful output.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2417
diff
changeset
|
3369 |
try: |
6aa75e77cafe
add --lsprof option. 3x faster than --profile, more useful output.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2417
diff
changeset
|
3370 |
from mercurial import lsprof |
6aa75e77cafe
add --lsprof option. 3x faster than --profile, more useful output.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2417
diff
changeset
|
3371 |
except ImportError: |
6aa75e77cafe
add --lsprof option. 3x faster than --profile, more useful output.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2417
diff
changeset
|
3372 |
raise util.Abort(_( |
6aa75e77cafe
add --lsprof option. 3x faster than --profile, more useful output.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2417
diff
changeset
|
3373 |
'lsprof not available - install from ' |
6aa75e77cafe
add --lsprof option. 3x faster than --profile, more useful output.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2417
diff
changeset
|
3374 |
'http://codespeak.net/svn/user/arigo/hack/misc/lsprof/')) |
6aa75e77cafe
add --lsprof option. 3x faster than --profile, more useful output.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2417
diff
changeset
|
3375 |
p = lsprof.Profiler() |
6aa75e77cafe
add --lsprof option. 3x faster than --profile, more useful output.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2417
diff
changeset
|
3376 |
p.enable(subcalls=True) |
6aa75e77cafe
add --lsprof option. 3x faster than --profile, more useful output.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2417
diff
changeset
|
3377 |
try: |
6aa75e77cafe
add --lsprof option. 3x faster than --profile, more useful output.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2417
diff
changeset
|
3378 |
return d() |
6aa75e77cafe
add --lsprof option. 3x faster than --profile, more useful output.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2417
diff
changeset
|
3379 |
finally: |
6aa75e77cafe
add --lsprof option. 3x faster than --profile, more useful output.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2417
diff
changeset
|
3380 |
p.disable() |
6aa75e77cafe
add --lsprof option. 3x faster than --profile, more useful output.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2417
diff
changeset
|
3381 |
stats = lsprof.Stats(p.getstats()) |
6aa75e77cafe
add --lsprof option. 3x faster than --profile, more useful output.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2417
diff
changeset
|
3382 |
stats.sort() |
6aa75e77cafe
add --lsprof option. 3x faster than --profile, more useful output.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2417
diff
changeset
|
3383 |
stats.pprint(top=10, file=sys.stderr, climit=5) |
1837
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3384 |
else: |
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3385 |
return d() |
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3386 |
finally: |
6f67a4c93493
make ui flush output. this makes error happen if printing to /dev/full.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1835
diff
changeset
|
3387 |
u.flush() |
527 | 3388 |
except: |
1225 | 3389 |
# enter the debugger when we hit an exception |
3390 |
if options['debugger']: |
|
3391 |
pdb.post_mortem(sys.exc_info()[2]) |
|
2335
f0680b2d1d64
add ui.print_exc(), make all traceback printing central.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2331
diff
changeset
|
3392 |
u.print_exc() |
527 | 3393 |
raise |
1875
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3394 |
except ParseError, inst: |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3395 |
if inst.args[0]: |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3396 |
u.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1])) |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3397 |
help_(u, inst.args[0]) |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3398 |
else: |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3399 |
u.warn(_("hg: %s\n") % inst.args[1]) |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3400 |
help_(u, 'shortlist') |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3401 |
except AmbiguousCommand, inst: |
1920 | 3402 |
u.warn(_("hg: command '%s' is ambiguous:\n %s\n") % |
1875
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3403 |
(inst.args[0], " ".join(inst.args[1]))) |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3404 |
except UnknownCommand, inst: |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3405 |
u.warn(_("hg: unknown command '%s'\n") % inst.args[0]) |
2f4a0734c100
Catch other exceptions (e.g. util.Abort) in parse(), too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1869
diff
changeset
|
3406 |
help_(u, 'shortlist') |
499 | 3407 |
except hg.RepoError, inst: |
2134
ef81e34ad674
write to stderr with a single write call.
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2127
diff
changeset
|
3408 |
u.warn(_("abort: %s!\n") % inst) |
2016
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
3409 |
except lock.LockHeld, inst: |
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
3410 |
if inst.errno == errno.ETIMEDOUT: |
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
3411 |
reason = _('timed out waiting for lock held by %s') % inst.locker |
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
3412 |
else: |
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
3413 |
reason = _('lock held by %s') % inst.locker |
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
3414 |
u.warn(_("abort: %s: %s\n") % (inst.desc or inst.filename, reason)) |
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
3415 |
except lock.LockUnavailable, inst: |
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
3416 |
u.warn(_("abort: could not lock %s: %s\n") % |
ff5c9a92f556
fix backtrace printed when cannot get lock.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
3417 |
(inst.desc or inst.filename, inst.strerror)) |
1214 | 3418 |
except revlog.RevlogError, inst: |
3072
bc3fe3b5b785
Never apply string formatting to generated errors with util.Abort.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3071
diff
changeset
|
3419 |
u.warn(_("abort: %s!\n") % inst) |
2153
635653cd73ab
move SignalInterrupt class into util module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2140
diff
changeset
|
3420 |
except util.SignalInterrupt: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3421 |
u.warn(_("killed!\n")) |
209 | 3422 |
except KeyboardInterrupt: |
832
b65773f7db41
Handle broken pipe on pressing Ctrl-C with e.g. 'hg log|grep something'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
818
diff
changeset
|
3423 |
try: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3424 |
u.warn(_("interrupted!\n")) |
832
b65773f7db41
Handle broken pipe on pressing Ctrl-C with e.g. 'hg log|grep something'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
818
diff
changeset
|
3425 |
except IOError, inst: |
b65773f7db41
Handle broken pipe on pressing Ctrl-C with e.g. 'hg log|grep something'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
818
diff
changeset
|
3426 |
if inst.errno == errno.EPIPE: |
b65773f7db41
Handle broken pipe on pressing Ctrl-C with e.g. 'hg log|grep something'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
818
diff
changeset
|
3427 |
if u.debugflag: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3428 |
u.warn(_("\nbroken pipe\n")) |
832
b65773f7db41
Handle broken pipe on pressing Ctrl-C with e.g. 'hg log|grep something'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
818
diff
changeset
|
3429 |
else: |
b65773f7db41
Handle broken pipe on pressing Ctrl-C with e.g. 'hg log|grep something'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
818
diff
changeset
|
3430 |
raise |
250 | 3431 |
except IOError, inst: |
395 | 3432 |
if hasattr(inst, "code"): |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3433 |
u.warn(_("abort: %s\n") % inst) |
395 | 3434 |
elif hasattr(inst, "reason"): |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3435 |
u.warn(_("abort: error: %s\n") % inst.reason[1]) |
395 | 3436 |
elif hasattr(inst, "args") and inst[0] == errno.EPIPE: |
1065
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
3437 |
if u.debugflag: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3438 |
u.warn(_("broken pipe\n")) |
1350 | 3439 |
elif getattr(inst, "strerror", None): |
1354
8cf364c65425
Made the abort message for IOError nicer when the filename is known.
Eric Hopper <hopper@omnifarious.org>
parents:
1350
diff
changeset
|
3440 |
if getattr(inst, "filename", None): |
3080
e270cbd4aa20
Fixed OSError "No such file or directory: None" and make IOError consistent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3079
diff
changeset
|
3441 |
u.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename)) |
1354
8cf364c65425
Made the abort message for IOError nicer when the filename is known.
Eric Hopper <hopper@omnifarious.org>
parents:
1350
diff
changeset
|
3442 |
else: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3443 |
u.warn(_("abort: %s\n") % inst.strerror) |
250 | 3444 |
else: |
3445 |
raise |
|
549 | 3446 |
except OSError, inst: |
3080
e270cbd4aa20
Fixed OSError "No such file or directory: None" and make IOError consistent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3079
diff
changeset
|
3447 |
if getattr(inst, "filename", None): |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3448 |
u.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename)) |
549 | 3449 |
else: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3450 |
u.warn(_("abort: %s\n") % inst.strerror) |
870
a82eae840447
Teach walk code about absolute paths.
Bryan O'Sullivan <bos@serpentine.com>
parents:
868
diff
changeset
|
3451 |
except util.Abort, inst: |
3072
bc3fe3b5b785
Never apply string formatting to generated errors with util.Abort.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3071
diff
changeset
|
3452 |
u.warn(_("abort: %s\n") % inst) |
212
48398a5353e3
commands: better argument processing, per-command help
mpm@selenic.com
parents:
211
diff
changeset
|
3453 |
except TypeError, inst: |
48398a5353e3
commands: better argument processing, per-command help
mpm@selenic.com
parents:
211
diff
changeset
|
3454 |
# was this an argument error? |
48398a5353e3
commands: better argument processing, per-command help
mpm@selenic.com
parents:
211
diff
changeset
|
3455 |
tb = traceback.extract_tb(sys.exc_info()[2]) |
48398a5353e3
commands: better argument processing, per-command help
mpm@selenic.com
parents:
211
diff
changeset
|
3456 |
if len(tb) > 2: # no |
48398a5353e3
commands: better argument processing, per-command help
mpm@selenic.com
parents:
211
diff
changeset
|
3457 |
raise |
293 | 3458 |
u.debug(inst, "\n") |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3459 |
u.warn(_("%s: invalid arguments\n") % cmd) |
697
cb1be2327220
Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
696
diff
changeset
|
3460 |
help_(u, cmd) |
2057
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3461 |
except SystemExit, inst: |
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3462 |
# Commands shouldn't sys.exit directly, but give a return code. |
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3463 |
# Just in case catch this and and pass exit code to caller. |
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3464 |
return inst.code |
1215
8b4435aae40a
Add reporting instructions to unknown exception backtraces
mpm@selenic.com
parents:
1214
diff
changeset
|
3465 |
except: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
3466 |
u.warn(_("** unknown exception encountered, details follow\n")) |
2625
70d65ca6d893
mention the bts for bug reporting in traceback message
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2617
diff
changeset
|
3467 |
u.warn(_("** report bug details to " |
70d65ca6d893
mention the bts for bug reporting in traceback message
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2617
diff
changeset
|
3468 |
"http://www.selenic.com/mercurial/bts\n")) |
70d65ca6d893
mention the bts for bug reporting in traceback message
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2617
diff
changeset
|
3469 |
u.warn(_("** or mercurial@selenic.com\n")) |
1552
7509fa02437f
Added version information to "report bug" message for unknown exceptions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1551
diff
changeset
|
3470 |
u.warn(_("** Mercurial Distributed SCM (version %s)\n") |
7509fa02437f
Added version information to "report bug" message for unknown exceptions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1551
diff
changeset
|
3471 |
% version.get_version()) |
1215
8b4435aae40a
Add reporting instructions to unknown exception backtraces
mpm@selenic.com
parents:
1214
diff
changeset
|
3472 |
raise |
293 | 3473 |
|
2057
fef2d653beaf
Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2056
diff
changeset
|
3474 |
return -1 |