author | Matt Mackall <mpm@selenic.com> |
Sun, 04 Mar 2012 16:48:04 -0600 | |
changeset 16227 | 7855c522a9cb |
parent 16218 | 81a1a00f5738 |
parent 16219 | 28c5648771d1 |
child 16232 | 877aea86fb73 |
permissions | -rw-r--r-- |
249 | 1 |
# commands.py - command processing for mercurial |
2 |
# |
|
4635
63b9d2deed48
Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4614
diff
changeset
|
3 |
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
249 | 4 |
# |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8210
diff
changeset
|
5 |
# This software may be used and distributed according to the terms of the |
10263 | 6 |
# GNU General Public License version 2 or any later version. |
249 | 7 |
|
13723
e615765fdcc7
wireproto: add known([id]) function
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13720
diff
changeset
|
8 |
from node import hex, bin, nullid, nullrev, short |
8109
496ae1ea4698
switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8088
diff
changeset
|
9 |
from lock import release |
7013
f56e788fa292
i18n: mark help strings for translation
Martin Geisler <mg@daimi.au.dk>
parents:
7012
diff
changeset
|
10 |
from i18n import _, gettext |
14639
e59a7b8f521a
commands: use ui descriptors when reading/writing from stdin/out
Idan Kamara <idankk86@gmail.com>
parents:
14635
diff
changeset
|
11 |
import os, re, difflib, time, tempfile, errno |
13970
d13913355390
move opener from util to scmutil
Adrian Buehlmann <adrian@cadifra.com>
parents:
13965
diff
changeset
|
12 |
import hg, scmutil, util, revlog, extensions, copies, error, bookmarks |
14064
e4bfb9c337f3
remove unused imports and variables
Alexander Solovyov <alexander@solovyov.net>
parents:
14055
diff
changeset
|
13 |
import patch, help, url, encoding, templatekw, discovery |
14647
2e9f379de0ac
serve: add --cmdserver option to communicate with hg over a pipe
Idan Kamara <idankk86@gmail.com>
parents:
14645
diff
changeset
|
14 |
import archival, changegroup, cmdutil, hbisect |
2e9f379de0ac
serve: add --cmdserver option to communicate with hg over a pipe
Idan Kamara <idankk86@gmail.com>
parents:
14645
diff
changeset
|
15 |
import sshserver, hgweb, hgweb.server, commandserver |
15856
6bed6cc6d0d0
commands: partial backout of fbb68b382040
Martin Geisler <mg@aragost.com>
parents:
15855
diff
changeset
|
16 |
import merge as mergemod |
14511
30506b894359
filesets: introduce basic fileset expression parser
Matt Mackall <mpm@selenic.com>
parents:
14509
diff
changeset
|
17 |
import minirst, revset, fileset |
14163
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
18 |
import dagparser, context, simplemerge |
14164
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
19 |
import random, setdiscovery, treediscovery, dagutil |
15853
fbb68b382040
commands: no need to rename merge and phases on import
Martin Geisler <mg@aragost.com>
parents:
15852
diff
changeset
|
20 |
import phases |
2731
ad4155e757da
Kill ui.setconfig_remoteopts
Matt Mackall <mpm@selenic.com>
parents:
2718
diff
changeset
|
21 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
22 |
table = {} |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
23 |
|
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
24 |
command = cmdutil.command(table) |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
25 |
|
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
26 |
# common command options |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
27 |
|
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
28 |
globalopts = [ |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
29 |
('R', 'repository', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
30 |
_('repository root directory or name of overlay bundle file'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
31 |
_('REPO')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
32 |
('', 'cwd', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
33 |
_('change working directory'), _('DIR')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
34 |
('y', 'noninteractive', None, |
14849
d87814992728
commands: improve help for -y/--noninteractive
Martin Geisler <mg@aragost.com>
parents:
14755
diff
changeset
|
35 |
_('do not prompt, automatically pick the first choice for all prompts')), |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
36 |
('q', 'quiet', None, _('suppress output')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
37 |
('v', 'verbose', None, _('enable additional output')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
38 |
('', 'config', [], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
39 |
_('set/override config option (use \'section.name=value\')'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
40 |
_('CONFIG')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
41 |
('', 'debug', None, _('enable debugging output')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
42 |
('', 'debugger', None, _('start debugger')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
43 |
('', 'encoding', encoding.encoding, _('set the charset encoding'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
44 |
_('ENCODE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
45 |
('', 'encodingmode', encoding.encodingmode, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
46 |
_('set the charset encoding mode'), _('MODE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
47 |
('', 'traceback', None, _('always print a traceback on exception')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
48 |
('', 'time', None, _('time how long the command takes')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
49 |
('', 'profile', None, _('print command execution profile')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
50 |
('', 'version', None, _('output version information and exit')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
51 |
('h', 'help', None, _('display help and exit')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
52 |
] |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
53 |
|
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
54 |
dryrunopts = [('n', 'dry-run', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
55 |
_('do not perform actions, just print output'))] |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
56 |
|
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
57 |
remoteopts = [ |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
58 |
('e', 'ssh', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
59 |
_('specify ssh command to use'), _('CMD')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
60 |
('', 'remotecmd', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
61 |
_('specify hg command to run on the remote side'), _('CMD')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
62 |
('', 'insecure', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
63 |
_('do not verify server certificate (ignoring web.cacerts config)')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
64 |
] |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
65 |
|
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
66 |
walkopts = [ |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
67 |
('I', 'include', [], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
68 |
_('include names matching the given patterns'), _('PATTERN')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
69 |
('X', 'exclude', [], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
70 |
_('exclude names matching the given patterns'), _('PATTERN')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
71 |
] |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
72 |
|
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
73 |
commitopts = [ |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
74 |
('m', 'message', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
75 |
_('use text as commit message'), _('TEXT')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
76 |
('l', 'logfile', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
77 |
_('read commit message from file'), _('FILE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
78 |
] |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
79 |
|
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
80 |
commitopts2 = [ |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
81 |
('d', 'date', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
82 |
_('record the specified date as commit date'), _('DATE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
83 |
('u', 'user', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
84 |
_('record the specified user as committer'), _('USER')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
85 |
] |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
86 |
|
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
87 |
templateopts = [ |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
88 |
('', 'style', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
89 |
_('display using template map file'), _('STYLE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
90 |
('', 'template', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
91 |
_('display with template'), _('TEMPLATE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
92 |
] |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
93 |
|
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
94 |
logopts = [ |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
95 |
('p', 'patch', None, _('show patch')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
96 |
('g', 'git', None, _('use git extended diff format')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
97 |
('l', 'limit', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
98 |
_('limit number of changes displayed'), _('NUM')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
99 |
('M', 'no-merges', None, _('do not show merges')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
100 |
('', 'stat', None, _('output diffstat-style summary of changes')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
101 |
] + templateopts |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
102 |
|
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
103 |
diffopts = [ |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
104 |
('a', 'text', None, _('treat all files as text')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
105 |
('g', 'git', None, _('use git extended diff format')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
106 |
('', 'nodates', None, _('omit dates from diff headers')) |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
107 |
] |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
108 |
|
15528
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15513
diff
changeset
|
109 |
diffwsopts = [ |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
110 |
('w', 'ignore-all-space', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
111 |
_('ignore white space when comparing lines')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
112 |
('b', 'ignore-space-change', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
113 |
_('ignore changes in the amount of white space')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
114 |
('B', 'ignore-blank-lines', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
115 |
_('ignore changes whose lines are all blank')), |
15528
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15513
diff
changeset
|
116 |
] |
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15513
diff
changeset
|
117 |
|
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15513
diff
changeset
|
118 |
diffopts2 = [ |
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15513
diff
changeset
|
119 |
('p', 'show-function', None, _('show which function each change is in')), |
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15513
diff
changeset
|
120 |
('', 'reverse', None, _('produce a diff that undoes the changes')), |
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15513
diff
changeset
|
121 |
] + diffwsopts + [ |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
122 |
('U', 'unified', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
123 |
_('number of lines of context to show'), _('NUM')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
124 |
('', 'stat', None, _('output diffstat-style summary of changes')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
125 |
] |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
126 |
|
14852
cac04f2f475b
commands: use mergetoolopts when a command supports --tool
Martin Geisler <mg@aragost.com>
parents:
14840
diff
changeset
|
127 |
mergetoolopts = [ |
cac04f2f475b
commands: use mergetoolopts when a command supports --tool
Martin Geisler <mg@aragost.com>
parents:
14840
diff
changeset
|
128 |
('t', 'tool', '', _('specify merge tool')), |
cac04f2f475b
commands: use mergetoolopts when a command supports --tool
Martin Geisler <mg@aragost.com>
parents:
14840
diff
changeset
|
129 |
] |
cac04f2f475b
commands: use mergetoolopts when a command supports --tool
Martin Geisler <mg@aragost.com>
parents:
14840
diff
changeset
|
130 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
131 |
similarityopts = [ |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
132 |
('s', 'similarity', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
133 |
_('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY')) |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
134 |
] |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
135 |
|
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
136 |
subrepoopts = [ |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
137 |
('S', 'subrepos', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
138 |
_('recurse into subrepositories')) |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
139 |
] |
2731
ad4155e757da
Kill ui.setconfig_remoteopts
Matt Mackall <mpm@selenic.com>
parents:
2718
diff
changeset
|
140 |
|
255 | 141 |
# Commands start here, listed alphabetically |
209 | 142 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
143 |
@command('^add', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
144 |
walkopts + subrepoopts + dryrunopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
145 |
_('[OPTION]... [FILE]...')) |
724
1c0c413cccdd
Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
723
diff
changeset
|
146 |
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
|
147 |
"""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
|
148 |
|
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
149 |
Schedule files to be version controlled and added to the |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
150 |
repository. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
151 |
|
3829
531c116b2028
Add doc notes about revert and hg status vs diff
Matt Mackall <mpm@selenic.com>
parents:
3822
diff
changeset
|
152 |
The files will be added to the repository at the next commit. To |
11193
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11185
diff
changeset
|
153 |
undo an add before that, see :hg:`forget`. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
154 |
|
7807
bd8f44638847
help: miscellaneous language fixes
timeless <timeless@gmail.com>
parents:
7765
diff
changeset
|
155 |
If no names are given, add all files to the repository. |
10446
a565a2445eb5
commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents:
10445
diff
changeset
|
156 |
|
a565a2445eb5
commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents:
10445
diff
changeset
|
157 |
.. container:: verbose |
a565a2445eb5
commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents:
10445
diff
changeset
|
158 |
|
a565a2445eb5
commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents:
10445
diff
changeset
|
159 |
An example showing how new (unknown) files are added |
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
160 |
automatically by :hg:`add`:: |
10446
a565a2445eb5
commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents:
10445
diff
changeset
|
161 |
|
a565a2445eb5
commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents:
10445
diff
changeset
|
162 |
$ ls |
a565a2445eb5
commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents:
10445
diff
changeset
|
163 |
foo.c |
a565a2445eb5
commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents:
10445
diff
changeset
|
164 |
$ hg status |
a565a2445eb5
commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents:
10445
diff
changeset
|
165 |
? foo.c |
a565a2445eb5
commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents:
10445
diff
changeset
|
166 |
$ hg add |
a565a2445eb5
commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents:
10445
diff
changeset
|
167 |
adding foo.c |
a565a2445eb5
commands: add verbose example to help text for add
Martin Geisler <mg@lazybytes.net>
parents:
10445
diff
changeset
|
168 |
$ hg status |
10448
6e5a47398fc5
commands: correct example in add help text
Martin Geisler <mg@lazybytes.net>
parents:
10446
diff
changeset
|
169 |
A foo.c |
11507
35e2d453cf0d
commands: document return values of add and paths commands
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11488
diff
changeset
|
170 |
|
35e2d453cf0d
commands: document return values of add and paths commands
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11488
diff
changeset
|
171 |
Returns 0 if all files are successfully added. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
172 |
""" |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
173 |
|
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
174 |
m = scmutil.match(repo[None], pats, opts) |
12270
166b9866580a
add: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12269
diff
changeset
|
175 |
rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'), |
15911
c654eac03452
add: fix subrepo recursion for explicit path handling
David M. Carr <david@carrclan.us>
parents:
15906
diff
changeset
|
176 |
opts.get('subrepos'), prefix="", explicitonly=False) |
12269
877236cdd437
add: move main part to cmdutil to make it easier to reuse
Martin Geisler <mg@lazybytes.net>
parents:
12266
diff
changeset
|
177 |
return rejected and 1 or 0 |
213 | 178 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
179 |
@command('addremove', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
180 |
similarityopts + walkopts + dryrunopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
181 |
_('[OPTION]... [FILE]...')) |
766
b444a7e053f1
Get addremove to use new walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
764
diff
changeset
|
182 |
def addremove(ui, repo, *pats, **opts): |
3181
3637d5d17cbc
Documentation fixes for addremove.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3172
diff
changeset
|
183 |
"""add all new files, delete all missing files |
2181
690da72b0b16
deprecate addremove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2179
diff
changeset
|
184 |
|
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
185 |
Add all new files and remove all missing files from the |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
186 |
repository. |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
187 |
|
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
188 |
New files are ignored if they match any of the patterns in |
13344
6367459decf7
doc: Add back quotes around filenames
Javi Merino <cibervicho@gmail.com>
parents:
13343
diff
changeset
|
189 |
``.hgignore``. As with add, these changes take effect at the next |
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
190 |
commit. |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2956
diff
changeset
|
191 |
|
8033
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
192 |
Use the -s/--similarity option to detect renamed files. With a |
9249
16f4cfc69e4f
commands: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9219
diff
changeset
|
193 |
parameter greater than 0, this compares every removed file with |
16f4cfc69e4f
commands: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9219
diff
changeset
|
194 |
every added file and records those similar enough as renames. This |
16f4cfc69e4f
commands: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9219
diff
changeset
|
195 |
option takes a percentage between 0 (disabled) and 100 (files must |
16f4cfc69e4f
commands: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9219
diff
changeset
|
196 |
be identical) as its parameter. Detecting renamed files this way |
11518
8d827f4a23f1
commands: mention "hg status -C" in addremove help
Arnab Bose <hirak99@gmail.com>
parents:
11515
diff
changeset
|
197 |
can be expensive. After using this option, :hg:`status -C` can be |
8d827f4a23f1
commands: mention "hg status -C" in addremove help
Arnab Bose <hirak99@gmail.com>
parents:
11515
diff
changeset
|
198 |
used to check which files were identified as moved or renamed. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
199 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
200 |
Returns 0 if all files are successfully added. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
201 |
""" |
4966
8d982aef0be1
addremove: print meaningful error message if --similar not numeric
Bryan O'Sullivan <bos@serpentine.com>
parents:
4950
diff
changeset
|
202 |
try: |
11551
4484a7b661f2
commands: addremove does similarity 100 by default
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11525
diff
changeset
|
203 |
sim = float(opts.get('similarity') or 100) |
4966
8d982aef0be1
addremove: print meaningful error message if --similar not numeric
Bryan O'Sullivan <bos@serpentine.com>
parents:
4950
diff
changeset
|
204 |
except ValueError: |
8d982aef0be1
addremove: print meaningful error message if --similar not numeric
Bryan O'Sullivan <bos@serpentine.com>
parents:
4950
diff
changeset
|
205 |
raise util.Abort(_('similarity must be a number')) |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2956
diff
changeset
|
206 |
if sim < 0 or sim > 100: |
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2956
diff
changeset
|
207 |
raise util.Abort(_('similarity must be between 0 and 100')) |
14321
003d63bb4fa5
scmutil: drop some aliases in cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14319
diff
changeset
|
208 |
return scmutil.addremove(repo, pats, opts, similarity=sim / 100.0) |
219
8ff4532376a4
hg checkout: refuse to checkout if there are outstanding changes
mpm@selenic.com
parents:
214
diff
changeset
|
209 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
210 |
@command('^annotate|blame', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
211 |
[('r', 'rev', '', _('annotate the specified revision'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
212 |
('', 'follow', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
213 |
_('follow copies/renames and list the filename (DEPRECATED)')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
214 |
('', 'no-follow', None, _("don't follow copies and renames")), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
215 |
('a', 'text', None, _('treat all files as text')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
216 |
('u', 'user', None, _('list the author (long with -v)')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
217 |
('f', 'file', None, _('list the filename')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
218 |
('d', 'date', None, _('list the date (short with -q)')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
219 |
('n', 'number', None, _('list the revision number (default)')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
220 |
('c', 'changeset', None, _('list the changeset')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
221 |
('l', 'line-number', None, _('show line number at the first appearance')) |
15528
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15513
diff
changeset
|
222 |
] + diffwsopts + walkopts, |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
223 |
_('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...')) |
733
1966c553f652
Convert annotate over to walk interface.
Bryan O'Sullivan <bos@serpentine.com>
parents:
732
diff
changeset
|
224 |
def annotate(ui, repo, *pats, **opts): |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
225 |
"""show changeset information by line for each file |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
226 |
|
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
227 |
List changes in files, showing the revision id responsible for |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
228 |
each line |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
229 |
|
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
230 |
This command is useful for discovering when a change was made and |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
231 |
by whom. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
232 |
|
8033
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
233 |
Without the -a/--text option, annotate will avoid processing files |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
234 |
it detects as binary. With -a, annotate will annotate the file |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
235 |
anyway, although the results will probably be neither useful |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
236 |
nor desirable. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
237 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
238 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
239 |
""" |
10579
f142fa3c0a8c
Make annotate --follow an alias for -f/--file to behave like in older versions
Thomas Arendsen Hein <thomas@intevation.de>
parents:
10564
diff
changeset
|
240 |
if opts.get('follow'): |
f142fa3c0a8c
Make annotate --follow an alias for -f/--file to behave like in older versions
Thomas Arendsen Hein <thomas@intevation.de>
parents:
10564
diff
changeset
|
241 |
# --follow is deprecated and now just an alias for -f/--file |
f142fa3c0a8c
Make annotate --follow an alias for -f/--file to behave like in older versions
Thomas Arendsen Hein <thomas@intevation.de>
parents:
10564
diff
changeset
|
242 |
# to mimic the behavior of Mercurial before version 1.5 |
14216
e3da95f84bcd
annotate: use real Booleans instead of 0/1
Martin Geisler <mg@aragost.com>
parents:
14198
diff
changeset
|
243 |
opts['file'] = True |
10579
f142fa3c0a8c
Make annotate --follow an alias for -f/--file to behave like in older versions
Thomas Arendsen Hein <thomas@intevation.de>
parents:
10564
diff
changeset
|
244 |
|
6134
7b937b26adf7
Make annotae/grep print short dates with -q/--quiet.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6133
diff
changeset
|
245 |
datefunc = ui.quiet and util.shortdate or util.datestr |
7b937b26adf7
Make annotae/grep print short dates with -q/--quiet.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6133
diff
changeset
|
246 |
getdate = util.cachefunc(lambda x: datefunc(x[0].date())) |
1522 | 247 |
|
744 | 248 |
if not pats: |
8761
0289f384e1e5
Generally replace "file name" with "filename" in help and comments.
timeless <timeless@gmail.com>
parents:
8760
diff
changeset
|
249 |
raise util.Abort(_('at least one filename or pattern is required')) |
744 | 250 |
|
15631
e5fd140a4e69
annotate: show full changeset hash when invoked with --debug and -c
Ion Savin <comp_@gmx.net>
parents:
15623
diff
changeset
|
251 |
hexfn = ui.debugflag and hex or short |
e5fd140a4e69
annotate: show full changeset hash when invoked with --debug and -c
Ion Savin <comp_@gmx.net>
parents:
15623
diff
changeset
|
252 |
|
14358
bf93e78f2638
annotate: fix alignment of columns in front of line numbers (issue2807)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14331
diff
changeset
|
253 |
opmap = [('user', ' ', lambda x: ui.shortuser(x[0].user())), |
bf93e78f2638
annotate: fix alignment of columns in front of line numbers (issue2807)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14331
diff
changeset
|
254 |
('number', ' ', lambda x: str(x[0].rev())), |
15631
e5fd140a4e69
annotate: show full changeset hash when invoked with --debug and -c
Ion Savin <comp_@gmx.net>
parents:
15623
diff
changeset
|
255 |
('changeset', ' ', lambda x: hexfn(x[0].node())), |
14358
bf93e78f2638
annotate: fix alignment of columns in front of line numbers (issue2807)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14331
diff
changeset
|
256 |
('date', ' ', getdate), |
bf93e78f2638
annotate: fix alignment of columns in front of line numbers (issue2807)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14331
diff
changeset
|
257 |
('file', ' ', lambda x: x[0].path()), |
bf93e78f2638
annotate: fix alignment of columns in front of line numbers (issue2807)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14331
diff
changeset
|
258 |
('line_number', ':', lambda x: str(x[1])), |
4857
2192001e4bb4
Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4849
diff
changeset
|
259 |
] |
2192001e4bb4
Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4849
diff
changeset
|
260 |
|
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10270
diff
changeset
|
261 |
if (not opts.get('user') and not opts.get('changeset') |
10369
98a0421b9e52
commands: annotate follows by default, separate -f/--file option
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10365
diff
changeset
|
262 |
and not opts.get('date') and not opts.get('file')): |
14216
e3da95f84bcd
annotate: use real Booleans instead of 0/1
Martin Geisler <mg@aragost.com>
parents:
14198
diff
changeset
|
263 |
opts['number'] = True |
209 | 264 |
|
4857
2192001e4bb4
Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4849
diff
changeset
|
265 |
linenumber = opts.get('line_number') is not None |
10394
4612cded5176
fix coding style (reported by pylint)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10390
diff
changeset
|
266 |
if linenumber and (not opts.get('changeset')) and (not opts.get('number')): |
4857
2192001e4bb4
Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4849
diff
changeset
|
267 |
raise util.Abort(_('at least one of -n/-c is required for -l')) |
2192001e4bb4
Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4849
diff
changeset
|
268 |
|
14358
bf93e78f2638
annotate: fix alignment of columns in front of line numbers (issue2807)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14331
diff
changeset
|
269 |
funcmap = [(func, sep) for op, sep, func in opmap if opts.get(op)] |
bf93e78f2638
annotate: fix alignment of columns in front of line numbers (issue2807)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14331
diff
changeset
|
270 |
funcmap[0] = (funcmap[0][0], '') # no separator in front of first column |
4857
2192001e4bb4
Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4849
diff
changeset
|
271 |
|
13697
eaee75036725
annotate: catch nonexistent files using match.bad callback (issue1590)
Matt Mackall <mpm@selenic.com>
parents:
13694
diff
changeset
|
272 |
def bad(x, y): |
eaee75036725
annotate: catch nonexistent files using match.bad callback (issue1590)
Matt Mackall <mpm@selenic.com>
parents:
13694
diff
changeset
|
273 |
raise util.Abort("%s: %s" % (x, y)) |
eaee75036725
annotate: catch nonexistent files using match.bad callback (issue1590)
Matt Mackall <mpm@selenic.com>
parents:
13694
diff
changeset
|
274 |
|
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
275 |
ctx = scmutil.revsingle(repo, opts.get('rev')) |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
276 |
m = scmutil.match(ctx, pats, opts) |
13697
eaee75036725
annotate: catch nonexistent files using match.bad callback (issue1590)
Matt Mackall <mpm@selenic.com>
parents:
13694
diff
changeset
|
277 |
m.bad = bad |
10369
98a0421b9e52
commands: annotate follows by default, separate -f/--file option
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10365
diff
changeset
|
278 |
follow = not opts.get('no_follow') |
15528
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15513
diff
changeset
|
279 |
diffopts = patch.diffopts(ui, opts, section='annotate') |
6764 | 280 |
for abs in ctx.walk(m): |
281 |
fctx = ctx[abs] |
|
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
282 |
if not opts.get('text') and util.binary(fctx.data()): |
6584
29c77e5dfb3c
walk: remove rel and exact returns
Matt Mackall <mpm@selenic.com>
parents:
6583
diff
changeset
|
283 |
ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs)) |
1016 | 284 |
continue |
285 |
||
15528
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15513
diff
changeset
|
286 |
lines = fctx.annotate(follow=follow, linenumber=linenumber, |
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15513
diff
changeset
|
287 |
diffopts=diffopts) |
209 | 288 |
pieces = [] |
289 |
||
14358
bf93e78f2638
annotate: fix alignment of columns in front of line numbers (issue2807)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14331
diff
changeset
|
290 |
for f, sep in funcmap: |
4857
2192001e4bb4
Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4849
diff
changeset
|
291 |
l = [f(n) for n, dummy in lines] |
2192001e4bb4
Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4849
diff
changeset
|
292 |
if l: |
11611
4f5a6df2af92
i18n: use encoding.colwidth() for correct column width
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11518
diff
changeset
|
293 |
sized = [(x, encoding.colwidth(x)) for x in l] |
4f5a6df2af92
i18n: use encoding.colwidth() for correct column width
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11518
diff
changeset
|
294 |
ml = max([w for x, w in sized]) |
14358
bf93e78f2638
annotate: fix alignment of columns in front of line numbers (issue2807)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14331
diff
changeset
|
295 |
pieces.append(["%s%s%s" % (sep, ' ' * (ml - w), x) |
bf93e78f2638
annotate: fix alignment of columns in front of line numbers (issue2807)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14331
diff
changeset
|
296 |
for x, w in sized]) |
209 | 297 |
|
771 | 298 |
if pieces: |
299 |
for p, l in zip(zip(*pieces), lines): |
|
14358
bf93e78f2638
annotate: fix alignment of columns in front of line numbers (issue2807)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14331
diff
changeset
|
300 |
ui.write("%s: %s" % ("".join(p), l[1])) |
209 | 301 |
|
15829
2c480532f36e
annotate: append newline after non newline-terminated file listings
Ion Savin <ion.savin@tora.com>
parents:
15780
diff
changeset
|
302 |
if lines and not lines[-1][1].endswith('\n'): |
2c480532f36e
annotate: append newline after non newline-terminated file listings
Ion Savin <ion.savin@tora.com>
parents:
15780
diff
changeset
|
303 |
ui.write('\n') |
2c480532f36e
annotate: append newline after non newline-terminated file listings
Ion Savin <ion.savin@tora.com>
parents:
15780
diff
changeset
|
304 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
305 |
@command('archive', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
306 |
[('', 'no-decode', None, _('do not pass files through decoders')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
307 |
('p', 'prefix', '', _('directory prefix for files in archive'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
308 |
_('PREFIX')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
309 |
('r', 'rev', '', _('revision to distribute'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
310 |
('t', 'type', '', _('type of distribution to create'), _('TYPE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
311 |
] + subrepoopts + walkopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
312 |
_('[OPTION]... DEST')) |
2112
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
313 |
def archive(ui, repo, dest, **opts): |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
314 |
'''create an unversioned archive of a repository revision |
2112
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
315 |
|
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
316 |
By default, the revision used is the parent of the working |
8033
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
317 |
directory; use -r/--rev to specify a different revision. |
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
318 |
|
10650
9ea7238ad935
archive: autodetect archive type by extension (issue2058)
David Wolever <david@wolever.net>
parents:
10649
diff
changeset
|
319 |
The archive type is automatically detected based on file |
9ea7238ad935
archive: autodetect archive type by extension (issue2058)
David Wolever <david@wolever.net>
parents:
10649
diff
changeset
|
320 |
extension (or override using -t/--type). |
9ea7238ad935
archive: autodetect archive type by extension (issue2058)
David Wolever <david@wolever.net>
parents:
10649
diff
changeset
|
321 |
|
15109
f7993be2c32f
archive: add help examples
Matt Mackall <mpm@selenic.com>
parents:
15105
diff
changeset
|
322 |
.. container:: verbose |
f7993be2c32f
archive: add help examples
Matt Mackall <mpm@selenic.com>
parents:
15105
diff
changeset
|
323 |
|
f7993be2c32f
archive: add help examples
Matt Mackall <mpm@selenic.com>
parents:
15105
diff
changeset
|
324 |
Examples: |
f7993be2c32f
archive: add help examples
Matt Mackall <mpm@selenic.com>
parents:
15105
diff
changeset
|
325 |
|
f7993be2c32f
archive: add help examples
Matt Mackall <mpm@selenic.com>
parents:
15105
diff
changeset
|
326 |
- create a zip file containing the 1.0 release:: |
f7993be2c32f
archive: add help examples
Matt Mackall <mpm@selenic.com>
parents:
15105
diff
changeset
|
327 |
|
f7993be2c32f
archive: add help examples
Matt Mackall <mpm@selenic.com>
parents:
15105
diff
changeset
|
328 |
hg archive -r 1.0 project-1.0.zip |
f7993be2c32f
archive: add help examples
Matt Mackall <mpm@selenic.com>
parents:
15105
diff
changeset
|
329 |
|
f7993be2c32f
archive: add help examples
Matt Mackall <mpm@selenic.com>
parents:
15105
diff
changeset
|
330 |
- create a tarball excluding .hg files:: |
f7993be2c32f
archive: add help examples
Matt Mackall <mpm@selenic.com>
parents:
15105
diff
changeset
|
331 |
|
f7993be2c32f
archive: add help examples
Matt Mackall <mpm@selenic.com>
parents:
15105
diff
changeset
|
332 |
hg archive project.tar.gz -X ".hg*" |
f7993be2c32f
archive: add help examples
Matt Mackall <mpm@selenic.com>
parents:
15105
diff
changeset
|
333 |
|
10650
9ea7238ad935
archive: autodetect archive type by extension (issue2058)
David Wolever <david@wolever.net>
parents:
10649
diff
changeset
|
334 |
Valid types are: |
9892
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
335 |
|
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
336 |
:``files``: a directory full of files (default) |
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
337 |
:``tar``: tar archive, uncompressed |
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
338 |
:``tbz2``: tar archive, compressed using bzip2 |
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
339 |
:``tgz``: tar archive, compressed using gzip |
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
340 |
:``uzip``: zip archive, uncompressed |
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
341 |
:``zip``: zip archive, compressed using deflate |
2112
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
342 |
|
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
343 |
The exact name of the destination archive or directory is given |
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
344 |
using a format string; see :hg:`help export` for details. |
2112
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
345 |
|
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
346 |
Each member added to an archive file has a directory prefix |
8033
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
347 |
prepended. Use -p/--prefix to specify a format string for the |
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
348 |
prefix. The default is the basename of the archive, with suffixes |
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
349 |
removed. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
350 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
351 |
Returns 0 on success. |
2112
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
352 |
''' |
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
353 |
|
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
354 |
ctx = scmutil.revsingle(repo, opts.get('rev')) |
5061
a49f2a4d5ff7
archive: abort on empty repository. Fixes #624.
Brendan Cully <brendan@kublai.com>
parents:
4966
diff
changeset
|
355 |
if not ctx: |
7528
eadcc075967e
archive: fix bogus error message with no working directory
Matt Mackall <mpm@selenic.com>
parents:
7527
diff
changeset
|
356 |
raise util.Abort(_('no working directory: please specify a revision')) |
5061
a49f2a4d5ff7
archive: abort on empty repository. Fixes #624.
Brendan Cully <brendan@kublai.com>
parents:
4966
diff
changeset
|
357 |
node = ctx.node() |
14290
86e70956da4f
cmdutil: make_filename -> makefilename
Matt Mackall <mpm@selenic.com>
parents:
14289
diff
changeset
|
358 |
dest = cmdutil.makefilename(repo, dest, node) |
15381
c519cd8f0169
backout dbdb777502dc (issue3077) (issue3071)
Matt Mackall <mpm@selenic.com>
parents:
15373
diff
changeset
|
359 |
if os.path.realpath(dest) == repo.root: |
2112
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
360 |
raise util.Abort(_('repository root cannot be destination')) |
10650
9ea7238ad935
archive: autodetect archive type by extension (issue2058)
David Wolever <david@wolever.net>
parents:
10649
diff
changeset
|
361 |
|
11557
57bdc2239535
archival: move commands.archive.guess_type to archival.guesskind
Martin Geisler <mg@lazybytes.net>
parents:
11551
diff
changeset
|
362 |
kind = opts.get('type') or archival.guesskind(dest) or 'files' |
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
363 |
prefix = opts.get('prefix') |
10650
9ea7238ad935
archive: autodetect archive type by extension (issue2058)
David Wolever <david@wolever.net>
parents:
10649
diff
changeset
|
364 |
|
2476
0f7e4a39d9af
archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2473
diff
changeset
|
365 |
if dest == '-': |
0f7e4a39d9af
archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2473
diff
changeset
|
366 |
if kind == 'files': |
0f7e4a39d9af
archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2473
diff
changeset
|
367 |
raise util.Abort(_('cannot archive plain files to stdout')) |
14742
271424fdbeec
archive: wrap the ui descriptor so it doesn't get closed
Idan Kamara <idankk86@gmail.com>
parents:
14740
diff
changeset
|
368 |
dest = cmdutil.makefileobj(repo, dest) |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10270
diff
changeset
|
369 |
if not prefix: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10270
diff
changeset
|
370 |
prefix = os.path.basename(repo.root) + '-%h' |
10650
9ea7238ad935
archive: autodetect archive type by extension (issue2058)
David Wolever <david@wolever.net>
parents:
10649
diff
changeset
|
371 |
|
14290
86e70956da4f
cmdutil: make_filename -> makefilename
Matt Mackall <mpm@selenic.com>
parents:
14289
diff
changeset
|
372 |
prefix = cmdutil.makefilename(repo, prefix, node) |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
373 |
matchfn = scmutil.match(ctx, [], opts) |
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
374 |
archival.archive(repo, dest, node, kind, not opts.get('no_decode'), |
12323
f00953d9533c
subrepo: add support for 'hg archive'
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
375 |
matchfn, prefix, subrepos=opts.get('subrepos')) |
2112
2b03c6733efa
add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2092
diff
changeset
|
376 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
377 |
@command('backout', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
378 |
[('', 'merge', None, _('merge with old dirstate parent after backout')), |
15211
1209de02034e
backout: deprecate/hide support for backing out merges
Matt Mackall <mpm@selenic.com>
parents:
15210
diff
changeset
|
379 |
('', 'parent', '', |
1209de02034e
backout: deprecate/hide support for backing out merges
Matt Mackall <mpm@selenic.com>
parents:
15210
diff
changeset
|
380 |
_('parent to choose when backing out merge (DEPRECATED)'), _('REV')), |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
381 |
('r', 'rev', '', _('revision to backout'), _('REV')), |
14852
cac04f2f475b
commands: use mergetoolopts when a command supports --tool
Martin Geisler <mg@aragost.com>
parents:
14840
diff
changeset
|
382 |
] + mergetoolopts + walkopts + commitopts + commitopts2, |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
383 |
_('[OPTION]... [-r] REV')) |
4450
8fa54b9c6c5a
accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents:
4445
diff
changeset
|
384 |
def backout(ui, repo, node=None, rev=None, **opts): |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
385 |
'''reverse effect of earlier changeset |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
386 |
|
13340
02aa06a021a0
backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents:
13328
diff
changeset
|
387 |
Prepare a new changeset with the effect of REV undone in the |
02aa06a021a0
backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents:
13328
diff
changeset
|
388 |
current working directory. |
02aa06a021a0
backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents:
13328
diff
changeset
|
389 |
|
13473
bbdd858e3229
backout: clarify which changesets are new in help text
Jonathan Nieder <jrnieder@gmail.com>
parents:
13472
diff
changeset
|
390 |
If REV is the parent of the working directory, then this new changeset |
13340
02aa06a021a0
backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents:
13328
diff
changeset
|
391 |
is committed automatically. Otherwise, hg needs to merge the |
02aa06a021a0
backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents:
13328
diff
changeset
|
392 |
changes and the merged result is left uncommitted. |
02aa06a021a0
backout: make help more explicit about what backout does
Jonathan Nieder <jrnieder@gmail.com>
parents:
13328
diff
changeset
|
393 |
|
15210
9d8115c5fbda
backout: add a note about not working on merges
Matt Mackall <mpm@selenic.com>
parents:
15209
diff
changeset
|
394 |
.. note:: |
9d8115c5fbda
backout: add a note about not working on merges
Matt Mackall <mpm@selenic.com>
parents:
15209
diff
changeset
|
395 |
backout cannot be used to fix either an unwanted or |
9d8115c5fbda
backout: add a note about not working on merges
Matt Mackall <mpm@selenic.com>
parents:
15209
diff
changeset
|
396 |
incorrect merge. |
9d8115c5fbda
backout: add a note about not working on merges
Matt Mackall <mpm@selenic.com>
parents:
15209
diff
changeset
|
397 |
|
15209
10f85a735601
backout: mark some help verbose
Matt Mackall <mpm@selenic.com>
parents:
15203
diff
changeset
|
398 |
.. container:: verbose |
10f85a735601
backout: mark some help verbose
Matt Mackall <mpm@selenic.com>
parents:
15203
diff
changeset
|
399 |
|
10f85a735601
backout: mark some help verbose
Matt Mackall <mpm@selenic.com>
parents:
15203
diff
changeset
|
400 |
By default, the pending changeset will have one parent, |
10f85a735601
backout: mark some help verbose
Matt Mackall <mpm@selenic.com>
parents:
15203
diff
changeset
|
401 |
maintaining a linear history. With --merge, the pending |
10f85a735601
backout: mark some help verbose
Matt Mackall <mpm@selenic.com>
parents:
15203
diff
changeset
|
402 |
changeset will instead have two parents: the old parent of the |
10f85a735601
backout: mark some help verbose
Matt Mackall <mpm@selenic.com>
parents:
15203
diff
changeset
|
403 |
working directory and a new child of REV that simply undoes REV. |
10f85a735601
backout: mark some help verbose
Matt Mackall <mpm@selenic.com>
parents:
15203
diff
changeset
|
404 |
|
10f85a735601
backout: mark some help verbose
Matt Mackall <mpm@selenic.com>
parents:
15203
diff
changeset
|
405 |
Before version 1.7, the behavior without --merge was equivalent |
10f85a735601
backout: mark some help verbose
Matt Mackall <mpm@selenic.com>
parents:
15203
diff
changeset
|
406 |
to specifying --merge followed by :hg:`update --clean .` to |
10f85a735601
backout: mark some help verbose
Matt Mackall <mpm@selenic.com>
parents:
15203
diff
changeset
|
407 |
cancel the merge and leave the child of REV as a head to be |
10f85a735601
backout: mark some help verbose
Matt Mackall <mpm@selenic.com>
parents:
15203
diff
changeset
|
408 |
merged separately. |
6163
1f733c2f0165
Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6161
diff
changeset
|
409 |
|
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
410 |
See :hg:`help dates` for a list of formats valid for -d/--date. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
411 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
412 |
Returns 0 on success. |
6163
1f733c2f0165
Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6161
diff
changeset
|
413 |
''' |
4450
8fa54b9c6c5a
accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents:
4445
diff
changeset
|
414 |
if rev and node: |
8fa54b9c6c5a
accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents:
4445
diff
changeset
|
415 |
raise util.Abort(_("please specify just one revision")) |
8fa54b9c6c5a
accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents:
4445
diff
changeset
|
416 |
|
8fa54b9c6c5a
accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents:
4445
diff
changeset
|
417 |
if not rev: |
8fa54b9c6c5a
accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents:
4445
diff
changeset
|
418 |
rev = node |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
419 |
|
4726
f6e961c0155b
Fix and test 'hg backout' without or with too many revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4718
diff
changeset
|
420 |
if not rev: |
f6e961c0155b
Fix and test 'hg backout' without or with too many revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4718
diff
changeset
|
421 |
raise util.Abort(_("please specify a revision to backout")) |
f6e961c0155b
Fix and test 'hg backout' without or with too many revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4718
diff
changeset
|
422 |
|
6139
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6134
diff
changeset
|
423 |
date = opts.get('date') |
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6134
diff
changeset
|
424 |
if date: |
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6134
diff
changeset
|
425 |
opts['date'] = util.parsedate(date) |
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6134
diff
changeset
|
426 |
|
14289
d68ddccf276b
cmdutil: bail_if_changed to bailifchanged
Matt Mackall <mpm@selenic.com>
parents:
14286
diff
changeset
|
427 |
cmdutil.bailifchanged(repo) |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
428 |
node = scmutil.revsingle(repo, rev).node() |
5716
be367cbafe70
cmdutil: make bail_if_changed bail on uncommitted merge
Matt Mackall <mpm@selenic.com>
parents:
5688
diff
changeset
|
429 |
|
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
430 |
op1, op2 = repo.dirstate.parents() |
5568
de620356064f
backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents:
5542
diff
changeset
|
431 |
a = repo.changelog.ancestor(op1, node) |
de620356064f
backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents:
5542
diff
changeset
|
432 |
if a != node: |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
433 |
raise util.Abort(_('cannot backout change on a different branch')) |
5568
de620356064f
backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents:
5542
diff
changeset
|
434 |
|
2614
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
435 |
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
|
436 |
if p1 == nullid: |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
437 |
raise util.Abort(_('cannot backout a change with no parents')) |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
438 |
if p2 != nullid: |
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
439 |
if not opts.get('parent'): |
15211
1209de02034e
backout: deprecate/hide support for backing out merges
Matt Mackall <mpm@selenic.com>
parents:
15210
diff
changeset
|
440 |
raise util.Abort(_('cannot backout a merge changeset')) |
2614
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
441 |
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
|
442 |
if p not in (p1, p2): |
3679
2956948b81f3
fix warnings generated by pygettext.py.
Marcos Chaves <marcos.nospam@gmail.com>
parents:
3673
diff
changeset
|
443 |
raise util.Abort(_('%s is not a parent of %s') % |
3680
69cf255a55a1
Indentation cleanups for 2956948b81f3.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3679
diff
changeset
|
444 |
(short(p), short(node))) |
2614
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
445 |
parent = p |
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
446 |
else: |
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
447 |
if opts.get('parent'): |
2614
8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2613
diff
changeset
|
448 |
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
|
449 |
parent = p1 |
5568
de620356064f
backout: disallow across branches (issue655)
Matt Mackall <mpm@selenic.com>
parents:
5542
diff
changeset
|
450 |
|
6423
fb374b1b3911
backout: reverse changeset belongs on current branch
Matt Mackall <mpm@selenic.com>
parents:
6385
diff
changeset
|
451 |
# the backout should appear on the same branch |
fb374b1b3911
backout: reverse changeset belongs on current branch
Matt Mackall <mpm@selenic.com>
parents:
6385
diff
changeset
|
452 |
branch = repo.dirstate.branch() |
2808
30f59f4a327e
Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents:
2806
diff
changeset
|
453 |
hg.clean(repo, node, show_stats=False) |
6423
fb374b1b3911
backout: reverse changeset belongs on current branch
Matt Mackall <mpm@selenic.com>
parents:
6385
diff
changeset
|
454 |
repo.dirstate.setbranch(branch) |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
455 |
revert_opts = opts.copy() |
3814
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3813
diff
changeset
|
456 |
revert_opts['date'] = None |
2982
890e285c52a1
revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2963
diff
changeset
|
457 |
revert_opts['all'] = True |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
458 |
revert_opts['rev'] = hex(parent) |
6031
7383384793fb
revert: don't assume ignored files will be returned in the unknown list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6030
diff
changeset
|
459 |
revert_opts['no_backup'] = None |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
460 |
revert(ui, repo, **revert_opts) |
12727
52971985be14
backout: provide linear backout as a default (without --merge option)
Gilles Moris <gilles.moris@free.fr>
parents:
12726
diff
changeset
|
461 |
if not opts.get('merge') and op1 != node: |
12810
a68ccfd9c7be
backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents:
12809
diff
changeset
|
462 |
try: |
a68ccfd9c7be
backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents:
12809
diff
changeset
|
463 |
ui.setconfig('ui', 'forcemerge', opts.get('tool', '')) |
a68ccfd9c7be
backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents:
12809
diff
changeset
|
464 |
return hg.update(repo, op1) |
a68ccfd9c7be
backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents:
12809
diff
changeset
|
465 |
finally: |
a68ccfd9c7be
backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents:
12809
diff
changeset
|
466 |
ui.setconfig('ui', 'forcemerge', '') |
12727
52971985be14
backout: provide linear backout as a default (without --merge option)
Gilles Moris <gilles.moris@free.fr>
parents:
12726
diff
changeset
|
467 |
|
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
468 |
commit_opts = opts.copy() |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
469 |
commit_opts['addremove'] = False |
2159
5c34b98ad6b1
Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2158
diff
changeset
|
470 |
if not commit_opts['message'] and not commit_opts['logfile']: |
9183
d0225fa2f6c4
do not translate commit messages
Martin Geisler <mg@lazybytes.net>
parents:
9128
diff
changeset
|
471 |
# we don't translate commit messages |
9197
a05aa192a00a
commands: remove ineffective parenthesis
Martin Geisler <mg@lazybytes.net>
parents:
9196
diff
changeset
|
472 |
commit_opts['message'] = "Backed out changeset %s" % short(node) |
2268
6c9305fbebaf
fix coding style of backout editor change.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2267
diff
changeset
|
473 |
commit_opts['force_editor'] = True |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
474 |
commit(ui, repo, **commit_opts) |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
475 |
def nice(node): |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
476 |
return '%d:%s' % (repo.changelog.rev(node), short(node)) |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
477 |
ui.status(_('changeset %s backs out changeset %s\n') % |
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
478 |
(nice(repo.changelog.tip()), nice(node))) |
12727
52971985be14
backout: provide linear backout as a default (without --merge option)
Gilles Moris <gilles.moris@free.fr>
parents:
12726
diff
changeset
|
479 |
if opts.get('merge') and op1 != node: |
6161
bc1ba9124799
Reverse the way backout is doing the merge
Gilles Moris <gilles.moris@free.fr>
parents:
6146
diff
changeset
|
480 |
hg.clean(repo, op1, show_stats=False) |
12727
52971985be14
backout: provide linear backout as a default (without --merge option)
Gilles Moris <gilles.moris@free.fr>
parents:
12726
diff
changeset
|
481 |
ui.status(_('merging with changeset %s\n') |
52971985be14
backout: provide linear backout as a default (without --merge option)
Gilles Moris <gilles.moris@free.fr>
parents:
12726
diff
changeset
|
482 |
% nice(repo.changelog.tip())) |
12810
a68ccfd9c7be
backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents:
12809
diff
changeset
|
483 |
try: |
a68ccfd9c7be
backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents:
12809
diff
changeset
|
484 |
ui.setconfig('ui', 'forcemerge', opts.get('tool', '')) |
a68ccfd9c7be
backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents:
12809
diff
changeset
|
485 |
return hg.merge(repo, hex(repo.changelog.tip())) |
a68ccfd9c7be
backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents:
12809
diff
changeset
|
486 |
finally: |
a68ccfd9c7be
backout: add --tool argument for specifying merge tool
Steve Borho <steve@borho.org>
parents:
12809
diff
changeset
|
487 |
ui.setconfig('ui', 'forcemerge', '') |
12727
52971985be14
backout: provide linear backout as a default (without --merge option)
Gilles Moris <gilles.moris@free.fr>
parents:
12726
diff
changeset
|
488 |
return 0 |
2158
ec96c4518236
add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2153
diff
changeset
|
489 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
490 |
@command('bisect', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
491 |
[('r', 'reset', False, _('reset bisect state')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
492 |
('g', 'good', False, _('mark changeset good')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
493 |
('b', 'bad', False, _('mark changeset bad')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
494 |
('s', 'skip', False, _('skip testing changeset')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
495 |
('e', 'extend', False, _('extend the bisect range')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
496 |
('c', 'command', '', _('use command to check changeset state'), _('CMD')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
497 |
('U', 'noupdate', False, _('do not update to target'))], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
498 |
_("[-gbsr] [-U] [-c CMD] [REV]")) |
7227
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
499 |
def bisect(ui, repo, rev=None, extra=None, command=None, |
13601
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
500 |
reset=None, good=None, bad=None, skip=None, extend=None, |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
501 |
noupdate=None): |
5775
2dd202a6e15b
bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents:
5764
diff
changeset
|
502 |
"""subdivision search of changesets |
2dd202a6e15b
bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents:
5764
diff
changeset
|
503 |
|
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
504 |
This command helps to find changesets which introduce problems. To |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
505 |
use, mark the earliest changeset you know exhibits the problem as |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
506 |
bad, then mark the latest changeset which is free from the problem |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
507 |
as good. Bisect will update your working directory to a revision |
8033
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
508 |
for testing (unless the -U/--noupdate option is specified). Once |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
509 |
you have performed tests, mark the working directory as good or |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
510 |
bad, and bisect will either update to another candidate changeset |
6928
1a4c66d741a2
bisect: expand help text to explain REV argument and --noupdate
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6858
diff
changeset
|
511 |
or announce that it has found the bad revision. |
7184
380fda3eed13
clean up trailing spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7037
diff
changeset
|
512 |
|
6928
1a4c66d741a2
bisect: expand help text to explain REV argument and --noupdate
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6858
diff
changeset
|
513 |
As a shortcut, you can also use the revision argument to mark a |
1a4c66d741a2
bisect: expand help text to explain REV argument and --noupdate
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6858
diff
changeset
|
514 |
revision as good or bad without checking it out first. |
7227
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
515 |
|
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
516 |
If you supply a command, it will be used for automatic bisection. |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
517 |
Its exit status will be used to mark revisions as good or bad: |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
518 |
status 0 means good, 125 means to skip the revision, 127 |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
519 |
(command not found) will abort the bisection, and any other |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
520 |
non-zero exit status means the revision is bad. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
521 |
|
15139
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
522 |
.. container:: verbose |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
523 |
|
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
524 |
Some examples: |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
525 |
|
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
526 |
- start a bisection with known bad revision 12, and good revision 34:: |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
527 |
|
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
528 |
hg bisect --bad 34 |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
529 |
hg bisect --good 12 |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
530 |
|
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
531 |
- advance the current bisection by marking current revision as good or |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
532 |
bad:: |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
533 |
|
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
534 |
hg bisect --good |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
535 |
hg bisect --bad |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
536 |
|
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
537 |
- mark the current revision, or a known revision, to be skipped (eg. if |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
538 |
that revision is not usable because of another issue):: |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
539 |
|
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
540 |
hg bisect --skip |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
541 |
hg bisect --skip 23 |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
542 |
|
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
543 |
- forget the current bisection:: |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
544 |
|
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
545 |
hg bisect --reset |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
546 |
|
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
547 |
- use 'make && make tests' to automatically find the first broken |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
548 |
revision:: |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
549 |
|
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
550 |
hg bisect --reset |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
551 |
hg bisect --bad 34 |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
552 |
hg bisect --good 12 |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
553 |
hg bisect --command 'make && make tests' |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
554 |
|
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
555 |
- see all changesets whose states are already known in the current |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
556 |
bisection:: |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
557 |
|
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
558 |
hg log -r "bisect(pruned)" |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
559 |
|
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
560 |
- see all changesets that took part in the current bisection:: |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
561 |
|
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
562 |
hg log -r "bisect(range)" |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
563 |
|
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
564 |
- with the graphlog extension, you can even get a nice graph:: |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
565 |
|
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
566 |
hg log --graph -r "bisect(range)" |
0834e0bb445a
bisect: add some bisection examples, and some log revset.bisect() examples
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15129
diff
changeset
|
567 |
|
15147
395ca8cd2669
revset.bisect: add 'ignored' set to the bisect keyword
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15145
diff
changeset
|
568 |
See :hg:`help revsets` for more about the `bisect()` keyword. |
395ca8cd2669
revset.bisect: add 'ignored' set to the bisect keyword
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15145
diff
changeset
|
569 |
|
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
570 |
Returns 0 on success. |
5775
2dd202a6e15b
bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents:
5764
diff
changeset
|
571 |
""" |
13601
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
572 |
def extendbisectrange(nodes, good): |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
573 |
# bisect is incomplete when it ends on a merge node and |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
574 |
# one of the parent was not checked. |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
575 |
parents = repo[nodes[0]].parents() |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
576 |
if len(parents) > 1: |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
577 |
side = good and state['bad'] or state['good'] |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
578 |
num = len(set(i.node() for i in parents) & set(side)) |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
579 |
if num == 1: |
14157 | 580 |
return parents[0].ancestor(parents[1]) |
13601
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
581 |
return None |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
582 |
|
7227
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
583 |
def print_result(nodes, good): |
5775
2dd202a6e15b
bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents:
5764
diff
changeset
|
584 |
displayer = cmdutil.show_changeset(ui, repo, {}) |
6858
8f256bf98219
Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents:
6842
diff
changeset
|
585 |
if len(nodes) == 1: |
8f256bf98219
Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents:
6842
diff
changeset
|
586 |
# narrowed it down to a single revision |
8088
bdeb380a10de
commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents:
8042
diff
changeset
|
587 |
if good: |
bdeb380a10de
commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents:
8042
diff
changeset
|
588 |
ui.write(_("The first good revision is:\n")) |
bdeb380a10de
commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents:
8042
diff
changeset
|
589 |
else: |
bdeb380a10de
commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents:
8042
diff
changeset
|
590 |
ui.write(_("The first bad revision is:\n")) |
7369
87158be081b8
cmdutil: use change contexts for cset-printer and cset-templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7364
diff
changeset
|
591 |
displayer.show(repo[nodes[0]]) |
13601
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
592 |
extendnode = extendbisectrange(nodes, good) |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
593 |
if extendnode is not None: |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
594 |
ui.write(_('Not all ancestors of this changeset have been' |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
595 |
' checked.\nUse bisect --extend to continue the ' |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
596 |
'bisection from\nthe common ancestor, %s.\n') |
14055
421d56a055fd
drop {short,hex}(ctx.node()) calls in favor of ctx methods
Alexander Solovyov <alexander@solovyov.net>
parents:
14048
diff
changeset
|
597 |
% extendnode) |
6858
8f256bf98219
Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents:
6842
diff
changeset
|
598 |
else: |
8f256bf98219
Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents:
6842
diff
changeset
|
599 |
# multiple possible revisions |
8088
bdeb380a10de
commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents:
8042
diff
changeset
|
600 |
if good: |
bdeb380a10de
commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents:
8042
diff
changeset
|
601 |
ui.write(_("Due to skipped revisions, the first " |
bdeb380a10de
commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents:
8042
diff
changeset
|
602 |
"good revision could be any of:\n")) |
bdeb380a10de
commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents:
8042
diff
changeset
|
603 |
else: |
bdeb380a10de
commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents:
8042
diff
changeset
|
604 |
ui.write(_("Due to skipped revisions, the first " |
bdeb380a10de
commands, i18n: avoid untranslated strings as message parameters
Wagner Bruna <wbruna@yahoo.com>
parents:
8042
diff
changeset
|
605 |
"bad revision could be any of:\n")) |
6858
8f256bf98219
Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents:
6842
diff
changeset
|
606 |
for n in nodes: |
7369
87158be081b8
cmdutil: use change contexts for cset-printer and cset-templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7364
diff
changeset
|
607 |
displayer.show(repo[n]) |
10152
56284451a22c
Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents:
10111
diff
changeset
|
608 |
displayer.close() |
7227
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
609 |
|
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
610 |
def check_state(state, interactive=True): |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
611 |
if not state['good'] or not state['bad']: |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
612 |
if (good or bad or skip or reset) and interactive: |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
613 |
return |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
614 |
if not state['good']: |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
615 |
raise util.Abort(_('cannot bisect (no known good revisions)')) |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
616 |
else: |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
617 |
raise util.Abort(_('cannot bisect (no known bad revisions)')) |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
618 |
return True |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
619 |
|
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
620 |
# backward compatibility |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
621 |
if rev in "good bad reset init".split(): |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
622 |
ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n")) |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
623 |
cmd, rev, extra = rev, extra, None |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
624 |
if cmd == "good": |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
625 |
good = True |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
626 |
elif cmd == "bad": |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
627 |
bad = True |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
628 |
else: |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
629 |
reset = True |
13601
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
630 |
elif extra or good + bad + skip + reset + extend + bool(command) > 1: |
7227
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
631 |
raise util.Abort(_('incompatible arguments')) |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
632 |
|
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
633 |
if reset: |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
634 |
p = repo.join("bisect.state") |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
635 |
if os.path.exists(p): |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
636 |
os.unlink(p) |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
637 |
return |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
638 |
|
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
639 |
state = hbisect.load_state(repo) |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
640 |
|
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
641 |
if command: |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
642 |
changesets = 1 |
7590
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
643 |
try: |
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
644 |
while changesets: |
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
645 |
# update state |
14740
d83ad13a280e
bisect: use ui out descriptor when calling util.system
Idan Kamara <idankk86@gmail.com>
parents:
14729
diff
changeset
|
646 |
status = util.system(command, out=ui.fout) |
7590
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
647 |
if status == 125: |
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
648 |
transition = "skip" |
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
649 |
elif status == 0: |
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
650 |
transition = "good" |
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
651 |
# status < 0 means process was killed |
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
652 |
elif status == 127: |
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
653 |
raise util.Abort(_("failed to execute %s") % command) |
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
654 |
elif status < 0: |
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
655 |
raise util.Abort(_("%s killed") % command) |
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
656 |
else: |
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
657 |
transition = "bad" |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
658 |
ctx = scmutil.revsingle(repo, rev) |
12925
6eab8f0df2ca
commands: add revset support to most commands
Matt Mackall <mpm@selenic.com>
parents:
12918
diff
changeset
|
659 |
rev = None # clear for future iterations |
8805
2726a6df11e9
bisect: improve --command output
Patrick Mezard <pmezard@gmail.com>
parents:
8802
diff
changeset
|
660 |
state[transition].append(ctx.node()) |
2726a6df11e9
bisect: improve --command output
Patrick Mezard <pmezard@gmail.com>
parents:
8802
diff
changeset
|
661 |
ui.status(_('Changeset %d:%s: %s\n') % (ctx, ctx, transition)) |
7590
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
662 |
check_state(state, interactive=False) |
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
663 |
# bisect |
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
664 |
nodes, changesets, good = hbisect.bisect(repo.changelog, state) |
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
665 |
# update to next check |
14289
d68ddccf276b
cmdutil: bail_if_changed to bailifchanged
Matt Mackall <mpm@selenic.com>
parents:
14286
diff
changeset
|
666 |
cmdutil.bailifchanged(repo) |
7590
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
667 |
hg.clean(repo, nodes[0], show_stats=False) |
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
668 |
finally: |
e5703ec08e64
bisect: improve hg bisect -c (relative paths, error handling)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7570
diff
changeset
|
669 |
hbisect.save_state(repo, state) |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
670 |
print_result(nodes, good) |
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
671 |
return |
7227
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
672 |
|
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
673 |
# update state |
12177
80399b5b5f13
bisect: allow revsets in addition to single revs (issue2360)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
12173
diff
changeset
|
674 |
|
80399b5b5f13
bisect: allow revsets in addition to single revs (issue2360)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
12173
diff
changeset
|
675 |
if rev: |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
676 |
nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])] |
12177
80399b5b5f13
bisect: allow revsets in addition to single revs (issue2360)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
12173
diff
changeset
|
677 |
else: |
80399b5b5f13
bisect: allow revsets in addition to single revs (issue2360)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
12173
diff
changeset
|
678 |
nodes = [repo.lookup('.')] |
80399b5b5f13
bisect: allow revsets in addition to single revs (issue2360)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
12173
diff
changeset
|
679 |
|
9689
57cee011ffcb
bisect: no need to save the state if it wasn't changed
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9687
diff
changeset
|
680 |
if good or bad or skip: |
57cee011ffcb
bisect: no need to save the state if it wasn't changed
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9687
diff
changeset
|
681 |
if good: |
12177
80399b5b5f13
bisect: allow revsets in addition to single revs (issue2360)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
12173
diff
changeset
|
682 |
state['good'] += nodes |
9689
57cee011ffcb
bisect: no need to save the state if it wasn't changed
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9687
diff
changeset
|
683 |
elif bad: |
12177
80399b5b5f13
bisect: allow revsets in addition to single revs (issue2360)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
12173
diff
changeset
|
684 |
state['bad'] += nodes |
9689
57cee011ffcb
bisect: no need to save the state if it wasn't changed
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9687
diff
changeset
|
685 |
elif skip: |
12177
80399b5b5f13
bisect: allow revsets in addition to single revs (issue2360)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
12173
diff
changeset
|
686 |
state['skip'] += nodes |
9689
57cee011ffcb
bisect: no need to save the state if it wasn't changed
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9687
diff
changeset
|
687 |
hbisect.save_state(repo, state) |
7227
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
688 |
|
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
689 |
if not check_state(state): |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
690 |
return |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
691 |
|
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
692 |
# actually bisect |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
693 |
nodes, changesets, good = hbisect.bisect(repo.changelog, state) |
13601
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
694 |
if extend: |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
695 |
if not changesets: |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
696 |
extendnode = extendbisectrange(nodes, good) |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
697 |
if extendnode is not None: |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
698 |
ui.write(_("Extending search to changeset %d:%s\n" |
14055
421d56a055fd
drop {short,hex}(ctx.node()) calls in favor of ctx methods
Alexander Solovyov <alexander@solovyov.net>
parents:
14048
diff
changeset
|
699 |
% (extendnode.rev(), extendnode))) |
13601
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
700 |
if noupdate: |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
701 |
return |
14289
d68ddccf276b
cmdutil: bail_if_changed to bailifchanged
Matt Mackall <mpm@selenic.com>
parents:
14286
diff
changeset
|
702 |
cmdutil.bailifchanged(repo) |
13601
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
703 |
return hg.clean(repo, extendnode.node()) |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
704 |
raise util.Abort(_("nothing to extend")) |
0388e3e36693
bisect: new command to extend the bisect range (issue2690)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13591
diff
changeset
|
705 |
|
7227
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
706 |
if changesets == 0: |
e1afb50ec2aa
bisect: ability to check revision with command
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7213
diff
changeset
|
707 |
print_result(nodes, good) |
6858
8f256bf98219
Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents:
6842
diff
changeset
|
708 |
else: |
8f256bf98219
Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents:
6842
diff
changeset
|
709 |
assert len(nodes) == 1 # only a single node can be tested next |
8f256bf98219
Add support for multiple possible bisect results (issue1228, issue1182)
Bernhard Leiner <bleiner@gmail.com>
parents:
6842
diff
changeset
|
710 |
node = nodes[0] |
5775
2dd202a6e15b
bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents:
5764
diff
changeset
|
711 |
# compute the approximate number of remaining tests |
2dd202a6e15b
bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents:
5764
diff
changeset
|
712 |
tests, size = 0, 2 |
2dd202a6e15b
bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents:
5764
diff
changeset
|
713 |
while size <= changesets: |
2dd202a6e15b
bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents:
5764
diff
changeset
|
714 |
tests, size = tests + 1, size * 2 |
2dd202a6e15b
bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents:
5764
diff
changeset
|
715 |
rev = repo.changelog.rev(node) |
9012
ada93c6bf554
bisect: fix format specifiers for integers
Cédric Duval <cedricduval@free.fr>
parents:
8995
diff
changeset
|
716 |
ui.write(_("Testing changeset %d:%s " |
ada93c6bf554
bisect: fix format specifiers for integers
Cédric Duval <cedricduval@free.fr>
parents:
8995
diff
changeset
|
717 |
"(%d changesets remaining, ~%d tests)\n") |
6217
fe8dbbe9520d
Avoid importing mercurial.node/mercurial.repo stuff from mercurial.hg
Joel Rosdahl <joel@rosdahl.net>
parents:
6212
diff
changeset
|
718 |
% (rev, short(node), changesets, tests)) |
5775
2dd202a6e15b
bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents:
5764
diff
changeset
|
719 |
if not noupdate: |
14289
d68ddccf276b
cmdutil: bail_if_changed to bailifchanged
Matt Mackall <mpm@selenic.com>
parents:
14286
diff
changeset
|
720 |
cmdutil.bailifchanged(repo) |
5775
2dd202a6e15b
bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents:
5764
diff
changeset
|
721 |
return hg.clean(repo, node) |
2dd202a6e15b
bisect: make bisect a built-in command
Matt Mackall <mpm@selenic.com>
parents:
5764
diff
changeset
|
722 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
723 |
@command('bookmarks', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
724 |
[('f', 'force', False, _('force')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
725 |
('r', 'rev', '', _('revision'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
726 |
('d', 'delete', False, _('delete a given bookmark')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
727 |
('m', 'rename', '', _('rename a given bookmark'), _('NAME')), |
15959
db33555eafea
bookmarks: correct correction of -i
Matt Mackall <mpm@selenic.com>
parents:
15958
diff
changeset
|
728 |
('i', 'inactive', False, _('mark a bookmark inactive'))], |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
729 |
_('hg bookmarks [-f] [-d] [-i] [-m NAME] [-r REV] [NAME]')) |
14188
9029b1a38c30
bookmarks: allow to create/move bookmark without making it current (issue2788)
Kevin Bullock <kbullock@ringworld.org>
parents:
14168
diff
changeset
|
730 |
def bookmark(ui, repo, mark=None, rev=None, force=False, delete=False, |
9029b1a38c30
bookmarks: allow to create/move bookmark without making it current (issue2788)
Kevin Bullock <kbullock@ringworld.org>
parents:
14168
diff
changeset
|
731 |
rename=None, inactive=False): |
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
732 |
'''track a line of development with movable markers |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
733 |
|
15620
73faa2664909
bookmarks: clarify help for use of merge and update
Kevin Bullock <kbullock@ringworld.org>
parents:
15619
diff
changeset
|
734 |
Bookmarks are pointers to certain commits that move when committing. |
73faa2664909
bookmarks: clarify help for use of merge and update
Kevin Bullock <kbullock@ringworld.org>
parents:
15619
diff
changeset
|
735 |
Bookmarks are local. They can be renamed, copied and deleted. It is |
73faa2664909
bookmarks: clarify help for use of merge and update
Kevin Bullock <kbullock@ringworld.org>
parents:
15619
diff
changeset
|
736 |
possible to use :hg:`merge NAME` to merge from a given bookmark, and |
73faa2664909
bookmarks: clarify help for use of merge and update
Kevin Bullock <kbullock@ringworld.org>
parents:
15619
diff
changeset
|
737 |
:hg:`update NAME` to update to a given bookmark. |
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
738 |
|
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
739 |
You can use :hg:`bookmark NAME` to set a bookmark on the working |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
740 |
directory's parent revision with the given name. If you specify |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
741 |
a revision using -r REV (where REV may be an existing bookmark), |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
742 |
the bookmark is assigned to that revision. |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
743 |
|
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
744 |
Bookmarks can be pushed and pulled between repositories (see :hg:`help |
13407
354f304152ad
bookmarks: update help text since moving into core
Kevin Bullock <kbullock@ringworld.org>
parents:
13406
diff
changeset
|
745 |
push` and :hg:`help pull`). This requires both the local and remote |
354f304152ad
bookmarks: update help text since moving into core
Kevin Bullock <kbullock@ringworld.org>
parents:
13406
diff
changeset
|
746 |
repositories to support bookmarks. For versions prior to 1.8, this means |
354f304152ad
bookmarks: update help text since moving into core
Kevin Bullock <kbullock@ringworld.org>
parents:
13406
diff
changeset
|
747 |
the bookmarks extension must be enabled. |
15939
f57f891eb88e
bookmarks: clarify help for -i/--inactive
Kevin Bullock <kbullock@ringworld.org>
parents:
15935
diff
changeset
|
748 |
|
f57f891eb88e
bookmarks: clarify help for -i/--inactive
Kevin Bullock <kbullock@ringworld.org>
parents:
15935
diff
changeset
|
749 |
With -i/--inactive, the new bookmark will not be made the active |
f57f891eb88e
bookmarks: clarify help for -i/--inactive
Kevin Bullock <kbullock@ringworld.org>
parents:
15935
diff
changeset
|
750 |
bookmark. If -r/--rev is given, the new bookmark will not be made |
f57f891eb88e
bookmarks: clarify help for -i/--inactive
Kevin Bullock <kbullock@ringworld.org>
parents:
15935
diff
changeset
|
751 |
active even if -i/--inactive is not given. If no NAME is given, the |
f57f891eb88e
bookmarks: clarify help for -i/--inactive
Kevin Bullock <kbullock@ringworld.org>
parents:
15935
diff
changeset
|
752 |
current active bookmark will be marked inactive. |
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
753 |
''' |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
754 |
hexfn = ui.debugflag and hex or short |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
755 |
marks = repo._bookmarks |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
756 |
cur = repo.changectx('.').node() |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
757 |
|
15490
875bb46e35ea
bookmark: same order for options and code
Kevin Bullock <kbullock@ringworld.org>
parents:
15474
diff
changeset
|
758 |
if delete: |
875bb46e35ea
bookmark: same order for options and code
Kevin Bullock <kbullock@ringworld.org>
parents:
15474
diff
changeset
|
759 |
if mark is None: |
875bb46e35ea
bookmark: same order for options and code
Kevin Bullock <kbullock@ringworld.org>
parents:
15474
diff
changeset
|
760 |
raise util.Abort(_("bookmark name required")) |
875bb46e35ea
bookmark: same order for options and code
Kevin Bullock <kbullock@ringworld.org>
parents:
15474
diff
changeset
|
761 |
if mark not in marks: |
875bb46e35ea
bookmark: same order for options and code
Kevin Bullock <kbullock@ringworld.org>
parents:
15474
diff
changeset
|
762 |
raise util.Abort(_("bookmark '%s' does not exist") % mark) |
875bb46e35ea
bookmark: same order for options and code
Kevin Bullock <kbullock@ringworld.org>
parents:
15474
diff
changeset
|
763 |
if mark == repo._bookmarkcurrent: |
875bb46e35ea
bookmark: same order for options and code
Kevin Bullock <kbullock@ringworld.org>
parents:
15474
diff
changeset
|
764 |
bookmarks.setcurrent(repo, None) |
875bb46e35ea
bookmark: same order for options and code
Kevin Bullock <kbullock@ringworld.org>
parents:
15474
diff
changeset
|
765 |
del marks[mark] |
875bb46e35ea
bookmark: same order for options and code
Kevin Bullock <kbullock@ringworld.org>
parents:
15474
diff
changeset
|
766 |
bookmarks.write(repo) |
875bb46e35ea
bookmark: same order for options and code
Kevin Bullock <kbullock@ringworld.org>
parents:
15474
diff
changeset
|
767 |
return |
875bb46e35ea
bookmark: same order for options and code
Kevin Bullock <kbullock@ringworld.org>
parents:
15474
diff
changeset
|
768 |
|
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
769 |
if rename: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
770 |
if rename not in marks: |
13911
6bc340940c18
bookmarks: change error messages to match those given by 'hg tag' commands
Idan Kamara <idankk86@gmail.com>
parents:
13899
diff
changeset
|
771 |
raise util.Abort(_("bookmark '%s' does not exist") % rename) |
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
772 |
if mark in marks and not force: |
13911
6bc340940c18
bookmarks: change error messages to match those given by 'hg tag' commands
Idan Kamara <idankk86@gmail.com>
parents:
13899
diff
changeset
|
773 |
raise util.Abort(_("bookmark '%s' already exists " |
6bc340940c18
bookmarks: change error messages to match those given by 'hg tag' commands
Idan Kamara <idankk86@gmail.com>
parents:
13899
diff
changeset
|
774 |
"(use -f to force)") % mark) |
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
775 |
if mark is None: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
776 |
raise util.Abort(_("new bookmark name required")) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
777 |
marks[mark] = marks[rename] |
14188
9029b1a38c30
bookmarks: allow to create/move bookmark without making it current (issue2788)
Kevin Bullock <kbullock@ringworld.org>
parents:
14168
diff
changeset
|
778 |
if repo._bookmarkcurrent == rename and not inactive: |
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
779 |
bookmarks.setcurrent(repo, mark) |
13620
8ee4b00ddfd8
bookmarks: fix update of the current bookmark during rename
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13477
diff
changeset
|
780 |
del marks[rename] |
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
781 |
bookmarks.write(repo) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
782 |
return |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
783 |
|
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
784 |
if mark is not None: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
785 |
if "\n" in mark: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
786 |
raise util.Abort(_("bookmark name cannot contain newlines")) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
787 |
mark = mark.strip() |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
788 |
if not mark: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
789 |
raise util.Abort(_("bookmark names cannot consist entirely of " |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
790 |
"whitespace")) |
14189
328422b0380d
bookmarks: allow deactivating current bookmark with -i
Kevin Bullock <kbullock@ringworld.org>
parents:
14188
diff
changeset
|
791 |
if inactive and mark == repo._bookmarkcurrent: |
328422b0380d
bookmarks: allow deactivating current bookmark with -i
Kevin Bullock <kbullock@ringworld.org>
parents:
14188
diff
changeset
|
792 |
bookmarks.setcurrent(repo, None) |
328422b0380d
bookmarks: allow deactivating current bookmark with -i
Kevin Bullock <kbullock@ringworld.org>
parents:
14188
diff
changeset
|
793 |
return |
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
794 |
if mark in marks and not force: |
13911
6bc340940c18
bookmarks: change error messages to match those given by 'hg tag' commands
Idan Kamara <idankk86@gmail.com>
parents:
13899
diff
changeset
|
795 |
raise util.Abort(_("bookmark '%s' already exists " |
6bc340940c18
bookmarks: change error messages to match those given by 'hg tag' commands
Idan Kamara <idankk86@gmail.com>
parents:
13899
diff
changeset
|
796 |
"(use -f to force)") % mark) |
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
797 |
if ((mark in repo.branchtags() or mark == repo.dirstate.branch()) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
798 |
and not force): |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
799 |
raise util.Abort( |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
800 |
_("a bookmark cannot have the name of an existing branch")) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
801 |
if rev: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
802 |
marks[mark] = repo.lookup(rev) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
803 |
else: |
15491
c0e42b47ec1a
bookmark: remove excess creation of changectx's
Kevin Bullock <kbullock@ringworld.org>
parents:
15490
diff
changeset
|
804 |
marks[mark] = cur |
c0e42b47ec1a
bookmark: remove excess creation of changectx's
Kevin Bullock <kbullock@ringworld.org>
parents:
15490
diff
changeset
|
805 |
if not inactive and cur == marks[mark]: |
13448
97b69883e929
bookmarks: mark new bookmark as current if it points to the current dirstate
David Soria Parra <dsp@php.net>
parents:
13416
diff
changeset
|
806 |
bookmarks.setcurrent(repo, mark) |
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
807 |
bookmarks.write(repo) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
808 |
return |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
809 |
|
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
810 |
if mark is None: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
811 |
if rev: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
812 |
raise util.Abort(_("bookmark name required")) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
813 |
if len(marks) == 0: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
814 |
ui.status(_("no bookmarks set\n")) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
815 |
else: |
13388
a184dbd9b2c5
localrepo: sort hg bookmark output
David Soria Parra <dsp@php.net>
parents:
13368
diff
changeset
|
816 |
for bmark, n in sorted(marks.iteritems()): |
13416
5431b3f3e52e
bookmarks: make track.current=True default behaviour and remove option (BC)
David Soria Parra <dsp@php.net>
parents:
13415
diff
changeset
|
817 |
current = repo._bookmarkcurrent |
5431b3f3e52e
bookmarks: make track.current=True default behaviour and remove option (BC)
David Soria Parra <dsp@php.net>
parents:
13415
diff
changeset
|
818 |
if bmark == current and n == cur: |
5431b3f3e52e
bookmarks: make track.current=True default behaviour and remove option (BC)
David Soria Parra <dsp@php.net>
parents:
13415
diff
changeset
|
819 |
prefix, label = '*', 'bookmarks.current' |
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
820 |
else: |
13416
5431b3f3e52e
bookmarks: make track.current=True default behaviour and remove option (BC)
David Soria Parra <dsp@php.net>
parents:
13415
diff
changeset
|
821 |
prefix, label = ' ', '' |
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
822 |
|
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
823 |
if ui.quiet: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
824 |
ui.write("%s\n" % bmark, label=label) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
825 |
else: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
826 |
ui.write(" %s %-25s %d:%s\n" % ( |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
827 |
prefix, bmark, repo.changelog.rev(n), hexfn(n)), |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
828 |
label=label) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
829 |
return |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
830 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
831 |
@command('branch', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
832 |
[('f', 'force', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
833 |
_('set branch name even if it shadows an existing branch')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
834 |
('C', 'clean', None, _('reset branch name to parent branch name'))], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
835 |
_('[-fC] [NAME]')) |
4202
b2873c587b1a
branch: require --force to shadow existing branches
Brendan Cully <brendan@kublai.com>
parents:
4200
diff
changeset
|
836 |
def branch(ui, repo, label=None, **opts): |
3502
8dc14d630b29
add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents:
3472
diff
changeset
|
837 |
"""set or show the current branch name |
8dc14d630b29
add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents:
3472
diff
changeset
|
838 |
|
15610
09b200396384
branch: move note about permanence to the top, add 'global'
Matt Mackall <mpm@selenic.com>
parents:
15511
diff
changeset
|
839 |
.. note:: |
09b200396384
branch: move note about permanence to the top, add 'global'
Matt Mackall <mpm@selenic.com>
parents:
15511
diff
changeset
|
840 |
Branch names are permanent and global. Use :hg:`bookmark` to create a |
09b200396384
branch: move note about permanence to the top, add 'global'
Matt Mackall <mpm@selenic.com>
parents:
15511
diff
changeset
|
841 |
light-weight bookmark instead. See :hg:`help glossary` for more |
09b200396384
branch: move note about permanence to the top, add 'global'
Matt Mackall <mpm@selenic.com>
parents:
15511
diff
changeset
|
842 |
information about named branches and bookmarks. |
09b200396384
branch: move note about permanence to the top, add 'global'
Matt Mackall <mpm@selenic.com>
parents:
15511
diff
changeset
|
843 |
|
4601
e69da61e467e
Notify the user that hg branch does not create a branch until commit
Brendan Cully <brendan@kublai.com>
parents:
4593
diff
changeset
|
844 |
With no argument, show the current branch name. With one argument, |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
845 |
set the working directory branch name (the branch will not exist |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
846 |
in the repository until the next commit). Standard practice |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
847 |
recommends that primary development take place on the 'default' |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
848 |
branch. |
4202
b2873c587b1a
branch: require --force to shadow existing branches
Brendan Cully <brendan@kublai.com>
parents:
4200
diff
changeset
|
849 |
|
8033
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
850 |
Unless -f/--force is specified, branch will not let you set a |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
851 |
branch name that already exists, even if it's inactive. |
5999
d1fe1a4eb2b7
Mention 'hg update' to switch branches in help for branch and branches.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5998
diff
changeset
|
852 |
|
8033
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
853 |
Use -C/--clean to reset the working directory branch to that of |
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
854 |
the parent of the working directory, negating a previous branch |
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
855 |
change. |
7006
92d44ec32430
branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
7003
diff
changeset
|
856 |
|
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
857 |
Use the command :hg:`update` to switch to an existing branch. Use |
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
858 |
:hg:`commit --close-branch` to mark this branch as closed. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
859 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
860 |
Returns 0 on success. |
3502
8dc14d630b29
add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents:
3472
diff
changeset
|
861 |
""" |
8dc14d630b29
add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents:
3472
diff
changeset
|
862 |
|
7006
92d44ec32430
branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
7003
diff
changeset
|
863 |
if opts.get('clean'): |
13878
a8d13ee0ce68
misc: replace .parents()[0] with p1()
Matt Mackall <mpm@selenic.com>
parents:
13855
diff
changeset
|
864 |
label = repo[None].p1().branch() |
7006
92d44ec32430
branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
7003
diff
changeset
|
865 |
repo.dirstate.setbranch(label) |
92d44ec32430
branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
7003
diff
changeset
|
866 |
ui.status(_('reset working directory to branch %s\n') % label) |
92d44ec32430
branch: added more support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
7003
diff
changeset
|
867 |
elif label: |
13047
6c375e07d673
branch: operate on branch names in local string space where possible
Matt Mackall <mpm@selenic.com>
parents:
13022
diff
changeset
|
868 |
if not opts.get('force') and label in repo.branchtags(): |
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6746
diff
changeset
|
869 |
if label not in [p.branch() for p in repo.parents()]: |
14198
8f11fd321014
commands: use util.Abort's hint some more
Martin Geisler <mg@aragost.com>
parents:
14197
diff
changeset
|
870 |
raise util.Abort(_('a branch of the same name already exists'), |
14242
5ee1309f7edb
commands, i18n: add translation hint for split message
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
14238
diff
changeset
|
871 |
# i18n: "it" refers to an existing branch |
14198
8f11fd321014
commands: use util.Abort's hint some more
Martin Geisler <mg@aragost.com>
parents:
14197
diff
changeset
|
872 |
hint=_("use 'hg update' to switch to it")) |
13047
6c375e07d673
branch: operate on branch names in local string space where possible
Matt Mackall <mpm@selenic.com>
parents:
13022
diff
changeset
|
873 |
repo.dirstate.setbranch(label) |
4601
e69da61e467e
Notify the user that hg branch does not create a branch until commit
Brendan Cully <brendan@kublai.com>
parents:
4593
diff
changeset
|
874 |
ui.status(_('marked working directory as branch %s\n') % label) |
15615 | 875 |
ui.status(_('(branches are permanent and global, ' |
876 |
'did you want a bookmark?)\n')) |
|
3502
8dc14d630b29
add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents:
3472
diff
changeset
|
877 |
else: |
13047
6c375e07d673
branch: operate on branch names in local string space where possible
Matt Mackall <mpm@selenic.com>
parents:
13022
diff
changeset
|
878 |
ui.write("%s\n" % repo.dirstate.branch()) |
3502
8dc14d630b29
add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents:
3472
diff
changeset
|
879 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
880 |
@command('branches', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
881 |
[('a', 'active', False, _('show only branches that have unmerged heads')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
882 |
('c', 'closed', False, _('show normal and closed branches'))], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
883 |
_('[-ac]')) |
8991
7e0b31dfc66f
branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents:
8958
diff
changeset
|
884 |
def branches(ui, repo, active=False, closed=False): |
3502
8dc14d630b29
add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents:
3472
diff
changeset
|
885 |
"""list repository named branches |
8dc14d630b29
add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents:
3472
diff
changeset
|
886 |
|
4675
6858a7477a5e
Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents:
4667
diff
changeset
|
887 |
List the repository's named branches, indicating which ones are |
8991
7e0b31dfc66f
branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents:
8958
diff
changeset
|
888 |
inactive. If -c/--closed is specified, also list branches which have |
11193
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11185
diff
changeset
|
889 |
been marked closed (see :hg:`commit --close-branch`). |
8991
7e0b31dfc66f
branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents:
8958
diff
changeset
|
890 |
|
7e0b31dfc66f
branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents:
8958
diff
changeset
|
891 |
If -a/--active is specified, only show active branches. A branch |
7e0b31dfc66f
branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents:
8958
diff
changeset
|
892 |
is considered active if it contains repository heads. |
5999
d1fe1a4eb2b7
Mention 'hg update' to switch branches in help for branch and branches.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5998
diff
changeset
|
893 |
|
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
894 |
Use the command :hg:`update` to switch to an existing branch. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
895 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
896 |
Returns 0. |
3502
8dc14d630b29
add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents:
3472
diff
changeset
|
897 |
""" |
8991
7e0b31dfc66f
branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents:
8958
diff
changeset
|
898 |
|
6631
a2b13cac0922
Active branches fix (issue1104)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
6625
diff
changeset
|
899 |
hexfunc = ui.debugflag and hex or short |
9675
ee913987e4b0
localrepo/branchcache: remove lbranchmap(), convert users to use utf-8 names
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9665
diff
changeset
|
900 |
activebranches = [repo[n].branch() for n in repo.heads()] |
8796
2bcef677a6c3
localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
8779
diff
changeset
|
901 |
def testactive(tag, node): |
2bcef677a6c3
localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
8779
diff
changeset
|
902 |
realhead = tag in activebranches |
2bcef677a6c3
localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
8779
diff
changeset
|
903 |
open = node in repo.branchheads(tag, closed=False) |
2bcef677a6c3
localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
8779
diff
changeset
|
904 |
return realhead and open |
2bcef677a6c3
localrepo: remove 'closed' argument to heads(...) function
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
8779
diff
changeset
|
905 |
branches = sorted([(testactive(tag, node), repo.changelog.rev(node), tag) |
8210
344751cd8cb8
replace various uses of list.reverse()
Matt Mackall <mpm@selenic.com>
parents:
8209
diff
changeset
|
906 |
for tag, node in repo.branchtags().items()], |
344751cd8cb8
replace various uses of list.reverse()
Matt Mackall <mpm@selenic.com>
parents:
8209
diff
changeset
|
907 |
reverse=True) |
6631
a2b13cac0922
Active branches fix (issue1104)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
6625
diff
changeset
|
908 |
|
a2b13cac0922
Active branches fix (issue1104)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
6625
diff
changeset
|
909 |
for isactive, node, tag in branches: |
a2b13cac0922
Active branches fix (issue1104)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
6625
diff
changeset
|
910 |
if (not active) or isactive: |
4675
6858a7477a5e
Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents:
4667
diff
changeset
|
911 |
if ui.quiet: |
13047
6c375e07d673
branch: operate on branch names in local string space where possible
Matt Mackall <mpm@selenic.com>
parents:
13022
diff
changeset
|
912 |
ui.write("%s\n" % tag) |
4675
6858a7477a5e
Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents:
4667
diff
changeset
|
913 |
else: |
7656
6a24fb994701
branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
7655
diff
changeset
|
914 |
hn = repo.lookup(node) |
6a24fb994701
branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
7655
diff
changeset
|
915 |
if isactive: |
11969
52ec5c813723
color: enable branches support
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
11941
diff
changeset
|
916 |
label = 'branches.active' |
7656
6a24fb994701
branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
7655
diff
changeset
|
917 |
notice = '' |
6a24fb994701
branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
7655
diff
changeset
|
918 |
elif hn not in repo.branchheads(tag, closed=False): |
8991
7e0b31dfc66f
branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents:
8958
diff
changeset
|
919 |
if not closed: |
7e0b31dfc66f
branches: add --closed flag for consistency with heads
Matt Mackall <mpm@selenic.com>
parents:
8958
diff
changeset
|
920 |
continue |
11969
52ec5c813723
color: enable branches support
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
11941
diff
changeset
|
921 |
label = 'branches.closed' |
9951
9b626a63f556
commands: mark strings for translation
Martin Geisler <mg@lazybytes.net>
parents:
9894
diff
changeset
|
922 |
notice = _(' (closed)') |
7656
6a24fb994701
branch closing: referencing open and closed branches/heads
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
7655
diff
changeset
|
923 |
else: |
11969
52ec5c813723
color: enable branches support
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
11941
diff
changeset
|
924 |
label = 'branches.inactive' |
9951
9b626a63f556
commands: mark strings for translation
Martin Geisler <mg@lazybytes.net>
parents:
9894
diff
changeset
|
925 |
notice = _(' (inactive)') |
11969
52ec5c813723
color: enable branches support
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
11941
diff
changeset
|
926 |
if tag == repo.dirstate.branch(): |
52ec5c813723
color: enable branches support
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
11941
diff
changeset
|
927 |
label = 'branches.current' |
13047
6c375e07d673
branch: operate on branch names in local string space where possible
Matt Mackall <mpm@selenic.com>
parents:
13022
diff
changeset
|
928 |
rev = str(node).rjust(31 - encoding.colwidth(tag)) |
11969
52ec5c813723
color: enable branches support
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
11941
diff
changeset
|
929 |
rev = ui.label('%s:%s' % (rev, hexfunc(hn)), 'log.changeset') |
13047
6c375e07d673
branch: operate on branch names in local string space where possible
Matt Mackall <mpm@selenic.com>
parents:
13022
diff
changeset
|
930 |
tag = ui.label(tag, label) |
6c375e07d673
branch: operate on branch names in local string space where possible
Matt Mackall <mpm@selenic.com>
parents:
13022
diff
changeset
|
931 |
ui.write("%s %s%s\n" % (tag, rev, notice)) |
3502
8dc14d630b29
add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents:
3472
diff
changeset
|
932 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
933 |
@command('bundle', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
934 |
[('f', 'force', None, _('run even when the destination is unrelated')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
935 |
('r', 'rev', [], _('a changeset intended to be added to the destination'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
936 |
_('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
937 |
('b', 'branch', [], _('a specific branch you would like to bundle'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
938 |
_('BRANCH')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
939 |
('', 'base', [], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
940 |
_('a base changeset assumed to be available at the destination'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
941 |
_('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
942 |
('a', 'all', None, _('bundle all changesets in the repository')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
943 |
('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
944 |
] + remoteopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
945 |
_('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]')) |
2494
73ac95671788
push, outgoing, bundle: fall back to "default" if "default-push" not defined
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2493
diff
changeset
|
946 |
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
|
947 |
"""create a changegroup file |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
948 |
|
3511
aa8f086cb141
Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3510
diff
changeset
|
949 |
Generate a compressed changegroup file collecting changesets not |
7807
bd8f44638847
help: miscellaneous language fixes
timeless <timeless@gmail.com>
parents:
7765
diff
changeset
|
950 |
known to be in another repository. |
3511
aa8f086cb141
Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3510
diff
changeset
|
951 |
|
10376 | 952 |
If you omit the destination repository, then hg assumes the |
953 |
destination will have all the nodes you specify with --base |
|
6448
cd3d49ffc6f6
Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents:
6442
diff
changeset
|
954 |
parameters. To create a bundle containing all changesets, use |
8903
d403cf4eb32d
help: describe bundle compression methods (issue1523)
Henrik Stuart <hg@hstuart.dk>
parents:
8902
diff
changeset
|
955 |
-a/--all (or --base null). |
d403cf4eb32d
help: describe bundle compression methods (issue1523)
Henrik Stuart <hg@hstuart.dk>
parents:
8902
diff
changeset
|
956 |
|
8958
8358cf63f612
commands: improve bundle compression methods description
Stefano Mioli <jstevie@gmail.com>
parents:
8955
diff
changeset
|
957 |
You can change compression method with the -t/--type option. |
8358cf63f612
commands: improve bundle compression methods description
Stefano Mioli <jstevie@gmail.com>
parents:
8955
diff
changeset
|
958 |
The available compression methods are: none, bzip2, and |
8903
d403cf4eb32d
help: describe bundle compression methods (issue1523)
Henrik Stuart <hg@hstuart.dk>
parents:
8902
diff
changeset
|
959 |
gzip (by default, bundles are compressed using bzip2). |
3511
aa8f086cb141
Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3510
diff
changeset
|
960 |
|
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
961 |
The bundle file can then be transferred using conventional means |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
962 |
and applied to another repository with the unbundle or pull |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
963 |
command. This is useful when direct push and pull are not |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
964 |
available or when exporting an entire repository is undesirable. |
3511
aa8f086cb141
Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3510
diff
changeset
|
965 |
|
aa8f086cb141
Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3510
diff
changeset
|
966 |
Applying bundles preserves all changeset contents including |
aa8f086cb141
Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3510
diff
changeset
|
967 |
permissions, copy/rename information, and revision history. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
968 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
969 |
Returns 0 on success, 1 if no changes found. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
970 |
""" |
12925
6eab8f0df2ca
commands: add revset support to most commands
Matt Mackall <mpm@selenic.com>
parents:
12918
diff
changeset
|
971 |
revs = None |
6eab8f0df2ca
commands: add revset support to most commands
Matt Mackall <mpm@selenic.com>
parents:
12918
diff
changeset
|
972 |
if 'rev' in opts: |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
973 |
revs = scmutil.revrange(repo, opts['rev']) |
12925
6eab8f0df2ca
commands: add revset support to most commands
Matt Mackall <mpm@selenic.com>
parents:
12918
diff
changeset
|
974 |
|
6171
73b1de288801
Add --all option to bundle command
John Mulligan <phlogistonjohn@yahoo.com>
parents:
6163
diff
changeset
|
975 |
if opts.get('all'): |
73b1de288801
Add --all option to bundle command
John Mulligan <phlogistonjohn@yahoo.com>
parents:
6163
diff
changeset
|
976 |
base = ['null'] |
73b1de288801
Add --all option to bundle command
John Mulligan <phlogistonjohn@yahoo.com>
parents:
6163
diff
changeset
|
977 |
else: |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
978 |
base = scmutil.revrange(repo, opts.get('base')) |
3284
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
979 |
if base: |
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
980 |
if dest: |
8669
6f0f69da003e
commands: typo in bundle abort message
Martin Geisler <mg@lazybytes.net>
parents:
8664
diff
changeset
|
981 |
raise util.Abort(_("--base is incompatible with specifying " |
3284
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
982 |
"a destination")) |
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14064
diff
changeset
|
983 |
common = [repo.lookup(rev) for rev in base] |
15837
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15836
diff
changeset
|
984 |
heads = revs and map(repo.lookup, revs) or revs |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15836
diff
changeset
|
985 |
cg = repo.getbundle('bundle', heads=heads, common=common) |
15993
0b05e0bfdc1c
scmutil: unify some 'no changes found' messages
Matt Mackall <mpm@selenic.com>
parents:
15991
diff
changeset
|
986 |
outgoing = None |
3284
d89e98840b08
add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3278
diff
changeset
|
987 |
else: |
10365
d757bc0c7865
interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents:
10364
diff
changeset
|
988 |
dest = ui.expandpath(dest or 'default-push', dest or 'default') |
10379
a78bfaf988e1
add -b/--branch option to clone, bundle, incoming, outgoing, pull, push
Sune Foldager <cryo@cyanite.org>
parents:
10376
diff
changeset
|
989 |
dest, branches = hg.parseurl(dest, opts.get('branch')) |
14556
517e1d88bf7e
hg: change various repository() users to use peer() where appropriate
Matt Mackall <mpm@selenic.com>
parents:
14553
diff
changeset
|
990 |
other = hg.peer(repo, opts, dest) |
10365
d757bc0c7865
interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents:
10364
diff
changeset
|
991 |
revs, checkout = hg.addbranchrevs(repo, other, branches, revs) |
14213
30273f0c776b
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14198
diff
changeset
|
992 |
heads = revs and map(repo.lookup, revs) or revs |
15837
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15836
diff
changeset
|
993 |
outgoing = discovery.findcommonoutgoing(repo, other, |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15836
diff
changeset
|
994 |
onlyheads=heads, |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15836
diff
changeset
|
995 |
force=opts.get('force')) |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15836
diff
changeset
|
996 |
cg = repo.getlocalbundle('bundle', outgoing) |
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14064
diff
changeset
|
997 |
if not cg: |
15993
0b05e0bfdc1c
scmutil: unify some 'no changes found' messages
Matt Mackall <mpm@selenic.com>
parents:
15991
diff
changeset
|
998 |
scmutil.nochangesfound(ui, outgoing and outgoing.excluded) |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
999 |
return 1 |
10616
65b178f30eae
bundle: fix bundle generation for empty changegroup
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10596
diff
changeset
|
1000 |
|
6570
626cb86a6523
add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents:
6518
diff
changeset
|
1001 |
bundletype = opts.get('type', 'bzip2').lower() |
626cb86a6523
add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents:
6518
diff
changeset
|
1002 |
btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'} |
626cb86a6523
add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents:
6518
diff
changeset
|
1003 |
bundletype = btypes.get(bundletype) |
626cb86a6523
add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents:
6518
diff
changeset
|
1004 |
if bundletype not in changegroup.bundletypes: |
626cb86a6523
add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents:
6518
diff
changeset
|
1005 |
raise util.Abort(_('unknown bundle type specified with --type')) |
626cb86a6523
add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents:
6518
diff
changeset
|
1006 |
|
626cb86a6523
add compression type type parameter to bundle command
Benoit Allard <benoit@aeteurope.nl>
parents:
6518
diff
changeset
|
1007 |
changegroup.writebundle(cg, fname, bundletype) |
1218
cde6818e082a
Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents:
1215
diff
changeset
|
1008 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1009 |
@command('cat', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1010 |
[('o', 'output', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1011 |
_('print output to file with formatted name'), _('FORMAT')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1012 |
('r', 'rev', '', _('print the given revision'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1013 |
('', 'decode', None, _('apply any matching decode filter')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1014 |
] + walkopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1015 |
_('[OPTION]... FILE...')) |
1254
e6560042b7b8
Switch cat command to use walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1253
diff
changeset
|
1016 |
def cat(ui, repo, file1, *pats, **opts): |
3914
283ee8971570
doc string fix: hg cat and manifest default to current parent revision.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3900
diff
changeset
|
1017 |
"""output the current or given revision of files |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1018 |
|
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
1019 |
Print the specified files as they were at the given revision. If |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
1020 |
no revision is given, the parent of the working directory is used, |
3915
3c82ab166eea
doc fix: hg tags defaults to current parent revision, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3914
diff
changeset
|
1021 |
or tip 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
|
1022 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1023 |
Output may be to a file, in which case the name of the file is |
6448
cd3d49ffc6f6
Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents:
6442
diff
changeset
|
1024 |
given using a format string. The formatting rules are the same as |
9892
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
1025 |
for the export command, with the following additions: |
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
1026 |
|
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
1027 |
:``%s``: basename of file being printed |
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
1028 |
:``%d``: dirname of file being printed, or '.' if in repository root |
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
1029 |
:``%p``: root-relative path name of file being printed |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1030 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1031 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1032 |
""" |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
1033 |
ctx = scmutil.revsingle(repo, opts.get('rev')) |
4697
5b2d986de0f8
cat: return an error on failure
Matt Mackall <mpm@selenic.com>
parents:
4692
diff
changeset
|
1034 |
err = 1 |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
1035 |
m = scmutil.match(ctx, (file1,) + pats, opts) |
6764 | 1036 |
for abs in ctx.walk(m): |
14291
1a791993ce59
cmdutil: make_file to makefileobj
Matt Mackall <mpm@selenic.com>
parents:
14290
diff
changeset
|
1037 |
fp = cmdutil.makefileobj(repo, opts.get('output'), ctx.node(), |
1a791993ce59
cmdutil: make_file to makefileobj
Matt Mackall <mpm@selenic.com>
parents:
14290
diff
changeset
|
1038 |
pathname=abs) |
6764 | 1039 |
data = ctx[abs].data() |
6094
3998c1b0828f
cat --decode: Drop short option, use opts.get() instead of opts[]
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6093
diff
changeset
|
1040 |
if opts.get('decode'): |
6093
f5b00b6e426a
Option --decode for hg cat to apply decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
6068
diff
changeset
|
1041 |
data = repo.wwritedata(abs, data) |
f5b00b6e426a
Option --decode for hg cat to apply decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
6068
diff
changeset
|
1042 |
fp.write(data) |
13400
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13396
diff
changeset
|
1043 |
fp.close() |
4697
5b2d986de0f8
cat: return an error on failure
Matt Mackall <mpm@selenic.com>
parents:
4692
diff
changeset
|
1044 |
err = 0 |
5b2d986de0f8
cat: return an error on failure
Matt Mackall <mpm@selenic.com>
parents:
4692
diff
changeset
|
1045 |
return err |
248 | 1046 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1047 |
@command('^clone', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1048 |
[('U', 'noupdate', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1049 |
_('the clone will include an empty working copy (only a repository)')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1050 |
('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1051 |
('r', 'rev', [], _('include the specified changeset'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1052 |
('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1053 |
('', 'pull', None, _('use pull protocol to copy metadata')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1054 |
('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1055 |
] + remoteopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1056 |
_('[OPTION]... SOURCE [DEST]')) |
698
df78d8ccac4c
Use python function instead of external 'cp' command when cloning repos.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
697
diff
changeset
|
1057 |
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
|
1058 |
"""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
|
1059 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1060 |
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
|
1061 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1062 |
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
|
1063 |
basename of the source. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1064 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1065 |
The location of the source is added to the new repository's |
13344
6367459decf7
doc: Add back quotes around filenames
Javi Merino <cibervicho@gmail.com>
parents:
13343
diff
changeset
|
1066 |
``.hg/hgrc`` file, as the default to be used for future pulls. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1067 |
|
15177
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1068 |
Only local paths and ``ssh://`` URLs are supported as |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1069 |
destinations. For ``ssh://`` destinations, no working directory or |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1070 |
``.hg/hgrc`` will be created on the remote side. |
7942
553cef16031f
mention default branch in branch and clone help
Matt Mackall <mpm@selenic.com>
parents:
7880
diff
changeset
|
1071 |
|
15174
9f1a08c00931
clone: improve help on -r/-b and tags
Matt Mackall <mpm@selenic.com>
parents:
15147
diff
changeset
|
1072 |
To pull only a subset of changesets, specify one or more revisions |
9f1a08c00931
clone: improve help on -r/-b and tags
Matt Mackall <mpm@selenic.com>
parents:
15147
diff
changeset
|
1073 |
identifiers with -r/--rev or branches with -b/--branch. The |
9f1a08c00931
clone: improve help on -r/-b and tags
Matt Mackall <mpm@selenic.com>
parents:
15147
diff
changeset
|
1074 |
resulting clone will contain only the specified changesets and |
9f1a08c00931
clone: improve help on -r/-b and tags
Matt Mackall <mpm@selenic.com>
parents:
15147
diff
changeset
|
1075 |
their ancestors. These options (or 'clone src#rev dest') imply |
9f1a08c00931
clone: improve help on -r/-b and tags
Matt Mackall <mpm@selenic.com>
parents:
15147
diff
changeset
|
1076 |
--pull, even for local source repositories. Note that specifying a |
9f1a08c00931
clone: improve help on -r/-b and tags
Matt Mackall <mpm@selenic.com>
parents:
15147
diff
changeset
|
1077 |
tag will include the tagged changeset but not the changeset |
9f1a08c00931
clone: improve help on -r/-b and tags
Matt Mackall <mpm@selenic.com>
parents:
15147
diff
changeset
|
1078 |
containing the tag. |
9714
2f1ab7f77ddc
clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents:
9698
diff
changeset
|
1079 |
|
15178
04e5449e25dc
clone: add a note about -u/-U
Matt Mackall <mpm@selenic.com>
parents:
15177
diff
changeset
|
1080 |
To check out a particular version, use -u/--update, or |
04e5449e25dc
clone: add a note about -u/-U
Matt Mackall <mpm@selenic.com>
parents:
15177
diff
changeset
|
1081 |
-U/--noupdate to create a clone with no working directory. |
04e5449e25dc
clone: add a note about -u/-U
Matt Mackall <mpm@selenic.com>
parents:
15177
diff
changeset
|
1082 |
|
15177
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1083 |
.. container:: verbose |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1084 |
|
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1085 |
For efficiency, hardlinks are used for cloning whenever the |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1086 |
source and destination are on the same filesystem (note this |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1087 |
applies only to the repository data, not to the working |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1088 |
directory). Some filesystems, such as AFS, implement hardlinking |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1089 |
incorrectly, but do not report errors. In these cases, use the |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1090 |
--pull option to avoid hardlinking. |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1091 |
|
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1092 |
In some cases, you can clone repositories and the working |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1093 |
directory using full hardlinks with :: |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1094 |
|
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1095 |
$ cp -al REPO REPOCLONE |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1096 |
|
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1097 |
This is the fastest way to clone, but it is not always safe. The |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1098 |
operation is not atomic (making sure REPO is not modified during |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1099 |
the operation is up to you) and you have to make sure your |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1100 |
editor breaks hardlinks (Emacs and most Linux Kernel tools do |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1101 |
so). Also, this is not compatible with certain extensions that |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1102 |
place their metadata under the .hg directory, such as mq. |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1103 |
|
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1104 |
Mercurial will update the working directory to the first applicable |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1105 |
revision from this list: |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1106 |
|
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1107 |
a) null if -U or the source repository has no changesets |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1108 |
b) if -u . and the source repository is local, the first parent of |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1109 |
the source repository's working directory |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1110 |
c) the changeset specified with -u (if a branch name, this means the |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1111 |
latest head of that branch) |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1112 |
d) the changeset specified with -r |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1113 |
e) the tipmost head specified with -b |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1114 |
f) the tipmost head specified with the url#branch source syntax |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1115 |
g) the tipmost head of the default branch |
1c57d8b38d5a
clone: move portions of help into the verbose section
Matt Mackall <mpm@selenic.com>
parents:
15175
diff
changeset
|
1116 |
h) tip |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1117 |
|
15179 | 1118 |
Examples: |
1119 |
||
1120 |
- clone a remote repository to a new directory named hg/:: |
|
1121 |
||
1122 |
hg clone http://selenic.com/hg |
|
1123 |
||
1124 |
- create a lightweight local clone:: |
|
1125 |
||
1126 |
hg clone project/ project-feature/ |
|
1127 |
||
1128 |
- clone from an absolute path on an ssh server (note double-slash):: |
|
1129 |
||
1130 |
hg clone ssh://user@server//home/projects/alpha/ |
|
1131 |
||
1132 |
- do a high-speed clone over a LAN while checking out a |
|
1133 |
specified version:: |
|
1134 |
||
1135 |
hg clone --uncompressed http://server/repo -u 1.5 |
|
1136 |
||
1137 |
- create a repository without changesets after a particular revision:: |
|
1138 |
||
1139 |
hg clone -r 04e544 experimental/ good/ |
|
1140 |
||
1141 |
- clone (and track) a particular named branch:: |
|
1142 |
||
1143 |
hg clone http://selenic.com/hg#stable |
|
1144 |
||
15175
282db9102c43
clone: move url crossref to bottom
Matt Mackall <mpm@selenic.com>
parents:
15174
diff
changeset
|
1145 |
See :hg:`help urls` for details on specifying URLs. |
282db9102c43
clone: move url crossref to bottom
Matt Mackall <mpm@selenic.com>
parents:
15174
diff
changeset
|
1146 |
|
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1147 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1148 |
""" |
9714
2f1ab7f77ddc
clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents:
9698
diff
changeset
|
1149 |
if opts.get('noupdate') and opts.get('updaterev'): |
2f1ab7f77ddc
clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents:
9698
diff
changeset
|
1150 |
raise util.Abort(_("cannot specify both --noupdate and --updaterev")) |
2f1ab7f77ddc
clone: add option -u/--updaterev
Adrian Buehlmann <adrian@cadifra.com>
parents:
9698
diff
changeset
|
1151 |
|
14553
d976542986d2
hg: add opts argument to clone for internal remoteui
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14551
diff
changeset
|
1152 |
r = hg.clone(ui, opts, source, dest, |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1153 |
pull=opts.get('pull'), |
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1154 |
stream=opts.get('uncompressed'), |
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1155 |
rev=opts.get('rev'), |
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1156 |
update=opts.get('updaterev') or not opts.get('noupdate'), |
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1157 |
branch=opts.get('branch')) |
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1158 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1159 |
return r is None |
515 | 1160 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1161 |
@command('^commit|ci', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1162 |
[('A', 'addremove', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1163 |
_('mark new/missing files as added/removed before committing')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1164 |
('', 'close-branch', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1165 |
_('mark a branch as closed, hiding it from the branch list')), |
15321
e174353e8cda
subrepos: abort commit by default if a subrepo is dirty (BC)
Martin Geisler <mg@lazybytes.net>
parents:
15307
diff
changeset
|
1166 |
] + walkopts + commitopts + commitopts2 + subrepoopts, |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1167 |
_('[OPTION]... [FILE]...')) |
813
80fd2958235a
Adapt commit to use file matching code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
812
diff
changeset
|
1168 |
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
|
1169 |
"""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
|
1170 |
|
7983
7b813bdbd5d0
Change double spaces to single spaces in help texts.
Martin Geisler <mg@daimi.au.dk>
parents:
7982
diff
changeset
|
1171 |
Commit changes to the given files into the repository. Unlike a |
13303
716ce1ea6fec
commit: use the term SCM instead of RCS
Adrian Buehlmann <adrian@cadifra.com>
parents:
13235
diff
changeset
|
1172 |
centralized SCM, this operation is a local operation. See |
11193
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11185
diff
changeset
|
1173 |
:hg:`push` for a way to actively distribute your changes. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1174 |
|
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
1175 |
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
|
1176 |
will be committed. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1177 |
|
6385
0d4e068e9e52
commit: when committing the results of a merge, it's all or nothing
Bryan O'Sullivan <bos@serpentine.com>
parents:
6375
diff
changeset
|
1178 |
If you are committing the result of a merge, do not provide any |
8761
0289f384e1e5
Generally replace "file name" with "filename" in help and comments.
timeless <timeless@gmail.com>
parents:
8760
diff
changeset
|
1179 |
filenames or -I/-X filters. |
6385
0d4e068e9e52
commit: when committing the results of a merge, it's all or nothing
Bryan O'Sullivan <bos@serpentine.com>
parents:
6375
diff
changeset
|
1180 |
|
11877
8f40125a0ed8
commit: explicitly document the existence of "last-message.txt"
Greg Ward <greg-hg@gerg.ca>
parents:
11836
diff
changeset
|
1181 |
If no commit message is specified, Mercurial starts your |
8f40125a0ed8
commit: explicitly document the existence of "last-message.txt"
Greg Ward <greg-hg@gerg.ca>
parents:
11836
diff
changeset
|
1182 |
configured editor where you can enter a message. In case your |
8f40125a0ed8
commit: explicitly document the existence of "last-message.txt"
Greg Ward <greg-hg@gerg.ca>
parents:
11836
diff
changeset
|
1183 |
commit fails, you will find a backup of your message in |
8f40125a0ed8
commit: explicitly document the existence of "last-message.txt"
Greg Ward <greg-hg@gerg.ca>
parents:
11836
diff
changeset
|
1184 |
``.hg/last-message.txt``. |
6163
1f733c2f0165
Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6161
diff
changeset
|
1185 |
|
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
1186 |
See :hg:`help dates` for a list of formats valid for -d/--date. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1187 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1188 |
Returns 0 on success, 1 if nothing changed. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1189 |
""" |
15321
e174353e8cda
subrepos: abort commit by default if a subrepo is dirty (BC)
Martin Geisler <mg@lazybytes.net>
parents:
15307
diff
changeset
|
1190 |
if opts.get('subrepos'): |
e174353e8cda
subrepos: abort commit by default if a subrepo is dirty (BC)
Martin Geisler <mg@lazybytes.net>
parents:
15307
diff
changeset
|
1191 |
# Let --subrepos on the command line overide config setting. |
e174353e8cda
subrepos: abort commit by default if a subrepo is dirty (BC)
Martin Geisler <mg@lazybytes.net>
parents:
15307
diff
changeset
|
1192 |
ui.setconfig('ui', 'commitsubrepos', True) |
e174353e8cda
subrepos: abort commit by default if a subrepo is dirty (BC)
Martin Geisler <mg@lazybytes.net>
parents:
15307
diff
changeset
|
1193 |
|
7655
cce37dab7ad6
branch closing: mark closed branches with a 'close' extra
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
7643
diff
changeset
|
1194 |
extra = {} |
cce37dab7ad6
branch closing: mark closed branches with a 'close' extra
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
7643
diff
changeset
|
1195 |
if opts.get('close_branch'): |
11163
acd61dc44a39
commit: prevent closing non-head changesets
Gilles Moris <gilles.moris@free.fr>
parents:
11104
diff
changeset
|
1196 |
if repo['.'].node() not in repo.branchheads(): |
acd61dc44a39
commit: prevent closing non-head changesets
Gilles Moris <gilles.moris@free.fr>
parents:
11104
diff
changeset
|
1197 |
# The topo heads set is included in the branch heads set of the |
acd61dc44a39
commit: prevent closing non-head changesets
Gilles Moris <gilles.moris@free.fr>
parents:
11104
diff
changeset
|
1198 |
# current branch, so it's sufficient to test branchheads |
acd61dc44a39
commit: prevent closing non-head changesets
Gilles Moris <gilles.moris@free.fr>
parents:
11104
diff
changeset
|
1199 |
raise util.Abort(_('can only close branch heads')) |
7655
cce37dab7ad6
branch closing: mark closed branches with a 'close' extra
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
7643
diff
changeset
|
1200 |
extra['close'] = 1 |
8407
223000a687b0
commit: move commit editor to cmdutil, pass as function
Matt Mackall <mpm@selenic.com>
parents:
8397
diff
changeset
|
1201 |
e = cmdutil.commiteditor |
223000a687b0
commit: move commit editor to cmdutil, pass as function
Matt Mackall <mpm@selenic.com>
parents:
8397
diff
changeset
|
1202 |
if opts.get('force_editor'): |
223000a687b0
commit: move commit editor to cmdutil, pass as function
Matt Mackall <mpm@selenic.com>
parents:
8397
diff
changeset
|
1203 |
e = cmdutil.commitforceeditor |
223000a687b0
commit: move commit editor to cmdutil, pass as function
Matt Mackall <mpm@selenic.com>
parents:
8397
diff
changeset
|
1204 |
|
6600
b822a379860b
match: stop passing files through commitfunc
Matt Mackall <mpm@selenic.com>
parents:
6599
diff
changeset
|
1205 |
def commitfunc(ui, repo, message, match, opts): |
8706
25e9c71b89de
commit: drop the now-unused files parameter
Matt Mackall <mpm@selenic.com>
parents:
8704
diff
changeset
|
1206 |
return repo.commit(message, opts.get('user'), opts.get('date'), match, |
25e9c71b89de
commit: drop the now-unused files parameter
Matt Mackall <mpm@selenic.com>
parents:
8704
diff
changeset
|
1207 |
editor=e, extra=extra) |
6336
4b0c9c674707
warn about new heads on commit (issue842)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6321
diff
changeset
|
1208 |
|
11173
5b48d819d5f9
commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents:
11169
diff
changeset
|
1209 |
branch = repo[None].branch() |
5b48d819d5f9
commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents:
11169
diff
changeset
|
1210 |
bheads = repo.branchheads(branch) |
5b48d819d5f9
commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents:
11169
diff
changeset
|
1211 |
|
6369
53912d30ac40
Avoid calling heads() twice on every hg commit.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6367
diff
changeset
|
1212 |
node = cmdutil.commit(ui, repo, commitfunc, pats, opts) |
53912d30ac40
Avoid calling heads() twice on every hg commit.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6367
diff
changeset
|
1213 |
if not node: |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
1214 |
stat = repo.status(match=scmutil.match(repo[None], pats, opts)) |
13899
a7cd0eee396b
commit: note when files are missing
Martin Geisler <mg@aragost.com>
parents:
13893
diff
changeset
|
1215 |
if stat[3]: |
a7cd0eee396b
commit: note when files are missing
Martin Geisler <mg@aragost.com>
parents:
13893
diff
changeset
|
1216 |
ui.status(_("nothing changed (%d missing files, see 'hg status')\n") |
a7cd0eee396b
commit: note when files are missing
Martin Geisler <mg@aragost.com>
parents:
13893
diff
changeset
|
1217 |
% len(stat[3])) |
a7cd0eee396b
commit: note when files are missing
Martin Geisler <mg@aragost.com>
parents:
13893
diff
changeset
|
1218 |
else: |
a7cd0eee396b
commit: note when files are missing
Martin Geisler <mg@aragost.com>
parents:
13893
diff
changeset
|
1219 |
ui.status(_("nothing changed\n")) |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1220 |
return 1 |
11173
5b48d819d5f9
commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents:
11169
diff
changeset
|
1221 |
|
5b48d819d5f9
commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents:
11169
diff
changeset
|
1222 |
ctx = repo[node] |
5b48d819d5f9
commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents:
11169
diff
changeset
|
1223 |
parents = ctx.parents() |
5b48d819d5f9
commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents:
11169
diff
changeset
|
1224 |
|
14874
d7b424a03627
commit: suppress spurious new head message for duplicate commit (issue2893)
Matt Mackall <mpm@selenic.com>
parents:
14853
diff
changeset
|
1225 |
if (bheads and node not in bheads and not |
d7b424a03627
commit: suppress spurious new head message for duplicate commit (issue2893)
Matt Mackall <mpm@selenic.com>
parents:
14853
diff
changeset
|
1226 |
[x for x in parents if x.node() in bheads and x.branch() == branch]): |
6336
4b0c9c674707
warn about new heads on commit (issue842)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6321
diff
changeset
|
1227 |
ui.status(_('created new head\n')) |
11317
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1228 |
# The message is not printed for initial roots. For the other |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1229 |
# changesets, it is printed in the following situations: |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1230 |
# |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1231 |
# Par column: for the 2 parents with ... |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1232 |
# N: null or no parent |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1233 |
# B: parent is on another named branch |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1234 |
# C: parent is a regular non head changeset |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1235 |
# H: parent was a branch head of the current branch |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1236 |
# Msg column: whether we print "created new head" message |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1237 |
# In the following, it is assumed that there already exists some |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1238 |
# initial branch heads of the current branch, otherwise nothing is |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1239 |
# printed anyway. |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1240 |
# |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1241 |
# Par Msg Comment |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1242 |
# NN y additional topo root |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1243 |
# |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1244 |
# BN y additional branch root |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1245 |
# CN y additional topo head |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1246 |
# HN n usual case |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1247 |
# |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1248 |
# BB y weird additional branch root |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1249 |
# CB y branch merge |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1250 |
# HB n merge with named branch |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1251 |
# |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1252 |
# CC y additional head from merge |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1253 |
# CH n merge with a head |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1254 |
# |
b66e414d38b0
commit: fix display of 'created new head' message (issue2186)
Gilles Moris <gilles.moris@free.fr>
parents:
11311
diff
changeset
|
1255 |
# HH n head merge: head count decreases |
245 | 1256 |
|
11164
e84600b0d81b
commit: inform the commiter when resurrecting a closed changeset
Gilles Moris <gilles.moris@free.fr>
parents:
11163
diff
changeset
|
1257 |
if not opts.get('close_branch'): |
e84600b0d81b
commit: inform the commiter when resurrecting a closed changeset
Gilles Moris <gilles.moris@free.fr>
parents:
11163
diff
changeset
|
1258 |
for r in parents: |
11515
cc982ff2dcf8
commands: only warn when reopening the workdir's branch
Robert Bauck Hamar <r.b.hamar@usit.uio.no>
parents:
11508
diff
changeset
|
1259 |
if r.extra().get('close') and r.branch() == branch: |
11164
e84600b0d81b
commit: inform the commiter when resurrecting a closed changeset
Gilles Moris <gilles.moris@free.fr>
parents:
11163
diff
changeset
|
1260 |
ui.status(_('reopening closed branch head %d\n') % r) |
e84600b0d81b
commit: inform the commiter when resurrecting a closed changeset
Gilles Moris <gilles.moris@free.fr>
parents:
11163
diff
changeset
|
1261 |
|
6935
03916abdfb64
Have verbose and debug flag print the changeset rev and hash when committing.
Gilles Moris <gilles.moris@free.fr>
parents:
6934
diff
changeset
|
1262 |
if ui.debugflag: |
11173
5b48d819d5f9
commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents:
11169
diff
changeset
|
1263 |
ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx.hex())) |
6935
03916abdfb64
Have verbose and debug flag print the changeset rev and hash when committing.
Gilles Moris <gilles.moris@free.fr>
parents:
6934
diff
changeset
|
1264 |
elif ui.verbose: |
11173
5b48d819d5f9
commit: note new branch heads rather than topological heads
Matt Mackall <mpm@selenic.com>
parents:
11169
diff
changeset
|
1265 |
ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx)) |
6935
03916abdfb64
Have verbose and debug flag print the changeset rev and hash when committing.
Gilles Moris <gilles.moris@free.fr>
parents:
6934
diff
changeset
|
1266 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1267 |
@command('copy|cp', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1268 |
[('A', 'after', None, _('record a copy that has already occurred')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1269 |
('f', 'force', None, _('forcibly copy over an existing managed file')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1270 |
] + walkopts + dryrunopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1271 |
_('[OPTION]... [SOURCE]... DEST')) |
1253
a45e717c61a8
Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1250
diff
changeset
|
1272 |
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
|
1273 |
"""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
|
1274 |
|
6448
cd3d49ffc6f6
Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents:
6442
diff
changeset
|
1275 |
Mark dest as having copies of source files. If dest is a |
cd3d49ffc6f6
Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents:
6442
diff
changeset
|
1276 |
directory, copies are put in that directory. If dest is a file, |
7807
bd8f44638847
help: miscellaneous language fixes
timeless <timeless@gmail.com>
parents:
7765
diff
changeset
|
1277 |
the source must be a single file. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1278 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1279 |
By default, this command copies the contents of files as they |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
1280 |
exist in the working directory. If invoked with -A/--after, the |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1281 |
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
|
1282 |
|
7807
bd8f44638847
help: miscellaneous language fixes
timeless <timeless@gmail.com>
parents:
7765
diff
changeset
|
1283 |
This command takes effect with the next commit. To undo a copy |
11193
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11185
diff
changeset
|
1284 |
before that, see :hg:`revert`. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1285 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1286 |
Returns 0 on success, 1 if errors are encountered. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
1287 |
""" |
4914 | 1288 |
wlock = repo.wlock(False) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
1289 |
try: |
5610
2493a478f395
copy: handle rename internally
Matt Mackall <mpm@selenic.com>
parents:
5589
diff
changeset
|
1290 |
return cmdutil.copy(ui, repo, pats, opts) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
1291 |
finally: |
8109
496ae1ea4698
switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8088
diff
changeset
|
1292 |
wlock.release() |
363 | 1293 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1294 |
@command('debugancestor', [], _('[INDEX] REV1 REV2')) |
6189
81cbb5dfdec0
Make hg debugancestor accept -R by making it an optionalrepo command.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6188
diff
changeset
|
1295 |
def debugancestor(ui, repo, *args): |
1262 | 1296 |
"""find the ancestor revision of two revisions in a given index""" |
6188
3b0c2b71e0d7
debugancestor: use *args instead of *opts, to not confuse with option dicts.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6182
diff
changeset
|
1297 |
if len(args) == 3: |
3b0c2b71e0d7
debugancestor: use *args instead of *opts, to not confuse with option dicts.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6182
diff
changeset
|
1298 |
index, rev1, rev2 = args |
13970
d13913355390
move opener from util to scmutil
Adrian Buehlmann <adrian@cadifra.com>
parents:
13965
diff
changeset
|
1299 |
r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index) |
6253
a7e3d0456d92
debugancestor: use repo.lookup when no revlog was specified
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6243
diff
changeset
|
1300 |
lookup = r.lookup |
6188
3b0c2b71e0d7
debugancestor: use *args instead of *opts, to not confuse with option dicts.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6182
diff
changeset
|
1301 |
elif len(args) == 2: |
6189
81cbb5dfdec0
Make hg debugancestor accept -R by making it an optionalrepo command.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6188
diff
changeset
|
1302 |
if not repo: |
12067
a4fbbe0fbc38
Lowercase error messages
Martin Geisler <mg@lazybytes.net>
parents:
11881
diff
changeset
|
1303 |
raise util.Abort(_("there is no Mercurial repository here " |
6189
81cbb5dfdec0
Make hg debugancestor accept -R by making it an optionalrepo command.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6188
diff
changeset
|
1304 |
"(.hg not found)")) |
6188
3b0c2b71e0d7
debugancestor: use *args instead of *opts, to not confuse with option dicts.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6182
diff
changeset
|
1305 |
rev1, rev2 = args |
6178
81afdd016867
debugancestor: make the index argument optional, defaulting to 00changelog.i
Bryan O'Sullivan <bos@serpentine.com>
parents:
6171
diff
changeset
|
1306 |
r = repo.changelog |
6253
a7e3d0456d92
debugancestor: use repo.lookup when no revlog was specified
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6243
diff
changeset
|
1307 |
lookup = repo.lookup |
6178
81afdd016867
debugancestor: make the index argument optional, defaulting to 00changelog.i
Bryan O'Sullivan <bos@serpentine.com>
parents:
6171
diff
changeset
|
1308 |
else: |
81afdd016867
debugancestor: make the index argument optional, defaulting to 00changelog.i
Bryan O'Sullivan <bos@serpentine.com>
parents:
6171
diff
changeset
|
1309 |
raise util.Abort(_('either two or three arguments required')) |
6253
a7e3d0456d92
debugancestor: use repo.lookup when no revlog was specified
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6243
diff
changeset
|
1310 |
a = r.ancestor(lookup(rev1), lookup(rev2)) |
1262 | 1311 |
ui.write("%d:%s\n" % (r.rev(a), hex(a))) |
1312 |
||
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1313 |
@command('debugbuilddag', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1314 |
[('m', 'mergeable-file', None, _('add single file mergeable changes')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1315 |
('o', 'overwritten-file', None, _('add single file all revs overwrite')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1316 |
('n', 'new-file', None, _('add new file at each rev'))], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1317 |
_('[OPTION]... [TEXT]')) |
14283
035489c9ea53
debugbuilddag: read DAG from stdin if not given on cmdline
Martin Geisler <mg@aragost.com>
parents:
14279
diff
changeset
|
1318 |
def debugbuilddag(ui, repo, text=None, |
11337
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1319 |
mergeable_file=False, |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1320 |
overwritten_file=False, |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1321 |
new_file=False): |
14283
035489c9ea53
debugbuilddag: read DAG from stdin if not given on cmdline
Martin Geisler <mg@aragost.com>
parents:
14279
diff
changeset
|
1322 |
"""builds a repo with a given DAG from scratch in the current empty repo |
035489c9ea53
debugbuilddag: read DAG from stdin if not given on cmdline
Martin Geisler <mg@aragost.com>
parents:
14279
diff
changeset
|
1323 |
|
035489c9ea53
debugbuilddag: read DAG from stdin if not given on cmdline
Martin Geisler <mg@aragost.com>
parents:
14279
diff
changeset
|
1324 |
The description of the DAG is read from stdin if not given on the |
035489c9ea53
debugbuilddag: read DAG from stdin if not given on cmdline
Martin Geisler <mg@aragost.com>
parents:
14279
diff
changeset
|
1325 |
command line. |
11337
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1326 |
|
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1327 |
Elements: |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1328 |
|
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1329 |
- "+n" is a linear run of n nodes based on the current default parent |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1330 |
- "." is a single node based on the current default parent |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1331 |
- "$" resets the default parent to null (implied at the start); |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1332 |
otherwise the default parent is always the last node created |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1333 |
- "<p" sets the default parent to the backref p |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1334 |
- "*p" is a fork at parent p, which is a backref |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1335 |
- "*p1/p2" is a merge of parents p1 and p2, which are backrefs |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1336 |
- "/p2" is a merge of the preceding node and p2 |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1337 |
- ":tag" defines a local tag for the preceding node |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1338 |
- "@branch" sets the named branch for subsequent nodes |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1339 |
- "#...\\n" is a comment up to the end of the line |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1340 |
|
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1341 |
Whitespace between the above elements is ignored. |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1342 |
|
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1343 |
A backref is either |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1344 |
|
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1345 |
- a number n, which references the node curr-n, where curr is the current |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1346 |
node, or |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1347 |
- the name of a local tag you placed earlier using ":tag", or |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1348 |
- empty to denote the default parent. |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1349 |
|
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1350 |
All string valued-elements are either strictly alphanumeric, or must |
11881
2da0cf99b642
debugbuilddag: escape backslash properly in help string
Martin Geisler <mg@lazybytes.net>
parents:
11877
diff
changeset
|
1351 |
be enclosed in double quotes ("..."), with "\\" as escape character. |
11337
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1352 |
""" |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1353 |
|
14283
035489c9ea53
debugbuilddag: read DAG from stdin if not given on cmdline
Martin Geisler <mg@aragost.com>
parents:
14279
diff
changeset
|
1354 |
if text is None: |
035489c9ea53
debugbuilddag: read DAG from stdin if not given on cmdline
Martin Geisler <mg@aragost.com>
parents:
14279
diff
changeset
|
1355 |
ui.status(_("reading DAG from stdin\n")) |
14639
e59a7b8f521a
commands: use ui descriptors when reading/writing from stdin/out
Idan Kamara <idankk86@gmail.com>
parents:
14635
diff
changeset
|
1356 |
text = ui.fin.read() |
14283
035489c9ea53
debugbuilddag: read DAG from stdin if not given on cmdline
Martin Geisler <mg@aragost.com>
parents:
14279
diff
changeset
|
1357 |
|
14163
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1358 |
cl = repo.changelog |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1359 |
if len(cl) > 0: |
11342
aecabad8dd7a
commands: get rid of generic exception in debugbuilddag
Martin Geisler <mg@aragost.com>
parents:
11338
diff
changeset
|
1360 |
raise util.Abort(_('repository is not empty')) |
11337
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1361 |
|
14279
b039b667515d
debugbuilddag: output progress information
Martin Geisler <mg@aragost.com>
parents:
14271
diff
changeset
|
1362 |
# determine number of revs in DAG |
b039b667515d
debugbuilddag: output progress information
Martin Geisler <mg@aragost.com>
parents:
14271
diff
changeset
|
1363 |
total = 0 |
b039b667515d
debugbuilddag: output progress information
Martin Geisler <mg@aragost.com>
parents:
14271
diff
changeset
|
1364 |
for type, data in dagparser.parsedag(text): |
b039b667515d
debugbuilddag: output progress information
Martin Geisler <mg@aragost.com>
parents:
14271
diff
changeset
|
1365 |
if type == 'n': |
b039b667515d
debugbuilddag: output progress information
Martin Geisler <mg@aragost.com>
parents:
14271
diff
changeset
|
1366 |
total += 1 |
11337
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1367 |
|
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1368 |
if mergeable_file: |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1369 |
linesperrev = 2 |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1370 |
# make a file with k lines per rev |
14279
b039b667515d
debugbuilddag: output progress information
Martin Geisler <mg@aragost.com>
parents:
14271
diff
changeset
|
1371 |
initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)] |
14163
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1372 |
initialmergedlines.append("") |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1373 |
|
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1374 |
tags = [] |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1375 |
|
15875
7eca9db689d6
debugbuilddag: lock repo before starting transaction
Mads Kiilerich <mads@kiilerich.com>
parents:
15862
diff
changeset
|
1376 |
lock = tr = None |
14163
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1377 |
try: |
15875
7eca9db689d6
debugbuilddag: lock repo before starting transaction
Mads Kiilerich <mads@kiilerich.com>
parents:
15862
diff
changeset
|
1378 |
lock = repo.lock() |
7eca9db689d6
debugbuilddag: lock repo before starting transaction
Mads Kiilerich <mads@kiilerich.com>
parents:
15862
diff
changeset
|
1379 |
tr = repo.transaction("builddag") |
14163
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1380 |
|
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1381 |
at = -1 |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1382 |
atbranch = 'default' |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1383 |
nodeids = [] |
16219
28c5648771d1
debugbuilddag: fix starting a dag on a non-default branch
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
16191
diff
changeset
|
1384 |
id = 0 |
28c5648771d1
debugbuilddag: fix starting a dag on a non-default branch
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
16191
diff
changeset
|
1385 |
ui.progress(_('building'), id, unit=_('revisions'), total=total) |
11337
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1386 |
for type, data in dagparser.parsedag(text): |
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1387 |
if type == 'n': |
14163
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1388 |
ui.note('node %s\n' % str(data)) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1389 |
id, ps = data |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1390 |
|
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1391 |
files = [] |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1392 |
fctxs = {} |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1393 |
|
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1394 |
p2 = None |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1395 |
if mergeable_file: |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1396 |
fn = "mf" |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1397 |
p1 = repo[ps[0]] |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1398 |
if len(ps) > 1: |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1399 |
p2 = repo[ps[1]] |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1400 |
pa = p1.ancestor(p2) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1401 |
base, local, other = [x[fn].data() for x in pa, p1, p2] |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1402 |
m3 = simplemerge.Merge3Text(base, local, other) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1403 |
ml = [l.strip() for l in m3.merge_lines()] |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1404 |
ml.append("") |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1405 |
elif at > 0: |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1406 |
ml = p1[fn].data().split("\n") |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1407 |
else: |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1408 |
ml = initialmergedlines |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1409 |
ml[id * linesperrev] += " r%i" % id |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1410 |
mergedtext = "\n".join(ml) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1411 |
files.append(fn) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1412 |
fctxs[fn] = context.memfilectx(fn, mergedtext) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1413 |
|
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1414 |
if overwritten_file: |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1415 |
fn = "of" |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1416 |
files.append(fn) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1417 |
fctxs[fn] = context.memfilectx(fn, "r%i\n" % id) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1418 |
|
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1419 |
if new_file: |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1420 |
fn = "nf%i" % id |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1421 |
files.append(fn) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1422 |
fctxs[fn] = context.memfilectx(fn, "r%i\n" % id) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1423 |
if len(ps) > 1: |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1424 |
if not p2: |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1425 |
p2 = repo[ps[1]] |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1426 |
for fn in p2: |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1427 |
if fn.startswith("nf"): |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1428 |
files.append(fn) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1429 |
fctxs[fn] = p2[fn] |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1430 |
|
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1431 |
def fctxfn(repo, cx, path): |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1432 |
return fctxs.get(path) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1433 |
|
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1434 |
if len(ps) == 0 or ps[0] < 0: |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1435 |
pars = [None, None] |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1436 |
elif len(ps) == 1: |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1437 |
pars = [nodeids[ps[0]], None] |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1438 |
else: |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1439 |
pars = [nodeids[p] for p in ps] |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1440 |
cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn, |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1441 |
date=(id, 0), |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1442 |
user="debugbuilddag", |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1443 |
extra={'branch': atbranch}) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1444 |
nodeid = repo.commitctx(cx) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1445 |
nodeids.append(nodeid) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1446 |
at = id |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1447 |
elif type == 'l': |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1448 |
id, name = data |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1449 |
ui.note('tag %s\n' % name) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1450 |
tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name)) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1451 |
elif type == 'a': |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1452 |
ui.note('branch %s\n' % data) |
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1453 |
atbranch = data |
14279
b039b667515d
debugbuilddag: output progress information
Martin Geisler <mg@aragost.com>
parents:
14271
diff
changeset
|
1454 |
ui.progress(_('building'), id, unit=_('revisions'), total=total) |
14163
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1455 |
tr.close() |
15875
7eca9db689d6
debugbuilddag: lock repo before starting transaction
Mads Kiilerich <mads@kiilerich.com>
parents:
15862
diff
changeset
|
1456 |
|
7eca9db689d6
debugbuilddag: lock repo before starting transaction
Mads Kiilerich <mads@kiilerich.com>
parents:
15862
diff
changeset
|
1457 |
if tags: |
7eca9db689d6
debugbuilddag: lock repo before starting transaction
Mads Kiilerich <mads@kiilerich.com>
parents:
15862
diff
changeset
|
1458 |
repo.opener.write("localtags", "".join(tags)) |
14163
38184a72d793
debugbuilddag: use memctx for speed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14157
diff
changeset
|
1459 |
finally: |
14279
b039b667515d
debugbuilddag: output progress information
Martin Geisler <mg@aragost.com>
parents:
14271
diff
changeset
|
1460 |
ui.progress(_('building'), None) |
15875
7eca9db689d6
debugbuilddag: lock repo before starting transaction
Mads Kiilerich <mads@kiilerich.com>
parents:
15862
diff
changeset
|
1461 |
release(tr, lock) |
11337
0f3c8a47960e
debugbuilddag: build a changelog dag from a concise description
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11336
diff
changeset
|
1462 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1463 |
@command('debugbundle', [('a', 'all', None, _('show all details'))], _('FILE')) |
13724
fe57046e9448
commands: add debugbundle command
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13723
diff
changeset
|
1464 |
def debugbundle(ui, bundlepath, all=None, **opts): |
fe57046e9448
commands: add debugbundle command
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13723
diff
changeset
|
1465 |
"""lists the contents of a bundle""" |
fe57046e9448
commands: add debugbundle command
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13723
diff
changeset
|
1466 |
f = url.open(ui, bundlepath) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
1467 |
try: |
13747
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1468 |
gen = changegroup.readbundle(f, bundlepath) |
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1469 |
if all: |
14141
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14098
diff
changeset
|
1470 |
ui.write("format: id, p1, p2, cset, delta base, len(delta)\n") |
13747
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1471 |
|
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1472 |
def showchunks(named): |
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1473 |
ui.write("\n%s\n" % named) |
14141
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14098
diff
changeset
|
1474 |
chain = None |
14494
1ffeeb91c55d
check-code: flag 0/1 used as constant Boolean expression
Martin Geisler <mg@lazybytes.net>
parents:
14485
diff
changeset
|
1475 |
while True: |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
1476 |
chunkdata = gen.deltachunk(chain) |
13724
fe57046e9448
commands: add debugbundle command
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13723
diff
changeset
|
1477 |
if not chunkdata: |
fe57046e9448
commands: add debugbundle command
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13723
diff
changeset
|
1478 |
break |
fe57046e9448
commands: add debugbundle command
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13723
diff
changeset
|
1479 |
node = chunkdata['node'] |
13747
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1480 |
p1 = chunkdata['p1'] |
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1481 |
p2 = chunkdata['p2'] |
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1482 |
cs = chunkdata['cs'] |
14141
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14098
diff
changeset
|
1483 |
deltabase = chunkdata['deltabase'] |
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14098
diff
changeset
|
1484 |
delta = chunkdata['delta'] |
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14098
diff
changeset
|
1485 |
ui.write("%s %s %s %s %s %s\n" % |
13747
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1486 |
(hex(node), hex(p1), hex(p2), |
14141
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14098
diff
changeset
|
1487 |
hex(cs), hex(deltabase), len(delta))) |
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14098
diff
changeset
|
1488 |
chain = node |
13747
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1489 |
|
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
1490 |
chunkdata = gen.changelogheader() |
13747
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1491 |
showchunks("changelog") |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
1492 |
chunkdata = gen.manifestheader() |
13747
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1493 |
showchunks("manifest") |
14494
1ffeeb91c55d
check-code: flag 0/1 used as constant Boolean expression
Martin Geisler <mg@lazybytes.net>
parents:
14485
diff
changeset
|
1494 |
while True: |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
1495 |
chunkdata = gen.filelogheader() |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
1496 |
if not chunkdata: |
13747
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1497 |
break |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
1498 |
fname = chunkdata['filename'] |
13747
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1499 |
showchunks(fname) |
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1500 |
else: |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
1501 |
chunkdata = gen.changelogheader() |
14141
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14098
diff
changeset
|
1502 |
chain = None |
14494
1ffeeb91c55d
check-code: flag 0/1 used as constant Boolean expression
Martin Geisler <mg@lazybytes.net>
parents:
14485
diff
changeset
|
1503 |
while True: |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14141
diff
changeset
|
1504 |
chunkdata = gen.deltachunk(chain) |
13747
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1505 |
if not chunkdata: |
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1506 |
break |
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1507 |
node = chunkdata['node'] |
cede00420e1e
code indentation fixes
Patrick Mezard <pmezard@gmail.com>
parents:
13741
diff
changeset
|
1508 |
ui.write("%s\n" % hex(node)) |
14141
bd1cbfe5db5c
bundler: make parsechunk return the base revision of the delta
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14098
diff
changeset
|
1509 |
chain = node |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
1510 |
finally: |
13724
fe57046e9448
commands: add debugbundle command
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13723
diff
changeset
|
1511 |
f.close() |
fe57046e9448
commands: add debugbundle command
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13723
diff
changeset
|
1512 |
|
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1513 |
@command('debugcheckstate', [], '') |
596 | 1514 |
def debugcheckstate(ui, repo): |
1515 |
"""validate the correctness of the current dirstate""" |
|
460 | 1516 |
parent1, parent2 = repo.dirstate.parents() |
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6746
diff
changeset
|
1517 |
m1 = repo[parent1].manifest() |
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6746
diff
changeset
|
1518 |
m2 = repo[parent2].manifest() |
460 | 1519 |
errors = 0 |
4906
30847b8af7ca
dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents:
4904
diff
changeset
|
1520 |
for f in repo.dirstate: |
30847b8af7ca
dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents:
4904
diff
changeset
|
1521 |
state = repo.dirstate[f] |
460 | 1522 |
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
|
1523 |
ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state)) |
460 | 1524 |
errors += 1 |
1525 |
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
|
1526 |
ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state)) |
460 | 1527 |
errors += 1 |
1528 |
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
|
1529 |
ui.warn(_("%s in state %s, but not in either manifest\n") % |
582 | 1530 |
(f, state)) |
460 | 1531 |
errors += 1 |
1532 |
for f in m1: |
|
4906
30847b8af7ca
dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents:
4904
diff
changeset
|
1533 |
state = repo.dirstate[f] |
460 | 1534 |
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
|
1535 |
ui.warn(_("%s in manifest1, but listed as state %s") % (f, state)) |
460 | 1536 |
errors += 1 |
1537 |
if errors: |
|
1602
fb4149eebdd4
strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1601
diff
changeset
|
1538 |
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
|
1539 |
raise util.Abort(error) |
460 | 1540 |
|
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1541 |
@command('debugcommands', [], _('[COMMAND]')) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1542 |
def debugcommands(ui, cmd='', *args): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1543 |
"""list all available commands and options""" |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1544 |
for cmd, vals in sorted(table.iteritems()): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1545 |
cmd = cmd.split('|')[0].strip('^') |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1546 |
opts = ', '.join([i[1] for i in vals[1]]) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1547 |
ui.write('%s: %s\n' % (cmd, opts)) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1548 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1549 |
@command('debugcomplete', |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1550 |
[('o', 'options', None, _('show the command options'))], |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1551 |
_('[-o] CMD')) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1552 |
def debugcomplete(ui, cmd='', **opts): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1553 |
"""returns the completion list associated with the given command""" |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1554 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1555 |
if opts.get('options'): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1556 |
options = [] |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1557 |
otables = [globalopts] |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1558 |
if cmd: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1559 |
aliases, entry = cmdutil.findcmd(cmd, table, False) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1560 |
otables.append(entry[1]) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1561 |
for t in otables: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1562 |
for o in t: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1563 |
if "(DEPRECATED)" in o[3]: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1564 |
continue |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1565 |
if o[0]: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1566 |
options.append('-%s' % o[0]) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1567 |
options.append('--%s' % o[1]) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1568 |
ui.write("%s\n" % "\n".join(options)) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1569 |
return |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1570 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1571 |
cmdlist = cmdutil.findpossible(cmd, table) |
11276
f28b58e35768
revset: add a debugrevspec command
Matt Mackall <mpm@selenic.com>
parents:
11273
diff
changeset
|
1572 |
if ui.verbose: |
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1573 |
cmdlist = [' '.join(c[0]) for c in cmdlist.values()] |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1574 |
ui.write("%s\n" % "\n".join(sorted(cmdlist))) |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
8810
diff
changeset
|
1575 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1576 |
@command('debugdag', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1577 |
[('t', 'tags', None, _('use tags as labels')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1578 |
('b', 'branches', None, _('annotate with branch names')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1579 |
('', 'dots', None, _('use dots for runs')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1580 |
('s', 'spaces', None, _('separate elements by spaces'))], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1581 |
_('[OPTION]... [FILE [REV]...]')) |
11336
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1582 |
def debugdag(ui, repo, file_=None, *revs, **opts): |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1583 |
"""format the changelog or an index DAG as a concise textual description |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1584 |
|
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1585 |
If you pass a revlog index, the revlog's DAG is emitted. If you list |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1586 |
revision numbers, they get labelled in the output as rN. |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1587 |
|
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1588 |
Otherwise, the changelog DAG of the current repo is emitted. |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1589 |
""" |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1590 |
spaces = opts.get('spaces') |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1591 |
dots = opts.get('dots') |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1592 |
if file_: |
13970
d13913355390
move opener from util to scmutil
Adrian Buehlmann <adrian@cadifra.com>
parents:
13965
diff
changeset
|
1593 |
rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_) |
11336
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1594 |
revs = set((int(r) for r in revs)) |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1595 |
def events(): |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1596 |
for r in rlog: |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1597 |
yield 'n', (r, list(set(p for p in rlog.parentrevs(r) if p != -1))) |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1598 |
if r in revs: |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1599 |
yield 'l', (r, "r%i" % r) |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1600 |
elif repo: |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1601 |
cl = repo.changelog |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1602 |
tags = opts.get('tags') |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1603 |
branches = opts.get('branches') |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1604 |
if tags: |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1605 |
labels = {} |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1606 |
for l, n in repo.tags().items(): |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1607 |
labels.setdefault(cl.rev(n), []).append(l) |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1608 |
def events(): |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1609 |
b = "default" |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1610 |
for r in cl: |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1611 |
if branches: |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1612 |
newb = cl.read(cl.node(r))[5]['branch'] |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1613 |
if newb != b: |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1614 |
yield 'a', newb |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1615 |
b = newb |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1616 |
yield 'n', (r, list(set(p for p in cl.parentrevs(r) if p != -1))) |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1617 |
if tags: |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1618 |
ls = labels.get(r) |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1619 |
if ls: |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1620 |
for l in ls: |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1621 |
yield 'l', (r, l) |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1622 |
else: |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1623 |
raise util.Abort(_('need repo for changelog dag')) |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1624 |
|
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1625 |
for line in dagparser.dagtextlines(events(), |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1626 |
addspaces=spaces, |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1627 |
wraplabels=True, |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1628 |
wrapannotations=True, |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1629 |
wrapnonlinear=dots, |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1630 |
usedots=dots, |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1631 |
maxlinewidth=70): |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1632 |
ui.write(line) |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1633 |
ui.write("\n") |
3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
11331
diff
changeset
|
1634 |
|
14323
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1635 |
@command('debugdata', |
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1636 |
[('c', 'changelog', False, _('open changelog')), |
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1637 |
('m', 'manifest', False, _('open manifest'))], |
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1638 |
_('-c|-m|FILE REV')) |
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1639 |
def debugdata(ui, repo, file_, rev = None, **opts): |
4258
b11a2fb59cf5
revlog: simplify revlog version handling
Matt Mackall <mpm@selenic.com>
parents:
4257
diff
changeset
|
1640 |
"""dump the contents of a data file revision""" |
14323
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1641 |
if opts.get('changelog') or opts.get('manifest'): |
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1642 |
file_, rev = None, file_ |
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1643 |
elif rev is None: |
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1644 |
raise error.CommandError('debugdata', _('invalid arguments')) |
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1645 |
r = cmdutil.openrevlog(repo, 'debugdata', file_, opts) |
1313
1cc7c0cbc30b
Fix traceback during invalid rev identifier for debugdata
Anupam Kapoor<anupam.kapoor@gmail.com>
parents:
1312
diff
changeset
|
1646 |
try: |
1cc7c0cbc30b
Fix traceback during invalid rev identifier for debugdata
Anupam Kapoor<anupam.kapoor@gmail.com>
parents:
1312
diff
changeset
|
1647 |
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
|
1648 |
except KeyError: |
3072
bc3fe3b5b785
Never apply string formatting to generated errors with util.Abort.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3071
diff
changeset
|
1649 |
raise util.Abort(_('invalid revision identifier %s') % rev) |
1039
4296754ba7b4
Add debugdata for dumping revlog revision data
mpm@selenic.com
parents:
1037
diff
changeset
|
1650 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1651 |
@command('debugdate', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1652 |
[('e', 'extended', None, _('try extended date formats'))], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1653 |
_('[-e] DATE [RANGE]')) |
3812 | 1654 |
def debugdate(ui, date, range=None, **opts): |
3805 | 1655 |
"""parse and display a date""" |
3812 | 1656 |
if opts["extended"]: |
1657 |
d = util.parsedate(date, util.extendeddateformats) |
|
1658 |
else: |
|
1659 |
d = util.parsedate(date) |
|
3805 | 1660 |
ui.write("internal: %s %s\n" % d) |
1661 |
ui.write("standard: %s\n" % util.datestr(d)) |
|
3812 | 1662 |
if range: |
1663 |
m = util.matchdate(range) |
|
1664 |
ui.write("match: %s\n" % m(d[0])) |
|
3805 | 1665 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1666 |
@command('debugdiscovery', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1667 |
[('', 'old', None, _('use old-style discovery')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1668 |
('', 'nonheads', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1669 |
_('use old-style discovery with non-heads included')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1670 |
] + remoteopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1671 |
_('[-l REV] [-r REV] [-b BRANCH]... [OTHER]')) |
14164
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1672 |
def debugdiscovery(ui, repo, remoteurl="default", **opts): |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1673 |
"""runs the changeset discovery protocol in isolation""" |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1674 |
remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl), opts.get('branch')) |
14556
517e1d88bf7e
hg: change various repository() users to use peer() where appropriate
Matt Mackall <mpm@selenic.com>
parents:
14553
diff
changeset
|
1675 |
remote = hg.peer(repo, opts, remoteurl) |
14164
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1676 |
ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl)) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1677 |
|
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1678 |
# make sure tests are repeatable |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1679 |
random.seed(12323) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1680 |
|
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1681 |
def doit(localheads, remoteheads): |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1682 |
if opts.get('old'): |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1683 |
if localheads: |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1684 |
raise util.Abort('cannot use localheads with old style discovery') |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1685 |
common, _in, hds = treediscovery.findcommonincoming(repo, remote, |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1686 |
force=True) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1687 |
common = set(common) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1688 |
if not opts.get('nonheads'): |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1689 |
ui.write("unpruned common: %s\n" % " ".join([short(n) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1690 |
for n in common])) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1691 |
dag = dagutil.revlogdag(repo.changelog) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1692 |
all = dag.ancestorset(dag.internalizeall(common)) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1693 |
common = dag.externalizeall(dag.headsetofconnecteds(all)) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1694 |
else: |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1695 |
common, any, hds = setdiscovery.findcommonheads(ui, repo, remote) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1696 |
common = set(common) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1697 |
rheads = set(hds) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1698 |
lheads = set(repo.heads()) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1699 |
ui.write("common heads: %s\n" % " ".join([short(n) for n in common])) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1700 |
if lheads <= common: |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1701 |
ui.write("local is subset\n") |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1702 |
elif rheads <= common: |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1703 |
ui.write("remote is subset\n") |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1704 |
|
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1705 |
serverlogs = opts.get('serverlog') |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1706 |
if serverlogs: |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1707 |
for filename in serverlogs: |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1708 |
logfile = open(filename, 'r') |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1709 |
try: |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1710 |
line = logfile.readline() |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1711 |
while line: |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1712 |
parts = line.strip().split(';') |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1713 |
op = parts[1] |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1714 |
if op == 'cg': |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1715 |
pass |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1716 |
elif op == 'cgss': |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1717 |
doit(parts[2].split(' '), parts[3].split(' ')) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1718 |
elif op == 'unb': |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1719 |
doit(parts[3].split(' '), parts[2].split(' ')) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1720 |
line = logfile.readline() |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1721 |
finally: |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1722 |
logfile.close() |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1723 |
|
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1724 |
else: |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1725 |
remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1726 |
opts.get('remote_head')) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1727 |
localrevs = opts.get('local_head') |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1728 |
doit(localrevs, remoterevs) |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14163
diff
changeset
|
1729 |
|
14511
30506b894359
filesets: introduce basic fileset expression parser
Matt Mackall <mpm@selenic.com>
parents:
14509
diff
changeset
|
1730 |
@command('debugfileset', [], ('REVSPEC')) |
30506b894359
filesets: introduce basic fileset expression parser
Matt Mackall <mpm@selenic.com>
parents:
14509
diff
changeset
|
1731 |
def debugfileset(ui, repo, expr): |
30506b894359
filesets: introduce basic fileset expression parser
Matt Mackall <mpm@selenic.com>
parents:
14509
diff
changeset
|
1732 |
'''parse and apply a fileset specification''' |
30506b894359
filesets: introduce basic fileset expression parser
Matt Mackall <mpm@selenic.com>
parents:
14509
diff
changeset
|
1733 |
if ui.verbose: |
30506b894359
filesets: introduce basic fileset expression parser
Matt Mackall <mpm@selenic.com>
parents:
14509
diff
changeset
|
1734 |
tree = fileset.parse(expr)[0] |
30506b894359
filesets: introduce basic fileset expression parser
Matt Mackall <mpm@selenic.com>
parents:
14509
diff
changeset
|
1735 |
ui.note(tree, "\n") |
14673 | 1736 |
|
1737 |
for f in fileset.getfileset(repo[None], expr): |
|
14551
68d814a3cefd
fileset: basic pattern and boolean support
Matt Mackall <mpm@selenic.com>
parents:
14548
diff
changeset
|
1738 |
ui.write("%s\n" % f) |
14511
30506b894359
filesets: introduce basic fileset expression parser
Matt Mackall <mpm@selenic.com>
parents:
14509
diff
changeset
|
1739 |
|
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1740 |
@command('debugfsinfo', [], _('[PATH]')) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1741 |
def debugfsinfo(ui, path = "."): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1742 |
"""show information detected about current filesystem""" |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1743 |
util.writefile('.debugfsinfo', '') |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1744 |
ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no')) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1745 |
ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no')) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1746 |
ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo') |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1747 |
and 'yes' or 'no')) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1748 |
os.unlink('.debugfsinfo') |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1749 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1750 |
@command('debuggetbundle', |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1751 |
[('H', 'head', [], _('id of head node'), _('ID')), |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1752 |
('C', 'common', [], _('id of common node'), _('ID')), |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1753 |
('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))], |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1754 |
_('REPO FILE [-H|-C ID]...')) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1755 |
def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1756 |
"""retrieves a bundle from a repo |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1757 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1758 |
Every ID must be a full-length hex node id string. Saves the bundle to the |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1759 |
given file. |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1760 |
""" |
14556
517e1d88bf7e
hg: change various repository() users to use peer() where appropriate
Matt Mackall <mpm@selenic.com>
parents:
14553
diff
changeset
|
1761 |
repo = hg.peer(ui, opts, repopath) |
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1762 |
if not repo.capable('getbundle'): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1763 |
raise util.Abort("getbundle() not supported by target repository") |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1764 |
args = {} |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1765 |
if common: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1766 |
args['common'] = [bin(s) for s in common] |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1767 |
if head: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1768 |
args['heads'] = [bin(s) for s in head] |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1769 |
bundle = repo.getbundle('debug', **args) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1770 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1771 |
bundletype = opts.get('type', 'bzip2').lower() |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1772 |
btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'} |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1773 |
bundletype = btypes.get(bundletype) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1774 |
if bundletype not in changegroup.bundletypes: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1775 |
raise util.Abort(_('unknown bundle type specified with --type')) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1776 |
changegroup.writebundle(bundle, bundlepath, bundletype) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1777 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1778 |
@command('debugignore', [], '') |
13396
3e66eec9a814
add debugignore which yields the combined ignore patten of the .hgignore files
jfh <jason@jasonfharris.com>
parents:
13388
diff
changeset
|
1779 |
def debugignore(ui, repo, *values, **opts): |
3e66eec9a814
add debugignore which yields the combined ignore patten of the .hgignore files
jfh <jason@jasonfharris.com>
parents:
13388
diff
changeset
|
1780 |
"""display the combined ignore pattern""" |
3e66eec9a814
add debugignore which yields the combined ignore patten of the .hgignore files
jfh <jason@jasonfharris.com>
parents:
13388
diff
changeset
|
1781 |
ignore = repo.dirstate._ignore |
14949
a4435770cf57
debugignore: use getattr instead of hasattr
Augie Fackler <durin42@gmail.com>
parents:
14943
diff
changeset
|
1782 |
includepat = getattr(ignore, 'includepat', None) |
a4435770cf57
debugignore: use getattr instead of hasattr
Augie Fackler <durin42@gmail.com>
parents:
14943
diff
changeset
|
1783 |
if includepat is not None: |
a4435770cf57
debugignore: use getattr instead of hasattr
Augie Fackler <durin42@gmail.com>
parents:
14943
diff
changeset
|
1784 |
ui.write("%s\n" % includepat) |
13406
5e57c199848d
debugignore: catch the case when ignore.includepat doesn't exist
jfh <jason@jasonfharris.com>
parents:
13400
diff
changeset
|
1785 |
else: |
5e57c199848d
debugignore: catch the case when ignore.includepat doesn't exist
jfh <jason@jasonfharris.com>
parents:
13400
diff
changeset
|
1786 |
raise util.Abort(_("no ignore patterns found")) |
13396
3e66eec9a814
add debugignore which yields the combined ignore patten of the .hgignore files
jfh <jason@jasonfharris.com>
parents:
13388
diff
changeset
|
1787 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1788 |
@command('debugindex', |
14323
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1789 |
[('c', 'changelog', False, _('open changelog')), |
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1790 |
('m', 'manifest', False, _('open manifest')), |
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1791 |
('f', 'format', 0, _('revlog format'), _('FORMAT'))], |
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1792 |
_('[-f FORMAT] -c|-m|FILE')) |
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1793 |
def debugindex(ui, repo, file_ = None, **opts): |
596 | 1794 |
"""dump the contents of an index file""" |
14323
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1795 |
r = cmdutil.openrevlog(repo, 'debugindex', file_, opts) |
12893
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1796 |
format = opts.get('format', 0) |
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1797 |
if format not in (0, 1): |
13470
64ce09e93aff
commands: mark strings for translation
Martin Geisler <mg@aragost.com>
parents:
13454
diff
changeset
|
1798 |
raise util.Abort(_("unknown format %d") % format) |
12893
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1799 |
|
14254
d6a762d93b77
debugindex: change output for generaldelta revlogs
Sune Foldager <cryo@cyanite.org>
parents:
14252
diff
changeset
|
1800 |
generaldelta = r.version & revlog.REVLOGGENERALDELTA |
d6a762d93b77
debugindex: change output for generaldelta revlogs
Sune Foldager <cryo@cyanite.org>
parents:
14252
diff
changeset
|
1801 |
if generaldelta: |
d6a762d93b77
debugindex: change output for generaldelta revlogs
Sune Foldager <cryo@cyanite.org>
parents:
14252
diff
changeset
|
1802 |
basehdr = ' delta' |
d6a762d93b77
debugindex: change output for generaldelta revlogs
Sune Foldager <cryo@cyanite.org>
parents:
14252
diff
changeset
|
1803 |
else: |
d6a762d93b77
debugindex: change output for generaldelta revlogs
Sune Foldager <cryo@cyanite.org>
parents:
14252
diff
changeset
|
1804 |
basehdr = ' base' |
12893
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1805 |
|
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1806 |
if format == 0: |
14254
d6a762d93b77
debugindex: change output for generaldelta revlogs
Sune Foldager <cryo@cyanite.org>
parents:
14252
diff
changeset
|
1807 |
ui.write(" rev offset length " + basehdr + " linkrev" |
12893
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1808 |
" nodeid p1 p2\n") |
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1809 |
elif format == 1: |
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1810 |
ui.write(" rev flag offset length" |
14254
d6a762d93b77
debugindex: change output for generaldelta revlogs
Sune Foldager <cryo@cyanite.org>
parents:
14252
diff
changeset
|
1811 |
" size " + basehdr + " link p1 p2 nodeid\n") |
12893
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1812 |
|
6750
fb42030d79d6
add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents:
6749
diff
changeset
|
1813 |
for i in r: |
2072 | 1814 |
node = r.node(i) |
14254
d6a762d93b77
debugindex: change output for generaldelta revlogs
Sune Foldager <cryo@cyanite.org>
parents:
14252
diff
changeset
|
1815 |
if generaldelta: |
d6a762d93b77
debugindex: change output for generaldelta revlogs
Sune Foldager <cryo@cyanite.org>
parents:
14252
diff
changeset
|
1816 |
base = r.deltaparent(i) |
d6a762d93b77
debugindex: change output for generaldelta revlogs
Sune Foldager <cryo@cyanite.org>
parents:
14252
diff
changeset
|
1817 |
else: |
d6a762d93b77
debugindex: change output for generaldelta revlogs
Sune Foldager <cryo@cyanite.org>
parents:
14252
diff
changeset
|
1818 |
base = r.chainbase(i) |
12893
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1819 |
if format == 0: |
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1820 |
try: |
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1821 |
pp = r.parents(node) |
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1822 |
except: |
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1823 |
pp = [nullid, nullid] |
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1824 |
ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( |
14254
d6a762d93b77
debugindex: change output for generaldelta revlogs
Sune Foldager <cryo@cyanite.org>
parents:
14252
diff
changeset
|
1825 |
i, r.start(i), r.length(i), base, r.linkrev(i), |
12893
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1826 |
short(node), short(pp[0]), short(pp[1]))) |
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1827 |
elif format == 1: |
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1828 |
pr = r.parentrevs(i) |
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1829 |
ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % ( |
15ca4bfecfe3
debugindex: add --format flag to allow debugging parentdelta
Matt Mackall <mpm@selenic.com>
parents:
12863
diff
changeset
|
1830 |
i, r.flags(i), r.start(i), r.length(i), r.rawsize(i), |
14254
d6a762d93b77
debugindex: change output for generaldelta revlogs
Sune Foldager <cryo@cyanite.org>
parents:
14252
diff
changeset
|
1831 |
base, r.linkrev(i), pr[0], pr[1], short(node))) |
248 | 1832 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1833 |
@command('debugindexdot', [], _('FILE')) |
12132
8a0e5b0c0ba9
debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents:
12131
diff
changeset
|
1834 |
def debugindexdot(ui, repo, file_): |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
1835 |
"""dump an index DAG as a graphviz dot file""" |
12132
8a0e5b0c0ba9
debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents:
12131
diff
changeset
|
1836 |
r = None |
8a0e5b0c0ba9
debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents:
12131
diff
changeset
|
1837 |
if repo: |
8a0e5b0c0ba9
debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents:
12131
diff
changeset
|
1838 |
filelog = repo.file(file_) |
8a0e5b0c0ba9
debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents:
12131
diff
changeset
|
1839 |
if len(filelog): |
8a0e5b0c0ba9
debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents:
12131
diff
changeset
|
1840 |
r = filelog |
8a0e5b0c0ba9
debugindex(dot): try to access filelogs through repo, if possible
Sune Foldager <sune.foldager@edlund.dk>
parents:
12131
diff
changeset
|
1841 |
if not r: |
13970
d13913355390
move opener from util to scmutil
Adrian Buehlmann <adrian@cadifra.com>
parents:
13965
diff
changeset
|
1842 |
r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_) |
582 | 1843 |
ui.write("digraph G {\n") |
6750
fb42030d79d6
add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents:
6749
diff
changeset
|
1844 |
for i in r: |
2287
3f18d1eea370
Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents:
2283
diff
changeset
|
1845 |
node = r.node(i) |
3f18d1eea370
Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents:
2283
diff
changeset
|
1846 |
pp = r.parents(node) |
3f18d1eea370
Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents:
2283
diff
changeset
|
1847 |
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
|
1848 |
if pp[1] != nullid: |
3f18d1eea370
Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents:
2283
diff
changeset
|
1849 |
ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) |
582 | 1850 |
ui.write("}\n") |
248 | 1851 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1852 |
@command('debuginstall', [], '') |
3844
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1853 |
def debuginstall(ui): |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1854 |
'''test Mercurial installation |
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1855 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1856 |
Returns 0 on success. |
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
1857 |
''' |
3844
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1858 |
|
3846
18855084b922
Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents:
3844
diff
changeset
|
1859 |
def writetemp(contents): |
4849
035489f60842
Use a prefix for debuginstall tempfiles.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4818
diff
changeset
|
1860 |
(fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-") |
3846
18855084b922
Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents:
3844
diff
changeset
|
1861 |
f = os.fdopen(fd, "wb") |
18855084b922
Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents:
3844
diff
changeset
|
1862 |
f.write(contents) |
18855084b922
Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents:
3844
diff
changeset
|
1863 |
f.close() |
18855084b922
Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents:
3844
diff
changeset
|
1864 |
return name |
18855084b922
Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents:
3844
diff
changeset
|
1865 |
|
3844
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1866 |
problems = 0 |
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1867 |
|
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1868 |
# encoding |
7948
de377b1a9a84
move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents:
7942
diff
changeset
|
1869 |
ui.status(_("Checking encoding (%s)...\n") % encoding.encoding) |
3844
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1870 |
try: |
7948
de377b1a9a84
move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents:
7942
diff
changeset
|
1871 |
encoding.fromlocal("test") |
3844
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1872 |
except util.Abort, inst: |
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1873 |
ui.write(" %s\n" % inst) |
3848
8cbf060f637e
Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents:
3846
diff
changeset
|
1874 |
ui.write(_(" (check that your locale is properly set)\n")) |
3844
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1875 |
problems += 1 |
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1876 |
|
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1877 |
# compiled modules |
12004
1fe4702fe2df
debuginstall: report installpath
Matt Mackall <mpm@selenic.com>
parents:
11969
diff
changeset
|
1878 |
ui.status(_("Checking installed modules (%s)...\n") |
1fe4702fe2df
debuginstall: report installpath
Matt Mackall <mpm@selenic.com>
parents:
11969
diff
changeset
|
1879 |
% os.path.dirname(__file__)) |
3844
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1880 |
try: |
12004
1fe4702fe2df
debuginstall: report installpath
Matt Mackall <mpm@selenic.com>
parents:
11969
diff
changeset
|
1881 |
import bdiff, mpatch, base85, osutil |
15223
fc035e5370ca
pyflakes: clean up some import noise
Matt Mackall <mpm@selenic.com>
parents:
15221
diff
changeset
|
1882 |
dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes |
3844
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1883 |
except Exception, inst: |
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1884 |
ui.write(" %s\n" % inst) |
3848
8cbf060f637e
Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents:
3846
diff
changeset
|
1885 |
ui.write(_(" One or more extensions could not be found")) |
8cbf060f637e
Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents:
3846
diff
changeset
|
1886 |
ui.write(_(" (check that you compiled the extensions)\n")) |
3844
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1887 |
problems += 1 |
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1888 |
|
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1889 |
# templates |
15200
797bf1dc1ff8
debuginstall: report the template path
Matt Mackall <mpm@selenic.com>
parents:
15198
diff
changeset
|
1890 |
import templater |
797bf1dc1ff8
debuginstall: report the template path
Matt Mackall <mpm@selenic.com>
parents:
15198
diff
changeset
|
1891 |
p = templater.templatepath() |
797bf1dc1ff8
debuginstall: report the template path
Matt Mackall <mpm@selenic.com>
parents:
15198
diff
changeset
|
1892 |
ui.status(_("Checking templates (%s)...\n") % ' '.join(p)) |
3844
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1893 |
try: |
7874
d812029cda85
cleanup: drop variables for unused return values
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7850
diff
changeset
|
1894 |
templater.templater(templater.templatepath("map-cmdline.default")) |
3844
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1895 |
except Exception, inst: |
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1896 |
ui.write(" %s\n" % inst) |
3848
8cbf060f637e
Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents:
3846
diff
changeset
|
1897 |
ui.write(_(" (templates seem to have been installed incorrectly)\n")) |
3844
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1898 |
problems += 1 |
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1899 |
|
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1900 |
# editor |
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1901 |
ui.status(_("Checking commit editor...\n")) |
5660
3c80ecdc1bcd
Use VISUAL in addition to EDITOR when choosing the editor to use.
Osku Salerma <osku@iki.fi>
parents:
5658
diff
changeset
|
1902 |
editor = ui.geteditor() |
14271
4030630fb59c
rename util.find_exe to findexe
Adrian Buehlmann <adrian@cadifra.com>
parents:
14260
diff
changeset
|
1903 |
cmdpath = util.findexe(editor) or util.findexe(editor.split()[0]) |
3844
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1904 |
if not cmdpath: |
3855
b9cdd6f2aa43
debuginstall: fix a copy/paste error
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3848
diff
changeset
|
1905 |
if editor == 'vi': |
3844
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1906 |
ui.write(_(" No commit editor set and can't find vi in PATH\n")) |
12083
ebfc46929f3e
help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents:
12067
diff
changeset
|
1907 |
ui.write(_(" (specify a commit editor in your configuration" |
ebfc46929f3e
help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents:
12067
diff
changeset
|
1908 |
" file)\n")) |
3844
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1909 |
else: |
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1910 |
ui.write(_(" Can't find editor '%s' in PATH\n") % editor) |
12083
ebfc46929f3e
help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents:
12067
diff
changeset
|
1911 |
ui.write(_(" (specify a commit editor in your configuration" |
ebfc46929f3e
help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents:
12067
diff
changeset
|
1912 |
" file)\n")) |
3844
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1913 |
problems += 1 |
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1914 |
|
3848
8cbf060f637e
Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents:
3846
diff
changeset
|
1915 |
# check username |
8cbf060f637e
Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents:
3846
diff
changeset
|
1916 |
ui.status(_("Checking username...\n")) |
9734
36c388a1aa51
commands: call ui.username carefully in debuginstall
Martin Geisler <mg@lazybytes.net>
parents:
9725
diff
changeset
|
1917 |
try: |
12063
516b000fbb7e
cleanup: remove unused variables
Brodie Rao <brodie@bitheap.org>
parents:
12033
diff
changeset
|
1918 |
ui.username() |
9734
36c388a1aa51
commands: call ui.username carefully in debuginstall
Martin Geisler <mg@lazybytes.net>
parents:
9725
diff
changeset
|
1919 |
except util.Abort, e: |
36c388a1aa51
commands: call ui.username carefully in debuginstall
Martin Geisler <mg@lazybytes.net>
parents:
9725
diff
changeset
|
1920 |
ui.write(" %s\n" % e) |
12083
ebfc46929f3e
help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents:
12067
diff
changeset
|
1921 |
ui.write(_(" (specify a username in your configuration file)\n")) |
9734
36c388a1aa51
commands: call ui.username carefully in debuginstall
Martin Geisler <mg@lazybytes.net>
parents:
9725
diff
changeset
|
1922 |
problems += 1 |
3848
8cbf060f637e
Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents:
3846
diff
changeset
|
1923 |
|
3844
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1924 |
if not problems: |
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1925 |
ui.status(_("No problems detected\n")) |
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1926 |
else: |
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1927 |
ui.write(_("%s problems detected," |
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1928 |
" please check your install!\n") % problems) |
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1929 |
|
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1930 |
return problems |
3ba82c3f4bc3
Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents:
3840
diff
changeset
|
1931 |
|
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1932 |
@command('debugknown', [], _('REPO ID...')) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1933 |
def debugknown(ui, repopath, *ids, **opts): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1934 |
"""test whether node ids are known to a repo |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1935 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1936 |
Every ID must be a full-length hex node id string. Returns a list of 0s and 1s |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1937 |
indicating unknown/known. |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1938 |
""" |
14556
517e1d88bf7e
hg: change various repository() users to use peer() where appropriate
Matt Mackall <mpm@selenic.com>
parents:
14553
diff
changeset
|
1939 |
repo = hg.peer(ui, opts, repopath) |
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1940 |
if not repo.capable('known'): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1941 |
raise util.Abort("known() not supported by target repository") |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1942 |
flags = repo.known([bin(s) for s in ids]) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1943 |
ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags]))) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1944 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1945 |
@command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]')) |
14556
517e1d88bf7e
hg: change various repository() users to use peer() where appropriate
Matt Mackall <mpm@selenic.com>
parents:
14553
diff
changeset
|
1946 |
def debugpushkey(ui, repopath, namespace, *keyinfo, **opts): |
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1947 |
'''access the pushkey key/value protocol |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1948 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1949 |
With two args, list the keys in the given namespace. |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1950 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1951 |
With five args, set a key to new if it currently is set to old. |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1952 |
Reports success or failure. |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1953 |
''' |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1954 |
|
14556
517e1d88bf7e
hg: change various repository() users to use peer() where appropriate
Matt Mackall <mpm@selenic.com>
parents:
14553
diff
changeset
|
1955 |
target = hg.peer(ui, {}, repopath) |
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1956 |
if keyinfo: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1957 |
key, old, new = keyinfo |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1958 |
r = target.pushkey(namespace, key, old, new) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1959 |
ui.status(str(r) + '\n') |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1960 |
return not r |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1961 |
else: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1962 |
for k, v in target.listkeys(namespace).iteritems(): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1963 |
ui.write("%s\t%s\n" % (k.encode('string-escape'), |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1964 |
v.encode('string-escape'))) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1965 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1966 |
@command('debugrebuildstate', |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1967 |
[('r', 'rev', '', _('revision to rebuild to'), _('REV'))], |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1968 |
_('[-r REV] [REV]')) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1969 |
def debugrebuildstate(ui, repo, rev="tip"): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1970 |
"""rebuild the dirstate as it would look like for the given revision""" |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
1971 |
ctx = scmutil.revsingle(repo, rev) |
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1972 |
wlock = repo.wlock() |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1973 |
try: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1974 |
repo.dirstate.rebuild(ctx.node(), ctx.manifest()) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1975 |
finally: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1976 |
wlock.release() |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
1977 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1978 |
@command('debugrename', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1979 |
[('r', 'rev', '', _('revision to debug'), _('REV'))], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
1980 |
_('[-r REV] FILE')) |
3652 | 1981 |
def debugrename(ui, repo, file1, *pats, **opts): |
1194
c165cbf56bb1
Add doc string for debugrename.
bos@serpentine.internal.keyresearch.com
parents:
1193
diff
changeset
|
1982 |
"""dump rename information""" |
3652 | 1983 |
|
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
1984 |
ctx = scmutil.revsingle(repo, opts.get('rev')) |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
1985 |
m = scmutil.match(ctx, (file1,) + pats, opts) |
6764 | 1986 |
for abs in ctx.walk(m): |
1987 |
fctx = ctx[abs] |
|
6579
0159b7a36184
walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents:
6578
diff
changeset
|
1988 |
o = fctx.filelog().renamed(fctx.filenode()) |
6584
29c77e5dfb3c
walk: remove rel and exact returns
Matt Mackall <mpm@selenic.com>
parents:
6583
diff
changeset
|
1989 |
rel = m.rel(abs) |
6579
0159b7a36184
walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents:
6578
diff
changeset
|
1990 |
if o: |
0159b7a36184
walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents:
6578
diff
changeset
|
1991 |
ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) |
3652 | 1992 |
else: |
1993 |
ui.write(_("%s not renamed\n") % rel) |
|
1116 | 1994 |
|
14323
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1995 |
@command('debugrevlog', |
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1996 |
[('c', 'changelog', False, _('open changelog')), |
14326
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
1997 |
('m', 'manifest', False, _('open manifest')), |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
1998 |
('d', 'dump', False, _('dump index data'))], |
14323
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
1999 |
_('-c|-m|FILE')) |
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
2000 |
def debugrevlog(ui, repo, file_ = None, **opts): |
14304 | 2001 |
"""show data and statistics about a revlog""" |
14323
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
2002 |
r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts) |
14326
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2003 |
|
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2004 |
if opts.get("dump"): |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2005 |
numrevs = len(r) |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2006 |
ui.write("# rev p1rev p2rev start end deltastart base p1 p2" |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2007 |
" rawsize totalsize compression heads\n") |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2008 |
ts = 0 |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2009 |
heads = set() |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2010 |
for rev in xrange(numrevs): |
14371 | 2011 |
dbase = r.deltaparent(rev) |
2012 |
if dbase == -1: |
|
2013 |
dbase = rev |
|
14326
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2014 |
cbase = r.chainbase(rev) |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2015 |
p1, p2 = r.parentrevs(rev) |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2016 |
rs = r.rawsize(rev) |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2017 |
ts = ts + rs |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2018 |
heads -= set(r.parentrevs(rev)) |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2019 |
heads.add(rev) |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2020 |
ui.write("%d %d %d %d %d %d %d %d %d %d %d %d %d\n" % |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2021 |
(rev, p1, p2, r.start(rev), r.end(rev), |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2022 |
r.start(dbase), r.start(cbase), |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2023 |
r.start(p1), r.start(p2), |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2024 |
rs, ts, ts / r.end(rev), len(heads))) |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2025 |
return 0 |
6078a99af433
debugrevlog: add --dump flag to dump graphable per-revision statistics
Matt Mackall <mpm@selenic.com>
parents:
14323
diff
changeset
|
2026 |
|
14304 | 2027 |
v = r.version |
2028 |
format = v & 0xFFFF |
|
2029 |
flags = [] |
|
2030 |
gdelta = False |
|
2031 |
if v & revlog.REVLOGNGINLINEDATA: |
|
2032 |
flags.append('inline') |
|
2033 |
if v & revlog.REVLOGGENERALDELTA: |
|
2034 |
gdelta = True |
|
2035 |
flags.append('generaldelta') |
|
14305
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2036 |
if not flags: |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2037 |
flags = ['(none)'] |
14304 | 2038 |
|
2039 |
nummerges = 0 |
|
14305
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2040 |
numfull = 0 |
14304 | 2041 |
numprev = 0 |
2042 |
nump1 = 0 |
|
2043 |
nump2 = 0 |
|
2044 |
numother = 0 |
|
2045 |
nump1prev = 0 |
|
2046 |
nump2prev = 0 |
|
14305
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2047 |
chainlengths = [] |
14304 | 2048 |
|
2049 |
datasize = [None, 0, 0L] |
|
14305
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2050 |
fullsize = [None, 0, 0L] |
14304 | 2051 |
deltasize = [None, 0, 0L] |
2052 |
||
2053 |
def addsize(size, l): |
|
2054 |
if l[0] is None or size < l[0]: |
|
2055 |
l[0] = size |
|
2056 |
if size > l[1]: |
|
2057 |
l[1] = size |
|
2058 |
l[2] += size |
|
2059 |
||
2060 |
numrevs = len(r) |
|
2061 |
for rev in xrange(numrevs): |
|
2062 |
p1, p2 = r.parentrevs(rev) |
|
2063 |
delta = r.deltaparent(rev) |
|
2064 |
if format > 0: |
|
2065 |
addsize(r.rawsize(rev), datasize) |
|
2066 |
if p2 != nullrev: |
|
2067 |
nummerges += 1 |
|
2068 |
size = r.length(rev) |
|
2069 |
if delta == nullrev: |
|
14305
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2070 |
chainlengths.append(0) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2071 |
numfull += 1 |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2072 |
addsize(size, fullsize) |
14304 | 2073 |
else: |
14305
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2074 |
chainlengths.append(chainlengths[delta] + 1) |
14304 | 2075 |
addsize(size, deltasize) |
14305
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2076 |
if delta == rev - 1: |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2077 |
numprev += 1 |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2078 |
if delta == p1: |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2079 |
nump1prev += 1 |
14304 | 2080 |
elif delta == p2: |
14305
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2081 |
nump2prev += 1 |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2082 |
elif delta == p1: |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2083 |
nump1 += 1 |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2084 |
elif delta == p2: |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2085 |
nump2 += 1 |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2086 |
elif delta != nullrev: |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2087 |
numother += 1 |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2088 |
|
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2089 |
numdeltas = numrevs - numfull |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2090 |
numoprev = numprev - nump1prev - nump2prev |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2091 |
totalrawsize = datasize[2] |
14304 | 2092 |
datasize[2] /= numrevs |
14305
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2093 |
fulltotal = fullsize[2] |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2094 |
fullsize[2] /= numfull |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2095 |
deltatotal = deltasize[2] |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2096 |
deltasize[2] /= numrevs - numfull |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2097 |
totalsize = fulltotal + deltatotal |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2098 |
avgchainlen = sum(chainlengths) / numrevs |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2099 |
compratio = totalrawsize / totalsize |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2100 |
|
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2101 |
basedfmtstr = '%%%dd\n' |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2102 |
basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n' |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2103 |
|
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2104 |
def dfmtstr(max): |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2105 |
return basedfmtstr % len(str(max)) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2106 |
def pcfmtstr(max, padding=0): |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2107 |
return basepcfmtstr % (len(str(max)), ' ' * padding) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2108 |
|
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2109 |
def pcfmt(value, total): |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2110 |
return (value, 100 * float(value) / total) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2111 |
|
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2112 |
ui.write('format : %d\n' % format) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2113 |
ui.write('flags : %s\n' % ', '.join(flags)) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2114 |
|
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2115 |
ui.write('\n') |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2116 |
fmt = pcfmtstr(totalsize) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2117 |
fmt2 = dfmtstr(totalsize) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2118 |
ui.write('revisions : ' + fmt2 % numrevs) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2119 |
ui.write(' merges : ' + fmt % pcfmt(nummerges, numrevs)) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2120 |
ui.write(' normal : ' + fmt % pcfmt(numrevs - nummerges, numrevs)) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2121 |
ui.write('revisions : ' + fmt2 % numrevs) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2122 |
ui.write(' full : ' + fmt % pcfmt(numfull, numrevs)) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2123 |
ui.write(' deltas : ' + fmt % pcfmt(numdeltas, numrevs)) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2124 |
ui.write('revision size : ' + fmt2 % totalsize) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2125 |
ui.write(' full : ' + fmt % pcfmt(fulltotal, totalsize)) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2126 |
ui.write(' deltas : ' + fmt % pcfmt(deltatotal, totalsize)) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2127 |
|
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2128 |
ui.write('\n') |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2129 |
fmt = dfmtstr(max(avgchainlen, compratio)) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2130 |
ui.write('avg chain length : ' + fmt % avgchainlen) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2131 |
ui.write('compression ratio : ' + fmt % compratio) |
14304 | 2132 |
|
2133 |
if format > 0: |
|
14305
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2134 |
ui.write('\n') |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2135 |
ui.write('uncompressed data size (min/max/avg) : %d / %d / %d\n' |
14304 | 2136 |
% tuple(datasize)) |
14305
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2137 |
ui.write('full revision size (min/max/avg) : %d / %d / %d\n' |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2138 |
% tuple(fullsize)) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2139 |
ui.write('delta size (min/max/avg) : %d / %d / %d\n' |
14304 | 2140 |
% tuple(deltasize)) |
2141 |
||
14305
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2142 |
if numdeltas > 0: |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2143 |
ui.write('\n') |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2144 |
fmt = pcfmtstr(numdeltas) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2145 |
fmt2 = pcfmtstr(numdeltas, 4) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2146 |
ui.write('deltas against prev : ' + fmt % pcfmt(numprev, numdeltas)) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2147 |
if numprev > 0: |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2148 |
ui.write(' where prev = p1 : ' + fmt2 % pcfmt(nump1prev, numprev)) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2149 |
ui.write(' where prev = p2 : ' + fmt2 % pcfmt(nump2prev, numprev)) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2150 |
ui.write(' other : ' + fmt2 % pcfmt(numoprev, numprev)) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2151 |
if gdelta: |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2152 |
ui.write('deltas against p1 : ' + fmt % pcfmt(nump1, numdeltas)) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2153 |
ui.write('deltas against p2 : ' + fmt % pcfmt(nump2, numdeltas)) |
32a548776b65
debugrevlog: many improvements
Sune Foldager <cryo@cyanite.org>
parents:
14304
diff
changeset
|
2154 |
ui.write('deltas against other : ' + fmt % pcfmt(numother, numdeltas)) |
14304 | 2155 |
|
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2156 |
@command('debugrevspec', [], ('REVSPEC')) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2157 |
def debugrevspec(ui, repo, expr): |
16104
5535e66b3016
debugrevspec: mention --verbose to print the parsed tree
Patrick Mezard <patrick@mezard.eu>
parents:
16097
diff
changeset
|
2158 |
"""parse and apply a revision specification |
5535e66b3016
debugrevspec: mention --verbose to print the parsed tree
Patrick Mezard <patrick@mezard.eu>
parents:
16097
diff
changeset
|
2159 |
|
5535e66b3016
debugrevspec: mention --verbose to print the parsed tree
Patrick Mezard <patrick@mezard.eu>
parents:
16097
diff
changeset
|
2160 |
Use --verbose to print the parsed tree before and after aliases |
5535e66b3016
debugrevspec: mention --verbose to print the parsed tree
Patrick Mezard <patrick@mezard.eu>
parents:
16097
diff
changeset
|
2161 |
expansion. |
5535e66b3016
debugrevspec: mention --verbose to print the parsed tree
Patrick Mezard <patrick@mezard.eu>
parents:
16097
diff
changeset
|
2162 |
""" |
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2163 |
if ui.verbose: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2164 |
tree = revset.parse(expr)[0] |
16218
81a1a00f5738
debugrevspec: pretty print output
Patrick Mezard <patrick@mezard.eu>
parents:
16192
diff
changeset
|
2165 |
ui.note(revset.prettyformat(tree), "\n") |
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2166 |
newtree = revset.findaliases(ui, tree) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2167 |
if newtree != tree: |
16218
81a1a00f5738
debugrevspec: pretty print output
Patrick Mezard <patrick@mezard.eu>
parents:
16192
diff
changeset
|
2168 |
ui.note(revset.prettyformat(newtree), "\n") |
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2169 |
func = revset.match(ui, expr) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2170 |
for c in func(repo, range(len(repo))): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2171 |
ui.write("%s\n" % c) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2172 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2173 |
@command('debugsetparents', [], _('REV1 [REV2]')) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2174 |
def debugsetparents(ui, repo, rev1, rev2=None): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2175 |
"""manually set the parents of the current working directory |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2176 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2177 |
This is useful for writing repository conversion tools, but should |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2178 |
be used with care. |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2179 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2180 |
Returns 0 on success. |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2181 |
""" |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2182 |
|
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
2183 |
r1 = scmutil.revsingle(repo, rev1).node() |
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
2184 |
r2 = scmutil.revsingle(repo, rev2, 'null').node() |
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2185 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2186 |
wlock = repo.wlock() |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2187 |
try: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2188 |
repo.dirstate.setparents(r1, r2) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2189 |
finally: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2190 |
wlock.release() |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2191 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2192 |
@command('debugstate', |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2193 |
[('', 'nodates', None, _('do not display the saved mtime')), |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2194 |
('', 'datesort', None, _('sort by saved mtime'))], |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2195 |
_('[OPTION]...')) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2196 |
def debugstate(ui, repo, nodates=None, datesort=None): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2197 |
"""show the contents of the current dirstate""" |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2198 |
timestr = "" |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2199 |
showdate = not nodates |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2200 |
if datesort: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2201 |
keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2202 |
else: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2203 |
keyfunc = None # sort by filename |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2204 |
for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2205 |
if showdate: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2206 |
if ent[3] == -1: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2207 |
# Pad or slice to locale representation |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2208 |
locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ", |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2209 |
time.localtime(0))) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2210 |
timestr = 'unset' |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2211 |
timestr = (timestr[:locale_len] + |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2212 |
' ' * (locale_len - len(timestr))) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2213 |
else: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2214 |
timestr = time.strftime("%Y-%m-%d %H:%M:%S ", |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2215 |
time.localtime(ent[3])) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2216 |
if ent[1] & 020000: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2217 |
mode = 'lnk' |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2218 |
else: |
15440
9ab2b3b730ee
windows: use umask 022 in debugstate output
Mads Kiilerich <mads@kiilerich.com>
parents:
15424
diff
changeset
|
2219 |
mode = '%3o' % (ent[1] & 0777 & ~util.umask) |
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2220 |
ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2221 |
for f in repo.dirstate.copies(): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2222 |
ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2223 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2224 |
@command('debugsub', |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2225 |
[('r', 'rev', '', |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2226 |
_('revision to check'), _('REV'))], |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2227 |
_('[-r REV] [REV]')) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2228 |
def debugsub(ui, repo, rev=None): |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
2229 |
ctx = scmutil.revsingle(repo, rev, None) |
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2230 |
for k, v in sorted(ctx.substate.items()): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2231 |
ui.write('path %s\n' % k) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2232 |
ui.write(' source %s\n' % v[0]) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2233 |
ui.write(' revision %s\n' % v[1]) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
2234 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2235 |
@command('debugwalk', walkopts, _('[OPTION]... [FILE]...')) |
820
89985a1b3427
Clean up walk and changes code to use normalised names properly.
Bryan O'Sullivan <bos@serpentine.com>
parents:
815
diff
changeset
|
2236 |
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
|
2237 |
"""show how files match on given patterns""" |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
2238 |
m = scmutil.match(repo[None], pats, opts) |
6585 | 2239 |
items = list(repo.walk(m)) |
1065
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
2240 |
if not items: |
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
2241 |
return |
6586
d3463007d368
walk: return a single value
Matt Mackall <mpm@selenic.com>
parents:
6585
diff
changeset
|
2242 |
fmt = 'f %%-%ds %%-%ds %%s' % ( |
d3463007d368
walk: return a single value
Matt Mackall <mpm@selenic.com>
parents:
6585
diff
changeset
|
2243 |
max([len(abs) for abs in items]), |
d3463007d368
walk: return a single value
Matt Mackall <mpm@selenic.com>
parents:
6585
diff
changeset
|
2244 |
max([len(m.rel(abs)) for abs in items])) |
d3463007d368
walk: return a single value
Matt Mackall <mpm@selenic.com>
parents:
6585
diff
changeset
|
2245 |
for abs in items: |
d3463007d368
walk: return a single value
Matt Mackall <mpm@selenic.com>
parents:
6585
diff
changeset
|
2246 |
line = fmt % (abs, m.rel(abs), m.exact(abs) and 'exact' or '') |
1309
332f225b835c
Make debugwalk strip trailing spaces and remove these from test-walk.out
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1285
diff
changeset
|
2247 |
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
|
2248 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2249 |
@command('debugwireargs', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2250 |
[('', 'three', '', 'three'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2251 |
('', 'four', '', 'four'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2252 |
('', 'five', '', 'five'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2253 |
] + remoteopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2254 |
_('REPO [OPTIONS]... [ONE [TWO]]')) |
13720
9c4e04fe267e
debug: add debugwireargs to test argument passing over the wire
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13697
diff
changeset
|
2255 |
def debugwireargs(ui, repopath, *vals, **opts): |
14556
517e1d88bf7e
hg: change various repository() users to use peer() where appropriate
Matt Mackall <mpm@selenic.com>
parents:
14553
diff
changeset
|
2256 |
repo = hg.peer(ui, opts, repopath) |
13720
9c4e04fe267e
debug: add debugwireargs to test argument passing over the wire
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13697
diff
changeset
|
2257 |
for opt in remoteopts: |
9c4e04fe267e
debug: add debugwireargs to test argument passing over the wire
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13697
diff
changeset
|
2258 |
del opts[opt[1]] |
9c4e04fe267e
debug: add debugwireargs to test argument passing over the wire
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13697
diff
changeset
|
2259 |
args = {} |
9c4e04fe267e
debug: add debugwireargs to test argument passing over the wire
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13697
diff
changeset
|
2260 |
for k, v in opts.iteritems(): |
9c4e04fe267e
debug: add debugwireargs to test argument passing over the wire
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13697
diff
changeset
|
2261 |
if v: |
9c4e04fe267e
debug: add debugwireargs to test argument passing over the wire
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13697
diff
changeset
|
2262 |
args[k] = v |
9c4e04fe267e
debug: add debugwireargs to test argument passing over the wire
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13697
diff
changeset
|
2263 |
# run twice to check that we don't mess up the stream for the next command |
9c4e04fe267e
debug: add debugwireargs to test argument passing over the wire
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13697
diff
changeset
|
2264 |
res1 = repo.debugwireargs(*vals, **args) |
9c4e04fe267e
debug: add debugwireargs to test argument passing over the wire
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13697
diff
changeset
|
2265 |
res2 = repo.debugwireargs(*vals, **args) |
9c4e04fe267e
debug: add debugwireargs to test argument passing over the wire
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13697
diff
changeset
|
2266 |
ui.write("%s\n" % res1) |
9c4e04fe267e
debug: add debugwireargs to test argument passing over the wire
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13697
diff
changeset
|
2267 |
if res1 != res2: |
9c4e04fe267e
debug: add debugwireargs to test argument passing over the wire
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13697
diff
changeset
|
2268 |
ui.warn("%s\n" % res2) |
9c4e04fe267e
debug: add debugwireargs to test argument passing over the wire
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13697
diff
changeset
|
2269 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2270 |
@command('^diff', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2271 |
[('r', 'rev', [], _('revision'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2272 |
('c', 'change', '', _('change made by revision'), _('REV')) |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2273 |
] + diffopts + diffopts2 + walkopts + subrepoopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2274 |
_('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...')) |
732
ba0b6d17a6de
Convert diff command over to using walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
731
diff
changeset
|
2275 |
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
|
2276 |
"""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
|
2277 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2278 |
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
|
2279 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2280 |
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
|
2281 |
|
12389 | 2282 |
.. note:: |
2283 |
diff may generate unexpected results for merges, as it will |
|
2284 |
default to comparing against the working directory's first |
|
2285 |
parent changeset if no revisions are specified. |
|
3822
28134d82db9b
Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents:
3815
diff
changeset
|
2286 |
|
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2287 |
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
|
2288 |
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
|
2289 |
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
|
2290 |
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
|
2291 |
to its parent. |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2292 |
|
10527
9c0ba837dc65
commands: correct diff -c explanation
timeless <timeless@mozdev.org>
parents:
10520
diff
changeset
|
2293 |
Alternatively you can specify -c/--change with a revision to see |
9c0ba837dc65
commands: correct diff -c explanation
timeless <timeless@mozdev.org>
parents:
10520
diff
changeset
|
2294 |
the changes in that changeset relative to its first parent. |
10520 | 2295 |
|
8033
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
2296 |
Without the -a/--text option, diff will avoid generating diffs of |
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
2297 |
files it detects as binary. With -a, diff will generate a diff |
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
2298 |
anyway, probably with undesirable results. |
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
2299 |
|
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
2300 |
Use the -g/--git option to generate diffs in the git extended diff |
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
2301 |
format. For more information, read :hg:`help diffs`. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
2302 |
|
15110 | 2303 |
.. container:: verbose |
2304 |
||
2305 |
Examples: |
|
2306 |
||
2307 |
- compare a file in the current working directory to its parent:: |
|
2308 |
||
2309 |
hg diff foo.c |
|
2310 |
||
2311 |
- compare two historical versions of a directory, with rename info:: |
|
2312 |
||
2313 |
hg diff --git -r 1.0:1.2 lib/ |
|
2314 |
||
2315 |
- get change stats relative to the last change on some date:: |
|
2316 |
||
2317 |
hg diff --stat -r "date('may 2')" |
|
2318 |
||
2319 |
- diff all newly-added files that contain a keyword:: |
|
2320 |
||
2321 |
hg diff "set:added() and grep(GNU)" |
|
2322 |
||
2323 |
- compare a revision and its parents:: |
|
2324 |
||
2325 |
hg diff -c 9353 # compare against first parent |
|
2326 |
hg diff -r 9353^:9353 # same using revset syntax |
|
2327 |
hg diff -r 9353^2:9353 # compare against the second parent |
|
2328 |
||
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
2329 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2330 |
""" |
7628
9c6ae2e09e11
diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents:
7622
diff
changeset
|
2331 |
|
9c6ae2e09e11
diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents:
7622
diff
changeset
|
2332 |
revs = opts.get('rev') |
9c6ae2e09e11
diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents:
7622
diff
changeset
|
2333 |
change = opts.get('change') |
9640
9e76232fbfbe
diff: add --stat for diffstat output
Brodie Rao <me+hg@dackz.net>
parents:
9636
diff
changeset
|
2334 |
stat = opts.get('stat') |
9857
24bc6e414610
diff: change --inverse to --reverse
Martin Geisler <mg@lazybytes.net>
parents:
9839
diff
changeset
|
2335 |
reverse = opts.get('reverse') |
7628
9c6ae2e09e11
diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents:
7622
diff
changeset
|
2336 |
|
9c6ae2e09e11
diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents:
7622
diff
changeset
|
2337 |
if revs and change: |
9c6ae2e09e11
diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents:
7622
diff
changeset
|
2338 |
msg = _('cannot specify --rev and --change at the same time') |
9c6ae2e09e11
diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents:
7622
diff
changeset
|
2339 |
raise util.Abort(msg) |
9c6ae2e09e11
diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents:
7622
diff
changeset
|
2340 |
elif change: |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
2341 |
node2 = scmutil.revsingle(repo, change, None).node() |
13878
a8d13ee0ce68
misc: replace .parents()[0] with p1()
Matt Mackall <mpm@selenic.com>
parents:
13855
diff
changeset
|
2342 |
node1 = repo[node2].p1().node() |
7628
9c6ae2e09e11
diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov <yozh@mx1.ru>
parents:
7622
diff
changeset
|
2343 |
else: |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
2344 |
node1, node2 = scmutil.revpair(repo, revs) |
245 | 2345 |
|
9857
24bc6e414610
diff: change --inverse to --reverse
Martin Geisler <mg@lazybytes.net>
parents:
9839
diff
changeset
|
2346 |
if reverse: |
9725
3f522d2fa633
diff: add --inverse option
Yannick Gingras <ygingras@ygingras.net>
parents:
9718
diff
changeset
|
2347 |
node1, node2 = node2, node1 |
3f522d2fa633
diff: add --inverse option
Yannick Gingras <ygingras@ygingras.net>
parents:
9718
diff
changeset
|
2348 |
|
9642
7d17794f08a9
diffstat: with --git, mark binary files with Bin
Brodie Rao <me+hg@dackz.net>
parents:
9640
diff
changeset
|
2349 |
diffopts = patch.diffopts(ui, opts) |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
2350 |
m = scmutil.match(repo[node2], pats, opts) |
12167
d2c5b0927c28
diff: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12166
diff
changeset
|
2351 |
cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat, |
d2c5b0927c28
diff: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12166
diff
changeset
|
2352 |
listsubrepos=opts.get('subrepos')) |
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
|
2353 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2354 |
@command('^export', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2355 |
[('o', 'output', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2356 |
_('print output to file with formatted name'), _('FORMAT')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2357 |
('', 'switch-parent', None, _('diff against the second parent')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2358 |
('r', 'rev', [], _('revisions to export'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2359 |
] + diffopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2360 |
_('[OPTION]... [-o OUTFILESPEC] REV...')) |
580 | 2361 |
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
|
2362 |
"""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
|
2363 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2364 |
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
|
2365 |
|
10334
3d75c691b77d
commands: fix the list of changeset header information in 'hg help export'
Steve Losh <steve@stevelosh.com>
parents:
10331
diff
changeset
|
2366 |
The information shown in the changeset header is: author, date, |
10335
6ae4f390ec61
commands: fix more changeset header information in 'hg help export'
Steve Losh <steve@stevelosh.com>
parents:
10334
diff
changeset
|
2367 |
branch name (if non-default), changeset hash, parent(s) and commit |
6ae4f390ec61
commands: fix more changeset header information in 'hg help export'
Steve Losh <steve@stevelosh.com>
parents:
10334
diff
changeset
|
2368 |
comment. |
3822
28134d82db9b
Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents:
3815
diff
changeset
|
2369 |
|
12390
aff4afdcfd2b
Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents:
12389
diff
changeset
|
2370 |
.. note:: |
aff4afdcfd2b
Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents:
12389
diff
changeset
|
2371 |
export may generate unexpected diff output for merge |
aff4afdcfd2b
Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents:
12389
diff
changeset
|
2372 |
changesets, as it will compare the merge changeset against its |
aff4afdcfd2b
Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents:
12389
diff
changeset
|
2373 |
first parent only. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2374 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2375 |
Output may be to a file, in which case the name of the file is |
9892
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
2376 |
given using a format string. The formatting rules are as follows: |
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
2377 |
|
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
2378 |
:``%%``: literal "%" character |
11718
3e979f47a4c9
help: fix bytes/digit confusion for hashes
Matt Mackall <mpm@selenic.com>
parents:
11697
diff
changeset
|
2379 |
:``%H``: changeset hash (40 hexadecimal digits) |
9892
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
2380 |
:``%N``: number of patches being generated |
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
2381 |
:``%R``: changeset revision number |
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
2382 |
:``%b``: basename of the exporting repository |
11718
3e979f47a4c9
help: fix bytes/digit confusion for hashes
Matt Mackall <mpm@selenic.com>
parents:
11697
diff
changeset
|
2383 |
:``%h``: short-form changeset hash (12 hexadecimal digits) |
14986
70e11de6964d
export: add %m to file format string (first line of the commit message)
Andrzej Bieniek <andyhelp@gmail.com>
parents:
14954
diff
changeset
|
2384 |
:``%m``: first line of the commit message (only alphanumeric characters) |
9892
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
2385 |
:``%n``: zero-padded sequence number, starting at 1 |
4322e39bd525
commands: use field lists instead of literal blocks in docstrings
Martin Geisler <mg@lazybytes.net>
parents:
9891
diff
changeset
|
2386 |
:``%r``: zero-padded changeset revision number |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2387 |
|
8033
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
2388 |
Without the -a/--text option, export will avoid generating diffs |
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
2389 |
of files it detects as binary. With -a, export will generate a |
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
2390 |
diff anyway, probably with undesirable results. |
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
2391 |
|
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
2392 |
Use the -g/--git option to generate diffs in the git extended diff |
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
2393 |
format. See :hg:`help diffs` for more information. |
7307
56380212d630
help: commands supporting --git point to the gitdiffs topic (issue1352)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7303
diff
changeset
|
2394 |
|
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2395 |
With the --switch-parent option, the diff will be against the |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2396 |
second parent. It can be useful to review a merge. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
2397 |
|
15111 | 2398 |
.. container:: verbose |
2399 |
||
2400 |
Examples: |
|
2401 |
||
2402 |
- use export and import to transplant a bugfix to the current |
|
2403 |
branch:: |
|
2404 |
||
2405 |
hg export -r 9353 | hg import - |
|
2406 |
||
2407 |
- export all the changesets between two revisions to a file with |
|
2408 |
rename information:: |
|
2409 |
||
2410 |
hg export --git -r 123:150 > changes.txt |
|
2411 |
||
2412 |
- split outgoing changes into a series of patches with |
|
2413 |
descriptive names:: |
|
2414 |
||
2415 |
hg export -r "outgoing()" -o "%n-%m.patch" |
|
2416 |
||
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
2417 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2418 |
""" |
10015
b5f352f33520
commands.export: accept -r option as revision specification
Alexander Solovyov <piranha@piranha.org.ua>
parents:
10014
diff
changeset
|
2419 |
changesets += tuple(opts.get('rev', [])) |
610
4c02464cb9f0
check export options for changeset before running
shaleh@speakeasy.net
parents:
609
diff
changeset
|
2420 |
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
|
2421 |
raise util.Abort(_("export requires at least one changeset")) |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
2422 |
revs = scmutil.revrange(repo, changesets) |
2874
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
2423 |
if len(revs) > 1: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
2424 |
ui.note(_('exporting patches:\n')) |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
2425 |
else: |
4ec58b157265
refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2871
diff
changeset
|
2426 |
ui.note(_('exporting patch:\n')) |
10611
e764f24a45ee
patch/diff: move patch.export() to cmdutil.export()
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10596
diff
changeset
|
2427 |
cmdutil.export(repo, revs, template=opts.get('output'), |
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
2428 |
switch_parent=opts.get('switch_parent'), |
2888
3848488244fc
Move ui.diffopts to patch.diffopts where it belongs
Matt Mackall <mpm@selenic.com>
parents:
2883
diff
changeset
|
2429 |
opts=patch.diffopts(ui, opts)) |
246
96cde50a746f
Migrate rawcommit, import, export, history, and merge
mpm@selenic.com
parents:
245
diff
changeset
|
2430 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2431 |
@command('^forget', walkopts, _('[OPTION]... FILE...')) |
8902
b9a8b616521d
Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents:
8879
diff
changeset
|
2432 |
def forget(ui, repo, *pats, **opts): |
b9a8b616521d
Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents:
8879
diff
changeset
|
2433 |
"""forget the specified files on the next commit |
b9a8b616521d
Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents:
8879
diff
changeset
|
2434 |
|
b9a8b616521d
Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents:
8879
diff
changeset
|
2435 |
Mark the specified files so they will no longer be tracked |
b9a8b616521d
Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents:
8879
diff
changeset
|
2436 |
after the next commit. |
b9a8b616521d
Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents:
8879
diff
changeset
|
2437 |
|
b9a8b616521d
Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents:
8879
diff
changeset
|
2438 |
This only removes files from the current branch, not from the |
b9a8b616521d
Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents:
8879
diff
changeset
|
2439 |
entire project history, and it does not delete them from the |
b9a8b616521d
Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents:
8879
diff
changeset
|
2440 |
working directory. |
b9a8b616521d
Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents:
8879
diff
changeset
|
2441 |
|
11193
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11185
diff
changeset
|
2442 |
To undo a forget before the next commit, see :hg:`add`. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
2443 |
|
15118 | 2444 |
.. container:: verbose |
2445 |
||
2446 |
Examples: |
|
2447 |
||
2448 |
- forget newly-added binary files:: |
|
2449 |
||
2450 |
hg forget "set:added() and binary()" |
|
2451 |
||
2452 |
- forget files that would be excluded by .hgignore:: |
|
2453 |
||
2454 |
hg forget "set:hgignore()" |
|
2455 |
||
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
2456 |
Returns 0 on success. |
8902
b9a8b616521d
Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents:
8879
diff
changeset
|
2457 |
""" |
b9a8b616521d
Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents:
8879
diff
changeset
|
2458 |
|
b9a8b616521d
Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents:
8879
diff
changeset
|
2459 |
if not pats: |
b9a8b616521d
Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents:
8879
diff
changeset
|
2460 |
raise util.Abort(_('no files specified')) |
b9a8b616521d
Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents:
8879
diff
changeset
|
2461 |
|
15912
2bd54ffaa27e
forget: fix subrepo recursion for explicit path handling
David M. Carr <david@carrclan.us>
parents:
15911
diff
changeset
|
2462 |
m = scmutil.match(repo[None], pats, opts) |
2bd54ffaa27e
forget: fix subrepo recursion for explicit path handling
David M. Carr <david@carrclan.us>
parents:
15911
diff
changeset
|
2463 |
rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0] |
2bd54ffaa27e
forget: fix subrepo recursion for explicit path handling
David M. Carr <david@carrclan.us>
parents:
15911
diff
changeset
|
2464 |
return rejected and 1 or 0 |
8902
b9a8b616521d
Add a forget command for easily untracking files.
Steve Losh <steve@stevelosh.com>
parents:
8879
diff
changeset
|
2465 |
|
15240
bfb93963bb39
graft: add user, date, and tool options
Matt Mackall <mpm@selenic.com>
parents:
15239
diff
changeset
|
2466 |
@command( |
bfb93963bb39
graft: add user, date, and tool options
Matt Mackall <mpm@selenic.com>
parents:
15239
diff
changeset
|
2467 |
'graft', |
15241
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2468 |
[('c', 'continue', False, _('resume interrupted graft')), |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2469 |
('e', 'edit', False, _('invoke editor on commit messages')), |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2470 |
('D', 'currentdate', False, |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2471 |
_('record the current date as commit date')), |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2472 |
('U', 'currentuser', False, |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2473 |
_('record the current user as committer'), _('DATE'))] |
15240
bfb93963bb39
graft: add user, date, and tool options
Matt Mackall <mpm@selenic.com>
parents:
15239
diff
changeset
|
2474 |
+ commitopts2 + mergetoolopts, |
15238
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2475 |
_('[OPTION]... REVISION...')) |
15241
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2476 |
def graft(ui, repo, *revs, **opts): |
15238
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2477 |
'''copy changes from other branches onto the current branch |
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2478 |
|
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2479 |
This command uses Mercurial's merge logic to copy individual |
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2480 |
changes from other branches without merging branches in the |
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2481 |
history graph. This is sometimes known as 'backporting' or |
15242
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2482 |
'cherry-picking'. By default, graft will copy user, date, and |
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2483 |
description from the source changesets. |
15238
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2484 |
|
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2485 |
Changesets that are ancestors of the current revision, that have |
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2486 |
already been grafted, or that are merges will be skipped. |
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2487 |
|
15241
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2488 |
If a graft merge results in conflicts, the graft process is |
15701
32a6e00e4cfe
graft: use consistent language in help
Kevin Bullock <kbullock@ringworld.org>
parents:
15633
diff
changeset
|
2489 |
interrupted so that the current merge can be manually resolved. |
32a6e00e4cfe
graft: use consistent language in help
Kevin Bullock <kbullock@ringworld.org>
parents:
15633
diff
changeset
|
2490 |
Once all conflicts are addressed, the graft process can be |
32a6e00e4cfe
graft: use consistent language in help
Kevin Bullock <kbullock@ringworld.org>
parents:
15633
diff
changeset
|
2491 |
continued with the -c/--continue option. |
15241
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2492 |
|
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2493 |
.. note:: |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2494 |
The -c/--continue option does not reapply earlier options. |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2495 |
|
15242
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2496 |
.. container:: verbose |
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2497 |
|
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2498 |
Examples: |
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2499 |
|
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2500 |
- copy a single change to the stable branch and edit its description:: |
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2501 |
|
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2502 |
hg update stable |
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2503 |
hg graft --edit 9393 |
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2504 |
|
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2505 |
- graft a range of changesets with one exception, updating dates:: |
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2506 |
|
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2507 |
hg graft -D "2085::2093 and not 2091" |
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2508 |
|
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2509 |
- continue a graft after resolving conflicts:: |
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2510 |
|
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2511 |
hg graft -c |
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2512 |
|
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2513 |
- show the source of a grafted changeset:: |
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2514 |
|
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2515 |
hg log --debug -r tip |
dac2edce4e4a
graft: add examples and information about copied metadata
Matt Mackall <mpm@selenic.com>
parents:
15241
diff
changeset
|
2516 |
|
15238
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2517 |
Returns 0 on successful completion. |
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2518 |
''' |
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2519 |
|
15240
bfb93963bb39
graft: add user, date, and tool options
Matt Mackall <mpm@selenic.com>
parents:
15239
diff
changeset
|
2520 |
if not opts.get('user') and opts.get('currentuser'): |
bfb93963bb39
graft: add user, date, and tool options
Matt Mackall <mpm@selenic.com>
parents:
15239
diff
changeset
|
2521 |
opts['user'] = ui.username() |
bfb93963bb39
graft: add user, date, and tool options
Matt Mackall <mpm@selenic.com>
parents:
15239
diff
changeset
|
2522 |
if not opts.get('date') and opts.get('currentdate'): |
bfb93963bb39
graft: add user, date, and tool options
Matt Mackall <mpm@selenic.com>
parents:
15239
diff
changeset
|
2523 |
opts['date'] = "%d %d" % util.makedate() |
bfb93963bb39
graft: add user, date, and tool options
Matt Mackall <mpm@selenic.com>
parents:
15239
diff
changeset
|
2524 |
|
15239 | 2525 |
editor = None |
2526 |
if opts.get('edit'): |
|
2527 |
editor = cmdutil.commitforceeditor |
|
2528 |
||
15241
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2529 |
cont = False |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2530 |
if opts['continue']: |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2531 |
cont = True |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2532 |
if revs: |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2533 |
raise util.Abort(_("can't specify --continue and revisions")) |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2534 |
# read in unfinished revisions |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2535 |
try: |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2536 |
nodes = repo.opener.read('graftstate').splitlines() |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2537 |
revs = [repo[node].rev() for node in nodes] |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2538 |
except IOError, inst: |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2539 |
if inst.errno != errno.ENOENT: |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2540 |
raise |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2541 |
raise util.Abort(_("no graft state found, can't continue")) |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2542 |
else: |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2543 |
cmdutil.bailifchanged(repo) |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2544 |
if not revs: |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2545 |
raise util.Abort(_('no revisions specified')) |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2546 |
revs = scmutil.revrange(repo, revs) |
15238
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2547 |
|
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2548 |
# check for merges |
15404
c1eb8398fe82
localrepo: convert various repo.set() users to repo.revs()
Matt Mackall <mpm@selenic.com>
parents:
15381
diff
changeset
|
2549 |
for rev in repo.revs('%ld and merge()', revs): |
c1eb8398fe82
localrepo: convert various repo.set() users to repo.revs()
Matt Mackall <mpm@selenic.com>
parents:
15381
diff
changeset
|
2550 |
ui.warn(_('skipping ungraftable merge revision %s\n') % rev) |
c1eb8398fe82
localrepo: convert various repo.set() users to repo.revs()
Matt Mackall <mpm@selenic.com>
parents:
15381
diff
changeset
|
2551 |
revs.remove(rev) |
15238
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2552 |
if not revs: |
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2553 |
return -1 |
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2554 |
|
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2555 |
# check for ancestors of dest branch |
15404
c1eb8398fe82
localrepo: convert various repo.set() users to repo.revs()
Matt Mackall <mpm@selenic.com>
parents:
15381
diff
changeset
|
2556 |
for rev in repo.revs('::. and %ld', revs): |
c1eb8398fe82
localrepo: convert various repo.set() users to repo.revs()
Matt Mackall <mpm@selenic.com>
parents:
15381
diff
changeset
|
2557 |
ui.warn(_('skipping ancestor revision %s\n') % rev) |
c1eb8398fe82
localrepo: convert various repo.set() users to repo.revs()
Matt Mackall <mpm@selenic.com>
parents:
15381
diff
changeset
|
2558 |
revs.remove(rev) |
15238
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2559 |
if not revs: |
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2560 |
return -1 |
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2561 |
|
15508
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2562 |
# analyze revs for earlier grafts |
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2563 |
ids = {} |
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2564 |
for ctx in repo.set("%ld", revs): |
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2565 |
ids[ctx.hex()] = ctx.rev() |
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2566 |
n = ctx.extra().get('source') |
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2567 |
if n: |
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2568 |
ids[n] = ctx.rev() |
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2569 |
|
15238
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2570 |
# check ancestors for earlier grafts |
15359
a5a8adf95e51
graft: fix duplicate scan message
Matt Mackall <mpm@selenic.com>
parents:
15357
diff
changeset
|
2571 |
ui.debug('scanning for duplicate grafts\n') |
15238
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2572 |
for ctx in repo.set("::. - ::%ld", revs): |
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2573 |
n = ctx.extra().get('source') |
15508
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2574 |
if n in ids: |
15238
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2575 |
r = repo[n].rev() |
15360
73628b32d0c0
graft: fix duplicate filter logic
Matt Mackall <mpm@selenic.com>
parents:
15359
diff
changeset
|
2576 |
if r in revs: |
73628b32d0c0
graft: fix duplicate filter logic
Matt Mackall <mpm@selenic.com>
parents:
15359
diff
changeset
|
2577 |
ui.warn(_('skipping already grafted revision %s\n') % r) |
73628b32d0c0
graft: fix duplicate filter logic
Matt Mackall <mpm@selenic.com>
parents:
15359
diff
changeset
|
2578 |
revs.remove(r) |
15508
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2579 |
elif ids[n] in revs: |
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2580 |
ui.warn(_('skipping already grafted revision %s ' |
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2581 |
'(same origin %d)\n') % (ids[n], r)) |
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2582 |
revs.remove(ids[n]) |
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2583 |
elif ctx.hex() in ids: |
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2584 |
r = ids[ctx.hex()] |
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2585 |
ui.warn(_('skipping already grafted revision %s ' |
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2586 |
'(was grafted from %d)\n') % (r, ctx.rev())) |
00276525e2b7
graft: disallow grafting grafted csets in specific situations (issue3091)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15506
diff
changeset
|
2587 |
revs.remove(r) |
15238
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2588 |
if not revs: |
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2589 |
return -1 |
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2590 |
|
15241
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2591 |
for pos, ctx in enumerate(repo.set("%ld", revs)): |
15238
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2592 |
current = repo['.'] |
15463
e1005da0ae04
graft: mark a string for translation
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15381
diff
changeset
|
2593 |
ui.status(_('grafting revision %s\n') % ctx.rev()) |
15241
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2594 |
|
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2595 |
# we don't merge the first commit when continuing |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2596 |
if not cont: |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2597 |
# perform the graft merge with p1(rev) as 'ancestor' |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2598 |
try: |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2599 |
# ui.forcemerge is an internal variable, do not document |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2600 |
repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', '')) |
15856
6bed6cc6d0d0
commands: partial backout of fbb68b382040
Martin Geisler <mg@aragost.com>
parents:
15855
diff
changeset
|
2601 |
stats = mergemod.update(repo, ctx.node(), True, True, False, |
6bed6cc6d0d0
commands: partial backout of fbb68b382040
Martin Geisler <mg@aragost.com>
parents:
15855
diff
changeset
|
2602 |
ctx.p1().node()) |
15241
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2603 |
finally: |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2604 |
ui.setconfig('ui', 'forcemerge', '') |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2605 |
# drop the second merge parent |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2606 |
repo.dirstate.setparents(current.node(), nullid) |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2607 |
repo.dirstate.write() |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2608 |
# fix up dirstate for copies and renames |
16163
807f796e9b1a
graft: use proper revisions for copy detection (issue3265)
Matt Mackall <mpm@selenic.com>
parents:
16107
diff
changeset
|
2609 |
cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev()) |
15241
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2610 |
# report any conflicts |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2611 |
if stats and stats[3] > 0: |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2612 |
# write out state for --continue |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2613 |
nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]] |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2614 |
repo.opener.write('graftstate', ''.join(nodelines)) |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2615 |
raise util.Abort( |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2616 |
_("unresolved conflicts, can't continue"), |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2617 |
hint=_('use hg resolve and hg graft --continue')) |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2618 |
else: |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2619 |
cont = False |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2620 |
|
15238
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2621 |
# commit |
15506
dc9fb7015d7f
graft: preserve original source in subsequent grafts
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15463
diff
changeset
|
2622 |
source = ctx.extra().get('source') |
dc9fb7015d7f
graft: preserve original source in subsequent grafts
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15463
diff
changeset
|
2623 |
if not source: |
dc9fb7015d7f
graft: preserve original source in subsequent grafts
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15463
diff
changeset
|
2624 |
source = ctx.hex() |
dc9fb7015d7f
graft: preserve original source in subsequent grafts
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
15463
diff
changeset
|
2625 |
extra = {'source': source} |
15240
bfb93963bb39
graft: add user, date, and tool options
Matt Mackall <mpm@selenic.com>
parents:
15239
diff
changeset
|
2626 |
user = ctx.user() |
bfb93963bb39
graft: add user, date, and tool options
Matt Mackall <mpm@selenic.com>
parents:
15239
diff
changeset
|
2627 |
if opts.get('user'): |
bfb93963bb39
graft: add user, date, and tool options
Matt Mackall <mpm@selenic.com>
parents:
15239
diff
changeset
|
2628 |
user = opts['user'] |
bfb93963bb39
graft: add user, date, and tool options
Matt Mackall <mpm@selenic.com>
parents:
15239
diff
changeset
|
2629 |
date = ctx.date() |
bfb93963bb39
graft: add user, date, and tool options
Matt Mackall <mpm@selenic.com>
parents:
15239
diff
changeset
|
2630 |
if opts.get('date'): |
bfb93963bb39
graft: add user, date, and tool options
Matt Mackall <mpm@selenic.com>
parents:
15239
diff
changeset
|
2631 |
date = opts['date'] |
bfb93963bb39
graft: add user, date, and tool options
Matt Mackall <mpm@selenic.com>
parents:
15239
diff
changeset
|
2632 |
repo.commit(text=ctx.description(), user=user, |
bfb93963bb39
graft: add user, date, and tool options
Matt Mackall <mpm@selenic.com>
parents:
15239
diff
changeset
|
2633 |
date=date, extra=extra, editor=editor) |
15238
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2634 |
|
15241
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2635 |
# remove state when we complete successfully |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2636 |
if os.path.exists(repo.join('graftstate')): |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2637 |
util.unlinkpath(repo.join('graftstate')) |
e4d135632f6d
graft: add --continue support
Matt Mackall <mpm@selenic.com>
parents:
15240
diff
changeset
|
2638 |
|
15238
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2639 |
return 0 |
2d710c12ffc0
graft: add initial implementation
Matt Mackall <mpm@selenic.com>
parents:
15232
diff
changeset
|
2640 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2641 |
@command('grep', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2642 |
[('0', 'print0', None, _('end fields with NUL')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2643 |
('', 'all', None, _('print all revisions that match')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2644 |
('a', 'text', None, _('treat all files as text')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2645 |
('f', 'follow', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2646 |
_('follow changeset history,' |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2647 |
' or file history across copies and renames')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2648 |
('i', 'ignore-case', None, _('ignore case when matching')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2649 |
('l', 'files-with-matches', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2650 |
_('print only filenames and revisions that match')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2651 |
('n', 'line-number', None, _('print matching line numbers')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2652 |
('r', 'rev', [], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2653 |
_('only search files changed within revision range'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2654 |
('u', 'user', None, _('list the author (long with -v)')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2655 |
('d', 'date', None, _('list the date (short with -q)')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2656 |
] + walkopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2657 |
_('[OPTION]... PATTERN [FILE]...')) |
1108
7a75d8fbbdaf
Remove some options from 'hg grep':
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1106
diff
changeset
|
2658 |
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
|
2659 |
"""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
|
2660 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2661 |
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
|
2662 |
|
6448
cd3d49ffc6f6
Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents:
6442
diff
changeset
|
2663 |
This command behaves differently than Unix grep. It only accepts |
cd3d49ffc6f6
Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents:
6442
diff
changeset
|
2664 |
Python/Perl regexps. It searches repository history, not the |
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2665 |
working directory. It always prints the revision number in which a |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2666 |
match appears. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2667 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2668 |
By default, grep only prints output for the first revision of a |
6448
cd3d49ffc6f6
Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents:
6442
diff
changeset
|
2669 |
file in which it finds a match. To get it to print every revision |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2670 |
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
|
2671 |
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
|
2672 |
use the --all flag. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
2673 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
2674 |
Returns 0 if a match is found, 1 otherwise. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2675 |
""" |
15765
1ef46bcd76f8
grep: make multiline mode the default (BC)
Matt Mackall <mpm@selenic.com>
parents:
15744
diff
changeset
|
2676 |
reflags = re.M |
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
2677 |
if opts.get('ignore_case'): |
1065
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
2678 |
reflags |= re.I |
4877
242026115e6a
hg grep: handle re.compile errors & update tests/test-grep
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
4835
diff
changeset
|
2679 |
try: |
242026115e6a
hg grep: handle re.compile errors & update tests/test-grep
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
4835
diff
changeset
|
2680 |
regexp = re.compile(pattern, reflags) |
12385
9a93f4fb141b
grep: only catch re.error when compiling regular expressions
Brodie Rao <brodie@bitheap.org>
parents:
12382
diff
changeset
|
2681 |
except re.error, inst: |
6057
218d5b9aa466
Remove trailing ! from two error messages as this was confusing.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6048
diff
changeset
|
2682 |
ui.warn(_("grep: invalid match pattern: %s\n") % inst) |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
2683 |
return 1 |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
2684 |
sep, eol = ':', '\n' |
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
2685 |
if opts.get('print0'): |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
2686 |
sep = eol = '\0' |
1057 | 2687 |
|
9097
431462bd8478
fix memory usage of revlog caches by limiting cache size [issue1639]
Matt Mackall <mpm@selenic.com>
parents:
8995
diff
changeset
|
2688 |
getfile = util.lrucachefunc(repo.file) |
1057 | 2689 |
|
2690 |
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
|
2691 |
begin = 0 |
4eab07ef66e2
grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents:
1058
diff
changeset
|
2692 |
linenum = 0 |
4eab07ef66e2
grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents:
1058
diff
changeset
|
2693 |
while True: |
4eab07ef66e2
grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents:
1058
diff
changeset
|
2694 |
match = regexp.search(body, begin) |
1065
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
2695 |
if not match: |
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
2696 |
break |
1059
4eab07ef66e2
grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents:
1058
diff
changeset
|
2697 |
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
|
2698 |
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
|
2699 |
lstart = body.rfind('\n', begin, mstart) + 1 or begin |
15293
0e34699d6988
grep: correct handling of matching lines without line ending (issue3050)
Mads Kiilerich <mads@kiilerich.com>
parents:
15278
diff
changeset
|
2700 |
begin = body.find('\n', mend) + 1 or len(body) + 1 |
7230
261a9f47b44b
grep: avoid infinite loop when trailing newline is missing
Matt Mackall <mpm@selenic.com>
parents:
7228
diff
changeset
|
2701 |
lend = begin - 1 |
1059
4eab07ef66e2
grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents:
1058
diff
changeset
|
2702 |
yield linenum, mstart - lstart, mend - lstart, body[lstart:lend] |
1057 | 2703 |
|
1559
59b3639df0a9
Convert all classes to new-style classes by deriving them from object.
Eric Hopper <hopper@omnifarious.org>
parents:
1552
diff
changeset
|
2704 |
class linestate(object): |
1057 | 2705 |
def __init__(self, line, linenum, colstart, colend): |
2706 |
self.line = line |
|
2707 |
self.linenum = linenum |
|
2708 |
self.colstart = colstart |
|
2709 |
self.colend = colend |
|
2869
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
2710 |
|
6469
fb502719c75c
python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore <p.f.moore@gmail.com>
parents:
6468
diff
changeset
|
2711 |
def __hash__(self): |
fb502719c75c
python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore <p.f.moore@gmail.com>
parents:
6468
diff
changeset
|
2712 |
return hash((self.linenum, self.line)) |
fb502719c75c
python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore <p.f.moore@gmail.com>
parents:
6468
diff
changeset
|
2713 |
|
1065
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
2714 |
def __eq__(self, other): |
6e94c0365d98
Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
2715 |
return self.line == other.line |
1057 | 2716 |
|
2717 |
matches = {} |
|
2870
8eaaf1321bfe
grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents:
2869
diff
changeset
|
2718 |
copies = {} |
1057 | 2719 |
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
|
2720 |
matches[rev].setdefault(fn, []) |
1057 | 2721 |
m = matches[rev][fn] |
2722 |
for lnum, cstart, cend, line in matchlines(body): |
|
2723 |
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
|
2724 |
m.append(s) |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
2725 |
|
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
2726 |
def difflinestates(a, b): |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
2727 |
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
|
2728 |
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
|
2729 |
if tag == 'insert': |
3472
df7202f6887c
use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3471
diff
changeset
|
2730 |
for i in xrange(blo, bhi): |
2869
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
2731 |
yield ('+', b[i]) |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
2732 |
elif tag == 'delete': |
3472
df7202f6887c
use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3471
diff
changeset
|
2733 |
for i in xrange(alo, ahi): |
2869
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
2734 |
yield ('-', a[i]) |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
2735 |
elif tag == 'replace': |
3472
df7202f6887c
use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3471
diff
changeset
|
2736 |
for i in xrange(alo, ahi): |
2869
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
2737 |
yield ('-', a[i]) |
3472
df7202f6887c
use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3471
diff
changeset
|
2738 |
for i in xrange(blo, bhi): |
2869
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
2739 |
yield ('+', b[i]) |
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
2740 |
|
9655
6d7d3f849062
walkchangerevs: internalize ctx caching
Matt Mackall <mpm@selenic.com>
parents:
9654
diff
changeset
|
2741 |
def display(fn, ctx, pstates, states): |
6d7d3f849062
walkchangerevs: internalize ctx caching
Matt Mackall <mpm@selenic.com>
parents:
9654
diff
changeset
|
2742 |
rev = ctx.rev() |
6134
7b937b26adf7
Make annotae/grep print short dates with -q/--quiet.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6133
diff
changeset
|
2743 |
datefunc = ui.quiet and util.shortdate or util.datestr |
3951
cb66641cdee3
grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3950
diff
changeset
|
2744 |
found = False |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
2745 |
filerevmatches = {} |
13920
332e400764e5
grep: don't print data from binary files for matches (issue2614)
Md. O. Shayan <mdoshayan@gmail.com>
parents:
13911
diff
changeset
|
2746 |
def binary(): |
332e400764e5
grep: don't print data from binary files for matches (issue2614)
Md. O. Shayan <mdoshayan@gmail.com>
parents:
13911
diff
changeset
|
2747 |
flog = getfile(fn) |
332e400764e5
grep: don't print data from binary files for matches (issue2614)
Md. O. Shayan <mdoshayan@gmail.com>
parents:
13911
diff
changeset
|
2748 |
return util.binary(flog.read(ctx.filenode(fn))) |
332e400764e5
grep: don't print data from binary files for matches (issue2614)
Md. O. Shayan <mdoshayan@gmail.com>
parents:
13911
diff
changeset
|
2749 |
|
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
2750 |
if opts.get('all'): |
8849
80cc4b1a62d0
compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
8834
diff
changeset
|
2751 |
iter = difflinestates(pstates, states) |
2869
81f351c5264d
grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents:
2854
diff
changeset
|
2752 |
else: |
8849
80cc4b1a62d0
compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
8834
diff
changeset
|
2753 |
iter = [('', l) for l in states] |
3951
cb66641cdee3
grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3950
diff
changeset
|
2754 |
for change, l in iter: |
9655
6d7d3f849062
walkchangerevs: internalize ctx caching
Matt Mackall <mpm@selenic.com>
parents:
9654
diff
changeset
|
2755 |
cols = [fn, str(rev)] |
10816
635d601e8f21
grep: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10654
diff
changeset
|
2756 |
before, match, after = None, None, None |
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
2757 |
if opts.get('line_number'): |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2758 |
cols.append(str(l.linenum)) |
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
2759 |
if opts.get('all'): |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2760 |
cols.append(change) |
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
2761 |
if opts.get('user'): |
9655
6d7d3f849062
walkchangerevs: internalize ctx caching
Matt Mackall <mpm@selenic.com>
parents:
9654
diff
changeset
|
2762 |
cols.append(ui.shortuser(ctx.user())) |
6133
779f2309d67a
Add hg grep -d/--date to list the commit date of matched revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6109
diff
changeset
|
2763 |
if opts.get('date'): |
9655
6d7d3f849062
walkchangerevs: internalize ctx caching
Matt Mackall <mpm@selenic.com>
parents:
9654
diff
changeset
|
2764 |
cols.append(datefunc(ctx.date())) |
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
2765 |
if opts.get('files_with_matches'): |
9655
6d7d3f849062
walkchangerevs: internalize ctx caching
Matt Mackall <mpm@selenic.com>
parents:
9654
diff
changeset
|
2766 |
c = (fn, rev) |
1615
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2767 |
if c in filerevmatches: |
83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1607
diff
changeset
|
2768 |
continue |
1146
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
2769 |
filerevmatches[c] = 1 |
9061f79c6c6f
grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents:
1145
diff
changeset
|
2770 |
else: |
10816
635d601e8f21
grep: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10654
diff
changeset
|
2771 |
before = l.line[:l.colstart] |
635d601e8f21
grep: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10654
diff
changeset
|
2772 |
match = l.line[l.colstart:l.colend] |
635d601e8f21
grep: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10654
diff
changeset
|
2773 |
after = l.line[l.colend:] |
635d601e8f21
grep: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10654
diff
changeset
|
2774 |
ui.write(sep.join(cols)) |
635d601e8f21
grep: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10654
diff
changeset
|
2775 |
if before is not None: |
13920
332e400764e5
grep: don't print data from binary files for matches (issue2614)
Md. O. Shayan <mdoshayan@gmail.com>
parents:
13911
diff
changeset
|
2776 |
if not opts.get('text') and binary(): |
332e400764e5
grep: don't print data from binary files for matches (issue2614)
Md. O. Shayan <mdoshayan@gmail.com>
parents:
13911
diff
changeset
|
2777 |
ui.write(sep + " Binary file matches") |
332e400764e5
grep: don't print data from binary files for matches (issue2614)
Md. O. Shayan <mdoshayan@gmail.com>
parents:
13911
diff
changeset
|
2778 |
else: |
332e400764e5
grep: don't print data from binary files for matches (issue2614)
Md. O. Shayan <mdoshayan@gmail.com>
parents:
13911
diff
changeset
|
2779 |
ui.write(sep + before) |
332e400764e5
grep: don't print data from binary files for matches (issue2614)
Md. O. Shayan <mdoshayan@gmail.com>
parents:
13911
diff
changeset
|
2780 |
ui.write(match, label='grep.match') |
332e400764e5
grep: don't print data from binary files for matches (issue2614)
Md. O. Shayan <mdoshayan@gmail.com>
parents:
13911
diff
changeset
|
2781 |
ui.write(after) |
10816
635d601e8f21
grep: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10654
diff
changeset
|
2782 |
ui.write(eol) |
3951
cb66641cdee3
grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3950
diff
changeset
|
2783 |
found = True |
cb66641cdee3
grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3950
diff
changeset
|
2784 |
return found |
1057 | 2785 |
|
1145
bd917e1a26dd
grep: change default to printing first matching rev.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1116
diff
changeset
|
2786 |
skip = {} |
8849
80cc4b1a62d0
compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
8834
diff
changeset
|
2787 |
revfiles = {} |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
2788 |
matchfn = scmutil.match(repo[None], pats, opts) |
3951
cb66641cdee3
grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3950
diff
changeset
|
2789 |
found = False |
2870
8eaaf1321bfe
grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents:
2869
diff
changeset
|
2790 |
follow = opts.get('follow') |
9662
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2791 |
|
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2792 |
def prep(ctx, fns): |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2793 |
rev = ctx.rev() |
13878
a8d13ee0ce68
misc: replace .parents()[0] with p1()
Matt Mackall <mpm@selenic.com>
parents:
13855
diff
changeset
|
2794 |
pctx = ctx.p1() |
9662
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2795 |
parent = pctx.rev() |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2796 |
matches.setdefault(rev, {}) |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2797 |
matches.setdefault(parent, {}) |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2798 |
files = revfiles.setdefault(rev, []) |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2799 |
for fn in fns: |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2800 |
flog = getfile(fn) |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2801 |
try: |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2802 |
fnode = ctx.filenode(fn) |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2803 |
except error.LookupError: |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2804 |
continue |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2805 |
|
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2806 |
copied = flog.renamed(fnode) |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2807 |
copy = follow and copied and copied[0] |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2808 |
if copy: |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2809 |
copies.setdefault(rev, {})[fn] = copy |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2810 |
if fn in skip: |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2811 |
if copy: |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2812 |
skip[copy] = True |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2813 |
continue |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2814 |
files.append(fn) |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2815 |
|
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2816 |
if fn not in matches[rev]: |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2817 |
grepbody(fn, rev, flog.read(fnode)) |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2818 |
|
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2819 |
pfn = copy or fn |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2820 |
if pfn not in matches[parent]: |
1057 | 2821 |
try: |
9662
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2822 |
fnode = pctx.filenode(pfn) |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2823 |
grepbody(pfn, parent, flog.read(fnode)) |
7633 | 2824 |
except error.LookupError: |
9662
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2825 |
pass |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2826 |
|
9665
1de5ebfa5585
walkchangerevs: drop ui arg
Matt Mackall <mpm@selenic.com>
parents:
9663
diff
changeset
|
2827 |
for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep): |
9662
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2828 |
rev = ctx.rev() |
13878
a8d13ee0ce68
misc: replace .parents()[0] with p1()
Matt Mackall <mpm@selenic.com>
parents:
13855
diff
changeset
|
2829 |
parent = ctx.p1().rev() |
9662
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2830 |
for fn in sorted(revfiles.get(rev, [])): |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2831 |
states = matches[rev][fn] |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2832 |
copy = copies.get(rev, {}).get(fn) |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2833 |
if fn in skip: |
8849
80cc4b1a62d0
compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
8834
diff
changeset
|
2834 |
if copy: |
9662
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2835 |
skip[copy] = True |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2836 |
continue |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2837 |
pstates = matches.get(parent, {}).get(copy or fn, []) |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2838 |
if pstates or states: |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2839 |
r = display(fn, ctx, pstates, states) |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2840 |
found = found or r |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2841 |
if r and not opts.get('all'): |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2842 |
skip[fn] = True |
8849
80cc4b1a62d0
compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
8834
diff
changeset
|
2843 |
if copy: |
80cc4b1a62d0
compare grep result between target and its parent
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
8834
diff
changeset
|
2844 |
skip[copy] = True |
9662
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2845 |
del matches[rev] |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
2846 |
del revfiles[rev] |
1057 | 2847 |
|
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
2848 |
return not found |
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
2849 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2850 |
@command('heads', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2851 |
[('r', 'rev', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2852 |
_('show only heads which are descendants of STARTREV'), _('STARTREV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2853 |
('t', 'topo', False, _('show topological heads only')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2854 |
('a', 'active', False, _('show active branchheads only (DEPRECATED)')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2855 |
('c', 'closed', False, _('show normal and closed branch heads')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2856 |
] + templateopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2857 |
_('[-ac] [-r STARTREV] [REV]...')) |
4648
8e503fa54d2d
Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents:
4646
diff
changeset
|
2858 |
def heads(ui, repo, *branchrevs, **opts): |
8e503fa54d2d
Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents:
4646
diff
changeset
|
2859 |
"""show current repository heads or show branch heads |
8e503fa54d2d
Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents:
4646
diff
changeset
|
2860 |
|
10350
fd511e9eeea6
commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10349
diff
changeset
|
2861 |
With no arguments, show all repository branch heads. |
4648
8e503fa54d2d
Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents:
4646
diff
changeset
|
2862 |
|
9502
8d7d68dd91fd
commands: tweak help for 'heads'.
Greg Ward <greg-hg@gerg.ca>
parents:
9189
diff
changeset
|
2863 |
Repository "heads" are changesets with no child changesets. They are |
8d7d68dd91fd
commands: tweak help for 'heads'.
Greg Ward <greg-hg@gerg.ca>
parents:
9189
diff
changeset
|
2864 |
where development generally takes place and are the usual targets |
10350
fd511e9eeea6
commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10349
diff
changeset
|
2865 |
for update and merge operations. Branch heads are changesets that have |
fd511e9eeea6
commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10349
diff
changeset
|
2866 |
no child changeset on the same branch. |
fd511e9eeea6
commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10349
diff
changeset
|
2867 |
|
fd511e9eeea6
commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10349
diff
changeset
|
2868 |
If one or more REVs are given, only branch heads on the branches |
15044
39eb2e86fb11
commands: clarify that 'hg heads foo' shows heads on branch foo
Martin Geisler <mg@aragost.com>
parents:
15042
diff
changeset
|
2869 |
associated with the specified changesets are shown. This means |
39eb2e86fb11
commands: clarify that 'hg heads foo' shows heads on branch foo
Martin Geisler <mg@aragost.com>
parents:
15042
diff
changeset
|
2870 |
that you can use :hg:`heads foo` to see the heads on a branch |
39eb2e86fb11
commands: clarify that 'hg heads foo' shows heads on branch foo
Martin Geisler <mg@aragost.com>
parents:
15042
diff
changeset
|
2871 |
named ``foo``. |
9502
8d7d68dd91fd
commands: tweak help for 'heads'.
Greg Ward <greg-hg@gerg.ca>
parents:
9189
diff
changeset
|
2872 |
|
8d7d68dd91fd
commands: tweak help for 'heads'.
Greg Ward <greg-hg@gerg.ca>
parents:
9189
diff
changeset
|
2873 |
If -c/--closed is specified, also show branch heads marked closed |
11193
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11185
diff
changeset
|
2874 |
(see :hg:`commit --close-branch`). |
9502
8d7d68dd91fd
commands: tweak help for 'heads'.
Greg Ward <greg-hg@gerg.ca>
parents:
9189
diff
changeset
|
2875 |
|
8d7d68dd91fd
commands: tweak help for 'heads'.
Greg Ward <greg-hg@gerg.ca>
parents:
9189
diff
changeset
|
2876 |
If STARTREV is specified, only those heads that are descendants of |
8d7d68dd91fd
commands: tweak help for 'heads'.
Greg Ward <greg-hg@gerg.ca>
parents:
9189
diff
changeset
|
2877 |
STARTREV will be displayed. |
10350
fd511e9eeea6
commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10349
diff
changeset
|
2878 |
|
fd511e9eeea6
commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10349
diff
changeset
|
2879 |
If -t/--topo is specified, named branch mechanics will be ignored and only |
fd511e9eeea6
commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10349
diff
changeset
|
2880 |
changesets without children will be shown. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
2881 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
2882 |
Returns 0 if matching heads are found, 1 if not. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
2883 |
""" |
10328
0798a3d5f812
commands: simplify heads a little bit before I start hacking it up
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10326
diff
changeset
|
2884 |
|
12925
6eab8f0df2ca
commands: add revset support to most commands
Matt Mackall <mpm@selenic.com>
parents:
12918
diff
changeset
|
2885 |
start = None |
6eab8f0df2ca
commands: add revset support to most commands
Matt Mackall <mpm@selenic.com>
parents:
12918
diff
changeset
|
2886 |
if 'rev' in opts: |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
2887 |
start = scmutil.revsingle(repo, opts['rev'], None).node() |
10328
0798a3d5f812
commands: simplify heads a little bit before I start hacking it up
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10326
diff
changeset
|
2888 |
|
10350
fd511e9eeea6
commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10349
diff
changeset
|
2889 |
if opts.get('topo'): |
fd511e9eeea6
commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10349
diff
changeset
|
2890 |
heads = [repo[h] for h in repo.heads(start)] |
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
|
2891 |
else: |
10348
0fc5222c0951
commands: externalize branchheads so we can do it for all branches at once
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10347
diff
changeset
|
2892 |
heads = [] |
14466
bd34a027f3ed
commands: use repo.branchheads in heads command
Martin Geisler <mg@aragost.com>
parents:
14465
diff
changeset
|
2893 |
for branch in repo.branchmap(): |
bd34a027f3ed
commands: use repo.branchheads in heads command
Martin Geisler <mg@aragost.com>
parents:
14465
diff
changeset
|
2894 |
heads += repo.branchheads(branch, start, opts.get('closed')) |
bd34a027f3ed
commands: use repo.branchheads in heads command
Martin Geisler <mg@aragost.com>
parents:
14465
diff
changeset
|
2895 |
heads = [repo[h] for h in heads] |
10350
fd511e9eeea6
commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10349
diff
changeset
|
2896 |
|
fd511e9eeea6
commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10349
diff
changeset
|
2897 |
if branchrevs: |
13047
6c375e07d673
branch: operate on branch names in local string space where possible
Matt Mackall <mpm@selenic.com>
parents:
13022
diff
changeset
|
2898 |
branches = set(repo[br].branch() for br in branchrevs) |
10350
fd511e9eeea6
commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10349
diff
changeset
|
2899 |
heads = [h for h in heads if h.branch() in branches] |
10328
0798a3d5f812
commands: simplify heads a little bit before I start hacking it up
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10326
diff
changeset
|
2900 |
|
10349
20356e69710c
commands: actually implement --closed for topological heads
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10348
diff
changeset
|
2901 |
if opts.get('active') and branchrevs: |
20356e69710c
commands: actually implement --closed for topological heads
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10348
diff
changeset
|
2902 |
dagheads = repo.heads(start) |
10350
fd511e9eeea6
commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10349
diff
changeset
|
2903 |
heads = [h for h in heads if h.node() in dagheads] |
10349
20356e69710c
commands: actually implement --closed for topological heads
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10348
diff
changeset
|
2904 |
|
20356e69710c
commands: actually implement --closed for topological heads
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10348
diff
changeset
|
2905 |
if branchrevs: |
10350
fd511e9eeea6
commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10349
diff
changeset
|
2906 |
haveheads = set(h.branch() for h in heads) |
10346
e2db50cae6e6
commands: don't do too much work for error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10345
diff
changeset
|
2907 |
if branches - haveheads: |
13047
6c375e07d673
branch: operate on branch names in local string space where possible
Matt Mackall <mpm@selenic.com>
parents:
13022
diff
changeset
|
2908 |
headless = ', '.join(b for b in branches - haveheads) |
10346
e2db50cae6e6
commands: don't do too much work for error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10345
diff
changeset
|
2909 |
msg = _('no open branch heads found on branches %s') |
e2db50cae6e6
commands: don't do too much work for error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10345
diff
changeset
|
2910 |
if opts.get('rev'): |
e2db50cae6e6
commands: don't do too much work for error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10345
diff
changeset
|
2911 |
msg += _(' (started at %s)' % opts['rev']) |
e2db50cae6e6
commands: don't do too much work for error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10345
diff
changeset
|
2912 |
ui.warn((msg + '\n') % headless) |
e2db50cae6e6
commands: don't do too much work for error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10345
diff
changeset
|
2913 |
|
4648
8e503fa54d2d
Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents:
4646
diff
changeset
|
2914 |
if not heads: |
8e503fa54d2d
Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents:
4646
diff
changeset
|
2915 |
return 1 |
10328
0798a3d5f812
commands: simplify heads a little bit before I start hacking it up
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10326
diff
changeset
|
2916 |
|
10350
fd511e9eeea6
commands: do all branch heads by default, demote topological to -t/--topo
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10349
diff
changeset
|
2917 |
heads = sorted(heads, key=lambda x: -x.rev()) |
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3631
diff
changeset
|
2918 |
displayer = cmdutil.show_changeset(ui, repo, opts) |
10331
ec5240a22f4a
commands: always order heads recent to oldest
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10330
diff
changeset
|
2919 |
for ctx in heads: |
ec5240a22f4a
commands: always order heads recent to oldest
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10330
diff
changeset
|
2920 |
displayer.show(ctx) |
10152
56284451a22c
Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents:
10111
diff
changeset
|
2921 |
displayer.close() |
221 | 2922 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2923 |
@command('help', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2924 |
[('e', 'extension', None, _('show only help for extensions')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2925 |
('c', 'command', None, _('show only help for commands'))], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
2926 |
_('[-ec] [TOPIC]')) |
15020 | 2927 |
def help_(ui, name=None, unknowncmd=False, full=True, **opts): |
7210 | 2928 |
"""show help for a given topic or a help overview |
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
2929 |
|
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
2930 |
With no arguments, print a list of commands with short help messages. |
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
2931 |
|
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
2932 |
Given a topic, extension, or command name, print help for that |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
2933 |
topic. |
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
2934 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
2935 |
Returns 0 if successful. |
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
2936 |
""" |
15023
157a294444b2
help: move option text display into a helper function
Matt Mackall <mpm@selenic.com>
parents:
15022
diff
changeset
|
2937 |
|
13608
63ab6b0ccedc
help: limit documentation width to at most 80 characters
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
13601
diff
changeset
|
2938 |
textwidth = min(ui.termwidth(), 80) - 2 |
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
2939 |
|
15145
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2940 |
def optrst(options): |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2941 |
data = [] |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2942 |
multioccur = False |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2943 |
for option in options: |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2944 |
if len(option) == 5: |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2945 |
shortopt, longopt, default, desc, optlabel = option |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2946 |
else: |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2947 |
shortopt, longopt, default, desc = option |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2948 |
optlabel = _("VALUE") # default label |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2949 |
|
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2950 |
if _("DEPRECATED") in desc and not ui.verbose: |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2951 |
continue |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2952 |
|
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2953 |
so = '' |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2954 |
if shortopt: |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2955 |
so = '-' + shortopt |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2956 |
lo = '--' + longopt |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2957 |
if default: |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2958 |
desc += _(" (default: %s)") % default |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2959 |
|
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2960 |
if isinstance(default, list): |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2961 |
lo += " %s [+]" % optlabel |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2962 |
multioccur = True |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2963 |
elif (default is not None) and not isinstance(default, bool): |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2964 |
lo += " %s" % optlabel |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2965 |
|
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2966 |
data.append((so, lo, desc)) |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2967 |
|
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2968 |
rst = minirst.maketable(data, 1) |
15192
3834ca04664a
rst: fix detection of single-row tables
Matt Mackall <mpm@selenic.com>
parents:
15183
diff
changeset
|
2969 |
|
15145
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2970 |
if multioccur: |
15203
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
2971 |
rst += _("\n[+] marked option can be specified multiple times\n") |
15145
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2972 |
|
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2973 |
return rst |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2974 |
|
15023
157a294444b2
help: move option text display into a helper function
Matt Mackall <mpm@selenic.com>
parents:
15022
diff
changeset
|
2975 |
# list all option lists |
157a294444b2
help: move option text display into a helper function
Matt Mackall <mpm@selenic.com>
parents:
15022
diff
changeset
|
2976 |
def opttext(optlist, width): |
15145
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2977 |
rst = '' |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2978 |
if not optlist: |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2979 |
return '' |
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2980 |
|
15023
157a294444b2
help: move option text display into a helper function
Matt Mackall <mpm@selenic.com>
parents:
15022
diff
changeset
|
2981 |
for title, options in optlist: |
15203
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
2982 |
rst += '\n%s\n' % title |
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
2983 |
if options: |
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
2984 |
rst += "\n" |
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
2985 |
rst += optrst(options) |
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
2986 |
rst += '\n' |
15145
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2987 |
|
ff26712a0c50
help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents:
15139
diff
changeset
|
2988 |
return '\n' + minirst.format(rst, width) |
15023
157a294444b2
help: move option text display into a helper function
Matt Mackall <mpm@selenic.com>
parents:
15022
diff
changeset
|
2989 |
|
15129
9b904d679850
help: make optlist local to subfunctions
Matt Mackall <mpm@selenic.com>
parents:
15128
diff
changeset
|
2990 |
def addglobalopts(optlist, aliases): |
9b904d679850
help: make optlist local to subfunctions
Matt Mackall <mpm@selenic.com>
parents:
15128
diff
changeset
|
2991 |
if ui.quiet: |
9b904d679850
help: make optlist local to subfunctions
Matt Mackall <mpm@selenic.com>
parents:
15128
diff
changeset
|
2992 |
return [] |
9b904d679850
help: make optlist local to subfunctions
Matt Mackall <mpm@selenic.com>
parents:
15128
diff
changeset
|
2993 |
|
4315
bc6f5a1d8b7b
Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4267
diff
changeset
|
2994 |
if ui.verbose: |
15022
bf1fa4ba582b
help: move 'additional help topics' code
Matt Mackall <mpm@selenic.com>
parents:
15020
diff
changeset
|
2995 |
optlist.append((_("global options:"), globalopts)) |
4315
bc6f5a1d8b7b
Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4267
diff
changeset
|
2996 |
if name == 'shortlist': |
15022
bf1fa4ba582b
help: move 'additional help topics' code
Matt Mackall <mpm@selenic.com>
parents:
15020
diff
changeset
|
2997 |
optlist.append((_('use "hg help" for the full list ' |
4315
bc6f5a1d8b7b
Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4267
diff
changeset
|
2998 |
'of commands'), ())) |
bc6f5a1d8b7b
Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4267
diff
changeset
|
2999 |
else: |
bc6f5a1d8b7b
Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4267
diff
changeset
|
3000 |
if name == 'shortlist': |
bc6f5a1d8b7b
Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4267
diff
changeset
|
3001 |
msg = _('use "hg help" for the full list of commands ' |
bc6f5a1d8b7b
Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4267
diff
changeset
|
3002 |
'or "hg -v" for details') |
13950
14d0553bd48b
help: do not show full help text for command on option errors
Adrian Buehlmann <adrian@cadifra.com>
parents:
13920
diff
changeset
|
3003 |
elif name and not full: |
14d0553bd48b
help: do not show full help text for command on option errors
Adrian Buehlmann <adrian@cadifra.com>
parents:
13920
diff
changeset
|
3004 |
msg = _('use "hg help %s" to show the full help text' % name) |
4315
bc6f5a1d8b7b
Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4267
diff
changeset
|
3005 |
elif aliases: |
13230
827a1cc127bf
commands: clarify which aliases "hg help -v" show (issue2572)
Martin Geisler <mg@aragost.com>
parents:
13135
diff
changeset
|
3006 |
msg = _('use "hg -v help%s" to show builtin aliases and ' |
4315
bc6f5a1d8b7b
Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4267
diff
changeset
|
3007 |
'global options') % (name and " " + name or "") |
bc6f5a1d8b7b
Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4267
diff
changeset
|
3008 |
else: |
15202
0150741caace
help: unify the two -v notes for command help
Matt Mackall <mpm@selenic.com>
parents:
15200
diff
changeset
|
3009 |
msg = _('use "hg -v help %s" to show more info') % name |
15022
bf1fa4ba582b
help: move 'additional help topics' code
Matt Mackall <mpm@selenic.com>
parents:
15020
diff
changeset
|
3010 |
optlist.append((msg, ())) |
4315
bc6f5a1d8b7b
Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4267
diff
changeset
|
3011 |
|
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3012 |
def helpcmd(name): |
6652
ffcf8e82f647
help: enable listing of a subset of the command list
Johannes Stezenbach <js@sig21.net>
parents:
6642
diff
changeset
|
3013 |
try: |
10364
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3014 |
aliases, entry = cmdutil.findcmd(name, table, strict=unknowncmd) |
7643
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7637
diff
changeset
|
3015 |
except error.AmbiguousCommand, inst: |
9035
8e34f363dd77
compat: don't reference an exception var inside a lambda
Alejandro Santos <alejolp@alejolp.com>
parents:
9031
diff
changeset
|
3016 |
# py3k fix: except vars can't be used outside the scope of the |
8e34f363dd77
compat: don't reference an exception var inside a lambda
Alejandro Santos <alejolp@alejolp.com>
parents:
9031
diff
changeset
|
3017 |
# except block, nor can be used inside a lambda. python issue4617 |
8e34f363dd77
compat: don't reference an exception var inside a lambda
Alejandro Santos <alejolp@alejolp.com>
parents:
9031
diff
changeset
|
3018 |
prefix = inst.args[0] |
8e34f363dd77
compat: don't reference an exception var inside a lambda
Alejandro Santos <alejolp@alejolp.com>
parents:
9031
diff
changeset
|
3019 |
select = lambda c: c.lstrip('^').startswith(prefix) |
15127
2c80862728cb
help: fold header selection into helplist
Matt Mackall <mpm@selenic.com>
parents:
15126
diff
changeset
|
3020 |
helplist(select) |
6652
ffcf8e82f647
help: enable listing of a subset of the command list
Johannes Stezenbach <js@sig21.net>
parents:
6642
diff
changeset
|
3021 |
return |
ffcf8e82f647
help: enable listing of a subset of the command list
Johannes Stezenbach <js@sig21.net>
parents:
6642
diff
changeset
|
3022 |
|
10021
0022f5c5459e
help: don't display bogus help messages for invalid aliases
Brodie Rao <me+hg@dackz.net>
parents:
10015
diff
changeset
|
3023 |
# check if it's an invalid alias and display its error if it is |
0022f5c5459e
help: don't display bogus help messages for invalid aliases
Brodie Rao <me+hg@dackz.net>
parents:
10015
diff
changeset
|
3024 |
if getattr(entry[0], 'badalias', False): |
10364
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3025 |
if not unknowncmd: |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3026 |
entry[0](ui) |
10021
0022f5c5459e
help: don't display bogus help messages for invalid aliases
Brodie Rao <me+hg@dackz.net>
parents:
10015
diff
changeset
|
3027 |
return |
0022f5c5459e
help: don't display bogus help messages for invalid aliases
Brodie Rao <me+hg@dackz.net>
parents:
10015
diff
changeset
|
3028 |
|
15203
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3029 |
rst = "" |
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3030 |
|
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3031 |
# synopsis |
9901
cb2a1836c50a
commands: minor refactoring
Henri Wiechers <hwiechers@gmail.com>
parents:
9894
diff
changeset
|
3032 |
if len(entry) > 2: |
cb2a1836c50a
commands: minor refactoring
Henri Wiechers <hwiechers@gmail.com>
parents:
9894
diff
changeset
|
3033 |
if entry[2].startswith('hg'): |
15203
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3034 |
rst += "%s\n" % entry[2] |
7364
ad7f736f3214
help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents:
7361
diff
changeset
|
3035 |
else: |
15203
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3036 |
rst += 'hg %s %s\n' % (aliases[0], entry[2]) |
7364
ad7f736f3214
help: remove redundant 'hg <command>' from command synopses
Matt Mackall <mpm@selenic.com>
parents:
7361
diff
changeset
|
3037 |
else: |
15203
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3038 |
rst += 'hg %s\n' % aliases[0] |
5783
28d9f8cd02f2
Move aliases section in help below synopsis (issue362)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5781
diff
changeset
|
3039 |
|
28d9f8cd02f2
Move aliases section in help below synopsis (issue362)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5781
diff
changeset
|
3040 |
# aliases |
13950
14d0553bd48b
help: do not show full help text for command on option errors
Adrian Buehlmann <adrian@cadifra.com>
parents:
13920
diff
changeset
|
3041 |
if full and not ui.quiet and len(aliases) > 1: |
15203
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3042 |
rst += _("\naliases: %s\n") % ', '.join(aliases[1:]) |
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3043 |
|
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3044 |
# description |
9901
cb2a1836c50a
commands: minor refactoring
Henri Wiechers <hwiechers@gmail.com>
parents:
9894
diff
changeset
|
3045 |
doc = gettext(entry[0].__doc__) |
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3046 |
if not doc: |
7598 | 3047 |
doc = _("(no help text available)") |
14954
ce7e3014fda7
help command: use safehasattr instead of hasattr
Augie Fackler <durin42@gmail.com>
parents:
14949
diff
changeset
|
3048 |
if util.safehasattr(entry[0], 'definition'): # aliased command |
11524
24965bb270b7
dispatch: add shell aliases
Steve Losh <steve@stevelosh.com>
parents:
11515
diff
changeset
|
3049 |
if entry[0].definition.startswith('!'): # shell alias |
24965bb270b7
dispatch: add shell aliases
Steve Losh <steve@stevelosh.com>
parents:
11515
diff
changeset
|
3050 |
doc = _('shell alias for::\n\n %s') % entry[0].definition[1:] |
24965bb270b7
dispatch: add shell aliases
Steve Losh <steve@stevelosh.com>
parents:
11515
diff
changeset
|
3051 |
else: |
24965bb270b7
dispatch: add shell aliases
Steve Losh <steve@stevelosh.com>
parents:
11515
diff
changeset
|
3052 |
doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc) |
13950
14d0553bd48b
help: do not show full help text for command on option errors
Adrian Buehlmann <adrian@cadifra.com>
parents:
13920
diff
changeset
|
3053 |
if ui.quiet or not full: |
9136
31177742f54a
for calls expecting bool args, pass bool instead of int
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9102
diff
changeset
|
3054 |
doc = doc.splitlines()[0] |
15203
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3055 |
rst += "\n" + doc + "\n" |
4315
bc6f5a1d8b7b
Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4267
diff
changeset
|
3056 |
|
14285
aa64a87b493d
help: give hint about 'hg help -e' when appropriate
Martin Geisler <mg@aragost.com>
parents:
14284
diff
changeset
|
3057 |
# check if this command shadows a non-trivial (multi-line) |
aa64a87b493d
help: give hint about 'hg help -e' when appropriate
Martin Geisler <mg@aragost.com>
parents:
14284
diff
changeset
|
3058 |
# extension help text |
aa64a87b493d
help: give hint about 'hg help -e' when appropriate
Martin Geisler <mg@aragost.com>
parents:
14284
diff
changeset
|
3059 |
try: |
aa64a87b493d
help: give hint about 'hg help -e' when appropriate
Martin Geisler <mg@aragost.com>
parents:
14284
diff
changeset
|
3060 |
mod = extensions.find(name) |
aa64a87b493d
help: give hint about 'hg help -e' when appropriate
Martin Geisler <mg@aragost.com>
parents:
14284
diff
changeset
|
3061 |
doc = gettext(mod.__doc__) or '' |
aa64a87b493d
help: give hint about 'hg help -e' when appropriate
Martin Geisler <mg@aragost.com>
parents:
14284
diff
changeset
|
3062 |
if '\n' in doc.strip(): |
aa64a87b493d
help: give hint about 'hg help -e' when appropriate
Martin Geisler <mg@aragost.com>
parents:
14284
diff
changeset
|
3063 |
msg = _('use "hg help -e %s" to show help for ' |
aa64a87b493d
help: give hint about 'hg help -e' when appropriate
Martin Geisler <mg@aragost.com>
parents:
14284
diff
changeset
|
3064 |
'the %s extension') % (name, name) |
15203
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3065 |
rst += '\n%s\n' % msg |
14285
aa64a87b493d
help: give hint about 'hg help -e' when appropriate
Martin Geisler <mg@aragost.com>
parents:
14284
diff
changeset
|
3066 |
except KeyError: |
aa64a87b493d
help: give hint about 'hg help -e' when appropriate
Martin Geisler <mg@aragost.com>
parents:
14284
diff
changeset
|
3067 |
pass |
aa64a87b493d
help: give hint about 'hg help -e' when appropriate
Martin Geisler <mg@aragost.com>
parents:
14284
diff
changeset
|
3068 |
|
15203
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3069 |
# options |
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3070 |
if not ui.quiet and entry[1]: |
15985
740b1b4c7958
help: mark strings for translation
Jens Bäckman <jens.backman@gmail.com>
parents:
15968
diff
changeset
|
3071 |
rst += '\n' |
740b1b4c7958
help: mark strings for translation
Jens Bäckman <jens.backman@gmail.com>
parents:
15968
diff
changeset
|
3072 |
rst += _("options:") |
740b1b4c7958
help: mark strings for translation
Jens Bäckman <jens.backman@gmail.com>
parents:
15968
diff
changeset
|
3073 |
rst += '\n\n' |
15203
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3074 |
rst += optrst(entry[1]) |
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3075 |
|
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3076 |
if ui.verbose: |
15985
740b1b4c7958
help: mark strings for translation
Jens Bäckman <jens.backman@gmail.com>
parents:
15968
diff
changeset
|
3077 |
rst += '\n' |
740b1b4c7958
help: mark strings for translation
Jens Bäckman <jens.backman@gmail.com>
parents:
15968
diff
changeset
|
3078 |
rst += _("global options:") |
740b1b4c7958
help: mark strings for translation
Jens Bäckman <jens.backman@gmail.com>
parents:
15968
diff
changeset
|
3079 |
rst += '\n\n' |
15203
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3080 |
rst += optrst(globalopts) |
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3081 |
|
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3082 |
keep = ui.verbose and ['verbose'] or [] |
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3083 |
formatted, pruned = minirst.format(rst, textwidth, keep=keep) |
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3084 |
ui.write(formatted) |
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3085 |
|
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3086 |
if not ui.verbose: |
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3087 |
if not full: |
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3088 |
ui.write(_('\nuse "hg help %s" to show the full help text\n') |
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3089 |
% name) |
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3090 |
elif not ui.quiet: |
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3091 |
ui.write(_('\nuse "hg -v help %s" to show more info\n') % name) |
c7ce651a6bc9
help: generate command help into a single RST string for formatting
Matt Mackall <mpm@selenic.com>
parents:
15202
diff
changeset
|
3092 |
|
15128
aaf666bd2942
help: move option list display into subfunctions
Matt Mackall <mpm@selenic.com>
parents:
15127
diff
changeset
|
3093 |
|
15127
2c80862728cb
help: fold header selection into helplist
Matt Mackall <mpm@selenic.com>
parents:
15126
diff
changeset
|
3094 |
def helplist(select=None): |
2c80862728cb
help: fold header selection into helplist
Matt Mackall <mpm@selenic.com>
parents:
15126
diff
changeset
|
3095 |
# list of commands |
2c80862728cb
help: fold header selection into helplist
Matt Mackall <mpm@selenic.com>
parents:
15126
diff
changeset
|
3096 |
if name == "shortlist": |
2c80862728cb
help: fold header selection into helplist
Matt Mackall <mpm@selenic.com>
parents:
15126
diff
changeset
|
3097 |
header = _('basic commands:\n\n') |
2c80862728cb
help: fold header selection into helplist
Matt Mackall <mpm@selenic.com>
parents:
15126
diff
changeset
|
3098 |
else: |
2c80862728cb
help: fold header selection into helplist
Matt Mackall <mpm@selenic.com>
parents:
15126
diff
changeset
|
3099 |
header = _('list of commands:\n\n') |
2c80862728cb
help: fold header selection into helplist
Matt Mackall <mpm@selenic.com>
parents:
15126
diff
changeset
|
3100 |
|
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3101 |
h = {} |
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3102 |
cmds = {} |
7622
4dd7b28003d2
use dict.iteritems() rather than dict.items()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7598
diff
changeset
|
3103 |
for c, e in table.iteritems(): |
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3104 |
f = c.split("|", 1)[0] |
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3105 |
if select and not select(f): |
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3106 |
continue |
7197
f60730693efc
help: show extension commands in short list, separate extension list in help
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7196
diff
changeset
|
3107 |
if (not select and name != 'shortlist' and |
f60730693efc
help: show extension commands in short list, separate extension list in help
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7196
diff
changeset
|
3108 |
e[0].__module__ != __name__): |
7126
111813de4188
remove extension commands from global help
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7125
diff
changeset
|
3109 |
continue |
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3110 |
if name == "shortlist" and not f.startswith("^"): |
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3111 |
continue |
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3112 |
f = f.lstrip("^") |
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3113 |
if not ui.debugflag and f.startswith("debug"): |
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3114 |
continue |
9128
98d90ad54749
commands: hide deprecated commands.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9097
diff
changeset
|
3115 |
doc = e[0].__doc__ |
98d90ad54749
commands: hide deprecated commands.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9097
diff
changeset
|
3116 |
if doc and 'DEPRECATED' in doc and not ui.verbose: |
98d90ad54749
commands: hide deprecated commands.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9097
diff
changeset
|
3117 |
continue |
98d90ad54749
commands: hide deprecated commands.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
9097
diff
changeset
|
3118 |
doc = gettext(doc) |
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3119 |
if not doc: |
7598 | 3120 |
doc = _("(no help text available)") |
9136
31177742f54a
for calls expecting bool args, pass bool instead of int
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
9102
diff
changeset
|
3121 |
h[f] = doc.splitlines()[0].rstrip() |
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3122 |
cmds[f] = c.lstrip("^") |
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3123 |
|
4950
93b7e2fa7ee3
help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4942
diff
changeset
|
3124 |
if not h: |
93b7e2fa7ee3
help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4942
diff
changeset
|
3125 |
ui.status(_('no commands defined\n')) |
93b7e2fa7ee3
help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4942
diff
changeset
|
3126 |
return |
93b7e2fa7ee3
help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4942
diff
changeset
|
3127 |
|
93b7e2fa7ee3
help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4942
diff
changeset
|
3128 |
ui.status(header) |
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
8190
diff
changeset
|
3129 |
fns = sorted(h) |
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3130 |
m = max(map(len, fns)) |
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3131 |
for f in fns: |
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3132 |
if ui.verbose: |
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3133 |
commands = cmds[f].replace("|",", ") |
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3134 |
ui.write(" %s:\n %s\n"%(commands, h[f])) |
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3135 |
else: |
12698
7aef77e74cf3
util: make wrap() require a width argument
Matt Mackall <mpm@selenic.com>
parents:
12697
diff
changeset
|
3136 |
ui.write('%s\n' % (util.wrap(h[f], textwidth, |
15862
d0f2a89c8cfa
help: fix column alignment in "hg help" output
Olav Reinert <seroton10@gmail.com>
parents:
15856
diff
changeset
|
3137 |
initindent=' %-*s ' % (m, f), |
11297
d320e70442a5
replace Python standard textwrap by MBCS sensitive one for i18n text
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11276
diff
changeset
|
3138 |
hangindent=' ' * (m + 4)))) |
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3139 |
|
15126
d3ad0e9d4be2
help: fold some list help clauses into the helplist function
Matt Mackall <mpm@selenic.com>
parents:
15125
diff
changeset
|
3140 |
if not name: |
d3ad0e9d4be2
help: fold some list help clauses into the helplist function
Matt Mackall <mpm@selenic.com>
parents:
15125
diff
changeset
|
3141 |
text = help.listexts(_('enabled extensions:'), extensions.enabled()) |
d3ad0e9d4be2
help: fold some list help clauses into the helplist function
Matt Mackall <mpm@selenic.com>
parents:
15125
diff
changeset
|
3142 |
if text: |
d3ad0e9d4be2
help: fold some list help clauses into the helplist function
Matt Mackall <mpm@selenic.com>
parents:
15125
diff
changeset
|
3143 |
ui.write("\n%s" % minirst.format(text, textwidth)) |
d3ad0e9d4be2
help: fold some list help clauses into the helplist function
Matt Mackall <mpm@selenic.com>
parents:
15125
diff
changeset
|
3144 |
|
d3ad0e9d4be2
help: fold some list help clauses into the helplist function
Matt Mackall <mpm@selenic.com>
parents:
15125
diff
changeset
|
3145 |
ui.write(_("\nadditional help topics:\n\n")) |
d3ad0e9d4be2
help: fold some list help clauses into the helplist function
Matt Mackall <mpm@selenic.com>
parents:
15125
diff
changeset
|
3146 |
topics = [] |
d3ad0e9d4be2
help: fold some list help clauses into the helplist function
Matt Mackall <mpm@selenic.com>
parents:
15125
diff
changeset
|
3147 |
for names, header, doc in help.helptable: |
d3ad0e9d4be2
help: fold some list help clauses into the helplist function
Matt Mackall <mpm@selenic.com>
parents:
15125
diff
changeset
|
3148 |
topics.append((sorted(names, key=len, reverse=True)[0], header)) |
d3ad0e9d4be2
help: fold some list help clauses into the helplist function
Matt Mackall <mpm@selenic.com>
parents:
15125
diff
changeset
|
3149 |
topics_len = max([len(s[0]) for s in topics]) |
d3ad0e9d4be2
help: fold some list help clauses into the helplist function
Matt Mackall <mpm@selenic.com>
parents:
15125
diff
changeset
|
3150 |
for t, desc in topics: |
15862
d0f2a89c8cfa
help: fix column alignment in "hg help" output
Olav Reinert <seroton10@gmail.com>
parents:
15856
diff
changeset
|
3151 |
ui.write(" %-*s %s\n" % (topics_len, t, desc)) |
15126
d3ad0e9d4be2
help: fold some list help clauses into the helplist function
Matt Mackall <mpm@selenic.com>
parents:
15125
diff
changeset
|
3152 |
|
15129
9b904d679850
help: make optlist local to subfunctions
Matt Mackall <mpm@selenic.com>
parents:
15128
diff
changeset
|
3153 |
optlist = [] |
9b904d679850
help: make optlist local to subfunctions
Matt Mackall <mpm@selenic.com>
parents:
15128
diff
changeset
|
3154 |
addglobalopts(optlist, True) |
15128
aaf666bd2942
help: move option list display into subfunctions
Matt Mackall <mpm@selenic.com>
parents:
15127
diff
changeset
|
3155 |
ui.write(opttext(optlist, textwidth)) |
aaf666bd2942
help: move option list display into subfunctions
Matt Mackall <mpm@selenic.com>
parents:
15127
diff
changeset
|
3156 |
|
3795
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
3786
diff
changeset
|
3157 |
def helptopic(name): |
7012 | 3158 |
for names, header, doc in help.helptable: |
3159 |
if name in names: |
|
3160 |
break |
|
3161 |
else: |
|
7643
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7637
diff
changeset
|
3162 |
raise error.UnknownCommand(name) |
3795
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
3786
diff
changeset
|
3163 |
|
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
3786
diff
changeset
|
3164 |
# description |
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
3786
diff
changeset
|
3165 |
if not doc: |
7598 | 3166 |
doc = _("(no help text available)") |
14943
d3bb825ddae3
globally: use safehasattr(x, '__call__') instead of hasattr(x, '__call__')
Augie Fackler <durin42@gmail.com>
parents:
14918
diff
changeset
|
3167 |
if util.safehasattr(doc, '__call__'): |
3796
58133ba5847d
Allow topics to be callables
Matt Mackall <mpm@selenic.com>
parents:
3795
diff
changeset
|
3168 |
doc = doc() |
3795
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
3786
diff
changeset
|
3169 |
|
9157
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9142
diff
changeset
|
3170 |
ui.write("%s\n\n" % header) |
15125
bdc595059108
minirst: end all blocks with newlines
Matt Mackall <mpm@selenic.com>
parents:
15119
diff
changeset
|
3171 |
ui.write("%s" % minirst.format(doc, textwidth, indent=4)) |
14286
005a540e9aee
help: add -c/--command flag to only show command help (issue2799)
Martin Geisler <mg@aragost.com>
parents:
14285
diff
changeset
|
3172 |
try: |
005a540e9aee
help: add -c/--command flag to only show command help (issue2799)
Martin Geisler <mg@aragost.com>
parents:
14285
diff
changeset
|
3173 |
cmdutil.findcmd(name, table) |
005a540e9aee
help: add -c/--command flag to only show command help (issue2799)
Martin Geisler <mg@aragost.com>
parents:
14285
diff
changeset
|
3174 |
ui.write(_('\nuse "hg help -c %s" to see help for ' |
005a540e9aee
help: add -c/--command flag to only show command help (issue2799)
Martin Geisler <mg@aragost.com>
parents:
14285
diff
changeset
|
3175 |
'the %s command\n') % (name, name)) |
005a540e9aee
help: add -c/--command flag to only show command help (issue2799)
Martin Geisler <mg@aragost.com>
parents:
14285
diff
changeset
|
3176 |
except error.UnknownCommand: |
005a540e9aee
help: add -c/--command flag to only show command help (issue2799)
Martin Geisler <mg@aragost.com>
parents:
14285
diff
changeset
|
3177 |
pass |
3795
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
3786
diff
changeset
|
3178 |
|
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3179 |
def helpext(name): |
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3180 |
try: |
4544
930ed513c864
Create a separate module for managing extensions
Matt Mackall <mpm@selenic.com>
parents:
4543
diff
changeset
|
3181 |
mod = extensions.find(name) |
10364
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3182 |
doc = gettext(mod.__doc__) or _('no help text available') |
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3183 |
except KeyError: |
10364
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3184 |
mod = None |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3185 |
doc = extensions.disabledext(name) |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3186 |
if not doc: |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3187 |
raise error.UnknownCommand(name) |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3188 |
|
9280
b694531a5aa7
commands: Check if helptext contains a newline before we split
David Soria Parra <dsp@php.net>
parents:
9249
diff
changeset
|
3189 |
if '\n' not in doc: |
b694531a5aa7
commands: Check if helptext contains a newline before we split
David Soria Parra <dsp@php.net>
parents:
9249
diff
changeset
|
3190 |
head, tail = doc, "" |
b694531a5aa7
commands: Check if helptext contains a newline before we split
David Soria Parra <dsp@php.net>
parents:
9249
diff
changeset
|
3191 |
else: |
b694531a5aa7
commands: Check if helptext contains a newline before we split
David Soria Parra <dsp@php.net>
parents:
9249
diff
changeset
|
3192 |
head, tail = doc.split('\n', 1) |
9157
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9142
diff
changeset
|
3193 |
ui.write(_('%s extension - %s\n\n') % (name.split('.')[-1], head)) |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9142
diff
changeset
|
3194 |
if tail: |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9142
diff
changeset
|
3195 |
ui.write(minirst.format(tail, textwidth)) |
15125
bdc595059108
minirst: end all blocks with newlines
Matt Mackall <mpm@selenic.com>
parents:
15119
diff
changeset
|
3196 |
ui.status('\n') |
4009
86098ec4b77a
fix hg help <ext> for extension that do not define any command
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3915
diff
changeset
|
3197 |
|
10364
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3198 |
if mod: |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3199 |
try: |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3200 |
ct = mod.cmdtable |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3201 |
except AttributeError: |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3202 |
ct = {} |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3203 |
modcmds = set([c.split('|', 1)[0] for c in ct]) |
15127
2c80862728cb
help: fold header selection into helplist
Matt Mackall <mpm@selenic.com>
parents:
15126
diff
changeset
|
3204 |
helplist(modcmds.__contains__) |
10364
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3205 |
else: |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3206 |
ui.write(_('use "hg help extensions" for information on enabling ' |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3207 |
'extensions\n')) |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3208 |
|
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3209 |
def helpextcmd(name): |
13191
1aea66b71f4f
extensions: warn about invalid extensions when listing disabled commands
Mads Kiilerich <mads@kiilerich.com>
parents:
13136
diff
changeset
|
3210 |
cmd, ext, mod = extensions.disabledcmd(ui, name, ui.config('ui', 'strict')) |
10364
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3211 |
doc = gettext(mod.__doc__).splitlines()[0] |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3212 |
|
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3213 |
msg = help.listexts(_("'%s' is provided by the following " |
14316
d5b525697ddb
extensions: drop maxlength from enabled and disabled
Matt Mackall <mpm@selenic.com>
parents:
14305
diff
changeset
|
3214 |
"extension:") % cmd, {ext: doc}, indent=4) |
10364
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3215 |
ui.write(minirst.format(msg, textwidth)) |
15125
bdc595059108
minirst: end all blocks with newlines
Matt Mackall <mpm@selenic.com>
parents:
15119
diff
changeset
|
3216 |
ui.write('\n') |
10364
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3217 |
ui.write(_('use "hg help extensions" for information on enabling ' |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3218 |
'extensions\n')) |
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3219 |
|
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3220 |
if name and name != 'shortlist': |
3795
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
3786
diff
changeset
|
3221 |
i = None |
10364
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3222 |
if unknowncmd: |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3223 |
queries = (helpextcmd,) |
14284
1f9e11f65cd7
help: add -e/--extension switch to display extension help text
Henri Wiechers <hwiechers@gmail.com>
parents:
14283
diff
changeset
|
3224 |
elif opts.get('extension'): |
1f9e11f65cd7
help: add -e/--extension switch to display extension help text
Henri Wiechers <hwiechers@gmail.com>
parents:
14283
diff
changeset
|
3225 |
queries = (helpext,) |
14286
005a540e9aee
help: add -c/--command flag to only show command help (issue2799)
Martin Geisler <mg@aragost.com>
parents:
14285
diff
changeset
|
3226 |
elif opts.get('command'): |
005a540e9aee
help: add -c/--command flag to only show command help (issue2799)
Martin Geisler <mg@aragost.com>
parents:
14285
diff
changeset
|
3227 |
queries = (helpcmd,) |
10364
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3228 |
else: |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3229 |
queries = (helptopic, helpcmd, helpext, helpextcmd) |
de1e7099d100
dispatch: provide help for disabled extensions and commands
Brodie Rao <me+hg@dackz.net>
parents:
10355
diff
changeset
|
3230 |
for f in queries: |
3795
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
3786
diff
changeset
|
3231 |
try: |
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
3786
diff
changeset
|
3232 |
f(name) |
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
3786
diff
changeset
|
3233 |
i = None |
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
3786
diff
changeset
|
3234 |
break |
7643
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7637
diff
changeset
|
3235 |
except error.UnknownCommand, inst: |
3795
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
3786
diff
changeset
|
3236 |
i = inst |
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
3786
diff
changeset
|
3237 |
if i: |
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
3786
diff
changeset
|
3238 |
raise i |
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3239 |
else: |
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3240 |
# program name |
15020 | 3241 |
ui.status(_("Mercurial Distributed SCM\n")) |
3655
da361aa7a118
alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents:
3654
diff
changeset
|
3242 |
ui.status('\n') |
15127
2c80862728cb
help: fold header selection into helplist
Matt Mackall <mpm@selenic.com>
parents:
15126
diff
changeset
|
3243 |
helplist() |
6653
a78d8edaeedd
help: list special help topics with -v
Johannes Stezenbach <js@sig21.net>
parents:
6652
diff
changeset
|
3244 |
|
221 | 3245 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3246 |
@command('identify|id', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3247 |
[('r', 'rev', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3248 |
_('identify the specified revision'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3249 |
('n', 'num', None, _('show local revision number')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3250 |
('i', 'id', None, _('show global revision id')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3251 |
('b', 'branch', None, _('show branch')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3252 |
('t', 'tags', None, _('show tags')), |
15580
5a7733563c2e
id: add command line options for handling ssh and https urls
Mads Kiilerich <mads@kiilerich.com>
parents:
15578
diff
changeset
|
3253 |
('B', 'bookmarks', None, _('show bookmarks')), |
5a7733563c2e
id: add command line options for handling ssh and https urls
Mads Kiilerich <mads@kiilerich.com>
parents:
15578
diff
changeset
|
3254 |
] + remoteopts, |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3255 |
_('[-nibtB] [-r REV] [SOURCE]')) |
13477
0fb2ff949790
id: add bookmarks to id
Kevin Bullock <kbullock@ringworld.org>
parents:
13473
diff
changeset
|
3256 |
def identify(ui, repo, source=None, rev=None, |
15580
5a7733563c2e
id: add command line options for handling ssh and https urls
Mads Kiilerich <mads@kiilerich.com>
parents:
15578
diff
changeset
|
3257 |
num=None, id=None, branch=None, tags=None, bookmarks=None, **opts): |
4665
091c9e54d306
identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents:
4664
diff
changeset
|
3258 |
"""identify the working copy or specified revision |
091c9e54d306
identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents:
4664
diff
changeset
|
3259 |
|
13963
3c753f9a2fbc
identify: further clarification of help
Kevin Bullock <kbullock@ringworld.org>
parents:
13952
diff
changeset
|
3260 |
Print a summary identifying the repository state at REV using one or |
3c753f9a2fbc
identify: further clarification of help
Kevin Bullock <kbullock@ringworld.org>
parents:
13952
diff
changeset
|
3261 |
two parent hash identifiers, followed by a "+" if the working |
3c753f9a2fbc
identify: further clarification of help
Kevin Bullock <kbullock@ringworld.org>
parents:
13952
diff
changeset
|
3262 |
directory has uncommitted changes, the branch name (if not default), |
3c753f9a2fbc
identify: further clarification of help
Kevin Bullock <kbullock@ringworld.org>
parents:
13952
diff
changeset
|
3263 |
a list of tags, and a list of bookmarks. |
13952
1416b9118540
identify/help: say what the command does first, mention bookmarks
Idan Kamara <idankk86@gmail.com>
parents:
13693
diff
changeset
|
3264 |
|
1416b9118540
identify/help: say what the command does first, mention bookmarks
Idan Kamara <idankk86@gmail.com>
parents:
13693
diff
changeset
|
3265 |
When REV is not given, print a summary of the current state of the |
8027
9c7ca86fc658
expand "repo" to "repository" in help texts
Martin Geisler <mg@lazybytes.net>
parents:
8026
diff
changeset
|
3266 |
repository. |
4671
150afe6becf6
identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents:
4667
diff
changeset
|
3267 |
|
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3268 |
Specifying a path to a repository root or Mercurial bundle will |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3269 |
cause lookup to operate on that repository/bundle. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3270 |
|
15112
24f5489452af
id: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15111
diff
changeset
|
3271 |
.. container:: verbose |
24f5489452af
id: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15111
diff
changeset
|
3272 |
|
24f5489452af
id: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15111
diff
changeset
|
3273 |
Examples: |
24f5489452af
id: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15111
diff
changeset
|
3274 |
|
24f5489452af
id: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15111
diff
changeset
|
3275 |
- generate a build identifier for the working directory:: |
24f5489452af
id: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15111
diff
changeset
|
3276 |
|
24f5489452af
id: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15111
diff
changeset
|
3277 |
hg id --id > build-id.dat |
24f5489452af
id: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15111
diff
changeset
|
3278 |
|
24f5489452af
id: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15111
diff
changeset
|
3279 |
- find the revision corresponding to a tag:: |
24f5489452af
id: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15111
diff
changeset
|
3280 |
|
24f5489452af
id: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15111
diff
changeset
|
3281 |
hg id -n -r 1.3 |
24f5489452af
id: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15111
diff
changeset
|
3282 |
|
24f5489452af
id: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15111
diff
changeset
|
3283 |
- check the most recent revision of a remote repository:: |
24f5489452af
id: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15111
diff
changeset
|
3284 |
|
24f5489452af
id: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15111
diff
changeset
|
3285 |
hg id -r tip http://selenic.com/hg/ |
24f5489452af
id: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15111
diff
changeset
|
3286 |
|
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
3287 |
Returns 0 if successful. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3288 |
""" |
4662
f9b8ea362b49
identify: show nullid for empty repo
Matt Mackall <mpm@selenic.com>
parents:
4659
diff
changeset
|
3289 |
|
5330
4528858e7202
make identify an optionalrepo command
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5329
diff
changeset
|
3290 |
if not repo and not source: |
12067
a4fbbe0fbc38
Lowercase error messages
Martin Geisler <mg@lazybytes.net>
parents:
11881
diff
changeset
|
3291 |
raise util.Abort(_("there is no Mercurial repository here " |
5330
4528858e7202
make identify an optionalrepo command
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5329
diff
changeset
|
3292 |
"(.hg not found)")) |
4528858e7202
make identify an optionalrepo command
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5329
diff
changeset
|
3293 |
|
2966
fb493241d7f6
Only show long hashes with --debug, not --verbose
Matt Mackall <mpm@selenic.com>
parents:
2963
diff
changeset
|
3294 |
hexfunc = ui.debugflag and hex or short |
13477
0fb2ff949790
id: add bookmarks to id
Kevin Bullock <kbullock@ringworld.org>
parents:
13473
diff
changeset
|
3295 |
default = not (num or id or branch or tags or bookmarks) |
4666
48c94bffdb28
identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents:
4665
diff
changeset
|
3296 |
output = [] |
7757
af6a63438a8a
identify: have consistent output for local repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7743
diff
changeset
|
3297 |
revs = [] |
13953
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3298 |
|
4671
150afe6becf6
identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents:
4667
diff
changeset
|
3299 |
if source: |
10365
d757bc0c7865
interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents:
10364
diff
changeset
|
3300 |
source, branches = hg.parseurl(ui.expandpath(source)) |
15580
5a7733563c2e
id: add command line options for handling ssh and https urls
Mads Kiilerich <mads@kiilerich.com>
parents:
15578
diff
changeset
|
3301 |
repo = hg.peer(ui, opts, source) |
10365
d757bc0c7865
interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents:
10364
diff
changeset
|
3302 |
revs, checkout = hg.addbranchrevs(repo, repo, branches, None) |
7757
af6a63438a8a
identify: have consistent output for local repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7743
diff
changeset
|
3303 |
|
af6a63438a8a
identify: have consistent output for local repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7743
diff
changeset
|
3304 |
if not repo.local(): |
13953
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3305 |
if num or branch or tags: |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3306 |
raise util.Abort( |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3307 |
_("can't query remote revision number, branch, or tags")) |
4671
150afe6becf6
identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents:
4667
diff
changeset
|
3308 |
if not rev and revs: |
150afe6becf6
identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents:
4667
diff
changeset
|
3309 |
rev = revs[0] |
4667
c7a81e3ae80f
identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents:
4666
diff
changeset
|
3310 |
if not rev: |
c7a81e3ae80f
identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents:
4666
diff
changeset
|
3311 |
rev = "tip" |
13644
7e6c2f58ad56
identify: list bookmarks for remote repositories
Nils Adermann <naderman@naderman.de>
parents:
13639
diff
changeset
|
3312 |
|
7e6c2f58ad56
identify: list bookmarks for remote repositories
Nils Adermann <naderman@naderman.de>
parents:
13639
diff
changeset
|
3313 |
remoterev = repo.lookup(rev) |
4666
48c94bffdb28
identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents:
4665
diff
changeset
|
3314 |
if default or id: |
13644
7e6c2f58ad56
identify: list bookmarks for remote repositories
Nils Adermann <naderman@naderman.de>
parents:
13639
diff
changeset
|
3315 |
output = [hexfunc(remoterev)] |
7e6c2f58ad56
identify: list bookmarks for remote repositories
Nils Adermann <naderman@naderman.de>
parents:
13639
diff
changeset
|
3316 |
|
13953
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3317 |
def getbms(): |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3318 |
bms = [] |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3319 |
|
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3320 |
if 'bookmarks' in repo.listkeys('namespaces'): |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3321 |
hexremoterev = hex(remoterev) |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3322 |
bms = [bm for bm, bmr in repo.listkeys('bookmarks').iteritems() |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3323 |
if bmr == hexremoterev] |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3324 |
|
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3325 |
return bms |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3326 |
|
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3327 |
if bookmarks: |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3328 |
output.extend(getbms()) |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3329 |
elif default and not ui.quiet: |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3330 |
# multiple bookmarks for a single parent separated by '/' |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3331 |
bm = '/'.join(getbms()) |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3332 |
if bm: |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3333 |
output.append(bm) |
4665
091c9e54d306
identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents:
4664
diff
changeset
|
3334 |
else: |
13953
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3335 |
if not rev: |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3336 |
ctx = repo[None] |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3337 |
parents = ctx.parents() |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3338 |
changed = "" |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3339 |
if default or id or num: |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3340 |
changed = util.any(repo.status()) and "+" or "" |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3341 |
if default or id: |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3342 |
output = ["%s%s" % |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3343 |
('+'.join([hexfunc(p.node()) for p in parents]), changed)] |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3344 |
if num: |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3345 |
output.append("%s%s" % |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3346 |
('+'.join([str(p.rev()) for p in parents]), changed)) |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3347 |
else: |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
3348 |
ctx = scmutil.revsingle(repo, rev) |
13953
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3349 |
if default or id: |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3350 |
output = [hexfunc(ctx.node())] |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3351 |
if num: |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3352 |
output.append(str(ctx.rev())) |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3353 |
|
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3354 |
if default and not ui.quiet: |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3355 |
b = ctx.branch() |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3356 |
if b != 'default': |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3357 |
output.append("(%s)" % b) |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3358 |
|
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3359 |
# multiple tags for a single parent separated by '/' |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3360 |
t = '/'.join(ctx.tags()) |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3361 |
if t: |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3362 |
output.append(t) |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3363 |
|
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3364 |
# multiple bookmarks for a single parent separated by '/' |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3365 |
bm = '/'.join(ctx.bookmarks()) |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3366 |
if bm: |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3367 |
output.append(bm) |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3368 |
else: |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3369 |
if branch: |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3370 |
output.append(ctx.branch()) |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3371 |
|
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3372 |
if tags: |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3373 |
output.extend(ctx.tags()) |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3374 |
|
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3375 |
if bookmarks: |
ae10a5e8e558
identify: restructure code to make it more readable
Idan Kamara <idankk86@gmail.com>
parents:
13950
diff
changeset
|
3376 |
output.extend(ctx.bookmarks()) |
13477
0fb2ff949790
id: add bookmarks to id
Kevin Bullock <kbullock@ringworld.org>
parents:
13473
diff
changeset
|
3377 |
|
386
494c8e3f47f3
Improvements for hg identify:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
371
diff
changeset
|
3378 |
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
|
3379 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3380 |
@command('import|patch', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3381 |
[('p', 'strip', 1, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3382 |
_('directory strip option for patch. This has the same ' |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3383 |
'meaning as the corresponding patch option'), _('NUM')), |
14532
2498128821a9
import: deprecate --base
Patrick Mezard <pmezard@gmail.com>
parents:
14529
diff
changeset
|
3384 |
('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')), |
15221 | 3385 |
('e', 'edit', False, _('invoke editor on commit messages')), |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3386 |
('f', 'force', None, _('skip check for outstanding uncommitted changes')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3387 |
('', 'no-commit', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3388 |
_("don't commit, just update the working directory")), |
14611
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3389 |
('', 'bypass', None, |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3390 |
_("apply patch without touching the working directory")), |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3391 |
('', 'exact', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3392 |
_('apply patch to the nodes from which it was generated')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3393 |
('', 'import-branch', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3394 |
_('use any branch information in patch (implied by --exact)'))] + |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3395 |
commitopts + commitopts2 + similarityopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3396 |
_('[OPTION]... PATCH...')) |
15327
67e92d29ecb5
import: abort usefully if no patch name given
Kevin Bullock <kbullock@ringworld.org>
parents:
15321
diff
changeset
|
3397 |
def import_(ui, repo, patch1=None, *patches, **opts): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3398 |
"""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
|
3399 |
|
9649 | 3400 |
Import a list of patches and commit them individually (unless |
3401 |
--no-commit is specified). |
|
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3402 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3403 |
If there are outstanding changes in the working directory, import |
8033
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
3404 |
will abort unless given the -f/--force flag. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3405 |
|
6448
cd3d49ffc6f6
Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents:
6442
diff
changeset
|
3406 |
You can import a patch straight from a mail message. Even patches |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3407 |
as attachments work (to use the body part, it must have type |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3408 |
text/plain or text/x-patch). From and Subject headers of email |
6448
cd3d49ffc6f6
Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents:
6442
diff
changeset
|
3409 |
message are used as default committer and commit message. All |
2515
a6700c222314
import: make help clearer. suggested by asak.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2513
diff
changeset
|
3410 |
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
|
3411 |
message. |
2504
158d3d2ae070
import: parse email messages
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2494
diff
changeset
|
3412 |
|
11193
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11185
diff
changeset
|
3413 |
If the imported patch was generated by :hg:`export`, user and |
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3414 |
description from patch override values from message headers and |
8033
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
3415 |
body. Values given on command line with -m/--message and -u/--user |
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
3416 |
override these. |
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3417 |
|
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3418 |
If --exact is specified, import will set the working directory to |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3419 |
the parent of each patch before applying it, and will abort if the |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3420 |
resulting changeset has a different ID than the one recorded in |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3421 |
the patch. This may happen due to character set problems or other |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3422 |
deficiencies in the text patch format. |
4263 | 3423 |
|
14611
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3424 |
Use --bypass to apply and commit patches directly to the |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3425 |
repository, not touching the working directory. Without --exact, |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3426 |
patches will be applied on top of the working directory parent |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3427 |
revision. |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3428 |
|
8033
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
3429 |
With -s/--similarity, hg will attempt to discover renames and |
15779
01831f55e972
commands: add link to addremove in commit help text
Martin Geisler <mg@lazybytes.net>
parents:
15765
diff
changeset
|
3430 |
copies in the patch in the same way as :hg:`addremove`. |
7402
bffdab64dfbb
import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents:
7372
diff
changeset
|
3431 |
|
8931
4c99eafb101e
commands: add note about import retrieving patches from URLs
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8927
diff
changeset
|
3432 |
To read a patch from standard input, use "-" as the patch name. If |
4c99eafb101e
commands: add note about import retrieving patches from URLs
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8927
diff
changeset
|
3433 |
a URL is specified, the patch will be downloaded from it. |
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
3434 |
See :hg:`help dates` for a list of formats valid for -d/--date. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
3435 |
|
15113 | 3436 |
.. container:: verbose |
3437 |
||
3438 |
Examples: |
|
3439 |
||
3440 |
- import a traditional patch from a website and detect renames:: |
|
3441 |
||
3442 |
hg import -s 80 http://example.com/bugfix.patch |
|
3443 |
||
3444 |
- import a changeset from an hgweb server:: |
|
3445 |
||
3446 |
hg import http://www.selenic.com/hg/rev/5ca8c111e9aa |
|
3447 |
||
3448 |
- import all the patches in an Unix-style mbox:: |
|
3449 |
||
3450 |
hg import incoming-patches.mbox |
|
3451 |
||
3452 |
- attempt to exactly restore an exported changeset (not always |
|
3453 |
possible):: |
|
3454 |
||
3455 |
hg import --exact proposed-fix.patch |
|
3456 |
||
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
3457 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3458 |
""" |
15327
67e92d29ecb5
import: abort usefully if no patch name given
Kevin Bullock <kbullock@ringworld.org>
parents:
15321
diff
changeset
|
3459 |
|
67e92d29ecb5
import: abort usefully if no patch name given
Kevin Bullock <kbullock@ringworld.org>
parents:
15321
diff
changeset
|
3460 |
if not patch1: |
67e92d29ecb5
import: abort usefully if no patch name given
Kevin Bullock <kbullock@ringworld.org>
parents:
15321
diff
changeset
|
3461 |
raise util.Abort(_('need at least one patch to import')) |
67e92d29ecb5
import: abort usefully if no patch name given
Kevin Bullock <kbullock@ringworld.org>
parents:
15321
diff
changeset
|
3462 |
|
437 | 3463 |
patches = (patch1,) + patches |
500
ebc4714a7632
[PATCH] Clean up destination directory if a clone fails.
mpm@selenic.com
parents:
499
diff
changeset
|
3464 |
|
6139
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6134
diff
changeset
|
3465 |
date = opts.get('date') |
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6134
diff
changeset
|
3466 |
if date: |
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6134
diff
changeset
|
3467 |
opts['date'] = util.parsedate(date) |
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6134
diff
changeset
|
3468 |
|
15221 | 3469 |
editor = cmdutil.commiteditor |
3470 |
if opts.get('edit'): |
|
3471 |
editor = cmdutil.commitforceeditor |
|
3472 |
||
14611
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3473 |
update = not opts.get('bypass') |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3474 |
if not update and opts.get('no_commit'): |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3475 |
raise util.Abort(_('cannot use --no-commit with --bypass')) |
7402
bffdab64dfbb
import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents:
7372
diff
changeset
|
3476 |
try: |
bffdab64dfbb
import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents:
7372
diff
changeset
|
3477 |
sim = float(opts.get('similarity') or 0) |
bffdab64dfbb
import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents:
7372
diff
changeset
|
3478 |
except ValueError: |
bffdab64dfbb
import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents:
7372
diff
changeset
|
3479 |
raise util.Abort(_('similarity must be a number')) |
bffdab64dfbb
import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents:
7372
diff
changeset
|
3480 |
if sim < 0 or sim > 100: |
bffdab64dfbb
import: add similarity option (issue295)
Brendan Cully <brendan@kublai.com>
parents:
7372
diff
changeset
|
3481 |
raise util.Abort(_('similarity must be between 0 and 100')) |
14611
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3482 |
if sim and not update: |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3483 |
raise util.Abort(_('cannot use --similarity with --bypass')) |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3484 |
|
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3485 |
if (opts.get('exact') or not opts.get('force')) and update: |
14289
d68ddccf276b
cmdutil: bail_if_changed to bailifchanged
Matt Mackall <mpm@selenic.com>
parents:
14286
diff
changeset
|
3486 |
cmdutil.bailifchanged(repo) |
966
022bcc738389
hg import: abort with uncommitted changes, override with --force
mpm@selenic.com
parents:
965
diff
changeset
|
3487 |
|
15195
5b2a3bb06cef
import: rename some local variables
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
3488 |
base = opts["base"] |
437 | 3489 |
strip = opts["strip"] |
15198
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15197
diff
changeset
|
3490 |
wlock = lock = tr = None |
12913
0e0a52bd58f9
import: --no-commit should update .hg/last-message.txt
Steve Borho <steve@borho.org>
parents:
12893
diff
changeset
|
3491 |
msgs = [] |
10384
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3492 |
|
14611
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3493 |
def checkexact(repo, n, nodeid): |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3494 |
if opts.get('exact') and hex(n) != nodeid: |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3495 |
repo.rollback() |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3496 |
raise util.Abort(_('patch is damaged or loses information')) |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3497 |
|
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3498 |
def tryone(ui, hunk, parents): |
10413
e433002acb05
fix up a bunch of check-code warnings
Matt Mackall <mpm@selenic.com>
parents:
10405
diff
changeset
|
3499 |
tmpname, message, user, date, branch, nodeid, p1, p2 = \ |
e433002acb05
fix up a bunch of check-code warnings
Matt Mackall <mpm@selenic.com>
parents:
10405
diff
changeset
|
3500 |
patch.extract(ui, hunk) |
10384
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3501 |
|
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3502 |
if not tmpname: |
15194
0705f2ac79d6
import: simplify status reporting logic (and make it more I18N-friendly)
Greg Ward <greg@gerg.ca>
parents:
15192
diff
changeset
|
3503 |
return (None, None) |
0705f2ac79d6
import: simplify status reporting logic (and make it more I18N-friendly)
Greg Ward <greg@gerg.ca>
parents:
15192
diff
changeset
|
3504 |
msg = _('applied to working directory') |
10384
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3505 |
|
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3506 |
try: |
14635
217b7d83afc3
cmdutil, logmessage: use ui.fin when reading from '-'
Idan Kamara <idankk86@gmail.com>
parents:
14631
diff
changeset
|
3507 |
cmdline_message = cmdutil.logmessage(ui, opts) |
10384
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3508 |
if cmdline_message: |
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3509 |
# pickup the cmdline msg |
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3510 |
message = cmdline_message |
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3511 |
elif message: |
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3512 |
# pickup the patch msg |
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3513 |
message = message.strip() |
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3514 |
else: |
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3515 |
# launch the editor |
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3516 |
message = None |
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3517 |
ui.debug('message:\n%s\n' % message) |
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3518 |
|
14611
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3519 |
if len(parents) == 1: |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3520 |
parents.append(repo[nullid]) |
10384
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3521 |
if opts.get('exact'): |
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3522 |
if not nodeid or not p1: |
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3523 |
raise util.Abort(_('not a Mercurial patch')) |
14610
5d6244930559
import: separate parents selection from working dir update
Patrick Mezard <pmezard@gmail.com>
parents:
14604
diff
changeset
|
3524 |
p1 = repo[p1] |
5d6244930559
import: separate parents selection from working dir update
Patrick Mezard <pmezard@gmail.com>
parents:
14604
diff
changeset
|
3525 |
p2 = repo[p2 or nullid] |
10384
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3526 |
elif p2: |
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3527 |
try: |
14610
5d6244930559
import: separate parents selection from working dir update
Patrick Mezard <pmezard@gmail.com>
parents:
14604
diff
changeset
|
3528 |
p1 = repo[p1] |
5d6244930559
import: separate parents selection from working dir update
Patrick Mezard <pmezard@gmail.com>
parents:
14604
diff
changeset
|
3529 |
p2 = repo[p2] |
15511
6cae68a361ed
import: fix parent selection when importing merges
Patrick Mezard <pmezard@gmail.com>
parents:
15508
diff
changeset
|
3530 |
# Without any options, consider p2 only if the |
6cae68a361ed
import: fix parent selection when importing merges
Patrick Mezard <pmezard@gmail.com>
parents:
15508
diff
changeset
|
3531 |
# patch is being applied on top of the recorded |
6cae68a361ed
import: fix parent selection when importing merges
Patrick Mezard <pmezard@gmail.com>
parents:
15508
diff
changeset
|
3532 |
# first parent. |
6cae68a361ed
import: fix parent selection when importing merges
Patrick Mezard <pmezard@gmail.com>
parents:
15508
diff
changeset
|
3533 |
if p1 != parents[0]: |
6cae68a361ed
import: fix parent selection when importing merges
Patrick Mezard <pmezard@gmail.com>
parents:
15508
diff
changeset
|
3534 |
p1 = parents[0] |
6cae68a361ed
import: fix parent selection when importing merges
Patrick Mezard <pmezard@gmail.com>
parents:
15508
diff
changeset
|
3535 |
p2 = repo[nullid] |
10384
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3536 |
except error.RepoError: |
14611
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3537 |
p1, p2 = parents |
14610
5d6244930559
import: separate parents selection from working dir update
Patrick Mezard <pmezard@gmail.com>
parents:
14604
diff
changeset
|
3538 |
else: |
14611
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3539 |
p1, p2 = parents |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3540 |
|
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3541 |
n = None |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3542 |
if update: |
15511
6cae68a361ed
import: fix parent selection when importing merges
Patrick Mezard <pmezard@gmail.com>
parents:
15508
diff
changeset
|
3543 |
if p1 != parents[0]: |
14611
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3544 |
hg.clean(repo, p1.node()) |
15511
6cae68a361ed
import: fix parent selection when importing merges
Patrick Mezard <pmezard@gmail.com>
parents:
15508
diff
changeset
|
3545 |
if p2 != parents[1]: |
14611
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3546 |
repo.dirstate.setparents(p1.node(), p2.node()) |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3547 |
|
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3548 |
if opts.get('exact') or opts.get('import_branch'): |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3549 |
repo.dirstate.setbranch(branch or 'default') |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3550 |
|
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3551 |
files = set() |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3552 |
patch.patch(ui, repo, tmpname, strip=strip, files=files, |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3553 |
eolmode=None, similarity=sim / 100.0) |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3554 |
files = list(files) |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3555 |
if opts.get('no_commit'): |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3556 |
if message: |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3557 |
msgs.append(message) |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3558 |
else: |
15511
6cae68a361ed
import: fix parent selection when importing merges
Patrick Mezard <pmezard@gmail.com>
parents:
15508
diff
changeset
|
3559 |
if opts.get('exact') or p2: |
6cae68a361ed
import: fix parent selection when importing merges
Patrick Mezard <pmezard@gmail.com>
parents:
15508
diff
changeset
|
3560 |
# If you got here, you either use --force and know what |
6cae68a361ed
import: fix parent selection when importing merges
Patrick Mezard <pmezard@gmail.com>
parents:
15508
diff
changeset
|
3561 |
# you are doing or used --exact or a merge patch while |
6cae68a361ed
import: fix parent selection when importing merges
Patrick Mezard <pmezard@gmail.com>
parents:
15508
diff
changeset
|
3562 |
# being updated to its first parent. |
14611
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3563 |
m = None |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3564 |
else: |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3565 |
m = scmutil.matchfiles(repo, files or []) |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3566 |
n = repo.commit(message, opts.get('user') or user, |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3567 |
opts.get('date') or date, match=m, |
15221 | 3568 |
editor=editor) |
14611
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3569 |
checkexact(repo, n, nodeid) |
12913
0e0a52bd58f9
import: --no-commit should update .hg/last-message.txt
Steve Borho <steve@borho.org>
parents:
12893
diff
changeset
|
3570 |
else: |
14611
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3571 |
if opts.get('exact') or opts.get('import_branch'): |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3572 |
branch = branch or 'default' |
10384
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3573 |
else: |
14611
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3574 |
branch = p1.branch() |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3575 |
store = patch.filestore() |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3576 |
try: |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3577 |
files = set() |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3578 |
try: |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3579 |
patch.patchrepo(ui, repo, p1, store, tmpname, strip, |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3580 |
files, eolmode=None) |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3581 |
except patch.PatchError, e: |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3582 |
raise util.Abort(str(e)) |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3583 |
memctx = patch.makememctx(repo, (p1.node(), p2.node()), |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3584 |
message, |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3585 |
opts.get('user') or user, |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3586 |
opts.get('date') or date, |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3587 |
branch, files, store, |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3588 |
editor=cmdutil.commiteditor) |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3589 |
repo.savecommitmessage(memctx.description()) |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3590 |
n = memctx.commit() |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3591 |
checkexact(repo, n, nodeid) |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3592 |
finally: |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3593 |
store.close() |
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3594 |
if n: |
15307
718e0684c703
import: add i18n context
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
15293
diff
changeset
|
3595 |
# i18n: refers to a short changeset id |
15194
0705f2ac79d6
import: simplify status reporting logic (and make it more I18N-friendly)
Greg Ward <greg@gerg.ca>
parents:
15192
diff
changeset
|
3596 |
msg = _('created %s') % short(n) |
0705f2ac79d6
import: simplify status reporting logic (and make it more I18N-friendly)
Greg Ward <greg@gerg.ca>
parents:
15192
diff
changeset
|
3597 |
return (msg, n) |
10384
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3598 |
finally: |
832f35386067
import: import each patch in a file or stream as a separate change
Brendan Cully <brendan@kublai.com>
parents:
10379
diff
changeset
|
3599 |
os.unlink(tmpname) |
10405
2d30d66a89ad
whitespace cleanup
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
10394
diff
changeset
|
3600 |
|
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
3601 |
try: |
15278
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3602 |
try: |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3603 |
wlock = repo.wlock() |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3604 |
lock = repo.lock() |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3605 |
tr = repo.transaction('import') |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3606 |
parents = repo.parents() |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3607 |
for patchurl in patches: |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3608 |
if patchurl == '-': |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3609 |
ui.status(_('applying patch from stdin\n')) |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3610 |
patchfile = ui.fin |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3611 |
patchurl = 'stdin' # for error message |
14611
adbf5e7df96d
import: add --bypass option
Patrick Mezard <pmezard@gmail.com>
parents:
14610
diff
changeset
|
3612 |
else: |
15278
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3613 |
patchurl = os.path.join(base, patchurl) |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3614 |
ui.status(_('applying %s\n') % patchurl) |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3615 |
patchfile = url.open(ui, patchurl) |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3616 |
|
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3617 |
haspatch = False |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3618 |
for hunk in patch.split(patchfile): |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3619 |
(msg, node) = tryone(ui, hunk, parents) |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3620 |
if msg: |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3621 |
haspatch = True |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3622 |
ui.note(msg + '\n') |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3623 |
if update or opts.get('exact'): |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3624 |
parents = repo.parents() |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3625 |
else: |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3626 |
parents = [repo[node]] |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3627 |
|
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3628 |
if not haspatch: |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3629 |
raise util.Abort(_('%s: no diffs found') % patchurl) |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3630 |
|
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3631 |
tr.close() |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3632 |
if msgs: |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3633 |
repo.savecommitmessage('\n* * *\n'.join(msgs)) |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3634 |
except: |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3635 |
# wlock.release() indirectly calls dirstate.write(): since |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3636 |
# we're crashing, we do not want to change the working dir |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3637 |
# parent after all, so make sure it writes nothing |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3638 |
repo.dirstate.invalidate() |
2ed335669e18
commands: use separate try/except and try/finally as needed for python2.4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15265
diff
changeset
|
3639 |
raise |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
3640 |
finally: |
15198
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15197
diff
changeset
|
3641 |
if tr: |
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15197
diff
changeset
|
3642 |
tr.release() |
8109
496ae1ea4698
switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8088
diff
changeset
|
3643 |
release(lock, wlock) |
437 | 3644 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3645 |
@command('incoming|in', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3646 |
[('f', 'force', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3647 |
_('run even if remote repository is unrelated')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3648 |
('n', 'newest-first', None, _('show newest record first')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3649 |
('', 'bundle', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3650 |
_('file to store the bundles into'), _('FILE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3651 |
('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3652 |
('B', 'bookmarks', False, _("compare bookmarks")), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3653 |
('b', 'branch', [], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3654 |
_('a specific branch you would like to pull'), _('BRANCH')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3655 |
] + logopts + remoteopts + subrepoopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3656 |
_('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]')) |
1192
6e165de907c5
Add -p to incoming and outgoing commands to show patch
TK Soh <teekaysoh@yahoo.com>
parents:
1191
diff
changeset
|
3657 |
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
|
3658 |
"""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
|
3659 |
|
1979
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
3660 |
Show new changesets found in the specified path/URL or the default |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3661 |
pull location. These are the changesets that would have been pulled |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3662 |
if a pull at the time you issued this command. |
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3663 |
|
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3664 |
For remote repository, using --bundle avoids downloading the |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
3665 |
changesets 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
|
3666 |
|
d545fa1426b9
More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1974
diff
changeset
|
3667 |
See pull for valid source format details. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
3668 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
3669 |
Returns 0 if there are incoming changes, 1 otherwise. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3670 |
""" |
12274
c02e1ed3d407
incoming: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12273
diff
changeset
|
3671 |
if opts.get('bundle') and opts.get('subrepos'): |
c02e1ed3d407
incoming: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12273
diff
changeset
|
3672 |
raise util.Abort(_('cannot combine --bundle and --subrepos')) |
c02e1ed3d407
incoming: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12273
diff
changeset
|
3673 |
|
13366
c756e9166417
bookmarks: merge incoming/outgoing into core
Matt Mackall <mpm@selenic.com>
parents:
13344
diff
changeset
|
3674 |
if opts.get('bookmarks'): |
c756e9166417
bookmarks: merge incoming/outgoing into core
Matt Mackall <mpm@selenic.com>
parents:
13344
diff
changeset
|
3675 |
source, branches = hg.parseurl(ui.expandpath(source), |
c756e9166417
bookmarks: merge incoming/outgoing into core
Matt Mackall <mpm@selenic.com>
parents:
13344
diff
changeset
|
3676 |
opts.get('branch')) |
14556
517e1d88bf7e
hg: change various repository() users to use peer() where appropriate
Matt Mackall <mpm@selenic.com>
parents:
14553
diff
changeset
|
3677 |
other = hg.peer(repo, opts, source) |
13453
c1b808020819
bookmarks: issue a warning if remote doesn't support comparing bookmarks
David Soria Parra <dsp@php.net>
parents:
13448
diff
changeset
|
3678 |
if 'bookmarks' not in other.listkeys('namespaces'): |
c1b808020819
bookmarks: issue a warning if remote doesn't support comparing bookmarks
David Soria Parra <dsp@php.net>
parents:
13448
diff
changeset
|
3679 |
ui.warn(_("remote doesn't support bookmarks\n")) |
c1b808020819
bookmarks: issue a warning if remote doesn't support comparing bookmarks
David Soria Parra <dsp@php.net>
parents:
13448
diff
changeset
|
3680 |
return 0 |
14076
924c82157d46
url: move URL parsing functions into util to improve startup time
Brodie Rao <brodie@bitheap.org>
parents:
14073
diff
changeset
|
3681 |
ui.status(_('comparing with %s\n') % util.hidepassword(source)) |
13366
c756e9166417
bookmarks: merge incoming/outgoing into core
Matt Mackall <mpm@selenic.com>
parents:
13344
diff
changeset
|
3682 |
return bookmarks.diff(ui, repo, other) |
c756e9166417
bookmarks: merge incoming/outgoing into core
Matt Mackall <mpm@selenic.com>
parents:
13344
diff
changeset
|
3683 |
|
14360
ab687820c4cc
subrepo: respect non-default path for incoming/outgoing
Martin Geisler <mg@aragost.com>
parents:
14014
diff
changeset
|
3684 |
repo._subtoppath = ui.expandpath(source) |
ab687820c4cc
subrepo: respect non-default path for incoming/outgoing
Martin Geisler <mg@aragost.com>
parents:
14014
diff
changeset
|
3685 |
try: |
14362
8c740a850ad7
commands: replace 'x = f(); return x' with 'return f()'
Martin Geisler <mg@lazybytes.net>
parents:
14361
diff
changeset
|
3686 |
return hg.incoming(ui, repo, source, opts) |
14360
ab687820c4cc
subrepo: respect non-default path for incoming/outgoing
Martin Geisler <mg@aragost.com>
parents:
14014
diff
changeset
|
3687 |
finally: |
ab687820c4cc
subrepo: respect non-default path for incoming/outgoing
Martin Geisler <mg@aragost.com>
parents:
14014
diff
changeset
|
3688 |
del repo._subtoppath |
ab687820c4cc
subrepo: respect non-default path for incoming/outgoing
Martin Geisler <mg@aragost.com>
parents:
14014
diff
changeset
|
3689 |
|
1944
fdf40c9b3306
incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1943
diff
changeset
|
3690 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3691 |
@command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]')) |
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
|
3692 |
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
|
3693 |
"""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
|
3694 |
|
6448
cd3d49ffc6f6
Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents:
6442
diff
changeset
|
3695 |
Initialize a new repository in the given directory. If the given |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3696 |
directory does not exist, it will be created. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3697 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3698 |
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
|
3699 |
|
9970
36760956f6d3
commands: mark "ssh://" as inline literals in help texts
Martin Geisler <mg@lazybytes.net>
parents:
9952
diff
changeset
|
3700 |
It is possible to specify an ``ssh://`` URL as the destination. |
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
3701 |
See :hg:`help urls` for more information. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
3702 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
3703 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3704 |
""" |
14556
517e1d88bf7e
hg: change various repository() users to use peer() where appropriate
Matt Mackall <mpm@selenic.com>
parents:
14553
diff
changeset
|
3705 |
hg.peer(ui, opts, ui.expandpath(dest), create=True) |
338 | 3706 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3707 |
@command('locate', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3708 |
[('r', 'rev', '', _('search the repository as it is in REV'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3709 |
('0', 'print0', None, _('end filenames with NUL, for use with xargs')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3710 |
('f', 'fullpath', None, _('print complete paths from the filesystem root')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3711 |
] + walkopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3712 |
_('[OPTION]... [PATTERN]...')) |
627 | 3713 |
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
|
3714 |
"""locate files matching specific patterns |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3715 |
|
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3716 |
Print files under Mercurial control in the working directory whose |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3717 |
names match the given patterns. |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3718 |
|
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3719 |
By default, this command searches all directories in the working |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3720 |
directory. To search just the current directory and its |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3721 |
subdirectories, use "--include .". |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3722 |
|
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3723 |
If no patterns are given to match, this command prints the names |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3724 |
of all files under Mercurial control in the working directory. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3725 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3726 |
If you want to feed the output of this command into the "xargs" |
8032
4726a522a182
commands: use double quotes consistently in help texts
Martin Geisler <mg@lazybytes.net>
parents:
8031
diff
changeset
|
3727 |
command, use the -0 option to both this command and "xargs". This |
4726a522a182
commands: use double quotes consistently in help texts
Martin Geisler <mg@lazybytes.net>
parents:
8031
diff
changeset
|
3728 |
will avoid the problem of "xargs" treating single filenames that |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3729 |
contain whitespace as multiple filenames. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
3730 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
3731 |
Returns 0 if a match is found, 1 otherwise. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3732 |
""" |
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
3733 |
end = opts.get('print0') and '\0' or '\n' |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
3734 |
rev = scmutil.revsingle(repo, opts.get('rev'), None).node() |
742 | 3735 |
|
4196
1c69c73d85d9
locate: exit(1) if we didn't print any file
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4195
diff
changeset
|
3736 |
ret = 1 |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
3737 |
m = scmutil.match(repo[rev], pats, opts, default='relglob') |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10270
diff
changeset
|
3738 |
m.bad = lambda x, y: False |
6764 | 3739 |
for abs in repo[rev].walk(m): |
3740 |
if not rev and abs not in repo.dirstate: |
|
4308
a5cde03cd019
locate: don't print "file not found" messages.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4252
diff
changeset
|
3741 |
continue |
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
3742 |
if opts.get('fullpath'): |
7570
e05aa73ce2b7
use repo.wjoin(f) instead of os.path.join(repo.root, f)
Martin Geisler <mg@daimi.au.dk>
parents:
7540
diff
changeset
|
3743 |
ui.write(repo.wjoin(abs), end) |
724
1c0c413cccdd
Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
723
diff
changeset
|
3744 |
else: |
6584
29c77e5dfb3c
walk: remove rel and exact returns
Matt Mackall <mpm@selenic.com>
parents:
6583
diff
changeset
|
3745 |
ui.write(((pats and m.rel(abs)) or abs), end) |
4196
1c69c73d85d9
locate: exit(1) if we didn't print any file
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4195
diff
changeset
|
3746 |
ret = 0 |
1c69c73d85d9
locate: exit(1) if we didn't print any file
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4195
diff
changeset
|
3747 |
|
1c69c73d85d9
locate: exit(1) if we didn't print any file
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4195
diff
changeset
|
3748 |
return ret |
627 | 3749 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3750 |
@command('^log|history', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3751 |
[('f', 'follow', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3752 |
_('follow changeset history, or file history across copies and renames')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3753 |
('', 'follow-first', None, |
15405
e4a17bb8472f
log: hide some low-utility options
Matt Mackall <mpm@selenic.com>
parents:
15404
diff
changeset
|
3754 |
_('only follow the first parent of merge changesets (DEPRECATED)')), |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3755 |
('d', 'date', '', _('show revisions matching date spec'), _('DATE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3756 |
('C', 'copies', None, _('show copied files')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3757 |
('k', 'keyword', [], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3758 |
_('do case-insensitive search for a given text'), _('TEXT')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3759 |
('r', 'rev', [], _('show the specified revision or range'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3760 |
('', 'removed', None, _('include revisions where files were removed')), |
15405
e4a17bb8472f
log: hide some low-utility options
Matt Mackall <mpm@selenic.com>
parents:
15404
diff
changeset
|
3761 |
('m', 'only-merges', None, _('show only merges (DEPRECATED)')), |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3762 |
('u', 'user', [], _('revisions committed by user'), _('USER')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3763 |
('', 'only-branch', [], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3764 |
_('show only changesets within the given named branch (DEPRECATED)'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3765 |
_('BRANCH')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3766 |
('b', 'branch', [], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3767 |
_('show changesets within the given named branch'), _('BRANCH')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3768 |
('P', 'prune', [], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3769 |
_('do not display revision or any of its ancestors'), _('REV')), |
15424
f3b5ba25d217
log: hide hidden option until it actually does something
Matt Mackall <mpm@selenic.com>
parents:
15405
diff
changeset
|
3770 |
('', 'hidden', False, _('show hidden changesets (DEPRECATED)')), |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3771 |
] + logopts + walkopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3772 |
_('[OPTION]... [FILE]')) |
1031
503aaf19a040
Rewrite log command. New version is faster and more featureful.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1030
diff
changeset
|
3773 |
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
|
3774 |
"""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
|
3775 |
|
2741
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
3776 |
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
|
3777 |
project. |
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
3778 |
|
15104
a20f5088013a
log: rearrange the help text a bit
Matt Mackall <mpm@selenic.com>
parents:
15103
diff
changeset
|
3779 |
If no revision range is specified, the default is ``tip:0`` unless |
a20f5088013a
log: rearrange the help text a bit
Matt Mackall <mpm@selenic.com>
parents:
15103
diff
changeset
|
3780 |
--follow is set, in which case the working directory parent is |
a20f5088013a
log: rearrange the help text a bit
Matt Mackall <mpm@selenic.com>
parents:
15103
diff
changeset
|
3781 |
used as the starting revision. |
a20f5088013a
log: rearrange the help text a bit
Matt Mackall <mpm@selenic.com>
parents:
15103
diff
changeset
|
3782 |
|
2741
ae5ce3454ef5
log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2739
diff
changeset
|
3783 |
File history is shown without following rename or copy history of |
8761
0289f384e1e5
Generally replace "file name" with "filename" in help and comments.
timeless <timeless@gmail.com>
parents:
8760
diff
changeset
|
3784 |
files. Use -f/--follow with a filename to follow history across |
0289f384e1e5
Generally replace "file name" with "filename" in help and comments.
timeless <timeless@gmail.com>
parents:
8760
diff
changeset
|
3785 |
renames and copies. --follow without a filename will only show |
15104
a20f5088013a
log: rearrange the help text a bit
Matt Mackall <mpm@selenic.com>
parents:
15103
diff
changeset
|
3786 |
ancestors or descendants of the starting revision. |
6163
1f733c2f0165
Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6161
diff
changeset
|
3787 |
|
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3788 |
By default this command prints revision number and changeset id, |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3789 |
tags, non-trivial parents, user, date and time, and a summary for |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3790 |
each commit. When the -v/--verbose switch is used, the list of |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3791 |
changed files and full commit message are shown. |
3822
28134d82db9b
Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents:
3815
diff
changeset
|
3792 |
|
12390
aff4afdcfd2b
Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents:
12389
diff
changeset
|
3793 |
.. note:: |
aff4afdcfd2b
Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents:
12389
diff
changeset
|
3794 |
log -p/--patch may generate unexpected diff output for merge |
aff4afdcfd2b
Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents:
12389
diff
changeset
|
3795 |
changesets, as it will only compare the merge changeset against |
aff4afdcfd2b
Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents:
12389
diff
changeset
|
3796 |
its first parent. Also, only files different from BOTH parents |
aff4afdcfd2b
Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents:
12389
diff
changeset
|
3797 |
will appear in files:. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
3798 |
|
15105
6e91fba485fa
log: add a usage note about --removed
Matt Mackall <mpm@selenic.com>
parents:
15104
diff
changeset
|
3799 |
.. note:: |
6e91fba485fa
log: add a usage note about --removed
Matt Mackall <mpm@selenic.com>
parents:
15104
diff
changeset
|
3800 |
for performance reasons, log FILE may omit duplicate changes |
6e91fba485fa
log: add a usage note about --removed
Matt Mackall <mpm@selenic.com>
parents:
15104
diff
changeset
|
3801 |
made on branches and will not show deletions. To see all |
6e91fba485fa
log: add a usage note about --removed
Matt Mackall <mpm@selenic.com>
parents:
15104
diff
changeset
|
3802 |
changes including duplicates and deletions, use the --removed |
6e91fba485fa
log: add a usage note about --removed
Matt Mackall <mpm@selenic.com>
parents:
15104
diff
changeset
|
3803 |
switch. |
6e91fba485fa
log: add a usage note about --removed
Matt Mackall <mpm@selenic.com>
parents:
15104
diff
changeset
|
3804 |
|
15103
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3805 |
.. container:: verbose |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3806 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3807 |
Some examples: |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3808 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3809 |
- changesets with full descriptions and file lists:: |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3810 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3811 |
hg log -v |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3812 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3813 |
- changesets ancestral to the working directory:: |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3814 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3815 |
hg log -f |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3816 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3817 |
- last 10 commits on the current branch:: |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3818 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3819 |
hg log -l 10 -b . |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3820 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3821 |
- changesets showing all modifications of a file, including removals:: |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3822 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3823 |
hg log --removed file.c |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3824 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3825 |
- all changesets that touch a directory, with diffs, excluding merges:: |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3826 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3827 |
hg log -Mp lib/ |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3828 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3829 |
- all revision numbers that match a keyword:: |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3830 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3831 |
hg log -k bug --template "{rev}\\n" |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3832 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3833 |
- check if a given changeset is included is a tagged release:: |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3834 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3835 |
hg log -r "a21ccf and ancestor(1.9)" |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3836 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3837 |
- find all changesets by some user in a date range:: |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3838 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3839 |
hg log -k alice -d "may 2008 to jul 2008" |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3840 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3841 |
- summary of all changesets after the last tag:: |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3842 |
|
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3843 |
hg log -r "last(tagged())::" --template "{desc|firstline}\\n" |
5ca8c111e9aa
log: add some usage examples to verbose help
Matt Mackall <mpm@selenic.com>
parents:
15081
diff
changeset
|
3844 |
|
15104
a20f5088013a
log: rearrange the help text a bit
Matt Mackall <mpm@selenic.com>
parents:
15103
diff
changeset
|
3845 |
See :hg:`help dates` for a list of formats valid for -d/--date. |
a20f5088013a
log: rearrange the help text a bit
Matt Mackall <mpm@selenic.com>
parents:
15103
diff
changeset
|
3846 |
|
a20f5088013a
log: rearrange the help text a bit
Matt Mackall <mpm@selenic.com>
parents:
15103
diff
changeset
|
3847 |
See :hg:`help revisions` and :hg:`help revsets` for more about |
a20f5088013a
log: rearrange the help text a bit
Matt Mackall <mpm@selenic.com>
parents:
15103
diff
changeset
|
3848 |
specifying revisions. |
a20f5088013a
log: rearrange the help text a bit
Matt Mackall <mpm@selenic.com>
parents:
15103
diff
changeset
|
3849 |
|
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
3850 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3851 |
""" |
1756
f29857aaa053
add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1747
diff
changeset
|
3852 |
|
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
3853 |
matchfn = scmutil.match(repo[None], pats, opts) |
6190
a79d9408806f
Move finding/checking the log limit to cmdutil
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6189
diff
changeset
|
3854 |
limit = cmdutil.loglimit(opts) |
1756
f29857aaa053
add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1747
diff
changeset
|
3855 |
count = 0 |
f29857aaa053
add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1747
diff
changeset
|
3856 |
|
16175
280e834c9d15
log: restore cache used by --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16163
diff
changeset
|
3857 |
getrenamed, endrev = None, None |
280e834c9d15
log: restore cache used by --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16163
diff
changeset
|
3858 |
if opts.get('copies'): |
280e834c9d15
log: restore cache used by --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16163
diff
changeset
|
3859 |
if opts.get('rev'): |
280e834c9d15
log: restore cache used by --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16163
diff
changeset
|
3860 |
endrev = max(scmutil.revrange(repo, opts.get('rev'))) + 1 |
280e834c9d15
log: restore cache used by --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16163
diff
changeset
|
3861 |
getrenamed = templatekw.getrenamedfn(repo, endrev=endrev) |
3197 | 3862 |
|
3813 | 3863 |
df = False |
3864 |
if opts["date"]: |
|
3865 |
df = util.matchdate(opts["date"]) |
|
3866 |
||
10963
9e314c5e6890
log -b: use opts.get() instead of assuming opts is correctly filled
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10962
diff
changeset
|
3867 |
branches = opts.get('branch', []) + opts.get('only_branch', []) |
9e314c5e6890
log -b: use opts.get() instead of assuming opts is correctly filled
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10962
diff
changeset
|
3868 |
opts['branch'] = [repo.lookupbranch(b) for b in branches] |
10957
0d5f139b23c1
commands: Add 'hg log --branch' and deprecate 'hg log --only-branch'
Steve Losh <steve@stevelosh.com>
parents:
10934
diff
changeset
|
3869 |
|
11488
f786fc4b8764
log: follow filenames through renames (issue647)
Mads Kiilerich <mads@kiilerich.com>
parents:
11459
diff
changeset
|
3870 |
displayer = cmdutil.show_changeset(ui, repo, opts, True) |
9662
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3871 |
def prep(ctx, fns): |
9655
6d7d3f849062
walkchangerevs: internalize ctx caching
Matt Mackall <mpm@selenic.com>
parents:
9654
diff
changeset
|
3872 |
rev = ctx.rev() |
9662
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3873 |
parents = [p for p in repo.changelog.parentrevs(rev) |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3874 |
if p != nullrev] |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3875 |
if opts.get('no_merges') and len(parents) == 2: |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3876 |
return |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3877 |
if opts.get('only_merges') and len(parents) != 2: |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3878 |
return |
10957
0d5f139b23c1
commands: Add 'hg log --branch' and deprecate 'hg log --only-branch'
Steve Losh <steve@stevelosh.com>
parents:
10934
diff
changeset
|
3879 |
if opts.get('branch') and ctx.branch() not in opts['branch']: |
9662
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3880 |
return |
14645
e4cfdff6d3f4
log: do not display hidden changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
14639
diff
changeset
|
3881 |
if not opts.get('hidden') and ctx.hidden(): |
e4cfdff6d3f4
log: do not display hidden changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
14639
diff
changeset
|
3882 |
return |
9662
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3883 |
if df and not df(ctx.date()[0]): |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3884 |
return |
15725
988409e44a76
i18n: use "encoding.lower()" to normalize specified keywords for log searching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15717
diff
changeset
|
3885 |
|
988409e44a76
i18n: use "encoding.lower()" to normalize specified keywords for log searching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15717
diff
changeset
|
3886 |
lower = encoding.lower |
988409e44a76
i18n: use "encoding.lower()" to normalize specified keywords for log searching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15717
diff
changeset
|
3887 |
if opts.get('user'): |
988409e44a76
i18n: use "encoding.lower()" to normalize specified keywords for log searching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15717
diff
changeset
|
3888 |
luser = lower(ctx.user()) |
988409e44a76
i18n: use "encoding.lower()" to normalize specified keywords for log searching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15717
diff
changeset
|
3889 |
for k in [lower(x) for x in opts['user']]: |
988409e44a76
i18n: use "encoding.lower()" to normalize specified keywords for log searching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15717
diff
changeset
|
3890 |
if (k in luser): |
988409e44a76
i18n: use "encoding.lower()" to normalize specified keywords for log searching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15717
diff
changeset
|
3891 |
break |
988409e44a76
i18n: use "encoding.lower()" to normalize specified keywords for log searching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15717
diff
changeset
|
3892 |
else: |
988409e44a76
i18n: use "encoding.lower()" to normalize specified keywords for log searching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15717
diff
changeset
|
3893 |
return |
9662
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3894 |
if opts.get('keyword'): |
15725
988409e44a76
i18n: use "encoding.lower()" to normalize specified keywords for log searching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15717
diff
changeset
|
3895 |
luser = lower(ctx.user()) |
988409e44a76
i18n: use "encoding.lower()" to normalize specified keywords for log searching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15717
diff
changeset
|
3896 |
ldesc = lower(ctx.description()) |
988409e44a76
i18n: use "encoding.lower()" to normalize specified keywords for log searching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15717
diff
changeset
|
3897 |
lfiles = lower(" ".join(ctx.files())) |
988409e44a76
i18n: use "encoding.lower()" to normalize specified keywords for log searching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15717
diff
changeset
|
3898 |
for k in [lower(x) for x in opts['keyword']]: |
988409e44a76
i18n: use "encoding.lower()" to normalize specified keywords for log searching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15717
diff
changeset
|
3899 |
if (k in luser or k in ldesc or k in lfiles): |
9662
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3900 |
break |
9663
4164a17e7126
log: tidy up some filter tests
Matt Mackall <mpm@selenic.com>
parents:
9662
diff
changeset
|
3901 |
else: |
9662
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3902 |
return |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3903 |
|
10060
f780b1098efc
templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents:
10021
diff
changeset
|
3904 |
copies = None |
16175
280e834c9d15
log: restore cache used by --copies
Patrick Mezard <patrick@mezard.eu>
parents:
16163
diff
changeset
|
3905 |
if getrenamed is not None and rev: |
10060
f780b1098efc
templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents:
10021
diff
changeset
|
3906 |
copies = [] |
9662
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3907 |
for fn in ctx.files(): |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3908 |
rename = getrenamed(fn, rev) |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3909 |
if rename: |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3910 |
copies.append((fn, rename[0])) |
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3911 |
|
11488
f786fc4b8764
log: follow filenames through renames (issue647)
Mads Kiilerich <mads@kiilerich.com>
parents:
11459
diff
changeset
|
3912 |
revmatchfn = None |
f786fc4b8764
log: follow filenames through renames (issue647)
Mads Kiilerich <mads@kiilerich.com>
parents:
11459
diff
changeset
|
3913 |
if opts.get('patch') or opts.get('stat'): |
12382
28ddf67198b2
log: include unmodified-in-merge files in log diff/stat (issue2383)
Mads Kiilerich <mads@kiilerich.com>
parents:
12129
diff
changeset
|
3914 |
if opts.get('follow') or opts.get('follow_first'): |
28ddf67198b2
log: include unmodified-in-merge files in log diff/stat (issue2383)
Mads Kiilerich <mads@kiilerich.com>
parents:
12129
diff
changeset
|
3915 |
# note: this might be wrong when following through merges |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
3916 |
revmatchfn = scmutil.match(repo[None], fns, default='path') |
12382
28ddf67198b2
log: include unmodified-in-merge files in log diff/stat (issue2383)
Mads Kiilerich <mads@kiilerich.com>
parents:
12129
diff
changeset
|
3917 |
else: |
28ddf67198b2
log: include unmodified-in-merge files in log diff/stat (issue2383)
Mads Kiilerich <mads@kiilerich.com>
parents:
12129
diff
changeset
|
3918 |
revmatchfn = matchfn |
11488
f786fc4b8764
log: follow filenames through renames (issue647)
Mads Kiilerich <mads@kiilerich.com>
parents:
11459
diff
changeset
|
3919 |
|
f786fc4b8764
log: follow filenames through renames (issue647)
Mads Kiilerich <mads@kiilerich.com>
parents:
11459
diff
changeset
|
3920 |
displayer.show(ctx, copies=copies, matchfn=revmatchfn) |
9662
f3d60543924f
walkchangerevs: move 'add' to callback
Matt Mackall <mpm@selenic.com>
parents:
9656
diff
changeset
|
3921 |
|
9665
1de5ebfa5585
walkchangerevs: drop ui arg
Matt Mackall <mpm@selenic.com>
parents:
9663
diff
changeset
|
3922 |
for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep): |
9687
c6da1cb3b255
log --limit: break after a limited number of csets (broken by f3d60543924f)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9679
diff
changeset
|
3923 |
if count == limit: |
c6da1cb3b255
log --limit: break after a limited number of csets (broken by f3d60543924f)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9679
diff
changeset
|
3924 |
break |
c6da1cb3b255
log --limit: break after a limited number of csets (broken by f3d60543924f)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9679
diff
changeset
|
3925 |
if displayer.flush(ctx.rev()): |
c6da1cb3b255
log --limit: break after a limited number of csets (broken by f3d60543924f)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9679
diff
changeset
|
3926 |
count += 1 |
10152
56284451a22c
Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents:
10111
diff
changeset
|
3927 |
displayer.close() |
255 | 3928 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3929 |
@command('manifest', |
14399
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3930 |
[('r', 'rev', '', _('revision to display'), _('REV')), |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3931 |
('', 'all', False, _("list files from all revisions"))], |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3932 |
_('[-r REV]')) |
14399
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3933 |
def manifest(ui, repo, node=None, rev=None, **opts): |
3914
283ee8971570
doc string fix: hg cat and manifest default to current parent revision.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3900
diff
changeset
|
3934 |
"""output the current or given revision of the project manifest |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3935 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3936 |
Print a list of version controlled files for the given revision. |
8041
87c5a4af0b5a
Fix manifest default rev doc when no rev is checked out (issue1603)
Patrick Mezard <pmezard@gmail.com>
parents:
7850
diff
changeset
|
3937 |
If no revision is given, the first parent of the working directory |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3938 |
is used, or the null revision if no revision is checked out. |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3939 |
|
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3940 |
With -v, print file permissions, symlink and executable bits. |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3941 |
With --debug, print file revision hashes. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
3942 |
|
14399
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3943 |
If option --all is specified, the list of all files from all revisions |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3944 |
is printed. This includes deleted and renamed files. |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3945 |
|
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
3946 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
3947 |
""" |
14399
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3948 |
if opts.get('all'): |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3949 |
if rev or node: |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3950 |
raise util.Abort(_("can't specify a revision with --all")) |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3951 |
|
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3952 |
res = [] |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3953 |
prefix = "data/" |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3954 |
suffix = ".i" |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3955 |
plen = len(prefix) |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3956 |
slen = len(suffix) |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3957 |
lock = repo.lock() |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3958 |
try: |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3959 |
for fn, b, size in repo.store.datafiles(): |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3960 |
if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix: |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3961 |
res.append(fn[plen:-slen]) |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3962 |
finally: |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3963 |
lock.release() |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3964 |
for f in sorted(res): |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3965 |
ui.write("%s\n" % f) |
71938479eff9
add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents:
14382
diff
changeset
|
3966 |
return |
3736 | 3967 |
|
5155
13d23d66a6cd
manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents:
5148
diff
changeset
|
3968 |
if rev and node: |
13d23d66a6cd
manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents:
5148
diff
changeset
|
3969 |
raise util.Abort(_("please specify just one revision")) |
13d23d66a6cd
manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents:
5148
diff
changeset
|
3970 |
|
13d23d66a6cd
manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents:
5148
diff
changeset
|
3971 |
if not node: |
13d23d66a6cd
manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents:
5148
diff
changeset
|
3972 |
node = rev |
13d23d66a6cd
manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents:
5148
diff
changeset
|
3973 |
|
6749
51b0e799352f
manifest: remove execf/linkf methods
Matt Mackall <mpm@selenic.com>
parents:
6748
diff
changeset
|
3974 |
decor = {'l':'644 @ ', 'x':'755 * ', '':'644 '} |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
3975 |
ctx = scmutil.revsingle(repo, node) |
6749
51b0e799352f
manifest: remove execf/linkf methods
Matt Mackall <mpm@selenic.com>
parents:
6748
diff
changeset
|
3976 |
for f in ctx: |
3736 | 3977 |
if ui.debugflag: |
6749
51b0e799352f
manifest: remove execf/linkf methods
Matt Mackall <mpm@selenic.com>
parents:
6748
diff
changeset
|
3978 |
ui.write("%40s " % hex(ctx.manifest()[f])) |
3736 | 3979 |
if ui.verbose: |
6749
51b0e799352f
manifest: remove execf/linkf methods
Matt Mackall <mpm@selenic.com>
parents:
6748
diff
changeset
|
3980 |
ui.write(decor[ctx.flags(f)]) |
3736 | 3981 |
ui.write("%s\n" % f) |
255 | 3982 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3983 |
@command('^merge', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3984 |
[('f', 'force', None, _('force a merge with outstanding changes')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3985 |
('r', 'rev', '', _('revision to merge'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3986 |
('P', 'preview', None, |
14852
cac04f2f475b
commands: use mergetoolopts when a command supports --tool
Martin Geisler <mg@aragost.com>
parents:
14840
diff
changeset
|
3987 |
_('review revisions to merge (no merge is performed)')) |
cac04f2f475b
commands: use mergetoolopts when a command supports --tool
Martin Geisler <mg@aragost.com>
parents:
14840
diff
changeset
|
3988 |
] + mergetoolopts, |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
3989 |
_('[-P] [-f] [[-r] REV]')) |
8387
50b6af595e0c
merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8366
diff
changeset
|
3990 |
def merge(ui, repo, node=None, **opts): |
4014
509342f95564
various doc fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4013
diff
changeset
|
3991 |
"""merge working directory with another revision |
2019
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
3992 |
|
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3993 |
The current working directory is updated with all changes made in |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3994 |
the requested revision since the last common predecessor revision. |
7977
1cd3775e097c
commands: better merge help text
Martin Geisler <mg@daimi.au.dk>
parents:
7976
diff
changeset
|
3995 |
|
1cd3775e097c
commands: better merge help text
Martin Geisler <mg@daimi.au.dk>
parents:
7976
diff
changeset
|
3996 |
Files that changed between either parent are marked as changed for |
1cd3775e097c
commands: better merge help text
Martin Geisler <mg@daimi.au.dk>
parents:
7976
diff
changeset
|
3997 |
the next commit and a commit must be performed before any further |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3998 |
updates to the repository are allowed. The next commit will have |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
3999 |
two parents. |
2915
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
4000 |
|
12750
05bd2658bbb3
merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents:
12727
diff
changeset
|
4001 |
``--tool`` can be used to specify the merge tool used for file |
05bd2658bbb3
merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents:
12727
diff
changeset
|
4002 |
merges. It overrides the HGMERGE environment variable and your |
13891
1bd9f3a6a0d0
merge: added info that hg help merge-tools shows the options for --tool
Arne Babenhauserheide <bab@draketo.de>
parents:
13878
diff
changeset
|
4003 |
configuration files. See :hg:`help merge-tools` for options. |
12750
05bd2658bbb3
merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents:
12727
diff
changeset
|
4004 |
|
2915
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2911
diff
changeset
|
4005 |
If no revision is specified, the working directory's parent is a |
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
4006 |
head revision, and the current branch contains exactly one other |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
4007 |
head, the other head is merged with by default. Otherwise, an |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
4008 |
explicit revision with which to merge with must be provided. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4009 |
|
12750
05bd2658bbb3
merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents:
12727
diff
changeset
|
4010 |
:hg:`resolve` must be used to resolve unresolved files. |
05bd2658bbb3
merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents:
12727
diff
changeset
|
4011 |
|
11452
eac141407b85
merge: document how to 'undo' a merge
Matt Mackall <mpm@selenic.com>
parents:
11442
diff
changeset
|
4012 |
To undo an uncommitted merge, use :hg:`update --clean .` which |
eac141407b85
merge: document how to 'undo' a merge
Matt Mackall <mpm@selenic.com>
parents:
11442
diff
changeset
|
4013 |
will check out a clean copy of the original merge parent, losing |
eac141407b85
merge: document how to 'undo' a merge
Matt Mackall <mpm@selenic.com>
parents:
11442
diff
changeset
|
4014 |
all changes. |
eac141407b85
merge: document how to 'undo' a merge
Matt Mackall <mpm@selenic.com>
parents:
11442
diff
changeset
|
4015 |
|
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4016 |
Returns 0 on success, 1 if there are unresolved files. |
2019
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
4017 |
""" |
2806
0bf22c109cc3
Factor doupdate into _lookup + hg.update
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
4018 |
|
8387
50b6af595e0c
merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8366
diff
changeset
|
4019 |
if opts.get('rev') and node: |
4450
8fa54b9c6c5a
accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents:
4445
diff
changeset
|
4020 |
raise util.Abort(_("please specify just one revision")) |
8fa54b9c6c5a
accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents:
4445
diff
changeset
|
4021 |
if not node: |
8387
50b6af595e0c
merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8366
diff
changeset
|
4022 |
node = opts.get('rev') |
4450
8fa54b9c6c5a
accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents:
4445
diff
changeset
|
4023 |
|
3876
1e0b94cfba0e
Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents:
3862
diff
changeset
|
4024 |
if not node: |
13047
6c375e07d673
branch: operate on branch names in local string space where possible
Matt Mackall <mpm@selenic.com>
parents:
13022
diff
changeset
|
4025 |
branch = repo[None].branch() |
6844
a38dff85d31f
merge: use correct branch name for counting heads
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6843
diff
changeset
|
4026 |
bheads = repo.branchheads(branch) |
6723
1fe6f365df2e
merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6686
diff
changeset
|
4027 |
if len(bheads) > 2: |
14198
8f11fd321014
commands: use util.Abort's hint some more
Martin Geisler <mg@aragost.com>
parents:
14197
diff
changeset
|
4028 |
raise util.Abort(_("branch '%s' has %d heads - " |
8f11fd321014
commands: use util.Abort's hint some more
Martin Geisler <mg@aragost.com>
parents:
14197
diff
changeset
|
4029 |
"please merge with an explicit rev") |
8f11fd321014
commands: use util.Abort's hint some more
Martin Geisler <mg@aragost.com>
parents:
14197
diff
changeset
|
4030 |
% (branch, len(bheads)), |
8f11fd321014
commands: use util.Abort's hint some more
Martin Geisler <mg@aragost.com>
parents:
14197
diff
changeset
|
4031 |
hint=_("run 'hg heads .' to see heads")) |
6723
1fe6f365df2e
merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6686
diff
changeset
|
4032 |
|
13878
a8d13ee0ce68
misc: replace .parents()[0] with p1()
Matt Mackall <mpm@selenic.com>
parents:
13855
diff
changeset
|
4033 |
parent = repo.dirstate.p1() |
6723
1fe6f365df2e
merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6686
diff
changeset
|
4034 |
if len(bheads) == 1: |
1fe6f365df2e
merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6686
diff
changeset
|
4035 |
if len(repo.heads()) > 1: |
14198
8f11fd321014
commands: use util.Abort's hint some more
Martin Geisler <mg@aragost.com>
parents:
14197
diff
changeset
|
4036 |
raise util.Abort(_("branch '%s' has one head - " |
8f11fd321014
commands: use util.Abort's hint some more
Martin Geisler <mg@aragost.com>
parents:
14197
diff
changeset
|
4037 |
"please merge with an explicit rev") |
8f11fd321014
commands: use util.Abort's hint some more
Martin Geisler <mg@aragost.com>
parents:
14197
diff
changeset
|
4038 |
% branch, |
8f11fd321014
commands: use util.Abort's hint some more
Martin Geisler <mg@aragost.com>
parents:
14197
diff
changeset
|
4039 |
hint=_("run 'hg heads' to see all heads")) |
15619
6c8573dd1b6b
merge: make 'nothing to merge' aborts consistent
Kevin Bullock <kbullock@ringworld.org>
parents:
15618
diff
changeset
|
4040 |
msg, hint = _('nothing to merge'), None |
15618
0aca2695a110
merge: remove excess creation of changectx
Kevin Bullock <kbullock@ringworld.org>
parents:
15614
diff
changeset
|
4041 |
if parent != repo.lookup(branch): |
15619
6c8573dd1b6b
merge: make 'nothing to merge' aborts consistent
Kevin Bullock <kbullock@ringworld.org>
parents:
15618
diff
changeset
|
4042 |
hint = _("use 'hg update' instead") |
6c8573dd1b6b
merge: make 'nothing to merge' aborts consistent
Kevin Bullock <kbullock@ringworld.org>
parents:
15618
diff
changeset
|
4043 |
raise util.Abort(msg, hint=hint) |
5242
9cd6578750b9
improve error message for 'hg merge' when repo already at branchtip
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
5205
diff
changeset
|
4044 |
|
6723
1fe6f365df2e
merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6686
diff
changeset
|
4045 |
if parent not in bheads: |
14198
8f11fd321014
commands: use util.Abort's hint some more
Martin Geisler <mg@aragost.com>
parents:
14197
diff
changeset
|
4046 |
raise util.Abort(_('working directory not at a head revision'), |
8f11fd321014
commands: use util.Abort's hint some more
Martin Geisler <mg@aragost.com>
parents:
14197
diff
changeset
|
4047 |
hint=_("use 'hg update' or merge with an " |
8f11fd321014
commands: use util.Abort's hint some more
Martin Geisler <mg@aragost.com>
parents:
14197
diff
changeset
|
4048 |
"explicit revision")) |
6723
1fe6f365df2e
merge: only in-branch merges can be implicit
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6686
diff
changeset
|
4049 |
node = parent == bheads[0] and bheads[-1] or bheads[0] |
12925
6eab8f0df2ca
commands: add revset support to most commands
Matt Mackall <mpm@selenic.com>
parents:
12918
diff
changeset
|
4050 |
else: |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
4051 |
node = scmutil.revsingle(repo, node).node() |
8387
50b6af595e0c
merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8366
diff
changeset
|
4052 |
|
8834
6d36fc70754e
merge: rename -S/--show option to -P/--preview
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8815
diff
changeset
|
4053 |
if opts.get('preview'): |
10505
b3311e26f94f
merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents:
10479
diff
changeset
|
4054 |
# find nodes that are ancestors of p2 but not of p1 |
b3311e26f94f
merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents:
10479
diff
changeset
|
4055 |
p1 = repo.lookup('.') |
b3311e26f94f
merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents:
10479
diff
changeset
|
4056 |
p2 = repo.lookup(node) |
b3311e26f94f
merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents:
10479
diff
changeset
|
4057 |
nodes = repo.changelog.findmissing(common=[p1], heads=[p2]) |
b3311e26f94f
merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents:
10479
diff
changeset
|
4058 |
|
8387
50b6af595e0c
merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8366
diff
changeset
|
4059 |
displayer = cmdutil.show_changeset(ui, repo, opts) |
10505
b3311e26f94f
merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents:
10479
diff
changeset
|
4060 |
for node in nodes: |
b3311e26f94f
merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents:
10479
diff
changeset
|
4061 |
displayer.show(repo[node]) |
10152
56284451a22c
Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents:
10111
diff
changeset
|
4062 |
displayer.close() |
8387
50b6af595e0c
merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8366
diff
changeset
|
4063 |
return 0 |
50b6af595e0c
merge: add -S/--show option to review revisions without merging
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8366
diff
changeset
|
4064 |
|
12788
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12765
diff
changeset
|
4065 |
try: |
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12765
diff
changeset
|
4066 |
# ui.forcemerge is an internal variable, do not document |
14840
11b5a5d2ca8b
commands, merge: call setconfig on the right ui
Idan Kamara <idankk86@gmail.com>
parents:
14755
diff
changeset
|
4067 |
repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', '')) |
12788
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12765
diff
changeset
|
4068 |
return hg.merge(repo, node, force=opts.get('force')) |
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12765
diff
changeset
|
4069 |
finally: |
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12765
diff
changeset
|
4070 |
ui.setconfig('ui', 'forcemerge', '') |
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
4071 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4072 |
@command('outgoing|out', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4073 |
[('f', 'force', None, _('run even when the destination is unrelated')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4074 |
('r', 'rev', [], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4075 |
_('a changeset intended to be included in the destination'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4076 |
('n', 'newest-first', None, _('show newest record first')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4077 |
('B', 'bookmarks', False, _('compare bookmarks')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4078 |
('b', 'branch', [], _('a specific branch you would like to push'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4079 |
_('BRANCH')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4080 |
] + logopts + remoteopts + subrepoopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4081 |
_('[-M] [-p] [-n] [-f] [-r REV]... [DEST]')) |
2494
73ac95671788
push, outgoing, bundle: fall back to "default" if "default-push" not defined
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2493
diff
changeset
|
4082 |
def outgoing(ui, repo, dest=None, **opts): |
10376 | 4083 |
"""show changesets not found in the destination |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4084 |
|
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
4085 |
Show changesets not found in the specified destination repository |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
4086 |
or the default push location. These are the changesets that would |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
4087 |
be pushed 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
|
4088 |
|
10376 | 4089 |
See pull for details of valid destination formats. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4090 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4091 |
Returns 0 if there are outgoing changes, 1 otherwise. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4092 |
""" |
13366
c756e9166417
bookmarks: merge incoming/outgoing into core
Matt Mackall <mpm@selenic.com>
parents:
13344
diff
changeset
|
4093 |
|
c756e9166417
bookmarks: merge incoming/outgoing into core
Matt Mackall <mpm@selenic.com>
parents:
13344
diff
changeset
|
4094 |
if opts.get('bookmarks'): |
c756e9166417
bookmarks: merge incoming/outgoing into core
Matt Mackall <mpm@selenic.com>
parents:
13344
diff
changeset
|
4095 |
dest = ui.expandpath(dest or 'default-push', dest or 'default') |
c756e9166417
bookmarks: merge incoming/outgoing into core
Matt Mackall <mpm@selenic.com>
parents:
13344
diff
changeset
|
4096 |
dest, branches = hg.parseurl(dest, opts.get('branch')) |
14556
517e1d88bf7e
hg: change various repository() users to use peer() where appropriate
Matt Mackall <mpm@selenic.com>
parents:
14553
diff
changeset
|
4097 |
other = hg.peer(repo, opts, dest) |
13453
c1b808020819
bookmarks: issue a warning if remote doesn't support comparing bookmarks
David Soria Parra <dsp@php.net>
parents:
13448
diff
changeset
|
4098 |
if 'bookmarks' not in other.listkeys('namespaces'): |
c1b808020819
bookmarks: issue a warning if remote doesn't support comparing bookmarks
David Soria Parra <dsp@php.net>
parents:
13448
diff
changeset
|
4099 |
ui.warn(_("remote doesn't support bookmarks\n")) |
c1b808020819
bookmarks: issue a warning if remote doesn't support comparing bookmarks
David Soria Parra <dsp@php.net>
parents:
13448
diff
changeset
|
4100 |
return 0 |
14076
924c82157d46
url: move URL parsing functions into util to improve startup time
Brodie Rao <brodie@bitheap.org>
parents:
14073
diff
changeset
|
4101 |
ui.status(_('comparing with %s\n') % util.hidepassword(dest)) |
13366
c756e9166417
bookmarks: merge incoming/outgoing into core
Matt Mackall <mpm@selenic.com>
parents:
13344
diff
changeset
|
4102 |
return bookmarks.diff(ui, other, repo) |
c756e9166417
bookmarks: merge incoming/outgoing into core
Matt Mackall <mpm@selenic.com>
parents:
13344
diff
changeset
|
4103 |
|
14360
ab687820c4cc
subrepo: respect non-default path for incoming/outgoing
Martin Geisler <mg@aragost.com>
parents:
14014
diff
changeset
|
4104 |
repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default') |
ab687820c4cc
subrepo: respect non-default path for incoming/outgoing
Martin Geisler <mg@aragost.com>
parents:
14014
diff
changeset
|
4105 |
try: |
14362
8c740a850ad7
commands: replace 'x = f(); return x' with 'return f()'
Martin Geisler <mg@lazybytes.net>
parents:
14361
diff
changeset
|
4106 |
return hg.outgoing(ui, repo, dest, opts) |
14360
ab687820c4cc
subrepo: respect non-default path for incoming/outgoing
Martin Geisler <mg@aragost.com>
parents:
14014
diff
changeset
|
4107 |
finally: |
ab687820c4cc
subrepo: respect non-default path for incoming/outgoing
Martin Geisler <mg@aragost.com>
parents:
14014
diff
changeset
|
4108 |
del repo._subtoppath |
920 | 4109 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4110 |
@command('parents', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4111 |
[('r', 'rev', '', _('show parents of the specified revision'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4112 |
] + templateopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4113 |
_('[-r REV] [FILE]')) |
3658
d12c8668b102
remove legacy hg parents REV syntax
Matt Mackall <mpm@selenic.com>
parents:
3657
diff
changeset
|
4114 |
def parents(ui, repo, file_=None, **opts): |
8026
683d8ebcf434
expand "dir" to "directory" in help texts
Martin Geisler <mg@lazybytes.net>
parents:
8021
diff
changeset
|
4115 |
"""show the parents of the working directory or revision |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4116 |
|
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
4117 |
Print the working directory's parent revisions. If a revision is |
8033
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
4118 |
given via -r/--rev, the parent of that revision will be printed. |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
4119 |
If a file argument is given, the revision in which the file was |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
4120 |
last changed (before the working directory revision or the |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
4121 |
argument to --rev if given) is printed. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4122 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4123 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4124 |
""" |
12925
6eab8f0df2ca
commands: add revset support to most commands
Matt Mackall <mpm@selenic.com>
parents:
12918
diff
changeset
|
4125 |
|
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
4126 |
ctx = scmutil.revsingle(repo, opts.get('rev'), None) |
5298
cba2a689117d
parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents:
5230
diff
changeset
|
4127 |
|
4586
1fcc076fcb17
Make parents with a file but not a revision use working directory revision.
Brendan Cully <brendan@kublai.com>
parents:
4451
diff
changeset
|
4128 |
if file_: |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
4129 |
m = scmutil.match(ctx, (file_,), opts) |
6582
5acbdd3941c4
walk: remove remaining users of cmdutils.matchpats
Matt Mackall <mpm@selenic.com>
parents:
6579
diff
changeset
|
4130 |
if m.anypats() or len(m.files()) != 1: |
8761
0289f384e1e5
Generally replace "file name" with "filename" in help and comments.
timeless <timeless@gmail.com>
parents:
8760
diff
changeset
|
4131 |
raise util.Abort(_('can only specify an explicit filename')) |
6582
5acbdd3941c4
walk: remove remaining users of cmdutils.matchpats
Matt Mackall <mpm@selenic.com>
parents:
6579
diff
changeset
|
4132 |
file_ = m.files()[0] |
5298
cba2a689117d
parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents:
5230
diff
changeset
|
4133 |
filenodes = [] |
cba2a689117d
parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents:
5230
diff
changeset
|
4134 |
for cp in ctx.parents(): |
cba2a689117d
parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents:
5230
diff
changeset
|
4135 |
if not cp: |
cba2a689117d
parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents:
5230
diff
changeset
|
4136 |
continue |
cba2a689117d
parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents:
5230
diff
changeset
|
4137 |
try: |
cba2a689117d
parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents:
5230
diff
changeset
|
4138 |
filenodes.append(cp.filenode(file_)) |
7633 | 4139 |
except error.LookupError: |
5298
cba2a689117d
parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents:
5230
diff
changeset
|
4140 |
pass |
cba2a689117d
parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents:
5230
diff
changeset
|
4141 |
if not filenodes: |
cba2a689117d
parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents:
5230
diff
changeset
|
4142 |
raise util.Abort(_("'%s' not found in manifest!") % file_) |
cba2a689117d
parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents:
5230
diff
changeset
|
4143 |
fl = repo.file(file_) |
7361
9fe97eea5510
linkrev: take a revision number rather than a hash
Matt Mackall <mpm@selenic.com>
parents:
7308
diff
changeset
|
4144 |
p = [repo.lookup(fl.linkrev(fl.rev(fn))) for fn in filenodes] |
255 | 4145 |
else: |
5298
cba2a689117d
parents: make it match the doc when called on a file
Patrick Mezard <pmezard@gmail.com>
parents:
5230
diff
changeset
|
4146 |
p = [cp.node() for cp in ctx.parents()] |
255 | 4147 |
|
3643
b4ad640a3bcf
templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents:
3631
diff
changeset
|
4148 |
displayer = cmdutil.show_changeset(ui, repo, opts) |
255 | 4149 |
for n in p: |
1092 | 4150 |
if n != nullid: |
7743
ec9b726a9428
commands: fix paths command docstring indention
Martin Geisler <mg@daimi.au.dk>
parents:
7739
diff
changeset
|
4151 |
displayer.show(repo[n]) |
10152
56284451a22c
Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents:
10111
diff
changeset
|
4152 |
displayer.close() |
255 | 4153 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4154 |
@command('paths', [], _('[NAME]')) |
1858
9fab6e903bae
Make hg paths and hg debugconfig work with -R/--repository option.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1857
diff
changeset
|
4155 |
def paths(ui, repo, search=None): |
7691
bcdc2fe3fd07
Clarified 'hg paths' command help
Bill Barry <after.fallout@gmail.com>
parents:
7684
diff
changeset
|
4156 |
"""show aliases for remote repositories |
bcdc2fe3fd07
Clarified 'hg paths' command help
Bill Barry <after.fallout@gmail.com>
parents:
7684
diff
changeset
|
4157 |
|
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
4158 |
Show definition of symbolic path name NAME. If no name is given, |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
4159 |
show definition of all available names. |
7743
ec9b726a9428
commands: fix paths command docstring indention
Martin Geisler <mg@daimi.au.dk>
parents:
7739
diff
changeset
|
4160 |
|
14331
3b9a896af09c
paths: Add support for -q/--quiet
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14326
diff
changeset
|
4161 |
Option -q/--quiet suppresses all output when searching for NAME |
3b9a896af09c
paths: Add support for -q/--quiet
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14326
diff
changeset
|
4162 |
and shows only the path names when listing all definitions. |
3b9a896af09c
paths: Add support for -q/--quiet
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14326
diff
changeset
|
4163 |
|
12083
ebfc46929f3e
help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents:
12067
diff
changeset
|
4164 |
Path names are defined in the [paths] section of your |
ebfc46929f3e
help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents:
12067
diff
changeset
|
4165 |
configuration file and in ``/etc/mercurial/hgrc``. If run inside a |
11009
4d3288197717
commands: better markup in "hg help paths"
Martin Geisler <mg@lazybytes.net>
parents:
11008
diff
changeset
|
4166 |
repository, ``.hg/hgrc`` is used, too. |
7693
e040f9d6b2f3
consolidated url help into urls help topic and added information about path aliases
Bill Barry <after.fallout@gmail.com>
parents:
7691
diff
changeset
|
4167 |
|
11007
a0102da324ab
commands: revised documentation of 'default' and 'default-push'
Faheem Mitha <faheem@email.unc.edu>
parents:
10948
diff
changeset
|
4168 |
The path names ``default`` and ``default-push`` have a special |
a0102da324ab
commands: revised documentation of 'default' and 'default-push'
Faheem Mitha <faheem@email.unc.edu>
parents:
10948
diff
changeset
|
4169 |
meaning. When performing a push or pull operation, they are used |
a0102da324ab
commands: revised documentation of 'default' and 'default-push'
Faheem Mitha <faheem@email.unc.edu>
parents:
10948
diff
changeset
|
4170 |
as fallbacks if no location is specified on the command-line. |
a0102da324ab
commands: revised documentation of 'default' and 'default-push'
Faheem Mitha <faheem@email.unc.edu>
parents:
10948
diff
changeset
|
4171 |
When ``default-push`` is set, it will be used for push and |
a0102da324ab
commands: revised documentation of 'default' and 'default-push'
Faheem Mitha <faheem@email.unc.edu>
parents:
10948
diff
changeset
|
4172 |
``default`` will be used for pull; otherwise ``default`` is used |
a0102da324ab
commands: revised documentation of 'default' and 'default-push'
Faheem Mitha <faheem@email.unc.edu>
parents:
10948
diff
changeset
|
4173 |
as the fallback for both. When cloning a repository, the clone |
a0102da324ab
commands: revised documentation of 'default' and 'default-push'
Faheem Mitha <faheem@email.unc.edu>
parents:
10948
diff
changeset
|
4174 |
source is written as ``default`` in ``.hg/hgrc``. Note that |
11009
4d3288197717
commands: better markup in "hg help paths"
Martin Geisler <mg@lazybytes.net>
parents:
11008
diff
changeset
|
4175 |
``default`` and ``default-push`` apply to all inbound (e.g. |
4d3288197717
commands: better markup in "hg help paths"
Martin Geisler <mg@lazybytes.net>
parents:
11008
diff
changeset
|
4176 |
:hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and |
4d3288197717
commands: better markup in "hg help paths"
Martin Geisler <mg@lazybytes.net>
parents:
11008
diff
changeset
|
4177 |
:hg:`bundle`) operations. |
10933
e3396b218e10
Document 'default' and 'default-push' in paths docstring
Faheem Mitha <faheem@email.unc.edu>
parents:
10645
diff
changeset
|
4178 |
|
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
4179 |
See :hg:`help urls` for more information. |
11507
35e2d453cf0d
commands: document return values of add and paths commands
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11488
diff
changeset
|
4180 |
|
35e2d453cf0d
commands: document return values of add and paths commands
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11488
diff
changeset
|
4181 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4182 |
""" |
779 | 4183 |
if search: |
4184 |
for name, path in ui.configitems("paths"): |
|
4185 |
if name == search: |
|
14331
3b9a896af09c
paths: Add support for -q/--quiet
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14326
diff
changeset
|
4186 |
ui.status("%s\n" % util.hidepassword(path)) |
779 | 4187 |
return |
14331
3b9a896af09c
paths: Add support for -q/--quiet
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14326
diff
changeset
|
4188 |
if not ui.quiet: |
3b9a896af09c
paths: Add support for -q/--quiet
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14326
diff
changeset
|
4189 |
ui.warn(_("not found!\n")) |
779 | 4190 |
return 1 |
4191 |
else: |
|
4192 |
for name, path in ui.configitems("paths"): |
|
14331
3b9a896af09c
paths: Add support for -q/--quiet
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14326
diff
changeset
|
4193 |
if ui.quiet: |
3b9a896af09c
paths: Add support for -q/--quiet
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14326
diff
changeset
|
4194 |
ui.write("%s\n" % name) |
3b9a896af09c
paths: Add support for -q/--quiet
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14326
diff
changeset
|
4195 |
else: |
3b9a896af09c
paths: Add support for -q/--quiet
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14326
diff
changeset
|
4196 |
ui.write("%s = %s\n" % (name, util.hidepassword(path))) |
779 | 4197 |
|
15830
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4198 |
@command('^phase', |
15849
513ca86b88ef
phase: lowercase option help, rephrase slightly
Martin Geisler <mg@aragost.com>
parents:
15837
diff
changeset
|
4199 |
[('p', 'public', False, _('set changeset phase to public')), |
513ca86b88ef
phase: lowercase option help, rephrase slightly
Martin Geisler <mg@aragost.com>
parents:
15837
diff
changeset
|
4200 |
('d', 'draft', False, _('set changeset phase to draft')), |
513ca86b88ef
phase: lowercase option help, rephrase slightly
Martin Geisler <mg@aragost.com>
parents:
15837
diff
changeset
|
4201 |
('s', 'secret', False, _('set changeset phase to secret')), |
15830
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4202 |
('f', 'force', False, _('allow to move boundary backward')), |
15855
09757185ce97
phase: add metavar to -r help text
Martin Geisler <mg@aragost.com>
parents:
15854
diff
changeset
|
4203 |
('r', 'rev', [], _('target revision'), _('REV')), |
15830
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4204 |
], |
15854
2260e6ed09c3
phase: the REV argument can be repeated
Martin Geisler <mg@aragost.com>
parents:
15853
diff
changeset
|
4205 |
_('[-p|-d|-s] [-f] [-r] REV...')) |
15830
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4206 |
def phase(ui, repo, *revs, **opts): |
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4207 |
"""set or show the current phase name |
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4208 |
|
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4209 |
With no argument, show the phase name of specified revisions. |
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4210 |
|
15851
05ccad068313
phase: use standard syntax for command line flags
Martin Geisler <mg@aragost.com>
parents:
15850
diff
changeset
|
4211 |
With one of -p/--public, -d/--draft or -s/--secret, change the |
15850
920433707a01
phase: fix RST markup (use ``...`` for literal text)
Martin Geisler <mg@aragost.com>
parents:
15849
diff
changeset
|
4212 |
phase value of the specified revisions. |
15830
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4213 |
|
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4214 |
Unless -f/--force is specified, :hg:`phase` won't move changeset from a |
15850
920433707a01
phase: fix RST markup (use ``...`` for literal text)
Martin Geisler <mg@aragost.com>
parents:
15849
diff
changeset
|
4215 |
lower phase to an higher phase. Phases are ordered as follows:: |
15832 | 4216 |
|
4217 |
public < draft < secret |
|
15906
aad565319fa3
phase: report phase movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15877
diff
changeset
|
4218 |
|
16097
8dc573a9c5e5
phase: when phase cannot be reduced, hint at --force and return 1 (BC)
Patrick Mezard <patrick@mezard.eu>
parents:
16095
diff
changeset
|
4219 |
Return 0 on success, 1 if no phases were changed or some could not |
8dc573a9c5e5
phase: when phase cannot be reduced, hint at --force and return 1 (BC)
Patrick Mezard <patrick@mezard.eu>
parents:
16095
diff
changeset
|
4220 |
be changed. |
15830
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4221 |
""" |
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4222 |
# search for a unique phase argument |
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4223 |
targetphase = None |
15853
fbb68b382040
commands: no need to rename merge and phases on import
Martin Geisler <mg@aragost.com>
parents:
15852
diff
changeset
|
4224 |
for idx, name in enumerate(phases.phasenames): |
15830
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4225 |
if opts[name]: |
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4226 |
if targetphase is not None: |
15833
3cf2bb3a9fcc
phase: mark messages for i18n
Matt Mackall <mpm@selenic.com>
parents:
15832
diff
changeset
|
4227 |
raise util.Abort(_('only one phase can be specified')) |
15830
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4228 |
targetphase = idx |
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4229 |
|
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4230 |
# look for specified revision |
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4231 |
revs = list(revs) |
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4232 |
revs.extend(opts['rev']) |
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4233 |
if not revs: |
15958
0d2ac0299020
commands: drop exclamation mark in abort message
Idan Kamara <idankk86@gmail.com>
parents:
15957
diff
changeset
|
4234 |
raise util.Abort(_('no revisions specified')) |
15831
0ecaf1e72609
phase: drop reference to working directory phase
Matt Mackall <mpm@selenic.com>
parents:
15830
diff
changeset
|
4235 |
|
16024
7c967c4a6144
phase: accept old style revision specification
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16023
diff
changeset
|
4236 |
revs = scmutil.revrange(repo, revs) |
7c967c4a6144
phase: accept old style revision specification
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16023
diff
changeset
|
4237 |
|
15830
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4238 |
lock = None |
15906
aad565319fa3
phase: report phase movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15877
diff
changeset
|
4239 |
ret = 0 |
15830
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4240 |
if targetphase is None: |
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4241 |
# display |
16024
7c967c4a6144
phase: accept old style revision specification
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16023
diff
changeset
|
4242 |
for r in revs: |
7c967c4a6144
phase: accept old style revision specification
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16023
diff
changeset
|
4243 |
ctx = repo[r] |
15830
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4244 |
ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr())) |
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4245 |
else: |
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4246 |
lock = repo.lock() |
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4247 |
try: |
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4248 |
# set phase |
16024
7c967c4a6144
phase: accept old style revision specification
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16023
diff
changeset
|
4249 |
nodes = [ctx.node() for ctx in repo.set('%ld', revs)] |
15830
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4250 |
if not nodes: |
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4251 |
raise util.Abort(_('empty revision set')) |
15906
aad565319fa3
phase: report phase movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15877
diff
changeset
|
4252 |
olddata = repo._phaserev[:] |
15853
fbb68b382040
commands: no need to rename merge and phases on import
Martin Geisler <mg@aragost.com>
parents:
15852
diff
changeset
|
4253 |
phases.advanceboundary(repo, targetphase, nodes) |
15830
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4254 |
if opts['force']: |
15853
fbb68b382040
commands: no need to rename merge and phases on import
Martin Geisler <mg@aragost.com>
parents:
15852
diff
changeset
|
4255 |
phases.retractboundary(repo, targetphase, nodes) |
15830
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4256 |
finally: |
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4257 |
lock.release() |
15906
aad565319fa3
phase: report phase movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15877
diff
changeset
|
4258 |
if olddata is not None: |
aad565319fa3
phase: report phase movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15877
diff
changeset
|
4259 |
changes = 0 |
aad565319fa3
phase: report phase movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15877
diff
changeset
|
4260 |
newdata = repo._phaserev |
aad565319fa3
phase: report phase movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15877
diff
changeset
|
4261 |
changes = sum(o != newdata[i] for i, o in enumerate(olddata)) |
16097
8dc573a9c5e5
phase: when phase cannot be reduced, hint at --force and return 1 (BC)
Patrick Mezard <patrick@mezard.eu>
parents:
16095
diff
changeset
|
4262 |
rejected = [n for n in nodes |
8dc573a9c5e5
phase: when phase cannot be reduced, hint at --force and return 1 (BC)
Patrick Mezard <patrick@mezard.eu>
parents:
16095
diff
changeset
|
4263 |
if newdata[repo[n].rev()] < targetphase] |
8dc573a9c5e5
phase: when phase cannot be reduced, hint at --force and return 1 (BC)
Patrick Mezard <patrick@mezard.eu>
parents:
16095
diff
changeset
|
4264 |
if rejected: |
8dc573a9c5e5
phase: when phase cannot be reduced, hint at --force and return 1 (BC)
Patrick Mezard <patrick@mezard.eu>
parents:
16095
diff
changeset
|
4265 |
ui.warn(_('cannot move %i changesets to a more permissive ' |
8dc573a9c5e5
phase: when phase cannot be reduced, hint at --force and return 1 (BC)
Patrick Mezard <patrick@mezard.eu>
parents:
16095
diff
changeset
|
4266 |
'phase, use --force\n') % len(rejected)) |
8dc573a9c5e5
phase: when phase cannot be reduced, hint at --force and return 1 (BC)
Patrick Mezard <patrick@mezard.eu>
parents:
16095
diff
changeset
|
4267 |
ret = 1 |
15906
aad565319fa3
phase: report phase movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15877
diff
changeset
|
4268 |
if changes: |
16097
8dc573a9c5e5
phase: when phase cannot be reduced, hint at --force and return 1 (BC)
Patrick Mezard <patrick@mezard.eu>
parents:
16095
diff
changeset
|
4269 |
msg = _('phase changed for %i changesets\n') % changes |
8dc573a9c5e5
phase: when phase cannot be reduced, hint at --force and return 1 (BC)
Patrick Mezard <patrick@mezard.eu>
parents:
16095
diff
changeset
|
4270 |
if ret: |
8dc573a9c5e5
phase: when phase cannot be reduced, hint at --force and return 1 (BC)
Patrick Mezard <patrick@mezard.eu>
parents:
16095
diff
changeset
|
4271 |
ui.status(msg) |
8dc573a9c5e5
phase: when phase cannot be reduced, hint at --force and return 1 (BC)
Patrick Mezard <patrick@mezard.eu>
parents:
16095
diff
changeset
|
4272 |
else: |
8dc573a9c5e5
phase: when phase cannot be reduced, hint at --force and return 1 (BC)
Patrick Mezard <patrick@mezard.eu>
parents:
16095
diff
changeset
|
4273 |
ui.note(msg) |
15906
aad565319fa3
phase: report phase movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15877
diff
changeset
|
4274 |
else: |
aad565319fa3
phase: report phase movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15877
diff
changeset
|
4275 |
ui.warn(_('no phases changed\n')) |
aad565319fa3
phase: report phase movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15877
diff
changeset
|
4276 |
ret = 1 |
15968
bf87b6b95ce5
phase: alway return a value
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15959
diff
changeset
|
4277 |
return ret |
15830
8ed112ed774a
phases: add a phases command to display and manipulate phases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15829
diff
changeset
|
4278 |
|
5224
20817af258d8
pull -u: if "url#rev" was given, update to rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5222
diff
changeset
|
4279 |
def postincoming(ui, repo, modheads, optupdate, checkout): |
2019
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
4280 |
if modheads == 0: |
16107
a3dcc59054ca
pull: backout change to return code
Matt Mackall <mpm@selenic.com>
parents:
16039
diff
changeset
|
4281 |
return |
2019
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
4282 |
if optupdate: |
16019
eb85d5f89fef
bookmarks: move current bookmark on update -u and bare pull -u (issue3222)
Matt Mackall <mpm@selenic.com>
parents:
16010
diff
changeset
|
4283 |
movemarkfrom = repo['.'].node() |
14485
610873cf064a
Make pull -u behave like pull && update
Brendan Cully <brendan@kublai.com>
parents:
14466
diff
changeset
|
4284 |
try: |
16019
eb85d5f89fef
bookmarks: move current bookmark on update -u and bare pull -u (issue3222)
Matt Mackall <mpm@selenic.com>
parents:
16010
diff
changeset
|
4285 |
ret = hg.update(repo, checkout) |
14485
610873cf064a
Make pull -u behave like pull && update
Brendan Cully <brendan@kublai.com>
parents:
14466
diff
changeset
|
4286 |
except util.Abort, inst: |
610873cf064a
Make pull -u behave like pull && update
Brendan Cully <brendan@kublai.com>
parents:
14466
diff
changeset
|
4287 |
ui.warn(_("not updating: %s\n" % str(inst))) |
610873cf064a
Make pull -u behave like pull && update
Brendan Cully <brendan@kublai.com>
parents:
14466
diff
changeset
|
4288 |
return 0 |
16019
eb85d5f89fef
bookmarks: move current bookmark on update -u and bare pull -u (issue3222)
Matt Mackall <mpm@selenic.com>
parents:
16010
diff
changeset
|
4289 |
if not ret and not checkout: |
eb85d5f89fef
bookmarks: move current bookmark on update -u and bare pull -u (issue3222)
Matt Mackall <mpm@selenic.com>
parents:
16010
diff
changeset
|
4290 |
if bookmarks.update(repo, [movemarkfrom], repo['.'].node()): |
eb85d5f89fef
bookmarks: move current bookmark on update -u and bare pull -u (issue3222)
Matt Mackall <mpm@selenic.com>
parents:
16010
diff
changeset
|
4291 |
ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent) |
eb85d5f89fef
bookmarks: move current bookmark on update -u and bare pull -u (issue3222)
Matt Mackall <mpm@selenic.com>
parents:
16010
diff
changeset
|
4292 |
return ret |
2019
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
4293 |
if modheads > 1: |
13804
7dc2bd4c0dc8
pull: new output message when there are multiple branches
Kevin Berridge <kevin.w.berridge@gmail.com>
parents:
13803
diff
changeset
|
4294 |
currentbranchheads = len(repo.branchheads()) |
7dc2bd4c0dc8
pull: new output message when there are multiple branches
Kevin Berridge <kevin.w.berridge@gmail.com>
parents:
13803
diff
changeset
|
4295 |
if currentbranchheads == modheads: |
13803
e380964d53f8
pull: don't suggest running hg merge when new heads are on different branches
Kevin Berridge <kevin.w.berridge@gmail.com>
parents:
13767
diff
changeset
|
4296 |
ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n")) |
13804
7dc2bd4c0dc8
pull: new output message when there are multiple branches
Kevin Berridge <kevin.w.berridge@gmail.com>
parents:
13803
diff
changeset
|
4297 |
elif currentbranchheads > 1: |
7dc2bd4c0dc8
pull: new output message when there are multiple branches
Kevin Berridge <kevin.w.berridge@gmail.com>
parents:
13803
diff
changeset
|
4298 |
ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to merge)\n")) |
2019
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
4299 |
else: |
13803
e380964d53f8
pull: don't suggest running hg merge when new heads are on different branches
Kevin Berridge <kevin.w.berridge@gmail.com>
parents:
13767
diff
changeset
|
4300 |
ui.status(_("(run 'hg heads' to see heads)\n")) |
2019
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
4301 |
else: |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1996
diff
changeset
|
4302 |
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
|
4303 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4304 |
@command('^pull', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4305 |
[('u', 'update', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4306 |
_('update to new branch head if changesets were pulled')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4307 |
('f', 'force', None, _('run even when remote repository is unrelated')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4308 |
('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4309 |
('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4310 |
('b', 'branch', [], _('a specific branch you would like to pull'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4311 |
_('BRANCH')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4312 |
] + remoteopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4313 |
_('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')) |
404 | 4314 |
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
|
4315 |
"""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
|
4316 |
|
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
4317 |
Pull changes from a remote repository to a local one. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4318 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4319 |
This finds all changes from the repository at the specified path |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
4320 |
or URL and adds them to a local repository (the current one unless |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
4321 |
-R is specified). By default, this does not update the copy of the |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
4322 |
project in the working directory. |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
4323 |
|
11193
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11185
diff
changeset
|
4324 |
Use :hg:`incoming` if you want to see what would have been added |
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11185
diff
changeset
|
4325 |
by a pull at the time you issued this command. If you then decide |
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11185
diff
changeset
|
4326 |
to add those changes to the repository, you should use :hg:`pull |
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11185
diff
changeset
|
4327 |
-r X` where ``X`` is the last changeset listed by :hg:`incoming`. |
7980
3d8252430e17
commands: make pull help point to the incoming command
Martin Geisler <mg@daimi.au.dk>
parents:
7979
diff
changeset
|
4328 |
|
7693
e040f9d6b2f3
consolidated url help into urls help topic and added information about path aliases
Bill Barry <after.fallout@gmail.com>
parents:
7691
diff
changeset
|
4329 |
If SOURCE is omitted, the 'default' path will be used. |
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
4330 |
See :hg:`help urls` for more information. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4331 |
|
16107
a3dcc59054ca
pull: backout change to return code
Matt Mackall <mpm@selenic.com>
parents:
16039
diff
changeset
|
4332 |
Returns 0 on success, 1 if an update had unresolved files. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4333 |
""" |
10379
a78bfaf988e1
add -b/--branch option to clone, bundle, incoming, outgoing, pull, push
Sune Foldager <cryo@cyanite.org>
parents:
10376
diff
changeset
|
4334 |
source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) |
14556
517e1d88bf7e
hg: change various repository() users to use peer() where appropriate
Matt Mackall <mpm@selenic.com>
parents:
14553
diff
changeset
|
4335 |
other = hg.peer(repo, opts, source) |
14076
924c82157d46
url: move URL parsing functions into util to improve startup time
Brodie Rao <brodie@bitheap.org>
parents:
14073
diff
changeset
|
4336 |
ui.status(_('pulling from %s\n') % util.hidepassword(source)) |
10365
d757bc0c7865
interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents:
10364
diff
changeset
|
4337 |
revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) |
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4338 |
|
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4339 |
if opts.get('bookmark'): |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4340 |
if not revs: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4341 |
revs = [] |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4342 |
rb = other.listkeys('bookmarks') |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4343 |
for b in opts['bookmark']: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4344 |
if b not in rb: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4345 |
raise util.Abort(_('remote bookmark %s not found!') % b) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4346 |
revs.append(rb[b]) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4347 |
|
4478
b2b55acbacdd
Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents:
4474
diff
changeset
|
4348 |
if revs: |
5259
65dc707606ed
Push capability checking into protocol-level code.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5248
diff
changeset
|
4349 |
try: |
4478
b2b55acbacdd
Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents:
4474
diff
changeset
|
4350 |
revs = [other.lookup(rev) for rev in revs] |
7637 | 4351 |
except error.CapabilityError: |
12128
090dc5eef746
pull: lowercase error message
Martin Geisler <mg@lazybytes.net>
parents:
12083
diff
changeset
|
4352 |
err = _("other repository doesn't support revision lookup, " |
7637 | 4353 |
"so a rev cannot be specified.") |
4354 |
raise util.Abort(err) |
|
4478
b2b55acbacdd
Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents:
4474
diff
changeset
|
4355 |
|
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
4356 |
modheads = repo.pull(other, heads=revs, force=opts.get('force')) |
15614
260a6449d83a
bookmarks: mark divergent bookmarks with book@pathalias when source in [paths]
Matt Mackall <mpm@selenic.com>
parents:
15611
diff
changeset
|
4357 |
bookmarks.updatefromremote(ui, repo, other, source) |
9645
02f40b2ece3f
commands: use rev from remote repo when updating as part of a pull
timeless@mozdev.org
parents:
9644
diff
changeset
|
4358 |
if checkout: |
02f40b2ece3f
commands: use rev from remote repo when updating as part of a pull
timeless@mozdev.org
parents:
9644
diff
changeset
|
4359 |
checkout = str(repo.changelog.rev(other.lookup(checkout))) |
12852
5dbff89cf107
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents:
12831
diff
changeset
|
4360 |
repo._subtoppath = source |
5dbff89cf107
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents:
12831
diff
changeset
|
4361 |
try: |
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4362 |
ret = postincoming(ui, repo, modheads, opts.get('update'), checkout) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4363 |
|
12852
5dbff89cf107
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents:
12831
diff
changeset
|
4364 |
finally: |
5dbff89cf107
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents:
12831
diff
changeset
|
4365 |
del repo._subtoppath |
246
96cde50a746f
Migrate rawcommit, import, export, history, and merge
mpm@selenic.com
parents:
245
diff
changeset
|
4366 |
|
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4367 |
# update specified bookmarks |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4368 |
if opts.get('bookmark'): |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4369 |
for b in opts['bookmark']: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4370 |
# explicit pull overrides local bookmark if any |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4371 |
ui.status(_("importing bookmark %s\n") % b) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4372 |
repo._bookmarks[b] = repo[rb[b]].node() |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4373 |
bookmarks.write(repo) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4374 |
|
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4375 |
return ret |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4376 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4377 |
@command('^push', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4378 |
[('f', 'force', None, _('force push')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4379 |
('r', 'rev', [], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4380 |
_('a changeset intended to be included in the destination'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4381 |
_('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4382 |
('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4383 |
('b', 'branch', [], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4384 |
_('a specific branch you would like to push'), _('BRANCH')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4385 |
('', 'new-branch', False, _('allow pushing a new branch')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4386 |
] + remoteopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4387 |
_('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')) |
2494
73ac95671788
push, outgoing, bundle: fall back to "default" if "default-push" not defined
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2493
diff
changeset
|
4388 |
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
|
4389 |
"""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
|
4390 |
|
11217
1b8aa9ffa7dc
commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents:
11103
diff
changeset
|
4391 |
Push changesets from the local repository to the specified |
1b8aa9ffa7dc
commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents:
11103
diff
changeset
|
4392 |
destination. |
1b8aa9ffa7dc
commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents:
11103
diff
changeset
|
4393 |
|
1b8aa9ffa7dc
commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents:
11103
diff
changeset
|
4394 |
This operation is symmetrical to pull: it is identical to a pull |
1b8aa9ffa7dc
commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents:
11103
diff
changeset
|
4395 |
in the destination repository from the current one. |
1b8aa9ffa7dc
commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents:
11103
diff
changeset
|
4396 |
|
1b8aa9ffa7dc
commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents:
11103
diff
changeset
|
4397 |
By default, push will not allow creation of new heads at the |
1b8aa9ffa7dc
commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents:
11103
diff
changeset
|
4398 |
destination, since multiple heads would make it unclear which head |
1b8aa9ffa7dc
commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents:
11103
diff
changeset
|
4399 |
to use. In this situation, it is recommended to pull and merge |
1b8aa9ffa7dc
commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents:
11103
diff
changeset
|
4400 |
before pushing. |
1b8aa9ffa7dc
commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents:
11103
diff
changeset
|
4401 |
|
11219
39a7f69a0a9a
commands: document --new-branch flag for push
Martin Geisler <mg@aragost.com>
parents:
11218
diff
changeset
|
4402 |
Use --new-branch if you want to allow push to create a new named |
39a7f69a0a9a
commands: document --new-branch flag for push
Martin Geisler <mg@aragost.com>
parents:
11218
diff
changeset
|
4403 |
branch that is not present at the destination. This allows you to |
39a7f69a0a9a
commands: document --new-branch flag for push
Martin Geisler <mg@aragost.com>
parents:
11218
diff
changeset
|
4404 |
only create a new branch without forcing other changes. |
39a7f69a0a9a
commands: document --new-branch flag for push
Martin Geisler <mg@aragost.com>
parents:
11218
diff
changeset
|
4405 |
|
11217
1b8aa9ffa7dc
commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents:
11103
diff
changeset
|
4406 |
Use -f/--force to override the default behavior and push all |
1b8aa9ffa7dc
commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents:
11103
diff
changeset
|
4407 |
changesets on all branches. |
1b8aa9ffa7dc
commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents:
11103
diff
changeset
|
4408 |
|
1b8aa9ffa7dc
commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents:
11103
diff
changeset
|
4409 |
If -r/--rev is used, the specified revision and all its ancestors |
1b8aa9ffa7dc
commands: updates to push docstring.
Faheem Mitha <faheem@email.unc.edu>
parents:
11103
diff
changeset
|
4410 |
will be pushed to the remote repository. |
7693
e040f9d6b2f3
consolidated url help into urls help topic and added information about path aliases
Bill Barry <after.fallout@gmail.com>
parents:
7691
diff
changeset
|
4411 |
|
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
4412 |
Please see :hg:`help urls` for important details about ``ssh://`` |
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
4413 |
URLs. If DESTINATION is omitted, a default path will be used. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4414 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4415 |
Returns 0 if push was successful, 1 if nothing to push. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4416 |
""" |
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4417 |
|
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4418 |
if opts.get('bookmark'): |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4419 |
for b in opts['bookmark']: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4420 |
# translate -B options to -r so changesets get pushed |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4421 |
if b in repo._bookmarks: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4422 |
opts.setdefault('rev', []).append(b) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4423 |
else: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4424 |
# if we try to push a deleted bookmark, translate it to null |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4425 |
# this lets simultaneous -r, -b options continue working |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4426 |
opts.setdefault('rev', []).append("null") |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4427 |
|
10365
d757bc0c7865
interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents:
10364
diff
changeset
|
4428 |
dest = ui.expandpath(dest or 'default-push', dest or 'default') |
10379
a78bfaf988e1
add -b/--branch option to clone, bundle, incoming, outgoing, pull, push
Sune Foldager <cryo@cyanite.org>
parents:
10376
diff
changeset
|
4429 |
dest, branches = hg.parseurl(dest, opts.get('branch')) |
14076
924c82157d46
url: move URL parsing functions into util to improve startup time
Brodie Rao <brodie@bitheap.org>
parents:
14073
diff
changeset
|
4430 |
ui.status(_('pushing to %s\n') % util.hidepassword(dest)) |
10365
d757bc0c7865
interpret repo#name url syntax as branch instead of revision
Sune Foldager <cryo@cyanite.org>
parents:
10364
diff
changeset
|
4431 |
revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) |
14556
517e1d88bf7e
hg: change various repository() users to use peer() where appropriate
Matt Mackall <mpm@selenic.com>
parents:
14553
diff
changeset
|
4432 |
other = hg.peer(repo, opts, dest) |
4478
b2b55acbacdd
Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents:
4474
diff
changeset
|
4433 |
if revs: |
b2b55acbacdd
Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents:
4474
diff
changeset
|
4434 |
revs = [repo.lookup(rev) for rev in revs] |
8815
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
4435 |
|
12852
5dbff89cf107
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents:
12831
diff
changeset
|
4436 |
repo._subtoppath = dest |
5dbff89cf107
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents:
12831
diff
changeset
|
4437 |
try: |
5dbff89cf107
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents:
12831
diff
changeset
|
4438 |
# push subrepos depth-first for coherent ordering |
5dbff89cf107
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents:
12831
diff
changeset
|
4439 |
c = repo[''] |
5dbff89cf107
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents:
12831
diff
changeset
|
4440 |
subs = c.substate # only repos that are committed |
5dbff89cf107
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents:
12831
diff
changeset
|
4441 |
for s in sorted(subs): |
16022
04604d1a9fc3
push: more precise failure check on subrepo push
Matt Mackall <mpm@selenic.com>
parents:
16021
diff
changeset
|
4442 |
if c.sub(s).push(opts) == 0: |
12852
5dbff89cf107
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents:
12831
diff
changeset
|
4443 |
return False |
5dbff89cf107
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents:
12831
diff
changeset
|
4444 |
finally: |
5dbff89cf107
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents:
12831
diff
changeset
|
4445 |
del repo._subtoppath |
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4446 |
result = repo.push(other, opts.get('force'), revs=revs, |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4447 |
newbranch=opts.get('new_branch')) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4448 |
|
16023
90f8b8dd0326
push: return 1 if no changes found (issue3228)
Matt Mackall <mpm@selenic.com>
parents:
16022
diff
changeset
|
4449 |
result = not result |
13368
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4450 |
|
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4451 |
if opts.get('bookmark'): |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4452 |
rb = other.listkeys('bookmarks') |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4453 |
for b in opts['bookmark']: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4454 |
# explicit push overrides remote bookmark if any |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4455 |
if b in repo._bookmarks: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4456 |
ui.status(_("exporting bookmark %s\n") % b) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4457 |
new = repo[b].hex() |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4458 |
elif b in rb: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4459 |
ui.status(_("deleting remote bookmark %s\n") % b) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4460 |
new = '' # delete |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4461 |
else: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4462 |
ui.warn(_('bookmark %s does not exist on the local ' |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4463 |
'or remote repository!\n') % b) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4464 |
return 2 |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4465 |
old = rb.get(b, '') |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4466 |
r = other.pushkey('bookmarks', b, old, new) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4467 |
if not r: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4468 |
ui.warn(_('updating bookmark %s failed!\n') % b) |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4469 |
if not result: |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4470 |
result = 2 |
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4471 |
|
d4ab9486e514
bookmarks: move push/pull command features to core
Matt Mackall <mpm@selenic.com>
parents:
13367
diff
changeset
|
4472 |
return result |
319 | 4473 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4474 |
@command('recover', []) |
245 | 4475 |
def recover(ui, repo): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4476 |
"""roll back an interrupted transaction |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4477 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4478 |
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
|
4479 |
|
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
4480 |
This command tries to fix the repository status after an |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
4481 |
interrupted operation. It should only be necessary when Mercurial |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
4482 |
suggests it. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4483 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4484 |
Returns 0 if successful, 1 if nothing to recover or verify fails. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4485 |
""" |
1516
0b1b029b4de3
Automatically run "verify" whenever we run "recover"
Matt Mackall <mpm@selenic.com>
parents:
1514
diff
changeset
|
4486 |
if repo.recover(): |
2778 | 4487 |
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
|
4488 |
return 1 |
245 | 4489 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4490 |
@command('^remove|rm', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4491 |
[('A', 'after', None, _('record delete for missing files')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4492 |
('f', 'force', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4493 |
_('remove (and delete) file even if added or modified')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4494 |
] + walkopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4495 |
_('[OPTION]... FILE...')) |
2179
520dd3d28e9b
add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2175
diff
changeset
|
4496 |
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
|
4497 |
"""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
|
4498 |
|
15114 | 4499 |
Schedule the indicated files for removal from the current branch. |
4500 |
||
4501 |
This command schedules the files to be removed at the next commit. |
|
4502 |
To undo a remove before that, see :hg:`revert`. To undo added |
|
4503 |
files, see :hg:`forget`. |
|
4504 |
||
4505 |
.. container:: verbose |
|
4506 |
||
4507 |
-A/--after can be used to remove only files that have already |
|
4508 |
been deleted, -f/--force can be used to force deletion, and -Af |
|
4509 |
can be used to remove files from the next revision without |
|
4510 |
deleting them from the working directory. |
|
4511 |
||
4512 |
The following table details the behavior of remove for different |
|
4513 |
file states (columns) and option combinations (rows). The file |
|
4514 |
states are Added [A], Clean [C], Modified [M] and Missing [!] |
|
4515 |
(as reported by :hg:`status`). The actions are Warn, Remove |
|
4516 |
(from branch) and Delete (from disk): |
|
15037
df47381b41d6
minirst: add simple table support
Matt Mackall <mpm@selenic.com>
parents:
15023
diff
changeset
|
4517 |
|
df47381b41d6
minirst: add simple table support
Matt Mackall <mpm@selenic.com>
parents:
15023
diff
changeset
|
4518 |
======= == == == == |
df47381b41d6
minirst: add simple table support
Matt Mackall <mpm@selenic.com>
parents:
15023
diff
changeset
|
4519 |
A C M ! |
df47381b41d6
minirst: add simple table support
Matt Mackall <mpm@selenic.com>
parents:
15023
diff
changeset
|
4520 |
======= == == == == |
df47381b41d6
minirst: add simple table support
Matt Mackall <mpm@selenic.com>
parents:
15023
diff
changeset
|
4521 |
none W RD W R |
df47381b41d6
minirst: add simple table support
Matt Mackall <mpm@selenic.com>
parents:
15023
diff
changeset
|
4522 |
-f R RD RD R |
df47381b41d6
minirst: add simple table support
Matt Mackall <mpm@selenic.com>
parents:
15023
diff
changeset
|
4523 |
-A W W W R |
df47381b41d6
minirst: add simple table support
Matt Mackall <mpm@selenic.com>
parents:
15023
diff
changeset
|
4524 |
-Af R R R R |
df47381b41d6
minirst: add simple table support
Matt Mackall <mpm@selenic.com>
parents:
15023
diff
changeset
|
4525 |
======= == == == == |
2309
b2f37c7026ca
remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2301
diff
changeset
|
4526 |
|
15114 | 4527 |
Note that remove never deletes files in Added [A] state from the |
4528 |
working directory, not even if option --force is specified. |
|
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4529 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4530 |
Returns 0 on success, 1 if any warnings encountered. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4531 |
""" |
6346
8e3b651382f5
improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6336
diff
changeset
|
4532 |
|
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4533 |
ret = 0 |
6346
8e3b651382f5
improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6336
diff
changeset
|
4534 |
after, force = opts.get('after'), opts.get('force') |
8e3b651382f5
improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6336
diff
changeset
|
4535 |
if not pats and not after: |
2179
520dd3d28e9b
add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2175
diff
changeset
|
4536 |
raise util.Abort(_('no files specified')) |
6346
8e3b651382f5
improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6336
diff
changeset
|
4537 |
|
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
4538 |
m = scmutil.match(repo[None], pats, opts) |
6761
cb981fc955fb
remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents:
6760
diff
changeset
|
4539 |
s = repo.status(match=m, clean=True) |
cb981fc955fb
remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents:
6760
diff
changeset
|
4540 |
modified, added, deleted, clean = s[0], s[1], s[3], s[6] |
cb981fc955fb
remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents:
6760
diff
changeset
|
4541 |
|
8533
6062c6362b2e
remove: warn if unversionned files are specified (issue1454)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8464
diff
changeset
|
4542 |
for f in m.files(): |
6062c6362b2e
remove: warn if unversionned files are specified (issue1454)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8464
diff
changeset
|
4543 |
if f not in repo.dirstate and not os.path.isdir(m.rel(f)): |
14604
b1a534335548
forget, remove: don't note on nonexistent file twice
Idan Kamara <idankk86@gmail.com>
parents:
14564
diff
changeset
|
4544 |
if os.path.exists(m.rel(f)): |
b1a534335548
forget, remove: don't note on nonexistent file twice
Idan Kamara <idankk86@gmail.com>
parents:
14564
diff
changeset
|
4545 |
ui.warn(_('not removing %s: file is untracked\n') % m.rel(f)) |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4546 |
ret = 1 |
8533
6062c6362b2e
remove: warn if unversionned files are specified (issue1454)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8464
diff
changeset
|
4547 |
|
6761
cb981fc955fb
remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents:
6760
diff
changeset
|
4548 |
if force: |
14450
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4549 |
list = modified + deleted + clean + added |
6761
cb981fc955fb
remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents:
6760
diff
changeset
|
4550 |
elif after: |
14450
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4551 |
list = deleted |
12129
07ac2a560fce
remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents:
12128
diff
changeset
|
4552 |
for f in modified + added + clean: |
07ac2a560fce
remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents:
12128
diff
changeset
|
4553 |
ui.warn(_('not removing %s: file still exists (use -f' |
07ac2a560fce
remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents:
12128
diff
changeset
|
4554 |
' to force removal)\n') % m.rel(f)) |
07ac2a560fce
remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents:
12128
diff
changeset
|
4555 |
ret = 1 |
6761
cb981fc955fb
remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents:
6760
diff
changeset
|
4556 |
else: |
14450
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4557 |
list = deleted + clean |
12129
07ac2a560fce
remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents:
12128
diff
changeset
|
4558 |
for f in modified: |
07ac2a560fce
remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents:
12128
diff
changeset
|
4559 |
ui.warn(_('not removing %s: file is modified (use -f' |
07ac2a560fce
remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents:
12128
diff
changeset
|
4560 |
' to force removal)\n') % m.rel(f)) |
07ac2a560fce
remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents:
12128
diff
changeset
|
4561 |
ret = 1 |
07ac2a560fce
remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents:
12128
diff
changeset
|
4562 |
for f in added: |
15115
c84b3f42d5ae
remove: suggest forget to undo adds
Matt Mackall <mpm@selenic.com>
parents:
15114
diff
changeset
|
4563 |
ui.warn(_('not removing %s: file has been marked for add' |
c84b3f42d5ae
remove: suggest forget to undo adds
Matt Mackall <mpm@selenic.com>
parents:
15114
diff
changeset
|
4564 |
' (use forget to undo)\n') % m.rel(f)) |
12129
07ac2a560fce
remove: properly set return code when warnings are issued
Brodie Rao <brodie@bitheap.org>
parents:
12128
diff
changeset
|
4565 |
ret = 1 |
6761
cb981fc955fb
remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents:
6760
diff
changeset
|
4566 |
|
14450
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4567 |
for f in sorted(list): |
6761
cb981fc955fb
remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents:
6760
diff
changeset
|
4568 |
if ui.verbose or not m.exact(f): |
cb981fc955fb
remove: work directly off status
Matt Mackall <mpm@selenic.com>
parents:
6760
diff
changeset
|
4569 |
ui.status(_('removing %s\n') % m.rel(f)) |
6346
8e3b651382f5
improved semantics for remove (issue438)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6336
diff
changeset
|
4570 |
|
14450
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4571 |
wlock = repo.wlock() |
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4572 |
try: |
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4573 |
if not after: |
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4574 |
for f in list: |
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4575 |
if f in added: |
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4576 |
continue # we never unlink added files on remove |
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4577 |
try: |
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4578 |
util.unlinkpath(repo.wjoin(f)) |
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4579 |
except OSError, inst: |
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4580 |
if inst.errno != errno.ENOENT: |
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4581 |
raise |
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4582 |
repo[None].forget(list) |
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4583 |
finally: |
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4584 |
wlock.release() |
d1a1578c5f78
commands.remove: don't use workingctx.remove(list, unlink=True)
Adrian Buehlmann <adrian@cadifra.com>
parents:
14435
diff
changeset
|
4585 |
|
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4586 |
return ret |
245 | 4587 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4588 |
@command('rename|move|mv', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4589 |
[('A', 'after', None, _('record a rename that has already occurred')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4590 |
('f', 'force', None, _('forcibly copy over an existing managed file')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4591 |
] + walkopts + dryrunopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4592 |
_('[OPTION]... SOURCE... DEST')) |
1253
a45e717c61a8
Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1250
diff
changeset
|
4593 |
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
|
4594 |
"""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
|
4595 |
|
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
4596 |
Mark dest as copies of sources; mark sources for deletion. If dest |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
4597 |
is a directory, copies are put in that directory. If dest is a |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
4598 |
file, there can only be one source. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4599 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4600 |
By default, this command copies the contents of files as they |
8033
aeb4a5c7a28e
commands: consistently write switches as -a/--abc
Martin Geisler <mg@lazybytes.net>
parents:
8032
diff
changeset
|
4601 |
exist in the working directory. If invoked with -A/--after, the |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4602 |
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
|
4603 |
|
7807
bd8f44638847
help: miscellaneous language fixes
timeless <timeless@gmail.com>
parents:
7765
diff
changeset
|
4604 |
This command takes effect at the next commit. To undo a rename |
11193
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
11185
diff
changeset
|
4605 |
before that, see :hg:`revert`. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4606 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4607 |
Returns 0 on success, 1 if errors are encountered. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4608 |
""" |
4914 | 4609 |
wlock = repo.wlock(False) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4610 |
try: |
5610
2493a478f395
copy: handle rename internally
Matt Mackall <mpm@selenic.com>
parents:
5589
diff
changeset
|
4611 |
return cmdutil.copy(ui, repo, pats, opts, rename=True) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4612 |
finally: |
8109
496ae1ea4698
switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8088
diff
changeset
|
4613 |
wlock.release() |
1253
a45e717c61a8
Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1250
diff
changeset
|
4614 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4615 |
@command('resolve', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4616 |
[('a', 'all', None, _('select all unresolved files')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4617 |
('l', 'list', None, _('list state of files needing merge')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4618 |
('m', 'mark', None, _('mark files as resolved')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4619 |
('u', 'unmark', None, _('mark files as unresolved')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4620 |
('n', 'no-status', None, _('hide status prefix'))] |
14852
cac04f2f475b
commands: use mergetoolopts when a command supports --tool
Martin Geisler <mg@aragost.com>
parents:
14840
diff
changeset
|
4621 |
+ mergetoolopts + walkopts, |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4622 |
_('[OPTION]... [FILE]...')) |
6518 | 4623 |
def resolve(ui, repo, *pats, **opts): |
11836
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4624 |
"""redo merges or set/view the merge status of files |
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4625 |
|
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4626 |
Merges with unresolved conflicts are often the result of |
12083
ebfc46929f3e
help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents:
12067
diff
changeset
|
4627 |
non-interactive merging using the ``internal:merge`` configuration |
ebfc46929f3e
help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents:
12067
diff
changeset
|
4628 |
setting, or a command-line merge tool like ``diff3``. The resolve |
ebfc46929f3e
help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents:
12067
diff
changeset
|
4629 |
command is used to manage the files involved in a merge, after |
ebfc46929f3e
help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents:
12067
diff
changeset
|
4630 |
:hg:`merge` has been run, and before :hg:`commit` is run (i.e. the |
16009
f1208827df7c
resolve: mention merge-tools topic in help
Augie Fackler <durin42@gmail.com>
parents:
15993
diff
changeset
|
4631 |
working directory must have two parents). See :hg:`help |
f1208827df7c
resolve: mention merge-tools topic in help
Augie Fackler <durin42@gmail.com>
parents:
15993
diff
changeset
|
4632 |
merge-tools` for information on configuring merge tools. |
11836
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4633 |
|
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4634 |
The resolve command can be used in the following ways: |
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4635 |
|
12809
e5922564ab01
help: improve merge-tools topic, describe --tool and clarify details
Mads Kiilerich <mads@kiilerich.com>
parents:
12803
diff
changeset
|
4636 |
- :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified |
12750
05bd2658bbb3
merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents:
12727
diff
changeset
|
4637 |
files, discarding any previous merge attempts. Re-merging is not |
11836
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4638 |
performed for files already marked as resolved. Use ``--all/-a`` |
15042
5e7f03cfeeb9
commands: fix grammar in resolve help text
Pang Yan Han <pangyanhan@gmail.com>
parents:
14903
diff
changeset
|
4639 |
to select all unresolved files. ``--tool`` can be used to specify |
12750
05bd2658bbb3
merge: add --tool argument to merge and resolve
Steve Borho <steve@borho.org>
parents:
12727
diff
changeset
|
4640 |
the merge tool used for the given files. It overrides the HGMERGE |
15232
5d9a5b919863
resolve: update documentation to mention the .orig backup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15223
diff
changeset
|
4641 |
environment variable and your configuration files. Previous file |
5d9a5b919863
resolve: update documentation to mention the .orig backup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15223
diff
changeset
|
4642 |
contents are saved with a ``.orig`` suffix. |
11836
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4643 |
|
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4644 |
- :hg:`resolve -m [FILE]`: mark a file as having been resolved |
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4645 |
(e.g. after having manually fixed-up the files). The default is |
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4646 |
to mark all unresolved files. |
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4647 |
|
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4648 |
- :hg:`resolve -u [FILE]...`: mark a file as unresolved. The |
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4649 |
default is to mark all resolved files. |
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4650 |
|
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4651 |
- :hg:`resolve -l`: list files which had or still have conflicts. |
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4652 |
In the printed list, ``U`` = unresolved and ``R`` = resolved. |
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4653 |
|
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4654 |
Note that Mercurial will not let you commit files with unresolved |
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4655 |
merge conflicts. You must use :hg:`resolve -m ...` before you can |
53fdc0989047
resolve: updated help documentation for improved clarity
Mark Edgington <edgimar@gmail.com>
parents:
11777
diff
changeset
|
4656 |
commit after a conflicting merge. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4657 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4658 |
Returns 0 on success, 1 if any files fail a resolve attempt. |
6518 | 4659 |
""" |
4660 |
||
9646
5b001f534452
commands: adding --no-status to resolve to match status
timeless <timeless@gmail.com>
parents:
9645
diff
changeset
|
4661 |
all, mark, unmark, show, nostatus = \ |
5b001f534452
commands: adding --no-status to resolve to match status
timeless <timeless@gmail.com>
parents:
9645
diff
changeset
|
4662 |
[opts.get(o) for o in 'all mark unmark list no_status'.split()] |
7527
5a14a8f3b909
resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents:
7449
diff
changeset
|
4663 |
|
5a14a8f3b909
resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents:
7449
diff
changeset
|
4664 |
if (show and (mark or unmark)) or (mark and unmark): |
6518 | 4665 |
raise util.Abort(_("too many options specified")) |
7527
5a14a8f3b909
resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents:
7449
diff
changeset
|
4666 |
if pats and all: |
5a14a8f3b909
resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents:
7449
diff
changeset
|
4667 |
raise util.Abort(_("can't specify --all and patterns")) |
5a14a8f3b909
resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents:
7449
diff
changeset
|
4668 |
if not (all or pats or show or mark or unmark): |
5a14a8f3b909
resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents:
7449
diff
changeset
|
4669 |
raise util.Abort(_('no files or directories specified; ' |
5a14a8f3b909
resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents:
7449
diff
changeset
|
4670 |
'use --all to remerge all files')) |
6518 | 4671 |
|
15856
6bed6cc6d0d0
commands: partial backout of fbb68b382040
Martin Geisler <mg@aragost.com>
parents:
15855
diff
changeset
|
4672 |
ms = mergemod.mergestate(repo) |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
4673 |
m = scmutil.match(repo[None], pats, opts) |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4674 |
ret = 0 |
6518 | 4675 |
|
4676 |
for f in ms: |
|
6594 | 4677 |
if m(f): |
7527
5a14a8f3b909
resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents:
7449
diff
changeset
|
4678 |
if show: |
9646
5b001f534452
commands: adding --no-status to resolve to match status
timeless <timeless@gmail.com>
parents:
9645
diff
changeset
|
4679 |
if nostatus: |
5b001f534452
commands: adding --no-status to resolve to match status
timeless <timeless@gmail.com>
parents:
9645
diff
changeset
|
4680 |
ui.write("%s\n" % f) |
5b001f534452
commands: adding --no-status to resolve to match status
timeless <timeless@gmail.com>
parents:
9645
diff
changeset
|
4681 |
else: |
10817
2096496b40ec
status: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10816
diff
changeset
|
4682 |
ui.write("%s %s\n" % (ms[f].upper(), f), |
2096496b40ec
status: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10816
diff
changeset
|
4683 |
label='resolve.' + |
2096496b40ec
status: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10816
diff
changeset
|
4684 |
{'u': 'unresolved', 'r': 'resolved'}[ms[f]]) |
7527
5a14a8f3b909
resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents:
7449
diff
changeset
|
4685 |
elif mark: |
6518 | 4686 |
ms.mark(f, "r") |
7527
5a14a8f3b909
resolve: require -a switch to resolve all files
Matt Mackall <mpm@selenic.com>
parents:
7449
diff
changeset
|
4687 |
elif unmark: |
6518 | 4688 |
ms.mark(f, "u") |
4689 |
else: |
|
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6746
diff
changeset
|
4690 |
wctx = repo[None] |
6518 | 4691 |
mctx = wctx.parents()[-1] |
7847 | 4692 |
|
4693 |
# backup pre-resolve (merge uses .orig for its own purposes) |
|
4694 |
a = repo.wjoin(f) |
|
4695 |
util.copyfile(a, a + ".resolve") |
|
4696 |
||
12788
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12765
diff
changeset
|
4697 |
try: |
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12765
diff
changeset
|
4698 |
# resolve file |
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12765
diff
changeset
|
4699 |
ui.setconfig('ui', 'forcemerge', opts.get('tool', '')) |
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12765
diff
changeset
|
4700 |
if ms.resolve(f, wctx, mctx): |
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12765
diff
changeset
|
4701 |
ret = 1 |
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12765
diff
changeset
|
4702 |
finally: |
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12765
diff
changeset
|
4703 |
ui.setconfig('ui', 'forcemerge', '') |
6518 | 4704 |
|
7847 | 4705 |
# replace filemerge's .orig file with our resolve file |
4706 |
util.rename(a + ".resolve", a + ".orig") |
|
12369
6f0d9d79111f
merge: delay writing the mergestate during until commit is called
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
12323
diff
changeset
|
4707 |
|
6f0d9d79111f
merge: delay writing the mergestate during until commit is called
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
12323
diff
changeset
|
4708 |
ms.commit() |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4709 |
return ret |
7847 | 4710 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4711 |
@command('revert', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4712 |
[('a', 'all', None, _('revert all changes when no arguments given')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4713 |
('d', 'date', '', _('tipmost revision matching date'), _('DATE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4714 |
('r', 'rev', '', _('revert to the specified revision'), _('REV')), |
15009
caa5283390f8
revert: introduce short option -C for --no-backup
Adrian Buehlmann <adrian@cadifra.com>
parents:
14986
diff
changeset
|
4715 |
('C', 'no-backup', None, _('do not save backup copies of files')), |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4716 |
] + walkopts + dryrunopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4717 |
_('[OPTION]... [-r REV] [NAME]...')) |
1472
3c909a747d7f
make revert use standard matcher
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1470
diff
changeset
|
4718 |
def revert(ui, repo, *pats, **opts): |
14540
944d9088da96
revert: rewrite help summary
Matt Mackall <mpm@selenic.com>
parents:
14532
diff
changeset
|
4719 |
"""restore files to their checkout state |
5574 | 4720 |
|
12390
aff4afdcfd2b
Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents:
12389
diff
changeset
|
4721 |
.. note:: |
14541
07ee46a2ece3
revert: simplify usage note
Matt Mackall <mpm@selenic.com>
parents:
14540
diff
changeset
|
4722 |
To check out earlier revisions, you should use :hg:`update REV`. |
07ee46a2ece3
revert: simplify usage note
Matt Mackall <mpm@selenic.com>
parents:
14540
diff
changeset
|
4723 |
To cancel a merge (and lose your changes), use :hg:`update --clean .`. |
2204
eb5fa83ffcfa
fix doc comments for revert command. people found them confusing.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2189
diff
changeset
|
4724 |
|
14544
586f33cc3cb9
revert: rearrange the date help
Matt Mackall <mpm@selenic.com>
parents:
14543
diff
changeset
|
4725 |
With no revision specified, revert the specified files or directories |
14903
a934b9249574
revert: restore check for uncommitted merge (issue2915) (BC)
Matt Mackall <mpm@selenic.com>
parents:
14849
diff
changeset
|
4726 |
to the contents they had in the parent of the working directory. |
14544
586f33cc3cb9
revert: rearrange the date help
Matt Mackall <mpm@selenic.com>
parents:
14543
diff
changeset
|
4727 |
This restores the contents of files to an unmodified |
14903
a934b9249574
revert: restore check for uncommitted merge (issue2915) (BC)
Matt Mackall <mpm@selenic.com>
parents:
14849
diff
changeset
|
4728 |
state and unschedules adds, removes, copies, and renames. If the |
a934b9249574
revert: restore check for uncommitted merge (issue2915) (BC)
Matt Mackall <mpm@selenic.com>
parents:
14849
diff
changeset
|
4729 |
working directory has two parents, you must explicitly specify a |
a934b9249574
revert: restore check for uncommitted merge (issue2915) (BC)
Matt Mackall <mpm@selenic.com>
parents:
14849
diff
changeset
|
4730 |
revision. |
1811
6cb548cffdf5
resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1804
diff
changeset
|
4731 |
|
14544
586f33cc3cb9
revert: rearrange the date help
Matt Mackall <mpm@selenic.com>
parents:
14543
diff
changeset
|
4732 |
Using the -r/--rev or -d/--date options, revert the given files or |
14557
f966979f61ce
revert: is reverting file states, not just file contents
Adrian Buehlmann <adrian@cadifra.com>
parents:
14556
diff
changeset
|
4733 |
directories to their states as of a specific revision. Because |
14546
99a7cd924636
revert: replace mention of 'roll back' with pointer to 'backout'
Matt Mackall <mpm@selenic.com>
parents:
14545
diff
changeset
|
4734 |
revert does not change the working directory parents, this will |
99a7cd924636
revert: replace mention of 'roll back' with pointer to 'backout'
Matt Mackall <mpm@selenic.com>
parents:
14545
diff
changeset
|
4735 |
cause these files to appear modified. This can be helpful to "back |
14547
a6cc0f2d0365
revert: actually add pointer to backout
Matt Mackall <mpm@selenic.com>
parents:
14546
diff
changeset
|
4736 |
out" some or all of an earlier change. See :hg:`backout` for a |
a6cc0f2d0365
revert: actually add pointer to backout
Matt Mackall <mpm@selenic.com>
parents:
14546
diff
changeset
|
4737 |
related method. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4738 |
|
5574 | 4739 |
Modified files are saved with a .orig suffix before reverting. |
4740 |
To disable these backups, use --no-backup. |
|
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4741 |
|
14544
586f33cc3cb9
revert: rearrange the date help
Matt Mackall <mpm@selenic.com>
parents:
14543
diff
changeset
|
4742 |
See :hg:`help dates` for a list of formats valid for -d/--date. |
586f33cc3cb9
revert: rearrange the date help
Matt Mackall <mpm@selenic.com>
parents:
14543
diff
changeset
|
4743 |
|
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4744 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4745 |
""" |
2982
890e285c52a1
revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2963
diff
changeset
|
4746 |
|
11941 | 4747 |
if opts.get("date"): |
4748 |
if opts.get("rev"): |
|
3814
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3813
diff
changeset
|
4749 |
raise util.Abort(_("you can't specify a revision and a date")) |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3813
diff
changeset
|
4750 |
opts["rev"] = cmdutil.finddate(ui, repo, opts["date"]) |
120be84f33de
Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents:
3813
diff
changeset
|
4751 |
|
13022
3fd4e4e81382
revert: improve merge advice and favor its error over all
timeless <timeless@gmail.com>
parents:
12968
diff
changeset
|
4752 |
parent, p2 = repo.dirstate.parents() |
14903
a934b9249574
revert: restore check for uncommitted merge (issue2915) (BC)
Matt Mackall <mpm@selenic.com>
parents:
14849
diff
changeset
|
4753 |
if not opts.get('rev') and p2 != nullid: |
a934b9249574
revert: restore check for uncommitted merge (issue2915) (BC)
Matt Mackall <mpm@selenic.com>
parents:
14849
diff
changeset
|
4754 |
# revert after merge is a trap for new users (issue2915) |
a934b9249574
revert: restore check for uncommitted merge (issue2915) (BC)
Matt Mackall <mpm@selenic.com>
parents:
14849
diff
changeset
|
4755 |
raise util.Abort(_('uncommitted merge with no revision specified'), |
a934b9249574
revert: restore check for uncommitted merge (issue2915) (BC)
Matt Mackall <mpm@selenic.com>
parents:
14849
diff
changeset
|
4756 |
hint=_('use "hg update" or see "hg help revert"')) |
a934b9249574
revert: restore check for uncommitted merge (issue2915) (BC)
Matt Mackall <mpm@selenic.com>
parents:
14849
diff
changeset
|
4757 |
|
14726
e0039716f3ea
revert: mention update in hint of abort when reverting to non-parent
Adrian Buehlmann <adrian@cadifra.com>
parents:
14725
diff
changeset
|
4758 |
ctx = scmutil.revsingle(repo, opts.get('rev')) |
e0039716f3ea
revert: mention update in hint of abort when reverting to non-parent
Adrian Buehlmann <adrian@cadifra.com>
parents:
14725
diff
changeset
|
4759 |
node = ctx.node() |
13022
3fd4e4e81382
revert: improve merge advice and favor its error over all
timeless <timeless@gmail.com>
parents:
12968
diff
changeset
|
4760 |
|
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
4761 |
if not pats and not opts.get('all'): |
14721
4fcde634f5e0
revert: be more helpful on uncommitted merges
Adrian Buehlmann <adrian@cadifra.com>
parents:
14713
diff
changeset
|
4762 |
msg = _("no files or directories specified") |
4fcde634f5e0
revert: be more helpful on uncommitted merges
Adrian Buehlmann <adrian@cadifra.com>
parents:
14713
diff
changeset
|
4763 |
if p2 != nullid: |
4fcde634f5e0
revert: be more helpful on uncommitted merges
Adrian Buehlmann <adrian@cadifra.com>
parents:
14713
diff
changeset
|
4764 |
hint = _("uncommitted merge, use --all to discard all changes," |
4fcde634f5e0
revert: be more helpful on uncommitted merges
Adrian Buehlmann <adrian@cadifra.com>
parents:
14713
diff
changeset
|
4765 |
" or 'hg update -C .' to abort the merge") |
14755
6ba51c81ff75
revert: improve hints on abort when reverting to parent without --all
Adrian Buehlmann <adrian@cadifra.com>
parents:
14742
diff
changeset
|
4766 |
raise util.Abort(msg, hint=hint) |
6ba51c81ff75
revert: improve hints on abort when reverting to parent without --all
Adrian Buehlmann <adrian@cadifra.com>
parents:
14742
diff
changeset
|
4767 |
dirty = util.any(repo.status()) |
6ba51c81ff75
revert: improve hints on abort when reverting to parent without --all
Adrian Buehlmann <adrian@cadifra.com>
parents:
14742
diff
changeset
|
4768 |
if node != parent: |
6ba51c81ff75
revert: improve hints on abort when reverting to parent without --all
Adrian Buehlmann <adrian@cadifra.com>
parents:
14742
diff
changeset
|
4769 |
if dirty: |
14726
e0039716f3ea
revert: mention update in hint of abort when reverting to non-parent
Adrian Buehlmann <adrian@cadifra.com>
parents:
14725
diff
changeset
|
4770 |
hint = _("uncommitted changes, use --all to discard all" |
e0039716f3ea
revert: mention update in hint of abort when reverting to non-parent
Adrian Buehlmann <adrian@cadifra.com>
parents:
14725
diff
changeset
|
4771 |
" changes, or 'hg update %s' to update") % ctx.rev() |
e0039716f3ea
revert: mention update in hint of abort when reverting to non-parent
Adrian Buehlmann <adrian@cadifra.com>
parents:
14725
diff
changeset
|
4772 |
else: |
e0039716f3ea
revert: mention update in hint of abort when reverting to non-parent
Adrian Buehlmann <adrian@cadifra.com>
parents:
14725
diff
changeset
|
4773 |
hint = _("use --all to revert all files," |
e0039716f3ea
revert: mention update in hint of abort when reverting to non-parent
Adrian Buehlmann <adrian@cadifra.com>
parents:
14725
diff
changeset
|
4774 |
" or 'hg update %s' to update") % ctx.rev() |
14755
6ba51c81ff75
revert: improve hints on abort when reverting to parent without --all
Adrian Buehlmann <adrian@cadifra.com>
parents:
14742
diff
changeset
|
4775 |
elif dirty: |
6ba51c81ff75
revert: improve hints on abort when reverting to parent without --all
Adrian Buehlmann <adrian@cadifra.com>
parents:
14742
diff
changeset
|
4776 |
hint = _("uncommitted changes, use --all to discard all changes") |
6ba51c81ff75
revert: improve hints on abort when reverting to parent without --all
Adrian Buehlmann <adrian@cadifra.com>
parents:
14742
diff
changeset
|
4777 |
else: |
6ba51c81ff75
revert: improve hints on abort when reverting to parent without --all
Adrian Buehlmann <adrian@cadifra.com>
parents:
14742
diff
changeset
|
4778 |
hint = _("use --all to revert all files") |
14721
4fcde634f5e0
revert: be more helpful on uncommitted merges
Adrian Buehlmann <adrian@cadifra.com>
parents:
14713
diff
changeset
|
4779 |
raise util.Abort(msg, hint=hint) |
2982
890e285c52a1
revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2963
diff
changeset
|
4780 |
|
3972
356e20d46b34
commands.py: use contexts in various places (debug*state, revert)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3951
diff
changeset
|
4781 |
mf = ctx.manifest() |
2407
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
4782 |
if node == parent: |
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
4783 |
pmf = mf |
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
4784 |
else: |
8fe3d60b7f19
revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2406
diff
changeset
|
4785 |
pmf = None |
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
4786 |
|
2042
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
4787 |
# 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
|
4788 |
# 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
|
4789 |
# but not other. |
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
4790 |
|
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
4791 |
names = {} |
2042
a514c7509fa9
small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2037
diff
changeset
|
4792 |
|
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4793 |
wlock = repo.wlock() |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4794 |
try: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4795 |
# walk dirstate. |
6579
0159b7a36184
walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents:
6578
diff
changeset
|
4796 |
|
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
4797 |
m = scmutil.match(repo[None], pats, opts) |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10270
diff
changeset
|
4798 |
m.bad = lambda x, y: False |
6586
d3463007d368
walk: return a single value
Matt Mackall <mpm@selenic.com>
parents:
6585
diff
changeset
|
4799 |
for abs in repo.walk(m): |
6584
29c77e5dfb3c
walk: remove rel and exact returns
Matt Mackall <mpm@selenic.com>
parents:
6583
diff
changeset
|
4800 |
names[abs] = m.rel(abs), m.exact(abs) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4801 |
|
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4802 |
# walk target manifest. |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4803 |
|
6579
0159b7a36184
walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents:
6578
diff
changeset
|
4804 |
def badfn(path, msg): |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4805 |
if path in names: |
8679
32537b12e091
add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents:
8669
diff
changeset
|
4806 |
return |
15265
460135339d74
revert: warn that subrepos cannot be reverted
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
15260
diff
changeset
|
4807 |
if path in repo[node].substate: |
460135339d74
revert: warn that subrepos cannot be reverted
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
15260
diff
changeset
|
4808 |
ui.warn("%s: %s\n" % (m.rel(path), |
460135339d74
revert: warn that subrepos cannot be reverted
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
15260
diff
changeset
|
4809 |
'reverting subrepos is unsupported')) |
460135339d74
revert: warn that subrepos cannot be reverted
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
15260
diff
changeset
|
4810 |
return |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4811 |
path_ = path + '/' |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4812 |
for f in names: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4813 |
if f.startswith(path_): |
8679
32537b12e091
add: use match.bad callback more effectively
Matt Mackall <mpm@selenic.com>
parents:
8669
diff
changeset
|
4814 |
return |
8615
94ca38e63576
use ui instead of repo.ui when the former is in scope
Martin Geisler <mg@lazybytes.net>
parents:
8544
diff
changeset
|
4815 |
ui.warn("%s: %s\n" % (m.rel(path), msg)) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4816 |
|
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
4817 |
m = scmutil.match(repo[node], pats, opts) |
6579
0159b7a36184
walk: pass match object to cmdutil.walk
Matt Mackall <mpm@selenic.com>
parents:
6578
diff
changeset
|
4818 |
m.bad = badfn |
6764 | 4819 |
for abs in repo[node].walk(m): |
6584
29c77e5dfb3c
walk: remove rel and exact returns
Matt Mackall <mpm@selenic.com>
parents:
6583
diff
changeset
|
4820 |
if abs not in names: |
29c77e5dfb3c
walk: remove rel and exact returns
Matt Mackall <mpm@selenic.com>
parents:
6583
diff
changeset
|
4821 |
names[abs] = m.rel(abs), m.exact(abs) |
6031
7383384793fb
revert: don't assume ignored files will be returned in the unknown list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6030
diff
changeset
|
4822 |
|
14322
a90131b85fd8
scmutil: drop aliases in cmdutil for match functions
Matt Mackall <mpm@selenic.com>
parents:
14321
diff
changeset
|
4823 |
m = scmutil.matchfiles(repo, names) |
6603
41eb20cc1c02
match: remove files arg from repo.status and friends
Matt Mackall <mpm@selenic.com>
parents:
6602
diff
changeset
|
4824 |
changes = repo.status(match=m)[:4] |
8152
08e1baf924ca
replace set-like dictionaries with real sets
Martin Geisler <mg@lazybytes.net>
parents:
8150
diff
changeset
|
4825 |
modified, added, removed, deleted = map(set, changes) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4826 |
|
5266 | 4827 |
# if f is a rename, also revert the source |
4828 |
cwd = repo.getcwd() |
|
4829 |
for f in added: |
|
4830 |
src = repo.dirstate.copied(f) |
|
4831 |
if src and src not in names and repo.dirstate[src] == 'r': |
|
8152
08e1baf924ca
replace set-like dictionaries with real sets
Martin Geisler <mg@lazybytes.net>
parents:
8150
diff
changeset
|
4832 |
removed.add(src) |
5266 | 4833 |
names[src] = (repo.pathto(src, cwd), True) |
4834 |
||
6109
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4835 |
def removeforget(abs): |
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4836 |
if repo.dirstate[abs] == 'a': |
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4837 |
return _('forgetting %s\n') |
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4838 |
return _('removing %s\n') |
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4839 |
|
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4840 |
revert = ([], _('reverting %s\n')) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4841 |
add = ([], _('adding %s\n')) |
6109
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4842 |
remove = ([], removeforget) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4843 |
undelete = ([], _('undeleting %s\n')) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4844 |
|
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4845 |
disptable = ( |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4846 |
# dispatch table: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4847 |
# file state |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4848 |
# action if in target manifest |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4849 |
# action if not in target manifest |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4850 |
# make backup if in target manifest |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4851 |
# make backup if not in target manifest |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4852 |
(modified, revert, remove, True, True), |
6109
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4853 |
(added, revert, remove, True, False), |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4854 |
(removed, undelete, None, False, False), |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4855 |
(deleted, revert, remove, False, False), |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4856 |
) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4857 |
|
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
8190
diff
changeset
|
4858 |
for abs, (rel, exact) in sorted(names.items()): |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4859 |
mfentry = mf.get(abs) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4860 |
target = repo.wjoin(abs) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4861 |
def handle(xlist, dobackup): |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4862 |
xlist[0].append(abs) |
12033 | 4863 |
if (dobackup and not opts.get('no_backup') and |
4864 |
os.path.lexists(target)): |
|
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4865 |
bakname = "%s.orig" % rel |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4866 |
ui.note(_('saving current version of %s as %s\n') % |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4867 |
(rel, bakname)) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4868 |
if not opts.get('dry_run'): |
11629
9e874ee0fe97
revert: rename original to .orig instead of copying (issue2282)
Mads Kiilerich <mads@kiilerich.com>
parents:
11612
diff
changeset
|
4869 |
util.rename(target, bakname) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4870 |
if ui.verbose or not exact: |
6109
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4871 |
msg = xlist[1] |
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4872 |
if not isinstance(msg, basestring): |
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4873 |
msg = msg(abs) |
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4874 |
ui.status(msg % rel) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4875 |
for table, hitlist, misslist, backuphit, backupmiss in disptable: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10270
diff
changeset
|
4876 |
if abs not in table: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10270
diff
changeset
|
4877 |
continue |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4878 |
# file has changed in dirstate |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4879 |
if mfentry: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4880 |
handle(hitlist, backuphit) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4881 |
elif misslist is not None: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4882 |
handle(misslist, backupmiss) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4883 |
break |
2029
d436b21b20dc
rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2022
diff
changeset
|
4884 |
else: |
6031
7383384793fb
revert: don't assume ignored files will be returned in the unknown list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6030
diff
changeset
|
4885 |
if abs not in repo.dirstate: |
7383384793fb
revert: don't assume ignored files will be returned in the unknown list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6030
diff
changeset
|
4886 |
if mfentry: |
7383384793fb
revert: don't assume ignored files will be returned in the unknown list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6030
diff
changeset
|
4887 |
handle(add, True) |
7383384793fb
revert: don't assume ignored files will be returned in the unknown list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6030
diff
changeset
|
4888 |
elif exact: |
7383384793fb
revert: don't assume ignored files will be returned in the unknown list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6030
diff
changeset
|
4889 |
ui.warn(_('file not managed: %s\n') % rel) |
7383384793fb
revert: don't assume ignored files will be returned in the unknown list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6030
diff
changeset
|
4890 |
continue |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4891 |
# file has not changed in dirstate |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4892 |
if node == parent: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10270
diff
changeset
|
4893 |
if exact: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10270
diff
changeset
|
4894 |
ui.warn(_('no changes needed to %s\n') % rel) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4895 |
continue |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4896 |
if pmf is None: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4897 |
# only need parent manifest in this unlikely case, |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4898 |
# so do not read by default |
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6746
diff
changeset
|
4899 |
pmf = repo[parent].manifest() |
15373
9a2582e325a5
revert: fix missing removes when parent was changed in dirstate
Peer Stritzinger <peer@stritzinger.com>
parents:
15360
diff
changeset
|
4900 |
if abs in pmf and mfentry: |
9a2582e325a5
revert: fix missing removes when parent was changed in dirstate
Peer Stritzinger <peer@stritzinger.com>
parents:
15360
diff
changeset
|
4901 |
# if version of file is same in parent and target |
9a2582e325a5
revert: fix missing removes when parent was changed in dirstate
Peer Stritzinger <peer@stritzinger.com>
parents:
15360
diff
changeset
|
4902 |
# manifests, do nothing |
9a2582e325a5
revert: fix missing removes when parent was changed in dirstate
Peer Stritzinger <peer@stritzinger.com>
parents:
15360
diff
changeset
|
4903 |
if (pmf[abs] != mfentry or |
9a2582e325a5
revert: fix missing removes when parent was changed in dirstate
Peer Stritzinger <peer@stritzinger.com>
parents:
15360
diff
changeset
|
4904 |
pmf.flags(abs) != mf.flags(abs)): |
9a2582e325a5
revert: fix missing removes when parent was changed in dirstate
Peer Stritzinger <peer@stritzinger.com>
parents:
15360
diff
changeset
|
4905 |
handle(revert, False) |
9a2582e325a5
revert: fix missing removes when parent was changed in dirstate
Peer Stritzinger <peer@stritzinger.com>
parents:
15360
diff
changeset
|
4906 |
else: |
9a2582e325a5
revert: fix missing removes when parent was changed in dirstate
Peer Stritzinger <peer@stritzinger.com>
parents:
15360
diff
changeset
|
4907 |
handle(remove, False) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4908 |
|
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4909 |
if not opts.get('dry_run'): |
6107
41bb88cb913e
commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6106
diff
changeset
|
4910 |
def checkout(f): |
41bb88cb913e
commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6106
diff
changeset
|
4911 |
fc = ctx[f] |
6743 | 4912 |
repo.wwrite(f, fc.data(), fc.flags()) |
6107
41bb88cb913e
commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6106
diff
changeset
|
4913 |
|
14220
21b8ce4d3331
rename path_auditor to pathauditor
Adrian Buehlmann <adrian@cadifra.com>
parents:
14216
diff
changeset
|
4914 |
audit_path = scmutil.pathauditor(repo.root) |
6109
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4915 |
for f in remove[0]: |
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4916 |
if repo.dirstate[f] == 'a': |
14434
cc8c09855d19
dirstate: rename forget to drop
Matt Mackall <mpm@selenic.com>
parents:
14414
diff
changeset
|
4917 |
repo.dirstate.drop(f) |
6109
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4918 |
continue |
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4919 |
audit_path(f) |
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4920 |
try: |
13235
6bf39d88c857
rename util.unlink to unlinkpath
Adrian Buehlmann <adrian@cadifra.com>
parents:
13234
diff
changeset
|
4921 |
util.unlinkpath(repo.wjoin(f)) |
6109
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4922 |
except OSError: |
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4923 |
pass |
242595e612ed
revert: unify forget and remove lists
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6108
diff
changeset
|
4924 |
repo.dirstate.remove(f) |
6107
41bb88cb913e
commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6106
diff
changeset
|
4925 |
|
6299
653ddd1d7cd7
revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6296
diff
changeset
|
4926 |
normal = None |
653ddd1d7cd7
revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6296
diff
changeset
|
4927 |
if node == parent: |
653ddd1d7cd7
revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6296
diff
changeset
|
4928 |
# We're reverting to our parent. If possible, we'd like status |
653ddd1d7cd7
revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6296
diff
changeset
|
4929 |
# to report the file as clean. We have to use normallookup for |
653ddd1d7cd7
revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6296
diff
changeset
|
4930 |
# merges to avoid losing information about merged/dirty files. |
653ddd1d7cd7
revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6296
diff
changeset
|
4931 |
if p2 != nullid: |
653ddd1d7cd7
revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6296
diff
changeset
|
4932 |
normal = repo.dirstate.normallookup |
653ddd1d7cd7
revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6296
diff
changeset
|
4933 |
else: |
653ddd1d7cd7
revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6296
diff
changeset
|
4934 |
normal = repo.dirstate.normal |
6107
41bb88cb913e
commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6106
diff
changeset
|
4935 |
for f in revert[0]: |
41bb88cb913e
commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6106
diff
changeset
|
4936 |
checkout(f) |
6299
653ddd1d7cd7
revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6296
diff
changeset
|
4937 |
if normal: |
653ddd1d7cd7
revert: update state of files in the "checkout" list
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6296
diff
changeset
|
4938 |
normal(f) |
6107
41bb88cb913e
commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6106
diff
changeset
|
4939 |
|
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4940 |
for f in add[0]: |
6107
41bb88cb913e
commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6106
diff
changeset
|
4941 |
checkout(f) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4942 |
repo.dirstate.add(f) |
6107
41bb88cb913e
commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6106
diff
changeset
|
4943 |
|
6108
5086576a2152
revert: only call dirstate.normal when we know the file is clean
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6107
diff
changeset
|
4944 |
normal = repo.dirstate.normallookup |
5086576a2152
revert: only call dirstate.normal when we know the file is clean
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6107
diff
changeset
|
4945 |
if node == parent and p2 == nullid: |
5086576a2152
revert: only call dirstate.normal when we know the file is clean
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6107
diff
changeset
|
4946 |
normal = repo.dirstate.normal |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4947 |
for f in undelete[0]: |
6107
41bb88cb913e
commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6106
diff
changeset
|
4948 |
checkout(f) |
6108
5086576a2152
revert: only call dirstate.normal when we know the file is clean
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6107
diff
changeset
|
4949 |
normal(f) |
6107
41bb88cb913e
commands.revert: don't call hg.revert
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6106
diff
changeset
|
4950 |
|
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
4951 |
finally: |
8109
496ae1ea4698
switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8088
diff
changeset
|
4952 |
wlock.release() |
588 | 4953 |
|
15183
59e8bc22506e
rollback: avoid unsafe rollback when not at tip (issue2998)
Greg Ward <greg@gerg.ca>
parents:
15179
diff
changeset
|
4954 |
@command('rollback', dryrunopts + |
59e8bc22506e
rollback: avoid unsafe rollback when not at tip (issue2998)
Greg Ward <greg@gerg.ca>
parents:
15179
diff
changeset
|
4955 |
[('f', 'force', False, _('ignore safety measures'))]) |
10882
f0bfe42c7b1f
rollback: add dry-run argument, emit transaction description
Steve Borho <steve@borho.org>
parents:
10835
diff
changeset
|
4956 |
def rollback(ui, repo, **opts): |
10889
e25c450c351e
commands: improve some command summaries
Matt Mackall <mpm@selenic.com>
parents:
10882
diff
changeset
|
4957 |
"""roll back the last transaction (dangerous) |
5575
8788ff630c26
imported patch rollback-help
Matt Mackall <mpm@selenic.com>
parents:
5574
diff
changeset
|
4958 |
|
8788ff630c26
imported patch rollback-help
Matt Mackall <mpm@selenic.com>
parents:
5574
diff
changeset
|
4959 |
This command should be used with care. There is only one level of |
8788ff630c26
imported patch rollback-help
Matt Mackall <mpm@selenic.com>
parents:
5574
diff
changeset
|
4960 |
rollback, and there is no way to undo a rollback. It will also |
8788ff630c26
imported patch rollback-help
Matt Mackall <mpm@selenic.com>
parents:
5574
diff
changeset
|
4961 |
restore the dirstate at the time of the last transaction, losing |
8856
f8d00346a62d
rollback: minor clarification (issue828)
Matt Mackall <mpm@selenic.com>
parents:
8855
diff
changeset
|
4962 |
any dirstate changes since that time. This command does not alter |
f8d00346a62d
rollback: minor clarification (issue828)
Matt Mackall <mpm@selenic.com>
parents:
8855
diff
changeset
|
4963 |
the working directory. |
2227
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
4964 |
|
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
4965 |
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
|
4966 |
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
|
4967 |
repository. For example, the following commands are transactional, |
9893
af873901b575
commands, dates: use real lists instead of literal blocks
Martin Geisler <mg@lazybytes.net>
parents:
9892
diff
changeset
|
4968 |
and their effects can be rolled back: |
af873901b575
commands, dates: use real lists instead of literal blocks
Martin Geisler <mg@lazybytes.net>
parents:
9892
diff
changeset
|
4969 |
|
af873901b575
commands, dates: use real lists instead of literal blocks
Martin Geisler <mg@lazybytes.net>
parents:
9892
diff
changeset
|
4970 |
- commit |
af873901b575
commands, dates: use real lists instead of literal blocks
Martin Geisler <mg@lazybytes.net>
parents:
9892
diff
changeset
|
4971 |
- import |
af873901b575
commands, dates: use real lists instead of literal blocks
Martin Geisler <mg@lazybytes.net>
parents:
9892
diff
changeset
|
4972 |
- pull |
10376 | 4973 |
- push (with this repository as the destination) |
9893
af873901b575
commands, dates: use real lists instead of literal blocks
Martin Geisler <mg@lazybytes.net>
parents:
9892
diff
changeset
|
4974 |
- unbundle |
2227
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
4975 |
|
15744
5a20115e7397
rollback: clarify --force text (issue3175)
Matt Mackall <mpm@selenic.com>
parents:
15701
diff
changeset
|
4976 |
To avoid permanent data loss, rollback will refuse to rollback a |
5a20115e7397
rollback: clarify --force text (issue3175)
Matt Mackall <mpm@selenic.com>
parents:
15701
diff
changeset
|
4977 |
commit transaction if it isn't checked out. Use --force to |
5a20115e7397
rollback: clarify --force text (issue3175)
Matt Mackall <mpm@selenic.com>
parents:
15701
diff
changeset
|
4978 |
override this protection. |
15183
59e8bc22506e
rollback: avoid unsafe rollback when not at tip (issue2998)
Greg Ward <greg@gerg.ca>
parents:
15179
diff
changeset
|
4979 |
|
2227
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
4980 |
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
|
4981 |
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
|
4982 |
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
|
4983 |
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
|
4984 |
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
|
4985 |
may fail if a rollback is performed. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4986 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4987 |
Returns 0 on success, 1 if no rollback data is available. |
2227
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
4988 |
""" |
15183
59e8bc22506e
rollback: avoid unsafe rollback when not at tip (issue2998)
Greg Ward <greg@gerg.ca>
parents:
15179
diff
changeset
|
4989 |
return repo.rollback(dryrun=opts.get('dry_run'), |
59e8bc22506e
rollback: avoid unsafe rollback when not at tip (issue2998)
Greg Ward <greg@gerg.ca>
parents:
15179
diff
changeset
|
4990 |
force=opts.get('force')) |
2227
4f072bb06e89
deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2212
diff
changeset
|
4991 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
4992 |
@command('root', []) |
468 | 4993 |
def root(ui, repo): |
8026
683d8ebcf434
expand "dir" to "directory" in help texts
Martin Geisler <mg@lazybytes.net>
parents:
8021
diff
changeset
|
4994 |
"""print the root (top) of the current working directory |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4995 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4996 |
Print the root directory of the current repository. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4997 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
4998 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
4999 |
""" |
468 | 5000 |
ui.write(repo.root + "\n") |
5001 |
||
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5002 |
@command('^serve', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5003 |
[('A', 'accesslog', '', _('name of access log file to write to'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5004 |
_('FILE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5005 |
('d', 'daemon', None, _('run server in background')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5006 |
('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('NUM')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5007 |
('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5008 |
# use string type, then we can check if something was passed |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5009 |
('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5010 |
('a', 'address', '', _('address to listen on (default: all interfaces)'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5011 |
_('ADDR')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5012 |
('', 'prefix', '', _('prefix path to serve from (default: server root)'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5013 |
_('PREFIX')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5014 |
('n', 'name', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5015 |
_('name to show in web pages (default: working directory)'), _('NAME')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5016 |
('', 'web-conf', '', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5017 |
_('name of the hgweb config file (see "hg help hgweb")'), _('FILE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5018 |
('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5019 |
_('FILE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5020 |
('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5021 |
('', 'stdio', None, _('for remote clients')), |
14647
2e9f379de0ac
serve: add --cmdserver option to communicate with hg over a pipe
Idan Kamara <idankk86@gmail.com>
parents:
14645
diff
changeset
|
5022 |
('', 'cmdserver', '', _('for remote clients'), _('MODE')), |
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5023 |
('t', 'templates', '', _('web templates to use'), _('TEMPLATE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5024 |
('', 'style', '', _('template style to use'), _('STYLE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5025 |
('6', 'ipv6', None, _('use IPv6 in addition to IPv4')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5026 |
('', 'certificate', '', _('SSL certificate file'), _('FILE'))], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5027 |
_('[OPTION]...')) |
245 | 5028 |
def serve(ui, repo, **opts): |
10889
e25c450c351e
commands: improve some command summaries
Matt Mackall <mpm@selenic.com>
parents:
10882
diff
changeset
|
5029 |
"""start stand-alone webserver |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5030 |
|
11102
275198bc904a
commands: explain that "hg serve" is mostly for ad-hoc sharing
Martin Geisler <mg@lazybytes.net>
parents:
11089
diff
changeset
|
5031 |
Start a local HTTP repository browser and pull server. You can use |
13065
de4a18cbfc98
serve: fix doc typo
Adrian Buehlmann <adrian@cadifra.com>
parents:
12965
diff
changeset
|
5032 |
this for ad-hoc sharing and browsing of repositories. It is |
11102
275198bc904a
commands: explain that "hg serve" is mostly for ad-hoc sharing
Martin Geisler <mg@lazybytes.net>
parents:
11089
diff
changeset
|
5033 |
recommended to use a real web server to serve a repository for |
275198bc904a
commands: explain that "hg serve" is mostly for ad-hoc sharing
Martin Geisler <mg@lazybytes.net>
parents:
11089
diff
changeset
|
5034 |
longer periods of time. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5035 |
|
11103
d29bd98ebff6
commands: explain that "hg serve" does not do authentication
Martin Geisler <mg@lazybytes.net>
parents:
11102
diff
changeset
|
5036 |
Please note that the server does not implement access control. |
d29bd98ebff6
commands: explain that "hg serve" does not do authentication
Martin Geisler <mg@lazybytes.net>
parents:
11102
diff
changeset
|
5037 |
This means that, by default, anybody can read from the server and |
d29bd98ebff6
commands: explain that "hg serve" does not do authentication
Martin Geisler <mg@lazybytes.net>
parents:
11102
diff
changeset
|
5038 |
nobody can write to it by default. Set the ``web.allow_push`` |
d29bd98ebff6
commands: explain that "hg serve" does not do authentication
Martin Geisler <mg@lazybytes.net>
parents:
11102
diff
changeset
|
5039 |
option to ``*`` to allow everybody to push to the server. You |
d29bd98ebff6
commands: explain that "hg serve" does not do authentication
Martin Geisler <mg@lazybytes.net>
parents:
11102
diff
changeset
|
5040 |
should use a real web server if you need to authenticate users. |
d29bd98ebff6
commands: explain that "hg serve" does not do authentication
Martin Geisler <mg@lazybytes.net>
parents:
11102
diff
changeset
|
5041 |
|
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5042 |
By default, the server logs accesses to stdout and errors to |
8277
b9403042968a
write options in "-r/--rev" style in help texts
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
5043 |
stderr. Use the -A/--accesslog and -E/--errorlog options to log to |
b9403042968a
write options in "-r/--rev" style in help texts
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
5044 |
files. |
10629
d3f27d15c9cb
serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents:
10617
diff
changeset
|
5045 |
|
d3f27d15c9cb
serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents:
10617
diff
changeset
|
5046 |
To have the server choose a free port number to listen on, specify |
d3f27d15c9cb
serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents:
10617
diff
changeset
|
5047 |
a port number of 0; in this case, the server will print the port |
d3f27d15c9cb
serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents:
10617
diff
changeset
|
5048 |
number it uses. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5049 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5050 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5051 |
""" |
624
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
618
diff
changeset
|
5052 |
|
14647
2e9f379de0ac
serve: add --cmdserver option to communicate with hg over a pipe
Idan Kamara <idankk86@gmail.com>
parents:
14645
diff
changeset
|
5053 |
if opts["stdio"] and opts["cmdserver"]: |
2e9f379de0ac
serve: add --cmdserver option to communicate with hg over a pipe
Idan Kamara <idankk86@gmail.com>
parents:
14645
diff
changeset
|
5054 |
raise util.Abort(_("cannot use --stdio with --cmdserver")) |
2e9f379de0ac
serve: add --cmdserver option to communicate with hg over a pipe
Idan Kamara <idankk86@gmail.com>
parents:
14645
diff
changeset
|
5055 |
|
2e9f379de0ac
serve: add --cmdserver option to communicate with hg over a pipe
Idan Kamara <idankk86@gmail.com>
parents:
14645
diff
changeset
|
5056 |
def checkrepo(): |
2127
8a85dbbadddf
Allow 'hg serve --webdir-conf foo' to be run outside a repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2125
diff
changeset
|
5057 |
if repo is None: |
7637 | 5058 |
raise error.RepoError(_("There is no Mercurial repository here" |
6217
fe8dbbe9520d
Avoid importing mercurial.node/mercurial.repo stuff from mercurial.hg
Joel Rosdahl <joel@rosdahl.net>
parents:
6212
diff
changeset
|
5059 |
" (.hg not found)")) |
14647
2e9f379de0ac
serve: add --cmdserver option to communicate with hg over a pipe
Idan Kamara <idankk86@gmail.com>
parents:
14645
diff
changeset
|
5060 |
|
2e9f379de0ac
serve: add --cmdserver option to communicate with hg over a pipe
Idan Kamara <idankk86@gmail.com>
parents:
14645
diff
changeset
|
5061 |
if opts["stdio"]: |
2e9f379de0ac
serve: add --cmdserver option to communicate with hg over a pipe
Idan Kamara <idankk86@gmail.com>
parents:
14645
diff
changeset
|
5062 |
checkrepo() |
2396
8d44649df03b
refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2392
diff
changeset
|
5063 |
s = sshserver.sshserver(ui, repo) |
8d44649df03b
refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2392
diff
changeset
|
5064 |
s.serve_forever() |
2363
fa4c11751367
Give a response to unknown SSH commands
Matt Mackall <mpm@selenic.com>
parents:
2362
diff
changeset
|
5065 |
|
14647
2e9f379de0ac
serve: add --cmdserver option to communicate with hg over a pipe
Idan Kamara <idankk86@gmail.com>
parents:
14645
diff
changeset
|
5066 |
if opts["cmdserver"]: |
2e9f379de0ac
serve: add --cmdserver option to communicate with hg over a pipe
Idan Kamara <idankk86@gmail.com>
parents:
14645
diff
changeset
|
5067 |
checkrepo() |
2e9f379de0ac
serve: add --cmdserver option to communicate with hg over a pipe
Idan Kamara <idankk86@gmail.com>
parents:
14645
diff
changeset
|
5068 |
s = commandserver.server(ui, repo, opts["cmdserver"]) |
2e9f379de0ac
serve: add --cmdserver option to communicate with hg over a pipe
Idan Kamara <idankk86@gmail.com>
parents:
14645
diff
changeset
|
5069 |
return s.serve() |
2e9f379de0ac
serve: add --cmdserver option to communicate with hg over a pipe
Idan Kamara <idankk86@gmail.com>
parents:
14645
diff
changeset
|
5070 |
|
10635
27027bee318e
serve: fix port config
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10632
diff
changeset
|
5071 |
# this way we can check if something was given in the command-line |
27027bee318e
serve: fix port config
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10632
diff
changeset
|
5072 |
if opts.get('port'): |
12076
49463314c24f
mail/hgweb: support service names for ports (issue2350)
Brodie Rao <brodie@bitheap.org>
parents:
12070
diff
changeset
|
5073 |
opts['port'] = util.getport(opts.get('port')) |
10635
27027bee318e
serve: fix port config
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10632
diff
changeset
|
5074 |
|
8190
9b8ac5fb7760
ui: kill most users of parentui name and arg, replace with .copy()
Matt Mackall <mpm@selenic.com>
parents:
8189
diff
changeset
|
5075 |
baseui = repo and repo.baseui or ui |
5835
bd34f0ac3cb0
adding "prefix" option to "hg serve" (command line and [web] section)
Michele Cella <michele.cella@gmail.com>
parents:
5811
diff
changeset
|
5076 |
optlist = ("name templates style address port prefix ipv6" |
10644
63948e7d37f7
server: initialize wsgi app in command, then wrap server around it
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
10635
diff
changeset
|
5077 |
" accesslog errorlog certificate encoding") |
987 | 5078 |
for o in optlist.split(): |
10630
9947e6b008bb
serve: fix options recording, trailing whitespace
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10629
diff
changeset
|
5079 |
val = opts.get(o, '') |
10631
5247260cee6a
make expression shorter, now the line fits into 80 chars
Thomas Arendsen Hein <thomas@intevation.de>
parents:
10630
diff
changeset
|
5080 |
if val in (None, ''): # should check against default options instead |
10630
9947e6b008bb
serve: fix options recording, trailing whitespace
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10629
diff
changeset
|
5081 |
continue |
9947e6b008bb
serve: fix options recording, trailing whitespace
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10629
diff
changeset
|
5082 |
baseui.setconfig("web", o, val) |
9947e6b008bb
serve: fix options recording, trailing whitespace
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10629
diff
changeset
|
5083 |
if repo and repo.ui != baseui: |
9947e6b008bb
serve: fix options recording, trailing whitespace
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10629
diff
changeset
|
5084 |
repo.ui.setconfig("web", o, val) |
987 | 5085 |
|
11003
aca9a7cf2c9a
serve: webdir_conf -> webconf
Matt Mackall <mpm@selenic.com>
parents:
10993
diff
changeset
|
5086 |
o = opts.get('web_conf') or opts.get('webdir_conf') |
11004
7bb10d3dbcd6
hgweb: unify hgweb calls in serve
Matt Mackall <mpm@selenic.com>
parents:
11003
diff
changeset
|
5087 |
if not o: |
7bb10d3dbcd6
hgweb: unify hgweb calls in serve
Matt Mackall <mpm@selenic.com>
parents:
11003
diff
changeset
|
5088 |
if not repo: |
7bb10d3dbcd6
hgweb: unify hgweb calls in serve
Matt Mackall <mpm@selenic.com>
parents:
11003
diff
changeset
|
5089 |
raise error.RepoError(_("There is no Mercurial repository" |
7bb10d3dbcd6
hgweb: unify hgweb calls in serve
Matt Mackall <mpm@selenic.com>
parents:
11003
diff
changeset
|
5090 |
" here (.hg not found)")) |
7bb10d3dbcd6
hgweb: unify hgweb calls in serve
Matt Mackall <mpm@selenic.com>
parents:
11003
diff
changeset
|
5091 |
o = repo.root |
7bb10d3dbcd6
hgweb: unify hgweb calls in serve
Matt Mackall <mpm@selenic.com>
parents:
11003
diff
changeset
|
5092 |
|
7bb10d3dbcd6
hgweb: unify hgweb calls in serve
Matt Mackall <mpm@selenic.com>
parents:
11003
diff
changeset
|
5093 |
app = hgweb.hgweb(o, baseui=ui) |
2127
8a85dbbadddf
Allow 'hg serve --webdir-conf foo' to be run outside a repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2125
diff
changeset
|
5094 |
|
8778
c5f36402daad
use new style classes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8761
diff
changeset
|
5095 |
class service(object): |
4380
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4376
diff
changeset
|
5096 |
def init(self): |
14237
4d684d8210a1
rename util.set_signal_handler to setsignalhandler
Adrian Buehlmann <adrian@cadifra.com>
parents:
14220
diff
changeset
|
5097 |
util.setsignalhandler() |
11004
7bb10d3dbcd6
hgweb: unify hgweb calls in serve
Matt Mackall <mpm@selenic.com>
parents:
11003
diff
changeset
|
5098 |
self.httpd = hgweb.server.create_server(ui, app) |
4380
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4376
diff
changeset
|
5099 |
|
10629
d3f27d15c9cb
serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents:
10617
diff
changeset
|
5100 |
if opts['port'] and not ui.verbose: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10270
diff
changeset
|
5101 |
return |
4380
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4376
diff
changeset
|
5102 |
|
5970
f25070ecf334
hgweb: fixes to make hg serve prefix handling more robust
Michele Cella <michele.cella@gmail.com>
parents:
5953
diff
changeset
|
5103 |
if self.httpd.prefix: |
f25070ecf334
hgweb: fixes to make hg serve prefix handling more robust
Michele Cella <michele.cella@gmail.com>
parents:
5953
diff
changeset
|
5104 |
prefix = self.httpd.prefix.strip('/') + '/' |
f25070ecf334
hgweb: fixes to make hg serve prefix handling more robust
Michele Cella <michele.cella@gmail.com>
parents:
5953
diff
changeset
|
5105 |
else: |
f25070ecf334
hgweb: fixes to make hg serve prefix handling more robust
Michele Cella <michele.cella@gmail.com>
parents:
5953
diff
changeset
|
5106 |
prefix = '' |
f25070ecf334
hgweb: fixes to make hg serve prefix handling more robust
Michele Cella <michele.cella@gmail.com>
parents:
5953
diff
changeset
|
5107 |
|
6262
de7256c82fad
hgweb: clarify which address and port can/cannot be bound at startup (bug 769)
Stephen Deasey <sdeasey@gmail.com>
parents:
6253
diff
changeset
|
5108 |
port = ':%d' % self.httpd.port |
de7256c82fad
hgweb: clarify which address and port can/cannot be bound at startup (bug 769)
Stephen Deasey <sdeasey@gmail.com>
parents:
6253
diff
changeset
|
5109 |
if port == ':80': |
de7256c82fad
hgweb: clarify which address and port can/cannot be bound at startup (bug 769)
Stephen Deasey <sdeasey@gmail.com>
parents:
6253
diff
changeset
|
5110 |
port = '' |
de7256c82fad
hgweb: clarify which address and port can/cannot be bound at startup (bug 769)
Stephen Deasey <sdeasey@gmail.com>
parents:
6253
diff
changeset
|
5111 |
|
6419
7c36aee46bf5
hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6405
diff
changeset
|
5112 |
bindaddr = self.httpd.addr |
7c36aee46bf5
hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6405
diff
changeset
|
5113 |
if bindaddr == '0.0.0.0': |
7c36aee46bf5
hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6405
diff
changeset
|
5114 |
bindaddr = '*' |
7c36aee46bf5
hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6405
diff
changeset
|
5115 |
elif ':' in bindaddr: # IPv6 |
7c36aee46bf5
hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6405
diff
changeset
|
5116 |
bindaddr = '[%s]' % bindaddr |
7c36aee46bf5
hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6405
diff
changeset
|
5117 |
|
7c36aee46bf5
hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6405
diff
changeset
|
5118 |
fqaddr = self.httpd.fqaddr |
7c36aee46bf5
hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6405
diff
changeset
|
5119 |
if ':' in fqaddr: |
7c36aee46bf5
hg serve: add clearer message when starting the server with --verbose
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6405
diff
changeset
|
5120 |
fqaddr = '[%s]' % fqaddr |
10629
d3f27d15c9cb
serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents:
10617
diff
changeset
|
5121 |
if opts['port']: |
10630
9947e6b008bb
serve: fix options recording, trailing whitespace
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10629
diff
changeset
|
5122 |
write = ui.status |
10629
d3f27d15c9cb
serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents:
10617
diff
changeset
|
5123 |
else: |
d3f27d15c9cb
serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents:
10617
diff
changeset
|
5124 |
write = ui.write |
d3f27d15c9cb
serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents:
10617
diff
changeset
|
5125 |
write(_('listening at http://%s%s/%s (bound to %s:%d)\n') % |
d3f27d15c9cb
serve: allow --port=0 to specify "server chooses the port number"
Bryan O'Sullivan <bos@serpentine.com>
parents:
10617
diff
changeset
|
5126 |
(fqaddr, port, prefix, bindaddr, self.httpd.port)) |
4380
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4376
diff
changeset
|
5127 |
|
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4376
diff
changeset
|
5128 |
def run(self): |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4376
diff
changeset
|
5129 |
self.httpd.serve_forever() |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4376
diff
changeset
|
5130 |
|
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4376
diff
changeset
|
5131 |
service = service() |
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4376
diff
changeset
|
5132 |
|
e89f9afc462b
Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4376
diff
changeset
|
5133 |
cmdutil.service(opts, initfn=service.init, runfn=service.run) |
500
ebc4714a7632
[PATCH] Clean up destination directory if a clone fails.
mpm@selenic.com
parents:
499
diff
changeset
|
5134 |
|
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5135 |
@command('showconfig|debugconfig', |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5136 |
[('u', 'untrusted', None, _('show untrusted configuration options'))], |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5137 |
_('[-u] [NAME]...')) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5138 |
def showconfig(ui, repo, *values, **opts): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5139 |
"""show combined config settings from all hgrc files |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5140 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5141 |
With no arguments, print names and values of all config items. |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5142 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5143 |
With one argument of the form section.name, print just the value |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5144 |
of that config item. |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5145 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5146 |
With multiple arguments, print names and values of all config |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5147 |
items with matching section names. |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5148 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5149 |
With --debug, the source (filename and line number) is printed |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5150 |
for each config item. |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5151 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5152 |
Returns 0 on success. |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5153 |
""" |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5154 |
|
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5155 |
for f in scmutil.rcpath(): |
14708
8083f4d00bd1
i18n: remove translation of debug messages
David Soria Parra <dsp@php.net>
parents:
14673
diff
changeset
|
5156 |
ui.debug('read config from: %s\n' % f) |
14302
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5157 |
untrusted = bool(opts.get('untrusted')) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5158 |
if values: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5159 |
sections = [v for v in values if '.' not in v] |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5160 |
items = [v for v in values if '.' in v] |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5161 |
if len(items) > 1 or items and sections: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5162 |
raise util.Abort(_('only one config item permitted')) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5163 |
for section, name, value in ui.walkconfig(untrusted=untrusted): |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5164 |
value = str(value).replace('\n', '\\n') |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5165 |
sectname = section + '.' + name |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5166 |
if values: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5167 |
for v in values: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5168 |
if v == section: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5169 |
ui.debug('%s: ' % |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5170 |
ui.configsource(section, name, untrusted)) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5171 |
ui.write('%s=%s\n' % (sectname, value)) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5172 |
elif v == sectname: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5173 |
ui.debug('%s: ' % |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5174 |
ui.configsource(section, name, untrusted)) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5175 |
ui.write(value, '\n') |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5176 |
else: |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5177 |
ui.debug('%s: ' % |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5178 |
ui.configsource(section, name, untrusted)) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5179 |
ui.write('%s=%s\n' % (sectname, value)) |
b0f97b2589cc
order commands alphabetically
Sune Foldager <cryo@cyanite.org>
parents:
14297
diff
changeset
|
5180 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5181 |
@command('^status|st', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5182 |
[('A', 'all', None, _('show status of all files')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5183 |
('m', 'modified', None, _('show only modified files')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5184 |
('a', 'added', None, _('show only added files')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5185 |
('r', 'removed', None, _('show only removed files')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5186 |
('d', 'deleted', None, _('show only deleted (but tracked) files')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5187 |
('c', 'clean', None, _('show only files without changes')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5188 |
('u', 'unknown', None, _('show only unknown (not tracked) files')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5189 |
('i', 'ignored', None, _('show only ignored files')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5190 |
('n', 'no-status', None, _('hide status prefix')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5191 |
('C', 'copies', None, _('show source of copied files')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5192 |
('0', 'print0', None, _('end filenames with NUL, for use with xargs')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5193 |
('', 'rev', [], _('show difference from revision'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5194 |
('', 'change', '', _('list the changed files of a revision'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5195 |
] + walkopts + subrepoopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5196 |
_('[OPTION]... [FILE]...')) |
731
91ca3afab8e8
Add name matching to status command.
Bryan O'Sullivan <bos@serpentine.com>
parents:
729
diff
changeset
|
5197 |
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
|
5198 |
"""show changed files in the working directory |
213 | 5199 |
|
6448
cd3d49ffc6f6
Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents:
6442
diff
changeset
|
5200 |
Show status of files in the repository. If names are given, only |
cd3d49ffc6f6
Consistently 1 space after full stops in command doc strings
Christian Ebert <blacktrash@gmx.net>
parents:
6442
diff
changeset
|
5201 |
files that match are shown. Files that are clean or ignored or |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
5202 |
the source of a copy/move operation, are not listed unless |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
5203 |
-c/--clean, -i/--ignored, -C/--copies or -A/--all are given. |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
5204 |
Unless options described with "show only ..." are given, the |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
5205 |
options -mardu are used. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5206 |
|
6201
305d4450036a
Extend/correct acc40572da5b regarding -qA and ignored files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6200
diff
changeset
|
5207 |
Option -q/--quiet hides untracked (unknown and ignored) files |
8009
76e4c08a48ad
commands: fix typo on flag description
Wagner Bruna <wbruna@yahoo.com>
parents:
8008
diff
changeset
|
5208 |
unless explicitly requested with -u/--unknown or -i/--ignored. |
6200
acc40572da5b
'hg status -q' output skips non-tracked files.
Zoran Bosnjak <zoran.bosnjak@via.si>
parents:
6192
diff
changeset
|
5209 |
|
12390
aff4afdcfd2b
Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents:
12389
diff
changeset
|
5210 |
.. note:: |
aff4afdcfd2b
Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents:
12389
diff
changeset
|
5211 |
status may appear to disagree with diff if permissions have |
aff4afdcfd2b
Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents:
12389
diff
changeset
|
5212 |
changed or a merge has occurred. The standard diff format does |
aff4afdcfd2b
Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents:
12389
diff
changeset
|
5213 |
not report permission changes and diff only reports changes |
aff4afdcfd2b
Use more note admonitions in help texts
Christian Ebert <blacktrash@gmx.net>
parents:
12389
diff
changeset
|
5214 |
relative to one merge parent. |
3822
28134d82db9b
Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents:
3815
diff
changeset
|
5215 |
|
3467
2b3b703b3a2b
Add --rev option to status
Brendan Cully <brendan@kublai.com>
parents:
3465
diff
changeset
|
5216 |
If one revision is given, it is used as the base revision. |
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
5217 |
If two revisions are given, the differences between them are |
10014
54cd28258ea7
status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents:
9983
diff
changeset
|
5218 |
shown. The --change option can also be used as a shortcut to list |
54cd28258ea7
status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents:
9983
diff
changeset
|
5219 |
the changed files of a revision from its first parent. |
3467
2b3b703b3a2b
Add --rev option to status
Brendan Cully <brendan@kublai.com>
parents:
3465
diff
changeset
|
5220 |
|
9157
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9142
diff
changeset
|
5221 |
The codes used to show the status of files are:: |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9142
diff
changeset
|
5222 |
|
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9142
diff
changeset
|
5223 |
M = modified |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9142
diff
changeset
|
5224 |
A = added |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9142
diff
changeset
|
5225 |
R = removed |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9142
diff
changeset
|
5226 |
C = clean |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9142
diff
changeset
|
5227 |
! = missing (deleted by non-hg command, but still tracked) |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9142
diff
changeset
|
5228 |
? = not tracked |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9142
diff
changeset
|
5229 |
I = ignored |
9261667e9b82
commands: use minirst parser when displaying help
Martin Geisler <mg@lazybytes.net>
parents:
9142
diff
changeset
|
5230 |
= origin of the previous file listed as A (added) |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5231 |
|
15119
ac46a9cdf6e6
status: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15118
diff
changeset
|
5232 |
.. container:: verbose |
ac46a9cdf6e6
status: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15118
diff
changeset
|
5233 |
|
ac46a9cdf6e6
status: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15118
diff
changeset
|
5234 |
Examples: |
ac46a9cdf6e6
status: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15118
diff
changeset
|
5235 |
|
15633
dc5d1394ecd1
status: add missing ":" to help text
Martin Geisler <mg@lazybytes.net>
parents:
15615
diff
changeset
|
5236 |
- show changes in the working directory relative to a |
dc5d1394ecd1
status: add missing ":" to help text
Martin Geisler <mg@lazybytes.net>
parents:
15615
diff
changeset
|
5237 |
changeset:: |
15119
ac46a9cdf6e6
status: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15118
diff
changeset
|
5238 |
|
ac46a9cdf6e6
status: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15118
diff
changeset
|
5239 |
hg status --rev 9353 |
ac46a9cdf6e6
status: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15118
diff
changeset
|
5240 |
|
ac46a9cdf6e6
status: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15118
diff
changeset
|
5241 |
- show all changes including copies in an existing changeset:: |
ac46a9cdf6e6
status: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15118
diff
changeset
|
5242 |
|
ac46a9cdf6e6
status: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15118
diff
changeset
|
5243 |
hg status --copies --change 9353 |
ac46a9cdf6e6
status: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15118
diff
changeset
|
5244 |
|
ac46a9cdf6e6
status: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15118
diff
changeset
|
5245 |
- get a NUL separated list of added files, suitable for xargs:: |
ac46a9cdf6e6
status: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15118
diff
changeset
|
5246 |
|
ac46a9cdf6e6
status: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15118
diff
changeset
|
5247 |
hg status -an0 |
ac46a9cdf6e6
status: add some help examples
Matt Mackall <mpm@selenic.com>
parents:
15118
diff
changeset
|
5248 |
|
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5249 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5250 |
""" |
312 | 5251 |
|
10014
54cd28258ea7
status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents:
9983
diff
changeset
|
5252 |
revs = opts.get('rev') |
54cd28258ea7
status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents:
9983
diff
changeset
|
5253 |
change = opts.get('change') |
54cd28258ea7
status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents:
9983
diff
changeset
|
5254 |
|
54cd28258ea7
status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents:
9983
diff
changeset
|
5255 |
if revs and change: |
54cd28258ea7
status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents:
9983
diff
changeset
|
5256 |
msg = _('cannot specify --rev and --change at the same time') |
54cd28258ea7
status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents:
9983
diff
changeset
|
5257 |
raise util.Abort(msg) |
54cd28258ea7
status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents:
9983
diff
changeset
|
5258 |
elif change: |
15578
db0e277bdd37
status: support revsets with --change
Patrick Mezard <pmezard@gmail.com>
parents:
15528
diff
changeset
|
5259 |
node2 = scmutil.revsingle(repo, change, None).node() |
13878
a8d13ee0ce68
misc: replace .parents()[0] with p1()
Matt Mackall <mpm@selenic.com>
parents:
13855
diff
changeset
|
5260 |
node1 = repo[node2].p1().node() |
10014
54cd28258ea7
status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents:
9983
diff
changeset
|
5261 |
else: |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
5262 |
node1, node2 = scmutil.revpair(repo, revs) |
10014
54cd28258ea7
status: add the --change option to display files changed in a revision
Gilles Moris <gilles.moris@free.fr>
parents:
9983
diff
changeset
|
5263 |
|
1625
e1bcf7fa983f
correct the relative path when walking from a subdir
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1622
diff
changeset
|
5264 |
cwd = (pats and repo.getcwd()) or '' |
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
5265 |
end = opts.get('print0') and '\0' or '\n' |
6276
c93ca83a3354
status: find copies and renames beyond the working directory
Matt Mackall <mpm@selenic.com>
parents:
6262
diff
changeset
|
5266 |
copy = {} |
6605
bf2bf986ff87
status: refactor status command
Matt Mackall <mpm@selenic.com>
parents:
6603
diff
changeset
|
5267 |
states = 'modified added removed deleted unknown ignored clean'.split() |
7684
ee3364d3d859
status: make options optional (issue1481)
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7656
diff
changeset
|
5268 |
show = [k for k in states if opts.get(k)] |
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
5269 |
if opts.get('all'): |
6605
bf2bf986ff87
status: refactor status command
Matt Mackall <mpm@selenic.com>
parents:
6603
diff
changeset
|
5270 |
show += ui.quiet and (states[:4] + ['clean']) or states |
bf2bf986ff87
status: refactor status command
Matt Mackall <mpm@selenic.com>
parents:
6603
diff
changeset
|
5271 |
if not show: |
bf2bf986ff87
status: refactor status command
Matt Mackall <mpm@selenic.com>
parents:
6603
diff
changeset
|
5272 |
show = ui.quiet and states[:4] or states[:5] |
bf2bf986ff87
status: refactor status command
Matt Mackall <mpm@selenic.com>
parents:
6603
diff
changeset
|
5273 |
|
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14647
diff
changeset
|
5274 |
stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts), |
12166
441a74b8def1
status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12132
diff
changeset
|
5275 |
'ignored' in show, 'clean' in show, 'unknown' in show, |
441a74b8def1
status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12132
diff
changeset
|
5276 |
opts.get('subrepos')) |
6605
bf2bf986ff87
status: refactor status command
Matt Mackall <mpm@selenic.com>
parents:
6603
diff
changeset
|
5277 |
changestates = zip(states, 'MAR!?IC', stat) |
bf2bf986ff87
status: refactor status command
Matt Mackall <mpm@selenic.com>
parents:
6603
diff
changeset
|
5278 |
|
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
5279 |
if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'): |
15775
91eb4512edd0
copies: rewrite copy detection for non-merge users
Matt Mackall <mpm@selenic.com>
parents:
15774
diff
changeset
|
5280 |
copy = copies.pathcopies(repo[node1], repo[node2]) |
6276
c93ca83a3354
status: find copies and renames beyond the working directory
Matt Mackall <mpm@selenic.com>
parents:
6262
diff
changeset
|
5281 |
|
16136
68007f0557de
formatter: convert status command
Matt Mackall <mpm@selenic.com>
parents:
16109
diff
changeset
|
5282 |
fm = ui.formatter('status', opts) |
68007f0557de
formatter: convert status command
Matt Mackall <mpm@selenic.com>
parents:
16109
diff
changeset
|
5283 |
format = '%s %s' + end |
68007f0557de
formatter: convert status command
Matt Mackall <mpm@selenic.com>
parents:
16109
diff
changeset
|
5284 |
if opts.get('no_status'): |
68007f0557de
formatter: convert status command
Matt Mackall <mpm@selenic.com>
parents:
16109
diff
changeset
|
5285 |
format = '%.0s%s' + end |
68007f0557de
formatter: convert status command
Matt Mackall <mpm@selenic.com>
parents:
16109
diff
changeset
|
5286 |
|
6605
bf2bf986ff87
status: refactor status command
Matt Mackall <mpm@selenic.com>
parents:
6603
diff
changeset
|
5287 |
for state, char, files in changestates: |
bf2bf986ff87
status: refactor status command
Matt Mackall <mpm@selenic.com>
parents:
6603
diff
changeset
|
5288 |
if state in show: |
16136
68007f0557de
formatter: convert status command
Matt Mackall <mpm@selenic.com>
parents:
16109
diff
changeset
|
5289 |
label = 'status.' + state |
6605
bf2bf986ff87
status: refactor status command
Matt Mackall <mpm@selenic.com>
parents:
6603
diff
changeset
|
5290 |
for f in files: |
16136
68007f0557de
formatter: convert status command
Matt Mackall <mpm@selenic.com>
parents:
16109
diff
changeset
|
5291 |
fm.startitem() |
16142
7ee1d0dd7ca3
status: fix format field thinko
Matt Mackall <mpm@selenic.com>
parents:
16136
diff
changeset
|
5292 |
fm.write("status path", format, char, |
16136
68007f0557de
formatter: convert status command
Matt Mackall <mpm@selenic.com>
parents:
16109
diff
changeset
|
5293 |
repo.pathto(f, cwd), label=label) |
6605
bf2bf986ff87
status: refactor status command
Matt Mackall <mpm@selenic.com>
parents:
6603
diff
changeset
|
5294 |
if f in copy: |
16136
68007f0557de
formatter: convert status command
Matt Mackall <mpm@selenic.com>
parents:
16109
diff
changeset
|
5295 |
fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd), |
10817
2096496b40ec
status: make use of output labeling
Brodie Rao <brodie@bitheap.org>
parents:
10816
diff
changeset
|
5296 |
label='status.copied') |
16136
68007f0557de
formatter: convert status command
Matt Mackall <mpm@selenic.com>
parents:
16109
diff
changeset
|
5297 |
fm.end() |
213 | 5298 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5299 |
@command('^summary|sum', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5300 |
[('', 'remote', None, _('check for push and pull'))], '[--remote]') |
9620 | 5301 |
def summary(ui, repo, **opts): |
9603 | 5302 |
"""summarize working directory state |
5303 |
||
5304 |
This generates a brief summary of the working directory state, |
|
5305 |
including parents, branch, commit status, and available updates. |
|
9620 | 5306 |
|
5307 |
With the --remote option, this will check the default paths for |
|
5308 |
incoming and outgoing changes. This can be time-consuming. |
|
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5309 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5310 |
Returns 0 on success. |
9603 | 5311 |
""" |
5312 |
||
5313 |
ctx = repo[None] |
|
5314 |
parents = ctx.parents() |
|
5315 |
pnode = parents[0].node() |
|
14906
7c3c8f37e84f
summary: show bookmarks separate from tags and note active mark (issue2892)
Augie Fackler <durin42@gmail.com>
parents:
14874
diff
changeset
|
5316 |
marks = [] |
9603 | 5317 |
|
5318 |
for p in parents: |
|
10832
420bc8124904
summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents:
10830
diff
changeset
|
5319 |
# label with log.changeset (instead of log.parent) since this |
420bc8124904
summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents:
10830
diff
changeset
|
5320 |
# shows a working directory parent *changeset*: |
420bc8124904
summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents:
10830
diff
changeset
|
5321 |
ui.write(_('parent: %d:%s ') % (p.rev(), str(p)), |
420bc8124904
summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents:
10830
diff
changeset
|
5322 |
label='log.changeset') |
10833
d7b601f1e02c
commands: retrieve tags from context object
Martin Geisler <mg@lazybytes.net>
parents:
10832
diff
changeset
|
5323 |
ui.write(' '.join(p.tags()), label='log.tag') |
13454
afc84a879ac8
summary: add bookmarks to summary
David Soria Parra <dsp@php.net>
parents:
13453
diff
changeset
|
5324 |
if p.bookmarks(): |
14906
7c3c8f37e84f
summary: show bookmarks separate from tags and note active mark (issue2892)
Augie Fackler <durin42@gmail.com>
parents:
14874
diff
changeset
|
5325 |
marks.extend(p.bookmarks()) |
9618
d75a309a24b1
summary: add empty repository and no revision checked out hints
Matt Mackall <mpm@selenic.com>
parents:
9617
diff
changeset
|
5326 |
if p.rev() == -1: |
d75a309a24b1
summary: add empty repository and no revision checked out hints
Matt Mackall <mpm@selenic.com>
parents:
9617
diff
changeset
|
5327 |
if not len(repo): |
10834
4ab459a6c25c
commands: small refactoring in summary
Martin Geisler <mg@lazybytes.net>
parents:
10833
diff
changeset
|
5328 |
ui.write(_(' (empty repository)')) |
9618
d75a309a24b1
summary: add empty repository and no revision checked out hints
Matt Mackall <mpm@selenic.com>
parents:
9617
diff
changeset
|
5329 |
else: |
10834
4ab459a6c25c
commands: small refactoring in summary
Martin Geisler <mg@lazybytes.net>
parents:
10833
diff
changeset
|
5330 |
ui.write(_(' (no revision checked out)')) |
10832
420bc8124904
summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents:
10830
diff
changeset
|
5331 |
ui.write('\n') |
9618
d75a309a24b1
summary: add empty repository and no revision checked out hints
Matt Mackall <mpm@selenic.com>
parents:
9617
diff
changeset
|
5332 |
if p.description(): |
10832
420bc8124904
summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents:
10830
diff
changeset
|
5333 |
ui.status(' ' + p.description().splitlines()[0].strip() + '\n', |
420bc8124904
summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents:
10830
diff
changeset
|
5334 |
label='log.summary') |
9603 | 5335 |
|
5336 |
branch = ctx.branch() |
|
5337 |
bheads = repo.branchheads(branch) |
|
9873
541218fbad2a
summary: note non-default branches with -q
Matt Mackall <mpm@selenic.com>
parents:
9857
diff
changeset
|
5338 |
m = _('branch: %s\n') % branch |
541218fbad2a
summary: note non-default branches with -q
Matt Mackall <mpm@selenic.com>
parents:
9857
diff
changeset
|
5339 |
if branch != 'default': |
10832
420bc8124904
summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents:
10830
diff
changeset
|
5340 |
ui.write(m, label='log.branch') |
9873
541218fbad2a
summary: note non-default branches with -q
Matt Mackall <mpm@selenic.com>
parents:
9857
diff
changeset
|
5341 |
else: |
10832
420bc8124904
summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents:
10830
diff
changeset
|
5342 |
ui.status(m, label='log.branch') |
9603 | 5343 |
|
14906
7c3c8f37e84f
summary: show bookmarks separate from tags and note active mark (issue2892)
Augie Fackler <durin42@gmail.com>
parents:
14874
diff
changeset
|
5344 |
if marks: |
7c3c8f37e84f
summary: show bookmarks separate from tags and note active mark (issue2892)
Augie Fackler <durin42@gmail.com>
parents:
14874
diff
changeset
|
5345 |
current = repo._bookmarkcurrent |
14907
84af56cc673b
summary: allow color to highlight active bookmark
Augie Fackler <durin42@gmail.com>
parents:
14906
diff
changeset
|
5346 |
ui.write(_('bookmarks:'), label='log.bookmark') |
14906
7c3c8f37e84f
summary: show bookmarks separate from tags and note active mark (issue2892)
Augie Fackler <durin42@gmail.com>
parents:
14874
diff
changeset
|
5347 |
if current is not None: |
7c3c8f37e84f
summary: show bookmarks separate from tags and note active mark (issue2892)
Augie Fackler <durin42@gmail.com>
parents:
14874
diff
changeset
|
5348 |
try: |
7c3c8f37e84f
summary: show bookmarks separate from tags and note active mark (issue2892)
Augie Fackler <durin42@gmail.com>
parents:
14874
diff
changeset
|
5349 |
marks.remove(current) |
14907
84af56cc673b
summary: allow color to highlight active bookmark
Augie Fackler <durin42@gmail.com>
parents:
14906
diff
changeset
|
5350 |
ui.write(' *' + current, label='bookmarks.current') |
14906
7c3c8f37e84f
summary: show bookmarks separate from tags and note active mark (issue2892)
Augie Fackler <durin42@gmail.com>
parents:
14874
diff
changeset
|
5351 |
except ValueError: |
7c3c8f37e84f
summary: show bookmarks separate from tags and note active mark (issue2892)
Augie Fackler <durin42@gmail.com>
parents:
14874
diff
changeset
|
5352 |
# current bookmark not in parent ctx marks |
7c3c8f37e84f
summary: show bookmarks separate from tags and note active mark (issue2892)
Augie Fackler <durin42@gmail.com>
parents:
14874
diff
changeset
|
5353 |
pass |
14907
84af56cc673b
summary: allow color to highlight active bookmark
Augie Fackler <durin42@gmail.com>
parents:
14906
diff
changeset
|
5354 |
for m in marks: |
84af56cc673b
summary: allow color to highlight active bookmark
Augie Fackler <durin42@gmail.com>
parents:
14906
diff
changeset
|
5355 |
ui.write(' ' + m, label='log.bookmark') |
84af56cc673b
summary: allow color to highlight active bookmark
Augie Fackler <durin42@gmail.com>
parents:
14906
diff
changeset
|
5356 |
ui.write('\n', label='log.bookmark') |
14906
7c3c8f37e84f
summary: show bookmarks separate from tags and note active mark (issue2892)
Augie Fackler <durin42@gmail.com>
parents:
14874
diff
changeset
|
5357 |
|
10390
f163775e36e0
summary: various fixes, add a test
Matt Mackall <mpm@selenic.com>
parents:
10389
diff
changeset
|
5358 |
st = list(repo.status(unknown=True))[:6] |
11088
c4347e48b0d0
summary: add subrepo status
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
5359 |
|
11331
997ab9af81df
summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
5360 |
c = repo.dirstate.copies() |
997ab9af81df
summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
5361 |
copied, renamed = [], [] |
997ab9af81df
summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
5362 |
for d, s in c.iteritems(): |
997ab9af81df
summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
5363 |
if s in st[2]: |
997ab9af81df
summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
5364 |
st[2].remove(s) |
997ab9af81df
summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
5365 |
renamed.append(d) |
997ab9af81df
summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
5366 |
else: |
997ab9af81df
summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
5367 |
copied.append(d) |
997ab9af81df
summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
5368 |
if d in st[1]: |
997ab9af81df
summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
5369 |
st[1].remove(d) |
997ab9af81df
summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
5370 |
st.insert(3, renamed) |
997ab9af81df
summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
5371 |
st.insert(4, copied) |
997ab9af81df
summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
5372 |
|
15856
6bed6cc6d0d0
commands: partial backout of fbb68b382040
Martin Geisler <mg@aragost.com>
parents:
15855
diff
changeset
|
5373 |
ms = mergemod.mergestate(repo) |
10390
f163775e36e0
summary: various fixes, add a test
Matt Mackall <mpm@selenic.com>
parents:
10389
diff
changeset
|
5374 |
st.append([f for f in ms if ms[f] == 'u']) |
11088
c4347e48b0d0
summary: add subrepo status
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
5375 |
|
c4347e48b0d0
summary: add subrepo status
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
5376 |
subs = [s for s in ctx.substate if ctx.sub(s).dirty()] |
c4347e48b0d0
summary: add subrepo status
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
5377 |
st.append(subs) |
c4347e48b0d0
summary: add subrepo status
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
5378 |
|
10832
420bc8124904
summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents:
10830
diff
changeset
|
5379 |
labels = [ui.label(_('%d modified'), 'status.modified'), |
420bc8124904
summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents:
10830
diff
changeset
|
5380 |
ui.label(_('%d added'), 'status.added'), |
420bc8124904
summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents:
10830
diff
changeset
|
5381 |
ui.label(_('%d removed'), 'status.removed'), |
11331
997ab9af81df
summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
5382 |
ui.label(_('%d renamed'), 'status.copied'), |
997ab9af81df
summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
5383 |
ui.label(_('%d copied'), 'status.copied'), |
10832
420bc8124904
summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents:
10830
diff
changeset
|
5384 |
ui.label(_('%d deleted'), 'status.deleted'), |
420bc8124904
summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents:
10830
diff
changeset
|
5385 |
ui.label(_('%d unknown'), 'status.unknown'), |
420bc8124904
summary: make use of output labeling
Eric Eisner <ede@mit.edu>
parents:
10830
diff
changeset
|
5386 |
ui.label(_('%d ignored'), 'status.ignored'), |
11088
c4347e48b0d0
summary: add subrepo status
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
5387 |
ui.label(_('%d unresolved'), 'resolve.unresolved'), |
c4347e48b0d0
summary: add subrepo status
Matt Mackall <mpm@selenic.com>
parents:
11078
diff
changeset
|
5388 |
ui.label(_('%d subrepos'), 'status.modified')] |
9603 | 5389 |
t = [] |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10270
diff
changeset
|
5390 |
for s, l in zip(st, labels): |
9607
8e0e0d854b60
commands: do not split a translated string
Martin Geisler <mg@lazybytes.net>
parents:
9603
diff
changeset
|
5391 |
if s: |
8e0e0d854b60
commands: do not split a translated string
Martin Geisler <mg@lazybytes.net>
parents:
9603
diff
changeset
|
5392 |
t.append(l % len(s)) |
9603 | 5393 |
|
5394 |
t = ', '.join(t) |
|
10269
acf001ee5ef8
summary: L10N messages hide clean-ness of workdir from 'hg summary'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
10263
diff
changeset
|
5395 |
cleanworkdir = False |
9603 | 5396 |
|
5397 |
if len(parents) > 1: |
|
11310
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
5398 |
t += _(' (merge)') |
9603 | 5399 |
elif branch != parents[0].branch(): |
11310
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
5400 |
t += _(' (new branch)') |
11165
e8915e19205a
summary: show if commit will be from a closed head
Gilles Moris <gilles.moris@free.fr>
parents:
11164
diff
changeset
|
5401 |
elif (parents[0].extra().get('close') and |
e8915e19205a
summary: show if commit will be from a closed head
Gilles Moris <gilles.moris@free.fr>
parents:
11164
diff
changeset
|
5402 |
pnode in repo.branchheads(branch, closed=True)): |
11310
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
5403 |
t += _(' (head closed)') |
11331
997ab9af81df
summary: report copies and renames
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
5404 |
elif not (st[0] or st[1] or st[2] or st[3] or st[4] or st[9]): |
11310
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
5405 |
t += _(' (clean)') |
10269
acf001ee5ef8
summary: L10N messages hide clean-ness of workdir from 'hg summary'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
10263
diff
changeset
|
5406 |
cleanworkdir = True |
9603 | 5407 |
elif pnode not in bheads: |
11310
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
5408 |
t += _(' (new branch head)') |
9603 | 5409 |
|
10269
acf001ee5ef8
summary: L10N messages hide clean-ness of workdir from 'hg summary'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
10263
diff
changeset
|
5410 |
if cleanworkdir: |
11310
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
5411 |
ui.status(_('commit: %s\n') % t.strip()) |
9605 | 5412 |
else: |
11310
ac873ecfc3c2
Backed out changeset: e1dde7363601
Steve Borho <steve@borho.org>
parents:
11302
diff
changeset
|
5413 |
ui.write(_('commit: %s\n') % t.strip()) |
9603 | 5414 |
|
5415 |
# all ancestors of branch heads - all ancestors of parent = new csets |
|
5416 |
new = [0] * len(repo) |
|
5417 |
cl = repo.changelog |
|
10390
f163775e36e0
summary: various fixes, add a test
Matt Mackall <mpm@selenic.com>
parents:
10389
diff
changeset
|
5418 |
for a in [cl.rev(n) for n in bheads]: |
f163775e36e0
summary: various fixes, add a test
Matt Mackall <mpm@selenic.com>
parents:
10389
diff
changeset
|
5419 |
new[a] = 1 |
9603 | 5420 |
for a in cl.ancestors(*[cl.rev(n) for n in bheads]): |
5421 |
new[a] = 1 |
|
10390
f163775e36e0
summary: various fixes, add a test
Matt Mackall <mpm@selenic.com>
parents:
10389
diff
changeset
|
5422 |
for a in [p.rev() for p in parents]: |
f163775e36e0
summary: various fixes, add a test
Matt Mackall <mpm@selenic.com>
parents:
10389
diff
changeset
|
5423 |
if a >= 0: |
f163775e36e0
summary: various fixes, add a test
Matt Mackall <mpm@selenic.com>
parents:
10389
diff
changeset
|
5424 |
new[a] = 0 |
9603 | 5425 |
for a in cl.ancestors(*[p.rev() for p in parents]): |
5426 |
new[a] = 0 |
|
5427 |
new = sum(new) |
|
5428 |
||
5429 |
if new == 0: |
|
9605 | 5430 |
ui.status(_('update: (current)\n')) |
9603 | 5431 |
elif pnode not in bheads: |
5432 |
ui.write(_('update: %d new changesets (update)\n') % new) |
|
5433 |
else: |
|
5434 |
ui.write(_('update: %d new changesets, %d branch heads (merge)\n') % |
|
5435 |
(new, len(bheads))) |
|
5436 |
||
9620 | 5437 |
if opts.get('remote'): |
5438 |
t = [] |
|
10389
6dc25b01e170
fix remaining hg.parseurl uses
Sune Foldager <cryo@cyanite.org>
parents:
10384
diff
changeset
|
5439 |
source, branches = hg.parseurl(ui.expandpath('default')) |
14556
517e1d88bf7e
hg: change various repository() users to use peer() where appropriate
Matt Mackall <mpm@selenic.com>
parents:
14553
diff
changeset
|
5440 |
other = hg.peer(repo, {}, source) |
10389
6dc25b01e170
fix remaining hg.parseurl uses
Sune Foldager <cryo@cyanite.org>
parents:
10384
diff
changeset
|
5441 |
revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) |
14076
924c82157d46
url: move URL parsing functions into util to improve startup time
Brodie Rao <brodie@bitheap.org>
parents:
14073
diff
changeset
|
5442 |
ui.debug('comparing with %s\n' % util.hidepassword(source)) |
9620 | 5443 |
repo.ui.pushbuffer() |
14214
c5db85676c38
summary: run discovery only once for in/out against same repo
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14213
diff
changeset
|
5444 |
commoninc = discovery.findcommonincoming(repo, other) |
c5db85676c38
summary: run discovery only once for in/out against same repo
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14213
diff
changeset
|
5445 |
_common, incoming, _rheads = commoninc |
9620 | 5446 |
repo.ui.popbuffer() |
5447 |
if incoming: |
|
5448 |
t.append(_('1 or more incoming')) |
|
5449 |
||
10389
6dc25b01e170
fix remaining hg.parseurl uses
Sune Foldager <cryo@cyanite.org>
parents:
10384
diff
changeset
|
5450 |
dest, branches = hg.parseurl(ui.expandpath('default-push', 'default')) |
6dc25b01e170
fix remaining hg.parseurl uses
Sune Foldager <cryo@cyanite.org>
parents:
10384
diff
changeset
|
5451 |
revs, checkout = hg.addbranchrevs(repo, repo, branches, None) |
14214
c5db85676c38
summary: run discovery only once for in/out against same repo
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14213
diff
changeset
|
5452 |
if source != dest: |
14556
517e1d88bf7e
hg: change various repository() users to use peer() where appropriate
Matt Mackall <mpm@selenic.com>
parents:
14553
diff
changeset
|
5453 |
other = hg.peer(repo, {}, dest) |
14214
c5db85676c38
summary: run discovery only once for in/out against same repo
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14213
diff
changeset
|
5454 |
commoninc = None |
c5db85676c38
summary: run discovery only once for in/out against same repo
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14213
diff
changeset
|
5455 |
ui.debug('comparing with %s\n' % util.hidepassword(dest)) |
9620 | 5456 |
repo.ui.pushbuffer() |
15837
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15836
diff
changeset
|
5457 |
outgoing = discovery.findcommonoutgoing(repo, other, |
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15836
diff
changeset
|
5458 |
commoninc=commoninc) |
9620 | 5459 |
repo.ui.popbuffer() |
15837
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15836
diff
changeset
|
5460 |
o = outgoing.missing |
9620 | 5461 |
if o: |
5462 |
t.append(_('%d outgoing') % len(o)) |
|
13454
afc84a879ac8
summary: add bookmarks to summary
David Soria Parra <dsp@php.net>
parents:
13453
diff
changeset
|
5463 |
if 'bookmarks' in other.listkeys('namespaces'): |
afc84a879ac8
summary: add bookmarks to summary
David Soria Parra <dsp@php.net>
parents:
13453
diff
changeset
|
5464 |
lmarks = repo.listkeys('bookmarks') |
afc84a879ac8
summary: add bookmarks to summary
David Soria Parra <dsp@php.net>
parents:
13453
diff
changeset
|
5465 |
rmarks = other.listkeys('bookmarks') |
afc84a879ac8
summary: add bookmarks to summary
David Soria Parra <dsp@php.net>
parents:
13453
diff
changeset
|
5466 |
diff = set(rmarks) - set(lmarks) |
afc84a879ac8
summary: add bookmarks to summary
David Soria Parra <dsp@php.net>
parents:
13453
diff
changeset
|
5467 |
if len(diff) > 0: |
afc84a879ac8
summary: add bookmarks to summary
David Soria Parra <dsp@php.net>
parents:
13453
diff
changeset
|
5468 |
t.append(_('%d incoming bookmarks') % len(diff)) |
afc84a879ac8
summary: add bookmarks to summary
David Soria Parra <dsp@php.net>
parents:
13453
diff
changeset
|
5469 |
diff = set(lmarks) - set(rmarks) |
afc84a879ac8
summary: add bookmarks to summary
David Soria Parra <dsp@php.net>
parents:
13453
diff
changeset
|
5470 |
if len(diff) > 0: |
afc84a879ac8
summary: add bookmarks to summary
David Soria Parra <dsp@php.net>
parents:
13453
diff
changeset
|
5471 |
t.append(_('%d outgoing bookmarks') % len(diff)) |
9620 | 5472 |
|
5473 |
if t: |
|
5474 |
ui.write(_('remote: %s\n') % (', '.join(t))) |
|
5475 |
else: |
|
5476 |
ui.status(_('remote: (synced)\n')) |
|
5477 |
||
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5478 |
@command('tag', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5479 |
[('f', 'force', None, _('force tag')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5480 |
('l', 'local', None, _('make the tag local')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5481 |
('r', 'rev', '', _('revision to tag'), _('REV')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5482 |
('', 'remove', None, _('remove a tag')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5483 |
# -l/--local is already there, commitopts cannot be used |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5484 |
('e', 'edit', None, _('edit commit message')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5485 |
('m', 'message', '', _('use <text> as commit message'), _('TEXT')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5486 |
] + commitopts2, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5487 |
_('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...')) |
6321
55ba3bc5b8fd
tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents:
6304
diff
changeset
|
5488 |
def tag(ui, repo, name1, *names, **opts): |
55ba3bc5b8fd
tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents:
6304
diff
changeset
|
5489 |
"""add one or more tags for the current or given revision |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5490 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5491 |
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
|
5492 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5493 |
Tags are used to name particular revisions of the repository and are |
6220
1939e29151ca
Fixed typo in tag help, found by John Coomes
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6217
diff
changeset
|
5494 |
very useful to compare different revisions, to go back to significant |
13135
1c1ca9d393f4
tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents:
13134
diff
changeset
|
5495 |
earlier versions or to mark branch points as releases, etc. Changing |
1c1ca9d393f4
tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents:
13134
diff
changeset
|
5496 |
an existing tag is normally disallowed; use -f/--force to override. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5497 |
|
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
5498 |
If no revision is given, the parent of the working directory is |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
5499 |
used, or tip 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
|
5500 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5501 |
To facilitate version control, distribution, and merging of tags, |
13135
1c1ca9d393f4
tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents:
13134
diff
changeset
|
5502 |
they are stored as a file named ".hgtags" which is managed similarly |
1c1ca9d393f4
tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents:
13134
diff
changeset
|
5503 |
to other project files and can be hand-edited if necessary. This |
1c1ca9d393f4
tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents:
13134
diff
changeset
|
5504 |
also means that tagging creates a new commit. The file |
1c1ca9d393f4
tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents:
13134
diff
changeset
|
5505 |
".hg/localtags" is used for local tags (not shared among |
1c1ca9d393f4
tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents:
13134
diff
changeset
|
5506 |
repositories). |
1c1ca9d393f4
tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents:
13134
diff
changeset
|
5507 |
|
1c1ca9d393f4
tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents:
13134
diff
changeset
|
5508 |
Tag commits are usually made at the head of a branch. If the parent |
1c1ca9d393f4
tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents:
13134
diff
changeset
|
5509 |
of the working directory is not a branch head, :hg:`tag` aborts; use |
1c1ca9d393f4
tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents:
13134
diff
changeset
|
5510 |
-f/--force to force the tag commit to be based on a non-head |
1c1ca9d393f4
tag: abort if not at a branch head (issue2552)
Kevin Bullock <kbullock@ringworld.org>
parents:
13134
diff
changeset
|
5511 |
changeset. |
6163
1f733c2f0165
Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6161
diff
changeset
|
5512 |
|
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
5513 |
See :hg:`help dates` for a list of formats valid for -d/--date. |
11063
eb23c876c111
tag: warn users about tag/branch possible name conflicts
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11061
diff
changeset
|
5514 |
|
eb23c876c111
tag: warn users about tag/branch possible name conflicts
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11061
diff
changeset
|
5515 |
Since tag names have priority over branch names during revision |
eb23c876c111
tag: warn users about tag/branch possible name conflicts
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11061
diff
changeset
|
5516 |
lookup, using an existing branch name as a tag name is discouraged. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5517 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5518 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5519 |
""" |
15877
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5520 |
wlock = lock = None |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5521 |
try: |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5522 |
wlock = repo.wlock() |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5523 |
lock = repo.lock() |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5524 |
rev_ = "." |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5525 |
names = [t.strip() for t in (name1,) + names] |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5526 |
if len(names) != len(set(names)): |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5527 |
raise util.Abort(_('tag names must be unique')) |
6321
55ba3bc5b8fd
tag: allow multiple tags to be added or removed
John Coomes <john.coomes@sun.com>
parents:
6304
diff
changeset
|
5528 |
for n in names: |
15877
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5529 |
if n in ['tip', '.', 'null']: |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5530 |
raise util.Abort(_("the name '%s' is reserved") % n) |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5531 |
if not n: |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5532 |
raise util.Abort(_('tag names cannot consist entirely of ' |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5533 |
'whitespace')) |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5534 |
if opts.get('rev') and opts.get('remove'): |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5535 |
raise util.Abort(_("--rev and --remove are incompatible")) |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5536 |
if opts.get('rev'): |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5537 |
rev_ = opts['rev'] |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5538 |
message = opts.get('message') |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5539 |
if opts.get('remove'): |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5540 |
expectedtype = opts.get('local') and 'local' or 'global' |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5541 |
for n in names: |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5542 |
if not repo.tagtype(n): |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5543 |
raise util.Abort(_("tag '%s' does not exist") % n) |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5544 |
if repo.tagtype(n) != expectedtype: |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5545 |
if expectedtype == 'global': |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5546 |
raise util.Abort(_("tag '%s' is not a global tag") % n) |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5547 |
else: |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5548 |
raise util.Abort(_("tag '%s' is not a local tag") % n) |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5549 |
rev_ = nullid |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5550 |
if not message: |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5551 |
# we don't translate commit messages |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5552 |
message = 'Removed tag %s' % ', '.join(names) |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5553 |
elif not opts.get('force'): |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5554 |
for n in names: |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5555 |
if n in repo.tags(): |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5556 |
raise util.Abort(_("tag '%s' already exists " |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5557 |
"(use -f to force)") % n) |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5558 |
if not opts.get('local'): |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5559 |
p1, p2 = repo.dirstate.parents() |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5560 |
if p2 != nullid: |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5561 |
raise util.Abort(_('uncommitted merge')) |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5562 |
bheads = repo.branchheads() |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5563 |
if not opts.get('force') and bheads and p1 not in bheads: |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5564 |
raise util.Abort(_('not at a branch head (use -f to force)')) |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5565 |
r = scmutil.revsingle(repo, rev_).node() |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5566 |
|
4213 | 5567 |
if not message: |
9183
d0225fa2f6c4
do not translate commit messages
Martin Geisler <mg@lazybytes.net>
parents:
9128
diff
changeset
|
5568 |
# we don't translate commit messages |
15877
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5569 |
message = ('Added tag %s for changeset %s' % |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5570 |
(', '.join(names), short(r))) |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5571 |
|
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5572 |
date = opts.get('date') |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5573 |
if date: |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5574 |
date = util.parsedate(date) |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5575 |
|
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5576 |
if opts.get('edit'): |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5577 |
message = ui.edit(message, ui.username()) |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5578 |
|
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5579 |
repo.tag(names, r, message, opts.get('local'), opts.get('user'), date) |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5580 |
finally: |
afd459933d5f
tag: lock before tagging
Mads Kiilerich <mads@kiilerich.com>
parents:
15875
diff
changeset
|
5581 |
release(lock, wlock) |
401
af4848f83e68
From: Radoslaw Szkodzinski <astralstorm@gorzow.mm.pl>
mpm@selenic.com
parents:
396
diff
changeset
|
5582 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5583 |
@command('tags', [], '') |
248 | 5584 |
def tags(ui, repo): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5585 |
"""list repository tags |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5586 |
|
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
5587 |
This lists both regular and local tags. When the -v/--verbose |
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
5588 |
switch is used, a third column "local" is printed for local tags. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5589 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5590 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5591 |
""" |
477
520540fd6b64
Handle errors in .hgtags or hgrc [tags] section more gracefully.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
470
diff
changeset
|
5592 |
|
2966
fb493241d7f6
Only show long hashes with --debug, not --verbose
Matt Mackall <mpm@selenic.com>
parents:
2963
diff
changeset
|
5593 |
hexfunc = ui.debugflag and hex or short |
5658
ae3089cefaab
Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents:
5657
diff
changeset
|
5594 |
tagtype = "" |
ae3089cefaab
Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents:
5657
diff
changeset
|
5595 |
|
8210
344751cd8cb8
replace various uses of list.reverse()
Matt Mackall <mpm@selenic.com>
parents:
8209
diff
changeset
|
5596 |
for t, n in reversed(repo.tagslist()): |
5658
ae3089cefaab
Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents:
5657
diff
changeset
|
5597 |
if ui.quiet: |
15047
ef43610a4cce
ui: use labels when outputting tags
Marc Simpson <marc@0branch.com>
parents:
15046
diff
changeset
|
5598 |
ui.write("%s\n" % t, label='tags.normal') |
5658
ae3089cefaab
Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents:
5657
diff
changeset
|
5599 |
continue |
ae3089cefaab
Add --verbose support to tags command.
Osku Salerma <osku@iki.fi>
parents:
5657
diff
changeset
|
5600 |
|
13893
1aea86673dee
tags: no need to check for valid nodes
Idan Kamara <idankk86@gmail.com>
parents:
13891
diff
changeset
|
5601 |
hn = hexfunc(n) |
1aea86673dee
tags: no need to check for valid nodes
Idan Kamara <idankk86@gmail.com>
parents:
13891
diff
changeset
|
5602 |
r = "%5d:%s" % (repo.changelog.rev(n), hn) |
15047
ef43610a4cce
ui: use labels when outputting tags
Marc Simpson <marc@0branch.com>
parents:
15046
diff
changeset
|
5603 |
rev = ui.label(r, 'log.changeset') |
13893
1aea86673dee
tags: no need to check for valid nodes
Idan Kamara <idankk86@gmail.com>
parents:
13891
diff
changeset
|
5604 |
spaces = " " * (30 - encoding.colwidth(t)) |
1aea86673dee
tags: no need to check for valid nodes
Idan Kamara <idankk86@gmail.com>
parents:
13891
diff
changeset
|
5605 |
|
15047
ef43610a4cce
ui: use labels when outputting tags
Marc Simpson <marc@0branch.com>
parents:
15046
diff
changeset
|
5606 |
tag = ui.label(t, 'tags.normal') |
13893
1aea86673dee
tags: no need to check for valid nodes
Idan Kamara <idankk86@gmail.com>
parents:
13891
diff
changeset
|
5607 |
if ui.verbose: |
1aea86673dee
tags: no need to check for valid nodes
Idan Kamara <idankk86@gmail.com>
parents:
13891
diff
changeset
|
5608 |
if repo.tagtype(t) == 'local': |
1aea86673dee
tags: no need to check for valid nodes
Idan Kamara <idankk86@gmail.com>
parents:
13891
diff
changeset
|
5609 |
tagtype = " local" |
15047
ef43610a4cce
ui: use labels when outputting tags
Marc Simpson <marc@0branch.com>
parents:
15046
diff
changeset
|
5610 |
tag = ui.label(t, 'tags.local') |
13893
1aea86673dee
tags: no need to check for valid nodes
Idan Kamara <idankk86@gmail.com>
parents:
13891
diff
changeset
|
5611 |
else: |
1aea86673dee
tags: no need to check for valid nodes
Idan Kamara <idankk86@gmail.com>
parents:
13891
diff
changeset
|
5612 |
tagtype = "" |
15047
ef43610a4cce
ui: use labels when outputting tags
Marc Simpson <marc@0branch.com>
parents:
15046
diff
changeset
|
5613 |
ui.write("%s%s %s%s\n" % (tag, spaces, rev, tagtype)) |
248 | 5614 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5615 |
@command('tip', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5616 |
[('p', 'patch', None, _('show patch')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5617 |
('g', 'git', None, _('use git extended diff format')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5618 |
] + templateopts, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5619 |
_('[-p] [-g]')) |
1731
251729df9cc6
add -p option to tip. for issue 64.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1728
diff
changeset
|
5620 |
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
|
5621 |
"""show the tip revision |
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5622 |
|
8779
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
5623 |
The tip revision (usually just called the tip) is the changeset |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
5624 |
most recently added to the repository (and therefore the most |
708938509732
Improve English for help text of many core hg commands.
timeless <timeless@gmail.com>
parents:
8778
diff
changeset
|
5625 |
recently changed head). |
6364
b22b39059722
Make tip help more helpful
Patrick Mezard <pmezard@gmail.com>
parents:
6353
diff
changeset
|
5626 |
|
6367
51984a2413f2
Remove unexpected "Alternately" word from tip help.
Patrick Mezard <pmezard@gmail.com>
parents:
6364
diff
changeset
|
5627 |
If you have just made a commit, that commit will be the tip. If |
51984a2413f2
Remove unexpected "Alternately" word from tip help.
Patrick Mezard <pmezard@gmail.com>
parents:
6364
diff
changeset
|
5628 |
you have just pulled changes from another repository, the tip of |
51984a2413f2
Remove unexpected "Alternately" word from tip help.
Patrick Mezard <pmezard@gmail.com>
parents:
6364
diff
changeset
|
5629 |
that repository becomes the current tip. The "tip" tag is special |
51984a2413f2
Remove unexpected "Alternately" word from tip help.
Patrick Mezard <pmezard@gmail.com>
parents:
6364
diff
changeset
|
5630 |
and cannot be renamed or assigned to a different changeset. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5631 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5632 |
Returns 0 on success. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5633 |
""" |
10152
56284451a22c
Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents:
10111
diff
changeset
|
5634 |
displayer = cmdutil.show_changeset(ui, repo, opts) |
56284451a22c
Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents:
10111
diff
changeset
|
5635 |
displayer.show(repo[len(repo) - 1]) |
56284451a22c
Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents:
10111
diff
changeset
|
5636 |
displayer.close() |
245 | 5637 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5638 |
@command('unbundle', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5639 |
[('u', 'update', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5640 |
_('update to new branch head if changesets were unbundled'))], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5641 |
_('[-u] FILE...')) |
4699
a6b62584d0b2
unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
4697
diff
changeset
|
5642 |
def unbundle(ui, repo, fname1, *fnames, **opts): |
a6b62584d0b2
unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
4697
diff
changeset
|
5643 |
"""apply one or more changegroup files |
a6b62584d0b2
unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
4697
diff
changeset
|
5644 |
|
a6b62584d0b2
unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
4697
diff
changeset
|
5645 |
Apply one or more compressed changegroup files generated by the |
a6b62584d0b2
unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
4697
diff
changeset
|
5646 |
bundle command. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5647 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5648 |
Returns 0 on success, 1 if an update has unresolved files. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5649 |
""" |
4699
a6b62584d0b2
unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
4697
diff
changeset
|
5650 |
fnames = (fname1,) + fnames |
6180
d98ef03893e6
commands: lock() the repo while unbundling (issue1004)
Patrick Mezard <pmezard@gmail.com>
parents:
6178
diff
changeset
|
5651 |
|
8109
496ae1ea4698
switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8088
diff
changeset
|
5652 |
lock = repo.lock() |
13663
d16c99f16f00
bundle: update current bookmark to most recent revision on current branch
David Soria Parra <dsp@php.net>
parents:
13646
diff
changeset
|
5653 |
wc = repo['.'] |
6180
d98ef03893e6
commands: lock() the repo while unbundling (issue1004)
Patrick Mezard <pmezard@gmail.com>
parents:
6178
diff
changeset
|
5654 |
try: |
d98ef03893e6
commands: lock() the repo while unbundling (issue1004)
Patrick Mezard <pmezard@gmail.com>
parents:
6178
diff
changeset
|
5655 |
for fname in fnames: |
7271
8046f0a070a6
use our urlopener (proxy handling, etc) instead of urllib
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7270
diff
changeset
|
5656 |
f = url.open(ui, fname) |
6180
d98ef03893e6
commands: lock() the repo while unbundling (issue1004)
Patrick Mezard <pmezard@gmail.com>
parents:
6178
diff
changeset
|
5657 |
gen = changegroup.readbundle(f, fname) |
15585
a348739da8f0
addchangegroup: remove the lock argument on the addchangegroup methods
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15580
diff
changeset
|
5658 |
modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname) |
13663
d16c99f16f00
bundle: update current bookmark to most recent revision on current branch
David Soria Parra <dsp@php.net>
parents:
13646
diff
changeset
|
5659 |
bookmarks.updatecurrentbookmark(repo, wc.node(), wc.branch()) |
6180
d98ef03893e6
commands: lock() the repo while unbundling (issue1004)
Patrick Mezard <pmezard@gmail.com>
parents:
6178
diff
changeset
|
5660 |
finally: |
8109
496ae1ea4698
switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8088
diff
changeset
|
5661 |
lock.release() |
7131
23bd7383891c
commands: optional options where possible
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7126
diff
changeset
|
5662 |
return postincoming(ui, repo, modheads, opts.get('update'), None) |
1218
cde6818e082a
Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents:
1215
diff
changeset
|
5663 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5664 |
@command('^update|up|checkout|co', |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5665 |
[('C', 'clean', None, _('discard uncommitted changes (no backup)')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5666 |
('c', 'check', None, |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5667 |
_('update across branches if no uncommitted changes')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5668 |
('d', 'date', '', _('tipmost revision matching date'), _('DATE')), |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5669 |
('r', 'rev', '', _('revision'), _('REV'))], |
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5670 |
_('[-c] [-C] [-d DATE] [[-r] REV]')) |
8855 | 5671 |
def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False): |
10889
e25c450c351e
commands: improve some command summaries
Matt Mackall <mpm@selenic.com>
parents:
10882
diff
changeset
|
5672 |
"""update working directory (or switch revisions) |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5673 |
|
8004
d5b1b846f277
commands: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7983
diff
changeset
|
5674 |
Update the repository's working directory to the specified |
12688
8c034a825cfe
help: improve description of update --check
Kevin Bullock <kbullock@ringworld.org>
parents:
12618
diff
changeset
|
5675 |
changeset. If no changeset is specified, update to the tip of the |
15957
12a1c9e92d66
update: note ways to avoid moving bookmark
Kevin Bullock <kbullock@ringworld.org>
parents:
15950
diff
changeset
|
5676 |
current named branch and move the current bookmark (see :hg:`help |
12a1c9e92d66
update: note ways to avoid moving bookmark
Kevin Bullock <kbullock@ringworld.org>
parents:
15950
diff
changeset
|
5677 |
bookmarks`). |
12688
8c034a825cfe
help: improve description of update --check
Kevin Bullock <kbullock@ringworld.org>
parents:
12618
diff
changeset
|
5678 |
|
8c034a825cfe
help: improve description of update --check
Kevin Bullock <kbullock@ringworld.org>
parents:
12618
diff
changeset
|
5679 |
If the changeset is not a descendant of the working directory's |
8c034a825cfe
help: improve description of update --check
Kevin Bullock <kbullock@ringworld.org>
parents:
12618
diff
changeset
|
5680 |
parent, the update is aborted. With the -c/--check option, the |
8c034a825cfe
help: improve description of update --check
Kevin Bullock <kbullock@ringworld.org>
parents:
12618
diff
changeset
|
5681 |
working directory is checked for uncommitted changes; if none are |
8c034a825cfe
help: improve description of update --check
Kevin Bullock <kbullock@ringworld.org>
parents:
12618
diff
changeset
|
5682 |
found, the working directory is updated to the specified |
9718
fe1b19bfe75b
help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents:
9714
diff
changeset
|
5683 |
changeset. |
fe1b19bfe75b
help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents:
9714
diff
changeset
|
5684 |
|
14725
2852933fc942
update: clarify that update changes the parent revison
Adrian Buehlmann <adrian@cadifra.com>
parents:
14721
diff
changeset
|
5685 |
Update sets the working directory's parent revison to the specified |
2852933fc942
update: clarify that update changes the parent revison
Adrian Buehlmann <adrian@cadifra.com>
parents:
14721
diff
changeset
|
5686 |
changeset (see :hg:`help parents`). |
2852933fc942
update: clarify that update changes the parent revison
Adrian Buehlmann <adrian@cadifra.com>
parents:
14721
diff
changeset
|
5687 |
|
9718
fe1b19bfe75b
help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents:
9714
diff
changeset
|
5688 |
The following rules apply when the working directory contains |
fe1b19bfe75b
help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents:
9714
diff
changeset
|
5689 |
uncommitted changes: |
fe1b19bfe75b
help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents:
9714
diff
changeset
|
5690 |
|
9831
9ebad1b93456
help: improve wording of update help text
Stuart W Marks <smarks@smarks.org>
parents:
9806
diff
changeset
|
5691 |
1. If neither -c/--check nor -C/--clean is specified, and if |
9ebad1b93456
help: improve wording of update help text
Stuart W Marks <smarks@smarks.org>
parents:
9806
diff
changeset
|
5692 |
the requested changeset is an ancestor or descendant of |
9ebad1b93456
help: improve wording of update help text
Stuart W Marks <smarks@smarks.org>
parents:
9806
diff
changeset
|
5693 |
the working directory's parent, the uncommitted changes |
9ebad1b93456
help: improve wording of update help text
Stuart W Marks <smarks@smarks.org>
parents:
9806
diff
changeset
|
5694 |
are merged into the requested changeset and the merged |
9ebad1b93456
help: improve wording of update help text
Stuart W Marks <smarks@smarks.org>
parents:
9806
diff
changeset
|
5695 |
result is left uncommitted. If the requested changeset is |
9ebad1b93456
help: improve wording of update help text
Stuart W Marks <smarks@smarks.org>
parents:
9806
diff
changeset
|
5696 |
not an ancestor or descendant (that is, it is on another |
9ebad1b93456
help: improve wording of update help text
Stuart W Marks <smarks@smarks.org>
parents:
9806
diff
changeset
|
5697 |
branch), the update is aborted and the uncommitted changes |
9740
2ebe679fec21
commands: use enumerated lists in help texts
Martin Geisler <mg@lazybytes.net>
parents:
9734
diff
changeset
|
5698 |
are preserved. |
9718
fe1b19bfe75b
help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents:
9714
diff
changeset
|
5699 |
|
fe1b19bfe75b
help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents:
9714
diff
changeset
|
5700 |
2. With the -c/--check option, the update is aborted and the |
9740
2ebe679fec21
commands: use enumerated lists in help texts
Martin Geisler <mg@lazybytes.net>
parents:
9734
diff
changeset
|
5701 |
uncommitted changes are preserved. |
9718
fe1b19bfe75b
help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents:
9714
diff
changeset
|
5702 |
|
fe1b19bfe75b
help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents:
9714
diff
changeset
|
5703 |
3. With the -C/--clean option, uncommitted changes are discarded and |
9740
2ebe679fec21
commands: use enumerated lists in help texts
Martin Geisler <mg@lazybytes.net>
parents:
9734
diff
changeset
|
5704 |
the working directory is updated to the requested changeset. |
9718
fe1b19bfe75b
help: describe new cross-branch behavior in update help text, plus cleanups
Stuart W Marks <smarks@smarks.org>
parents:
9714
diff
changeset
|
5705 |
|
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
5706 |
Use null as the changeset to remove the working directory (like |
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
5707 |
:hg:`clone -U`). |
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
5708 |
|
14729
94eea58da2a3
update: do not use the term 'update' when mentioning reverting one file
Adrian Buehlmann <adrian@cadifra.com>
parents:
14726
diff
changeset
|
5709 |
If you want to revert just one file to an older revision, use |
94eea58da2a3
update: do not use the term 'update' when mentioning reverting one file
Adrian Buehlmann <adrian@cadifra.com>
parents:
14726
diff
changeset
|
5710 |
:hg:`revert [-r REV] NAME`. |
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
5711 |
|
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10963
diff
changeset
|
5712 |
See :hg:`help dates` for a list of formats valid for -d/--date. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5713 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5714 |
Returns 0 on success, 1 if there are unresolved files. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5715 |
""" |
4450
8fa54b9c6c5a
accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents:
4445
diff
changeset
|
5716 |
if rev and node: |
8fa54b9c6c5a
accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents:
4445
diff
changeset
|
5717 |
raise util.Abort(_("please specify just one revision")) |
8fa54b9c6c5a
accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents:
4445
diff
changeset
|
5718 |
|
13568
0b79cf616e65
commands.update() now works properly with a revision of 0
Mark Drago <markdrago@gmail.com>
parents:
13477
diff
changeset
|
5719 |
if rev is None or rev == '': |
4450
8fa54b9c6c5a
accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents:
4445
diff
changeset
|
5720 |
rev = node |
8fa54b9c6c5a
accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents:
4445
diff
changeset
|
5721 |
|
15935
6c97eb445341
bookmarks: automatically advance bookmark on naked update (BC) (issue2894)
Matt Mackall <mpm@selenic.com>
parents:
15912
diff
changeset
|
5722 |
# with no argument, we also move the current bookmark, if any |
6c97eb445341
bookmarks: automatically advance bookmark on naked update (BC) (issue2894)
Matt Mackall <mpm@selenic.com>
parents:
15912
diff
changeset
|
5723 |
movemarkfrom = None |
16189
41bef17e6ad8
update: don't move the active bookmark if a rev is specified with -r
Idan Kamara <idankk86@gmail.com>
parents:
16175
diff
changeset
|
5724 |
if rev is None or node == '': |
15935
6c97eb445341
bookmarks: automatically advance bookmark on naked update (BC) (issue2894)
Matt Mackall <mpm@selenic.com>
parents:
15912
diff
changeset
|
5725 |
movemarkfrom = repo['.'].node() |
6c97eb445341
bookmarks: automatically advance bookmark on naked update (BC) (issue2894)
Matt Mackall <mpm@selenic.com>
parents:
15912
diff
changeset
|
5726 |
|
13415
25b5694b9337
update: preserve possible bookmark name to set current bookmark correctly
David Soria Parra <dsp@php.net>
parents:
13407
diff
changeset
|
5727 |
# if we defined a bookmark, we have to remember the original bookmark name |
25b5694b9337
update: preserve possible bookmark name to set current bookmark correctly
David Soria Parra <dsp@php.net>
parents:
13407
diff
changeset
|
5728 |
brev = rev |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
5729 |
rev = scmutil.revsingle(repo, rev, rev).rev() |
12726
61c0df2b089a
update: use revsingle to enable use of revsets as update targets (issue1993)
Augie Fackler <durin42@gmail.com>
parents:
12705
diff
changeset
|
5730 |
|
9450
e78967d3dd6f
commands: forbid 'hg update --check --clean'
Stuart W Marks <smarks@smarks.org>
parents:
9429
diff
changeset
|
5731 |
if check and clean: |
9451
3e673c988c85
commands: expand -c and -C in update error message
Martin Geisler <mg@lazybytes.net>
parents:
9450
diff
changeset
|
5732 |
raise util.Abort(_("cannot specify both -c/--check and -C/--clean")) |
9450
e78967d3dd6f
commands: forbid 'hg update --check --clean'
Stuart W Marks <smarks@smarks.org>
parents:
9429
diff
changeset
|
5733 |
|
16092
914bc95e227b
update: use normal update path with --check (issue2450)
Matt Mackall <mpm@selenic.com>
parents:
16039
diff
changeset
|
5734 |
if date: |
914bc95e227b
update: use normal update path with --check (issue2450)
Matt Mackall <mpm@selenic.com>
parents:
16039
diff
changeset
|
5735 |
if rev is not None: |
914bc95e227b
update: use normal update path with --check (issue2450)
Matt Mackall <mpm@selenic.com>
parents:
16039
diff
changeset
|
5736 |
raise util.Abort(_("you can't specify a revision and a date")) |
914bc95e227b
update: use normal update path with --check (issue2450)
Matt Mackall <mpm@selenic.com>
parents:
16039
diff
changeset
|
5737 |
rev = cmdutil.finddate(ui, repo, date) |
914bc95e227b
update: use normal update path with --check (issue2450)
Matt Mackall <mpm@selenic.com>
parents:
16039
diff
changeset
|
5738 |
|
9450
e78967d3dd6f
commands: forbid 'hg update --check --clean'
Stuart W Marks <smarks@smarks.org>
parents:
9429
diff
changeset
|
5739 |
if check: |
8855 | 5740 |
# we could use dirty() but we can ignore merge and branch trivia |
5741 |
c = repo[None] |
|
5742 |
if c.modified() or c.added() or c.removed(): |
|
5743 |
raise util.Abort(_("uncommitted local changes")) |
|
16092
914bc95e227b
update: use normal update path with --check (issue2450)
Matt Mackall <mpm@selenic.com>
parents:
16039
diff
changeset
|
5744 |
if not rev: |
914bc95e227b
update: use normal update path with --check (issue2450)
Matt Mackall <mpm@selenic.com>
parents:
16039
diff
changeset
|
5745 |
rev = repo[repo[None].branch()].rev() |
16095
3eab42088be4
update: just merge unknown file collisions
Matt Mackall <mpm@selenic.com>
parents:
16092
diff
changeset
|
5746 |
mergemod._checkunknown(repo, repo[None], repo[rev]) |
16092
914bc95e227b
update: use normal update path with --check (issue2450)
Matt Mackall <mpm@selenic.com>
parents:
16039
diff
changeset
|
5747 |
|
914bc95e227b
update: use normal update path with --check (issue2450)
Matt Mackall <mpm@selenic.com>
parents:
16039
diff
changeset
|
5748 |
if clean: |
13367
cef73cd9c268
bookmarks: merge current tracking on update into core
Matt Mackall <mpm@selenic.com>
parents:
13366
diff
changeset
|
5749 |
ret = hg.clean(repo, rev) |
2808
30f59f4a327e
Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents:
2806
diff
changeset
|
5750 |
else: |
13367
cef73cd9c268
bookmarks: merge current tracking on update into core
Matt Mackall <mpm@selenic.com>
parents:
13366
diff
changeset
|
5751 |
ret = hg.update(repo, rev) |
cef73cd9c268
bookmarks: merge current tracking on update into core
Matt Mackall <mpm@selenic.com>
parents:
13366
diff
changeset
|
5752 |
|
15935
6c97eb445341
bookmarks: automatically advance bookmark on naked update (BC) (issue2894)
Matt Mackall <mpm@selenic.com>
parents:
15912
diff
changeset
|
5753 |
if not ret and movemarkfrom: |
16010
c7811ca6fb94
update: note updated bookmark
Kevin Bullock <kbullock@ringworld.org>
parents:
16009
diff
changeset
|
5754 |
if bookmarks.update(repo, [movemarkfrom], repo['.'].node()): |
c7811ca6fb94
update: note updated bookmark
Kevin Bullock <kbullock@ringworld.org>
parents:
16009
diff
changeset
|
5755 |
ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent) |
15935
6c97eb445341
bookmarks: automatically advance bookmark on naked update (BC) (issue2894)
Matt Mackall <mpm@selenic.com>
parents:
15912
diff
changeset
|
5756 |
elif brev in repo._bookmarks: |
13415
25b5694b9337
update: preserve possible bookmark name to set current bookmark correctly
David Soria Parra <dsp@php.net>
parents:
13407
diff
changeset
|
5757 |
bookmarks.setcurrent(repo, brev) |
16191
7c75924a6926
update: delete bookmarks.current when explicitly updating to a rev (issue3276)
Idan Kamara <idankk86@gmail.com>
parents:
16189
diff
changeset
|
5758 |
elif brev: |
7c75924a6926
update: delete bookmarks.current when explicitly updating to a rev (issue3276)
Idan Kamara <idankk86@gmail.com>
parents:
16189
diff
changeset
|
5759 |
bookmarks.unsetcurrent(repo) |
13367
cef73cd9c268
bookmarks: merge current tracking on update into core
Matt Mackall <mpm@selenic.com>
parents:
13366
diff
changeset
|
5760 |
|
cef73cd9c268
bookmarks: merge current tracking on update into core
Matt Mackall <mpm@selenic.com>
parents:
13366
diff
changeset
|
5761 |
return ret |
254 | 5762 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5763 |
@command('verify', []) |
247 | 5764 |
def verify(ui, repo): |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5765 |
"""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
|
5766 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5767 |
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
|
5768 |
|
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5769 |
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
|
5770 |
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
|
5771 |
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
|
5772 |
integrity of their crosslinks and indices. |
11177
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5773 |
|
6a64813276ed
commands: initial audit of exit codes
Matt Mackall <mpm@selenic.com>
parents:
11173
diff
changeset
|
5774 |
Returns 0 on success, 1 if errors are encountered. |
1437
ea51d296085f
import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1436
diff
changeset
|
5775 |
""" |
2778 | 5776 |
return hg.verify(repo) |
247 | 5777 |
|
14297
2daa5179e73f
commands: use a decorator to build table incrementally
Adrian Buehlmann <adrian@cadifra.com>
parents:
14291
diff
changeset
|
5778 |
@command('version', []) |
3651
6389205291c6
move show_version to version_
Matt Mackall <mpm@selenic.com>
parents:
3650
diff
changeset
|
5779 |
def version_(ui): |
6389205291c6
move show_version to version_
Matt Mackall <mpm@selenic.com>
parents:
3650
diff
changeset
|
5780 |
"""output version and copyright information""" |
6389205291c6
move show_version to version_
Matt Mackall <mpm@selenic.com>
parents:
3650
diff
changeset
|
5781 |
ui.write(_("Mercurial Distributed SCM (version %s)\n") |
7632 | 5782 |
% util.version()) |
3651
6389205291c6
move show_version to version_
Matt Mackall <mpm@selenic.com>
parents:
3650
diff
changeset
|
5783 |
ui.status(_( |
12829
01145ee78c53
version: replace email address with url to reduce private mail
Matt Mackall <mpm@selenic.com>
parents:
12821
diff
changeset
|
5784 |
"(see http://mercurial.selenic.com for more information)\n" |
15834
65f7e986a0d0
commands: bump copyright year
Martin Geisler <mg@aragost.com>
parents:
15833
diff
changeset
|
5785 |
"\nCopyright (C) 2005-2012 Matt Mackall and others\n" |
3651
6389205291c6
move show_version to version_
Matt Mackall <mpm@selenic.com>
parents:
3650
diff
changeset
|
5786 |
"This is free software; see the source for copying conditions. " |
6389205291c6
move show_version to version_
Matt Mackall <mpm@selenic.com>
parents:
3650
diff
changeset
|
5787 |
"There is NO\nwarranty; " |
6389205291c6
move show_version to version_
Matt Mackall <mpm@selenic.com>
parents:
3650
diff
changeset
|
5788 |
"not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" |
6389205291c6
move show_version to version_
Matt Mackall <mpm@selenic.com>
parents:
3650
diff
changeset
|
5789 |
)) |
6389205291c6
move show_version to version_
Matt Mackall <mpm@selenic.com>
parents:
3650
diff
changeset
|
5790 |
|
12131
c061f9882ff7
debugdata: try to access filelogs through repo, if possible
Sune Foldager <cryo@cyanite.org>
parents:
12130
diff
changeset
|
5791 |
norepo = ("clone init version help debugcommands debugcomplete" |
13723
e615765fdcc7
wireproto: add known([id]) function
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13720
diff
changeset
|
5792 |
" debugdate debuginstall debugfsinfo debugpushkey debugwireargs" |
13741
b51bf961b3cb
wireproto: add getbundle() function
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13727
diff
changeset
|
5793 |
" debugknown debuggetbundle debugbundle") |
12131
c061f9882ff7
debugdata: try to access filelogs through repo, if possible
Sune Foldager <cryo@cyanite.org>
parents:
12130
diff
changeset
|
5794 |
optionalrepo = ("identify paths serve showconfig debugancestor debugdag" |
14323
a79fea6b3e77
debugindex etc.: add --changelog and --manifest options
Sune Foldager <cryo@cyanite.org>
parents:
14322
diff
changeset
|
5795 |
" debugdata debugindex debugindexdot debugrevlog") |