##// END OF EJS Templates
diff: add a --noprefix option...
Siddharth Agarwal -
r23298:dc4d0c7b default
parent child Browse files
Show More
@@ -1,6252 +1,6253 b''
1 # commands.py - command processing for mercurial
1 # commands.py - command processing for mercurial
2 #
2 #
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from node import hex, bin, nullid, nullrev, short
8 from node import hex, bin, nullid, nullrev, short
9 from lock import release
9 from lock import release
10 from i18n import _
10 from i18n import _
11 import os, re, difflib, time, tempfile, errno, shlex
11 import os, re, difflib, time, tempfile, errno, shlex
12 import sys, socket
12 import sys, socket
13 import hg, scmutil, util, revlog, copies, error, bookmarks
13 import hg, scmutil, util, revlog, copies, error, bookmarks
14 import patch, help, encoding, templatekw, discovery
14 import patch, help, encoding, templatekw, discovery
15 import archival, changegroup, cmdutil, hbisect
15 import archival, changegroup, cmdutil, hbisect
16 import sshserver, hgweb, commandserver
16 import sshserver, hgweb, commandserver
17 import extensions
17 import extensions
18 from hgweb import server as hgweb_server
18 from hgweb import server as hgweb_server
19 import merge as mergemod
19 import merge as mergemod
20 import minirst, revset, fileset
20 import minirst, revset, fileset
21 import dagparser, context, simplemerge, graphmod, copies
21 import dagparser, context, simplemerge, graphmod, copies
22 import random
22 import random
23 import setdiscovery, treediscovery, dagutil, pvec, localrepo
23 import setdiscovery, treediscovery, dagutil, pvec, localrepo
24 import phases, obsolete, exchange
24 import phases, obsolete, exchange
25 import ui as uimod
25 import ui as uimod
26
26
27 table = {}
27 table = {}
28
28
29 command = cmdutil.command(table)
29 command = cmdutil.command(table)
30
30
31 # Space delimited list of commands that don't require local repositories.
31 # Space delimited list of commands that don't require local repositories.
32 # This should be populated by passing norepo=True into the @command decorator.
32 # This should be populated by passing norepo=True into the @command decorator.
33 norepo = ''
33 norepo = ''
34 # Space delimited list of commands that optionally require local repositories.
34 # Space delimited list of commands that optionally require local repositories.
35 # This should be populated by passing optionalrepo=True into the @command
35 # This should be populated by passing optionalrepo=True into the @command
36 # decorator.
36 # decorator.
37 optionalrepo = ''
37 optionalrepo = ''
38 # Space delimited list of commands that will examine arguments looking for
38 # Space delimited list of commands that will examine arguments looking for
39 # a repository. This should be populated by passing inferrepo=True into the
39 # a repository. This should be populated by passing inferrepo=True into the
40 # @command decorator.
40 # @command decorator.
41 inferrepo = ''
41 inferrepo = ''
42
42
43 # common command options
43 # common command options
44
44
45 globalopts = [
45 globalopts = [
46 ('R', 'repository', '',
46 ('R', 'repository', '',
47 _('repository root directory or name of overlay bundle file'),
47 _('repository root directory or name of overlay bundle file'),
48 _('REPO')),
48 _('REPO')),
49 ('', 'cwd', '',
49 ('', 'cwd', '',
50 _('change working directory'), _('DIR')),
50 _('change working directory'), _('DIR')),
51 ('y', 'noninteractive', None,
51 ('y', 'noninteractive', None,
52 _('do not prompt, automatically pick the first choice for all prompts')),
52 _('do not prompt, automatically pick the first choice for all prompts')),
53 ('q', 'quiet', None, _('suppress output')),
53 ('q', 'quiet', None, _('suppress output')),
54 ('v', 'verbose', None, _('enable additional output')),
54 ('v', 'verbose', None, _('enable additional output')),
55 ('', 'config', [],
55 ('', 'config', [],
56 _('set/override config option (use \'section.name=value\')'),
56 _('set/override config option (use \'section.name=value\')'),
57 _('CONFIG')),
57 _('CONFIG')),
58 ('', 'debug', None, _('enable debugging output')),
58 ('', 'debug', None, _('enable debugging output')),
59 ('', 'debugger', None, _('start debugger')),
59 ('', 'debugger', None, _('start debugger')),
60 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
60 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
61 _('ENCODE')),
61 _('ENCODE')),
62 ('', 'encodingmode', encoding.encodingmode,
62 ('', 'encodingmode', encoding.encodingmode,
63 _('set the charset encoding mode'), _('MODE')),
63 _('set the charset encoding mode'), _('MODE')),
64 ('', 'traceback', None, _('always print a traceback on exception')),
64 ('', 'traceback', None, _('always print a traceback on exception')),
65 ('', 'time', None, _('time how long the command takes')),
65 ('', 'time', None, _('time how long the command takes')),
66 ('', 'profile', None, _('print command execution profile')),
66 ('', 'profile', None, _('print command execution profile')),
67 ('', 'version', None, _('output version information and exit')),
67 ('', 'version', None, _('output version information and exit')),
68 ('h', 'help', None, _('display help and exit')),
68 ('h', 'help', None, _('display help and exit')),
69 ('', 'hidden', False, _('consider hidden changesets')),
69 ('', 'hidden', False, _('consider hidden changesets')),
70 ]
70 ]
71
71
72 dryrunopts = [('n', 'dry-run', None,
72 dryrunopts = [('n', 'dry-run', None,
73 _('do not perform actions, just print output'))]
73 _('do not perform actions, just print output'))]
74
74
75 remoteopts = [
75 remoteopts = [
76 ('e', 'ssh', '',
76 ('e', 'ssh', '',
77 _('specify ssh command to use'), _('CMD')),
77 _('specify ssh command to use'), _('CMD')),
78 ('', 'remotecmd', '',
78 ('', 'remotecmd', '',
79 _('specify hg command to run on the remote side'), _('CMD')),
79 _('specify hg command to run on the remote side'), _('CMD')),
80 ('', 'insecure', None,
80 ('', 'insecure', None,
81 _('do not verify server certificate (ignoring web.cacerts config)')),
81 _('do not verify server certificate (ignoring web.cacerts config)')),
82 ]
82 ]
83
83
84 walkopts = [
84 walkopts = [
85 ('I', 'include', [],
85 ('I', 'include', [],
86 _('include names matching the given patterns'), _('PATTERN')),
86 _('include names matching the given patterns'), _('PATTERN')),
87 ('X', 'exclude', [],
87 ('X', 'exclude', [],
88 _('exclude names matching the given patterns'), _('PATTERN')),
88 _('exclude names matching the given patterns'), _('PATTERN')),
89 ]
89 ]
90
90
91 commitopts = [
91 commitopts = [
92 ('m', 'message', '',
92 ('m', 'message', '',
93 _('use text as commit message'), _('TEXT')),
93 _('use text as commit message'), _('TEXT')),
94 ('l', 'logfile', '',
94 ('l', 'logfile', '',
95 _('read commit message from file'), _('FILE')),
95 _('read commit message from file'), _('FILE')),
96 ]
96 ]
97
97
98 commitopts2 = [
98 commitopts2 = [
99 ('d', 'date', '',
99 ('d', 'date', '',
100 _('record the specified date as commit date'), _('DATE')),
100 _('record the specified date as commit date'), _('DATE')),
101 ('u', 'user', '',
101 ('u', 'user', '',
102 _('record the specified user as committer'), _('USER')),
102 _('record the specified user as committer'), _('USER')),
103 ]
103 ]
104
104
105 # hidden for now
105 # hidden for now
106 formatteropts = [
106 formatteropts = [
107 ('T', 'template', '',
107 ('T', 'template', '',
108 _('display with template (DEPRECATED)'), _('TEMPLATE')),
108 _('display with template (DEPRECATED)'), _('TEMPLATE')),
109 ]
109 ]
110
110
111 templateopts = [
111 templateopts = [
112 ('', 'style', '',
112 ('', 'style', '',
113 _('display using template map file (DEPRECATED)'), _('STYLE')),
113 _('display using template map file (DEPRECATED)'), _('STYLE')),
114 ('T', 'template', '',
114 ('T', 'template', '',
115 _('display with template'), _('TEMPLATE')),
115 _('display with template'), _('TEMPLATE')),
116 ]
116 ]
117
117
118 logopts = [
118 logopts = [
119 ('p', 'patch', None, _('show patch')),
119 ('p', 'patch', None, _('show patch')),
120 ('g', 'git', None, _('use git extended diff format')),
120 ('g', 'git', None, _('use git extended diff format')),
121 ('l', 'limit', '',
121 ('l', 'limit', '',
122 _('limit number of changes displayed'), _('NUM')),
122 _('limit number of changes displayed'), _('NUM')),
123 ('M', 'no-merges', None, _('do not show merges')),
123 ('M', 'no-merges', None, _('do not show merges')),
124 ('', 'stat', None, _('output diffstat-style summary of changes')),
124 ('', 'stat', None, _('output diffstat-style summary of changes')),
125 ('G', 'graph', None, _("show the revision DAG")),
125 ('G', 'graph', None, _("show the revision DAG")),
126 ] + templateopts
126 ] + templateopts
127
127
128 diffopts = [
128 diffopts = [
129 ('a', 'text', None, _('treat all files as text')),
129 ('a', 'text', None, _('treat all files as text')),
130 ('g', 'git', None, _('use git extended diff format')),
130 ('g', 'git', None, _('use git extended diff format')),
131 ('', 'nodates', None, _('omit dates from diff headers'))
131 ('', 'nodates', None, _('omit dates from diff headers'))
132 ]
132 ]
133
133
134 diffwsopts = [
134 diffwsopts = [
135 ('w', 'ignore-all-space', None,
135 ('w', 'ignore-all-space', None,
136 _('ignore white space when comparing lines')),
136 _('ignore white space when comparing lines')),
137 ('b', 'ignore-space-change', None,
137 ('b', 'ignore-space-change', None,
138 _('ignore changes in the amount of white space')),
138 _('ignore changes in the amount of white space')),
139 ('B', 'ignore-blank-lines', None,
139 ('B', 'ignore-blank-lines', None,
140 _('ignore changes whose lines are all blank')),
140 _('ignore changes whose lines are all blank')),
141 ]
141 ]
142
142
143 diffopts2 = [
143 diffopts2 = [
144 ('', 'noprefix', None, _('omit a/ and b/ prefixes from filenames')),
144 ('p', 'show-function', None, _('show which function each change is in')),
145 ('p', 'show-function', None, _('show which function each change is in')),
145 ('', 'reverse', None, _('produce a diff that undoes the changes')),
146 ('', 'reverse', None, _('produce a diff that undoes the changes')),
146 ] + diffwsopts + [
147 ] + diffwsopts + [
147 ('U', 'unified', '',
148 ('U', 'unified', '',
148 _('number of lines of context to show'), _('NUM')),
149 _('number of lines of context to show'), _('NUM')),
149 ('', 'stat', None, _('output diffstat-style summary of changes')),
150 ('', 'stat', None, _('output diffstat-style summary of changes')),
150 ]
151 ]
151
152
152 mergetoolopts = [
153 mergetoolopts = [
153 ('t', 'tool', '', _('specify merge tool')),
154 ('t', 'tool', '', _('specify merge tool')),
154 ]
155 ]
155
156
156 similarityopts = [
157 similarityopts = [
157 ('s', 'similarity', '',
158 ('s', 'similarity', '',
158 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
159 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
159 ]
160 ]
160
161
161 subrepoopts = [
162 subrepoopts = [
162 ('S', 'subrepos', None,
163 ('S', 'subrepos', None,
163 _('recurse into subrepositories'))
164 _('recurse into subrepositories'))
164 ]
165 ]
165
166
166 # Commands start here, listed alphabetically
167 # Commands start here, listed alphabetically
167
168
168 @command('^add',
169 @command('^add',
169 walkopts + subrepoopts + dryrunopts,
170 walkopts + subrepoopts + dryrunopts,
170 _('[OPTION]... [FILE]...'),
171 _('[OPTION]... [FILE]...'),
171 inferrepo=True)
172 inferrepo=True)
172 def add(ui, repo, *pats, **opts):
173 def add(ui, repo, *pats, **opts):
173 """add the specified files on the next commit
174 """add the specified files on the next commit
174
175
175 Schedule files to be version controlled and added to the
176 Schedule files to be version controlled and added to the
176 repository.
177 repository.
177
178
178 The files will be added to the repository at the next commit. To
179 The files will be added to the repository at the next commit. To
179 undo an add before that, see :hg:`forget`.
180 undo an add before that, see :hg:`forget`.
180
181
181 If no names are given, add all files to the repository.
182 If no names are given, add all files to the repository.
182
183
183 .. container:: verbose
184 .. container:: verbose
184
185
185 An example showing how new (unknown) files are added
186 An example showing how new (unknown) files are added
186 automatically by :hg:`add`::
187 automatically by :hg:`add`::
187
188
188 $ ls
189 $ ls
189 foo.c
190 foo.c
190 $ hg status
191 $ hg status
191 ? foo.c
192 ? foo.c
192 $ hg add
193 $ hg add
193 adding foo.c
194 adding foo.c
194 $ hg status
195 $ hg status
195 A foo.c
196 A foo.c
196
197
197 Returns 0 if all files are successfully added.
198 Returns 0 if all files are successfully added.
198 """
199 """
199
200
200 m = scmutil.match(repo[None], pats, opts)
201 m = scmutil.match(repo[None], pats, opts)
201 rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'),
202 rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'),
202 opts.get('subrepos'), prefix="", explicitonly=False)
203 opts.get('subrepos'), prefix="", explicitonly=False)
203 return rejected and 1 or 0
204 return rejected and 1 or 0
204
205
205 @command('addremove',
206 @command('addremove',
206 similarityopts + walkopts + dryrunopts,
207 similarityopts + walkopts + dryrunopts,
207 _('[OPTION]... [FILE]...'),
208 _('[OPTION]... [FILE]...'),
208 inferrepo=True)
209 inferrepo=True)
209 def addremove(ui, repo, *pats, **opts):
210 def addremove(ui, repo, *pats, **opts):
210 """add all new files, delete all missing files
211 """add all new files, delete all missing files
211
212
212 Add all new files and remove all missing files from the
213 Add all new files and remove all missing files from the
213 repository.
214 repository.
214
215
215 New files are ignored if they match any of the patterns in
216 New files are ignored if they match any of the patterns in
216 ``.hgignore``. As with add, these changes take effect at the next
217 ``.hgignore``. As with add, these changes take effect at the next
217 commit.
218 commit.
218
219
219 Use the -s/--similarity option to detect renamed files. This
220 Use the -s/--similarity option to detect renamed files. This
220 option takes a percentage between 0 (disabled) and 100 (files must
221 option takes a percentage between 0 (disabled) and 100 (files must
221 be identical) as its parameter. With a parameter greater than 0,
222 be identical) as its parameter. With a parameter greater than 0,
222 this compares every removed file with every added file and records
223 this compares every removed file with every added file and records
223 those similar enough as renames. Detecting renamed files this way
224 those similar enough as renames. Detecting renamed files this way
224 can be expensive. After using this option, :hg:`status -C` can be
225 can be expensive. After using this option, :hg:`status -C` can be
225 used to check which files were identified as moved or renamed. If
226 used to check which files were identified as moved or renamed. If
226 not specified, -s/--similarity defaults to 100 and only renames of
227 not specified, -s/--similarity defaults to 100 and only renames of
227 identical files are detected.
228 identical files are detected.
228
229
229 Returns 0 if all files are successfully added.
230 Returns 0 if all files are successfully added.
230 """
231 """
231 try:
232 try:
232 sim = float(opts.get('similarity') or 100)
233 sim = float(opts.get('similarity') or 100)
233 except ValueError:
234 except ValueError:
234 raise util.Abort(_('similarity must be a number'))
235 raise util.Abort(_('similarity must be a number'))
235 if sim < 0 or sim > 100:
236 if sim < 0 or sim > 100:
236 raise util.Abort(_('similarity must be between 0 and 100'))
237 raise util.Abort(_('similarity must be between 0 and 100'))
237 return scmutil.addremove(repo, pats, opts, similarity=sim / 100.0)
238 return scmutil.addremove(repo, pats, opts, similarity=sim / 100.0)
238
239
239 @command('^annotate|blame',
240 @command('^annotate|blame',
240 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
241 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
241 ('', 'follow', None,
242 ('', 'follow', None,
242 _('follow copies/renames and list the filename (DEPRECATED)')),
243 _('follow copies/renames and list the filename (DEPRECATED)')),
243 ('', 'no-follow', None, _("don't follow copies and renames")),
244 ('', 'no-follow', None, _("don't follow copies and renames")),
244 ('a', 'text', None, _('treat all files as text')),
245 ('a', 'text', None, _('treat all files as text')),
245 ('u', 'user', None, _('list the author (long with -v)')),
246 ('u', 'user', None, _('list the author (long with -v)')),
246 ('f', 'file', None, _('list the filename')),
247 ('f', 'file', None, _('list the filename')),
247 ('d', 'date', None, _('list the date (short with -q)')),
248 ('d', 'date', None, _('list the date (short with -q)')),
248 ('n', 'number', None, _('list the revision number (default)')),
249 ('n', 'number', None, _('list the revision number (default)')),
249 ('c', 'changeset', None, _('list the changeset')),
250 ('c', 'changeset', None, _('list the changeset')),
250 ('l', 'line-number', None, _('show line number at the first appearance'))
251 ('l', 'line-number', None, _('show line number at the first appearance'))
251 ] + diffwsopts + walkopts + formatteropts,
252 ] + diffwsopts + walkopts + formatteropts,
252 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
253 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
253 inferrepo=True)
254 inferrepo=True)
254 def annotate(ui, repo, *pats, **opts):
255 def annotate(ui, repo, *pats, **opts):
255 """show changeset information by line for each file
256 """show changeset information by line for each file
256
257
257 List changes in files, showing the revision id responsible for
258 List changes in files, showing the revision id responsible for
258 each line
259 each line
259
260
260 This command is useful for discovering when a change was made and
261 This command is useful for discovering when a change was made and
261 by whom.
262 by whom.
262
263
263 Without the -a/--text option, annotate will avoid processing files
264 Without the -a/--text option, annotate will avoid processing files
264 it detects as binary. With -a, annotate will annotate the file
265 it detects as binary. With -a, annotate will annotate the file
265 anyway, although the results will probably be neither useful
266 anyway, although the results will probably be neither useful
266 nor desirable.
267 nor desirable.
267
268
268 Returns 0 on success.
269 Returns 0 on success.
269 """
270 """
270 if not pats:
271 if not pats:
271 raise util.Abort(_('at least one filename or pattern is required'))
272 raise util.Abort(_('at least one filename or pattern is required'))
272
273
273 if opts.get('follow'):
274 if opts.get('follow'):
274 # --follow is deprecated and now just an alias for -f/--file
275 # --follow is deprecated and now just an alias for -f/--file
275 # to mimic the behavior of Mercurial before version 1.5
276 # to mimic the behavior of Mercurial before version 1.5
276 opts['file'] = True
277 opts['file'] = True
277
278
278 fm = ui.formatter('annotate', opts)
279 fm = ui.formatter('annotate', opts)
279 datefunc = ui.quiet and util.shortdate or util.datestr
280 datefunc = ui.quiet and util.shortdate or util.datestr
280 hexfn = fm.hexfunc
281 hexfn = fm.hexfunc
281
282
282 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
283 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
283 ('number', ' ', lambda x: x[0].rev(), str),
284 ('number', ' ', lambda x: x[0].rev(), str),
284 ('changeset', ' ', lambda x: hexfn(x[0].node()), str),
285 ('changeset', ' ', lambda x: hexfn(x[0].node()), str),
285 ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)),
286 ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)),
286 ('file', ' ', lambda x: x[0].path(), str),
287 ('file', ' ', lambda x: x[0].path(), str),
287 ('line_number', ':', lambda x: x[1], str),
288 ('line_number', ':', lambda x: x[1], str),
288 ]
289 ]
289 fieldnamemap = {'number': 'rev', 'changeset': 'node'}
290 fieldnamemap = {'number': 'rev', 'changeset': 'node'}
290
291
291 if (not opts.get('user') and not opts.get('changeset')
292 if (not opts.get('user') and not opts.get('changeset')
292 and not opts.get('date') and not opts.get('file')):
293 and not opts.get('date') and not opts.get('file')):
293 opts['number'] = True
294 opts['number'] = True
294
295
295 linenumber = opts.get('line_number') is not None
296 linenumber = opts.get('line_number') is not None
296 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
297 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
297 raise util.Abort(_('at least one of -n/-c is required for -l'))
298 raise util.Abort(_('at least one of -n/-c is required for -l'))
298
299
299 if fm:
300 if fm:
300 def makefunc(get, fmt):
301 def makefunc(get, fmt):
301 return get
302 return get
302 else:
303 else:
303 def makefunc(get, fmt):
304 def makefunc(get, fmt):
304 return lambda x: fmt(get(x))
305 return lambda x: fmt(get(x))
305 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap
306 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap
306 if opts.get(op)]
307 if opts.get(op)]
307 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
308 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
308 fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap
309 fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap
309 if opts.get(op))
310 if opts.get(op))
310
311
311 def bad(x, y):
312 def bad(x, y):
312 raise util.Abort("%s: %s" % (x, y))
313 raise util.Abort("%s: %s" % (x, y))
313
314
314 ctx = scmutil.revsingle(repo, opts.get('rev'))
315 ctx = scmutil.revsingle(repo, opts.get('rev'))
315 m = scmutil.match(ctx, pats, opts)
316 m = scmutil.match(ctx, pats, opts)
316 m.bad = bad
317 m.bad = bad
317 follow = not opts.get('no_follow')
318 follow = not opts.get('no_follow')
318 diffopts = patch.diffopts(ui, opts, section='annotate')
319 diffopts = patch.diffopts(ui, opts, section='annotate')
319 for abs in ctx.walk(m):
320 for abs in ctx.walk(m):
320 fctx = ctx[abs]
321 fctx = ctx[abs]
321 if not opts.get('text') and util.binary(fctx.data()):
322 if not opts.get('text') and util.binary(fctx.data()):
322 fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
323 fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
323 continue
324 continue
324
325
325 lines = fctx.annotate(follow=follow, linenumber=linenumber,
326 lines = fctx.annotate(follow=follow, linenumber=linenumber,
326 diffopts=diffopts)
327 diffopts=diffopts)
327 formats = []
328 formats = []
328 pieces = []
329 pieces = []
329
330
330 for f, sep in funcmap:
331 for f, sep in funcmap:
331 l = [f(n) for n, dummy in lines]
332 l = [f(n) for n, dummy in lines]
332 if l:
333 if l:
333 if fm:
334 if fm:
334 formats.append(['%s' for x in l])
335 formats.append(['%s' for x in l])
335 else:
336 else:
336 sizes = [encoding.colwidth(x) for x in l]
337 sizes = [encoding.colwidth(x) for x in l]
337 ml = max(sizes)
338 ml = max(sizes)
338 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes])
339 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes])
339 pieces.append(l)
340 pieces.append(l)
340
341
341 for f, p, l in zip(zip(*formats), zip(*pieces), lines):
342 for f, p, l in zip(zip(*formats), zip(*pieces), lines):
342 fm.startitem()
343 fm.startitem()
343 fm.write(fields, "".join(f), *p)
344 fm.write(fields, "".join(f), *p)
344 fm.write('line', ": %s", l[1])
345 fm.write('line', ": %s", l[1])
345
346
346 if lines and not lines[-1][1].endswith('\n'):
347 if lines and not lines[-1][1].endswith('\n'):
347 fm.plain('\n')
348 fm.plain('\n')
348
349
349 fm.end()
350 fm.end()
350
351
351 @command('archive',
352 @command('archive',
352 [('', 'no-decode', None, _('do not pass files through decoders')),
353 [('', 'no-decode', None, _('do not pass files through decoders')),
353 ('p', 'prefix', '', _('directory prefix for files in archive'),
354 ('p', 'prefix', '', _('directory prefix for files in archive'),
354 _('PREFIX')),
355 _('PREFIX')),
355 ('r', 'rev', '', _('revision to distribute'), _('REV')),
356 ('r', 'rev', '', _('revision to distribute'), _('REV')),
356 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
357 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
357 ] + subrepoopts + walkopts,
358 ] + subrepoopts + walkopts,
358 _('[OPTION]... DEST'))
359 _('[OPTION]... DEST'))
359 def archive(ui, repo, dest, **opts):
360 def archive(ui, repo, dest, **opts):
360 '''create an unversioned archive of a repository revision
361 '''create an unversioned archive of a repository revision
361
362
362 By default, the revision used is the parent of the working
363 By default, the revision used is the parent of the working
363 directory; use -r/--rev to specify a different revision.
364 directory; use -r/--rev to specify a different revision.
364
365
365 The archive type is automatically detected based on file
366 The archive type is automatically detected based on file
366 extension (or override using -t/--type).
367 extension (or override using -t/--type).
367
368
368 .. container:: verbose
369 .. container:: verbose
369
370
370 Examples:
371 Examples:
371
372
372 - create a zip file containing the 1.0 release::
373 - create a zip file containing the 1.0 release::
373
374
374 hg archive -r 1.0 project-1.0.zip
375 hg archive -r 1.0 project-1.0.zip
375
376
376 - create a tarball excluding .hg files::
377 - create a tarball excluding .hg files::
377
378
378 hg archive project.tar.gz -X ".hg*"
379 hg archive project.tar.gz -X ".hg*"
379
380
380 Valid types are:
381 Valid types are:
381
382
382 :``files``: a directory full of files (default)
383 :``files``: a directory full of files (default)
383 :``tar``: tar archive, uncompressed
384 :``tar``: tar archive, uncompressed
384 :``tbz2``: tar archive, compressed using bzip2
385 :``tbz2``: tar archive, compressed using bzip2
385 :``tgz``: tar archive, compressed using gzip
386 :``tgz``: tar archive, compressed using gzip
386 :``uzip``: zip archive, uncompressed
387 :``uzip``: zip archive, uncompressed
387 :``zip``: zip archive, compressed using deflate
388 :``zip``: zip archive, compressed using deflate
388
389
389 The exact name of the destination archive or directory is given
390 The exact name of the destination archive or directory is given
390 using a format string; see :hg:`help export` for details.
391 using a format string; see :hg:`help export` for details.
391
392
392 Each member added to an archive file has a directory prefix
393 Each member added to an archive file has a directory prefix
393 prepended. Use -p/--prefix to specify a format string for the
394 prepended. Use -p/--prefix to specify a format string for the
394 prefix. The default is the basename of the archive, with suffixes
395 prefix. The default is the basename of the archive, with suffixes
395 removed.
396 removed.
396
397
397 Returns 0 on success.
398 Returns 0 on success.
398 '''
399 '''
399
400
400 ctx = scmutil.revsingle(repo, opts.get('rev'))
401 ctx = scmutil.revsingle(repo, opts.get('rev'))
401 if not ctx:
402 if not ctx:
402 raise util.Abort(_('no working directory: please specify a revision'))
403 raise util.Abort(_('no working directory: please specify a revision'))
403 node = ctx.node()
404 node = ctx.node()
404 dest = cmdutil.makefilename(repo, dest, node)
405 dest = cmdutil.makefilename(repo, dest, node)
405 if os.path.realpath(dest) == repo.root:
406 if os.path.realpath(dest) == repo.root:
406 raise util.Abort(_('repository root cannot be destination'))
407 raise util.Abort(_('repository root cannot be destination'))
407
408
408 kind = opts.get('type') or archival.guesskind(dest) or 'files'
409 kind = opts.get('type') or archival.guesskind(dest) or 'files'
409 prefix = opts.get('prefix')
410 prefix = opts.get('prefix')
410
411
411 if dest == '-':
412 if dest == '-':
412 if kind == 'files':
413 if kind == 'files':
413 raise util.Abort(_('cannot archive plain files to stdout'))
414 raise util.Abort(_('cannot archive plain files to stdout'))
414 dest = cmdutil.makefileobj(repo, dest)
415 dest = cmdutil.makefileobj(repo, dest)
415 if not prefix:
416 if not prefix:
416 prefix = os.path.basename(repo.root) + '-%h'
417 prefix = os.path.basename(repo.root) + '-%h'
417
418
418 prefix = cmdutil.makefilename(repo, prefix, node)
419 prefix = cmdutil.makefilename(repo, prefix, node)
419 matchfn = scmutil.match(ctx, [], opts)
420 matchfn = scmutil.match(ctx, [], opts)
420 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
421 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
421 matchfn, prefix, subrepos=opts.get('subrepos'))
422 matchfn, prefix, subrepos=opts.get('subrepos'))
422
423
423 @command('backout',
424 @command('backout',
424 [('', 'merge', None, _('merge with old dirstate parent after backout')),
425 [('', 'merge', None, _('merge with old dirstate parent after backout')),
425 ('', 'parent', '',
426 ('', 'parent', '',
426 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
427 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
427 ('r', 'rev', '', _('revision to backout'), _('REV')),
428 ('r', 'rev', '', _('revision to backout'), _('REV')),
428 ('e', 'edit', False, _('invoke editor on commit messages')),
429 ('e', 'edit', False, _('invoke editor on commit messages')),
429 ] + mergetoolopts + walkopts + commitopts + commitopts2,
430 ] + mergetoolopts + walkopts + commitopts + commitopts2,
430 _('[OPTION]... [-r] REV'))
431 _('[OPTION]... [-r] REV'))
431 def backout(ui, repo, node=None, rev=None, **opts):
432 def backout(ui, repo, node=None, rev=None, **opts):
432 '''reverse effect of earlier changeset
433 '''reverse effect of earlier changeset
433
434
434 Prepare a new changeset with the effect of REV undone in the
435 Prepare a new changeset with the effect of REV undone in the
435 current working directory.
436 current working directory.
436
437
437 If REV is the parent of the working directory, then this new changeset
438 If REV is the parent of the working directory, then this new changeset
438 is committed automatically. Otherwise, hg needs to merge the
439 is committed automatically. Otherwise, hg needs to merge the
439 changes and the merged result is left uncommitted.
440 changes and the merged result is left uncommitted.
440
441
441 .. note::
442 .. note::
442
443
443 backout cannot be used to fix either an unwanted or
444 backout cannot be used to fix either an unwanted or
444 incorrect merge.
445 incorrect merge.
445
446
446 .. container:: verbose
447 .. container:: verbose
447
448
448 By default, the pending changeset will have one parent,
449 By default, the pending changeset will have one parent,
449 maintaining a linear history. With --merge, the pending
450 maintaining a linear history. With --merge, the pending
450 changeset will instead have two parents: the old parent of the
451 changeset will instead have two parents: the old parent of the
451 working directory and a new child of REV that simply undoes REV.
452 working directory and a new child of REV that simply undoes REV.
452
453
453 Before version 1.7, the behavior without --merge was equivalent
454 Before version 1.7, the behavior without --merge was equivalent
454 to specifying --merge followed by :hg:`update --clean .` to
455 to specifying --merge followed by :hg:`update --clean .` to
455 cancel the merge and leave the child of REV as a head to be
456 cancel the merge and leave the child of REV as a head to be
456 merged separately.
457 merged separately.
457
458
458 See :hg:`help dates` for a list of formats valid for -d/--date.
459 See :hg:`help dates` for a list of formats valid for -d/--date.
459
460
460 Returns 0 on success, 1 if nothing to backout or there are unresolved
461 Returns 0 on success, 1 if nothing to backout or there are unresolved
461 files.
462 files.
462 '''
463 '''
463 if rev and node:
464 if rev and node:
464 raise util.Abort(_("please specify just one revision"))
465 raise util.Abort(_("please specify just one revision"))
465
466
466 if not rev:
467 if not rev:
467 rev = node
468 rev = node
468
469
469 if not rev:
470 if not rev:
470 raise util.Abort(_("please specify a revision to backout"))
471 raise util.Abort(_("please specify a revision to backout"))
471
472
472 date = opts.get('date')
473 date = opts.get('date')
473 if date:
474 if date:
474 opts['date'] = util.parsedate(date)
475 opts['date'] = util.parsedate(date)
475
476
476 cmdutil.checkunfinished(repo)
477 cmdutil.checkunfinished(repo)
477 cmdutil.bailifchanged(repo)
478 cmdutil.bailifchanged(repo)
478 node = scmutil.revsingle(repo, rev).node()
479 node = scmutil.revsingle(repo, rev).node()
479
480
480 op1, op2 = repo.dirstate.parents()
481 op1, op2 = repo.dirstate.parents()
481 if not repo.changelog.isancestor(node, op1):
482 if not repo.changelog.isancestor(node, op1):
482 raise util.Abort(_('cannot backout change that is not an ancestor'))
483 raise util.Abort(_('cannot backout change that is not an ancestor'))
483
484
484 p1, p2 = repo.changelog.parents(node)
485 p1, p2 = repo.changelog.parents(node)
485 if p1 == nullid:
486 if p1 == nullid:
486 raise util.Abort(_('cannot backout a change with no parents'))
487 raise util.Abort(_('cannot backout a change with no parents'))
487 if p2 != nullid:
488 if p2 != nullid:
488 if not opts.get('parent'):
489 if not opts.get('parent'):
489 raise util.Abort(_('cannot backout a merge changeset'))
490 raise util.Abort(_('cannot backout a merge changeset'))
490 p = repo.lookup(opts['parent'])
491 p = repo.lookup(opts['parent'])
491 if p not in (p1, p2):
492 if p not in (p1, p2):
492 raise util.Abort(_('%s is not a parent of %s') %
493 raise util.Abort(_('%s is not a parent of %s') %
493 (short(p), short(node)))
494 (short(p), short(node)))
494 parent = p
495 parent = p
495 else:
496 else:
496 if opts.get('parent'):
497 if opts.get('parent'):
497 raise util.Abort(_('cannot use --parent on non-merge changeset'))
498 raise util.Abort(_('cannot use --parent on non-merge changeset'))
498 parent = p1
499 parent = p1
499
500
500 # the backout should appear on the same branch
501 # the backout should appear on the same branch
501 wlock = repo.wlock()
502 wlock = repo.wlock()
502 try:
503 try:
503 branch = repo.dirstate.branch()
504 branch = repo.dirstate.branch()
504 bheads = repo.branchheads(branch)
505 bheads = repo.branchheads(branch)
505 rctx = scmutil.revsingle(repo, hex(parent))
506 rctx = scmutil.revsingle(repo, hex(parent))
506 if not opts.get('merge') and op1 != node:
507 if not opts.get('merge') and op1 != node:
507 try:
508 try:
508 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
509 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
509 'backout')
510 'backout')
510 repo.dirstate.beginparentchange()
511 repo.dirstate.beginparentchange()
511 stats = mergemod.update(repo, parent, True, True, False,
512 stats = mergemod.update(repo, parent, True, True, False,
512 node, False)
513 node, False)
513 repo.setparents(op1, op2)
514 repo.setparents(op1, op2)
514 repo.dirstate.endparentchange()
515 repo.dirstate.endparentchange()
515 hg._showstats(repo, stats)
516 hg._showstats(repo, stats)
516 if stats[3]:
517 if stats[3]:
517 repo.ui.status(_("use 'hg resolve' to retry unresolved "
518 repo.ui.status(_("use 'hg resolve' to retry unresolved "
518 "file merges\n"))
519 "file merges\n"))
519 else:
520 else:
520 msg = _("changeset %s backed out, "
521 msg = _("changeset %s backed out, "
521 "don't forget to commit.\n")
522 "don't forget to commit.\n")
522 ui.status(msg % short(node))
523 ui.status(msg % short(node))
523 return stats[3] > 0
524 return stats[3] > 0
524 finally:
525 finally:
525 ui.setconfig('ui', 'forcemerge', '', '')
526 ui.setconfig('ui', 'forcemerge', '', '')
526 else:
527 else:
527 hg.clean(repo, node, show_stats=False)
528 hg.clean(repo, node, show_stats=False)
528 repo.dirstate.setbranch(branch)
529 repo.dirstate.setbranch(branch)
529 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
530 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
530
531
531
532
532 def commitfunc(ui, repo, message, match, opts):
533 def commitfunc(ui, repo, message, match, opts):
533 editform = 'backout'
534 editform = 'backout'
534 e = cmdutil.getcommiteditor(editform=editform, **opts)
535 e = cmdutil.getcommiteditor(editform=editform, **opts)
535 if not message:
536 if not message:
536 # we don't translate commit messages
537 # we don't translate commit messages
537 message = "Backed out changeset %s" % short(node)
538 message = "Backed out changeset %s" % short(node)
538 e = cmdutil.getcommiteditor(edit=True, editform=editform)
539 e = cmdutil.getcommiteditor(edit=True, editform=editform)
539 return repo.commit(message, opts.get('user'), opts.get('date'),
540 return repo.commit(message, opts.get('user'), opts.get('date'),
540 match, editor=e)
541 match, editor=e)
541 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
542 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
542 if not newnode:
543 if not newnode:
543 ui.status(_("nothing changed\n"))
544 ui.status(_("nothing changed\n"))
544 return 1
545 return 1
545 cmdutil.commitstatus(repo, newnode, branch, bheads)
546 cmdutil.commitstatus(repo, newnode, branch, bheads)
546
547
547 def nice(node):
548 def nice(node):
548 return '%d:%s' % (repo.changelog.rev(node), short(node))
549 return '%d:%s' % (repo.changelog.rev(node), short(node))
549 ui.status(_('changeset %s backs out changeset %s\n') %
550 ui.status(_('changeset %s backs out changeset %s\n') %
550 (nice(repo.changelog.tip()), nice(node)))
551 (nice(repo.changelog.tip()), nice(node)))
551 if opts.get('merge') and op1 != node:
552 if opts.get('merge') and op1 != node:
552 hg.clean(repo, op1, show_stats=False)
553 hg.clean(repo, op1, show_stats=False)
553 ui.status(_('merging with changeset %s\n')
554 ui.status(_('merging with changeset %s\n')
554 % nice(repo.changelog.tip()))
555 % nice(repo.changelog.tip()))
555 try:
556 try:
556 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
557 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
557 'backout')
558 'backout')
558 return hg.merge(repo, hex(repo.changelog.tip()))
559 return hg.merge(repo, hex(repo.changelog.tip()))
559 finally:
560 finally:
560 ui.setconfig('ui', 'forcemerge', '', '')
561 ui.setconfig('ui', 'forcemerge', '', '')
561 finally:
562 finally:
562 wlock.release()
563 wlock.release()
563 return 0
564 return 0
564
565
565 @command('bisect',
566 @command('bisect',
566 [('r', 'reset', False, _('reset bisect state')),
567 [('r', 'reset', False, _('reset bisect state')),
567 ('g', 'good', False, _('mark changeset good')),
568 ('g', 'good', False, _('mark changeset good')),
568 ('b', 'bad', False, _('mark changeset bad')),
569 ('b', 'bad', False, _('mark changeset bad')),
569 ('s', 'skip', False, _('skip testing changeset')),
570 ('s', 'skip', False, _('skip testing changeset')),
570 ('e', 'extend', False, _('extend the bisect range')),
571 ('e', 'extend', False, _('extend the bisect range')),
571 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
572 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
572 ('U', 'noupdate', False, _('do not update to target'))],
573 ('U', 'noupdate', False, _('do not update to target'))],
573 _("[-gbsr] [-U] [-c CMD] [REV]"))
574 _("[-gbsr] [-U] [-c CMD] [REV]"))
574 def bisect(ui, repo, rev=None, extra=None, command=None,
575 def bisect(ui, repo, rev=None, extra=None, command=None,
575 reset=None, good=None, bad=None, skip=None, extend=None,
576 reset=None, good=None, bad=None, skip=None, extend=None,
576 noupdate=None):
577 noupdate=None):
577 """subdivision search of changesets
578 """subdivision search of changesets
578
579
579 This command helps to find changesets which introduce problems. To
580 This command helps to find changesets which introduce problems. To
580 use, mark the earliest changeset you know exhibits the problem as
581 use, mark the earliest changeset you know exhibits the problem as
581 bad, then mark the latest changeset which is free from the problem
582 bad, then mark the latest changeset which is free from the problem
582 as good. Bisect will update your working directory to a revision
583 as good. Bisect will update your working directory to a revision
583 for testing (unless the -U/--noupdate option is specified). Once
584 for testing (unless the -U/--noupdate option is specified). Once
584 you have performed tests, mark the working directory as good or
585 you have performed tests, mark the working directory as good or
585 bad, and bisect will either update to another candidate changeset
586 bad, and bisect will either update to another candidate changeset
586 or announce that it has found the bad revision.
587 or announce that it has found the bad revision.
587
588
588 As a shortcut, you can also use the revision argument to mark a
589 As a shortcut, you can also use the revision argument to mark a
589 revision as good or bad without checking it out first.
590 revision as good or bad without checking it out first.
590
591
591 If you supply a command, it will be used for automatic bisection.
592 If you supply a command, it will be used for automatic bisection.
592 The environment variable HG_NODE will contain the ID of the
593 The environment variable HG_NODE will contain the ID of the
593 changeset being tested. The exit status of the command will be
594 changeset being tested. The exit status of the command will be
594 used to mark revisions as good or bad: status 0 means good, 125
595 used to mark revisions as good or bad: status 0 means good, 125
595 means to skip the revision, 127 (command not found) will abort the
596 means to skip the revision, 127 (command not found) will abort the
596 bisection, and any other non-zero exit status means the revision
597 bisection, and any other non-zero exit status means the revision
597 is bad.
598 is bad.
598
599
599 .. container:: verbose
600 .. container:: verbose
600
601
601 Some examples:
602 Some examples:
602
603
603 - start a bisection with known bad revision 34, and good revision 12::
604 - start a bisection with known bad revision 34, and good revision 12::
604
605
605 hg bisect --bad 34
606 hg bisect --bad 34
606 hg bisect --good 12
607 hg bisect --good 12
607
608
608 - advance the current bisection by marking current revision as good or
609 - advance the current bisection by marking current revision as good or
609 bad::
610 bad::
610
611
611 hg bisect --good
612 hg bisect --good
612 hg bisect --bad
613 hg bisect --bad
613
614
614 - mark the current revision, or a known revision, to be skipped (e.g. if
615 - mark the current revision, or a known revision, to be skipped (e.g. if
615 that revision is not usable because of another issue)::
616 that revision is not usable because of another issue)::
616
617
617 hg bisect --skip
618 hg bisect --skip
618 hg bisect --skip 23
619 hg bisect --skip 23
619
620
620 - skip all revisions that do not touch directories ``foo`` or ``bar``::
621 - skip all revisions that do not touch directories ``foo`` or ``bar``::
621
622
622 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
623 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
623
624
624 - forget the current bisection::
625 - forget the current bisection::
625
626
626 hg bisect --reset
627 hg bisect --reset
627
628
628 - use 'make && make tests' to automatically find the first broken
629 - use 'make && make tests' to automatically find the first broken
629 revision::
630 revision::
630
631
631 hg bisect --reset
632 hg bisect --reset
632 hg bisect --bad 34
633 hg bisect --bad 34
633 hg bisect --good 12
634 hg bisect --good 12
634 hg bisect --command "make && make tests"
635 hg bisect --command "make && make tests"
635
636
636 - see all changesets whose states are already known in the current
637 - see all changesets whose states are already known in the current
637 bisection::
638 bisection::
638
639
639 hg log -r "bisect(pruned)"
640 hg log -r "bisect(pruned)"
640
641
641 - see the changeset currently being bisected (especially useful
642 - see the changeset currently being bisected (especially useful
642 if running with -U/--noupdate)::
643 if running with -U/--noupdate)::
643
644
644 hg log -r "bisect(current)"
645 hg log -r "bisect(current)"
645
646
646 - see all changesets that took part in the current bisection::
647 - see all changesets that took part in the current bisection::
647
648
648 hg log -r "bisect(range)"
649 hg log -r "bisect(range)"
649
650
650 - you can even get a nice graph::
651 - you can even get a nice graph::
651
652
652 hg log --graph -r "bisect(range)"
653 hg log --graph -r "bisect(range)"
653
654
654 See :hg:`help revsets` for more about the `bisect()` keyword.
655 See :hg:`help revsets` for more about the `bisect()` keyword.
655
656
656 Returns 0 on success.
657 Returns 0 on success.
657 """
658 """
658 def extendbisectrange(nodes, good):
659 def extendbisectrange(nodes, good):
659 # bisect is incomplete when it ends on a merge node and
660 # bisect is incomplete when it ends on a merge node and
660 # one of the parent was not checked.
661 # one of the parent was not checked.
661 parents = repo[nodes[0]].parents()
662 parents = repo[nodes[0]].parents()
662 if len(parents) > 1:
663 if len(parents) > 1:
663 side = good and state['bad'] or state['good']
664 side = good and state['bad'] or state['good']
664 num = len(set(i.node() for i in parents) & set(side))
665 num = len(set(i.node() for i in parents) & set(side))
665 if num == 1:
666 if num == 1:
666 return parents[0].ancestor(parents[1])
667 return parents[0].ancestor(parents[1])
667 return None
668 return None
668
669
669 def print_result(nodes, good):
670 def print_result(nodes, good):
670 displayer = cmdutil.show_changeset(ui, repo, {})
671 displayer = cmdutil.show_changeset(ui, repo, {})
671 if len(nodes) == 1:
672 if len(nodes) == 1:
672 # narrowed it down to a single revision
673 # narrowed it down to a single revision
673 if good:
674 if good:
674 ui.write(_("The first good revision is:\n"))
675 ui.write(_("The first good revision is:\n"))
675 else:
676 else:
676 ui.write(_("The first bad revision is:\n"))
677 ui.write(_("The first bad revision is:\n"))
677 displayer.show(repo[nodes[0]])
678 displayer.show(repo[nodes[0]])
678 extendnode = extendbisectrange(nodes, good)
679 extendnode = extendbisectrange(nodes, good)
679 if extendnode is not None:
680 if extendnode is not None:
680 ui.write(_('Not all ancestors of this changeset have been'
681 ui.write(_('Not all ancestors of this changeset have been'
681 ' checked.\nUse bisect --extend to continue the '
682 ' checked.\nUse bisect --extend to continue the '
682 'bisection from\nthe common ancestor, %s.\n')
683 'bisection from\nthe common ancestor, %s.\n')
683 % extendnode)
684 % extendnode)
684 else:
685 else:
685 # multiple possible revisions
686 # multiple possible revisions
686 if good:
687 if good:
687 ui.write(_("Due to skipped revisions, the first "
688 ui.write(_("Due to skipped revisions, the first "
688 "good revision could be any of:\n"))
689 "good revision could be any of:\n"))
689 else:
690 else:
690 ui.write(_("Due to skipped revisions, the first "
691 ui.write(_("Due to skipped revisions, the first "
691 "bad revision could be any of:\n"))
692 "bad revision could be any of:\n"))
692 for n in nodes:
693 for n in nodes:
693 displayer.show(repo[n])
694 displayer.show(repo[n])
694 displayer.close()
695 displayer.close()
695
696
696 def check_state(state, interactive=True):
697 def check_state(state, interactive=True):
697 if not state['good'] or not state['bad']:
698 if not state['good'] or not state['bad']:
698 if (good or bad or skip or reset) and interactive:
699 if (good or bad or skip or reset) and interactive:
699 return
700 return
700 if not state['good']:
701 if not state['good']:
701 raise util.Abort(_('cannot bisect (no known good revisions)'))
702 raise util.Abort(_('cannot bisect (no known good revisions)'))
702 else:
703 else:
703 raise util.Abort(_('cannot bisect (no known bad revisions)'))
704 raise util.Abort(_('cannot bisect (no known bad revisions)'))
704 return True
705 return True
705
706
706 # backward compatibility
707 # backward compatibility
707 if rev in "good bad reset init".split():
708 if rev in "good bad reset init".split():
708 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
709 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
709 cmd, rev, extra = rev, extra, None
710 cmd, rev, extra = rev, extra, None
710 if cmd == "good":
711 if cmd == "good":
711 good = True
712 good = True
712 elif cmd == "bad":
713 elif cmd == "bad":
713 bad = True
714 bad = True
714 else:
715 else:
715 reset = True
716 reset = True
716 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
717 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
717 raise util.Abort(_('incompatible arguments'))
718 raise util.Abort(_('incompatible arguments'))
718
719
719 cmdutil.checkunfinished(repo)
720 cmdutil.checkunfinished(repo)
720
721
721 if reset:
722 if reset:
722 p = repo.join("bisect.state")
723 p = repo.join("bisect.state")
723 if os.path.exists(p):
724 if os.path.exists(p):
724 os.unlink(p)
725 os.unlink(p)
725 return
726 return
726
727
727 state = hbisect.load_state(repo)
728 state = hbisect.load_state(repo)
728
729
729 if command:
730 if command:
730 changesets = 1
731 changesets = 1
731 if noupdate:
732 if noupdate:
732 try:
733 try:
733 node = state['current'][0]
734 node = state['current'][0]
734 except LookupError:
735 except LookupError:
735 raise util.Abort(_('current bisect revision is unknown - '
736 raise util.Abort(_('current bisect revision is unknown - '
736 'start a new bisect to fix'))
737 'start a new bisect to fix'))
737 else:
738 else:
738 node, p2 = repo.dirstate.parents()
739 node, p2 = repo.dirstate.parents()
739 if p2 != nullid:
740 if p2 != nullid:
740 raise util.Abort(_('current bisect revision is a merge'))
741 raise util.Abort(_('current bisect revision is a merge'))
741 try:
742 try:
742 while changesets:
743 while changesets:
743 # update state
744 # update state
744 state['current'] = [node]
745 state['current'] = [node]
745 hbisect.save_state(repo, state)
746 hbisect.save_state(repo, state)
746 status = ui.system(command, environ={'HG_NODE': hex(node)})
747 status = ui.system(command, environ={'HG_NODE': hex(node)})
747 if status == 125:
748 if status == 125:
748 transition = "skip"
749 transition = "skip"
749 elif status == 0:
750 elif status == 0:
750 transition = "good"
751 transition = "good"
751 # status < 0 means process was killed
752 # status < 0 means process was killed
752 elif status == 127:
753 elif status == 127:
753 raise util.Abort(_("failed to execute %s") % command)
754 raise util.Abort(_("failed to execute %s") % command)
754 elif status < 0:
755 elif status < 0:
755 raise util.Abort(_("%s killed") % command)
756 raise util.Abort(_("%s killed") % command)
756 else:
757 else:
757 transition = "bad"
758 transition = "bad"
758 ctx = scmutil.revsingle(repo, rev, node)
759 ctx = scmutil.revsingle(repo, rev, node)
759 rev = None # clear for future iterations
760 rev = None # clear for future iterations
760 state[transition].append(ctx.node())
761 state[transition].append(ctx.node())
761 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
762 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
762 check_state(state, interactive=False)
763 check_state(state, interactive=False)
763 # bisect
764 # bisect
764 nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
765 nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
765 # update to next check
766 # update to next check
766 node = nodes[0]
767 node = nodes[0]
767 if not noupdate:
768 if not noupdate:
768 cmdutil.bailifchanged(repo)
769 cmdutil.bailifchanged(repo)
769 hg.clean(repo, node, show_stats=False)
770 hg.clean(repo, node, show_stats=False)
770 finally:
771 finally:
771 state['current'] = [node]
772 state['current'] = [node]
772 hbisect.save_state(repo, state)
773 hbisect.save_state(repo, state)
773 print_result(nodes, bgood)
774 print_result(nodes, bgood)
774 return
775 return
775
776
776 # update state
777 # update state
777
778
778 if rev:
779 if rev:
779 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
780 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
780 else:
781 else:
781 nodes = [repo.lookup('.')]
782 nodes = [repo.lookup('.')]
782
783
783 if good or bad or skip:
784 if good or bad or skip:
784 if good:
785 if good:
785 state['good'] += nodes
786 state['good'] += nodes
786 elif bad:
787 elif bad:
787 state['bad'] += nodes
788 state['bad'] += nodes
788 elif skip:
789 elif skip:
789 state['skip'] += nodes
790 state['skip'] += nodes
790 hbisect.save_state(repo, state)
791 hbisect.save_state(repo, state)
791
792
792 if not check_state(state):
793 if not check_state(state):
793 return
794 return
794
795
795 # actually bisect
796 # actually bisect
796 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
797 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
797 if extend:
798 if extend:
798 if not changesets:
799 if not changesets:
799 extendnode = extendbisectrange(nodes, good)
800 extendnode = extendbisectrange(nodes, good)
800 if extendnode is not None:
801 if extendnode is not None:
801 ui.write(_("Extending search to changeset %d:%s\n")
802 ui.write(_("Extending search to changeset %d:%s\n")
802 % (extendnode.rev(), extendnode))
803 % (extendnode.rev(), extendnode))
803 state['current'] = [extendnode.node()]
804 state['current'] = [extendnode.node()]
804 hbisect.save_state(repo, state)
805 hbisect.save_state(repo, state)
805 if noupdate:
806 if noupdate:
806 return
807 return
807 cmdutil.bailifchanged(repo)
808 cmdutil.bailifchanged(repo)
808 return hg.clean(repo, extendnode.node())
809 return hg.clean(repo, extendnode.node())
809 raise util.Abort(_("nothing to extend"))
810 raise util.Abort(_("nothing to extend"))
810
811
811 if changesets == 0:
812 if changesets == 0:
812 print_result(nodes, good)
813 print_result(nodes, good)
813 else:
814 else:
814 assert len(nodes) == 1 # only a single node can be tested next
815 assert len(nodes) == 1 # only a single node can be tested next
815 node = nodes[0]
816 node = nodes[0]
816 # compute the approximate number of remaining tests
817 # compute the approximate number of remaining tests
817 tests, size = 0, 2
818 tests, size = 0, 2
818 while size <= changesets:
819 while size <= changesets:
819 tests, size = tests + 1, size * 2
820 tests, size = tests + 1, size * 2
820 rev = repo.changelog.rev(node)
821 rev = repo.changelog.rev(node)
821 ui.write(_("Testing changeset %d:%s "
822 ui.write(_("Testing changeset %d:%s "
822 "(%d changesets remaining, ~%d tests)\n")
823 "(%d changesets remaining, ~%d tests)\n")
823 % (rev, short(node), changesets, tests))
824 % (rev, short(node), changesets, tests))
824 state['current'] = [node]
825 state['current'] = [node]
825 hbisect.save_state(repo, state)
826 hbisect.save_state(repo, state)
826 if not noupdate:
827 if not noupdate:
827 cmdutil.bailifchanged(repo)
828 cmdutil.bailifchanged(repo)
828 return hg.clean(repo, node)
829 return hg.clean(repo, node)
829
830
830 @command('bookmarks|bookmark',
831 @command('bookmarks|bookmark',
831 [('f', 'force', False, _('force')),
832 [('f', 'force', False, _('force')),
832 ('r', 'rev', '', _('revision'), _('REV')),
833 ('r', 'rev', '', _('revision'), _('REV')),
833 ('d', 'delete', False, _('delete a given bookmark')),
834 ('d', 'delete', False, _('delete a given bookmark')),
834 ('m', 'rename', '', _('rename a given bookmark'), _('NAME')),
835 ('m', 'rename', '', _('rename a given bookmark'), _('NAME')),
835 ('i', 'inactive', False, _('mark a bookmark inactive')),
836 ('i', 'inactive', False, _('mark a bookmark inactive')),
836 ] + formatteropts,
837 ] + formatteropts,
837 _('hg bookmarks [OPTIONS]... [NAME]...'))
838 _('hg bookmarks [OPTIONS]... [NAME]...'))
838 def bookmark(ui, repo, *names, **opts):
839 def bookmark(ui, repo, *names, **opts):
839 '''create a new bookmark or list existing bookmarks
840 '''create a new bookmark or list existing bookmarks
840
841
841 Bookmarks are labels on changesets to help track lines of development.
842 Bookmarks are labels on changesets to help track lines of development.
842 Bookmarks are unversioned and can be moved, renamed and deleted.
843 Bookmarks are unversioned and can be moved, renamed and deleted.
843 Deleting or moving a bookmark has no effect on the associated changesets.
844 Deleting or moving a bookmark has no effect on the associated changesets.
844
845
845 Creating or updating to a bookmark causes it to be marked as 'active'.
846 Creating or updating to a bookmark causes it to be marked as 'active'.
846 The active bookmark is indicated with a '*'.
847 The active bookmark is indicated with a '*'.
847 When a commit is made, the active bookmark will advance to the new commit.
848 When a commit is made, the active bookmark will advance to the new commit.
848 A plain :hg:`update` will also advance an active bookmark, if possible.
849 A plain :hg:`update` will also advance an active bookmark, if possible.
849 Updating away from a bookmark will cause it to be deactivated.
850 Updating away from a bookmark will cause it to be deactivated.
850
851
851 Bookmarks can be pushed and pulled between repositories (see
852 Bookmarks can be pushed and pulled between repositories (see
852 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
853 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
853 diverged, a new 'divergent bookmark' of the form 'name@path' will
854 diverged, a new 'divergent bookmark' of the form 'name@path' will
854 be created. Using :hg:`merge` will resolve the divergence.
855 be created. Using :hg:`merge` will resolve the divergence.
855
856
856 A bookmark named '@' has the special property that :hg:`clone` will
857 A bookmark named '@' has the special property that :hg:`clone` will
857 check it out by default if it exists.
858 check it out by default if it exists.
858
859
859 .. container:: verbose
860 .. container:: verbose
860
861
861 Examples:
862 Examples:
862
863
863 - create an active bookmark for a new line of development::
864 - create an active bookmark for a new line of development::
864
865
865 hg book new-feature
866 hg book new-feature
866
867
867 - create an inactive bookmark as a place marker::
868 - create an inactive bookmark as a place marker::
868
869
869 hg book -i reviewed
870 hg book -i reviewed
870
871
871 - create an inactive bookmark on another changeset::
872 - create an inactive bookmark on another changeset::
872
873
873 hg book -r .^ tested
874 hg book -r .^ tested
874
875
875 - move the '@' bookmark from another branch::
876 - move the '@' bookmark from another branch::
876
877
877 hg book -f @
878 hg book -f @
878 '''
879 '''
879 force = opts.get('force')
880 force = opts.get('force')
880 rev = opts.get('rev')
881 rev = opts.get('rev')
881 delete = opts.get('delete')
882 delete = opts.get('delete')
882 rename = opts.get('rename')
883 rename = opts.get('rename')
883 inactive = opts.get('inactive')
884 inactive = opts.get('inactive')
884
885
885 def checkformat(mark):
886 def checkformat(mark):
886 mark = mark.strip()
887 mark = mark.strip()
887 if not mark:
888 if not mark:
888 raise util.Abort(_("bookmark names cannot consist entirely of "
889 raise util.Abort(_("bookmark names cannot consist entirely of "
889 "whitespace"))
890 "whitespace"))
890 scmutil.checknewlabel(repo, mark, 'bookmark')
891 scmutil.checknewlabel(repo, mark, 'bookmark')
891 return mark
892 return mark
892
893
893 def checkconflict(repo, mark, cur, force=False, target=None):
894 def checkconflict(repo, mark, cur, force=False, target=None):
894 if mark in marks and not force:
895 if mark in marks and not force:
895 if target:
896 if target:
896 if marks[mark] == target and target == cur:
897 if marks[mark] == target and target == cur:
897 # re-activating a bookmark
898 # re-activating a bookmark
898 return
899 return
899 anc = repo.changelog.ancestors([repo[target].rev()])
900 anc = repo.changelog.ancestors([repo[target].rev()])
900 bmctx = repo[marks[mark]]
901 bmctx = repo[marks[mark]]
901 divs = [repo[b].node() for b in marks
902 divs = [repo[b].node() for b in marks
902 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
903 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
903
904
904 # allow resolving a single divergent bookmark even if moving
905 # allow resolving a single divergent bookmark even if moving
905 # the bookmark across branches when a revision is specified
906 # the bookmark across branches when a revision is specified
906 # that contains a divergent bookmark
907 # that contains a divergent bookmark
907 if bmctx.rev() not in anc and target in divs:
908 if bmctx.rev() not in anc and target in divs:
908 bookmarks.deletedivergent(repo, [target], mark)
909 bookmarks.deletedivergent(repo, [target], mark)
909 return
910 return
910
911
911 deletefrom = [b for b in divs
912 deletefrom = [b for b in divs
912 if repo[b].rev() in anc or b == target]
913 if repo[b].rev() in anc or b == target]
913 bookmarks.deletedivergent(repo, deletefrom, mark)
914 bookmarks.deletedivergent(repo, deletefrom, mark)
914 if bookmarks.validdest(repo, bmctx, repo[target]):
915 if bookmarks.validdest(repo, bmctx, repo[target]):
915 ui.status(_("moving bookmark '%s' forward from %s\n") %
916 ui.status(_("moving bookmark '%s' forward from %s\n") %
916 (mark, short(bmctx.node())))
917 (mark, short(bmctx.node())))
917 return
918 return
918 raise util.Abort(_("bookmark '%s' already exists "
919 raise util.Abort(_("bookmark '%s' already exists "
919 "(use -f to force)") % mark)
920 "(use -f to force)") % mark)
920 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
921 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
921 and not force):
922 and not force):
922 raise util.Abort(
923 raise util.Abort(
923 _("a bookmark cannot have the name of an existing branch"))
924 _("a bookmark cannot have the name of an existing branch"))
924
925
925 if delete and rename:
926 if delete and rename:
926 raise util.Abort(_("--delete and --rename are incompatible"))
927 raise util.Abort(_("--delete and --rename are incompatible"))
927 if delete and rev:
928 if delete and rev:
928 raise util.Abort(_("--rev is incompatible with --delete"))
929 raise util.Abort(_("--rev is incompatible with --delete"))
929 if rename and rev:
930 if rename and rev:
930 raise util.Abort(_("--rev is incompatible with --rename"))
931 raise util.Abort(_("--rev is incompatible with --rename"))
931 if not names and (delete or rev):
932 if not names and (delete or rev):
932 raise util.Abort(_("bookmark name required"))
933 raise util.Abort(_("bookmark name required"))
933
934
934 if delete or rename or names or inactive:
935 if delete or rename or names or inactive:
935 wlock = repo.wlock()
936 wlock = repo.wlock()
936 try:
937 try:
937 cur = repo.changectx('.').node()
938 cur = repo.changectx('.').node()
938 marks = repo._bookmarks
939 marks = repo._bookmarks
939 if delete:
940 if delete:
940 for mark in names:
941 for mark in names:
941 if mark not in marks:
942 if mark not in marks:
942 raise util.Abort(_("bookmark '%s' does not exist") %
943 raise util.Abort(_("bookmark '%s' does not exist") %
943 mark)
944 mark)
944 if mark == repo._bookmarkcurrent:
945 if mark == repo._bookmarkcurrent:
945 bookmarks.unsetcurrent(repo)
946 bookmarks.unsetcurrent(repo)
946 del marks[mark]
947 del marks[mark]
947 marks.write()
948 marks.write()
948
949
949 elif rename:
950 elif rename:
950 if not names:
951 if not names:
951 raise util.Abort(_("new bookmark name required"))
952 raise util.Abort(_("new bookmark name required"))
952 elif len(names) > 1:
953 elif len(names) > 1:
953 raise util.Abort(_("only one new bookmark name allowed"))
954 raise util.Abort(_("only one new bookmark name allowed"))
954 mark = checkformat(names[0])
955 mark = checkformat(names[0])
955 if rename not in marks:
956 if rename not in marks:
956 raise util.Abort(_("bookmark '%s' does not exist") % rename)
957 raise util.Abort(_("bookmark '%s' does not exist") % rename)
957 checkconflict(repo, mark, cur, force)
958 checkconflict(repo, mark, cur, force)
958 marks[mark] = marks[rename]
959 marks[mark] = marks[rename]
959 if repo._bookmarkcurrent == rename and not inactive:
960 if repo._bookmarkcurrent == rename and not inactive:
960 bookmarks.setcurrent(repo, mark)
961 bookmarks.setcurrent(repo, mark)
961 del marks[rename]
962 del marks[rename]
962 marks.write()
963 marks.write()
963
964
964 elif names:
965 elif names:
965 newact = None
966 newact = None
966 for mark in names:
967 for mark in names:
967 mark = checkformat(mark)
968 mark = checkformat(mark)
968 if newact is None:
969 if newact is None:
969 newact = mark
970 newact = mark
970 if inactive and mark == repo._bookmarkcurrent:
971 if inactive and mark == repo._bookmarkcurrent:
971 bookmarks.unsetcurrent(repo)
972 bookmarks.unsetcurrent(repo)
972 return
973 return
973 tgt = cur
974 tgt = cur
974 if rev:
975 if rev:
975 tgt = scmutil.revsingle(repo, rev).node()
976 tgt = scmutil.revsingle(repo, rev).node()
976 checkconflict(repo, mark, cur, force, tgt)
977 checkconflict(repo, mark, cur, force, tgt)
977 marks[mark] = tgt
978 marks[mark] = tgt
978 if not inactive and cur == marks[newact] and not rev:
979 if not inactive and cur == marks[newact] and not rev:
979 bookmarks.setcurrent(repo, newact)
980 bookmarks.setcurrent(repo, newact)
980 elif cur != tgt and newact == repo._bookmarkcurrent:
981 elif cur != tgt and newact == repo._bookmarkcurrent:
981 bookmarks.unsetcurrent(repo)
982 bookmarks.unsetcurrent(repo)
982 marks.write()
983 marks.write()
983
984
984 elif inactive:
985 elif inactive:
985 if len(marks) == 0:
986 if len(marks) == 0:
986 ui.status(_("no bookmarks set\n"))
987 ui.status(_("no bookmarks set\n"))
987 elif not repo._bookmarkcurrent:
988 elif not repo._bookmarkcurrent:
988 ui.status(_("no active bookmark\n"))
989 ui.status(_("no active bookmark\n"))
989 else:
990 else:
990 bookmarks.unsetcurrent(repo)
991 bookmarks.unsetcurrent(repo)
991 finally:
992 finally:
992 wlock.release()
993 wlock.release()
993 else: # show bookmarks
994 else: # show bookmarks
994 fm = ui.formatter('bookmarks', opts)
995 fm = ui.formatter('bookmarks', opts)
995 hexfn = fm.hexfunc
996 hexfn = fm.hexfunc
996 marks = repo._bookmarks
997 marks = repo._bookmarks
997 if len(marks) == 0 and not fm:
998 if len(marks) == 0 and not fm:
998 ui.status(_("no bookmarks set\n"))
999 ui.status(_("no bookmarks set\n"))
999 for bmark, n in sorted(marks.iteritems()):
1000 for bmark, n in sorted(marks.iteritems()):
1000 current = repo._bookmarkcurrent
1001 current = repo._bookmarkcurrent
1001 if bmark == current:
1002 if bmark == current:
1002 prefix, label = '*', 'bookmarks.current'
1003 prefix, label = '*', 'bookmarks.current'
1003 else:
1004 else:
1004 prefix, label = ' ', ''
1005 prefix, label = ' ', ''
1005
1006
1006 fm.startitem()
1007 fm.startitem()
1007 if not ui.quiet:
1008 if not ui.quiet:
1008 fm.plain(' %s ' % prefix, label=label)
1009 fm.plain(' %s ' % prefix, label=label)
1009 fm.write('bookmark', '%s', bmark, label=label)
1010 fm.write('bookmark', '%s', bmark, label=label)
1010 pad = " " * (25 - encoding.colwidth(bmark))
1011 pad = " " * (25 - encoding.colwidth(bmark))
1011 fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s',
1012 fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s',
1012 repo.changelog.rev(n), hexfn(n), label=label)
1013 repo.changelog.rev(n), hexfn(n), label=label)
1013 fm.data(active=(bmark == current))
1014 fm.data(active=(bmark == current))
1014 fm.plain('\n')
1015 fm.plain('\n')
1015 fm.end()
1016 fm.end()
1016
1017
1017 @command('branch',
1018 @command('branch',
1018 [('f', 'force', None,
1019 [('f', 'force', None,
1019 _('set branch name even if it shadows an existing branch')),
1020 _('set branch name even if it shadows an existing branch')),
1020 ('C', 'clean', None, _('reset branch name to parent branch name'))],
1021 ('C', 'clean', None, _('reset branch name to parent branch name'))],
1021 _('[-fC] [NAME]'))
1022 _('[-fC] [NAME]'))
1022 def branch(ui, repo, label=None, **opts):
1023 def branch(ui, repo, label=None, **opts):
1023 """set or show the current branch name
1024 """set or show the current branch name
1024
1025
1025 .. note::
1026 .. note::
1026
1027
1027 Branch names are permanent and global. Use :hg:`bookmark` to create a
1028 Branch names are permanent and global. Use :hg:`bookmark` to create a
1028 light-weight bookmark instead. See :hg:`help glossary` for more
1029 light-weight bookmark instead. See :hg:`help glossary` for more
1029 information about named branches and bookmarks.
1030 information about named branches and bookmarks.
1030
1031
1031 With no argument, show the current branch name. With one argument,
1032 With no argument, show the current branch name. With one argument,
1032 set the working directory branch name (the branch will not exist
1033 set the working directory branch name (the branch will not exist
1033 in the repository until the next commit). Standard practice
1034 in the repository until the next commit). Standard practice
1034 recommends that primary development take place on the 'default'
1035 recommends that primary development take place on the 'default'
1035 branch.
1036 branch.
1036
1037
1037 Unless -f/--force is specified, branch will not let you set a
1038 Unless -f/--force is specified, branch will not let you set a
1038 branch name that already exists, even if it's inactive.
1039 branch name that already exists, even if it's inactive.
1039
1040
1040 Use -C/--clean to reset the working directory branch to that of
1041 Use -C/--clean to reset the working directory branch to that of
1041 the parent of the working directory, negating a previous branch
1042 the parent of the working directory, negating a previous branch
1042 change.
1043 change.
1043
1044
1044 Use the command :hg:`update` to switch to an existing branch. Use
1045 Use the command :hg:`update` to switch to an existing branch. Use
1045 :hg:`commit --close-branch` to mark this branch as closed.
1046 :hg:`commit --close-branch` to mark this branch as closed.
1046
1047
1047 Returns 0 on success.
1048 Returns 0 on success.
1048 """
1049 """
1049 if label:
1050 if label:
1050 label = label.strip()
1051 label = label.strip()
1051
1052
1052 if not opts.get('clean') and not label:
1053 if not opts.get('clean') and not label:
1053 ui.write("%s\n" % repo.dirstate.branch())
1054 ui.write("%s\n" % repo.dirstate.branch())
1054 return
1055 return
1055
1056
1056 wlock = repo.wlock()
1057 wlock = repo.wlock()
1057 try:
1058 try:
1058 if opts.get('clean'):
1059 if opts.get('clean'):
1059 label = repo[None].p1().branch()
1060 label = repo[None].p1().branch()
1060 repo.dirstate.setbranch(label)
1061 repo.dirstate.setbranch(label)
1061 ui.status(_('reset working directory to branch %s\n') % label)
1062 ui.status(_('reset working directory to branch %s\n') % label)
1062 elif label:
1063 elif label:
1063 if not opts.get('force') and label in repo.branchmap():
1064 if not opts.get('force') and label in repo.branchmap():
1064 if label not in [p.branch() for p in repo.parents()]:
1065 if label not in [p.branch() for p in repo.parents()]:
1065 raise util.Abort(_('a branch of the same name already'
1066 raise util.Abort(_('a branch of the same name already'
1066 ' exists'),
1067 ' exists'),
1067 # i18n: "it" refers to an existing branch
1068 # i18n: "it" refers to an existing branch
1068 hint=_("use 'hg update' to switch to it"))
1069 hint=_("use 'hg update' to switch to it"))
1069 scmutil.checknewlabel(repo, label, 'branch')
1070 scmutil.checknewlabel(repo, label, 'branch')
1070 repo.dirstate.setbranch(label)
1071 repo.dirstate.setbranch(label)
1071 ui.status(_('marked working directory as branch %s\n') % label)
1072 ui.status(_('marked working directory as branch %s\n') % label)
1072 ui.status(_('(branches are permanent and global, '
1073 ui.status(_('(branches are permanent and global, '
1073 'did you want a bookmark?)\n'))
1074 'did you want a bookmark?)\n'))
1074 finally:
1075 finally:
1075 wlock.release()
1076 wlock.release()
1076
1077
1077 @command('branches',
1078 @command('branches',
1078 [('a', 'active', False, _('show only branches that have unmerged heads')),
1079 [('a', 'active', False, _('show only branches that have unmerged heads')),
1079 ('c', 'closed', False, _('show normal and closed branches')),
1080 ('c', 'closed', False, _('show normal and closed branches')),
1080 ] + formatteropts,
1081 ] + formatteropts,
1081 _('[-ac]'))
1082 _('[-ac]'))
1082 def branches(ui, repo, active=False, closed=False, **opts):
1083 def branches(ui, repo, active=False, closed=False, **opts):
1083 """list repository named branches
1084 """list repository named branches
1084
1085
1085 List the repository's named branches, indicating which ones are
1086 List the repository's named branches, indicating which ones are
1086 inactive. If -c/--closed is specified, also list branches which have
1087 inactive. If -c/--closed is specified, also list branches which have
1087 been marked closed (see :hg:`commit --close-branch`).
1088 been marked closed (see :hg:`commit --close-branch`).
1088
1089
1089 If -a/--active is specified, only show active branches. A branch
1090 If -a/--active is specified, only show active branches. A branch
1090 is considered active if it contains repository heads.
1091 is considered active if it contains repository heads.
1091
1092
1092 Use the command :hg:`update` to switch to an existing branch.
1093 Use the command :hg:`update` to switch to an existing branch.
1093
1094
1094 Returns 0.
1095 Returns 0.
1095 """
1096 """
1096
1097
1097 fm = ui.formatter('branches', opts)
1098 fm = ui.formatter('branches', opts)
1098 hexfunc = fm.hexfunc
1099 hexfunc = fm.hexfunc
1099
1100
1100 allheads = set(repo.heads())
1101 allheads = set(repo.heads())
1101 branches = []
1102 branches = []
1102 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1103 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1103 isactive = not isclosed and bool(set(heads) & allheads)
1104 isactive = not isclosed and bool(set(heads) & allheads)
1104 branches.append((tag, repo[tip], isactive, not isclosed))
1105 branches.append((tag, repo[tip], isactive, not isclosed))
1105 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1106 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1106 reverse=True)
1107 reverse=True)
1107
1108
1108 for tag, ctx, isactive, isopen in branches:
1109 for tag, ctx, isactive, isopen in branches:
1109 if active and not isactive:
1110 if active and not isactive:
1110 continue
1111 continue
1111 if isactive:
1112 if isactive:
1112 label = 'branches.active'
1113 label = 'branches.active'
1113 notice = ''
1114 notice = ''
1114 elif not isopen:
1115 elif not isopen:
1115 if not closed:
1116 if not closed:
1116 continue
1117 continue
1117 label = 'branches.closed'
1118 label = 'branches.closed'
1118 notice = _(' (closed)')
1119 notice = _(' (closed)')
1119 else:
1120 else:
1120 label = 'branches.inactive'
1121 label = 'branches.inactive'
1121 notice = _(' (inactive)')
1122 notice = _(' (inactive)')
1122 current = (tag == repo.dirstate.branch())
1123 current = (tag == repo.dirstate.branch())
1123 if current:
1124 if current:
1124 label = 'branches.current'
1125 label = 'branches.current'
1125
1126
1126 fm.startitem()
1127 fm.startitem()
1127 fm.write('branch', '%s', tag, label=label)
1128 fm.write('branch', '%s', tag, label=label)
1128 rev = ctx.rev()
1129 rev = ctx.rev()
1129 padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0)
1130 padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0)
1130 fmt = ' ' * padsize + ' %d:%s'
1131 fmt = ' ' * padsize + ' %d:%s'
1131 fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
1132 fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
1132 label='log.changeset changeset.%s' % ctx.phasestr())
1133 label='log.changeset changeset.%s' % ctx.phasestr())
1133 fm.data(active=isactive, closed=not isopen, current=current)
1134 fm.data(active=isactive, closed=not isopen, current=current)
1134 if not ui.quiet:
1135 if not ui.quiet:
1135 fm.plain(notice)
1136 fm.plain(notice)
1136 fm.plain('\n')
1137 fm.plain('\n')
1137 fm.end()
1138 fm.end()
1138
1139
1139 @command('bundle',
1140 @command('bundle',
1140 [('f', 'force', None, _('run even when the destination is unrelated')),
1141 [('f', 'force', None, _('run even when the destination is unrelated')),
1141 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1142 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1142 _('REV')),
1143 _('REV')),
1143 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1144 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1144 _('BRANCH')),
1145 _('BRANCH')),
1145 ('', 'base', [],
1146 ('', 'base', [],
1146 _('a base changeset assumed to be available at the destination'),
1147 _('a base changeset assumed to be available at the destination'),
1147 _('REV')),
1148 _('REV')),
1148 ('a', 'all', None, _('bundle all changesets in the repository')),
1149 ('a', 'all', None, _('bundle all changesets in the repository')),
1149 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1150 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1150 ] + remoteopts,
1151 ] + remoteopts,
1151 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1152 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1152 def bundle(ui, repo, fname, dest=None, **opts):
1153 def bundle(ui, repo, fname, dest=None, **opts):
1153 """create a changegroup file
1154 """create a changegroup file
1154
1155
1155 Generate a compressed changegroup file collecting changesets not
1156 Generate a compressed changegroup file collecting changesets not
1156 known to be in another repository.
1157 known to be in another repository.
1157
1158
1158 If you omit the destination repository, then hg assumes the
1159 If you omit the destination repository, then hg assumes the
1159 destination will have all the nodes you specify with --base
1160 destination will have all the nodes you specify with --base
1160 parameters. To create a bundle containing all changesets, use
1161 parameters. To create a bundle containing all changesets, use
1161 -a/--all (or --base null).
1162 -a/--all (or --base null).
1162
1163
1163 You can change compression method with the -t/--type option.
1164 You can change compression method with the -t/--type option.
1164 The available compression methods are: none, bzip2, and
1165 The available compression methods are: none, bzip2, and
1165 gzip (by default, bundles are compressed using bzip2).
1166 gzip (by default, bundles are compressed using bzip2).
1166
1167
1167 The bundle file can then be transferred using conventional means
1168 The bundle file can then be transferred using conventional means
1168 and applied to another repository with the unbundle or pull
1169 and applied to another repository with the unbundle or pull
1169 command. This is useful when direct push and pull are not
1170 command. This is useful when direct push and pull are not
1170 available or when exporting an entire repository is undesirable.
1171 available or when exporting an entire repository is undesirable.
1171
1172
1172 Applying bundles preserves all changeset contents including
1173 Applying bundles preserves all changeset contents including
1173 permissions, copy/rename information, and revision history.
1174 permissions, copy/rename information, and revision history.
1174
1175
1175 Returns 0 on success, 1 if no changes found.
1176 Returns 0 on success, 1 if no changes found.
1176 """
1177 """
1177 revs = None
1178 revs = None
1178 if 'rev' in opts:
1179 if 'rev' in opts:
1179 revs = scmutil.revrange(repo, opts['rev'])
1180 revs = scmutil.revrange(repo, opts['rev'])
1180
1181
1181 bundletype = opts.get('type', 'bzip2').lower()
1182 bundletype = opts.get('type', 'bzip2').lower()
1182 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
1183 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
1183 bundletype = btypes.get(bundletype)
1184 bundletype = btypes.get(bundletype)
1184 if bundletype not in changegroup.bundletypes:
1185 if bundletype not in changegroup.bundletypes:
1185 raise util.Abort(_('unknown bundle type specified with --type'))
1186 raise util.Abort(_('unknown bundle type specified with --type'))
1186
1187
1187 if opts.get('all'):
1188 if opts.get('all'):
1188 base = ['null']
1189 base = ['null']
1189 else:
1190 else:
1190 base = scmutil.revrange(repo, opts.get('base'))
1191 base = scmutil.revrange(repo, opts.get('base'))
1191 # TODO: get desired bundlecaps from command line.
1192 # TODO: get desired bundlecaps from command line.
1192 bundlecaps = None
1193 bundlecaps = None
1193 if base:
1194 if base:
1194 if dest:
1195 if dest:
1195 raise util.Abort(_("--base is incompatible with specifying "
1196 raise util.Abort(_("--base is incompatible with specifying "
1196 "a destination"))
1197 "a destination"))
1197 common = [repo.lookup(rev) for rev in base]
1198 common = [repo.lookup(rev) for rev in base]
1198 heads = revs and map(repo.lookup, revs) or revs
1199 heads = revs and map(repo.lookup, revs) or revs
1199 cg = changegroup.getchangegroup(repo, 'bundle', heads=heads,
1200 cg = changegroup.getchangegroup(repo, 'bundle', heads=heads,
1200 common=common, bundlecaps=bundlecaps)
1201 common=common, bundlecaps=bundlecaps)
1201 outgoing = None
1202 outgoing = None
1202 else:
1203 else:
1203 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1204 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1204 dest, branches = hg.parseurl(dest, opts.get('branch'))
1205 dest, branches = hg.parseurl(dest, opts.get('branch'))
1205 other = hg.peer(repo, opts, dest)
1206 other = hg.peer(repo, opts, dest)
1206 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1207 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1207 heads = revs and map(repo.lookup, revs) or revs
1208 heads = revs and map(repo.lookup, revs) or revs
1208 outgoing = discovery.findcommonoutgoing(repo, other,
1209 outgoing = discovery.findcommonoutgoing(repo, other,
1209 onlyheads=heads,
1210 onlyheads=heads,
1210 force=opts.get('force'),
1211 force=opts.get('force'),
1211 portable=True)
1212 portable=True)
1212 cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing,
1213 cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing,
1213 bundlecaps)
1214 bundlecaps)
1214 if not cg:
1215 if not cg:
1215 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1216 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1216 return 1
1217 return 1
1217
1218
1218 changegroup.writebundle(cg, fname, bundletype)
1219 changegroup.writebundle(cg, fname, bundletype)
1219
1220
1220 @command('cat',
1221 @command('cat',
1221 [('o', 'output', '',
1222 [('o', 'output', '',
1222 _('print output to file with formatted name'), _('FORMAT')),
1223 _('print output to file with formatted name'), _('FORMAT')),
1223 ('r', 'rev', '', _('print the given revision'), _('REV')),
1224 ('r', 'rev', '', _('print the given revision'), _('REV')),
1224 ('', 'decode', None, _('apply any matching decode filter')),
1225 ('', 'decode', None, _('apply any matching decode filter')),
1225 ] + walkopts,
1226 ] + walkopts,
1226 _('[OPTION]... FILE...'),
1227 _('[OPTION]... FILE...'),
1227 inferrepo=True)
1228 inferrepo=True)
1228 def cat(ui, repo, file1, *pats, **opts):
1229 def cat(ui, repo, file1, *pats, **opts):
1229 """output the current or given revision of files
1230 """output the current or given revision of files
1230
1231
1231 Print the specified files as they were at the given revision. If
1232 Print the specified files as they were at the given revision. If
1232 no revision is given, the parent of the working directory is used.
1233 no revision is given, the parent of the working directory is used.
1233
1234
1234 Output may be to a file, in which case the name of the file is
1235 Output may be to a file, in which case the name of the file is
1235 given using a format string. The formatting rules as follows:
1236 given using a format string. The formatting rules as follows:
1236
1237
1237 :``%%``: literal "%" character
1238 :``%%``: literal "%" character
1238 :``%s``: basename of file being printed
1239 :``%s``: basename of file being printed
1239 :``%d``: dirname of file being printed, or '.' if in repository root
1240 :``%d``: dirname of file being printed, or '.' if in repository root
1240 :``%p``: root-relative path name of file being printed
1241 :``%p``: root-relative path name of file being printed
1241 :``%H``: changeset hash (40 hexadecimal digits)
1242 :``%H``: changeset hash (40 hexadecimal digits)
1242 :``%R``: changeset revision number
1243 :``%R``: changeset revision number
1243 :``%h``: short-form changeset hash (12 hexadecimal digits)
1244 :``%h``: short-form changeset hash (12 hexadecimal digits)
1244 :``%r``: zero-padded changeset revision number
1245 :``%r``: zero-padded changeset revision number
1245 :``%b``: basename of the exporting repository
1246 :``%b``: basename of the exporting repository
1246
1247
1247 Returns 0 on success.
1248 Returns 0 on success.
1248 """
1249 """
1249 ctx = scmutil.revsingle(repo, opts.get('rev'))
1250 ctx = scmutil.revsingle(repo, opts.get('rev'))
1250 m = scmutil.match(ctx, (file1,) + pats, opts)
1251 m = scmutil.match(ctx, (file1,) + pats, opts)
1251
1252
1252 return cmdutil.cat(ui, repo, ctx, m, '', **opts)
1253 return cmdutil.cat(ui, repo, ctx, m, '', **opts)
1253
1254
1254 @command('^clone',
1255 @command('^clone',
1255 [('U', 'noupdate', None,
1256 [('U', 'noupdate', None,
1256 _('the clone will include an empty working copy (only a repository)')),
1257 _('the clone will include an empty working copy (only a repository)')),
1257 ('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')),
1258 ('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')),
1258 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1259 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1259 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1260 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1260 ('', 'pull', None, _('use pull protocol to copy metadata')),
1261 ('', 'pull', None, _('use pull protocol to copy metadata')),
1261 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1262 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1262 ] + remoteopts,
1263 ] + remoteopts,
1263 _('[OPTION]... SOURCE [DEST]'),
1264 _('[OPTION]... SOURCE [DEST]'),
1264 norepo=True)
1265 norepo=True)
1265 def clone(ui, source, dest=None, **opts):
1266 def clone(ui, source, dest=None, **opts):
1266 """make a copy of an existing repository
1267 """make a copy of an existing repository
1267
1268
1268 Create a copy of an existing repository in a new directory.
1269 Create a copy of an existing repository in a new directory.
1269
1270
1270 If no destination directory name is specified, it defaults to the
1271 If no destination directory name is specified, it defaults to the
1271 basename of the source.
1272 basename of the source.
1272
1273
1273 The location of the source is added to the new repository's
1274 The location of the source is added to the new repository's
1274 ``.hg/hgrc`` file, as the default to be used for future pulls.
1275 ``.hg/hgrc`` file, as the default to be used for future pulls.
1275
1276
1276 Only local paths and ``ssh://`` URLs are supported as
1277 Only local paths and ``ssh://`` URLs are supported as
1277 destinations. For ``ssh://`` destinations, no working directory or
1278 destinations. For ``ssh://`` destinations, no working directory or
1278 ``.hg/hgrc`` will be created on the remote side.
1279 ``.hg/hgrc`` will be created on the remote side.
1279
1280
1280 To pull only a subset of changesets, specify one or more revisions
1281 To pull only a subset of changesets, specify one or more revisions
1281 identifiers with -r/--rev or branches with -b/--branch. The
1282 identifiers with -r/--rev or branches with -b/--branch. The
1282 resulting clone will contain only the specified changesets and
1283 resulting clone will contain only the specified changesets and
1283 their ancestors. These options (or 'clone src#rev dest') imply
1284 their ancestors. These options (or 'clone src#rev dest') imply
1284 --pull, even for local source repositories. Note that specifying a
1285 --pull, even for local source repositories. Note that specifying a
1285 tag will include the tagged changeset but not the changeset
1286 tag will include the tagged changeset but not the changeset
1286 containing the tag.
1287 containing the tag.
1287
1288
1288 If the source repository has a bookmark called '@' set, that
1289 If the source repository has a bookmark called '@' set, that
1289 revision will be checked out in the new repository by default.
1290 revision will be checked out in the new repository by default.
1290
1291
1291 To check out a particular version, use -u/--update, or
1292 To check out a particular version, use -u/--update, or
1292 -U/--noupdate to create a clone with no working directory.
1293 -U/--noupdate to create a clone with no working directory.
1293
1294
1294 .. container:: verbose
1295 .. container:: verbose
1295
1296
1296 For efficiency, hardlinks are used for cloning whenever the
1297 For efficiency, hardlinks are used for cloning whenever the
1297 source and destination are on the same filesystem (note this
1298 source and destination are on the same filesystem (note this
1298 applies only to the repository data, not to the working
1299 applies only to the repository data, not to the working
1299 directory). Some filesystems, such as AFS, implement hardlinking
1300 directory). Some filesystems, such as AFS, implement hardlinking
1300 incorrectly, but do not report errors. In these cases, use the
1301 incorrectly, but do not report errors. In these cases, use the
1301 --pull option to avoid hardlinking.
1302 --pull option to avoid hardlinking.
1302
1303
1303 In some cases, you can clone repositories and the working
1304 In some cases, you can clone repositories and the working
1304 directory using full hardlinks with ::
1305 directory using full hardlinks with ::
1305
1306
1306 $ cp -al REPO REPOCLONE
1307 $ cp -al REPO REPOCLONE
1307
1308
1308 This is the fastest way to clone, but it is not always safe. The
1309 This is the fastest way to clone, but it is not always safe. The
1309 operation is not atomic (making sure REPO is not modified during
1310 operation is not atomic (making sure REPO is not modified during
1310 the operation is up to you) and you have to make sure your
1311 the operation is up to you) and you have to make sure your
1311 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1312 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1312 so). Also, this is not compatible with certain extensions that
1313 so). Also, this is not compatible with certain extensions that
1313 place their metadata under the .hg directory, such as mq.
1314 place their metadata under the .hg directory, such as mq.
1314
1315
1315 Mercurial will update the working directory to the first applicable
1316 Mercurial will update the working directory to the first applicable
1316 revision from this list:
1317 revision from this list:
1317
1318
1318 a) null if -U or the source repository has no changesets
1319 a) null if -U or the source repository has no changesets
1319 b) if -u . and the source repository is local, the first parent of
1320 b) if -u . and the source repository is local, the first parent of
1320 the source repository's working directory
1321 the source repository's working directory
1321 c) the changeset specified with -u (if a branch name, this means the
1322 c) the changeset specified with -u (if a branch name, this means the
1322 latest head of that branch)
1323 latest head of that branch)
1323 d) the changeset specified with -r
1324 d) the changeset specified with -r
1324 e) the tipmost head specified with -b
1325 e) the tipmost head specified with -b
1325 f) the tipmost head specified with the url#branch source syntax
1326 f) the tipmost head specified with the url#branch source syntax
1326 g) the revision marked with the '@' bookmark, if present
1327 g) the revision marked with the '@' bookmark, if present
1327 h) the tipmost head of the default branch
1328 h) the tipmost head of the default branch
1328 i) tip
1329 i) tip
1329
1330
1330 Examples:
1331 Examples:
1331
1332
1332 - clone a remote repository to a new directory named hg/::
1333 - clone a remote repository to a new directory named hg/::
1333
1334
1334 hg clone http://selenic.com/hg
1335 hg clone http://selenic.com/hg
1335
1336
1336 - create a lightweight local clone::
1337 - create a lightweight local clone::
1337
1338
1338 hg clone project/ project-feature/
1339 hg clone project/ project-feature/
1339
1340
1340 - clone from an absolute path on an ssh server (note double-slash)::
1341 - clone from an absolute path on an ssh server (note double-slash)::
1341
1342
1342 hg clone ssh://user@server//home/projects/alpha/
1343 hg clone ssh://user@server//home/projects/alpha/
1343
1344
1344 - do a high-speed clone over a LAN while checking out a
1345 - do a high-speed clone over a LAN while checking out a
1345 specified version::
1346 specified version::
1346
1347
1347 hg clone --uncompressed http://server/repo -u 1.5
1348 hg clone --uncompressed http://server/repo -u 1.5
1348
1349
1349 - create a repository without changesets after a particular revision::
1350 - create a repository without changesets after a particular revision::
1350
1351
1351 hg clone -r 04e544 experimental/ good/
1352 hg clone -r 04e544 experimental/ good/
1352
1353
1353 - clone (and track) a particular named branch::
1354 - clone (and track) a particular named branch::
1354
1355
1355 hg clone http://selenic.com/hg#stable
1356 hg clone http://selenic.com/hg#stable
1356
1357
1357 See :hg:`help urls` for details on specifying URLs.
1358 See :hg:`help urls` for details on specifying URLs.
1358
1359
1359 Returns 0 on success.
1360 Returns 0 on success.
1360 """
1361 """
1361 if opts.get('noupdate') and opts.get('updaterev'):
1362 if opts.get('noupdate') and opts.get('updaterev'):
1362 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
1363 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
1363
1364
1364 r = hg.clone(ui, opts, source, dest,
1365 r = hg.clone(ui, opts, source, dest,
1365 pull=opts.get('pull'),
1366 pull=opts.get('pull'),
1366 stream=opts.get('uncompressed'),
1367 stream=opts.get('uncompressed'),
1367 rev=opts.get('rev'),
1368 rev=opts.get('rev'),
1368 update=opts.get('updaterev') or not opts.get('noupdate'),
1369 update=opts.get('updaterev') or not opts.get('noupdate'),
1369 branch=opts.get('branch'))
1370 branch=opts.get('branch'))
1370
1371
1371 return r is None
1372 return r is None
1372
1373
1373 @command('^commit|ci',
1374 @command('^commit|ci',
1374 [('A', 'addremove', None,
1375 [('A', 'addremove', None,
1375 _('mark new/missing files as added/removed before committing')),
1376 _('mark new/missing files as added/removed before committing')),
1376 ('', 'close-branch', None,
1377 ('', 'close-branch', None,
1377 _('mark a branch as closed, hiding it from the branch list')),
1378 _('mark a branch as closed, hiding it from the branch list')),
1378 ('', 'amend', None, _('amend the parent of the working dir')),
1379 ('', 'amend', None, _('amend the parent of the working dir')),
1379 ('s', 'secret', None, _('use the secret phase for committing')),
1380 ('s', 'secret', None, _('use the secret phase for committing')),
1380 ('e', 'edit', None, _('invoke editor on commit messages')),
1381 ('e', 'edit', None, _('invoke editor on commit messages')),
1381 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1382 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1382 _('[OPTION]... [FILE]...'),
1383 _('[OPTION]... [FILE]...'),
1383 inferrepo=True)
1384 inferrepo=True)
1384 def commit(ui, repo, *pats, **opts):
1385 def commit(ui, repo, *pats, **opts):
1385 """commit the specified files or all outstanding changes
1386 """commit the specified files or all outstanding changes
1386
1387
1387 Commit changes to the given files into the repository. Unlike a
1388 Commit changes to the given files into the repository. Unlike a
1388 centralized SCM, this operation is a local operation. See
1389 centralized SCM, this operation is a local operation. See
1389 :hg:`push` for a way to actively distribute your changes.
1390 :hg:`push` for a way to actively distribute your changes.
1390
1391
1391 If a list of files is omitted, all changes reported by :hg:`status`
1392 If a list of files is omitted, all changes reported by :hg:`status`
1392 will be committed.
1393 will be committed.
1393
1394
1394 If you are committing the result of a merge, do not provide any
1395 If you are committing the result of a merge, do not provide any
1395 filenames or -I/-X filters.
1396 filenames or -I/-X filters.
1396
1397
1397 If no commit message is specified, Mercurial starts your
1398 If no commit message is specified, Mercurial starts your
1398 configured editor where you can enter a message. In case your
1399 configured editor where you can enter a message. In case your
1399 commit fails, you will find a backup of your message in
1400 commit fails, you will find a backup of your message in
1400 ``.hg/last-message.txt``.
1401 ``.hg/last-message.txt``.
1401
1402
1402 The --amend flag can be used to amend the parent of the
1403 The --amend flag can be used to amend the parent of the
1403 working directory with a new commit that contains the changes
1404 working directory with a new commit that contains the changes
1404 in the parent in addition to those currently reported by :hg:`status`,
1405 in the parent in addition to those currently reported by :hg:`status`,
1405 if there are any. The old commit is stored in a backup bundle in
1406 if there are any. The old commit is stored in a backup bundle in
1406 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1407 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1407 on how to restore it).
1408 on how to restore it).
1408
1409
1409 Message, user and date are taken from the amended commit unless
1410 Message, user and date are taken from the amended commit unless
1410 specified. When a message isn't specified on the command line,
1411 specified. When a message isn't specified on the command line,
1411 the editor will open with the message of the amended commit.
1412 the editor will open with the message of the amended commit.
1412
1413
1413 It is not possible to amend public changesets (see :hg:`help phases`)
1414 It is not possible to amend public changesets (see :hg:`help phases`)
1414 or changesets that have children.
1415 or changesets that have children.
1415
1416
1416 See :hg:`help dates` for a list of formats valid for -d/--date.
1417 See :hg:`help dates` for a list of formats valid for -d/--date.
1417
1418
1418 Returns 0 on success, 1 if nothing changed.
1419 Returns 0 on success, 1 if nothing changed.
1419 """
1420 """
1420 if opts.get('subrepos'):
1421 if opts.get('subrepos'):
1421 if opts.get('amend'):
1422 if opts.get('amend'):
1422 raise util.Abort(_('cannot amend with --subrepos'))
1423 raise util.Abort(_('cannot amend with --subrepos'))
1423 # Let --subrepos on the command line override config setting.
1424 # Let --subrepos on the command line override config setting.
1424 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1425 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1425
1426
1426 cmdutil.checkunfinished(repo, commit=True)
1427 cmdutil.checkunfinished(repo, commit=True)
1427
1428
1428 branch = repo[None].branch()
1429 branch = repo[None].branch()
1429 bheads = repo.branchheads(branch)
1430 bheads = repo.branchheads(branch)
1430
1431
1431 extra = {}
1432 extra = {}
1432 if opts.get('close_branch'):
1433 if opts.get('close_branch'):
1433 extra['close'] = 1
1434 extra['close'] = 1
1434
1435
1435 if not bheads:
1436 if not bheads:
1436 raise util.Abort(_('can only close branch heads'))
1437 raise util.Abort(_('can only close branch heads'))
1437 elif opts.get('amend'):
1438 elif opts.get('amend'):
1438 if repo.parents()[0].p1().branch() != branch and \
1439 if repo.parents()[0].p1().branch() != branch and \
1439 repo.parents()[0].p2().branch() != branch:
1440 repo.parents()[0].p2().branch() != branch:
1440 raise util.Abort(_('can only close branch heads'))
1441 raise util.Abort(_('can only close branch heads'))
1441
1442
1442 if opts.get('amend'):
1443 if opts.get('amend'):
1443 if ui.configbool('ui', 'commitsubrepos'):
1444 if ui.configbool('ui', 'commitsubrepos'):
1444 raise util.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1445 raise util.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1445
1446
1446 old = repo['.']
1447 old = repo['.']
1447 if not old.mutable():
1448 if not old.mutable():
1448 raise util.Abort(_('cannot amend public changesets'))
1449 raise util.Abort(_('cannot amend public changesets'))
1449 if len(repo[None].parents()) > 1:
1450 if len(repo[None].parents()) > 1:
1450 raise util.Abort(_('cannot amend while merging'))
1451 raise util.Abort(_('cannot amend while merging'))
1451 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1452 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1452 if not allowunstable and old.children():
1453 if not allowunstable and old.children():
1453 raise util.Abort(_('cannot amend changeset with children'))
1454 raise util.Abort(_('cannot amend changeset with children'))
1454
1455
1455 # commitfunc is used only for temporary amend commit by cmdutil.amend
1456 # commitfunc is used only for temporary amend commit by cmdutil.amend
1456 def commitfunc(ui, repo, message, match, opts):
1457 def commitfunc(ui, repo, message, match, opts):
1457 return repo.commit(message,
1458 return repo.commit(message,
1458 opts.get('user') or old.user(),
1459 opts.get('user') or old.user(),
1459 opts.get('date') or old.date(),
1460 opts.get('date') or old.date(),
1460 match,
1461 match,
1461 extra=extra)
1462 extra=extra)
1462
1463
1463 current = repo._bookmarkcurrent
1464 current = repo._bookmarkcurrent
1464 marks = old.bookmarks()
1465 marks = old.bookmarks()
1465 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1466 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1466 if node == old.node():
1467 if node == old.node():
1467 ui.status(_("nothing changed\n"))
1468 ui.status(_("nothing changed\n"))
1468 return 1
1469 return 1
1469 elif marks:
1470 elif marks:
1470 ui.debug('moving bookmarks %r from %s to %s\n' %
1471 ui.debug('moving bookmarks %r from %s to %s\n' %
1471 (marks, old.hex(), hex(node)))
1472 (marks, old.hex(), hex(node)))
1472 newmarks = repo._bookmarks
1473 newmarks = repo._bookmarks
1473 for bm in marks:
1474 for bm in marks:
1474 newmarks[bm] = node
1475 newmarks[bm] = node
1475 if bm == current:
1476 if bm == current:
1476 bookmarks.setcurrent(repo, bm)
1477 bookmarks.setcurrent(repo, bm)
1477 newmarks.write()
1478 newmarks.write()
1478 else:
1479 else:
1479 def commitfunc(ui, repo, message, match, opts):
1480 def commitfunc(ui, repo, message, match, opts):
1480 backup = ui.backupconfig('phases', 'new-commit')
1481 backup = ui.backupconfig('phases', 'new-commit')
1481 baseui = repo.baseui
1482 baseui = repo.baseui
1482 basebackup = baseui.backupconfig('phases', 'new-commit')
1483 basebackup = baseui.backupconfig('phases', 'new-commit')
1483 try:
1484 try:
1484 if opts.get('secret'):
1485 if opts.get('secret'):
1485 ui.setconfig('phases', 'new-commit', 'secret', 'commit')
1486 ui.setconfig('phases', 'new-commit', 'secret', 'commit')
1486 # Propagate to subrepos
1487 # Propagate to subrepos
1487 baseui.setconfig('phases', 'new-commit', 'secret', 'commit')
1488 baseui.setconfig('phases', 'new-commit', 'secret', 'commit')
1488
1489
1489 editform = cmdutil.mergeeditform(repo[None], 'commit.normal')
1490 editform = cmdutil.mergeeditform(repo[None], 'commit.normal')
1490 editor = cmdutil.getcommiteditor(editform=editform, **opts)
1491 editor = cmdutil.getcommiteditor(editform=editform, **opts)
1491 return repo.commit(message, opts.get('user'), opts.get('date'),
1492 return repo.commit(message, opts.get('user'), opts.get('date'),
1492 match,
1493 match,
1493 editor=editor,
1494 editor=editor,
1494 extra=extra)
1495 extra=extra)
1495 finally:
1496 finally:
1496 ui.restoreconfig(backup)
1497 ui.restoreconfig(backup)
1497 repo.baseui.restoreconfig(basebackup)
1498 repo.baseui.restoreconfig(basebackup)
1498
1499
1499
1500
1500 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1501 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1501
1502
1502 if not node:
1503 if not node:
1503 stat = repo.status(match=scmutil.match(repo[None], pats, opts))
1504 stat = repo.status(match=scmutil.match(repo[None], pats, opts))
1504 if stat[3]:
1505 if stat[3]:
1505 ui.status(_("nothing changed (%d missing files, see "
1506 ui.status(_("nothing changed (%d missing files, see "
1506 "'hg status')\n") % len(stat[3]))
1507 "'hg status')\n") % len(stat[3]))
1507 else:
1508 else:
1508 ui.status(_("nothing changed\n"))
1509 ui.status(_("nothing changed\n"))
1509 return 1
1510 return 1
1510
1511
1511 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1512 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1512
1513
1513 @command('config|showconfig|debugconfig',
1514 @command('config|showconfig|debugconfig',
1514 [('u', 'untrusted', None, _('show untrusted configuration options')),
1515 [('u', 'untrusted', None, _('show untrusted configuration options')),
1515 ('e', 'edit', None, _('edit user config')),
1516 ('e', 'edit', None, _('edit user config')),
1516 ('l', 'local', None, _('edit repository config')),
1517 ('l', 'local', None, _('edit repository config')),
1517 ('g', 'global', None, _('edit global config'))],
1518 ('g', 'global', None, _('edit global config'))],
1518 _('[-u] [NAME]...'),
1519 _('[-u] [NAME]...'),
1519 optionalrepo=True)
1520 optionalrepo=True)
1520 def config(ui, repo, *values, **opts):
1521 def config(ui, repo, *values, **opts):
1521 """show combined config settings from all hgrc files
1522 """show combined config settings from all hgrc files
1522
1523
1523 With no arguments, print names and values of all config items.
1524 With no arguments, print names and values of all config items.
1524
1525
1525 With one argument of the form section.name, print just the value
1526 With one argument of the form section.name, print just the value
1526 of that config item.
1527 of that config item.
1527
1528
1528 With multiple arguments, print names and values of all config
1529 With multiple arguments, print names and values of all config
1529 items with matching section names.
1530 items with matching section names.
1530
1531
1531 With --edit, start an editor on the user-level config file. With
1532 With --edit, start an editor on the user-level config file. With
1532 --global, edit the system-wide config file. With --local, edit the
1533 --global, edit the system-wide config file. With --local, edit the
1533 repository-level config file.
1534 repository-level config file.
1534
1535
1535 With --debug, the source (filename and line number) is printed
1536 With --debug, the source (filename and line number) is printed
1536 for each config item.
1537 for each config item.
1537
1538
1538 See :hg:`help config` for more information about config files.
1539 See :hg:`help config` for more information about config files.
1539
1540
1540 Returns 0 on success, 1 if NAME does not exist.
1541 Returns 0 on success, 1 if NAME does not exist.
1541
1542
1542 """
1543 """
1543
1544
1544 if opts.get('edit') or opts.get('local') or opts.get('global'):
1545 if opts.get('edit') or opts.get('local') or opts.get('global'):
1545 if opts.get('local') and opts.get('global'):
1546 if opts.get('local') and opts.get('global'):
1546 raise util.Abort(_("can't use --local and --global together"))
1547 raise util.Abort(_("can't use --local and --global together"))
1547
1548
1548 if opts.get('local'):
1549 if opts.get('local'):
1549 if not repo:
1550 if not repo:
1550 raise util.Abort(_("can't use --local outside a repository"))
1551 raise util.Abort(_("can't use --local outside a repository"))
1551 paths = [repo.join('hgrc')]
1552 paths = [repo.join('hgrc')]
1552 elif opts.get('global'):
1553 elif opts.get('global'):
1553 paths = scmutil.systemrcpath()
1554 paths = scmutil.systemrcpath()
1554 else:
1555 else:
1555 paths = scmutil.userrcpath()
1556 paths = scmutil.userrcpath()
1556
1557
1557 for f in paths:
1558 for f in paths:
1558 if os.path.exists(f):
1559 if os.path.exists(f):
1559 break
1560 break
1560 else:
1561 else:
1561 if opts.get('global'):
1562 if opts.get('global'):
1562 samplehgrc = uimod.samplehgrcs['global']
1563 samplehgrc = uimod.samplehgrcs['global']
1563 elif opts.get('local'):
1564 elif opts.get('local'):
1564 samplehgrc = uimod.samplehgrcs['local']
1565 samplehgrc = uimod.samplehgrcs['local']
1565 else:
1566 else:
1566 samplehgrc = uimod.samplehgrcs['user']
1567 samplehgrc = uimod.samplehgrcs['user']
1567
1568
1568 f = paths[0]
1569 f = paths[0]
1569 fp = open(f, "w")
1570 fp = open(f, "w")
1570 fp.write(samplehgrc)
1571 fp.write(samplehgrc)
1571 fp.close()
1572 fp.close()
1572
1573
1573 editor = ui.geteditor()
1574 editor = ui.geteditor()
1574 ui.system("%s \"%s\"" % (editor, f),
1575 ui.system("%s \"%s\"" % (editor, f),
1575 onerr=util.Abort, errprefix=_("edit failed"))
1576 onerr=util.Abort, errprefix=_("edit failed"))
1576 return
1577 return
1577
1578
1578 for f in scmutil.rcpath():
1579 for f in scmutil.rcpath():
1579 ui.debug('read config from: %s\n' % f)
1580 ui.debug('read config from: %s\n' % f)
1580 untrusted = bool(opts.get('untrusted'))
1581 untrusted = bool(opts.get('untrusted'))
1581 if values:
1582 if values:
1582 sections = [v for v in values if '.' not in v]
1583 sections = [v for v in values if '.' not in v]
1583 items = [v for v in values if '.' in v]
1584 items = [v for v in values if '.' in v]
1584 if len(items) > 1 or items and sections:
1585 if len(items) > 1 or items and sections:
1585 raise util.Abort(_('only one config item permitted'))
1586 raise util.Abort(_('only one config item permitted'))
1586 matched = False
1587 matched = False
1587 for section, name, value in ui.walkconfig(untrusted=untrusted):
1588 for section, name, value in ui.walkconfig(untrusted=untrusted):
1588 value = str(value).replace('\n', '\\n')
1589 value = str(value).replace('\n', '\\n')
1589 sectname = section + '.' + name
1590 sectname = section + '.' + name
1590 if values:
1591 if values:
1591 for v in values:
1592 for v in values:
1592 if v == section:
1593 if v == section:
1593 ui.debug('%s: ' %
1594 ui.debug('%s: ' %
1594 ui.configsource(section, name, untrusted))
1595 ui.configsource(section, name, untrusted))
1595 ui.write('%s=%s\n' % (sectname, value))
1596 ui.write('%s=%s\n' % (sectname, value))
1596 matched = True
1597 matched = True
1597 elif v == sectname:
1598 elif v == sectname:
1598 ui.debug('%s: ' %
1599 ui.debug('%s: ' %
1599 ui.configsource(section, name, untrusted))
1600 ui.configsource(section, name, untrusted))
1600 ui.write(value, '\n')
1601 ui.write(value, '\n')
1601 matched = True
1602 matched = True
1602 else:
1603 else:
1603 ui.debug('%s: ' %
1604 ui.debug('%s: ' %
1604 ui.configsource(section, name, untrusted))
1605 ui.configsource(section, name, untrusted))
1605 ui.write('%s=%s\n' % (sectname, value))
1606 ui.write('%s=%s\n' % (sectname, value))
1606 matched = True
1607 matched = True
1607 if matched:
1608 if matched:
1608 return 0
1609 return 0
1609 return 1
1610 return 1
1610
1611
1611 @command('copy|cp',
1612 @command('copy|cp',
1612 [('A', 'after', None, _('record a copy that has already occurred')),
1613 [('A', 'after', None, _('record a copy that has already occurred')),
1613 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1614 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1614 ] + walkopts + dryrunopts,
1615 ] + walkopts + dryrunopts,
1615 _('[OPTION]... [SOURCE]... DEST'))
1616 _('[OPTION]... [SOURCE]... DEST'))
1616 def copy(ui, repo, *pats, **opts):
1617 def copy(ui, repo, *pats, **opts):
1617 """mark files as copied for the next commit
1618 """mark files as copied for the next commit
1618
1619
1619 Mark dest as having copies of source files. If dest is a
1620 Mark dest as having copies of source files. If dest is a
1620 directory, copies are put in that directory. If dest is a file,
1621 directory, copies are put in that directory. If dest is a file,
1621 the source must be a single file.
1622 the source must be a single file.
1622
1623
1623 By default, this command copies the contents of files as they
1624 By default, this command copies the contents of files as they
1624 exist in the working directory. If invoked with -A/--after, the
1625 exist in the working directory. If invoked with -A/--after, the
1625 operation is recorded, but no copying is performed.
1626 operation is recorded, but no copying is performed.
1626
1627
1627 This command takes effect with the next commit. To undo a copy
1628 This command takes effect with the next commit. To undo a copy
1628 before that, see :hg:`revert`.
1629 before that, see :hg:`revert`.
1629
1630
1630 Returns 0 on success, 1 if errors are encountered.
1631 Returns 0 on success, 1 if errors are encountered.
1631 """
1632 """
1632 wlock = repo.wlock(False)
1633 wlock = repo.wlock(False)
1633 try:
1634 try:
1634 return cmdutil.copy(ui, repo, pats, opts)
1635 return cmdutil.copy(ui, repo, pats, opts)
1635 finally:
1636 finally:
1636 wlock.release()
1637 wlock.release()
1637
1638
1638 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
1639 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
1639 def debugancestor(ui, repo, *args):
1640 def debugancestor(ui, repo, *args):
1640 """find the ancestor revision of two revisions in a given index"""
1641 """find the ancestor revision of two revisions in a given index"""
1641 if len(args) == 3:
1642 if len(args) == 3:
1642 index, rev1, rev2 = args
1643 index, rev1, rev2 = args
1643 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
1644 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
1644 lookup = r.lookup
1645 lookup = r.lookup
1645 elif len(args) == 2:
1646 elif len(args) == 2:
1646 if not repo:
1647 if not repo:
1647 raise util.Abort(_("there is no Mercurial repository here "
1648 raise util.Abort(_("there is no Mercurial repository here "
1648 "(.hg not found)"))
1649 "(.hg not found)"))
1649 rev1, rev2 = args
1650 rev1, rev2 = args
1650 r = repo.changelog
1651 r = repo.changelog
1651 lookup = repo.lookup
1652 lookup = repo.lookup
1652 else:
1653 else:
1653 raise util.Abort(_('either two or three arguments required'))
1654 raise util.Abort(_('either two or three arguments required'))
1654 a = r.ancestor(lookup(rev1), lookup(rev2))
1655 a = r.ancestor(lookup(rev1), lookup(rev2))
1655 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
1656 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
1656
1657
1657 @command('debugbuilddag',
1658 @command('debugbuilddag',
1658 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
1659 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
1659 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
1660 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
1660 ('n', 'new-file', None, _('add new file at each rev'))],
1661 ('n', 'new-file', None, _('add new file at each rev'))],
1661 _('[OPTION]... [TEXT]'))
1662 _('[OPTION]... [TEXT]'))
1662 def debugbuilddag(ui, repo, text=None,
1663 def debugbuilddag(ui, repo, text=None,
1663 mergeable_file=False,
1664 mergeable_file=False,
1664 overwritten_file=False,
1665 overwritten_file=False,
1665 new_file=False):
1666 new_file=False):
1666 """builds a repo with a given DAG from scratch in the current empty repo
1667 """builds a repo with a given DAG from scratch in the current empty repo
1667
1668
1668 The description of the DAG is read from stdin if not given on the
1669 The description of the DAG is read from stdin if not given on the
1669 command line.
1670 command line.
1670
1671
1671 Elements:
1672 Elements:
1672
1673
1673 - "+n" is a linear run of n nodes based on the current default parent
1674 - "+n" is a linear run of n nodes based on the current default parent
1674 - "." is a single node based on the current default parent
1675 - "." is a single node based on the current default parent
1675 - "$" resets the default parent to null (implied at the start);
1676 - "$" resets the default parent to null (implied at the start);
1676 otherwise the default parent is always the last node created
1677 otherwise the default parent is always the last node created
1677 - "<p" sets the default parent to the backref p
1678 - "<p" sets the default parent to the backref p
1678 - "*p" is a fork at parent p, which is a backref
1679 - "*p" is a fork at parent p, which is a backref
1679 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
1680 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
1680 - "/p2" is a merge of the preceding node and p2
1681 - "/p2" is a merge of the preceding node and p2
1681 - ":tag" defines a local tag for the preceding node
1682 - ":tag" defines a local tag for the preceding node
1682 - "@branch" sets the named branch for subsequent nodes
1683 - "@branch" sets the named branch for subsequent nodes
1683 - "#...\\n" is a comment up to the end of the line
1684 - "#...\\n" is a comment up to the end of the line
1684
1685
1685 Whitespace between the above elements is ignored.
1686 Whitespace between the above elements is ignored.
1686
1687
1687 A backref is either
1688 A backref is either
1688
1689
1689 - a number n, which references the node curr-n, where curr is the current
1690 - a number n, which references the node curr-n, where curr is the current
1690 node, or
1691 node, or
1691 - the name of a local tag you placed earlier using ":tag", or
1692 - the name of a local tag you placed earlier using ":tag", or
1692 - empty to denote the default parent.
1693 - empty to denote the default parent.
1693
1694
1694 All string valued-elements are either strictly alphanumeric, or must
1695 All string valued-elements are either strictly alphanumeric, or must
1695 be enclosed in double quotes ("..."), with "\\" as escape character.
1696 be enclosed in double quotes ("..."), with "\\" as escape character.
1696 """
1697 """
1697
1698
1698 if text is None:
1699 if text is None:
1699 ui.status(_("reading DAG from stdin\n"))
1700 ui.status(_("reading DAG from stdin\n"))
1700 text = ui.fin.read()
1701 text = ui.fin.read()
1701
1702
1702 cl = repo.changelog
1703 cl = repo.changelog
1703 if len(cl) > 0:
1704 if len(cl) > 0:
1704 raise util.Abort(_('repository is not empty'))
1705 raise util.Abort(_('repository is not empty'))
1705
1706
1706 # determine number of revs in DAG
1707 # determine number of revs in DAG
1707 total = 0
1708 total = 0
1708 for type, data in dagparser.parsedag(text):
1709 for type, data in dagparser.parsedag(text):
1709 if type == 'n':
1710 if type == 'n':
1710 total += 1
1711 total += 1
1711
1712
1712 if mergeable_file:
1713 if mergeable_file:
1713 linesperrev = 2
1714 linesperrev = 2
1714 # make a file with k lines per rev
1715 # make a file with k lines per rev
1715 initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)]
1716 initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)]
1716 initialmergedlines.append("")
1717 initialmergedlines.append("")
1717
1718
1718 tags = []
1719 tags = []
1719
1720
1720 lock = tr = None
1721 lock = tr = None
1721 try:
1722 try:
1722 lock = repo.lock()
1723 lock = repo.lock()
1723 tr = repo.transaction("builddag")
1724 tr = repo.transaction("builddag")
1724
1725
1725 at = -1
1726 at = -1
1726 atbranch = 'default'
1727 atbranch = 'default'
1727 nodeids = []
1728 nodeids = []
1728 id = 0
1729 id = 0
1729 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1730 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1730 for type, data in dagparser.parsedag(text):
1731 for type, data in dagparser.parsedag(text):
1731 if type == 'n':
1732 if type == 'n':
1732 ui.note(('node %s\n' % str(data)))
1733 ui.note(('node %s\n' % str(data)))
1733 id, ps = data
1734 id, ps = data
1734
1735
1735 files = []
1736 files = []
1736 fctxs = {}
1737 fctxs = {}
1737
1738
1738 p2 = None
1739 p2 = None
1739 if mergeable_file:
1740 if mergeable_file:
1740 fn = "mf"
1741 fn = "mf"
1741 p1 = repo[ps[0]]
1742 p1 = repo[ps[0]]
1742 if len(ps) > 1:
1743 if len(ps) > 1:
1743 p2 = repo[ps[1]]
1744 p2 = repo[ps[1]]
1744 pa = p1.ancestor(p2)
1745 pa = p1.ancestor(p2)
1745 base, local, other = [x[fn].data() for x in (pa, p1,
1746 base, local, other = [x[fn].data() for x in (pa, p1,
1746 p2)]
1747 p2)]
1747 m3 = simplemerge.Merge3Text(base, local, other)
1748 m3 = simplemerge.Merge3Text(base, local, other)
1748 ml = [l.strip() for l in m3.merge_lines()]
1749 ml = [l.strip() for l in m3.merge_lines()]
1749 ml.append("")
1750 ml.append("")
1750 elif at > 0:
1751 elif at > 0:
1751 ml = p1[fn].data().split("\n")
1752 ml = p1[fn].data().split("\n")
1752 else:
1753 else:
1753 ml = initialmergedlines
1754 ml = initialmergedlines
1754 ml[id * linesperrev] += " r%i" % id
1755 ml[id * linesperrev] += " r%i" % id
1755 mergedtext = "\n".join(ml)
1756 mergedtext = "\n".join(ml)
1756 files.append(fn)
1757 files.append(fn)
1757 fctxs[fn] = context.memfilectx(repo, fn, mergedtext)
1758 fctxs[fn] = context.memfilectx(repo, fn, mergedtext)
1758
1759
1759 if overwritten_file:
1760 if overwritten_file:
1760 fn = "of"
1761 fn = "of"
1761 files.append(fn)
1762 files.append(fn)
1762 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1763 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1763
1764
1764 if new_file:
1765 if new_file:
1765 fn = "nf%i" % id
1766 fn = "nf%i" % id
1766 files.append(fn)
1767 files.append(fn)
1767 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1768 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1768 if len(ps) > 1:
1769 if len(ps) > 1:
1769 if not p2:
1770 if not p2:
1770 p2 = repo[ps[1]]
1771 p2 = repo[ps[1]]
1771 for fn in p2:
1772 for fn in p2:
1772 if fn.startswith("nf"):
1773 if fn.startswith("nf"):
1773 files.append(fn)
1774 files.append(fn)
1774 fctxs[fn] = p2[fn]
1775 fctxs[fn] = p2[fn]
1775
1776
1776 def fctxfn(repo, cx, path):
1777 def fctxfn(repo, cx, path):
1777 return fctxs.get(path)
1778 return fctxs.get(path)
1778
1779
1779 if len(ps) == 0 or ps[0] < 0:
1780 if len(ps) == 0 or ps[0] < 0:
1780 pars = [None, None]
1781 pars = [None, None]
1781 elif len(ps) == 1:
1782 elif len(ps) == 1:
1782 pars = [nodeids[ps[0]], None]
1783 pars = [nodeids[ps[0]], None]
1783 else:
1784 else:
1784 pars = [nodeids[p] for p in ps]
1785 pars = [nodeids[p] for p in ps]
1785 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
1786 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
1786 date=(id, 0),
1787 date=(id, 0),
1787 user="debugbuilddag",
1788 user="debugbuilddag",
1788 extra={'branch': atbranch})
1789 extra={'branch': atbranch})
1789 nodeid = repo.commitctx(cx)
1790 nodeid = repo.commitctx(cx)
1790 nodeids.append(nodeid)
1791 nodeids.append(nodeid)
1791 at = id
1792 at = id
1792 elif type == 'l':
1793 elif type == 'l':
1793 id, name = data
1794 id, name = data
1794 ui.note(('tag %s\n' % name))
1795 ui.note(('tag %s\n' % name))
1795 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
1796 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
1796 elif type == 'a':
1797 elif type == 'a':
1797 ui.note(('branch %s\n' % data))
1798 ui.note(('branch %s\n' % data))
1798 atbranch = data
1799 atbranch = data
1799 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1800 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1800 tr.close()
1801 tr.close()
1801
1802
1802 if tags:
1803 if tags:
1803 repo.opener.write("localtags", "".join(tags))
1804 repo.opener.write("localtags", "".join(tags))
1804 finally:
1805 finally:
1805 ui.progress(_('building'), None)
1806 ui.progress(_('building'), None)
1806 release(tr, lock)
1807 release(tr, lock)
1807
1808
1808 @command('debugbundle',
1809 @command('debugbundle',
1809 [('a', 'all', None, _('show all details'))],
1810 [('a', 'all', None, _('show all details'))],
1810 _('FILE'),
1811 _('FILE'),
1811 norepo=True)
1812 norepo=True)
1812 def debugbundle(ui, bundlepath, all=None, **opts):
1813 def debugbundle(ui, bundlepath, all=None, **opts):
1813 """lists the contents of a bundle"""
1814 """lists the contents of a bundle"""
1814 f = hg.openpath(ui, bundlepath)
1815 f = hg.openpath(ui, bundlepath)
1815 try:
1816 try:
1816 gen = exchange.readbundle(ui, f, bundlepath)
1817 gen = exchange.readbundle(ui, f, bundlepath)
1817 if all:
1818 if all:
1818 ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n"))
1819 ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n"))
1819
1820
1820 def showchunks(named):
1821 def showchunks(named):
1821 ui.write("\n%s\n" % named)
1822 ui.write("\n%s\n" % named)
1822 chain = None
1823 chain = None
1823 while True:
1824 while True:
1824 chunkdata = gen.deltachunk(chain)
1825 chunkdata = gen.deltachunk(chain)
1825 if not chunkdata:
1826 if not chunkdata:
1826 break
1827 break
1827 node = chunkdata['node']
1828 node = chunkdata['node']
1828 p1 = chunkdata['p1']
1829 p1 = chunkdata['p1']
1829 p2 = chunkdata['p2']
1830 p2 = chunkdata['p2']
1830 cs = chunkdata['cs']
1831 cs = chunkdata['cs']
1831 deltabase = chunkdata['deltabase']
1832 deltabase = chunkdata['deltabase']
1832 delta = chunkdata['delta']
1833 delta = chunkdata['delta']
1833 ui.write("%s %s %s %s %s %s\n" %
1834 ui.write("%s %s %s %s %s %s\n" %
1834 (hex(node), hex(p1), hex(p2),
1835 (hex(node), hex(p1), hex(p2),
1835 hex(cs), hex(deltabase), len(delta)))
1836 hex(cs), hex(deltabase), len(delta)))
1836 chain = node
1837 chain = node
1837
1838
1838 chunkdata = gen.changelogheader()
1839 chunkdata = gen.changelogheader()
1839 showchunks("changelog")
1840 showchunks("changelog")
1840 chunkdata = gen.manifestheader()
1841 chunkdata = gen.manifestheader()
1841 showchunks("manifest")
1842 showchunks("manifest")
1842 while True:
1843 while True:
1843 chunkdata = gen.filelogheader()
1844 chunkdata = gen.filelogheader()
1844 if not chunkdata:
1845 if not chunkdata:
1845 break
1846 break
1846 fname = chunkdata['filename']
1847 fname = chunkdata['filename']
1847 showchunks(fname)
1848 showchunks(fname)
1848 else:
1849 else:
1849 chunkdata = gen.changelogheader()
1850 chunkdata = gen.changelogheader()
1850 chain = None
1851 chain = None
1851 while True:
1852 while True:
1852 chunkdata = gen.deltachunk(chain)
1853 chunkdata = gen.deltachunk(chain)
1853 if not chunkdata:
1854 if not chunkdata:
1854 break
1855 break
1855 node = chunkdata['node']
1856 node = chunkdata['node']
1856 ui.write("%s\n" % hex(node))
1857 ui.write("%s\n" % hex(node))
1857 chain = node
1858 chain = node
1858 finally:
1859 finally:
1859 f.close()
1860 f.close()
1860
1861
1861 @command('debugcheckstate', [], '')
1862 @command('debugcheckstate', [], '')
1862 def debugcheckstate(ui, repo):
1863 def debugcheckstate(ui, repo):
1863 """validate the correctness of the current dirstate"""
1864 """validate the correctness of the current dirstate"""
1864 parent1, parent2 = repo.dirstate.parents()
1865 parent1, parent2 = repo.dirstate.parents()
1865 m1 = repo[parent1].manifest()
1866 m1 = repo[parent1].manifest()
1866 m2 = repo[parent2].manifest()
1867 m2 = repo[parent2].manifest()
1867 errors = 0
1868 errors = 0
1868 for f in repo.dirstate:
1869 for f in repo.dirstate:
1869 state = repo.dirstate[f]
1870 state = repo.dirstate[f]
1870 if state in "nr" and f not in m1:
1871 if state in "nr" and f not in m1:
1871 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
1872 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
1872 errors += 1
1873 errors += 1
1873 if state in "a" and f in m1:
1874 if state in "a" and f in m1:
1874 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
1875 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
1875 errors += 1
1876 errors += 1
1876 if state in "m" and f not in m1 and f not in m2:
1877 if state in "m" and f not in m1 and f not in m2:
1877 ui.warn(_("%s in state %s, but not in either manifest\n") %
1878 ui.warn(_("%s in state %s, but not in either manifest\n") %
1878 (f, state))
1879 (f, state))
1879 errors += 1
1880 errors += 1
1880 for f in m1:
1881 for f in m1:
1881 state = repo.dirstate[f]
1882 state = repo.dirstate[f]
1882 if state not in "nrm":
1883 if state not in "nrm":
1883 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
1884 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
1884 errors += 1
1885 errors += 1
1885 if errors:
1886 if errors:
1886 error = _(".hg/dirstate inconsistent with current parent's manifest")
1887 error = _(".hg/dirstate inconsistent with current parent's manifest")
1887 raise util.Abort(error)
1888 raise util.Abort(error)
1888
1889
1889 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
1890 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
1890 def debugcommands(ui, cmd='', *args):
1891 def debugcommands(ui, cmd='', *args):
1891 """list all available commands and options"""
1892 """list all available commands and options"""
1892 for cmd, vals in sorted(table.iteritems()):
1893 for cmd, vals in sorted(table.iteritems()):
1893 cmd = cmd.split('|')[0].strip('^')
1894 cmd = cmd.split('|')[0].strip('^')
1894 opts = ', '.join([i[1] for i in vals[1]])
1895 opts = ', '.join([i[1] for i in vals[1]])
1895 ui.write('%s: %s\n' % (cmd, opts))
1896 ui.write('%s: %s\n' % (cmd, opts))
1896
1897
1897 @command('debugcomplete',
1898 @command('debugcomplete',
1898 [('o', 'options', None, _('show the command options'))],
1899 [('o', 'options', None, _('show the command options'))],
1899 _('[-o] CMD'),
1900 _('[-o] CMD'),
1900 norepo=True)
1901 norepo=True)
1901 def debugcomplete(ui, cmd='', **opts):
1902 def debugcomplete(ui, cmd='', **opts):
1902 """returns the completion list associated with the given command"""
1903 """returns the completion list associated with the given command"""
1903
1904
1904 if opts.get('options'):
1905 if opts.get('options'):
1905 options = []
1906 options = []
1906 otables = [globalopts]
1907 otables = [globalopts]
1907 if cmd:
1908 if cmd:
1908 aliases, entry = cmdutil.findcmd(cmd, table, False)
1909 aliases, entry = cmdutil.findcmd(cmd, table, False)
1909 otables.append(entry[1])
1910 otables.append(entry[1])
1910 for t in otables:
1911 for t in otables:
1911 for o in t:
1912 for o in t:
1912 if "(DEPRECATED)" in o[3]:
1913 if "(DEPRECATED)" in o[3]:
1913 continue
1914 continue
1914 if o[0]:
1915 if o[0]:
1915 options.append('-%s' % o[0])
1916 options.append('-%s' % o[0])
1916 options.append('--%s' % o[1])
1917 options.append('--%s' % o[1])
1917 ui.write("%s\n" % "\n".join(options))
1918 ui.write("%s\n" % "\n".join(options))
1918 return
1919 return
1919
1920
1920 cmdlist = cmdutil.findpossible(cmd, table)
1921 cmdlist = cmdutil.findpossible(cmd, table)
1921 if ui.verbose:
1922 if ui.verbose:
1922 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
1923 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
1923 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
1924 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
1924
1925
1925 @command('debugdag',
1926 @command('debugdag',
1926 [('t', 'tags', None, _('use tags as labels')),
1927 [('t', 'tags', None, _('use tags as labels')),
1927 ('b', 'branches', None, _('annotate with branch names')),
1928 ('b', 'branches', None, _('annotate with branch names')),
1928 ('', 'dots', None, _('use dots for runs')),
1929 ('', 'dots', None, _('use dots for runs')),
1929 ('s', 'spaces', None, _('separate elements by spaces'))],
1930 ('s', 'spaces', None, _('separate elements by spaces'))],
1930 _('[OPTION]... [FILE [REV]...]'),
1931 _('[OPTION]... [FILE [REV]...]'),
1931 optionalrepo=True)
1932 optionalrepo=True)
1932 def debugdag(ui, repo, file_=None, *revs, **opts):
1933 def debugdag(ui, repo, file_=None, *revs, **opts):
1933 """format the changelog or an index DAG as a concise textual description
1934 """format the changelog or an index DAG as a concise textual description
1934
1935
1935 If you pass a revlog index, the revlog's DAG is emitted. If you list
1936 If you pass a revlog index, the revlog's DAG is emitted. If you list
1936 revision numbers, they get labeled in the output as rN.
1937 revision numbers, they get labeled in the output as rN.
1937
1938
1938 Otherwise, the changelog DAG of the current repo is emitted.
1939 Otherwise, the changelog DAG of the current repo is emitted.
1939 """
1940 """
1940 spaces = opts.get('spaces')
1941 spaces = opts.get('spaces')
1941 dots = opts.get('dots')
1942 dots = opts.get('dots')
1942 if file_:
1943 if file_:
1943 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1944 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1944 revs = set((int(r) for r in revs))
1945 revs = set((int(r) for r in revs))
1945 def events():
1946 def events():
1946 for r in rlog:
1947 for r in rlog:
1947 yield 'n', (r, list(p for p in rlog.parentrevs(r)
1948 yield 'n', (r, list(p for p in rlog.parentrevs(r)
1948 if p != -1))
1949 if p != -1))
1949 if r in revs:
1950 if r in revs:
1950 yield 'l', (r, "r%i" % r)
1951 yield 'l', (r, "r%i" % r)
1951 elif repo:
1952 elif repo:
1952 cl = repo.changelog
1953 cl = repo.changelog
1953 tags = opts.get('tags')
1954 tags = opts.get('tags')
1954 branches = opts.get('branches')
1955 branches = opts.get('branches')
1955 if tags:
1956 if tags:
1956 labels = {}
1957 labels = {}
1957 for l, n in repo.tags().items():
1958 for l, n in repo.tags().items():
1958 labels.setdefault(cl.rev(n), []).append(l)
1959 labels.setdefault(cl.rev(n), []).append(l)
1959 def events():
1960 def events():
1960 b = "default"
1961 b = "default"
1961 for r in cl:
1962 for r in cl:
1962 if branches:
1963 if branches:
1963 newb = cl.read(cl.node(r))[5]['branch']
1964 newb = cl.read(cl.node(r))[5]['branch']
1964 if newb != b:
1965 if newb != b:
1965 yield 'a', newb
1966 yield 'a', newb
1966 b = newb
1967 b = newb
1967 yield 'n', (r, list(p for p in cl.parentrevs(r)
1968 yield 'n', (r, list(p for p in cl.parentrevs(r)
1968 if p != -1))
1969 if p != -1))
1969 if tags:
1970 if tags:
1970 ls = labels.get(r)
1971 ls = labels.get(r)
1971 if ls:
1972 if ls:
1972 for l in ls:
1973 for l in ls:
1973 yield 'l', (r, l)
1974 yield 'l', (r, l)
1974 else:
1975 else:
1975 raise util.Abort(_('need repo for changelog dag'))
1976 raise util.Abort(_('need repo for changelog dag'))
1976
1977
1977 for line in dagparser.dagtextlines(events(),
1978 for line in dagparser.dagtextlines(events(),
1978 addspaces=spaces,
1979 addspaces=spaces,
1979 wraplabels=True,
1980 wraplabels=True,
1980 wrapannotations=True,
1981 wrapannotations=True,
1981 wrapnonlinear=dots,
1982 wrapnonlinear=dots,
1982 usedots=dots,
1983 usedots=dots,
1983 maxlinewidth=70):
1984 maxlinewidth=70):
1984 ui.write(line)
1985 ui.write(line)
1985 ui.write("\n")
1986 ui.write("\n")
1986
1987
1987 @command('debugdata',
1988 @command('debugdata',
1988 [('c', 'changelog', False, _('open changelog')),
1989 [('c', 'changelog', False, _('open changelog')),
1989 ('m', 'manifest', False, _('open manifest'))],
1990 ('m', 'manifest', False, _('open manifest'))],
1990 _('-c|-m|FILE REV'))
1991 _('-c|-m|FILE REV'))
1991 def debugdata(ui, repo, file_, rev=None, **opts):
1992 def debugdata(ui, repo, file_, rev=None, **opts):
1992 """dump the contents of a data file revision"""
1993 """dump the contents of a data file revision"""
1993 if opts.get('changelog') or opts.get('manifest'):
1994 if opts.get('changelog') or opts.get('manifest'):
1994 file_, rev = None, file_
1995 file_, rev = None, file_
1995 elif rev is None:
1996 elif rev is None:
1996 raise error.CommandError('debugdata', _('invalid arguments'))
1997 raise error.CommandError('debugdata', _('invalid arguments'))
1997 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
1998 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
1998 try:
1999 try:
1999 ui.write(r.revision(r.lookup(rev)))
2000 ui.write(r.revision(r.lookup(rev)))
2000 except KeyError:
2001 except KeyError:
2001 raise util.Abort(_('invalid revision identifier %s') % rev)
2002 raise util.Abort(_('invalid revision identifier %s') % rev)
2002
2003
2003 @command('debugdate',
2004 @command('debugdate',
2004 [('e', 'extended', None, _('try extended date formats'))],
2005 [('e', 'extended', None, _('try extended date formats'))],
2005 _('[-e] DATE [RANGE]'),
2006 _('[-e] DATE [RANGE]'),
2006 norepo=True, optionalrepo=True)
2007 norepo=True, optionalrepo=True)
2007 def debugdate(ui, date, range=None, **opts):
2008 def debugdate(ui, date, range=None, **opts):
2008 """parse and display a date"""
2009 """parse and display a date"""
2009 if opts["extended"]:
2010 if opts["extended"]:
2010 d = util.parsedate(date, util.extendeddateformats)
2011 d = util.parsedate(date, util.extendeddateformats)
2011 else:
2012 else:
2012 d = util.parsedate(date)
2013 d = util.parsedate(date)
2013 ui.write(("internal: %s %s\n") % d)
2014 ui.write(("internal: %s %s\n") % d)
2014 ui.write(("standard: %s\n") % util.datestr(d))
2015 ui.write(("standard: %s\n") % util.datestr(d))
2015 if range:
2016 if range:
2016 m = util.matchdate(range)
2017 m = util.matchdate(range)
2017 ui.write(("match: %s\n") % m(d[0]))
2018 ui.write(("match: %s\n") % m(d[0]))
2018
2019
2019 @command('debugdiscovery',
2020 @command('debugdiscovery',
2020 [('', 'old', None, _('use old-style discovery')),
2021 [('', 'old', None, _('use old-style discovery')),
2021 ('', 'nonheads', None,
2022 ('', 'nonheads', None,
2022 _('use old-style discovery with non-heads included')),
2023 _('use old-style discovery with non-heads included')),
2023 ] + remoteopts,
2024 ] + remoteopts,
2024 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
2025 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
2025 def debugdiscovery(ui, repo, remoteurl="default", **opts):
2026 def debugdiscovery(ui, repo, remoteurl="default", **opts):
2026 """runs the changeset discovery protocol in isolation"""
2027 """runs the changeset discovery protocol in isolation"""
2027 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
2028 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
2028 opts.get('branch'))
2029 opts.get('branch'))
2029 remote = hg.peer(repo, opts, remoteurl)
2030 remote = hg.peer(repo, opts, remoteurl)
2030 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
2031 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
2031
2032
2032 # make sure tests are repeatable
2033 # make sure tests are repeatable
2033 random.seed(12323)
2034 random.seed(12323)
2034
2035
2035 def doit(localheads, remoteheads, remote=remote):
2036 def doit(localheads, remoteheads, remote=remote):
2036 if opts.get('old'):
2037 if opts.get('old'):
2037 if localheads:
2038 if localheads:
2038 raise util.Abort('cannot use localheads with old style '
2039 raise util.Abort('cannot use localheads with old style '
2039 'discovery')
2040 'discovery')
2040 if not util.safehasattr(remote, 'branches'):
2041 if not util.safehasattr(remote, 'branches'):
2041 # enable in-client legacy support
2042 # enable in-client legacy support
2042 remote = localrepo.locallegacypeer(remote.local())
2043 remote = localrepo.locallegacypeer(remote.local())
2043 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
2044 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
2044 force=True)
2045 force=True)
2045 common = set(common)
2046 common = set(common)
2046 if not opts.get('nonheads'):
2047 if not opts.get('nonheads'):
2047 ui.write(("unpruned common: %s\n") %
2048 ui.write(("unpruned common: %s\n") %
2048 " ".join(sorted(short(n) for n in common)))
2049 " ".join(sorted(short(n) for n in common)))
2049 dag = dagutil.revlogdag(repo.changelog)
2050 dag = dagutil.revlogdag(repo.changelog)
2050 all = dag.ancestorset(dag.internalizeall(common))
2051 all = dag.ancestorset(dag.internalizeall(common))
2051 common = dag.externalizeall(dag.headsetofconnecteds(all))
2052 common = dag.externalizeall(dag.headsetofconnecteds(all))
2052 else:
2053 else:
2053 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
2054 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
2054 common = set(common)
2055 common = set(common)
2055 rheads = set(hds)
2056 rheads = set(hds)
2056 lheads = set(repo.heads())
2057 lheads = set(repo.heads())
2057 ui.write(("common heads: %s\n") %
2058 ui.write(("common heads: %s\n") %
2058 " ".join(sorted(short(n) for n in common)))
2059 " ".join(sorted(short(n) for n in common)))
2059 if lheads <= common:
2060 if lheads <= common:
2060 ui.write(("local is subset\n"))
2061 ui.write(("local is subset\n"))
2061 elif rheads <= common:
2062 elif rheads <= common:
2062 ui.write(("remote is subset\n"))
2063 ui.write(("remote is subset\n"))
2063
2064
2064 serverlogs = opts.get('serverlog')
2065 serverlogs = opts.get('serverlog')
2065 if serverlogs:
2066 if serverlogs:
2066 for filename in serverlogs:
2067 for filename in serverlogs:
2067 logfile = open(filename, 'r')
2068 logfile = open(filename, 'r')
2068 try:
2069 try:
2069 line = logfile.readline()
2070 line = logfile.readline()
2070 while line:
2071 while line:
2071 parts = line.strip().split(';')
2072 parts = line.strip().split(';')
2072 op = parts[1]
2073 op = parts[1]
2073 if op == 'cg':
2074 if op == 'cg':
2074 pass
2075 pass
2075 elif op == 'cgss':
2076 elif op == 'cgss':
2076 doit(parts[2].split(' '), parts[3].split(' '))
2077 doit(parts[2].split(' '), parts[3].split(' '))
2077 elif op == 'unb':
2078 elif op == 'unb':
2078 doit(parts[3].split(' '), parts[2].split(' '))
2079 doit(parts[3].split(' '), parts[2].split(' '))
2079 line = logfile.readline()
2080 line = logfile.readline()
2080 finally:
2081 finally:
2081 logfile.close()
2082 logfile.close()
2082
2083
2083 else:
2084 else:
2084 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
2085 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
2085 opts.get('remote_head'))
2086 opts.get('remote_head'))
2086 localrevs = opts.get('local_head')
2087 localrevs = opts.get('local_head')
2087 doit(localrevs, remoterevs)
2088 doit(localrevs, remoterevs)
2088
2089
2089 @command('debugfileset',
2090 @command('debugfileset',
2090 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
2091 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
2091 _('[-r REV] FILESPEC'))
2092 _('[-r REV] FILESPEC'))
2092 def debugfileset(ui, repo, expr, **opts):
2093 def debugfileset(ui, repo, expr, **opts):
2093 '''parse and apply a fileset specification'''
2094 '''parse and apply a fileset specification'''
2094 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
2095 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
2095 if ui.verbose:
2096 if ui.verbose:
2096 tree = fileset.parse(expr)[0]
2097 tree = fileset.parse(expr)[0]
2097 ui.note(tree, "\n")
2098 ui.note(tree, "\n")
2098
2099
2099 for f in ctx.getfileset(expr):
2100 for f in ctx.getfileset(expr):
2100 ui.write("%s\n" % f)
2101 ui.write("%s\n" % f)
2101
2102
2102 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
2103 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
2103 def debugfsinfo(ui, path="."):
2104 def debugfsinfo(ui, path="."):
2104 """show information detected about current filesystem"""
2105 """show information detected about current filesystem"""
2105 util.writefile('.debugfsinfo', '')
2106 util.writefile('.debugfsinfo', '')
2106 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
2107 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
2107 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
2108 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
2108 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
2109 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
2109 ui.write(('case-sensitive: %s\n') % (util.checkcase('.debugfsinfo')
2110 ui.write(('case-sensitive: %s\n') % (util.checkcase('.debugfsinfo')
2110 and 'yes' or 'no'))
2111 and 'yes' or 'no'))
2111 os.unlink('.debugfsinfo')
2112 os.unlink('.debugfsinfo')
2112
2113
2113 @command('debuggetbundle',
2114 @command('debuggetbundle',
2114 [('H', 'head', [], _('id of head node'), _('ID')),
2115 [('H', 'head', [], _('id of head node'), _('ID')),
2115 ('C', 'common', [], _('id of common node'), _('ID')),
2116 ('C', 'common', [], _('id of common node'), _('ID')),
2116 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
2117 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
2117 _('REPO FILE [-H|-C ID]...'),
2118 _('REPO FILE [-H|-C ID]...'),
2118 norepo=True)
2119 norepo=True)
2119 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
2120 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
2120 """retrieves a bundle from a repo
2121 """retrieves a bundle from a repo
2121
2122
2122 Every ID must be a full-length hex node id string. Saves the bundle to the
2123 Every ID must be a full-length hex node id string. Saves the bundle to the
2123 given file.
2124 given file.
2124 """
2125 """
2125 repo = hg.peer(ui, opts, repopath)
2126 repo = hg.peer(ui, opts, repopath)
2126 if not repo.capable('getbundle'):
2127 if not repo.capable('getbundle'):
2127 raise util.Abort("getbundle() not supported by target repository")
2128 raise util.Abort("getbundle() not supported by target repository")
2128 args = {}
2129 args = {}
2129 if common:
2130 if common:
2130 args['common'] = [bin(s) for s in common]
2131 args['common'] = [bin(s) for s in common]
2131 if head:
2132 if head:
2132 args['heads'] = [bin(s) for s in head]
2133 args['heads'] = [bin(s) for s in head]
2133 # TODO: get desired bundlecaps from command line.
2134 # TODO: get desired bundlecaps from command line.
2134 args['bundlecaps'] = None
2135 args['bundlecaps'] = None
2135 bundle = repo.getbundle('debug', **args)
2136 bundle = repo.getbundle('debug', **args)
2136
2137
2137 bundletype = opts.get('type', 'bzip2').lower()
2138 bundletype = opts.get('type', 'bzip2').lower()
2138 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
2139 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
2139 bundletype = btypes.get(bundletype)
2140 bundletype = btypes.get(bundletype)
2140 if bundletype not in changegroup.bundletypes:
2141 if bundletype not in changegroup.bundletypes:
2141 raise util.Abort(_('unknown bundle type specified with --type'))
2142 raise util.Abort(_('unknown bundle type specified with --type'))
2142 changegroup.writebundle(bundle, bundlepath, bundletype)
2143 changegroup.writebundle(bundle, bundlepath, bundletype)
2143
2144
2144 @command('debugignore', [], '')
2145 @command('debugignore', [], '')
2145 def debugignore(ui, repo, *values, **opts):
2146 def debugignore(ui, repo, *values, **opts):
2146 """display the combined ignore pattern"""
2147 """display the combined ignore pattern"""
2147 ignore = repo.dirstate._ignore
2148 ignore = repo.dirstate._ignore
2148 includepat = getattr(ignore, 'includepat', None)
2149 includepat = getattr(ignore, 'includepat', None)
2149 if includepat is not None:
2150 if includepat is not None:
2150 ui.write("%s\n" % includepat)
2151 ui.write("%s\n" % includepat)
2151 else:
2152 else:
2152 raise util.Abort(_("no ignore patterns found"))
2153 raise util.Abort(_("no ignore patterns found"))
2153
2154
2154 @command('debugindex',
2155 @command('debugindex',
2155 [('c', 'changelog', False, _('open changelog')),
2156 [('c', 'changelog', False, _('open changelog')),
2156 ('m', 'manifest', False, _('open manifest')),
2157 ('m', 'manifest', False, _('open manifest')),
2157 ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
2158 ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
2158 _('[-f FORMAT] -c|-m|FILE'),
2159 _('[-f FORMAT] -c|-m|FILE'),
2159 optionalrepo=True)
2160 optionalrepo=True)
2160 def debugindex(ui, repo, file_=None, **opts):
2161 def debugindex(ui, repo, file_=None, **opts):
2161 """dump the contents of an index file"""
2162 """dump the contents of an index file"""
2162 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
2163 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
2163 format = opts.get('format', 0)
2164 format = opts.get('format', 0)
2164 if format not in (0, 1):
2165 if format not in (0, 1):
2165 raise util.Abort(_("unknown format %d") % format)
2166 raise util.Abort(_("unknown format %d") % format)
2166
2167
2167 generaldelta = r.version & revlog.REVLOGGENERALDELTA
2168 generaldelta = r.version & revlog.REVLOGGENERALDELTA
2168 if generaldelta:
2169 if generaldelta:
2169 basehdr = ' delta'
2170 basehdr = ' delta'
2170 else:
2171 else:
2171 basehdr = ' base'
2172 basehdr = ' base'
2172
2173
2173 if format == 0:
2174 if format == 0:
2174 ui.write(" rev offset length " + basehdr + " linkrev"
2175 ui.write(" rev offset length " + basehdr + " linkrev"
2175 " nodeid p1 p2\n")
2176 " nodeid p1 p2\n")
2176 elif format == 1:
2177 elif format == 1:
2177 ui.write(" rev flag offset length"
2178 ui.write(" rev flag offset length"
2178 " size " + basehdr + " link p1 p2"
2179 " size " + basehdr + " link p1 p2"
2179 " nodeid\n")
2180 " nodeid\n")
2180
2181
2181 for i in r:
2182 for i in r:
2182 node = r.node(i)
2183 node = r.node(i)
2183 if generaldelta:
2184 if generaldelta:
2184 base = r.deltaparent(i)
2185 base = r.deltaparent(i)
2185 else:
2186 else:
2186 base = r.chainbase(i)
2187 base = r.chainbase(i)
2187 if format == 0:
2188 if format == 0:
2188 try:
2189 try:
2189 pp = r.parents(node)
2190 pp = r.parents(node)
2190 except Exception:
2191 except Exception:
2191 pp = [nullid, nullid]
2192 pp = [nullid, nullid]
2192 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
2193 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
2193 i, r.start(i), r.length(i), base, r.linkrev(i),
2194 i, r.start(i), r.length(i), base, r.linkrev(i),
2194 short(node), short(pp[0]), short(pp[1])))
2195 short(node), short(pp[0]), short(pp[1])))
2195 elif format == 1:
2196 elif format == 1:
2196 pr = r.parentrevs(i)
2197 pr = r.parentrevs(i)
2197 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
2198 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
2198 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2199 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2199 base, r.linkrev(i), pr[0], pr[1], short(node)))
2200 base, r.linkrev(i), pr[0], pr[1], short(node)))
2200
2201
2201 @command('debugindexdot', [], _('FILE'), optionalrepo=True)
2202 @command('debugindexdot', [], _('FILE'), optionalrepo=True)
2202 def debugindexdot(ui, repo, file_):
2203 def debugindexdot(ui, repo, file_):
2203 """dump an index DAG as a graphviz dot file"""
2204 """dump an index DAG as a graphviz dot file"""
2204 r = None
2205 r = None
2205 if repo:
2206 if repo:
2206 filelog = repo.file(file_)
2207 filelog = repo.file(file_)
2207 if len(filelog):
2208 if len(filelog):
2208 r = filelog
2209 r = filelog
2209 if not r:
2210 if not r:
2210 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2211 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2211 ui.write(("digraph G {\n"))
2212 ui.write(("digraph G {\n"))
2212 for i in r:
2213 for i in r:
2213 node = r.node(i)
2214 node = r.node(i)
2214 pp = r.parents(node)
2215 pp = r.parents(node)
2215 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
2216 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
2216 if pp[1] != nullid:
2217 if pp[1] != nullid:
2217 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
2218 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
2218 ui.write("}\n")
2219 ui.write("}\n")
2219
2220
2220 @command('debuginstall', [], '', norepo=True)
2221 @command('debuginstall', [], '', norepo=True)
2221 def debuginstall(ui):
2222 def debuginstall(ui):
2222 '''test Mercurial installation
2223 '''test Mercurial installation
2223
2224
2224 Returns 0 on success.
2225 Returns 0 on success.
2225 '''
2226 '''
2226
2227
2227 def writetemp(contents):
2228 def writetemp(contents):
2228 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
2229 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
2229 f = os.fdopen(fd, "wb")
2230 f = os.fdopen(fd, "wb")
2230 f.write(contents)
2231 f.write(contents)
2231 f.close()
2232 f.close()
2232 return name
2233 return name
2233
2234
2234 problems = 0
2235 problems = 0
2235
2236
2236 # encoding
2237 # encoding
2237 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
2238 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
2238 try:
2239 try:
2239 encoding.fromlocal("test")
2240 encoding.fromlocal("test")
2240 except util.Abort, inst:
2241 except util.Abort, inst:
2241 ui.write(" %s\n" % inst)
2242 ui.write(" %s\n" % inst)
2242 ui.write(_(" (check that your locale is properly set)\n"))
2243 ui.write(_(" (check that your locale is properly set)\n"))
2243 problems += 1
2244 problems += 1
2244
2245
2245 # Python
2246 # Python
2246 ui.status(_("checking Python executable (%s)\n") % sys.executable)
2247 ui.status(_("checking Python executable (%s)\n") % sys.executable)
2247 ui.status(_("checking Python version (%s)\n")
2248 ui.status(_("checking Python version (%s)\n")
2248 % ("%s.%s.%s" % sys.version_info[:3]))
2249 % ("%s.%s.%s" % sys.version_info[:3]))
2249 ui.status(_("checking Python lib (%s)...\n")
2250 ui.status(_("checking Python lib (%s)...\n")
2250 % os.path.dirname(os.__file__))
2251 % os.path.dirname(os.__file__))
2251
2252
2252 # compiled modules
2253 # compiled modules
2253 ui.status(_("checking installed modules (%s)...\n")
2254 ui.status(_("checking installed modules (%s)...\n")
2254 % os.path.dirname(__file__))
2255 % os.path.dirname(__file__))
2255 try:
2256 try:
2256 import bdiff, mpatch, base85, osutil
2257 import bdiff, mpatch, base85, osutil
2257 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
2258 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
2258 except Exception, inst:
2259 except Exception, inst:
2259 ui.write(" %s\n" % inst)
2260 ui.write(" %s\n" % inst)
2260 ui.write(_(" One or more extensions could not be found"))
2261 ui.write(_(" One or more extensions could not be found"))
2261 ui.write(_(" (check that you compiled the extensions)\n"))
2262 ui.write(_(" (check that you compiled the extensions)\n"))
2262 problems += 1
2263 problems += 1
2263
2264
2264 # templates
2265 # templates
2265 import templater
2266 import templater
2266 p = templater.templatepaths()
2267 p = templater.templatepaths()
2267 ui.status(_("checking templates (%s)...\n") % ' '.join(p))
2268 ui.status(_("checking templates (%s)...\n") % ' '.join(p))
2268 if p:
2269 if p:
2269 m = templater.templatepath("map-cmdline.default")
2270 m = templater.templatepath("map-cmdline.default")
2270 if m:
2271 if m:
2271 # template found, check if it is working
2272 # template found, check if it is working
2272 try:
2273 try:
2273 templater.templater(m)
2274 templater.templater(m)
2274 except Exception, inst:
2275 except Exception, inst:
2275 ui.write(" %s\n" % inst)
2276 ui.write(" %s\n" % inst)
2276 p = None
2277 p = None
2277 else:
2278 else:
2278 ui.write(_(" template 'default' not found\n"))
2279 ui.write(_(" template 'default' not found\n"))
2279 p = None
2280 p = None
2280 else:
2281 else:
2281 ui.write(_(" no template directories found\n"))
2282 ui.write(_(" no template directories found\n"))
2282 if not p:
2283 if not p:
2283 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
2284 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
2284 problems += 1
2285 problems += 1
2285
2286
2286 # editor
2287 # editor
2287 ui.status(_("checking commit editor...\n"))
2288 ui.status(_("checking commit editor...\n"))
2288 editor = ui.geteditor()
2289 editor = ui.geteditor()
2289 cmdpath = util.findexe(shlex.split(editor)[0])
2290 cmdpath = util.findexe(shlex.split(editor)[0])
2290 if not cmdpath:
2291 if not cmdpath:
2291 if editor == 'vi':
2292 if editor == 'vi':
2292 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
2293 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
2293 ui.write(_(" (specify a commit editor in your configuration"
2294 ui.write(_(" (specify a commit editor in your configuration"
2294 " file)\n"))
2295 " file)\n"))
2295 else:
2296 else:
2296 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
2297 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
2297 ui.write(_(" (specify a commit editor in your configuration"
2298 ui.write(_(" (specify a commit editor in your configuration"
2298 " file)\n"))
2299 " file)\n"))
2299 problems += 1
2300 problems += 1
2300
2301
2301 # check username
2302 # check username
2302 ui.status(_("checking username...\n"))
2303 ui.status(_("checking username...\n"))
2303 try:
2304 try:
2304 ui.username()
2305 ui.username()
2305 except util.Abort, e:
2306 except util.Abort, e:
2306 ui.write(" %s\n" % e)
2307 ui.write(" %s\n" % e)
2307 ui.write(_(" (specify a username in your configuration file)\n"))
2308 ui.write(_(" (specify a username in your configuration file)\n"))
2308 problems += 1
2309 problems += 1
2309
2310
2310 if not problems:
2311 if not problems:
2311 ui.status(_("no problems detected\n"))
2312 ui.status(_("no problems detected\n"))
2312 else:
2313 else:
2313 ui.write(_("%s problems detected,"
2314 ui.write(_("%s problems detected,"
2314 " please check your install!\n") % problems)
2315 " please check your install!\n") % problems)
2315
2316
2316 return problems
2317 return problems
2317
2318
2318 @command('debugknown', [], _('REPO ID...'), norepo=True)
2319 @command('debugknown', [], _('REPO ID...'), norepo=True)
2319 def debugknown(ui, repopath, *ids, **opts):
2320 def debugknown(ui, repopath, *ids, **opts):
2320 """test whether node ids are known to a repo
2321 """test whether node ids are known to a repo
2321
2322
2322 Every ID must be a full-length hex node id string. Returns a list of 0s
2323 Every ID must be a full-length hex node id string. Returns a list of 0s
2323 and 1s indicating unknown/known.
2324 and 1s indicating unknown/known.
2324 """
2325 """
2325 repo = hg.peer(ui, opts, repopath)
2326 repo = hg.peer(ui, opts, repopath)
2326 if not repo.capable('known'):
2327 if not repo.capable('known'):
2327 raise util.Abort("known() not supported by target repository")
2328 raise util.Abort("known() not supported by target repository")
2328 flags = repo.known([bin(s) for s in ids])
2329 flags = repo.known([bin(s) for s in ids])
2329 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2330 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2330
2331
2331 @command('debuglabelcomplete', [], _('LABEL...'))
2332 @command('debuglabelcomplete', [], _('LABEL...'))
2332 def debuglabelcomplete(ui, repo, *args):
2333 def debuglabelcomplete(ui, repo, *args):
2333 '''complete "labels" - tags, open branch names, bookmark names'''
2334 '''complete "labels" - tags, open branch names, bookmark names'''
2334
2335
2335 labels = set()
2336 labels = set()
2336 labels.update(t[0] for t in repo.tagslist())
2337 labels.update(t[0] for t in repo.tagslist())
2337 labels.update(repo._bookmarks.keys())
2338 labels.update(repo._bookmarks.keys())
2338 labels.update(tag for (tag, heads, tip, closed)
2339 labels.update(tag for (tag, heads, tip, closed)
2339 in repo.branchmap().iterbranches() if not closed)
2340 in repo.branchmap().iterbranches() if not closed)
2340 completions = set()
2341 completions = set()
2341 if not args:
2342 if not args:
2342 args = ['']
2343 args = ['']
2343 for a in args:
2344 for a in args:
2344 completions.update(l for l in labels if l.startswith(a))
2345 completions.update(l for l in labels if l.startswith(a))
2345 ui.write('\n'.join(sorted(completions)))
2346 ui.write('\n'.join(sorted(completions)))
2346 ui.write('\n')
2347 ui.write('\n')
2347
2348
2348 @command('debuglocks',
2349 @command('debuglocks',
2349 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')),
2350 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')),
2350 ('W', 'force-wlock', None,
2351 ('W', 'force-wlock', None,
2351 _('free the working state lock (DANGEROUS)'))],
2352 _('free the working state lock (DANGEROUS)'))],
2352 _('[OPTION]...'))
2353 _('[OPTION]...'))
2353 def debuglocks(ui, repo, **opts):
2354 def debuglocks(ui, repo, **opts):
2354 """show or modify state of locks
2355 """show or modify state of locks
2355
2356
2356 By default, this command will show which locks are held. This
2357 By default, this command will show which locks are held. This
2357 includes the user and process holding the lock, the amount of time
2358 includes the user and process holding the lock, the amount of time
2358 the lock has been held, and the machine name where the process is
2359 the lock has been held, and the machine name where the process is
2359 running if it's not local.
2360 running if it's not local.
2360
2361
2361 Locks protect the integrity of Mercurial's data, so should be
2362 Locks protect the integrity of Mercurial's data, so should be
2362 treated with care. System crashes or other interruptions may cause
2363 treated with care. System crashes or other interruptions may cause
2363 locks to not be properly released, though Mercurial will usually
2364 locks to not be properly released, though Mercurial will usually
2364 detect and remove such stale locks automatically.
2365 detect and remove such stale locks automatically.
2365
2366
2366 However, detecting stale locks may not always be possible (for
2367 However, detecting stale locks may not always be possible (for
2367 instance, on a shared filesystem). Removing locks may also be
2368 instance, on a shared filesystem). Removing locks may also be
2368 blocked by filesystem permissions.
2369 blocked by filesystem permissions.
2369
2370
2370 Returns 0 if no locks are held.
2371 Returns 0 if no locks are held.
2371
2372
2372 """
2373 """
2373
2374
2374 if opts.get('force_lock'):
2375 if opts.get('force_lock'):
2375 repo.svfs.unlink('lock')
2376 repo.svfs.unlink('lock')
2376 if opts.get('force_wlock'):
2377 if opts.get('force_wlock'):
2377 repo.vfs.unlink('wlock')
2378 repo.vfs.unlink('wlock')
2378 if opts.get('force_lock') or opts.get('force_lock'):
2379 if opts.get('force_lock') or opts.get('force_lock'):
2379 return 0
2380 return 0
2380
2381
2381 now = time.time()
2382 now = time.time()
2382 held = 0
2383 held = 0
2383
2384
2384 def report(vfs, name, method):
2385 def report(vfs, name, method):
2385 # this causes stale locks to get reaped for more accurate reporting
2386 # this causes stale locks to get reaped for more accurate reporting
2386 try:
2387 try:
2387 l = method(False)
2388 l = method(False)
2388 except error.LockHeld:
2389 except error.LockHeld:
2389 l = None
2390 l = None
2390
2391
2391 if l:
2392 if l:
2392 l.release()
2393 l.release()
2393 else:
2394 else:
2394 try:
2395 try:
2395 stat = repo.svfs.lstat(name)
2396 stat = repo.svfs.lstat(name)
2396 age = now - stat.st_mtime
2397 age = now - stat.st_mtime
2397 user = util.username(stat.st_uid)
2398 user = util.username(stat.st_uid)
2398 locker = vfs.readlock(name)
2399 locker = vfs.readlock(name)
2399 if ":" in locker:
2400 if ":" in locker:
2400 host, pid = locker.split(':')
2401 host, pid = locker.split(':')
2401 if host == socket.gethostname():
2402 if host == socket.gethostname():
2402 locker = 'user %s, process %s' % (user, pid)
2403 locker = 'user %s, process %s' % (user, pid)
2403 else:
2404 else:
2404 locker = 'user %s, process %s, host %s' \
2405 locker = 'user %s, process %s, host %s' \
2405 % (user, pid, host)
2406 % (user, pid, host)
2406 ui.write("%-6s %s (%ds)\n" % (name + ":", locker, age))
2407 ui.write("%-6s %s (%ds)\n" % (name + ":", locker, age))
2407 return 1
2408 return 1
2408 except OSError, e:
2409 except OSError, e:
2409 if e.errno != errno.ENOENT:
2410 if e.errno != errno.ENOENT:
2410 raise
2411 raise
2411
2412
2412 ui.write("%-6s free\n" % (name + ":"))
2413 ui.write("%-6s free\n" % (name + ":"))
2413 return 0
2414 return 0
2414
2415
2415 held += report(repo.svfs, "lock", repo.lock)
2416 held += report(repo.svfs, "lock", repo.lock)
2416 held += report(repo.vfs, "wlock", repo.wlock)
2417 held += report(repo.vfs, "wlock", repo.wlock)
2417
2418
2418 return held
2419 return held
2419
2420
2420 @command('debugobsolete',
2421 @command('debugobsolete',
2421 [('', 'flags', 0, _('markers flag')),
2422 [('', 'flags', 0, _('markers flag')),
2422 ('', 'record-parents', False,
2423 ('', 'record-parents', False,
2423 _('record parent information for the precursor')),
2424 _('record parent information for the precursor')),
2424 ('r', 'rev', [], _('display markers relevant to REV')),
2425 ('r', 'rev', [], _('display markers relevant to REV')),
2425 ] + commitopts2,
2426 ] + commitopts2,
2426 _('[OBSOLETED [REPLACEMENT] [REPL... ]'))
2427 _('[OBSOLETED [REPLACEMENT] [REPL... ]'))
2427 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
2428 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
2428 """create arbitrary obsolete marker
2429 """create arbitrary obsolete marker
2429
2430
2430 With no arguments, displays the list of obsolescence markers."""
2431 With no arguments, displays the list of obsolescence markers."""
2431
2432
2432 def parsenodeid(s):
2433 def parsenodeid(s):
2433 try:
2434 try:
2434 # We do not use revsingle/revrange functions here to accept
2435 # We do not use revsingle/revrange functions here to accept
2435 # arbitrary node identifiers, possibly not present in the
2436 # arbitrary node identifiers, possibly not present in the
2436 # local repository.
2437 # local repository.
2437 n = bin(s)
2438 n = bin(s)
2438 if len(n) != len(nullid):
2439 if len(n) != len(nullid):
2439 raise TypeError()
2440 raise TypeError()
2440 return n
2441 return n
2441 except TypeError:
2442 except TypeError:
2442 raise util.Abort('changeset references must be full hexadecimal '
2443 raise util.Abort('changeset references must be full hexadecimal '
2443 'node identifiers')
2444 'node identifiers')
2444
2445
2445 if precursor is not None:
2446 if precursor is not None:
2446 if opts['rev']:
2447 if opts['rev']:
2447 raise util.Abort('cannot select revision when creating marker')
2448 raise util.Abort('cannot select revision when creating marker')
2448 metadata = {}
2449 metadata = {}
2449 metadata['user'] = opts['user'] or ui.username()
2450 metadata['user'] = opts['user'] or ui.username()
2450 succs = tuple(parsenodeid(succ) for succ in successors)
2451 succs = tuple(parsenodeid(succ) for succ in successors)
2451 l = repo.lock()
2452 l = repo.lock()
2452 try:
2453 try:
2453 tr = repo.transaction('debugobsolete')
2454 tr = repo.transaction('debugobsolete')
2454 try:
2455 try:
2455 try:
2456 try:
2456 date = opts.get('date')
2457 date = opts.get('date')
2457 if date:
2458 if date:
2458 date = util.parsedate(date)
2459 date = util.parsedate(date)
2459 else:
2460 else:
2460 date = None
2461 date = None
2461 prec = parsenodeid(precursor)
2462 prec = parsenodeid(precursor)
2462 parents = None
2463 parents = None
2463 if opts['record_parents']:
2464 if opts['record_parents']:
2464 if prec not in repo.unfiltered():
2465 if prec not in repo.unfiltered():
2465 raise util.Abort('cannot used --record-parents on '
2466 raise util.Abort('cannot used --record-parents on '
2466 'unknown changesets')
2467 'unknown changesets')
2467 parents = repo.unfiltered()[prec].parents()
2468 parents = repo.unfiltered()[prec].parents()
2468 parents = tuple(p.node() for p in parents)
2469 parents = tuple(p.node() for p in parents)
2469 repo.obsstore.create(tr, prec, succs, opts['flags'],
2470 repo.obsstore.create(tr, prec, succs, opts['flags'],
2470 parents=parents, date=date,
2471 parents=parents, date=date,
2471 metadata=metadata)
2472 metadata=metadata)
2472 tr.close()
2473 tr.close()
2473 except ValueError, exc:
2474 except ValueError, exc:
2474 raise util.Abort(_('bad obsmarker input: %s') % exc)
2475 raise util.Abort(_('bad obsmarker input: %s') % exc)
2475 finally:
2476 finally:
2476 tr.release()
2477 tr.release()
2477 finally:
2478 finally:
2478 l.release()
2479 l.release()
2479 else:
2480 else:
2480 if opts['rev']:
2481 if opts['rev']:
2481 revs = scmutil.revrange(repo, opts['rev'])
2482 revs = scmutil.revrange(repo, opts['rev'])
2482 nodes = [repo[r].node() for r in revs]
2483 nodes = [repo[r].node() for r in revs]
2483 markers = list(obsolete.getmarkers(repo, nodes=nodes))
2484 markers = list(obsolete.getmarkers(repo, nodes=nodes))
2484 markers.sort(key=lambda x: x._data)
2485 markers.sort(key=lambda x: x._data)
2485 else:
2486 else:
2486 markers = obsolete.getmarkers(repo)
2487 markers = obsolete.getmarkers(repo)
2487
2488
2488 for m in markers:
2489 for m in markers:
2489 cmdutil.showmarker(ui, m)
2490 cmdutil.showmarker(ui, m)
2490
2491
2491 @command('debugpathcomplete',
2492 @command('debugpathcomplete',
2492 [('f', 'full', None, _('complete an entire path')),
2493 [('f', 'full', None, _('complete an entire path')),
2493 ('n', 'normal', None, _('show only normal files')),
2494 ('n', 'normal', None, _('show only normal files')),
2494 ('a', 'added', None, _('show only added files')),
2495 ('a', 'added', None, _('show only added files')),
2495 ('r', 'removed', None, _('show only removed files'))],
2496 ('r', 'removed', None, _('show only removed files'))],
2496 _('FILESPEC...'))
2497 _('FILESPEC...'))
2497 def debugpathcomplete(ui, repo, *specs, **opts):
2498 def debugpathcomplete(ui, repo, *specs, **opts):
2498 '''complete part or all of a tracked path
2499 '''complete part or all of a tracked path
2499
2500
2500 This command supports shells that offer path name completion. It
2501 This command supports shells that offer path name completion. It
2501 currently completes only files already known to the dirstate.
2502 currently completes only files already known to the dirstate.
2502
2503
2503 Completion extends only to the next path segment unless
2504 Completion extends only to the next path segment unless
2504 --full is specified, in which case entire paths are used.'''
2505 --full is specified, in which case entire paths are used.'''
2505
2506
2506 def complete(path, acceptable):
2507 def complete(path, acceptable):
2507 dirstate = repo.dirstate
2508 dirstate = repo.dirstate
2508 spec = os.path.normpath(os.path.join(os.getcwd(), path))
2509 spec = os.path.normpath(os.path.join(os.getcwd(), path))
2509 rootdir = repo.root + os.sep
2510 rootdir = repo.root + os.sep
2510 if spec != repo.root and not spec.startswith(rootdir):
2511 if spec != repo.root and not spec.startswith(rootdir):
2511 return [], []
2512 return [], []
2512 if os.path.isdir(spec):
2513 if os.path.isdir(spec):
2513 spec += '/'
2514 spec += '/'
2514 spec = spec[len(rootdir):]
2515 spec = spec[len(rootdir):]
2515 fixpaths = os.sep != '/'
2516 fixpaths = os.sep != '/'
2516 if fixpaths:
2517 if fixpaths:
2517 spec = spec.replace(os.sep, '/')
2518 spec = spec.replace(os.sep, '/')
2518 speclen = len(spec)
2519 speclen = len(spec)
2519 fullpaths = opts['full']
2520 fullpaths = opts['full']
2520 files, dirs = set(), set()
2521 files, dirs = set(), set()
2521 adddir, addfile = dirs.add, files.add
2522 adddir, addfile = dirs.add, files.add
2522 for f, st in dirstate.iteritems():
2523 for f, st in dirstate.iteritems():
2523 if f.startswith(spec) and st[0] in acceptable:
2524 if f.startswith(spec) and st[0] in acceptable:
2524 if fixpaths:
2525 if fixpaths:
2525 f = f.replace('/', os.sep)
2526 f = f.replace('/', os.sep)
2526 if fullpaths:
2527 if fullpaths:
2527 addfile(f)
2528 addfile(f)
2528 continue
2529 continue
2529 s = f.find(os.sep, speclen)
2530 s = f.find(os.sep, speclen)
2530 if s >= 0:
2531 if s >= 0:
2531 adddir(f[:s])
2532 adddir(f[:s])
2532 else:
2533 else:
2533 addfile(f)
2534 addfile(f)
2534 return files, dirs
2535 return files, dirs
2535
2536
2536 acceptable = ''
2537 acceptable = ''
2537 if opts['normal']:
2538 if opts['normal']:
2538 acceptable += 'nm'
2539 acceptable += 'nm'
2539 if opts['added']:
2540 if opts['added']:
2540 acceptable += 'a'
2541 acceptable += 'a'
2541 if opts['removed']:
2542 if opts['removed']:
2542 acceptable += 'r'
2543 acceptable += 'r'
2543 cwd = repo.getcwd()
2544 cwd = repo.getcwd()
2544 if not specs:
2545 if not specs:
2545 specs = ['.']
2546 specs = ['.']
2546
2547
2547 files, dirs = set(), set()
2548 files, dirs = set(), set()
2548 for spec in specs:
2549 for spec in specs:
2549 f, d = complete(spec, acceptable or 'nmar')
2550 f, d = complete(spec, acceptable or 'nmar')
2550 files.update(f)
2551 files.update(f)
2551 dirs.update(d)
2552 dirs.update(d)
2552 files.update(dirs)
2553 files.update(dirs)
2553 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
2554 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
2554 ui.write('\n')
2555 ui.write('\n')
2555
2556
2556 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
2557 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
2557 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
2558 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
2558 '''access the pushkey key/value protocol
2559 '''access the pushkey key/value protocol
2559
2560
2560 With two args, list the keys in the given namespace.
2561 With two args, list the keys in the given namespace.
2561
2562
2562 With five args, set a key to new if it currently is set to old.
2563 With five args, set a key to new if it currently is set to old.
2563 Reports success or failure.
2564 Reports success or failure.
2564 '''
2565 '''
2565
2566
2566 target = hg.peer(ui, {}, repopath)
2567 target = hg.peer(ui, {}, repopath)
2567 if keyinfo:
2568 if keyinfo:
2568 key, old, new = keyinfo
2569 key, old, new = keyinfo
2569 r = target.pushkey(namespace, key, old, new)
2570 r = target.pushkey(namespace, key, old, new)
2570 ui.status(str(r) + '\n')
2571 ui.status(str(r) + '\n')
2571 return not r
2572 return not r
2572 else:
2573 else:
2573 for k, v in sorted(target.listkeys(namespace).iteritems()):
2574 for k, v in sorted(target.listkeys(namespace).iteritems()):
2574 ui.write("%s\t%s\n" % (k.encode('string-escape'),
2575 ui.write("%s\t%s\n" % (k.encode('string-escape'),
2575 v.encode('string-escape')))
2576 v.encode('string-escape')))
2576
2577
2577 @command('debugpvec', [], _('A B'))
2578 @command('debugpvec', [], _('A B'))
2578 def debugpvec(ui, repo, a, b=None):
2579 def debugpvec(ui, repo, a, b=None):
2579 ca = scmutil.revsingle(repo, a)
2580 ca = scmutil.revsingle(repo, a)
2580 cb = scmutil.revsingle(repo, b)
2581 cb = scmutil.revsingle(repo, b)
2581 pa = pvec.ctxpvec(ca)
2582 pa = pvec.ctxpvec(ca)
2582 pb = pvec.ctxpvec(cb)
2583 pb = pvec.ctxpvec(cb)
2583 if pa == pb:
2584 if pa == pb:
2584 rel = "="
2585 rel = "="
2585 elif pa > pb:
2586 elif pa > pb:
2586 rel = ">"
2587 rel = ">"
2587 elif pa < pb:
2588 elif pa < pb:
2588 rel = "<"
2589 rel = "<"
2589 elif pa | pb:
2590 elif pa | pb:
2590 rel = "|"
2591 rel = "|"
2591 ui.write(_("a: %s\n") % pa)
2592 ui.write(_("a: %s\n") % pa)
2592 ui.write(_("b: %s\n") % pb)
2593 ui.write(_("b: %s\n") % pb)
2593 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
2594 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
2594 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
2595 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
2595 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
2596 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
2596 pa.distance(pb), rel))
2597 pa.distance(pb), rel))
2597
2598
2598 @command('debugrebuilddirstate|debugrebuildstate',
2599 @command('debugrebuilddirstate|debugrebuildstate',
2599 [('r', 'rev', '', _('revision to rebuild to'), _('REV'))],
2600 [('r', 'rev', '', _('revision to rebuild to'), _('REV'))],
2600 _('[-r REV]'))
2601 _('[-r REV]'))
2601 def debugrebuilddirstate(ui, repo, rev):
2602 def debugrebuilddirstate(ui, repo, rev):
2602 """rebuild the dirstate as it would look like for the given revision
2603 """rebuild the dirstate as it would look like for the given revision
2603
2604
2604 If no revision is specified the first current parent will be used.
2605 If no revision is specified the first current parent will be used.
2605
2606
2606 The dirstate will be set to the files of the given revision.
2607 The dirstate will be set to the files of the given revision.
2607 The actual working directory content or existing dirstate
2608 The actual working directory content or existing dirstate
2608 information such as adds or removes is not considered.
2609 information such as adds or removes is not considered.
2609
2610
2610 One use of this command is to make the next :hg:`status` invocation
2611 One use of this command is to make the next :hg:`status` invocation
2611 check the actual file content.
2612 check the actual file content.
2612 """
2613 """
2613 ctx = scmutil.revsingle(repo, rev)
2614 ctx = scmutil.revsingle(repo, rev)
2614 wlock = repo.wlock()
2615 wlock = repo.wlock()
2615 try:
2616 try:
2616 repo.dirstate.rebuild(ctx.node(), ctx.manifest())
2617 repo.dirstate.rebuild(ctx.node(), ctx.manifest())
2617 finally:
2618 finally:
2618 wlock.release()
2619 wlock.release()
2619
2620
2620 @command('debugrename',
2621 @command('debugrename',
2621 [('r', 'rev', '', _('revision to debug'), _('REV'))],
2622 [('r', 'rev', '', _('revision to debug'), _('REV'))],
2622 _('[-r REV] FILE'))
2623 _('[-r REV] FILE'))
2623 def debugrename(ui, repo, file1, *pats, **opts):
2624 def debugrename(ui, repo, file1, *pats, **opts):
2624 """dump rename information"""
2625 """dump rename information"""
2625
2626
2626 ctx = scmutil.revsingle(repo, opts.get('rev'))
2627 ctx = scmutil.revsingle(repo, opts.get('rev'))
2627 m = scmutil.match(ctx, (file1,) + pats, opts)
2628 m = scmutil.match(ctx, (file1,) + pats, opts)
2628 for abs in ctx.walk(m):
2629 for abs in ctx.walk(m):
2629 fctx = ctx[abs]
2630 fctx = ctx[abs]
2630 o = fctx.filelog().renamed(fctx.filenode())
2631 o = fctx.filelog().renamed(fctx.filenode())
2631 rel = m.rel(abs)
2632 rel = m.rel(abs)
2632 if o:
2633 if o:
2633 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
2634 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
2634 else:
2635 else:
2635 ui.write(_("%s not renamed\n") % rel)
2636 ui.write(_("%s not renamed\n") % rel)
2636
2637
2637 @command('debugrevlog',
2638 @command('debugrevlog',
2638 [('c', 'changelog', False, _('open changelog')),
2639 [('c', 'changelog', False, _('open changelog')),
2639 ('m', 'manifest', False, _('open manifest')),
2640 ('m', 'manifest', False, _('open manifest')),
2640 ('d', 'dump', False, _('dump index data'))],
2641 ('d', 'dump', False, _('dump index data'))],
2641 _('-c|-m|FILE'),
2642 _('-c|-m|FILE'),
2642 optionalrepo=True)
2643 optionalrepo=True)
2643 def debugrevlog(ui, repo, file_=None, **opts):
2644 def debugrevlog(ui, repo, file_=None, **opts):
2644 """show data and statistics about a revlog"""
2645 """show data and statistics about a revlog"""
2645 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
2646 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
2646
2647
2647 if opts.get("dump"):
2648 if opts.get("dump"):
2648 numrevs = len(r)
2649 numrevs = len(r)
2649 ui.write("# rev p1rev p2rev start end deltastart base p1 p2"
2650 ui.write("# rev p1rev p2rev start end deltastart base p1 p2"
2650 " rawsize totalsize compression heads chainlen\n")
2651 " rawsize totalsize compression heads chainlen\n")
2651 ts = 0
2652 ts = 0
2652 heads = set()
2653 heads = set()
2653
2654
2654 for rev in xrange(numrevs):
2655 for rev in xrange(numrevs):
2655 dbase = r.deltaparent(rev)
2656 dbase = r.deltaparent(rev)
2656 if dbase == -1:
2657 if dbase == -1:
2657 dbase = rev
2658 dbase = rev
2658 cbase = r.chainbase(rev)
2659 cbase = r.chainbase(rev)
2659 clen = r.chainlen(rev)
2660 clen = r.chainlen(rev)
2660 p1, p2 = r.parentrevs(rev)
2661 p1, p2 = r.parentrevs(rev)
2661 rs = r.rawsize(rev)
2662 rs = r.rawsize(rev)
2662 ts = ts + rs
2663 ts = ts + rs
2663 heads -= set(r.parentrevs(rev))
2664 heads -= set(r.parentrevs(rev))
2664 heads.add(rev)
2665 heads.add(rev)
2665 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d "
2666 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d "
2666 "%11d %5d %8d\n" %
2667 "%11d %5d %8d\n" %
2667 (rev, p1, p2, r.start(rev), r.end(rev),
2668 (rev, p1, p2, r.start(rev), r.end(rev),
2668 r.start(dbase), r.start(cbase),
2669 r.start(dbase), r.start(cbase),
2669 r.start(p1), r.start(p2),
2670 r.start(p1), r.start(p2),
2670 rs, ts, ts / r.end(rev), len(heads), clen))
2671 rs, ts, ts / r.end(rev), len(heads), clen))
2671 return 0
2672 return 0
2672
2673
2673 v = r.version
2674 v = r.version
2674 format = v & 0xFFFF
2675 format = v & 0xFFFF
2675 flags = []
2676 flags = []
2676 gdelta = False
2677 gdelta = False
2677 if v & revlog.REVLOGNGINLINEDATA:
2678 if v & revlog.REVLOGNGINLINEDATA:
2678 flags.append('inline')
2679 flags.append('inline')
2679 if v & revlog.REVLOGGENERALDELTA:
2680 if v & revlog.REVLOGGENERALDELTA:
2680 gdelta = True
2681 gdelta = True
2681 flags.append('generaldelta')
2682 flags.append('generaldelta')
2682 if not flags:
2683 if not flags:
2683 flags = ['(none)']
2684 flags = ['(none)']
2684
2685
2685 nummerges = 0
2686 nummerges = 0
2686 numfull = 0
2687 numfull = 0
2687 numprev = 0
2688 numprev = 0
2688 nump1 = 0
2689 nump1 = 0
2689 nump2 = 0
2690 nump2 = 0
2690 numother = 0
2691 numother = 0
2691 nump1prev = 0
2692 nump1prev = 0
2692 nump2prev = 0
2693 nump2prev = 0
2693 chainlengths = []
2694 chainlengths = []
2694
2695
2695 datasize = [None, 0, 0L]
2696 datasize = [None, 0, 0L]
2696 fullsize = [None, 0, 0L]
2697 fullsize = [None, 0, 0L]
2697 deltasize = [None, 0, 0L]
2698 deltasize = [None, 0, 0L]
2698
2699
2699 def addsize(size, l):
2700 def addsize(size, l):
2700 if l[0] is None or size < l[0]:
2701 if l[0] is None or size < l[0]:
2701 l[0] = size
2702 l[0] = size
2702 if size > l[1]:
2703 if size > l[1]:
2703 l[1] = size
2704 l[1] = size
2704 l[2] += size
2705 l[2] += size
2705
2706
2706 numrevs = len(r)
2707 numrevs = len(r)
2707 for rev in xrange(numrevs):
2708 for rev in xrange(numrevs):
2708 p1, p2 = r.parentrevs(rev)
2709 p1, p2 = r.parentrevs(rev)
2709 delta = r.deltaparent(rev)
2710 delta = r.deltaparent(rev)
2710 if format > 0:
2711 if format > 0:
2711 addsize(r.rawsize(rev), datasize)
2712 addsize(r.rawsize(rev), datasize)
2712 if p2 != nullrev:
2713 if p2 != nullrev:
2713 nummerges += 1
2714 nummerges += 1
2714 size = r.length(rev)
2715 size = r.length(rev)
2715 if delta == nullrev:
2716 if delta == nullrev:
2716 chainlengths.append(0)
2717 chainlengths.append(0)
2717 numfull += 1
2718 numfull += 1
2718 addsize(size, fullsize)
2719 addsize(size, fullsize)
2719 else:
2720 else:
2720 chainlengths.append(chainlengths[delta] + 1)
2721 chainlengths.append(chainlengths[delta] + 1)
2721 addsize(size, deltasize)
2722 addsize(size, deltasize)
2722 if delta == rev - 1:
2723 if delta == rev - 1:
2723 numprev += 1
2724 numprev += 1
2724 if delta == p1:
2725 if delta == p1:
2725 nump1prev += 1
2726 nump1prev += 1
2726 elif delta == p2:
2727 elif delta == p2:
2727 nump2prev += 1
2728 nump2prev += 1
2728 elif delta == p1:
2729 elif delta == p1:
2729 nump1 += 1
2730 nump1 += 1
2730 elif delta == p2:
2731 elif delta == p2:
2731 nump2 += 1
2732 nump2 += 1
2732 elif delta != nullrev:
2733 elif delta != nullrev:
2733 numother += 1
2734 numother += 1
2734
2735
2735 # Adjust size min value for empty cases
2736 # Adjust size min value for empty cases
2736 for size in (datasize, fullsize, deltasize):
2737 for size in (datasize, fullsize, deltasize):
2737 if size[0] is None:
2738 if size[0] is None:
2738 size[0] = 0
2739 size[0] = 0
2739
2740
2740 numdeltas = numrevs - numfull
2741 numdeltas = numrevs - numfull
2741 numoprev = numprev - nump1prev - nump2prev
2742 numoprev = numprev - nump1prev - nump2prev
2742 totalrawsize = datasize[2]
2743 totalrawsize = datasize[2]
2743 datasize[2] /= numrevs
2744 datasize[2] /= numrevs
2744 fulltotal = fullsize[2]
2745 fulltotal = fullsize[2]
2745 fullsize[2] /= numfull
2746 fullsize[2] /= numfull
2746 deltatotal = deltasize[2]
2747 deltatotal = deltasize[2]
2747 if numrevs - numfull > 0:
2748 if numrevs - numfull > 0:
2748 deltasize[2] /= numrevs - numfull
2749 deltasize[2] /= numrevs - numfull
2749 totalsize = fulltotal + deltatotal
2750 totalsize = fulltotal + deltatotal
2750 avgchainlen = sum(chainlengths) / numrevs
2751 avgchainlen = sum(chainlengths) / numrevs
2751 compratio = totalrawsize / totalsize
2752 compratio = totalrawsize / totalsize
2752
2753
2753 basedfmtstr = '%%%dd\n'
2754 basedfmtstr = '%%%dd\n'
2754 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
2755 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
2755
2756
2756 def dfmtstr(max):
2757 def dfmtstr(max):
2757 return basedfmtstr % len(str(max))
2758 return basedfmtstr % len(str(max))
2758 def pcfmtstr(max, padding=0):
2759 def pcfmtstr(max, padding=0):
2759 return basepcfmtstr % (len(str(max)), ' ' * padding)
2760 return basepcfmtstr % (len(str(max)), ' ' * padding)
2760
2761
2761 def pcfmt(value, total):
2762 def pcfmt(value, total):
2762 return (value, 100 * float(value) / total)
2763 return (value, 100 * float(value) / total)
2763
2764
2764 ui.write(('format : %d\n') % format)
2765 ui.write(('format : %d\n') % format)
2765 ui.write(('flags : %s\n') % ', '.join(flags))
2766 ui.write(('flags : %s\n') % ', '.join(flags))
2766
2767
2767 ui.write('\n')
2768 ui.write('\n')
2768 fmt = pcfmtstr(totalsize)
2769 fmt = pcfmtstr(totalsize)
2769 fmt2 = dfmtstr(totalsize)
2770 fmt2 = dfmtstr(totalsize)
2770 ui.write(('revisions : ') + fmt2 % numrevs)
2771 ui.write(('revisions : ') + fmt2 % numrevs)
2771 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
2772 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
2772 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
2773 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
2773 ui.write(('revisions : ') + fmt2 % numrevs)
2774 ui.write(('revisions : ') + fmt2 % numrevs)
2774 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
2775 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
2775 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
2776 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
2776 ui.write(('revision size : ') + fmt2 % totalsize)
2777 ui.write(('revision size : ') + fmt2 % totalsize)
2777 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
2778 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
2778 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
2779 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
2779
2780
2780 ui.write('\n')
2781 ui.write('\n')
2781 fmt = dfmtstr(max(avgchainlen, compratio))
2782 fmt = dfmtstr(max(avgchainlen, compratio))
2782 ui.write(('avg chain length : ') + fmt % avgchainlen)
2783 ui.write(('avg chain length : ') + fmt % avgchainlen)
2783 ui.write(('compression ratio : ') + fmt % compratio)
2784 ui.write(('compression ratio : ') + fmt % compratio)
2784
2785
2785 if format > 0:
2786 if format > 0:
2786 ui.write('\n')
2787 ui.write('\n')
2787 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
2788 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
2788 % tuple(datasize))
2789 % tuple(datasize))
2789 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
2790 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
2790 % tuple(fullsize))
2791 % tuple(fullsize))
2791 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
2792 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
2792 % tuple(deltasize))
2793 % tuple(deltasize))
2793
2794
2794 if numdeltas > 0:
2795 if numdeltas > 0:
2795 ui.write('\n')
2796 ui.write('\n')
2796 fmt = pcfmtstr(numdeltas)
2797 fmt = pcfmtstr(numdeltas)
2797 fmt2 = pcfmtstr(numdeltas, 4)
2798 fmt2 = pcfmtstr(numdeltas, 4)
2798 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
2799 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
2799 if numprev > 0:
2800 if numprev > 0:
2800 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
2801 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
2801 numprev))
2802 numprev))
2802 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
2803 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
2803 numprev))
2804 numprev))
2804 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
2805 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
2805 numprev))
2806 numprev))
2806 if gdelta:
2807 if gdelta:
2807 ui.write(('deltas against p1 : ')
2808 ui.write(('deltas against p1 : ')
2808 + fmt % pcfmt(nump1, numdeltas))
2809 + fmt % pcfmt(nump1, numdeltas))
2809 ui.write(('deltas against p2 : ')
2810 ui.write(('deltas against p2 : ')
2810 + fmt % pcfmt(nump2, numdeltas))
2811 + fmt % pcfmt(nump2, numdeltas))
2811 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
2812 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
2812 numdeltas))
2813 numdeltas))
2813
2814
2814 @command('debugrevspec',
2815 @command('debugrevspec',
2815 [('', 'optimize', None, _('print parsed tree after optimizing'))],
2816 [('', 'optimize', None, _('print parsed tree after optimizing'))],
2816 ('REVSPEC'))
2817 ('REVSPEC'))
2817 def debugrevspec(ui, repo, expr, **opts):
2818 def debugrevspec(ui, repo, expr, **opts):
2818 """parse and apply a revision specification
2819 """parse and apply a revision specification
2819
2820
2820 Use --verbose to print the parsed tree before and after aliases
2821 Use --verbose to print the parsed tree before and after aliases
2821 expansion.
2822 expansion.
2822 """
2823 """
2823 if ui.verbose:
2824 if ui.verbose:
2824 tree = revset.parse(expr)[0]
2825 tree = revset.parse(expr)[0]
2825 ui.note(revset.prettyformat(tree), "\n")
2826 ui.note(revset.prettyformat(tree), "\n")
2826 newtree = revset.findaliases(ui, tree)
2827 newtree = revset.findaliases(ui, tree)
2827 if newtree != tree:
2828 if newtree != tree:
2828 ui.note(revset.prettyformat(newtree), "\n")
2829 ui.note(revset.prettyformat(newtree), "\n")
2829 if opts["optimize"]:
2830 if opts["optimize"]:
2830 weight, optimizedtree = revset.optimize(newtree, True)
2831 weight, optimizedtree = revset.optimize(newtree, True)
2831 ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n")
2832 ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n")
2832 func = revset.match(ui, expr)
2833 func = revset.match(ui, expr)
2833 for c in func(repo, revset.spanset(repo)):
2834 for c in func(repo, revset.spanset(repo)):
2834 ui.write("%s\n" % c)
2835 ui.write("%s\n" % c)
2835
2836
2836 @command('debugsetparents', [], _('REV1 [REV2]'))
2837 @command('debugsetparents', [], _('REV1 [REV2]'))
2837 def debugsetparents(ui, repo, rev1, rev2=None):
2838 def debugsetparents(ui, repo, rev1, rev2=None):
2838 """manually set the parents of the current working directory
2839 """manually set the parents of the current working directory
2839
2840
2840 This is useful for writing repository conversion tools, but should
2841 This is useful for writing repository conversion tools, but should
2841 be used with care.
2842 be used with care.
2842
2843
2843 Returns 0 on success.
2844 Returns 0 on success.
2844 """
2845 """
2845
2846
2846 r1 = scmutil.revsingle(repo, rev1).node()
2847 r1 = scmutil.revsingle(repo, rev1).node()
2847 r2 = scmutil.revsingle(repo, rev2, 'null').node()
2848 r2 = scmutil.revsingle(repo, rev2, 'null').node()
2848
2849
2849 wlock = repo.wlock()
2850 wlock = repo.wlock()
2850 try:
2851 try:
2851 repo.dirstate.beginparentchange()
2852 repo.dirstate.beginparentchange()
2852 repo.setparents(r1, r2)
2853 repo.setparents(r1, r2)
2853 repo.dirstate.endparentchange()
2854 repo.dirstate.endparentchange()
2854 finally:
2855 finally:
2855 wlock.release()
2856 wlock.release()
2856
2857
2857 @command('debugdirstate|debugstate',
2858 @command('debugdirstate|debugstate',
2858 [('', 'nodates', None, _('do not display the saved mtime')),
2859 [('', 'nodates', None, _('do not display the saved mtime')),
2859 ('', 'datesort', None, _('sort by saved mtime'))],
2860 ('', 'datesort', None, _('sort by saved mtime'))],
2860 _('[OPTION]...'))
2861 _('[OPTION]...'))
2861 def debugstate(ui, repo, nodates=None, datesort=None):
2862 def debugstate(ui, repo, nodates=None, datesort=None):
2862 """show the contents of the current dirstate"""
2863 """show the contents of the current dirstate"""
2863 timestr = ""
2864 timestr = ""
2864 showdate = not nodates
2865 showdate = not nodates
2865 if datesort:
2866 if datesort:
2866 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
2867 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
2867 else:
2868 else:
2868 keyfunc = None # sort by filename
2869 keyfunc = None # sort by filename
2869 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
2870 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
2870 if showdate:
2871 if showdate:
2871 if ent[3] == -1:
2872 if ent[3] == -1:
2872 # Pad or slice to locale representation
2873 # Pad or slice to locale representation
2873 locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ",
2874 locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ",
2874 time.localtime(0)))
2875 time.localtime(0)))
2875 timestr = 'unset'
2876 timestr = 'unset'
2876 timestr = (timestr[:locale_len] +
2877 timestr = (timestr[:locale_len] +
2877 ' ' * (locale_len - len(timestr)))
2878 ' ' * (locale_len - len(timestr)))
2878 else:
2879 else:
2879 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
2880 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
2880 time.localtime(ent[3]))
2881 time.localtime(ent[3]))
2881 if ent[1] & 020000:
2882 if ent[1] & 020000:
2882 mode = 'lnk'
2883 mode = 'lnk'
2883 else:
2884 else:
2884 mode = '%3o' % (ent[1] & 0777 & ~util.umask)
2885 mode = '%3o' % (ent[1] & 0777 & ~util.umask)
2885 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
2886 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
2886 for f in repo.dirstate.copies():
2887 for f in repo.dirstate.copies():
2887 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
2888 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
2888
2889
2889 @command('debugsub',
2890 @command('debugsub',
2890 [('r', 'rev', '',
2891 [('r', 'rev', '',
2891 _('revision to check'), _('REV'))],
2892 _('revision to check'), _('REV'))],
2892 _('[-r REV] [REV]'))
2893 _('[-r REV] [REV]'))
2893 def debugsub(ui, repo, rev=None):
2894 def debugsub(ui, repo, rev=None):
2894 ctx = scmutil.revsingle(repo, rev, None)
2895 ctx = scmutil.revsingle(repo, rev, None)
2895 for k, v in sorted(ctx.substate.items()):
2896 for k, v in sorted(ctx.substate.items()):
2896 ui.write(('path %s\n') % k)
2897 ui.write(('path %s\n') % k)
2897 ui.write((' source %s\n') % v[0])
2898 ui.write((' source %s\n') % v[0])
2898 ui.write((' revision %s\n') % v[1])
2899 ui.write((' revision %s\n') % v[1])
2899
2900
2900 @command('debugsuccessorssets',
2901 @command('debugsuccessorssets',
2901 [],
2902 [],
2902 _('[REV]'))
2903 _('[REV]'))
2903 def debugsuccessorssets(ui, repo, *revs):
2904 def debugsuccessorssets(ui, repo, *revs):
2904 """show set of successors for revision
2905 """show set of successors for revision
2905
2906
2906 A successors set of changeset A is a consistent group of revisions that
2907 A successors set of changeset A is a consistent group of revisions that
2907 succeed A. It contains non-obsolete changesets only.
2908 succeed A. It contains non-obsolete changesets only.
2908
2909
2909 In most cases a changeset A has a single successors set containing a single
2910 In most cases a changeset A has a single successors set containing a single
2910 successor (changeset A replaced by A').
2911 successor (changeset A replaced by A').
2911
2912
2912 A changeset that is made obsolete with no successors are called "pruned".
2913 A changeset that is made obsolete with no successors are called "pruned".
2913 Such changesets have no successors sets at all.
2914 Such changesets have no successors sets at all.
2914
2915
2915 A changeset that has been "split" will have a successors set containing
2916 A changeset that has been "split" will have a successors set containing
2916 more than one successor.
2917 more than one successor.
2917
2918
2918 A changeset that has been rewritten in multiple different ways is called
2919 A changeset that has been rewritten in multiple different ways is called
2919 "divergent". Such changesets have multiple successor sets (each of which
2920 "divergent". Such changesets have multiple successor sets (each of which
2920 may also be split, i.e. have multiple successors).
2921 may also be split, i.e. have multiple successors).
2921
2922
2922 Results are displayed as follows::
2923 Results are displayed as follows::
2923
2924
2924 <rev1>
2925 <rev1>
2925 <successors-1A>
2926 <successors-1A>
2926 <rev2>
2927 <rev2>
2927 <successors-2A>
2928 <successors-2A>
2928 <successors-2B1> <successors-2B2> <successors-2B3>
2929 <successors-2B1> <successors-2B2> <successors-2B3>
2929
2930
2930 Here rev2 has two possible (i.e. divergent) successors sets. The first
2931 Here rev2 has two possible (i.e. divergent) successors sets. The first
2931 holds one element, whereas the second holds three (i.e. the changeset has
2932 holds one element, whereas the second holds three (i.e. the changeset has
2932 been split).
2933 been split).
2933 """
2934 """
2934 # passed to successorssets caching computation from one call to another
2935 # passed to successorssets caching computation from one call to another
2935 cache = {}
2936 cache = {}
2936 ctx2str = str
2937 ctx2str = str
2937 node2str = short
2938 node2str = short
2938 if ui.debug():
2939 if ui.debug():
2939 def ctx2str(ctx):
2940 def ctx2str(ctx):
2940 return ctx.hex()
2941 return ctx.hex()
2941 node2str = hex
2942 node2str = hex
2942 for rev in scmutil.revrange(repo, revs):
2943 for rev in scmutil.revrange(repo, revs):
2943 ctx = repo[rev]
2944 ctx = repo[rev]
2944 ui.write('%s\n'% ctx2str(ctx))
2945 ui.write('%s\n'% ctx2str(ctx))
2945 for succsset in obsolete.successorssets(repo, ctx.node(), cache):
2946 for succsset in obsolete.successorssets(repo, ctx.node(), cache):
2946 if succsset:
2947 if succsset:
2947 ui.write(' ')
2948 ui.write(' ')
2948 ui.write(node2str(succsset[0]))
2949 ui.write(node2str(succsset[0]))
2949 for node in succsset[1:]:
2950 for node in succsset[1:]:
2950 ui.write(' ')
2951 ui.write(' ')
2951 ui.write(node2str(node))
2952 ui.write(node2str(node))
2952 ui.write('\n')
2953 ui.write('\n')
2953
2954
2954 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'), inferrepo=True)
2955 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'), inferrepo=True)
2955 def debugwalk(ui, repo, *pats, **opts):
2956 def debugwalk(ui, repo, *pats, **opts):
2956 """show how files match on given patterns"""
2957 """show how files match on given patterns"""
2957 m = scmutil.match(repo[None], pats, opts)
2958 m = scmutil.match(repo[None], pats, opts)
2958 items = list(repo.walk(m))
2959 items = list(repo.walk(m))
2959 if not items:
2960 if not items:
2960 return
2961 return
2961 f = lambda fn: fn
2962 f = lambda fn: fn
2962 if ui.configbool('ui', 'slash') and os.sep != '/':
2963 if ui.configbool('ui', 'slash') and os.sep != '/':
2963 f = lambda fn: util.normpath(fn)
2964 f = lambda fn: util.normpath(fn)
2964 fmt = 'f %%-%ds %%-%ds %%s' % (
2965 fmt = 'f %%-%ds %%-%ds %%s' % (
2965 max([len(abs) for abs in items]),
2966 max([len(abs) for abs in items]),
2966 max([len(m.rel(abs)) for abs in items]))
2967 max([len(m.rel(abs)) for abs in items]))
2967 for abs in items:
2968 for abs in items:
2968 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
2969 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
2969 ui.write("%s\n" % line.rstrip())
2970 ui.write("%s\n" % line.rstrip())
2970
2971
2971 @command('debugwireargs',
2972 @command('debugwireargs',
2972 [('', 'three', '', 'three'),
2973 [('', 'three', '', 'three'),
2973 ('', 'four', '', 'four'),
2974 ('', 'four', '', 'four'),
2974 ('', 'five', '', 'five'),
2975 ('', 'five', '', 'five'),
2975 ] + remoteopts,
2976 ] + remoteopts,
2976 _('REPO [OPTIONS]... [ONE [TWO]]'),
2977 _('REPO [OPTIONS]... [ONE [TWO]]'),
2977 norepo=True)
2978 norepo=True)
2978 def debugwireargs(ui, repopath, *vals, **opts):
2979 def debugwireargs(ui, repopath, *vals, **opts):
2979 repo = hg.peer(ui, opts, repopath)
2980 repo = hg.peer(ui, opts, repopath)
2980 for opt in remoteopts:
2981 for opt in remoteopts:
2981 del opts[opt[1]]
2982 del opts[opt[1]]
2982 args = {}
2983 args = {}
2983 for k, v in opts.iteritems():
2984 for k, v in opts.iteritems():
2984 if v:
2985 if v:
2985 args[k] = v
2986 args[k] = v
2986 # run twice to check that we don't mess up the stream for the next command
2987 # run twice to check that we don't mess up the stream for the next command
2987 res1 = repo.debugwireargs(*vals, **args)
2988 res1 = repo.debugwireargs(*vals, **args)
2988 res2 = repo.debugwireargs(*vals, **args)
2989 res2 = repo.debugwireargs(*vals, **args)
2989 ui.write("%s\n" % res1)
2990 ui.write("%s\n" % res1)
2990 if res1 != res2:
2991 if res1 != res2:
2991 ui.warn("%s\n" % res2)
2992 ui.warn("%s\n" % res2)
2992
2993
2993 @command('^diff',
2994 @command('^diff',
2994 [('r', 'rev', [], _('revision'), _('REV')),
2995 [('r', 'rev', [], _('revision'), _('REV')),
2995 ('c', 'change', '', _('change made by revision'), _('REV'))
2996 ('c', 'change', '', _('change made by revision'), _('REV'))
2996 ] + diffopts + diffopts2 + walkopts + subrepoopts,
2997 ] + diffopts + diffopts2 + walkopts + subrepoopts,
2997 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
2998 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
2998 inferrepo=True)
2999 inferrepo=True)
2999 def diff(ui, repo, *pats, **opts):
3000 def diff(ui, repo, *pats, **opts):
3000 """diff repository (or selected files)
3001 """diff repository (or selected files)
3001
3002
3002 Show differences between revisions for the specified files.
3003 Show differences between revisions for the specified files.
3003
3004
3004 Differences between files are shown using the unified diff format.
3005 Differences between files are shown using the unified diff format.
3005
3006
3006 .. note::
3007 .. note::
3007
3008
3008 diff may generate unexpected results for merges, as it will
3009 diff may generate unexpected results for merges, as it will
3009 default to comparing against the working directory's first
3010 default to comparing against the working directory's first
3010 parent changeset if no revisions are specified.
3011 parent changeset if no revisions are specified.
3011
3012
3012 When two revision arguments are given, then changes are shown
3013 When two revision arguments are given, then changes are shown
3013 between those revisions. If only one revision is specified then
3014 between those revisions. If only one revision is specified then
3014 that revision is compared to the working directory, and, when no
3015 that revision is compared to the working directory, and, when no
3015 revisions are specified, the working directory files are compared
3016 revisions are specified, the working directory files are compared
3016 to its parent.
3017 to its parent.
3017
3018
3018 Alternatively you can specify -c/--change with a revision to see
3019 Alternatively you can specify -c/--change with a revision to see
3019 the changes in that changeset relative to its first parent.
3020 the changes in that changeset relative to its first parent.
3020
3021
3021 Without the -a/--text option, diff will avoid generating diffs of
3022 Without the -a/--text option, diff will avoid generating diffs of
3022 files it detects as binary. With -a, diff will generate a diff
3023 files it detects as binary. With -a, diff will generate a diff
3023 anyway, probably with undesirable results.
3024 anyway, probably with undesirable results.
3024
3025
3025 Use the -g/--git option to generate diffs in the git extended diff
3026 Use the -g/--git option to generate diffs in the git extended diff
3026 format. For more information, read :hg:`help diffs`.
3027 format. For more information, read :hg:`help diffs`.
3027
3028
3028 .. container:: verbose
3029 .. container:: verbose
3029
3030
3030 Examples:
3031 Examples:
3031
3032
3032 - compare a file in the current working directory to its parent::
3033 - compare a file in the current working directory to its parent::
3033
3034
3034 hg diff foo.c
3035 hg diff foo.c
3035
3036
3036 - compare two historical versions of a directory, with rename info::
3037 - compare two historical versions of a directory, with rename info::
3037
3038
3038 hg diff --git -r 1.0:1.2 lib/
3039 hg diff --git -r 1.0:1.2 lib/
3039
3040
3040 - get change stats relative to the last change on some date::
3041 - get change stats relative to the last change on some date::
3041
3042
3042 hg diff --stat -r "date('may 2')"
3043 hg diff --stat -r "date('may 2')"
3043
3044
3044 - diff all newly-added files that contain a keyword::
3045 - diff all newly-added files that contain a keyword::
3045
3046
3046 hg diff "set:added() and grep(GNU)"
3047 hg diff "set:added() and grep(GNU)"
3047
3048
3048 - compare a revision and its parents::
3049 - compare a revision and its parents::
3049
3050
3050 hg diff -c 9353 # compare against first parent
3051 hg diff -c 9353 # compare against first parent
3051 hg diff -r 9353^:9353 # same using revset syntax
3052 hg diff -r 9353^:9353 # same using revset syntax
3052 hg diff -r 9353^2:9353 # compare against the second parent
3053 hg diff -r 9353^2:9353 # compare against the second parent
3053
3054
3054 Returns 0 on success.
3055 Returns 0 on success.
3055 """
3056 """
3056
3057
3057 revs = opts.get('rev')
3058 revs = opts.get('rev')
3058 change = opts.get('change')
3059 change = opts.get('change')
3059 stat = opts.get('stat')
3060 stat = opts.get('stat')
3060 reverse = opts.get('reverse')
3061 reverse = opts.get('reverse')
3061
3062
3062 if revs and change:
3063 if revs and change:
3063 msg = _('cannot specify --rev and --change at the same time')
3064 msg = _('cannot specify --rev and --change at the same time')
3064 raise util.Abort(msg)
3065 raise util.Abort(msg)
3065 elif change:
3066 elif change:
3066 node2 = scmutil.revsingle(repo, change, None).node()
3067 node2 = scmutil.revsingle(repo, change, None).node()
3067 node1 = repo[node2].p1().node()
3068 node1 = repo[node2].p1().node()
3068 else:
3069 else:
3069 node1, node2 = scmutil.revpair(repo, revs)
3070 node1, node2 = scmutil.revpair(repo, revs)
3070
3071
3071 if reverse:
3072 if reverse:
3072 node1, node2 = node2, node1
3073 node1, node2 = node2, node1
3073
3074
3074 diffopts = patch.diffopts(ui, opts)
3075 diffopts = patch.diffopts(ui, opts)
3075 m = scmutil.match(repo[node2], pats, opts)
3076 m = scmutil.match(repo[node2], pats, opts)
3076 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
3077 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
3077 listsubrepos=opts.get('subrepos'))
3078 listsubrepos=opts.get('subrepos'))
3078
3079
3079 @command('^export',
3080 @command('^export',
3080 [('o', 'output', '',
3081 [('o', 'output', '',
3081 _('print output to file with formatted name'), _('FORMAT')),
3082 _('print output to file with formatted name'), _('FORMAT')),
3082 ('', 'switch-parent', None, _('diff against the second parent')),
3083 ('', 'switch-parent', None, _('diff against the second parent')),
3083 ('r', 'rev', [], _('revisions to export'), _('REV')),
3084 ('r', 'rev', [], _('revisions to export'), _('REV')),
3084 ] + diffopts,
3085 ] + diffopts,
3085 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
3086 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
3086 def export(ui, repo, *changesets, **opts):
3087 def export(ui, repo, *changesets, **opts):
3087 """dump the header and diffs for one or more changesets
3088 """dump the header and diffs for one or more changesets
3088
3089
3089 Print the changeset header and diffs for one or more revisions.
3090 Print the changeset header and diffs for one or more revisions.
3090 If no revision is given, the parent of the working directory is used.
3091 If no revision is given, the parent of the working directory is used.
3091
3092
3092 The information shown in the changeset header is: author, date,
3093 The information shown in the changeset header is: author, date,
3093 branch name (if non-default), changeset hash, parent(s) and commit
3094 branch name (if non-default), changeset hash, parent(s) and commit
3094 comment.
3095 comment.
3095
3096
3096 .. note::
3097 .. note::
3097
3098
3098 export may generate unexpected diff output for merge
3099 export may generate unexpected diff output for merge
3099 changesets, as it will compare the merge changeset against its
3100 changesets, as it will compare the merge changeset against its
3100 first parent only.
3101 first parent only.
3101
3102
3102 Output may be to a file, in which case the name of the file is
3103 Output may be to a file, in which case the name of the file is
3103 given using a format string. The formatting rules are as follows:
3104 given using a format string. The formatting rules are as follows:
3104
3105
3105 :``%%``: literal "%" character
3106 :``%%``: literal "%" character
3106 :``%H``: changeset hash (40 hexadecimal digits)
3107 :``%H``: changeset hash (40 hexadecimal digits)
3107 :``%N``: number of patches being generated
3108 :``%N``: number of patches being generated
3108 :``%R``: changeset revision number
3109 :``%R``: changeset revision number
3109 :``%b``: basename of the exporting repository
3110 :``%b``: basename of the exporting repository
3110 :``%h``: short-form changeset hash (12 hexadecimal digits)
3111 :``%h``: short-form changeset hash (12 hexadecimal digits)
3111 :``%m``: first line of the commit message (only alphanumeric characters)
3112 :``%m``: first line of the commit message (only alphanumeric characters)
3112 :``%n``: zero-padded sequence number, starting at 1
3113 :``%n``: zero-padded sequence number, starting at 1
3113 :``%r``: zero-padded changeset revision number
3114 :``%r``: zero-padded changeset revision number
3114
3115
3115 Without the -a/--text option, export will avoid generating diffs
3116 Without the -a/--text option, export will avoid generating diffs
3116 of files it detects as binary. With -a, export will generate a
3117 of files it detects as binary. With -a, export will generate a
3117 diff anyway, probably with undesirable results.
3118 diff anyway, probably with undesirable results.
3118
3119
3119 Use the -g/--git option to generate diffs in the git extended diff
3120 Use the -g/--git option to generate diffs in the git extended diff
3120 format. See :hg:`help diffs` for more information.
3121 format. See :hg:`help diffs` for more information.
3121
3122
3122 With the --switch-parent option, the diff will be against the
3123 With the --switch-parent option, the diff will be against the
3123 second parent. It can be useful to review a merge.
3124 second parent. It can be useful to review a merge.
3124
3125
3125 .. container:: verbose
3126 .. container:: verbose
3126
3127
3127 Examples:
3128 Examples:
3128
3129
3129 - use export and import to transplant a bugfix to the current
3130 - use export and import to transplant a bugfix to the current
3130 branch::
3131 branch::
3131
3132
3132 hg export -r 9353 | hg import -
3133 hg export -r 9353 | hg import -
3133
3134
3134 - export all the changesets between two revisions to a file with
3135 - export all the changesets between two revisions to a file with
3135 rename information::
3136 rename information::
3136
3137
3137 hg export --git -r 123:150 > changes.txt
3138 hg export --git -r 123:150 > changes.txt
3138
3139
3139 - split outgoing changes into a series of patches with
3140 - split outgoing changes into a series of patches with
3140 descriptive names::
3141 descriptive names::
3141
3142
3142 hg export -r "outgoing()" -o "%n-%m.patch"
3143 hg export -r "outgoing()" -o "%n-%m.patch"
3143
3144
3144 Returns 0 on success.
3145 Returns 0 on success.
3145 """
3146 """
3146 changesets += tuple(opts.get('rev', []))
3147 changesets += tuple(opts.get('rev', []))
3147 if not changesets:
3148 if not changesets:
3148 changesets = ['.']
3149 changesets = ['.']
3149 revs = scmutil.revrange(repo, changesets)
3150 revs = scmutil.revrange(repo, changesets)
3150 if not revs:
3151 if not revs:
3151 raise util.Abort(_("export requires at least one changeset"))
3152 raise util.Abort(_("export requires at least one changeset"))
3152 if len(revs) > 1:
3153 if len(revs) > 1:
3153 ui.note(_('exporting patches:\n'))
3154 ui.note(_('exporting patches:\n'))
3154 else:
3155 else:
3155 ui.note(_('exporting patch:\n'))
3156 ui.note(_('exporting patch:\n'))
3156 cmdutil.export(repo, revs, template=opts.get('output'),
3157 cmdutil.export(repo, revs, template=opts.get('output'),
3157 switch_parent=opts.get('switch_parent'),
3158 switch_parent=opts.get('switch_parent'),
3158 opts=patch.diffopts(ui, opts))
3159 opts=patch.diffopts(ui, opts))
3159
3160
3160 @command('files',
3161 @command('files',
3161 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3162 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3162 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3163 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3163 ] + walkopts + formatteropts,
3164 ] + walkopts + formatteropts,
3164 _('[OPTION]... [PATTERN]...'))
3165 _('[OPTION]... [PATTERN]...'))
3165 def files(ui, repo, *pats, **opts):
3166 def files(ui, repo, *pats, **opts):
3166 """list tracked files
3167 """list tracked files
3167
3168
3168 Print files under Mercurial control in the working directory or
3169 Print files under Mercurial control in the working directory or
3169 specified revision whose names match the given patterns (excluding
3170 specified revision whose names match the given patterns (excluding
3170 removed files).
3171 removed files).
3171
3172
3172 If no patterns are given to match, this command prints the names
3173 If no patterns are given to match, this command prints the names
3173 of all files under Mercurial control in the working copy.
3174 of all files under Mercurial control in the working copy.
3174
3175
3175 .. container:: verbose
3176 .. container:: verbose
3176
3177
3177 Examples:
3178 Examples:
3178
3179
3179 - list all files under the current directory::
3180 - list all files under the current directory::
3180
3181
3181 hg files .
3182 hg files .
3182
3183
3183 - shows sizes and flags for current revision::
3184 - shows sizes and flags for current revision::
3184
3185
3185 hg files -vr .
3186 hg files -vr .
3186
3187
3187 - list all files named README::
3188 - list all files named README::
3188
3189
3189 hg files -I "**/README"
3190 hg files -I "**/README"
3190
3191
3191 - list all binary files::
3192 - list all binary files::
3192
3193
3193 hg files "set:binary()"
3194 hg files "set:binary()"
3194
3195
3195 - find files containing a regular expression::
3196 - find files containing a regular expression::
3196
3197
3197 hg files "set:grep('bob')"
3198 hg files "set:grep('bob')"
3198
3199
3199 - search tracked file contents with xargs and grep::
3200 - search tracked file contents with xargs and grep::
3200
3201
3201 hg files -0 | xargs -0 grep foo
3202 hg files -0 | xargs -0 grep foo
3202
3203
3203 See :hg:`help pattern` and :hg:`help filesets` for more information
3204 See :hg:`help pattern` and :hg:`help filesets` for more information
3204 on specifying file patterns.
3205 on specifying file patterns.
3205
3206
3206 Returns 0 if a match is found, 1 otherwise.
3207 Returns 0 if a match is found, 1 otherwise.
3207
3208
3208 """
3209 """
3209 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3210 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3210 rev = ctx.rev()
3211 rev = ctx.rev()
3211 ret = 1
3212 ret = 1
3212
3213
3213 end = '\n'
3214 end = '\n'
3214 if opts.get('print0'):
3215 if opts.get('print0'):
3215 end = '\0'
3216 end = '\0'
3216 fm = ui.formatter('files', opts)
3217 fm = ui.formatter('files', opts)
3217 fmt = '%s' + end
3218 fmt = '%s' + end
3218
3219
3219 m = scmutil.match(ctx, pats, opts)
3220 m = scmutil.match(ctx, pats, opts)
3220 ds = repo.dirstate
3221 ds = repo.dirstate
3221 for f in ctx.matches(m):
3222 for f in ctx.matches(m):
3222 if rev is None and ds[f] == 'r':
3223 if rev is None and ds[f] == 'r':
3223 continue
3224 continue
3224 fm.startitem()
3225 fm.startitem()
3225 if ui.verbose:
3226 if ui.verbose:
3226 fc = ctx[f]
3227 fc = ctx[f]
3227 fm.write('size flags', '% 10d % 1s ', fc.size(), fc.flags())
3228 fm.write('size flags', '% 10d % 1s ', fc.size(), fc.flags())
3228 fm.data(abspath=f)
3229 fm.data(abspath=f)
3229 fm.write('path', fmt, m.rel(f))
3230 fm.write('path', fmt, m.rel(f))
3230 ret = 0
3231 ret = 0
3231
3232
3232 fm.end()
3233 fm.end()
3233
3234
3234 return ret
3235 return ret
3235
3236
3236 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
3237 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
3237 def forget(ui, repo, *pats, **opts):
3238 def forget(ui, repo, *pats, **opts):
3238 """forget the specified files on the next commit
3239 """forget the specified files on the next commit
3239
3240
3240 Mark the specified files so they will no longer be tracked
3241 Mark the specified files so they will no longer be tracked
3241 after the next commit.
3242 after the next commit.
3242
3243
3243 This only removes files from the current branch, not from the
3244 This only removes files from the current branch, not from the
3244 entire project history, and it does not delete them from the
3245 entire project history, and it does not delete them from the
3245 working directory.
3246 working directory.
3246
3247
3247 To undo a forget before the next commit, see :hg:`add`.
3248 To undo a forget before the next commit, see :hg:`add`.
3248
3249
3249 .. container:: verbose
3250 .. container:: verbose
3250
3251
3251 Examples:
3252 Examples:
3252
3253
3253 - forget newly-added binary files::
3254 - forget newly-added binary files::
3254
3255
3255 hg forget "set:added() and binary()"
3256 hg forget "set:added() and binary()"
3256
3257
3257 - forget files that would be excluded by .hgignore::
3258 - forget files that would be excluded by .hgignore::
3258
3259
3259 hg forget "set:hgignore()"
3260 hg forget "set:hgignore()"
3260
3261
3261 Returns 0 on success.
3262 Returns 0 on success.
3262 """
3263 """
3263
3264
3264 if not pats:
3265 if not pats:
3265 raise util.Abort(_('no files specified'))
3266 raise util.Abort(_('no files specified'))
3266
3267
3267 m = scmutil.match(repo[None], pats, opts)
3268 m = scmutil.match(repo[None], pats, opts)
3268 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
3269 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
3269 return rejected and 1 or 0
3270 return rejected and 1 or 0
3270
3271
3271 @command(
3272 @command(
3272 'graft',
3273 'graft',
3273 [('r', 'rev', [], _('revisions to graft'), _('REV')),
3274 [('r', 'rev', [], _('revisions to graft'), _('REV')),
3274 ('c', 'continue', False, _('resume interrupted graft')),
3275 ('c', 'continue', False, _('resume interrupted graft')),
3275 ('e', 'edit', False, _('invoke editor on commit messages')),
3276 ('e', 'edit', False, _('invoke editor on commit messages')),
3276 ('', 'log', None, _('append graft info to log message')),
3277 ('', 'log', None, _('append graft info to log message')),
3277 ('f', 'force', False, _('force graft')),
3278 ('f', 'force', False, _('force graft')),
3278 ('D', 'currentdate', False,
3279 ('D', 'currentdate', False,
3279 _('record the current date as commit date')),
3280 _('record the current date as commit date')),
3280 ('U', 'currentuser', False,
3281 ('U', 'currentuser', False,
3281 _('record the current user as committer'), _('DATE'))]
3282 _('record the current user as committer'), _('DATE'))]
3282 + commitopts2 + mergetoolopts + dryrunopts,
3283 + commitopts2 + mergetoolopts + dryrunopts,
3283 _('[OPTION]... [-r] REV...'))
3284 _('[OPTION]... [-r] REV...'))
3284 def graft(ui, repo, *revs, **opts):
3285 def graft(ui, repo, *revs, **opts):
3285 '''copy changes from other branches onto the current branch
3286 '''copy changes from other branches onto the current branch
3286
3287
3287 This command uses Mercurial's merge logic to copy individual
3288 This command uses Mercurial's merge logic to copy individual
3288 changes from other branches without merging branches in the
3289 changes from other branches without merging branches in the
3289 history graph. This is sometimes known as 'backporting' or
3290 history graph. This is sometimes known as 'backporting' or
3290 'cherry-picking'. By default, graft will copy user, date, and
3291 'cherry-picking'. By default, graft will copy user, date, and
3291 description from the source changesets.
3292 description from the source changesets.
3292
3293
3293 Changesets that are ancestors of the current revision, that have
3294 Changesets that are ancestors of the current revision, that have
3294 already been grafted, or that are merges will be skipped.
3295 already been grafted, or that are merges will be skipped.
3295
3296
3296 If --log is specified, log messages will have a comment appended
3297 If --log is specified, log messages will have a comment appended
3297 of the form::
3298 of the form::
3298
3299
3299 (grafted from CHANGESETHASH)
3300 (grafted from CHANGESETHASH)
3300
3301
3301 If --force is specified, revisions will be grafted even if they
3302 If --force is specified, revisions will be grafted even if they
3302 are already ancestors of or have been grafted to the destination.
3303 are already ancestors of or have been grafted to the destination.
3303 This is useful when the revisions have since been backed out.
3304 This is useful when the revisions have since been backed out.
3304
3305
3305 If a graft merge results in conflicts, the graft process is
3306 If a graft merge results in conflicts, the graft process is
3306 interrupted so that the current merge can be manually resolved.
3307 interrupted so that the current merge can be manually resolved.
3307 Once all conflicts are addressed, the graft process can be
3308 Once all conflicts are addressed, the graft process can be
3308 continued with the -c/--continue option.
3309 continued with the -c/--continue option.
3309
3310
3310 .. note::
3311 .. note::
3311
3312
3312 The -c/--continue option does not reapply earlier options, except
3313 The -c/--continue option does not reapply earlier options, except
3313 for --force.
3314 for --force.
3314
3315
3315 .. container:: verbose
3316 .. container:: verbose
3316
3317
3317 Examples:
3318 Examples:
3318
3319
3319 - copy a single change to the stable branch and edit its description::
3320 - copy a single change to the stable branch and edit its description::
3320
3321
3321 hg update stable
3322 hg update stable
3322 hg graft --edit 9393
3323 hg graft --edit 9393
3323
3324
3324 - graft a range of changesets with one exception, updating dates::
3325 - graft a range of changesets with one exception, updating dates::
3325
3326
3326 hg graft -D "2085::2093 and not 2091"
3327 hg graft -D "2085::2093 and not 2091"
3327
3328
3328 - continue a graft after resolving conflicts::
3329 - continue a graft after resolving conflicts::
3329
3330
3330 hg graft -c
3331 hg graft -c
3331
3332
3332 - show the source of a grafted changeset::
3333 - show the source of a grafted changeset::
3333
3334
3334 hg log --debug -r .
3335 hg log --debug -r .
3335
3336
3336 See :hg:`help revisions` and :hg:`help revsets` for more about
3337 See :hg:`help revisions` and :hg:`help revsets` for more about
3337 specifying revisions.
3338 specifying revisions.
3338
3339
3339 Returns 0 on successful completion.
3340 Returns 0 on successful completion.
3340 '''
3341 '''
3341
3342
3342 revs = list(revs)
3343 revs = list(revs)
3343 revs.extend(opts['rev'])
3344 revs.extend(opts['rev'])
3344
3345
3345 if not opts.get('user') and opts.get('currentuser'):
3346 if not opts.get('user') and opts.get('currentuser'):
3346 opts['user'] = ui.username()
3347 opts['user'] = ui.username()
3347 if not opts.get('date') and opts.get('currentdate'):
3348 if not opts.get('date') and opts.get('currentdate'):
3348 opts['date'] = "%d %d" % util.makedate()
3349 opts['date'] = "%d %d" % util.makedate()
3349
3350
3350 editor = cmdutil.getcommiteditor(editform='graft', **opts)
3351 editor = cmdutil.getcommiteditor(editform='graft', **opts)
3351
3352
3352 cont = False
3353 cont = False
3353 if opts['continue']:
3354 if opts['continue']:
3354 cont = True
3355 cont = True
3355 if revs:
3356 if revs:
3356 raise util.Abort(_("can't specify --continue and revisions"))
3357 raise util.Abort(_("can't specify --continue and revisions"))
3357 # read in unfinished revisions
3358 # read in unfinished revisions
3358 try:
3359 try:
3359 nodes = repo.opener.read('graftstate').splitlines()
3360 nodes = repo.opener.read('graftstate').splitlines()
3360 revs = [repo[node].rev() for node in nodes]
3361 revs = [repo[node].rev() for node in nodes]
3361 except IOError, inst:
3362 except IOError, inst:
3362 if inst.errno != errno.ENOENT:
3363 if inst.errno != errno.ENOENT:
3363 raise
3364 raise
3364 raise util.Abort(_("no graft state found, can't continue"))
3365 raise util.Abort(_("no graft state found, can't continue"))
3365 else:
3366 else:
3366 cmdutil.checkunfinished(repo)
3367 cmdutil.checkunfinished(repo)
3367 cmdutil.bailifchanged(repo)
3368 cmdutil.bailifchanged(repo)
3368 if not revs:
3369 if not revs:
3369 raise util.Abort(_('no revisions specified'))
3370 raise util.Abort(_('no revisions specified'))
3370 revs = scmutil.revrange(repo, revs)
3371 revs = scmutil.revrange(repo, revs)
3371
3372
3372 skipped = set()
3373 skipped = set()
3373 # check for merges
3374 # check for merges
3374 for rev in repo.revs('%ld and merge()', revs):
3375 for rev in repo.revs('%ld and merge()', revs):
3375 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
3376 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
3376 skipped.add(rev)
3377 skipped.add(rev)
3377 revs = [r for r in revs if r not in skipped]
3378 revs = [r for r in revs if r not in skipped]
3378 if not revs:
3379 if not revs:
3379 return -1
3380 return -1
3380
3381
3381 # Don't check in the --continue case, in effect retaining --force across
3382 # Don't check in the --continue case, in effect retaining --force across
3382 # --continues. That's because without --force, any revisions we decided to
3383 # --continues. That's because without --force, any revisions we decided to
3383 # skip would have been filtered out here, so they wouldn't have made their
3384 # skip would have been filtered out here, so they wouldn't have made their
3384 # way to the graftstate. With --force, any revisions we would have otherwise
3385 # way to the graftstate. With --force, any revisions we would have otherwise
3385 # skipped would not have been filtered out, and if they hadn't been applied
3386 # skipped would not have been filtered out, and if they hadn't been applied
3386 # already, they'd have been in the graftstate.
3387 # already, they'd have been in the graftstate.
3387 if not (cont or opts.get('force')):
3388 if not (cont or opts.get('force')):
3388 # check for ancestors of dest branch
3389 # check for ancestors of dest branch
3389 crev = repo['.'].rev()
3390 crev = repo['.'].rev()
3390 ancestors = repo.changelog.ancestors([crev], inclusive=True)
3391 ancestors = repo.changelog.ancestors([crev], inclusive=True)
3391 # Cannot use x.remove(y) on smart set, this has to be a list.
3392 # Cannot use x.remove(y) on smart set, this has to be a list.
3392 # XXX make this lazy in the future
3393 # XXX make this lazy in the future
3393 revs = list(revs)
3394 revs = list(revs)
3394 # don't mutate while iterating, create a copy
3395 # don't mutate while iterating, create a copy
3395 for rev in list(revs):
3396 for rev in list(revs):
3396 if rev in ancestors:
3397 if rev in ancestors:
3397 ui.warn(_('skipping ancestor revision %s\n') % rev)
3398 ui.warn(_('skipping ancestor revision %s\n') % rev)
3398 # XXX remove on list is slow
3399 # XXX remove on list is slow
3399 revs.remove(rev)
3400 revs.remove(rev)
3400 if not revs:
3401 if not revs:
3401 return -1
3402 return -1
3402
3403
3403 # analyze revs for earlier grafts
3404 # analyze revs for earlier grafts
3404 ids = {}
3405 ids = {}
3405 for ctx in repo.set("%ld", revs):
3406 for ctx in repo.set("%ld", revs):
3406 ids[ctx.hex()] = ctx.rev()
3407 ids[ctx.hex()] = ctx.rev()
3407 n = ctx.extra().get('source')
3408 n = ctx.extra().get('source')
3408 if n:
3409 if n:
3409 ids[n] = ctx.rev()
3410 ids[n] = ctx.rev()
3410
3411
3411 # check ancestors for earlier grafts
3412 # check ancestors for earlier grafts
3412 ui.debug('scanning for duplicate grafts\n')
3413 ui.debug('scanning for duplicate grafts\n')
3413
3414
3414 for rev in repo.changelog.findmissingrevs(revs, [crev]):
3415 for rev in repo.changelog.findmissingrevs(revs, [crev]):
3415 ctx = repo[rev]
3416 ctx = repo[rev]
3416 n = ctx.extra().get('source')
3417 n = ctx.extra().get('source')
3417 if n in ids:
3418 if n in ids:
3418 try:
3419 try:
3419 r = repo[n].rev()
3420 r = repo[n].rev()
3420 except error.RepoLookupError:
3421 except error.RepoLookupError:
3421 r = None
3422 r = None
3422 if r in revs:
3423 if r in revs:
3423 ui.warn(_('skipping revision %s (already grafted to %s)\n')
3424 ui.warn(_('skipping revision %s (already grafted to %s)\n')
3424 % (r, rev))
3425 % (r, rev))
3425 revs.remove(r)
3426 revs.remove(r)
3426 elif ids[n] in revs:
3427 elif ids[n] in revs:
3427 if r is None:
3428 if r is None:
3428 ui.warn(_('skipping already grafted revision %s '
3429 ui.warn(_('skipping already grafted revision %s '
3429 '(%s also has unknown origin %s)\n')
3430 '(%s also has unknown origin %s)\n')
3430 % (ids[n], rev, n))
3431 % (ids[n], rev, n))
3431 else:
3432 else:
3432 ui.warn(_('skipping already grafted revision %s '
3433 ui.warn(_('skipping already grafted revision %s '
3433 '(%s also has origin %d)\n')
3434 '(%s also has origin %d)\n')
3434 % (ids[n], rev, r))
3435 % (ids[n], rev, r))
3435 revs.remove(ids[n])
3436 revs.remove(ids[n])
3436 elif ctx.hex() in ids:
3437 elif ctx.hex() in ids:
3437 r = ids[ctx.hex()]
3438 r = ids[ctx.hex()]
3438 ui.warn(_('skipping already grafted revision %s '
3439 ui.warn(_('skipping already grafted revision %s '
3439 '(was grafted from %d)\n') % (r, rev))
3440 '(was grafted from %d)\n') % (r, rev))
3440 revs.remove(r)
3441 revs.remove(r)
3441 if not revs:
3442 if not revs:
3442 return -1
3443 return -1
3443
3444
3444 wlock = repo.wlock()
3445 wlock = repo.wlock()
3445 try:
3446 try:
3446 for pos, ctx in enumerate(repo.set("%ld", revs)):
3447 for pos, ctx in enumerate(repo.set("%ld", revs)):
3447
3448
3448 ui.status(_('grafting revision %s\n') % ctx.rev())
3449 ui.status(_('grafting revision %s\n') % ctx.rev())
3449 if opts.get('dry_run'):
3450 if opts.get('dry_run'):
3450 continue
3451 continue
3451
3452
3452 source = ctx.extra().get('source')
3453 source = ctx.extra().get('source')
3453 if not source:
3454 if not source:
3454 source = ctx.hex()
3455 source = ctx.hex()
3455 extra = {'source': source}
3456 extra = {'source': source}
3456 user = ctx.user()
3457 user = ctx.user()
3457 if opts.get('user'):
3458 if opts.get('user'):
3458 user = opts['user']
3459 user = opts['user']
3459 date = ctx.date()
3460 date = ctx.date()
3460 if opts.get('date'):
3461 if opts.get('date'):
3461 date = opts['date']
3462 date = opts['date']
3462 message = ctx.description()
3463 message = ctx.description()
3463 if opts.get('log'):
3464 if opts.get('log'):
3464 message += '\n(grafted from %s)' % ctx.hex()
3465 message += '\n(grafted from %s)' % ctx.hex()
3465
3466
3466 # we don't merge the first commit when continuing
3467 # we don't merge the first commit when continuing
3467 if not cont:
3468 if not cont:
3468 # perform the graft merge with p1(rev) as 'ancestor'
3469 # perform the graft merge with p1(rev) as 'ancestor'
3469 try:
3470 try:
3470 # ui.forcemerge is an internal variable, do not document
3471 # ui.forcemerge is an internal variable, do not document
3471 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
3472 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
3472 'graft')
3473 'graft')
3473 stats = mergemod.graft(repo, ctx, ctx.p1(),
3474 stats = mergemod.graft(repo, ctx, ctx.p1(),
3474 ['local', 'graft'])
3475 ['local', 'graft'])
3475 finally:
3476 finally:
3476 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
3477 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
3477 # report any conflicts
3478 # report any conflicts
3478 if stats and stats[3] > 0:
3479 if stats and stats[3] > 0:
3479 # write out state for --continue
3480 # write out state for --continue
3480 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3481 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3481 repo.opener.write('graftstate', ''.join(nodelines))
3482 repo.opener.write('graftstate', ''.join(nodelines))
3482 raise util.Abort(
3483 raise util.Abort(
3483 _("unresolved conflicts, can't continue"),
3484 _("unresolved conflicts, can't continue"),
3484 hint=_('use hg resolve and hg graft --continue'))
3485 hint=_('use hg resolve and hg graft --continue'))
3485 else:
3486 else:
3486 cont = False
3487 cont = False
3487
3488
3488 # commit
3489 # commit
3489 node = repo.commit(text=message, user=user,
3490 node = repo.commit(text=message, user=user,
3490 date=date, extra=extra, editor=editor)
3491 date=date, extra=extra, editor=editor)
3491 if node is None:
3492 if node is None:
3492 ui.status(_('graft for revision %s is empty\n') % ctx.rev())
3493 ui.status(_('graft for revision %s is empty\n') % ctx.rev())
3493 finally:
3494 finally:
3494 wlock.release()
3495 wlock.release()
3495
3496
3496 # remove state when we complete successfully
3497 # remove state when we complete successfully
3497 if not opts.get('dry_run'):
3498 if not opts.get('dry_run'):
3498 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
3499 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
3499
3500
3500 return 0
3501 return 0
3501
3502
3502 @command('grep',
3503 @command('grep',
3503 [('0', 'print0', None, _('end fields with NUL')),
3504 [('0', 'print0', None, _('end fields with NUL')),
3504 ('', 'all', None, _('print all revisions that match')),
3505 ('', 'all', None, _('print all revisions that match')),
3505 ('a', 'text', None, _('treat all files as text')),
3506 ('a', 'text', None, _('treat all files as text')),
3506 ('f', 'follow', None,
3507 ('f', 'follow', None,
3507 _('follow changeset history,'
3508 _('follow changeset history,'
3508 ' or file history across copies and renames')),
3509 ' or file history across copies and renames')),
3509 ('i', 'ignore-case', None, _('ignore case when matching')),
3510 ('i', 'ignore-case', None, _('ignore case when matching')),
3510 ('l', 'files-with-matches', None,
3511 ('l', 'files-with-matches', None,
3511 _('print only filenames and revisions that match')),
3512 _('print only filenames and revisions that match')),
3512 ('n', 'line-number', None, _('print matching line numbers')),
3513 ('n', 'line-number', None, _('print matching line numbers')),
3513 ('r', 'rev', [],
3514 ('r', 'rev', [],
3514 _('only search files changed within revision range'), _('REV')),
3515 _('only search files changed within revision range'), _('REV')),
3515 ('u', 'user', None, _('list the author (long with -v)')),
3516 ('u', 'user', None, _('list the author (long with -v)')),
3516 ('d', 'date', None, _('list the date (short with -q)')),
3517 ('d', 'date', None, _('list the date (short with -q)')),
3517 ] + walkopts,
3518 ] + walkopts,
3518 _('[OPTION]... PATTERN [FILE]...'),
3519 _('[OPTION]... PATTERN [FILE]...'),
3519 inferrepo=True)
3520 inferrepo=True)
3520 def grep(ui, repo, pattern, *pats, **opts):
3521 def grep(ui, repo, pattern, *pats, **opts):
3521 """search for a pattern in specified files and revisions
3522 """search for a pattern in specified files and revisions
3522
3523
3523 Search revisions of files for a regular expression.
3524 Search revisions of files for a regular expression.
3524
3525
3525 This command behaves differently than Unix grep. It only accepts
3526 This command behaves differently than Unix grep. It only accepts
3526 Python/Perl regexps. It searches repository history, not the
3527 Python/Perl regexps. It searches repository history, not the
3527 working directory. It always prints the revision number in which a
3528 working directory. It always prints the revision number in which a
3528 match appears.
3529 match appears.
3529
3530
3530 By default, grep only prints output for the first revision of a
3531 By default, grep only prints output for the first revision of a
3531 file in which it finds a match. To get it to print every revision
3532 file in which it finds a match. To get it to print every revision
3532 that contains a change in match status ("-" for a match that
3533 that contains a change in match status ("-" for a match that
3533 becomes a non-match, or "+" for a non-match that becomes a match),
3534 becomes a non-match, or "+" for a non-match that becomes a match),
3534 use the --all flag.
3535 use the --all flag.
3535
3536
3536 Returns 0 if a match is found, 1 otherwise.
3537 Returns 0 if a match is found, 1 otherwise.
3537 """
3538 """
3538 reflags = re.M
3539 reflags = re.M
3539 if opts.get('ignore_case'):
3540 if opts.get('ignore_case'):
3540 reflags |= re.I
3541 reflags |= re.I
3541 try:
3542 try:
3542 regexp = util.re.compile(pattern, reflags)
3543 regexp = util.re.compile(pattern, reflags)
3543 except re.error, inst:
3544 except re.error, inst:
3544 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
3545 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
3545 return 1
3546 return 1
3546 sep, eol = ':', '\n'
3547 sep, eol = ':', '\n'
3547 if opts.get('print0'):
3548 if opts.get('print0'):
3548 sep = eol = '\0'
3549 sep = eol = '\0'
3549
3550
3550 getfile = util.lrucachefunc(repo.file)
3551 getfile = util.lrucachefunc(repo.file)
3551
3552
3552 def matchlines(body):
3553 def matchlines(body):
3553 begin = 0
3554 begin = 0
3554 linenum = 0
3555 linenum = 0
3555 while begin < len(body):
3556 while begin < len(body):
3556 match = regexp.search(body, begin)
3557 match = regexp.search(body, begin)
3557 if not match:
3558 if not match:
3558 break
3559 break
3559 mstart, mend = match.span()
3560 mstart, mend = match.span()
3560 linenum += body.count('\n', begin, mstart) + 1
3561 linenum += body.count('\n', begin, mstart) + 1
3561 lstart = body.rfind('\n', begin, mstart) + 1 or begin
3562 lstart = body.rfind('\n', begin, mstart) + 1 or begin
3562 begin = body.find('\n', mend) + 1 or len(body) + 1
3563 begin = body.find('\n', mend) + 1 or len(body) + 1
3563 lend = begin - 1
3564 lend = begin - 1
3564 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
3565 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
3565
3566
3566 class linestate(object):
3567 class linestate(object):
3567 def __init__(self, line, linenum, colstart, colend):
3568 def __init__(self, line, linenum, colstart, colend):
3568 self.line = line
3569 self.line = line
3569 self.linenum = linenum
3570 self.linenum = linenum
3570 self.colstart = colstart
3571 self.colstart = colstart
3571 self.colend = colend
3572 self.colend = colend
3572
3573
3573 def __hash__(self):
3574 def __hash__(self):
3574 return hash((self.linenum, self.line))
3575 return hash((self.linenum, self.line))
3575
3576
3576 def __eq__(self, other):
3577 def __eq__(self, other):
3577 return self.line == other.line
3578 return self.line == other.line
3578
3579
3579 def __iter__(self):
3580 def __iter__(self):
3580 yield (self.line[:self.colstart], '')
3581 yield (self.line[:self.colstart], '')
3581 yield (self.line[self.colstart:self.colend], 'grep.match')
3582 yield (self.line[self.colstart:self.colend], 'grep.match')
3582 rest = self.line[self.colend:]
3583 rest = self.line[self.colend:]
3583 while rest != '':
3584 while rest != '':
3584 match = regexp.search(rest)
3585 match = regexp.search(rest)
3585 if not match:
3586 if not match:
3586 yield (rest, '')
3587 yield (rest, '')
3587 break
3588 break
3588 mstart, mend = match.span()
3589 mstart, mend = match.span()
3589 yield (rest[:mstart], '')
3590 yield (rest[:mstart], '')
3590 yield (rest[mstart:mend], 'grep.match')
3591 yield (rest[mstart:mend], 'grep.match')
3591 rest = rest[mend:]
3592 rest = rest[mend:]
3592
3593
3593 matches = {}
3594 matches = {}
3594 copies = {}
3595 copies = {}
3595 def grepbody(fn, rev, body):
3596 def grepbody(fn, rev, body):
3596 matches[rev].setdefault(fn, [])
3597 matches[rev].setdefault(fn, [])
3597 m = matches[rev][fn]
3598 m = matches[rev][fn]
3598 for lnum, cstart, cend, line in matchlines(body):
3599 for lnum, cstart, cend, line in matchlines(body):
3599 s = linestate(line, lnum, cstart, cend)
3600 s = linestate(line, lnum, cstart, cend)
3600 m.append(s)
3601 m.append(s)
3601
3602
3602 def difflinestates(a, b):
3603 def difflinestates(a, b):
3603 sm = difflib.SequenceMatcher(None, a, b)
3604 sm = difflib.SequenceMatcher(None, a, b)
3604 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
3605 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
3605 if tag == 'insert':
3606 if tag == 'insert':
3606 for i in xrange(blo, bhi):
3607 for i in xrange(blo, bhi):
3607 yield ('+', b[i])
3608 yield ('+', b[i])
3608 elif tag == 'delete':
3609 elif tag == 'delete':
3609 for i in xrange(alo, ahi):
3610 for i in xrange(alo, ahi):
3610 yield ('-', a[i])
3611 yield ('-', a[i])
3611 elif tag == 'replace':
3612 elif tag == 'replace':
3612 for i in xrange(alo, ahi):
3613 for i in xrange(alo, ahi):
3613 yield ('-', a[i])
3614 yield ('-', a[i])
3614 for i in xrange(blo, bhi):
3615 for i in xrange(blo, bhi):
3615 yield ('+', b[i])
3616 yield ('+', b[i])
3616
3617
3617 def display(fn, ctx, pstates, states):
3618 def display(fn, ctx, pstates, states):
3618 rev = ctx.rev()
3619 rev = ctx.rev()
3619 datefunc = ui.quiet and util.shortdate or util.datestr
3620 datefunc = ui.quiet and util.shortdate or util.datestr
3620 found = False
3621 found = False
3621 @util.cachefunc
3622 @util.cachefunc
3622 def binary():
3623 def binary():
3623 flog = getfile(fn)
3624 flog = getfile(fn)
3624 return util.binary(flog.read(ctx.filenode(fn)))
3625 return util.binary(flog.read(ctx.filenode(fn)))
3625
3626
3626 if opts.get('all'):
3627 if opts.get('all'):
3627 iter = difflinestates(pstates, states)
3628 iter = difflinestates(pstates, states)
3628 else:
3629 else:
3629 iter = [('', l) for l in states]
3630 iter = [('', l) for l in states]
3630 for change, l in iter:
3631 for change, l in iter:
3631 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
3632 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
3632
3633
3633 if opts.get('line_number'):
3634 if opts.get('line_number'):
3634 cols.append((str(l.linenum), 'grep.linenumber'))
3635 cols.append((str(l.linenum), 'grep.linenumber'))
3635 if opts.get('all'):
3636 if opts.get('all'):
3636 cols.append((change, 'grep.change'))
3637 cols.append((change, 'grep.change'))
3637 if opts.get('user'):
3638 if opts.get('user'):
3638 cols.append((ui.shortuser(ctx.user()), 'grep.user'))
3639 cols.append((ui.shortuser(ctx.user()), 'grep.user'))
3639 if opts.get('date'):
3640 if opts.get('date'):
3640 cols.append((datefunc(ctx.date()), 'grep.date'))
3641 cols.append((datefunc(ctx.date()), 'grep.date'))
3641 for col, label in cols[:-1]:
3642 for col, label in cols[:-1]:
3642 ui.write(col, label=label)
3643 ui.write(col, label=label)
3643 ui.write(sep, label='grep.sep')
3644 ui.write(sep, label='grep.sep')
3644 ui.write(cols[-1][0], label=cols[-1][1])
3645 ui.write(cols[-1][0], label=cols[-1][1])
3645 if not opts.get('files_with_matches'):
3646 if not opts.get('files_with_matches'):
3646 ui.write(sep, label='grep.sep')
3647 ui.write(sep, label='grep.sep')
3647 if not opts.get('text') and binary():
3648 if not opts.get('text') and binary():
3648 ui.write(" Binary file matches")
3649 ui.write(" Binary file matches")
3649 else:
3650 else:
3650 for s, label in l:
3651 for s, label in l:
3651 ui.write(s, label=label)
3652 ui.write(s, label=label)
3652 ui.write(eol)
3653 ui.write(eol)
3653 found = True
3654 found = True
3654 if opts.get('files_with_matches'):
3655 if opts.get('files_with_matches'):
3655 break
3656 break
3656 return found
3657 return found
3657
3658
3658 skip = {}
3659 skip = {}
3659 revfiles = {}
3660 revfiles = {}
3660 matchfn = scmutil.match(repo[None], pats, opts)
3661 matchfn = scmutil.match(repo[None], pats, opts)
3661 found = False
3662 found = False
3662 follow = opts.get('follow')
3663 follow = opts.get('follow')
3663
3664
3664 def prep(ctx, fns):
3665 def prep(ctx, fns):
3665 rev = ctx.rev()
3666 rev = ctx.rev()
3666 pctx = ctx.p1()
3667 pctx = ctx.p1()
3667 parent = pctx.rev()
3668 parent = pctx.rev()
3668 matches.setdefault(rev, {})
3669 matches.setdefault(rev, {})
3669 matches.setdefault(parent, {})
3670 matches.setdefault(parent, {})
3670 files = revfiles.setdefault(rev, [])
3671 files = revfiles.setdefault(rev, [])
3671 for fn in fns:
3672 for fn in fns:
3672 flog = getfile(fn)
3673 flog = getfile(fn)
3673 try:
3674 try:
3674 fnode = ctx.filenode(fn)
3675 fnode = ctx.filenode(fn)
3675 except error.LookupError:
3676 except error.LookupError:
3676 continue
3677 continue
3677
3678
3678 copied = flog.renamed(fnode)
3679 copied = flog.renamed(fnode)
3679 copy = follow and copied and copied[0]
3680 copy = follow and copied and copied[0]
3680 if copy:
3681 if copy:
3681 copies.setdefault(rev, {})[fn] = copy
3682 copies.setdefault(rev, {})[fn] = copy
3682 if fn in skip:
3683 if fn in skip:
3683 if copy:
3684 if copy:
3684 skip[copy] = True
3685 skip[copy] = True
3685 continue
3686 continue
3686 files.append(fn)
3687 files.append(fn)
3687
3688
3688 if fn not in matches[rev]:
3689 if fn not in matches[rev]:
3689 grepbody(fn, rev, flog.read(fnode))
3690 grepbody(fn, rev, flog.read(fnode))
3690
3691
3691 pfn = copy or fn
3692 pfn = copy or fn
3692 if pfn not in matches[parent]:
3693 if pfn not in matches[parent]:
3693 try:
3694 try:
3694 fnode = pctx.filenode(pfn)
3695 fnode = pctx.filenode(pfn)
3695 grepbody(pfn, parent, flog.read(fnode))
3696 grepbody(pfn, parent, flog.read(fnode))
3696 except error.LookupError:
3697 except error.LookupError:
3697 pass
3698 pass
3698
3699
3699 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
3700 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
3700 rev = ctx.rev()
3701 rev = ctx.rev()
3701 parent = ctx.p1().rev()
3702 parent = ctx.p1().rev()
3702 for fn in sorted(revfiles.get(rev, [])):
3703 for fn in sorted(revfiles.get(rev, [])):
3703 states = matches[rev][fn]
3704 states = matches[rev][fn]
3704 copy = copies.get(rev, {}).get(fn)
3705 copy = copies.get(rev, {}).get(fn)
3705 if fn in skip:
3706 if fn in skip:
3706 if copy:
3707 if copy:
3707 skip[copy] = True
3708 skip[copy] = True
3708 continue
3709 continue
3709 pstates = matches.get(parent, {}).get(copy or fn, [])
3710 pstates = matches.get(parent, {}).get(copy or fn, [])
3710 if pstates or states:
3711 if pstates or states:
3711 r = display(fn, ctx, pstates, states)
3712 r = display(fn, ctx, pstates, states)
3712 found = found or r
3713 found = found or r
3713 if r and not opts.get('all'):
3714 if r and not opts.get('all'):
3714 skip[fn] = True
3715 skip[fn] = True
3715 if copy:
3716 if copy:
3716 skip[copy] = True
3717 skip[copy] = True
3717 del matches[rev]
3718 del matches[rev]
3718 del revfiles[rev]
3719 del revfiles[rev]
3719
3720
3720 return not found
3721 return not found
3721
3722
3722 @command('heads',
3723 @command('heads',
3723 [('r', 'rev', '',
3724 [('r', 'rev', '',
3724 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
3725 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
3725 ('t', 'topo', False, _('show topological heads only')),
3726 ('t', 'topo', False, _('show topological heads only')),
3726 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
3727 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
3727 ('c', 'closed', False, _('show normal and closed branch heads')),
3728 ('c', 'closed', False, _('show normal and closed branch heads')),
3728 ] + templateopts,
3729 ] + templateopts,
3729 _('[-ct] [-r STARTREV] [REV]...'))
3730 _('[-ct] [-r STARTREV] [REV]...'))
3730 def heads(ui, repo, *branchrevs, **opts):
3731 def heads(ui, repo, *branchrevs, **opts):
3731 """show branch heads
3732 """show branch heads
3732
3733
3733 With no arguments, show all open branch heads in the repository.
3734 With no arguments, show all open branch heads in the repository.
3734 Branch heads are changesets that have no descendants on the
3735 Branch heads are changesets that have no descendants on the
3735 same branch. They are where development generally takes place and
3736 same branch. They are where development generally takes place and
3736 are the usual targets for update and merge operations.
3737 are the usual targets for update and merge operations.
3737
3738
3738 If one or more REVs are given, only open branch heads on the
3739 If one or more REVs are given, only open branch heads on the
3739 branches associated with the specified changesets are shown. This
3740 branches associated with the specified changesets are shown. This
3740 means that you can use :hg:`heads .` to see the heads on the
3741 means that you can use :hg:`heads .` to see the heads on the
3741 currently checked-out branch.
3742 currently checked-out branch.
3742
3743
3743 If -c/--closed is specified, also show branch heads marked closed
3744 If -c/--closed is specified, also show branch heads marked closed
3744 (see :hg:`commit --close-branch`).
3745 (see :hg:`commit --close-branch`).
3745
3746
3746 If STARTREV is specified, only those heads that are descendants of
3747 If STARTREV is specified, only those heads that are descendants of
3747 STARTREV will be displayed.
3748 STARTREV will be displayed.
3748
3749
3749 If -t/--topo is specified, named branch mechanics will be ignored and only
3750 If -t/--topo is specified, named branch mechanics will be ignored and only
3750 topological heads (changesets with no children) will be shown.
3751 topological heads (changesets with no children) will be shown.
3751
3752
3752 Returns 0 if matching heads are found, 1 if not.
3753 Returns 0 if matching heads are found, 1 if not.
3753 """
3754 """
3754
3755
3755 start = None
3756 start = None
3756 if 'rev' in opts:
3757 if 'rev' in opts:
3757 start = scmutil.revsingle(repo, opts['rev'], None).node()
3758 start = scmutil.revsingle(repo, opts['rev'], None).node()
3758
3759
3759 if opts.get('topo'):
3760 if opts.get('topo'):
3760 heads = [repo[h] for h in repo.heads(start)]
3761 heads = [repo[h] for h in repo.heads(start)]
3761 else:
3762 else:
3762 heads = []
3763 heads = []
3763 for branch in repo.branchmap():
3764 for branch in repo.branchmap():
3764 heads += repo.branchheads(branch, start, opts.get('closed'))
3765 heads += repo.branchheads(branch, start, opts.get('closed'))
3765 heads = [repo[h] for h in heads]
3766 heads = [repo[h] for h in heads]
3766
3767
3767 if branchrevs:
3768 if branchrevs:
3768 branches = set(repo[br].branch() for br in branchrevs)
3769 branches = set(repo[br].branch() for br in branchrevs)
3769 heads = [h for h in heads if h.branch() in branches]
3770 heads = [h for h in heads if h.branch() in branches]
3770
3771
3771 if opts.get('active') and branchrevs:
3772 if opts.get('active') and branchrevs:
3772 dagheads = repo.heads(start)
3773 dagheads = repo.heads(start)
3773 heads = [h for h in heads if h.node() in dagheads]
3774 heads = [h for h in heads if h.node() in dagheads]
3774
3775
3775 if branchrevs:
3776 if branchrevs:
3776 haveheads = set(h.branch() for h in heads)
3777 haveheads = set(h.branch() for h in heads)
3777 if branches - haveheads:
3778 if branches - haveheads:
3778 headless = ', '.join(b for b in branches - haveheads)
3779 headless = ', '.join(b for b in branches - haveheads)
3779 msg = _('no open branch heads found on branches %s')
3780 msg = _('no open branch heads found on branches %s')
3780 if opts.get('rev'):
3781 if opts.get('rev'):
3781 msg += _(' (started at %s)') % opts['rev']
3782 msg += _(' (started at %s)') % opts['rev']
3782 ui.warn((msg + '\n') % headless)
3783 ui.warn((msg + '\n') % headless)
3783
3784
3784 if not heads:
3785 if not heads:
3785 return 1
3786 return 1
3786
3787
3787 heads = sorted(heads, key=lambda x: -x.rev())
3788 heads = sorted(heads, key=lambda x: -x.rev())
3788 displayer = cmdutil.show_changeset(ui, repo, opts)
3789 displayer = cmdutil.show_changeset(ui, repo, opts)
3789 for ctx in heads:
3790 for ctx in heads:
3790 displayer.show(ctx)
3791 displayer.show(ctx)
3791 displayer.close()
3792 displayer.close()
3792
3793
3793 @command('help',
3794 @command('help',
3794 [('e', 'extension', None, _('show only help for extensions')),
3795 [('e', 'extension', None, _('show only help for extensions')),
3795 ('c', 'command', None, _('show only help for commands')),
3796 ('c', 'command', None, _('show only help for commands')),
3796 ('k', 'keyword', '', _('show topics matching keyword')),
3797 ('k', 'keyword', '', _('show topics matching keyword')),
3797 ],
3798 ],
3798 _('[-ec] [TOPIC]'),
3799 _('[-ec] [TOPIC]'),
3799 norepo=True)
3800 norepo=True)
3800 def help_(ui, name=None, **opts):
3801 def help_(ui, name=None, **opts):
3801 """show help for a given topic or a help overview
3802 """show help for a given topic or a help overview
3802
3803
3803 With no arguments, print a list of commands with short help messages.
3804 With no arguments, print a list of commands with short help messages.
3804
3805
3805 Given a topic, extension, or command name, print help for that
3806 Given a topic, extension, or command name, print help for that
3806 topic.
3807 topic.
3807
3808
3808 Returns 0 if successful.
3809 Returns 0 if successful.
3809 """
3810 """
3810
3811
3811 textwidth = min(ui.termwidth(), 80) - 2
3812 textwidth = min(ui.termwidth(), 80) - 2
3812
3813
3813 keep = []
3814 keep = []
3814 if ui.verbose:
3815 if ui.verbose:
3815 keep.append('verbose')
3816 keep.append('verbose')
3816 if sys.platform.startswith('win'):
3817 if sys.platform.startswith('win'):
3817 keep.append('windows')
3818 keep.append('windows')
3818 elif sys.platform == 'OpenVMS':
3819 elif sys.platform == 'OpenVMS':
3819 keep.append('vms')
3820 keep.append('vms')
3820 elif sys.platform == 'plan9':
3821 elif sys.platform == 'plan9':
3821 keep.append('plan9')
3822 keep.append('plan9')
3822 else:
3823 else:
3823 keep.append('unix')
3824 keep.append('unix')
3824 keep.append(sys.platform.lower())
3825 keep.append(sys.platform.lower())
3825
3826
3826 section = None
3827 section = None
3827 if name and '.' in name:
3828 if name and '.' in name:
3828 name, section = name.split('.', 1)
3829 name, section = name.split('.', 1)
3829
3830
3830 text = help.help_(ui, name, **opts)
3831 text = help.help_(ui, name, **opts)
3831
3832
3832 formatted, pruned = minirst.format(text, textwidth, keep=keep,
3833 formatted, pruned = minirst.format(text, textwidth, keep=keep,
3833 section=section)
3834 section=section)
3834 if section and not formatted:
3835 if section and not formatted:
3835 raise util.Abort(_("help section not found"))
3836 raise util.Abort(_("help section not found"))
3836
3837
3837 if 'verbose' in pruned:
3838 if 'verbose' in pruned:
3838 keep.append('omitted')
3839 keep.append('omitted')
3839 else:
3840 else:
3840 keep.append('notomitted')
3841 keep.append('notomitted')
3841 formatted, pruned = minirst.format(text, textwidth, keep=keep,
3842 formatted, pruned = minirst.format(text, textwidth, keep=keep,
3842 section=section)
3843 section=section)
3843 ui.write(formatted)
3844 ui.write(formatted)
3844
3845
3845
3846
3846 @command('identify|id',
3847 @command('identify|id',
3847 [('r', 'rev', '',
3848 [('r', 'rev', '',
3848 _('identify the specified revision'), _('REV')),
3849 _('identify the specified revision'), _('REV')),
3849 ('n', 'num', None, _('show local revision number')),
3850 ('n', 'num', None, _('show local revision number')),
3850 ('i', 'id', None, _('show global revision id')),
3851 ('i', 'id', None, _('show global revision id')),
3851 ('b', 'branch', None, _('show branch')),
3852 ('b', 'branch', None, _('show branch')),
3852 ('t', 'tags', None, _('show tags')),
3853 ('t', 'tags', None, _('show tags')),
3853 ('B', 'bookmarks', None, _('show bookmarks')),
3854 ('B', 'bookmarks', None, _('show bookmarks')),
3854 ] + remoteopts,
3855 ] + remoteopts,
3855 _('[-nibtB] [-r REV] [SOURCE]'),
3856 _('[-nibtB] [-r REV] [SOURCE]'),
3856 optionalrepo=True)
3857 optionalrepo=True)
3857 def identify(ui, repo, source=None, rev=None,
3858 def identify(ui, repo, source=None, rev=None,
3858 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
3859 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
3859 """identify the working copy or specified revision
3860 """identify the working copy or specified revision
3860
3861
3861 Print a summary identifying the repository state at REV using one or
3862 Print a summary identifying the repository state at REV using one or
3862 two parent hash identifiers, followed by a "+" if the working
3863 two parent hash identifiers, followed by a "+" if the working
3863 directory has uncommitted changes, the branch name (if not default),
3864 directory has uncommitted changes, the branch name (if not default),
3864 a list of tags, and a list of bookmarks.
3865 a list of tags, and a list of bookmarks.
3865
3866
3866 When REV is not given, print a summary of the current state of the
3867 When REV is not given, print a summary of the current state of the
3867 repository.
3868 repository.
3868
3869
3869 Specifying a path to a repository root or Mercurial bundle will
3870 Specifying a path to a repository root or Mercurial bundle will
3870 cause lookup to operate on that repository/bundle.
3871 cause lookup to operate on that repository/bundle.
3871
3872
3872 .. container:: verbose
3873 .. container:: verbose
3873
3874
3874 Examples:
3875 Examples:
3875
3876
3876 - generate a build identifier for the working directory::
3877 - generate a build identifier for the working directory::
3877
3878
3878 hg id --id > build-id.dat
3879 hg id --id > build-id.dat
3879
3880
3880 - find the revision corresponding to a tag::
3881 - find the revision corresponding to a tag::
3881
3882
3882 hg id -n -r 1.3
3883 hg id -n -r 1.3
3883
3884
3884 - check the most recent revision of a remote repository::
3885 - check the most recent revision of a remote repository::
3885
3886
3886 hg id -r tip http://selenic.com/hg/
3887 hg id -r tip http://selenic.com/hg/
3887
3888
3888 Returns 0 if successful.
3889 Returns 0 if successful.
3889 """
3890 """
3890
3891
3891 if not repo and not source:
3892 if not repo and not source:
3892 raise util.Abort(_("there is no Mercurial repository here "
3893 raise util.Abort(_("there is no Mercurial repository here "
3893 "(.hg not found)"))
3894 "(.hg not found)"))
3894
3895
3895 hexfunc = ui.debugflag and hex or short
3896 hexfunc = ui.debugflag and hex or short
3896 default = not (num or id or branch or tags or bookmarks)
3897 default = not (num or id or branch or tags or bookmarks)
3897 output = []
3898 output = []
3898 revs = []
3899 revs = []
3899
3900
3900 if source:
3901 if source:
3901 source, branches = hg.parseurl(ui.expandpath(source))
3902 source, branches = hg.parseurl(ui.expandpath(source))
3902 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
3903 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
3903 repo = peer.local()
3904 repo = peer.local()
3904 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
3905 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
3905
3906
3906 if not repo:
3907 if not repo:
3907 if num or branch or tags:
3908 if num or branch or tags:
3908 raise util.Abort(
3909 raise util.Abort(
3909 _("can't query remote revision number, branch, or tags"))
3910 _("can't query remote revision number, branch, or tags"))
3910 if not rev and revs:
3911 if not rev and revs:
3911 rev = revs[0]
3912 rev = revs[0]
3912 if not rev:
3913 if not rev:
3913 rev = "tip"
3914 rev = "tip"
3914
3915
3915 remoterev = peer.lookup(rev)
3916 remoterev = peer.lookup(rev)
3916 if default or id:
3917 if default or id:
3917 output = [hexfunc(remoterev)]
3918 output = [hexfunc(remoterev)]
3918
3919
3919 def getbms():
3920 def getbms():
3920 bms = []
3921 bms = []
3921
3922
3922 if 'bookmarks' in peer.listkeys('namespaces'):
3923 if 'bookmarks' in peer.listkeys('namespaces'):
3923 hexremoterev = hex(remoterev)
3924 hexremoterev = hex(remoterev)
3924 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
3925 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
3925 if bmr == hexremoterev]
3926 if bmr == hexremoterev]
3926
3927
3927 return sorted(bms)
3928 return sorted(bms)
3928
3929
3929 if bookmarks:
3930 if bookmarks:
3930 output.extend(getbms())
3931 output.extend(getbms())
3931 elif default and not ui.quiet:
3932 elif default and not ui.quiet:
3932 # multiple bookmarks for a single parent separated by '/'
3933 # multiple bookmarks for a single parent separated by '/'
3933 bm = '/'.join(getbms())
3934 bm = '/'.join(getbms())
3934 if bm:
3935 if bm:
3935 output.append(bm)
3936 output.append(bm)
3936 else:
3937 else:
3937 if not rev:
3938 if not rev:
3938 ctx = repo[None]
3939 ctx = repo[None]
3939 parents = ctx.parents()
3940 parents = ctx.parents()
3940 changed = ""
3941 changed = ""
3941 if default or id or num:
3942 if default or id or num:
3942 if (util.any(repo.status())
3943 if (util.any(repo.status())
3943 or util.any(ctx.sub(s).dirty() for s in ctx.substate)):
3944 or util.any(ctx.sub(s).dirty() for s in ctx.substate)):
3944 changed = '+'
3945 changed = '+'
3945 if default or id:
3946 if default or id:
3946 output = ["%s%s" %
3947 output = ["%s%s" %
3947 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
3948 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
3948 if num:
3949 if num:
3949 output.append("%s%s" %
3950 output.append("%s%s" %
3950 ('+'.join([str(p.rev()) for p in parents]), changed))
3951 ('+'.join([str(p.rev()) for p in parents]), changed))
3951 else:
3952 else:
3952 ctx = scmutil.revsingle(repo, rev)
3953 ctx = scmutil.revsingle(repo, rev)
3953 if default or id:
3954 if default or id:
3954 output = [hexfunc(ctx.node())]
3955 output = [hexfunc(ctx.node())]
3955 if num:
3956 if num:
3956 output.append(str(ctx.rev()))
3957 output.append(str(ctx.rev()))
3957
3958
3958 if default and not ui.quiet:
3959 if default and not ui.quiet:
3959 b = ctx.branch()
3960 b = ctx.branch()
3960 if b != 'default':
3961 if b != 'default':
3961 output.append("(%s)" % b)
3962 output.append("(%s)" % b)
3962
3963
3963 # multiple tags for a single parent separated by '/'
3964 # multiple tags for a single parent separated by '/'
3964 t = '/'.join(ctx.tags())
3965 t = '/'.join(ctx.tags())
3965 if t:
3966 if t:
3966 output.append(t)
3967 output.append(t)
3967
3968
3968 # multiple bookmarks for a single parent separated by '/'
3969 # multiple bookmarks for a single parent separated by '/'
3969 bm = '/'.join(ctx.bookmarks())
3970 bm = '/'.join(ctx.bookmarks())
3970 if bm:
3971 if bm:
3971 output.append(bm)
3972 output.append(bm)
3972 else:
3973 else:
3973 if branch:
3974 if branch:
3974 output.append(ctx.branch())
3975 output.append(ctx.branch())
3975
3976
3976 if tags:
3977 if tags:
3977 output.extend(ctx.tags())
3978 output.extend(ctx.tags())
3978
3979
3979 if bookmarks:
3980 if bookmarks:
3980 output.extend(ctx.bookmarks())
3981 output.extend(ctx.bookmarks())
3981
3982
3982 ui.write("%s\n" % ' '.join(output))
3983 ui.write("%s\n" % ' '.join(output))
3983
3984
3984 @command('import|patch',
3985 @command('import|patch',
3985 [('p', 'strip', 1,
3986 [('p', 'strip', 1,
3986 _('directory strip option for patch. This has the same '
3987 _('directory strip option for patch. This has the same '
3987 'meaning as the corresponding patch option'), _('NUM')),
3988 'meaning as the corresponding patch option'), _('NUM')),
3988 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
3989 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
3989 ('e', 'edit', False, _('invoke editor on commit messages')),
3990 ('e', 'edit', False, _('invoke editor on commit messages')),
3990 ('f', 'force', None,
3991 ('f', 'force', None,
3991 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
3992 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
3992 ('', 'no-commit', None,
3993 ('', 'no-commit', None,
3993 _("don't commit, just update the working directory")),
3994 _("don't commit, just update the working directory")),
3994 ('', 'bypass', None,
3995 ('', 'bypass', None,
3995 _("apply patch without touching the working directory")),
3996 _("apply patch without touching the working directory")),
3996 ('', 'partial', None,
3997 ('', 'partial', None,
3997 _('commit even if some hunks fail')),
3998 _('commit even if some hunks fail')),
3998 ('', 'exact', None,
3999 ('', 'exact', None,
3999 _('apply patch to the nodes from which it was generated')),
4000 _('apply patch to the nodes from which it was generated')),
4000 ('', 'import-branch', None,
4001 ('', 'import-branch', None,
4001 _('use any branch information in patch (implied by --exact)'))] +
4002 _('use any branch information in patch (implied by --exact)'))] +
4002 commitopts + commitopts2 + similarityopts,
4003 commitopts + commitopts2 + similarityopts,
4003 _('[OPTION]... PATCH...'))
4004 _('[OPTION]... PATCH...'))
4004 def import_(ui, repo, patch1=None, *patches, **opts):
4005 def import_(ui, repo, patch1=None, *patches, **opts):
4005 """import an ordered set of patches
4006 """import an ordered set of patches
4006
4007
4007 Import a list of patches and commit them individually (unless
4008 Import a list of patches and commit them individually (unless
4008 --no-commit is specified).
4009 --no-commit is specified).
4009
4010
4010 Because import first applies changes to the working directory,
4011 Because import first applies changes to the working directory,
4011 import will abort if there are outstanding changes.
4012 import will abort if there are outstanding changes.
4012
4013
4013 You can import a patch straight from a mail message. Even patches
4014 You can import a patch straight from a mail message. Even patches
4014 as attachments work (to use the body part, it must have type
4015 as attachments work (to use the body part, it must have type
4015 text/plain or text/x-patch). From and Subject headers of email
4016 text/plain or text/x-patch). From and Subject headers of email
4016 message are used as default committer and commit message. All
4017 message are used as default committer and commit message. All
4017 text/plain body parts before first diff are added to commit
4018 text/plain body parts before first diff are added to commit
4018 message.
4019 message.
4019
4020
4020 If the imported patch was generated by :hg:`export`, user and
4021 If the imported patch was generated by :hg:`export`, user and
4021 description from patch override values from message headers and
4022 description from patch override values from message headers and
4022 body. Values given on command line with -m/--message and -u/--user
4023 body. Values given on command line with -m/--message and -u/--user
4023 override these.
4024 override these.
4024
4025
4025 If --exact is specified, import will set the working directory to
4026 If --exact is specified, import will set the working directory to
4026 the parent of each patch before applying it, and will abort if the
4027 the parent of each patch before applying it, and will abort if the
4027 resulting changeset has a different ID than the one recorded in
4028 resulting changeset has a different ID than the one recorded in
4028 the patch. This may happen due to character set problems or other
4029 the patch. This may happen due to character set problems or other
4029 deficiencies in the text patch format.
4030 deficiencies in the text patch format.
4030
4031
4031 Use --bypass to apply and commit patches directly to the
4032 Use --bypass to apply and commit patches directly to the
4032 repository, not touching the working directory. Without --exact,
4033 repository, not touching the working directory. Without --exact,
4033 patches will be applied on top of the working directory parent
4034 patches will be applied on top of the working directory parent
4034 revision.
4035 revision.
4035
4036
4036 With -s/--similarity, hg will attempt to discover renames and
4037 With -s/--similarity, hg will attempt to discover renames and
4037 copies in the patch in the same way as :hg:`addremove`.
4038 copies in the patch in the same way as :hg:`addremove`.
4038
4039
4039 Use --partial to ensure a changeset will be created from the patch
4040 Use --partial to ensure a changeset will be created from the patch
4040 even if some hunks fail to apply. Hunks that fail to apply will be
4041 even if some hunks fail to apply. Hunks that fail to apply will be
4041 written to a <target-file>.rej file. Conflicts can then be resolved
4042 written to a <target-file>.rej file. Conflicts can then be resolved
4042 by hand before :hg:`commit --amend` is run to update the created
4043 by hand before :hg:`commit --amend` is run to update the created
4043 changeset. This flag exists to let people import patches that
4044 changeset. This flag exists to let people import patches that
4044 partially apply without losing the associated metadata (author,
4045 partially apply without losing the associated metadata (author,
4045 date, description, ...). Note that when none of the hunk applies
4046 date, description, ...). Note that when none of the hunk applies
4046 cleanly, :hg:`import --partial` will create an empty changeset,
4047 cleanly, :hg:`import --partial` will create an empty changeset,
4047 importing only the patch metadata.
4048 importing only the patch metadata.
4048
4049
4049 To read a patch from standard input, use "-" as the patch name. If
4050 To read a patch from standard input, use "-" as the patch name. If
4050 a URL is specified, the patch will be downloaded from it.
4051 a URL is specified, the patch will be downloaded from it.
4051 See :hg:`help dates` for a list of formats valid for -d/--date.
4052 See :hg:`help dates` for a list of formats valid for -d/--date.
4052
4053
4053 .. container:: verbose
4054 .. container:: verbose
4054
4055
4055 Examples:
4056 Examples:
4056
4057
4057 - import a traditional patch from a website and detect renames::
4058 - import a traditional patch from a website and detect renames::
4058
4059
4059 hg import -s 80 http://example.com/bugfix.patch
4060 hg import -s 80 http://example.com/bugfix.patch
4060
4061
4061 - import a changeset from an hgweb server::
4062 - import a changeset from an hgweb server::
4062
4063
4063 hg import http://www.selenic.com/hg/rev/5ca8c111e9aa
4064 hg import http://www.selenic.com/hg/rev/5ca8c111e9aa
4064
4065
4065 - import all the patches in an Unix-style mbox::
4066 - import all the patches in an Unix-style mbox::
4066
4067
4067 hg import incoming-patches.mbox
4068 hg import incoming-patches.mbox
4068
4069
4069 - attempt to exactly restore an exported changeset (not always
4070 - attempt to exactly restore an exported changeset (not always
4070 possible)::
4071 possible)::
4071
4072
4072 hg import --exact proposed-fix.patch
4073 hg import --exact proposed-fix.patch
4073
4074
4074 Returns 0 on success, 1 on partial success (see --partial).
4075 Returns 0 on success, 1 on partial success (see --partial).
4075 """
4076 """
4076
4077
4077 if not patch1:
4078 if not patch1:
4078 raise util.Abort(_('need at least one patch to import'))
4079 raise util.Abort(_('need at least one patch to import'))
4079
4080
4080 patches = (patch1,) + patches
4081 patches = (patch1,) + patches
4081
4082
4082 date = opts.get('date')
4083 date = opts.get('date')
4083 if date:
4084 if date:
4084 opts['date'] = util.parsedate(date)
4085 opts['date'] = util.parsedate(date)
4085
4086
4086 update = not opts.get('bypass')
4087 update = not opts.get('bypass')
4087 if not update and opts.get('no_commit'):
4088 if not update and opts.get('no_commit'):
4088 raise util.Abort(_('cannot use --no-commit with --bypass'))
4089 raise util.Abort(_('cannot use --no-commit with --bypass'))
4089 try:
4090 try:
4090 sim = float(opts.get('similarity') or 0)
4091 sim = float(opts.get('similarity') or 0)
4091 except ValueError:
4092 except ValueError:
4092 raise util.Abort(_('similarity must be a number'))
4093 raise util.Abort(_('similarity must be a number'))
4093 if sim < 0 or sim > 100:
4094 if sim < 0 or sim > 100:
4094 raise util.Abort(_('similarity must be between 0 and 100'))
4095 raise util.Abort(_('similarity must be between 0 and 100'))
4095 if sim and not update:
4096 if sim and not update:
4096 raise util.Abort(_('cannot use --similarity with --bypass'))
4097 raise util.Abort(_('cannot use --similarity with --bypass'))
4097 if opts.get('exact') and opts.get('edit'):
4098 if opts.get('exact') and opts.get('edit'):
4098 raise util.Abort(_('cannot use --exact with --edit'))
4099 raise util.Abort(_('cannot use --exact with --edit'))
4099
4100
4100 if update:
4101 if update:
4101 cmdutil.checkunfinished(repo)
4102 cmdutil.checkunfinished(repo)
4102 if (opts.get('exact') or not opts.get('force')) and update:
4103 if (opts.get('exact') or not opts.get('force')) and update:
4103 cmdutil.bailifchanged(repo)
4104 cmdutil.bailifchanged(repo)
4104
4105
4105 base = opts["base"]
4106 base = opts["base"]
4106 wlock = lock = tr = None
4107 wlock = lock = tr = None
4107 msgs = []
4108 msgs = []
4108 ret = 0
4109 ret = 0
4109
4110
4110
4111
4111 try:
4112 try:
4112 try:
4113 try:
4113 wlock = repo.wlock()
4114 wlock = repo.wlock()
4114 repo.dirstate.beginparentchange()
4115 repo.dirstate.beginparentchange()
4115 if not opts.get('no_commit'):
4116 if not opts.get('no_commit'):
4116 lock = repo.lock()
4117 lock = repo.lock()
4117 tr = repo.transaction('import')
4118 tr = repo.transaction('import')
4118 parents = repo.parents()
4119 parents = repo.parents()
4119 for patchurl in patches:
4120 for patchurl in patches:
4120 if patchurl == '-':
4121 if patchurl == '-':
4121 ui.status(_('applying patch from stdin\n'))
4122 ui.status(_('applying patch from stdin\n'))
4122 patchfile = ui.fin
4123 patchfile = ui.fin
4123 patchurl = 'stdin' # for error message
4124 patchurl = 'stdin' # for error message
4124 else:
4125 else:
4125 patchurl = os.path.join(base, patchurl)
4126 patchurl = os.path.join(base, patchurl)
4126 ui.status(_('applying %s\n') % patchurl)
4127 ui.status(_('applying %s\n') % patchurl)
4127 patchfile = hg.openpath(ui, patchurl)
4128 patchfile = hg.openpath(ui, patchurl)
4128
4129
4129 haspatch = False
4130 haspatch = False
4130 for hunk in patch.split(patchfile):
4131 for hunk in patch.split(patchfile):
4131 (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk,
4132 (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk,
4132 parents, opts,
4133 parents, opts,
4133 msgs, hg.clean)
4134 msgs, hg.clean)
4134 if msg:
4135 if msg:
4135 haspatch = True
4136 haspatch = True
4136 ui.note(msg + '\n')
4137 ui.note(msg + '\n')
4137 if update or opts.get('exact'):
4138 if update or opts.get('exact'):
4138 parents = repo.parents()
4139 parents = repo.parents()
4139 else:
4140 else:
4140 parents = [repo[node]]
4141 parents = [repo[node]]
4141 if rej:
4142 if rej:
4142 ui.write_err(_("patch applied partially\n"))
4143 ui.write_err(_("patch applied partially\n"))
4143 ui.write_err(_("(fix the .rej files and run "
4144 ui.write_err(_("(fix the .rej files and run "
4144 "`hg commit --amend`)\n"))
4145 "`hg commit --amend`)\n"))
4145 ret = 1
4146 ret = 1
4146 break
4147 break
4147
4148
4148 if not haspatch:
4149 if not haspatch:
4149 raise util.Abort(_('%s: no diffs found') % patchurl)
4150 raise util.Abort(_('%s: no diffs found') % patchurl)
4150
4151
4151 if tr:
4152 if tr:
4152 tr.close()
4153 tr.close()
4153 if msgs:
4154 if msgs:
4154 repo.savecommitmessage('\n* * *\n'.join(msgs))
4155 repo.savecommitmessage('\n* * *\n'.join(msgs))
4155 repo.dirstate.endparentchange()
4156 repo.dirstate.endparentchange()
4156 return ret
4157 return ret
4157 except: # re-raises
4158 except: # re-raises
4158 # wlock.release() indirectly calls dirstate.write(): since
4159 # wlock.release() indirectly calls dirstate.write(): since
4159 # we're crashing, we do not want to change the working dir
4160 # we're crashing, we do not want to change the working dir
4160 # parent after all, so make sure it writes nothing
4161 # parent after all, so make sure it writes nothing
4161 repo.dirstate.invalidate()
4162 repo.dirstate.invalidate()
4162 raise
4163 raise
4163 finally:
4164 finally:
4164 if tr:
4165 if tr:
4165 tr.release()
4166 tr.release()
4166 release(lock, wlock)
4167 release(lock, wlock)
4167
4168
4168 @command('incoming|in',
4169 @command('incoming|in',
4169 [('f', 'force', None,
4170 [('f', 'force', None,
4170 _('run even if remote repository is unrelated')),
4171 _('run even if remote repository is unrelated')),
4171 ('n', 'newest-first', None, _('show newest record first')),
4172 ('n', 'newest-first', None, _('show newest record first')),
4172 ('', 'bundle', '',
4173 ('', 'bundle', '',
4173 _('file to store the bundles into'), _('FILE')),
4174 _('file to store the bundles into'), _('FILE')),
4174 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
4175 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
4175 ('B', 'bookmarks', False, _("compare bookmarks")),
4176 ('B', 'bookmarks', False, _("compare bookmarks")),
4176 ('b', 'branch', [],
4177 ('b', 'branch', [],
4177 _('a specific branch you would like to pull'), _('BRANCH')),
4178 _('a specific branch you would like to pull'), _('BRANCH')),
4178 ] + logopts + remoteopts + subrepoopts,
4179 ] + logopts + remoteopts + subrepoopts,
4179 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
4180 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
4180 def incoming(ui, repo, source="default", **opts):
4181 def incoming(ui, repo, source="default", **opts):
4181 """show new changesets found in source
4182 """show new changesets found in source
4182
4183
4183 Show new changesets found in the specified path/URL or the default
4184 Show new changesets found in the specified path/URL or the default
4184 pull location. These are the changesets that would have been pulled
4185 pull location. These are the changesets that would have been pulled
4185 if a pull at the time you issued this command.
4186 if a pull at the time you issued this command.
4186
4187
4187 For remote repository, using --bundle avoids downloading the
4188 For remote repository, using --bundle avoids downloading the
4188 changesets twice if the incoming is followed by a pull.
4189 changesets twice if the incoming is followed by a pull.
4189
4190
4190 See pull for valid source format details.
4191 See pull for valid source format details.
4191
4192
4192 .. container:: verbose
4193 .. container:: verbose
4193
4194
4194 Examples:
4195 Examples:
4195
4196
4196 - show incoming changes with patches and full description::
4197 - show incoming changes with patches and full description::
4197
4198
4198 hg incoming -vp
4199 hg incoming -vp
4199
4200
4200 - show incoming changes excluding merges, store a bundle::
4201 - show incoming changes excluding merges, store a bundle::
4201
4202
4202 hg in -vpM --bundle incoming.hg
4203 hg in -vpM --bundle incoming.hg
4203 hg pull incoming.hg
4204 hg pull incoming.hg
4204
4205
4205 - briefly list changes inside a bundle::
4206 - briefly list changes inside a bundle::
4206
4207
4207 hg in changes.hg -T "{desc|firstline}\\n"
4208 hg in changes.hg -T "{desc|firstline}\\n"
4208
4209
4209 Returns 0 if there are incoming changes, 1 otherwise.
4210 Returns 0 if there are incoming changes, 1 otherwise.
4210 """
4211 """
4211 if opts.get('graph'):
4212 if opts.get('graph'):
4212 cmdutil.checkunsupportedgraphflags([], opts)
4213 cmdutil.checkunsupportedgraphflags([], opts)
4213 def display(other, chlist, displayer):
4214 def display(other, chlist, displayer):
4214 revdag = cmdutil.graphrevs(other, chlist, opts)
4215 revdag = cmdutil.graphrevs(other, chlist, opts)
4215 showparents = [ctx.node() for ctx in repo[None].parents()]
4216 showparents = [ctx.node() for ctx in repo[None].parents()]
4216 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4217 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4217 graphmod.asciiedges)
4218 graphmod.asciiedges)
4218
4219
4219 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
4220 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
4220 return 0
4221 return 0
4221
4222
4222 if opts.get('bundle') and opts.get('subrepos'):
4223 if opts.get('bundle') and opts.get('subrepos'):
4223 raise util.Abort(_('cannot combine --bundle and --subrepos'))
4224 raise util.Abort(_('cannot combine --bundle and --subrepos'))
4224
4225
4225 if opts.get('bookmarks'):
4226 if opts.get('bookmarks'):
4226 source, branches = hg.parseurl(ui.expandpath(source),
4227 source, branches = hg.parseurl(ui.expandpath(source),
4227 opts.get('branch'))
4228 opts.get('branch'))
4228 other = hg.peer(repo, opts, source)
4229 other = hg.peer(repo, opts, source)
4229 if 'bookmarks' not in other.listkeys('namespaces'):
4230 if 'bookmarks' not in other.listkeys('namespaces'):
4230 ui.warn(_("remote doesn't support bookmarks\n"))
4231 ui.warn(_("remote doesn't support bookmarks\n"))
4231 return 0
4232 return 0
4232 ui.status(_('comparing with %s\n') % util.hidepassword(source))
4233 ui.status(_('comparing with %s\n') % util.hidepassword(source))
4233 return bookmarks.diff(ui, repo, other)
4234 return bookmarks.diff(ui, repo, other)
4234
4235
4235 repo._subtoppath = ui.expandpath(source)
4236 repo._subtoppath = ui.expandpath(source)
4236 try:
4237 try:
4237 return hg.incoming(ui, repo, source, opts)
4238 return hg.incoming(ui, repo, source, opts)
4238 finally:
4239 finally:
4239 del repo._subtoppath
4240 del repo._subtoppath
4240
4241
4241
4242
4242 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
4243 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
4243 norepo=True)
4244 norepo=True)
4244 def init(ui, dest=".", **opts):
4245 def init(ui, dest=".", **opts):
4245 """create a new repository in the given directory
4246 """create a new repository in the given directory
4246
4247
4247 Initialize a new repository in the given directory. If the given
4248 Initialize a new repository in the given directory. If the given
4248 directory does not exist, it will be created.
4249 directory does not exist, it will be created.
4249
4250
4250 If no directory is given, the current directory is used.
4251 If no directory is given, the current directory is used.
4251
4252
4252 It is possible to specify an ``ssh://`` URL as the destination.
4253 It is possible to specify an ``ssh://`` URL as the destination.
4253 See :hg:`help urls` for more information.
4254 See :hg:`help urls` for more information.
4254
4255
4255 Returns 0 on success.
4256 Returns 0 on success.
4256 """
4257 """
4257 hg.peer(ui, opts, ui.expandpath(dest), create=True)
4258 hg.peer(ui, opts, ui.expandpath(dest), create=True)
4258
4259
4259 @command('locate',
4260 @command('locate',
4260 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
4261 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
4261 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
4262 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
4262 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
4263 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
4263 ] + walkopts,
4264 ] + walkopts,
4264 _('[OPTION]... [PATTERN]...'))
4265 _('[OPTION]... [PATTERN]...'))
4265 def locate(ui, repo, *pats, **opts):
4266 def locate(ui, repo, *pats, **opts):
4266 """locate files matching specific patterns (DEPRECATED)
4267 """locate files matching specific patterns (DEPRECATED)
4267
4268
4268 Print files under Mercurial control in the working directory whose
4269 Print files under Mercurial control in the working directory whose
4269 names match the given patterns.
4270 names match the given patterns.
4270
4271
4271 By default, this command searches all directories in the working
4272 By default, this command searches all directories in the working
4272 directory. To search just the current directory and its
4273 directory. To search just the current directory and its
4273 subdirectories, use "--include .".
4274 subdirectories, use "--include .".
4274
4275
4275 If no patterns are given to match, this command prints the names
4276 If no patterns are given to match, this command prints the names
4276 of all files under Mercurial control in the working directory.
4277 of all files under Mercurial control in the working directory.
4277
4278
4278 If you want to feed the output of this command into the "xargs"
4279 If you want to feed the output of this command into the "xargs"
4279 command, use the -0 option to both this command and "xargs". This
4280 command, use the -0 option to both this command and "xargs". This
4280 will avoid the problem of "xargs" treating single filenames that
4281 will avoid the problem of "xargs" treating single filenames that
4281 contain whitespace as multiple filenames.
4282 contain whitespace as multiple filenames.
4282
4283
4283 See :hg:`help files` for a more versatile command.
4284 See :hg:`help files` for a more versatile command.
4284
4285
4285 Returns 0 if a match is found, 1 otherwise.
4286 Returns 0 if a match is found, 1 otherwise.
4286 """
4287 """
4287 end = opts.get('print0') and '\0' or '\n'
4288 end = opts.get('print0') and '\0' or '\n'
4288 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
4289 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
4289
4290
4290 ret = 1
4291 ret = 1
4291 ctx = repo[rev]
4292 ctx = repo[rev]
4292 m = scmutil.match(ctx, pats, opts, default='relglob')
4293 m = scmutil.match(ctx, pats, opts, default='relglob')
4293 m.bad = lambda x, y: False
4294 m.bad = lambda x, y: False
4294
4295
4295 for abs in ctx.matches(m):
4296 for abs in ctx.matches(m):
4296 if opts.get('fullpath'):
4297 if opts.get('fullpath'):
4297 ui.write(repo.wjoin(abs), end)
4298 ui.write(repo.wjoin(abs), end)
4298 else:
4299 else:
4299 ui.write(((pats and m.rel(abs)) or abs), end)
4300 ui.write(((pats and m.rel(abs)) or abs), end)
4300 ret = 0
4301 ret = 0
4301
4302
4302 return ret
4303 return ret
4303
4304
4304 @command('^log|history',
4305 @command('^log|history',
4305 [('f', 'follow', None,
4306 [('f', 'follow', None,
4306 _('follow changeset history, or file history across copies and renames')),
4307 _('follow changeset history, or file history across copies and renames')),
4307 ('', 'follow-first', None,
4308 ('', 'follow-first', None,
4308 _('only follow the first parent of merge changesets (DEPRECATED)')),
4309 _('only follow the first parent of merge changesets (DEPRECATED)')),
4309 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
4310 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
4310 ('C', 'copies', None, _('show copied files')),
4311 ('C', 'copies', None, _('show copied files')),
4311 ('k', 'keyword', [],
4312 ('k', 'keyword', [],
4312 _('do case-insensitive search for a given text'), _('TEXT')),
4313 _('do case-insensitive search for a given text'), _('TEXT')),
4313 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
4314 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
4314 ('', 'removed', None, _('include revisions where files were removed')),
4315 ('', 'removed', None, _('include revisions where files were removed')),
4315 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
4316 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
4316 ('u', 'user', [], _('revisions committed by user'), _('USER')),
4317 ('u', 'user', [], _('revisions committed by user'), _('USER')),
4317 ('', 'only-branch', [],
4318 ('', 'only-branch', [],
4318 _('show only changesets within the given named branch (DEPRECATED)'),
4319 _('show only changesets within the given named branch (DEPRECATED)'),
4319 _('BRANCH')),
4320 _('BRANCH')),
4320 ('b', 'branch', [],
4321 ('b', 'branch', [],
4321 _('show changesets within the given named branch'), _('BRANCH')),
4322 _('show changesets within the given named branch'), _('BRANCH')),
4322 ('P', 'prune', [],
4323 ('P', 'prune', [],
4323 _('do not display revision or any of its ancestors'), _('REV')),
4324 _('do not display revision or any of its ancestors'), _('REV')),
4324 ] + logopts + walkopts,
4325 ] + logopts + walkopts,
4325 _('[OPTION]... [FILE]'),
4326 _('[OPTION]... [FILE]'),
4326 inferrepo=True)
4327 inferrepo=True)
4327 def log(ui, repo, *pats, **opts):
4328 def log(ui, repo, *pats, **opts):
4328 """show revision history of entire repository or files
4329 """show revision history of entire repository or files
4329
4330
4330 Print the revision history of the specified files or the entire
4331 Print the revision history of the specified files or the entire
4331 project.
4332 project.
4332
4333
4333 If no revision range is specified, the default is ``tip:0`` unless
4334 If no revision range is specified, the default is ``tip:0`` unless
4334 --follow is set, in which case the working directory parent is
4335 --follow is set, in which case the working directory parent is
4335 used as the starting revision.
4336 used as the starting revision.
4336
4337
4337 File history is shown without following rename or copy history of
4338 File history is shown without following rename or copy history of
4338 files. Use -f/--follow with a filename to follow history across
4339 files. Use -f/--follow with a filename to follow history across
4339 renames and copies. --follow without a filename will only show
4340 renames and copies. --follow without a filename will only show
4340 ancestors or descendants of the starting revision.
4341 ancestors or descendants of the starting revision.
4341
4342
4342 By default this command prints revision number and changeset id,
4343 By default this command prints revision number and changeset id,
4343 tags, non-trivial parents, user, date and time, and a summary for
4344 tags, non-trivial parents, user, date and time, and a summary for
4344 each commit. When the -v/--verbose switch is used, the list of
4345 each commit. When the -v/--verbose switch is used, the list of
4345 changed files and full commit message are shown.
4346 changed files and full commit message are shown.
4346
4347
4347 With --graph the revisions are shown as an ASCII art DAG with the most
4348 With --graph the revisions are shown as an ASCII art DAG with the most
4348 recent changeset at the top.
4349 recent changeset at the top.
4349 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
4350 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
4350 and '+' represents a fork where the changeset from the lines below is a
4351 and '+' represents a fork where the changeset from the lines below is a
4351 parent of the 'o' merge on the same line.
4352 parent of the 'o' merge on the same line.
4352
4353
4353 .. note::
4354 .. note::
4354
4355
4355 log -p/--patch may generate unexpected diff output for merge
4356 log -p/--patch may generate unexpected diff output for merge
4356 changesets, as it will only compare the merge changeset against
4357 changesets, as it will only compare the merge changeset against
4357 its first parent. Also, only files different from BOTH parents
4358 its first parent. Also, only files different from BOTH parents
4358 will appear in files:.
4359 will appear in files:.
4359
4360
4360 .. note::
4361 .. note::
4361
4362
4362 for performance reasons, log FILE may omit duplicate changes
4363 for performance reasons, log FILE may omit duplicate changes
4363 made on branches and will not show removals or mode changes. To
4364 made on branches and will not show removals or mode changes. To
4364 see all such changes, use the --removed switch.
4365 see all such changes, use the --removed switch.
4365
4366
4366 .. container:: verbose
4367 .. container:: verbose
4367
4368
4368 Some examples:
4369 Some examples:
4369
4370
4370 - changesets with full descriptions and file lists::
4371 - changesets with full descriptions and file lists::
4371
4372
4372 hg log -v
4373 hg log -v
4373
4374
4374 - changesets ancestral to the working directory::
4375 - changesets ancestral to the working directory::
4375
4376
4376 hg log -f
4377 hg log -f
4377
4378
4378 - last 10 commits on the current branch::
4379 - last 10 commits on the current branch::
4379
4380
4380 hg log -l 10 -b .
4381 hg log -l 10 -b .
4381
4382
4382 - changesets showing all modifications of a file, including removals::
4383 - changesets showing all modifications of a file, including removals::
4383
4384
4384 hg log --removed file.c
4385 hg log --removed file.c
4385
4386
4386 - all changesets that touch a directory, with diffs, excluding merges::
4387 - all changesets that touch a directory, with diffs, excluding merges::
4387
4388
4388 hg log -Mp lib/
4389 hg log -Mp lib/
4389
4390
4390 - all revision numbers that match a keyword::
4391 - all revision numbers that match a keyword::
4391
4392
4392 hg log -k bug --template "{rev}\\n"
4393 hg log -k bug --template "{rev}\\n"
4393
4394
4394 - list available log templates::
4395 - list available log templates::
4395
4396
4396 hg log -T list
4397 hg log -T list
4397
4398
4398 - check if a given changeset is included in a tagged release::
4399 - check if a given changeset is included in a tagged release::
4399
4400
4400 hg log -r "a21ccf and ancestor(1.9)"
4401 hg log -r "a21ccf and ancestor(1.9)"
4401
4402
4402 - find all changesets by some user in a date range::
4403 - find all changesets by some user in a date range::
4403
4404
4404 hg log -k alice -d "may 2008 to jul 2008"
4405 hg log -k alice -d "may 2008 to jul 2008"
4405
4406
4406 - summary of all changesets after the last tag::
4407 - summary of all changesets after the last tag::
4407
4408
4408 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4409 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4409
4410
4410 See :hg:`help dates` for a list of formats valid for -d/--date.
4411 See :hg:`help dates` for a list of formats valid for -d/--date.
4411
4412
4412 See :hg:`help revisions` and :hg:`help revsets` for more about
4413 See :hg:`help revisions` and :hg:`help revsets` for more about
4413 specifying revisions.
4414 specifying revisions.
4414
4415
4415 See :hg:`help templates` for more about pre-packaged styles and
4416 See :hg:`help templates` for more about pre-packaged styles and
4416 specifying custom templates.
4417 specifying custom templates.
4417
4418
4418 Returns 0 on success.
4419 Returns 0 on success.
4419
4420
4420 """
4421 """
4421 if opts.get('graph'):
4422 if opts.get('graph'):
4422 return cmdutil.graphlog(ui, repo, *pats, **opts)
4423 return cmdutil.graphlog(ui, repo, *pats, **opts)
4423
4424
4424 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
4425 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
4425 limit = cmdutil.loglimit(opts)
4426 limit = cmdutil.loglimit(opts)
4426 count = 0
4427 count = 0
4427
4428
4428 getrenamed = None
4429 getrenamed = None
4429 if opts.get('copies'):
4430 if opts.get('copies'):
4430 endrev = None
4431 endrev = None
4431 if opts.get('rev'):
4432 if opts.get('rev'):
4432 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
4433 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
4433 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
4434 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
4434
4435
4435 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4436 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4436 for rev in revs:
4437 for rev in revs:
4437 if count == limit:
4438 if count == limit:
4438 break
4439 break
4439 ctx = repo[rev]
4440 ctx = repo[rev]
4440 copies = None
4441 copies = None
4441 if getrenamed is not None and rev:
4442 if getrenamed is not None and rev:
4442 copies = []
4443 copies = []
4443 for fn in ctx.files():
4444 for fn in ctx.files():
4444 rename = getrenamed(fn, rev)
4445 rename = getrenamed(fn, rev)
4445 if rename:
4446 if rename:
4446 copies.append((fn, rename[0]))
4447 copies.append((fn, rename[0]))
4447 revmatchfn = filematcher and filematcher(ctx.rev()) or None
4448 revmatchfn = filematcher and filematcher(ctx.rev()) or None
4448 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4449 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4449 if displayer.flush(rev):
4450 if displayer.flush(rev):
4450 count += 1
4451 count += 1
4451
4452
4452 displayer.close()
4453 displayer.close()
4453
4454
4454 @command('manifest',
4455 @command('manifest',
4455 [('r', 'rev', '', _('revision to display'), _('REV')),
4456 [('r', 'rev', '', _('revision to display'), _('REV')),
4456 ('', 'all', False, _("list files from all revisions"))]
4457 ('', 'all', False, _("list files from all revisions"))]
4457 + formatteropts,
4458 + formatteropts,
4458 _('[-r REV]'))
4459 _('[-r REV]'))
4459 def manifest(ui, repo, node=None, rev=None, **opts):
4460 def manifest(ui, repo, node=None, rev=None, **opts):
4460 """output the current or given revision of the project manifest
4461 """output the current or given revision of the project manifest
4461
4462
4462 Print a list of version controlled files for the given revision.
4463 Print a list of version controlled files for the given revision.
4463 If no revision is given, the first parent of the working directory
4464 If no revision is given, the first parent of the working directory
4464 is used, or the null revision if no revision is checked out.
4465 is used, or the null revision if no revision is checked out.
4465
4466
4466 With -v, print file permissions, symlink and executable bits.
4467 With -v, print file permissions, symlink and executable bits.
4467 With --debug, print file revision hashes.
4468 With --debug, print file revision hashes.
4468
4469
4469 If option --all is specified, the list of all files from all revisions
4470 If option --all is specified, the list of all files from all revisions
4470 is printed. This includes deleted and renamed files.
4471 is printed. This includes deleted and renamed files.
4471
4472
4472 Returns 0 on success.
4473 Returns 0 on success.
4473 """
4474 """
4474
4475
4475 fm = ui.formatter('manifest', opts)
4476 fm = ui.formatter('manifest', opts)
4476
4477
4477 if opts.get('all'):
4478 if opts.get('all'):
4478 if rev or node:
4479 if rev or node:
4479 raise util.Abort(_("can't specify a revision with --all"))
4480 raise util.Abort(_("can't specify a revision with --all"))
4480
4481
4481 res = []
4482 res = []
4482 prefix = "data/"
4483 prefix = "data/"
4483 suffix = ".i"
4484 suffix = ".i"
4484 plen = len(prefix)
4485 plen = len(prefix)
4485 slen = len(suffix)
4486 slen = len(suffix)
4486 lock = repo.lock()
4487 lock = repo.lock()
4487 try:
4488 try:
4488 for fn, b, size in repo.store.datafiles():
4489 for fn, b, size in repo.store.datafiles():
4489 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
4490 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
4490 res.append(fn[plen:-slen])
4491 res.append(fn[plen:-slen])
4491 finally:
4492 finally:
4492 lock.release()
4493 lock.release()
4493 for f in res:
4494 for f in res:
4494 fm.startitem()
4495 fm.startitem()
4495 fm.write("path", '%s\n', f)
4496 fm.write("path", '%s\n', f)
4496 fm.end()
4497 fm.end()
4497 return
4498 return
4498
4499
4499 if rev and node:
4500 if rev and node:
4500 raise util.Abort(_("please specify just one revision"))
4501 raise util.Abort(_("please specify just one revision"))
4501
4502
4502 if not node:
4503 if not node:
4503 node = rev
4504 node = rev
4504
4505
4505 char = {'l': '@', 'x': '*', '': ''}
4506 char = {'l': '@', 'x': '*', '': ''}
4506 mode = {'l': '644', 'x': '755', '': '644'}
4507 mode = {'l': '644', 'x': '755', '': '644'}
4507 ctx = scmutil.revsingle(repo, node)
4508 ctx = scmutil.revsingle(repo, node)
4508 mf = ctx.manifest()
4509 mf = ctx.manifest()
4509 for f in ctx:
4510 for f in ctx:
4510 fm.startitem()
4511 fm.startitem()
4511 fl = ctx[f].flags()
4512 fl = ctx[f].flags()
4512 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
4513 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
4513 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
4514 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
4514 fm.write('path', '%s\n', f)
4515 fm.write('path', '%s\n', f)
4515 fm.end()
4516 fm.end()
4516
4517
4517 @command('^merge',
4518 @command('^merge',
4518 [('f', 'force', None,
4519 [('f', 'force', None,
4519 _('force a merge including outstanding changes (DEPRECATED)')),
4520 _('force a merge including outstanding changes (DEPRECATED)')),
4520 ('r', 'rev', '', _('revision to merge'), _('REV')),
4521 ('r', 'rev', '', _('revision to merge'), _('REV')),
4521 ('P', 'preview', None,
4522 ('P', 'preview', None,
4522 _('review revisions to merge (no merge is performed)'))
4523 _('review revisions to merge (no merge is performed)'))
4523 ] + mergetoolopts,
4524 ] + mergetoolopts,
4524 _('[-P] [-f] [[-r] REV]'))
4525 _('[-P] [-f] [[-r] REV]'))
4525 def merge(ui, repo, node=None, **opts):
4526 def merge(ui, repo, node=None, **opts):
4526 """merge working directory with another revision
4527 """merge working directory with another revision
4527
4528
4528 The current working directory is updated with all changes made in
4529 The current working directory is updated with all changes made in
4529 the requested revision since the last common predecessor revision.
4530 the requested revision since the last common predecessor revision.
4530
4531
4531 Files that changed between either parent are marked as changed for
4532 Files that changed between either parent are marked as changed for
4532 the next commit and a commit must be performed before any further
4533 the next commit and a commit must be performed before any further
4533 updates to the repository are allowed. The next commit will have
4534 updates to the repository are allowed. The next commit will have
4534 two parents.
4535 two parents.
4535
4536
4536 ``--tool`` can be used to specify the merge tool used for file
4537 ``--tool`` can be used to specify the merge tool used for file
4537 merges. It overrides the HGMERGE environment variable and your
4538 merges. It overrides the HGMERGE environment variable and your
4538 configuration files. See :hg:`help merge-tools` for options.
4539 configuration files. See :hg:`help merge-tools` for options.
4539
4540
4540 If no revision is specified, the working directory's parent is a
4541 If no revision is specified, the working directory's parent is a
4541 head revision, and the current branch contains exactly one other
4542 head revision, and the current branch contains exactly one other
4542 head, the other head is merged with by default. Otherwise, an
4543 head, the other head is merged with by default. Otherwise, an
4543 explicit revision with which to merge with must be provided.
4544 explicit revision with which to merge with must be provided.
4544
4545
4545 :hg:`resolve` must be used to resolve unresolved files.
4546 :hg:`resolve` must be used to resolve unresolved files.
4546
4547
4547 To undo an uncommitted merge, use :hg:`update --clean .` which
4548 To undo an uncommitted merge, use :hg:`update --clean .` which
4548 will check out a clean copy of the original merge parent, losing
4549 will check out a clean copy of the original merge parent, losing
4549 all changes.
4550 all changes.
4550
4551
4551 Returns 0 on success, 1 if there are unresolved files.
4552 Returns 0 on success, 1 if there are unresolved files.
4552 """
4553 """
4553
4554
4554 if opts.get('rev') and node:
4555 if opts.get('rev') and node:
4555 raise util.Abort(_("please specify just one revision"))
4556 raise util.Abort(_("please specify just one revision"))
4556 if not node:
4557 if not node:
4557 node = opts.get('rev')
4558 node = opts.get('rev')
4558
4559
4559 if node:
4560 if node:
4560 node = scmutil.revsingle(repo, node).node()
4561 node = scmutil.revsingle(repo, node).node()
4561
4562
4562 if not node and repo._bookmarkcurrent:
4563 if not node and repo._bookmarkcurrent:
4563 bmheads = repo.bookmarkheads(repo._bookmarkcurrent)
4564 bmheads = repo.bookmarkheads(repo._bookmarkcurrent)
4564 curhead = repo[repo._bookmarkcurrent].node()
4565 curhead = repo[repo._bookmarkcurrent].node()
4565 if len(bmheads) == 2:
4566 if len(bmheads) == 2:
4566 if curhead == bmheads[0]:
4567 if curhead == bmheads[0]:
4567 node = bmheads[1]
4568 node = bmheads[1]
4568 else:
4569 else:
4569 node = bmheads[0]
4570 node = bmheads[0]
4570 elif len(bmheads) > 2:
4571 elif len(bmheads) > 2:
4571 raise util.Abort(_("multiple matching bookmarks to merge - "
4572 raise util.Abort(_("multiple matching bookmarks to merge - "
4572 "please merge with an explicit rev or bookmark"),
4573 "please merge with an explicit rev or bookmark"),
4573 hint=_("run 'hg heads' to see all heads"))
4574 hint=_("run 'hg heads' to see all heads"))
4574 elif len(bmheads) <= 1:
4575 elif len(bmheads) <= 1:
4575 raise util.Abort(_("no matching bookmark to merge - "
4576 raise util.Abort(_("no matching bookmark to merge - "
4576 "please merge with an explicit rev or bookmark"),
4577 "please merge with an explicit rev or bookmark"),
4577 hint=_("run 'hg heads' to see all heads"))
4578 hint=_("run 'hg heads' to see all heads"))
4578
4579
4579 if not node and not repo._bookmarkcurrent:
4580 if not node and not repo._bookmarkcurrent:
4580 branch = repo[None].branch()
4581 branch = repo[None].branch()
4581 bheads = repo.branchheads(branch)
4582 bheads = repo.branchheads(branch)
4582 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
4583 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
4583
4584
4584 if len(nbhs) > 2:
4585 if len(nbhs) > 2:
4585 raise util.Abort(_("branch '%s' has %d heads - "
4586 raise util.Abort(_("branch '%s' has %d heads - "
4586 "please merge with an explicit rev")
4587 "please merge with an explicit rev")
4587 % (branch, len(bheads)),
4588 % (branch, len(bheads)),
4588 hint=_("run 'hg heads .' to see heads"))
4589 hint=_("run 'hg heads .' to see heads"))
4589
4590
4590 parent = repo.dirstate.p1()
4591 parent = repo.dirstate.p1()
4591 if len(nbhs) <= 1:
4592 if len(nbhs) <= 1:
4592 if len(bheads) > 1:
4593 if len(bheads) > 1:
4593 raise util.Abort(_("heads are bookmarked - "
4594 raise util.Abort(_("heads are bookmarked - "
4594 "please merge with an explicit rev"),
4595 "please merge with an explicit rev"),
4595 hint=_("run 'hg heads' to see all heads"))
4596 hint=_("run 'hg heads' to see all heads"))
4596 if len(repo.heads()) > 1:
4597 if len(repo.heads()) > 1:
4597 raise util.Abort(_("branch '%s' has one head - "
4598 raise util.Abort(_("branch '%s' has one head - "
4598 "please merge with an explicit rev")
4599 "please merge with an explicit rev")
4599 % branch,
4600 % branch,
4600 hint=_("run 'hg heads' to see all heads"))
4601 hint=_("run 'hg heads' to see all heads"))
4601 msg, hint = _('nothing to merge'), None
4602 msg, hint = _('nothing to merge'), None
4602 if parent != repo.lookup(branch):
4603 if parent != repo.lookup(branch):
4603 hint = _("use 'hg update' instead")
4604 hint = _("use 'hg update' instead")
4604 raise util.Abort(msg, hint=hint)
4605 raise util.Abort(msg, hint=hint)
4605
4606
4606 if parent not in bheads:
4607 if parent not in bheads:
4607 raise util.Abort(_('working directory not at a head revision'),
4608 raise util.Abort(_('working directory not at a head revision'),
4608 hint=_("use 'hg update' or merge with an "
4609 hint=_("use 'hg update' or merge with an "
4609 "explicit revision"))
4610 "explicit revision"))
4610 if parent == nbhs[0]:
4611 if parent == nbhs[0]:
4611 node = nbhs[-1]
4612 node = nbhs[-1]
4612 else:
4613 else:
4613 node = nbhs[0]
4614 node = nbhs[0]
4614
4615
4615 if opts.get('preview'):
4616 if opts.get('preview'):
4616 # find nodes that are ancestors of p2 but not of p1
4617 # find nodes that are ancestors of p2 but not of p1
4617 p1 = repo.lookup('.')
4618 p1 = repo.lookup('.')
4618 p2 = repo.lookup(node)
4619 p2 = repo.lookup(node)
4619 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4620 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4620
4621
4621 displayer = cmdutil.show_changeset(ui, repo, opts)
4622 displayer = cmdutil.show_changeset(ui, repo, opts)
4622 for node in nodes:
4623 for node in nodes:
4623 displayer.show(repo[node])
4624 displayer.show(repo[node])
4624 displayer.close()
4625 displayer.close()
4625 return 0
4626 return 0
4626
4627
4627 try:
4628 try:
4628 # ui.forcemerge is an internal variable, do not document
4629 # ui.forcemerge is an internal variable, do not document
4629 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
4630 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
4630 return hg.merge(repo, node, force=opts.get('force'))
4631 return hg.merge(repo, node, force=opts.get('force'))
4631 finally:
4632 finally:
4632 ui.setconfig('ui', 'forcemerge', '', 'merge')
4633 ui.setconfig('ui', 'forcemerge', '', 'merge')
4633
4634
4634 @command('outgoing|out',
4635 @command('outgoing|out',
4635 [('f', 'force', None, _('run even when the destination is unrelated')),
4636 [('f', 'force', None, _('run even when the destination is unrelated')),
4636 ('r', 'rev', [],
4637 ('r', 'rev', [],
4637 _('a changeset intended to be included in the destination'), _('REV')),
4638 _('a changeset intended to be included in the destination'), _('REV')),
4638 ('n', 'newest-first', None, _('show newest record first')),
4639 ('n', 'newest-first', None, _('show newest record first')),
4639 ('B', 'bookmarks', False, _('compare bookmarks')),
4640 ('B', 'bookmarks', False, _('compare bookmarks')),
4640 ('b', 'branch', [], _('a specific branch you would like to push'),
4641 ('b', 'branch', [], _('a specific branch you would like to push'),
4641 _('BRANCH')),
4642 _('BRANCH')),
4642 ] + logopts + remoteopts + subrepoopts,
4643 ] + logopts + remoteopts + subrepoopts,
4643 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
4644 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
4644 def outgoing(ui, repo, dest=None, **opts):
4645 def outgoing(ui, repo, dest=None, **opts):
4645 """show changesets not found in the destination
4646 """show changesets not found in the destination
4646
4647
4647 Show changesets not found in the specified destination repository
4648 Show changesets not found in the specified destination repository
4648 or the default push location. These are the changesets that would
4649 or the default push location. These are the changesets that would
4649 be pushed if a push was requested.
4650 be pushed if a push was requested.
4650
4651
4651 See pull for details of valid destination formats.
4652 See pull for details of valid destination formats.
4652
4653
4653 Returns 0 if there are outgoing changes, 1 otherwise.
4654 Returns 0 if there are outgoing changes, 1 otherwise.
4654 """
4655 """
4655 if opts.get('graph'):
4656 if opts.get('graph'):
4656 cmdutil.checkunsupportedgraphflags([], opts)
4657 cmdutil.checkunsupportedgraphflags([], opts)
4657 o, other = hg._outgoing(ui, repo, dest, opts)
4658 o, other = hg._outgoing(ui, repo, dest, opts)
4658 if not o:
4659 if not o:
4659 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4660 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4660 return
4661 return
4661
4662
4662 revdag = cmdutil.graphrevs(repo, o, opts)
4663 revdag = cmdutil.graphrevs(repo, o, opts)
4663 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4664 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4664 showparents = [ctx.node() for ctx in repo[None].parents()]
4665 showparents = [ctx.node() for ctx in repo[None].parents()]
4665 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4666 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4666 graphmod.asciiedges)
4667 graphmod.asciiedges)
4667 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4668 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4668 return 0
4669 return 0
4669
4670
4670 if opts.get('bookmarks'):
4671 if opts.get('bookmarks'):
4671 dest = ui.expandpath(dest or 'default-push', dest or 'default')
4672 dest = ui.expandpath(dest or 'default-push', dest or 'default')
4672 dest, branches = hg.parseurl(dest, opts.get('branch'))
4673 dest, branches = hg.parseurl(dest, opts.get('branch'))
4673 other = hg.peer(repo, opts, dest)
4674 other = hg.peer(repo, opts, dest)
4674 if 'bookmarks' not in other.listkeys('namespaces'):
4675 if 'bookmarks' not in other.listkeys('namespaces'):
4675 ui.warn(_("remote doesn't support bookmarks\n"))
4676 ui.warn(_("remote doesn't support bookmarks\n"))
4676 return 0
4677 return 0
4677 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
4678 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
4678 return bookmarks.diff(ui, other, repo)
4679 return bookmarks.diff(ui, other, repo)
4679
4680
4680 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
4681 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
4681 try:
4682 try:
4682 return hg.outgoing(ui, repo, dest, opts)
4683 return hg.outgoing(ui, repo, dest, opts)
4683 finally:
4684 finally:
4684 del repo._subtoppath
4685 del repo._subtoppath
4685
4686
4686 @command('parents',
4687 @command('parents',
4687 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
4688 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
4688 ] + templateopts,
4689 ] + templateopts,
4689 _('[-r REV] [FILE]'),
4690 _('[-r REV] [FILE]'),
4690 inferrepo=True)
4691 inferrepo=True)
4691 def parents(ui, repo, file_=None, **opts):
4692 def parents(ui, repo, file_=None, **opts):
4692 """show the parents of the working directory or revision (DEPRECATED)
4693 """show the parents of the working directory or revision (DEPRECATED)
4693
4694
4694 Print the working directory's parent revisions. If a revision is
4695 Print the working directory's parent revisions. If a revision is
4695 given via -r/--rev, the parent of that revision will be printed.
4696 given via -r/--rev, the parent of that revision will be printed.
4696 If a file argument is given, the revision in which the file was
4697 If a file argument is given, the revision in which the file was
4697 last changed (before the working directory revision or the
4698 last changed (before the working directory revision or the
4698 argument to --rev if given) is printed.
4699 argument to --rev if given) is printed.
4699
4700
4700 See :hg:`summary` and :hg:`help revsets` for related information.
4701 See :hg:`summary` and :hg:`help revsets` for related information.
4701
4702
4702 Returns 0 on success.
4703 Returns 0 on success.
4703 """
4704 """
4704
4705
4705 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
4706 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
4706
4707
4707 if file_:
4708 if file_:
4708 m = scmutil.match(ctx, (file_,), opts)
4709 m = scmutil.match(ctx, (file_,), opts)
4709 if m.anypats() or len(m.files()) != 1:
4710 if m.anypats() or len(m.files()) != 1:
4710 raise util.Abort(_('can only specify an explicit filename'))
4711 raise util.Abort(_('can only specify an explicit filename'))
4711 file_ = m.files()[0]
4712 file_ = m.files()[0]
4712 filenodes = []
4713 filenodes = []
4713 for cp in ctx.parents():
4714 for cp in ctx.parents():
4714 if not cp:
4715 if not cp:
4715 continue
4716 continue
4716 try:
4717 try:
4717 filenodes.append(cp.filenode(file_))
4718 filenodes.append(cp.filenode(file_))
4718 except error.LookupError:
4719 except error.LookupError:
4719 pass
4720 pass
4720 if not filenodes:
4721 if not filenodes:
4721 raise util.Abort(_("'%s' not found in manifest!") % file_)
4722 raise util.Abort(_("'%s' not found in manifest!") % file_)
4722 p = []
4723 p = []
4723 for fn in filenodes:
4724 for fn in filenodes:
4724 fctx = repo.filectx(file_, fileid=fn)
4725 fctx = repo.filectx(file_, fileid=fn)
4725 p.append(fctx.node())
4726 p.append(fctx.node())
4726 else:
4727 else:
4727 p = [cp.node() for cp in ctx.parents()]
4728 p = [cp.node() for cp in ctx.parents()]
4728
4729
4729 displayer = cmdutil.show_changeset(ui, repo, opts)
4730 displayer = cmdutil.show_changeset(ui, repo, opts)
4730 for n in p:
4731 for n in p:
4731 if n != nullid:
4732 if n != nullid:
4732 displayer.show(repo[n])
4733 displayer.show(repo[n])
4733 displayer.close()
4734 displayer.close()
4734
4735
4735 @command('paths', [], _('[NAME]'), optionalrepo=True)
4736 @command('paths', [], _('[NAME]'), optionalrepo=True)
4736 def paths(ui, repo, search=None):
4737 def paths(ui, repo, search=None):
4737 """show aliases for remote repositories
4738 """show aliases for remote repositories
4738
4739
4739 Show definition of symbolic path name NAME. If no name is given,
4740 Show definition of symbolic path name NAME. If no name is given,
4740 show definition of all available names.
4741 show definition of all available names.
4741
4742
4742 Option -q/--quiet suppresses all output when searching for NAME
4743 Option -q/--quiet suppresses all output when searching for NAME
4743 and shows only the path names when listing all definitions.
4744 and shows only the path names when listing all definitions.
4744
4745
4745 Path names are defined in the [paths] section of your
4746 Path names are defined in the [paths] section of your
4746 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
4747 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
4747 repository, ``.hg/hgrc`` is used, too.
4748 repository, ``.hg/hgrc`` is used, too.
4748
4749
4749 The path names ``default`` and ``default-push`` have a special
4750 The path names ``default`` and ``default-push`` have a special
4750 meaning. When performing a push or pull operation, they are used
4751 meaning. When performing a push or pull operation, they are used
4751 as fallbacks if no location is specified on the command-line.
4752 as fallbacks if no location is specified on the command-line.
4752 When ``default-push`` is set, it will be used for push and
4753 When ``default-push`` is set, it will be used for push and
4753 ``default`` will be used for pull; otherwise ``default`` is used
4754 ``default`` will be used for pull; otherwise ``default`` is used
4754 as the fallback for both. When cloning a repository, the clone
4755 as the fallback for both. When cloning a repository, the clone
4755 source is written as ``default`` in ``.hg/hgrc``. Note that
4756 source is written as ``default`` in ``.hg/hgrc``. Note that
4756 ``default`` and ``default-push`` apply to all inbound (e.g.
4757 ``default`` and ``default-push`` apply to all inbound (e.g.
4757 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
4758 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
4758 :hg:`bundle`) operations.
4759 :hg:`bundle`) operations.
4759
4760
4760 See :hg:`help urls` for more information.
4761 See :hg:`help urls` for more information.
4761
4762
4762 Returns 0 on success.
4763 Returns 0 on success.
4763 """
4764 """
4764 if search:
4765 if search:
4765 for name, path in ui.configitems("paths"):
4766 for name, path in ui.configitems("paths"):
4766 if name == search:
4767 if name == search:
4767 ui.status("%s\n" % util.hidepassword(path))
4768 ui.status("%s\n" % util.hidepassword(path))
4768 return
4769 return
4769 if not ui.quiet:
4770 if not ui.quiet:
4770 ui.warn(_("not found!\n"))
4771 ui.warn(_("not found!\n"))
4771 return 1
4772 return 1
4772 else:
4773 else:
4773 for name, path in ui.configitems("paths"):
4774 for name, path in ui.configitems("paths"):
4774 if ui.quiet:
4775 if ui.quiet:
4775 ui.write("%s\n" % name)
4776 ui.write("%s\n" % name)
4776 else:
4777 else:
4777 ui.write("%s = %s\n" % (name, util.hidepassword(path)))
4778 ui.write("%s = %s\n" % (name, util.hidepassword(path)))
4778
4779
4779 @command('phase',
4780 @command('phase',
4780 [('p', 'public', False, _('set changeset phase to public')),
4781 [('p', 'public', False, _('set changeset phase to public')),
4781 ('d', 'draft', False, _('set changeset phase to draft')),
4782 ('d', 'draft', False, _('set changeset phase to draft')),
4782 ('s', 'secret', False, _('set changeset phase to secret')),
4783 ('s', 'secret', False, _('set changeset phase to secret')),
4783 ('f', 'force', False, _('allow to move boundary backward')),
4784 ('f', 'force', False, _('allow to move boundary backward')),
4784 ('r', 'rev', [], _('target revision'), _('REV')),
4785 ('r', 'rev', [], _('target revision'), _('REV')),
4785 ],
4786 ],
4786 _('[-p|-d|-s] [-f] [-r] REV...'))
4787 _('[-p|-d|-s] [-f] [-r] REV...'))
4787 def phase(ui, repo, *revs, **opts):
4788 def phase(ui, repo, *revs, **opts):
4788 """set or show the current phase name
4789 """set or show the current phase name
4789
4790
4790 With no argument, show the phase name of specified revisions.
4791 With no argument, show the phase name of specified revisions.
4791
4792
4792 With one of -p/--public, -d/--draft or -s/--secret, change the
4793 With one of -p/--public, -d/--draft or -s/--secret, change the
4793 phase value of the specified revisions.
4794 phase value of the specified revisions.
4794
4795
4795 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
4796 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
4796 lower phase to an higher phase. Phases are ordered as follows::
4797 lower phase to an higher phase. Phases are ordered as follows::
4797
4798
4798 public < draft < secret
4799 public < draft < secret
4799
4800
4800 Returns 0 on success, 1 if no phases were changed or some could not
4801 Returns 0 on success, 1 if no phases were changed or some could not
4801 be changed.
4802 be changed.
4802 """
4803 """
4803 # search for a unique phase argument
4804 # search for a unique phase argument
4804 targetphase = None
4805 targetphase = None
4805 for idx, name in enumerate(phases.phasenames):
4806 for idx, name in enumerate(phases.phasenames):
4806 if opts[name]:
4807 if opts[name]:
4807 if targetphase is not None:
4808 if targetphase is not None:
4808 raise util.Abort(_('only one phase can be specified'))
4809 raise util.Abort(_('only one phase can be specified'))
4809 targetphase = idx
4810 targetphase = idx
4810
4811
4811 # look for specified revision
4812 # look for specified revision
4812 revs = list(revs)
4813 revs = list(revs)
4813 revs.extend(opts['rev'])
4814 revs.extend(opts['rev'])
4814 if not revs:
4815 if not revs:
4815 raise util.Abort(_('no revisions specified'))
4816 raise util.Abort(_('no revisions specified'))
4816
4817
4817 revs = scmutil.revrange(repo, revs)
4818 revs = scmutil.revrange(repo, revs)
4818
4819
4819 lock = None
4820 lock = None
4820 ret = 0
4821 ret = 0
4821 if targetphase is None:
4822 if targetphase is None:
4822 # display
4823 # display
4823 for r in revs:
4824 for r in revs:
4824 ctx = repo[r]
4825 ctx = repo[r]
4825 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
4826 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
4826 else:
4827 else:
4827 tr = None
4828 tr = None
4828 lock = repo.lock()
4829 lock = repo.lock()
4829 try:
4830 try:
4830 tr = repo.transaction("phase")
4831 tr = repo.transaction("phase")
4831 # set phase
4832 # set phase
4832 if not revs:
4833 if not revs:
4833 raise util.Abort(_('empty revision set'))
4834 raise util.Abort(_('empty revision set'))
4834 nodes = [repo[r].node() for r in revs]
4835 nodes = [repo[r].node() for r in revs]
4835 # moving revision from public to draft may hide them
4836 # moving revision from public to draft may hide them
4836 # We have to check result on an unfiltered repository
4837 # We have to check result on an unfiltered repository
4837 unfi = repo.unfiltered()
4838 unfi = repo.unfiltered()
4838 getphase = unfi._phasecache.phase
4839 getphase = unfi._phasecache.phase
4839 olddata = [getphase(unfi, r) for r in unfi]
4840 olddata = [getphase(unfi, r) for r in unfi]
4840 phases.advanceboundary(repo, tr, targetphase, nodes)
4841 phases.advanceboundary(repo, tr, targetphase, nodes)
4841 if opts['force']:
4842 if opts['force']:
4842 phases.retractboundary(repo, tr, targetphase, nodes)
4843 phases.retractboundary(repo, tr, targetphase, nodes)
4843 tr.close()
4844 tr.close()
4844 finally:
4845 finally:
4845 if tr is not None:
4846 if tr is not None:
4846 tr.release()
4847 tr.release()
4847 lock.release()
4848 lock.release()
4848 getphase = unfi._phasecache.phase
4849 getphase = unfi._phasecache.phase
4849 newdata = [getphase(unfi, r) for r in unfi]
4850 newdata = [getphase(unfi, r) for r in unfi]
4850 changes = sum(newdata[r] != olddata[r] for r in unfi)
4851 changes = sum(newdata[r] != olddata[r] for r in unfi)
4851 cl = unfi.changelog
4852 cl = unfi.changelog
4852 rejected = [n for n in nodes
4853 rejected = [n for n in nodes
4853 if newdata[cl.rev(n)] < targetphase]
4854 if newdata[cl.rev(n)] < targetphase]
4854 if rejected:
4855 if rejected:
4855 ui.warn(_('cannot move %i changesets to a higher '
4856 ui.warn(_('cannot move %i changesets to a higher '
4856 'phase, use --force\n') % len(rejected))
4857 'phase, use --force\n') % len(rejected))
4857 ret = 1
4858 ret = 1
4858 if changes:
4859 if changes:
4859 msg = _('phase changed for %i changesets\n') % changes
4860 msg = _('phase changed for %i changesets\n') % changes
4860 if ret:
4861 if ret:
4861 ui.status(msg)
4862 ui.status(msg)
4862 else:
4863 else:
4863 ui.note(msg)
4864 ui.note(msg)
4864 else:
4865 else:
4865 ui.warn(_('no phases changed\n'))
4866 ui.warn(_('no phases changed\n'))
4866 ret = 1
4867 ret = 1
4867 return ret
4868 return ret
4868
4869
4869 def postincoming(ui, repo, modheads, optupdate, checkout):
4870 def postincoming(ui, repo, modheads, optupdate, checkout):
4870 if modheads == 0:
4871 if modheads == 0:
4871 return
4872 return
4872 if optupdate:
4873 if optupdate:
4873 checkout, movemarkfrom = bookmarks.calculateupdate(ui, repo, checkout)
4874 checkout, movemarkfrom = bookmarks.calculateupdate(ui, repo, checkout)
4874 try:
4875 try:
4875 ret = hg.update(repo, checkout)
4876 ret = hg.update(repo, checkout)
4876 except util.Abort, inst:
4877 except util.Abort, inst:
4877 ui.warn(_("not updating: %s\n") % str(inst))
4878 ui.warn(_("not updating: %s\n") % str(inst))
4878 if inst.hint:
4879 if inst.hint:
4879 ui.warn(_("(%s)\n") % inst.hint)
4880 ui.warn(_("(%s)\n") % inst.hint)
4880 return 0
4881 return 0
4881 if not ret and not checkout:
4882 if not ret and not checkout:
4882 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
4883 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
4883 ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
4884 ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
4884 return ret
4885 return ret
4885 if modheads > 1:
4886 if modheads > 1:
4886 currentbranchheads = len(repo.branchheads())
4887 currentbranchheads = len(repo.branchheads())
4887 if currentbranchheads == modheads:
4888 if currentbranchheads == modheads:
4888 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
4889 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
4889 elif currentbranchheads > 1:
4890 elif currentbranchheads > 1:
4890 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
4891 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
4891 "merge)\n"))
4892 "merge)\n"))
4892 else:
4893 else:
4893 ui.status(_("(run 'hg heads' to see heads)\n"))
4894 ui.status(_("(run 'hg heads' to see heads)\n"))
4894 else:
4895 else:
4895 ui.status(_("(run 'hg update' to get a working copy)\n"))
4896 ui.status(_("(run 'hg update' to get a working copy)\n"))
4896
4897
4897 @command('^pull',
4898 @command('^pull',
4898 [('u', 'update', None,
4899 [('u', 'update', None,
4899 _('update to new branch head if changesets were pulled')),
4900 _('update to new branch head if changesets were pulled')),
4900 ('f', 'force', None, _('run even when remote repository is unrelated')),
4901 ('f', 'force', None, _('run even when remote repository is unrelated')),
4901 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
4902 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
4902 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
4903 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
4903 ('b', 'branch', [], _('a specific branch you would like to pull'),
4904 ('b', 'branch', [], _('a specific branch you would like to pull'),
4904 _('BRANCH')),
4905 _('BRANCH')),
4905 ] + remoteopts,
4906 ] + remoteopts,
4906 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
4907 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
4907 def pull(ui, repo, source="default", **opts):
4908 def pull(ui, repo, source="default", **opts):
4908 """pull changes from the specified source
4909 """pull changes from the specified source
4909
4910
4910 Pull changes from a remote repository to a local one.
4911 Pull changes from a remote repository to a local one.
4911
4912
4912 This finds all changes from the repository at the specified path
4913 This finds all changes from the repository at the specified path
4913 or URL and adds them to a local repository (the current one unless
4914 or URL and adds them to a local repository (the current one unless
4914 -R is specified). By default, this does not update the copy of the
4915 -R is specified). By default, this does not update the copy of the
4915 project in the working directory.
4916 project in the working directory.
4916
4917
4917 Use :hg:`incoming` if you want to see what would have been added
4918 Use :hg:`incoming` if you want to see what would have been added
4918 by a pull at the time you issued this command. If you then decide
4919 by a pull at the time you issued this command. If you then decide
4919 to add those changes to the repository, you should use :hg:`pull
4920 to add those changes to the repository, you should use :hg:`pull
4920 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
4921 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
4921
4922
4922 If SOURCE is omitted, the 'default' path will be used.
4923 If SOURCE is omitted, the 'default' path will be used.
4923 See :hg:`help urls` for more information.
4924 See :hg:`help urls` for more information.
4924
4925
4925 Returns 0 on success, 1 if an update had unresolved files.
4926 Returns 0 on success, 1 if an update had unresolved files.
4926 """
4927 """
4927 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
4928 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
4928 other = hg.peer(repo, opts, source)
4929 other = hg.peer(repo, opts, source)
4929 try:
4930 try:
4930 ui.status(_('pulling from %s\n') % util.hidepassword(source))
4931 ui.status(_('pulling from %s\n') % util.hidepassword(source))
4931 revs, checkout = hg.addbranchrevs(repo, other, branches,
4932 revs, checkout = hg.addbranchrevs(repo, other, branches,
4932 opts.get('rev'))
4933 opts.get('rev'))
4933
4934
4934 remotebookmarks = other.listkeys('bookmarks')
4935 remotebookmarks = other.listkeys('bookmarks')
4935
4936
4936 if opts.get('bookmark'):
4937 if opts.get('bookmark'):
4937 if not revs:
4938 if not revs:
4938 revs = []
4939 revs = []
4939 for b in opts['bookmark']:
4940 for b in opts['bookmark']:
4940 if b not in remotebookmarks:
4941 if b not in remotebookmarks:
4941 raise util.Abort(_('remote bookmark %s not found!') % b)
4942 raise util.Abort(_('remote bookmark %s not found!') % b)
4942 revs.append(remotebookmarks[b])
4943 revs.append(remotebookmarks[b])
4943
4944
4944 if revs:
4945 if revs:
4945 try:
4946 try:
4946 revs = [other.lookup(rev) for rev in revs]
4947 revs = [other.lookup(rev) for rev in revs]
4947 except error.CapabilityError:
4948 except error.CapabilityError:
4948 err = _("other repository doesn't support revision lookup, "
4949 err = _("other repository doesn't support revision lookup, "
4949 "so a rev cannot be specified.")
4950 "so a rev cannot be specified.")
4950 raise util.Abort(err)
4951 raise util.Abort(err)
4951
4952
4952 modheads = exchange.pull(repo, other, heads=revs,
4953 modheads = exchange.pull(repo, other, heads=revs,
4953 force=opts.get('force'),
4954 force=opts.get('force'),
4954 bookmarks=opts.get('bookmark', ())).cgresult
4955 bookmarks=opts.get('bookmark', ())).cgresult
4955 if checkout:
4956 if checkout:
4956 checkout = str(repo.changelog.rev(other.lookup(checkout)))
4957 checkout = str(repo.changelog.rev(other.lookup(checkout)))
4957 repo._subtoppath = source
4958 repo._subtoppath = source
4958 try:
4959 try:
4959 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
4960 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
4960
4961
4961 finally:
4962 finally:
4962 del repo._subtoppath
4963 del repo._subtoppath
4963
4964
4964 finally:
4965 finally:
4965 other.close()
4966 other.close()
4966 return ret
4967 return ret
4967
4968
4968 @command('^push',
4969 @command('^push',
4969 [('f', 'force', None, _('force push')),
4970 [('f', 'force', None, _('force push')),
4970 ('r', 'rev', [],
4971 ('r', 'rev', [],
4971 _('a changeset intended to be included in the destination'),
4972 _('a changeset intended to be included in the destination'),
4972 _('REV')),
4973 _('REV')),
4973 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
4974 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
4974 ('b', 'branch', [],
4975 ('b', 'branch', [],
4975 _('a specific branch you would like to push'), _('BRANCH')),
4976 _('a specific branch you would like to push'), _('BRANCH')),
4976 ('', 'new-branch', False, _('allow pushing a new branch')),
4977 ('', 'new-branch', False, _('allow pushing a new branch')),
4977 ] + remoteopts,
4978 ] + remoteopts,
4978 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
4979 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
4979 def push(ui, repo, dest=None, **opts):
4980 def push(ui, repo, dest=None, **opts):
4980 """push changes to the specified destination
4981 """push changes to the specified destination
4981
4982
4982 Push changesets from the local repository to the specified
4983 Push changesets from the local repository to the specified
4983 destination.
4984 destination.
4984
4985
4985 This operation is symmetrical to pull: it is identical to a pull
4986 This operation is symmetrical to pull: it is identical to a pull
4986 in the destination repository from the current one.
4987 in the destination repository from the current one.
4987
4988
4988 By default, push will not allow creation of new heads at the
4989 By default, push will not allow creation of new heads at the
4989 destination, since multiple heads would make it unclear which head
4990 destination, since multiple heads would make it unclear which head
4990 to use. In this situation, it is recommended to pull and merge
4991 to use. In this situation, it is recommended to pull and merge
4991 before pushing.
4992 before pushing.
4992
4993
4993 Use --new-branch if you want to allow push to create a new named
4994 Use --new-branch if you want to allow push to create a new named
4994 branch that is not present at the destination. This allows you to
4995 branch that is not present at the destination. This allows you to
4995 only create a new branch without forcing other changes.
4996 only create a new branch without forcing other changes.
4996
4997
4997 .. note::
4998 .. note::
4998
4999
4999 Extra care should be taken with the -f/--force option,
5000 Extra care should be taken with the -f/--force option,
5000 which will push all new heads on all branches, an action which will
5001 which will push all new heads on all branches, an action which will
5001 almost always cause confusion for collaborators.
5002 almost always cause confusion for collaborators.
5002
5003
5003 If -r/--rev is used, the specified revision and all its ancestors
5004 If -r/--rev is used, the specified revision and all its ancestors
5004 will be pushed to the remote repository.
5005 will be pushed to the remote repository.
5005
5006
5006 If -B/--bookmark is used, the specified bookmarked revision, its
5007 If -B/--bookmark is used, the specified bookmarked revision, its
5007 ancestors, and the bookmark will be pushed to the remote
5008 ancestors, and the bookmark will be pushed to the remote
5008 repository.
5009 repository.
5009
5010
5010 Please see :hg:`help urls` for important details about ``ssh://``
5011 Please see :hg:`help urls` for important details about ``ssh://``
5011 URLs. If DESTINATION is omitted, a default path will be used.
5012 URLs. If DESTINATION is omitted, a default path will be used.
5012
5013
5013 Returns 0 if push was successful, 1 if nothing to push.
5014 Returns 0 if push was successful, 1 if nothing to push.
5014 """
5015 """
5015
5016
5016 if opts.get('bookmark'):
5017 if opts.get('bookmark'):
5017 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
5018 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
5018 for b in opts['bookmark']:
5019 for b in opts['bookmark']:
5019 # translate -B options to -r so changesets get pushed
5020 # translate -B options to -r so changesets get pushed
5020 if b in repo._bookmarks:
5021 if b in repo._bookmarks:
5021 opts.setdefault('rev', []).append(b)
5022 opts.setdefault('rev', []).append(b)
5022 else:
5023 else:
5023 # if we try to push a deleted bookmark, translate it to null
5024 # if we try to push a deleted bookmark, translate it to null
5024 # this lets simultaneous -r, -b options continue working
5025 # this lets simultaneous -r, -b options continue working
5025 opts.setdefault('rev', []).append("null")
5026 opts.setdefault('rev', []).append("null")
5026
5027
5027 dest = ui.expandpath(dest or 'default-push', dest or 'default')
5028 dest = ui.expandpath(dest or 'default-push', dest or 'default')
5028 dest, branches = hg.parseurl(dest, opts.get('branch'))
5029 dest, branches = hg.parseurl(dest, opts.get('branch'))
5029 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
5030 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
5030 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
5031 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
5031 try:
5032 try:
5032 other = hg.peer(repo, opts, dest)
5033 other = hg.peer(repo, opts, dest)
5033 except error.RepoError:
5034 except error.RepoError:
5034 if dest == "default-push":
5035 if dest == "default-push":
5035 raise util.Abort(_("default repository not configured!"),
5036 raise util.Abort(_("default repository not configured!"),
5036 hint=_('see the "path" section in "hg help config"'))
5037 hint=_('see the "path" section in "hg help config"'))
5037 else:
5038 else:
5038 raise
5039 raise
5039
5040
5040 if revs:
5041 if revs:
5041 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
5042 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
5042
5043
5043 repo._subtoppath = dest
5044 repo._subtoppath = dest
5044 try:
5045 try:
5045 # push subrepos depth-first for coherent ordering
5046 # push subrepos depth-first for coherent ordering
5046 c = repo['']
5047 c = repo['']
5047 subs = c.substate # only repos that are committed
5048 subs = c.substate # only repos that are committed
5048 for s in sorted(subs):
5049 for s in sorted(subs):
5049 result = c.sub(s).push(opts)
5050 result = c.sub(s).push(opts)
5050 if result == 0:
5051 if result == 0:
5051 return not result
5052 return not result
5052 finally:
5053 finally:
5053 del repo._subtoppath
5054 del repo._subtoppath
5054 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
5055 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
5055 newbranch=opts.get('new_branch'),
5056 newbranch=opts.get('new_branch'),
5056 bookmarks=opts.get('bookmark', ()))
5057 bookmarks=opts.get('bookmark', ()))
5057
5058
5058 result = not pushop.cgresult
5059 result = not pushop.cgresult
5059
5060
5060 if pushop.bkresult is not None:
5061 if pushop.bkresult is not None:
5061 if pushop.bkresult == 2:
5062 if pushop.bkresult == 2:
5062 result = 2
5063 result = 2
5063 elif not result and pushop.bkresult:
5064 elif not result and pushop.bkresult:
5064 result = 2
5065 result = 2
5065
5066
5066 return result
5067 return result
5067
5068
5068 @command('recover', [])
5069 @command('recover', [])
5069 def recover(ui, repo):
5070 def recover(ui, repo):
5070 """roll back an interrupted transaction
5071 """roll back an interrupted transaction
5071
5072
5072 Recover from an interrupted commit or pull.
5073 Recover from an interrupted commit or pull.
5073
5074
5074 This command tries to fix the repository status after an
5075 This command tries to fix the repository status after an
5075 interrupted operation. It should only be necessary when Mercurial
5076 interrupted operation. It should only be necessary when Mercurial
5076 suggests it.
5077 suggests it.
5077
5078
5078 Returns 0 if successful, 1 if nothing to recover or verify fails.
5079 Returns 0 if successful, 1 if nothing to recover or verify fails.
5079 """
5080 """
5080 if repo.recover():
5081 if repo.recover():
5081 return hg.verify(repo)
5082 return hg.verify(repo)
5082 return 1
5083 return 1
5083
5084
5084 @command('^remove|rm',
5085 @command('^remove|rm',
5085 [('A', 'after', None, _('record delete for missing files')),
5086 [('A', 'after', None, _('record delete for missing files')),
5086 ('f', 'force', None,
5087 ('f', 'force', None,
5087 _('remove (and delete) file even if added or modified')),
5088 _('remove (and delete) file even if added or modified')),
5088 ] + walkopts,
5089 ] + walkopts,
5089 _('[OPTION]... FILE...'),
5090 _('[OPTION]... FILE...'),
5090 inferrepo=True)
5091 inferrepo=True)
5091 def remove(ui, repo, *pats, **opts):
5092 def remove(ui, repo, *pats, **opts):
5092 """remove the specified files on the next commit
5093 """remove the specified files on the next commit
5093
5094
5094 Schedule the indicated files for removal from the current branch.
5095 Schedule the indicated files for removal from the current branch.
5095
5096
5096 This command schedules the files to be removed at the next commit.
5097 This command schedules the files to be removed at the next commit.
5097 To undo a remove before that, see :hg:`revert`. To undo added
5098 To undo a remove before that, see :hg:`revert`. To undo added
5098 files, see :hg:`forget`.
5099 files, see :hg:`forget`.
5099
5100
5100 .. container:: verbose
5101 .. container:: verbose
5101
5102
5102 -A/--after can be used to remove only files that have already
5103 -A/--after can be used to remove only files that have already
5103 been deleted, -f/--force can be used to force deletion, and -Af
5104 been deleted, -f/--force can be used to force deletion, and -Af
5104 can be used to remove files from the next revision without
5105 can be used to remove files from the next revision without
5105 deleting them from the working directory.
5106 deleting them from the working directory.
5106
5107
5107 The following table details the behavior of remove for different
5108 The following table details the behavior of remove for different
5108 file states (columns) and option combinations (rows). The file
5109 file states (columns) and option combinations (rows). The file
5109 states are Added [A], Clean [C], Modified [M] and Missing [!]
5110 states are Added [A], Clean [C], Modified [M] and Missing [!]
5110 (as reported by :hg:`status`). The actions are Warn, Remove
5111 (as reported by :hg:`status`). The actions are Warn, Remove
5111 (from branch) and Delete (from disk):
5112 (from branch) and Delete (from disk):
5112
5113
5113 ========= == == == ==
5114 ========= == == == ==
5114 opt/state A C M !
5115 opt/state A C M !
5115 ========= == == == ==
5116 ========= == == == ==
5116 none W RD W R
5117 none W RD W R
5117 -f R RD RD R
5118 -f R RD RD R
5118 -A W W W R
5119 -A W W W R
5119 -Af R R R R
5120 -Af R R R R
5120 ========= == == == ==
5121 ========= == == == ==
5121
5122
5122 Note that remove never deletes files in Added [A] state from the
5123 Note that remove never deletes files in Added [A] state from the
5123 working directory, not even if option --force is specified.
5124 working directory, not even if option --force is specified.
5124
5125
5125 Returns 0 on success, 1 if any warnings encountered.
5126 Returns 0 on success, 1 if any warnings encountered.
5126 """
5127 """
5127
5128
5128 after, force = opts.get('after'), opts.get('force')
5129 after, force = opts.get('after'), opts.get('force')
5129 if not pats and not after:
5130 if not pats and not after:
5130 raise util.Abort(_('no files specified'))
5131 raise util.Abort(_('no files specified'))
5131
5132
5132 m = scmutil.match(repo[None], pats, opts)
5133 m = scmutil.match(repo[None], pats, opts)
5133 return cmdutil.remove(ui, repo, m, after, force)
5134 return cmdutil.remove(ui, repo, m, after, force)
5134
5135
5135 @command('rename|move|mv',
5136 @command('rename|move|mv',
5136 [('A', 'after', None, _('record a rename that has already occurred')),
5137 [('A', 'after', None, _('record a rename that has already occurred')),
5137 ('f', 'force', None, _('forcibly copy over an existing managed file')),
5138 ('f', 'force', None, _('forcibly copy over an existing managed file')),
5138 ] + walkopts + dryrunopts,
5139 ] + walkopts + dryrunopts,
5139 _('[OPTION]... SOURCE... DEST'))
5140 _('[OPTION]... SOURCE... DEST'))
5140 def rename(ui, repo, *pats, **opts):
5141 def rename(ui, repo, *pats, **opts):
5141 """rename files; equivalent of copy + remove
5142 """rename files; equivalent of copy + remove
5142
5143
5143 Mark dest as copies of sources; mark sources for deletion. If dest
5144 Mark dest as copies of sources; mark sources for deletion. If dest
5144 is a directory, copies are put in that directory. If dest is a
5145 is a directory, copies are put in that directory. If dest is a
5145 file, there can only be one source.
5146 file, there can only be one source.
5146
5147
5147 By default, this command copies the contents of files as they
5148 By default, this command copies the contents of files as they
5148 exist in the working directory. If invoked with -A/--after, the
5149 exist in the working directory. If invoked with -A/--after, the
5149 operation is recorded, but no copying is performed.
5150 operation is recorded, but no copying is performed.
5150
5151
5151 This command takes effect at the next commit. To undo a rename
5152 This command takes effect at the next commit. To undo a rename
5152 before that, see :hg:`revert`.
5153 before that, see :hg:`revert`.
5153
5154
5154 Returns 0 on success, 1 if errors are encountered.
5155 Returns 0 on success, 1 if errors are encountered.
5155 """
5156 """
5156 wlock = repo.wlock(False)
5157 wlock = repo.wlock(False)
5157 try:
5158 try:
5158 return cmdutil.copy(ui, repo, pats, opts, rename=True)
5159 return cmdutil.copy(ui, repo, pats, opts, rename=True)
5159 finally:
5160 finally:
5160 wlock.release()
5161 wlock.release()
5161
5162
5162 @command('resolve',
5163 @command('resolve',
5163 [('a', 'all', None, _('select all unresolved files')),
5164 [('a', 'all', None, _('select all unresolved files')),
5164 ('l', 'list', None, _('list state of files needing merge')),
5165 ('l', 'list', None, _('list state of files needing merge')),
5165 ('m', 'mark', None, _('mark files as resolved')),
5166 ('m', 'mark', None, _('mark files as resolved')),
5166 ('u', 'unmark', None, _('mark files as unresolved')),
5167 ('u', 'unmark', None, _('mark files as unresolved')),
5167 ('n', 'no-status', None, _('hide status prefix'))]
5168 ('n', 'no-status', None, _('hide status prefix'))]
5168 + mergetoolopts + walkopts,
5169 + mergetoolopts + walkopts,
5169 _('[OPTION]... [FILE]...'),
5170 _('[OPTION]... [FILE]...'),
5170 inferrepo=True)
5171 inferrepo=True)
5171 def resolve(ui, repo, *pats, **opts):
5172 def resolve(ui, repo, *pats, **opts):
5172 """redo merges or set/view the merge status of files
5173 """redo merges or set/view the merge status of files
5173
5174
5174 Merges with unresolved conflicts are often the result of
5175 Merges with unresolved conflicts are often the result of
5175 non-interactive merging using the ``internal:merge`` configuration
5176 non-interactive merging using the ``internal:merge`` configuration
5176 setting, or a command-line merge tool like ``diff3``. The resolve
5177 setting, or a command-line merge tool like ``diff3``. The resolve
5177 command is used to manage the files involved in a merge, after
5178 command is used to manage the files involved in a merge, after
5178 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
5179 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
5179 working directory must have two parents). See :hg:`help
5180 working directory must have two parents). See :hg:`help
5180 merge-tools` for information on configuring merge tools.
5181 merge-tools` for information on configuring merge tools.
5181
5182
5182 The resolve command can be used in the following ways:
5183 The resolve command can be used in the following ways:
5183
5184
5184 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
5185 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
5185 files, discarding any previous merge attempts. Re-merging is not
5186 files, discarding any previous merge attempts. Re-merging is not
5186 performed for files already marked as resolved. Use ``--all/-a``
5187 performed for files already marked as resolved. Use ``--all/-a``
5187 to select all unresolved files. ``--tool`` can be used to specify
5188 to select all unresolved files. ``--tool`` can be used to specify
5188 the merge tool used for the given files. It overrides the HGMERGE
5189 the merge tool used for the given files. It overrides the HGMERGE
5189 environment variable and your configuration files. Previous file
5190 environment variable and your configuration files. Previous file
5190 contents are saved with a ``.orig`` suffix.
5191 contents are saved with a ``.orig`` suffix.
5191
5192
5192 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
5193 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
5193 (e.g. after having manually fixed-up the files). The default is
5194 (e.g. after having manually fixed-up the files). The default is
5194 to mark all unresolved files.
5195 to mark all unresolved files.
5195
5196
5196 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
5197 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
5197 default is to mark all resolved files.
5198 default is to mark all resolved files.
5198
5199
5199 - :hg:`resolve -l`: list files which had or still have conflicts.
5200 - :hg:`resolve -l`: list files which had or still have conflicts.
5200 In the printed list, ``U`` = unresolved and ``R`` = resolved.
5201 In the printed list, ``U`` = unresolved and ``R`` = resolved.
5201
5202
5202 Note that Mercurial will not let you commit files with unresolved
5203 Note that Mercurial will not let you commit files with unresolved
5203 merge conflicts. You must use :hg:`resolve -m ...` before you can
5204 merge conflicts. You must use :hg:`resolve -m ...` before you can
5204 commit after a conflicting merge.
5205 commit after a conflicting merge.
5205
5206
5206 Returns 0 on success, 1 if any files fail a resolve attempt.
5207 Returns 0 on success, 1 if any files fail a resolve attempt.
5207 """
5208 """
5208
5209
5209 all, mark, unmark, show, nostatus = \
5210 all, mark, unmark, show, nostatus = \
5210 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
5211 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
5211
5212
5212 if (show and (mark or unmark)) or (mark and unmark):
5213 if (show and (mark or unmark)) or (mark and unmark):
5213 raise util.Abort(_("too many options specified"))
5214 raise util.Abort(_("too many options specified"))
5214 if pats and all:
5215 if pats and all:
5215 raise util.Abort(_("can't specify --all and patterns"))
5216 raise util.Abort(_("can't specify --all and patterns"))
5216 if not (all or pats or show or mark or unmark):
5217 if not (all or pats or show or mark or unmark):
5217 raise util.Abort(_('no files or directories specified'),
5218 raise util.Abort(_('no files or directories specified'),
5218 hint=('use --all to remerge all files'))
5219 hint=('use --all to remerge all files'))
5219
5220
5220 wlock = repo.wlock()
5221 wlock = repo.wlock()
5221 try:
5222 try:
5222 ms = mergemod.mergestate(repo)
5223 ms = mergemod.mergestate(repo)
5223
5224
5224 if not (ms.active() or repo.dirstate.p2() != nullid) and not show:
5225 if not (ms.active() or repo.dirstate.p2() != nullid) and not show:
5225 raise util.Abort(
5226 raise util.Abort(
5226 _('resolve command not applicable when not merging'))
5227 _('resolve command not applicable when not merging'))
5227
5228
5228 m = scmutil.match(repo[None], pats, opts)
5229 m = scmutil.match(repo[None], pats, opts)
5229 ret = 0
5230 ret = 0
5230 didwork = False
5231 didwork = False
5231
5232
5232 for f in ms:
5233 for f in ms:
5233 if not m(f):
5234 if not m(f):
5234 continue
5235 continue
5235
5236
5236 didwork = True
5237 didwork = True
5237
5238
5238 if show:
5239 if show:
5239 if nostatus:
5240 if nostatus:
5240 ui.write("%s\n" % f)
5241 ui.write("%s\n" % f)
5241 else:
5242 else:
5242 ui.write("%s %s\n" % (ms[f].upper(), f),
5243 ui.write("%s %s\n" % (ms[f].upper(), f),
5243 label='resolve.' +
5244 label='resolve.' +
5244 {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
5245 {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
5245 elif mark:
5246 elif mark:
5246 ms.mark(f, "r")
5247 ms.mark(f, "r")
5247 elif unmark:
5248 elif unmark:
5248 ms.mark(f, "u")
5249 ms.mark(f, "u")
5249 else:
5250 else:
5250 wctx = repo[None]
5251 wctx = repo[None]
5251
5252
5252 # backup pre-resolve (merge uses .orig for its own purposes)
5253 # backup pre-resolve (merge uses .orig for its own purposes)
5253 a = repo.wjoin(f)
5254 a = repo.wjoin(f)
5254 util.copyfile(a, a + ".resolve")
5255 util.copyfile(a, a + ".resolve")
5255
5256
5256 try:
5257 try:
5257 # resolve file
5258 # resolve file
5258 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
5259 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
5259 'resolve')
5260 'resolve')
5260 if ms.resolve(f, wctx):
5261 if ms.resolve(f, wctx):
5261 ret = 1
5262 ret = 1
5262 finally:
5263 finally:
5263 ui.setconfig('ui', 'forcemerge', '', 'resolve')
5264 ui.setconfig('ui', 'forcemerge', '', 'resolve')
5264 ms.commit()
5265 ms.commit()
5265
5266
5266 # replace filemerge's .orig file with our resolve file
5267 # replace filemerge's .orig file with our resolve file
5267 util.rename(a + ".resolve", a + ".orig")
5268 util.rename(a + ".resolve", a + ".orig")
5268
5269
5269 ms.commit()
5270 ms.commit()
5270
5271
5271 if not didwork and pats:
5272 if not didwork and pats:
5272 ui.warn(_("arguments do not match paths that need resolving\n"))
5273 ui.warn(_("arguments do not match paths that need resolving\n"))
5273
5274
5274 finally:
5275 finally:
5275 wlock.release()
5276 wlock.release()
5276
5277
5277 # Nudge users into finishing an unfinished operation. We don't print
5278 # Nudge users into finishing an unfinished operation. We don't print
5278 # this with the list/show operation because we want list/show to remain
5279 # this with the list/show operation because we want list/show to remain
5279 # machine readable.
5280 # machine readable.
5280 if not list(ms.unresolved()) and not show:
5281 if not list(ms.unresolved()) and not show:
5281 ui.status(_('(no more unresolved files)\n'))
5282 ui.status(_('(no more unresolved files)\n'))
5282
5283
5283 return ret
5284 return ret
5284
5285
5285 @command('revert',
5286 @command('revert',
5286 [('a', 'all', None, _('revert all changes when no arguments given')),
5287 [('a', 'all', None, _('revert all changes when no arguments given')),
5287 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5288 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5288 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
5289 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
5289 ('C', 'no-backup', None, _('do not save backup copies of files')),
5290 ('C', 'no-backup', None, _('do not save backup copies of files')),
5290 ] + walkopts + dryrunopts,
5291 ] + walkopts + dryrunopts,
5291 _('[OPTION]... [-r REV] [NAME]...'))
5292 _('[OPTION]... [-r REV] [NAME]...'))
5292 def revert(ui, repo, *pats, **opts):
5293 def revert(ui, repo, *pats, **opts):
5293 """restore files to their checkout state
5294 """restore files to their checkout state
5294
5295
5295 .. note::
5296 .. note::
5296
5297
5297 To check out earlier revisions, you should use :hg:`update REV`.
5298 To check out earlier revisions, you should use :hg:`update REV`.
5298 To cancel an uncommitted merge (and lose your changes),
5299 To cancel an uncommitted merge (and lose your changes),
5299 use :hg:`update --clean .`.
5300 use :hg:`update --clean .`.
5300
5301
5301 With no revision specified, revert the specified files or directories
5302 With no revision specified, revert the specified files or directories
5302 to the contents they had in the parent of the working directory.
5303 to the contents they had in the parent of the working directory.
5303 This restores the contents of files to an unmodified
5304 This restores the contents of files to an unmodified
5304 state and unschedules adds, removes, copies, and renames. If the
5305 state and unschedules adds, removes, copies, and renames. If the
5305 working directory has two parents, you must explicitly specify a
5306 working directory has two parents, you must explicitly specify a
5306 revision.
5307 revision.
5307
5308
5308 Using the -r/--rev or -d/--date options, revert the given files or
5309 Using the -r/--rev or -d/--date options, revert the given files or
5309 directories to their states as of a specific revision. Because
5310 directories to their states as of a specific revision. Because
5310 revert does not change the working directory parents, this will
5311 revert does not change the working directory parents, this will
5311 cause these files to appear modified. This can be helpful to "back
5312 cause these files to appear modified. This can be helpful to "back
5312 out" some or all of an earlier change. See :hg:`backout` for a
5313 out" some or all of an earlier change. See :hg:`backout` for a
5313 related method.
5314 related method.
5314
5315
5315 Modified files are saved with a .orig suffix before reverting.
5316 Modified files are saved with a .orig suffix before reverting.
5316 To disable these backups, use --no-backup.
5317 To disable these backups, use --no-backup.
5317
5318
5318 See :hg:`help dates` for a list of formats valid for -d/--date.
5319 See :hg:`help dates` for a list of formats valid for -d/--date.
5319
5320
5320 Returns 0 on success.
5321 Returns 0 on success.
5321 """
5322 """
5322
5323
5323 if opts.get("date"):
5324 if opts.get("date"):
5324 if opts.get("rev"):
5325 if opts.get("rev"):
5325 raise util.Abort(_("you can't specify a revision and a date"))
5326 raise util.Abort(_("you can't specify a revision and a date"))
5326 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
5327 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
5327
5328
5328 parent, p2 = repo.dirstate.parents()
5329 parent, p2 = repo.dirstate.parents()
5329 if not opts.get('rev') and p2 != nullid:
5330 if not opts.get('rev') and p2 != nullid:
5330 # revert after merge is a trap for new users (issue2915)
5331 # revert after merge is a trap for new users (issue2915)
5331 raise util.Abort(_('uncommitted merge with no revision specified'),
5332 raise util.Abort(_('uncommitted merge with no revision specified'),
5332 hint=_('use "hg update" or see "hg help revert"'))
5333 hint=_('use "hg update" or see "hg help revert"'))
5333
5334
5334 ctx = scmutil.revsingle(repo, opts.get('rev'))
5335 ctx = scmutil.revsingle(repo, opts.get('rev'))
5335
5336
5336 if not pats and not opts.get('all'):
5337 if not pats and not opts.get('all'):
5337 msg = _("no files or directories specified")
5338 msg = _("no files or directories specified")
5338 if p2 != nullid:
5339 if p2 != nullid:
5339 hint = _("uncommitted merge, use --all to discard all changes,"
5340 hint = _("uncommitted merge, use --all to discard all changes,"
5340 " or 'hg update -C .' to abort the merge")
5341 " or 'hg update -C .' to abort the merge")
5341 raise util.Abort(msg, hint=hint)
5342 raise util.Abort(msg, hint=hint)
5342 dirty = util.any(repo.status())
5343 dirty = util.any(repo.status())
5343 node = ctx.node()
5344 node = ctx.node()
5344 if node != parent:
5345 if node != parent:
5345 if dirty:
5346 if dirty:
5346 hint = _("uncommitted changes, use --all to discard all"
5347 hint = _("uncommitted changes, use --all to discard all"
5347 " changes, or 'hg update %s' to update") % ctx.rev()
5348 " changes, or 'hg update %s' to update") % ctx.rev()
5348 else:
5349 else:
5349 hint = _("use --all to revert all files,"
5350 hint = _("use --all to revert all files,"
5350 " or 'hg update %s' to update") % ctx.rev()
5351 " or 'hg update %s' to update") % ctx.rev()
5351 elif dirty:
5352 elif dirty:
5352 hint = _("uncommitted changes, use --all to discard all changes")
5353 hint = _("uncommitted changes, use --all to discard all changes")
5353 else:
5354 else:
5354 hint = _("use --all to revert all files")
5355 hint = _("use --all to revert all files")
5355 raise util.Abort(msg, hint=hint)
5356 raise util.Abort(msg, hint=hint)
5356
5357
5357 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
5358 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
5358
5359
5359 @command('rollback', dryrunopts +
5360 @command('rollback', dryrunopts +
5360 [('f', 'force', False, _('ignore safety measures'))])
5361 [('f', 'force', False, _('ignore safety measures'))])
5361 def rollback(ui, repo, **opts):
5362 def rollback(ui, repo, **opts):
5362 """roll back the last transaction (DANGEROUS) (DEPRECATED)
5363 """roll back the last transaction (DANGEROUS) (DEPRECATED)
5363
5364
5364 Please use :hg:`commit --amend` instead of rollback to correct
5365 Please use :hg:`commit --amend` instead of rollback to correct
5365 mistakes in the last commit.
5366 mistakes in the last commit.
5366
5367
5367 This command should be used with care. There is only one level of
5368 This command should be used with care. There is only one level of
5368 rollback, and there is no way to undo a rollback. It will also
5369 rollback, and there is no way to undo a rollback. It will also
5369 restore the dirstate at the time of the last transaction, losing
5370 restore the dirstate at the time of the last transaction, losing
5370 any dirstate changes since that time. This command does not alter
5371 any dirstate changes since that time. This command does not alter
5371 the working directory.
5372 the working directory.
5372
5373
5373 Transactions are used to encapsulate the effects of all commands
5374 Transactions are used to encapsulate the effects of all commands
5374 that create new changesets or propagate existing changesets into a
5375 that create new changesets or propagate existing changesets into a
5375 repository.
5376 repository.
5376
5377
5377 .. container:: verbose
5378 .. container:: verbose
5378
5379
5379 For example, the following commands are transactional, and their
5380 For example, the following commands are transactional, and their
5380 effects can be rolled back:
5381 effects can be rolled back:
5381
5382
5382 - commit
5383 - commit
5383 - import
5384 - import
5384 - pull
5385 - pull
5385 - push (with this repository as the destination)
5386 - push (with this repository as the destination)
5386 - unbundle
5387 - unbundle
5387
5388
5388 To avoid permanent data loss, rollback will refuse to rollback a
5389 To avoid permanent data loss, rollback will refuse to rollback a
5389 commit transaction if it isn't checked out. Use --force to
5390 commit transaction if it isn't checked out. Use --force to
5390 override this protection.
5391 override this protection.
5391
5392
5392 This command is not intended for use on public repositories. Once
5393 This command is not intended for use on public repositories. Once
5393 changes are visible for pull by other users, rolling a transaction
5394 changes are visible for pull by other users, rolling a transaction
5394 back locally is ineffective (someone else may already have pulled
5395 back locally is ineffective (someone else may already have pulled
5395 the changes). Furthermore, a race is possible with readers of the
5396 the changes). Furthermore, a race is possible with readers of the
5396 repository; for example an in-progress pull from the repository
5397 repository; for example an in-progress pull from the repository
5397 may fail if a rollback is performed.
5398 may fail if a rollback is performed.
5398
5399
5399 Returns 0 on success, 1 if no rollback data is available.
5400 Returns 0 on success, 1 if no rollback data is available.
5400 """
5401 """
5401 return repo.rollback(dryrun=opts.get('dry_run'),
5402 return repo.rollback(dryrun=opts.get('dry_run'),
5402 force=opts.get('force'))
5403 force=opts.get('force'))
5403
5404
5404 @command('root', [])
5405 @command('root', [])
5405 def root(ui, repo):
5406 def root(ui, repo):
5406 """print the root (top) of the current working directory
5407 """print the root (top) of the current working directory
5407
5408
5408 Print the root directory of the current repository.
5409 Print the root directory of the current repository.
5409
5410
5410 Returns 0 on success.
5411 Returns 0 on success.
5411 """
5412 """
5412 ui.write(repo.root + "\n")
5413 ui.write(repo.root + "\n")
5413
5414
5414 @command('^serve',
5415 @command('^serve',
5415 [('A', 'accesslog', '', _('name of access log file to write to'),
5416 [('A', 'accesslog', '', _('name of access log file to write to'),
5416 _('FILE')),
5417 _('FILE')),
5417 ('d', 'daemon', None, _('run server in background')),
5418 ('d', 'daemon', None, _('run server in background')),
5418 ('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('FILE')),
5419 ('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('FILE')),
5419 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
5420 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
5420 # use string type, then we can check if something was passed
5421 # use string type, then we can check if something was passed
5421 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
5422 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
5422 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
5423 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
5423 _('ADDR')),
5424 _('ADDR')),
5424 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
5425 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
5425 _('PREFIX')),
5426 _('PREFIX')),
5426 ('n', 'name', '',
5427 ('n', 'name', '',
5427 _('name to show in web pages (default: working directory)'), _('NAME')),
5428 _('name to show in web pages (default: working directory)'), _('NAME')),
5428 ('', 'web-conf', '',
5429 ('', 'web-conf', '',
5429 _('name of the hgweb config file (see "hg help hgweb")'), _('FILE')),
5430 _('name of the hgweb config file (see "hg help hgweb")'), _('FILE')),
5430 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
5431 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
5431 _('FILE')),
5432 _('FILE')),
5432 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
5433 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
5433 ('', 'stdio', None, _('for remote clients')),
5434 ('', 'stdio', None, _('for remote clients')),
5434 ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
5435 ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
5435 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
5436 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
5436 ('', 'style', '', _('template style to use'), _('STYLE')),
5437 ('', 'style', '', _('template style to use'), _('STYLE')),
5437 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
5438 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
5438 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
5439 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
5439 _('[OPTION]...'),
5440 _('[OPTION]...'),
5440 optionalrepo=True)
5441 optionalrepo=True)
5441 def serve(ui, repo, **opts):
5442 def serve(ui, repo, **opts):
5442 """start stand-alone webserver
5443 """start stand-alone webserver
5443
5444
5444 Start a local HTTP repository browser and pull server. You can use
5445 Start a local HTTP repository browser and pull server. You can use
5445 this for ad-hoc sharing and browsing of repositories. It is
5446 this for ad-hoc sharing and browsing of repositories. It is
5446 recommended to use a real web server to serve a repository for
5447 recommended to use a real web server to serve a repository for
5447 longer periods of time.
5448 longer periods of time.
5448
5449
5449 Please note that the server does not implement access control.
5450 Please note that the server does not implement access control.
5450 This means that, by default, anybody can read from the server and
5451 This means that, by default, anybody can read from the server and
5451 nobody can write to it by default. Set the ``web.allow_push``
5452 nobody can write to it by default. Set the ``web.allow_push``
5452 option to ``*`` to allow everybody to push to the server. You
5453 option to ``*`` to allow everybody to push to the server. You
5453 should use a real web server if you need to authenticate users.
5454 should use a real web server if you need to authenticate users.
5454
5455
5455 By default, the server logs accesses to stdout and errors to
5456 By default, the server logs accesses to stdout and errors to
5456 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
5457 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
5457 files.
5458 files.
5458
5459
5459 To have the server choose a free port number to listen on, specify
5460 To have the server choose a free port number to listen on, specify
5460 a port number of 0; in this case, the server will print the port
5461 a port number of 0; in this case, the server will print the port
5461 number it uses.
5462 number it uses.
5462
5463
5463 Returns 0 on success.
5464 Returns 0 on success.
5464 """
5465 """
5465
5466
5466 if opts["stdio"] and opts["cmdserver"]:
5467 if opts["stdio"] and opts["cmdserver"]:
5467 raise util.Abort(_("cannot use --stdio with --cmdserver"))
5468 raise util.Abort(_("cannot use --stdio with --cmdserver"))
5468
5469
5469 if opts["stdio"]:
5470 if opts["stdio"]:
5470 if repo is None:
5471 if repo is None:
5471 raise error.RepoError(_("there is no Mercurial repository here"
5472 raise error.RepoError(_("there is no Mercurial repository here"
5472 " (.hg not found)"))
5473 " (.hg not found)"))
5473 s = sshserver.sshserver(ui, repo)
5474 s = sshserver.sshserver(ui, repo)
5474 s.serve_forever()
5475 s.serve_forever()
5475
5476
5476 if opts["cmdserver"]:
5477 if opts["cmdserver"]:
5477 service = commandserver.createservice(ui, repo, opts)
5478 service = commandserver.createservice(ui, repo, opts)
5478 return cmdutil.service(opts, initfn=service.init, runfn=service.run)
5479 return cmdutil.service(opts, initfn=service.init, runfn=service.run)
5479
5480
5480 # this way we can check if something was given in the command-line
5481 # this way we can check if something was given in the command-line
5481 if opts.get('port'):
5482 if opts.get('port'):
5482 opts['port'] = util.getport(opts.get('port'))
5483 opts['port'] = util.getport(opts.get('port'))
5483
5484
5484 baseui = repo and repo.baseui or ui
5485 baseui = repo and repo.baseui or ui
5485 optlist = ("name templates style address port prefix ipv6"
5486 optlist = ("name templates style address port prefix ipv6"
5486 " accesslog errorlog certificate encoding")
5487 " accesslog errorlog certificate encoding")
5487 for o in optlist.split():
5488 for o in optlist.split():
5488 val = opts.get(o, '')
5489 val = opts.get(o, '')
5489 if val in (None, ''): # should check against default options instead
5490 if val in (None, ''): # should check against default options instead
5490 continue
5491 continue
5491 baseui.setconfig("web", o, val, 'serve')
5492 baseui.setconfig("web", o, val, 'serve')
5492 if repo and repo.ui != baseui:
5493 if repo and repo.ui != baseui:
5493 repo.ui.setconfig("web", o, val, 'serve')
5494 repo.ui.setconfig("web", o, val, 'serve')
5494
5495
5495 o = opts.get('web_conf') or opts.get('webdir_conf')
5496 o = opts.get('web_conf') or opts.get('webdir_conf')
5496 if not o:
5497 if not o:
5497 if not repo:
5498 if not repo:
5498 raise error.RepoError(_("there is no Mercurial repository"
5499 raise error.RepoError(_("there is no Mercurial repository"
5499 " here (.hg not found)"))
5500 " here (.hg not found)"))
5500 o = repo
5501 o = repo
5501
5502
5502 app = hgweb.hgweb(o, baseui=baseui)
5503 app = hgweb.hgweb(o, baseui=baseui)
5503 service = httpservice(ui, app, opts)
5504 service = httpservice(ui, app, opts)
5504 cmdutil.service(opts, initfn=service.init, runfn=service.run)
5505 cmdutil.service(opts, initfn=service.init, runfn=service.run)
5505
5506
5506 class httpservice(object):
5507 class httpservice(object):
5507 def __init__(self, ui, app, opts):
5508 def __init__(self, ui, app, opts):
5508 self.ui = ui
5509 self.ui = ui
5509 self.app = app
5510 self.app = app
5510 self.opts = opts
5511 self.opts = opts
5511
5512
5512 def init(self):
5513 def init(self):
5513 util.setsignalhandler()
5514 util.setsignalhandler()
5514 self.httpd = hgweb_server.create_server(self.ui, self.app)
5515 self.httpd = hgweb_server.create_server(self.ui, self.app)
5515
5516
5516 if self.opts['port'] and not self.ui.verbose:
5517 if self.opts['port'] and not self.ui.verbose:
5517 return
5518 return
5518
5519
5519 if self.httpd.prefix:
5520 if self.httpd.prefix:
5520 prefix = self.httpd.prefix.strip('/') + '/'
5521 prefix = self.httpd.prefix.strip('/') + '/'
5521 else:
5522 else:
5522 prefix = ''
5523 prefix = ''
5523
5524
5524 port = ':%d' % self.httpd.port
5525 port = ':%d' % self.httpd.port
5525 if port == ':80':
5526 if port == ':80':
5526 port = ''
5527 port = ''
5527
5528
5528 bindaddr = self.httpd.addr
5529 bindaddr = self.httpd.addr
5529 if bindaddr == '0.0.0.0':
5530 if bindaddr == '0.0.0.0':
5530 bindaddr = '*'
5531 bindaddr = '*'
5531 elif ':' in bindaddr: # IPv6
5532 elif ':' in bindaddr: # IPv6
5532 bindaddr = '[%s]' % bindaddr
5533 bindaddr = '[%s]' % bindaddr
5533
5534
5534 fqaddr = self.httpd.fqaddr
5535 fqaddr = self.httpd.fqaddr
5535 if ':' in fqaddr:
5536 if ':' in fqaddr:
5536 fqaddr = '[%s]' % fqaddr
5537 fqaddr = '[%s]' % fqaddr
5537 if self.opts['port']:
5538 if self.opts['port']:
5538 write = self.ui.status
5539 write = self.ui.status
5539 else:
5540 else:
5540 write = self.ui.write
5541 write = self.ui.write
5541 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
5542 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
5542 (fqaddr, port, prefix, bindaddr, self.httpd.port))
5543 (fqaddr, port, prefix, bindaddr, self.httpd.port))
5543 self.ui.flush() # avoid buffering of status message
5544 self.ui.flush() # avoid buffering of status message
5544
5545
5545 def run(self):
5546 def run(self):
5546 self.httpd.serve_forever()
5547 self.httpd.serve_forever()
5547
5548
5548
5549
5549 @command('^status|st',
5550 @command('^status|st',
5550 [('A', 'all', None, _('show status of all files')),
5551 [('A', 'all', None, _('show status of all files')),
5551 ('m', 'modified', None, _('show only modified files')),
5552 ('m', 'modified', None, _('show only modified files')),
5552 ('a', 'added', None, _('show only added files')),
5553 ('a', 'added', None, _('show only added files')),
5553 ('r', 'removed', None, _('show only removed files')),
5554 ('r', 'removed', None, _('show only removed files')),
5554 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
5555 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
5555 ('c', 'clean', None, _('show only files without changes')),
5556 ('c', 'clean', None, _('show only files without changes')),
5556 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
5557 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
5557 ('i', 'ignored', None, _('show only ignored files')),
5558 ('i', 'ignored', None, _('show only ignored files')),
5558 ('n', 'no-status', None, _('hide status prefix')),
5559 ('n', 'no-status', None, _('hide status prefix')),
5559 ('C', 'copies', None, _('show source of copied files')),
5560 ('C', 'copies', None, _('show source of copied files')),
5560 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
5561 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
5561 ('', 'rev', [], _('show difference from revision'), _('REV')),
5562 ('', 'rev', [], _('show difference from revision'), _('REV')),
5562 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
5563 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
5563 ] + walkopts + subrepoopts + formatteropts,
5564 ] + walkopts + subrepoopts + formatteropts,
5564 _('[OPTION]... [FILE]...'),
5565 _('[OPTION]... [FILE]...'),
5565 inferrepo=True)
5566 inferrepo=True)
5566 def status(ui, repo, *pats, **opts):
5567 def status(ui, repo, *pats, **opts):
5567 """show changed files in the working directory
5568 """show changed files in the working directory
5568
5569
5569 Show status of files in the repository. If names are given, only
5570 Show status of files in the repository. If names are given, only
5570 files that match are shown. Files that are clean or ignored or
5571 files that match are shown. Files that are clean or ignored or
5571 the source of a copy/move operation, are not listed unless
5572 the source of a copy/move operation, are not listed unless
5572 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
5573 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
5573 Unless options described with "show only ..." are given, the
5574 Unless options described with "show only ..." are given, the
5574 options -mardu are used.
5575 options -mardu are used.
5575
5576
5576 Option -q/--quiet hides untracked (unknown and ignored) files
5577 Option -q/--quiet hides untracked (unknown and ignored) files
5577 unless explicitly requested with -u/--unknown or -i/--ignored.
5578 unless explicitly requested with -u/--unknown or -i/--ignored.
5578
5579
5579 .. note::
5580 .. note::
5580
5581
5581 status may appear to disagree with diff if permissions have
5582 status may appear to disagree with diff if permissions have
5582 changed or a merge has occurred. The standard diff format does
5583 changed or a merge has occurred. The standard diff format does
5583 not report permission changes and diff only reports changes
5584 not report permission changes and diff only reports changes
5584 relative to one merge parent.
5585 relative to one merge parent.
5585
5586
5586 If one revision is given, it is used as the base revision.
5587 If one revision is given, it is used as the base revision.
5587 If two revisions are given, the differences between them are
5588 If two revisions are given, the differences between them are
5588 shown. The --change option can also be used as a shortcut to list
5589 shown. The --change option can also be used as a shortcut to list
5589 the changed files of a revision from its first parent.
5590 the changed files of a revision from its first parent.
5590
5591
5591 The codes used to show the status of files are::
5592 The codes used to show the status of files are::
5592
5593
5593 M = modified
5594 M = modified
5594 A = added
5595 A = added
5595 R = removed
5596 R = removed
5596 C = clean
5597 C = clean
5597 ! = missing (deleted by non-hg command, but still tracked)
5598 ! = missing (deleted by non-hg command, but still tracked)
5598 ? = not tracked
5599 ? = not tracked
5599 I = ignored
5600 I = ignored
5600 = origin of the previous file (with --copies)
5601 = origin of the previous file (with --copies)
5601
5602
5602 .. container:: verbose
5603 .. container:: verbose
5603
5604
5604 Examples:
5605 Examples:
5605
5606
5606 - show changes in the working directory relative to a
5607 - show changes in the working directory relative to a
5607 changeset::
5608 changeset::
5608
5609
5609 hg status --rev 9353
5610 hg status --rev 9353
5610
5611
5611 - show all changes including copies in an existing changeset::
5612 - show all changes including copies in an existing changeset::
5612
5613
5613 hg status --copies --change 9353
5614 hg status --copies --change 9353
5614
5615
5615 - get a NUL separated list of added files, suitable for xargs::
5616 - get a NUL separated list of added files, suitable for xargs::
5616
5617
5617 hg status -an0
5618 hg status -an0
5618
5619
5619 Returns 0 on success.
5620 Returns 0 on success.
5620 """
5621 """
5621
5622
5622 revs = opts.get('rev')
5623 revs = opts.get('rev')
5623 change = opts.get('change')
5624 change = opts.get('change')
5624
5625
5625 if revs and change:
5626 if revs and change:
5626 msg = _('cannot specify --rev and --change at the same time')
5627 msg = _('cannot specify --rev and --change at the same time')
5627 raise util.Abort(msg)
5628 raise util.Abort(msg)
5628 elif change:
5629 elif change:
5629 node2 = scmutil.revsingle(repo, change, None).node()
5630 node2 = scmutil.revsingle(repo, change, None).node()
5630 node1 = repo[node2].p1().node()
5631 node1 = repo[node2].p1().node()
5631 else:
5632 else:
5632 node1, node2 = scmutil.revpair(repo, revs)
5633 node1, node2 = scmutil.revpair(repo, revs)
5633
5634
5634 cwd = (pats and repo.getcwd()) or ''
5635 cwd = (pats and repo.getcwd()) or ''
5635 end = opts.get('print0') and '\0' or '\n'
5636 end = opts.get('print0') and '\0' or '\n'
5636 copy = {}
5637 copy = {}
5637 states = 'modified added removed deleted unknown ignored clean'.split()
5638 states = 'modified added removed deleted unknown ignored clean'.split()
5638 show = [k for k in states if opts.get(k)]
5639 show = [k for k in states if opts.get(k)]
5639 if opts.get('all'):
5640 if opts.get('all'):
5640 show += ui.quiet and (states[:4] + ['clean']) or states
5641 show += ui.quiet and (states[:4] + ['clean']) or states
5641 if not show:
5642 if not show:
5642 show = ui.quiet and states[:4] or states[:5]
5643 show = ui.quiet and states[:4] or states[:5]
5643
5644
5644 stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts),
5645 stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts),
5645 'ignored' in show, 'clean' in show, 'unknown' in show,
5646 'ignored' in show, 'clean' in show, 'unknown' in show,
5646 opts.get('subrepos'))
5647 opts.get('subrepos'))
5647 changestates = zip(states, 'MAR!?IC', stat)
5648 changestates = zip(states, 'MAR!?IC', stat)
5648
5649
5649 if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'):
5650 if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'):
5650 copy = copies.pathcopies(repo[node1], repo[node2])
5651 copy = copies.pathcopies(repo[node1], repo[node2])
5651
5652
5652 fm = ui.formatter('status', opts)
5653 fm = ui.formatter('status', opts)
5653 fmt = '%s' + end
5654 fmt = '%s' + end
5654 showchar = not opts.get('no_status')
5655 showchar = not opts.get('no_status')
5655
5656
5656 for state, char, files in changestates:
5657 for state, char, files in changestates:
5657 if state in show:
5658 if state in show:
5658 label = 'status.' + state
5659 label = 'status.' + state
5659 for f in files:
5660 for f in files:
5660 fm.startitem()
5661 fm.startitem()
5661 fm.condwrite(showchar, 'status', '%s ', char, label=label)
5662 fm.condwrite(showchar, 'status', '%s ', char, label=label)
5662 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
5663 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
5663 if f in copy:
5664 if f in copy:
5664 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
5665 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
5665 label='status.copied')
5666 label='status.copied')
5666 fm.end()
5667 fm.end()
5667
5668
5668 @command('^summary|sum',
5669 @command('^summary|sum',
5669 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
5670 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
5670 def summary(ui, repo, **opts):
5671 def summary(ui, repo, **opts):
5671 """summarize working directory state
5672 """summarize working directory state
5672
5673
5673 This generates a brief summary of the working directory state,
5674 This generates a brief summary of the working directory state,
5674 including parents, branch, commit status, and available updates.
5675 including parents, branch, commit status, and available updates.
5675
5676
5676 With the --remote option, this will check the default paths for
5677 With the --remote option, this will check the default paths for
5677 incoming and outgoing changes. This can be time-consuming.
5678 incoming and outgoing changes. This can be time-consuming.
5678
5679
5679 Returns 0 on success.
5680 Returns 0 on success.
5680 """
5681 """
5681
5682
5682 ctx = repo[None]
5683 ctx = repo[None]
5683 parents = ctx.parents()
5684 parents = ctx.parents()
5684 pnode = parents[0].node()
5685 pnode = parents[0].node()
5685 marks = []
5686 marks = []
5686
5687
5687 for p in parents:
5688 for p in parents:
5688 # label with log.changeset (instead of log.parent) since this
5689 # label with log.changeset (instead of log.parent) since this
5689 # shows a working directory parent *changeset*:
5690 # shows a working directory parent *changeset*:
5690 # i18n: column positioning for "hg summary"
5691 # i18n: column positioning for "hg summary"
5691 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
5692 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
5692 label='log.changeset changeset.%s' % p.phasestr())
5693 label='log.changeset changeset.%s' % p.phasestr())
5693 ui.write(' '.join(p.tags()), label='log.tag')
5694 ui.write(' '.join(p.tags()), label='log.tag')
5694 if p.bookmarks():
5695 if p.bookmarks():
5695 marks.extend(p.bookmarks())
5696 marks.extend(p.bookmarks())
5696 if p.rev() == -1:
5697 if p.rev() == -1:
5697 if not len(repo):
5698 if not len(repo):
5698 ui.write(_(' (empty repository)'))
5699 ui.write(_(' (empty repository)'))
5699 else:
5700 else:
5700 ui.write(_(' (no revision checked out)'))
5701 ui.write(_(' (no revision checked out)'))
5701 ui.write('\n')
5702 ui.write('\n')
5702 if p.description():
5703 if p.description():
5703 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
5704 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
5704 label='log.summary')
5705 label='log.summary')
5705
5706
5706 branch = ctx.branch()
5707 branch = ctx.branch()
5707 bheads = repo.branchheads(branch)
5708 bheads = repo.branchheads(branch)
5708 # i18n: column positioning for "hg summary"
5709 # i18n: column positioning for "hg summary"
5709 m = _('branch: %s\n') % branch
5710 m = _('branch: %s\n') % branch
5710 if branch != 'default':
5711 if branch != 'default':
5711 ui.write(m, label='log.branch')
5712 ui.write(m, label='log.branch')
5712 else:
5713 else:
5713 ui.status(m, label='log.branch')
5714 ui.status(m, label='log.branch')
5714
5715
5715 if marks:
5716 if marks:
5716 current = repo._bookmarkcurrent
5717 current = repo._bookmarkcurrent
5717 # i18n: column positioning for "hg summary"
5718 # i18n: column positioning for "hg summary"
5718 ui.write(_('bookmarks:'), label='log.bookmark')
5719 ui.write(_('bookmarks:'), label='log.bookmark')
5719 if current is not None:
5720 if current is not None:
5720 if current in marks:
5721 if current in marks:
5721 ui.write(' *' + current, label='bookmarks.current')
5722 ui.write(' *' + current, label='bookmarks.current')
5722 marks.remove(current)
5723 marks.remove(current)
5723 else:
5724 else:
5724 ui.write(' [%s]' % current, label='bookmarks.current')
5725 ui.write(' [%s]' % current, label='bookmarks.current')
5725 for m in marks:
5726 for m in marks:
5726 ui.write(' ' + m, label='log.bookmark')
5727 ui.write(' ' + m, label='log.bookmark')
5727 ui.write('\n', label='log.bookmark')
5728 ui.write('\n', label='log.bookmark')
5728
5729
5729 status = repo.status(unknown=True)
5730 status = repo.status(unknown=True)
5730
5731
5731 c = repo.dirstate.copies()
5732 c = repo.dirstate.copies()
5732 copied, renamed = [], []
5733 copied, renamed = [], []
5733 for d, s in c.iteritems():
5734 for d, s in c.iteritems():
5734 if s in status.removed:
5735 if s in status.removed:
5735 status.removed.remove(s)
5736 status.removed.remove(s)
5736 renamed.append(d)
5737 renamed.append(d)
5737 else:
5738 else:
5738 copied.append(d)
5739 copied.append(d)
5739 if d in status.added:
5740 if d in status.added:
5740 status.added.remove(d)
5741 status.added.remove(d)
5741
5742
5742 ms = mergemod.mergestate(repo)
5743 ms = mergemod.mergestate(repo)
5743 unresolved = [f for f in ms if ms[f] == 'u']
5744 unresolved = [f for f in ms if ms[f] == 'u']
5744
5745
5745 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
5746 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
5746
5747
5747 labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified),
5748 labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified),
5748 (ui.label(_('%d added'), 'status.added'), status.added),
5749 (ui.label(_('%d added'), 'status.added'), status.added),
5749 (ui.label(_('%d removed'), 'status.removed'), status.removed),
5750 (ui.label(_('%d removed'), 'status.removed'), status.removed),
5750 (ui.label(_('%d renamed'), 'status.copied'), renamed),
5751 (ui.label(_('%d renamed'), 'status.copied'), renamed),
5751 (ui.label(_('%d copied'), 'status.copied'), copied),
5752 (ui.label(_('%d copied'), 'status.copied'), copied),
5752 (ui.label(_('%d deleted'), 'status.deleted'), status.deleted),
5753 (ui.label(_('%d deleted'), 'status.deleted'), status.deleted),
5753 (ui.label(_('%d unknown'), 'status.unknown'), status.unknown),
5754 (ui.label(_('%d unknown'), 'status.unknown'), status.unknown),
5754 (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved),
5755 (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved),
5755 (ui.label(_('%d subrepos'), 'status.modified'), subs)]
5756 (ui.label(_('%d subrepos'), 'status.modified'), subs)]
5756 t = []
5757 t = []
5757 for l, s in labels:
5758 for l, s in labels:
5758 if s:
5759 if s:
5759 t.append(l % len(s))
5760 t.append(l % len(s))
5760
5761
5761 t = ', '.join(t)
5762 t = ', '.join(t)
5762 cleanworkdir = False
5763 cleanworkdir = False
5763
5764
5764 if repo.vfs.exists('updatestate'):
5765 if repo.vfs.exists('updatestate'):
5765 t += _(' (interrupted update)')
5766 t += _(' (interrupted update)')
5766 elif len(parents) > 1:
5767 elif len(parents) > 1:
5767 t += _(' (merge)')
5768 t += _(' (merge)')
5768 elif branch != parents[0].branch():
5769 elif branch != parents[0].branch():
5769 t += _(' (new branch)')
5770 t += _(' (new branch)')
5770 elif (parents[0].closesbranch() and
5771 elif (parents[0].closesbranch() and
5771 pnode in repo.branchheads(branch, closed=True)):
5772 pnode in repo.branchheads(branch, closed=True)):
5772 t += _(' (head closed)')
5773 t += _(' (head closed)')
5773 elif not (status.modified or status.added or status.removed or renamed or
5774 elif not (status.modified or status.added or status.removed or renamed or
5774 copied or subs):
5775 copied or subs):
5775 t += _(' (clean)')
5776 t += _(' (clean)')
5776 cleanworkdir = True
5777 cleanworkdir = True
5777 elif pnode not in bheads:
5778 elif pnode not in bheads:
5778 t += _(' (new branch head)')
5779 t += _(' (new branch head)')
5779
5780
5780 if cleanworkdir:
5781 if cleanworkdir:
5781 # i18n: column positioning for "hg summary"
5782 # i18n: column positioning for "hg summary"
5782 ui.status(_('commit: %s\n') % t.strip())
5783 ui.status(_('commit: %s\n') % t.strip())
5783 else:
5784 else:
5784 # i18n: column positioning for "hg summary"
5785 # i18n: column positioning for "hg summary"
5785 ui.write(_('commit: %s\n') % t.strip())
5786 ui.write(_('commit: %s\n') % t.strip())
5786
5787
5787 # all ancestors of branch heads - all ancestors of parent = new csets
5788 # all ancestors of branch heads - all ancestors of parent = new csets
5788 new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
5789 new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
5789 bheads))
5790 bheads))
5790
5791
5791 if new == 0:
5792 if new == 0:
5792 # i18n: column positioning for "hg summary"
5793 # i18n: column positioning for "hg summary"
5793 ui.status(_('update: (current)\n'))
5794 ui.status(_('update: (current)\n'))
5794 elif pnode not in bheads:
5795 elif pnode not in bheads:
5795 # i18n: column positioning for "hg summary"
5796 # i18n: column positioning for "hg summary"
5796 ui.write(_('update: %d new changesets (update)\n') % new)
5797 ui.write(_('update: %d new changesets (update)\n') % new)
5797 else:
5798 else:
5798 # i18n: column positioning for "hg summary"
5799 # i18n: column positioning for "hg summary"
5799 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
5800 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
5800 (new, len(bheads)))
5801 (new, len(bheads)))
5801
5802
5802 cmdutil.summaryhooks(ui, repo)
5803 cmdutil.summaryhooks(ui, repo)
5803
5804
5804 if opts.get('remote'):
5805 if opts.get('remote'):
5805 needsincoming, needsoutgoing = True, True
5806 needsincoming, needsoutgoing = True, True
5806 else:
5807 else:
5807 needsincoming, needsoutgoing = False, False
5808 needsincoming, needsoutgoing = False, False
5808 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
5809 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
5809 if i:
5810 if i:
5810 needsincoming = True
5811 needsincoming = True
5811 if o:
5812 if o:
5812 needsoutgoing = True
5813 needsoutgoing = True
5813 if not needsincoming and not needsoutgoing:
5814 if not needsincoming and not needsoutgoing:
5814 return
5815 return
5815
5816
5816 def getincoming():
5817 def getincoming():
5817 source, branches = hg.parseurl(ui.expandpath('default'))
5818 source, branches = hg.parseurl(ui.expandpath('default'))
5818 sbranch = branches[0]
5819 sbranch = branches[0]
5819 try:
5820 try:
5820 other = hg.peer(repo, {}, source)
5821 other = hg.peer(repo, {}, source)
5821 except error.RepoError:
5822 except error.RepoError:
5822 if opts.get('remote'):
5823 if opts.get('remote'):
5823 raise
5824 raise
5824 return source, sbranch, None, None, None
5825 return source, sbranch, None, None, None
5825 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
5826 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
5826 if revs:
5827 if revs:
5827 revs = [other.lookup(rev) for rev in revs]
5828 revs = [other.lookup(rev) for rev in revs]
5828 ui.debug('comparing with %s\n' % util.hidepassword(source))
5829 ui.debug('comparing with %s\n' % util.hidepassword(source))
5829 repo.ui.pushbuffer()
5830 repo.ui.pushbuffer()
5830 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
5831 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
5831 repo.ui.popbuffer()
5832 repo.ui.popbuffer()
5832 return source, sbranch, other, commoninc, commoninc[1]
5833 return source, sbranch, other, commoninc, commoninc[1]
5833
5834
5834 if needsincoming:
5835 if needsincoming:
5835 source, sbranch, sother, commoninc, incoming = getincoming()
5836 source, sbranch, sother, commoninc, incoming = getincoming()
5836 else:
5837 else:
5837 source = sbranch = sother = commoninc = incoming = None
5838 source = sbranch = sother = commoninc = incoming = None
5838
5839
5839 def getoutgoing():
5840 def getoutgoing():
5840 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
5841 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
5841 dbranch = branches[0]
5842 dbranch = branches[0]
5842 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
5843 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
5843 if source != dest:
5844 if source != dest:
5844 try:
5845 try:
5845 dother = hg.peer(repo, {}, dest)
5846 dother = hg.peer(repo, {}, dest)
5846 except error.RepoError:
5847 except error.RepoError:
5847 if opts.get('remote'):
5848 if opts.get('remote'):
5848 raise
5849 raise
5849 return dest, dbranch, None, None
5850 return dest, dbranch, None, None
5850 ui.debug('comparing with %s\n' % util.hidepassword(dest))
5851 ui.debug('comparing with %s\n' % util.hidepassword(dest))
5851 elif sother is None:
5852 elif sother is None:
5852 # there is no explicit destination peer, but source one is invalid
5853 # there is no explicit destination peer, but source one is invalid
5853 return dest, dbranch, None, None
5854 return dest, dbranch, None, None
5854 else:
5855 else:
5855 dother = sother
5856 dother = sother
5856 if (source != dest or (sbranch is not None and sbranch != dbranch)):
5857 if (source != dest or (sbranch is not None and sbranch != dbranch)):
5857 common = None
5858 common = None
5858 else:
5859 else:
5859 common = commoninc
5860 common = commoninc
5860 if revs:
5861 if revs:
5861 revs = [repo.lookup(rev) for rev in revs]
5862 revs = [repo.lookup(rev) for rev in revs]
5862 repo.ui.pushbuffer()
5863 repo.ui.pushbuffer()
5863 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
5864 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
5864 commoninc=common)
5865 commoninc=common)
5865 repo.ui.popbuffer()
5866 repo.ui.popbuffer()
5866 return dest, dbranch, dother, outgoing
5867 return dest, dbranch, dother, outgoing
5867
5868
5868 if needsoutgoing:
5869 if needsoutgoing:
5869 dest, dbranch, dother, outgoing = getoutgoing()
5870 dest, dbranch, dother, outgoing = getoutgoing()
5870 else:
5871 else:
5871 dest = dbranch = dother = outgoing = None
5872 dest = dbranch = dother = outgoing = None
5872
5873
5873 if opts.get('remote'):
5874 if opts.get('remote'):
5874 t = []
5875 t = []
5875 if incoming:
5876 if incoming:
5876 t.append(_('1 or more incoming'))
5877 t.append(_('1 or more incoming'))
5877 o = outgoing.missing
5878 o = outgoing.missing
5878 if o:
5879 if o:
5879 t.append(_('%d outgoing') % len(o))
5880 t.append(_('%d outgoing') % len(o))
5880 other = dother or sother
5881 other = dother or sother
5881 if 'bookmarks' in other.listkeys('namespaces'):
5882 if 'bookmarks' in other.listkeys('namespaces'):
5882 lmarks = repo.listkeys('bookmarks')
5883 lmarks = repo.listkeys('bookmarks')
5883 rmarks = other.listkeys('bookmarks')
5884 rmarks = other.listkeys('bookmarks')
5884 diff = set(rmarks) - set(lmarks)
5885 diff = set(rmarks) - set(lmarks)
5885 if len(diff) > 0:
5886 if len(diff) > 0:
5886 t.append(_('%d incoming bookmarks') % len(diff))
5887 t.append(_('%d incoming bookmarks') % len(diff))
5887 diff = set(lmarks) - set(rmarks)
5888 diff = set(lmarks) - set(rmarks)
5888 if len(diff) > 0:
5889 if len(diff) > 0:
5889 t.append(_('%d outgoing bookmarks') % len(diff))
5890 t.append(_('%d outgoing bookmarks') % len(diff))
5890
5891
5891 if t:
5892 if t:
5892 # i18n: column positioning for "hg summary"
5893 # i18n: column positioning for "hg summary"
5893 ui.write(_('remote: %s\n') % (', '.join(t)))
5894 ui.write(_('remote: %s\n') % (', '.join(t)))
5894 else:
5895 else:
5895 # i18n: column positioning for "hg summary"
5896 # i18n: column positioning for "hg summary"
5896 ui.status(_('remote: (synced)\n'))
5897 ui.status(_('remote: (synced)\n'))
5897
5898
5898 cmdutil.summaryremotehooks(ui, repo, opts,
5899 cmdutil.summaryremotehooks(ui, repo, opts,
5899 ((source, sbranch, sother, commoninc),
5900 ((source, sbranch, sother, commoninc),
5900 (dest, dbranch, dother, outgoing)))
5901 (dest, dbranch, dother, outgoing)))
5901
5902
5902 @command('tag',
5903 @command('tag',
5903 [('f', 'force', None, _('force tag')),
5904 [('f', 'force', None, _('force tag')),
5904 ('l', 'local', None, _('make the tag local')),
5905 ('l', 'local', None, _('make the tag local')),
5905 ('r', 'rev', '', _('revision to tag'), _('REV')),
5906 ('r', 'rev', '', _('revision to tag'), _('REV')),
5906 ('', 'remove', None, _('remove a tag')),
5907 ('', 'remove', None, _('remove a tag')),
5907 # -l/--local is already there, commitopts cannot be used
5908 # -l/--local is already there, commitopts cannot be used
5908 ('e', 'edit', None, _('invoke editor on commit messages')),
5909 ('e', 'edit', None, _('invoke editor on commit messages')),
5909 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
5910 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
5910 ] + commitopts2,
5911 ] + commitopts2,
5911 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
5912 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
5912 def tag(ui, repo, name1, *names, **opts):
5913 def tag(ui, repo, name1, *names, **opts):
5913 """add one or more tags for the current or given revision
5914 """add one or more tags for the current or given revision
5914
5915
5915 Name a particular revision using <name>.
5916 Name a particular revision using <name>.
5916
5917
5917 Tags are used to name particular revisions of the repository and are
5918 Tags are used to name particular revisions of the repository and are
5918 very useful to compare different revisions, to go back to significant
5919 very useful to compare different revisions, to go back to significant
5919 earlier versions or to mark branch points as releases, etc. Changing
5920 earlier versions or to mark branch points as releases, etc. Changing
5920 an existing tag is normally disallowed; use -f/--force to override.
5921 an existing tag is normally disallowed; use -f/--force to override.
5921
5922
5922 If no revision is given, the parent of the working directory is
5923 If no revision is given, the parent of the working directory is
5923 used.
5924 used.
5924
5925
5925 To facilitate version control, distribution, and merging of tags,
5926 To facilitate version control, distribution, and merging of tags,
5926 they are stored as a file named ".hgtags" which is managed similarly
5927 they are stored as a file named ".hgtags" which is managed similarly
5927 to other project files and can be hand-edited if necessary. This
5928 to other project files and can be hand-edited if necessary. This
5928 also means that tagging creates a new commit. The file
5929 also means that tagging creates a new commit. The file
5929 ".hg/localtags" is used for local tags (not shared among
5930 ".hg/localtags" is used for local tags (not shared among
5930 repositories).
5931 repositories).
5931
5932
5932 Tag commits are usually made at the head of a branch. If the parent
5933 Tag commits are usually made at the head of a branch. If the parent
5933 of the working directory is not a branch head, :hg:`tag` aborts; use
5934 of the working directory is not a branch head, :hg:`tag` aborts; use
5934 -f/--force to force the tag commit to be based on a non-head
5935 -f/--force to force the tag commit to be based on a non-head
5935 changeset.
5936 changeset.
5936
5937
5937 See :hg:`help dates` for a list of formats valid for -d/--date.
5938 See :hg:`help dates` for a list of formats valid for -d/--date.
5938
5939
5939 Since tag names have priority over branch names during revision
5940 Since tag names have priority over branch names during revision
5940 lookup, using an existing branch name as a tag name is discouraged.
5941 lookup, using an existing branch name as a tag name is discouraged.
5941
5942
5942 Returns 0 on success.
5943 Returns 0 on success.
5943 """
5944 """
5944 wlock = lock = None
5945 wlock = lock = None
5945 try:
5946 try:
5946 wlock = repo.wlock()
5947 wlock = repo.wlock()
5947 lock = repo.lock()
5948 lock = repo.lock()
5948 rev_ = "."
5949 rev_ = "."
5949 names = [t.strip() for t in (name1,) + names]
5950 names = [t.strip() for t in (name1,) + names]
5950 if len(names) != len(set(names)):
5951 if len(names) != len(set(names)):
5951 raise util.Abort(_('tag names must be unique'))
5952 raise util.Abort(_('tag names must be unique'))
5952 for n in names:
5953 for n in names:
5953 scmutil.checknewlabel(repo, n, 'tag')
5954 scmutil.checknewlabel(repo, n, 'tag')
5954 if not n:
5955 if not n:
5955 raise util.Abort(_('tag names cannot consist entirely of '
5956 raise util.Abort(_('tag names cannot consist entirely of '
5956 'whitespace'))
5957 'whitespace'))
5957 if opts.get('rev') and opts.get('remove'):
5958 if opts.get('rev') and opts.get('remove'):
5958 raise util.Abort(_("--rev and --remove are incompatible"))
5959 raise util.Abort(_("--rev and --remove are incompatible"))
5959 if opts.get('rev'):
5960 if opts.get('rev'):
5960 rev_ = opts['rev']
5961 rev_ = opts['rev']
5961 message = opts.get('message')
5962 message = opts.get('message')
5962 if opts.get('remove'):
5963 if opts.get('remove'):
5963 expectedtype = opts.get('local') and 'local' or 'global'
5964 expectedtype = opts.get('local') and 'local' or 'global'
5964 for n in names:
5965 for n in names:
5965 if not repo.tagtype(n):
5966 if not repo.tagtype(n):
5966 raise util.Abort(_("tag '%s' does not exist") % n)
5967 raise util.Abort(_("tag '%s' does not exist") % n)
5967 if repo.tagtype(n) != expectedtype:
5968 if repo.tagtype(n) != expectedtype:
5968 if expectedtype == 'global':
5969 if expectedtype == 'global':
5969 raise util.Abort(_("tag '%s' is not a global tag") % n)
5970 raise util.Abort(_("tag '%s' is not a global tag") % n)
5970 else:
5971 else:
5971 raise util.Abort(_("tag '%s' is not a local tag") % n)
5972 raise util.Abort(_("tag '%s' is not a local tag") % n)
5972 rev_ = nullid
5973 rev_ = nullid
5973 if not message:
5974 if not message:
5974 # we don't translate commit messages
5975 # we don't translate commit messages
5975 message = 'Removed tag %s' % ', '.join(names)
5976 message = 'Removed tag %s' % ', '.join(names)
5976 elif not opts.get('force'):
5977 elif not opts.get('force'):
5977 for n in names:
5978 for n in names:
5978 if n in repo.tags():
5979 if n in repo.tags():
5979 raise util.Abort(_("tag '%s' already exists "
5980 raise util.Abort(_("tag '%s' already exists "
5980 "(use -f to force)") % n)
5981 "(use -f to force)") % n)
5981 if not opts.get('local'):
5982 if not opts.get('local'):
5982 p1, p2 = repo.dirstate.parents()
5983 p1, p2 = repo.dirstate.parents()
5983 if p2 != nullid:
5984 if p2 != nullid:
5984 raise util.Abort(_('uncommitted merge'))
5985 raise util.Abort(_('uncommitted merge'))
5985 bheads = repo.branchheads()
5986 bheads = repo.branchheads()
5986 if not opts.get('force') and bheads and p1 not in bheads:
5987 if not opts.get('force') and bheads and p1 not in bheads:
5987 raise util.Abort(_('not at a branch head (use -f to force)'))
5988 raise util.Abort(_('not at a branch head (use -f to force)'))
5988 r = scmutil.revsingle(repo, rev_).node()
5989 r = scmutil.revsingle(repo, rev_).node()
5989
5990
5990 if not message:
5991 if not message:
5991 # we don't translate commit messages
5992 # we don't translate commit messages
5992 message = ('Added tag %s for changeset %s' %
5993 message = ('Added tag %s for changeset %s' %
5993 (', '.join(names), short(r)))
5994 (', '.join(names), short(r)))
5994
5995
5995 date = opts.get('date')
5996 date = opts.get('date')
5996 if date:
5997 if date:
5997 date = util.parsedate(date)
5998 date = util.parsedate(date)
5998
5999
5999 if opts.get('remove'):
6000 if opts.get('remove'):
6000 editform = 'tag.remove'
6001 editform = 'tag.remove'
6001 else:
6002 else:
6002 editform = 'tag.add'
6003 editform = 'tag.add'
6003 editor = cmdutil.getcommiteditor(editform=editform, **opts)
6004 editor = cmdutil.getcommiteditor(editform=editform, **opts)
6004
6005
6005 # don't allow tagging the null rev
6006 # don't allow tagging the null rev
6006 if (not opts.get('remove') and
6007 if (not opts.get('remove') and
6007 scmutil.revsingle(repo, rev_).rev() == nullrev):
6008 scmutil.revsingle(repo, rev_).rev() == nullrev):
6008 raise util.Abort(_("cannot tag null revision"))
6009 raise util.Abort(_("cannot tag null revision"))
6009
6010
6010 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
6011 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
6011 editor=editor)
6012 editor=editor)
6012 finally:
6013 finally:
6013 release(lock, wlock)
6014 release(lock, wlock)
6014
6015
6015 @command('tags', formatteropts, '')
6016 @command('tags', formatteropts, '')
6016 def tags(ui, repo, **opts):
6017 def tags(ui, repo, **opts):
6017 """list repository tags
6018 """list repository tags
6018
6019
6019 This lists both regular and local tags. When the -v/--verbose
6020 This lists both regular and local tags. When the -v/--verbose
6020 switch is used, a third column "local" is printed for local tags.
6021 switch is used, a third column "local" is printed for local tags.
6021
6022
6022 Returns 0 on success.
6023 Returns 0 on success.
6023 """
6024 """
6024
6025
6025 fm = ui.formatter('tags', opts)
6026 fm = ui.formatter('tags', opts)
6026 hexfunc = fm.hexfunc
6027 hexfunc = fm.hexfunc
6027 tagtype = ""
6028 tagtype = ""
6028
6029
6029 for t, n in reversed(repo.tagslist()):
6030 for t, n in reversed(repo.tagslist()):
6030 hn = hexfunc(n)
6031 hn = hexfunc(n)
6031 label = 'tags.normal'
6032 label = 'tags.normal'
6032 tagtype = ''
6033 tagtype = ''
6033 if repo.tagtype(t) == 'local':
6034 if repo.tagtype(t) == 'local':
6034 label = 'tags.local'
6035 label = 'tags.local'
6035 tagtype = 'local'
6036 tagtype = 'local'
6036
6037
6037 fm.startitem()
6038 fm.startitem()
6038 fm.write('tag', '%s', t, label=label)
6039 fm.write('tag', '%s', t, label=label)
6039 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
6040 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
6040 fm.condwrite(not ui.quiet, 'rev node', fmt,
6041 fm.condwrite(not ui.quiet, 'rev node', fmt,
6041 repo.changelog.rev(n), hn, label=label)
6042 repo.changelog.rev(n), hn, label=label)
6042 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
6043 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
6043 tagtype, label=label)
6044 tagtype, label=label)
6044 fm.plain('\n')
6045 fm.plain('\n')
6045 fm.end()
6046 fm.end()
6046
6047
6047 @command('tip',
6048 @command('tip',
6048 [('p', 'patch', None, _('show patch')),
6049 [('p', 'patch', None, _('show patch')),
6049 ('g', 'git', None, _('use git extended diff format')),
6050 ('g', 'git', None, _('use git extended diff format')),
6050 ] + templateopts,
6051 ] + templateopts,
6051 _('[-p] [-g]'))
6052 _('[-p] [-g]'))
6052 def tip(ui, repo, **opts):
6053 def tip(ui, repo, **opts):
6053 """show the tip revision (DEPRECATED)
6054 """show the tip revision (DEPRECATED)
6054
6055
6055 The tip revision (usually just called the tip) is the changeset
6056 The tip revision (usually just called the tip) is the changeset
6056 most recently added to the repository (and therefore the most
6057 most recently added to the repository (and therefore the most
6057 recently changed head).
6058 recently changed head).
6058
6059
6059 If you have just made a commit, that commit will be the tip. If
6060 If you have just made a commit, that commit will be the tip. If
6060 you have just pulled changes from another repository, the tip of
6061 you have just pulled changes from another repository, the tip of
6061 that repository becomes the current tip. The "tip" tag is special
6062 that repository becomes the current tip. The "tip" tag is special
6062 and cannot be renamed or assigned to a different changeset.
6063 and cannot be renamed or assigned to a different changeset.
6063
6064
6064 This command is deprecated, please use :hg:`heads` instead.
6065 This command is deprecated, please use :hg:`heads` instead.
6065
6066
6066 Returns 0 on success.
6067 Returns 0 on success.
6067 """
6068 """
6068 displayer = cmdutil.show_changeset(ui, repo, opts)
6069 displayer = cmdutil.show_changeset(ui, repo, opts)
6069 displayer.show(repo['tip'])
6070 displayer.show(repo['tip'])
6070 displayer.close()
6071 displayer.close()
6071
6072
6072 @command('unbundle',
6073 @command('unbundle',
6073 [('u', 'update', None,
6074 [('u', 'update', None,
6074 _('update to new branch head if changesets were unbundled'))],
6075 _('update to new branch head if changesets were unbundled'))],
6075 _('[-u] FILE...'))
6076 _('[-u] FILE...'))
6076 def unbundle(ui, repo, fname1, *fnames, **opts):
6077 def unbundle(ui, repo, fname1, *fnames, **opts):
6077 """apply one or more changegroup files
6078 """apply one or more changegroup files
6078
6079
6079 Apply one or more compressed changegroup files generated by the
6080 Apply one or more compressed changegroup files generated by the
6080 bundle command.
6081 bundle command.
6081
6082
6082 Returns 0 on success, 1 if an update has unresolved files.
6083 Returns 0 on success, 1 if an update has unresolved files.
6083 """
6084 """
6084 fnames = (fname1,) + fnames
6085 fnames = (fname1,) + fnames
6085
6086
6086 lock = repo.lock()
6087 lock = repo.lock()
6087 try:
6088 try:
6088 for fname in fnames:
6089 for fname in fnames:
6089 f = hg.openpath(ui, fname)
6090 f = hg.openpath(ui, fname)
6090 gen = exchange.readbundle(ui, f, fname)
6091 gen = exchange.readbundle(ui, f, fname)
6091 modheads = changegroup.addchangegroup(repo, gen, 'unbundle',
6092 modheads = changegroup.addchangegroup(repo, gen, 'unbundle',
6092 'bundle:' + fname)
6093 'bundle:' + fname)
6093 finally:
6094 finally:
6094 lock.release()
6095 lock.release()
6095
6096
6096 return postincoming(ui, repo, modheads, opts.get('update'), None)
6097 return postincoming(ui, repo, modheads, opts.get('update'), None)
6097
6098
6098 @command('^update|up|checkout|co',
6099 @command('^update|up|checkout|co',
6099 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
6100 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
6100 ('c', 'check', None,
6101 ('c', 'check', None,
6101 _('update across branches if no uncommitted changes')),
6102 _('update across branches if no uncommitted changes')),
6102 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
6103 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
6103 ('r', 'rev', '', _('revision'), _('REV'))
6104 ('r', 'rev', '', _('revision'), _('REV'))
6104 ] + mergetoolopts,
6105 ] + mergetoolopts,
6105 _('[-c] [-C] [-d DATE] [[-r] REV]'))
6106 _('[-c] [-C] [-d DATE] [[-r] REV]'))
6106 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
6107 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
6107 tool=None):
6108 tool=None):
6108 """update working directory (or switch revisions)
6109 """update working directory (or switch revisions)
6109
6110
6110 Update the repository's working directory to the specified
6111 Update the repository's working directory to the specified
6111 changeset. If no changeset is specified, update to the tip of the
6112 changeset. If no changeset is specified, update to the tip of the
6112 current named branch and move the current bookmark (see :hg:`help
6113 current named branch and move the current bookmark (see :hg:`help
6113 bookmarks`).
6114 bookmarks`).
6114
6115
6115 Update sets the working directory's parent revision to the specified
6116 Update sets the working directory's parent revision to the specified
6116 changeset (see :hg:`help parents`).
6117 changeset (see :hg:`help parents`).
6117
6118
6118 If the changeset is not a descendant or ancestor of the working
6119 If the changeset is not a descendant or ancestor of the working
6119 directory's parent, the update is aborted. With the -c/--check
6120 directory's parent, the update is aborted. With the -c/--check
6120 option, the working directory is checked for uncommitted changes; if
6121 option, the working directory is checked for uncommitted changes; if
6121 none are found, the working directory is updated to the specified
6122 none are found, the working directory is updated to the specified
6122 changeset.
6123 changeset.
6123
6124
6124 .. container:: verbose
6125 .. container:: verbose
6125
6126
6126 The following rules apply when the working directory contains
6127 The following rules apply when the working directory contains
6127 uncommitted changes:
6128 uncommitted changes:
6128
6129
6129 1. If neither -c/--check nor -C/--clean is specified, and if
6130 1. If neither -c/--check nor -C/--clean is specified, and if
6130 the requested changeset is an ancestor or descendant of
6131 the requested changeset is an ancestor or descendant of
6131 the working directory's parent, the uncommitted changes
6132 the working directory's parent, the uncommitted changes
6132 are merged into the requested changeset and the merged
6133 are merged into the requested changeset and the merged
6133 result is left uncommitted. If the requested changeset is
6134 result is left uncommitted. If the requested changeset is
6134 not an ancestor or descendant (that is, it is on another
6135 not an ancestor or descendant (that is, it is on another
6135 branch), the update is aborted and the uncommitted changes
6136 branch), the update is aborted and the uncommitted changes
6136 are preserved.
6137 are preserved.
6137
6138
6138 2. With the -c/--check option, the update is aborted and the
6139 2. With the -c/--check option, the update is aborted and the
6139 uncommitted changes are preserved.
6140 uncommitted changes are preserved.
6140
6141
6141 3. With the -C/--clean option, uncommitted changes are discarded and
6142 3. With the -C/--clean option, uncommitted changes are discarded and
6142 the working directory is updated to the requested changeset.
6143 the working directory is updated to the requested changeset.
6143
6144
6144 To cancel an uncommitted merge (and lose your changes), use
6145 To cancel an uncommitted merge (and lose your changes), use
6145 :hg:`update --clean .`.
6146 :hg:`update --clean .`.
6146
6147
6147 Use null as the changeset to remove the working directory (like
6148 Use null as the changeset to remove the working directory (like
6148 :hg:`clone -U`).
6149 :hg:`clone -U`).
6149
6150
6150 If you want to revert just one file to an older revision, use
6151 If you want to revert just one file to an older revision, use
6151 :hg:`revert [-r REV] NAME`.
6152 :hg:`revert [-r REV] NAME`.
6152
6153
6153 See :hg:`help dates` for a list of formats valid for -d/--date.
6154 See :hg:`help dates` for a list of formats valid for -d/--date.
6154
6155
6155 Returns 0 on success, 1 if there are unresolved files.
6156 Returns 0 on success, 1 if there are unresolved files.
6156 """
6157 """
6157 if rev and node:
6158 if rev and node:
6158 raise util.Abort(_("please specify just one revision"))
6159 raise util.Abort(_("please specify just one revision"))
6159
6160
6160 if rev is None or rev == '':
6161 if rev is None or rev == '':
6161 rev = node
6162 rev = node
6162
6163
6163 cmdutil.clearunfinished(repo)
6164 cmdutil.clearunfinished(repo)
6164
6165
6165 # with no argument, we also move the current bookmark, if any
6166 # with no argument, we also move the current bookmark, if any
6166 rev, movemarkfrom = bookmarks.calculateupdate(ui, repo, rev)
6167 rev, movemarkfrom = bookmarks.calculateupdate(ui, repo, rev)
6167
6168
6168 # if we defined a bookmark, we have to remember the original bookmark name
6169 # if we defined a bookmark, we have to remember the original bookmark name
6169 brev = rev
6170 brev = rev
6170 rev = scmutil.revsingle(repo, rev, rev).rev()
6171 rev = scmutil.revsingle(repo, rev, rev).rev()
6171
6172
6172 if check and clean:
6173 if check and clean:
6173 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
6174 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
6174
6175
6175 if date:
6176 if date:
6176 if rev is not None:
6177 if rev is not None:
6177 raise util.Abort(_("you can't specify a revision and a date"))
6178 raise util.Abort(_("you can't specify a revision and a date"))
6178 rev = cmdutil.finddate(ui, repo, date)
6179 rev = cmdutil.finddate(ui, repo, date)
6179
6180
6180 if check:
6181 if check:
6181 c = repo[None]
6182 c = repo[None]
6182 if c.dirty(merge=False, branch=False, missing=True):
6183 if c.dirty(merge=False, branch=False, missing=True):
6183 raise util.Abort(_("uncommitted changes"))
6184 raise util.Abort(_("uncommitted changes"))
6184 if rev is None:
6185 if rev is None:
6185 rev = repo[repo[None].branch()].rev()
6186 rev = repo[repo[None].branch()].rev()
6186 mergemod._checkunknown(repo, repo[None], repo[rev])
6187 mergemod._checkunknown(repo, repo[None], repo[rev])
6187
6188
6188 repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
6189 repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
6189
6190
6190 if clean:
6191 if clean:
6191 ret = hg.clean(repo, rev)
6192 ret = hg.clean(repo, rev)
6192 else:
6193 else:
6193 ret = hg.update(repo, rev)
6194 ret = hg.update(repo, rev)
6194
6195
6195 if not ret and movemarkfrom:
6196 if not ret and movemarkfrom:
6196 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
6197 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
6197 ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
6198 ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
6198 elif brev in repo._bookmarks:
6199 elif brev in repo._bookmarks:
6199 bookmarks.setcurrent(repo, brev)
6200 bookmarks.setcurrent(repo, brev)
6200 ui.status(_("(activating bookmark %s)\n") % brev)
6201 ui.status(_("(activating bookmark %s)\n") % brev)
6201 elif brev:
6202 elif brev:
6202 if repo._bookmarkcurrent:
6203 if repo._bookmarkcurrent:
6203 ui.status(_("(leaving bookmark %s)\n") %
6204 ui.status(_("(leaving bookmark %s)\n") %
6204 repo._bookmarkcurrent)
6205 repo._bookmarkcurrent)
6205 bookmarks.unsetcurrent(repo)
6206 bookmarks.unsetcurrent(repo)
6206
6207
6207 return ret
6208 return ret
6208
6209
6209 @command('verify', [])
6210 @command('verify', [])
6210 def verify(ui, repo):
6211 def verify(ui, repo):
6211 """verify the integrity of the repository
6212 """verify the integrity of the repository
6212
6213
6213 Verify the integrity of the current repository.
6214 Verify the integrity of the current repository.
6214
6215
6215 This will perform an extensive check of the repository's
6216 This will perform an extensive check of the repository's
6216 integrity, validating the hashes and checksums of each entry in
6217 integrity, validating the hashes and checksums of each entry in
6217 the changelog, manifest, and tracked files, as well as the
6218 the changelog, manifest, and tracked files, as well as the
6218 integrity of their crosslinks and indices.
6219 integrity of their crosslinks and indices.
6219
6220
6220 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption
6221 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption
6221 for more information about recovery from corruption of the
6222 for more information about recovery from corruption of the
6222 repository.
6223 repository.
6223
6224
6224 Returns 0 on success, 1 if errors are encountered.
6225 Returns 0 on success, 1 if errors are encountered.
6225 """
6226 """
6226 return hg.verify(repo)
6227 return hg.verify(repo)
6227
6228
6228 @command('version', [], norepo=True)
6229 @command('version', [], norepo=True)
6229 def version_(ui):
6230 def version_(ui):
6230 """output version and copyright information"""
6231 """output version and copyright information"""
6231 ui.write(_("Mercurial Distributed SCM (version %s)\n")
6232 ui.write(_("Mercurial Distributed SCM (version %s)\n")
6232 % util.version())
6233 % util.version())
6233 ui.status(_(
6234 ui.status(_(
6234 "(see http://mercurial.selenic.com for more information)\n"
6235 "(see http://mercurial.selenic.com for more information)\n"
6235 "\nCopyright (C) 2005-2014 Matt Mackall and others\n"
6236 "\nCopyright (C) 2005-2014 Matt Mackall and others\n"
6236 "This is free software; see the source for copying conditions. "
6237 "This is free software; see the source for copying conditions. "
6237 "There is NO\nwarranty; "
6238 "There is NO\nwarranty; "
6238 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
6239 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
6239 ))
6240 ))
6240
6241
6241 ui.note(_("\nEnabled extensions:\n\n"))
6242 ui.note(_("\nEnabled extensions:\n\n"))
6242 if ui.verbose:
6243 if ui.verbose:
6243 # format names and versions into columns
6244 # format names and versions into columns
6244 names = []
6245 names = []
6245 vers = []
6246 vers = []
6246 for name, module in extensions.extensions():
6247 for name, module in extensions.extensions():
6247 names.append(name)
6248 names.append(name)
6248 vers.append(extensions.moduleversion(module))
6249 vers.append(extensions.moduleversion(module))
6249 if names:
6250 if names:
6250 maxnamelen = max(len(n) for n in names)
6251 maxnamelen = max(len(n) for n in names)
6251 for i, name in enumerate(names):
6252 for i, name in enumerate(names):
6252 ui.write(" %-*s %s\n" % (maxnamelen, name, vers[i]))
6253 ui.write(" %-*s %s\n" % (maxnamelen, name, vers[i]))
@@ -1,336 +1,336 b''
1 Show all commands except debug commands
1 Show all commands except debug commands
2 $ hg debugcomplete
2 $ hg debugcomplete
3 add
3 add
4 addremove
4 addremove
5 annotate
5 annotate
6 archive
6 archive
7 backout
7 backout
8 bisect
8 bisect
9 bookmarks
9 bookmarks
10 branch
10 branch
11 branches
11 branches
12 bundle
12 bundle
13 cat
13 cat
14 clone
14 clone
15 commit
15 commit
16 config
16 config
17 copy
17 copy
18 diff
18 diff
19 export
19 export
20 files
20 files
21 forget
21 forget
22 graft
22 graft
23 grep
23 grep
24 heads
24 heads
25 help
25 help
26 identify
26 identify
27 import
27 import
28 incoming
28 incoming
29 init
29 init
30 locate
30 locate
31 log
31 log
32 manifest
32 manifest
33 merge
33 merge
34 outgoing
34 outgoing
35 parents
35 parents
36 paths
36 paths
37 phase
37 phase
38 pull
38 pull
39 push
39 push
40 recover
40 recover
41 remove
41 remove
42 rename
42 rename
43 resolve
43 resolve
44 revert
44 revert
45 rollback
45 rollback
46 root
46 root
47 serve
47 serve
48 status
48 status
49 summary
49 summary
50 tag
50 tag
51 tags
51 tags
52 tip
52 tip
53 unbundle
53 unbundle
54 update
54 update
55 verify
55 verify
56 version
56 version
57
57
58 Show all commands that start with "a"
58 Show all commands that start with "a"
59 $ hg debugcomplete a
59 $ hg debugcomplete a
60 add
60 add
61 addremove
61 addremove
62 annotate
62 annotate
63 archive
63 archive
64
64
65 Do not show debug commands if there are other candidates
65 Do not show debug commands if there are other candidates
66 $ hg debugcomplete d
66 $ hg debugcomplete d
67 diff
67 diff
68
68
69 Show debug commands if there are no other candidates
69 Show debug commands if there are no other candidates
70 $ hg debugcomplete debug
70 $ hg debugcomplete debug
71 debugancestor
71 debugancestor
72 debugbuilddag
72 debugbuilddag
73 debugbundle
73 debugbundle
74 debugcheckstate
74 debugcheckstate
75 debugcommands
75 debugcommands
76 debugcomplete
76 debugcomplete
77 debugconfig
77 debugconfig
78 debugdag
78 debugdag
79 debugdata
79 debugdata
80 debugdate
80 debugdate
81 debugdirstate
81 debugdirstate
82 debugdiscovery
82 debugdiscovery
83 debugfileset
83 debugfileset
84 debugfsinfo
84 debugfsinfo
85 debuggetbundle
85 debuggetbundle
86 debugignore
86 debugignore
87 debugindex
87 debugindex
88 debugindexdot
88 debugindexdot
89 debuginstall
89 debuginstall
90 debugknown
90 debugknown
91 debuglabelcomplete
91 debuglabelcomplete
92 debuglocks
92 debuglocks
93 debugobsolete
93 debugobsolete
94 debugpathcomplete
94 debugpathcomplete
95 debugpushkey
95 debugpushkey
96 debugpvec
96 debugpvec
97 debugrebuilddirstate
97 debugrebuilddirstate
98 debugrename
98 debugrename
99 debugrevlog
99 debugrevlog
100 debugrevspec
100 debugrevspec
101 debugsetparents
101 debugsetparents
102 debugsub
102 debugsub
103 debugsuccessorssets
103 debugsuccessorssets
104 debugwalk
104 debugwalk
105 debugwireargs
105 debugwireargs
106
106
107 Do not show the alias of a debug command if there are other candidates
107 Do not show the alias of a debug command if there are other candidates
108 (this should hide rawcommit)
108 (this should hide rawcommit)
109 $ hg debugcomplete r
109 $ hg debugcomplete r
110 recover
110 recover
111 remove
111 remove
112 rename
112 rename
113 resolve
113 resolve
114 revert
114 revert
115 rollback
115 rollback
116 root
116 root
117 Show the alias of a debug command if there are no other candidates
117 Show the alias of a debug command if there are no other candidates
118 $ hg debugcomplete rawc
118 $ hg debugcomplete rawc
119
119
120
120
121 Show the global options
121 Show the global options
122 $ hg debugcomplete --options | sort
122 $ hg debugcomplete --options | sort
123 --config
123 --config
124 --cwd
124 --cwd
125 --debug
125 --debug
126 --debugger
126 --debugger
127 --encoding
127 --encoding
128 --encodingmode
128 --encodingmode
129 --help
129 --help
130 --hidden
130 --hidden
131 --noninteractive
131 --noninteractive
132 --profile
132 --profile
133 --quiet
133 --quiet
134 --repository
134 --repository
135 --time
135 --time
136 --traceback
136 --traceback
137 --verbose
137 --verbose
138 --version
138 --version
139 -R
139 -R
140 -h
140 -h
141 -q
141 -q
142 -v
142 -v
143 -y
143 -y
144
144
145 Show the options for the "serve" command
145 Show the options for the "serve" command
146 $ hg debugcomplete --options serve | sort
146 $ hg debugcomplete --options serve | sort
147 --accesslog
147 --accesslog
148 --address
148 --address
149 --certificate
149 --certificate
150 --cmdserver
150 --cmdserver
151 --config
151 --config
152 --cwd
152 --cwd
153 --daemon
153 --daemon
154 --daemon-pipefds
154 --daemon-pipefds
155 --debug
155 --debug
156 --debugger
156 --debugger
157 --encoding
157 --encoding
158 --encodingmode
158 --encodingmode
159 --errorlog
159 --errorlog
160 --help
160 --help
161 --hidden
161 --hidden
162 --ipv6
162 --ipv6
163 --name
163 --name
164 --noninteractive
164 --noninteractive
165 --pid-file
165 --pid-file
166 --port
166 --port
167 --prefix
167 --prefix
168 --profile
168 --profile
169 --quiet
169 --quiet
170 --repository
170 --repository
171 --stdio
171 --stdio
172 --style
172 --style
173 --templates
173 --templates
174 --time
174 --time
175 --traceback
175 --traceback
176 --verbose
176 --verbose
177 --version
177 --version
178 --web-conf
178 --web-conf
179 -6
179 -6
180 -A
180 -A
181 -E
181 -E
182 -R
182 -R
183 -a
183 -a
184 -d
184 -d
185 -h
185 -h
186 -n
186 -n
187 -p
187 -p
188 -q
188 -q
189 -t
189 -t
190 -v
190 -v
191 -y
191 -y
192
192
193 Show an error if we use --options with an ambiguous abbreviation
193 Show an error if we use --options with an ambiguous abbreviation
194 $ hg debugcomplete --options s
194 $ hg debugcomplete --options s
195 hg: command 's' is ambiguous:
195 hg: command 's' is ambiguous:
196 serve showconfig status summary
196 serve showconfig status summary
197 [255]
197 [255]
198
198
199 Show all commands + options
199 Show all commands + options
200 $ hg debugcommands
200 $ hg debugcommands
201 add: include, exclude, subrepos, dry-run
201 add: include, exclude, subrepos, dry-run
202 annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, ignore-all-space, ignore-space-change, ignore-blank-lines, include, exclude, template
202 annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, ignore-all-space, ignore-space-change, ignore-blank-lines, include, exclude, template
203 clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure
203 clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure
204 commit: addremove, close-branch, amend, secret, edit, include, exclude, message, logfile, date, user, subrepos
204 commit: addremove, close-branch, amend, secret, edit, include, exclude, message, logfile, date, user, subrepos
205 diff: rev, change, text, git, nodates, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, include, exclude, subrepos
205 diff: rev, change, text, git, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, include, exclude, subrepos
206 export: output, switch-parent, rev, text, git, nodates
206 export: output, switch-parent, rev, text, git, nodates
207 forget: include, exclude
207 forget: include, exclude
208 init: ssh, remotecmd, insecure
208 init: ssh, remotecmd, insecure
209 log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
209 log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
210 merge: force, rev, preview, tool
210 merge: force, rev, preview, tool
211 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
211 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
212 push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
212 push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
213 remove: after, force, include, exclude
213 remove: after, force, include, exclude
214 serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate
214 serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate
215 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos, template
215 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos, template
216 summary: remote
216 summary: remote
217 update: clean, check, date, rev, tool
217 update: clean, check, date, rev, tool
218 addremove: similarity, include, exclude, dry-run
218 addremove: similarity, include, exclude, dry-run
219 archive: no-decode, prefix, rev, type, subrepos, include, exclude
219 archive: no-decode, prefix, rev, type, subrepos, include, exclude
220 backout: merge, parent, rev, edit, tool, include, exclude, message, logfile, date, user
220 backout: merge, parent, rev, edit, tool, include, exclude, message, logfile, date, user
221 bisect: reset, good, bad, skip, extend, command, noupdate
221 bisect: reset, good, bad, skip, extend, command, noupdate
222 bookmarks: force, rev, delete, rename, inactive, template
222 bookmarks: force, rev, delete, rename, inactive, template
223 branch: force, clean
223 branch: force, clean
224 branches: active, closed, template
224 branches: active, closed, template
225 bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
225 bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
226 cat: output, rev, decode, include, exclude
226 cat: output, rev, decode, include, exclude
227 config: untrusted, edit, local, global
227 config: untrusted, edit, local, global
228 copy: after, force, include, exclude, dry-run
228 copy: after, force, include, exclude, dry-run
229 debugancestor:
229 debugancestor:
230 debugbuilddag: mergeable-file, overwritten-file, new-file
230 debugbuilddag: mergeable-file, overwritten-file, new-file
231 debugbundle: all
231 debugbundle: all
232 debugcheckstate:
232 debugcheckstate:
233 debugcommands:
233 debugcommands:
234 debugcomplete: options
234 debugcomplete: options
235 debugdag: tags, branches, dots, spaces
235 debugdag: tags, branches, dots, spaces
236 debugdata: changelog, manifest
236 debugdata: changelog, manifest
237 debugdate: extended
237 debugdate: extended
238 debugdirstate: nodates, datesort
238 debugdirstate: nodates, datesort
239 debugdiscovery: old, nonheads, ssh, remotecmd, insecure
239 debugdiscovery: old, nonheads, ssh, remotecmd, insecure
240 debugfileset: rev
240 debugfileset: rev
241 debugfsinfo:
241 debugfsinfo:
242 debuggetbundle: head, common, type
242 debuggetbundle: head, common, type
243 debugignore:
243 debugignore:
244 debugindex: changelog, manifest, format
244 debugindex: changelog, manifest, format
245 debugindexdot:
245 debugindexdot:
246 debuginstall:
246 debuginstall:
247 debugknown:
247 debugknown:
248 debuglabelcomplete:
248 debuglabelcomplete:
249 debuglocks: force-lock, force-wlock
249 debuglocks: force-lock, force-wlock
250 debugobsolete: flags, record-parents, rev, date, user
250 debugobsolete: flags, record-parents, rev, date, user
251 debugpathcomplete: full, normal, added, removed
251 debugpathcomplete: full, normal, added, removed
252 debugpushkey:
252 debugpushkey:
253 debugpvec:
253 debugpvec:
254 debugrebuilddirstate: rev
254 debugrebuilddirstate: rev
255 debugrename: rev
255 debugrename: rev
256 debugrevlog: changelog, manifest, dump
256 debugrevlog: changelog, manifest, dump
257 debugrevspec: optimize
257 debugrevspec: optimize
258 debugsetparents:
258 debugsetparents:
259 debugsub: rev
259 debugsub: rev
260 debugsuccessorssets:
260 debugsuccessorssets:
261 debugwalk: include, exclude
261 debugwalk: include, exclude
262 debugwireargs: three, four, five, ssh, remotecmd, insecure
262 debugwireargs: three, four, five, ssh, remotecmd, insecure
263 files: rev, print0, include, exclude, template
263 files: rev, print0, include, exclude, template
264 graft: rev, continue, edit, log, force, currentdate, currentuser, date, user, tool, dry-run
264 graft: rev, continue, edit, log, force, currentdate, currentuser, date, user, tool, dry-run
265 grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
265 grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
266 heads: rev, topo, active, closed, style, template
266 heads: rev, topo, active, closed, style, template
267 help: extension, command, keyword
267 help: extension, command, keyword
268 identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure
268 identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure
269 import: strip, base, edit, force, no-commit, bypass, partial, exact, import-branch, message, logfile, date, user, similarity
269 import: strip, base, edit, force, no-commit, bypass, partial, exact, import-branch, message, logfile, date, user, similarity
270 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
270 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
271 locate: rev, print0, fullpath, include, exclude
271 locate: rev, print0, fullpath, include, exclude
272 manifest: rev, all, template
272 manifest: rev, all, template
273 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
273 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
274 parents: rev, style, template
274 parents: rev, style, template
275 paths:
275 paths:
276 phase: public, draft, secret, force, rev
276 phase: public, draft, secret, force, rev
277 recover:
277 recover:
278 rename: after, force, include, exclude, dry-run
278 rename: after, force, include, exclude, dry-run
279 resolve: all, list, mark, unmark, no-status, tool, include, exclude
279 resolve: all, list, mark, unmark, no-status, tool, include, exclude
280 revert: all, date, rev, no-backup, include, exclude, dry-run
280 revert: all, date, rev, no-backup, include, exclude, dry-run
281 rollback: dry-run, force
281 rollback: dry-run, force
282 root:
282 root:
283 tag: force, local, rev, remove, edit, message, date, user
283 tag: force, local, rev, remove, edit, message, date, user
284 tags: template
284 tags: template
285 tip: patch, git, style, template
285 tip: patch, git, style, template
286 unbundle: update
286 unbundle: update
287 verify:
287 verify:
288 version:
288 version:
289
289
290 $ hg init a
290 $ hg init a
291 $ cd a
291 $ cd a
292 $ echo fee > fee
292 $ echo fee > fee
293 $ hg ci -q -Amfee
293 $ hg ci -q -Amfee
294 $ hg tag fee
294 $ hg tag fee
295 $ mkdir fie
295 $ mkdir fie
296 $ echo dead > fie/dead
296 $ echo dead > fie/dead
297 $ echo live > fie/live
297 $ echo live > fie/live
298 $ hg bookmark fo
298 $ hg bookmark fo
299 $ hg branch -q fie
299 $ hg branch -q fie
300 $ hg ci -q -Amfie
300 $ hg ci -q -Amfie
301 $ echo fo > fo
301 $ echo fo > fo
302 $ hg branch -qf default
302 $ hg branch -qf default
303 $ hg ci -q -Amfo
303 $ hg ci -q -Amfo
304 $ echo Fum > Fum
304 $ echo Fum > Fum
305 $ hg ci -q -AmFum
305 $ hg ci -q -AmFum
306 $ hg bookmark Fum
306 $ hg bookmark Fum
307
307
308 Test debugpathcomplete
308 Test debugpathcomplete
309
309
310 $ hg debugpathcomplete f
310 $ hg debugpathcomplete f
311 fee
311 fee
312 fie
312 fie
313 fo
313 fo
314 $ hg debugpathcomplete -f f
314 $ hg debugpathcomplete -f f
315 fee
315 fee
316 fie/dead
316 fie/dead
317 fie/live
317 fie/live
318 fo
318 fo
319
319
320 $ hg rm Fum
320 $ hg rm Fum
321 $ hg debugpathcomplete -r F
321 $ hg debugpathcomplete -r F
322 Fum
322 Fum
323
323
324 Test debuglabelcomplete
324 Test debuglabelcomplete
325
325
326 $ hg debuglabelcomplete
326 $ hg debuglabelcomplete
327 Fum
327 Fum
328 default
328 default
329 fee
329 fee
330 fie
330 fie
331 fo
331 fo
332 tip
332 tip
333 $ hg debuglabelcomplete f
333 $ hg debuglabelcomplete f
334 fee
334 fee
335 fie
335 fie
336 fo
336 fo
@@ -1,254 +1,289 b''
1 $ hg init repo
1 $ hg init repo
2 $ cd repo
2 $ cd repo
3 $ cat > a <<EOF
3 $ cat > a <<EOF
4 > c
4 > c
5 > c
5 > c
6 > a
6 > a
7 > a
7 > a
8 > b
8 > b
9 > a
9 > a
10 > a
10 > a
11 > c
11 > c
12 > c
12 > c
13 > EOF
13 > EOF
14 $ hg ci -Am adda
14 $ hg ci -Am adda
15 adding a
15 adding a
16
16
17 $ cat > a <<EOF
17 $ cat > a <<EOF
18 > c
18 > c
19 > c
19 > c
20 > a
20 > a
21 > a
21 > a
22 > dd
22 > dd
23 > a
23 > a
24 > a
24 > a
25 > c
25 > c
26 > c
26 > c
27 > EOF
27 > EOF
28
28
29 default context
29 default context
30
30
31 $ hg diff --nodates
31 $ hg diff --nodates
32 diff -r cf9f4ba66af2 a
32 diff -r cf9f4ba66af2 a
33 --- a/a
33 --- a/a
34 +++ b/a
34 +++ b/a
35 @@ -2,7 +2,7 @@
35 @@ -2,7 +2,7 @@
36 c
36 c
37 a
37 a
38 a
38 a
39 -b
39 -b
40 +dd
40 +dd
41 a
41 a
42 a
42 a
43 c
43 c
44
44
45 invalid --unified
45 invalid --unified
46
46
47 $ hg diff --nodates -U foo
47 $ hg diff --nodates -U foo
48 abort: diff context lines count must be an integer, not 'foo'
48 abort: diff context lines count must be an integer, not 'foo'
49 [255]
49 [255]
50
50
51
51
52 $ hg diff --nodates -U 2
52 $ hg diff --nodates -U 2
53 diff -r cf9f4ba66af2 a
53 diff -r cf9f4ba66af2 a
54 --- a/a
54 --- a/a
55 +++ b/a
55 +++ b/a
56 @@ -3,5 +3,5 @@
56 @@ -3,5 +3,5 @@
57 a
57 a
58 a
58 a
59 -b
59 -b
60 +dd
60 +dd
61 a
61 a
62 a
62 a
63
63
64 $ hg --config diff.unified=2 diff --nodates
64 $ hg --config diff.unified=2 diff --nodates
65 diff -r cf9f4ba66af2 a
65 diff -r cf9f4ba66af2 a
66 --- a/a
66 --- a/a
67 +++ b/a
67 +++ b/a
68 @@ -3,5 +3,5 @@
68 @@ -3,5 +3,5 @@
69 a
69 a
70 a
70 a
71 -b
71 -b
72 +dd
72 +dd
73 a
73 a
74 a
74 a
75
75
76 $ hg diff --nodates -U 1
76 $ hg diff --nodates -U 1
77 diff -r cf9f4ba66af2 a
77 diff -r cf9f4ba66af2 a
78 --- a/a
78 --- a/a
79 +++ b/a
79 +++ b/a
80 @@ -4,3 +4,3 @@
80 @@ -4,3 +4,3 @@
81 a
81 a
82 -b
82 -b
83 +dd
83 +dd
84 a
84 a
85
85
86 invalid diff.unified
86 invalid diff.unified
87
87
88 $ hg --config diff.unified=foo diff --nodates
88 $ hg --config diff.unified=foo diff --nodates
89 abort: diff context lines count must be an integer, not 'foo'
89 abort: diff context lines count must be an integer, not 'foo'
90 [255]
90 [255]
91
91
92 noprefix config
92 noprefix config and option
93
93
94 $ hg --config diff.noprefix=True diff --nodates
94 $ hg --config diff.noprefix=True diff --nodates
95 diff -r cf9f4ba66af2 a
95 diff -r cf9f4ba66af2 a
96 --- a/a
96 --- a/a
97 +++ b/a
97 +++ b/a
98 @@ -2,7 +2,7 @@
98 @@ -2,7 +2,7 @@
99 c
99 c
100 a
100 a
101 a
101 a
102 -b
102 -b
103 +dd
103 +dd
104 a
104 a
105 a
105 a
106 c
106 c
107 $ hg diff --noprefix --nodates
108 diff -r cf9f4ba66af2 a
109 --- a/a
110 +++ b/a
111 @@ -2,7 +2,7 @@
112 c
113 a
114 a
115 -b
116 +dd
117 a
118 a
119 c
107
120
108 noprefix disabled in plain mode
121 noprefix config disabled in plain mode, but option still enabled
109
122
110 $ HGPLAIN=1 hg --config diff.noprefix=True diff --nodates
123 $ HGPLAIN=1 hg --config diff.noprefix=True diff --nodates
111 diff -r cf9f4ba66af2 a
124 diff -r cf9f4ba66af2 a
112 --- a/a
125 --- a/a
113 +++ b/a
126 +++ b/a
114 @@ -2,7 +2,7 @@
127 @@ -2,7 +2,7 @@
115 c
128 c
116 a
129 a
117 a
130 a
118 -b
131 -b
119 +dd
132 +dd
120 a
133 a
121 a
134 a
122 c
135 c
136 $ HGPLAIN=1 hg diff --noprefix --nodates
137 diff -r cf9f4ba66af2 a
138 --- a/a
139 +++ b/a
140 @@ -2,7 +2,7 @@
141 c
142 a
143 a
144 -b
145 +dd
146 a
147 a
148 c
123
149
124 $ cd ..
150 $ cd ..
125
151
126
152
127 0 lines of context hunk header matches gnu diff hunk header
153 0 lines of context hunk header matches gnu diff hunk header
128
154
129 $ hg init diffzero
155 $ hg init diffzero
130 $ cd diffzero
156 $ cd diffzero
131 $ cat > f1 << EOF
157 $ cat > f1 << EOF
132 > c2
158 > c2
133 > c4
159 > c4
134 > c5
160 > c5
135 > EOF
161 > EOF
136 $ hg commit -Am0
162 $ hg commit -Am0
137 adding f1
163 adding f1
138
164
139 $ cat > f2 << EOF
165 $ cat > f2 << EOF
140 > c1
166 > c1
141 > c2
167 > c2
142 > c3
168 > c3
143 > c4
169 > c4
144 > EOF
170 > EOF
145 $ mv f2 f1
171 $ mv f2 f1
146 $ hg diff -U0 --nodates
172 $ hg diff -U0 --nodates
147 diff -r 55d8ff78db23 f1
173 diff -r 55d8ff78db23 f1
148 --- a/f1
174 --- a/f1
149 +++ b/f1
175 +++ b/f1
150 @@ -0,0 +1,1 @@
176 @@ -0,0 +1,1 @@
151 +c1
177 +c1
152 @@ -1,0 +3,1 @@
178 @@ -1,0 +3,1 @@
153 +c3
179 +c3
154 @@ -3,1 +4,0 @@
180 @@ -3,1 +4,0 @@
155 -c5
181 -c5
156
182
157 $ hg diff -U0 --nodates --git
183 $ hg diff -U0 --nodates --git
158 diff --git a/f1 b/f1
184 diff --git a/f1 b/f1
159 --- a/f1
185 --- a/f1
160 +++ b/f1
186 +++ b/f1
161 @@ -0,0 +1,1 @@
187 @@ -0,0 +1,1 @@
162 +c1
188 +c1
163 @@ -1,0 +3,1 @@
189 @@ -1,0 +3,1 @@
164 +c3
190 +c3
165 @@ -3,1 +4,0 @@
191 @@ -3,1 +4,0 @@
166 -c5
192 -c5
167
193
168 $ hg diff -U0 --nodates -p
194 $ hg diff -U0 --nodates -p
169 diff -r 55d8ff78db23 f1
195 diff -r 55d8ff78db23 f1
170 --- a/f1
196 --- a/f1
171 +++ b/f1
197 +++ b/f1
172 @@ -0,0 +1,1 @@
198 @@ -0,0 +1,1 @@
173 +c1
199 +c1
174 @@ -1,0 +3,1 @@ c2
200 @@ -1,0 +3,1 @@ c2
175 +c3
201 +c3
176 @@ -3,1 +4,0 @@ c4
202 @@ -3,1 +4,0 @@ c4
177 -c5
203 -c5
178
204
179 $ echo a > f1
205 $ echo a > f1
180 $ hg ci -m movef2
206 $ hg ci -m movef2
181
207
182 Test diff headers terminating with TAB when necessary (issue3357)
208 Test diff headers terminating with TAB when necessary (issue3357)
183 Regular diff --nodates, file creation
209 Regular diff --nodates, file creation
184
210
185 $ hg mv f1 'f 1'
211 $ hg mv f1 'f 1'
186 $ echo b > 'f 1'
212 $ echo b > 'f 1'
187 $ hg diff --nodates 'f 1'
213 $ hg diff --nodates 'f 1'
188 diff -r 7574207d0d15 f 1
214 diff -r 7574207d0d15 f 1
189 --- /dev/null
215 --- /dev/null
190 +++ b/f 1
216 +++ b/f 1
191 @@ -0,0 +1,1 @@
217 @@ -0,0 +1,1 @@
192 +b
218 +b
193
219
194 Git diff, adding space
220 Git diff, adding space
195
221
196 $ hg diff --git
222 $ hg diff --git
197 diff --git a/f1 b/f 1
223 diff --git a/f1 b/f 1
198 rename from f1
224 rename from f1
199 rename to f 1
225 rename to f 1
200 --- a/f1
226 --- a/f1
201 +++ b/f 1
227 +++ b/f 1
202 @@ -1,1 +1,1 @@
228 @@ -1,1 +1,1 @@
203 -a
229 -a
204 +b
230 +b
205
231
206 Git diff with noprefix
232 Git diff with noprefix
207
233
208 $ hg --config diff.noprefix=True diff --git --nodates
234 $ hg --config diff.noprefix=True diff --git --nodates
209 diff --git a/f1 b/f 1
235 diff --git a/f1 b/f 1
210 rename from f1
236 rename from f1
211 rename to f 1
237 rename to f 1
212 --- a/f1
238 --- a/f1
213 +++ b/f 1
239 +++ b/f 1
214 @@ -1,1 +1,1 @@
240 @@ -1,1 +1,1 @@
215 -a
241 -a
216 +b
242 +b
217
243
218 noprefix config disabled in plain mode
244 noprefix config disabled in plain mode, but option still enabled
219
245
220 $ HGPLAIN=1 hg --config diff.noprefix=True diff --git --nodates
246 $ HGPLAIN=1 hg --config diff.noprefix=True diff --git --nodates
221 diff --git a/f1 b/f 1
247 diff --git a/f1 b/f 1
222 rename from f1
248 rename from f1
223 rename to f 1
249 rename to f 1
224 --- a/f1
250 --- a/f1
225 +++ b/f 1
251 +++ b/f 1
226 @@ -1,1 +1,1 @@
252 @@ -1,1 +1,1 @@
227 -a
253 -a
228 +b
254 +b
255 $ HGPLAIN=1 hg diff --git --noprefix --nodates
256 diff --git a/f1 b/f 1
257 rename from f1
258 rename to f 1
259 --- a/f1
260 +++ b/f 1
261 @@ -1,1 +1,1 @@
262 -a
263 +b
229
264
230 Regular diff --nodates, file deletion
265 Regular diff --nodates, file deletion
231
266
232 $ hg ci -m addspace
267 $ hg ci -m addspace
233 $ hg mv 'f 1' f1
268 $ hg mv 'f 1' f1
234 $ echo a > f1
269 $ echo a > f1
235 $ hg diff --nodates 'f 1'
270 $ hg diff --nodates 'f 1'
236 diff -r ca50fe67c9c7 f 1
271 diff -r ca50fe67c9c7 f 1
237 --- a/f 1
272 --- a/f 1
238 +++ /dev/null
273 +++ /dev/null
239 @@ -1,1 +0,0 @@
274 @@ -1,1 +0,0 @@
240 -b
275 -b
241
276
242 Git diff, removing space
277 Git diff, removing space
243
278
244 $ hg diff --git
279 $ hg diff --git
245 diff --git a/f 1 b/f1
280 diff --git a/f 1 b/f1
246 rename from f 1
281 rename from f 1
247 rename to f1
282 rename to f1
248 --- a/f 1
283 --- a/f 1
249 +++ b/f1
284 +++ b/f1
250 @@ -1,1 +1,1 @@
285 @@ -1,1 +1,1 @@
251 -b
286 -b
252 +a
287 +a
253
288
254 $ cd ..
289 $ cd ..
@@ -1,2115 +1,2116 b''
1 Short help:
1 Short help:
2
2
3 $ hg
3 $ hg
4 Mercurial Distributed SCM
4 Mercurial Distributed SCM
5
5
6 basic commands:
6 basic commands:
7
7
8 add add the specified files on the next commit
8 add add the specified files on the next commit
9 annotate show changeset information by line for each file
9 annotate show changeset information by line for each file
10 clone make a copy of an existing repository
10 clone make a copy of an existing repository
11 commit commit the specified files or all outstanding changes
11 commit commit the specified files or all outstanding changes
12 diff diff repository (or selected files)
12 diff diff repository (or selected files)
13 export dump the header and diffs for one or more changesets
13 export dump the header and diffs for one or more changesets
14 forget forget the specified files on the next commit
14 forget forget the specified files on the next commit
15 init create a new repository in the given directory
15 init create a new repository in the given directory
16 log show revision history of entire repository or files
16 log show revision history of entire repository or files
17 merge merge working directory with another revision
17 merge merge working directory with another revision
18 pull pull changes from the specified source
18 pull pull changes from the specified source
19 push push changes to the specified destination
19 push push changes to the specified destination
20 remove remove the specified files on the next commit
20 remove remove the specified files on the next commit
21 serve start stand-alone webserver
21 serve start stand-alone webserver
22 status show changed files in the working directory
22 status show changed files in the working directory
23 summary summarize working directory state
23 summary summarize working directory state
24 update update working directory (or switch revisions)
24 update update working directory (or switch revisions)
25
25
26 (use "hg help" for the full list of commands or "hg -v" for details)
26 (use "hg help" for the full list of commands or "hg -v" for details)
27
27
28 $ hg -q
28 $ hg -q
29 add add the specified files on the next commit
29 add add the specified files on the next commit
30 annotate show changeset information by line for each file
30 annotate show changeset information by line for each file
31 clone make a copy of an existing repository
31 clone make a copy of an existing repository
32 commit commit the specified files or all outstanding changes
32 commit commit the specified files or all outstanding changes
33 diff diff repository (or selected files)
33 diff diff repository (or selected files)
34 export dump the header and diffs for one or more changesets
34 export dump the header and diffs for one or more changesets
35 forget forget the specified files on the next commit
35 forget forget the specified files on the next commit
36 init create a new repository in the given directory
36 init create a new repository in the given directory
37 log show revision history of entire repository or files
37 log show revision history of entire repository or files
38 merge merge working directory with another revision
38 merge merge working directory with another revision
39 pull pull changes from the specified source
39 pull pull changes from the specified source
40 push push changes to the specified destination
40 push push changes to the specified destination
41 remove remove the specified files on the next commit
41 remove remove the specified files on the next commit
42 serve start stand-alone webserver
42 serve start stand-alone webserver
43 status show changed files in the working directory
43 status show changed files in the working directory
44 summary summarize working directory state
44 summary summarize working directory state
45 update update working directory (or switch revisions)
45 update update working directory (or switch revisions)
46
46
47 $ hg help
47 $ hg help
48 Mercurial Distributed SCM
48 Mercurial Distributed SCM
49
49
50 list of commands:
50 list of commands:
51
51
52 add add the specified files on the next commit
52 add add the specified files on the next commit
53 addremove add all new files, delete all missing files
53 addremove add all new files, delete all missing files
54 annotate show changeset information by line for each file
54 annotate show changeset information by line for each file
55 archive create an unversioned archive of a repository revision
55 archive create an unversioned archive of a repository revision
56 backout reverse effect of earlier changeset
56 backout reverse effect of earlier changeset
57 bisect subdivision search of changesets
57 bisect subdivision search of changesets
58 bookmarks create a new bookmark or list existing bookmarks
58 bookmarks create a new bookmark or list existing bookmarks
59 branch set or show the current branch name
59 branch set or show the current branch name
60 branches list repository named branches
60 branches list repository named branches
61 bundle create a changegroup file
61 bundle create a changegroup file
62 cat output the current or given revision of files
62 cat output the current or given revision of files
63 clone make a copy of an existing repository
63 clone make a copy of an existing repository
64 commit commit the specified files or all outstanding changes
64 commit commit the specified files or all outstanding changes
65 config show combined config settings from all hgrc files
65 config show combined config settings from all hgrc files
66 copy mark files as copied for the next commit
66 copy mark files as copied for the next commit
67 diff diff repository (or selected files)
67 diff diff repository (or selected files)
68 export dump the header and diffs for one or more changesets
68 export dump the header and diffs for one or more changesets
69 files list tracked files
69 files list tracked files
70 forget forget the specified files on the next commit
70 forget forget the specified files on the next commit
71 graft copy changes from other branches onto the current branch
71 graft copy changes from other branches onto the current branch
72 grep search for a pattern in specified files and revisions
72 grep search for a pattern in specified files and revisions
73 heads show branch heads
73 heads show branch heads
74 help show help for a given topic or a help overview
74 help show help for a given topic or a help overview
75 identify identify the working copy or specified revision
75 identify identify the working copy or specified revision
76 import import an ordered set of patches
76 import import an ordered set of patches
77 incoming show new changesets found in source
77 incoming show new changesets found in source
78 init create a new repository in the given directory
78 init create a new repository in the given directory
79 log show revision history of entire repository or files
79 log show revision history of entire repository or files
80 manifest output the current or given revision of the project manifest
80 manifest output the current or given revision of the project manifest
81 merge merge working directory with another revision
81 merge merge working directory with another revision
82 outgoing show changesets not found in the destination
82 outgoing show changesets not found in the destination
83 paths show aliases for remote repositories
83 paths show aliases for remote repositories
84 phase set or show the current phase name
84 phase set or show the current phase name
85 pull pull changes from the specified source
85 pull pull changes from the specified source
86 push push changes to the specified destination
86 push push changes to the specified destination
87 recover roll back an interrupted transaction
87 recover roll back an interrupted transaction
88 remove remove the specified files on the next commit
88 remove remove the specified files on the next commit
89 rename rename files; equivalent of copy + remove
89 rename rename files; equivalent of copy + remove
90 resolve redo merges or set/view the merge status of files
90 resolve redo merges or set/view the merge status of files
91 revert restore files to their checkout state
91 revert restore files to their checkout state
92 root print the root (top) of the current working directory
92 root print the root (top) of the current working directory
93 serve start stand-alone webserver
93 serve start stand-alone webserver
94 status show changed files in the working directory
94 status show changed files in the working directory
95 summary summarize working directory state
95 summary summarize working directory state
96 tag add one or more tags for the current or given revision
96 tag add one or more tags for the current or given revision
97 tags list repository tags
97 tags list repository tags
98 unbundle apply one or more changegroup files
98 unbundle apply one or more changegroup files
99 update update working directory (or switch revisions)
99 update update working directory (or switch revisions)
100 verify verify the integrity of the repository
100 verify verify the integrity of the repository
101 version output version and copyright information
101 version output version and copyright information
102
102
103 additional help topics:
103 additional help topics:
104
104
105 config Configuration Files
105 config Configuration Files
106 dates Date Formats
106 dates Date Formats
107 diffs Diff Formats
107 diffs Diff Formats
108 environment Environment Variables
108 environment Environment Variables
109 extensions Using Additional Features
109 extensions Using Additional Features
110 filesets Specifying File Sets
110 filesets Specifying File Sets
111 glossary Glossary
111 glossary Glossary
112 hgignore Syntax for Mercurial Ignore Files
112 hgignore Syntax for Mercurial Ignore Files
113 hgweb Configuring hgweb
113 hgweb Configuring hgweb
114 merge-tools Merge Tools
114 merge-tools Merge Tools
115 multirevs Specifying Multiple Revisions
115 multirevs Specifying Multiple Revisions
116 patterns File Name Patterns
116 patterns File Name Patterns
117 phases Working with Phases
117 phases Working with Phases
118 revisions Specifying Single Revisions
118 revisions Specifying Single Revisions
119 revsets Specifying Revision Sets
119 revsets Specifying Revision Sets
120 subrepos Subrepositories
120 subrepos Subrepositories
121 templating Template Usage
121 templating Template Usage
122 urls URL Paths
122 urls URL Paths
123
123
124 (use "hg help -v" to show built-in aliases and global options)
124 (use "hg help -v" to show built-in aliases and global options)
125
125
126 $ hg -q help
126 $ hg -q help
127 add add the specified files on the next commit
127 add add the specified files on the next commit
128 addremove add all new files, delete all missing files
128 addremove add all new files, delete all missing files
129 annotate show changeset information by line for each file
129 annotate show changeset information by line for each file
130 archive create an unversioned archive of a repository revision
130 archive create an unversioned archive of a repository revision
131 backout reverse effect of earlier changeset
131 backout reverse effect of earlier changeset
132 bisect subdivision search of changesets
132 bisect subdivision search of changesets
133 bookmarks create a new bookmark or list existing bookmarks
133 bookmarks create a new bookmark or list existing bookmarks
134 branch set or show the current branch name
134 branch set or show the current branch name
135 branches list repository named branches
135 branches list repository named branches
136 bundle create a changegroup file
136 bundle create a changegroup file
137 cat output the current or given revision of files
137 cat output the current or given revision of files
138 clone make a copy of an existing repository
138 clone make a copy of an existing repository
139 commit commit the specified files or all outstanding changes
139 commit commit the specified files or all outstanding changes
140 config show combined config settings from all hgrc files
140 config show combined config settings from all hgrc files
141 copy mark files as copied for the next commit
141 copy mark files as copied for the next commit
142 diff diff repository (or selected files)
142 diff diff repository (or selected files)
143 export dump the header and diffs for one or more changesets
143 export dump the header and diffs for one or more changesets
144 files list tracked files
144 files list tracked files
145 forget forget the specified files on the next commit
145 forget forget the specified files on the next commit
146 graft copy changes from other branches onto the current branch
146 graft copy changes from other branches onto the current branch
147 grep search for a pattern in specified files and revisions
147 grep search for a pattern in specified files and revisions
148 heads show branch heads
148 heads show branch heads
149 help show help for a given topic or a help overview
149 help show help for a given topic or a help overview
150 identify identify the working copy or specified revision
150 identify identify the working copy or specified revision
151 import import an ordered set of patches
151 import import an ordered set of patches
152 incoming show new changesets found in source
152 incoming show new changesets found in source
153 init create a new repository in the given directory
153 init create a new repository in the given directory
154 log show revision history of entire repository or files
154 log show revision history of entire repository or files
155 manifest output the current or given revision of the project manifest
155 manifest output the current or given revision of the project manifest
156 merge merge working directory with another revision
156 merge merge working directory with another revision
157 outgoing show changesets not found in the destination
157 outgoing show changesets not found in the destination
158 paths show aliases for remote repositories
158 paths show aliases for remote repositories
159 phase set or show the current phase name
159 phase set or show the current phase name
160 pull pull changes from the specified source
160 pull pull changes from the specified source
161 push push changes to the specified destination
161 push push changes to the specified destination
162 recover roll back an interrupted transaction
162 recover roll back an interrupted transaction
163 remove remove the specified files on the next commit
163 remove remove the specified files on the next commit
164 rename rename files; equivalent of copy + remove
164 rename rename files; equivalent of copy + remove
165 resolve redo merges or set/view the merge status of files
165 resolve redo merges or set/view the merge status of files
166 revert restore files to their checkout state
166 revert restore files to their checkout state
167 root print the root (top) of the current working directory
167 root print the root (top) of the current working directory
168 serve start stand-alone webserver
168 serve start stand-alone webserver
169 status show changed files in the working directory
169 status show changed files in the working directory
170 summary summarize working directory state
170 summary summarize working directory state
171 tag add one or more tags for the current or given revision
171 tag add one or more tags for the current or given revision
172 tags list repository tags
172 tags list repository tags
173 unbundle apply one or more changegroup files
173 unbundle apply one or more changegroup files
174 update update working directory (or switch revisions)
174 update update working directory (or switch revisions)
175 verify verify the integrity of the repository
175 verify verify the integrity of the repository
176 version output version and copyright information
176 version output version and copyright information
177
177
178 additional help topics:
178 additional help topics:
179
179
180 config Configuration Files
180 config Configuration Files
181 dates Date Formats
181 dates Date Formats
182 diffs Diff Formats
182 diffs Diff Formats
183 environment Environment Variables
183 environment Environment Variables
184 extensions Using Additional Features
184 extensions Using Additional Features
185 filesets Specifying File Sets
185 filesets Specifying File Sets
186 glossary Glossary
186 glossary Glossary
187 hgignore Syntax for Mercurial Ignore Files
187 hgignore Syntax for Mercurial Ignore Files
188 hgweb Configuring hgweb
188 hgweb Configuring hgweb
189 merge-tools Merge Tools
189 merge-tools Merge Tools
190 multirevs Specifying Multiple Revisions
190 multirevs Specifying Multiple Revisions
191 patterns File Name Patterns
191 patterns File Name Patterns
192 phases Working with Phases
192 phases Working with Phases
193 revisions Specifying Single Revisions
193 revisions Specifying Single Revisions
194 revsets Specifying Revision Sets
194 revsets Specifying Revision Sets
195 subrepos Subrepositories
195 subrepos Subrepositories
196 templating Template Usage
196 templating Template Usage
197 urls URL Paths
197 urls URL Paths
198
198
199 Test extension help:
199 Test extension help:
200 $ hg help extensions --config extensions.rebase= --config extensions.children=
200 $ hg help extensions --config extensions.rebase= --config extensions.children=
201 Using Additional Features
201 Using Additional Features
202 """""""""""""""""""""""""
202 """""""""""""""""""""""""
203
203
204 Mercurial has the ability to add new features through the use of
204 Mercurial has the ability to add new features through the use of
205 extensions. Extensions may add new commands, add options to existing
205 extensions. Extensions may add new commands, add options to existing
206 commands, change the default behavior of commands, or implement hooks.
206 commands, change the default behavior of commands, or implement hooks.
207
207
208 To enable the "foo" extension, either shipped with Mercurial or in the
208 To enable the "foo" extension, either shipped with Mercurial or in the
209 Python search path, create an entry for it in your configuration file,
209 Python search path, create an entry for it in your configuration file,
210 like this:
210 like this:
211
211
212 [extensions]
212 [extensions]
213 foo =
213 foo =
214
214
215 You may also specify the full path to an extension:
215 You may also specify the full path to an extension:
216
216
217 [extensions]
217 [extensions]
218 myfeature = ~/.hgext/myfeature.py
218 myfeature = ~/.hgext/myfeature.py
219
219
220 See "hg help config" for more information on configuration files.
220 See "hg help config" for more information on configuration files.
221
221
222 Extensions are not loaded by default for a variety of reasons: they can
222 Extensions are not loaded by default for a variety of reasons: they can
223 increase startup overhead; they may be meant for advanced usage only; they
223 increase startup overhead; they may be meant for advanced usage only; they
224 may provide potentially dangerous abilities (such as letting you destroy
224 may provide potentially dangerous abilities (such as letting you destroy
225 or modify history); they might not be ready for prime time; or they may
225 or modify history); they might not be ready for prime time; or they may
226 alter some usual behaviors of stock Mercurial. It is thus up to the user
226 alter some usual behaviors of stock Mercurial. It is thus up to the user
227 to activate extensions as needed.
227 to activate extensions as needed.
228
228
229 To explicitly disable an extension enabled in a configuration file of
229 To explicitly disable an extension enabled in a configuration file of
230 broader scope, prepend its path with !:
230 broader scope, prepend its path with !:
231
231
232 [extensions]
232 [extensions]
233 # disabling extension bar residing in /path/to/extension/bar.py
233 # disabling extension bar residing in /path/to/extension/bar.py
234 bar = !/path/to/extension/bar.py
234 bar = !/path/to/extension/bar.py
235 # ditto, but no path was supplied for extension baz
235 # ditto, but no path was supplied for extension baz
236 baz = !
236 baz = !
237
237
238 enabled extensions:
238 enabled extensions:
239
239
240 children command to display child changesets (DEPRECATED)
240 children command to display child changesets (DEPRECATED)
241 rebase command to move sets of revisions to a different ancestor
241 rebase command to move sets of revisions to a different ancestor
242
242
243 disabled extensions:
243 disabled extensions:
244
244
245 acl hooks for controlling repository access
245 acl hooks for controlling repository access
246 blackbox log repository events to a blackbox for debugging
246 blackbox log repository events to a blackbox for debugging
247 bugzilla hooks for integrating with the Bugzilla bug tracker
247 bugzilla hooks for integrating with the Bugzilla bug tracker
248 churn command to display statistics about repository history
248 churn command to display statistics about repository history
249 color colorize output from some commands
249 color colorize output from some commands
250 convert import revisions from foreign VCS repositories into
250 convert import revisions from foreign VCS repositories into
251 Mercurial
251 Mercurial
252 eol automatically manage newlines in repository files
252 eol automatically manage newlines in repository files
253 extdiff command to allow external programs to compare revisions
253 extdiff command to allow external programs to compare revisions
254 factotum http authentication with factotum
254 factotum http authentication with factotum
255 gpg commands to sign and verify changesets
255 gpg commands to sign and verify changesets
256 hgcia hooks for integrating with the CIA.vc notification service
256 hgcia hooks for integrating with the CIA.vc notification service
257 hgk browse the repository in a graphical way
257 hgk browse the repository in a graphical way
258 highlight syntax highlighting for hgweb (requires Pygments)
258 highlight syntax highlighting for hgweb (requires Pygments)
259 histedit interactive history editing
259 histedit interactive history editing
260 keyword expand keywords in tracked files
260 keyword expand keywords in tracked files
261 largefiles track large binary files
261 largefiles track large binary files
262 mq manage a stack of patches
262 mq manage a stack of patches
263 notify hooks for sending email push notifications
263 notify hooks for sending email push notifications
264 pager browse command output with an external pager
264 pager browse command output with an external pager
265 patchbomb command to send changesets as (a series of) patch emails
265 patchbomb command to send changesets as (a series of) patch emails
266 progress show progress bars for some actions
266 progress show progress bars for some actions
267 purge command to delete untracked files from the working
267 purge command to delete untracked files from the working
268 directory
268 directory
269 record commands to interactively select changes for
269 record commands to interactively select changes for
270 commit/qrefresh
270 commit/qrefresh
271 relink recreates hardlinks between repository clones
271 relink recreates hardlinks between repository clones
272 schemes extend schemes with shortcuts to repository swarms
272 schemes extend schemes with shortcuts to repository swarms
273 share share a common history between several working directories
273 share share a common history between several working directories
274 shelve save and restore changes to the working directory
274 shelve save and restore changes to the working directory
275 strip strip changesets and their descendants from history
275 strip strip changesets and their descendants from history
276 transplant command to transplant changesets from another branch
276 transplant command to transplant changesets from another branch
277 win32mbcs allow the use of MBCS paths with problematic encodings
277 win32mbcs allow the use of MBCS paths with problematic encodings
278 zeroconf discover and advertise repositories on the local network
278 zeroconf discover and advertise repositories on the local network
279 Test short command list with verbose option
279 Test short command list with verbose option
280
280
281 $ hg -v help shortlist
281 $ hg -v help shortlist
282 Mercurial Distributed SCM
282 Mercurial Distributed SCM
283
283
284 basic commands:
284 basic commands:
285
285
286 add add the specified files on the next commit
286 add add the specified files on the next commit
287 annotate, blame
287 annotate, blame
288 show changeset information by line for each file
288 show changeset information by line for each file
289 clone make a copy of an existing repository
289 clone make a copy of an existing repository
290 commit, ci commit the specified files or all outstanding changes
290 commit, ci commit the specified files or all outstanding changes
291 diff diff repository (or selected files)
291 diff diff repository (or selected files)
292 export dump the header and diffs for one or more changesets
292 export dump the header and diffs for one or more changesets
293 forget forget the specified files on the next commit
293 forget forget the specified files on the next commit
294 init create a new repository in the given directory
294 init create a new repository in the given directory
295 log, history show revision history of entire repository or files
295 log, history show revision history of entire repository or files
296 merge merge working directory with another revision
296 merge merge working directory with another revision
297 pull pull changes from the specified source
297 pull pull changes from the specified source
298 push push changes to the specified destination
298 push push changes to the specified destination
299 remove, rm remove the specified files on the next commit
299 remove, rm remove the specified files on the next commit
300 serve start stand-alone webserver
300 serve start stand-alone webserver
301 status, st show changed files in the working directory
301 status, st show changed files in the working directory
302 summary, sum summarize working directory state
302 summary, sum summarize working directory state
303 update, up, checkout, co
303 update, up, checkout, co
304 update working directory (or switch revisions)
304 update working directory (or switch revisions)
305
305
306 global options ([+] can be repeated):
306 global options ([+] can be repeated):
307
307
308 -R --repository REPO repository root directory or name of overlay bundle
308 -R --repository REPO repository root directory or name of overlay bundle
309 file
309 file
310 --cwd DIR change working directory
310 --cwd DIR change working directory
311 -y --noninteractive do not prompt, automatically pick the first choice for
311 -y --noninteractive do not prompt, automatically pick the first choice for
312 all prompts
312 all prompts
313 -q --quiet suppress output
313 -q --quiet suppress output
314 -v --verbose enable additional output
314 -v --verbose enable additional output
315 --config CONFIG [+] set/override config option (use 'section.name=value')
315 --config CONFIG [+] set/override config option (use 'section.name=value')
316 --debug enable debugging output
316 --debug enable debugging output
317 --debugger start debugger
317 --debugger start debugger
318 --encoding ENCODE set the charset encoding (default: ascii)
318 --encoding ENCODE set the charset encoding (default: ascii)
319 --encodingmode MODE set the charset encoding mode (default: strict)
319 --encodingmode MODE set the charset encoding mode (default: strict)
320 --traceback always print a traceback on exception
320 --traceback always print a traceback on exception
321 --time time how long the command takes
321 --time time how long the command takes
322 --profile print command execution profile
322 --profile print command execution profile
323 --version output version information and exit
323 --version output version information and exit
324 -h --help display help and exit
324 -h --help display help and exit
325 --hidden consider hidden changesets
325 --hidden consider hidden changesets
326
326
327 (use "hg help" for the full list of commands)
327 (use "hg help" for the full list of commands)
328
328
329 $ hg add -h
329 $ hg add -h
330 hg add [OPTION]... [FILE]...
330 hg add [OPTION]... [FILE]...
331
331
332 add the specified files on the next commit
332 add the specified files on the next commit
333
333
334 Schedule files to be version controlled and added to the repository.
334 Schedule files to be version controlled and added to the repository.
335
335
336 The files will be added to the repository at the next commit. To undo an
336 The files will be added to the repository at the next commit. To undo an
337 add before that, see "hg forget".
337 add before that, see "hg forget".
338
338
339 If no names are given, add all files to the repository.
339 If no names are given, add all files to the repository.
340
340
341 Returns 0 if all files are successfully added.
341 Returns 0 if all files are successfully added.
342
342
343 options ([+] can be repeated):
343 options ([+] can be repeated):
344
344
345 -I --include PATTERN [+] include names matching the given patterns
345 -I --include PATTERN [+] include names matching the given patterns
346 -X --exclude PATTERN [+] exclude names matching the given patterns
346 -X --exclude PATTERN [+] exclude names matching the given patterns
347 -S --subrepos recurse into subrepositories
347 -S --subrepos recurse into subrepositories
348 -n --dry-run do not perform actions, just print output
348 -n --dry-run do not perform actions, just print output
349
349
350 (some details hidden, use --verbose to show complete help)
350 (some details hidden, use --verbose to show complete help)
351
351
352 Verbose help for add
352 Verbose help for add
353
353
354 $ hg add -hv
354 $ hg add -hv
355 hg add [OPTION]... [FILE]...
355 hg add [OPTION]... [FILE]...
356
356
357 add the specified files on the next commit
357 add the specified files on the next commit
358
358
359 Schedule files to be version controlled and added to the repository.
359 Schedule files to be version controlled and added to the repository.
360
360
361 The files will be added to the repository at the next commit. To undo an
361 The files will be added to the repository at the next commit. To undo an
362 add before that, see "hg forget".
362 add before that, see "hg forget".
363
363
364 If no names are given, add all files to the repository.
364 If no names are given, add all files to the repository.
365
365
366 An example showing how new (unknown) files are added automatically by "hg
366 An example showing how new (unknown) files are added automatically by "hg
367 add":
367 add":
368
368
369 $ ls
369 $ ls
370 foo.c
370 foo.c
371 $ hg status
371 $ hg status
372 ? foo.c
372 ? foo.c
373 $ hg add
373 $ hg add
374 adding foo.c
374 adding foo.c
375 $ hg status
375 $ hg status
376 A foo.c
376 A foo.c
377
377
378 Returns 0 if all files are successfully added.
378 Returns 0 if all files are successfully added.
379
379
380 options ([+] can be repeated):
380 options ([+] can be repeated):
381
381
382 -I --include PATTERN [+] include names matching the given patterns
382 -I --include PATTERN [+] include names matching the given patterns
383 -X --exclude PATTERN [+] exclude names matching the given patterns
383 -X --exclude PATTERN [+] exclude names matching the given patterns
384 -S --subrepos recurse into subrepositories
384 -S --subrepos recurse into subrepositories
385 -n --dry-run do not perform actions, just print output
385 -n --dry-run do not perform actions, just print output
386
386
387 global options ([+] can be repeated):
387 global options ([+] can be repeated):
388
388
389 -R --repository REPO repository root directory or name of overlay bundle
389 -R --repository REPO repository root directory or name of overlay bundle
390 file
390 file
391 --cwd DIR change working directory
391 --cwd DIR change working directory
392 -y --noninteractive do not prompt, automatically pick the first choice for
392 -y --noninteractive do not prompt, automatically pick the first choice for
393 all prompts
393 all prompts
394 -q --quiet suppress output
394 -q --quiet suppress output
395 -v --verbose enable additional output
395 -v --verbose enable additional output
396 --config CONFIG [+] set/override config option (use 'section.name=value')
396 --config CONFIG [+] set/override config option (use 'section.name=value')
397 --debug enable debugging output
397 --debug enable debugging output
398 --debugger start debugger
398 --debugger start debugger
399 --encoding ENCODE set the charset encoding (default: ascii)
399 --encoding ENCODE set the charset encoding (default: ascii)
400 --encodingmode MODE set the charset encoding mode (default: strict)
400 --encodingmode MODE set the charset encoding mode (default: strict)
401 --traceback always print a traceback on exception
401 --traceback always print a traceback on exception
402 --time time how long the command takes
402 --time time how long the command takes
403 --profile print command execution profile
403 --profile print command execution profile
404 --version output version information and exit
404 --version output version information and exit
405 -h --help display help and exit
405 -h --help display help and exit
406 --hidden consider hidden changesets
406 --hidden consider hidden changesets
407
407
408 Test help option with version option
408 Test help option with version option
409
409
410 $ hg add -h --version
410 $ hg add -h --version
411 Mercurial Distributed SCM (version *) (glob)
411 Mercurial Distributed SCM (version *) (glob)
412 (see http://mercurial.selenic.com for more information)
412 (see http://mercurial.selenic.com for more information)
413
413
414 Copyright (C) 2005-2014 Matt Mackall and others
414 Copyright (C) 2005-2014 Matt Mackall and others
415 This is free software; see the source for copying conditions. There is NO
415 This is free software; see the source for copying conditions. There is NO
416 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
416 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
417
417
418 $ hg add --skjdfks
418 $ hg add --skjdfks
419 hg add: option --skjdfks not recognized
419 hg add: option --skjdfks not recognized
420 hg add [OPTION]... [FILE]...
420 hg add [OPTION]... [FILE]...
421
421
422 add the specified files on the next commit
422 add the specified files on the next commit
423
423
424 options ([+] can be repeated):
424 options ([+] can be repeated):
425
425
426 -I --include PATTERN [+] include names matching the given patterns
426 -I --include PATTERN [+] include names matching the given patterns
427 -X --exclude PATTERN [+] exclude names matching the given patterns
427 -X --exclude PATTERN [+] exclude names matching the given patterns
428 -S --subrepos recurse into subrepositories
428 -S --subrepos recurse into subrepositories
429 -n --dry-run do not perform actions, just print output
429 -n --dry-run do not perform actions, just print output
430
430
431 (use "hg add -h" to show more help)
431 (use "hg add -h" to show more help)
432 [255]
432 [255]
433
433
434 Test ambiguous command help
434 Test ambiguous command help
435
435
436 $ hg help ad
436 $ hg help ad
437 list of commands:
437 list of commands:
438
438
439 add add the specified files on the next commit
439 add add the specified files on the next commit
440 addremove add all new files, delete all missing files
440 addremove add all new files, delete all missing files
441
441
442 (use "hg help -v ad" to show built-in aliases and global options)
442 (use "hg help -v ad" to show built-in aliases and global options)
443
443
444 Test command without options
444 Test command without options
445
445
446 $ hg help verify
446 $ hg help verify
447 hg verify
447 hg verify
448
448
449 verify the integrity of the repository
449 verify the integrity of the repository
450
450
451 Verify the integrity of the current repository.
451 Verify the integrity of the current repository.
452
452
453 This will perform an extensive check of the repository's integrity,
453 This will perform an extensive check of the repository's integrity,
454 validating the hashes and checksums of each entry in the changelog,
454 validating the hashes and checksums of each entry in the changelog,
455 manifest, and tracked files, as well as the integrity of their crosslinks
455 manifest, and tracked files, as well as the integrity of their crosslinks
456 and indices.
456 and indices.
457
457
458 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption for more
458 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption for more
459 information about recovery from corruption of the repository.
459 information about recovery from corruption of the repository.
460
460
461 Returns 0 on success, 1 if errors are encountered.
461 Returns 0 on success, 1 if errors are encountered.
462
462
463 (some details hidden, use --verbose to show complete help)
463 (some details hidden, use --verbose to show complete help)
464
464
465 $ hg help diff
465 $ hg help diff
466 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
466 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
467
467
468 diff repository (or selected files)
468 diff repository (or selected files)
469
469
470 Show differences between revisions for the specified files.
470 Show differences between revisions for the specified files.
471
471
472 Differences between files are shown using the unified diff format.
472 Differences between files are shown using the unified diff format.
473
473
474 Note:
474 Note:
475 diff may generate unexpected results for merges, as it will default to
475 diff may generate unexpected results for merges, as it will default to
476 comparing against the working directory's first parent changeset if no
476 comparing against the working directory's first parent changeset if no
477 revisions are specified.
477 revisions are specified.
478
478
479 When two revision arguments are given, then changes are shown between
479 When two revision arguments are given, then changes are shown between
480 those revisions. If only one revision is specified then that revision is
480 those revisions. If only one revision is specified then that revision is
481 compared to the working directory, and, when no revisions are specified,
481 compared to the working directory, and, when no revisions are specified,
482 the working directory files are compared to its parent.
482 the working directory files are compared to its parent.
483
483
484 Alternatively you can specify -c/--change with a revision to see the
484 Alternatively you can specify -c/--change with a revision to see the
485 changes in that changeset relative to its first parent.
485 changes in that changeset relative to its first parent.
486
486
487 Without the -a/--text option, diff will avoid generating diffs of files it
487 Without the -a/--text option, diff will avoid generating diffs of files it
488 detects as binary. With -a, diff will generate a diff anyway, probably
488 detects as binary. With -a, diff will generate a diff anyway, probably
489 with undesirable results.
489 with undesirable results.
490
490
491 Use the -g/--git option to generate diffs in the git extended diff format.
491 Use the -g/--git option to generate diffs in the git extended diff format.
492 For more information, read "hg help diffs".
492 For more information, read "hg help diffs".
493
493
494 Returns 0 on success.
494 Returns 0 on success.
495
495
496 options ([+] can be repeated):
496 options ([+] can be repeated):
497
497
498 -r --rev REV [+] revision
498 -r --rev REV [+] revision
499 -c --change REV change made by revision
499 -c --change REV change made by revision
500 -a --text treat all files as text
500 -a --text treat all files as text
501 -g --git use git extended diff format
501 -g --git use git extended diff format
502 --nodates omit dates from diff headers
502 --nodates omit dates from diff headers
503 --noprefix omit a/ and b/ prefixes from filenames
503 -p --show-function show which function each change is in
504 -p --show-function show which function each change is in
504 --reverse produce a diff that undoes the changes
505 --reverse produce a diff that undoes the changes
505 -w --ignore-all-space ignore white space when comparing lines
506 -w --ignore-all-space ignore white space when comparing lines
506 -b --ignore-space-change ignore changes in the amount of white space
507 -b --ignore-space-change ignore changes in the amount of white space
507 -B --ignore-blank-lines ignore changes whose lines are all blank
508 -B --ignore-blank-lines ignore changes whose lines are all blank
508 -U --unified NUM number of lines of context to show
509 -U --unified NUM number of lines of context to show
509 --stat output diffstat-style summary of changes
510 --stat output diffstat-style summary of changes
510 -I --include PATTERN [+] include names matching the given patterns
511 -I --include PATTERN [+] include names matching the given patterns
511 -X --exclude PATTERN [+] exclude names matching the given patterns
512 -X --exclude PATTERN [+] exclude names matching the given patterns
512 -S --subrepos recurse into subrepositories
513 -S --subrepos recurse into subrepositories
513
514
514 (some details hidden, use --verbose to show complete help)
515 (some details hidden, use --verbose to show complete help)
515
516
516 $ hg help status
517 $ hg help status
517 hg status [OPTION]... [FILE]...
518 hg status [OPTION]... [FILE]...
518
519
519 aliases: st
520 aliases: st
520
521
521 show changed files in the working directory
522 show changed files in the working directory
522
523
523 Show status of files in the repository. If names are given, only files
524 Show status of files in the repository. If names are given, only files
524 that match are shown. Files that are clean or ignored or the source of a
525 that match are shown. Files that are clean or ignored or the source of a
525 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
526 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
526 -C/--copies or -A/--all are given. Unless options described with "show
527 -C/--copies or -A/--all are given. Unless options described with "show
527 only ..." are given, the options -mardu are used.
528 only ..." are given, the options -mardu are used.
528
529
529 Option -q/--quiet hides untracked (unknown and ignored) files unless
530 Option -q/--quiet hides untracked (unknown and ignored) files unless
530 explicitly requested with -u/--unknown or -i/--ignored.
531 explicitly requested with -u/--unknown or -i/--ignored.
531
532
532 Note:
533 Note:
533 status may appear to disagree with diff if permissions have changed or
534 status may appear to disagree with diff if permissions have changed or
534 a merge has occurred. The standard diff format does not report
535 a merge has occurred. The standard diff format does not report
535 permission changes and diff only reports changes relative to one merge
536 permission changes and diff only reports changes relative to one merge
536 parent.
537 parent.
537
538
538 If one revision is given, it is used as the base revision. If two
539 If one revision is given, it is used as the base revision. If two
539 revisions are given, the differences between them are shown. The --change
540 revisions are given, the differences between them are shown. The --change
540 option can also be used as a shortcut to list the changed files of a
541 option can also be used as a shortcut to list the changed files of a
541 revision from its first parent.
542 revision from its first parent.
542
543
543 The codes used to show the status of files are:
544 The codes used to show the status of files are:
544
545
545 M = modified
546 M = modified
546 A = added
547 A = added
547 R = removed
548 R = removed
548 C = clean
549 C = clean
549 ! = missing (deleted by non-hg command, but still tracked)
550 ! = missing (deleted by non-hg command, but still tracked)
550 ? = not tracked
551 ? = not tracked
551 I = ignored
552 I = ignored
552 = origin of the previous file (with --copies)
553 = origin of the previous file (with --copies)
553
554
554 Returns 0 on success.
555 Returns 0 on success.
555
556
556 options ([+] can be repeated):
557 options ([+] can be repeated):
557
558
558 -A --all show status of all files
559 -A --all show status of all files
559 -m --modified show only modified files
560 -m --modified show only modified files
560 -a --added show only added files
561 -a --added show only added files
561 -r --removed show only removed files
562 -r --removed show only removed files
562 -d --deleted show only deleted (but tracked) files
563 -d --deleted show only deleted (but tracked) files
563 -c --clean show only files without changes
564 -c --clean show only files without changes
564 -u --unknown show only unknown (not tracked) files
565 -u --unknown show only unknown (not tracked) files
565 -i --ignored show only ignored files
566 -i --ignored show only ignored files
566 -n --no-status hide status prefix
567 -n --no-status hide status prefix
567 -C --copies show source of copied files
568 -C --copies show source of copied files
568 -0 --print0 end filenames with NUL, for use with xargs
569 -0 --print0 end filenames with NUL, for use with xargs
569 --rev REV [+] show difference from revision
570 --rev REV [+] show difference from revision
570 --change REV list the changed files of a revision
571 --change REV list the changed files of a revision
571 -I --include PATTERN [+] include names matching the given patterns
572 -I --include PATTERN [+] include names matching the given patterns
572 -X --exclude PATTERN [+] exclude names matching the given patterns
573 -X --exclude PATTERN [+] exclude names matching the given patterns
573 -S --subrepos recurse into subrepositories
574 -S --subrepos recurse into subrepositories
574
575
575 (some details hidden, use --verbose to show complete help)
576 (some details hidden, use --verbose to show complete help)
576
577
577 $ hg -q help status
578 $ hg -q help status
578 hg status [OPTION]... [FILE]...
579 hg status [OPTION]... [FILE]...
579
580
580 show changed files in the working directory
581 show changed files in the working directory
581
582
582 $ hg help foo
583 $ hg help foo
583 abort: no such help topic: foo
584 abort: no such help topic: foo
584 (try "hg help --keyword foo")
585 (try "hg help --keyword foo")
585 [255]
586 [255]
586
587
587 $ hg skjdfks
588 $ hg skjdfks
588 hg: unknown command 'skjdfks'
589 hg: unknown command 'skjdfks'
589 Mercurial Distributed SCM
590 Mercurial Distributed SCM
590
591
591 basic commands:
592 basic commands:
592
593
593 add add the specified files on the next commit
594 add add the specified files on the next commit
594 annotate show changeset information by line for each file
595 annotate show changeset information by line for each file
595 clone make a copy of an existing repository
596 clone make a copy of an existing repository
596 commit commit the specified files or all outstanding changes
597 commit commit the specified files or all outstanding changes
597 diff diff repository (or selected files)
598 diff diff repository (or selected files)
598 export dump the header and diffs for one or more changesets
599 export dump the header and diffs for one or more changesets
599 forget forget the specified files on the next commit
600 forget forget the specified files on the next commit
600 init create a new repository in the given directory
601 init create a new repository in the given directory
601 log show revision history of entire repository or files
602 log show revision history of entire repository or files
602 merge merge working directory with another revision
603 merge merge working directory with another revision
603 pull pull changes from the specified source
604 pull pull changes from the specified source
604 push push changes to the specified destination
605 push push changes to the specified destination
605 remove remove the specified files on the next commit
606 remove remove the specified files on the next commit
606 serve start stand-alone webserver
607 serve start stand-alone webserver
607 status show changed files in the working directory
608 status show changed files in the working directory
608 summary summarize working directory state
609 summary summarize working directory state
609 update update working directory (or switch revisions)
610 update update working directory (or switch revisions)
610
611
611 (use "hg help" for the full list of commands or "hg -v" for details)
612 (use "hg help" for the full list of commands or "hg -v" for details)
612 [255]
613 [255]
613
614
614
615
615 $ cat > helpext.py <<EOF
616 $ cat > helpext.py <<EOF
616 > import os
617 > import os
617 > from mercurial import cmdutil, commands
618 > from mercurial import cmdutil, commands
618 >
619 >
619 > cmdtable = {}
620 > cmdtable = {}
620 > command = cmdutil.command(cmdtable)
621 > command = cmdutil.command(cmdtable)
621 >
622 >
622 > @command('nohelp',
623 > @command('nohelp',
623 > [('', 'longdesc', 3, 'x'*90),
624 > [('', 'longdesc', 3, 'x'*90),
624 > ('n', '', None, 'normal desc'),
625 > ('n', '', None, 'normal desc'),
625 > ('', 'newline', '', 'line1\nline2')],
626 > ('', 'newline', '', 'line1\nline2')],
626 > 'hg nohelp',
627 > 'hg nohelp',
627 > norepo=True)
628 > norepo=True)
628 > @command('debugoptDEP', [('', 'dopt', None, 'option is DEPRECATED')])
629 > @command('debugoptDEP', [('', 'dopt', None, 'option is DEPRECATED')])
629 > def nohelp(ui, *args, **kwargs):
630 > def nohelp(ui, *args, **kwargs):
630 > pass
631 > pass
631 >
632 >
632 > EOF
633 > EOF
633 $ echo '[extensions]' >> $HGRCPATH
634 $ echo '[extensions]' >> $HGRCPATH
634 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
635 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
635
636
636 Test command with no help text
637 Test command with no help text
637
638
638 $ hg help nohelp
639 $ hg help nohelp
639 hg nohelp
640 hg nohelp
640
641
641 (no help text available)
642 (no help text available)
642
643
643 options:
644 options:
644
645
645 --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
646 --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
646 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3)
647 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3)
647 -n -- normal desc
648 -n -- normal desc
648 --newline VALUE line1 line2
649 --newline VALUE line1 line2
649
650
650 (some details hidden, use --verbose to show complete help)
651 (some details hidden, use --verbose to show complete help)
651
652
652 $ hg help -k nohelp
653 $ hg help -k nohelp
653 Commands:
654 Commands:
654
655
655 nohelp hg nohelp
656 nohelp hg nohelp
656
657
657 Extension Commands:
658 Extension Commands:
658
659
659 nohelp (no help text available)
660 nohelp (no help text available)
660
661
661 Test that default list of commands omits extension commands
662 Test that default list of commands omits extension commands
662
663
663 $ hg help
664 $ hg help
664 Mercurial Distributed SCM
665 Mercurial Distributed SCM
665
666
666 list of commands:
667 list of commands:
667
668
668 add add the specified files on the next commit
669 add add the specified files on the next commit
669 addremove add all new files, delete all missing files
670 addremove add all new files, delete all missing files
670 annotate show changeset information by line for each file
671 annotate show changeset information by line for each file
671 archive create an unversioned archive of a repository revision
672 archive create an unversioned archive of a repository revision
672 backout reverse effect of earlier changeset
673 backout reverse effect of earlier changeset
673 bisect subdivision search of changesets
674 bisect subdivision search of changesets
674 bookmarks create a new bookmark or list existing bookmarks
675 bookmarks create a new bookmark or list existing bookmarks
675 branch set or show the current branch name
676 branch set or show the current branch name
676 branches list repository named branches
677 branches list repository named branches
677 bundle create a changegroup file
678 bundle create a changegroup file
678 cat output the current or given revision of files
679 cat output the current or given revision of files
679 clone make a copy of an existing repository
680 clone make a copy of an existing repository
680 commit commit the specified files or all outstanding changes
681 commit commit the specified files or all outstanding changes
681 config show combined config settings from all hgrc files
682 config show combined config settings from all hgrc files
682 copy mark files as copied for the next commit
683 copy mark files as copied for the next commit
683 diff diff repository (or selected files)
684 diff diff repository (or selected files)
684 export dump the header and diffs for one or more changesets
685 export dump the header and diffs for one or more changesets
685 files list tracked files
686 files list tracked files
686 forget forget the specified files on the next commit
687 forget forget the specified files on the next commit
687 graft copy changes from other branches onto the current branch
688 graft copy changes from other branches onto the current branch
688 grep search for a pattern in specified files and revisions
689 grep search for a pattern in specified files and revisions
689 heads show branch heads
690 heads show branch heads
690 help show help for a given topic or a help overview
691 help show help for a given topic or a help overview
691 identify identify the working copy or specified revision
692 identify identify the working copy or specified revision
692 import import an ordered set of patches
693 import import an ordered set of patches
693 incoming show new changesets found in source
694 incoming show new changesets found in source
694 init create a new repository in the given directory
695 init create a new repository in the given directory
695 log show revision history of entire repository or files
696 log show revision history of entire repository or files
696 manifest output the current or given revision of the project manifest
697 manifest output the current or given revision of the project manifest
697 merge merge working directory with another revision
698 merge merge working directory with another revision
698 outgoing show changesets not found in the destination
699 outgoing show changesets not found in the destination
699 paths show aliases for remote repositories
700 paths show aliases for remote repositories
700 phase set or show the current phase name
701 phase set or show the current phase name
701 pull pull changes from the specified source
702 pull pull changes from the specified source
702 push push changes to the specified destination
703 push push changes to the specified destination
703 recover roll back an interrupted transaction
704 recover roll back an interrupted transaction
704 remove remove the specified files on the next commit
705 remove remove the specified files on the next commit
705 rename rename files; equivalent of copy + remove
706 rename rename files; equivalent of copy + remove
706 resolve redo merges or set/view the merge status of files
707 resolve redo merges or set/view the merge status of files
707 revert restore files to their checkout state
708 revert restore files to their checkout state
708 root print the root (top) of the current working directory
709 root print the root (top) of the current working directory
709 serve start stand-alone webserver
710 serve start stand-alone webserver
710 status show changed files in the working directory
711 status show changed files in the working directory
711 summary summarize working directory state
712 summary summarize working directory state
712 tag add one or more tags for the current or given revision
713 tag add one or more tags for the current or given revision
713 tags list repository tags
714 tags list repository tags
714 unbundle apply one or more changegroup files
715 unbundle apply one or more changegroup files
715 update update working directory (or switch revisions)
716 update update working directory (or switch revisions)
716 verify verify the integrity of the repository
717 verify verify the integrity of the repository
717 version output version and copyright information
718 version output version and copyright information
718
719
719 enabled extensions:
720 enabled extensions:
720
721
721 helpext (no help text available)
722 helpext (no help text available)
722
723
723 additional help topics:
724 additional help topics:
724
725
725 config Configuration Files
726 config Configuration Files
726 dates Date Formats
727 dates Date Formats
727 diffs Diff Formats
728 diffs Diff Formats
728 environment Environment Variables
729 environment Environment Variables
729 extensions Using Additional Features
730 extensions Using Additional Features
730 filesets Specifying File Sets
731 filesets Specifying File Sets
731 glossary Glossary
732 glossary Glossary
732 hgignore Syntax for Mercurial Ignore Files
733 hgignore Syntax for Mercurial Ignore Files
733 hgweb Configuring hgweb
734 hgweb Configuring hgweb
734 merge-tools Merge Tools
735 merge-tools Merge Tools
735 multirevs Specifying Multiple Revisions
736 multirevs Specifying Multiple Revisions
736 patterns File Name Patterns
737 patterns File Name Patterns
737 phases Working with Phases
738 phases Working with Phases
738 revisions Specifying Single Revisions
739 revisions Specifying Single Revisions
739 revsets Specifying Revision Sets
740 revsets Specifying Revision Sets
740 subrepos Subrepositories
741 subrepos Subrepositories
741 templating Template Usage
742 templating Template Usage
742 urls URL Paths
743 urls URL Paths
743
744
744 (use "hg help -v" to show built-in aliases and global options)
745 (use "hg help -v" to show built-in aliases and global options)
745
746
746
747
747 Test list of internal help commands
748 Test list of internal help commands
748
749
749 $ hg help debug
750 $ hg help debug
750 debug commands (internal and unsupported):
751 debug commands (internal and unsupported):
751
752
752 debugancestor
753 debugancestor
753 find the ancestor revision of two revisions in a given index
754 find the ancestor revision of two revisions in a given index
754 debugbuilddag
755 debugbuilddag
755 builds a repo with a given DAG from scratch in the current
756 builds a repo with a given DAG from scratch in the current
756 empty repo
757 empty repo
757 debugbundle lists the contents of a bundle
758 debugbundle lists the contents of a bundle
758 debugcheckstate
759 debugcheckstate
759 validate the correctness of the current dirstate
760 validate the correctness of the current dirstate
760 debugcommands
761 debugcommands
761 list all available commands and options
762 list all available commands and options
762 debugcomplete
763 debugcomplete
763 returns the completion list associated with the given command
764 returns the completion list associated with the given command
764 debugdag format the changelog or an index DAG as a concise textual
765 debugdag format the changelog or an index DAG as a concise textual
765 description
766 description
766 debugdata dump the contents of a data file revision
767 debugdata dump the contents of a data file revision
767 debugdate parse and display a date
768 debugdate parse and display a date
768 debugdirstate
769 debugdirstate
769 show the contents of the current dirstate
770 show the contents of the current dirstate
770 debugdiscovery
771 debugdiscovery
771 runs the changeset discovery protocol in isolation
772 runs the changeset discovery protocol in isolation
772 debugfileset parse and apply a fileset specification
773 debugfileset parse and apply a fileset specification
773 debugfsinfo show information detected about current filesystem
774 debugfsinfo show information detected about current filesystem
774 debuggetbundle
775 debuggetbundle
775 retrieves a bundle from a repo
776 retrieves a bundle from a repo
776 debugignore display the combined ignore pattern
777 debugignore display the combined ignore pattern
777 debugindex dump the contents of an index file
778 debugindex dump the contents of an index file
778 debugindexdot
779 debugindexdot
779 dump an index DAG as a graphviz dot file
780 dump an index DAG as a graphviz dot file
780 debuginstall test Mercurial installation
781 debuginstall test Mercurial installation
781 debugknown test whether node ids are known to a repo
782 debugknown test whether node ids are known to a repo
782 debuglabelcomplete
783 debuglabelcomplete
783 complete "labels" - tags, open branch names, bookmark names
784 complete "labels" - tags, open branch names, bookmark names
784 debuglocks show or modify state of locks
785 debuglocks show or modify state of locks
785 debugobsolete
786 debugobsolete
786 create arbitrary obsolete marker
787 create arbitrary obsolete marker
787 debugoptDEP (no help text available)
788 debugoptDEP (no help text available)
788 debugpathcomplete
789 debugpathcomplete
789 complete part or all of a tracked path
790 complete part or all of a tracked path
790 debugpushkey access the pushkey key/value protocol
791 debugpushkey access the pushkey key/value protocol
791 debugpvec (no help text available)
792 debugpvec (no help text available)
792 debugrebuilddirstate
793 debugrebuilddirstate
793 rebuild the dirstate as it would look like for the given
794 rebuild the dirstate as it would look like for the given
794 revision
795 revision
795 debugrename dump rename information
796 debugrename dump rename information
796 debugrevlog show data and statistics about a revlog
797 debugrevlog show data and statistics about a revlog
797 debugrevspec parse and apply a revision specification
798 debugrevspec parse and apply a revision specification
798 debugsetparents
799 debugsetparents
799 manually set the parents of the current working directory
800 manually set the parents of the current working directory
800 debugsub (no help text available)
801 debugsub (no help text available)
801 debugsuccessorssets
802 debugsuccessorssets
802 show set of successors for revision
803 show set of successors for revision
803 debugwalk show how files match on given patterns
804 debugwalk show how files match on given patterns
804 debugwireargs
805 debugwireargs
805 (no help text available)
806 (no help text available)
806
807
807 (use "hg help -v debug" to show built-in aliases and global options)
808 (use "hg help -v debug" to show built-in aliases and global options)
808
809
809
810
810 Test list of commands with command with no help text
811 Test list of commands with command with no help text
811
812
812 $ hg help helpext
813 $ hg help helpext
813 helpext extension - no help text available
814 helpext extension - no help text available
814
815
815 list of commands:
816 list of commands:
816
817
817 nohelp (no help text available)
818 nohelp (no help text available)
818
819
819 (use "hg help -v helpext" to show built-in aliases and global options)
820 (use "hg help -v helpext" to show built-in aliases and global options)
820
821
821
822
822 test deprecated option is hidden in command help
823 test deprecated option is hidden in command help
823 $ hg help debugoptDEP
824 $ hg help debugoptDEP
824 hg debugoptDEP
825 hg debugoptDEP
825
826
826 (no help text available)
827 (no help text available)
827
828
828 options:
829 options:
829
830
830 (some details hidden, use --verbose to show complete help)
831 (some details hidden, use --verbose to show complete help)
831
832
832 test deprecated option is shown with -v
833 test deprecated option is shown with -v
833 $ hg help -v debugoptDEP | grep dopt
834 $ hg help -v debugoptDEP | grep dopt
834 --dopt option is DEPRECATED
835 --dopt option is DEPRECATED
835
836
836 #if gettext
837 #if gettext
837 test deprecated option is hidden with translation with untranslated description
838 test deprecated option is hidden with translation with untranslated description
838 (use many globy for not failing on changed transaction)
839 (use many globy for not failing on changed transaction)
839 $ LANGUAGE=sv hg help debugoptDEP
840 $ LANGUAGE=sv hg help debugoptDEP
840 hg debugoptDEP
841 hg debugoptDEP
841
842
842 (*) (glob)
843 (*) (glob)
843
844
844 options:
845 options:
845
846
846 (some details hidden, use --verbose to show complete help)
847 (some details hidden, use --verbose to show complete help)
847 #endif
848 #endif
848
849
849 Test commands that collide with topics (issue4240)
850 Test commands that collide with topics (issue4240)
850
851
851 $ hg config -hq
852 $ hg config -hq
852 hg config [-u] [NAME]...
853 hg config [-u] [NAME]...
853
854
854 show combined config settings from all hgrc files
855 show combined config settings from all hgrc files
855 $ hg showconfig -hq
856 $ hg showconfig -hq
856 hg config [-u] [NAME]...
857 hg config [-u] [NAME]...
857
858
858 show combined config settings from all hgrc files
859 show combined config settings from all hgrc files
859
860
860 Test a help topic
861 Test a help topic
861
862
862 $ hg help revs
863 $ hg help revs
863 Specifying Single Revisions
864 Specifying Single Revisions
864 """""""""""""""""""""""""""
865 """""""""""""""""""""""""""
865
866
866 Mercurial supports several ways to specify individual revisions.
867 Mercurial supports several ways to specify individual revisions.
867
868
868 A plain integer is treated as a revision number. Negative integers are
869 A plain integer is treated as a revision number. Negative integers are
869 treated as sequential offsets from the tip, with -1 denoting the tip, -2
870 treated as sequential offsets from the tip, with -1 denoting the tip, -2
870 denoting the revision prior to the tip, and so forth.
871 denoting the revision prior to the tip, and so forth.
871
872
872 A 40-digit hexadecimal string is treated as a unique revision identifier.
873 A 40-digit hexadecimal string is treated as a unique revision identifier.
873
874
874 A hexadecimal string less than 40 characters long is treated as a unique
875 A hexadecimal string less than 40 characters long is treated as a unique
875 revision identifier and is referred to as a short-form identifier. A
876 revision identifier and is referred to as a short-form identifier. A
876 short-form identifier is only valid if it is the prefix of exactly one
877 short-form identifier is only valid if it is the prefix of exactly one
877 full-length identifier.
878 full-length identifier.
878
879
879 Any other string is treated as a bookmark, tag, or branch name. A bookmark
880 Any other string is treated as a bookmark, tag, or branch name. A bookmark
880 is a movable pointer to a revision. A tag is a permanent name associated
881 is a movable pointer to a revision. A tag is a permanent name associated
881 with a revision. A branch name denotes the tipmost open branch head of
882 with a revision. A branch name denotes the tipmost open branch head of
882 that branch - or if they are all closed, the tipmost closed head of the
883 that branch - or if they are all closed, the tipmost closed head of the
883 branch. Bookmark, tag, and branch names must not contain the ":"
884 branch. Bookmark, tag, and branch names must not contain the ":"
884 character.
885 character.
885
886
886 The reserved name "tip" always identifies the most recent revision.
887 The reserved name "tip" always identifies the most recent revision.
887
888
888 The reserved name "null" indicates the null revision. This is the revision
889 The reserved name "null" indicates the null revision. This is the revision
889 of an empty repository, and the parent of revision 0.
890 of an empty repository, and the parent of revision 0.
890
891
891 The reserved name "." indicates the working directory parent. If no
892 The reserved name "." indicates the working directory parent. If no
892 working directory is checked out, it is equivalent to null. If an
893 working directory is checked out, it is equivalent to null. If an
893 uncommitted merge is in progress, "." is the revision of the first parent.
894 uncommitted merge is in progress, "." is the revision of the first parent.
894
895
895 Test templating help
896 Test templating help
896
897
897 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
898 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
898 desc String. The text of the changeset description.
899 desc String. The text of the changeset description.
899 diffstat String. Statistics of changes with the following format:
900 diffstat String. Statistics of changes with the following format:
900 firstline Any text. Returns the first line of text.
901 firstline Any text. Returns the first line of text.
901 nonempty Any text. Returns '(none)' if the string is empty.
902 nonempty Any text. Returns '(none)' if the string is empty.
902
903
903 Test help hooks
904 Test help hooks
904
905
905 $ cat > helphook1.py <<EOF
906 $ cat > helphook1.py <<EOF
906 > from mercurial import help
907 > from mercurial import help
907 >
908 >
908 > def rewrite(topic, doc):
909 > def rewrite(topic, doc):
909 > return doc + '\nhelphook1\n'
910 > return doc + '\nhelphook1\n'
910 >
911 >
911 > def extsetup(ui):
912 > def extsetup(ui):
912 > help.addtopichook('revsets', rewrite)
913 > help.addtopichook('revsets', rewrite)
913 > EOF
914 > EOF
914 $ cat > helphook2.py <<EOF
915 $ cat > helphook2.py <<EOF
915 > from mercurial import help
916 > from mercurial import help
916 >
917 >
917 > def rewrite(topic, doc):
918 > def rewrite(topic, doc):
918 > return doc + '\nhelphook2\n'
919 > return doc + '\nhelphook2\n'
919 >
920 >
920 > def extsetup(ui):
921 > def extsetup(ui):
921 > help.addtopichook('revsets', rewrite)
922 > help.addtopichook('revsets', rewrite)
922 > EOF
923 > EOF
923 $ echo '[extensions]' >> $HGRCPATH
924 $ echo '[extensions]' >> $HGRCPATH
924 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
925 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
925 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
926 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
926 $ hg help revsets | grep helphook
927 $ hg help revsets | grep helphook
927 helphook1
928 helphook1
928 helphook2
929 helphook2
929
930
930 Test keyword search help
931 Test keyword search help
931
932
932 $ cat > prefixedname.py <<EOF
933 $ cat > prefixedname.py <<EOF
933 > '''matched against word "clone"
934 > '''matched against word "clone"
934 > '''
935 > '''
935 > EOF
936 > EOF
936 $ echo '[extensions]' >> $HGRCPATH
937 $ echo '[extensions]' >> $HGRCPATH
937 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
938 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
938 $ hg help -k clone
939 $ hg help -k clone
939 Topics:
940 Topics:
940
941
941 config Configuration Files
942 config Configuration Files
942 extensions Using Additional Features
943 extensions Using Additional Features
943 glossary Glossary
944 glossary Glossary
944 phases Working with Phases
945 phases Working with Phases
945 subrepos Subrepositories
946 subrepos Subrepositories
946 urls URL Paths
947 urls URL Paths
947
948
948 Commands:
949 Commands:
949
950
950 bookmarks create a new bookmark or list existing bookmarks
951 bookmarks create a new bookmark or list existing bookmarks
951 clone make a copy of an existing repository
952 clone make a copy of an existing repository
952 paths show aliases for remote repositories
953 paths show aliases for remote repositories
953 update update working directory (or switch revisions)
954 update update working directory (or switch revisions)
954
955
955 Extensions:
956 Extensions:
956
957
957 prefixedname matched against word "clone"
958 prefixedname matched against word "clone"
958 relink recreates hardlinks between repository clones
959 relink recreates hardlinks between repository clones
959
960
960 Extension Commands:
961 Extension Commands:
961
962
962 qclone clone main and patch repository at same time
963 qclone clone main and patch repository at same time
963
964
964 Test unfound topic
965 Test unfound topic
965
966
966 $ hg help nonexistingtopicthatwillneverexisteverever
967 $ hg help nonexistingtopicthatwillneverexisteverever
967 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
968 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
968 (try "hg help --keyword nonexistingtopicthatwillneverexisteverever")
969 (try "hg help --keyword nonexistingtopicthatwillneverexisteverever")
969 [255]
970 [255]
970
971
971 Test unfound keyword
972 Test unfound keyword
972
973
973 $ hg help --keyword nonexistingwordthatwillneverexisteverever
974 $ hg help --keyword nonexistingwordthatwillneverexisteverever
974 abort: no matches
975 abort: no matches
975 (try "hg help" for a list of topics)
976 (try "hg help" for a list of topics)
976 [255]
977 [255]
977
978
978 Test omit indicating for help
979 Test omit indicating for help
979
980
980 $ cat > addverboseitems.py <<EOF
981 $ cat > addverboseitems.py <<EOF
981 > '''extension to test omit indicating.
982 > '''extension to test omit indicating.
982 >
983 >
983 > This paragraph is never omitted (for extension)
984 > This paragraph is never omitted (for extension)
984 >
985 >
985 > .. container:: verbose
986 > .. container:: verbose
986 >
987 >
987 > This paragraph is omitted,
988 > This paragraph is omitted,
988 > if :hg:\`help\` is invoked witout \`\`-v\`\` (for extension)
989 > if :hg:\`help\` is invoked witout \`\`-v\`\` (for extension)
989 >
990 >
990 > This paragraph is never omitted, too (for extension)
991 > This paragraph is never omitted, too (for extension)
991 > '''
992 > '''
992 >
993 >
993 > from mercurial import help, commands
994 > from mercurial import help, commands
994 > testtopic = """This paragraph is never omitted (for topic).
995 > testtopic = """This paragraph is never omitted (for topic).
995 >
996 >
996 > .. container:: verbose
997 > .. container:: verbose
997 >
998 >
998 > This paragraph is omitted,
999 > This paragraph is omitted,
999 > if :hg:\`help\` is invoked witout \`\`-v\`\` (for topic)
1000 > if :hg:\`help\` is invoked witout \`\`-v\`\` (for topic)
1000 >
1001 >
1001 > This paragraph is never omitted, too (for topic)
1002 > This paragraph is never omitted, too (for topic)
1002 > """
1003 > """
1003 > def extsetup(ui):
1004 > def extsetup(ui):
1004 > help.helptable.append((["topic-containing-verbose"],
1005 > help.helptable.append((["topic-containing-verbose"],
1005 > "This is the topic to test omit indicating.",
1006 > "This is the topic to test omit indicating.",
1006 > lambda : testtopic))
1007 > lambda : testtopic))
1007 > EOF
1008 > EOF
1008 $ echo '[extensions]' >> $HGRCPATH
1009 $ echo '[extensions]' >> $HGRCPATH
1009 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1010 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1010 $ hg help addverboseitems
1011 $ hg help addverboseitems
1011 addverboseitems extension - extension to test omit indicating.
1012 addverboseitems extension - extension to test omit indicating.
1012
1013
1013 This paragraph is never omitted (for extension)
1014 This paragraph is never omitted (for extension)
1014
1015
1015 This paragraph is never omitted, too (for extension)
1016 This paragraph is never omitted, too (for extension)
1016
1017
1017 (some details hidden, use --verbose to show complete help)
1018 (some details hidden, use --verbose to show complete help)
1018
1019
1019 no commands defined
1020 no commands defined
1020 $ hg help -v addverboseitems
1021 $ hg help -v addverboseitems
1021 addverboseitems extension - extension to test omit indicating.
1022 addverboseitems extension - extension to test omit indicating.
1022
1023
1023 This paragraph is never omitted (for extension)
1024 This paragraph is never omitted (for extension)
1024
1025
1025 This paragraph is omitted, if "hg help" is invoked witout "-v" (for extension)
1026 This paragraph is omitted, if "hg help" is invoked witout "-v" (for extension)
1026
1027
1027 This paragraph is never omitted, too (for extension)
1028 This paragraph is never omitted, too (for extension)
1028
1029
1029 no commands defined
1030 no commands defined
1030 $ hg help topic-containing-verbose
1031 $ hg help topic-containing-verbose
1031 This is the topic to test omit indicating.
1032 This is the topic to test omit indicating.
1032 """"""""""""""""""""""""""""""""""""""""""
1033 """"""""""""""""""""""""""""""""""""""""""
1033
1034
1034 This paragraph is never omitted (for topic).
1035 This paragraph is never omitted (for topic).
1035
1036
1036 This paragraph is never omitted, too (for topic)
1037 This paragraph is never omitted, too (for topic)
1037
1038
1038 (some details hidden, use --verbose to show complete help)
1039 (some details hidden, use --verbose to show complete help)
1039 $ hg help -v topic-containing-verbose
1040 $ hg help -v topic-containing-verbose
1040 This is the topic to test omit indicating.
1041 This is the topic to test omit indicating.
1041 """"""""""""""""""""""""""""""""""""""""""
1042 """"""""""""""""""""""""""""""""""""""""""
1042
1043
1043 This paragraph is never omitted (for topic).
1044 This paragraph is never omitted (for topic).
1044
1045
1045 This paragraph is omitted, if "hg help" is invoked witout "-v" (for topic)
1046 This paragraph is omitted, if "hg help" is invoked witout "-v" (for topic)
1046
1047
1047 This paragraph is never omitted, too (for topic)
1048 This paragraph is never omitted, too (for topic)
1048
1049
1049 Test section lookup
1050 Test section lookup
1050
1051
1051 $ hg help revset.merge
1052 $ hg help revset.merge
1052 "merge()"
1053 "merge()"
1053 Changeset is a merge changeset.
1054 Changeset is a merge changeset.
1054
1055
1055 $ hg help glossary.dag
1056 $ hg help glossary.dag
1056 DAG
1057 DAG
1057 The repository of changesets of a distributed version control system
1058 The repository of changesets of a distributed version control system
1058 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1059 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1059 of nodes and edges, where nodes correspond to changesets and edges
1060 of nodes and edges, where nodes correspond to changesets and edges
1060 imply a parent -> child relation. This graph can be visualized by
1061 imply a parent -> child relation. This graph can be visualized by
1061 graphical tools such as "hg log --graph". In Mercurial, the DAG is
1062 graphical tools such as "hg log --graph". In Mercurial, the DAG is
1062 limited by the requirement for children to have at most two parents.
1063 limited by the requirement for children to have at most two parents.
1063
1064
1064
1065
1065 $ hg help hgrc.paths
1066 $ hg help hgrc.paths
1066 "paths"
1067 "paths"
1067 -------
1068 -------
1068
1069
1069 Assigns symbolic names to repositories. The left side is the symbolic
1070 Assigns symbolic names to repositories. The left side is the symbolic
1070 name, and the right gives the directory or URL that is the location of the
1071 name, and the right gives the directory or URL that is the location of the
1071 repository. Default paths can be declared by setting the following
1072 repository. Default paths can be declared by setting the following
1072 entries.
1073 entries.
1073
1074
1074 "default"
1075 "default"
1075 Directory or URL to use when pulling if no source is specified.
1076 Directory or URL to use when pulling if no source is specified.
1076 Default is set to repository from which the current repository was
1077 Default is set to repository from which the current repository was
1077 cloned.
1078 cloned.
1078
1079
1079 "default-push"
1080 "default-push"
1080 Optional. Directory or URL to use when pushing if no destination is
1081 Optional. Directory or URL to use when pushing if no destination is
1081 specified.
1082 specified.
1082
1083
1083 Custom paths can be defined by assigning the path to a name that later can
1084 Custom paths can be defined by assigning the path to a name that later can
1084 be used from the command line. Example:
1085 be used from the command line. Example:
1085
1086
1086 [paths]
1087 [paths]
1087 my_path = http://example.com/path
1088 my_path = http://example.com/path
1088
1089
1089 To push to the path defined in "my_path" run the command:
1090 To push to the path defined in "my_path" run the command:
1090
1091
1091 hg push my_path
1092 hg push my_path
1092
1093
1093 $ hg help glossary.mcguffin
1094 $ hg help glossary.mcguffin
1094 abort: help section not found
1095 abort: help section not found
1095 [255]
1096 [255]
1096
1097
1097 $ hg help glossary.mc.guffin
1098 $ hg help glossary.mc.guffin
1098 abort: help section not found
1099 abort: help section not found
1099 [255]
1100 [255]
1100
1101
1101 Test usage of section marks in help documents
1102 Test usage of section marks in help documents
1102
1103
1103 $ cd "$TESTDIR"/../doc
1104 $ cd "$TESTDIR"/../doc
1104 $ python check-seclevel.py
1105 $ python check-seclevel.py
1105 $ cd $TESTTMP
1106 $ cd $TESTTMP
1106
1107
1107 #if serve
1108 #if serve
1108
1109
1109 Test the help pages in hgweb.
1110 Test the help pages in hgweb.
1110
1111
1111 Dish up an empty repo; serve it cold.
1112 Dish up an empty repo; serve it cold.
1112
1113
1113 $ hg init "$TESTTMP/test"
1114 $ hg init "$TESTTMP/test"
1114 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
1115 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
1115 $ cat hg.pid >> $DAEMON_PIDS
1116 $ cat hg.pid >> $DAEMON_PIDS
1116
1117
1117 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help"
1118 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help"
1118 200 Script output follows
1119 200 Script output follows
1119
1120
1120 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1121 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1121 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1122 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1122 <head>
1123 <head>
1123 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1124 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1124 <meta name="robots" content="index, nofollow" />
1125 <meta name="robots" content="index, nofollow" />
1125 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1126 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1126 <script type="text/javascript" src="/static/mercurial.js"></script>
1127 <script type="text/javascript" src="/static/mercurial.js"></script>
1127
1128
1128 <title>Help: Index</title>
1129 <title>Help: Index</title>
1129 </head>
1130 </head>
1130 <body>
1131 <body>
1131
1132
1132 <div class="container">
1133 <div class="container">
1133 <div class="menu">
1134 <div class="menu">
1134 <div class="logo">
1135 <div class="logo">
1135 <a href="http://mercurial.selenic.com/">
1136 <a href="http://mercurial.selenic.com/">
1136 <img src="/static/hglogo.png" alt="mercurial" /></a>
1137 <img src="/static/hglogo.png" alt="mercurial" /></a>
1137 </div>
1138 </div>
1138 <ul>
1139 <ul>
1139 <li><a href="/shortlog">log</a></li>
1140 <li><a href="/shortlog">log</a></li>
1140 <li><a href="/graph">graph</a></li>
1141 <li><a href="/graph">graph</a></li>
1141 <li><a href="/tags">tags</a></li>
1142 <li><a href="/tags">tags</a></li>
1142 <li><a href="/bookmarks">bookmarks</a></li>
1143 <li><a href="/bookmarks">bookmarks</a></li>
1143 <li><a href="/branches">branches</a></li>
1144 <li><a href="/branches">branches</a></li>
1144 </ul>
1145 </ul>
1145 <ul>
1146 <ul>
1146 <li class="active">help</li>
1147 <li class="active">help</li>
1147 </ul>
1148 </ul>
1148 </div>
1149 </div>
1149
1150
1150 <div class="main">
1151 <div class="main">
1151 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1152 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1152 <form class="search" action="/log">
1153 <form class="search" action="/log">
1153
1154
1154 <p><input name="rev" id="search1" type="text" size="30" /></p>
1155 <p><input name="rev" id="search1" type="text" size="30" /></p>
1155 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1156 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1156 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1157 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1157 </form>
1158 </form>
1158 <table class="bigtable">
1159 <table class="bigtable">
1159 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
1160 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
1160
1161
1161 <tr><td>
1162 <tr><td>
1162 <a href="/help/config">
1163 <a href="/help/config">
1163 config
1164 config
1164 </a>
1165 </a>
1165 </td><td>
1166 </td><td>
1166 Configuration Files
1167 Configuration Files
1167 </td></tr>
1168 </td></tr>
1168 <tr><td>
1169 <tr><td>
1169 <a href="/help/dates">
1170 <a href="/help/dates">
1170 dates
1171 dates
1171 </a>
1172 </a>
1172 </td><td>
1173 </td><td>
1173 Date Formats
1174 Date Formats
1174 </td></tr>
1175 </td></tr>
1175 <tr><td>
1176 <tr><td>
1176 <a href="/help/diffs">
1177 <a href="/help/diffs">
1177 diffs
1178 diffs
1178 </a>
1179 </a>
1179 </td><td>
1180 </td><td>
1180 Diff Formats
1181 Diff Formats
1181 </td></tr>
1182 </td></tr>
1182 <tr><td>
1183 <tr><td>
1183 <a href="/help/environment">
1184 <a href="/help/environment">
1184 environment
1185 environment
1185 </a>
1186 </a>
1186 </td><td>
1187 </td><td>
1187 Environment Variables
1188 Environment Variables
1188 </td></tr>
1189 </td></tr>
1189 <tr><td>
1190 <tr><td>
1190 <a href="/help/extensions">
1191 <a href="/help/extensions">
1191 extensions
1192 extensions
1192 </a>
1193 </a>
1193 </td><td>
1194 </td><td>
1194 Using Additional Features
1195 Using Additional Features
1195 </td></tr>
1196 </td></tr>
1196 <tr><td>
1197 <tr><td>
1197 <a href="/help/filesets">
1198 <a href="/help/filesets">
1198 filesets
1199 filesets
1199 </a>
1200 </a>
1200 </td><td>
1201 </td><td>
1201 Specifying File Sets
1202 Specifying File Sets
1202 </td></tr>
1203 </td></tr>
1203 <tr><td>
1204 <tr><td>
1204 <a href="/help/glossary">
1205 <a href="/help/glossary">
1205 glossary
1206 glossary
1206 </a>
1207 </a>
1207 </td><td>
1208 </td><td>
1208 Glossary
1209 Glossary
1209 </td></tr>
1210 </td></tr>
1210 <tr><td>
1211 <tr><td>
1211 <a href="/help/hgignore">
1212 <a href="/help/hgignore">
1212 hgignore
1213 hgignore
1213 </a>
1214 </a>
1214 </td><td>
1215 </td><td>
1215 Syntax for Mercurial Ignore Files
1216 Syntax for Mercurial Ignore Files
1216 </td></tr>
1217 </td></tr>
1217 <tr><td>
1218 <tr><td>
1218 <a href="/help/hgweb">
1219 <a href="/help/hgweb">
1219 hgweb
1220 hgweb
1220 </a>
1221 </a>
1221 </td><td>
1222 </td><td>
1222 Configuring hgweb
1223 Configuring hgweb
1223 </td></tr>
1224 </td></tr>
1224 <tr><td>
1225 <tr><td>
1225 <a href="/help/merge-tools">
1226 <a href="/help/merge-tools">
1226 merge-tools
1227 merge-tools
1227 </a>
1228 </a>
1228 </td><td>
1229 </td><td>
1229 Merge Tools
1230 Merge Tools
1230 </td></tr>
1231 </td></tr>
1231 <tr><td>
1232 <tr><td>
1232 <a href="/help/multirevs">
1233 <a href="/help/multirevs">
1233 multirevs
1234 multirevs
1234 </a>
1235 </a>
1235 </td><td>
1236 </td><td>
1236 Specifying Multiple Revisions
1237 Specifying Multiple Revisions
1237 </td></tr>
1238 </td></tr>
1238 <tr><td>
1239 <tr><td>
1239 <a href="/help/patterns">
1240 <a href="/help/patterns">
1240 patterns
1241 patterns
1241 </a>
1242 </a>
1242 </td><td>
1243 </td><td>
1243 File Name Patterns
1244 File Name Patterns
1244 </td></tr>
1245 </td></tr>
1245 <tr><td>
1246 <tr><td>
1246 <a href="/help/phases">
1247 <a href="/help/phases">
1247 phases
1248 phases
1248 </a>
1249 </a>
1249 </td><td>
1250 </td><td>
1250 Working with Phases
1251 Working with Phases
1251 </td></tr>
1252 </td></tr>
1252 <tr><td>
1253 <tr><td>
1253 <a href="/help/revisions">
1254 <a href="/help/revisions">
1254 revisions
1255 revisions
1255 </a>
1256 </a>
1256 </td><td>
1257 </td><td>
1257 Specifying Single Revisions
1258 Specifying Single Revisions
1258 </td></tr>
1259 </td></tr>
1259 <tr><td>
1260 <tr><td>
1260 <a href="/help/revsets">
1261 <a href="/help/revsets">
1261 revsets
1262 revsets
1262 </a>
1263 </a>
1263 </td><td>
1264 </td><td>
1264 Specifying Revision Sets
1265 Specifying Revision Sets
1265 </td></tr>
1266 </td></tr>
1266 <tr><td>
1267 <tr><td>
1267 <a href="/help/subrepos">
1268 <a href="/help/subrepos">
1268 subrepos
1269 subrepos
1269 </a>
1270 </a>
1270 </td><td>
1271 </td><td>
1271 Subrepositories
1272 Subrepositories
1272 </td></tr>
1273 </td></tr>
1273 <tr><td>
1274 <tr><td>
1274 <a href="/help/templating">
1275 <a href="/help/templating">
1275 templating
1276 templating
1276 </a>
1277 </a>
1277 </td><td>
1278 </td><td>
1278 Template Usage
1279 Template Usage
1279 </td></tr>
1280 </td></tr>
1280 <tr><td>
1281 <tr><td>
1281 <a href="/help/urls">
1282 <a href="/help/urls">
1282 urls
1283 urls
1283 </a>
1284 </a>
1284 </td><td>
1285 </td><td>
1285 URL Paths
1286 URL Paths
1286 </td></tr>
1287 </td></tr>
1287 <tr><td>
1288 <tr><td>
1288 <a href="/help/topic-containing-verbose">
1289 <a href="/help/topic-containing-verbose">
1289 topic-containing-verbose
1290 topic-containing-verbose
1290 </a>
1291 </a>
1291 </td><td>
1292 </td><td>
1292 This is the topic to test omit indicating.
1293 This is the topic to test omit indicating.
1293 </td></tr>
1294 </td></tr>
1294
1295
1295 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
1296 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
1296
1297
1297 <tr><td>
1298 <tr><td>
1298 <a href="/help/add">
1299 <a href="/help/add">
1299 add
1300 add
1300 </a>
1301 </a>
1301 </td><td>
1302 </td><td>
1302 add the specified files on the next commit
1303 add the specified files on the next commit
1303 </td></tr>
1304 </td></tr>
1304 <tr><td>
1305 <tr><td>
1305 <a href="/help/annotate">
1306 <a href="/help/annotate">
1306 annotate
1307 annotate
1307 </a>
1308 </a>
1308 </td><td>
1309 </td><td>
1309 show changeset information by line for each file
1310 show changeset information by line for each file
1310 </td></tr>
1311 </td></tr>
1311 <tr><td>
1312 <tr><td>
1312 <a href="/help/clone">
1313 <a href="/help/clone">
1313 clone
1314 clone
1314 </a>
1315 </a>
1315 </td><td>
1316 </td><td>
1316 make a copy of an existing repository
1317 make a copy of an existing repository
1317 </td></tr>
1318 </td></tr>
1318 <tr><td>
1319 <tr><td>
1319 <a href="/help/commit">
1320 <a href="/help/commit">
1320 commit
1321 commit
1321 </a>
1322 </a>
1322 </td><td>
1323 </td><td>
1323 commit the specified files or all outstanding changes
1324 commit the specified files or all outstanding changes
1324 </td></tr>
1325 </td></tr>
1325 <tr><td>
1326 <tr><td>
1326 <a href="/help/diff">
1327 <a href="/help/diff">
1327 diff
1328 diff
1328 </a>
1329 </a>
1329 </td><td>
1330 </td><td>
1330 diff repository (or selected files)
1331 diff repository (or selected files)
1331 </td></tr>
1332 </td></tr>
1332 <tr><td>
1333 <tr><td>
1333 <a href="/help/export">
1334 <a href="/help/export">
1334 export
1335 export
1335 </a>
1336 </a>
1336 </td><td>
1337 </td><td>
1337 dump the header and diffs for one or more changesets
1338 dump the header and diffs for one or more changesets
1338 </td></tr>
1339 </td></tr>
1339 <tr><td>
1340 <tr><td>
1340 <a href="/help/forget">
1341 <a href="/help/forget">
1341 forget
1342 forget
1342 </a>
1343 </a>
1343 </td><td>
1344 </td><td>
1344 forget the specified files on the next commit
1345 forget the specified files on the next commit
1345 </td></tr>
1346 </td></tr>
1346 <tr><td>
1347 <tr><td>
1347 <a href="/help/init">
1348 <a href="/help/init">
1348 init
1349 init
1349 </a>
1350 </a>
1350 </td><td>
1351 </td><td>
1351 create a new repository in the given directory
1352 create a new repository in the given directory
1352 </td></tr>
1353 </td></tr>
1353 <tr><td>
1354 <tr><td>
1354 <a href="/help/log">
1355 <a href="/help/log">
1355 log
1356 log
1356 </a>
1357 </a>
1357 </td><td>
1358 </td><td>
1358 show revision history of entire repository or files
1359 show revision history of entire repository or files
1359 </td></tr>
1360 </td></tr>
1360 <tr><td>
1361 <tr><td>
1361 <a href="/help/merge">
1362 <a href="/help/merge">
1362 merge
1363 merge
1363 </a>
1364 </a>
1364 </td><td>
1365 </td><td>
1365 merge working directory with another revision
1366 merge working directory with another revision
1366 </td></tr>
1367 </td></tr>
1367 <tr><td>
1368 <tr><td>
1368 <a href="/help/pull">
1369 <a href="/help/pull">
1369 pull
1370 pull
1370 </a>
1371 </a>
1371 </td><td>
1372 </td><td>
1372 pull changes from the specified source
1373 pull changes from the specified source
1373 </td></tr>
1374 </td></tr>
1374 <tr><td>
1375 <tr><td>
1375 <a href="/help/push">
1376 <a href="/help/push">
1376 push
1377 push
1377 </a>
1378 </a>
1378 </td><td>
1379 </td><td>
1379 push changes to the specified destination
1380 push changes to the specified destination
1380 </td></tr>
1381 </td></tr>
1381 <tr><td>
1382 <tr><td>
1382 <a href="/help/remove">
1383 <a href="/help/remove">
1383 remove
1384 remove
1384 </a>
1385 </a>
1385 </td><td>
1386 </td><td>
1386 remove the specified files on the next commit
1387 remove the specified files on the next commit
1387 </td></tr>
1388 </td></tr>
1388 <tr><td>
1389 <tr><td>
1389 <a href="/help/serve">
1390 <a href="/help/serve">
1390 serve
1391 serve
1391 </a>
1392 </a>
1392 </td><td>
1393 </td><td>
1393 start stand-alone webserver
1394 start stand-alone webserver
1394 </td></tr>
1395 </td></tr>
1395 <tr><td>
1396 <tr><td>
1396 <a href="/help/status">
1397 <a href="/help/status">
1397 status
1398 status
1398 </a>
1399 </a>
1399 </td><td>
1400 </td><td>
1400 show changed files in the working directory
1401 show changed files in the working directory
1401 </td></tr>
1402 </td></tr>
1402 <tr><td>
1403 <tr><td>
1403 <a href="/help/summary">
1404 <a href="/help/summary">
1404 summary
1405 summary
1405 </a>
1406 </a>
1406 </td><td>
1407 </td><td>
1407 summarize working directory state
1408 summarize working directory state
1408 </td></tr>
1409 </td></tr>
1409 <tr><td>
1410 <tr><td>
1410 <a href="/help/update">
1411 <a href="/help/update">
1411 update
1412 update
1412 </a>
1413 </a>
1413 </td><td>
1414 </td><td>
1414 update working directory (or switch revisions)
1415 update working directory (or switch revisions)
1415 </td></tr>
1416 </td></tr>
1416
1417
1417 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
1418 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
1418
1419
1419 <tr><td>
1420 <tr><td>
1420 <a href="/help/addremove">
1421 <a href="/help/addremove">
1421 addremove
1422 addremove
1422 </a>
1423 </a>
1423 </td><td>
1424 </td><td>
1424 add all new files, delete all missing files
1425 add all new files, delete all missing files
1425 </td></tr>
1426 </td></tr>
1426 <tr><td>
1427 <tr><td>
1427 <a href="/help/archive">
1428 <a href="/help/archive">
1428 archive
1429 archive
1429 </a>
1430 </a>
1430 </td><td>
1431 </td><td>
1431 create an unversioned archive of a repository revision
1432 create an unversioned archive of a repository revision
1432 </td></tr>
1433 </td></tr>
1433 <tr><td>
1434 <tr><td>
1434 <a href="/help/backout">
1435 <a href="/help/backout">
1435 backout
1436 backout
1436 </a>
1437 </a>
1437 </td><td>
1438 </td><td>
1438 reverse effect of earlier changeset
1439 reverse effect of earlier changeset
1439 </td></tr>
1440 </td></tr>
1440 <tr><td>
1441 <tr><td>
1441 <a href="/help/bisect">
1442 <a href="/help/bisect">
1442 bisect
1443 bisect
1443 </a>
1444 </a>
1444 </td><td>
1445 </td><td>
1445 subdivision search of changesets
1446 subdivision search of changesets
1446 </td></tr>
1447 </td></tr>
1447 <tr><td>
1448 <tr><td>
1448 <a href="/help/bookmarks">
1449 <a href="/help/bookmarks">
1449 bookmarks
1450 bookmarks
1450 </a>
1451 </a>
1451 </td><td>
1452 </td><td>
1452 create a new bookmark or list existing bookmarks
1453 create a new bookmark or list existing bookmarks
1453 </td></tr>
1454 </td></tr>
1454 <tr><td>
1455 <tr><td>
1455 <a href="/help/branch">
1456 <a href="/help/branch">
1456 branch
1457 branch
1457 </a>
1458 </a>
1458 </td><td>
1459 </td><td>
1459 set or show the current branch name
1460 set or show the current branch name
1460 </td></tr>
1461 </td></tr>
1461 <tr><td>
1462 <tr><td>
1462 <a href="/help/branches">
1463 <a href="/help/branches">
1463 branches
1464 branches
1464 </a>
1465 </a>
1465 </td><td>
1466 </td><td>
1466 list repository named branches
1467 list repository named branches
1467 </td></tr>
1468 </td></tr>
1468 <tr><td>
1469 <tr><td>
1469 <a href="/help/bundle">
1470 <a href="/help/bundle">
1470 bundle
1471 bundle
1471 </a>
1472 </a>
1472 </td><td>
1473 </td><td>
1473 create a changegroup file
1474 create a changegroup file
1474 </td></tr>
1475 </td></tr>
1475 <tr><td>
1476 <tr><td>
1476 <a href="/help/cat">
1477 <a href="/help/cat">
1477 cat
1478 cat
1478 </a>
1479 </a>
1479 </td><td>
1480 </td><td>
1480 output the current or given revision of files
1481 output the current or given revision of files
1481 </td></tr>
1482 </td></tr>
1482 <tr><td>
1483 <tr><td>
1483 <a href="/help/config">
1484 <a href="/help/config">
1484 config
1485 config
1485 </a>
1486 </a>
1486 </td><td>
1487 </td><td>
1487 show combined config settings from all hgrc files
1488 show combined config settings from all hgrc files
1488 </td></tr>
1489 </td></tr>
1489 <tr><td>
1490 <tr><td>
1490 <a href="/help/copy">
1491 <a href="/help/copy">
1491 copy
1492 copy
1492 </a>
1493 </a>
1493 </td><td>
1494 </td><td>
1494 mark files as copied for the next commit
1495 mark files as copied for the next commit
1495 </td></tr>
1496 </td></tr>
1496 <tr><td>
1497 <tr><td>
1497 <a href="/help/files">
1498 <a href="/help/files">
1498 files
1499 files
1499 </a>
1500 </a>
1500 </td><td>
1501 </td><td>
1501 list tracked files
1502 list tracked files
1502 </td></tr>
1503 </td></tr>
1503 <tr><td>
1504 <tr><td>
1504 <a href="/help/graft">
1505 <a href="/help/graft">
1505 graft
1506 graft
1506 </a>
1507 </a>
1507 </td><td>
1508 </td><td>
1508 copy changes from other branches onto the current branch
1509 copy changes from other branches onto the current branch
1509 </td></tr>
1510 </td></tr>
1510 <tr><td>
1511 <tr><td>
1511 <a href="/help/grep">
1512 <a href="/help/grep">
1512 grep
1513 grep
1513 </a>
1514 </a>
1514 </td><td>
1515 </td><td>
1515 search for a pattern in specified files and revisions
1516 search for a pattern in specified files and revisions
1516 </td></tr>
1517 </td></tr>
1517 <tr><td>
1518 <tr><td>
1518 <a href="/help/heads">
1519 <a href="/help/heads">
1519 heads
1520 heads
1520 </a>
1521 </a>
1521 </td><td>
1522 </td><td>
1522 show branch heads
1523 show branch heads
1523 </td></tr>
1524 </td></tr>
1524 <tr><td>
1525 <tr><td>
1525 <a href="/help/help">
1526 <a href="/help/help">
1526 help
1527 help
1527 </a>
1528 </a>
1528 </td><td>
1529 </td><td>
1529 show help for a given topic or a help overview
1530 show help for a given topic or a help overview
1530 </td></tr>
1531 </td></tr>
1531 <tr><td>
1532 <tr><td>
1532 <a href="/help/identify">
1533 <a href="/help/identify">
1533 identify
1534 identify
1534 </a>
1535 </a>
1535 </td><td>
1536 </td><td>
1536 identify the working copy or specified revision
1537 identify the working copy or specified revision
1537 </td></tr>
1538 </td></tr>
1538 <tr><td>
1539 <tr><td>
1539 <a href="/help/import">
1540 <a href="/help/import">
1540 import
1541 import
1541 </a>
1542 </a>
1542 </td><td>
1543 </td><td>
1543 import an ordered set of patches
1544 import an ordered set of patches
1544 </td></tr>
1545 </td></tr>
1545 <tr><td>
1546 <tr><td>
1546 <a href="/help/incoming">
1547 <a href="/help/incoming">
1547 incoming
1548 incoming
1548 </a>
1549 </a>
1549 </td><td>
1550 </td><td>
1550 show new changesets found in source
1551 show new changesets found in source
1551 </td></tr>
1552 </td></tr>
1552 <tr><td>
1553 <tr><td>
1553 <a href="/help/manifest">
1554 <a href="/help/manifest">
1554 manifest
1555 manifest
1555 </a>
1556 </a>
1556 </td><td>
1557 </td><td>
1557 output the current or given revision of the project manifest
1558 output the current or given revision of the project manifest
1558 </td></tr>
1559 </td></tr>
1559 <tr><td>
1560 <tr><td>
1560 <a href="/help/nohelp">
1561 <a href="/help/nohelp">
1561 nohelp
1562 nohelp
1562 </a>
1563 </a>
1563 </td><td>
1564 </td><td>
1564 (no help text available)
1565 (no help text available)
1565 </td></tr>
1566 </td></tr>
1566 <tr><td>
1567 <tr><td>
1567 <a href="/help/outgoing">
1568 <a href="/help/outgoing">
1568 outgoing
1569 outgoing
1569 </a>
1570 </a>
1570 </td><td>
1571 </td><td>
1571 show changesets not found in the destination
1572 show changesets not found in the destination
1572 </td></tr>
1573 </td></tr>
1573 <tr><td>
1574 <tr><td>
1574 <a href="/help/paths">
1575 <a href="/help/paths">
1575 paths
1576 paths
1576 </a>
1577 </a>
1577 </td><td>
1578 </td><td>
1578 show aliases for remote repositories
1579 show aliases for remote repositories
1579 </td></tr>
1580 </td></tr>
1580 <tr><td>
1581 <tr><td>
1581 <a href="/help/phase">
1582 <a href="/help/phase">
1582 phase
1583 phase
1583 </a>
1584 </a>
1584 </td><td>
1585 </td><td>
1585 set or show the current phase name
1586 set or show the current phase name
1586 </td></tr>
1587 </td></tr>
1587 <tr><td>
1588 <tr><td>
1588 <a href="/help/recover">
1589 <a href="/help/recover">
1589 recover
1590 recover
1590 </a>
1591 </a>
1591 </td><td>
1592 </td><td>
1592 roll back an interrupted transaction
1593 roll back an interrupted transaction
1593 </td></tr>
1594 </td></tr>
1594 <tr><td>
1595 <tr><td>
1595 <a href="/help/rename">
1596 <a href="/help/rename">
1596 rename
1597 rename
1597 </a>
1598 </a>
1598 </td><td>
1599 </td><td>
1599 rename files; equivalent of copy + remove
1600 rename files; equivalent of copy + remove
1600 </td></tr>
1601 </td></tr>
1601 <tr><td>
1602 <tr><td>
1602 <a href="/help/resolve">
1603 <a href="/help/resolve">
1603 resolve
1604 resolve
1604 </a>
1605 </a>
1605 </td><td>
1606 </td><td>
1606 redo merges or set/view the merge status of files
1607 redo merges or set/view the merge status of files
1607 </td></tr>
1608 </td></tr>
1608 <tr><td>
1609 <tr><td>
1609 <a href="/help/revert">
1610 <a href="/help/revert">
1610 revert
1611 revert
1611 </a>
1612 </a>
1612 </td><td>
1613 </td><td>
1613 restore files to their checkout state
1614 restore files to their checkout state
1614 </td></tr>
1615 </td></tr>
1615 <tr><td>
1616 <tr><td>
1616 <a href="/help/root">
1617 <a href="/help/root">
1617 root
1618 root
1618 </a>
1619 </a>
1619 </td><td>
1620 </td><td>
1620 print the root (top) of the current working directory
1621 print the root (top) of the current working directory
1621 </td></tr>
1622 </td></tr>
1622 <tr><td>
1623 <tr><td>
1623 <a href="/help/tag">
1624 <a href="/help/tag">
1624 tag
1625 tag
1625 </a>
1626 </a>
1626 </td><td>
1627 </td><td>
1627 add one or more tags for the current or given revision
1628 add one or more tags for the current or given revision
1628 </td></tr>
1629 </td></tr>
1629 <tr><td>
1630 <tr><td>
1630 <a href="/help/tags">
1631 <a href="/help/tags">
1631 tags
1632 tags
1632 </a>
1633 </a>
1633 </td><td>
1634 </td><td>
1634 list repository tags
1635 list repository tags
1635 </td></tr>
1636 </td></tr>
1636 <tr><td>
1637 <tr><td>
1637 <a href="/help/unbundle">
1638 <a href="/help/unbundle">
1638 unbundle
1639 unbundle
1639 </a>
1640 </a>
1640 </td><td>
1641 </td><td>
1641 apply one or more changegroup files
1642 apply one or more changegroup files
1642 </td></tr>
1643 </td></tr>
1643 <tr><td>
1644 <tr><td>
1644 <a href="/help/verify">
1645 <a href="/help/verify">
1645 verify
1646 verify
1646 </a>
1647 </a>
1647 </td><td>
1648 </td><td>
1648 verify the integrity of the repository
1649 verify the integrity of the repository
1649 </td></tr>
1650 </td></tr>
1650 <tr><td>
1651 <tr><td>
1651 <a href="/help/version">
1652 <a href="/help/version">
1652 version
1653 version
1653 </a>
1654 </a>
1654 </td><td>
1655 </td><td>
1655 output version and copyright information
1656 output version and copyright information
1656 </td></tr>
1657 </td></tr>
1657 </table>
1658 </table>
1658 </div>
1659 </div>
1659 </div>
1660 </div>
1660
1661
1661 <script type="text/javascript">process_dates()</script>
1662 <script type="text/javascript">process_dates()</script>
1662
1663
1663
1664
1664 </body>
1665 </body>
1665 </html>
1666 </html>
1666
1667
1667
1668
1668 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/add"
1669 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/add"
1669 200 Script output follows
1670 200 Script output follows
1670
1671
1671 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1672 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1672 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1673 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1673 <head>
1674 <head>
1674 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1675 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1675 <meta name="robots" content="index, nofollow" />
1676 <meta name="robots" content="index, nofollow" />
1676 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1677 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1677 <script type="text/javascript" src="/static/mercurial.js"></script>
1678 <script type="text/javascript" src="/static/mercurial.js"></script>
1678
1679
1679 <title>Help: add</title>
1680 <title>Help: add</title>
1680 </head>
1681 </head>
1681 <body>
1682 <body>
1682
1683
1683 <div class="container">
1684 <div class="container">
1684 <div class="menu">
1685 <div class="menu">
1685 <div class="logo">
1686 <div class="logo">
1686 <a href="http://mercurial.selenic.com/">
1687 <a href="http://mercurial.selenic.com/">
1687 <img src="/static/hglogo.png" alt="mercurial" /></a>
1688 <img src="/static/hglogo.png" alt="mercurial" /></a>
1688 </div>
1689 </div>
1689 <ul>
1690 <ul>
1690 <li><a href="/shortlog">log</a></li>
1691 <li><a href="/shortlog">log</a></li>
1691 <li><a href="/graph">graph</a></li>
1692 <li><a href="/graph">graph</a></li>
1692 <li><a href="/tags">tags</a></li>
1693 <li><a href="/tags">tags</a></li>
1693 <li><a href="/bookmarks">bookmarks</a></li>
1694 <li><a href="/bookmarks">bookmarks</a></li>
1694 <li><a href="/branches">branches</a></li>
1695 <li><a href="/branches">branches</a></li>
1695 </ul>
1696 </ul>
1696 <ul>
1697 <ul>
1697 <li class="active"><a href="/help">help</a></li>
1698 <li class="active"><a href="/help">help</a></li>
1698 </ul>
1699 </ul>
1699 </div>
1700 </div>
1700
1701
1701 <div class="main">
1702 <div class="main">
1702 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1703 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1703 <h3>Help: add</h3>
1704 <h3>Help: add</h3>
1704
1705
1705 <form class="search" action="/log">
1706 <form class="search" action="/log">
1706
1707
1707 <p><input name="rev" id="search1" type="text" size="30" /></p>
1708 <p><input name="rev" id="search1" type="text" size="30" /></p>
1708 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1709 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1709 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1710 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1710 </form>
1711 </form>
1711 <div id="doc">
1712 <div id="doc">
1712 <p>
1713 <p>
1713 hg add [OPTION]... [FILE]...
1714 hg add [OPTION]... [FILE]...
1714 </p>
1715 </p>
1715 <p>
1716 <p>
1716 add the specified files on the next commit
1717 add the specified files on the next commit
1717 </p>
1718 </p>
1718 <p>
1719 <p>
1719 Schedule files to be version controlled and added to the
1720 Schedule files to be version controlled and added to the
1720 repository.
1721 repository.
1721 </p>
1722 </p>
1722 <p>
1723 <p>
1723 The files will be added to the repository at the next commit. To
1724 The files will be added to the repository at the next commit. To
1724 undo an add before that, see &quot;hg forget&quot;.
1725 undo an add before that, see &quot;hg forget&quot;.
1725 </p>
1726 </p>
1726 <p>
1727 <p>
1727 If no names are given, add all files to the repository.
1728 If no names are given, add all files to the repository.
1728 </p>
1729 </p>
1729 <p>
1730 <p>
1730 An example showing how new (unknown) files are added
1731 An example showing how new (unknown) files are added
1731 automatically by &quot;hg add&quot;:
1732 automatically by &quot;hg add&quot;:
1732 </p>
1733 </p>
1733 <pre>
1734 <pre>
1734 \$ ls (re)
1735 \$ ls (re)
1735 foo.c
1736 foo.c
1736 \$ hg status (re)
1737 \$ hg status (re)
1737 ? foo.c
1738 ? foo.c
1738 \$ hg add (re)
1739 \$ hg add (re)
1739 adding foo.c
1740 adding foo.c
1740 \$ hg status (re)
1741 \$ hg status (re)
1741 A foo.c
1742 A foo.c
1742 </pre>
1743 </pre>
1743 <p>
1744 <p>
1744 Returns 0 if all files are successfully added.
1745 Returns 0 if all files are successfully added.
1745 </p>
1746 </p>
1746 <p>
1747 <p>
1747 options ([+] can be repeated):
1748 options ([+] can be repeated):
1748 </p>
1749 </p>
1749 <table>
1750 <table>
1750 <tr><td>-I</td>
1751 <tr><td>-I</td>
1751 <td>--include PATTERN [+]</td>
1752 <td>--include PATTERN [+]</td>
1752 <td>include names matching the given patterns</td></tr>
1753 <td>include names matching the given patterns</td></tr>
1753 <tr><td>-X</td>
1754 <tr><td>-X</td>
1754 <td>--exclude PATTERN [+]</td>
1755 <td>--exclude PATTERN [+]</td>
1755 <td>exclude names matching the given patterns</td></tr>
1756 <td>exclude names matching the given patterns</td></tr>
1756 <tr><td>-S</td>
1757 <tr><td>-S</td>
1757 <td>--subrepos</td>
1758 <td>--subrepos</td>
1758 <td>recurse into subrepositories</td></tr>
1759 <td>recurse into subrepositories</td></tr>
1759 <tr><td>-n</td>
1760 <tr><td>-n</td>
1760 <td>--dry-run</td>
1761 <td>--dry-run</td>
1761 <td>do not perform actions, just print output</td></tr>
1762 <td>do not perform actions, just print output</td></tr>
1762 </table>
1763 </table>
1763 <p>
1764 <p>
1764 global options ([+] can be repeated):
1765 global options ([+] can be repeated):
1765 </p>
1766 </p>
1766 <table>
1767 <table>
1767 <tr><td>-R</td>
1768 <tr><td>-R</td>
1768 <td>--repository REPO</td>
1769 <td>--repository REPO</td>
1769 <td>repository root directory or name of overlay bundle file</td></tr>
1770 <td>repository root directory or name of overlay bundle file</td></tr>
1770 <tr><td></td>
1771 <tr><td></td>
1771 <td>--cwd DIR</td>
1772 <td>--cwd DIR</td>
1772 <td>change working directory</td></tr>
1773 <td>change working directory</td></tr>
1773 <tr><td>-y</td>
1774 <tr><td>-y</td>
1774 <td>--noninteractive</td>
1775 <td>--noninteractive</td>
1775 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
1776 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
1776 <tr><td>-q</td>
1777 <tr><td>-q</td>
1777 <td>--quiet</td>
1778 <td>--quiet</td>
1778 <td>suppress output</td></tr>
1779 <td>suppress output</td></tr>
1779 <tr><td>-v</td>
1780 <tr><td>-v</td>
1780 <td>--verbose</td>
1781 <td>--verbose</td>
1781 <td>enable additional output</td></tr>
1782 <td>enable additional output</td></tr>
1782 <tr><td></td>
1783 <tr><td></td>
1783 <td>--config CONFIG [+]</td>
1784 <td>--config CONFIG [+]</td>
1784 <td>set/override config option (use 'section.name=value')</td></tr>
1785 <td>set/override config option (use 'section.name=value')</td></tr>
1785 <tr><td></td>
1786 <tr><td></td>
1786 <td>--debug</td>
1787 <td>--debug</td>
1787 <td>enable debugging output</td></tr>
1788 <td>enable debugging output</td></tr>
1788 <tr><td></td>
1789 <tr><td></td>
1789 <td>--debugger</td>
1790 <td>--debugger</td>
1790 <td>start debugger</td></tr>
1791 <td>start debugger</td></tr>
1791 <tr><td></td>
1792 <tr><td></td>
1792 <td>--encoding ENCODE</td>
1793 <td>--encoding ENCODE</td>
1793 <td>set the charset encoding (default: ascii)</td></tr>
1794 <td>set the charset encoding (default: ascii)</td></tr>
1794 <tr><td></td>
1795 <tr><td></td>
1795 <td>--encodingmode MODE</td>
1796 <td>--encodingmode MODE</td>
1796 <td>set the charset encoding mode (default: strict)</td></tr>
1797 <td>set the charset encoding mode (default: strict)</td></tr>
1797 <tr><td></td>
1798 <tr><td></td>
1798 <td>--traceback</td>
1799 <td>--traceback</td>
1799 <td>always print a traceback on exception</td></tr>
1800 <td>always print a traceback on exception</td></tr>
1800 <tr><td></td>
1801 <tr><td></td>
1801 <td>--time</td>
1802 <td>--time</td>
1802 <td>time how long the command takes</td></tr>
1803 <td>time how long the command takes</td></tr>
1803 <tr><td></td>
1804 <tr><td></td>
1804 <td>--profile</td>
1805 <td>--profile</td>
1805 <td>print command execution profile</td></tr>
1806 <td>print command execution profile</td></tr>
1806 <tr><td></td>
1807 <tr><td></td>
1807 <td>--version</td>
1808 <td>--version</td>
1808 <td>output version information and exit</td></tr>
1809 <td>output version information and exit</td></tr>
1809 <tr><td>-h</td>
1810 <tr><td>-h</td>
1810 <td>--help</td>
1811 <td>--help</td>
1811 <td>display help and exit</td></tr>
1812 <td>display help and exit</td></tr>
1812 <tr><td></td>
1813 <tr><td></td>
1813 <td>--hidden</td>
1814 <td>--hidden</td>
1814 <td>consider hidden changesets</td></tr>
1815 <td>consider hidden changesets</td></tr>
1815 </table>
1816 </table>
1816
1817
1817 </div>
1818 </div>
1818 </div>
1819 </div>
1819 </div>
1820 </div>
1820
1821
1821 <script type="text/javascript">process_dates()</script>
1822 <script type="text/javascript">process_dates()</script>
1822
1823
1823
1824
1824 </body>
1825 </body>
1825 </html>
1826 </html>
1826
1827
1827
1828
1828 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/remove"
1829 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/remove"
1829 200 Script output follows
1830 200 Script output follows
1830
1831
1831 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1832 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1832 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1833 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1833 <head>
1834 <head>
1834 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1835 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1835 <meta name="robots" content="index, nofollow" />
1836 <meta name="robots" content="index, nofollow" />
1836 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1837 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1837 <script type="text/javascript" src="/static/mercurial.js"></script>
1838 <script type="text/javascript" src="/static/mercurial.js"></script>
1838
1839
1839 <title>Help: remove</title>
1840 <title>Help: remove</title>
1840 </head>
1841 </head>
1841 <body>
1842 <body>
1842
1843
1843 <div class="container">
1844 <div class="container">
1844 <div class="menu">
1845 <div class="menu">
1845 <div class="logo">
1846 <div class="logo">
1846 <a href="http://mercurial.selenic.com/">
1847 <a href="http://mercurial.selenic.com/">
1847 <img src="/static/hglogo.png" alt="mercurial" /></a>
1848 <img src="/static/hglogo.png" alt="mercurial" /></a>
1848 </div>
1849 </div>
1849 <ul>
1850 <ul>
1850 <li><a href="/shortlog">log</a></li>
1851 <li><a href="/shortlog">log</a></li>
1851 <li><a href="/graph">graph</a></li>
1852 <li><a href="/graph">graph</a></li>
1852 <li><a href="/tags">tags</a></li>
1853 <li><a href="/tags">tags</a></li>
1853 <li><a href="/bookmarks">bookmarks</a></li>
1854 <li><a href="/bookmarks">bookmarks</a></li>
1854 <li><a href="/branches">branches</a></li>
1855 <li><a href="/branches">branches</a></li>
1855 </ul>
1856 </ul>
1856 <ul>
1857 <ul>
1857 <li class="active"><a href="/help">help</a></li>
1858 <li class="active"><a href="/help">help</a></li>
1858 </ul>
1859 </ul>
1859 </div>
1860 </div>
1860
1861
1861 <div class="main">
1862 <div class="main">
1862 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1863 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1863 <h3>Help: remove</h3>
1864 <h3>Help: remove</h3>
1864
1865
1865 <form class="search" action="/log">
1866 <form class="search" action="/log">
1866
1867
1867 <p><input name="rev" id="search1" type="text" size="30" /></p>
1868 <p><input name="rev" id="search1" type="text" size="30" /></p>
1868 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1869 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1869 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1870 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1870 </form>
1871 </form>
1871 <div id="doc">
1872 <div id="doc">
1872 <p>
1873 <p>
1873 hg remove [OPTION]... FILE...
1874 hg remove [OPTION]... FILE...
1874 </p>
1875 </p>
1875 <p>
1876 <p>
1876 aliases: rm
1877 aliases: rm
1877 </p>
1878 </p>
1878 <p>
1879 <p>
1879 remove the specified files on the next commit
1880 remove the specified files on the next commit
1880 </p>
1881 </p>
1881 <p>
1882 <p>
1882 Schedule the indicated files for removal from the current branch.
1883 Schedule the indicated files for removal from the current branch.
1883 </p>
1884 </p>
1884 <p>
1885 <p>
1885 This command schedules the files to be removed at the next commit.
1886 This command schedules the files to be removed at the next commit.
1886 To undo a remove before that, see &quot;hg revert&quot;. To undo added
1887 To undo a remove before that, see &quot;hg revert&quot;. To undo added
1887 files, see &quot;hg forget&quot;.
1888 files, see &quot;hg forget&quot;.
1888 </p>
1889 </p>
1889 <p>
1890 <p>
1890 -A/--after can be used to remove only files that have already
1891 -A/--after can be used to remove only files that have already
1891 been deleted, -f/--force can be used to force deletion, and -Af
1892 been deleted, -f/--force can be used to force deletion, and -Af
1892 can be used to remove files from the next revision without
1893 can be used to remove files from the next revision without
1893 deleting them from the working directory.
1894 deleting them from the working directory.
1894 </p>
1895 </p>
1895 <p>
1896 <p>
1896 The following table details the behavior of remove for different
1897 The following table details the behavior of remove for different
1897 file states (columns) and option combinations (rows). The file
1898 file states (columns) and option combinations (rows). The file
1898 states are Added [A], Clean [C], Modified [M] and Missing [!]
1899 states are Added [A], Clean [C], Modified [M] and Missing [!]
1899 (as reported by &quot;hg status&quot;). The actions are Warn, Remove
1900 (as reported by &quot;hg status&quot;). The actions are Warn, Remove
1900 (from branch) and Delete (from disk):
1901 (from branch) and Delete (from disk):
1901 </p>
1902 </p>
1902 <table>
1903 <table>
1903 <tr><td>opt/state</td>
1904 <tr><td>opt/state</td>
1904 <td>A</td>
1905 <td>A</td>
1905 <td>C</td>
1906 <td>C</td>
1906 <td>M</td>
1907 <td>M</td>
1907 <td>!</td></tr>
1908 <td>!</td></tr>
1908 <tr><td>none</td>
1909 <tr><td>none</td>
1909 <td>W</td>
1910 <td>W</td>
1910 <td>RD</td>
1911 <td>RD</td>
1911 <td>W</td>
1912 <td>W</td>
1912 <td>R</td></tr>
1913 <td>R</td></tr>
1913 <tr><td>-f</td>
1914 <tr><td>-f</td>
1914 <td>R</td>
1915 <td>R</td>
1915 <td>RD</td>
1916 <td>RD</td>
1916 <td>RD</td>
1917 <td>RD</td>
1917 <td>R</td></tr>
1918 <td>R</td></tr>
1918 <tr><td>-A</td>
1919 <tr><td>-A</td>
1919 <td>W</td>
1920 <td>W</td>
1920 <td>W</td>
1921 <td>W</td>
1921 <td>W</td>
1922 <td>W</td>
1922 <td>R</td></tr>
1923 <td>R</td></tr>
1923 <tr><td>-Af</td>
1924 <tr><td>-Af</td>
1924 <td>R</td>
1925 <td>R</td>
1925 <td>R</td>
1926 <td>R</td>
1926 <td>R</td>
1927 <td>R</td>
1927 <td>R</td></tr>
1928 <td>R</td></tr>
1928 </table>
1929 </table>
1929 <p>
1930 <p>
1930 Note that remove never deletes files in Added [A] state from the
1931 Note that remove never deletes files in Added [A] state from the
1931 working directory, not even if option --force is specified.
1932 working directory, not even if option --force is specified.
1932 </p>
1933 </p>
1933 <p>
1934 <p>
1934 Returns 0 on success, 1 if any warnings encountered.
1935 Returns 0 on success, 1 if any warnings encountered.
1935 </p>
1936 </p>
1936 <p>
1937 <p>
1937 options ([+] can be repeated):
1938 options ([+] can be repeated):
1938 </p>
1939 </p>
1939 <table>
1940 <table>
1940 <tr><td>-A</td>
1941 <tr><td>-A</td>
1941 <td>--after</td>
1942 <td>--after</td>
1942 <td>record delete for missing files</td></tr>
1943 <td>record delete for missing files</td></tr>
1943 <tr><td>-f</td>
1944 <tr><td>-f</td>
1944 <td>--force</td>
1945 <td>--force</td>
1945 <td>remove (and delete) file even if added or modified</td></tr>
1946 <td>remove (and delete) file even if added or modified</td></tr>
1946 <tr><td>-I</td>
1947 <tr><td>-I</td>
1947 <td>--include PATTERN [+]</td>
1948 <td>--include PATTERN [+]</td>
1948 <td>include names matching the given patterns</td></tr>
1949 <td>include names matching the given patterns</td></tr>
1949 <tr><td>-X</td>
1950 <tr><td>-X</td>
1950 <td>--exclude PATTERN [+]</td>
1951 <td>--exclude PATTERN [+]</td>
1951 <td>exclude names matching the given patterns</td></tr>
1952 <td>exclude names matching the given patterns</td></tr>
1952 </table>
1953 </table>
1953 <p>
1954 <p>
1954 global options ([+] can be repeated):
1955 global options ([+] can be repeated):
1955 </p>
1956 </p>
1956 <table>
1957 <table>
1957 <tr><td>-R</td>
1958 <tr><td>-R</td>
1958 <td>--repository REPO</td>
1959 <td>--repository REPO</td>
1959 <td>repository root directory or name of overlay bundle file</td></tr>
1960 <td>repository root directory or name of overlay bundle file</td></tr>
1960 <tr><td></td>
1961 <tr><td></td>
1961 <td>--cwd DIR</td>
1962 <td>--cwd DIR</td>
1962 <td>change working directory</td></tr>
1963 <td>change working directory</td></tr>
1963 <tr><td>-y</td>
1964 <tr><td>-y</td>
1964 <td>--noninteractive</td>
1965 <td>--noninteractive</td>
1965 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
1966 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
1966 <tr><td>-q</td>
1967 <tr><td>-q</td>
1967 <td>--quiet</td>
1968 <td>--quiet</td>
1968 <td>suppress output</td></tr>
1969 <td>suppress output</td></tr>
1969 <tr><td>-v</td>
1970 <tr><td>-v</td>
1970 <td>--verbose</td>
1971 <td>--verbose</td>
1971 <td>enable additional output</td></tr>
1972 <td>enable additional output</td></tr>
1972 <tr><td></td>
1973 <tr><td></td>
1973 <td>--config CONFIG [+]</td>
1974 <td>--config CONFIG [+]</td>
1974 <td>set/override config option (use 'section.name=value')</td></tr>
1975 <td>set/override config option (use 'section.name=value')</td></tr>
1975 <tr><td></td>
1976 <tr><td></td>
1976 <td>--debug</td>
1977 <td>--debug</td>
1977 <td>enable debugging output</td></tr>
1978 <td>enable debugging output</td></tr>
1978 <tr><td></td>
1979 <tr><td></td>
1979 <td>--debugger</td>
1980 <td>--debugger</td>
1980 <td>start debugger</td></tr>
1981 <td>start debugger</td></tr>
1981 <tr><td></td>
1982 <tr><td></td>
1982 <td>--encoding ENCODE</td>
1983 <td>--encoding ENCODE</td>
1983 <td>set the charset encoding (default: ascii)</td></tr>
1984 <td>set the charset encoding (default: ascii)</td></tr>
1984 <tr><td></td>
1985 <tr><td></td>
1985 <td>--encodingmode MODE</td>
1986 <td>--encodingmode MODE</td>
1986 <td>set the charset encoding mode (default: strict)</td></tr>
1987 <td>set the charset encoding mode (default: strict)</td></tr>
1987 <tr><td></td>
1988 <tr><td></td>
1988 <td>--traceback</td>
1989 <td>--traceback</td>
1989 <td>always print a traceback on exception</td></tr>
1990 <td>always print a traceback on exception</td></tr>
1990 <tr><td></td>
1991 <tr><td></td>
1991 <td>--time</td>
1992 <td>--time</td>
1992 <td>time how long the command takes</td></tr>
1993 <td>time how long the command takes</td></tr>
1993 <tr><td></td>
1994 <tr><td></td>
1994 <td>--profile</td>
1995 <td>--profile</td>
1995 <td>print command execution profile</td></tr>
1996 <td>print command execution profile</td></tr>
1996 <tr><td></td>
1997 <tr><td></td>
1997 <td>--version</td>
1998 <td>--version</td>
1998 <td>output version information and exit</td></tr>
1999 <td>output version information and exit</td></tr>
1999 <tr><td>-h</td>
2000 <tr><td>-h</td>
2000 <td>--help</td>
2001 <td>--help</td>
2001 <td>display help and exit</td></tr>
2002 <td>display help and exit</td></tr>
2002 <tr><td></td>
2003 <tr><td></td>
2003 <td>--hidden</td>
2004 <td>--hidden</td>
2004 <td>consider hidden changesets</td></tr>
2005 <td>consider hidden changesets</td></tr>
2005 </table>
2006 </table>
2006
2007
2007 </div>
2008 </div>
2008 </div>
2009 </div>
2009 </div>
2010 </div>
2010
2011
2011 <script type="text/javascript">process_dates()</script>
2012 <script type="text/javascript">process_dates()</script>
2012
2013
2013
2014
2014 </body>
2015 </body>
2015 </html>
2016 </html>
2016
2017
2017
2018
2018 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/revisions"
2019 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/revisions"
2019 200 Script output follows
2020 200 Script output follows
2020
2021
2021 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2022 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2022 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2023 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2023 <head>
2024 <head>
2024 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2025 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2025 <meta name="robots" content="index, nofollow" />
2026 <meta name="robots" content="index, nofollow" />
2026 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2027 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2027 <script type="text/javascript" src="/static/mercurial.js"></script>
2028 <script type="text/javascript" src="/static/mercurial.js"></script>
2028
2029
2029 <title>Help: revisions</title>
2030 <title>Help: revisions</title>
2030 </head>
2031 </head>
2031 <body>
2032 <body>
2032
2033
2033 <div class="container">
2034 <div class="container">
2034 <div class="menu">
2035 <div class="menu">
2035 <div class="logo">
2036 <div class="logo">
2036 <a href="http://mercurial.selenic.com/">
2037 <a href="http://mercurial.selenic.com/">
2037 <img src="/static/hglogo.png" alt="mercurial" /></a>
2038 <img src="/static/hglogo.png" alt="mercurial" /></a>
2038 </div>
2039 </div>
2039 <ul>
2040 <ul>
2040 <li><a href="/shortlog">log</a></li>
2041 <li><a href="/shortlog">log</a></li>
2041 <li><a href="/graph">graph</a></li>
2042 <li><a href="/graph">graph</a></li>
2042 <li><a href="/tags">tags</a></li>
2043 <li><a href="/tags">tags</a></li>
2043 <li><a href="/bookmarks">bookmarks</a></li>
2044 <li><a href="/bookmarks">bookmarks</a></li>
2044 <li><a href="/branches">branches</a></li>
2045 <li><a href="/branches">branches</a></li>
2045 </ul>
2046 </ul>
2046 <ul>
2047 <ul>
2047 <li class="active"><a href="/help">help</a></li>
2048 <li class="active"><a href="/help">help</a></li>
2048 </ul>
2049 </ul>
2049 </div>
2050 </div>
2050
2051
2051 <div class="main">
2052 <div class="main">
2052 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2053 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2053 <h3>Help: revisions</h3>
2054 <h3>Help: revisions</h3>
2054
2055
2055 <form class="search" action="/log">
2056 <form class="search" action="/log">
2056
2057
2057 <p><input name="rev" id="search1" type="text" size="30" /></p>
2058 <p><input name="rev" id="search1" type="text" size="30" /></p>
2058 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2059 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2059 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2060 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2060 </form>
2061 </form>
2061 <div id="doc">
2062 <div id="doc">
2062 <h1>Specifying Single Revisions</h1>
2063 <h1>Specifying Single Revisions</h1>
2063 <p>
2064 <p>
2064 Mercurial supports several ways to specify individual revisions.
2065 Mercurial supports several ways to specify individual revisions.
2065 </p>
2066 </p>
2066 <p>
2067 <p>
2067 A plain integer is treated as a revision number. Negative integers are
2068 A plain integer is treated as a revision number. Negative integers are
2068 treated as sequential offsets from the tip, with -1 denoting the tip,
2069 treated as sequential offsets from the tip, with -1 denoting the tip,
2069 -2 denoting the revision prior to the tip, and so forth.
2070 -2 denoting the revision prior to the tip, and so forth.
2070 </p>
2071 </p>
2071 <p>
2072 <p>
2072 A 40-digit hexadecimal string is treated as a unique revision
2073 A 40-digit hexadecimal string is treated as a unique revision
2073 identifier.
2074 identifier.
2074 </p>
2075 </p>
2075 <p>
2076 <p>
2076 A hexadecimal string less than 40 characters long is treated as a
2077 A hexadecimal string less than 40 characters long is treated as a
2077 unique revision identifier and is referred to as a short-form
2078 unique revision identifier and is referred to as a short-form
2078 identifier. A short-form identifier is only valid if it is the prefix
2079 identifier. A short-form identifier is only valid if it is the prefix
2079 of exactly one full-length identifier.
2080 of exactly one full-length identifier.
2080 </p>
2081 </p>
2081 <p>
2082 <p>
2082 Any other string is treated as a bookmark, tag, or branch name. A
2083 Any other string is treated as a bookmark, tag, or branch name. A
2083 bookmark is a movable pointer to a revision. A tag is a permanent name
2084 bookmark is a movable pointer to a revision. A tag is a permanent name
2084 associated with a revision. A branch name denotes the tipmost open branch head
2085 associated with a revision. A branch name denotes the tipmost open branch head
2085 of that branch - or if they are all closed, the tipmost closed head of the
2086 of that branch - or if they are all closed, the tipmost closed head of the
2086 branch. Bookmark, tag, and branch names must not contain the &quot;:&quot; character.
2087 branch. Bookmark, tag, and branch names must not contain the &quot;:&quot; character.
2087 </p>
2088 </p>
2088 <p>
2089 <p>
2089 The reserved name &quot;tip&quot; always identifies the most recent revision.
2090 The reserved name &quot;tip&quot; always identifies the most recent revision.
2090 </p>
2091 </p>
2091 <p>
2092 <p>
2092 The reserved name &quot;null&quot; indicates the null revision. This is the
2093 The reserved name &quot;null&quot; indicates the null revision. This is the
2093 revision of an empty repository, and the parent of revision 0.
2094 revision of an empty repository, and the parent of revision 0.
2094 </p>
2095 </p>
2095 <p>
2096 <p>
2096 The reserved name &quot;.&quot; indicates the working directory parent. If no
2097 The reserved name &quot;.&quot; indicates the working directory parent. If no
2097 working directory is checked out, it is equivalent to null. If an
2098 working directory is checked out, it is equivalent to null. If an
2098 uncommitted merge is in progress, &quot;.&quot; is the revision of the first
2099 uncommitted merge is in progress, &quot;.&quot; is the revision of the first
2099 parent.
2100 parent.
2100 </p>
2101 </p>
2101
2102
2102 </div>
2103 </div>
2103 </div>
2104 </div>
2104 </div>
2105 </div>
2105
2106
2106 <script type="text/javascript">process_dates()</script>
2107 <script type="text/javascript">process_dates()</script>
2107
2108
2108
2109
2109 </body>
2110 </body>
2110 </html>
2111 </html>
2111
2112
2112
2113
2113 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
2114 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
2114
2115
2115 #endif
2116 #endif
General Comments 0
You need to be logged in to leave comments. Login now