##// END OF EJS Templates
diff: add --from and --to flags as clearer alternative to -r -r...
Martin von Zweigbergk -
r46703:64292add default
parent child Browse files
Show More
@@ -1,7732 +1,7744 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 __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import errno
10 import errno
11 import os
11 import os
12 import re
12 import re
13 import sys
13 import sys
14
14
15 from .i18n import _
15 from .i18n import _
16 from .node import (
16 from .node import (
17 hex,
17 hex,
18 nullid,
18 nullid,
19 nullrev,
19 nullrev,
20 short,
20 short,
21 wdirhex,
21 wdirhex,
22 wdirrev,
22 wdirrev,
23 )
23 )
24 from .pycompat import open
24 from .pycompat import open
25 from . import (
25 from . import (
26 archival,
26 archival,
27 bookmarks,
27 bookmarks,
28 bundle2,
28 bundle2,
29 bundlecaches,
29 bundlecaches,
30 changegroup,
30 changegroup,
31 cmdutil,
31 cmdutil,
32 copies,
32 copies,
33 debugcommands as debugcommandsmod,
33 debugcommands as debugcommandsmod,
34 destutil,
34 destutil,
35 dirstateguard,
35 dirstateguard,
36 discovery,
36 discovery,
37 encoding,
37 encoding,
38 error,
38 error,
39 exchange,
39 exchange,
40 extensions,
40 extensions,
41 filemerge,
41 filemerge,
42 formatter,
42 formatter,
43 graphmod,
43 graphmod,
44 grep as grepmod,
44 grep as grepmod,
45 hbisect,
45 hbisect,
46 help,
46 help,
47 hg,
47 hg,
48 logcmdutil,
48 logcmdutil,
49 merge as mergemod,
49 merge as mergemod,
50 mergestate as mergestatemod,
50 mergestate as mergestatemod,
51 narrowspec,
51 narrowspec,
52 obsolete,
52 obsolete,
53 obsutil,
53 obsutil,
54 patch,
54 patch,
55 phases,
55 phases,
56 pycompat,
56 pycompat,
57 rcutil,
57 rcutil,
58 registrar,
58 registrar,
59 requirements,
59 requirements,
60 revsetlang,
60 revsetlang,
61 rewriteutil,
61 rewriteutil,
62 scmutil,
62 scmutil,
63 server,
63 server,
64 shelve as shelvemod,
64 shelve as shelvemod,
65 state as statemod,
65 state as statemod,
66 streamclone,
66 streamclone,
67 tags as tagsmod,
67 tags as tagsmod,
68 ui as uimod,
68 ui as uimod,
69 util,
69 util,
70 verify as verifymod,
70 verify as verifymod,
71 vfs as vfsmod,
71 vfs as vfsmod,
72 wireprotoserver,
72 wireprotoserver,
73 )
73 )
74 from .utils import (
74 from .utils import (
75 dateutil,
75 dateutil,
76 stringutil,
76 stringutil,
77 )
77 )
78
78
79 table = {}
79 table = {}
80 table.update(debugcommandsmod.command._table)
80 table.update(debugcommandsmod.command._table)
81
81
82 command = registrar.command(table)
82 command = registrar.command(table)
83 INTENT_READONLY = registrar.INTENT_READONLY
83 INTENT_READONLY = registrar.INTENT_READONLY
84
84
85 # common command options
85 # common command options
86
86
87 globalopts = [
87 globalopts = [
88 (
88 (
89 b'R',
89 b'R',
90 b'repository',
90 b'repository',
91 b'',
91 b'',
92 _(b'repository root directory or name of overlay bundle file'),
92 _(b'repository root directory or name of overlay bundle file'),
93 _(b'REPO'),
93 _(b'REPO'),
94 ),
94 ),
95 (b'', b'cwd', b'', _(b'change working directory'), _(b'DIR')),
95 (b'', b'cwd', b'', _(b'change working directory'), _(b'DIR')),
96 (
96 (
97 b'y',
97 b'y',
98 b'noninteractive',
98 b'noninteractive',
99 None,
99 None,
100 _(
100 _(
101 b'do not prompt, automatically pick the first choice for all prompts'
101 b'do not prompt, automatically pick the first choice for all prompts'
102 ),
102 ),
103 ),
103 ),
104 (b'q', b'quiet', None, _(b'suppress output')),
104 (b'q', b'quiet', None, _(b'suppress output')),
105 (b'v', b'verbose', None, _(b'enable additional output')),
105 (b'v', b'verbose', None, _(b'enable additional output')),
106 (
106 (
107 b'',
107 b'',
108 b'color',
108 b'color',
109 b'',
109 b'',
110 # i18n: 'always', 'auto', 'never', and 'debug' are keywords
110 # i18n: 'always', 'auto', 'never', and 'debug' are keywords
111 # and should not be translated
111 # and should not be translated
112 _(b"when to colorize (boolean, always, auto, never, or debug)"),
112 _(b"when to colorize (boolean, always, auto, never, or debug)"),
113 _(b'TYPE'),
113 _(b'TYPE'),
114 ),
114 ),
115 (
115 (
116 b'',
116 b'',
117 b'config',
117 b'config',
118 [],
118 [],
119 _(b'set/override config option (use \'section.name=value\')'),
119 _(b'set/override config option (use \'section.name=value\')'),
120 _(b'CONFIG'),
120 _(b'CONFIG'),
121 ),
121 ),
122 (b'', b'debug', None, _(b'enable debugging output')),
122 (b'', b'debug', None, _(b'enable debugging output')),
123 (b'', b'debugger', None, _(b'start debugger')),
123 (b'', b'debugger', None, _(b'start debugger')),
124 (
124 (
125 b'',
125 b'',
126 b'encoding',
126 b'encoding',
127 encoding.encoding,
127 encoding.encoding,
128 _(b'set the charset encoding'),
128 _(b'set the charset encoding'),
129 _(b'ENCODE'),
129 _(b'ENCODE'),
130 ),
130 ),
131 (
131 (
132 b'',
132 b'',
133 b'encodingmode',
133 b'encodingmode',
134 encoding.encodingmode,
134 encoding.encodingmode,
135 _(b'set the charset encoding mode'),
135 _(b'set the charset encoding mode'),
136 _(b'MODE'),
136 _(b'MODE'),
137 ),
137 ),
138 (b'', b'traceback', None, _(b'always print a traceback on exception')),
138 (b'', b'traceback', None, _(b'always print a traceback on exception')),
139 (b'', b'time', None, _(b'time how long the command takes')),
139 (b'', b'time', None, _(b'time how long the command takes')),
140 (b'', b'profile', None, _(b'print command execution profile')),
140 (b'', b'profile', None, _(b'print command execution profile')),
141 (b'', b'version', None, _(b'output version information and exit')),
141 (b'', b'version', None, _(b'output version information and exit')),
142 (b'h', b'help', None, _(b'display help and exit')),
142 (b'h', b'help', None, _(b'display help and exit')),
143 (b'', b'hidden', False, _(b'consider hidden changesets')),
143 (b'', b'hidden', False, _(b'consider hidden changesets')),
144 (
144 (
145 b'',
145 b'',
146 b'pager',
146 b'pager',
147 b'auto',
147 b'auto',
148 _(b"when to paginate (boolean, always, auto, or never)"),
148 _(b"when to paginate (boolean, always, auto, or never)"),
149 _(b'TYPE'),
149 _(b'TYPE'),
150 ),
150 ),
151 ]
151 ]
152
152
153 dryrunopts = cmdutil.dryrunopts
153 dryrunopts = cmdutil.dryrunopts
154 remoteopts = cmdutil.remoteopts
154 remoteopts = cmdutil.remoteopts
155 walkopts = cmdutil.walkopts
155 walkopts = cmdutil.walkopts
156 commitopts = cmdutil.commitopts
156 commitopts = cmdutil.commitopts
157 commitopts2 = cmdutil.commitopts2
157 commitopts2 = cmdutil.commitopts2
158 commitopts3 = cmdutil.commitopts3
158 commitopts3 = cmdutil.commitopts3
159 formatteropts = cmdutil.formatteropts
159 formatteropts = cmdutil.formatteropts
160 templateopts = cmdutil.templateopts
160 templateopts = cmdutil.templateopts
161 logopts = cmdutil.logopts
161 logopts = cmdutil.logopts
162 diffopts = cmdutil.diffopts
162 diffopts = cmdutil.diffopts
163 diffwsopts = cmdutil.diffwsopts
163 diffwsopts = cmdutil.diffwsopts
164 diffopts2 = cmdutil.diffopts2
164 diffopts2 = cmdutil.diffopts2
165 mergetoolopts = cmdutil.mergetoolopts
165 mergetoolopts = cmdutil.mergetoolopts
166 similarityopts = cmdutil.similarityopts
166 similarityopts = cmdutil.similarityopts
167 subrepoopts = cmdutil.subrepoopts
167 subrepoopts = cmdutil.subrepoopts
168 debugrevlogopts = cmdutil.debugrevlogopts
168 debugrevlogopts = cmdutil.debugrevlogopts
169
169
170 # Commands start here, listed alphabetically
170 # Commands start here, listed alphabetically
171
171
172
172
173 @command(
173 @command(
174 b'abort',
174 b'abort',
175 dryrunopts,
175 dryrunopts,
176 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
176 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
177 helpbasic=True,
177 helpbasic=True,
178 )
178 )
179 def abort(ui, repo, **opts):
179 def abort(ui, repo, **opts):
180 """abort an unfinished operation (EXPERIMENTAL)
180 """abort an unfinished operation (EXPERIMENTAL)
181
181
182 Aborts a multistep operation like graft, histedit, rebase, merge,
182 Aborts a multistep operation like graft, histedit, rebase, merge,
183 and unshelve if they are in an unfinished state.
183 and unshelve if they are in an unfinished state.
184
184
185 use --dry-run/-n to dry run the command.
185 use --dry-run/-n to dry run the command.
186 """
186 """
187 dryrun = opts.get('dry_run')
187 dryrun = opts.get('dry_run')
188 abortstate = cmdutil.getunfinishedstate(repo)
188 abortstate = cmdutil.getunfinishedstate(repo)
189 if not abortstate:
189 if not abortstate:
190 raise error.StateError(_(b'no operation in progress'))
190 raise error.StateError(_(b'no operation in progress'))
191 if not abortstate.abortfunc:
191 if not abortstate.abortfunc:
192 raise error.InputError(
192 raise error.InputError(
193 (
193 (
194 _(b"%s in progress but does not support 'hg abort'")
194 _(b"%s in progress but does not support 'hg abort'")
195 % (abortstate._opname)
195 % (abortstate._opname)
196 ),
196 ),
197 hint=abortstate.hint(),
197 hint=abortstate.hint(),
198 )
198 )
199 if dryrun:
199 if dryrun:
200 ui.status(
200 ui.status(
201 _(b'%s in progress, will be aborted\n') % (abortstate._opname)
201 _(b'%s in progress, will be aborted\n') % (abortstate._opname)
202 )
202 )
203 return
203 return
204 return abortstate.abortfunc(ui, repo)
204 return abortstate.abortfunc(ui, repo)
205
205
206
206
207 @command(
207 @command(
208 b'add',
208 b'add',
209 walkopts + subrepoopts + dryrunopts,
209 walkopts + subrepoopts + dryrunopts,
210 _(b'[OPTION]... [FILE]...'),
210 _(b'[OPTION]... [FILE]...'),
211 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
211 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
212 helpbasic=True,
212 helpbasic=True,
213 inferrepo=True,
213 inferrepo=True,
214 )
214 )
215 def add(ui, repo, *pats, **opts):
215 def add(ui, repo, *pats, **opts):
216 """add the specified files on the next commit
216 """add the specified files on the next commit
217
217
218 Schedule files to be version controlled and added to the
218 Schedule files to be version controlled and added to the
219 repository.
219 repository.
220
220
221 The files will be added to the repository at the next commit. To
221 The files will be added to the repository at the next commit. To
222 undo an add before that, see :hg:`forget`.
222 undo an add before that, see :hg:`forget`.
223
223
224 If no names are given, add all files to the repository (except
224 If no names are given, add all files to the repository (except
225 files matching ``.hgignore``).
225 files matching ``.hgignore``).
226
226
227 .. container:: verbose
227 .. container:: verbose
228
228
229 Examples:
229 Examples:
230
230
231 - New (unknown) files are added
231 - New (unknown) files are added
232 automatically by :hg:`add`::
232 automatically by :hg:`add`::
233
233
234 $ ls
234 $ ls
235 foo.c
235 foo.c
236 $ hg status
236 $ hg status
237 ? foo.c
237 ? foo.c
238 $ hg add
238 $ hg add
239 adding foo.c
239 adding foo.c
240 $ hg status
240 $ hg status
241 A foo.c
241 A foo.c
242
242
243 - Specific files to be added can be specified::
243 - Specific files to be added can be specified::
244
244
245 $ ls
245 $ ls
246 bar.c foo.c
246 bar.c foo.c
247 $ hg status
247 $ hg status
248 ? bar.c
248 ? bar.c
249 ? foo.c
249 ? foo.c
250 $ hg add bar.c
250 $ hg add bar.c
251 $ hg status
251 $ hg status
252 A bar.c
252 A bar.c
253 ? foo.c
253 ? foo.c
254
254
255 Returns 0 if all files are successfully added.
255 Returns 0 if all files are successfully added.
256 """
256 """
257
257
258 m = scmutil.match(repo[None], pats, pycompat.byteskwargs(opts))
258 m = scmutil.match(repo[None], pats, pycompat.byteskwargs(opts))
259 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
259 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
260 rejected = cmdutil.add(ui, repo, m, b"", uipathfn, False, **opts)
260 rejected = cmdutil.add(ui, repo, m, b"", uipathfn, False, **opts)
261 return rejected and 1 or 0
261 return rejected and 1 or 0
262
262
263
263
264 @command(
264 @command(
265 b'addremove',
265 b'addremove',
266 similarityopts + subrepoopts + walkopts + dryrunopts,
266 similarityopts + subrepoopts + walkopts + dryrunopts,
267 _(b'[OPTION]... [FILE]...'),
267 _(b'[OPTION]... [FILE]...'),
268 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
268 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
269 inferrepo=True,
269 inferrepo=True,
270 )
270 )
271 def addremove(ui, repo, *pats, **opts):
271 def addremove(ui, repo, *pats, **opts):
272 """add all new files, delete all missing files
272 """add all new files, delete all missing files
273
273
274 Add all new files and remove all missing files from the
274 Add all new files and remove all missing files from the
275 repository.
275 repository.
276
276
277 Unless names are given, new files are ignored if they match any of
277 Unless names are given, new files are ignored if they match any of
278 the patterns in ``.hgignore``. As with add, these changes take
278 the patterns in ``.hgignore``. As with add, these changes take
279 effect at the next commit.
279 effect at the next commit.
280
280
281 Use the -s/--similarity option to detect renamed files. This
281 Use the -s/--similarity option to detect renamed files. This
282 option takes a percentage between 0 (disabled) and 100 (files must
282 option takes a percentage between 0 (disabled) and 100 (files must
283 be identical) as its parameter. With a parameter greater than 0,
283 be identical) as its parameter. With a parameter greater than 0,
284 this compares every removed file with every added file and records
284 this compares every removed file with every added file and records
285 those similar enough as renames. Detecting renamed files this way
285 those similar enough as renames. Detecting renamed files this way
286 can be expensive. After using this option, :hg:`status -C` can be
286 can be expensive. After using this option, :hg:`status -C` can be
287 used to check which files were identified as moved or renamed. If
287 used to check which files were identified as moved or renamed. If
288 not specified, -s/--similarity defaults to 100 and only renames of
288 not specified, -s/--similarity defaults to 100 and only renames of
289 identical files are detected.
289 identical files are detected.
290
290
291 .. container:: verbose
291 .. container:: verbose
292
292
293 Examples:
293 Examples:
294
294
295 - A number of files (bar.c and foo.c) are new,
295 - A number of files (bar.c and foo.c) are new,
296 while foobar.c has been removed (without using :hg:`remove`)
296 while foobar.c has been removed (without using :hg:`remove`)
297 from the repository::
297 from the repository::
298
298
299 $ ls
299 $ ls
300 bar.c foo.c
300 bar.c foo.c
301 $ hg status
301 $ hg status
302 ! foobar.c
302 ! foobar.c
303 ? bar.c
303 ? bar.c
304 ? foo.c
304 ? foo.c
305 $ hg addremove
305 $ hg addremove
306 adding bar.c
306 adding bar.c
307 adding foo.c
307 adding foo.c
308 removing foobar.c
308 removing foobar.c
309 $ hg status
309 $ hg status
310 A bar.c
310 A bar.c
311 A foo.c
311 A foo.c
312 R foobar.c
312 R foobar.c
313
313
314 - A file foobar.c was moved to foo.c without using :hg:`rename`.
314 - A file foobar.c was moved to foo.c without using :hg:`rename`.
315 Afterwards, it was edited slightly::
315 Afterwards, it was edited slightly::
316
316
317 $ ls
317 $ ls
318 foo.c
318 foo.c
319 $ hg status
319 $ hg status
320 ! foobar.c
320 ! foobar.c
321 ? foo.c
321 ? foo.c
322 $ hg addremove --similarity 90
322 $ hg addremove --similarity 90
323 removing foobar.c
323 removing foobar.c
324 adding foo.c
324 adding foo.c
325 recording removal of foobar.c as rename to foo.c (94% similar)
325 recording removal of foobar.c as rename to foo.c (94% similar)
326 $ hg status -C
326 $ hg status -C
327 A foo.c
327 A foo.c
328 foobar.c
328 foobar.c
329 R foobar.c
329 R foobar.c
330
330
331 Returns 0 if all files are successfully added.
331 Returns 0 if all files are successfully added.
332 """
332 """
333 opts = pycompat.byteskwargs(opts)
333 opts = pycompat.byteskwargs(opts)
334 if not opts.get(b'similarity'):
334 if not opts.get(b'similarity'):
335 opts[b'similarity'] = b'100'
335 opts[b'similarity'] = b'100'
336 matcher = scmutil.match(repo[None], pats, opts)
336 matcher = scmutil.match(repo[None], pats, opts)
337 relative = scmutil.anypats(pats, opts)
337 relative = scmutil.anypats(pats, opts)
338 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=relative)
338 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=relative)
339 return scmutil.addremove(repo, matcher, b"", uipathfn, opts)
339 return scmutil.addremove(repo, matcher, b"", uipathfn, opts)
340
340
341
341
342 @command(
342 @command(
343 b'annotate|blame',
343 b'annotate|blame',
344 [
344 [
345 (b'r', b'rev', b'', _(b'annotate the specified revision'), _(b'REV')),
345 (b'r', b'rev', b'', _(b'annotate the specified revision'), _(b'REV')),
346 (
346 (
347 b'',
347 b'',
348 b'follow',
348 b'follow',
349 None,
349 None,
350 _(b'follow copies/renames and list the filename (DEPRECATED)'),
350 _(b'follow copies/renames and list the filename (DEPRECATED)'),
351 ),
351 ),
352 (b'', b'no-follow', None, _(b"don't follow copies and renames")),
352 (b'', b'no-follow', None, _(b"don't follow copies and renames")),
353 (b'a', b'text', None, _(b'treat all files as text')),
353 (b'a', b'text', None, _(b'treat all files as text')),
354 (b'u', b'user', None, _(b'list the author (long with -v)')),
354 (b'u', b'user', None, _(b'list the author (long with -v)')),
355 (b'f', b'file', None, _(b'list the filename')),
355 (b'f', b'file', None, _(b'list the filename')),
356 (b'd', b'date', None, _(b'list the date (short with -q)')),
356 (b'd', b'date', None, _(b'list the date (short with -q)')),
357 (b'n', b'number', None, _(b'list the revision number (default)')),
357 (b'n', b'number', None, _(b'list the revision number (default)')),
358 (b'c', b'changeset', None, _(b'list the changeset')),
358 (b'c', b'changeset', None, _(b'list the changeset')),
359 (
359 (
360 b'l',
360 b'l',
361 b'line-number',
361 b'line-number',
362 None,
362 None,
363 _(b'show line number at the first appearance'),
363 _(b'show line number at the first appearance'),
364 ),
364 ),
365 (
365 (
366 b'',
366 b'',
367 b'skip',
367 b'skip',
368 [],
368 [],
369 _(b'revset to not display (EXPERIMENTAL)'),
369 _(b'revset to not display (EXPERIMENTAL)'),
370 _(b'REV'),
370 _(b'REV'),
371 ),
371 ),
372 ]
372 ]
373 + diffwsopts
373 + diffwsopts
374 + walkopts
374 + walkopts
375 + formatteropts,
375 + formatteropts,
376 _(b'[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
376 _(b'[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
377 helpcategory=command.CATEGORY_FILE_CONTENTS,
377 helpcategory=command.CATEGORY_FILE_CONTENTS,
378 helpbasic=True,
378 helpbasic=True,
379 inferrepo=True,
379 inferrepo=True,
380 )
380 )
381 def annotate(ui, repo, *pats, **opts):
381 def annotate(ui, repo, *pats, **opts):
382 """show changeset information by line for each file
382 """show changeset information by line for each file
383
383
384 List changes in files, showing the revision id responsible for
384 List changes in files, showing the revision id responsible for
385 each line.
385 each line.
386
386
387 This command is useful for discovering when a change was made and
387 This command is useful for discovering when a change was made and
388 by whom.
388 by whom.
389
389
390 If you include --file, --user, or --date, the revision number is
390 If you include --file, --user, or --date, the revision number is
391 suppressed unless you also include --number.
391 suppressed unless you also include --number.
392
392
393 Without the -a/--text option, annotate will avoid processing files
393 Without the -a/--text option, annotate will avoid processing files
394 it detects as binary. With -a, annotate will annotate the file
394 it detects as binary. With -a, annotate will annotate the file
395 anyway, although the results will probably be neither useful
395 anyway, although the results will probably be neither useful
396 nor desirable.
396 nor desirable.
397
397
398 .. container:: verbose
398 .. container:: verbose
399
399
400 Template:
400 Template:
401
401
402 The following keywords are supported in addition to the common template
402 The following keywords are supported in addition to the common template
403 keywords and functions. See also :hg:`help templates`.
403 keywords and functions. See also :hg:`help templates`.
404
404
405 :lines: List of lines with annotation data.
405 :lines: List of lines with annotation data.
406 :path: String. Repository-absolute path of the specified file.
406 :path: String. Repository-absolute path of the specified file.
407
407
408 And each entry of ``{lines}`` provides the following sub-keywords in
408 And each entry of ``{lines}`` provides the following sub-keywords in
409 addition to ``{date}``, ``{node}``, ``{rev}``, ``{user}``, etc.
409 addition to ``{date}``, ``{node}``, ``{rev}``, ``{user}``, etc.
410
410
411 :line: String. Line content.
411 :line: String. Line content.
412 :lineno: Integer. Line number at that revision.
412 :lineno: Integer. Line number at that revision.
413 :path: String. Repository-absolute path of the file at that revision.
413 :path: String. Repository-absolute path of the file at that revision.
414
414
415 See :hg:`help templates.operators` for the list expansion syntax.
415 See :hg:`help templates.operators` for the list expansion syntax.
416
416
417 Returns 0 on success.
417 Returns 0 on success.
418 """
418 """
419 opts = pycompat.byteskwargs(opts)
419 opts = pycompat.byteskwargs(opts)
420 if not pats:
420 if not pats:
421 raise error.InputError(
421 raise error.InputError(
422 _(b'at least one filename or pattern is required')
422 _(b'at least one filename or pattern is required')
423 )
423 )
424
424
425 if opts.get(b'follow'):
425 if opts.get(b'follow'):
426 # --follow is deprecated and now just an alias for -f/--file
426 # --follow is deprecated and now just an alias for -f/--file
427 # to mimic the behavior of Mercurial before version 1.5
427 # to mimic the behavior of Mercurial before version 1.5
428 opts[b'file'] = True
428 opts[b'file'] = True
429
429
430 if (
430 if (
431 not opts.get(b'user')
431 not opts.get(b'user')
432 and not opts.get(b'changeset')
432 and not opts.get(b'changeset')
433 and not opts.get(b'date')
433 and not opts.get(b'date')
434 and not opts.get(b'file')
434 and not opts.get(b'file')
435 ):
435 ):
436 opts[b'number'] = True
436 opts[b'number'] = True
437
437
438 linenumber = opts.get(b'line_number') is not None
438 linenumber = opts.get(b'line_number') is not None
439 if (
439 if (
440 linenumber
440 linenumber
441 and (not opts.get(b'changeset'))
441 and (not opts.get(b'changeset'))
442 and (not opts.get(b'number'))
442 and (not opts.get(b'number'))
443 ):
443 ):
444 raise error.InputError(_(b'at least one of -n/-c is required for -l'))
444 raise error.InputError(_(b'at least one of -n/-c is required for -l'))
445
445
446 rev = opts.get(b'rev')
446 rev = opts.get(b'rev')
447 if rev:
447 if rev:
448 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
448 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
449 ctx = scmutil.revsingle(repo, rev)
449 ctx = scmutil.revsingle(repo, rev)
450
450
451 ui.pager(b'annotate')
451 ui.pager(b'annotate')
452 rootfm = ui.formatter(b'annotate', opts)
452 rootfm = ui.formatter(b'annotate', opts)
453 if ui.debugflag:
453 if ui.debugflag:
454 shorthex = pycompat.identity
454 shorthex = pycompat.identity
455 else:
455 else:
456
456
457 def shorthex(h):
457 def shorthex(h):
458 return h[:12]
458 return h[:12]
459
459
460 if ui.quiet:
460 if ui.quiet:
461 datefunc = dateutil.shortdate
461 datefunc = dateutil.shortdate
462 else:
462 else:
463 datefunc = dateutil.datestr
463 datefunc = dateutil.datestr
464 if ctx.rev() is None:
464 if ctx.rev() is None:
465 if opts.get(b'changeset'):
465 if opts.get(b'changeset'):
466 # omit "+" suffix which is appended to node hex
466 # omit "+" suffix which is appended to node hex
467 def formatrev(rev):
467 def formatrev(rev):
468 if rev == wdirrev:
468 if rev == wdirrev:
469 return b'%d' % ctx.p1().rev()
469 return b'%d' % ctx.p1().rev()
470 else:
470 else:
471 return b'%d' % rev
471 return b'%d' % rev
472
472
473 else:
473 else:
474
474
475 def formatrev(rev):
475 def formatrev(rev):
476 if rev == wdirrev:
476 if rev == wdirrev:
477 return b'%d+' % ctx.p1().rev()
477 return b'%d+' % ctx.p1().rev()
478 else:
478 else:
479 return b'%d ' % rev
479 return b'%d ' % rev
480
480
481 def formathex(h):
481 def formathex(h):
482 if h == wdirhex:
482 if h == wdirhex:
483 return b'%s+' % shorthex(hex(ctx.p1().node()))
483 return b'%s+' % shorthex(hex(ctx.p1().node()))
484 else:
484 else:
485 return b'%s ' % shorthex(h)
485 return b'%s ' % shorthex(h)
486
486
487 else:
487 else:
488 formatrev = b'%d'.__mod__
488 formatrev = b'%d'.__mod__
489 formathex = shorthex
489 formathex = shorthex
490
490
491 opmap = [
491 opmap = [
492 (b'user', b' ', lambda x: x.fctx.user(), ui.shortuser),
492 (b'user', b' ', lambda x: x.fctx.user(), ui.shortuser),
493 (b'rev', b' ', lambda x: scmutil.intrev(x.fctx), formatrev),
493 (b'rev', b' ', lambda x: scmutil.intrev(x.fctx), formatrev),
494 (b'node', b' ', lambda x: hex(scmutil.binnode(x.fctx)), formathex),
494 (b'node', b' ', lambda x: hex(scmutil.binnode(x.fctx)), formathex),
495 (b'date', b' ', lambda x: x.fctx.date(), util.cachefunc(datefunc)),
495 (b'date', b' ', lambda x: x.fctx.date(), util.cachefunc(datefunc)),
496 (b'path', b' ', lambda x: x.fctx.path(), pycompat.bytestr),
496 (b'path', b' ', lambda x: x.fctx.path(), pycompat.bytestr),
497 (b'lineno', b':', lambda x: x.lineno, pycompat.bytestr),
497 (b'lineno', b':', lambda x: x.lineno, pycompat.bytestr),
498 ]
498 ]
499 opnamemap = {
499 opnamemap = {
500 b'rev': b'number',
500 b'rev': b'number',
501 b'node': b'changeset',
501 b'node': b'changeset',
502 b'path': b'file',
502 b'path': b'file',
503 b'lineno': b'line_number',
503 b'lineno': b'line_number',
504 }
504 }
505
505
506 if rootfm.isplain():
506 if rootfm.isplain():
507
507
508 def makefunc(get, fmt):
508 def makefunc(get, fmt):
509 return lambda x: fmt(get(x))
509 return lambda x: fmt(get(x))
510
510
511 else:
511 else:
512
512
513 def makefunc(get, fmt):
513 def makefunc(get, fmt):
514 return get
514 return get
515
515
516 datahint = rootfm.datahint()
516 datahint = rootfm.datahint()
517 funcmap = [
517 funcmap = [
518 (makefunc(get, fmt), sep)
518 (makefunc(get, fmt), sep)
519 for fn, sep, get, fmt in opmap
519 for fn, sep, get, fmt in opmap
520 if opts.get(opnamemap.get(fn, fn)) or fn in datahint
520 if opts.get(opnamemap.get(fn, fn)) or fn in datahint
521 ]
521 ]
522 funcmap[0] = (funcmap[0][0], b'') # no separator in front of first column
522 funcmap[0] = (funcmap[0][0], b'') # no separator in front of first column
523 fields = b' '.join(
523 fields = b' '.join(
524 fn
524 fn
525 for fn, sep, get, fmt in opmap
525 for fn, sep, get, fmt in opmap
526 if opts.get(opnamemap.get(fn, fn)) or fn in datahint
526 if opts.get(opnamemap.get(fn, fn)) or fn in datahint
527 )
527 )
528
528
529 def bad(x, y):
529 def bad(x, y):
530 raise error.Abort(b"%s: %s" % (x, y))
530 raise error.Abort(b"%s: %s" % (x, y))
531
531
532 m = scmutil.match(ctx, pats, opts, badfn=bad)
532 m = scmutil.match(ctx, pats, opts, badfn=bad)
533
533
534 follow = not opts.get(b'no_follow')
534 follow = not opts.get(b'no_follow')
535 diffopts = patch.difffeatureopts(
535 diffopts = patch.difffeatureopts(
536 ui, opts, section=b'annotate', whitespace=True
536 ui, opts, section=b'annotate', whitespace=True
537 )
537 )
538 skiprevs = opts.get(b'skip')
538 skiprevs = opts.get(b'skip')
539 if skiprevs:
539 if skiprevs:
540 skiprevs = scmutil.revrange(repo, skiprevs)
540 skiprevs = scmutil.revrange(repo, skiprevs)
541
541
542 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
542 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
543 for abs in ctx.walk(m):
543 for abs in ctx.walk(m):
544 fctx = ctx[abs]
544 fctx = ctx[abs]
545 rootfm.startitem()
545 rootfm.startitem()
546 rootfm.data(path=abs)
546 rootfm.data(path=abs)
547 if not opts.get(b'text') and fctx.isbinary():
547 if not opts.get(b'text') and fctx.isbinary():
548 rootfm.plain(_(b"%s: binary file\n") % uipathfn(abs))
548 rootfm.plain(_(b"%s: binary file\n") % uipathfn(abs))
549 continue
549 continue
550
550
551 fm = rootfm.nested(b'lines', tmpl=b'{rev}: {line}')
551 fm = rootfm.nested(b'lines', tmpl=b'{rev}: {line}')
552 lines = fctx.annotate(
552 lines = fctx.annotate(
553 follow=follow, skiprevs=skiprevs, diffopts=diffopts
553 follow=follow, skiprevs=skiprevs, diffopts=diffopts
554 )
554 )
555 if not lines:
555 if not lines:
556 fm.end()
556 fm.end()
557 continue
557 continue
558 formats = []
558 formats = []
559 pieces = []
559 pieces = []
560
560
561 for f, sep in funcmap:
561 for f, sep in funcmap:
562 l = [f(n) for n in lines]
562 l = [f(n) for n in lines]
563 if fm.isplain():
563 if fm.isplain():
564 sizes = [encoding.colwidth(x) for x in l]
564 sizes = [encoding.colwidth(x) for x in l]
565 ml = max(sizes)
565 ml = max(sizes)
566 formats.append([sep + b' ' * (ml - w) + b'%s' for w in sizes])
566 formats.append([sep + b' ' * (ml - w) + b'%s' for w in sizes])
567 else:
567 else:
568 formats.append([b'%s'] * len(l))
568 formats.append([b'%s'] * len(l))
569 pieces.append(l)
569 pieces.append(l)
570
570
571 for f, p, n in zip(zip(*formats), zip(*pieces), lines):
571 for f, p, n in zip(zip(*formats), zip(*pieces), lines):
572 fm.startitem()
572 fm.startitem()
573 fm.context(fctx=n.fctx)
573 fm.context(fctx=n.fctx)
574 fm.write(fields, b"".join(f), *p)
574 fm.write(fields, b"".join(f), *p)
575 if n.skip:
575 if n.skip:
576 fmt = b"* %s"
576 fmt = b"* %s"
577 else:
577 else:
578 fmt = b": %s"
578 fmt = b": %s"
579 fm.write(b'line', fmt, n.text)
579 fm.write(b'line', fmt, n.text)
580
580
581 if not lines[-1].text.endswith(b'\n'):
581 if not lines[-1].text.endswith(b'\n'):
582 fm.plain(b'\n')
582 fm.plain(b'\n')
583 fm.end()
583 fm.end()
584
584
585 rootfm.end()
585 rootfm.end()
586
586
587
587
588 @command(
588 @command(
589 b'archive',
589 b'archive',
590 [
590 [
591 (b'', b'no-decode', None, _(b'do not pass files through decoders')),
591 (b'', b'no-decode', None, _(b'do not pass files through decoders')),
592 (
592 (
593 b'p',
593 b'p',
594 b'prefix',
594 b'prefix',
595 b'',
595 b'',
596 _(b'directory prefix for files in archive'),
596 _(b'directory prefix for files in archive'),
597 _(b'PREFIX'),
597 _(b'PREFIX'),
598 ),
598 ),
599 (b'r', b'rev', b'', _(b'revision to distribute'), _(b'REV')),
599 (b'r', b'rev', b'', _(b'revision to distribute'), _(b'REV')),
600 (b't', b'type', b'', _(b'type of distribution to create'), _(b'TYPE')),
600 (b't', b'type', b'', _(b'type of distribution to create'), _(b'TYPE')),
601 ]
601 ]
602 + subrepoopts
602 + subrepoopts
603 + walkopts,
603 + walkopts,
604 _(b'[OPTION]... DEST'),
604 _(b'[OPTION]... DEST'),
605 helpcategory=command.CATEGORY_IMPORT_EXPORT,
605 helpcategory=command.CATEGORY_IMPORT_EXPORT,
606 )
606 )
607 def archive(ui, repo, dest, **opts):
607 def archive(ui, repo, dest, **opts):
608 """create an unversioned archive of a repository revision
608 """create an unversioned archive of a repository revision
609
609
610 By default, the revision used is the parent of the working
610 By default, the revision used is the parent of the working
611 directory; use -r/--rev to specify a different revision.
611 directory; use -r/--rev to specify a different revision.
612
612
613 The archive type is automatically detected based on file
613 The archive type is automatically detected based on file
614 extension (to override, use -t/--type).
614 extension (to override, use -t/--type).
615
615
616 .. container:: verbose
616 .. container:: verbose
617
617
618 Examples:
618 Examples:
619
619
620 - create a zip file containing the 1.0 release::
620 - create a zip file containing the 1.0 release::
621
621
622 hg archive -r 1.0 project-1.0.zip
622 hg archive -r 1.0 project-1.0.zip
623
623
624 - create a tarball excluding .hg files::
624 - create a tarball excluding .hg files::
625
625
626 hg archive project.tar.gz -X ".hg*"
626 hg archive project.tar.gz -X ".hg*"
627
627
628 Valid types are:
628 Valid types are:
629
629
630 :``files``: a directory full of files (default)
630 :``files``: a directory full of files (default)
631 :``tar``: tar archive, uncompressed
631 :``tar``: tar archive, uncompressed
632 :``tbz2``: tar archive, compressed using bzip2
632 :``tbz2``: tar archive, compressed using bzip2
633 :``tgz``: tar archive, compressed using gzip
633 :``tgz``: tar archive, compressed using gzip
634 :``txz``: tar archive, compressed using lzma (only in Python 3)
634 :``txz``: tar archive, compressed using lzma (only in Python 3)
635 :``uzip``: zip archive, uncompressed
635 :``uzip``: zip archive, uncompressed
636 :``zip``: zip archive, compressed using deflate
636 :``zip``: zip archive, compressed using deflate
637
637
638 The exact name of the destination archive or directory is given
638 The exact name of the destination archive or directory is given
639 using a format string; see :hg:`help export` for details.
639 using a format string; see :hg:`help export` for details.
640
640
641 Each member added to an archive file has a directory prefix
641 Each member added to an archive file has a directory prefix
642 prepended. Use -p/--prefix to specify a format string for the
642 prepended. Use -p/--prefix to specify a format string for the
643 prefix. The default is the basename of the archive, with suffixes
643 prefix. The default is the basename of the archive, with suffixes
644 removed.
644 removed.
645
645
646 Returns 0 on success.
646 Returns 0 on success.
647 """
647 """
648
648
649 opts = pycompat.byteskwargs(opts)
649 opts = pycompat.byteskwargs(opts)
650 rev = opts.get(b'rev')
650 rev = opts.get(b'rev')
651 if rev:
651 if rev:
652 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
652 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
653 ctx = scmutil.revsingle(repo, rev)
653 ctx = scmutil.revsingle(repo, rev)
654 if not ctx:
654 if not ctx:
655 raise error.InputError(
655 raise error.InputError(
656 _(b'no working directory: please specify a revision')
656 _(b'no working directory: please specify a revision')
657 )
657 )
658 node = ctx.node()
658 node = ctx.node()
659 dest = cmdutil.makefilename(ctx, dest)
659 dest = cmdutil.makefilename(ctx, dest)
660 if os.path.realpath(dest) == repo.root:
660 if os.path.realpath(dest) == repo.root:
661 raise error.InputError(_(b'repository root cannot be destination'))
661 raise error.InputError(_(b'repository root cannot be destination'))
662
662
663 kind = opts.get(b'type') or archival.guesskind(dest) or b'files'
663 kind = opts.get(b'type') or archival.guesskind(dest) or b'files'
664 prefix = opts.get(b'prefix')
664 prefix = opts.get(b'prefix')
665
665
666 if dest == b'-':
666 if dest == b'-':
667 if kind == b'files':
667 if kind == b'files':
668 raise error.InputError(_(b'cannot archive plain files to stdout'))
668 raise error.InputError(_(b'cannot archive plain files to stdout'))
669 dest = cmdutil.makefileobj(ctx, dest)
669 dest = cmdutil.makefileobj(ctx, dest)
670 if not prefix:
670 if not prefix:
671 prefix = os.path.basename(repo.root) + b'-%h'
671 prefix = os.path.basename(repo.root) + b'-%h'
672
672
673 prefix = cmdutil.makefilename(ctx, prefix)
673 prefix = cmdutil.makefilename(ctx, prefix)
674 match = scmutil.match(ctx, [], opts)
674 match = scmutil.match(ctx, [], opts)
675 archival.archive(
675 archival.archive(
676 repo,
676 repo,
677 dest,
677 dest,
678 node,
678 node,
679 kind,
679 kind,
680 not opts.get(b'no_decode'),
680 not opts.get(b'no_decode'),
681 match,
681 match,
682 prefix,
682 prefix,
683 subrepos=opts.get(b'subrepos'),
683 subrepos=opts.get(b'subrepos'),
684 )
684 )
685
685
686
686
687 @command(
687 @command(
688 b'backout',
688 b'backout',
689 [
689 [
690 (
690 (
691 b'',
691 b'',
692 b'merge',
692 b'merge',
693 None,
693 None,
694 _(b'merge with old dirstate parent after backout'),
694 _(b'merge with old dirstate parent after backout'),
695 ),
695 ),
696 (
696 (
697 b'',
697 b'',
698 b'commit',
698 b'commit',
699 None,
699 None,
700 _(b'commit if no conflicts were encountered (DEPRECATED)'),
700 _(b'commit if no conflicts were encountered (DEPRECATED)'),
701 ),
701 ),
702 (b'', b'no-commit', None, _(b'do not commit')),
702 (b'', b'no-commit', None, _(b'do not commit')),
703 (
703 (
704 b'',
704 b'',
705 b'parent',
705 b'parent',
706 b'',
706 b'',
707 _(b'parent to choose when backing out merge (DEPRECATED)'),
707 _(b'parent to choose when backing out merge (DEPRECATED)'),
708 _(b'REV'),
708 _(b'REV'),
709 ),
709 ),
710 (b'r', b'rev', b'', _(b'revision to backout'), _(b'REV')),
710 (b'r', b'rev', b'', _(b'revision to backout'), _(b'REV')),
711 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
711 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
712 ]
712 ]
713 + mergetoolopts
713 + mergetoolopts
714 + walkopts
714 + walkopts
715 + commitopts
715 + commitopts
716 + commitopts2,
716 + commitopts2,
717 _(b'[OPTION]... [-r] REV'),
717 _(b'[OPTION]... [-r] REV'),
718 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
718 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
719 )
719 )
720 def backout(ui, repo, node=None, rev=None, **opts):
720 def backout(ui, repo, node=None, rev=None, **opts):
721 """reverse effect of earlier changeset
721 """reverse effect of earlier changeset
722
722
723 Prepare a new changeset with the effect of REV undone in the
723 Prepare a new changeset with the effect of REV undone in the
724 current working directory. If no conflicts were encountered,
724 current working directory. If no conflicts were encountered,
725 it will be committed immediately.
725 it will be committed immediately.
726
726
727 If REV is the parent of the working directory, then this new changeset
727 If REV is the parent of the working directory, then this new changeset
728 is committed automatically (unless --no-commit is specified).
728 is committed automatically (unless --no-commit is specified).
729
729
730 .. note::
730 .. note::
731
731
732 :hg:`backout` cannot be used to fix either an unwanted or
732 :hg:`backout` cannot be used to fix either an unwanted or
733 incorrect merge.
733 incorrect merge.
734
734
735 .. container:: verbose
735 .. container:: verbose
736
736
737 Examples:
737 Examples:
738
738
739 - Reverse the effect of the parent of the working directory.
739 - Reverse the effect of the parent of the working directory.
740 This backout will be committed immediately::
740 This backout will be committed immediately::
741
741
742 hg backout -r .
742 hg backout -r .
743
743
744 - Reverse the effect of previous bad revision 23::
744 - Reverse the effect of previous bad revision 23::
745
745
746 hg backout -r 23
746 hg backout -r 23
747
747
748 - Reverse the effect of previous bad revision 23 and
748 - Reverse the effect of previous bad revision 23 and
749 leave changes uncommitted::
749 leave changes uncommitted::
750
750
751 hg backout -r 23 --no-commit
751 hg backout -r 23 --no-commit
752 hg commit -m "Backout revision 23"
752 hg commit -m "Backout revision 23"
753
753
754 By default, the pending changeset will have one parent,
754 By default, the pending changeset will have one parent,
755 maintaining a linear history. With --merge, the pending
755 maintaining a linear history. With --merge, the pending
756 changeset will instead have two parents: the old parent of the
756 changeset will instead have two parents: the old parent of the
757 working directory and a new child of REV that simply undoes REV.
757 working directory and a new child of REV that simply undoes REV.
758
758
759 Before version 1.7, the behavior without --merge was equivalent
759 Before version 1.7, the behavior without --merge was equivalent
760 to specifying --merge followed by :hg:`update --clean .` to
760 to specifying --merge followed by :hg:`update --clean .` to
761 cancel the merge and leave the child of REV as a head to be
761 cancel the merge and leave the child of REV as a head to be
762 merged separately.
762 merged separately.
763
763
764 See :hg:`help dates` for a list of formats valid for -d/--date.
764 See :hg:`help dates` for a list of formats valid for -d/--date.
765
765
766 See :hg:`help revert` for a way to restore files to the state
766 See :hg:`help revert` for a way to restore files to the state
767 of another revision.
767 of another revision.
768
768
769 Returns 0 on success, 1 if nothing to backout or there are unresolved
769 Returns 0 on success, 1 if nothing to backout or there are unresolved
770 files.
770 files.
771 """
771 """
772 with repo.wlock(), repo.lock():
772 with repo.wlock(), repo.lock():
773 return _dobackout(ui, repo, node, rev, **opts)
773 return _dobackout(ui, repo, node, rev, **opts)
774
774
775
775
776 def _dobackout(ui, repo, node=None, rev=None, **opts):
776 def _dobackout(ui, repo, node=None, rev=None, **opts):
777 cmdutil.check_incompatible_arguments(opts, 'no_commit', ['commit', 'merge'])
777 cmdutil.check_incompatible_arguments(opts, 'no_commit', ['commit', 'merge'])
778 opts = pycompat.byteskwargs(opts)
778 opts = pycompat.byteskwargs(opts)
779
779
780 if rev and node:
780 if rev and node:
781 raise error.InputError(_(b"please specify just one revision"))
781 raise error.InputError(_(b"please specify just one revision"))
782
782
783 if not rev:
783 if not rev:
784 rev = node
784 rev = node
785
785
786 if not rev:
786 if not rev:
787 raise error.InputError(_(b"please specify a revision to backout"))
787 raise error.InputError(_(b"please specify a revision to backout"))
788
788
789 date = opts.get(b'date')
789 date = opts.get(b'date')
790 if date:
790 if date:
791 opts[b'date'] = dateutil.parsedate(date)
791 opts[b'date'] = dateutil.parsedate(date)
792
792
793 cmdutil.checkunfinished(repo)
793 cmdutil.checkunfinished(repo)
794 cmdutil.bailifchanged(repo)
794 cmdutil.bailifchanged(repo)
795 ctx = scmutil.revsingle(repo, rev)
795 ctx = scmutil.revsingle(repo, rev)
796 node = ctx.node()
796 node = ctx.node()
797
797
798 op1, op2 = repo.dirstate.parents()
798 op1, op2 = repo.dirstate.parents()
799 if not repo.changelog.isancestor(node, op1):
799 if not repo.changelog.isancestor(node, op1):
800 raise error.InputError(
800 raise error.InputError(
801 _(b'cannot backout change that is not an ancestor')
801 _(b'cannot backout change that is not an ancestor')
802 )
802 )
803
803
804 p1, p2 = repo.changelog.parents(node)
804 p1, p2 = repo.changelog.parents(node)
805 if p1 == nullid:
805 if p1 == nullid:
806 raise error.InputError(_(b'cannot backout a change with no parents'))
806 raise error.InputError(_(b'cannot backout a change with no parents'))
807 if p2 != nullid:
807 if p2 != nullid:
808 if not opts.get(b'parent'):
808 if not opts.get(b'parent'):
809 raise error.InputError(_(b'cannot backout a merge changeset'))
809 raise error.InputError(_(b'cannot backout a merge changeset'))
810 p = repo.lookup(opts[b'parent'])
810 p = repo.lookup(opts[b'parent'])
811 if p not in (p1, p2):
811 if p not in (p1, p2):
812 raise error.InputError(
812 raise error.InputError(
813 _(b'%s is not a parent of %s') % (short(p), short(node))
813 _(b'%s is not a parent of %s') % (short(p), short(node))
814 )
814 )
815 parent = p
815 parent = p
816 else:
816 else:
817 if opts.get(b'parent'):
817 if opts.get(b'parent'):
818 raise error.InputError(
818 raise error.InputError(
819 _(b'cannot use --parent on non-merge changeset')
819 _(b'cannot use --parent on non-merge changeset')
820 )
820 )
821 parent = p1
821 parent = p1
822
822
823 # the backout should appear on the same branch
823 # the backout should appear on the same branch
824 branch = repo.dirstate.branch()
824 branch = repo.dirstate.branch()
825 bheads = repo.branchheads(branch)
825 bheads = repo.branchheads(branch)
826 rctx = scmutil.revsingle(repo, hex(parent))
826 rctx = scmutil.revsingle(repo, hex(parent))
827 if not opts.get(b'merge') and op1 != node:
827 if not opts.get(b'merge') and op1 != node:
828 with dirstateguard.dirstateguard(repo, b'backout'):
828 with dirstateguard.dirstateguard(repo, b'backout'):
829 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
829 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
830 with ui.configoverride(overrides, b'backout'):
830 with ui.configoverride(overrides, b'backout'):
831 stats = mergemod.back_out(ctx, parent=repo[parent])
831 stats = mergemod.back_out(ctx, parent=repo[parent])
832 repo.setparents(op1, op2)
832 repo.setparents(op1, op2)
833 hg._showstats(repo, stats)
833 hg._showstats(repo, stats)
834 if stats.unresolvedcount:
834 if stats.unresolvedcount:
835 repo.ui.status(
835 repo.ui.status(
836 _(b"use 'hg resolve' to retry unresolved file merges\n")
836 _(b"use 'hg resolve' to retry unresolved file merges\n")
837 )
837 )
838 return 1
838 return 1
839 else:
839 else:
840 hg.clean(repo, node, show_stats=False)
840 hg.clean(repo, node, show_stats=False)
841 repo.dirstate.setbranch(branch)
841 repo.dirstate.setbranch(branch)
842 cmdutil.revert(ui, repo, rctx)
842 cmdutil.revert(ui, repo, rctx)
843
843
844 if opts.get(b'no_commit'):
844 if opts.get(b'no_commit'):
845 msg = _(b"changeset %s backed out, don't forget to commit.\n")
845 msg = _(b"changeset %s backed out, don't forget to commit.\n")
846 ui.status(msg % short(node))
846 ui.status(msg % short(node))
847 return 0
847 return 0
848
848
849 def commitfunc(ui, repo, message, match, opts):
849 def commitfunc(ui, repo, message, match, opts):
850 editform = b'backout'
850 editform = b'backout'
851 e = cmdutil.getcommiteditor(
851 e = cmdutil.getcommiteditor(
852 editform=editform, **pycompat.strkwargs(opts)
852 editform=editform, **pycompat.strkwargs(opts)
853 )
853 )
854 if not message:
854 if not message:
855 # we don't translate commit messages
855 # we don't translate commit messages
856 message = b"Backed out changeset %s" % short(node)
856 message = b"Backed out changeset %s" % short(node)
857 e = cmdutil.getcommiteditor(edit=True, editform=editform)
857 e = cmdutil.getcommiteditor(edit=True, editform=editform)
858 return repo.commit(
858 return repo.commit(
859 message, opts.get(b'user'), opts.get(b'date'), match, editor=e
859 message, opts.get(b'user'), opts.get(b'date'), match, editor=e
860 )
860 )
861
861
862 # save to detect changes
862 # save to detect changes
863 tip = repo.changelog.tip()
863 tip = repo.changelog.tip()
864
864
865 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
865 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
866 if not newnode:
866 if not newnode:
867 ui.status(_(b"nothing changed\n"))
867 ui.status(_(b"nothing changed\n"))
868 return 1
868 return 1
869 cmdutil.commitstatus(repo, newnode, branch, bheads, tip)
869 cmdutil.commitstatus(repo, newnode, branch, bheads, tip)
870
870
871 def nice(node):
871 def nice(node):
872 return b'%d:%s' % (repo.changelog.rev(node), short(node))
872 return b'%d:%s' % (repo.changelog.rev(node), short(node))
873
873
874 ui.status(
874 ui.status(
875 _(b'changeset %s backs out changeset %s\n')
875 _(b'changeset %s backs out changeset %s\n')
876 % (nice(newnode), nice(node))
876 % (nice(newnode), nice(node))
877 )
877 )
878 if opts.get(b'merge') and op1 != node:
878 if opts.get(b'merge') and op1 != node:
879 hg.clean(repo, op1, show_stats=False)
879 hg.clean(repo, op1, show_stats=False)
880 ui.status(_(b'merging with changeset %s\n') % nice(newnode))
880 ui.status(_(b'merging with changeset %s\n') % nice(newnode))
881 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
881 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
882 with ui.configoverride(overrides, b'backout'):
882 with ui.configoverride(overrides, b'backout'):
883 return hg.merge(repo[b'tip'])
883 return hg.merge(repo[b'tip'])
884 return 0
884 return 0
885
885
886
886
887 @command(
887 @command(
888 b'bisect',
888 b'bisect',
889 [
889 [
890 (b'r', b'reset', False, _(b'reset bisect state')),
890 (b'r', b'reset', False, _(b'reset bisect state')),
891 (b'g', b'good', False, _(b'mark changeset good')),
891 (b'g', b'good', False, _(b'mark changeset good')),
892 (b'b', b'bad', False, _(b'mark changeset bad')),
892 (b'b', b'bad', False, _(b'mark changeset bad')),
893 (b's', b'skip', False, _(b'skip testing changeset')),
893 (b's', b'skip', False, _(b'skip testing changeset')),
894 (b'e', b'extend', False, _(b'extend the bisect range')),
894 (b'e', b'extend', False, _(b'extend the bisect range')),
895 (
895 (
896 b'c',
896 b'c',
897 b'command',
897 b'command',
898 b'',
898 b'',
899 _(b'use command to check changeset state'),
899 _(b'use command to check changeset state'),
900 _(b'CMD'),
900 _(b'CMD'),
901 ),
901 ),
902 (b'U', b'noupdate', False, _(b'do not update to target')),
902 (b'U', b'noupdate', False, _(b'do not update to target')),
903 ],
903 ],
904 _(b"[-gbsr] [-U] [-c CMD] [REV]"),
904 _(b"[-gbsr] [-U] [-c CMD] [REV]"),
905 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
905 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
906 )
906 )
907 def bisect(
907 def bisect(
908 ui,
908 ui,
909 repo,
909 repo,
910 positional_1=None,
910 positional_1=None,
911 positional_2=None,
911 positional_2=None,
912 command=None,
912 command=None,
913 reset=None,
913 reset=None,
914 good=None,
914 good=None,
915 bad=None,
915 bad=None,
916 skip=None,
916 skip=None,
917 extend=None,
917 extend=None,
918 noupdate=None,
918 noupdate=None,
919 ):
919 ):
920 """subdivision search of changesets
920 """subdivision search of changesets
921
921
922 This command helps to find changesets which introduce problems. To
922 This command helps to find changesets which introduce problems. To
923 use, mark the earliest changeset you know exhibits the problem as
923 use, mark the earliest changeset you know exhibits the problem as
924 bad, then mark the latest changeset which is free from the problem
924 bad, then mark the latest changeset which is free from the problem
925 as good. Bisect will update your working directory to a revision
925 as good. Bisect will update your working directory to a revision
926 for testing (unless the -U/--noupdate option is specified). Once
926 for testing (unless the -U/--noupdate option is specified). Once
927 you have performed tests, mark the working directory as good or
927 you have performed tests, mark the working directory as good or
928 bad, and bisect will either update to another candidate changeset
928 bad, and bisect will either update to another candidate changeset
929 or announce that it has found the bad revision.
929 or announce that it has found the bad revision.
930
930
931 As a shortcut, you can also use the revision argument to mark a
931 As a shortcut, you can also use the revision argument to mark a
932 revision as good or bad without checking it out first.
932 revision as good or bad without checking it out first.
933
933
934 If you supply a command, it will be used for automatic bisection.
934 If you supply a command, it will be used for automatic bisection.
935 The environment variable HG_NODE will contain the ID of the
935 The environment variable HG_NODE will contain the ID of the
936 changeset being tested. The exit status of the command will be
936 changeset being tested. The exit status of the command will be
937 used to mark revisions as good or bad: status 0 means good, 125
937 used to mark revisions as good or bad: status 0 means good, 125
938 means to skip the revision, 127 (command not found) will abort the
938 means to skip the revision, 127 (command not found) will abort the
939 bisection, and any other non-zero exit status means the revision
939 bisection, and any other non-zero exit status means the revision
940 is bad.
940 is bad.
941
941
942 .. container:: verbose
942 .. container:: verbose
943
943
944 Some examples:
944 Some examples:
945
945
946 - start a bisection with known bad revision 34, and good revision 12::
946 - start a bisection with known bad revision 34, and good revision 12::
947
947
948 hg bisect --bad 34
948 hg bisect --bad 34
949 hg bisect --good 12
949 hg bisect --good 12
950
950
951 - advance the current bisection by marking current revision as good or
951 - advance the current bisection by marking current revision as good or
952 bad::
952 bad::
953
953
954 hg bisect --good
954 hg bisect --good
955 hg bisect --bad
955 hg bisect --bad
956
956
957 - mark the current revision, or a known revision, to be skipped (e.g. if
957 - mark the current revision, or a known revision, to be skipped (e.g. if
958 that revision is not usable because of another issue)::
958 that revision is not usable because of another issue)::
959
959
960 hg bisect --skip
960 hg bisect --skip
961 hg bisect --skip 23
961 hg bisect --skip 23
962
962
963 - skip all revisions that do not touch directories ``foo`` or ``bar``::
963 - skip all revisions that do not touch directories ``foo`` or ``bar``::
964
964
965 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
965 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
966
966
967 - forget the current bisection::
967 - forget the current bisection::
968
968
969 hg bisect --reset
969 hg bisect --reset
970
970
971 - use 'make && make tests' to automatically find the first broken
971 - use 'make && make tests' to automatically find the first broken
972 revision::
972 revision::
973
973
974 hg bisect --reset
974 hg bisect --reset
975 hg bisect --bad 34
975 hg bisect --bad 34
976 hg bisect --good 12
976 hg bisect --good 12
977 hg bisect --command "make && make tests"
977 hg bisect --command "make && make tests"
978
978
979 - see all changesets whose states are already known in the current
979 - see all changesets whose states are already known in the current
980 bisection::
980 bisection::
981
981
982 hg log -r "bisect(pruned)"
982 hg log -r "bisect(pruned)"
983
983
984 - see the changeset currently being bisected (especially useful
984 - see the changeset currently being bisected (especially useful
985 if running with -U/--noupdate)::
985 if running with -U/--noupdate)::
986
986
987 hg log -r "bisect(current)"
987 hg log -r "bisect(current)"
988
988
989 - see all changesets that took part in the current bisection::
989 - see all changesets that took part in the current bisection::
990
990
991 hg log -r "bisect(range)"
991 hg log -r "bisect(range)"
992
992
993 - you can even get a nice graph::
993 - you can even get a nice graph::
994
994
995 hg log --graph -r "bisect(range)"
995 hg log --graph -r "bisect(range)"
996
996
997 See :hg:`help revisions.bisect` for more about the `bisect()` predicate.
997 See :hg:`help revisions.bisect` for more about the `bisect()` predicate.
998
998
999 Returns 0 on success.
999 Returns 0 on success.
1000 """
1000 """
1001 rev = []
1001 rev = []
1002 # backward compatibility
1002 # backward compatibility
1003 if positional_1 in (b"good", b"bad", b"reset", b"init"):
1003 if positional_1 in (b"good", b"bad", b"reset", b"init"):
1004 ui.warn(_(b"(use of 'hg bisect <cmd>' is deprecated)\n"))
1004 ui.warn(_(b"(use of 'hg bisect <cmd>' is deprecated)\n"))
1005 cmd = positional_1
1005 cmd = positional_1
1006 rev.append(positional_2)
1006 rev.append(positional_2)
1007 if cmd == b"good":
1007 if cmd == b"good":
1008 good = True
1008 good = True
1009 elif cmd == b"bad":
1009 elif cmd == b"bad":
1010 bad = True
1010 bad = True
1011 else:
1011 else:
1012 reset = True
1012 reset = True
1013 elif positional_2:
1013 elif positional_2:
1014 raise error.InputError(_(b'incompatible arguments'))
1014 raise error.InputError(_(b'incompatible arguments'))
1015 elif positional_1 is not None:
1015 elif positional_1 is not None:
1016 rev.append(positional_1)
1016 rev.append(positional_1)
1017
1017
1018 incompatibles = {
1018 incompatibles = {
1019 b'--bad': bad,
1019 b'--bad': bad,
1020 b'--command': bool(command),
1020 b'--command': bool(command),
1021 b'--extend': extend,
1021 b'--extend': extend,
1022 b'--good': good,
1022 b'--good': good,
1023 b'--reset': reset,
1023 b'--reset': reset,
1024 b'--skip': skip,
1024 b'--skip': skip,
1025 }
1025 }
1026
1026
1027 enabled = [x for x in incompatibles if incompatibles[x]]
1027 enabled = [x for x in incompatibles if incompatibles[x]]
1028
1028
1029 if len(enabled) > 1:
1029 if len(enabled) > 1:
1030 raise error.InputError(
1030 raise error.InputError(
1031 _(b'%s and %s are incompatible') % tuple(sorted(enabled)[0:2])
1031 _(b'%s and %s are incompatible') % tuple(sorted(enabled)[0:2])
1032 )
1032 )
1033
1033
1034 if reset:
1034 if reset:
1035 hbisect.resetstate(repo)
1035 hbisect.resetstate(repo)
1036 return
1036 return
1037
1037
1038 state = hbisect.load_state(repo)
1038 state = hbisect.load_state(repo)
1039
1039
1040 if rev:
1040 if rev:
1041 nodes = [repo[i].node() for i in scmutil.revrange(repo, rev)]
1041 nodes = [repo[i].node() for i in scmutil.revrange(repo, rev)]
1042 else:
1042 else:
1043 nodes = [repo.lookup(b'.')]
1043 nodes = [repo.lookup(b'.')]
1044
1044
1045 # update state
1045 # update state
1046 if good or bad or skip:
1046 if good or bad or skip:
1047 if good:
1047 if good:
1048 state[b'good'] += nodes
1048 state[b'good'] += nodes
1049 elif bad:
1049 elif bad:
1050 state[b'bad'] += nodes
1050 state[b'bad'] += nodes
1051 elif skip:
1051 elif skip:
1052 state[b'skip'] += nodes
1052 state[b'skip'] += nodes
1053 hbisect.save_state(repo, state)
1053 hbisect.save_state(repo, state)
1054 if not (state[b'good'] and state[b'bad']):
1054 if not (state[b'good'] and state[b'bad']):
1055 return
1055 return
1056
1056
1057 def mayupdate(repo, node, show_stats=True):
1057 def mayupdate(repo, node, show_stats=True):
1058 """common used update sequence"""
1058 """common used update sequence"""
1059 if noupdate:
1059 if noupdate:
1060 return
1060 return
1061 cmdutil.checkunfinished(repo)
1061 cmdutil.checkunfinished(repo)
1062 cmdutil.bailifchanged(repo)
1062 cmdutil.bailifchanged(repo)
1063 return hg.clean(repo, node, show_stats=show_stats)
1063 return hg.clean(repo, node, show_stats=show_stats)
1064
1064
1065 displayer = logcmdutil.changesetdisplayer(ui, repo, {})
1065 displayer = logcmdutil.changesetdisplayer(ui, repo, {})
1066
1066
1067 if command:
1067 if command:
1068 changesets = 1
1068 changesets = 1
1069 if noupdate:
1069 if noupdate:
1070 try:
1070 try:
1071 node = state[b'current'][0]
1071 node = state[b'current'][0]
1072 except LookupError:
1072 except LookupError:
1073 raise error.StateError(
1073 raise error.StateError(
1074 _(
1074 _(
1075 b'current bisect revision is unknown - '
1075 b'current bisect revision is unknown - '
1076 b'start a new bisect to fix'
1076 b'start a new bisect to fix'
1077 )
1077 )
1078 )
1078 )
1079 else:
1079 else:
1080 node, p2 = repo.dirstate.parents()
1080 node, p2 = repo.dirstate.parents()
1081 if p2 != nullid:
1081 if p2 != nullid:
1082 raise error.StateError(_(b'current bisect revision is a merge'))
1082 raise error.StateError(_(b'current bisect revision is a merge'))
1083 if rev:
1083 if rev:
1084 if not nodes:
1084 if not nodes:
1085 raise error.Abort(_(b'empty revision set'))
1085 raise error.Abort(_(b'empty revision set'))
1086 node = repo[nodes.last()].node()
1086 node = repo[nodes.last()].node()
1087 with hbisect.restore_state(repo, state, node):
1087 with hbisect.restore_state(repo, state, node):
1088 while changesets:
1088 while changesets:
1089 # update state
1089 # update state
1090 state[b'current'] = [node]
1090 state[b'current'] = [node]
1091 hbisect.save_state(repo, state)
1091 hbisect.save_state(repo, state)
1092 status = ui.system(
1092 status = ui.system(
1093 command,
1093 command,
1094 environ={b'HG_NODE': hex(node)},
1094 environ={b'HG_NODE': hex(node)},
1095 blockedtag=b'bisect_check',
1095 blockedtag=b'bisect_check',
1096 )
1096 )
1097 if status == 125:
1097 if status == 125:
1098 transition = b"skip"
1098 transition = b"skip"
1099 elif status == 0:
1099 elif status == 0:
1100 transition = b"good"
1100 transition = b"good"
1101 # status < 0 means process was killed
1101 # status < 0 means process was killed
1102 elif status == 127:
1102 elif status == 127:
1103 raise error.Abort(_(b"failed to execute %s") % command)
1103 raise error.Abort(_(b"failed to execute %s") % command)
1104 elif status < 0:
1104 elif status < 0:
1105 raise error.Abort(_(b"%s killed") % command)
1105 raise error.Abort(_(b"%s killed") % command)
1106 else:
1106 else:
1107 transition = b"bad"
1107 transition = b"bad"
1108 state[transition].append(node)
1108 state[transition].append(node)
1109 ctx = repo[node]
1109 ctx = repo[node]
1110 ui.status(
1110 ui.status(
1111 _(b'changeset %d:%s: %s\n') % (ctx.rev(), ctx, transition)
1111 _(b'changeset %d:%s: %s\n') % (ctx.rev(), ctx, transition)
1112 )
1112 )
1113 hbisect.checkstate(state)
1113 hbisect.checkstate(state)
1114 # bisect
1114 # bisect
1115 nodes, changesets, bgood = hbisect.bisect(repo, state)
1115 nodes, changesets, bgood = hbisect.bisect(repo, state)
1116 # update to next check
1116 # update to next check
1117 node = nodes[0]
1117 node = nodes[0]
1118 mayupdate(repo, node, show_stats=False)
1118 mayupdate(repo, node, show_stats=False)
1119 hbisect.printresult(ui, repo, state, displayer, nodes, bgood)
1119 hbisect.printresult(ui, repo, state, displayer, nodes, bgood)
1120 return
1120 return
1121
1121
1122 hbisect.checkstate(state)
1122 hbisect.checkstate(state)
1123
1123
1124 # actually bisect
1124 # actually bisect
1125 nodes, changesets, good = hbisect.bisect(repo, state)
1125 nodes, changesets, good = hbisect.bisect(repo, state)
1126 if extend:
1126 if extend:
1127 if not changesets:
1127 if not changesets:
1128 extendnode = hbisect.extendrange(repo, state, nodes, good)
1128 extendnode = hbisect.extendrange(repo, state, nodes, good)
1129 if extendnode is not None:
1129 if extendnode is not None:
1130 ui.write(
1130 ui.write(
1131 _(b"Extending search to changeset %d:%s\n")
1131 _(b"Extending search to changeset %d:%s\n")
1132 % (extendnode.rev(), extendnode)
1132 % (extendnode.rev(), extendnode)
1133 )
1133 )
1134 state[b'current'] = [extendnode.node()]
1134 state[b'current'] = [extendnode.node()]
1135 hbisect.save_state(repo, state)
1135 hbisect.save_state(repo, state)
1136 return mayupdate(repo, extendnode.node())
1136 return mayupdate(repo, extendnode.node())
1137 raise error.StateError(_(b"nothing to extend"))
1137 raise error.StateError(_(b"nothing to extend"))
1138
1138
1139 if changesets == 0:
1139 if changesets == 0:
1140 hbisect.printresult(ui, repo, state, displayer, nodes, good)
1140 hbisect.printresult(ui, repo, state, displayer, nodes, good)
1141 else:
1141 else:
1142 assert len(nodes) == 1 # only a single node can be tested next
1142 assert len(nodes) == 1 # only a single node can be tested next
1143 node = nodes[0]
1143 node = nodes[0]
1144 # compute the approximate number of remaining tests
1144 # compute the approximate number of remaining tests
1145 tests, size = 0, 2
1145 tests, size = 0, 2
1146 while size <= changesets:
1146 while size <= changesets:
1147 tests, size = tests + 1, size * 2
1147 tests, size = tests + 1, size * 2
1148 rev = repo.changelog.rev(node)
1148 rev = repo.changelog.rev(node)
1149 ui.write(
1149 ui.write(
1150 _(
1150 _(
1151 b"Testing changeset %d:%s "
1151 b"Testing changeset %d:%s "
1152 b"(%d changesets remaining, ~%d tests)\n"
1152 b"(%d changesets remaining, ~%d tests)\n"
1153 )
1153 )
1154 % (rev, short(node), changesets, tests)
1154 % (rev, short(node), changesets, tests)
1155 )
1155 )
1156 state[b'current'] = [node]
1156 state[b'current'] = [node]
1157 hbisect.save_state(repo, state)
1157 hbisect.save_state(repo, state)
1158 return mayupdate(repo, node)
1158 return mayupdate(repo, node)
1159
1159
1160
1160
1161 @command(
1161 @command(
1162 b'bookmarks|bookmark',
1162 b'bookmarks|bookmark',
1163 [
1163 [
1164 (b'f', b'force', False, _(b'force')),
1164 (b'f', b'force', False, _(b'force')),
1165 (b'r', b'rev', b'', _(b'revision for bookmark action'), _(b'REV')),
1165 (b'r', b'rev', b'', _(b'revision for bookmark action'), _(b'REV')),
1166 (b'd', b'delete', False, _(b'delete a given bookmark')),
1166 (b'd', b'delete', False, _(b'delete a given bookmark')),
1167 (b'm', b'rename', b'', _(b'rename a given bookmark'), _(b'OLD')),
1167 (b'm', b'rename', b'', _(b'rename a given bookmark'), _(b'OLD')),
1168 (b'i', b'inactive', False, _(b'mark a bookmark inactive')),
1168 (b'i', b'inactive', False, _(b'mark a bookmark inactive')),
1169 (b'l', b'list', False, _(b'list existing bookmarks')),
1169 (b'l', b'list', False, _(b'list existing bookmarks')),
1170 ]
1170 ]
1171 + formatteropts,
1171 + formatteropts,
1172 _(b'hg bookmarks [OPTIONS]... [NAME]...'),
1172 _(b'hg bookmarks [OPTIONS]... [NAME]...'),
1173 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
1173 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
1174 )
1174 )
1175 def bookmark(ui, repo, *names, **opts):
1175 def bookmark(ui, repo, *names, **opts):
1176 """create a new bookmark or list existing bookmarks
1176 """create a new bookmark or list existing bookmarks
1177
1177
1178 Bookmarks are labels on changesets to help track lines of development.
1178 Bookmarks are labels on changesets to help track lines of development.
1179 Bookmarks are unversioned and can be moved, renamed and deleted.
1179 Bookmarks are unversioned and can be moved, renamed and deleted.
1180 Deleting or moving a bookmark has no effect on the associated changesets.
1180 Deleting or moving a bookmark has no effect on the associated changesets.
1181
1181
1182 Creating or updating to a bookmark causes it to be marked as 'active'.
1182 Creating or updating to a bookmark causes it to be marked as 'active'.
1183 The active bookmark is indicated with a '*'.
1183 The active bookmark is indicated with a '*'.
1184 When a commit is made, the active bookmark will advance to the new commit.
1184 When a commit is made, the active bookmark will advance to the new commit.
1185 A plain :hg:`update` will also advance an active bookmark, if possible.
1185 A plain :hg:`update` will also advance an active bookmark, if possible.
1186 Updating away from a bookmark will cause it to be deactivated.
1186 Updating away from a bookmark will cause it to be deactivated.
1187
1187
1188 Bookmarks can be pushed and pulled between repositories (see
1188 Bookmarks can be pushed and pulled between repositories (see
1189 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
1189 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
1190 diverged, a new 'divergent bookmark' of the form 'name@path' will
1190 diverged, a new 'divergent bookmark' of the form 'name@path' will
1191 be created. Using :hg:`merge` will resolve the divergence.
1191 be created. Using :hg:`merge` will resolve the divergence.
1192
1192
1193 Specifying bookmark as '.' to -m/-d/-l options is equivalent to specifying
1193 Specifying bookmark as '.' to -m/-d/-l options is equivalent to specifying
1194 the active bookmark's name.
1194 the active bookmark's name.
1195
1195
1196 A bookmark named '@' has the special property that :hg:`clone` will
1196 A bookmark named '@' has the special property that :hg:`clone` will
1197 check it out by default if it exists.
1197 check it out by default if it exists.
1198
1198
1199 .. container:: verbose
1199 .. container:: verbose
1200
1200
1201 Template:
1201 Template:
1202
1202
1203 The following keywords are supported in addition to the common template
1203 The following keywords are supported in addition to the common template
1204 keywords and functions such as ``{bookmark}``. See also
1204 keywords and functions such as ``{bookmark}``. See also
1205 :hg:`help templates`.
1205 :hg:`help templates`.
1206
1206
1207 :active: Boolean. True if the bookmark is active.
1207 :active: Boolean. True if the bookmark is active.
1208
1208
1209 Examples:
1209 Examples:
1210
1210
1211 - create an active bookmark for a new line of development::
1211 - create an active bookmark for a new line of development::
1212
1212
1213 hg book new-feature
1213 hg book new-feature
1214
1214
1215 - create an inactive bookmark as a place marker::
1215 - create an inactive bookmark as a place marker::
1216
1216
1217 hg book -i reviewed
1217 hg book -i reviewed
1218
1218
1219 - create an inactive bookmark on another changeset::
1219 - create an inactive bookmark on another changeset::
1220
1220
1221 hg book -r .^ tested
1221 hg book -r .^ tested
1222
1222
1223 - rename bookmark turkey to dinner::
1223 - rename bookmark turkey to dinner::
1224
1224
1225 hg book -m turkey dinner
1225 hg book -m turkey dinner
1226
1226
1227 - move the '@' bookmark from another branch::
1227 - move the '@' bookmark from another branch::
1228
1228
1229 hg book -f @
1229 hg book -f @
1230
1230
1231 - print only the active bookmark name::
1231 - print only the active bookmark name::
1232
1232
1233 hg book -ql .
1233 hg book -ql .
1234 """
1234 """
1235 opts = pycompat.byteskwargs(opts)
1235 opts = pycompat.byteskwargs(opts)
1236 force = opts.get(b'force')
1236 force = opts.get(b'force')
1237 rev = opts.get(b'rev')
1237 rev = opts.get(b'rev')
1238 inactive = opts.get(b'inactive') # meaning add/rename to inactive bookmark
1238 inactive = opts.get(b'inactive') # meaning add/rename to inactive bookmark
1239
1239
1240 action = cmdutil.check_at_most_one_arg(opts, b'delete', b'rename', b'list')
1240 action = cmdutil.check_at_most_one_arg(opts, b'delete', b'rename', b'list')
1241 if action:
1241 if action:
1242 cmdutil.check_incompatible_arguments(opts, action, [b'rev'])
1242 cmdutil.check_incompatible_arguments(opts, action, [b'rev'])
1243 elif names or rev:
1243 elif names or rev:
1244 action = b'add'
1244 action = b'add'
1245 elif inactive:
1245 elif inactive:
1246 action = b'inactive' # meaning deactivate
1246 action = b'inactive' # meaning deactivate
1247 else:
1247 else:
1248 action = b'list'
1248 action = b'list'
1249
1249
1250 cmdutil.check_incompatible_arguments(
1250 cmdutil.check_incompatible_arguments(
1251 opts, b'inactive', [b'delete', b'list']
1251 opts, b'inactive', [b'delete', b'list']
1252 )
1252 )
1253 if not names and action in {b'add', b'delete'}:
1253 if not names and action in {b'add', b'delete'}:
1254 raise error.InputError(_(b"bookmark name required"))
1254 raise error.InputError(_(b"bookmark name required"))
1255
1255
1256 if action in {b'add', b'delete', b'rename', b'inactive'}:
1256 if action in {b'add', b'delete', b'rename', b'inactive'}:
1257 with repo.wlock(), repo.lock(), repo.transaction(b'bookmark') as tr:
1257 with repo.wlock(), repo.lock(), repo.transaction(b'bookmark') as tr:
1258 if action == b'delete':
1258 if action == b'delete':
1259 names = pycompat.maplist(repo._bookmarks.expandname, names)
1259 names = pycompat.maplist(repo._bookmarks.expandname, names)
1260 bookmarks.delete(repo, tr, names)
1260 bookmarks.delete(repo, tr, names)
1261 elif action == b'rename':
1261 elif action == b'rename':
1262 if not names:
1262 if not names:
1263 raise error.InputError(_(b"new bookmark name required"))
1263 raise error.InputError(_(b"new bookmark name required"))
1264 elif len(names) > 1:
1264 elif len(names) > 1:
1265 raise error.InputError(
1265 raise error.InputError(
1266 _(b"only one new bookmark name allowed")
1266 _(b"only one new bookmark name allowed")
1267 )
1267 )
1268 oldname = repo._bookmarks.expandname(opts[b'rename'])
1268 oldname = repo._bookmarks.expandname(opts[b'rename'])
1269 bookmarks.rename(repo, tr, oldname, names[0], force, inactive)
1269 bookmarks.rename(repo, tr, oldname, names[0], force, inactive)
1270 elif action == b'add':
1270 elif action == b'add':
1271 bookmarks.addbookmarks(repo, tr, names, rev, force, inactive)
1271 bookmarks.addbookmarks(repo, tr, names, rev, force, inactive)
1272 elif action == b'inactive':
1272 elif action == b'inactive':
1273 if len(repo._bookmarks) == 0:
1273 if len(repo._bookmarks) == 0:
1274 ui.status(_(b"no bookmarks set\n"))
1274 ui.status(_(b"no bookmarks set\n"))
1275 elif not repo._activebookmark:
1275 elif not repo._activebookmark:
1276 ui.status(_(b"no active bookmark\n"))
1276 ui.status(_(b"no active bookmark\n"))
1277 else:
1277 else:
1278 bookmarks.deactivate(repo)
1278 bookmarks.deactivate(repo)
1279 elif action == b'list':
1279 elif action == b'list':
1280 names = pycompat.maplist(repo._bookmarks.expandname, names)
1280 names = pycompat.maplist(repo._bookmarks.expandname, names)
1281 with ui.formatter(b'bookmarks', opts) as fm:
1281 with ui.formatter(b'bookmarks', opts) as fm:
1282 bookmarks.printbookmarks(ui, repo, fm, names)
1282 bookmarks.printbookmarks(ui, repo, fm, names)
1283 else:
1283 else:
1284 raise error.ProgrammingError(b'invalid action: %s' % action)
1284 raise error.ProgrammingError(b'invalid action: %s' % action)
1285
1285
1286
1286
1287 @command(
1287 @command(
1288 b'branch',
1288 b'branch',
1289 [
1289 [
1290 (
1290 (
1291 b'f',
1291 b'f',
1292 b'force',
1292 b'force',
1293 None,
1293 None,
1294 _(b'set branch name even if it shadows an existing branch'),
1294 _(b'set branch name even if it shadows an existing branch'),
1295 ),
1295 ),
1296 (b'C', b'clean', None, _(b'reset branch name to parent branch name')),
1296 (b'C', b'clean', None, _(b'reset branch name to parent branch name')),
1297 (
1297 (
1298 b'r',
1298 b'r',
1299 b'rev',
1299 b'rev',
1300 [],
1300 [],
1301 _(b'change branches of the given revs (EXPERIMENTAL)'),
1301 _(b'change branches of the given revs (EXPERIMENTAL)'),
1302 ),
1302 ),
1303 ],
1303 ],
1304 _(b'[-fC] [NAME]'),
1304 _(b'[-fC] [NAME]'),
1305 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
1305 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
1306 )
1306 )
1307 def branch(ui, repo, label=None, **opts):
1307 def branch(ui, repo, label=None, **opts):
1308 """set or show the current branch name
1308 """set or show the current branch name
1309
1309
1310 .. note::
1310 .. note::
1311
1311
1312 Branch names are permanent and global. Use :hg:`bookmark` to create a
1312 Branch names are permanent and global. Use :hg:`bookmark` to create a
1313 light-weight bookmark instead. See :hg:`help glossary` for more
1313 light-weight bookmark instead. See :hg:`help glossary` for more
1314 information about named branches and bookmarks.
1314 information about named branches and bookmarks.
1315
1315
1316 With no argument, show the current branch name. With one argument,
1316 With no argument, show the current branch name. With one argument,
1317 set the working directory branch name (the branch will not exist
1317 set the working directory branch name (the branch will not exist
1318 in the repository until the next commit). Standard practice
1318 in the repository until the next commit). Standard practice
1319 recommends that primary development take place on the 'default'
1319 recommends that primary development take place on the 'default'
1320 branch.
1320 branch.
1321
1321
1322 Unless -f/--force is specified, branch will not let you set a
1322 Unless -f/--force is specified, branch will not let you set a
1323 branch name that already exists.
1323 branch name that already exists.
1324
1324
1325 Use -C/--clean to reset the working directory branch to that of
1325 Use -C/--clean to reset the working directory branch to that of
1326 the parent of the working directory, negating a previous branch
1326 the parent of the working directory, negating a previous branch
1327 change.
1327 change.
1328
1328
1329 Use the command :hg:`update` to switch to an existing branch. Use
1329 Use the command :hg:`update` to switch to an existing branch. Use
1330 :hg:`commit --close-branch` to mark this branch head as closed.
1330 :hg:`commit --close-branch` to mark this branch head as closed.
1331 When all heads of a branch are closed, the branch will be
1331 When all heads of a branch are closed, the branch will be
1332 considered closed.
1332 considered closed.
1333
1333
1334 Returns 0 on success.
1334 Returns 0 on success.
1335 """
1335 """
1336 opts = pycompat.byteskwargs(opts)
1336 opts = pycompat.byteskwargs(opts)
1337 revs = opts.get(b'rev')
1337 revs = opts.get(b'rev')
1338 if label:
1338 if label:
1339 label = label.strip()
1339 label = label.strip()
1340
1340
1341 if not opts.get(b'clean') and not label:
1341 if not opts.get(b'clean') and not label:
1342 if revs:
1342 if revs:
1343 raise error.InputError(
1343 raise error.InputError(
1344 _(b"no branch name specified for the revisions")
1344 _(b"no branch name specified for the revisions")
1345 )
1345 )
1346 ui.write(b"%s\n" % repo.dirstate.branch())
1346 ui.write(b"%s\n" % repo.dirstate.branch())
1347 return
1347 return
1348
1348
1349 with repo.wlock():
1349 with repo.wlock():
1350 if opts.get(b'clean'):
1350 if opts.get(b'clean'):
1351 label = repo[b'.'].branch()
1351 label = repo[b'.'].branch()
1352 repo.dirstate.setbranch(label)
1352 repo.dirstate.setbranch(label)
1353 ui.status(_(b'reset working directory to branch %s\n') % label)
1353 ui.status(_(b'reset working directory to branch %s\n') % label)
1354 elif label:
1354 elif label:
1355
1355
1356 scmutil.checknewlabel(repo, label, b'branch')
1356 scmutil.checknewlabel(repo, label, b'branch')
1357 if revs:
1357 if revs:
1358 return cmdutil.changebranch(ui, repo, revs, label, opts)
1358 return cmdutil.changebranch(ui, repo, revs, label, opts)
1359
1359
1360 if not opts.get(b'force') and label in repo.branchmap():
1360 if not opts.get(b'force') and label in repo.branchmap():
1361 if label not in [p.branch() for p in repo[None].parents()]:
1361 if label not in [p.branch() for p in repo[None].parents()]:
1362 raise error.InputError(
1362 raise error.InputError(
1363 _(b'a branch of the same name already exists'),
1363 _(b'a branch of the same name already exists'),
1364 # i18n: "it" refers to an existing branch
1364 # i18n: "it" refers to an existing branch
1365 hint=_(b"use 'hg update' to switch to it"),
1365 hint=_(b"use 'hg update' to switch to it"),
1366 )
1366 )
1367
1367
1368 repo.dirstate.setbranch(label)
1368 repo.dirstate.setbranch(label)
1369 ui.status(_(b'marked working directory as branch %s\n') % label)
1369 ui.status(_(b'marked working directory as branch %s\n') % label)
1370
1370
1371 # find any open named branches aside from default
1371 # find any open named branches aside from default
1372 for n, h, t, c in repo.branchmap().iterbranches():
1372 for n, h, t, c in repo.branchmap().iterbranches():
1373 if n != b"default" and not c:
1373 if n != b"default" and not c:
1374 return 0
1374 return 0
1375 ui.status(
1375 ui.status(
1376 _(
1376 _(
1377 b'(branches are permanent and global, '
1377 b'(branches are permanent and global, '
1378 b'did you want a bookmark?)\n'
1378 b'did you want a bookmark?)\n'
1379 )
1379 )
1380 )
1380 )
1381
1381
1382
1382
1383 @command(
1383 @command(
1384 b'branches',
1384 b'branches',
1385 [
1385 [
1386 (
1386 (
1387 b'a',
1387 b'a',
1388 b'active',
1388 b'active',
1389 False,
1389 False,
1390 _(b'show only branches that have unmerged heads (DEPRECATED)'),
1390 _(b'show only branches that have unmerged heads (DEPRECATED)'),
1391 ),
1391 ),
1392 (b'c', b'closed', False, _(b'show normal and closed branches')),
1392 (b'c', b'closed', False, _(b'show normal and closed branches')),
1393 (b'r', b'rev', [], _(b'show branch name(s) of the given rev')),
1393 (b'r', b'rev', [], _(b'show branch name(s) of the given rev')),
1394 ]
1394 ]
1395 + formatteropts,
1395 + formatteropts,
1396 _(b'[-c]'),
1396 _(b'[-c]'),
1397 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
1397 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
1398 intents={INTENT_READONLY},
1398 intents={INTENT_READONLY},
1399 )
1399 )
1400 def branches(ui, repo, active=False, closed=False, **opts):
1400 def branches(ui, repo, active=False, closed=False, **opts):
1401 """list repository named branches
1401 """list repository named branches
1402
1402
1403 List the repository's named branches, indicating which ones are
1403 List the repository's named branches, indicating which ones are
1404 inactive. If -c/--closed is specified, also list branches which have
1404 inactive. If -c/--closed is specified, also list branches which have
1405 been marked closed (see :hg:`commit --close-branch`).
1405 been marked closed (see :hg:`commit --close-branch`).
1406
1406
1407 Use the command :hg:`update` to switch to an existing branch.
1407 Use the command :hg:`update` to switch to an existing branch.
1408
1408
1409 .. container:: verbose
1409 .. container:: verbose
1410
1410
1411 Template:
1411 Template:
1412
1412
1413 The following keywords are supported in addition to the common template
1413 The following keywords are supported in addition to the common template
1414 keywords and functions such as ``{branch}``. See also
1414 keywords and functions such as ``{branch}``. See also
1415 :hg:`help templates`.
1415 :hg:`help templates`.
1416
1416
1417 :active: Boolean. True if the branch is active.
1417 :active: Boolean. True if the branch is active.
1418 :closed: Boolean. True if the branch is closed.
1418 :closed: Boolean. True if the branch is closed.
1419 :current: Boolean. True if it is the current branch.
1419 :current: Boolean. True if it is the current branch.
1420
1420
1421 Returns 0.
1421 Returns 0.
1422 """
1422 """
1423
1423
1424 opts = pycompat.byteskwargs(opts)
1424 opts = pycompat.byteskwargs(opts)
1425 revs = opts.get(b'rev')
1425 revs = opts.get(b'rev')
1426 selectedbranches = None
1426 selectedbranches = None
1427 if revs:
1427 if revs:
1428 revs = scmutil.revrange(repo, revs)
1428 revs = scmutil.revrange(repo, revs)
1429 getbi = repo.revbranchcache().branchinfo
1429 getbi = repo.revbranchcache().branchinfo
1430 selectedbranches = {getbi(r)[0] for r in revs}
1430 selectedbranches = {getbi(r)[0] for r in revs}
1431
1431
1432 ui.pager(b'branches')
1432 ui.pager(b'branches')
1433 fm = ui.formatter(b'branches', opts)
1433 fm = ui.formatter(b'branches', opts)
1434 hexfunc = fm.hexfunc
1434 hexfunc = fm.hexfunc
1435
1435
1436 allheads = set(repo.heads())
1436 allheads = set(repo.heads())
1437 branches = []
1437 branches = []
1438 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1438 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1439 if selectedbranches is not None and tag not in selectedbranches:
1439 if selectedbranches is not None and tag not in selectedbranches:
1440 continue
1440 continue
1441 isactive = False
1441 isactive = False
1442 if not isclosed:
1442 if not isclosed:
1443 openheads = set(repo.branchmap().iteropen(heads))
1443 openheads = set(repo.branchmap().iteropen(heads))
1444 isactive = bool(openheads & allheads)
1444 isactive = bool(openheads & allheads)
1445 branches.append((tag, repo[tip], isactive, not isclosed))
1445 branches.append((tag, repo[tip], isactive, not isclosed))
1446 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]), reverse=True)
1446 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]), reverse=True)
1447
1447
1448 for tag, ctx, isactive, isopen in branches:
1448 for tag, ctx, isactive, isopen in branches:
1449 if active and not isactive:
1449 if active and not isactive:
1450 continue
1450 continue
1451 if isactive:
1451 if isactive:
1452 label = b'branches.active'
1452 label = b'branches.active'
1453 notice = b''
1453 notice = b''
1454 elif not isopen:
1454 elif not isopen:
1455 if not closed:
1455 if not closed:
1456 continue
1456 continue
1457 label = b'branches.closed'
1457 label = b'branches.closed'
1458 notice = _(b' (closed)')
1458 notice = _(b' (closed)')
1459 else:
1459 else:
1460 label = b'branches.inactive'
1460 label = b'branches.inactive'
1461 notice = _(b' (inactive)')
1461 notice = _(b' (inactive)')
1462 current = tag == repo.dirstate.branch()
1462 current = tag == repo.dirstate.branch()
1463 if current:
1463 if current:
1464 label = b'branches.current'
1464 label = b'branches.current'
1465
1465
1466 fm.startitem()
1466 fm.startitem()
1467 fm.write(b'branch', b'%s', tag, label=label)
1467 fm.write(b'branch', b'%s', tag, label=label)
1468 rev = ctx.rev()
1468 rev = ctx.rev()
1469 padsize = max(31 - len(b"%d" % rev) - encoding.colwidth(tag), 0)
1469 padsize = max(31 - len(b"%d" % rev) - encoding.colwidth(tag), 0)
1470 fmt = b' ' * padsize + b' %d:%s'
1470 fmt = b' ' * padsize + b' %d:%s'
1471 fm.condwrite(
1471 fm.condwrite(
1472 not ui.quiet,
1472 not ui.quiet,
1473 b'rev node',
1473 b'rev node',
1474 fmt,
1474 fmt,
1475 rev,
1475 rev,
1476 hexfunc(ctx.node()),
1476 hexfunc(ctx.node()),
1477 label=b'log.changeset changeset.%s' % ctx.phasestr(),
1477 label=b'log.changeset changeset.%s' % ctx.phasestr(),
1478 )
1478 )
1479 fm.context(ctx=ctx)
1479 fm.context(ctx=ctx)
1480 fm.data(active=isactive, closed=not isopen, current=current)
1480 fm.data(active=isactive, closed=not isopen, current=current)
1481 if not ui.quiet:
1481 if not ui.quiet:
1482 fm.plain(notice)
1482 fm.plain(notice)
1483 fm.plain(b'\n')
1483 fm.plain(b'\n')
1484 fm.end()
1484 fm.end()
1485
1485
1486
1486
1487 @command(
1487 @command(
1488 b'bundle',
1488 b'bundle',
1489 [
1489 [
1490 (
1490 (
1491 b'f',
1491 b'f',
1492 b'force',
1492 b'force',
1493 None,
1493 None,
1494 _(b'run even when the destination is unrelated'),
1494 _(b'run even when the destination is unrelated'),
1495 ),
1495 ),
1496 (
1496 (
1497 b'r',
1497 b'r',
1498 b'rev',
1498 b'rev',
1499 [],
1499 [],
1500 _(b'a changeset intended to be added to the destination'),
1500 _(b'a changeset intended to be added to the destination'),
1501 _(b'REV'),
1501 _(b'REV'),
1502 ),
1502 ),
1503 (
1503 (
1504 b'b',
1504 b'b',
1505 b'branch',
1505 b'branch',
1506 [],
1506 [],
1507 _(b'a specific branch you would like to bundle'),
1507 _(b'a specific branch you would like to bundle'),
1508 _(b'BRANCH'),
1508 _(b'BRANCH'),
1509 ),
1509 ),
1510 (
1510 (
1511 b'',
1511 b'',
1512 b'base',
1512 b'base',
1513 [],
1513 [],
1514 _(b'a base changeset assumed to be available at the destination'),
1514 _(b'a base changeset assumed to be available at the destination'),
1515 _(b'REV'),
1515 _(b'REV'),
1516 ),
1516 ),
1517 (b'a', b'all', None, _(b'bundle all changesets in the repository')),
1517 (b'a', b'all', None, _(b'bundle all changesets in the repository')),
1518 (
1518 (
1519 b't',
1519 b't',
1520 b'type',
1520 b'type',
1521 b'bzip2',
1521 b'bzip2',
1522 _(b'bundle compression type to use'),
1522 _(b'bundle compression type to use'),
1523 _(b'TYPE'),
1523 _(b'TYPE'),
1524 ),
1524 ),
1525 ]
1525 ]
1526 + remoteopts,
1526 + remoteopts,
1527 _(b'[-f] [-t BUNDLESPEC] [-a] [-r REV]... [--base REV]... FILE [DEST]'),
1527 _(b'[-f] [-t BUNDLESPEC] [-a] [-r REV]... [--base REV]... FILE [DEST]'),
1528 helpcategory=command.CATEGORY_IMPORT_EXPORT,
1528 helpcategory=command.CATEGORY_IMPORT_EXPORT,
1529 )
1529 )
1530 def bundle(ui, repo, fname, dest=None, **opts):
1530 def bundle(ui, repo, fname, dest=None, **opts):
1531 """create a bundle file
1531 """create a bundle file
1532
1532
1533 Generate a bundle file containing data to be transferred to another
1533 Generate a bundle file containing data to be transferred to another
1534 repository.
1534 repository.
1535
1535
1536 To create a bundle containing all changesets, use -a/--all
1536 To create a bundle containing all changesets, use -a/--all
1537 (or --base null). Otherwise, hg assumes the destination will have
1537 (or --base null). Otherwise, hg assumes the destination will have
1538 all the nodes you specify with --base parameters. Otherwise, hg
1538 all the nodes you specify with --base parameters. Otherwise, hg
1539 will assume the repository has all the nodes in destination, or
1539 will assume the repository has all the nodes in destination, or
1540 default-push/default if no destination is specified, where destination
1540 default-push/default if no destination is specified, where destination
1541 is the repository you provide through DEST option.
1541 is the repository you provide through DEST option.
1542
1542
1543 You can change bundle format with the -t/--type option. See
1543 You can change bundle format with the -t/--type option. See
1544 :hg:`help bundlespec` for documentation on this format. By default,
1544 :hg:`help bundlespec` for documentation on this format. By default,
1545 the most appropriate format is used and compression defaults to
1545 the most appropriate format is used and compression defaults to
1546 bzip2.
1546 bzip2.
1547
1547
1548 The bundle file can then be transferred using conventional means
1548 The bundle file can then be transferred using conventional means
1549 and applied to another repository with the unbundle or pull
1549 and applied to another repository with the unbundle or pull
1550 command. This is useful when direct push and pull are not
1550 command. This is useful when direct push and pull are not
1551 available or when exporting an entire repository is undesirable.
1551 available or when exporting an entire repository is undesirable.
1552
1552
1553 Applying bundles preserves all changeset contents including
1553 Applying bundles preserves all changeset contents including
1554 permissions, copy/rename information, and revision history.
1554 permissions, copy/rename information, and revision history.
1555
1555
1556 Returns 0 on success, 1 if no changes found.
1556 Returns 0 on success, 1 if no changes found.
1557 """
1557 """
1558 opts = pycompat.byteskwargs(opts)
1558 opts = pycompat.byteskwargs(opts)
1559 revs = None
1559 revs = None
1560 if b'rev' in opts:
1560 if b'rev' in opts:
1561 revstrings = opts[b'rev']
1561 revstrings = opts[b'rev']
1562 revs = scmutil.revrange(repo, revstrings)
1562 revs = scmutil.revrange(repo, revstrings)
1563 if revstrings and not revs:
1563 if revstrings and not revs:
1564 raise error.InputError(_(b'no commits to bundle'))
1564 raise error.InputError(_(b'no commits to bundle'))
1565
1565
1566 bundletype = opts.get(b'type', b'bzip2').lower()
1566 bundletype = opts.get(b'type', b'bzip2').lower()
1567 try:
1567 try:
1568 bundlespec = bundlecaches.parsebundlespec(
1568 bundlespec = bundlecaches.parsebundlespec(
1569 repo, bundletype, strict=False
1569 repo, bundletype, strict=False
1570 )
1570 )
1571 except error.UnsupportedBundleSpecification as e:
1571 except error.UnsupportedBundleSpecification as e:
1572 raise error.InputError(
1572 raise error.InputError(
1573 pycompat.bytestr(e),
1573 pycompat.bytestr(e),
1574 hint=_(b"see 'hg help bundlespec' for supported values for --type"),
1574 hint=_(b"see 'hg help bundlespec' for supported values for --type"),
1575 )
1575 )
1576 cgversion = bundlespec.contentopts[b"cg.version"]
1576 cgversion = bundlespec.contentopts[b"cg.version"]
1577
1577
1578 # Packed bundles are a pseudo bundle format for now.
1578 # Packed bundles are a pseudo bundle format for now.
1579 if cgversion == b's1':
1579 if cgversion == b's1':
1580 raise error.InputError(
1580 raise error.InputError(
1581 _(b'packed bundles cannot be produced by "hg bundle"'),
1581 _(b'packed bundles cannot be produced by "hg bundle"'),
1582 hint=_(b"use 'hg debugcreatestreamclonebundle'"),
1582 hint=_(b"use 'hg debugcreatestreamclonebundle'"),
1583 )
1583 )
1584
1584
1585 if opts.get(b'all'):
1585 if opts.get(b'all'):
1586 if dest:
1586 if dest:
1587 raise error.InputError(
1587 raise error.InputError(
1588 _(b"--all is incompatible with specifying a destination")
1588 _(b"--all is incompatible with specifying a destination")
1589 )
1589 )
1590 if opts.get(b'base'):
1590 if opts.get(b'base'):
1591 ui.warn(_(b"ignoring --base because --all was specified\n"))
1591 ui.warn(_(b"ignoring --base because --all was specified\n"))
1592 base = [nullrev]
1592 base = [nullrev]
1593 else:
1593 else:
1594 base = scmutil.revrange(repo, opts.get(b'base'))
1594 base = scmutil.revrange(repo, opts.get(b'base'))
1595 if cgversion not in changegroup.supportedoutgoingversions(repo):
1595 if cgversion not in changegroup.supportedoutgoingversions(repo):
1596 raise error.Abort(
1596 raise error.Abort(
1597 _(b"repository does not support bundle version %s") % cgversion
1597 _(b"repository does not support bundle version %s") % cgversion
1598 )
1598 )
1599
1599
1600 if base:
1600 if base:
1601 if dest:
1601 if dest:
1602 raise error.InputError(
1602 raise error.InputError(
1603 _(b"--base is incompatible with specifying a destination")
1603 _(b"--base is incompatible with specifying a destination")
1604 )
1604 )
1605 common = [repo[rev].node() for rev in base]
1605 common = [repo[rev].node() for rev in base]
1606 heads = [repo[r].node() for r in revs] if revs else None
1606 heads = [repo[r].node() for r in revs] if revs else None
1607 outgoing = discovery.outgoing(repo, common, heads)
1607 outgoing = discovery.outgoing(repo, common, heads)
1608 else:
1608 else:
1609 dest = ui.expandpath(dest or b'default-push', dest or b'default')
1609 dest = ui.expandpath(dest or b'default-push', dest or b'default')
1610 dest, branches = hg.parseurl(dest, opts.get(b'branch'))
1610 dest, branches = hg.parseurl(dest, opts.get(b'branch'))
1611 other = hg.peer(repo, opts, dest)
1611 other = hg.peer(repo, opts, dest)
1612 revs = [repo[r].hex() for r in revs]
1612 revs = [repo[r].hex() for r in revs]
1613 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1613 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1614 heads = revs and pycompat.maplist(repo.lookup, revs) or revs
1614 heads = revs and pycompat.maplist(repo.lookup, revs) or revs
1615 outgoing = discovery.findcommonoutgoing(
1615 outgoing = discovery.findcommonoutgoing(
1616 repo,
1616 repo,
1617 other,
1617 other,
1618 onlyheads=heads,
1618 onlyheads=heads,
1619 force=opts.get(b'force'),
1619 force=opts.get(b'force'),
1620 portable=True,
1620 portable=True,
1621 )
1621 )
1622
1622
1623 if not outgoing.missing:
1623 if not outgoing.missing:
1624 scmutil.nochangesfound(ui, repo, not base and outgoing.excluded)
1624 scmutil.nochangesfound(ui, repo, not base and outgoing.excluded)
1625 return 1
1625 return 1
1626
1626
1627 if cgversion == b'01': # bundle1
1627 if cgversion == b'01': # bundle1
1628 bversion = b'HG10' + bundlespec.wirecompression
1628 bversion = b'HG10' + bundlespec.wirecompression
1629 bcompression = None
1629 bcompression = None
1630 elif cgversion in (b'02', b'03'):
1630 elif cgversion in (b'02', b'03'):
1631 bversion = b'HG20'
1631 bversion = b'HG20'
1632 bcompression = bundlespec.wirecompression
1632 bcompression = bundlespec.wirecompression
1633 else:
1633 else:
1634 raise error.ProgrammingError(
1634 raise error.ProgrammingError(
1635 b'bundle: unexpected changegroup version %s' % cgversion
1635 b'bundle: unexpected changegroup version %s' % cgversion
1636 )
1636 )
1637
1637
1638 # TODO compression options should be derived from bundlespec parsing.
1638 # TODO compression options should be derived from bundlespec parsing.
1639 # This is a temporary hack to allow adjusting bundle compression
1639 # This is a temporary hack to allow adjusting bundle compression
1640 # level without a) formalizing the bundlespec changes to declare it
1640 # level without a) formalizing the bundlespec changes to declare it
1641 # b) introducing a command flag.
1641 # b) introducing a command flag.
1642 compopts = {}
1642 compopts = {}
1643 complevel = ui.configint(
1643 complevel = ui.configint(
1644 b'experimental', b'bundlecomplevel.' + bundlespec.compression
1644 b'experimental', b'bundlecomplevel.' + bundlespec.compression
1645 )
1645 )
1646 if complevel is None:
1646 if complevel is None:
1647 complevel = ui.configint(b'experimental', b'bundlecomplevel')
1647 complevel = ui.configint(b'experimental', b'bundlecomplevel')
1648 if complevel is not None:
1648 if complevel is not None:
1649 compopts[b'level'] = complevel
1649 compopts[b'level'] = complevel
1650
1650
1651 # Allow overriding the bundling of obsmarker in phases through
1651 # Allow overriding the bundling of obsmarker in phases through
1652 # configuration while we don't have a bundle version that include them
1652 # configuration while we don't have a bundle version that include them
1653 if repo.ui.configbool(b'experimental', b'evolution.bundle-obsmarker'):
1653 if repo.ui.configbool(b'experimental', b'evolution.bundle-obsmarker'):
1654 bundlespec.contentopts[b'obsolescence'] = True
1654 bundlespec.contentopts[b'obsolescence'] = True
1655 if repo.ui.configbool(b'experimental', b'bundle-phases'):
1655 if repo.ui.configbool(b'experimental', b'bundle-phases'):
1656 bundlespec.contentopts[b'phases'] = True
1656 bundlespec.contentopts[b'phases'] = True
1657
1657
1658 bundle2.writenewbundle(
1658 bundle2.writenewbundle(
1659 ui,
1659 ui,
1660 repo,
1660 repo,
1661 b'bundle',
1661 b'bundle',
1662 fname,
1662 fname,
1663 bversion,
1663 bversion,
1664 outgoing,
1664 outgoing,
1665 bundlespec.contentopts,
1665 bundlespec.contentopts,
1666 compression=bcompression,
1666 compression=bcompression,
1667 compopts=compopts,
1667 compopts=compopts,
1668 )
1668 )
1669
1669
1670
1670
1671 @command(
1671 @command(
1672 b'cat',
1672 b'cat',
1673 [
1673 [
1674 (
1674 (
1675 b'o',
1675 b'o',
1676 b'output',
1676 b'output',
1677 b'',
1677 b'',
1678 _(b'print output to file with formatted name'),
1678 _(b'print output to file with formatted name'),
1679 _(b'FORMAT'),
1679 _(b'FORMAT'),
1680 ),
1680 ),
1681 (b'r', b'rev', b'', _(b'print the given revision'), _(b'REV')),
1681 (b'r', b'rev', b'', _(b'print the given revision'), _(b'REV')),
1682 (b'', b'decode', None, _(b'apply any matching decode filter')),
1682 (b'', b'decode', None, _(b'apply any matching decode filter')),
1683 ]
1683 ]
1684 + walkopts
1684 + walkopts
1685 + formatteropts,
1685 + formatteropts,
1686 _(b'[OPTION]... FILE...'),
1686 _(b'[OPTION]... FILE...'),
1687 helpcategory=command.CATEGORY_FILE_CONTENTS,
1687 helpcategory=command.CATEGORY_FILE_CONTENTS,
1688 inferrepo=True,
1688 inferrepo=True,
1689 intents={INTENT_READONLY},
1689 intents={INTENT_READONLY},
1690 )
1690 )
1691 def cat(ui, repo, file1, *pats, **opts):
1691 def cat(ui, repo, file1, *pats, **opts):
1692 """output the current or given revision of files
1692 """output the current or given revision of files
1693
1693
1694 Print the specified files as they were at the given revision. If
1694 Print the specified files as they were at the given revision. If
1695 no revision is given, the parent of the working directory is used.
1695 no revision is given, the parent of the working directory is used.
1696
1696
1697 Output may be to a file, in which case the name of the file is
1697 Output may be to a file, in which case the name of the file is
1698 given using a template string. See :hg:`help templates`. In addition
1698 given using a template string. See :hg:`help templates`. In addition
1699 to the common template keywords, the following formatting rules are
1699 to the common template keywords, the following formatting rules are
1700 supported:
1700 supported:
1701
1701
1702 :``%%``: literal "%" character
1702 :``%%``: literal "%" character
1703 :``%s``: basename of file being printed
1703 :``%s``: basename of file being printed
1704 :``%d``: dirname of file being printed, or '.' if in repository root
1704 :``%d``: dirname of file being printed, or '.' if in repository root
1705 :``%p``: root-relative path name of file being printed
1705 :``%p``: root-relative path name of file being printed
1706 :``%H``: changeset hash (40 hexadecimal digits)
1706 :``%H``: changeset hash (40 hexadecimal digits)
1707 :``%R``: changeset revision number
1707 :``%R``: changeset revision number
1708 :``%h``: short-form changeset hash (12 hexadecimal digits)
1708 :``%h``: short-form changeset hash (12 hexadecimal digits)
1709 :``%r``: zero-padded changeset revision number
1709 :``%r``: zero-padded changeset revision number
1710 :``%b``: basename of the exporting repository
1710 :``%b``: basename of the exporting repository
1711 :``\\``: literal "\\" character
1711 :``\\``: literal "\\" character
1712
1712
1713 .. container:: verbose
1713 .. container:: verbose
1714
1714
1715 Template:
1715 Template:
1716
1716
1717 The following keywords are supported in addition to the common template
1717 The following keywords are supported in addition to the common template
1718 keywords and functions. See also :hg:`help templates`.
1718 keywords and functions. See also :hg:`help templates`.
1719
1719
1720 :data: String. File content.
1720 :data: String. File content.
1721 :path: String. Repository-absolute path of the file.
1721 :path: String. Repository-absolute path of the file.
1722
1722
1723 Returns 0 on success.
1723 Returns 0 on success.
1724 """
1724 """
1725 opts = pycompat.byteskwargs(opts)
1725 opts = pycompat.byteskwargs(opts)
1726 rev = opts.get(b'rev')
1726 rev = opts.get(b'rev')
1727 if rev:
1727 if rev:
1728 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
1728 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
1729 ctx = scmutil.revsingle(repo, rev)
1729 ctx = scmutil.revsingle(repo, rev)
1730 m = scmutil.match(ctx, (file1,) + pats, opts)
1730 m = scmutil.match(ctx, (file1,) + pats, opts)
1731 fntemplate = opts.pop(b'output', b'')
1731 fntemplate = opts.pop(b'output', b'')
1732 if cmdutil.isstdiofilename(fntemplate):
1732 if cmdutil.isstdiofilename(fntemplate):
1733 fntemplate = b''
1733 fntemplate = b''
1734
1734
1735 if fntemplate:
1735 if fntemplate:
1736 fm = formatter.nullformatter(ui, b'cat', opts)
1736 fm = formatter.nullformatter(ui, b'cat', opts)
1737 else:
1737 else:
1738 ui.pager(b'cat')
1738 ui.pager(b'cat')
1739 fm = ui.formatter(b'cat', opts)
1739 fm = ui.formatter(b'cat', opts)
1740 with fm:
1740 with fm:
1741 return cmdutil.cat(
1741 return cmdutil.cat(
1742 ui, repo, ctx, m, fm, fntemplate, b'', **pycompat.strkwargs(opts)
1742 ui, repo, ctx, m, fm, fntemplate, b'', **pycompat.strkwargs(opts)
1743 )
1743 )
1744
1744
1745
1745
1746 @command(
1746 @command(
1747 b'clone',
1747 b'clone',
1748 [
1748 [
1749 (
1749 (
1750 b'U',
1750 b'U',
1751 b'noupdate',
1751 b'noupdate',
1752 None,
1752 None,
1753 _(
1753 _(
1754 b'the clone will include an empty working '
1754 b'the clone will include an empty working '
1755 b'directory (only a repository)'
1755 b'directory (only a repository)'
1756 ),
1756 ),
1757 ),
1757 ),
1758 (
1758 (
1759 b'u',
1759 b'u',
1760 b'updaterev',
1760 b'updaterev',
1761 b'',
1761 b'',
1762 _(b'revision, tag, or branch to check out'),
1762 _(b'revision, tag, or branch to check out'),
1763 _(b'REV'),
1763 _(b'REV'),
1764 ),
1764 ),
1765 (
1765 (
1766 b'r',
1766 b'r',
1767 b'rev',
1767 b'rev',
1768 [],
1768 [],
1769 _(
1769 _(
1770 b'do not clone everything, but include this changeset'
1770 b'do not clone everything, but include this changeset'
1771 b' and its ancestors'
1771 b' and its ancestors'
1772 ),
1772 ),
1773 _(b'REV'),
1773 _(b'REV'),
1774 ),
1774 ),
1775 (
1775 (
1776 b'b',
1776 b'b',
1777 b'branch',
1777 b'branch',
1778 [],
1778 [],
1779 _(
1779 _(
1780 b'do not clone everything, but include this branch\'s'
1780 b'do not clone everything, but include this branch\'s'
1781 b' changesets and their ancestors'
1781 b' changesets and their ancestors'
1782 ),
1782 ),
1783 _(b'BRANCH'),
1783 _(b'BRANCH'),
1784 ),
1784 ),
1785 (b'', b'pull', None, _(b'use pull protocol to copy metadata')),
1785 (b'', b'pull', None, _(b'use pull protocol to copy metadata')),
1786 (b'', b'uncompressed', None, _(b'an alias to --stream (DEPRECATED)')),
1786 (b'', b'uncompressed', None, _(b'an alias to --stream (DEPRECATED)')),
1787 (b'', b'stream', None, _(b'clone with minimal data processing')),
1787 (b'', b'stream', None, _(b'clone with minimal data processing')),
1788 ]
1788 ]
1789 + remoteopts,
1789 + remoteopts,
1790 _(b'[OPTION]... SOURCE [DEST]'),
1790 _(b'[OPTION]... SOURCE [DEST]'),
1791 helpcategory=command.CATEGORY_REPO_CREATION,
1791 helpcategory=command.CATEGORY_REPO_CREATION,
1792 helpbasic=True,
1792 helpbasic=True,
1793 norepo=True,
1793 norepo=True,
1794 )
1794 )
1795 def clone(ui, source, dest=None, **opts):
1795 def clone(ui, source, dest=None, **opts):
1796 """make a copy of an existing repository
1796 """make a copy of an existing repository
1797
1797
1798 Create a copy of an existing repository in a new directory.
1798 Create a copy of an existing repository in a new directory.
1799
1799
1800 If no destination directory name is specified, it defaults to the
1800 If no destination directory name is specified, it defaults to the
1801 basename of the source.
1801 basename of the source.
1802
1802
1803 The location of the source is added to the new repository's
1803 The location of the source is added to the new repository's
1804 ``.hg/hgrc`` file, as the default to be used for future pulls.
1804 ``.hg/hgrc`` file, as the default to be used for future pulls.
1805
1805
1806 Only local paths and ``ssh://`` URLs are supported as
1806 Only local paths and ``ssh://`` URLs are supported as
1807 destinations. For ``ssh://`` destinations, no working directory or
1807 destinations. For ``ssh://`` destinations, no working directory or
1808 ``.hg/hgrc`` will be created on the remote side.
1808 ``.hg/hgrc`` will be created on the remote side.
1809
1809
1810 If the source repository has a bookmark called '@' set, that
1810 If the source repository has a bookmark called '@' set, that
1811 revision will be checked out in the new repository by default.
1811 revision will be checked out in the new repository by default.
1812
1812
1813 To check out a particular version, use -u/--update, or
1813 To check out a particular version, use -u/--update, or
1814 -U/--noupdate to create a clone with no working directory.
1814 -U/--noupdate to create a clone with no working directory.
1815
1815
1816 To pull only a subset of changesets, specify one or more revisions
1816 To pull only a subset of changesets, specify one or more revisions
1817 identifiers with -r/--rev or branches with -b/--branch. The
1817 identifiers with -r/--rev or branches with -b/--branch. The
1818 resulting clone will contain only the specified changesets and
1818 resulting clone will contain only the specified changesets and
1819 their ancestors. These options (or 'clone src#rev dest') imply
1819 their ancestors. These options (or 'clone src#rev dest') imply
1820 --pull, even for local source repositories.
1820 --pull, even for local source repositories.
1821
1821
1822 In normal clone mode, the remote normalizes repository data into a common
1822 In normal clone mode, the remote normalizes repository data into a common
1823 exchange format and the receiving end translates this data into its local
1823 exchange format and the receiving end translates this data into its local
1824 storage format. --stream activates a different clone mode that essentially
1824 storage format. --stream activates a different clone mode that essentially
1825 copies repository files from the remote with minimal data processing. This
1825 copies repository files from the remote with minimal data processing. This
1826 significantly reduces the CPU cost of a clone both remotely and locally.
1826 significantly reduces the CPU cost of a clone both remotely and locally.
1827 However, it often increases the transferred data size by 30-40%. This can
1827 However, it often increases the transferred data size by 30-40%. This can
1828 result in substantially faster clones where I/O throughput is plentiful,
1828 result in substantially faster clones where I/O throughput is plentiful,
1829 especially for larger repositories. A side-effect of --stream clones is
1829 especially for larger repositories. A side-effect of --stream clones is
1830 that storage settings and requirements on the remote are applied locally:
1830 that storage settings and requirements on the remote are applied locally:
1831 a modern client may inherit legacy or inefficient storage used by the
1831 a modern client may inherit legacy or inefficient storage used by the
1832 remote or a legacy Mercurial client may not be able to clone from a
1832 remote or a legacy Mercurial client may not be able to clone from a
1833 modern Mercurial remote.
1833 modern Mercurial remote.
1834
1834
1835 .. note::
1835 .. note::
1836
1836
1837 Specifying a tag will include the tagged changeset but not the
1837 Specifying a tag will include the tagged changeset but not the
1838 changeset containing the tag.
1838 changeset containing the tag.
1839
1839
1840 .. container:: verbose
1840 .. container:: verbose
1841
1841
1842 For efficiency, hardlinks are used for cloning whenever the
1842 For efficiency, hardlinks are used for cloning whenever the
1843 source and destination are on the same filesystem (note this
1843 source and destination are on the same filesystem (note this
1844 applies only to the repository data, not to the working
1844 applies only to the repository data, not to the working
1845 directory). Some filesystems, such as AFS, implement hardlinking
1845 directory). Some filesystems, such as AFS, implement hardlinking
1846 incorrectly, but do not report errors. In these cases, use the
1846 incorrectly, but do not report errors. In these cases, use the
1847 --pull option to avoid hardlinking.
1847 --pull option to avoid hardlinking.
1848
1848
1849 Mercurial will update the working directory to the first applicable
1849 Mercurial will update the working directory to the first applicable
1850 revision from this list:
1850 revision from this list:
1851
1851
1852 a) null if -U or the source repository has no changesets
1852 a) null if -U or the source repository has no changesets
1853 b) if -u . and the source repository is local, the first parent of
1853 b) if -u . and the source repository is local, the first parent of
1854 the source repository's working directory
1854 the source repository's working directory
1855 c) the changeset specified with -u (if a branch name, this means the
1855 c) the changeset specified with -u (if a branch name, this means the
1856 latest head of that branch)
1856 latest head of that branch)
1857 d) the changeset specified with -r
1857 d) the changeset specified with -r
1858 e) the tipmost head specified with -b
1858 e) the tipmost head specified with -b
1859 f) the tipmost head specified with the url#branch source syntax
1859 f) the tipmost head specified with the url#branch source syntax
1860 g) the revision marked with the '@' bookmark, if present
1860 g) the revision marked with the '@' bookmark, if present
1861 h) the tipmost head of the default branch
1861 h) the tipmost head of the default branch
1862 i) tip
1862 i) tip
1863
1863
1864 When cloning from servers that support it, Mercurial may fetch
1864 When cloning from servers that support it, Mercurial may fetch
1865 pre-generated data from a server-advertised URL or inline from the
1865 pre-generated data from a server-advertised URL or inline from the
1866 same stream. When this is done, hooks operating on incoming changesets
1866 same stream. When this is done, hooks operating on incoming changesets
1867 and changegroups may fire more than once, once for each pre-generated
1867 and changegroups may fire more than once, once for each pre-generated
1868 bundle and as well as for any additional remaining data. In addition,
1868 bundle and as well as for any additional remaining data. In addition,
1869 if an error occurs, the repository may be rolled back to a partial
1869 if an error occurs, the repository may be rolled back to a partial
1870 clone. This behavior may change in future releases.
1870 clone. This behavior may change in future releases.
1871 See :hg:`help -e clonebundles` for more.
1871 See :hg:`help -e clonebundles` for more.
1872
1872
1873 Examples:
1873 Examples:
1874
1874
1875 - clone a remote repository to a new directory named hg/::
1875 - clone a remote repository to a new directory named hg/::
1876
1876
1877 hg clone https://www.mercurial-scm.org/repo/hg/
1877 hg clone https://www.mercurial-scm.org/repo/hg/
1878
1878
1879 - create a lightweight local clone::
1879 - create a lightweight local clone::
1880
1880
1881 hg clone project/ project-feature/
1881 hg clone project/ project-feature/
1882
1882
1883 - clone from an absolute path on an ssh server (note double-slash)::
1883 - clone from an absolute path on an ssh server (note double-slash)::
1884
1884
1885 hg clone ssh://user@server//home/projects/alpha/
1885 hg clone ssh://user@server//home/projects/alpha/
1886
1886
1887 - do a streaming clone while checking out a specified version::
1887 - do a streaming clone while checking out a specified version::
1888
1888
1889 hg clone --stream http://server/repo -u 1.5
1889 hg clone --stream http://server/repo -u 1.5
1890
1890
1891 - create a repository without changesets after a particular revision::
1891 - create a repository without changesets after a particular revision::
1892
1892
1893 hg clone -r 04e544 experimental/ good/
1893 hg clone -r 04e544 experimental/ good/
1894
1894
1895 - clone (and track) a particular named branch::
1895 - clone (and track) a particular named branch::
1896
1896
1897 hg clone https://www.mercurial-scm.org/repo/hg/#stable
1897 hg clone https://www.mercurial-scm.org/repo/hg/#stable
1898
1898
1899 See :hg:`help urls` for details on specifying URLs.
1899 See :hg:`help urls` for details on specifying URLs.
1900
1900
1901 Returns 0 on success.
1901 Returns 0 on success.
1902 """
1902 """
1903 opts = pycompat.byteskwargs(opts)
1903 opts = pycompat.byteskwargs(opts)
1904 cmdutil.check_at_most_one_arg(opts, b'noupdate', b'updaterev')
1904 cmdutil.check_at_most_one_arg(opts, b'noupdate', b'updaterev')
1905
1905
1906 # --include/--exclude can come from narrow or sparse.
1906 # --include/--exclude can come from narrow or sparse.
1907 includepats, excludepats = None, None
1907 includepats, excludepats = None, None
1908
1908
1909 # hg.clone() differentiates between None and an empty set. So make sure
1909 # hg.clone() differentiates between None and an empty set. So make sure
1910 # patterns are sets if narrow is requested without patterns.
1910 # patterns are sets if narrow is requested without patterns.
1911 if opts.get(b'narrow'):
1911 if opts.get(b'narrow'):
1912 includepats = set()
1912 includepats = set()
1913 excludepats = set()
1913 excludepats = set()
1914
1914
1915 if opts.get(b'include'):
1915 if opts.get(b'include'):
1916 includepats = narrowspec.parsepatterns(opts.get(b'include'))
1916 includepats = narrowspec.parsepatterns(opts.get(b'include'))
1917 if opts.get(b'exclude'):
1917 if opts.get(b'exclude'):
1918 excludepats = narrowspec.parsepatterns(opts.get(b'exclude'))
1918 excludepats = narrowspec.parsepatterns(opts.get(b'exclude'))
1919
1919
1920 r = hg.clone(
1920 r = hg.clone(
1921 ui,
1921 ui,
1922 opts,
1922 opts,
1923 source,
1923 source,
1924 dest,
1924 dest,
1925 pull=opts.get(b'pull'),
1925 pull=opts.get(b'pull'),
1926 stream=opts.get(b'stream') or opts.get(b'uncompressed'),
1926 stream=opts.get(b'stream') or opts.get(b'uncompressed'),
1927 revs=opts.get(b'rev'),
1927 revs=opts.get(b'rev'),
1928 update=opts.get(b'updaterev') or not opts.get(b'noupdate'),
1928 update=opts.get(b'updaterev') or not opts.get(b'noupdate'),
1929 branch=opts.get(b'branch'),
1929 branch=opts.get(b'branch'),
1930 shareopts=opts.get(b'shareopts'),
1930 shareopts=opts.get(b'shareopts'),
1931 storeincludepats=includepats,
1931 storeincludepats=includepats,
1932 storeexcludepats=excludepats,
1932 storeexcludepats=excludepats,
1933 depth=opts.get(b'depth') or None,
1933 depth=opts.get(b'depth') or None,
1934 )
1934 )
1935
1935
1936 return r is None
1936 return r is None
1937
1937
1938
1938
1939 @command(
1939 @command(
1940 b'commit|ci',
1940 b'commit|ci',
1941 [
1941 [
1942 (
1942 (
1943 b'A',
1943 b'A',
1944 b'addremove',
1944 b'addremove',
1945 None,
1945 None,
1946 _(b'mark new/missing files as added/removed before committing'),
1946 _(b'mark new/missing files as added/removed before committing'),
1947 ),
1947 ),
1948 (b'', b'close-branch', None, _(b'mark a branch head as closed')),
1948 (b'', b'close-branch', None, _(b'mark a branch head as closed')),
1949 (b'', b'amend', None, _(b'amend the parent of the working directory')),
1949 (b'', b'amend', None, _(b'amend the parent of the working directory')),
1950 (b's', b'secret', None, _(b'use the secret phase for committing')),
1950 (b's', b'secret', None, _(b'use the secret phase for committing')),
1951 (b'e', b'edit', None, _(b'invoke editor on commit messages')),
1951 (b'e', b'edit', None, _(b'invoke editor on commit messages')),
1952 (
1952 (
1953 b'',
1953 b'',
1954 b'force-close-branch',
1954 b'force-close-branch',
1955 None,
1955 None,
1956 _(b'forcibly close branch from a non-head changeset (ADVANCED)'),
1956 _(b'forcibly close branch from a non-head changeset (ADVANCED)'),
1957 ),
1957 ),
1958 (b'i', b'interactive', None, _(b'use interactive mode')),
1958 (b'i', b'interactive', None, _(b'use interactive mode')),
1959 ]
1959 ]
1960 + walkopts
1960 + walkopts
1961 + commitopts
1961 + commitopts
1962 + commitopts2
1962 + commitopts2
1963 + subrepoopts,
1963 + subrepoopts,
1964 _(b'[OPTION]... [FILE]...'),
1964 _(b'[OPTION]... [FILE]...'),
1965 helpcategory=command.CATEGORY_COMMITTING,
1965 helpcategory=command.CATEGORY_COMMITTING,
1966 helpbasic=True,
1966 helpbasic=True,
1967 inferrepo=True,
1967 inferrepo=True,
1968 )
1968 )
1969 def commit(ui, repo, *pats, **opts):
1969 def commit(ui, repo, *pats, **opts):
1970 """commit the specified files or all outstanding changes
1970 """commit the specified files or all outstanding changes
1971
1971
1972 Commit changes to the given files into the repository. Unlike a
1972 Commit changes to the given files into the repository. Unlike a
1973 centralized SCM, this operation is a local operation. See
1973 centralized SCM, this operation is a local operation. See
1974 :hg:`push` for a way to actively distribute your changes.
1974 :hg:`push` for a way to actively distribute your changes.
1975
1975
1976 If a list of files is omitted, all changes reported by :hg:`status`
1976 If a list of files is omitted, all changes reported by :hg:`status`
1977 will be committed.
1977 will be committed.
1978
1978
1979 If you are committing the result of a merge, do not provide any
1979 If you are committing the result of a merge, do not provide any
1980 filenames or -I/-X filters.
1980 filenames or -I/-X filters.
1981
1981
1982 If no commit message is specified, Mercurial starts your
1982 If no commit message is specified, Mercurial starts your
1983 configured editor where you can enter a message. In case your
1983 configured editor where you can enter a message. In case your
1984 commit fails, you will find a backup of your message in
1984 commit fails, you will find a backup of your message in
1985 ``.hg/last-message.txt``.
1985 ``.hg/last-message.txt``.
1986
1986
1987 The --close-branch flag can be used to mark the current branch
1987 The --close-branch flag can be used to mark the current branch
1988 head closed. When all heads of a branch are closed, the branch
1988 head closed. When all heads of a branch are closed, the branch
1989 will be considered closed and no longer listed.
1989 will be considered closed and no longer listed.
1990
1990
1991 The --amend flag can be used to amend the parent of the
1991 The --amend flag can be used to amend the parent of the
1992 working directory with a new commit that contains the changes
1992 working directory with a new commit that contains the changes
1993 in the parent in addition to those currently reported by :hg:`status`,
1993 in the parent in addition to those currently reported by :hg:`status`,
1994 if there are any. The old commit is stored in a backup bundle in
1994 if there are any. The old commit is stored in a backup bundle in
1995 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1995 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1996 on how to restore it).
1996 on how to restore it).
1997
1997
1998 Message, user and date are taken from the amended commit unless
1998 Message, user and date are taken from the amended commit unless
1999 specified. When a message isn't specified on the command line,
1999 specified. When a message isn't specified on the command line,
2000 the editor will open with the message of the amended commit.
2000 the editor will open with the message of the amended commit.
2001
2001
2002 It is not possible to amend public changesets (see :hg:`help phases`)
2002 It is not possible to amend public changesets (see :hg:`help phases`)
2003 or changesets that have children.
2003 or changesets that have children.
2004
2004
2005 See :hg:`help dates` for a list of formats valid for -d/--date.
2005 See :hg:`help dates` for a list of formats valid for -d/--date.
2006
2006
2007 Returns 0 on success, 1 if nothing changed.
2007 Returns 0 on success, 1 if nothing changed.
2008
2008
2009 .. container:: verbose
2009 .. container:: verbose
2010
2010
2011 Examples:
2011 Examples:
2012
2012
2013 - commit all files ending in .py::
2013 - commit all files ending in .py::
2014
2014
2015 hg commit --include "set:**.py"
2015 hg commit --include "set:**.py"
2016
2016
2017 - commit all non-binary files::
2017 - commit all non-binary files::
2018
2018
2019 hg commit --exclude "set:binary()"
2019 hg commit --exclude "set:binary()"
2020
2020
2021 - amend the current commit and set the date to now::
2021 - amend the current commit and set the date to now::
2022
2022
2023 hg commit --amend --date now
2023 hg commit --amend --date now
2024 """
2024 """
2025 with repo.wlock(), repo.lock():
2025 with repo.wlock(), repo.lock():
2026 return _docommit(ui, repo, *pats, **opts)
2026 return _docommit(ui, repo, *pats, **opts)
2027
2027
2028
2028
2029 def _docommit(ui, repo, *pats, **opts):
2029 def _docommit(ui, repo, *pats, **opts):
2030 if opts.get('interactive'):
2030 if opts.get('interactive'):
2031 opts.pop('interactive')
2031 opts.pop('interactive')
2032 ret = cmdutil.dorecord(
2032 ret = cmdutil.dorecord(
2033 ui, repo, commit, None, False, cmdutil.recordfilter, *pats, **opts
2033 ui, repo, commit, None, False, cmdutil.recordfilter, *pats, **opts
2034 )
2034 )
2035 # ret can be 0 (no changes to record) or the value returned by
2035 # ret can be 0 (no changes to record) or the value returned by
2036 # commit(), 1 if nothing changed or None on success.
2036 # commit(), 1 if nothing changed or None on success.
2037 return 1 if ret == 0 else ret
2037 return 1 if ret == 0 else ret
2038
2038
2039 opts = pycompat.byteskwargs(opts)
2039 opts = pycompat.byteskwargs(opts)
2040 if opts.get(b'subrepos'):
2040 if opts.get(b'subrepos'):
2041 cmdutil.check_incompatible_arguments(opts, b'subrepos', [b'amend'])
2041 cmdutil.check_incompatible_arguments(opts, b'subrepos', [b'amend'])
2042 # Let --subrepos on the command line override config setting.
2042 # Let --subrepos on the command line override config setting.
2043 ui.setconfig(b'ui', b'commitsubrepos', True, b'commit')
2043 ui.setconfig(b'ui', b'commitsubrepos', True, b'commit')
2044
2044
2045 cmdutil.checkunfinished(repo, commit=True)
2045 cmdutil.checkunfinished(repo, commit=True)
2046
2046
2047 branch = repo[None].branch()
2047 branch = repo[None].branch()
2048 bheads = repo.branchheads(branch)
2048 bheads = repo.branchheads(branch)
2049 tip = repo.changelog.tip()
2049 tip = repo.changelog.tip()
2050
2050
2051 extra = {}
2051 extra = {}
2052 if opts.get(b'close_branch') or opts.get(b'force_close_branch'):
2052 if opts.get(b'close_branch') or opts.get(b'force_close_branch'):
2053 extra[b'close'] = b'1'
2053 extra[b'close'] = b'1'
2054
2054
2055 if repo[b'.'].closesbranch():
2055 if repo[b'.'].closesbranch():
2056 raise error.InputError(
2056 raise error.InputError(
2057 _(b'current revision is already a branch closing head')
2057 _(b'current revision is already a branch closing head')
2058 )
2058 )
2059 elif not bheads:
2059 elif not bheads:
2060 raise error.InputError(
2060 raise error.InputError(
2061 _(b'branch "%s" has no heads to close') % branch
2061 _(b'branch "%s" has no heads to close') % branch
2062 )
2062 )
2063 elif (
2063 elif (
2064 branch == repo[b'.'].branch()
2064 branch == repo[b'.'].branch()
2065 and repo[b'.'].node() not in bheads
2065 and repo[b'.'].node() not in bheads
2066 and not opts.get(b'force_close_branch')
2066 and not opts.get(b'force_close_branch')
2067 ):
2067 ):
2068 hint = _(
2068 hint = _(
2069 b'use --force-close-branch to close branch from a non-head'
2069 b'use --force-close-branch to close branch from a non-head'
2070 b' changeset'
2070 b' changeset'
2071 )
2071 )
2072 raise error.InputError(_(b'can only close branch heads'), hint=hint)
2072 raise error.InputError(_(b'can only close branch heads'), hint=hint)
2073 elif opts.get(b'amend'):
2073 elif opts.get(b'amend'):
2074 if (
2074 if (
2075 repo[b'.'].p1().branch() != branch
2075 repo[b'.'].p1().branch() != branch
2076 and repo[b'.'].p2().branch() != branch
2076 and repo[b'.'].p2().branch() != branch
2077 ):
2077 ):
2078 raise error.InputError(_(b'can only close branch heads'))
2078 raise error.InputError(_(b'can only close branch heads'))
2079
2079
2080 if opts.get(b'amend'):
2080 if opts.get(b'amend'):
2081 if ui.configbool(b'ui', b'commitsubrepos'):
2081 if ui.configbool(b'ui', b'commitsubrepos'):
2082 raise error.InputError(
2082 raise error.InputError(
2083 _(b'cannot amend with ui.commitsubrepos enabled')
2083 _(b'cannot amend with ui.commitsubrepos enabled')
2084 )
2084 )
2085
2085
2086 old = repo[b'.']
2086 old = repo[b'.']
2087 rewriteutil.precheck(repo, [old.rev()], b'amend')
2087 rewriteutil.precheck(repo, [old.rev()], b'amend')
2088
2088
2089 # Currently histedit gets confused if an amend happens while histedit
2089 # Currently histedit gets confused if an amend happens while histedit
2090 # is in progress. Since we have a checkunfinished command, we are
2090 # is in progress. Since we have a checkunfinished command, we are
2091 # temporarily honoring it.
2091 # temporarily honoring it.
2092 #
2092 #
2093 # Note: eventually this guard will be removed. Please do not expect
2093 # Note: eventually this guard will be removed. Please do not expect
2094 # this behavior to remain.
2094 # this behavior to remain.
2095 if not obsolete.isenabled(repo, obsolete.createmarkersopt):
2095 if not obsolete.isenabled(repo, obsolete.createmarkersopt):
2096 cmdutil.checkunfinished(repo)
2096 cmdutil.checkunfinished(repo)
2097
2097
2098 node = cmdutil.amend(ui, repo, old, extra, pats, opts)
2098 node = cmdutil.amend(ui, repo, old, extra, pats, opts)
2099 if node == old.node():
2099 if node == old.node():
2100 ui.status(_(b"nothing changed\n"))
2100 ui.status(_(b"nothing changed\n"))
2101 return 1
2101 return 1
2102 else:
2102 else:
2103
2103
2104 def commitfunc(ui, repo, message, match, opts):
2104 def commitfunc(ui, repo, message, match, opts):
2105 overrides = {}
2105 overrides = {}
2106 if opts.get(b'secret'):
2106 if opts.get(b'secret'):
2107 overrides[(b'phases', b'new-commit')] = b'secret'
2107 overrides[(b'phases', b'new-commit')] = b'secret'
2108
2108
2109 baseui = repo.baseui
2109 baseui = repo.baseui
2110 with baseui.configoverride(overrides, b'commit'):
2110 with baseui.configoverride(overrides, b'commit'):
2111 with ui.configoverride(overrides, b'commit'):
2111 with ui.configoverride(overrides, b'commit'):
2112 editform = cmdutil.mergeeditform(
2112 editform = cmdutil.mergeeditform(
2113 repo[None], b'commit.normal'
2113 repo[None], b'commit.normal'
2114 )
2114 )
2115 editor = cmdutil.getcommiteditor(
2115 editor = cmdutil.getcommiteditor(
2116 editform=editform, **pycompat.strkwargs(opts)
2116 editform=editform, **pycompat.strkwargs(opts)
2117 )
2117 )
2118 return repo.commit(
2118 return repo.commit(
2119 message,
2119 message,
2120 opts.get(b'user'),
2120 opts.get(b'user'),
2121 opts.get(b'date'),
2121 opts.get(b'date'),
2122 match,
2122 match,
2123 editor=editor,
2123 editor=editor,
2124 extra=extra,
2124 extra=extra,
2125 )
2125 )
2126
2126
2127 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
2127 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
2128
2128
2129 if not node:
2129 if not node:
2130 stat = cmdutil.postcommitstatus(repo, pats, opts)
2130 stat = cmdutil.postcommitstatus(repo, pats, opts)
2131 if stat.deleted:
2131 if stat.deleted:
2132 ui.status(
2132 ui.status(
2133 _(
2133 _(
2134 b"nothing changed (%d missing files, see "
2134 b"nothing changed (%d missing files, see "
2135 b"'hg status')\n"
2135 b"'hg status')\n"
2136 )
2136 )
2137 % len(stat.deleted)
2137 % len(stat.deleted)
2138 )
2138 )
2139 else:
2139 else:
2140 ui.status(_(b"nothing changed\n"))
2140 ui.status(_(b"nothing changed\n"))
2141 return 1
2141 return 1
2142
2142
2143 cmdutil.commitstatus(repo, node, branch, bheads, tip, opts)
2143 cmdutil.commitstatus(repo, node, branch, bheads, tip, opts)
2144
2144
2145 if not ui.quiet and ui.configbool(b'commands', b'commit.post-status'):
2145 if not ui.quiet and ui.configbool(b'commands', b'commit.post-status'):
2146 status(
2146 status(
2147 ui,
2147 ui,
2148 repo,
2148 repo,
2149 modified=True,
2149 modified=True,
2150 added=True,
2150 added=True,
2151 removed=True,
2151 removed=True,
2152 deleted=True,
2152 deleted=True,
2153 unknown=True,
2153 unknown=True,
2154 subrepos=opts.get(b'subrepos'),
2154 subrepos=opts.get(b'subrepos'),
2155 )
2155 )
2156
2156
2157
2157
2158 @command(
2158 @command(
2159 b'config|showconfig|debugconfig',
2159 b'config|showconfig|debugconfig',
2160 [
2160 [
2161 (b'u', b'untrusted', None, _(b'show untrusted configuration options')),
2161 (b'u', b'untrusted', None, _(b'show untrusted configuration options')),
2162 (b'e', b'edit', None, _(b'edit user config')),
2162 (b'e', b'edit', None, _(b'edit user config')),
2163 (b'l', b'local', None, _(b'edit repository config')),
2163 (b'l', b'local', None, _(b'edit repository config')),
2164 (
2164 (
2165 b'',
2165 b'',
2166 b'shared',
2166 b'shared',
2167 None,
2167 None,
2168 _(b'edit shared source repository config (EXPERIMENTAL)'),
2168 _(b'edit shared source repository config (EXPERIMENTAL)'),
2169 ),
2169 ),
2170 (b'', b'non-shared', None, _(b'edit non shared config (EXPERIMENTAL)')),
2170 (b'', b'non-shared', None, _(b'edit non shared config (EXPERIMENTAL)')),
2171 (b'g', b'global', None, _(b'edit global config')),
2171 (b'g', b'global', None, _(b'edit global config')),
2172 ]
2172 ]
2173 + formatteropts,
2173 + formatteropts,
2174 _(b'[-u] [NAME]...'),
2174 _(b'[-u] [NAME]...'),
2175 helpcategory=command.CATEGORY_HELP,
2175 helpcategory=command.CATEGORY_HELP,
2176 optionalrepo=True,
2176 optionalrepo=True,
2177 intents={INTENT_READONLY},
2177 intents={INTENT_READONLY},
2178 )
2178 )
2179 def config(ui, repo, *values, **opts):
2179 def config(ui, repo, *values, **opts):
2180 """show combined config settings from all hgrc files
2180 """show combined config settings from all hgrc files
2181
2181
2182 With no arguments, print names and values of all config items.
2182 With no arguments, print names and values of all config items.
2183
2183
2184 With one argument of the form section.name, print just the value
2184 With one argument of the form section.name, print just the value
2185 of that config item.
2185 of that config item.
2186
2186
2187 With multiple arguments, print names and values of all config
2187 With multiple arguments, print names and values of all config
2188 items with matching section names or section.names.
2188 items with matching section names or section.names.
2189
2189
2190 With --edit, start an editor on the user-level config file. With
2190 With --edit, start an editor on the user-level config file. With
2191 --global, edit the system-wide config file. With --local, edit the
2191 --global, edit the system-wide config file. With --local, edit the
2192 repository-level config file.
2192 repository-level config file.
2193
2193
2194 With --debug, the source (filename and line number) is printed
2194 With --debug, the source (filename and line number) is printed
2195 for each config item.
2195 for each config item.
2196
2196
2197 See :hg:`help config` for more information about config files.
2197 See :hg:`help config` for more information about config files.
2198
2198
2199 .. container:: verbose
2199 .. container:: verbose
2200
2200
2201 --non-shared flag is used to edit `.hg/hgrc-not-shared` config file.
2201 --non-shared flag is used to edit `.hg/hgrc-not-shared` config file.
2202 This file is not shared across shares when in share-safe mode.
2202 This file is not shared across shares when in share-safe mode.
2203
2203
2204 Template:
2204 Template:
2205
2205
2206 The following keywords are supported. See also :hg:`help templates`.
2206 The following keywords are supported. See also :hg:`help templates`.
2207
2207
2208 :name: String. Config name.
2208 :name: String. Config name.
2209 :source: String. Filename and line number where the item is defined.
2209 :source: String. Filename and line number where the item is defined.
2210 :value: String. Config value.
2210 :value: String. Config value.
2211
2211
2212 The --shared flag can be used to edit the config file of shared source
2212 The --shared flag can be used to edit the config file of shared source
2213 repository. It only works when you have shared using the experimental
2213 repository. It only works when you have shared using the experimental
2214 share safe feature.
2214 share safe feature.
2215
2215
2216 Returns 0 on success, 1 if NAME does not exist.
2216 Returns 0 on success, 1 if NAME does not exist.
2217
2217
2218 """
2218 """
2219
2219
2220 opts = pycompat.byteskwargs(opts)
2220 opts = pycompat.byteskwargs(opts)
2221 editopts = (b'edit', b'local', b'global', b'shared', b'non_shared')
2221 editopts = (b'edit', b'local', b'global', b'shared', b'non_shared')
2222 if any(opts.get(o) for o in editopts):
2222 if any(opts.get(o) for o in editopts):
2223 cmdutil.check_at_most_one_arg(opts, *editopts[1:])
2223 cmdutil.check_at_most_one_arg(opts, *editopts[1:])
2224 if opts.get(b'local'):
2224 if opts.get(b'local'):
2225 if not repo:
2225 if not repo:
2226 raise error.InputError(
2226 raise error.InputError(
2227 _(b"can't use --local outside a repository")
2227 _(b"can't use --local outside a repository")
2228 )
2228 )
2229 paths = [repo.vfs.join(b'hgrc')]
2229 paths = [repo.vfs.join(b'hgrc')]
2230 elif opts.get(b'global'):
2230 elif opts.get(b'global'):
2231 paths = rcutil.systemrcpath()
2231 paths = rcutil.systemrcpath()
2232 elif opts.get(b'shared'):
2232 elif opts.get(b'shared'):
2233 if not repo.shared():
2233 if not repo.shared():
2234 raise error.InputError(
2234 raise error.InputError(
2235 _(b"repository is not shared; can't use --shared")
2235 _(b"repository is not shared; can't use --shared")
2236 )
2236 )
2237 if requirements.SHARESAFE_REQUIREMENT not in repo.requirements:
2237 if requirements.SHARESAFE_REQUIREMENT not in repo.requirements:
2238 raise error.InputError(
2238 raise error.InputError(
2239 _(
2239 _(
2240 b"share safe feature not enabled; "
2240 b"share safe feature not enabled; "
2241 b"unable to edit shared source repository config"
2241 b"unable to edit shared source repository config"
2242 )
2242 )
2243 )
2243 )
2244 paths = [vfsmod.vfs(repo.sharedpath).join(b'hgrc')]
2244 paths = [vfsmod.vfs(repo.sharedpath).join(b'hgrc')]
2245 elif opts.get(b'non_shared'):
2245 elif opts.get(b'non_shared'):
2246 paths = [repo.vfs.join(b'hgrc-not-shared')]
2246 paths = [repo.vfs.join(b'hgrc-not-shared')]
2247 else:
2247 else:
2248 paths = rcutil.userrcpath()
2248 paths = rcutil.userrcpath()
2249
2249
2250 for f in paths:
2250 for f in paths:
2251 if os.path.exists(f):
2251 if os.path.exists(f):
2252 break
2252 break
2253 else:
2253 else:
2254 if opts.get(b'global'):
2254 if opts.get(b'global'):
2255 samplehgrc = uimod.samplehgrcs[b'global']
2255 samplehgrc = uimod.samplehgrcs[b'global']
2256 elif opts.get(b'local'):
2256 elif opts.get(b'local'):
2257 samplehgrc = uimod.samplehgrcs[b'local']
2257 samplehgrc = uimod.samplehgrcs[b'local']
2258 else:
2258 else:
2259 samplehgrc = uimod.samplehgrcs[b'user']
2259 samplehgrc = uimod.samplehgrcs[b'user']
2260
2260
2261 f = paths[0]
2261 f = paths[0]
2262 fp = open(f, b"wb")
2262 fp = open(f, b"wb")
2263 fp.write(util.tonativeeol(samplehgrc))
2263 fp.write(util.tonativeeol(samplehgrc))
2264 fp.close()
2264 fp.close()
2265
2265
2266 editor = ui.geteditor()
2266 editor = ui.geteditor()
2267 ui.system(
2267 ui.system(
2268 b"%s \"%s\"" % (editor, f),
2268 b"%s \"%s\"" % (editor, f),
2269 onerr=error.InputError,
2269 onerr=error.InputError,
2270 errprefix=_(b"edit failed"),
2270 errprefix=_(b"edit failed"),
2271 blockedtag=b'config_edit',
2271 blockedtag=b'config_edit',
2272 )
2272 )
2273 return
2273 return
2274 ui.pager(b'config')
2274 ui.pager(b'config')
2275 fm = ui.formatter(b'config', opts)
2275 fm = ui.formatter(b'config', opts)
2276 for t, f in rcutil.rccomponents():
2276 for t, f in rcutil.rccomponents():
2277 if t == b'path':
2277 if t == b'path':
2278 ui.debug(b'read config from: %s\n' % f)
2278 ui.debug(b'read config from: %s\n' % f)
2279 elif t == b'resource':
2279 elif t == b'resource':
2280 ui.debug(b'read config from: resource:%s.%s\n' % (f[0], f[1]))
2280 ui.debug(b'read config from: resource:%s.%s\n' % (f[0], f[1]))
2281 elif t == b'items':
2281 elif t == b'items':
2282 # Don't print anything for 'items'.
2282 # Don't print anything for 'items'.
2283 pass
2283 pass
2284 else:
2284 else:
2285 raise error.ProgrammingError(b'unknown rctype: %s' % t)
2285 raise error.ProgrammingError(b'unknown rctype: %s' % t)
2286 untrusted = bool(opts.get(b'untrusted'))
2286 untrusted = bool(opts.get(b'untrusted'))
2287
2287
2288 selsections = selentries = []
2288 selsections = selentries = []
2289 if values:
2289 if values:
2290 selsections = [v for v in values if b'.' not in v]
2290 selsections = [v for v in values if b'.' not in v]
2291 selentries = [v for v in values if b'.' in v]
2291 selentries = [v for v in values if b'.' in v]
2292 uniquesel = len(selentries) == 1 and not selsections
2292 uniquesel = len(selentries) == 1 and not selsections
2293 selsections = set(selsections)
2293 selsections = set(selsections)
2294 selentries = set(selentries)
2294 selentries = set(selentries)
2295
2295
2296 matched = False
2296 matched = False
2297 for section, name, value in ui.walkconfig(untrusted=untrusted):
2297 for section, name, value in ui.walkconfig(untrusted=untrusted):
2298 source = ui.configsource(section, name, untrusted)
2298 source = ui.configsource(section, name, untrusted)
2299 value = pycompat.bytestr(value)
2299 value = pycompat.bytestr(value)
2300 defaultvalue = ui.configdefault(section, name)
2300 defaultvalue = ui.configdefault(section, name)
2301 if fm.isplain():
2301 if fm.isplain():
2302 source = source or b'none'
2302 source = source or b'none'
2303 value = value.replace(b'\n', b'\\n')
2303 value = value.replace(b'\n', b'\\n')
2304 entryname = section + b'.' + name
2304 entryname = section + b'.' + name
2305 if values and not (section in selsections or entryname in selentries):
2305 if values and not (section in selsections or entryname in selentries):
2306 continue
2306 continue
2307 fm.startitem()
2307 fm.startitem()
2308 fm.condwrite(ui.debugflag, b'source', b'%s: ', source)
2308 fm.condwrite(ui.debugflag, b'source', b'%s: ', source)
2309 if uniquesel:
2309 if uniquesel:
2310 fm.data(name=entryname)
2310 fm.data(name=entryname)
2311 fm.write(b'value', b'%s\n', value)
2311 fm.write(b'value', b'%s\n', value)
2312 else:
2312 else:
2313 fm.write(b'name value', b'%s=%s\n', entryname, value)
2313 fm.write(b'name value', b'%s=%s\n', entryname, value)
2314 if formatter.isprintable(defaultvalue):
2314 if formatter.isprintable(defaultvalue):
2315 fm.data(defaultvalue=defaultvalue)
2315 fm.data(defaultvalue=defaultvalue)
2316 elif isinstance(defaultvalue, list) and all(
2316 elif isinstance(defaultvalue, list) and all(
2317 formatter.isprintable(e) for e in defaultvalue
2317 formatter.isprintable(e) for e in defaultvalue
2318 ):
2318 ):
2319 fm.data(defaultvalue=fm.formatlist(defaultvalue, name=b'value'))
2319 fm.data(defaultvalue=fm.formatlist(defaultvalue, name=b'value'))
2320 # TODO: no idea how to process unsupported defaultvalue types
2320 # TODO: no idea how to process unsupported defaultvalue types
2321 matched = True
2321 matched = True
2322 fm.end()
2322 fm.end()
2323 if matched:
2323 if matched:
2324 return 0
2324 return 0
2325 return 1
2325 return 1
2326
2326
2327
2327
2328 @command(
2328 @command(
2329 b'continue',
2329 b'continue',
2330 dryrunopts,
2330 dryrunopts,
2331 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
2331 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
2332 helpbasic=True,
2332 helpbasic=True,
2333 )
2333 )
2334 def continuecmd(ui, repo, **opts):
2334 def continuecmd(ui, repo, **opts):
2335 """resumes an interrupted operation (EXPERIMENTAL)
2335 """resumes an interrupted operation (EXPERIMENTAL)
2336
2336
2337 Finishes a multistep operation like graft, histedit, rebase, merge,
2337 Finishes a multistep operation like graft, histedit, rebase, merge,
2338 and unshelve if they are in an interrupted state.
2338 and unshelve if they are in an interrupted state.
2339
2339
2340 use --dry-run/-n to dry run the command.
2340 use --dry-run/-n to dry run the command.
2341 """
2341 """
2342 dryrun = opts.get('dry_run')
2342 dryrun = opts.get('dry_run')
2343 contstate = cmdutil.getunfinishedstate(repo)
2343 contstate = cmdutil.getunfinishedstate(repo)
2344 if not contstate:
2344 if not contstate:
2345 raise error.StateError(_(b'no operation in progress'))
2345 raise error.StateError(_(b'no operation in progress'))
2346 if not contstate.continuefunc:
2346 if not contstate.continuefunc:
2347 raise error.StateError(
2347 raise error.StateError(
2348 (
2348 (
2349 _(b"%s in progress but does not support 'hg continue'")
2349 _(b"%s in progress but does not support 'hg continue'")
2350 % (contstate._opname)
2350 % (contstate._opname)
2351 ),
2351 ),
2352 hint=contstate.continuemsg(),
2352 hint=contstate.continuemsg(),
2353 )
2353 )
2354 if dryrun:
2354 if dryrun:
2355 ui.status(_(b'%s in progress, will be resumed\n') % (contstate._opname))
2355 ui.status(_(b'%s in progress, will be resumed\n') % (contstate._opname))
2356 return
2356 return
2357 return contstate.continuefunc(ui, repo)
2357 return contstate.continuefunc(ui, repo)
2358
2358
2359
2359
2360 @command(
2360 @command(
2361 b'copy|cp',
2361 b'copy|cp',
2362 [
2362 [
2363 (b'', b'forget', None, _(b'unmark a destination file as copied')),
2363 (b'', b'forget', None, _(b'unmark a destination file as copied')),
2364 (b'A', b'after', None, _(b'record a copy that has already occurred')),
2364 (b'A', b'after', None, _(b'record a copy that has already occurred')),
2365 (
2365 (
2366 b'',
2366 b'',
2367 b'at-rev',
2367 b'at-rev',
2368 b'',
2368 b'',
2369 _(b'(un)mark copies in the given revision (EXPERIMENTAL)'),
2369 _(b'(un)mark copies in the given revision (EXPERIMENTAL)'),
2370 _(b'REV'),
2370 _(b'REV'),
2371 ),
2371 ),
2372 (
2372 (
2373 b'f',
2373 b'f',
2374 b'force',
2374 b'force',
2375 None,
2375 None,
2376 _(b'forcibly copy over an existing managed file'),
2376 _(b'forcibly copy over an existing managed file'),
2377 ),
2377 ),
2378 ]
2378 ]
2379 + walkopts
2379 + walkopts
2380 + dryrunopts,
2380 + dryrunopts,
2381 _(b'[OPTION]... (SOURCE... DEST | --forget DEST...)'),
2381 _(b'[OPTION]... (SOURCE... DEST | --forget DEST...)'),
2382 helpcategory=command.CATEGORY_FILE_CONTENTS,
2382 helpcategory=command.CATEGORY_FILE_CONTENTS,
2383 )
2383 )
2384 def copy(ui, repo, *pats, **opts):
2384 def copy(ui, repo, *pats, **opts):
2385 """mark files as copied for the next commit
2385 """mark files as copied for the next commit
2386
2386
2387 Mark dest as having copies of source files. If dest is a
2387 Mark dest as having copies of source files. If dest is a
2388 directory, copies are put in that directory. If dest is a file,
2388 directory, copies are put in that directory. If dest is a file,
2389 the source must be a single file.
2389 the source must be a single file.
2390
2390
2391 By default, this command copies the contents of files as they
2391 By default, this command copies the contents of files as they
2392 exist in the working directory. If invoked with -A/--after, the
2392 exist in the working directory. If invoked with -A/--after, the
2393 operation is recorded, but no copying is performed.
2393 operation is recorded, but no copying is performed.
2394
2394
2395 To undo marking a destination file as copied, use --forget. With that
2395 To undo marking a destination file as copied, use --forget. With that
2396 option, all given (positional) arguments are unmarked as copies. The
2396 option, all given (positional) arguments are unmarked as copies. The
2397 destination file(s) will be left in place (still tracked).
2397 destination file(s) will be left in place (still tracked).
2398
2398
2399 This command takes effect with the next commit by default.
2399 This command takes effect with the next commit by default.
2400
2400
2401 Returns 0 on success, 1 if errors are encountered.
2401 Returns 0 on success, 1 if errors are encountered.
2402 """
2402 """
2403 opts = pycompat.byteskwargs(opts)
2403 opts = pycompat.byteskwargs(opts)
2404 with repo.wlock():
2404 with repo.wlock():
2405 return cmdutil.copy(ui, repo, pats, opts)
2405 return cmdutil.copy(ui, repo, pats, opts)
2406
2406
2407
2407
2408 @command(
2408 @command(
2409 b'debugcommands',
2409 b'debugcommands',
2410 [],
2410 [],
2411 _(b'[COMMAND]'),
2411 _(b'[COMMAND]'),
2412 helpcategory=command.CATEGORY_HELP,
2412 helpcategory=command.CATEGORY_HELP,
2413 norepo=True,
2413 norepo=True,
2414 )
2414 )
2415 def debugcommands(ui, cmd=b'', *args):
2415 def debugcommands(ui, cmd=b'', *args):
2416 """list all available commands and options"""
2416 """list all available commands and options"""
2417 for cmd, vals in sorted(pycompat.iteritems(table)):
2417 for cmd, vals in sorted(pycompat.iteritems(table)):
2418 cmd = cmd.split(b'|')[0]
2418 cmd = cmd.split(b'|')[0]
2419 opts = b', '.join([i[1] for i in vals[1]])
2419 opts = b', '.join([i[1] for i in vals[1]])
2420 ui.write(b'%s: %s\n' % (cmd, opts))
2420 ui.write(b'%s: %s\n' % (cmd, opts))
2421
2421
2422
2422
2423 @command(
2423 @command(
2424 b'debugcomplete',
2424 b'debugcomplete',
2425 [(b'o', b'options', None, _(b'show the command options'))],
2425 [(b'o', b'options', None, _(b'show the command options'))],
2426 _(b'[-o] CMD'),
2426 _(b'[-o] CMD'),
2427 helpcategory=command.CATEGORY_HELP,
2427 helpcategory=command.CATEGORY_HELP,
2428 norepo=True,
2428 norepo=True,
2429 )
2429 )
2430 def debugcomplete(ui, cmd=b'', **opts):
2430 def debugcomplete(ui, cmd=b'', **opts):
2431 """returns the completion list associated with the given command"""
2431 """returns the completion list associated with the given command"""
2432
2432
2433 if opts.get('options'):
2433 if opts.get('options'):
2434 options = []
2434 options = []
2435 otables = [globalopts]
2435 otables = [globalopts]
2436 if cmd:
2436 if cmd:
2437 aliases, entry = cmdutil.findcmd(cmd, table, False)
2437 aliases, entry = cmdutil.findcmd(cmd, table, False)
2438 otables.append(entry[1])
2438 otables.append(entry[1])
2439 for t in otables:
2439 for t in otables:
2440 for o in t:
2440 for o in t:
2441 if b"(DEPRECATED)" in o[3]:
2441 if b"(DEPRECATED)" in o[3]:
2442 continue
2442 continue
2443 if o[0]:
2443 if o[0]:
2444 options.append(b'-%s' % o[0])
2444 options.append(b'-%s' % o[0])
2445 options.append(b'--%s' % o[1])
2445 options.append(b'--%s' % o[1])
2446 ui.write(b"%s\n" % b"\n".join(options))
2446 ui.write(b"%s\n" % b"\n".join(options))
2447 return
2447 return
2448
2448
2449 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
2449 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
2450 if ui.verbose:
2450 if ui.verbose:
2451 cmdlist = [b' '.join(c[0]) for c in cmdlist.values()]
2451 cmdlist = [b' '.join(c[0]) for c in cmdlist.values()]
2452 ui.write(b"%s\n" % b"\n".join(sorted(cmdlist)))
2452 ui.write(b"%s\n" % b"\n".join(sorted(cmdlist)))
2453
2453
2454
2454
2455 @command(
2455 @command(
2456 b'diff',
2456 b'diff',
2457 [
2457 [
2458 (b'r', b'rev', [], _(b'revision'), _(b'REV')),
2458 (b'r', b'rev', [], _(b'revision'), _(b'REV')),
2459 (b'', b'from', b'', _(b'revision to diff from'), _(b'REV')),
2460 (b'', b'to', b'', _(b'revision to diff to'), _(b'REV')),
2459 (b'c', b'change', b'', _(b'change made by revision'), _(b'REV')),
2461 (b'c', b'change', b'', _(b'change made by revision'), _(b'REV')),
2460 ]
2462 ]
2461 + diffopts
2463 + diffopts
2462 + diffopts2
2464 + diffopts2
2463 + walkopts
2465 + walkopts
2464 + subrepoopts,
2466 + subrepoopts,
2465 _(b'[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
2467 _(b'[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
2466 helpcategory=command.CATEGORY_FILE_CONTENTS,
2468 helpcategory=command.CATEGORY_FILE_CONTENTS,
2467 helpbasic=True,
2469 helpbasic=True,
2468 inferrepo=True,
2470 inferrepo=True,
2469 intents={INTENT_READONLY},
2471 intents={INTENT_READONLY},
2470 )
2472 )
2471 def diff(ui, repo, *pats, **opts):
2473 def diff(ui, repo, *pats, **opts):
2472 """diff repository (or selected files)
2474 """diff repository (or selected files)
2473
2475
2474 Show differences between revisions for the specified files.
2476 Show differences between revisions for the specified files.
2475
2477
2476 Differences between files are shown using the unified diff format.
2478 Differences between files are shown using the unified diff format.
2477
2479
2478 .. note::
2480 .. note::
2479
2481
2480 :hg:`diff` may generate unexpected results for merges, as it will
2482 :hg:`diff` may generate unexpected results for merges, as it will
2481 default to comparing against the working directory's first
2483 default to comparing against the working directory's first
2482 parent changeset if no revisions are specified.
2484 parent changeset if no revisions are specified.
2483
2485
2484 When two revision arguments are given, then changes are shown
2486 When two revision arguments are given, then changes are shown
2485 between those revisions. If only one revision is specified then
2487 between those revisions. If only one revision is specified then
2486 that revision is compared to the working directory, and, when no
2488 that revision is compared to the working directory, and, when no
2487 revisions are specified, the working directory files are compared
2489 revisions are specified, the working directory files are compared
2488 to its first parent.
2490 to its first parent.
2489
2491
2490 Alternatively you can specify -c/--change with a revision to see
2492 Alternatively you can specify -c/--change with a revision to see
2491 the changes in that changeset relative to its first parent.
2493 the changes in that changeset relative to its first parent.
2492
2494
2493 Without the -a/--text option, diff will avoid generating diffs of
2495 Without the -a/--text option, diff will avoid generating diffs of
2494 files it detects as binary. With -a, diff will generate a diff
2496 files it detects as binary. With -a, diff will generate a diff
2495 anyway, probably with undesirable results.
2497 anyway, probably with undesirable results.
2496
2498
2497 Use the -g/--git option to generate diffs in the git extended diff
2499 Use the -g/--git option to generate diffs in the git extended diff
2498 format. For more information, read :hg:`help diffs`.
2500 format. For more information, read :hg:`help diffs`.
2499
2501
2500 .. container:: verbose
2502 .. container:: verbose
2501
2503
2502 Examples:
2504 Examples:
2503
2505
2504 - compare a file in the current working directory to its parent::
2506 - compare a file in the current working directory to its parent::
2505
2507
2506 hg diff foo.c
2508 hg diff foo.c
2507
2509
2508 - compare two historical versions of a directory, with rename info::
2510 - compare two historical versions of a directory, with rename info::
2509
2511
2510 hg diff --git -r 1.0:1.2 lib/
2512 hg diff --git -r 1.0:1.2 lib/
2511
2513
2512 - get change stats relative to the last change on some date::
2514 - get change stats relative to the last change on some date::
2513
2515
2514 hg diff --stat -r "date('may 2')"
2516 hg diff --stat -r "date('may 2')"
2515
2517
2516 - diff all newly-added files that contain a keyword::
2518 - diff all newly-added files that contain a keyword::
2517
2519
2518 hg diff "set:added() and grep(GNU)"
2520 hg diff "set:added() and grep(GNU)"
2519
2521
2520 - compare a revision and its parents::
2522 - compare a revision and its parents::
2521
2523
2522 hg diff -c 9353 # compare against first parent
2524 hg diff -c 9353 # compare against first parent
2523 hg diff -r 9353^:9353 # same using revset syntax
2525 hg diff -r 9353^:9353 # same using revset syntax
2524 hg diff -r 9353^2:9353 # compare against the second parent
2526 hg diff -r 9353^2:9353 # compare against the second parent
2525
2527
2526 Returns 0 on success.
2528 Returns 0 on success.
2527 """
2529 """
2528
2530
2529 cmdutil.check_at_most_one_arg(opts, 'rev', 'change')
2531 cmdutil.check_at_most_one_arg(opts, 'rev', 'change')
2530 opts = pycompat.byteskwargs(opts)
2532 opts = pycompat.byteskwargs(opts)
2531 revs = opts.get(b'rev')
2533 revs = opts.get(b'rev')
2532 change = opts.get(b'change')
2534 change = opts.get(b'change')
2535 from_rev = opts.get(b'from')
2536 to_rev = opts.get(b'to')
2533 stat = opts.get(b'stat')
2537 stat = opts.get(b'stat')
2534 reverse = opts.get(b'reverse')
2538 reverse = opts.get(b'reverse')
2535
2539
2540 cmdutil.check_incompatible_arguments(opts, b'from', [b'rev', b'change'])
2541 cmdutil.check_incompatible_arguments(opts, b'to', [b'rev', b'change'])
2536 if change:
2542 if change:
2537 repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
2543 repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
2538 ctx2 = scmutil.revsingle(repo, change, None)
2544 ctx2 = scmutil.revsingle(repo, change, None)
2539 ctx1 = ctx2.p1()
2545 ctx1 = ctx2.p1()
2546 elif from_rev or to_rev:
2547 repo = scmutil.unhidehashlikerevs(
2548 repo, [from_rev] + [to_rev], b'nowarn'
2549 )
2550 ctx1 = scmutil.revsingle(repo, from_rev, None)
2551 ctx2 = scmutil.revsingle(repo, to_rev, None)
2540 else:
2552 else:
2541 repo = scmutil.unhidehashlikerevs(repo, revs, b'nowarn')
2553 repo = scmutil.unhidehashlikerevs(repo, revs, b'nowarn')
2542 ctx1, ctx2 = scmutil.revpair(repo, revs)
2554 ctx1, ctx2 = scmutil.revpair(repo, revs)
2543
2555
2544 if reverse:
2556 if reverse:
2545 ctxleft = ctx2
2557 ctxleft = ctx2
2546 ctxright = ctx1
2558 ctxright = ctx1
2547 else:
2559 else:
2548 ctxleft = ctx1
2560 ctxleft = ctx1
2549 ctxright = ctx2
2561 ctxright = ctx2
2550
2562
2551 diffopts = patch.diffallopts(ui, opts)
2563 diffopts = patch.diffallopts(ui, opts)
2552 m = scmutil.match(ctx2, pats, opts)
2564 m = scmutil.match(ctx2, pats, opts)
2553 m = repo.narrowmatch(m)
2565 m = repo.narrowmatch(m)
2554 ui.pager(b'diff')
2566 ui.pager(b'diff')
2555 logcmdutil.diffordiffstat(
2567 logcmdutil.diffordiffstat(
2556 ui,
2568 ui,
2557 repo,
2569 repo,
2558 diffopts,
2570 diffopts,
2559 ctxleft,
2571 ctxleft,
2560 ctxright,
2572 ctxright,
2561 m,
2573 m,
2562 stat=stat,
2574 stat=stat,
2563 listsubrepos=opts.get(b'subrepos'),
2575 listsubrepos=opts.get(b'subrepos'),
2564 root=opts.get(b'root'),
2576 root=opts.get(b'root'),
2565 )
2577 )
2566
2578
2567
2579
2568 @command(
2580 @command(
2569 b'export',
2581 b'export',
2570 [
2582 [
2571 (
2583 (
2572 b'B',
2584 b'B',
2573 b'bookmark',
2585 b'bookmark',
2574 b'',
2586 b'',
2575 _(b'export changes only reachable by given bookmark'),
2587 _(b'export changes only reachable by given bookmark'),
2576 _(b'BOOKMARK'),
2588 _(b'BOOKMARK'),
2577 ),
2589 ),
2578 (
2590 (
2579 b'o',
2591 b'o',
2580 b'output',
2592 b'output',
2581 b'',
2593 b'',
2582 _(b'print output to file with formatted name'),
2594 _(b'print output to file with formatted name'),
2583 _(b'FORMAT'),
2595 _(b'FORMAT'),
2584 ),
2596 ),
2585 (b'', b'switch-parent', None, _(b'diff against the second parent')),
2597 (b'', b'switch-parent', None, _(b'diff against the second parent')),
2586 (b'r', b'rev', [], _(b'revisions to export'), _(b'REV')),
2598 (b'r', b'rev', [], _(b'revisions to export'), _(b'REV')),
2587 ]
2599 ]
2588 + diffopts
2600 + diffopts
2589 + formatteropts,
2601 + formatteropts,
2590 _(b'[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'),
2602 _(b'[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'),
2591 helpcategory=command.CATEGORY_IMPORT_EXPORT,
2603 helpcategory=command.CATEGORY_IMPORT_EXPORT,
2592 helpbasic=True,
2604 helpbasic=True,
2593 intents={INTENT_READONLY},
2605 intents={INTENT_READONLY},
2594 )
2606 )
2595 def export(ui, repo, *changesets, **opts):
2607 def export(ui, repo, *changesets, **opts):
2596 """dump the header and diffs for one or more changesets
2608 """dump the header and diffs for one or more changesets
2597
2609
2598 Print the changeset header and diffs for one or more revisions.
2610 Print the changeset header and diffs for one or more revisions.
2599 If no revision is given, the parent of the working directory is used.
2611 If no revision is given, the parent of the working directory is used.
2600
2612
2601 The information shown in the changeset header is: author, date,
2613 The information shown in the changeset header is: author, date,
2602 branch name (if non-default), changeset hash, parent(s) and commit
2614 branch name (if non-default), changeset hash, parent(s) and commit
2603 comment.
2615 comment.
2604
2616
2605 .. note::
2617 .. note::
2606
2618
2607 :hg:`export` may generate unexpected diff output for merge
2619 :hg:`export` may generate unexpected diff output for merge
2608 changesets, as it will compare the merge changeset against its
2620 changesets, as it will compare the merge changeset against its
2609 first parent only.
2621 first parent only.
2610
2622
2611 Output may be to a file, in which case the name of the file is
2623 Output may be to a file, in which case the name of the file is
2612 given using a template string. See :hg:`help templates`. In addition
2624 given using a template string. See :hg:`help templates`. In addition
2613 to the common template keywords, the following formatting rules are
2625 to the common template keywords, the following formatting rules are
2614 supported:
2626 supported:
2615
2627
2616 :``%%``: literal "%" character
2628 :``%%``: literal "%" character
2617 :``%H``: changeset hash (40 hexadecimal digits)
2629 :``%H``: changeset hash (40 hexadecimal digits)
2618 :``%N``: number of patches being generated
2630 :``%N``: number of patches being generated
2619 :``%R``: changeset revision number
2631 :``%R``: changeset revision number
2620 :``%b``: basename of the exporting repository
2632 :``%b``: basename of the exporting repository
2621 :``%h``: short-form changeset hash (12 hexadecimal digits)
2633 :``%h``: short-form changeset hash (12 hexadecimal digits)
2622 :``%m``: first line of the commit message (only alphanumeric characters)
2634 :``%m``: first line of the commit message (only alphanumeric characters)
2623 :``%n``: zero-padded sequence number, starting at 1
2635 :``%n``: zero-padded sequence number, starting at 1
2624 :``%r``: zero-padded changeset revision number
2636 :``%r``: zero-padded changeset revision number
2625 :``\\``: literal "\\" character
2637 :``\\``: literal "\\" character
2626
2638
2627 Without the -a/--text option, export will avoid generating diffs
2639 Without the -a/--text option, export will avoid generating diffs
2628 of files it detects as binary. With -a, export will generate a
2640 of files it detects as binary. With -a, export will generate a
2629 diff anyway, probably with undesirable results.
2641 diff anyway, probably with undesirable results.
2630
2642
2631 With -B/--bookmark changesets reachable by the given bookmark are
2643 With -B/--bookmark changesets reachable by the given bookmark are
2632 selected.
2644 selected.
2633
2645
2634 Use the -g/--git option to generate diffs in the git extended diff
2646 Use the -g/--git option to generate diffs in the git extended diff
2635 format. See :hg:`help diffs` for more information.
2647 format. See :hg:`help diffs` for more information.
2636
2648
2637 With the --switch-parent option, the diff will be against the
2649 With the --switch-parent option, the diff will be against the
2638 second parent. It can be useful to review a merge.
2650 second parent. It can be useful to review a merge.
2639
2651
2640 .. container:: verbose
2652 .. container:: verbose
2641
2653
2642 Template:
2654 Template:
2643
2655
2644 The following keywords are supported in addition to the common template
2656 The following keywords are supported in addition to the common template
2645 keywords and functions. See also :hg:`help templates`.
2657 keywords and functions. See also :hg:`help templates`.
2646
2658
2647 :diff: String. Diff content.
2659 :diff: String. Diff content.
2648 :parents: List of strings. Parent nodes of the changeset.
2660 :parents: List of strings. Parent nodes of the changeset.
2649
2661
2650 Examples:
2662 Examples:
2651
2663
2652 - use export and import to transplant a bugfix to the current
2664 - use export and import to transplant a bugfix to the current
2653 branch::
2665 branch::
2654
2666
2655 hg export -r 9353 | hg import -
2667 hg export -r 9353 | hg import -
2656
2668
2657 - export all the changesets between two revisions to a file with
2669 - export all the changesets between two revisions to a file with
2658 rename information::
2670 rename information::
2659
2671
2660 hg export --git -r 123:150 > changes.txt
2672 hg export --git -r 123:150 > changes.txt
2661
2673
2662 - split outgoing changes into a series of patches with
2674 - split outgoing changes into a series of patches with
2663 descriptive names::
2675 descriptive names::
2664
2676
2665 hg export -r "outgoing()" -o "%n-%m.patch"
2677 hg export -r "outgoing()" -o "%n-%m.patch"
2666
2678
2667 Returns 0 on success.
2679 Returns 0 on success.
2668 """
2680 """
2669 opts = pycompat.byteskwargs(opts)
2681 opts = pycompat.byteskwargs(opts)
2670 bookmark = opts.get(b'bookmark')
2682 bookmark = opts.get(b'bookmark')
2671 changesets += tuple(opts.get(b'rev', []))
2683 changesets += tuple(opts.get(b'rev', []))
2672
2684
2673 cmdutil.check_at_most_one_arg(opts, b'rev', b'bookmark')
2685 cmdutil.check_at_most_one_arg(opts, b'rev', b'bookmark')
2674
2686
2675 if bookmark:
2687 if bookmark:
2676 if bookmark not in repo._bookmarks:
2688 if bookmark not in repo._bookmarks:
2677 raise error.InputError(_(b"bookmark '%s' not found") % bookmark)
2689 raise error.InputError(_(b"bookmark '%s' not found") % bookmark)
2678
2690
2679 revs = scmutil.bookmarkrevs(repo, bookmark)
2691 revs = scmutil.bookmarkrevs(repo, bookmark)
2680 else:
2692 else:
2681 if not changesets:
2693 if not changesets:
2682 changesets = [b'.']
2694 changesets = [b'.']
2683
2695
2684 repo = scmutil.unhidehashlikerevs(repo, changesets, b'nowarn')
2696 repo = scmutil.unhidehashlikerevs(repo, changesets, b'nowarn')
2685 revs = scmutil.revrange(repo, changesets)
2697 revs = scmutil.revrange(repo, changesets)
2686
2698
2687 if not revs:
2699 if not revs:
2688 raise error.InputError(_(b"export requires at least one changeset"))
2700 raise error.InputError(_(b"export requires at least one changeset"))
2689 if len(revs) > 1:
2701 if len(revs) > 1:
2690 ui.note(_(b'exporting patches:\n'))
2702 ui.note(_(b'exporting patches:\n'))
2691 else:
2703 else:
2692 ui.note(_(b'exporting patch:\n'))
2704 ui.note(_(b'exporting patch:\n'))
2693
2705
2694 fntemplate = opts.get(b'output')
2706 fntemplate = opts.get(b'output')
2695 if cmdutil.isstdiofilename(fntemplate):
2707 if cmdutil.isstdiofilename(fntemplate):
2696 fntemplate = b''
2708 fntemplate = b''
2697
2709
2698 if fntemplate:
2710 if fntemplate:
2699 fm = formatter.nullformatter(ui, b'export', opts)
2711 fm = formatter.nullformatter(ui, b'export', opts)
2700 else:
2712 else:
2701 ui.pager(b'export')
2713 ui.pager(b'export')
2702 fm = ui.formatter(b'export', opts)
2714 fm = ui.formatter(b'export', opts)
2703 with fm:
2715 with fm:
2704 cmdutil.export(
2716 cmdutil.export(
2705 repo,
2717 repo,
2706 revs,
2718 revs,
2707 fm,
2719 fm,
2708 fntemplate=fntemplate,
2720 fntemplate=fntemplate,
2709 switch_parent=opts.get(b'switch_parent'),
2721 switch_parent=opts.get(b'switch_parent'),
2710 opts=patch.diffallopts(ui, opts),
2722 opts=patch.diffallopts(ui, opts),
2711 )
2723 )
2712
2724
2713
2725
2714 @command(
2726 @command(
2715 b'files',
2727 b'files',
2716 [
2728 [
2717 (
2729 (
2718 b'r',
2730 b'r',
2719 b'rev',
2731 b'rev',
2720 b'',
2732 b'',
2721 _(b'search the repository as it is in REV'),
2733 _(b'search the repository as it is in REV'),
2722 _(b'REV'),
2734 _(b'REV'),
2723 ),
2735 ),
2724 (
2736 (
2725 b'0',
2737 b'0',
2726 b'print0',
2738 b'print0',
2727 None,
2739 None,
2728 _(b'end filenames with NUL, for use with xargs'),
2740 _(b'end filenames with NUL, for use with xargs'),
2729 ),
2741 ),
2730 ]
2742 ]
2731 + walkopts
2743 + walkopts
2732 + formatteropts
2744 + formatteropts
2733 + subrepoopts,
2745 + subrepoopts,
2734 _(b'[OPTION]... [FILE]...'),
2746 _(b'[OPTION]... [FILE]...'),
2735 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
2747 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
2736 intents={INTENT_READONLY},
2748 intents={INTENT_READONLY},
2737 )
2749 )
2738 def files(ui, repo, *pats, **opts):
2750 def files(ui, repo, *pats, **opts):
2739 """list tracked files
2751 """list tracked files
2740
2752
2741 Print files under Mercurial control in the working directory or
2753 Print files under Mercurial control in the working directory or
2742 specified revision for given files (excluding removed files).
2754 specified revision for given files (excluding removed files).
2743 Files can be specified as filenames or filesets.
2755 Files can be specified as filenames or filesets.
2744
2756
2745 If no files are given to match, this command prints the names
2757 If no files are given to match, this command prints the names
2746 of all files under Mercurial control.
2758 of all files under Mercurial control.
2747
2759
2748 .. container:: verbose
2760 .. container:: verbose
2749
2761
2750 Template:
2762 Template:
2751
2763
2752 The following keywords are supported in addition to the common template
2764 The following keywords are supported in addition to the common template
2753 keywords and functions. See also :hg:`help templates`.
2765 keywords and functions. See also :hg:`help templates`.
2754
2766
2755 :flags: String. Character denoting file's symlink and executable bits.
2767 :flags: String. Character denoting file's symlink and executable bits.
2756 :path: String. Repository-absolute path of the file.
2768 :path: String. Repository-absolute path of the file.
2757 :size: Integer. Size of the file in bytes.
2769 :size: Integer. Size of the file in bytes.
2758
2770
2759 Examples:
2771 Examples:
2760
2772
2761 - list all files under the current directory::
2773 - list all files under the current directory::
2762
2774
2763 hg files .
2775 hg files .
2764
2776
2765 - shows sizes and flags for current revision::
2777 - shows sizes and flags for current revision::
2766
2778
2767 hg files -vr .
2779 hg files -vr .
2768
2780
2769 - list all files named README::
2781 - list all files named README::
2770
2782
2771 hg files -I "**/README"
2783 hg files -I "**/README"
2772
2784
2773 - list all binary files::
2785 - list all binary files::
2774
2786
2775 hg files "set:binary()"
2787 hg files "set:binary()"
2776
2788
2777 - find files containing a regular expression::
2789 - find files containing a regular expression::
2778
2790
2779 hg files "set:grep('bob')"
2791 hg files "set:grep('bob')"
2780
2792
2781 - search tracked file contents with xargs and grep::
2793 - search tracked file contents with xargs and grep::
2782
2794
2783 hg files -0 | xargs -0 grep foo
2795 hg files -0 | xargs -0 grep foo
2784
2796
2785 See :hg:`help patterns` and :hg:`help filesets` for more information
2797 See :hg:`help patterns` and :hg:`help filesets` for more information
2786 on specifying file patterns.
2798 on specifying file patterns.
2787
2799
2788 Returns 0 if a match is found, 1 otherwise.
2800 Returns 0 if a match is found, 1 otherwise.
2789
2801
2790 """
2802 """
2791
2803
2792 opts = pycompat.byteskwargs(opts)
2804 opts = pycompat.byteskwargs(opts)
2793 rev = opts.get(b'rev')
2805 rev = opts.get(b'rev')
2794 if rev:
2806 if rev:
2795 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
2807 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
2796 ctx = scmutil.revsingle(repo, rev, None)
2808 ctx = scmutil.revsingle(repo, rev, None)
2797
2809
2798 end = b'\n'
2810 end = b'\n'
2799 if opts.get(b'print0'):
2811 if opts.get(b'print0'):
2800 end = b'\0'
2812 end = b'\0'
2801 fmt = b'%s' + end
2813 fmt = b'%s' + end
2802
2814
2803 m = scmutil.match(ctx, pats, opts)
2815 m = scmutil.match(ctx, pats, opts)
2804 ui.pager(b'files')
2816 ui.pager(b'files')
2805 uipathfn = scmutil.getuipathfn(ctx.repo(), legacyrelativevalue=True)
2817 uipathfn = scmutil.getuipathfn(ctx.repo(), legacyrelativevalue=True)
2806 with ui.formatter(b'files', opts) as fm:
2818 with ui.formatter(b'files', opts) as fm:
2807 return cmdutil.files(
2819 return cmdutil.files(
2808 ui, ctx, m, uipathfn, fm, fmt, opts.get(b'subrepos')
2820 ui, ctx, m, uipathfn, fm, fmt, opts.get(b'subrepos')
2809 )
2821 )
2810
2822
2811
2823
2812 @command(
2824 @command(
2813 b'forget',
2825 b'forget',
2814 [
2826 [
2815 (b'i', b'interactive', None, _(b'use interactive mode')),
2827 (b'i', b'interactive', None, _(b'use interactive mode')),
2816 ]
2828 ]
2817 + walkopts
2829 + walkopts
2818 + dryrunopts,
2830 + dryrunopts,
2819 _(b'[OPTION]... FILE...'),
2831 _(b'[OPTION]... FILE...'),
2820 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
2832 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
2821 helpbasic=True,
2833 helpbasic=True,
2822 inferrepo=True,
2834 inferrepo=True,
2823 )
2835 )
2824 def forget(ui, repo, *pats, **opts):
2836 def forget(ui, repo, *pats, **opts):
2825 """forget the specified files on the next commit
2837 """forget the specified files on the next commit
2826
2838
2827 Mark the specified files so they will no longer be tracked
2839 Mark the specified files so they will no longer be tracked
2828 after the next commit.
2840 after the next commit.
2829
2841
2830 This only removes files from the current branch, not from the
2842 This only removes files from the current branch, not from the
2831 entire project history, and it does not delete them from the
2843 entire project history, and it does not delete them from the
2832 working directory.
2844 working directory.
2833
2845
2834 To delete the file from the working directory, see :hg:`remove`.
2846 To delete the file from the working directory, see :hg:`remove`.
2835
2847
2836 To undo a forget before the next commit, see :hg:`add`.
2848 To undo a forget before the next commit, see :hg:`add`.
2837
2849
2838 .. container:: verbose
2850 .. container:: verbose
2839
2851
2840 Examples:
2852 Examples:
2841
2853
2842 - forget newly-added binary files::
2854 - forget newly-added binary files::
2843
2855
2844 hg forget "set:added() and binary()"
2856 hg forget "set:added() and binary()"
2845
2857
2846 - forget files that would be excluded by .hgignore::
2858 - forget files that would be excluded by .hgignore::
2847
2859
2848 hg forget "set:hgignore()"
2860 hg forget "set:hgignore()"
2849
2861
2850 Returns 0 on success.
2862 Returns 0 on success.
2851 """
2863 """
2852
2864
2853 opts = pycompat.byteskwargs(opts)
2865 opts = pycompat.byteskwargs(opts)
2854 if not pats:
2866 if not pats:
2855 raise error.InputError(_(b'no files specified'))
2867 raise error.InputError(_(b'no files specified'))
2856
2868
2857 m = scmutil.match(repo[None], pats, opts)
2869 m = scmutil.match(repo[None], pats, opts)
2858 dryrun, interactive = opts.get(b'dry_run'), opts.get(b'interactive')
2870 dryrun, interactive = opts.get(b'dry_run'), opts.get(b'interactive')
2859 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
2871 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
2860 rejected = cmdutil.forget(
2872 rejected = cmdutil.forget(
2861 ui,
2873 ui,
2862 repo,
2874 repo,
2863 m,
2875 m,
2864 prefix=b"",
2876 prefix=b"",
2865 uipathfn=uipathfn,
2877 uipathfn=uipathfn,
2866 explicitonly=False,
2878 explicitonly=False,
2867 dryrun=dryrun,
2879 dryrun=dryrun,
2868 interactive=interactive,
2880 interactive=interactive,
2869 )[0]
2881 )[0]
2870 return rejected and 1 or 0
2882 return rejected and 1 or 0
2871
2883
2872
2884
2873 @command(
2885 @command(
2874 b'graft',
2886 b'graft',
2875 [
2887 [
2876 (b'r', b'rev', [], _(b'revisions to graft'), _(b'REV')),
2888 (b'r', b'rev', [], _(b'revisions to graft'), _(b'REV')),
2877 (
2889 (
2878 b'',
2890 b'',
2879 b'base',
2891 b'base',
2880 b'',
2892 b'',
2881 _(b'base revision when doing the graft merge (ADVANCED)'),
2893 _(b'base revision when doing the graft merge (ADVANCED)'),
2882 _(b'REV'),
2894 _(b'REV'),
2883 ),
2895 ),
2884 (b'c', b'continue', False, _(b'resume interrupted graft')),
2896 (b'c', b'continue', False, _(b'resume interrupted graft')),
2885 (b'', b'stop', False, _(b'stop interrupted graft')),
2897 (b'', b'stop', False, _(b'stop interrupted graft')),
2886 (b'', b'abort', False, _(b'abort interrupted graft')),
2898 (b'', b'abort', False, _(b'abort interrupted graft')),
2887 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
2899 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
2888 (b'', b'log', None, _(b'append graft info to log message')),
2900 (b'', b'log', None, _(b'append graft info to log message')),
2889 (
2901 (
2890 b'',
2902 b'',
2891 b'no-commit',
2903 b'no-commit',
2892 None,
2904 None,
2893 _(b"don't commit, just apply the changes in working directory"),
2905 _(b"don't commit, just apply the changes in working directory"),
2894 ),
2906 ),
2895 (b'f', b'force', False, _(b'force graft')),
2907 (b'f', b'force', False, _(b'force graft')),
2896 (
2908 (
2897 b'D',
2909 b'D',
2898 b'currentdate',
2910 b'currentdate',
2899 False,
2911 False,
2900 _(b'record the current date as commit date'),
2912 _(b'record the current date as commit date'),
2901 ),
2913 ),
2902 (
2914 (
2903 b'U',
2915 b'U',
2904 b'currentuser',
2916 b'currentuser',
2905 False,
2917 False,
2906 _(b'record the current user as committer'),
2918 _(b'record the current user as committer'),
2907 ),
2919 ),
2908 ]
2920 ]
2909 + commitopts2
2921 + commitopts2
2910 + mergetoolopts
2922 + mergetoolopts
2911 + dryrunopts,
2923 + dryrunopts,
2912 _(b'[OPTION]... [-r REV]... REV...'),
2924 _(b'[OPTION]... [-r REV]... REV...'),
2913 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
2925 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
2914 )
2926 )
2915 def graft(ui, repo, *revs, **opts):
2927 def graft(ui, repo, *revs, **opts):
2916 """copy changes from other branches onto the current branch
2928 """copy changes from other branches onto the current branch
2917
2929
2918 This command uses Mercurial's merge logic to copy individual
2930 This command uses Mercurial's merge logic to copy individual
2919 changes from other branches without merging branches in the
2931 changes from other branches without merging branches in the
2920 history graph. This is sometimes known as 'backporting' or
2932 history graph. This is sometimes known as 'backporting' or
2921 'cherry-picking'. By default, graft will copy user, date, and
2933 'cherry-picking'. By default, graft will copy user, date, and
2922 description from the source changesets.
2934 description from the source changesets.
2923
2935
2924 Changesets that are ancestors of the current revision, that have
2936 Changesets that are ancestors of the current revision, that have
2925 already been grafted, or that are merges will be skipped.
2937 already been grafted, or that are merges will be skipped.
2926
2938
2927 If --log is specified, log messages will have a comment appended
2939 If --log is specified, log messages will have a comment appended
2928 of the form::
2940 of the form::
2929
2941
2930 (grafted from CHANGESETHASH)
2942 (grafted from CHANGESETHASH)
2931
2943
2932 If --force is specified, revisions will be grafted even if they
2944 If --force is specified, revisions will be grafted even if they
2933 are already ancestors of, or have been grafted to, the destination.
2945 are already ancestors of, or have been grafted to, the destination.
2934 This is useful when the revisions have since been backed out.
2946 This is useful when the revisions have since been backed out.
2935
2947
2936 If a graft merge results in conflicts, the graft process is
2948 If a graft merge results in conflicts, the graft process is
2937 interrupted so that the current merge can be manually resolved.
2949 interrupted so that the current merge can be manually resolved.
2938 Once all conflicts are addressed, the graft process can be
2950 Once all conflicts are addressed, the graft process can be
2939 continued with the -c/--continue option.
2951 continued with the -c/--continue option.
2940
2952
2941 The -c/--continue option reapplies all the earlier options.
2953 The -c/--continue option reapplies all the earlier options.
2942
2954
2943 .. container:: verbose
2955 .. container:: verbose
2944
2956
2945 The --base option exposes more of how graft internally uses merge with a
2957 The --base option exposes more of how graft internally uses merge with a
2946 custom base revision. --base can be used to specify another ancestor than
2958 custom base revision. --base can be used to specify another ancestor than
2947 the first and only parent.
2959 the first and only parent.
2948
2960
2949 The command::
2961 The command::
2950
2962
2951 hg graft -r 345 --base 234
2963 hg graft -r 345 --base 234
2952
2964
2953 is thus pretty much the same as::
2965 is thus pretty much the same as::
2954
2966
2955 hg diff -r 234 -r 345 | hg import
2967 hg diff -r 234 -r 345 | hg import
2956
2968
2957 but using merge to resolve conflicts and track moved files.
2969 but using merge to resolve conflicts and track moved files.
2958
2970
2959 The result of a merge can thus be backported as a single commit by
2971 The result of a merge can thus be backported as a single commit by
2960 specifying one of the merge parents as base, and thus effectively
2972 specifying one of the merge parents as base, and thus effectively
2961 grafting the changes from the other side.
2973 grafting the changes from the other side.
2962
2974
2963 It is also possible to collapse multiple changesets and clean up history
2975 It is also possible to collapse multiple changesets and clean up history
2964 by specifying another ancestor as base, much like rebase --collapse
2976 by specifying another ancestor as base, much like rebase --collapse
2965 --keep.
2977 --keep.
2966
2978
2967 The commit message can be tweaked after the fact using commit --amend .
2979 The commit message can be tweaked after the fact using commit --amend .
2968
2980
2969 For using non-ancestors as the base to backout changes, see the backout
2981 For using non-ancestors as the base to backout changes, see the backout
2970 command and the hidden --parent option.
2982 command and the hidden --parent option.
2971
2983
2972 .. container:: verbose
2984 .. container:: verbose
2973
2985
2974 Examples:
2986 Examples:
2975
2987
2976 - copy a single change to the stable branch and edit its description::
2988 - copy a single change to the stable branch and edit its description::
2977
2989
2978 hg update stable
2990 hg update stable
2979 hg graft --edit 9393
2991 hg graft --edit 9393
2980
2992
2981 - graft a range of changesets with one exception, updating dates::
2993 - graft a range of changesets with one exception, updating dates::
2982
2994
2983 hg graft -D "2085::2093 and not 2091"
2995 hg graft -D "2085::2093 and not 2091"
2984
2996
2985 - continue a graft after resolving conflicts::
2997 - continue a graft after resolving conflicts::
2986
2998
2987 hg graft -c
2999 hg graft -c
2988
3000
2989 - show the source of a grafted changeset::
3001 - show the source of a grafted changeset::
2990
3002
2991 hg log --debug -r .
3003 hg log --debug -r .
2992
3004
2993 - show revisions sorted by date::
3005 - show revisions sorted by date::
2994
3006
2995 hg log -r "sort(all(), date)"
3007 hg log -r "sort(all(), date)"
2996
3008
2997 - backport the result of a merge as a single commit::
3009 - backport the result of a merge as a single commit::
2998
3010
2999 hg graft -r 123 --base 123^
3011 hg graft -r 123 --base 123^
3000
3012
3001 - land a feature branch as one changeset::
3013 - land a feature branch as one changeset::
3002
3014
3003 hg up -cr default
3015 hg up -cr default
3004 hg graft -r featureX --base "ancestor('featureX', 'default')"
3016 hg graft -r featureX --base "ancestor('featureX', 'default')"
3005
3017
3006 See :hg:`help revisions` for more about specifying revisions.
3018 See :hg:`help revisions` for more about specifying revisions.
3007
3019
3008 Returns 0 on successful completion, 1 if there are unresolved files.
3020 Returns 0 on successful completion, 1 if there are unresolved files.
3009 """
3021 """
3010 with repo.wlock():
3022 with repo.wlock():
3011 return _dograft(ui, repo, *revs, **opts)
3023 return _dograft(ui, repo, *revs, **opts)
3012
3024
3013
3025
3014 def _dograft(ui, repo, *revs, **opts):
3026 def _dograft(ui, repo, *revs, **opts):
3015 opts = pycompat.byteskwargs(opts)
3027 opts = pycompat.byteskwargs(opts)
3016 if revs and opts.get(b'rev'):
3028 if revs and opts.get(b'rev'):
3017 ui.warn(
3029 ui.warn(
3018 _(
3030 _(
3019 b'warning: inconsistent use of --rev might give unexpected '
3031 b'warning: inconsistent use of --rev might give unexpected '
3020 b'revision ordering!\n'
3032 b'revision ordering!\n'
3021 )
3033 )
3022 )
3034 )
3023
3035
3024 revs = list(revs)
3036 revs = list(revs)
3025 revs.extend(opts.get(b'rev'))
3037 revs.extend(opts.get(b'rev'))
3026 # a dict of data to be stored in state file
3038 # a dict of data to be stored in state file
3027 statedata = {}
3039 statedata = {}
3028 # list of new nodes created by ongoing graft
3040 # list of new nodes created by ongoing graft
3029 statedata[b'newnodes'] = []
3041 statedata[b'newnodes'] = []
3030
3042
3031 cmdutil.resolvecommitoptions(ui, opts)
3043 cmdutil.resolvecommitoptions(ui, opts)
3032
3044
3033 editor = cmdutil.getcommiteditor(
3045 editor = cmdutil.getcommiteditor(
3034 editform=b'graft', **pycompat.strkwargs(opts)
3046 editform=b'graft', **pycompat.strkwargs(opts)
3035 )
3047 )
3036
3048
3037 cmdutil.check_at_most_one_arg(opts, b'abort', b'stop', b'continue')
3049 cmdutil.check_at_most_one_arg(opts, b'abort', b'stop', b'continue')
3038
3050
3039 cont = False
3051 cont = False
3040 if opts.get(b'no_commit'):
3052 if opts.get(b'no_commit'):
3041 cmdutil.check_incompatible_arguments(
3053 cmdutil.check_incompatible_arguments(
3042 opts,
3054 opts,
3043 b'no_commit',
3055 b'no_commit',
3044 [b'edit', b'currentuser', b'currentdate', b'log'],
3056 [b'edit', b'currentuser', b'currentdate', b'log'],
3045 )
3057 )
3046
3058
3047 graftstate = statemod.cmdstate(repo, b'graftstate')
3059 graftstate = statemod.cmdstate(repo, b'graftstate')
3048
3060
3049 if opts.get(b'stop'):
3061 if opts.get(b'stop'):
3050 cmdutil.check_incompatible_arguments(
3062 cmdutil.check_incompatible_arguments(
3051 opts,
3063 opts,
3052 b'stop',
3064 b'stop',
3053 [
3065 [
3054 b'edit',
3066 b'edit',
3055 b'log',
3067 b'log',
3056 b'user',
3068 b'user',
3057 b'date',
3069 b'date',
3058 b'currentdate',
3070 b'currentdate',
3059 b'currentuser',
3071 b'currentuser',
3060 b'rev',
3072 b'rev',
3061 ],
3073 ],
3062 )
3074 )
3063 return _stopgraft(ui, repo, graftstate)
3075 return _stopgraft(ui, repo, graftstate)
3064 elif opts.get(b'abort'):
3076 elif opts.get(b'abort'):
3065 cmdutil.check_incompatible_arguments(
3077 cmdutil.check_incompatible_arguments(
3066 opts,
3078 opts,
3067 b'abort',
3079 b'abort',
3068 [
3080 [
3069 b'edit',
3081 b'edit',
3070 b'log',
3082 b'log',
3071 b'user',
3083 b'user',
3072 b'date',
3084 b'date',
3073 b'currentdate',
3085 b'currentdate',
3074 b'currentuser',
3086 b'currentuser',
3075 b'rev',
3087 b'rev',
3076 ],
3088 ],
3077 )
3089 )
3078 return cmdutil.abortgraft(ui, repo, graftstate)
3090 return cmdutil.abortgraft(ui, repo, graftstate)
3079 elif opts.get(b'continue'):
3091 elif opts.get(b'continue'):
3080 cont = True
3092 cont = True
3081 if revs:
3093 if revs:
3082 raise error.InputError(_(b"can't specify --continue and revisions"))
3094 raise error.InputError(_(b"can't specify --continue and revisions"))
3083 # read in unfinished revisions
3095 # read in unfinished revisions
3084 if graftstate.exists():
3096 if graftstate.exists():
3085 statedata = cmdutil.readgraftstate(repo, graftstate)
3097 statedata = cmdutil.readgraftstate(repo, graftstate)
3086 if statedata.get(b'date'):
3098 if statedata.get(b'date'):
3087 opts[b'date'] = statedata[b'date']
3099 opts[b'date'] = statedata[b'date']
3088 if statedata.get(b'user'):
3100 if statedata.get(b'user'):
3089 opts[b'user'] = statedata[b'user']
3101 opts[b'user'] = statedata[b'user']
3090 if statedata.get(b'log'):
3102 if statedata.get(b'log'):
3091 opts[b'log'] = True
3103 opts[b'log'] = True
3092 if statedata.get(b'no_commit'):
3104 if statedata.get(b'no_commit'):
3093 opts[b'no_commit'] = statedata.get(b'no_commit')
3105 opts[b'no_commit'] = statedata.get(b'no_commit')
3094 if statedata.get(b'base'):
3106 if statedata.get(b'base'):
3095 opts[b'base'] = statedata.get(b'base')
3107 opts[b'base'] = statedata.get(b'base')
3096 nodes = statedata[b'nodes']
3108 nodes = statedata[b'nodes']
3097 revs = [repo[node].rev() for node in nodes]
3109 revs = [repo[node].rev() for node in nodes]
3098 else:
3110 else:
3099 cmdutil.wrongtooltocontinue(repo, _(b'graft'))
3111 cmdutil.wrongtooltocontinue(repo, _(b'graft'))
3100 else:
3112 else:
3101 if not revs:
3113 if not revs:
3102 raise error.InputError(_(b'no revisions specified'))
3114 raise error.InputError(_(b'no revisions specified'))
3103 cmdutil.checkunfinished(repo)
3115 cmdutil.checkunfinished(repo)
3104 cmdutil.bailifchanged(repo)
3116 cmdutil.bailifchanged(repo)
3105 revs = scmutil.revrange(repo, revs)
3117 revs = scmutil.revrange(repo, revs)
3106
3118
3107 skipped = set()
3119 skipped = set()
3108 basectx = None
3120 basectx = None
3109 if opts.get(b'base'):
3121 if opts.get(b'base'):
3110 basectx = scmutil.revsingle(repo, opts[b'base'], None)
3122 basectx = scmutil.revsingle(repo, opts[b'base'], None)
3111 if basectx is None:
3123 if basectx is None:
3112 # check for merges
3124 # check for merges
3113 for rev in repo.revs(b'%ld and merge()', revs):
3125 for rev in repo.revs(b'%ld and merge()', revs):
3114 ui.warn(_(b'skipping ungraftable merge revision %d\n') % rev)
3126 ui.warn(_(b'skipping ungraftable merge revision %d\n') % rev)
3115 skipped.add(rev)
3127 skipped.add(rev)
3116 revs = [r for r in revs if r not in skipped]
3128 revs = [r for r in revs if r not in skipped]
3117 if not revs:
3129 if not revs:
3118 return -1
3130 return -1
3119 if basectx is not None and len(revs) != 1:
3131 if basectx is not None and len(revs) != 1:
3120 raise error.InputError(_(b'only one revision allowed with --base '))
3132 raise error.InputError(_(b'only one revision allowed with --base '))
3121
3133
3122 # Don't check in the --continue case, in effect retaining --force across
3134 # Don't check in the --continue case, in effect retaining --force across
3123 # --continues. That's because without --force, any revisions we decided to
3135 # --continues. That's because without --force, any revisions we decided to
3124 # skip would have been filtered out here, so they wouldn't have made their
3136 # skip would have been filtered out here, so they wouldn't have made their
3125 # way to the graftstate. With --force, any revisions we would have otherwise
3137 # way to the graftstate. With --force, any revisions we would have otherwise
3126 # skipped would not have been filtered out, and if they hadn't been applied
3138 # skipped would not have been filtered out, and if they hadn't been applied
3127 # already, they'd have been in the graftstate.
3139 # already, they'd have been in the graftstate.
3128 if not (cont or opts.get(b'force')) and basectx is None:
3140 if not (cont or opts.get(b'force')) and basectx is None:
3129 # check for ancestors of dest branch
3141 # check for ancestors of dest branch
3130 ancestors = repo.revs(b'%ld & (::.)', revs)
3142 ancestors = repo.revs(b'%ld & (::.)', revs)
3131 for rev in ancestors:
3143 for rev in ancestors:
3132 ui.warn(_(b'skipping ancestor revision %d:%s\n') % (rev, repo[rev]))
3144 ui.warn(_(b'skipping ancestor revision %d:%s\n') % (rev, repo[rev]))
3133
3145
3134 revs = [r for r in revs if r not in ancestors]
3146 revs = [r for r in revs if r not in ancestors]
3135
3147
3136 if not revs:
3148 if not revs:
3137 return -1
3149 return -1
3138
3150
3139 # analyze revs for earlier grafts
3151 # analyze revs for earlier grafts
3140 ids = {}
3152 ids = {}
3141 for ctx in repo.set(b"%ld", revs):
3153 for ctx in repo.set(b"%ld", revs):
3142 ids[ctx.hex()] = ctx.rev()
3154 ids[ctx.hex()] = ctx.rev()
3143 n = ctx.extra().get(b'source')
3155 n = ctx.extra().get(b'source')
3144 if n:
3156 if n:
3145 ids[n] = ctx.rev()
3157 ids[n] = ctx.rev()
3146
3158
3147 # check ancestors for earlier grafts
3159 # check ancestors for earlier grafts
3148 ui.debug(b'scanning for duplicate grafts\n')
3160 ui.debug(b'scanning for duplicate grafts\n')
3149
3161
3150 # The only changesets we can be sure doesn't contain grafts of any
3162 # The only changesets we can be sure doesn't contain grafts of any
3151 # revs, are the ones that are common ancestors of *all* revs:
3163 # revs, are the ones that are common ancestors of *all* revs:
3152 for rev in repo.revs(b'only(%d,ancestor(%ld))', repo[b'.'].rev(), revs):
3164 for rev in repo.revs(b'only(%d,ancestor(%ld))', repo[b'.'].rev(), revs):
3153 ctx = repo[rev]
3165 ctx = repo[rev]
3154 n = ctx.extra().get(b'source')
3166 n = ctx.extra().get(b'source')
3155 if n in ids:
3167 if n in ids:
3156 try:
3168 try:
3157 r = repo[n].rev()
3169 r = repo[n].rev()
3158 except error.RepoLookupError:
3170 except error.RepoLookupError:
3159 r = None
3171 r = None
3160 if r in revs:
3172 if r in revs:
3161 ui.warn(
3173 ui.warn(
3162 _(
3174 _(
3163 b'skipping revision %d:%s '
3175 b'skipping revision %d:%s '
3164 b'(already grafted to %d:%s)\n'
3176 b'(already grafted to %d:%s)\n'
3165 )
3177 )
3166 % (r, repo[r], rev, ctx)
3178 % (r, repo[r], rev, ctx)
3167 )
3179 )
3168 revs.remove(r)
3180 revs.remove(r)
3169 elif ids[n] in revs:
3181 elif ids[n] in revs:
3170 if r is None:
3182 if r is None:
3171 ui.warn(
3183 ui.warn(
3172 _(
3184 _(
3173 b'skipping already grafted revision %d:%s '
3185 b'skipping already grafted revision %d:%s '
3174 b'(%d:%s also has unknown origin %s)\n'
3186 b'(%d:%s also has unknown origin %s)\n'
3175 )
3187 )
3176 % (ids[n], repo[ids[n]], rev, ctx, n[:12])
3188 % (ids[n], repo[ids[n]], rev, ctx, n[:12])
3177 )
3189 )
3178 else:
3190 else:
3179 ui.warn(
3191 ui.warn(
3180 _(
3192 _(
3181 b'skipping already grafted revision %d:%s '
3193 b'skipping already grafted revision %d:%s '
3182 b'(%d:%s also has origin %d:%s)\n'
3194 b'(%d:%s also has origin %d:%s)\n'
3183 )
3195 )
3184 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12])
3196 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12])
3185 )
3197 )
3186 revs.remove(ids[n])
3198 revs.remove(ids[n])
3187 elif ctx.hex() in ids:
3199 elif ctx.hex() in ids:
3188 r = ids[ctx.hex()]
3200 r = ids[ctx.hex()]
3189 if r in revs:
3201 if r in revs:
3190 ui.warn(
3202 ui.warn(
3191 _(
3203 _(
3192 b'skipping already grafted revision %d:%s '
3204 b'skipping already grafted revision %d:%s '
3193 b'(was grafted from %d:%s)\n'
3205 b'(was grafted from %d:%s)\n'
3194 )
3206 )
3195 % (r, repo[r], rev, ctx)
3207 % (r, repo[r], rev, ctx)
3196 )
3208 )
3197 revs.remove(r)
3209 revs.remove(r)
3198 if not revs:
3210 if not revs:
3199 return -1
3211 return -1
3200
3212
3201 if opts.get(b'no_commit'):
3213 if opts.get(b'no_commit'):
3202 statedata[b'no_commit'] = True
3214 statedata[b'no_commit'] = True
3203 if opts.get(b'base'):
3215 if opts.get(b'base'):
3204 statedata[b'base'] = opts[b'base']
3216 statedata[b'base'] = opts[b'base']
3205 for pos, ctx in enumerate(repo.set(b"%ld", revs)):
3217 for pos, ctx in enumerate(repo.set(b"%ld", revs)):
3206 desc = b'%d:%s "%s"' % (
3218 desc = b'%d:%s "%s"' % (
3207 ctx.rev(),
3219 ctx.rev(),
3208 ctx,
3220 ctx,
3209 ctx.description().split(b'\n', 1)[0],
3221 ctx.description().split(b'\n', 1)[0],
3210 )
3222 )
3211 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
3223 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
3212 if names:
3224 if names:
3213 desc += b' (%s)' % b' '.join(names)
3225 desc += b' (%s)' % b' '.join(names)
3214 ui.status(_(b'grafting %s\n') % desc)
3226 ui.status(_(b'grafting %s\n') % desc)
3215 if opts.get(b'dry_run'):
3227 if opts.get(b'dry_run'):
3216 continue
3228 continue
3217
3229
3218 source = ctx.extra().get(b'source')
3230 source = ctx.extra().get(b'source')
3219 extra = {}
3231 extra = {}
3220 if source:
3232 if source:
3221 extra[b'source'] = source
3233 extra[b'source'] = source
3222 extra[b'intermediate-source'] = ctx.hex()
3234 extra[b'intermediate-source'] = ctx.hex()
3223 else:
3235 else:
3224 extra[b'source'] = ctx.hex()
3236 extra[b'source'] = ctx.hex()
3225 user = ctx.user()
3237 user = ctx.user()
3226 if opts.get(b'user'):
3238 if opts.get(b'user'):
3227 user = opts[b'user']
3239 user = opts[b'user']
3228 statedata[b'user'] = user
3240 statedata[b'user'] = user
3229 date = ctx.date()
3241 date = ctx.date()
3230 if opts.get(b'date'):
3242 if opts.get(b'date'):
3231 date = opts[b'date']
3243 date = opts[b'date']
3232 statedata[b'date'] = date
3244 statedata[b'date'] = date
3233 message = ctx.description()
3245 message = ctx.description()
3234 if opts.get(b'log'):
3246 if opts.get(b'log'):
3235 message += b'\n(grafted from %s)' % ctx.hex()
3247 message += b'\n(grafted from %s)' % ctx.hex()
3236 statedata[b'log'] = True
3248 statedata[b'log'] = True
3237
3249
3238 # we don't merge the first commit when continuing
3250 # we don't merge the first commit when continuing
3239 if not cont:
3251 if not cont:
3240 # perform the graft merge with p1(rev) as 'ancestor'
3252 # perform the graft merge with p1(rev) as 'ancestor'
3241 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
3253 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
3242 base = ctx.p1() if basectx is None else basectx
3254 base = ctx.p1() if basectx is None else basectx
3243 with ui.configoverride(overrides, b'graft'):
3255 with ui.configoverride(overrides, b'graft'):
3244 stats = mergemod.graft(repo, ctx, base, [b'local', b'graft'])
3256 stats = mergemod.graft(repo, ctx, base, [b'local', b'graft'])
3245 # report any conflicts
3257 # report any conflicts
3246 if stats.unresolvedcount > 0:
3258 if stats.unresolvedcount > 0:
3247 # write out state for --continue
3259 # write out state for --continue
3248 nodes = [repo[rev].hex() for rev in revs[pos:]]
3260 nodes = [repo[rev].hex() for rev in revs[pos:]]
3249 statedata[b'nodes'] = nodes
3261 statedata[b'nodes'] = nodes
3250 stateversion = 1
3262 stateversion = 1
3251 graftstate.save(stateversion, statedata)
3263 graftstate.save(stateversion, statedata)
3252 ui.error(_(b"abort: unresolved conflicts, can't continue\n"))
3264 ui.error(_(b"abort: unresolved conflicts, can't continue\n"))
3253 ui.error(_(b"(use 'hg resolve' and 'hg graft --continue')\n"))
3265 ui.error(_(b"(use 'hg resolve' and 'hg graft --continue')\n"))
3254 return 1
3266 return 1
3255 else:
3267 else:
3256 cont = False
3268 cont = False
3257
3269
3258 # commit if --no-commit is false
3270 # commit if --no-commit is false
3259 if not opts.get(b'no_commit'):
3271 if not opts.get(b'no_commit'):
3260 node = repo.commit(
3272 node = repo.commit(
3261 text=message, user=user, date=date, extra=extra, editor=editor
3273 text=message, user=user, date=date, extra=extra, editor=editor
3262 )
3274 )
3263 if node is None:
3275 if node is None:
3264 ui.warn(
3276 ui.warn(
3265 _(b'note: graft of %d:%s created no changes to commit\n')
3277 _(b'note: graft of %d:%s created no changes to commit\n')
3266 % (ctx.rev(), ctx)
3278 % (ctx.rev(), ctx)
3267 )
3279 )
3268 # checking that newnodes exist because old state files won't have it
3280 # checking that newnodes exist because old state files won't have it
3269 elif statedata.get(b'newnodes') is not None:
3281 elif statedata.get(b'newnodes') is not None:
3270 statedata[b'newnodes'].append(node)
3282 statedata[b'newnodes'].append(node)
3271
3283
3272 # remove state when we complete successfully
3284 # remove state when we complete successfully
3273 if not opts.get(b'dry_run'):
3285 if not opts.get(b'dry_run'):
3274 graftstate.delete()
3286 graftstate.delete()
3275
3287
3276 return 0
3288 return 0
3277
3289
3278
3290
3279 def _stopgraft(ui, repo, graftstate):
3291 def _stopgraft(ui, repo, graftstate):
3280 """stop the interrupted graft"""
3292 """stop the interrupted graft"""
3281 if not graftstate.exists():
3293 if not graftstate.exists():
3282 raise error.StateError(_(b"no interrupted graft found"))
3294 raise error.StateError(_(b"no interrupted graft found"))
3283 pctx = repo[b'.']
3295 pctx = repo[b'.']
3284 mergemod.clean_update(pctx)
3296 mergemod.clean_update(pctx)
3285 graftstate.delete()
3297 graftstate.delete()
3286 ui.status(_(b"stopped the interrupted graft\n"))
3298 ui.status(_(b"stopped the interrupted graft\n"))
3287 ui.status(_(b"working directory is now at %s\n") % pctx.hex()[:12])
3299 ui.status(_(b"working directory is now at %s\n") % pctx.hex()[:12])
3288 return 0
3300 return 0
3289
3301
3290
3302
3291 statemod.addunfinished(
3303 statemod.addunfinished(
3292 b'graft',
3304 b'graft',
3293 fname=b'graftstate',
3305 fname=b'graftstate',
3294 clearable=True,
3306 clearable=True,
3295 stopflag=True,
3307 stopflag=True,
3296 continueflag=True,
3308 continueflag=True,
3297 abortfunc=cmdutil.hgabortgraft,
3309 abortfunc=cmdutil.hgabortgraft,
3298 cmdhint=_(b"use 'hg graft --continue' or 'hg graft --stop' to stop"),
3310 cmdhint=_(b"use 'hg graft --continue' or 'hg graft --stop' to stop"),
3299 )
3311 )
3300
3312
3301
3313
3302 @command(
3314 @command(
3303 b'grep',
3315 b'grep',
3304 [
3316 [
3305 (b'0', b'print0', None, _(b'end fields with NUL')),
3317 (b'0', b'print0', None, _(b'end fields with NUL')),
3306 (b'', b'all', None, _(b'an alias to --diff (DEPRECATED)')),
3318 (b'', b'all', None, _(b'an alias to --diff (DEPRECATED)')),
3307 (
3319 (
3308 b'',
3320 b'',
3309 b'diff',
3321 b'diff',
3310 None,
3322 None,
3311 _(
3323 _(
3312 b'search revision differences for when the pattern was added '
3324 b'search revision differences for when the pattern was added '
3313 b'or removed'
3325 b'or removed'
3314 ),
3326 ),
3315 ),
3327 ),
3316 (b'a', b'text', None, _(b'treat all files as text')),
3328 (b'a', b'text', None, _(b'treat all files as text')),
3317 (
3329 (
3318 b'f',
3330 b'f',
3319 b'follow',
3331 b'follow',
3320 None,
3332 None,
3321 _(
3333 _(
3322 b'follow changeset history,'
3334 b'follow changeset history,'
3323 b' or file history across copies and renames'
3335 b' or file history across copies and renames'
3324 ),
3336 ),
3325 ),
3337 ),
3326 (b'i', b'ignore-case', None, _(b'ignore case when matching')),
3338 (b'i', b'ignore-case', None, _(b'ignore case when matching')),
3327 (
3339 (
3328 b'l',
3340 b'l',
3329 b'files-with-matches',
3341 b'files-with-matches',
3330 None,
3342 None,
3331 _(b'print only filenames and revisions that match'),
3343 _(b'print only filenames and revisions that match'),
3332 ),
3344 ),
3333 (b'n', b'line-number', None, _(b'print matching line numbers')),
3345 (b'n', b'line-number', None, _(b'print matching line numbers')),
3334 (
3346 (
3335 b'r',
3347 b'r',
3336 b'rev',
3348 b'rev',
3337 [],
3349 [],
3338 _(b'search files changed within revision range'),
3350 _(b'search files changed within revision range'),
3339 _(b'REV'),
3351 _(b'REV'),
3340 ),
3352 ),
3341 (
3353 (
3342 b'',
3354 b'',
3343 b'all-files',
3355 b'all-files',
3344 None,
3356 None,
3345 _(
3357 _(
3346 b'include all files in the changeset while grepping (DEPRECATED)'
3358 b'include all files in the changeset while grepping (DEPRECATED)'
3347 ),
3359 ),
3348 ),
3360 ),
3349 (b'u', b'user', None, _(b'list the author (long with -v)')),
3361 (b'u', b'user', None, _(b'list the author (long with -v)')),
3350 (b'd', b'date', None, _(b'list the date (short with -q)')),
3362 (b'd', b'date', None, _(b'list the date (short with -q)')),
3351 ]
3363 ]
3352 + formatteropts
3364 + formatteropts
3353 + walkopts,
3365 + walkopts,
3354 _(b'[--diff] [OPTION]... PATTERN [FILE]...'),
3366 _(b'[--diff] [OPTION]... PATTERN [FILE]...'),
3355 helpcategory=command.CATEGORY_FILE_CONTENTS,
3367 helpcategory=command.CATEGORY_FILE_CONTENTS,
3356 inferrepo=True,
3368 inferrepo=True,
3357 intents={INTENT_READONLY},
3369 intents={INTENT_READONLY},
3358 )
3370 )
3359 def grep(ui, repo, pattern, *pats, **opts):
3371 def grep(ui, repo, pattern, *pats, **opts):
3360 """search for a pattern in specified files
3372 """search for a pattern in specified files
3361
3373
3362 Search the working directory or revision history for a regular
3374 Search the working directory or revision history for a regular
3363 expression in the specified files for the entire repository.
3375 expression in the specified files for the entire repository.
3364
3376
3365 By default, grep searches the repository files in the working
3377 By default, grep searches the repository files in the working
3366 directory and prints the files where it finds a match. To specify
3378 directory and prints the files where it finds a match. To specify
3367 historical revisions instead of the working directory, use the
3379 historical revisions instead of the working directory, use the
3368 --rev flag.
3380 --rev flag.
3369
3381
3370 To search instead historical revision differences that contains a
3382 To search instead historical revision differences that contains a
3371 change in match status ("-" for a match that becomes a non-match,
3383 change in match status ("-" for a match that becomes a non-match,
3372 or "+" for a non-match that becomes a match), use the --diff flag.
3384 or "+" for a non-match that becomes a match), use the --diff flag.
3373
3385
3374 PATTERN can be any Python (roughly Perl-compatible) regular
3386 PATTERN can be any Python (roughly Perl-compatible) regular
3375 expression.
3387 expression.
3376
3388
3377 If no FILEs are specified and the --rev flag isn't supplied, all
3389 If no FILEs are specified and the --rev flag isn't supplied, all
3378 files in the working directory are searched. When using the --rev
3390 files in the working directory are searched. When using the --rev
3379 flag and specifying FILEs, use the --follow argument to also
3391 flag and specifying FILEs, use the --follow argument to also
3380 follow the specified FILEs across renames and copies.
3392 follow the specified FILEs across renames and copies.
3381
3393
3382 .. container:: verbose
3394 .. container:: verbose
3383
3395
3384 Template:
3396 Template:
3385
3397
3386 The following keywords are supported in addition to the common template
3398 The following keywords are supported in addition to the common template
3387 keywords and functions. See also :hg:`help templates`.
3399 keywords and functions. See also :hg:`help templates`.
3388
3400
3389 :change: String. Character denoting insertion ``+`` or removal ``-``.
3401 :change: String. Character denoting insertion ``+`` or removal ``-``.
3390 Available if ``--diff`` is specified.
3402 Available if ``--diff`` is specified.
3391 :lineno: Integer. Line number of the match.
3403 :lineno: Integer. Line number of the match.
3392 :path: String. Repository-absolute path of the file.
3404 :path: String. Repository-absolute path of the file.
3393 :texts: List of text chunks.
3405 :texts: List of text chunks.
3394
3406
3395 And each entry of ``{texts}`` provides the following sub-keywords.
3407 And each entry of ``{texts}`` provides the following sub-keywords.
3396
3408
3397 :matched: Boolean. True if the chunk matches the specified pattern.
3409 :matched: Boolean. True if the chunk matches the specified pattern.
3398 :text: String. Chunk content.
3410 :text: String. Chunk content.
3399
3411
3400 See :hg:`help templates.operators` for the list expansion syntax.
3412 See :hg:`help templates.operators` for the list expansion syntax.
3401
3413
3402 Returns 0 if a match is found, 1 otherwise.
3414 Returns 0 if a match is found, 1 otherwise.
3403
3415
3404 """
3416 """
3405 cmdutil.check_incompatible_arguments(opts, 'all_files', ['all', 'diff'])
3417 cmdutil.check_incompatible_arguments(opts, 'all_files', ['all', 'diff'])
3406 opts = pycompat.byteskwargs(opts)
3418 opts = pycompat.byteskwargs(opts)
3407 diff = opts.get(b'all') or opts.get(b'diff')
3419 diff = opts.get(b'all') or opts.get(b'diff')
3408 follow = opts.get(b'follow')
3420 follow = opts.get(b'follow')
3409 if opts.get(b'all_files') is None and not diff:
3421 if opts.get(b'all_files') is None and not diff:
3410 opts[b'all_files'] = True
3422 opts[b'all_files'] = True
3411 plaingrep = (
3423 plaingrep = (
3412 opts.get(b'all_files')
3424 opts.get(b'all_files')
3413 and not opts.get(b'rev')
3425 and not opts.get(b'rev')
3414 and not opts.get(b'follow')
3426 and not opts.get(b'follow')
3415 )
3427 )
3416 all_files = opts.get(b'all_files')
3428 all_files = opts.get(b'all_files')
3417 if plaingrep:
3429 if plaingrep:
3418 opts[b'rev'] = [b'wdir()']
3430 opts[b'rev'] = [b'wdir()']
3419
3431
3420 reflags = re.M
3432 reflags = re.M
3421 if opts.get(b'ignore_case'):
3433 if opts.get(b'ignore_case'):
3422 reflags |= re.I
3434 reflags |= re.I
3423 try:
3435 try:
3424 regexp = util.re.compile(pattern, reflags)
3436 regexp = util.re.compile(pattern, reflags)
3425 except re.error as inst:
3437 except re.error as inst:
3426 ui.warn(
3438 ui.warn(
3427 _(b"grep: invalid match pattern: %s\n") % pycompat.bytestr(inst)
3439 _(b"grep: invalid match pattern: %s\n") % pycompat.bytestr(inst)
3428 )
3440 )
3429 return 1
3441 return 1
3430 sep, eol = b':', b'\n'
3442 sep, eol = b':', b'\n'
3431 if opts.get(b'print0'):
3443 if opts.get(b'print0'):
3432 sep = eol = b'\0'
3444 sep = eol = b'\0'
3433
3445
3434 searcher = grepmod.grepsearcher(
3446 searcher = grepmod.grepsearcher(
3435 ui, repo, regexp, all_files=all_files, diff=diff, follow=follow
3447 ui, repo, regexp, all_files=all_files, diff=diff, follow=follow
3436 )
3448 )
3437
3449
3438 getfile = searcher._getfile
3450 getfile = searcher._getfile
3439
3451
3440 uipathfn = scmutil.getuipathfn(repo)
3452 uipathfn = scmutil.getuipathfn(repo)
3441
3453
3442 def display(fm, fn, ctx, pstates, states):
3454 def display(fm, fn, ctx, pstates, states):
3443 rev = scmutil.intrev(ctx)
3455 rev = scmutil.intrev(ctx)
3444 if fm.isplain():
3456 if fm.isplain():
3445 formatuser = ui.shortuser
3457 formatuser = ui.shortuser
3446 else:
3458 else:
3447 formatuser = pycompat.bytestr
3459 formatuser = pycompat.bytestr
3448 if ui.quiet:
3460 if ui.quiet:
3449 datefmt = b'%Y-%m-%d'
3461 datefmt = b'%Y-%m-%d'
3450 else:
3462 else:
3451 datefmt = b'%a %b %d %H:%M:%S %Y %1%2'
3463 datefmt = b'%a %b %d %H:%M:%S %Y %1%2'
3452 found = False
3464 found = False
3453
3465
3454 @util.cachefunc
3466 @util.cachefunc
3455 def binary():
3467 def binary():
3456 flog = getfile(fn)
3468 flog = getfile(fn)
3457 try:
3469 try:
3458 return stringutil.binary(flog.read(ctx.filenode(fn)))
3470 return stringutil.binary(flog.read(ctx.filenode(fn)))
3459 except error.WdirUnsupported:
3471 except error.WdirUnsupported:
3460 return ctx[fn].isbinary()
3472 return ctx[fn].isbinary()
3461
3473
3462 fieldnamemap = {b'linenumber': b'lineno'}
3474 fieldnamemap = {b'linenumber': b'lineno'}
3463 if diff:
3475 if diff:
3464 iter = grepmod.difflinestates(pstates, states)
3476 iter = grepmod.difflinestates(pstates, states)
3465 else:
3477 else:
3466 iter = [(b'', l) for l in states]
3478 iter = [(b'', l) for l in states]
3467 for change, l in iter:
3479 for change, l in iter:
3468 fm.startitem()
3480 fm.startitem()
3469 fm.context(ctx=ctx)
3481 fm.context(ctx=ctx)
3470 fm.data(node=fm.hexfunc(scmutil.binnode(ctx)), path=fn)
3482 fm.data(node=fm.hexfunc(scmutil.binnode(ctx)), path=fn)
3471 fm.plain(uipathfn(fn), label=b'grep.filename')
3483 fm.plain(uipathfn(fn), label=b'grep.filename')
3472
3484
3473 cols = [
3485 cols = [
3474 (b'rev', b'%d', rev, not plaingrep, b''),
3486 (b'rev', b'%d', rev, not plaingrep, b''),
3475 (
3487 (
3476 b'linenumber',
3488 b'linenumber',
3477 b'%d',
3489 b'%d',
3478 l.linenum,
3490 l.linenum,
3479 opts.get(b'line_number'),
3491 opts.get(b'line_number'),
3480 b'',
3492 b'',
3481 ),
3493 ),
3482 ]
3494 ]
3483 if diff:
3495 if diff:
3484 cols.append(
3496 cols.append(
3485 (
3497 (
3486 b'change',
3498 b'change',
3487 b'%s',
3499 b'%s',
3488 change,
3500 change,
3489 True,
3501 True,
3490 b'grep.inserted '
3502 b'grep.inserted '
3491 if change == b'+'
3503 if change == b'+'
3492 else b'grep.deleted ',
3504 else b'grep.deleted ',
3493 )
3505 )
3494 )
3506 )
3495 cols.extend(
3507 cols.extend(
3496 [
3508 [
3497 (
3509 (
3498 b'user',
3510 b'user',
3499 b'%s',
3511 b'%s',
3500 formatuser(ctx.user()),
3512 formatuser(ctx.user()),
3501 opts.get(b'user'),
3513 opts.get(b'user'),
3502 b'',
3514 b'',
3503 ),
3515 ),
3504 (
3516 (
3505 b'date',
3517 b'date',
3506 b'%s',
3518 b'%s',
3507 fm.formatdate(ctx.date(), datefmt),
3519 fm.formatdate(ctx.date(), datefmt),
3508 opts.get(b'date'),
3520 opts.get(b'date'),
3509 b'',
3521 b'',
3510 ),
3522 ),
3511 ]
3523 ]
3512 )
3524 )
3513 for name, fmt, data, cond, extra_label in cols:
3525 for name, fmt, data, cond, extra_label in cols:
3514 if cond:
3526 if cond:
3515 fm.plain(sep, label=b'grep.sep')
3527 fm.plain(sep, label=b'grep.sep')
3516 field = fieldnamemap.get(name, name)
3528 field = fieldnamemap.get(name, name)
3517 label = extra_label + (b'grep.%s' % name)
3529 label = extra_label + (b'grep.%s' % name)
3518 fm.condwrite(cond, field, fmt, data, label=label)
3530 fm.condwrite(cond, field, fmt, data, label=label)
3519 if not opts.get(b'files_with_matches'):
3531 if not opts.get(b'files_with_matches'):
3520 fm.plain(sep, label=b'grep.sep')
3532 fm.plain(sep, label=b'grep.sep')
3521 if not opts.get(b'text') and binary():
3533 if not opts.get(b'text') and binary():
3522 fm.plain(_(b" Binary file matches"))
3534 fm.plain(_(b" Binary file matches"))
3523 else:
3535 else:
3524 displaymatches(fm.nested(b'texts', tmpl=b'{text}'), l)
3536 displaymatches(fm.nested(b'texts', tmpl=b'{text}'), l)
3525 fm.plain(eol)
3537 fm.plain(eol)
3526 found = True
3538 found = True
3527 if opts.get(b'files_with_matches'):
3539 if opts.get(b'files_with_matches'):
3528 break
3540 break
3529 return found
3541 return found
3530
3542
3531 def displaymatches(fm, l):
3543 def displaymatches(fm, l):
3532 p = 0
3544 p = 0
3533 for s, e in l.findpos(regexp):
3545 for s, e in l.findpos(regexp):
3534 if p < s:
3546 if p < s:
3535 fm.startitem()
3547 fm.startitem()
3536 fm.write(b'text', b'%s', l.line[p:s])
3548 fm.write(b'text', b'%s', l.line[p:s])
3537 fm.data(matched=False)
3549 fm.data(matched=False)
3538 fm.startitem()
3550 fm.startitem()
3539 fm.write(b'text', b'%s', l.line[s:e], label=b'grep.match')
3551 fm.write(b'text', b'%s', l.line[s:e], label=b'grep.match')
3540 fm.data(matched=True)
3552 fm.data(matched=True)
3541 p = e
3553 p = e
3542 if p < len(l.line):
3554 if p < len(l.line):
3543 fm.startitem()
3555 fm.startitem()
3544 fm.write(b'text', b'%s', l.line[p:])
3556 fm.write(b'text', b'%s', l.line[p:])
3545 fm.data(matched=False)
3557 fm.data(matched=False)
3546 fm.end()
3558 fm.end()
3547
3559
3548 found = False
3560 found = False
3549
3561
3550 wopts = logcmdutil.walkopts(
3562 wopts = logcmdutil.walkopts(
3551 pats=pats,
3563 pats=pats,
3552 opts=opts,
3564 opts=opts,
3553 revspec=opts[b'rev'],
3565 revspec=opts[b'rev'],
3554 include_pats=opts[b'include'],
3566 include_pats=opts[b'include'],
3555 exclude_pats=opts[b'exclude'],
3567 exclude_pats=opts[b'exclude'],
3556 follow=follow,
3568 follow=follow,
3557 force_changelog_traversal=all_files,
3569 force_changelog_traversal=all_files,
3558 filter_revisions_by_pats=not all_files,
3570 filter_revisions_by_pats=not all_files,
3559 )
3571 )
3560 revs, makefilematcher = logcmdutil.makewalker(repo, wopts)
3572 revs, makefilematcher = logcmdutil.makewalker(repo, wopts)
3561
3573
3562 ui.pager(b'grep')
3574 ui.pager(b'grep')
3563 fm = ui.formatter(b'grep', opts)
3575 fm = ui.formatter(b'grep', opts)
3564 for fn, ctx, pstates, states in searcher.searchfiles(revs, makefilematcher):
3576 for fn, ctx, pstates, states in searcher.searchfiles(revs, makefilematcher):
3565 r = display(fm, fn, ctx, pstates, states)
3577 r = display(fm, fn, ctx, pstates, states)
3566 found = found or r
3578 found = found or r
3567 if r and not diff and not all_files:
3579 if r and not diff and not all_files:
3568 searcher.skipfile(fn, ctx.rev())
3580 searcher.skipfile(fn, ctx.rev())
3569 fm.end()
3581 fm.end()
3570
3582
3571 return not found
3583 return not found
3572
3584
3573
3585
3574 @command(
3586 @command(
3575 b'heads',
3587 b'heads',
3576 [
3588 [
3577 (
3589 (
3578 b'r',
3590 b'r',
3579 b'rev',
3591 b'rev',
3580 b'',
3592 b'',
3581 _(b'show only heads which are descendants of STARTREV'),
3593 _(b'show only heads which are descendants of STARTREV'),
3582 _(b'STARTREV'),
3594 _(b'STARTREV'),
3583 ),
3595 ),
3584 (b't', b'topo', False, _(b'show topological heads only')),
3596 (b't', b'topo', False, _(b'show topological heads only')),
3585 (
3597 (
3586 b'a',
3598 b'a',
3587 b'active',
3599 b'active',
3588 False,
3600 False,
3589 _(b'show active branchheads only (DEPRECATED)'),
3601 _(b'show active branchheads only (DEPRECATED)'),
3590 ),
3602 ),
3591 (b'c', b'closed', False, _(b'show normal and closed branch heads')),
3603 (b'c', b'closed', False, _(b'show normal and closed branch heads')),
3592 ]
3604 ]
3593 + templateopts,
3605 + templateopts,
3594 _(b'[-ct] [-r STARTREV] [REV]...'),
3606 _(b'[-ct] [-r STARTREV] [REV]...'),
3595 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
3607 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
3596 intents={INTENT_READONLY},
3608 intents={INTENT_READONLY},
3597 )
3609 )
3598 def heads(ui, repo, *branchrevs, **opts):
3610 def heads(ui, repo, *branchrevs, **opts):
3599 """show branch heads
3611 """show branch heads
3600
3612
3601 With no arguments, show all open branch heads in the repository.
3613 With no arguments, show all open branch heads in the repository.
3602 Branch heads are changesets that have no descendants on the
3614 Branch heads are changesets that have no descendants on the
3603 same branch. They are where development generally takes place and
3615 same branch. They are where development generally takes place and
3604 are the usual targets for update and merge operations.
3616 are the usual targets for update and merge operations.
3605
3617
3606 If one or more REVs are given, only open branch heads on the
3618 If one or more REVs are given, only open branch heads on the
3607 branches associated with the specified changesets are shown. This
3619 branches associated with the specified changesets are shown. This
3608 means that you can use :hg:`heads .` to see the heads on the
3620 means that you can use :hg:`heads .` to see the heads on the
3609 currently checked-out branch.
3621 currently checked-out branch.
3610
3622
3611 If -c/--closed is specified, also show branch heads marked closed
3623 If -c/--closed is specified, also show branch heads marked closed
3612 (see :hg:`commit --close-branch`).
3624 (see :hg:`commit --close-branch`).
3613
3625
3614 If STARTREV is specified, only those heads that are descendants of
3626 If STARTREV is specified, only those heads that are descendants of
3615 STARTREV will be displayed.
3627 STARTREV will be displayed.
3616
3628
3617 If -t/--topo is specified, named branch mechanics will be ignored and only
3629 If -t/--topo is specified, named branch mechanics will be ignored and only
3618 topological heads (changesets with no children) will be shown.
3630 topological heads (changesets with no children) will be shown.
3619
3631
3620 Returns 0 if matching heads are found, 1 if not.
3632 Returns 0 if matching heads are found, 1 if not.
3621 """
3633 """
3622
3634
3623 opts = pycompat.byteskwargs(opts)
3635 opts = pycompat.byteskwargs(opts)
3624 start = None
3636 start = None
3625 rev = opts.get(b'rev')
3637 rev = opts.get(b'rev')
3626 if rev:
3638 if rev:
3627 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
3639 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
3628 start = scmutil.revsingle(repo, rev, None).node()
3640 start = scmutil.revsingle(repo, rev, None).node()
3629
3641
3630 if opts.get(b'topo'):
3642 if opts.get(b'topo'):
3631 heads = [repo[h] for h in repo.heads(start)]
3643 heads = [repo[h] for h in repo.heads(start)]
3632 else:
3644 else:
3633 heads = []
3645 heads = []
3634 for branch in repo.branchmap():
3646 for branch in repo.branchmap():
3635 heads += repo.branchheads(branch, start, opts.get(b'closed'))
3647 heads += repo.branchheads(branch, start, opts.get(b'closed'))
3636 heads = [repo[h] for h in heads]
3648 heads = [repo[h] for h in heads]
3637
3649
3638 if branchrevs:
3650 if branchrevs:
3639 branches = {
3651 branches = {
3640 repo[r].branch() for r in scmutil.revrange(repo, branchrevs)
3652 repo[r].branch() for r in scmutil.revrange(repo, branchrevs)
3641 }
3653 }
3642 heads = [h for h in heads if h.branch() in branches]
3654 heads = [h for h in heads if h.branch() in branches]
3643
3655
3644 if opts.get(b'active') and branchrevs:
3656 if opts.get(b'active') and branchrevs:
3645 dagheads = repo.heads(start)
3657 dagheads = repo.heads(start)
3646 heads = [h for h in heads if h.node() in dagheads]
3658 heads = [h for h in heads if h.node() in dagheads]
3647
3659
3648 if branchrevs:
3660 if branchrevs:
3649 haveheads = {h.branch() for h in heads}
3661 haveheads = {h.branch() for h in heads}
3650 if branches - haveheads:
3662 if branches - haveheads:
3651 headless = b', '.join(b for b in branches - haveheads)
3663 headless = b', '.join(b for b in branches - haveheads)
3652 msg = _(b'no open branch heads found on branches %s')
3664 msg = _(b'no open branch heads found on branches %s')
3653 if opts.get(b'rev'):
3665 if opts.get(b'rev'):
3654 msg += _(b' (started at %s)') % opts[b'rev']
3666 msg += _(b' (started at %s)') % opts[b'rev']
3655 ui.warn((msg + b'\n') % headless)
3667 ui.warn((msg + b'\n') % headless)
3656
3668
3657 if not heads:
3669 if not heads:
3658 return 1
3670 return 1
3659
3671
3660 ui.pager(b'heads')
3672 ui.pager(b'heads')
3661 heads = sorted(heads, key=lambda x: -(x.rev()))
3673 heads = sorted(heads, key=lambda x: -(x.rev()))
3662 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
3674 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
3663 for ctx in heads:
3675 for ctx in heads:
3664 displayer.show(ctx)
3676 displayer.show(ctx)
3665 displayer.close()
3677 displayer.close()
3666
3678
3667
3679
3668 @command(
3680 @command(
3669 b'help',
3681 b'help',
3670 [
3682 [
3671 (b'e', b'extension', None, _(b'show only help for extensions')),
3683 (b'e', b'extension', None, _(b'show only help for extensions')),
3672 (b'c', b'command', None, _(b'show only help for commands')),
3684 (b'c', b'command', None, _(b'show only help for commands')),
3673 (b'k', b'keyword', None, _(b'show topics matching keyword')),
3685 (b'k', b'keyword', None, _(b'show topics matching keyword')),
3674 (
3686 (
3675 b's',
3687 b's',
3676 b'system',
3688 b'system',
3677 [],
3689 [],
3678 _(b'show help for specific platform(s)'),
3690 _(b'show help for specific platform(s)'),
3679 _(b'PLATFORM'),
3691 _(b'PLATFORM'),
3680 ),
3692 ),
3681 ],
3693 ],
3682 _(b'[-eck] [-s PLATFORM] [TOPIC]'),
3694 _(b'[-eck] [-s PLATFORM] [TOPIC]'),
3683 helpcategory=command.CATEGORY_HELP,
3695 helpcategory=command.CATEGORY_HELP,
3684 norepo=True,
3696 norepo=True,
3685 intents={INTENT_READONLY},
3697 intents={INTENT_READONLY},
3686 )
3698 )
3687 def help_(ui, name=None, **opts):
3699 def help_(ui, name=None, **opts):
3688 """show help for a given topic or a help overview
3700 """show help for a given topic or a help overview
3689
3701
3690 With no arguments, print a list of commands with short help messages.
3702 With no arguments, print a list of commands with short help messages.
3691
3703
3692 Given a topic, extension, or command name, print help for that
3704 Given a topic, extension, or command name, print help for that
3693 topic.
3705 topic.
3694
3706
3695 Returns 0 if successful.
3707 Returns 0 if successful.
3696 """
3708 """
3697
3709
3698 keep = opts.get('system') or []
3710 keep = opts.get('system') or []
3699 if len(keep) == 0:
3711 if len(keep) == 0:
3700 if pycompat.sysplatform.startswith(b'win'):
3712 if pycompat.sysplatform.startswith(b'win'):
3701 keep.append(b'windows')
3713 keep.append(b'windows')
3702 elif pycompat.sysplatform == b'OpenVMS':
3714 elif pycompat.sysplatform == b'OpenVMS':
3703 keep.append(b'vms')
3715 keep.append(b'vms')
3704 elif pycompat.sysplatform == b'plan9':
3716 elif pycompat.sysplatform == b'plan9':
3705 keep.append(b'plan9')
3717 keep.append(b'plan9')
3706 else:
3718 else:
3707 keep.append(b'unix')
3719 keep.append(b'unix')
3708 keep.append(pycompat.sysplatform.lower())
3720 keep.append(pycompat.sysplatform.lower())
3709 if ui.verbose:
3721 if ui.verbose:
3710 keep.append(b'verbose')
3722 keep.append(b'verbose')
3711
3723
3712 commands = sys.modules[__name__]
3724 commands = sys.modules[__name__]
3713 formatted = help.formattedhelp(ui, commands, name, keep=keep, **opts)
3725 formatted = help.formattedhelp(ui, commands, name, keep=keep, **opts)
3714 ui.pager(b'help')
3726 ui.pager(b'help')
3715 ui.write(formatted)
3727 ui.write(formatted)
3716
3728
3717
3729
3718 @command(
3730 @command(
3719 b'identify|id',
3731 b'identify|id',
3720 [
3732 [
3721 (b'r', b'rev', b'', _(b'identify the specified revision'), _(b'REV')),
3733 (b'r', b'rev', b'', _(b'identify the specified revision'), _(b'REV')),
3722 (b'n', b'num', None, _(b'show local revision number')),
3734 (b'n', b'num', None, _(b'show local revision number')),
3723 (b'i', b'id', None, _(b'show global revision id')),
3735 (b'i', b'id', None, _(b'show global revision id')),
3724 (b'b', b'branch', None, _(b'show branch')),
3736 (b'b', b'branch', None, _(b'show branch')),
3725 (b't', b'tags', None, _(b'show tags')),
3737 (b't', b'tags', None, _(b'show tags')),
3726 (b'B', b'bookmarks', None, _(b'show bookmarks')),
3738 (b'B', b'bookmarks', None, _(b'show bookmarks')),
3727 ]
3739 ]
3728 + remoteopts
3740 + remoteopts
3729 + formatteropts,
3741 + formatteropts,
3730 _(b'[-nibtB] [-r REV] [SOURCE]'),
3742 _(b'[-nibtB] [-r REV] [SOURCE]'),
3731 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
3743 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
3732 optionalrepo=True,
3744 optionalrepo=True,
3733 intents={INTENT_READONLY},
3745 intents={INTENT_READONLY},
3734 )
3746 )
3735 def identify(
3747 def identify(
3736 ui,
3748 ui,
3737 repo,
3749 repo,
3738 source=None,
3750 source=None,
3739 rev=None,
3751 rev=None,
3740 num=None,
3752 num=None,
3741 id=None,
3753 id=None,
3742 branch=None,
3754 branch=None,
3743 tags=None,
3755 tags=None,
3744 bookmarks=None,
3756 bookmarks=None,
3745 **opts
3757 **opts
3746 ):
3758 ):
3747 """identify the working directory or specified revision
3759 """identify the working directory or specified revision
3748
3760
3749 Print a summary identifying the repository state at REV using one or
3761 Print a summary identifying the repository state at REV using one or
3750 two parent hash identifiers, followed by a "+" if the working
3762 two parent hash identifiers, followed by a "+" if the working
3751 directory has uncommitted changes, the branch name (if not default),
3763 directory has uncommitted changes, the branch name (if not default),
3752 a list of tags, and a list of bookmarks.
3764 a list of tags, and a list of bookmarks.
3753
3765
3754 When REV is not given, print a summary of the current state of the
3766 When REV is not given, print a summary of the current state of the
3755 repository including the working directory. Specify -r. to get information
3767 repository including the working directory. Specify -r. to get information
3756 of the working directory parent without scanning uncommitted changes.
3768 of the working directory parent without scanning uncommitted changes.
3757
3769
3758 Specifying a path to a repository root or Mercurial bundle will
3770 Specifying a path to a repository root or Mercurial bundle will
3759 cause lookup to operate on that repository/bundle.
3771 cause lookup to operate on that repository/bundle.
3760
3772
3761 .. container:: verbose
3773 .. container:: verbose
3762
3774
3763 Template:
3775 Template:
3764
3776
3765 The following keywords are supported in addition to the common template
3777 The following keywords are supported in addition to the common template
3766 keywords and functions. See also :hg:`help templates`.
3778 keywords and functions. See also :hg:`help templates`.
3767
3779
3768 :dirty: String. Character ``+`` denoting if the working directory has
3780 :dirty: String. Character ``+`` denoting if the working directory has
3769 uncommitted changes.
3781 uncommitted changes.
3770 :id: String. One or two nodes, optionally followed by ``+``.
3782 :id: String. One or two nodes, optionally followed by ``+``.
3771 :parents: List of strings. Parent nodes of the changeset.
3783 :parents: List of strings. Parent nodes of the changeset.
3772
3784
3773 Examples:
3785 Examples:
3774
3786
3775 - generate a build identifier for the working directory::
3787 - generate a build identifier for the working directory::
3776
3788
3777 hg id --id > build-id.dat
3789 hg id --id > build-id.dat
3778
3790
3779 - find the revision corresponding to a tag::
3791 - find the revision corresponding to a tag::
3780
3792
3781 hg id -n -r 1.3
3793 hg id -n -r 1.3
3782
3794
3783 - check the most recent revision of a remote repository::
3795 - check the most recent revision of a remote repository::
3784
3796
3785 hg id -r tip https://www.mercurial-scm.org/repo/hg/
3797 hg id -r tip https://www.mercurial-scm.org/repo/hg/
3786
3798
3787 See :hg:`log` for generating more information about specific revisions,
3799 See :hg:`log` for generating more information about specific revisions,
3788 including full hash identifiers.
3800 including full hash identifiers.
3789
3801
3790 Returns 0 if successful.
3802 Returns 0 if successful.
3791 """
3803 """
3792
3804
3793 opts = pycompat.byteskwargs(opts)
3805 opts = pycompat.byteskwargs(opts)
3794 if not repo and not source:
3806 if not repo and not source:
3795 raise error.InputError(
3807 raise error.InputError(
3796 _(b"there is no Mercurial repository here (.hg not found)")
3808 _(b"there is no Mercurial repository here (.hg not found)")
3797 )
3809 )
3798
3810
3799 default = not (num or id or branch or tags or bookmarks)
3811 default = not (num or id or branch or tags or bookmarks)
3800 output = []
3812 output = []
3801 revs = []
3813 revs = []
3802
3814
3803 if source:
3815 if source:
3804 source, branches = hg.parseurl(ui.expandpath(source))
3816 source, branches = hg.parseurl(ui.expandpath(source))
3805 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
3817 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
3806 repo = peer.local()
3818 repo = peer.local()
3807 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
3819 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
3808
3820
3809 fm = ui.formatter(b'identify', opts)
3821 fm = ui.formatter(b'identify', opts)
3810 fm.startitem()
3822 fm.startitem()
3811
3823
3812 if not repo:
3824 if not repo:
3813 if num or branch or tags:
3825 if num or branch or tags:
3814 raise error.InputError(
3826 raise error.InputError(
3815 _(b"can't query remote revision number, branch, or tags")
3827 _(b"can't query remote revision number, branch, or tags")
3816 )
3828 )
3817 if not rev and revs:
3829 if not rev and revs:
3818 rev = revs[0]
3830 rev = revs[0]
3819 if not rev:
3831 if not rev:
3820 rev = b"tip"
3832 rev = b"tip"
3821
3833
3822 remoterev = peer.lookup(rev)
3834 remoterev = peer.lookup(rev)
3823 hexrev = fm.hexfunc(remoterev)
3835 hexrev = fm.hexfunc(remoterev)
3824 if default or id:
3836 if default or id:
3825 output = [hexrev]
3837 output = [hexrev]
3826 fm.data(id=hexrev)
3838 fm.data(id=hexrev)
3827
3839
3828 @util.cachefunc
3840 @util.cachefunc
3829 def getbms():
3841 def getbms():
3830 bms = []
3842 bms = []
3831
3843
3832 if b'bookmarks' in peer.listkeys(b'namespaces'):
3844 if b'bookmarks' in peer.listkeys(b'namespaces'):
3833 hexremoterev = hex(remoterev)
3845 hexremoterev = hex(remoterev)
3834 bms = [
3846 bms = [
3835 bm
3847 bm
3836 for bm, bmr in pycompat.iteritems(
3848 for bm, bmr in pycompat.iteritems(
3837 peer.listkeys(b'bookmarks')
3849 peer.listkeys(b'bookmarks')
3838 )
3850 )
3839 if bmr == hexremoterev
3851 if bmr == hexremoterev
3840 ]
3852 ]
3841
3853
3842 return sorted(bms)
3854 return sorted(bms)
3843
3855
3844 if fm.isplain():
3856 if fm.isplain():
3845 if bookmarks:
3857 if bookmarks:
3846 output.extend(getbms())
3858 output.extend(getbms())
3847 elif default and not ui.quiet:
3859 elif default and not ui.quiet:
3848 # multiple bookmarks for a single parent separated by '/'
3860 # multiple bookmarks for a single parent separated by '/'
3849 bm = b'/'.join(getbms())
3861 bm = b'/'.join(getbms())
3850 if bm:
3862 if bm:
3851 output.append(bm)
3863 output.append(bm)
3852 else:
3864 else:
3853 fm.data(node=hex(remoterev))
3865 fm.data(node=hex(remoterev))
3854 if bookmarks or b'bookmarks' in fm.datahint():
3866 if bookmarks or b'bookmarks' in fm.datahint():
3855 fm.data(bookmarks=fm.formatlist(getbms(), name=b'bookmark'))
3867 fm.data(bookmarks=fm.formatlist(getbms(), name=b'bookmark'))
3856 else:
3868 else:
3857 if rev:
3869 if rev:
3858 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
3870 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
3859 ctx = scmutil.revsingle(repo, rev, None)
3871 ctx = scmutil.revsingle(repo, rev, None)
3860
3872
3861 if ctx.rev() is None:
3873 if ctx.rev() is None:
3862 ctx = repo[None]
3874 ctx = repo[None]
3863 parents = ctx.parents()
3875 parents = ctx.parents()
3864 taglist = []
3876 taglist = []
3865 for p in parents:
3877 for p in parents:
3866 taglist.extend(p.tags())
3878 taglist.extend(p.tags())
3867
3879
3868 dirty = b""
3880 dirty = b""
3869 if ctx.dirty(missing=True, merge=False, branch=False):
3881 if ctx.dirty(missing=True, merge=False, branch=False):
3870 dirty = b'+'
3882 dirty = b'+'
3871 fm.data(dirty=dirty)
3883 fm.data(dirty=dirty)
3872
3884
3873 hexoutput = [fm.hexfunc(p.node()) for p in parents]
3885 hexoutput = [fm.hexfunc(p.node()) for p in parents]
3874 if default or id:
3886 if default or id:
3875 output = [b"%s%s" % (b'+'.join(hexoutput), dirty)]
3887 output = [b"%s%s" % (b'+'.join(hexoutput), dirty)]
3876 fm.data(id=b"%s%s" % (b'+'.join(hexoutput), dirty))
3888 fm.data(id=b"%s%s" % (b'+'.join(hexoutput), dirty))
3877
3889
3878 if num:
3890 if num:
3879 numoutput = [b"%d" % p.rev() for p in parents]
3891 numoutput = [b"%d" % p.rev() for p in parents]
3880 output.append(b"%s%s" % (b'+'.join(numoutput), dirty))
3892 output.append(b"%s%s" % (b'+'.join(numoutput), dirty))
3881
3893
3882 fm.data(
3894 fm.data(
3883 parents=fm.formatlist(
3895 parents=fm.formatlist(
3884 [fm.hexfunc(p.node()) for p in parents], name=b'node'
3896 [fm.hexfunc(p.node()) for p in parents], name=b'node'
3885 )
3897 )
3886 )
3898 )
3887 else:
3899 else:
3888 hexoutput = fm.hexfunc(ctx.node())
3900 hexoutput = fm.hexfunc(ctx.node())
3889 if default or id:
3901 if default or id:
3890 output = [hexoutput]
3902 output = [hexoutput]
3891 fm.data(id=hexoutput)
3903 fm.data(id=hexoutput)
3892
3904
3893 if num:
3905 if num:
3894 output.append(pycompat.bytestr(ctx.rev()))
3906 output.append(pycompat.bytestr(ctx.rev()))
3895 taglist = ctx.tags()
3907 taglist = ctx.tags()
3896
3908
3897 if default and not ui.quiet:
3909 if default and not ui.quiet:
3898 b = ctx.branch()
3910 b = ctx.branch()
3899 if b != b'default':
3911 if b != b'default':
3900 output.append(b"(%s)" % b)
3912 output.append(b"(%s)" % b)
3901
3913
3902 # multiple tags for a single parent separated by '/'
3914 # multiple tags for a single parent separated by '/'
3903 t = b'/'.join(taglist)
3915 t = b'/'.join(taglist)
3904 if t:
3916 if t:
3905 output.append(t)
3917 output.append(t)
3906
3918
3907 # multiple bookmarks for a single parent separated by '/'
3919 # multiple bookmarks for a single parent separated by '/'
3908 bm = b'/'.join(ctx.bookmarks())
3920 bm = b'/'.join(ctx.bookmarks())
3909 if bm:
3921 if bm:
3910 output.append(bm)
3922 output.append(bm)
3911 else:
3923 else:
3912 if branch:
3924 if branch:
3913 output.append(ctx.branch())
3925 output.append(ctx.branch())
3914
3926
3915 if tags:
3927 if tags:
3916 output.extend(taglist)
3928 output.extend(taglist)
3917
3929
3918 if bookmarks:
3930 if bookmarks:
3919 output.extend(ctx.bookmarks())
3931 output.extend(ctx.bookmarks())
3920
3932
3921 fm.data(node=ctx.hex())
3933 fm.data(node=ctx.hex())
3922 fm.data(branch=ctx.branch())
3934 fm.data(branch=ctx.branch())
3923 fm.data(tags=fm.formatlist(taglist, name=b'tag', sep=b':'))
3935 fm.data(tags=fm.formatlist(taglist, name=b'tag', sep=b':'))
3924 fm.data(bookmarks=fm.formatlist(ctx.bookmarks(), name=b'bookmark'))
3936 fm.data(bookmarks=fm.formatlist(ctx.bookmarks(), name=b'bookmark'))
3925 fm.context(ctx=ctx)
3937 fm.context(ctx=ctx)
3926
3938
3927 fm.plain(b"%s\n" % b' '.join(output))
3939 fm.plain(b"%s\n" % b' '.join(output))
3928 fm.end()
3940 fm.end()
3929
3941
3930
3942
3931 @command(
3943 @command(
3932 b'import|patch',
3944 b'import|patch',
3933 [
3945 [
3934 (
3946 (
3935 b'p',
3947 b'p',
3936 b'strip',
3948 b'strip',
3937 1,
3949 1,
3938 _(
3950 _(
3939 b'directory strip option for patch. This has the same '
3951 b'directory strip option for patch. This has the same '
3940 b'meaning as the corresponding patch option'
3952 b'meaning as the corresponding patch option'
3941 ),
3953 ),
3942 _(b'NUM'),
3954 _(b'NUM'),
3943 ),
3955 ),
3944 (b'b', b'base', b'', _(b'base path (DEPRECATED)'), _(b'PATH')),
3956 (b'b', b'base', b'', _(b'base path (DEPRECATED)'), _(b'PATH')),
3945 (b'', b'secret', None, _(b'use the secret phase for committing')),
3957 (b'', b'secret', None, _(b'use the secret phase for committing')),
3946 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
3958 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
3947 (
3959 (
3948 b'f',
3960 b'f',
3949 b'force',
3961 b'force',
3950 None,
3962 None,
3951 _(b'skip check for outstanding uncommitted changes (DEPRECATED)'),
3963 _(b'skip check for outstanding uncommitted changes (DEPRECATED)'),
3952 ),
3964 ),
3953 (
3965 (
3954 b'',
3966 b'',
3955 b'no-commit',
3967 b'no-commit',
3956 None,
3968 None,
3957 _(b"don't commit, just update the working directory"),
3969 _(b"don't commit, just update the working directory"),
3958 ),
3970 ),
3959 (
3971 (
3960 b'',
3972 b'',
3961 b'bypass',
3973 b'bypass',
3962 None,
3974 None,
3963 _(b"apply patch without touching the working directory"),
3975 _(b"apply patch without touching the working directory"),
3964 ),
3976 ),
3965 (b'', b'partial', None, _(b'commit even if some hunks fail')),
3977 (b'', b'partial', None, _(b'commit even if some hunks fail')),
3966 (b'', b'exact', None, _(b'abort if patch would apply lossily')),
3978 (b'', b'exact', None, _(b'abort if patch would apply lossily')),
3967 (b'', b'prefix', b'', _(b'apply patch to subdirectory'), _(b'DIR')),
3979 (b'', b'prefix', b'', _(b'apply patch to subdirectory'), _(b'DIR')),
3968 (
3980 (
3969 b'',
3981 b'',
3970 b'import-branch',
3982 b'import-branch',
3971 None,
3983 None,
3972 _(b'use any branch information in patch (implied by --exact)'),
3984 _(b'use any branch information in patch (implied by --exact)'),
3973 ),
3985 ),
3974 ]
3986 ]
3975 + commitopts
3987 + commitopts
3976 + commitopts2
3988 + commitopts2
3977 + similarityopts,
3989 + similarityopts,
3978 _(b'[OPTION]... PATCH...'),
3990 _(b'[OPTION]... PATCH...'),
3979 helpcategory=command.CATEGORY_IMPORT_EXPORT,
3991 helpcategory=command.CATEGORY_IMPORT_EXPORT,
3980 )
3992 )
3981 def import_(ui, repo, patch1=None, *patches, **opts):
3993 def import_(ui, repo, patch1=None, *patches, **opts):
3982 """import an ordered set of patches
3994 """import an ordered set of patches
3983
3995
3984 Import a list of patches and commit them individually (unless
3996 Import a list of patches and commit them individually (unless
3985 --no-commit is specified).
3997 --no-commit is specified).
3986
3998
3987 To read a patch from standard input (stdin), use "-" as the patch
3999 To read a patch from standard input (stdin), use "-" as the patch
3988 name. If a URL is specified, the patch will be downloaded from
4000 name. If a URL is specified, the patch will be downloaded from
3989 there.
4001 there.
3990
4002
3991 Import first applies changes to the working directory (unless
4003 Import first applies changes to the working directory (unless
3992 --bypass is specified), import will abort if there are outstanding
4004 --bypass is specified), import will abort if there are outstanding
3993 changes.
4005 changes.
3994
4006
3995 Use --bypass to apply and commit patches directly to the
4007 Use --bypass to apply and commit patches directly to the
3996 repository, without affecting the working directory. Without
4008 repository, without affecting the working directory. Without
3997 --exact, patches will be applied on top of the working directory
4009 --exact, patches will be applied on top of the working directory
3998 parent revision.
4010 parent revision.
3999
4011
4000 You can import a patch straight from a mail message. Even patches
4012 You can import a patch straight from a mail message. Even patches
4001 as attachments work (to use the body part, it must have type
4013 as attachments work (to use the body part, it must have type
4002 text/plain or text/x-patch). From and Subject headers of email
4014 text/plain or text/x-patch). From and Subject headers of email
4003 message are used as default committer and commit message. All
4015 message are used as default committer and commit message. All
4004 text/plain body parts before first diff are added to the commit
4016 text/plain body parts before first diff are added to the commit
4005 message.
4017 message.
4006
4018
4007 If the imported patch was generated by :hg:`export`, user and
4019 If the imported patch was generated by :hg:`export`, user and
4008 description from patch override values from message headers and
4020 description from patch override values from message headers and
4009 body. Values given on command line with -m/--message and -u/--user
4021 body. Values given on command line with -m/--message and -u/--user
4010 override these.
4022 override these.
4011
4023
4012 If --exact is specified, import will set the working directory to
4024 If --exact is specified, import will set the working directory to
4013 the parent of each patch before applying it, and will abort if the
4025 the parent of each patch before applying it, and will abort if the
4014 resulting changeset has a different ID than the one recorded in
4026 resulting changeset has a different ID than the one recorded in
4015 the patch. This will guard against various ways that portable
4027 the patch. This will guard against various ways that portable
4016 patch formats and mail systems might fail to transfer Mercurial
4028 patch formats and mail systems might fail to transfer Mercurial
4017 data or metadata. See :hg:`bundle` for lossless transmission.
4029 data or metadata. See :hg:`bundle` for lossless transmission.
4018
4030
4019 Use --partial to ensure a changeset will be created from the patch
4031 Use --partial to ensure a changeset will be created from the patch
4020 even if some hunks fail to apply. Hunks that fail to apply will be
4032 even if some hunks fail to apply. Hunks that fail to apply will be
4021 written to a <target-file>.rej file. Conflicts can then be resolved
4033 written to a <target-file>.rej file. Conflicts can then be resolved
4022 by hand before :hg:`commit --amend` is run to update the created
4034 by hand before :hg:`commit --amend` is run to update the created
4023 changeset. This flag exists to let people import patches that
4035 changeset. This flag exists to let people import patches that
4024 partially apply without losing the associated metadata (author,
4036 partially apply without losing the associated metadata (author,
4025 date, description, ...).
4037 date, description, ...).
4026
4038
4027 .. note::
4039 .. note::
4028
4040
4029 When no hunks apply cleanly, :hg:`import --partial` will create
4041 When no hunks apply cleanly, :hg:`import --partial` will create
4030 an empty changeset, importing only the patch metadata.
4042 an empty changeset, importing only the patch metadata.
4031
4043
4032 With -s/--similarity, hg will attempt to discover renames and
4044 With -s/--similarity, hg will attempt to discover renames and
4033 copies in the patch in the same way as :hg:`addremove`.
4045 copies in the patch in the same way as :hg:`addremove`.
4034
4046
4035 It is possible to use external patch programs to perform the patch
4047 It is possible to use external patch programs to perform the patch
4036 by setting the ``ui.patch`` configuration option. For the default
4048 by setting the ``ui.patch`` configuration option. For the default
4037 internal tool, the fuzz can also be configured via ``patch.fuzz``.
4049 internal tool, the fuzz can also be configured via ``patch.fuzz``.
4038 See :hg:`help config` for more information about configuration
4050 See :hg:`help config` for more information about configuration
4039 files and how to use these options.
4051 files and how to use these options.
4040
4052
4041 See :hg:`help dates` for a list of formats valid for -d/--date.
4053 See :hg:`help dates` for a list of formats valid for -d/--date.
4042
4054
4043 .. container:: verbose
4055 .. container:: verbose
4044
4056
4045 Examples:
4057 Examples:
4046
4058
4047 - import a traditional patch from a website and detect renames::
4059 - import a traditional patch from a website and detect renames::
4048
4060
4049 hg import -s 80 http://example.com/bugfix.patch
4061 hg import -s 80 http://example.com/bugfix.patch
4050
4062
4051 - import a changeset from an hgweb server::
4063 - import a changeset from an hgweb server::
4052
4064
4053 hg import https://www.mercurial-scm.org/repo/hg/rev/5ca8c111e9aa
4065 hg import https://www.mercurial-scm.org/repo/hg/rev/5ca8c111e9aa
4054
4066
4055 - import all the patches in an Unix-style mbox::
4067 - import all the patches in an Unix-style mbox::
4056
4068
4057 hg import incoming-patches.mbox
4069 hg import incoming-patches.mbox
4058
4070
4059 - import patches from stdin::
4071 - import patches from stdin::
4060
4072
4061 hg import -
4073 hg import -
4062
4074
4063 - attempt to exactly restore an exported changeset (not always
4075 - attempt to exactly restore an exported changeset (not always
4064 possible)::
4076 possible)::
4065
4077
4066 hg import --exact proposed-fix.patch
4078 hg import --exact proposed-fix.patch
4067
4079
4068 - use an external tool to apply a patch which is too fuzzy for
4080 - use an external tool to apply a patch which is too fuzzy for
4069 the default internal tool.
4081 the default internal tool.
4070
4082
4071 hg import --config ui.patch="patch --merge" fuzzy.patch
4083 hg import --config ui.patch="patch --merge" fuzzy.patch
4072
4084
4073 - change the default fuzzing from 2 to a less strict 7
4085 - change the default fuzzing from 2 to a less strict 7
4074
4086
4075 hg import --config ui.fuzz=7 fuzz.patch
4087 hg import --config ui.fuzz=7 fuzz.patch
4076
4088
4077 Returns 0 on success, 1 on partial success (see --partial).
4089 Returns 0 on success, 1 on partial success (see --partial).
4078 """
4090 """
4079
4091
4080 cmdutil.check_incompatible_arguments(
4092 cmdutil.check_incompatible_arguments(
4081 opts, 'no_commit', ['bypass', 'secret']
4093 opts, 'no_commit', ['bypass', 'secret']
4082 )
4094 )
4083 cmdutil.check_incompatible_arguments(opts, 'exact', ['edit', 'prefix'])
4095 cmdutil.check_incompatible_arguments(opts, 'exact', ['edit', 'prefix'])
4084 opts = pycompat.byteskwargs(opts)
4096 opts = pycompat.byteskwargs(opts)
4085 if not patch1:
4097 if not patch1:
4086 raise error.InputError(_(b'need at least one patch to import'))
4098 raise error.InputError(_(b'need at least one patch to import'))
4087
4099
4088 patches = (patch1,) + patches
4100 patches = (patch1,) + patches
4089
4101
4090 date = opts.get(b'date')
4102 date = opts.get(b'date')
4091 if date:
4103 if date:
4092 opts[b'date'] = dateutil.parsedate(date)
4104 opts[b'date'] = dateutil.parsedate(date)
4093
4105
4094 exact = opts.get(b'exact')
4106 exact = opts.get(b'exact')
4095 update = not opts.get(b'bypass')
4107 update = not opts.get(b'bypass')
4096 try:
4108 try:
4097 sim = float(opts.get(b'similarity') or 0)
4109 sim = float(opts.get(b'similarity') or 0)
4098 except ValueError:
4110 except ValueError:
4099 raise error.InputError(_(b'similarity must be a number'))
4111 raise error.InputError(_(b'similarity must be a number'))
4100 if sim < 0 or sim > 100:
4112 if sim < 0 or sim > 100:
4101 raise error.InputError(_(b'similarity must be between 0 and 100'))
4113 raise error.InputError(_(b'similarity must be between 0 and 100'))
4102 if sim and not update:
4114 if sim and not update:
4103 raise error.InputError(_(b'cannot use --similarity with --bypass'))
4115 raise error.InputError(_(b'cannot use --similarity with --bypass'))
4104
4116
4105 base = opts[b"base"]
4117 base = opts[b"base"]
4106 msgs = []
4118 msgs = []
4107 ret = 0
4119 ret = 0
4108
4120
4109 with repo.wlock():
4121 with repo.wlock():
4110 if update:
4122 if update:
4111 cmdutil.checkunfinished(repo)
4123 cmdutil.checkunfinished(repo)
4112 if exact or not opts.get(b'force'):
4124 if exact or not opts.get(b'force'):
4113 cmdutil.bailifchanged(repo)
4125 cmdutil.bailifchanged(repo)
4114
4126
4115 if not opts.get(b'no_commit'):
4127 if not opts.get(b'no_commit'):
4116 lock = repo.lock
4128 lock = repo.lock
4117 tr = lambda: repo.transaction(b'import')
4129 tr = lambda: repo.transaction(b'import')
4118 dsguard = util.nullcontextmanager
4130 dsguard = util.nullcontextmanager
4119 else:
4131 else:
4120 lock = util.nullcontextmanager
4132 lock = util.nullcontextmanager
4121 tr = util.nullcontextmanager
4133 tr = util.nullcontextmanager
4122 dsguard = lambda: dirstateguard.dirstateguard(repo, b'import')
4134 dsguard = lambda: dirstateguard.dirstateguard(repo, b'import')
4123 with lock(), tr(), dsguard():
4135 with lock(), tr(), dsguard():
4124 parents = repo[None].parents()
4136 parents = repo[None].parents()
4125 for patchurl in patches:
4137 for patchurl in patches:
4126 if patchurl == b'-':
4138 if patchurl == b'-':
4127 ui.status(_(b'applying patch from stdin\n'))
4139 ui.status(_(b'applying patch from stdin\n'))
4128 patchfile = ui.fin
4140 patchfile = ui.fin
4129 patchurl = b'stdin' # for error message
4141 patchurl = b'stdin' # for error message
4130 else:
4142 else:
4131 patchurl = os.path.join(base, patchurl)
4143 patchurl = os.path.join(base, patchurl)
4132 ui.status(_(b'applying %s\n') % patchurl)
4144 ui.status(_(b'applying %s\n') % patchurl)
4133 patchfile = hg.openpath(ui, patchurl, sendaccept=False)
4145 patchfile = hg.openpath(ui, patchurl, sendaccept=False)
4134
4146
4135 haspatch = False
4147 haspatch = False
4136 for hunk in patch.split(patchfile):
4148 for hunk in patch.split(patchfile):
4137 with patch.extract(ui, hunk) as patchdata:
4149 with patch.extract(ui, hunk) as patchdata:
4138 msg, node, rej = cmdutil.tryimportone(
4150 msg, node, rej = cmdutil.tryimportone(
4139 ui, repo, patchdata, parents, opts, msgs, hg.clean
4151 ui, repo, patchdata, parents, opts, msgs, hg.clean
4140 )
4152 )
4141 if msg:
4153 if msg:
4142 haspatch = True
4154 haspatch = True
4143 ui.note(msg + b'\n')
4155 ui.note(msg + b'\n')
4144 if update or exact:
4156 if update or exact:
4145 parents = repo[None].parents()
4157 parents = repo[None].parents()
4146 else:
4158 else:
4147 parents = [repo[node]]
4159 parents = [repo[node]]
4148 if rej:
4160 if rej:
4149 ui.write_err(_(b"patch applied partially\n"))
4161 ui.write_err(_(b"patch applied partially\n"))
4150 ui.write_err(
4162 ui.write_err(
4151 _(
4163 _(
4152 b"(fix the .rej files and run "
4164 b"(fix the .rej files and run "
4153 b"`hg commit --amend`)\n"
4165 b"`hg commit --amend`)\n"
4154 )
4166 )
4155 )
4167 )
4156 ret = 1
4168 ret = 1
4157 break
4169 break
4158
4170
4159 if not haspatch:
4171 if not haspatch:
4160 raise error.InputError(_(b'%s: no diffs found') % patchurl)
4172 raise error.InputError(_(b'%s: no diffs found') % patchurl)
4161
4173
4162 if msgs:
4174 if msgs:
4163 repo.savecommitmessage(b'\n* * *\n'.join(msgs))
4175 repo.savecommitmessage(b'\n* * *\n'.join(msgs))
4164 return ret
4176 return ret
4165
4177
4166
4178
4167 @command(
4179 @command(
4168 b'incoming|in',
4180 b'incoming|in',
4169 [
4181 [
4170 (
4182 (
4171 b'f',
4183 b'f',
4172 b'force',
4184 b'force',
4173 None,
4185 None,
4174 _(b'run even if remote repository is unrelated'),
4186 _(b'run even if remote repository is unrelated'),
4175 ),
4187 ),
4176 (b'n', b'newest-first', None, _(b'show newest record first')),
4188 (b'n', b'newest-first', None, _(b'show newest record first')),
4177 (b'', b'bundle', b'', _(b'file to store the bundles into'), _(b'FILE')),
4189 (b'', b'bundle', b'', _(b'file to store the bundles into'), _(b'FILE')),
4178 (
4190 (
4179 b'r',
4191 b'r',
4180 b'rev',
4192 b'rev',
4181 [],
4193 [],
4182 _(b'a remote changeset intended to be added'),
4194 _(b'a remote changeset intended to be added'),
4183 _(b'REV'),
4195 _(b'REV'),
4184 ),
4196 ),
4185 (b'B', b'bookmarks', False, _(b"compare bookmarks")),
4197 (b'B', b'bookmarks', False, _(b"compare bookmarks")),
4186 (
4198 (
4187 b'b',
4199 b'b',
4188 b'branch',
4200 b'branch',
4189 [],
4201 [],
4190 _(b'a specific branch you would like to pull'),
4202 _(b'a specific branch you would like to pull'),
4191 _(b'BRANCH'),
4203 _(b'BRANCH'),
4192 ),
4204 ),
4193 ]
4205 ]
4194 + logopts
4206 + logopts
4195 + remoteopts
4207 + remoteopts
4196 + subrepoopts,
4208 + subrepoopts,
4197 _(b'[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'),
4209 _(b'[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'),
4198 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
4210 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
4199 )
4211 )
4200 def incoming(ui, repo, source=b"default", **opts):
4212 def incoming(ui, repo, source=b"default", **opts):
4201 """show new changesets found in source
4213 """show new changesets found in source
4202
4214
4203 Show new changesets found in the specified path/URL or the default
4215 Show new changesets found in the specified path/URL or the default
4204 pull location. These are the changesets that would have been pulled
4216 pull location. These are the changesets that would have been pulled
4205 by :hg:`pull` at the time you issued this command.
4217 by :hg:`pull` at the time you issued this command.
4206
4218
4207 See pull for valid source format details.
4219 See pull for valid source format details.
4208
4220
4209 .. container:: verbose
4221 .. container:: verbose
4210
4222
4211 With -B/--bookmarks, the result of bookmark comparison between
4223 With -B/--bookmarks, the result of bookmark comparison between
4212 local and remote repositories is displayed. With -v/--verbose,
4224 local and remote repositories is displayed. With -v/--verbose,
4213 status is also displayed for each bookmark like below::
4225 status is also displayed for each bookmark like below::
4214
4226
4215 BM1 01234567890a added
4227 BM1 01234567890a added
4216 BM2 1234567890ab advanced
4228 BM2 1234567890ab advanced
4217 BM3 234567890abc diverged
4229 BM3 234567890abc diverged
4218 BM4 34567890abcd changed
4230 BM4 34567890abcd changed
4219
4231
4220 The action taken locally when pulling depends on the
4232 The action taken locally when pulling depends on the
4221 status of each bookmark:
4233 status of each bookmark:
4222
4234
4223 :``added``: pull will create it
4235 :``added``: pull will create it
4224 :``advanced``: pull will update it
4236 :``advanced``: pull will update it
4225 :``diverged``: pull will create a divergent bookmark
4237 :``diverged``: pull will create a divergent bookmark
4226 :``changed``: result depends on remote changesets
4238 :``changed``: result depends on remote changesets
4227
4239
4228 From the point of view of pulling behavior, bookmark
4240 From the point of view of pulling behavior, bookmark
4229 existing only in the remote repository are treated as ``added``,
4241 existing only in the remote repository are treated as ``added``,
4230 even if it is in fact locally deleted.
4242 even if it is in fact locally deleted.
4231
4243
4232 .. container:: verbose
4244 .. container:: verbose
4233
4245
4234 For remote repository, using --bundle avoids downloading the
4246 For remote repository, using --bundle avoids downloading the
4235 changesets twice if the incoming is followed by a pull.
4247 changesets twice if the incoming is followed by a pull.
4236
4248
4237 Examples:
4249 Examples:
4238
4250
4239 - show incoming changes with patches and full description::
4251 - show incoming changes with patches and full description::
4240
4252
4241 hg incoming -vp
4253 hg incoming -vp
4242
4254
4243 - show incoming changes excluding merges, store a bundle::
4255 - show incoming changes excluding merges, store a bundle::
4244
4256
4245 hg in -vpM --bundle incoming.hg
4257 hg in -vpM --bundle incoming.hg
4246 hg pull incoming.hg
4258 hg pull incoming.hg
4247
4259
4248 - briefly list changes inside a bundle::
4260 - briefly list changes inside a bundle::
4249
4261
4250 hg in changes.hg -T "{desc|firstline}\\n"
4262 hg in changes.hg -T "{desc|firstline}\\n"
4251
4263
4252 Returns 0 if there are incoming changes, 1 otherwise.
4264 Returns 0 if there are incoming changes, 1 otherwise.
4253 """
4265 """
4254 opts = pycompat.byteskwargs(opts)
4266 opts = pycompat.byteskwargs(opts)
4255 if opts.get(b'graph'):
4267 if opts.get(b'graph'):
4256 logcmdutil.checkunsupportedgraphflags([], opts)
4268 logcmdutil.checkunsupportedgraphflags([], opts)
4257
4269
4258 def display(other, chlist, displayer):
4270 def display(other, chlist, displayer):
4259 revdag = logcmdutil.graphrevs(other, chlist, opts)
4271 revdag = logcmdutil.graphrevs(other, chlist, opts)
4260 logcmdutil.displaygraph(
4272 logcmdutil.displaygraph(
4261 ui, repo, revdag, displayer, graphmod.asciiedges
4273 ui, repo, revdag, displayer, graphmod.asciiedges
4262 )
4274 )
4263
4275
4264 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
4276 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
4265 return 0
4277 return 0
4266
4278
4267 cmdutil.check_incompatible_arguments(opts, b'subrepos', [b'bundle'])
4279 cmdutil.check_incompatible_arguments(opts, b'subrepos', [b'bundle'])
4268
4280
4269 if opts.get(b'bookmarks'):
4281 if opts.get(b'bookmarks'):
4270 source, branches = hg.parseurl(
4282 source, branches = hg.parseurl(
4271 ui.expandpath(source), opts.get(b'branch')
4283 ui.expandpath(source), opts.get(b'branch')
4272 )
4284 )
4273 other = hg.peer(repo, opts, source)
4285 other = hg.peer(repo, opts, source)
4274 if b'bookmarks' not in other.listkeys(b'namespaces'):
4286 if b'bookmarks' not in other.listkeys(b'namespaces'):
4275 ui.warn(_(b"remote doesn't support bookmarks\n"))
4287 ui.warn(_(b"remote doesn't support bookmarks\n"))
4276 return 0
4288 return 0
4277 ui.pager(b'incoming')
4289 ui.pager(b'incoming')
4278 ui.status(_(b'comparing with %s\n') % util.hidepassword(source))
4290 ui.status(_(b'comparing with %s\n') % util.hidepassword(source))
4279 return bookmarks.incoming(ui, repo, other)
4291 return bookmarks.incoming(ui, repo, other)
4280
4292
4281 repo._subtoppath = ui.expandpath(source)
4293 repo._subtoppath = ui.expandpath(source)
4282 try:
4294 try:
4283 return hg.incoming(ui, repo, source, opts)
4295 return hg.incoming(ui, repo, source, opts)
4284 finally:
4296 finally:
4285 del repo._subtoppath
4297 del repo._subtoppath
4286
4298
4287
4299
4288 @command(
4300 @command(
4289 b'init',
4301 b'init',
4290 remoteopts,
4302 remoteopts,
4291 _(b'[-e CMD] [--remotecmd CMD] [DEST]'),
4303 _(b'[-e CMD] [--remotecmd CMD] [DEST]'),
4292 helpcategory=command.CATEGORY_REPO_CREATION,
4304 helpcategory=command.CATEGORY_REPO_CREATION,
4293 helpbasic=True,
4305 helpbasic=True,
4294 norepo=True,
4306 norepo=True,
4295 )
4307 )
4296 def init(ui, dest=b".", **opts):
4308 def init(ui, dest=b".", **opts):
4297 """create a new repository in the given directory
4309 """create a new repository in the given directory
4298
4310
4299 Initialize a new repository in the given directory. If the given
4311 Initialize a new repository in the given directory. If the given
4300 directory does not exist, it will be created.
4312 directory does not exist, it will be created.
4301
4313
4302 If no directory is given, the current directory is used.
4314 If no directory is given, the current directory is used.
4303
4315
4304 It is possible to specify an ``ssh://`` URL as the destination.
4316 It is possible to specify an ``ssh://`` URL as the destination.
4305 See :hg:`help urls` for more information.
4317 See :hg:`help urls` for more information.
4306
4318
4307 Returns 0 on success.
4319 Returns 0 on success.
4308 """
4320 """
4309 opts = pycompat.byteskwargs(opts)
4321 opts = pycompat.byteskwargs(opts)
4310 hg.peer(ui, opts, ui.expandpath(dest), create=True)
4322 hg.peer(ui, opts, ui.expandpath(dest), create=True)
4311
4323
4312
4324
4313 @command(
4325 @command(
4314 b'locate',
4326 b'locate',
4315 [
4327 [
4316 (
4328 (
4317 b'r',
4329 b'r',
4318 b'rev',
4330 b'rev',
4319 b'',
4331 b'',
4320 _(b'search the repository as it is in REV'),
4332 _(b'search the repository as it is in REV'),
4321 _(b'REV'),
4333 _(b'REV'),
4322 ),
4334 ),
4323 (
4335 (
4324 b'0',
4336 b'0',
4325 b'print0',
4337 b'print0',
4326 None,
4338 None,
4327 _(b'end filenames with NUL, for use with xargs'),
4339 _(b'end filenames with NUL, for use with xargs'),
4328 ),
4340 ),
4329 (
4341 (
4330 b'f',
4342 b'f',
4331 b'fullpath',
4343 b'fullpath',
4332 None,
4344 None,
4333 _(b'print complete paths from the filesystem root'),
4345 _(b'print complete paths from the filesystem root'),
4334 ),
4346 ),
4335 ]
4347 ]
4336 + walkopts,
4348 + walkopts,
4337 _(b'[OPTION]... [PATTERN]...'),
4349 _(b'[OPTION]... [PATTERN]...'),
4338 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
4350 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
4339 )
4351 )
4340 def locate(ui, repo, *pats, **opts):
4352 def locate(ui, repo, *pats, **opts):
4341 """locate files matching specific patterns (DEPRECATED)
4353 """locate files matching specific patterns (DEPRECATED)
4342
4354
4343 Print files under Mercurial control in the working directory whose
4355 Print files under Mercurial control in the working directory whose
4344 names match the given patterns.
4356 names match the given patterns.
4345
4357
4346 By default, this command searches all directories in the working
4358 By default, this command searches all directories in the working
4347 directory. To search just the current directory and its
4359 directory. To search just the current directory and its
4348 subdirectories, use "--include .".
4360 subdirectories, use "--include .".
4349
4361
4350 If no patterns are given to match, this command prints the names
4362 If no patterns are given to match, this command prints the names
4351 of all files under Mercurial control in the working directory.
4363 of all files under Mercurial control in the working directory.
4352
4364
4353 If you want to feed the output of this command into the "xargs"
4365 If you want to feed the output of this command into the "xargs"
4354 command, use the -0 option to both this command and "xargs". This
4366 command, use the -0 option to both this command and "xargs". This
4355 will avoid the problem of "xargs" treating single filenames that
4367 will avoid the problem of "xargs" treating single filenames that
4356 contain whitespace as multiple filenames.
4368 contain whitespace as multiple filenames.
4357
4369
4358 See :hg:`help files` for a more versatile command.
4370 See :hg:`help files` for a more versatile command.
4359
4371
4360 Returns 0 if a match is found, 1 otherwise.
4372 Returns 0 if a match is found, 1 otherwise.
4361 """
4373 """
4362 opts = pycompat.byteskwargs(opts)
4374 opts = pycompat.byteskwargs(opts)
4363 if opts.get(b'print0'):
4375 if opts.get(b'print0'):
4364 end = b'\0'
4376 end = b'\0'
4365 else:
4377 else:
4366 end = b'\n'
4378 end = b'\n'
4367 ctx = scmutil.revsingle(repo, opts.get(b'rev'), None)
4379 ctx = scmutil.revsingle(repo, opts.get(b'rev'), None)
4368
4380
4369 ret = 1
4381 ret = 1
4370 m = scmutil.match(
4382 m = scmutil.match(
4371 ctx, pats, opts, default=b'relglob', badfn=lambda x, y: False
4383 ctx, pats, opts, default=b'relglob', badfn=lambda x, y: False
4372 )
4384 )
4373
4385
4374 ui.pager(b'locate')
4386 ui.pager(b'locate')
4375 if ctx.rev() is None:
4387 if ctx.rev() is None:
4376 # When run on the working copy, "locate" includes removed files, so
4388 # When run on the working copy, "locate" includes removed files, so
4377 # we get the list of files from the dirstate.
4389 # we get the list of files from the dirstate.
4378 filesgen = sorted(repo.dirstate.matches(m))
4390 filesgen = sorted(repo.dirstate.matches(m))
4379 else:
4391 else:
4380 filesgen = ctx.matches(m)
4392 filesgen = ctx.matches(m)
4381 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=bool(pats))
4393 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=bool(pats))
4382 for abs in filesgen:
4394 for abs in filesgen:
4383 if opts.get(b'fullpath'):
4395 if opts.get(b'fullpath'):
4384 ui.write(repo.wjoin(abs), end)
4396 ui.write(repo.wjoin(abs), end)
4385 else:
4397 else:
4386 ui.write(uipathfn(abs), end)
4398 ui.write(uipathfn(abs), end)
4387 ret = 0
4399 ret = 0
4388
4400
4389 return ret
4401 return ret
4390
4402
4391
4403
4392 @command(
4404 @command(
4393 b'log|history',
4405 b'log|history',
4394 [
4406 [
4395 (
4407 (
4396 b'f',
4408 b'f',
4397 b'follow',
4409 b'follow',
4398 None,
4410 None,
4399 _(
4411 _(
4400 b'follow changeset history, or file history across copies and renames'
4412 b'follow changeset history, or file history across copies and renames'
4401 ),
4413 ),
4402 ),
4414 ),
4403 (
4415 (
4404 b'',
4416 b'',
4405 b'follow-first',
4417 b'follow-first',
4406 None,
4418 None,
4407 _(b'only follow the first parent of merge changesets (DEPRECATED)'),
4419 _(b'only follow the first parent of merge changesets (DEPRECATED)'),
4408 ),
4420 ),
4409 (
4421 (
4410 b'd',
4422 b'd',
4411 b'date',
4423 b'date',
4412 b'',
4424 b'',
4413 _(b'show revisions matching date spec'),
4425 _(b'show revisions matching date spec'),
4414 _(b'DATE'),
4426 _(b'DATE'),
4415 ),
4427 ),
4416 (b'C', b'copies', None, _(b'show copied files')),
4428 (b'C', b'copies', None, _(b'show copied files')),
4417 (
4429 (
4418 b'k',
4430 b'k',
4419 b'keyword',
4431 b'keyword',
4420 [],
4432 [],
4421 _(b'do case-insensitive search for a given text'),
4433 _(b'do case-insensitive search for a given text'),
4422 _(b'TEXT'),
4434 _(b'TEXT'),
4423 ),
4435 ),
4424 (
4436 (
4425 b'r',
4437 b'r',
4426 b'rev',
4438 b'rev',
4427 [],
4439 [],
4428 _(b'show the specified revision or revset'),
4440 _(b'show the specified revision or revset'),
4429 _(b'REV'),
4441 _(b'REV'),
4430 ),
4442 ),
4431 (
4443 (
4432 b'L',
4444 b'L',
4433 b'line-range',
4445 b'line-range',
4434 [],
4446 [],
4435 _(b'follow line range of specified file (EXPERIMENTAL)'),
4447 _(b'follow line range of specified file (EXPERIMENTAL)'),
4436 _(b'FILE,RANGE'),
4448 _(b'FILE,RANGE'),
4437 ),
4449 ),
4438 (
4450 (
4439 b'',
4451 b'',
4440 b'removed',
4452 b'removed',
4441 None,
4453 None,
4442 _(b'include revisions where files were removed'),
4454 _(b'include revisions where files were removed'),
4443 ),
4455 ),
4444 (
4456 (
4445 b'm',
4457 b'm',
4446 b'only-merges',
4458 b'only-merges',
4447 None,
4459 None,
4448 _(b'show only merges (DEPRECATED) (use -r "merge()" instead)'),
4460 _(b'show only merges (DEPRECATED) (use -r "merge()" instead)'),
4449 ),
4461 ),
4450 (b'u', b'user', [], _(b'revisions committed by user'), _(b'USER')),
4462 (b'u', b'user', [], _(b'revisions committed by user'), _(b'USER')),
4451 (
4463 (
4452 b'',
4464 b'',
4453 b'only-branch',
4465 b'only-branch',
4454 [],
4466 [],
4455 _(
4467 _(
4456 b'show only changesets within the given named branch (DEPRECATED)'
4468 b'show only changesets within the given named branch (DEPRECATED)'
4457 ),
4469 ),
4458 _(b'BRANCH'),
4470 _(b'BRANCH'),
4459 ),
4471 ),
4460 (
4472 (
4461 b'b',
4473 b'b',
4462 b'branch',
4474 b'branch',
4463 [],
4475 [],
4464 _(b'show changesets within the given named branch'),
4476 _(b'show changesets within the given named branch'),
4465 _(b'BRANCH'),
4477 _(b'BRANCH'),
4466 ),
4478 ),
4467 (
4479 (
4468 b'B',
4480 b'B',
4469 b'bookmark',
4481 b'bookmark',
4470 [],
4482 [],
4471 _(b"show changesets within the given bookmark"),
4483 _(b"show changesets within the given bookmark"),
4472 _(b'BOOKMARK'),
4484 _(b'BOOKMARK'),
4473 ),
4485 ),
4474 (
4486 (
4475 b'P',
4487 b'P',
4476 b'prune',
4488 b'prune',
4477 [],
4489 [],
4478 _(b'do not display revision or any of its ancestors'),
4490 _(b'do not display revision or any of its ancestors'),
4479 _(b'REV'),
4491 _(b'REV'),
4480 ),
4492 ),
4481 ]
4493 ]
4482 + logopts
4494 + logopts
4483 + walkopts,
4495 + walkopts,
4484 _(b'[OPTION]... [FILE]'),
4496 _(b'[OPTION]... [FILE]'),
4485 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
4497 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
4486 helpbasic=True,
4498 helpbasic=True,
4487 inferrepo=True,
4499 inferrepo=True,
4488 intents={INTENT_READONLY},
4500 intents={INTENT_READONLY},
4489 )
4501 )
4490 def log(ui, repo, *pats, **opts):
4502 def log(ui, repo, *pats, **opts):
4491 """show revision history of entire repository or files
4503 """show revision history of entire repository or files
4492
4504
4493 Print the revision history of the specified files or the entire
4505 Print the revision history of the specified files or the entire
4494 project.
4506 project.
4495
4507
4496 If no revision range is specified, the default is ``tip:0`` unless
4508 If no revision range is specified, the default is ``tip:0`` unless
4497 --follow is set, in which case the working directory parent is
4509 --follow is set, in which case the working directory parent is
4498 used as the starting revision.
4510 used as the starting revision.
4499
4511
4500 File history is shown without following rename or copy history of
4512 File history is shown without following rename or copy history of
4501 files. Use -f/--follow with a filename to follow history across
4513 files. Use -f/--follow with a filename to follow history across
4502 renames and copies. --follow without a filename will only show
4514 renames and copies. --follow without a filename will only show
4503 ancestors of the starting revision.
4515 ancestors of the starting revision.
4504
4516
4505 By default this command prints revision number and changeset id,
4517 By default this command prints revision number and changeset id,
4506 tags, non-trivial parents, user, date and time, and a summary for
4518 tags, non-trivial parents, user, date and time, and a summary for
4507 each commit. When the -v/--verbose switch is used, the list of
4519 each commit. When the -v/--verbose switch is used, the list of
4508 changed files and full commit message are shown.
4520 changed files and full commit message are shown.
4509
4521
4510 With --graph the revisions are shown as an ASCII art DAG with the most
4522 With --graph the revisions are shown as an ASCII art DAG with the most
4511 recent changeset at the top.
4523 recent changeset at the top.
4512 'o' is a changeset, '@' is a working directory parent, '%' is a changeset
4524 'o' is a changeset, '@' is a working directory parent, '%' is a changeset
4513 involved in an unresolved merge conflict, '_' closes a branch,
4525 involved in an unresolved merge conflict, '_' closes a branch,
4514 'x' is obsolete, '*' is unstable, and '+' represents a fork where the
4526 'x' is obsolete, '*' is unstable, and '+' represents a fork where the
4515 changeset from the lines below is a parent of the 'o' merge on the same
4527 changeset from the lines below is a parent of the 'o' merge on the same
4516 line.
4528 line.
4517 Paths in the DAG are represented with '|', '/' and so forth. ':' in place
4529 Paths in the DAG are represented with '|', '/' and so forth. ':' in place
4518 of a '|' indicates one or more revisions in a path are omitted.
4530 of a '|' indicates one or more revisions in a path are omitted.
4519
4531
4520 .. container:: verbose
4532 .. container:: verbose
4521
4533
4522 Use -L/--line-range FILE,M:N options to follow the history of lines
4534 Use -L/--line-range FILE,M:N options to follow the history of lines
4523 from M to N in FILE. With -p/--patch only diff hunks affecting
4535 from M to N in FILE. With -p/--patch only diff hunks affecting
4524 specified line range will be shown. This option requires --follow;
4536 specified line range will be shown. This option requires --follow;
4525 it can be specified multiple times. Currently, this option is not
4537 it can be specified multiple times. Currently, this option is not
4526 compatible with --graph. This option is experimental.
4538 compatible with --graph. This option is experimental.
4527
4539
4528 .. note::
4540 .. note::
4529
4541
4530 :hg:`log --patch` may generate unexpected diff output for merge
4542 :hg:`log --patch` may generate unexpected diff output for merge
4531 changesets, as it will only compare the merge changeset against
4543 changesets, as it will only compare the merge changeset against
4532 its first parent. Also, only files different from BOTH parents
4544 its first parent. Also, only files different from BOTH parents
4533 will appear in files:.
4545 will appear in files:.
4534
4546
4535 .. note::
4547 .. note::
4536
4548
4537 For performance reasons, :hg:`log FILE` may omit duplicate changes
4549 For performance reasons, :hg:`log FILE` may omit duplicate changes
4538 made on branches and will not show removals or mode changes. To
4550 made on branches and will not show removals or mode changes. To
4539 see all such changes, use the --removed switch.
4551 see all such changes, use the --removed switch.
4540
4552
4541 .. container:: verbose
4553 .. container:: verbose
4542
4554
4543 .. note::
4555 .. note::
4544
4556
4545 The history resulting from -L/--line-range options depends on diff
4557 The history resulting from -L/--line-range options depends on diff
4546 options; for instance if white-spaces are ignored, respective changes
4558 options; for instance if white-spaces are ignored, respective changes
4547 with only white-spaces in specified line range will not be listed.
4559 with only white-spaces in specified line range will not be listed.
4548
4560
4549 .. container:: verbose
4561 .. container:: verbose
4550
4562
4551 Some examples:
4563 Some examples:
4552
4564
4553 - changesets with full descriptions and file lists::
4565 - changesets with full descriptions and file lists::
4554
4566
4555 hg log -v
4567 hg log -v
4556
4568
4557 - changesets ancestral to the working directory::
4569 - changesets ancestral to the working directory::
4558
4570
4559 hg log -f
4571 hg log -f
4560
4572
4561 - last 10 commits on the current branch::
4573 - last 10 commits on the current branch::
4562
4574
4563 hg log -l 10 -b .
4575 hg log -l 10 -b .
4564
4576
4565 - changesets showing all modifications of a file, including removals::
4577 - changesets showing all modifications of a file, including removals::
4566
4578
4567 hg log --removed file.c
4579 hg log --removed file.c
4568
4580
4569 - all changesets that touch a directory, with diffs, excluding merges::
4581 - all changesets that touch a directory, with diffs, excluding merges::
4570
4582
4571 hg log -Mp lib/
4583 hg log -Mp lib/
4572
4584
4573 - all revision numbers that match a keyword::
4585 - all revision numbers that match a keyword::
4574
4586
4575 hg log -k bug --template "{rev}\\n"
4587 hg log -k bug --template "{rev}\\n"
4576
4588
4577 - the full hash identifier of the working directory parent::
4589 - the full hash identifier of the working directory parent::
4578
4590
4579 hg log -r . --template "{node}\\n"
4591 hg log -r . --template "{node}\\n"
4580
4592
4581 - list available log templates::
4593 - list available log templates::
4582
4594
4583 hg log -T list
4595 hg log -T list
4584
4596
4585 - check if a given changeset is included in a tagged release::
4597 - check if a given changeset is included in a tagged release::
4586
4598
4587 hg log -r "a21ccf and ancestor(1.9)"
4599 hg log -r "a21ccf and ancestor(1.9)"
4588
4600
4589 - find all changesets by some user in a date range::
4601 - find all changesets by some user in a date range::
4590
4602
4591 hg log -k alice -d "may 2008 to jul 2008"
4603 hg log -k alice -d "may 2008 to jul 2008"
4592
4604
4593 - summary of all changesets after the last tag::
4605 - summary of all changesets after the last tag::
4594
4606
4595 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4607 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4596
4608
4597 - changesets touching lines 13 to 23 for file.c::
4609 - changesets touching lines 13 to 23 for file.c::
4598
4610
4599 hg log -L file.c,13:23
4611 hg log -L file.c,13:23
4600
4612
4601 - changesets touching lines 13 to 23 for file.c and lines 2 to 6 of
4613 - changesets touching lines 13 to 23 for file.c and lines 2 to 6 of
4602 main.c with patch::
4614 main.c with patch::
4603
4615
4604 hg log -L file.c,13:23 -L main.c,2:6 -p
4616 hg log -L file.c,13:23 -L main.c,2:6 -p
4605
4617
4606 See :hg:`help dates` for a list of formats valid for -d/--date.
4618 See :hg:`help dates` for a list of formats valid for -d/--date.
4607
4619
4608 See :hg:`help revisions` for more about specifying and ordering
4620 See :hg:`help revisions` for more about specifying and ordering
4609 revisions.
4621 revisions.
4610
4622
4611 See :hg:`help templates` for more about pre-packaged styles and
4623 See :hg:`help templates` for more about pre-packaged styles and
4612 specifying custom templates. The default template used by the log
4624 specifying custom templates. The default template used by the log
4613 command can be customized via the ``command-templates.log`` configuration
4625 command can be customized via the ``command-templates.log`` configuration
4614 setting.
4626 setting.
4615
4627
4616 Returns 0 on success.
4628 Returns 0 on success.
4617
4629
4618 """
4630 """
4619 opts = pycompat.byteskwargs(opts)
4631 opts = pycompat.byteskwargs(opts)
4620 linerange = opts.get(b'line_range')
4632 linerange = opts.get(b'line_range')
4621
4633
4622 if linerange and not opts.get(b'follow'):
4634 if linerange and not opts.get(b'follow'):
4623 raise error.InputError(_(b'--line-range requires --follow'))
4635 raise error.InputError(_(b'--line-range requires --follow'))
4624
4636
4625 if linerange and pats:
4637 if linerange and pats:
4626 # TODO: take pats as patterns with no line-range filter
4638 # TODO: take pats as patterns with no line-range filter
4627 raise error.InputError(
4639 raise error.InputError(
4628 _(b'FILE arguments are not compatible with --line-range option')
4640 _(b'FILE arguments are not compatible with --line-range option')
4629 )
4641 )
4630
4642
4631 repo = scmutil.unhidehashlikerevs(repo, opts.get(b'rev'), b'nowarn')
4643 repo = scmutil.unhidehashlikerevs(repo, opts.get(b'rev'), b'nowarn')
4632 walk_opts = logcmdutil.parseopts(ui, pats, opts)
4644 walk_opts = logcmdutil.parseopts(ui, pats, opts)
4633 revs, differ = logcmdutil.getrevs(repo, walk_opts)
4645 revs, differ = logcmdutil.getrevs(repo, walk_opts)
4634 if linerange:
4646 if linerange:
4635 # TODO: should follow file history from logcmdutil._initialrevs(),
4647 # TODO: should follow file history from logcmdutil._initialrevs(),
4636 # then filter the result by logcmdutil._makerevset() and --limit
4648 # then filter the result by logcmdutil._makerevset() and --limit
4637 revs, differ = logcmdutil.getlinerangerevs(repo, revs, opts)
4649 revs, differ = logcmdutil.getlinerangerevs(repo, revs, opts)
4638
4650
4639 getcopies = None
4651 getcopies = None
4640 if opts.get(b'copies'):
4652 if opts.get(b'copies'):
4641 endrev = None
4653 endrev = None
4642 if revs:
4654 if revs:
4643 endrev = revs.max() + 1
4655 endrev = revs.max() + 1
4644 getcopies = scmutil.getcopiesfn(repo, endrev=endrev)
4656 getcopies = scmutil.getcopiesfn(repo, endrev=endrev)
4645
4657
4646 ui.pager(b'log')
4658 ui.pager(b'log')
4647 displayer = logcmdutil.changesetdisplayer(
4659 displayer = logcmdutil.changesetdisplayer(
4648 ui, repo, opts, differ, buffered=True
4660 ui, repo, opts, differ, buffered=True
4649 )
4661 )
4650 if opts.get(b'graph'):
4662 if opts.get(b'graph'):
4651 displayfn = logcmdutil.displaygraphrevs
4663 displayfn = logcmdutil.displaygraphrevs
4652 else:
4664 else:
4653 displayfn = logcmdutil.displayrevs
4665 displayfn = logcmdutil.displayrevs
4654 displayfn(ui, repo, revs, displayer, getcopies)
4666 displayfn(ui, repo, revs, displayer, getcopies)
4655
4667
4656
4668
4657 @command(
4669 @command(
4658 b'manifest',
4670 b'manifest',
4659 [
4671 [
4660 (b'r', b'rev', b'', _(b'revision to display'), _(b'REV')),
4672 (b'r', b'rev', b'', _(b'revision to display'), _(b'REV')),
4661 (b'', b'all', False, _(b"list files from all revisions")),
4673 (b'', b'all', False, _(b"list files from all revisions")),
4662 ]
4674 ]
4663 + formatteropts,
4675 + formatteropts,
4664 _(b'[-r REV]'),
4676 _(b'[-r REV]'),
4665 helpcategory=command.CATEGORY_MAINTENANCE,
4677 helpcategory=command.CATEGORY_MAINTENANCE,
4666 intents={INTENT_READONLY},
4678 intents={INTENT_READONLY},
4667 )
4679 )
4668 def manifest(ui, repo, node=None, rev=None, **opts):
4680 def manifest(ui, repo, node=None, rev=None, **opts):
4669 """output the current or given revision of the project manifest
4681 """output the current or given revision of the project manifest
4670
4682
4671 Print a list of version controlled files for the given revision.
4683 Print a list of version controlled files for the given revision.
4672 If no revision is given, the first parent of the working directory
4684 If no revision is given, the first parent of the working directory
4673 is used, or the null revision if no revision is checked out.
4685 is used, or the null revision if no revision is checked out.
4674
4686
4675 With -v, print file permissions, symlink and executable bits.
4687 With -v, print file permissions, symlink and executable bits.
4676 With --debug, print file revision hashes.
4688 With --debug, print file revision hashes.
4677
4689
4678 If option --all is specified, the list of all files from all revisions
4690 If option --all is specified, the list of all files from all revisions
4679 is printed. This includes deleted and renamed files.
4691 is printed. This includes deleted and renamed files.
4680
4692
4681 Returns 0 on success.
4693 Returns 0 on success.
4682 """
4694 """
4683 opts = pycompat.byteskwargs(opts)
4695 opts = pycompat.byteskwargs(opts)
4684 fm = ui.formatter(b'manifest', opts)
4696 fm = ui.formatter(b'manifest', opts)
4685
4697
4686 if opts.get(b'all'):
4698 if opts.get(b'all'):
4687 if rev or node:
4699 if rev or node:
4688 raise error.InputError(_(b"can't specify a revision with --all"))
4700 raise error.InputError(_(b"can't specify a revision with --all"))
4689
4701
4690 res = set()
4702 res = set()
4691 for rev in repo:
4703 for rev in repo:
4692 ctx = repo[rev]
4704 ctx = repo[rev]
4693 res |= set(ctx.files())
4705 res |= set(ctx.files())
4694
4706
4695 ui.pager(b'manifest')
4707 ui.pager(b'manifest')
4696 for f in sorted(res):
4708 for f in sorted(res):
4697 fm.startitem()
4709 fm.startitem()
4698 fm.write(b"path", b'%s\n', f)
4710 fm.write(b"path", b'%s\n', f)
4699 fm.end()
4711 fm.end()
4700 return
4712 return
4701
4713
4702 if rev and node:
4714 if rev and node:
4703 raise error.InputError(_(b"please specify just one revision"))
4715 raise error.InputError(_(b"please specify just one revision"))
4704
4716
4705 if not node:
4717 if not node:
4706 node = rev
4718 node = rev
4707
4719
4708 char = {b'l': b'@', b'x': b'*', b'': b'', b't': b'd'}
4720 char = {b'l': b'@', b'x': b'*', b'': b'', b't': b'd'}
4709 mode = {b'l': b'644', b'x': b'755', b'': b'644', b't': b'755'}
4721 mode = {b'l': b'644', b'x': b'755', b'': b'644', b't': b'755'}
4710 if node:
4722 if node:
4711 repo = scmutil.unhidehashlikerevs(repo, [node], b'nowarn')
4723 repo = scmutil.unhidehashlikerevs(repo, [node], b'nowarn')
4712 ctx = scmutil.revsingle(repo, node)
4724 ctx = scmutil.revsingle(repo, node)
4713 mf = ctx.manifest()
4725 mf = ctx.manifest()
4714 ui.pager(b'manifest')
4726 ui.pager(b'manifest')
4715 for f in ctx:
4727 for f in ctx:
4716 fm.startitem()
4728 fm.startitem()
4717 fm.context(ctx=ctx)
4729 fm.context(ctx=ctx)
4718 fl = ctx[f].flags()
4730 fl = ctx[f].flags()
4719 fm.condwrite(ui.debugflag, b'hash', b'%s ', hex(mf[f]))
4731 fm.condwrite(ui.debugflag, b'hash', b'%s ', hex(mf[f]))
4720 fm.condwrite(ui.verbose, b'mode type', b'%s %1s ', mode[fl], char[fl])
4732 fm.condwrite(ui.verbose, b'mode type', b'%s %1s ', mode[fl], char[fl])
4721 fm.write(b'path', b'%s\n', f)
4733 fm.write(b'path', b'%s\n', f)
4722 fm.end()
4734 fm.end()
4723
4735
4724
4736
4725 @command(
4737 @command(
4726 b'merge',
4738 b'merge',
4727 [
4739 [
4728 (
4740 (
4729 b'f',
4741 b'f',
4730 b'force',
4742 b'force',
4731 None,
4743 None,
4732 _(b'force a merge including outstanding changes (DEPRECATED)'),
4744 _(b'force a merge including outstanding changes (DEPRECATED)'),
4733 ),
4745 ),
4734 (b'r', b'rev', b'', _(b'revision to merge'), _(b'REV')),
4746 (b'r', b'rev', b'', _(b'revision to merge'), _(b'REV')),
4735 (
4747 (
4736 b'P',
4748 b'P',
4737 b'preview',
4749 b'preview',
4738 None,
4750 None,
4739 _(b'review revisions to merge (no merge is performed)'),
4751 _(b'review revisions to merge (no merge is performed)'),
4740 ),
4752 ),
4741 (b'', b'abort', None, _(b'abort the ongoing merge')),
4753 (b'', b'abort', None, _(b'abort the ongoing merge')),
4742 ]
4754 ]
4743 + mergetoolopts,
4755 + mergetoolopts,
4744 _(b'[-P] [[-r] REV]'),
4756 _(b'[-P] [[-r] REV]'),
4745 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
4757 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
4746 helpbasic=True,
4758 helpbasic=True,
4747 )
4759 )
4748 def merge(ui, repo, node=None, **opts):
4760 def merge(ui, repo, node=None, **opts):
4749 """merge another revision into working directory
4761 """merge another revision into working directory
4750
4762
4751 The current working directory is updated with all changes made in
4763 The current working directory is updated with all changes made in
4752 the requested revision since the last common predecessor revision.
4764 the requested revision since the last common predecessor revision.
4753
4765
4754 Files that changed between either parent are marked as changed for
4766 Files that changed between either parent are marked as changed for
4755 the next commit and a commit must be performed before any further
4767 the next commit and a commit must be performed before any further
4756 updates to the repository are allowed. The next commit will have
4768 updates to the repository are allowed. The next commit will have
4757 two parents.
4769 two parents.
4758
4770
4759 ``--tool`` can be used to specify the merge tool used for file
4771 ``--tool`` can be used to specify the merge tool used for file
4760 merges. It overrides the HGMERGE environment variable and your
4772 merges. It overrides the HGMERGE environment variable and your
4761 configuration files. See :hg:`help merge-tools` for options.
4773 configuration files. See :hg:`help merge-tools` for options.
4762
4774
4763 If no revision is specified, the working directory's parent is a
4775 If no revision is specified, the working directory's parent is a
4764 head revision, and the current branch contains exactly one other
4776 head revision, and the current branch contains exactly one other
4765 head, the other head is merged with by default. Otherwise, an
4777 head, the other head is merged with by default. Otherwise, an
4766 explicit revision with which to merge must be provided.
4778 explicit revision with which to merge must be provided.
4767
4779
4768 See :hg:`help resolve` for information on handling file conflicts.
4780 See :hg:`help resolve` for information on handling file conflicts.
4769
4781
4770 To undo an uncommitted merge, use :hg:`merge --abort` which
4782 To undo an uncommitted merge, use :hg:`merge --abort` which
4771 will check out a clean copy of the original merge parent, losing
4783 will check out a clean copy of the original merge parent, losing
4772 all changes.
4784 all changes.
4773
4785
4774 Returns 0 on success, 1 if there are unresolved files.
4786 Returns 0 on success, 1 if there are unresolved files.
4775 """
4787 """
4776
4788
4777 opts = pycompat.byteskwargs(opts)
4789 opts = pycompat.byteskwargs(opts)
4778 abort = opts.get(b'abort')
4790 abort = opts.get(b'abort')
4779 if abort and repo.dirstate.p2() == nullid:
4791 if abort and repo.dirstate.p2() == nullid:
4780 cmdutil.wrongtooltocontinue(repo, _(b'merge'))
4792 cmdutil.wrongtooltocontinue(repo, _(b'merge'))
4781 cmdutil.check_incompatible_arguments(opts, b'abort', [b'rev', b'preview'])
4793 cmdutil.check_incompatible_arguments(opts, b'abort', [b'rev', b'preview'])
4782 if abort:
4794 if abort:
4783 state = cmdutil.getunfinishedstate(repo)
4795 state = cmdutil.getunfinishedstate(repo)
4784 if state and state._opname != b'merge':
4796 if state and state._opname != b'merge':
4785 raise error.StateError(
4797 raise error.StateError(
4786 _(b'cannot abort merge with %s in progress') % (state._opname),
4798 _(b'cannot abort merge with %s in progress') % (state._opname),
4787 hint=state.hint(),
4799 hint=state.hint(),
4788 )
4800 )
4789 if node:
4801 if node:
4790 raise error.InputError(_(b"cannot specify a node with --abort"))
4802 raise error.InputError(_(b"cannot specify a node with --abort"))
4791 return hg.abortmerge(repo.ui, repo)
4803 return hg.abortmerge(repo.ui, repo)
4792
4804
4793 if opts.get(b'rev') and node:
4805 if opts.get(b'rev') and node:
4794 raise error.InputError(_(b"please specify just one revision"))
4806 raise error.InputError(_(b"please specify just one revision"))
4795 if not node:
4807 if not node:
4796 node = opts.get(b'rev')
4808 node = opts.get(b'rev')
4797
4809
4798 if node:
4810 if node:
4799 ctx = scmutil.revsingle(repo, node)
4811 ctx = scmutil.revsingle(repo, node)
4800 else:
4812 else:
4801 if ui.configbool(b'commands', b'merge.require-rev'):
4813 if ui.configbool(b'commands', b'merge.require-rev'):
4802 raise error.InputError(
4814 raise error.InputError(
4803 _(
4815 _(
4804 b'configuration requires specifying revision to merge '
4816 b'configuration requires specifying revision to merge '
4805 b'with'
4817 b'with'
4806 )
4818 )
4807 )
4819 )
4808 ctx = repo[destutil.destmerge(repo)]
4820 ctx = repo[destutil.destmerge(repo)]
4809
4821
4810 if ctx.node() is None:
4822 if ctx.node() is None:
4811 raise error.InputError(
4823 raise error.InputError(
4812 _(b'merging with the working copy has no effect')
4824 _(b'merging with the working copy has no effect')
4813 )
4825 )
4814
4826
4815 if opts.get(b'preview'):
4827 if opts.get(b'preview'):
4816 # find nodes that are ancestors of p2 but not of p1
4828 # find nodes that are ancestors of p2 but not of p1
4817 p1 = repo[b'.'].node()
4829 p1 = repo[b'.'].node()
4818 p2 = ctx.node()
4830 p2 = ctx.node()
4819 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4831 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4820
4832
4821 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
4833 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
4822 for node in nodes:
4834 for node in nodes:
4823 displayer.show(repo[node])
4835 displayer.show(repo[node])
4824 displayer.close()
4836 displayer.close()
4825 return 0
4837 return 0
4826
4838
4827 # ui.forcemerge is an internal variable, do not document
4839 # ui.forcemerge is an internal variable, do not document
4828 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
4840 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
4829 with ui.configoverride(overrides, b'merge'):
4841 with ui.configoverride(overrides, b'merge'):
4830 force = opts.get(b'force')
4842 force = opts.get(b'force')
4831 labels = [b'working copy', b'merge rev']
4843 labels = [b'working copy', b'merge rev']
4832 return hg.merge(ctx, force=force, labels=labels)
4844 return hg.merge(ctx, force=force, labels=labels)
4833
4845
4834
4846
4835 statemod.addunfinished(
4847 statemod.addunfinished(
4836 b'merge',
4848 b'merge',
4837 fname=None,
4849 fname=None,
4838 clearable=True,
4850 clearable=True,
4839 allowcommit=True,
4851 allowcommit=True,
4840 cmdmsg=_(b'outstanding uncommitted merge'),
4852 cmdmsg=_(b'outstanding uncommitted merge'),
4841 abortfunc=hg.abortmerge,
4853 abortfunc=hg.abortmerge,
4842 statushint=_(
4854 statushint=_(
4843 b'To continue: hg commit\nTo abort: hg merge --abort'
4855 b'To continue: hg commit\nTo abort: hg merge --abort'
4844 ),
4856 ),
4845 cmdhint=_(b"use 'hg commit' or 'hg merge --abort'"),
4857 cmdhint=_(b"use 'hg commit' or 'hg merge --abort'"),
4846 )
4858 )
4847
4859
4848
4860
4849 @command(
4861 @command(
4850 b'outgoing|out',
4862 b'outgoing|out',
4851 [
4863 [
4852 (
4864 (
4853 b'f',
4865 b'f',
4854 b'force',
4866 b'force',
4855 None,
4867 None,
4856 _(b'run even when the destination is unrelated'),
4868 _(b'run even when the destination is unrelated'),
4857 ),
4869 ),
4858 (
4870 (
4859 b'r',
4871 b'r',
4860 b'rev',
4872 b'rev',
4861 [],
4873 [],
4862 _(b'a changeset intended to be included in the destination'),
4874 _(b'a changeset intended to be included in the destination'),
4863 _(b'REV'),
4875 _(b'REV'),
4864 ),
4876 ),
4865 (b'n', b'newest-first', None, _(b'show newest record first')),
4877 (b'n', b'newest-first', None, _(b'show newest record first')),
4866 (b'B', b'bookmarks', False, _(b'compare bookmarks')),
4878 (b'B', b'bookmarks', False, _(b'compare bookmarks')),
4867 (
4879 (
4868 b'b',
4880 b'b',
4869 b'branch',
4881 b'branch',
4870 [],
4882 [],
4871 _(b'a specific branch you would like to push'),
4883 _(b'a specific branch you would like to push'),
4872 _(b'BRANCH'),
4884 _(b'BRANCH'),
4873 ),
4885 ),
4874 ]
4886 ]
4875 + logopts
4887 + logopts
4876 + remoteopts
4888 + remoteopts
4877 + subrepoopts,
4889 + subrepoopts,
4878 _(b'[-M] [-p] [-n] [-f] [-r REV]... [DEST]'),
4890 _(b'[-M] [-p] [-n] [-f] [-r REV]... [DEST]'),
4879 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
4891 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
4880 )
4892 )
4881 def outgoing(ui, repo, dest=None, **opts):
4893 def outgoing(ui, repo, dest=None, **opts):
4882 """show changesets not found in the destination
4894 """show changesets not found in the destination
4883
4895
4884 Show changesets not found in the specified destination repository
4896 Show changesets not found in the specified destination repository
4885 or the default push location. These are the changesets that would
4897 or the default push location. These are the changesets that would
4886 be pushed if a push was requested.
4898 be pushed if a push was requested.
4887
4899
4888 See pull for details of valid destination formats.
4900 See pull for details of valid destination formats.
4889
4901
4890 .. container:: verbose
4902 .. container:: verbose
4891
4903
4892 With -B/--bookmarks, the result of bookmark comparison between
4904 With -B/--bookmarks, the result of bookmark comparison between
4893 local and remote repositories is displayed. With -v/--verbose,
4905 local and remote repositories is displayed. With -v/--verbose,
4894 status is also displayed for each bookmark like below::
4906 status is also displayed for each bookmark like below::
4895
4907
4896 BM1 01234567890a added
4908 BM1 01234567890a added
4897 BM2 deleted
4909 BM2 deleted
4898 BM3 234567890abc advanced
4910 BM3 234567890abc advanced
4899 BM4 34567890abcd diverged
4911 BM4 34567890abcd diverged
4900 BM5 4567890abcde changed
4912 BM5 4567890abcde changed
4901
4913
4902 The action taken when pushing depends on the
4914 The action taken when pushing depends on the
4903 status of each bookmark:
4915 status of each bookmark:
4904
4916
4905 :``added``: push with ``-B`` will create it
4917 :``added``: push with ``-B`` will create it
4906 :``deleted``: push with ``-B`` will delete it
4918 :``deleted``: push with ``-B`` will delete it
4907 :``advanced``: push will update it
4919 :``advanced``: push will update it
4908 :``diverged``: push with ``-B`` will update it
4920 :``diverged``: push with ``-B`` will update it
4909 :``changed``: push with ``-B`` will update it
4921 :``changed``: push with ``-B`` will update it
4910
4922
4911 From the point of view of pushing behavior, bookmarks
4923 From the point of view of pushing behavior, bookmarks
4912 existing only in the remote repository are treated as
4924 existing only in the remote repository are treated as
4913 ``deleted``, even if it is in fact added remotely.
4925 ``deleted``, even if it is in fact added remotely.
4914
4926
4915 Returns 0 if there are outgoing changes, 1 otherwise.
4927 Returns 0 if there are outgoing changes, 1 otherwise.
4916 """
4928 """
4917 # hg._outgoing() needs to re-resolve the path in order to handle #branch
4929 # hg._outgoing() needs to re-resolve the path in order to handle #branch
4918 # style URLs, so don't overwrite dest.
4930 # style URLs, so don't overwrite dest.
4919 path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
4931 path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
4920 if not path:
4932 if not path:
4921 raise error.ConfigError(
4933 raise error.ConfigError(
4922 _(b'default repository not configured!'),
4934 _(b'default repository not configured!'),
4923 hint=_(b"see 'hg help config.paths'"),
4935 hint=_(b"see 'hg help config.paths'"),
4924 )
4936 )
4925
4937
4926 opts = pycompat.byteskwargs(opts)
4938 opts = pycompat.byteskwargs(opts)
4927 if opts.get(b'graph'):
4939 if opts.get(b'graph'):
4928 logcmdutil.checkunsupportedgraphflags([], opts)
4940 logcmdutil.checkunsupportedgraphflags([], opts)
4929 o, other = hg._outgoing(ui, repo, dest, opts)
4941 o, other = hg._outgoing(ui, repo, dest, opts)
4930 if not o:
4942 if not o:
4931 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4943 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4932 return
4944 return
4933
4945
4934 revdag = logcmdutil.graphrevs(repo, o, opts)
4946 revdag = logcmdutil.graphrevs(repo, o, opts)
4935 ui.pager(b'outgoing')
4947 ui.pager(b'outgoing')
4936 displayer = logcmdutil.changesetdisplayer(ui, repo, opts, buffered=True)
4948 displayer = logcmdutil.changesetdisplayer(ui, repo, opts, buffered=True)
4937 logcmdutil.displaygraph(
4949 logcmdutil.displaygraph(
4938 ui, repo, revdag, displayer, graphmod.asciiedges
4950 ui, repo, revdag, displayer, graphmod.asciiedges
4939 )
4951 )
4940 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4952 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4941 return 0
4953 return 0
4942
4954
4943 if opts.get(b'bookmarks'):
4955 if opts.get(b'bookmarks'):
4944 dest = path.pushloc or path.loc
4956 dest = path.pushloc or path.loc
4945 other = hg.peer(repo, opts, dest)
4957 other = hg.peer(repo, opts, dest)
4946 if b'bookmarks' not in other.listkeys(b'namespaces'):
4958 if b'bookmarks' not in other.listkeys(b'namespaces'):
4947 ui.warn(_(b"remote doesn't support bookmarks\n"))
4959 ui.warn(_(b"remote doesn't support bookmarks\n"))
4948 return 0
4960 return 0
4949 ui.status(_(b'comparing with %s\n') % util.hidepassword(dest))
4961 ui.status(_(b'comparing with %s\n') % util.hidepassword(dest))
4950 ui.pager(b'outgoing')
4962 ui.pager(b'outgoing')
4951 return bookmarks.outgoing(ui, repo, other)
4963 return bookmarks.outgoing(ui, repo, other)
4952
4964
4953 repo._subtoppath = path.pushloc or path.loc
4965 repo._subtoppath = path.pushloc or path.loc
4954 try:
4966 try:
4955 return hg.outgoing(ui, repo, dest, opts)
4967 return hg.outgoing(ui, repo, dest, opts)
4956 finally:
4968 finally:
4957 del repo._subtoppath
4969 del repo._subtoppath
4958
4970
4959
4971
4960 @command(
4972 @command(
4961 b'parents',
4973 b'parents',
4962 [
4974 [
4963 (
4975 (
4964 b'r',
4976 b'r',
4965 b'rev',
4977 b'rev',
4966 b'',
4978 b'',
4967 _(b'show parents of the specified revision'),
4979 _(b'show parents of the specified revision'),
4968 _(b'REV'),
4980 _(b'REV'),
4969 ),
4981 ),
4970 ]
4982 ]
4971 + templateopts,
4983 + templateopts,
4972 _(b'[-r REV] [FILE]'),
4984 _(b'[-r REV] [FILE]'),
4973 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
4985 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
4974 inferrepo=True,
4986 inferrepo=True,
4975 )
4987 )
4976 def parents(ui, repo, file_=None, **opts):
4988 def parents(ui, repo, file_=None, **opts):
4977 """show the parents of the working directory or revision (DEPRECATED)
4989 """show the parents of the working directory or revision (DEPRECATED)
4978
4990
4979 Print the working directory's parent revisions. If a revision is
4991 Print the working directory's parent revisions. If a revision is
4980 given via -r/--rev, the parent of that revision will be printed.
4992 given via -r/--rev, the parent of that revision will be printed.
4981 If a file argument is given, the revision in which the file was
4993 If a file argument is given, the revision in which the file was
4982 last changed (before the working directory revision or the
4994 last changed (before the working directory revision or the
4983 argument to --rev if given) is printed.
4995 argument to --rev if given) is printed.
4984
4996
4985 This command is equivalent to::
4997 This command is equivalent to::
4986
4998
4987 hg log -r "p1()+p2()" or
4999 hg log -r "p1()+p2()" or
4988 hg log -r "p1(REV)+p2(REV)" or
5000 hg log -r "p1(REV)+p2(REV)" or
4989 hg log -r "max(::p1() and file(FILE))+max(::p2() and file(FILE))" or
5001 hg log -r "max(::p1() and file(FILE))+max(::p2() and file(FILE))" or
4990 hg log -r "max(::p1(REV) and file(FILE))+max(::p2(REV) and file(FILE))"
5002 hg log -r "max(::p1(REV) and file(FILE))+max(::p2(REV) and file(FILE))"
4991
5003
4992 See :hg:`summary` and :hg:`help revsets` for related information.
5004 See :hg:`summary` and :hg:`help revsets` for related information.
4993
5005
4994 Returns 0 on success.
5006 Returns 0 on success.
4995 """
5007 """
4996
5008
4997 opts = pycompat.byteskwargs(opts)
5009 opts = pycompat.byteskwargs(opts)
4998 rev = opts.get(b'rev')
5010 rev = opts.get(b'rev')
4999 if rev:
5011 if rev:
5000 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
5012 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
5001 ctx = scmutil.revsingle(repo, rev, None)
5013 ctx = scmutil.revsingle(repo, rev, None)
5002
5014
5003 if file_:
5015 if file_:
5004 m = scmutil.match(ctx, (file_,), opts)
5016 m = scmutil.match(ctx, (file_,), opts)
5005 if m.anypats() or len(m.files()) != 1:
5017 if m.anypats() or len(m.files()) != 1:
5006 raise error.InputError(_(b'can only specify an explicit filename'))
5018 raise error.InputError(_(b'can only specify an explicit filename'))
5007 file_ = m.files()[0]
5019 file_ = m.files()[0]
5008 filenodes = []
5020 filenodes = []
5009 for cp in ctx.parents():
5021 for cp in ctx.parents():
5010 if not cp:
5022 if not cp:
5011 continue
5023 continue
5012 try:
5024 try:
5013 filenodes.append(cp.filenode(file_))
5025 filenodes.append(cp.filenode(file_))
5014 except error.LookupError:
5026 except error.LookupError:
5015 pass
5027 pass
5016 if not filenodes:
5028 if not filenodes:
5017 raise error.InputError(_(b"'%s' not found in manifest") % file_)
5029 raise error.InputError(_(b"'%s' not found in manifest") % file_)
5018 p = []
5030 p = []
5019 for fn in filenodes:
5031 for fn in filenodes:
5020 fctx = repo.filectx(file_, fileid=fn)
5032 fctx = repo.filectx(file_, fileid=fn)
5021 p.append(fctx.node())
5033 p.append(fctx.node())
5022 else:
5034 else:
5023 p = [cp.node() for cp in ctx.parents()]
5035 p = [cp.node() for cp in ctx.parents()]
5024
5036
5025 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
5037 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
5026 for n in p:
5038 for n in p:
5027 if n != nullid:
5039 if n != nullid:
5028 displayer.show(repo[n])
5040 displayer.show(repo[n])
5029 displayer.close()
5041 displayer.close()
5030
5042
5031
5043
5032 @command(
5044 @command(
5033 b'paths',
5045 b'paths',
5034 formatteropts,
5046 formatteropts,
5035 _(b'[NAME]'),
5047 _(b'[NAME]'),
5036 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
5048 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
5037 optionalrepo=True,
5049 optionalrepo=True,
5038 intents={INTENT_READONLY},
5050 intents={INTENT_READONLY},
5039 )
5051 )
5040 def paths(ui, repo, search=None, **opts):
5052 def paths(ui, repo, search=None, **opts):
5041 """show aliases for remote repositories
5053 """show aliases for remote repositories
5042
5054
5043 Show definition of symbolic path name NAME. If no name is given,
5055 Show definition of symbolic path name NAME. If no name is given,
5044 show definition of all available names.
5056 show definition of all available names.
5045
5057
5046 Option -q/--quiet suppresses all output when searching for NAME
5058 Option -q/--quiet suppresses all output when searching for NAME
5047 and shows only the path names when listing all definitions.
5059 and shows only the path names when listing all definitions.
5048
5060
5049 Path names are defined in the [paths] section of your
5061 Path names are defined in the [paths] section of your
5050 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
5062 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
5051 repository, ``.hg/hgrc`` is used, too.
5063 repository, ``.hg/hgrc`` is used, too.
5052
5064
5053 The path names ``default`` and ``default-push`` have a special
5065 The path names ``default`` and ``default-push`` have a special
5054 meaning. When performing a push or pull operation, they are used
5066 meaning. When performing a push or pull operation, they are used
5055 as fallbacks if no location is specified on the command-line.
5067 as fallbacks if no location is specified on the command-line.
5056 When ``default-push`` is set, it will be used for push and
5068 When ``default-push`` is set, it will be used for push and
5057 ``default`` will be used for pull; otherwise ``default`` is used
5069 ``default`` will be used for pull; otherwise ``default`` is used
5058 as the fallback for both. When cloning a repository, the clone
5070 as the fallback for both. When cloning a repository, the clone
5059 source is written as ``default`` in ``.hg/hgrc``.
5071 source is written as ``default`` in ``.hg/hgrc``.
5060
5072
5061 .. note::
5073 .. note::
5062
5074
5063 ``default`` and ``default-push`` apply to all inbound (e.g.
5075 ``default`` and ``default-push`` apply to all inbound (e.g.
5064 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email`
5076 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email`
5065 and :hg:`bundle`) operations.
5077 and :hg:`bundle`) operations.
5066
5078
5067 See :hg:`help urls` for more information.
5079 See :hg:`help urls` for more information.
5068
5080
5069 .. container:: verbose
5081 .. container:: verbose
5070
5082
5071 Template:
5083 Template:
5072
5084
5073 The following keywords are supported. See also :hg:`help templates`.
5085 The following keywords are supported. See also :hg:`help templates`.
5074
5086
5075 :name: String. Symbolic name of the path alias.
5087 :name: String. Symbolic name of the path alias.
5076 :pushurl: String. URL for push operations.
5088 :pushurl: String. URL for push operations.
5077 :url: String. URL or directory path for the other operations.
5089 :url: String. URL or directory path for the other operations.
5078
5090
5079 Returns 0 on success.
5091 Returns 0 on success.
5080 """
5092 """
5081
5093
5082 opts = pycompat.byteskwargs(opts)
5094 opts = pycompat.byteskwargs(opts)
5083 ui.pager(b'paths')
5095 ui.pager(b'paths')
5084 if search:
5096 if search:
5085 pathitems = [
5097 pathitems = [
5086 (name, path)
5098 (name, path)
5087 for name, path in pycompat.iteritems(ui.paths)
5099 for name, path in pycompat.iteritems(ui.paths)
5088 if name == search
5100 if name == search
5089 ]
5101 ]
5090 else:
5102 else:
5091 pathitems = sorted(pycompat.iteritems(ui.paths))
5103 pathitems = sorted(pycompat.iteritems(ui.paths))
5092
5104
5093 fm = ui.formatter(b'paths', opts)
5105 fm = ui.formatter(b'paths', opts)
5094 if fm.isplain():
5106 if fm.isplain():
5095 hidepassword = util.hidepassword
5107 hidepassword = util.hidepassword
5096 else:
5108 else:
5097 hidepassword = bytes
5109 hidepassword = bytes
5098 if ui.quiet:
5110 if ui.quiet:
5099 namefmt = b'%s\n'
5111 namefmt = b'%s\n'
5100 else:
5112 else:
5101 namefmt = b'%s = '
5113 namefmt = b'%s = '
5102 showsubopts = not search and not ui.quiet
5114 showsubopts = not search and not ui.quiet
5103
5115
5104 for name, path in pathitems:
5116 for name, path in pathitems:
5105 fm.startitem()
5117 fm.startitem()
5106 fm.condwrite(not search, b'name', namefmt, name)
5118 fm.condwrite(not search, b'name', namefmt, name)
5107 fm.condwrite(not ui.quiet, b'url', b'%s\n', hidepassword(path.rawloc))
5119 fm.condwrite(not ui.quiet, b'url', b'%s\n', hidepassword(path.rawloc))
5108 for subopt, value in sorted(path.suboptions.items()):
5120 for subopt, value in sorted(path.suboptions.items()):
5109 assert subopt not in (b'name', b'url')
5121 assert subopt not in (b'name', b'url')
5110 if showsubopts:
5122 if showsubopts:
5111 fm.plain(b'%s:%s = ' % (name, subopt))
5123 fm.plain(b'%s:%s = ' % (name, subopt))
5112 fm.condwrite(showsubopts, subopt, b'%s\n', value)
5124 fm.condwrite(showsubopts, subopt, b'%s\n', value)
5113
5125
5114 fm.end()
5126 fm.end()
5115
5127
5116 if search and not pathitems:
5128 if search and not pathitems:
5117 if not ui.quiet:
5129 if not ui.quiet:
5118 ui.warn(_(b"not found!\n"))
5130 ui.warn(_(b"not found!\n"))
5119 return 1
5131 return 1
5120 else:
5132 else:
5121 return 0
5133 return 0
5122
5134
5123
5135
5124 @command(
5136 @command(
5125 b'phase',
5137 b'phase',
5126 [
5138 [
5127 (b'p', b'public', False, _(b'set changeset phase to public')),
5139 (b'p', b'public', False, _(b'set changeset phase to public')),
5128 (b'd', b'draft', False, _(b'set changeset phase to draft')),
5140 (b'd', b'draft', False, _(b'set changeset phase to draft')),
5129 (b's', b'secret', False, _(b'set changeset phase to secret')),
5141 (b's', b'secret', False, _(b'set changeset phase to secret')),
5130 (b'f', b'force', False, _(b'allow to move boundary backward')),
5142 (b'f', b'force', False, _(b'allow to move boundary backward')),
5131 (b'r', b'rev', [], _(b'target revision'), _(b'REV')),
5143 (b'r', b'rev', [], _(b'target revision'), _(b'REV')),
5132 ],
5144 ],
5133 _(b'[-p|-d|-s] [-f] [-r] [REV...]'),
5145 _(b'[-p|-d|-s] [-f] [-r] [REV...]'),
5134 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
5146 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
5135 )
5147 )
5136 def phase(ui, repo, *revs, **opts):
5148 def phase(ui, repo, *revs, **opts):
5137 """set or show the current phase name
5149 """set or show the current phase name
5138
5150
5139 With no argument, show the phase name of the current revision(s).
5151 With no argument, show the phase name of the current revision(s).
5140
5152
5141 With one of -p/--public, -d/--draft or -s/--secret, change the
5153 With one of -p/--public, -d/--draft or -s/--secret, change the
5142 phase value of the specified revisions.
5154 phase value of the specified revisions.
5143
5155
5144 Unless -f/--force is specified, :hg:`phase` won't move changesets from a
5156 Unless -f/--force is specified, :hg:`phase` won't move changesets from a
5145 lower phase to a higher phase. Phases are ordered as follows::
5157 lower phase to a higher phase. Phases are ordered as follows::
5146
5158
5147 public < draft < secret
5159 public < draft < secret
5148
5160
5149 Returns 0 on success, 1 if some phases could not be changed.
5161 Returns 0 on success, 1 if some phases could not be changed.
5150
5162
5151 (For more information about the phases concept, see :hg:`help phases`.)
5163 (For more information about the phases concept, see :hg:`help phases`.)
5152 """
5164 """
5153 opts = pycompat.byteskwargs(opts)
5165 opts = pycompat.byteskwargs(opts)
5154 # search for a unique phase argument
5166 # search for a unique phase argument
5155 targetphase = None
5167 targetphase = None
5156 for idx, name in enumerate(phases.cmdphasenames):
5168 for idx, name in enumerate(phases.cmdphasenames):
5157 if opts[name]:
5169 if opts[name]:
5158 if targetphase is not None:
5170 if targetphase is not None:
5159 raise error.InputError(_(b'only one phase can be specified'))
5171 raise error.InputError(_(b'only one phase can be specified'))
5160 targetphase = idx
5172 targetphase = idx
5161
5173
5162 # look for specified revision
5174 # look for specified revision
5163 revs = list(revs)
5175 revs = list(revs)
5164 revs.extend(opts[b'rev'])
5176 revs.extend(opts[b'rev'])
5165 if not revs:
5177 if not revs:
5166 # display both parents as the second parent phase can influence
5178 # display both parents as the second parent phase can influence
5167 # the phase of a merge commit
5179 # the phase of a merge commit
5168 revs = [c.rev() for c in repo[None].parents()]
5180 revs = [c.rev() for c in repo[None].parents()]
5169
5181
5170 revs = scmutil.revrange(repo, revs)
5182 revs = scmutil.revrange(repo, revs)
5171
5183
5172 ret = 0
5184 ret = 0
5173 if targetphase is None:
5185 if targetphase is None:
5174 # display
5186 # display
5175 for r in revs:
5187 for r in revs:
5176 ctx = repo[r]
5188 ctx = repo[r]
5177 ui.write(b'%i: %s\n' % (ctx.rev(), ctx.phasestr()))
5189 ui.write(b'%i: %s\n' % (ctx.rev(), ctx.phasestr()))
5178 else:
5190 else:
5179 with repo.lock(), repo.transaction(b"phase") as tr:
5191 with repo.lock(), repo.transaction(b"phase") as tr:
5180 # set phase
5192 # set phase
5181 if not revs:
5193 if not revs:
5182 raise error.InputError(_(b'empty revision set'))
5194 raise error.InputError(_(b'empty revision set'))
5183 nodes = [repo[r].node() for r in revs]
5195 nodes = [repo[r].node() for r in revs]
5184 # moving revision from public to draft may hide them
5196 # moving revision from public to draft may hide them
5185 # We have to check result on an unfiltered repository
5197 # We have to check result on an unfiltered repository
5186 unfi = repo.unfiltered()
5198 unfi = repo.unfiltered()
5187 getphase = unfi._phasecache.phase
5199 getphase = unfi._phasecache.phase
5188 olddata = [getphase(unfi, r) for r in unfi]
5200 olddata = [getphase(unfi, r) for r in unfi]
5189 phases.advanceboundary(repo, tr, targetphase, nodes)
5201 phases.advanceboundary(repo, tr, targetphase, nodes)
5190 if opts[b'force']:
5202 if opts[b'force']:
5191 phases.retractboundary(repo, tr, targetphase, nodes)
5203 phases.retractboundary(repo, tr, targetphase, nodes)
5192 getphase = unfi._phasecache.phase
5204 getphase = unfi._phasecache.phase
5193 newdata = [getphase(unfi, r) for r in unfi]
5205 newdata = [getphase(unfi, r) for r in unfi]
5194 changes = sum(newdata[r] != olddata[r] for r in unfi)
5206 changes = sum(newdata[r] != olddata[r] for r in unfi)
5195 cl = unfi.changelog
5207 cl = unfi.changelog
5196 rejected = [n for n in nodes if newdata[cl.rev(n)] < targetphase]
5208 rejected = [n for n in nodes if newdata[cl.rev(n)] < targetphase]
5197 if rejected:
5209 if rejected:
5198 ui.warn(
5210 ui.warn(
5199 _(
5211 _(
5200 b'cannot move %i changesets to a higher '
5212 b'cannot move %i changesets to a higher '
5201 b'phase, use --force\n'
5213 b'phase, use --force\n'
5202 )
5214 )
5203 % len(rejected)
5215 % len(rejected)
5204 )
5216 )
5205 ret = 1
5217 ret = 1
5206 if changes:
5218 if changes:
5207 msg = _(b'phase changed for %i changesets\n') % changes
5219 msg = _(b'phase changed for %i changesets\n') % changes
5208 if ret:
5220 if ret:
5209 ui.status(msg)
5221 ui.status(msg)
5210 else:
5222 else:
5211 ui.note(msg)
5223 ui.note(msg)
5212 else:
5224 else:
5213 ui.warn(_(b'no phases changed\n'))
5225 ui.warn(_(b'no phases changed\n'))
5214 return ret
5226 return ret
5215
5227
5216
5228
5217 def postincoming(ui, repo, modheads, optupdate, checkout, brev):
5229 def postincoming(ui, repo, modheads, optupdate, checkout, brev):
5218 """Run after a changegroup has been added via pull/unbundle
5230 """Run after a changegroup has been added via pull/unbundle
5219
5231
5220 This takes arguments below:
5232 This takes arguments below:
5221
5233
5222 :modheads: change of heads by pull/unbundle
5234 :modheads: change of heads by pull/unbundle
5223 :optupdate: updating working directory is needed or not
5235 :optupdate: updating working directory is needed or not
5224 :checkout: update destination revision (or None to default destination)
5236 :checkout: update destination revision (or None to default destination)
5225 :brev: a name, which might be a bookmark to be activated after updating
5237 :brev: a name, which might be a bookmark to be activated after updating
5226 """
5238 """
5227 if modheads == 0:
5239 if modheads == 0:
5228 return
5240 return
5229 if optupdate:
5241 if optupdate:
5230 try:
5242 try:
5231 return hg.updatetotally(ui, repo, checkout, brev)
5243 return hg.updatetotally(ui, repo, checkout, brev)
5232 except error.UpdateAbort as inst:
5244 except error.UpdateAbort as inst:
5233 msg = _(b"not updating: %s") % stringutil.forcebytestr(inst)
5245 msg = _(b"not updating: %s") % stringutil.forcebytestr(inst)
5234 hint = inst.hint
5246 hint = inst.hint
5235 raise error.UpdateAbort(msg, hint=hint)
5247 raise error.UpdateAbort(msg, hint=hint)
5236 if modheads is not None and modheads > 1:
5248 if modheads is not None and modheads > 1:
5237 currentbranchheads = len(repo.branchheads())
5249 currentbranchheads = len(repo.branchheads())
5238 if currentbranchheads == modheads:
5250 if currentbranchheads == modheads:
5239 ui.status(
5251 ui.status(
5240 _(b"(run 'hg heads' to see heads, 'hg merge' to merge)\n")
5252 _(b"(run 'hg heads' to see heads, 'hg merge' to merge)\n")
5241 )
5253 )
5242 elif currentbranchheads > 1:
5254 elif currentbranchheads > 1:
5243 ui.status(
5255 ui.status(
5244 _(b"(run 'hg heads .' to see heads, 'hg merge' to merge)\n")
5256 _(b"(run 'hg heads .' to see heads, 'hg merge' to merge)\n")
5245 )
5257 )
5246 else:
5258 else:
5247 ui.status(_(b"(run 'hg heads' to see heads)\n"))
5259 ui.status(_(b"(run 'hg heads' to see heads)\n"))
5248 elif not ui.configbool(b'commands', b'update.requiredest'):
5260 elif not ui.configbool(b'commands', b'update.requiredest'):
5249 ui.status(_(b"(run 'hg update' to get a working copy)\n"))
5261 ui.status(_(b"(run 'hg update' to get a working copy)\n"))
5250
5262
5251
5263
5252 @command(
5264 @command(
5253 b'pull',
5265 b'pull',
5254 [
5266 [
5255 (
5267 (
5256 b'u',
5268 b'u',
5257 b'update',
5269 b'update',
5258 None,
5270 None,
5259 _(b'update to new branch head if new descendants were pulled'),
5271 _(b'update to new branch head if new descendants were pulled'),
5260 ),
5272 ),
5261 (
5273 (
5262 b'f',
5274 b'f',
5263 b'force',
5275 b'force',
5264 None,
5276 None,
5265 _(b'run even when remote repository is unrelated'),
5277 _(b'run even when remote repository is unrelated'),
5266 ),
5278 ),
5267 (
5279 (
5268 b'',
5280 b'',
5269 b'confirm',
5281 b'confirm',
5270 None,
5282 None,
5271 _(b'confirm pull before applying changes'),
5283 _(b'confirm pull before applying changes'),
5272 ),
5284 ),
5273 (
5285 (
5274 b'r',
5286 b'r',
5275 b'rev',
5287 b'rev',
5276 [],
5288 [],
5277 _(b'a remote changeset intended to be added'),
5289 _(b'a remote changeset intended to be added'),
5278 _(b'REV'),
5290 _(b'REV'),
5279 ),
5291 ),
5280 (b'B', b'bookmark', [], _(b"bookmark to pull"), _(b'BOOKMARK')),
5292 (b'B', b'bookmark', [], _(b"bookmark to pull"), _(b'BOOKMARK')),
5281 (
5293 (
5282 b'b',
5294 b'b',
5283 b'branch',
5295 b'branch',
5284 [],
5296 [],
5285 _(b'a specific branch you would like to pull'),
5297 _(b'a specific branch you would like to pull'),
5286 _(b'BRANCH'),
5298 _(b'BRANCH'),
5287 ),
5299 ),
5288 ]
5300 ]
5289 + remoteopts,
5301 + remoteopts,
5290 _(b'[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'),
5302 _(b'[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'),
5291 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
5303 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
5292 helpbasic=True,
5304 helpbasic=True,
5293 )
5305 )
5294 def pull(ui, repo, source=b"default", **opts):
5306 def pull(ui, repo, source=b"default", **opts):
5295 """pull changes from the specified source
5307 """pull changes from the specified source
5296
5308
5297 Pull changes from a remote repository to a local one.
5309 Pull changes from a remote repository to a local one.
5298
5310
5299 This finds all changes from the repository at the specified path
5311 This finds all changes from the repository at the specified path
5300 or URL and adds them to a local repository (the current one unless
5312 or URL and adds them to a local repository (the current one unless
5301 -R is specified). By default, this does not update the copy of the
5313 -R is specified). By default, this does not update the copy of the
5302 project in the working directory.
5314 project in the working directory.
5303
5315
5304 When cloning from servers that support it, Mercurial may fetch
5316 When cloning from servers that support it, Mercurial may fetch
5305 pre-generated data. When this is done, hooks operating on incoming
5317 pre-generated data. When this is done, hooks operating on incoming
5306 changesets and changegroups may fire more than once, once for each
5318 changesets and changegroups may fire more than once, once for each
5307 pre-generated bundle and as well as for any additional remaining
5319 pre-generated bundle and as well as for any additional remaining
5308 data. See :hg:`help -e clonebundles` for more.
5320 data. See :hg:`help -e clonebundles` for more.
5309
5321
5310 Use :hg:`incoming` if you want to see what would have been added
5322 Use :hg:`incoming` if you want to see what would have been added
5311 by a pull at the time you issued this command. If you then decide
5323 by a pull at the time you issued this command. If you then decide
5312 to add those changes to the repository, you should use :hg:`pull
5324 to add those changes to the repository, you should use :hg:`pull
5313 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
5325 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
5314
5326
5315 If SOURCE is omitted, the 'default' path will be used.
5327 If SOURCE is omitted, the 'default' path will be used.
5316 See :hg:`help urls` for more information.
5328 See :hg:`help urls` for more information.
5317
5329
5318 Specifying bookmark as ``.`` is equivalent to specifying the active
5330 Specifying bookmark as ``.`` is equivalent to specifying the active
5319 bookmark's name.
5331 bookmark's name.
5320
5332
5321 Returns 0 on success, 1 if an update had unresolved files.
5333 Returns 0 on success, 1 if an update had unresolved files.
5322 """
5334 """
5323
5335
5324 opts = pycompat.byteskwargs(opts)
5336 opts = pycompat.byteskwargs(opts)
5325 if ui.configbool(b'commands', b'update.requiredest') and opts.get(
5337 if ui.configbool(b'commands', b'update.requiredest') and opts.get(
5326 b'update'
5338 b'update'
5327 ):
5339 ):
5328 msg = _(b'update destination required by configuration')
5340 msg = _(b'update destination required by configuration')
5329 hint = _(b'use hg pull followed by hg update DEST')
5341 hint = _(b'use hg pull followed by hg update DEST')
5330 raise error.InputError(msg, hint=hint)
5342 raise error.InputError(msg, hint=hint)
5331
5343
5332 source, branches = hg.parseurl(ui.expandpath(source), opts.get(b'branch'))
5344 source, branches = hg.parseurl(ui.expandpath(source), opts.get(b'branch'))
5333 ui.status(_(b'pulling from %s\n') % util.hidepassword(source))
5345 ui.status(_(b'pulling from %s\n') % util.hidepassword(source))
5334 ui.flush()
5346 ui.flush()
5335 other = hg.peer(repo, opts, source)
5347 other = hg.peer(repo, opts, source)
5336 try:
5348 try:
5337 revs, checkout = hg.addbranchrevs(
5349 revs, checkout = hg.addbranchrevs(
5338 repo, other, branches, opts.get(b'rev')
5350 repo, other, branches, opts.get(b'rev')
5339 )
5351 )
5340
5352
5341 pullopargs = {}
5353 pullopargs = {}
5342
5354
5343 nodes = None
5355 nodes = None
5344 if opts.get(b'bookmark') or revs:
5356 if opts.get(b'bookmark') or revs:
5345 # The list of bookmark used here is the same used to actually update
5357 # The list of bookmark used here is the same used to actually update
5346 # the bookmark names, to avoid the race from issue 4689 and we do
5358 # the bookmark names, to avoid the race from issue 4689 and we do
5347 # all lookup and bookmark queries in one go so they see the same
5359 # all lookup and bookmark queries in one go so they see the same
5348 # version of the server state (issue 4700).
5360 # version of the server state (issue 4700).
5349 nodes = []
5361 nodes = []
5350 fnodes = []
5362 fnodes = []
5351 revs = revs or []
5363 revs = revs or []
5352 if revs and not other.capable(b'lookup'):
5364 if revs and not other.capable(b'lookup'):
5353 err = _(
5365 err = _(
5354 b"other repository doesn't support revision lookup, "
5366 b"other repository doesn't support revision lookup, "
5355 b"so a rev cannot be specified."
5367 b"so a rev cannot be specified."
5356 )
5368 )
5357 raise error.Abort(err)
5369 raise error.Abort(err)
5358 with other.commandexecutor() as e:
5370 with other.commandexecutor() as e:
5359 fremotebookmarks = e.callcommand(
5371 fremotebookmarks = e.callcommand(
5360 b'listkeys', {b'namespace': b'bookmarks'}
5372 b'listkeys', {b'namespace': b'bookmarks'}
5361 )
5373 )
5362 for r in revs:
5374 for r in revs:
5363 fnodes.append(e.callcommand(b'lookup', {b'key': r}))
5375 fnodes.append(e.callcommand(b'lookup', {b'key': r}))
5364 remotebookmarks = fremotebookmarks.result()
5376 remotebookmarks = fremotebookmarks.result()
5365 remotebookmarks = bookmarks.unhexlifybookmarks(remotebookmarks)
5377 remotebookmarks = bookmarks.unhexlifybookmarks(remotebookmarks)
5366 pullopargs[b'remotebookmarks'] = remotebookmarks
5378 pullopargs[b'remotebookmarks'] = remotebookmarks
5367 for b in opts.get(b'bookmark', []):
5379 for b in opts.get(b'bookmark', []):
5368 b = repo._bookmarks.expandname(b)
5380 b = repo._bookmarks.expandname(b)
5369 if b not in remotebookmarks:
5381 if b not in remotebookmarks:
5370 raise error.InputError(
5382 raise error.InputError(
5371 _(b'remote bookmark %s not found!') % b
5383 _(b'remote bookmark %s not found!') % b
5372 )
5384 )
5373 nodes.append(remotebookmarks[b])
5385 nodes.append(remotebookmarks[b])
5374 for i, rev in enumerate(revs):
5386 for i, rev in enumerate(revs):
5375 node = fnodes[i].result()
5387 node = fnodes[i].result()
5376 nodes.append(node)
5388 nodes.append(node)
5377 if rev == checkout:
5389 if rev == checkout:
5378 checkout = node
5390 checkout = node
5379
5391
5380 wlock = util.nullcontextmanager()
5392 wlock = util.nullcontextmanager()
5381 if opts.get(b'update'):
5393 if opts.get(b'update'):
5382 wlock = repo.wlock()
5394 wlock = repo.wlock()
5383 with wlock:
5395 with wlock:
5384 pullopargs.update(opts.get(b'opargs', {}))
5396 pullopargs.update(opts.get(b'opargs', {}))
5385 modheads = exchange.pull(
5397 modheads = exchange.pull(
5386 repo,
5398 repo,
5387 other,
5399 other,
5388 heads=nodes,
5400 heads=nodes,
5389 force=opts.get(b'force'),
5401 force=opts.get(b'force'),
5390 bookmarks=opts.get(b'bookmark', ()),
5402 bookmarks=opts.get(b'bookmark', ()),
5391 opargs=pullopargs,
5403 opargs=pullopargs,
5392 confirm=opts.get(b'confirm'),
5404 confirm=opts.get(b'confirm'),
5393 ).cgresult
5405 ).cgresult
5394
5406
5395 # brev is a name, which might be a bookmark to be activated at
5407 # brev is a name, which might be a bookmark to be activated at
5396 # the end of the update. In other words, it is an explicit
5408 # the end of the update. In other words, it is an explicit
5397 # destination of the update
5409 # destination of the update
5398 brev = None
5410 brev = None
5399
5411
5400 if checkout:
5412 if checkout:
5401 checkout = repo.unfiltered().changelog.rev(checkout)
5413 checkout = repo.unfiltered().changelog.rev(checkout)
5402
5414
5403 # order below depends on implementation of
5415 # order below depends on implementation of
5404 # hg.addbranchrevs(). opts['bookmark'] is ignored,
5416 # hg.addbranchrevs(). opts['bookmark'] is ignored,
5405 # because 'checkout' is determined without it.
5417 # because 'checkout' is determined without it.
5406 if opts.get(b'rev'):
5418 if opts.get(b'rev'):
5407 brev = opts[b'rev'][0]
5419 brev = opts[b'rev'][0]
5408 elif opts.get(b'branch'):
5420 elif opts.get(b'branch'):
5409 brev = opts[b'branch'][0]
5421 brev = opts[b'branch'][0]
5410 else:
5422 else:
5411 brev = branches[0]
5423 brev = branches[0]
5412 repo._subtoppath = source
5424 repo._subtoppath = source
5413 try:
5425 try:
5414 ret = postincoming(
5426 ret = postincoming(
5415 ui, repo, modheads, opts.get(b'update'), checkout, brev
5427 ui, repo, modheads, opts.get(b'update'), checkout, brev
5416 )
5428 )
5417 except error.FilteredRepoLookupError as exc:
5429 except error.FilteredRepoLookupError as exc:
5418 msg = _(b'cannot update to target: %s') % exc.args[0]
5430 msg = _(b'cannot update to target: %s') % exc.args[0]
5419 exc.args = (msg,) + exc.args[1:]
5431 exc.args = (msg,) + exc.args[1:]
5420 raise
5432 raise
5421 finally:
5433 finally:
5422 del repo._subtoppath
5434 del repo._subtoppath
5423
5435
5424 finally:
5436 finally:
5425 other.close()
5437 other.close()
5426 return ret
5438 return ret
5427
5439
5428
5440
5429 @command(
5441 @command(
5430 b'push',
5442 b'push',
5431 [
5443 [
5432 (b'f', b'force', None, _(b'force push')),
5444 (b'f', b'force', None, _(b'force push')),
5433 (
5445 (
5434 b'r',
5446 b'r',
5435 b'rev',
5447 b'rev',
5436 [],
5448 [],
5437 _(b'a changeset intended to be included in the destination'),
5449 _(b'a changeset intended to be included in the destination'),
5438 _(b'REV'),
5450 _(b'REV'),
5439 ),
5451 ),
5440 (b'B', b'bookmark', [], _(b"bookmark to push"), _(b'BOOKMARK')),
5452 (b'B', b'bookmark', [], _(b"bookmark to push"), _(b'BOOKMARK')),
5441 (b'', b'all-bookmarks', None, _(b"push all bookmarks (EXPERIMENTAL)")),
5453 (b'', b'all-bookmarks', None, _(b"push all bookmarks (EXPERIMENTAL)")),
5442 (
5454 (
5443 b'b',
5455 b'b',
5444 b'branch',
5456 b'branch',
5445 [],
5457 [],
5446 _(b'a specific branch you would like to push'),
5458 _(b'a specific branch you would like to push'),
5447 _(b'BRANCH'),
5459 _(b'BRANCH'),
5448 ),
5460 ),
5449 (b'', b'new-branch', False, _(b'allow pushing a new branch')),
5461 (b'', b'new-branch', False, _(b'allow pushing a new branch')),
5450 (
5462 (
5451 b'',
5463 b'',
5452 b'pushvars',
5464 b'pushvars',
5453 [],
5465 [],
5454 _(b'variables that can be sent to server (ADVANCED)'),
5466 _(b'variables that can be sent to server (ADVANCED)'),
5455 ),
5467 ),
5456 (
5468 (
5457 b'',
5469 b'',
5458 b'publish',
5470 b'publish',
5459 False,
5471 False,
5460 _(b'push the changeset as public (EXPERIMENTAL)'),
5472 _(b'push the changeset as public (EXPERIMENTAL)'),
5461 ),
5473 ),
5462 ]
5474 ]
5463 + remoteopts,
5475 + remoteopts,
5464 _(b'[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'),
5476 _(b'[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'),
5465 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
5477 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
5466 helpbasic=True,
5478 helpbasic=True,
5467 )
5479 )
5468 def push(ui, repo, dest=None, **opts):
5480 def push(ui, repo, dest=None, **opts):
5469 """push changes to the specified destination
5481 """push changes to the specified destination
5470
5482
5471 Push changesets from the local repository to the specified
5483 Push changesets from the local repository to the specified
5472 destination.
5484 destination.
5473
5485
5474 This operation is symmetrical to pull: it is identical to a pull
5486 This operation is symmetrical to pull: it is identical to a pull
5475 in the destination repository from the current one.
5487 in the destination repository from the current one.
5476
5488
5477 By default, push will not allow creation of new heads at the
5489 By default, push will not allow creation of new heads at the
5478 destination, since multiple heads would make it unclear which head
5490 destination, since multiple heads would make it unclear which head
5479 to use. In this situation, it is recommended to pull and merge
5491 to use. In this situation, it is recommended to pull and merge
5480 before pushing.
5492 before pushing.
5481
5493
5482 Use --new-branch if you want to allow push to create a new named
5494 Use --new-branch if you want to allow push to create a new named
5483 branch that is not present at the destination. This allows you to
5495 branch that is not present at the destination. This allows you to
5484 only create a new branch without forcing other changes.
5496 only create a new branch without forcing other changes.
5485
5497
5486 .. note::
5498 .. note::
5487
5499
5488 Extra care should be taken with the -f/--force option,
5500 Extra care should be taken with the -f/--force option,
5489 which will push all new heads on all branches, an action which will
5501 which will push all new heads on all branches, an action which will
5490 almost always cause confusion for collaborators.
5502 almost always cause confusion for collaborators.
5491
5503
5492 If -r/--rev is used, the specified revision and all its ancestors
5504 If -r/--rev is used, the specified revision and all its ancestors
5493 will be pushed to the remote repository.
5505 will be pushed to the remote repository.
5494
5506
5495 If -B/--bookmark is used, the specified bookmarked revision, its
5507 If -B/--bookmark is used, the specified bookmarked revision, its
5496 ancestors, and the bookmark will be pushed to the remote
5508 ancestors, and the bookmark will be pushed to the remote
5497 repository. Specifying ``.`` is equivalent to specifying the active
5509 repository. Specifying ``.`` is equivalent to specifying the active
5498 bookmark's name. Use the --all-bookmarks option for pushing all
5510 bookmark's name. Use the --all-bookmarks option for pushing all
5499 current bookmarks.
5511 current bookmarks.
5500
5512
5501 Please see :hg:`help urls` for important details about ``ssh://``
5513 Please see :hg:`help urls` for important details about ``ssh://``
5502 URLs. If DESTINATION is omitted, a default path will be used.
5514 URLs. If DESTINATION is omitted, a default path will be used.
5503
5515
5504 .. container:: verbose
5516 .. container:: verbose
5505
5517
5506 The --pushvars option sends strings to the server that become
5518 The --pushvars option sends strings to the server that become
5507 environment variables prepended with ``HG_USERVAR_``. For example,
5519 environment variables prepended with ``HG_USERVAR_``. For example,
5508 ``--pushvars ENABLE_FEATURE=true``, provides the server side hooks with
5520 ``--pushvars ENABLE_FEATURE=true``, provides the server side hooks with
5509 ``HG_USERVAR_ENABLE_FEATURE=true`` as part of their environment.
5521 ``HG_USERVAR_ENABLE_FEATURE=true`` as part of their environment.
5510
5522
5511 pushvars can provide for user-overridable hooks as well as set debug
5523 pushvars can provide for user-overridable hooks as well as set debug
5512 levels. One example is having a hook that blocks commits containing
5524 levels. One example is having a hook that blocks commits containing
5513 conflict markers, but enables the user to override the hook if the file
5525 conflict markers, but enables the user to override the hook if the file
5514 is using conflict markers for testing purposes or the file format has
5526 is using conflict markers for testing purposes or the file format has
5515 strings that look like conflict markers.
5527 strings that look like conflict markers.
5516
5528
5517 By default, servers will ignore `--pushvars`. To enable it add the
5529 By default, servers will ignore `--pushvars`. To enable it add the
5518 following to your configuration file::
5530 following to your configuration file::
5519
5531
5520 [push]
5532 [push]
5521 pushvars.server = true
5533 pushvars.server = true
5522
5534
5523 Returns 0 if push was successful, 1 if nothing to push.
5535 Returns 0 if push was successful, 1 if nothing to push.
5524 """
5536 """
5525
5537
5526 opts = pycompat.byteskwargs(opts)
5538 opts = pycompat.byteskwargs(opts)
5527
5539
5528 if opts.get(b'all_bookmarks'):
5540 if opts.get(b'all_bookmarks'):
5529 cmdutil.check_incompatible_arguments(
5541 cmdutil.check_incompatible_arguments(
5530 opts,
5542 opts,
5531 b'all_bookmarks',
5543 b'all_bookmarks',
5532 [b'bookmark', b'rev'],
5544 [b'bookmark', b'rev'],
5533 )
5545 )
5534 opts[b'bookmark'] = list(repo._bookmarks)
5546 opts[b'bookmark'] = list(repo._bookmarks)
5535
5547
5536 if opts.get(b'bookmark'):
5548 if opts.get(b'bookmark'):
5537 ui.setconfig(b'bookmarks', b'pushing', opts[b'bookmark'], b'push')
5549 ui.setconfig(b'bookmarks', b'pushing', opts[b'bookmark'], b'push')
5538 for b in opts[b'bookmark']:
5550 for b in opts[b'bookmark']:
5539 # translate -B options to -r so changesets get pushed
5551 # translate -B options to -r so changesets get pushed
5540 b = repo._bookmarks.expandname(b)
5552 b = repo._bookmarks.expandname(b)
5541 if b in repo._bookmarks:
5553 if b in repo._bookmarks:
5542 opts.setdefault(b'rev', []).append(b)
5554 opts.setdefault(b'rev', []).append(b)
5543 else:
5555 else:
5544 # if we try to push a deleted bookmark, translate it to null
5556 # if we try to push a deleted bookmark, translate it to null
5545 # this lets simultaneous -r, -b options continue working
5557 # this lets simultaneous -r, -b options continue working
5546 opts.setdefault(b'rev', []).append(b"null")
5558 opts.setdefault(b'rev', []).append(b"null")
5547
5559
5548 path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
5560 path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
5549 if not path:
5561 if not path:
5550 raise error.ConfigError(
5562 raise error.ConfigError(
5551 _(b'default repository not configured!'),
5563 _(b'default repository not configured!'),
5552 hint=_(b"see 'hg help config.paths'"),
5564 hint=_(b"see 'hg help config.paths'"),
5553 )
5565 )
5554 dest = path.pushloc or path.loc
5566 dest = path.pushloc or path.loc
5555 branches = (path.branch, opts.get(b'branch') or [])
5567 branches = (path.branch, opts.get(b'branch') or [])
5556 ui.status(_(b'pushing to %s\n') % util.hidepassword(dest))
5568 ui.status(_(b'pushing to %s\n') % util.hidepassword(dest))
5557 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get(b'rev'))
5569 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get(b'rev'))
5558 other = hg.peer(repo, opts, dest)
5570 other = hg.peer(repo, opts, dest)
5559
5571
5560 if revs:
5572 if revs:
5561 revs = [repo[r].node() for r in scmutil.revrange(repo, revs)]
5573 revs = [repo[r].node() for r in scmutil.revrange(repo, revs)]
5562 if not revs:
5574 if not revs:
5563 raise error.InputError(
5575 raise error.InputError(
5564 _(b"specified revisions evaluate to an empty set"),
5576 _(b"specified revisions evaluate to an empty set"),
5565 hint=_(b"use different revision arguments"),
5577 hint=_(b"use different revision arguments"),
5566 )
5578 )
5567 elif path.pushrev:
5579 elif path.pushrev:
5568 # It doesn't make any sense to specify ancestor revisions. So limit
5580 # It doesn't make any sense to specify ancestor revisions. So limit
5569 # to DAG heads to make discovery simpler.
5581 # to DAG heads to make discovery simpler.
5570 expr = revsetlang.formatspec(b'heads(%r)', path.pushrev)
5582 expr = revsetlang.formatspec(b'heads(%r)', path.pushrev)
5571 revs = scmutil.revrange(repo, [expr])
5583 revs = scmutil.revrange(repo, [expr])
5572 revs = [repo[rev].node() for rev in revs]
5584 revs = [repo[rev].node() for rev in revs]
5573 if not revs:
5585 if not revs:
5574 raise error.InputError(
5586 raise error.InputError(
5575 _(b'default push revset for path evaluates to an empty set')
5587 _(b'default push revset for path evaluates to an empty set')
5576 )
5588 )
5577 elif ui.configbool(b'commands', b'push.require-revs'):
5589 elif ui.configbool(b'commands', b'push.require-revs'):
5578 raise error.InputError(
5590 raise error.InputError(
5579 _(b'no revisions specified to push'),
5591 _(b'no revisions specified to push'),
5580 hint=_(b'did you mean "hg push -r ."?'),
5592 hint=_(b'did you mean "hg push -r ."?'),
5581 )
5593 )
5582
5594
5583 repo._subtoppath = dest
5595 repo._subtoppath = dest
5584 try:
5596 try:
5585 # push subrepos depth-first for coherent ordering
5597 # push subrepos depth-first for coherent ordering
5586 c = repo[b'.']
5598 c = repo[b'.']
5587 subs = c.substate # only repos that are committed
5599 subs = c.substate # only repos that are committed
5588 for s in sorted(subs):
5600 for s in sorted(subs):
5589 result = c.sub(s).push(opts)
5601 result = c.sub(s).push(opts)
5590 if result == 0:
5602 if result == 0:
5591 return not result
5603 return not result
5592 finally:
5604 finally:
5593 del repo._subtoppath
5605 del repo._subtoppath
5594
5606
5595 opargs = dict(opts.get(b'opargs', {})) # copy opargs since we may mutate it
5607 opargs = dict(opts.get(b'opargs', {})) # copy opargs since we may mutate it
5596 opargs.setdefault(b'pushvars', []).extend(opts.get(b'pushvars', []))
5608 opargs.setdefault(b'pushvars', []).extend(opts.get(b'pushvars', []))
5597
5609
5598 pushop = exchange.push(
5610 pushop = exchange.push(
5599 repo,
5611 repo,
5600 other,
5612 other,
5601 opts.get(b'force'),
5613 opts.get(b'force'),
5602 revs=revs,
5614 revs=revs,
5603 newbranch=opts.get(b'new_branch'),
5615 newbranch=opts.get(b'new_branch'),
5604 bookmarks=opts.get(b'bookmark', ()),
5616 bookmarks=opts.get(b'bookmark', ()),
5605 publish=opts.get(b'publish'),
5617 publish=opts.get(b'publish'),
5606 opargs=opargs,
5618 opargs=opargs,
5607 )
5619 )
5608
5620
5609 result = not pushop.cgresult
5621 result = not pushop.cgresult
5610
5622
5611 if pushop.bkresult is not None:
5623 if pushop.bkresult is not None:
5612 if pushop.bkresult == 2:
5624 if pushop.bkresult == 2:
5613 result = 2
5625 result = 2
5614 elif not result and pushop.bkresult:
5626 elif not result and pushop.bkresult:
5615 result = 2
5627 result = 2
5616
5628
5617 return result
5629 return result
5618
5630
5619
5631
5620 @command(
5632 @command(
5621 b'recover',
5633 b'recover',
5622 [
5634 [
5623 (b'', b'verify', False, b"run `hg verify` after successful recover"),
5635 (b'', b'verify', False, b"run `hg verify` after successful recover"),
5624 ],
5636 ],
5625 helpcategory=command.CATEGORY_MAINTENANCE,
5637 helpcategory=command.CATEGORY_MAINTENANCE,
5626 )
5638 )
5627 def recover(ui, repo, **opts):
5639 def recover(ui, repo, **opts):
5628 """roll back an interrupted transaction
5640 """roll back an interrupted transaction
5629
5641
5630 Recover from an interrupted commit or pull.
5642 Recover from an interrupted commit or pull.
5631
5643
5632 This command tries to fix the repository status after an
5644 This command tries to fix the repository status after an
5633 interrupted operation. It should only be necessary when Mercurial
5645 interrupted operation. It should only be necessary when Mercurial
5634 suggests it.
5646 suggests it.
5635
5647
5636 Returns 0 if successful, 1 if nothing to recover or verify fails.
5648 Returns 0 if successful, 1 if nothing to recover or verify fails.
5637 """
5649 """
5638 ret = repo.recover()
5650 ret = repo.recover()
5639 if ret:
5651 if ret:
5640 if opts['verify']:
5652 if opts['verify']:
5641 return hg.verify(repo)
5653 return hg.verify(repo)
5642 else:
5654 else:
5643 msg = _(
5655 msg = _(
5644 b"(verify step skipped, run `hg verify` to check your "
5656 b"(verify step skipped, run `hg verify` to check your "
5645 b"repository content)\n"
5657 b"repository content)\n"
5646 )
5658 )
5647 ui.warn(msg)
5659 ui.warn(msg)
5648 return 0
5660 return 0
5649 return 1
5661 return 1
5650
5662
5651
5663
5652 @command(
5664 @command(
5653 b'remove|rm',
5665 b'remove|rm',
5654 [
5666 [
5655 (b'A', b'after', None, _(b'record delete for missing files')),
5667 (b'A', b'after', None, _(b'record delete for missing files')),
5656 (b'f', b'force', None, _(b'forget added files, delete modified files')),
5668 (b'f', b'force', None, _(b'forget added files, delete modified files')),
5657 ]
5669 ]
5658 + subrepoopts
5670 + subrepoopts
5659 + walkopts
5671 + walkopts
5660 + dryrunopts,
5672 + dryrunopts,
5661 _(b'[OPTION]... FILE...'),
5673 _(b'[OPTION]... FILE...'),
5662 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
5674 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
5663 helpbasic=True,
5675 helpbasic=True,
5664 inferrepo=True,
5676 inferrepo=True,
5665 )
5677 )
5666 def remove(ui, repo, *pats, **opts):
5678 def remove(ui, repo, *pats, **opts):
5667 """remove the specified files on the next commit
5679 """remove the specified files on the next commit
5668
5680
5669 Schedule the indicated files for removal from the current branch.
5681 Schedule the indicated files for removal from the current branch.
5670
5682
5671 This command schedules the files to be removed at the next commit.
5683 This command schedules the files to be removed at the next commit.
5672 To undo a remove before that, see :hg:`revert`. To undo added
5684 To undo a remove before that, see :hg:`revert`. To undo added
5673 files, see :hg:`forget`.
5685 files, see :hg:`forget`.
5674
5686
5675 .. container:: verbose
5687 .. container:: verbose
5676
5688
5677 -A/--after can be used to remove only files that have already
5689 -A/--after can be used to remove only files that have already
5678 been deleted, -f/--force can be used to force deletion, and -Af
5690 been deleted, -f/--force can be used to force deletion, and -Af
5679 can be used to remove files from the next revision without
5691 can be used to remove files from the next revision without
5680 deleting them from the working directory.
5692 deleting them from the working directory.
5681
5693
5682 The following table details the behavior of remove for different
5694 The following table details the behavior of remove for different
5683 file states (columns) and option combinations (rows). The file
5695 file states (columns) and option combinations (rows). The file
5684 states are Added [A], Clean [C], Modified [M] and Missing [!]
5696 states are Added [A], Clean [C], Modified [M] and Missing [!]
5685 (as reported by :hg:`status`). The actions are Warn, Remove
5697 (as reported by :hg:`status`). The actions are Warn, Remove
5686 (from branch) and Delete (from disk):
5698 (from branch) and Delete (from disk):
5687
5699
5688 ========= == == == ==
5700 ========= == == == ==
5689 opt/state A C M !
5701 opt/state A C M !
5690 ========= == == == ==
5702 ========= == == == ==
5691 none W RD W R
5703 none W RD W R
5692 -f R RD RD R
5704 -f R RD RD R
5693 -A W W W R
5705 -A W W W R
5694 -Af R R R R
5706 -Af R R R R
5695 ========= == == == ==
5707 ========= == == == ==
5696
5708
5697 .. note::
5709 .. note::
5698
5710
5699 :hg:`remove` never deletes files in Added [A] state from the
5711 :hg:`remove` never deletes files in Added [A] state from the
5700 working directory, not even if ``--force`` is specified.
5712 working directory, not even if ``--force`` is specified.
5701
5713
5702 Returns 0 on success, 1 if any warnings encountered.
5714 Returns 0 on success, 1 if any warnings encountered.
5703 """
5715 """
5704
5716
5705 opts = pycompat.byteskwargs(opts)
5717 opts = pycompat.byteskwargs(opts)
5706 after, force = opts.get(b'after'), opts.get(b'force')
5718 after, force = opts.get(b'after'), opts.get(b'force')
5707 dryrun = opts.get(b'dry_run')
5719 dryrun = opts.get(b'dry_run')
5708 if not pats and not after:
5720 if not pats and not after:
5709 raise error.InputError(_(b'no files specified'))
5721 raise error.InputError(_(b'no files specified'))
5710
5722
5711 m = scmutil.match(repo[None], pats, opts)
5723 m = scmutil.match(repo[None], pats, opts)
5712 subrepos = opts.get(b'subrepos')
5724 subrepos = opts.get(b'subrepos')
5713 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
5725 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
5714 return cmdutil.remove(
5726 return cmdutil.remove(
5715 ui, repo, m, b"", uipathfn, after, force, subrepos, dryrun=dryrun
5727 ui, repo, m, b"", uipathfn, after, force, subrepos, dryrun=dryrun
5716 )
5728 )
5717
5729
5718
5730
5719 @command(
5731 @command(
5720 b'rename|move|mv',
5732 b'rename|move|mv',
5721 [
5733 [
5722 (b'A', b'after', None, _(b'record a rename that has already occurred')),
5734 (b'A', b'after', None, _(b'record a rename that has already occurred')),
5723 (
5735 (
5724 b'',
5736 b'',
5725 b'at-rev',
5737 b'at-rev',
5726 b'',
5738 b'',
5727 _(b'(un)mark renames in the given revision (EXPERIMENTAL)'),
5739 _(b'(un)mark renames in the given revision (EXPERIMENTAL)'),
5728 _(b'REV'),
5740 _(b'REV'),
5729 ),
5741 ),
5730 (
5742 (
5731 b'f',
5743 b'f',
5732 b'force',
5744 b'force',
5733 None,
5745 None,
5734 _(b'forcibly move over an existing managed file'),
5746 _(b'forcibly move over an existing managed file'),
5735 ),
5747 ),
5736 ]
5748 ]
5737 + walkopts
5749 + walkopts
5738 + dryrunopts,
5750 + dryrunopts,
5739 _(b'[OPTION]... SOURCE... DEST'),
5751 _(b'[OPTION]... SOURCE... DEST'),
5740 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
5752 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
5741 )
5753 )
5742 def rename(ui, repo, *pats, **opts):
5754 def rename(ui, repo, *pats, **opts):
5743 """rename files; equivalent of copy + remove
5755 """rename files; equivalent of copy + remove
5744
5756
5745 Mark dest as copies of sources; mark sources for deletion. If dest
5757 Mark dest as copies of sources; mark sources for deletion. If dest
5746 is a directory, copies are put in that directory. If dest is a
5758 is a directory, copies are put in that directory. If dest is a
5747 file, there can only be one source.
5759 file, there can only be one source.
5748
5760
5749 By default, this command copies the contents of files as they
5761 By default, this command copies the contents of files as they
5750 exist in the working directory. If invoked with -A/--after, the
5762 exist in the working directory. If invoked with -A/--after, the
5751 operation is recorded, but no copying is performed.
5763 operation is recorded, but no copying is performed.
5752
5764
5753 This command takes effect at the next commit. To undo a rename
5765 This command takes effect at the next commit. To undo a rename
5754 before that, see :hg:`revert`.
5766 before that, see :hg:`revert`.
5755
5767
5756 Returns 0 on success, 1 if errors are encountered.
5768 Returns 0 on success, 1 if errors are encountered.
5757 """
5769 """
5758 opts = pycompat.byteskwargs(opts)
5770 opts = pycompat.byteskwargs(opts)
5759 with repo.wlock():
5771 with repo.wlock():
5760 return cmdutil.copy(ui, repo, pats, opts, rename=True)
5772 return cmdutil.copy(ui, repo, pats, opts, rename=True)
5761
5773
5762
5774
5763 @command(
5775 @command(
5764 b'resolve',
5776 b'resolve',
5765 [
5777 [
5766 (b'a', b'all', None, _(b'select all unresolved files')),
5778 (b'a', b'all', None, _(b'select all unresolved files')),
5767 (b'l', b'list', None, _(b'list state of files needing merge')),
5779 (b'l', b'list', None, _(b'list state of files needing merge')),
5768 (b'm', b'mark', None, _(b'mark files as resolved')),
5780 (b'm', b'mark', None, _(b'mark files as resolved')),
5769 (b'u', b'unmark', None, _(b'mark files as unresolved')),
5781 (b'u', b'unmark', None, _(b'mark files as unresolved')),
5770 (b'n', b'no-status', None, _(b'hide status prefix')),
5782 (b'n', b'no-status', None, _(b'hide status prefix')),
5771 (b'', b're-merge', None, _(b're-merge files')),
5783 (b'', b're-merge', None, _(b're-merge files')),
5772 ]
5784 ]
5773 + mergetoolopts
5785 + mergetoolopts
5774 + walkopts
5786 + walkopts
5775 + formatteropts,
5787 + formatteropts,
5776 _(b'[OPTION]... [FILE]...'),
5788 _(b'[OPTION]... [FILE]...'),
5777 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
5789 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
5778 inferrepo=True,
5790 inferrepo=True,
5779 )
5791 )
5780 def resolve(ui, repo, *pats, **opts):
5792 def resolve(ui, repo, *pats, **opts):
5781 """redo merges or set/view the merge status of files
5793 """redo merges or set/view the merge status of files
5782
5794
5783 Merges with unresolved conflicts are often the result of
5795 Merges with unresolved conflicts are often the result of
5784 non-interactive merging using the ``internal:merge`` configuration
5796 non-interactive merging using the ``internal:merge`` configuration
5785 setting, or a command-line merge tool like ``diff3``. The resolve
5797 setting, or a command-line merge tool like ``diff3``. The resolve
5786 command is used to manage the files involved in a merge, after
5798 command is used to manage the files involved in a merge, after
5787 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
5799 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
5788 working directory must have two parents). See :hg:`help
5800 working directory must have two parents). See :hg:`help
5789 merge-tools` for information on configuring merge tools.
5801 merge-tools` for information on configuring merge tools.
5790
5802
5791 The resolve command can be used in the following ways:
5803 The resolve command can be used in the following ways:
5792
5804
5793 - :hg:`resolve [--re-merge] [--tool TOOL] FILE...`: attempt to re-merge
5805 - :hg:`resolve [--re-merge] [--tool TOOL] FILE...`: attempt to re-merge
5794 the specified files, discarding any previous merge attempts. Re-merging
5806 the specified files, discarding any previous merge attempts. Re-merging
5795 is not performed for files already marked as resolved. Use ``--all/-a``
5807 is not performed for files already marked as resolved. Use ``--all/-a``
5796 to select all unresolved files. ``--tool`` can be used to specify
5808 to select all unresolved files. ``--tool`` can be used to specify
5797 the merge tool used for the given files. It overrides the HGMERGE
5809 the merge tool used for the given files. It overrides the HGMERGE
5798 environment variable and your configuration files. Previous file
5810 environment variable and your configuration files. Previous file
5799 contents are saved with a ``.orig`` suffix.
5811 contents are saved with a ``.orig`` suffix.
5800
5812
5801 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
5813 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
5802 (e.g. after having manually fixed-up the files). The default is
5814 (e.g. after having manually fixed-up the files). The default is
5803 to mark all unresolved files.
5815 to mark all unresolved files.
5804
5816
5805 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
5817 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
5806 default is to mark all resolved files.
5818 default is to mark all resolved files.
5807
5819
5808 - :hg:`resolve -l`: list files which had or still have conflicts.
5820 - :hg:`resolve -l`: list files which had or still have conflicts.
5809 In the printed list, ``U`` = unresolved and ``R`` = resolved.
5821 In the printed list, ``U`` = unresolved and ``R`` = resolved.
5810 You can use ``set:unresolved()`` or ``set:resolved()`` to filter
5822 You can use ``set:unresolved()`` or ``set:resolved()`` to filter
5811 the list. See :hg:`help filesets` for details.
5823 the list. See :hg:`help filesets` for details.
5812
5824
5813 .. note::
5825 .. note::
5814
5826
5815 Mercurial will not let you commit files with unresolved merge
5827 Mercurial will not let you commit files with unresolved merge
5816 conflicts. You must use :hg:`resolve -m ...` before you can
5828 conflicts. You must use :hg:`resolve -m ...` before you can
5817 commit after a conflicting merge.
5829 commit after a conflicting merge.
5818
5830
5819 .. container:: verbose
5831 .. container:: verbose
5820
5832
5821 Template:
5833 Template:
5822
5834
5823 The following keywords are supported in addition to the common template
5835 The following keywords are supported in addition to the common template
5824 keywords and functions. See also :hg:`help templates`.
5836 keywords and functions. See also :hg:`help templates`.
5825
5837
5826 :mergestatus: String. Character denoting merge conflicts, ``U`` or ``R``.
5838 :mergestatus: String. Character denoting merge conflicts, ``U`` or ``R``.
5827 :path: String. Repository-absolute path of the file.
5839 :path: String. Repository-absolute path of the file.
5828
5840
5829 Returns 0 on success, 1 if any files fail a resolve attempt.
5841 Returns 0 on success, 1 if any files fail a resolve attempt.
5830 """
5842 """
5831
5843
5832 opts = pycompat.byteskwargs(opts)
5844 opts = pycompat.byteskwargs(opts)
5833 confirm = ui.configbool(b'commands', b'resolve.confirm')
5845 confirm = ui.configbool(b'commands', b'resolve.confirm')
5834 flaglist = b'all mark unmark list no_status re_merge'.split()
5846 flaglist = b'all mark unmark list no_status re_merge'.split()
5835 all, mark, unmark, show, nostatus, remerge = [opts.get(o) for o in flaglist]
5847 all, mark, unmark, show, nostatus, remerge = [opts.get(o) for o in flaglist]
5836
5848
5837 actioncount = len(list(filter(None, [show, mark, unmark, remerge])))
5849 actioncount = len(list(filter(None, [show, mark, unmark, remerge])))
5838 if actioncount > 1:
5850 if actioncount > 1:
5839 raise error.InputError(_(b"too many actions specified"))
5851 raise error.InputError(_(b"too many actions specified"))
5840 elif actioncount == 0 and ui.configbool(
5852 elif actioncount == 0 and ui.configbool(
5841 b'commands', b'resolve.explicit-re-merge'
5853 b'commands', b'resolve.explicit-re-merge'
5842 ):
5854 ):
5843 hint = _(b'use --mark, --unmark, --list or --re-merge')
5855 hint = _(b'use --mark, --unmark, --list or --re-merge')
5844 raise error.InputError(_(b'no action specified'), hint=hint)
5856 raise error.InputError(_(b'no action specified'), hint=hint)
5845 if pats and all:
5857 if pats and all:
5846 raise error.InputError(_(b"can't specify --all and patterns"))
5858 raise error.InputError(_(b"can't specify --all and patterns"))
5847 if not (all or pats or show or mark or unmark):
5859 if not (all or pats or show or mark or unmark):
5848 raise error.InputError(
5860 raise error.InputError(
5849 _(b'no files or directories specified'),
5861 _(b'no files or directories specified'),
5850 hint=b'use --all to re-merge all unresolved files',
5862 hint=b'use --all to re-merge all unresolved files',
5851 )
5863 )
5852
5864
5853 if confirm:
5865 if confirm:
5854 if all:
5866 if all:
5855 if ui.promptchoice(
5867 if ui.promptchoice(
5856 _(b're-merge all unresolved files (yn)?$$ &Yes $$ &No')
5868 _(b're-merge all unresolved files (yn)?$$ &Yes $$ &No')
5857 ):
5869 ):
5858 raise error.CanceledError(_(b'user quit'))
5870 raise error.CanceledError(_(b'user quit'))
5859 if mark and not pats:
5871 if mark and not pats:
5860 if ui.promptchoice(
5872 if ui.promptchoice(
5861 _(
5873 _(
5862 b'mark all unresolved files as resolved (yn)?'
5874 b'mark all unresolved files as resolved (yn)?'
5863 b'$$ &Yes $$ &No'
5875 b'$$ &Yes $$ &No'
5864 )
5876 )
5865 ):
5877 ):
5866 raise error.CanceledError(_(b'user quit'))
5878 raise error.CanceledError(_(b'user quit'))
5867 if unmark and not pats:
5879 if unmark and not pats:
5868 if ui.promptchoice(
5880 if ui.promptchoice(
5869 _(
5881 _(
5870 b'mark all resolved files as unresolved (yn)?'
5882 b'mark all resolved files as unresolved (yn)?'
5871 b'$$ &Yes $$ &No'
5883 b'$$ &Yes $$ &No'
5872 )
5884 )
5873 ):
5885 ):
5874 raise error.CanceledError(_(b'user quit'))
5886 raise error.CanceledError(_(b'user quit'))
5875
5887
5876 uipathfn = scmutil.getuipathfn(repo)
5888 uipathfn = scmutil.getuipathfn(repo)
5877
5889
5878 if show:
5890 if show:
5879 ui.pager(b'resolve')
5891 ui.pager(b'resolve')
5880 fm = ui.formatter(b'resolve', opts)
5892 fm = ui.formatter(b'resolve', opts)
5881 ms = mergestatemod.mergestate.read(repo)
5893 ms = mergestatemod.mergestate.read(repo)
5882 wctx = repo[None]
5894 wctx = repo[None]
5883 m = scmutil.match(wctx, pats, opts)
5895 m = scmutil.match(wctx, pats, opts)
5884
5896
5885 # Labels and keys based on merge state. Unresolved path conflicts show
5897 # Labels and keys based on merge state. Unresolved path conflicts show
5886 # as 'P'. Resolved path conflicts show as 'R', the same as normal
5898 # as 'P'. Resolved path conflicts show as 'R', the same as normal
5887 # resolved conflicts.
5899 # resolved conflicts.
5888 mergestateinfo = {
5900 mergestateinfo = {
5889 mergestatemod.MERGE_RECORD_UNRESOLVED: (
5901 mergestatemod.MERGE_RECORD_UNRESOLVED: (
5890 b'resolve.unresolved',
5902 b'resolve.unresolved',
5891 b'U',
5903 b'U',
5892 ),
5904 ),
5893 mergestatemod.MERGE_RECORD_RESOLVED: (b'resolve.resolved', b'R'),
5905 mergestatemod.MERGE_RECORD_RESOLVED: (b'resolve.resolved', b'R'),
5894 mergestatemod.MERGE_RECORD_UNRESOLVED_PATH: (
5906 mergestatemod.MERGE_RECORD_UNRESOLVED_PATH: (
5895 b'resolve.unresolved',
5907 b'resolve.unresolved',
5896 b'P',
5908 b'P',
5897 ),
5909 ),
5898 mergestatemod.MERGE_RECORD_RESOLVED_PATH: (
5910 mergestatemod.MERGE_RECORD_RESOLVED_PATH: (
5899 b'resolve.resolved',
5911 b'resolve.resolved',
5900 b'R',
5912 b'R',
5901 ),
5913 ),
5902 }
5914 }
5903
5915
5904 for f in ms:
5916 for f in ms:
5905 if not m(f):
5917 if not m(f):
5906 continue
5918 continue
5907
5919
5908 label, key = mergestateinfo[ms[f]]
5920 label, key = mergestateinfo[ms[f]]
5909 fm.startitem()
5921 fm.startitem()
5910 fm.context(ctx=wctx)
5922 fm.context(ctx=wctx)
5911 fm.condwrite(not nostatus, b'mergestatus', b'%s ', key, label=label)
5923 fm.condwrite(not nostatus, b'mergestatus', b'%s ', key, label=label)
5912 fm.data(path=f)
5924 fm.data(path=f)
5913 fm.plain(b'%s\n' % uipathfn(f), label=label)
5925 fm.plain(b'%s\n' % uipathfn(f), label=label)
5914 fm.end()
5926 fm.end()
5915 return 0
5927 return 0
5916
5928
5917 with repo.wlock():
5929 with repo.wlock():
5918 ms = mergestatemod.mergestate.read(repo)
5930 ms = mergestatemod.mergestate.read(repo)
5919
5931
5920 if not (ms.active() or repo.dirstate.p2() != nullid):
5932 if not (ms.active() or repo.dirstate.p2() != nullid):
5921 raise error.StateError(
5933 raise error.StateError(
5922 _(b'resolve command not applicable when not merging')
5934 _(b'resolve command not applicable when not merging')
5923 )
5935 )
5924
5936
5925 wctx = repo[None]
5937 wctx = repo[None]
5926 m = scmutil.match(wctx, pats, opts)
5938 m = scmutil.match(wctx, pats, opts)
5927 ret = 0
5939 ret = 0
5928 didwork = False
5940 didwork = False
5929
5941
5930 tocomplete = []
5942 tocomplete = []
5931 hasconflictmarkers = []
5943 hasconflictmarkers = []
5932 if mark:
5944 if mark:
5933 markcheck = ui.config(b'commands', b'resolve.mark-check')
5945 markcheck = ui.config(b'commands', b'resolve.mark-check')
5934 if markcheck not in [b'warn', b'abort']:
5946 if markcheck not in [b'warn', b'abort']:
5935 # Treat all invalid / unrecognized values as 'none'.
5947 # Treat all invalid / unrecognized values as 'none'.
5936 markcheck = False
5948 markcheck = False
5937 for f in ms:
5949 for f in ms:
5938 if not m(f):
5950 if not m(f):
5939 continue
5951 continue
5940
5952
5941 didwork = True
5953 didwork = True
5942
5954
5943 # path conflicts must be resolved manually
5955 # path conflicts must be resolved manually
5944 if ms[f] in (
5956 if ms[f] in (
5945 mergestatemod.MERGE_RECORD_UNRESOLVED_PATH,
5957 mergestatemod.MERGE_RECORD_UNRESOLVED_PATH,
5946 mergestatemod.MERGE_RECORD_RESOLVED_PATH,
5958 mergestatemod.MERGE_RECORD_RESOLVED_PATH,
5947 ):
5959 ):
5948 if mark:
5960 if mark:
5949 ms.mark(f, mergestatemod.MERGE_RECORD_RESOLVED_PATH)
5961 ms.mark(f, mergestatemod.MERGE_RECORD_RESOLVED_PATH)
5950 elif unmark:
5962 elif unmark:
5951 ms.mark(f, mergestatemod.MERGE_RECORD_UNRESOLVED_PATH)
5963 ms.mark(f, mergestatemod.MERGE_RECORD_UNRESOLVED_PATH)
5952 elif ms[f] == mergestatemod.MERGE_RECORD_UNRESOLVED_PATH:
5964 elif ms[f] == mergestatemod.MERGE_RECORD_UNRESOLVED_PATH:
5953 ui.warn(
5965 ui.warn(
5954 _(b'%s: path conflict must be resolved manually\n')
5966 _(b'%s: path conflict must be resolved manually\n')
5955 % uipathfn(f)
5967 % uipathfn(f)
5956 )
5968 )
5957 continue
5969 continue
5958
5970
5959 if mark:
5971 if mark:
5960 if markcheck:
5972 if markcheck:
5961 fdata = repo.wvfs.tryread(f)
5973 fdata = repo.wvfs.tryread(f)
5962 if (
5974 if (
5963 filemerge.hasconflictmarkers(fdata)
5975 filemerge.hasconflictmarkers(fdata)
5964 and ms[f] != mergestatemod.MERGE_RECORD_RESOLVED
5976 and ms[f] != mergestatemod.MERGE_RECORD_RESOLVED
5965 ):
5977 ):
5966 hasconflictmarkers.append(f)
5978 hasconflictmarkers.append(f)
5967 ms.mark(f, mergestatemod.MERGE_RECORD_RESOLVED)
5979 ms.mark(f, mergestatemod.MERGE_RECORD_RESOLVED)
5968 elif unmark:
5980 elif unmark:
5969 ms.mark(f, mergestatemod.MERGE_RECORD_UNRESOLVED)
5981 ms.mark(f, mergestatemod.MERGE_RECORD_UNRESOLVED)
5970 else:
5982 else:
5971 # backup pre-resolve (merge uses .orig for its own purposes)
5983 # backup pre-resolve (merge uses .orig for its own purposes)
5972 a = repo.wjoin(f)
5984 a = repo.wjoin(f)
5973 try:
5985 try:
5974 util.copyfile(a, a + b".resolve")
5986 util.copyfile(a, a + b".resolve")
5975 except (IOError, OSError) as inst:
5987 except (IOError, OSError) as inst:
5976 if inst.errno != errno.ENOENT:
5988 if inst.errno != errno.ENOENT:
5977 raise
5989 raise
5978
5990
5979 try:
5991 try:
5980 # preresolve file
5992 # preresolve file
5981 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
5993 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
5982 with ui.configoverride(overrides, b'resolve'):
5994 with ui.configoverride(overrides, b'resolve'):
5983 complete, r = ms.preresolve(f, wctx)
5995 complete, r = ms.preresolve(f, wctx)
5984 if not complete:
5996 if not complete:
5985 tocomplete.append(f)
5997 tocomplete.append(f)
5986 elif r:
5998 elif r:
5987 ret = 1
5999 ret = 1
5988 finally:
6000 finally:
5989 ms.commit()
6001 ms.commit()
5990
6002
5991 # replace filemerge's .orig file with our resolve file, but only
6003 # replace filemerge's .orig file with our resolve file, but only
5992 # for merges that are complete
6004 # for merges that are complete
5993 if complete:
6005 if complete:
5994 try:
6006 try:
5995 util.rename(
6007 util.rename(
5996 a + b".resolve", scmutil.backuppath(ui, repo, f)
6008 a + b".resolve", scmutil.backuppath(ui, repo, f)
5997 )
6009 )
5998 except OSError as inst:
6010 except OSError as inst:
5999 if inst.errno != errno.ENOENT:
6011 if inst.errno != errno.ENOENT:
6000 raise
6012 raise
6001
6013
6002 if hasconflictmarkers:
6014 if hasconflictmarkers:
6003 ui.warn(
6015 ui.warn(
6004 _(
6016 _(
6005 b'warning: the following files still have conflict '
6017 b'warning: the following files still have conflict '
6006 b'markers:\n'
6018 b'markers:\n'
6007 )
6019 )
6008 + b''.join(
6020 + b''.join(
6009 b' ' + uipathfn(f) + b'\n' for f in hasconflictmarkers
6021 b' ' + uipathfn(f) + b'\n' for f in hasconflictmarkers
6010 )
6022 )
6011 )
6023 )
6012 if markcheck == b'abort' and not all and not pats:
6024 if markcheck == b'abort' and not all and not pats:
6013 raise error.StateError(
6025 raise error.StateError(
6014 _(b'conflict markers detected'),
6026 _(b'conflict markers detected'),
6015 hint=_(b'use --all to mark anyway'),
6027 hint=_(b'use --all to mark anyway'),
6016 )
6028 )
6017
6029
6018 for f in tocomplete:
6030 for f in tocomplete:
6019 try:
6031 try:
6020 # resolve file
6032 # resolve file
6021 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
6033 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
6022 with ui.configoverride(overrides, b'resolve'):
6034 with ui.configoverride(overrides, b'resolve'):
6023 r = ms.resolve(f, wctx)
6035 r = ms.resolve(f, wctx)
6024 if r:
6036 if r:
6025 ret = 1
6037 ret = 1
6026 finally:
6038 finally:
6027 ms.commit()
6039 ms.commit()
6028
6040
6029 # replace filemerge's .orig file with our resolve file
6041 # replace filemerge's .orig file with our resolve file
6030 a = repo.wjoin(f)
6042 a = repo.wjoin(f)
6031 try:
6043 try:
6032 util.rename(a + b".resolve", scmutil.backuppath(ui, repo, f))
6044 util.rename(a + b".resolve", scmutil.backuppath(ui, repo, f))
6033 except OSError as inst:
6045 except OSError as inst:
6034 if inst.errno != errno.ENOENT:
6046 if inst.errno != errno.ENOENT:
6035 raise
6047 raise
6036
6048
6037 ms.commit()
6049 ms.commit()
6038 branchmerge = repo.dirstate.p2() != nullid
6050 branchmerge = repo.dirstate.p2() != nullid
6039 mergestatemod.recordupdates(repo, ms.actions(), branchmerge, None)
6051 mergestatemod.recordupdates(repo, ms.actions(), branchmerge, None)
6040
6052
6041 if not didwork and pats:
6053 if not didwork and pats:
6042 hint = None
6054 hint = None
6043 if not any([p for p in pats if p.find(b':') >= 0]):
6055 if not any([p for p in pats if p.find(b':') >= 0]):
6044 pats = [b'path:%s' % p for p in pats]
6056 pats = [b'path:%s' % p for p in pats]
6045 m = scmutil.match(wctx, pats, opts)
6057 m = scmutil.match(wctx, pats, opts)
6046 for f in ms:
6058 for f in ms:
6047 if not m(f):
6059 if not m(f):
6048 continue
6060 continue
6049
6061
6050 def flag(o):
6062 def flag(o):
6051 if o == b're_merge':
6063 if o == b're_merge':
6052 return b'--re-merge '
6064 return b'--re-merge '
6053 return b'-%s ' % o[0:1]
6065 return b'-%s ' % o[0:1]
6054
6066
6055 flags = b''.join([flag(o) for o in flaglist if opts.get(o)])
6067 flags = b''.join([flag(o) for o in flaglist if opts.get(o)])
6056 hint = _(b"(try: hg resolve %s%s)\n") % (
6068 hint = _(b"(try: hg resolve %s%s)\n") % (
6057 flags,
6069 flags,
6058 b' '.join(pats),
6070 b' '.join(pats),
6059 )
6071 )
6060 break
6072 break
6061 ui.warn(_(b"arguments do not match paths that need resolving\n"))
6073 ui.warn(_(b"arguments do not match paths that need resolving\n"))
6062 if hint:
6074 if hint:
6063 ui.warn(hint)
6075 ui.warn(hint)
6064
6076
6065 unresolvedf = list(ms.unresolved())
6077 unresolvedf = list(ms.unresolved())
6066 if not unresolvedf:
6078 if not unresolvedf:
6067 ui.status(_(b'(no more unresolved files)\n'))
6079 ui.status(_(b'(no more unresolved files)\n'))
6068 cmdutil.checkafterresolved(repo)
6080 cmdutil.checkafterresolved(repo)
6069
6081
6070 return ret
6082 return ret
6071
6083
6072
6084
6073 @command(
6085 @command(
6074 b'revert',
6086 b'revert',
6075 [
6087 [
6076 (b'a', b'all', None, _(b'revert all changes when no arguments given')),
6088 (b'a', b'all', None, _(b'revert all changes when no arguments given')),
6077 (b'd', b'date', b'', _(b'tipmost revision matching date'), _(b'DATE')),
6089 (b'd', b'date', b'', _(b'tipmost revision matching date'), _(b'DATE')),
6078 (b'r', b'rev', b'', _(b'revert to the specified revision'), _(b'REV')),
6090 (b'r', b'rev', b'', _(b'revert to the specified revision'), _(b'REV')),
6079 (b'C', b'no-backup', None, _(b'do not save backup copies of files')),
6091 (b'C', b'no-backup', None, _(b'do not save backup copies of files')),
6080 (b'i', b'interactive', None, _(b'interactively select the changes')),
6092 (b'i', b'interactive', None, _(b'interactively select the changes')),
6081 ]
6093 ]
6082 + walkopts
6094 + walkopts
6083 + dryrunopts,
6095 + dryrunopts,
6084 _(b'[OPTION]... [-r REV] [NAME]...'),
6096 _(b'[OPTION]... [-r REV] [NAME]...'),
6085 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6097 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6086 )
6098 )
6087 def revert(ui, repo, *pats, **opts):
6099 def revert(ui, repo, *pats, **opts):
6088 """restore files to their checkout state
6100 """restore files to their checkout state
6089
6101
6090 .. note::
6102 .. note::
6091
6103
6092 To check out earlier revisions, you should use :hg:`update REV`.
6104 To check out earlier revisions, you should use :hg:`update REV`.
6093 To cancel an uncommitted merge (and lose your changes),
6105 To cancel an uncommitted merge (and lose your changes),
6094 use :hg:`merge --abort`.
6106 use :hg:`merge --abort`.
6095
6107
6096 With no revision specified, revert the specified files or directories
6108 With no revision specified, revert the specified files or directories
6097 to the contents they had in the parent of the working directory.
6109 to the contents they had in the parent of the working directory.
6098 This restores the contents of files to an unmodified
6110 This restores the contents of files to an unmodified
6099 state and unschedules adds, removes, copies, and renames. If the
6111 state and unschedules adds, removes, copies, and renames. If the
6100 working directory has two parents, you must explicitly specify a
6112 working directory has two parents, you must explicitly specify a
6101 revision.
6113 revision.
6102
6114
6103 Using the -r/--rev or -d/--date options, revert the given files or
6115 Using the -r/--rev or -d/--date options, revert the given files or
6104 directories to their states as of a specific revision. Because
6116 directories to their states as of a specific revision. Because
6105 revert does not change the working directory parents, this will
6117 revert does not change the working directory parents, this will
6106 cause these files to appear modified. This can be helpful to "back
6118 cause these files to appear modified. This can be helpful to "back
6107 out" some or all of an earlier change. See :hg:`backout` for a
6119 out" some or all of an earlier change. See :hg:`backout` for a
6108 related method.
6120 related method.
6109
6121
6110 Modified files are saved with a .orig suffix before reverting.
6122 Modified files are saved with a .orig suffix before reverting.
6111 To disable these backups, use --no-backup. It is possible to store
6123 To disable these backups, use --no-backup. It is possible to store
6112 the backup files in a custom directory relative to the root of the
6124 the backup files in a custom directory relative to the root of the
6113 repository by setting the ``ui.origbackuppath`` configuration
6125 repository by setting the ``ui.origbackuppath`` configuration
6114 option.
6126 option.
6115
6127
6116 See :hg:`help dates` for a list of formats valid for -d/--date.
6128 See :hg:`help dates` for a list of formats valid for -d/--date.
6117
6129
6118 See :hg:`help backout` for a way to reverse the effect of an
6130 See :hg:`help backout` for a way to reverse the effect of an
6119 earlier changeset.
6131 earlier changeset.
6120
6132
6121 Returns 0 on success.
6133 Returns 0 on success.
6122 """
6134 """
6123
6135
6124 opts = pycompat.byteskwargs(opts)
6136 opts = pycompat.byteskwargs(opts)
6125 if opts.get(b"date"):
6137 if opts.get(b"date"):
6126 cmdutil.check_incompatible_arguments(opts, b'date', [b'rev'])
6138 cmdutil.check_incompatible_arguments(opts, b'date', [b'rev'])
6127 opts[b"rev"] = cmdutil.finddate(ui, repo, opts[b"date"])
6139 opts[b"rev"] = cmdutil.finddate(ui, repo, opts[b"date"])
6128
6140
6129 parent, p2 = repo.dirstate.parents()
6141 parent, p2 = repo.dirstate.parents()
6130 if not opts.get(b'rev') and p2 != nullid:
6142 if not opts.get(b'rev') and p2 != nullid:
6131 # revert after merge is a trap for new users (issue2915)
6143 # revert after merge is a trap for new users (issue2915)
6132 raise error.InputError(
6144 raise error.InputError(
6133 _(b'uncommitted merge with no revision specified'),
6145 _(b'uncommitted merge with no revision specified'),
6134 hint=_(b"use 'hg update' or see 'hg help revert'"),
6146 hint=_(b"use 'hg update' or see 'hg help revert'"),
6135 )
6147 )
6136
6148
6137 rev = opts.get(b'rev')
6149 rev = opts.get(b'rev')
6138 if rev:
6150 if rev:
6139 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
6151 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
6140 ctx = scmutil.revsingle(repo, rev)
6152 ctx = scmutil.revsingle(repo, rev)
6141
6153
6142 if not (
6154 if not (
6143 pats
6155 pats
6144 or opts.get(b'include')
6156 or opts.get(b'include')
6145 or opts.get(b'exclude')
6157 or opts.get(b'exclude')
6146 or opts.get(b'all')
6158 or opts.get(b'all')
6147 or opts.get(b'interactive')
6159 or opts.get(b'interactive')
6148 ):
6160 ):
6149 msg = _(b"no files or directories specified")
6161 msg = _(b"no files or directories specified")
6150 if p2 != nullid:
6162 if p2 != nullid:
6151 hint = _(
6163 hint = _(
6152 b"uncommitted merge, use --all to discard all changes,"
6164 b"uncommitted merge, use --all to discard all changes,"
6153 b" or 'hg update -C .' to abort the merge"
6165 b" or 'hg update -C .' to abort the merge"
6154 )
6166 )
6155 raise error.InputError(msg, hint=hint)
6167 raise error.InputError(msg, hint=hint)
6156 dirty = any(repo.status())
6168 dirty = any(repo.status())
6157 node = ctx.node()
6169 node = ctx.node()
6158 if node != parent:
6170 if node != parent:
6159 if dirty:
6171 if dirty:
6160 hint = (
6172 hint = (
6161 _(
6173 _(
6162 b"uncommitted changes, use --all to discard all"
6174 b"uncommitted changes, use --all to discard all"
6163 b" changes, or 'hg update %d' to update"
6175 b" changes, or 'hg update %d' to update"
6164 )
6176 )
6165 % ctx.rev()
6177 % ctx.rev()
6166 )
6178 )
6167 else:
6179 else:
6168 hint = (
6180 hint = (
6169 _(
6181 _(
6170 b"use --all to revert all files,"
6182 b"use --all to revert all files,"
6171 b" or 'hg update %d' to update"
6183 b" or 'hg update %d' to update"
6172 )
6184 )
6173 % ctx.rev()
6185 % ctx.rev()
6174 )
6186 )
6175 elif dirty:
6187 elif dirty:
6176 hint = _(b"uncommitted changes, use --all to discard all changes")
6188 hint = _(b"uncommitted changes, use --all to discard all changes")
6177 else:
6189 else:
6178 hint = _(b"use --all to revert all files")
6190 hint = _(b"use --all to revert all files")
6179 raise error.InputError(msg, hint=hint)
6191 raise error.InputError(msg, hint=hint)
6180
6192
6181 return cmdutil.revert(ui, repo, ctx, *pats, **pycompat.strkwargs(opts))
6193 return cmdutil.revert(ui, repo, ctx, *pats, **pycompat.strkwargs(opts))
6182
6194
6183
6195
6184 @command(
6196 @command(
6185 b'rollback',
6197 b'rollback',
6186 dryrunopts + [(b'f', b'force', False, _(b'ignore safety measures'))],
6198 dryrunopts + [(b'f', b'force', False, _(b'ignore safety measures'))],
6187 helpcategory=command.CATEGORY_MAINTENANCE,
6199 helpcategory=command.CATEGORY_MAINTENANCE,
6188 )
6200 )
6189 def rollback(ui, repo, **opts):
6201 def rollback(ui, repo, **opts):
6190 """roll back the last transaction (DANGEROUS) (DEPRECATED)
6202 """roll back the last transaction (DANGEROUS) (DEPRECATED)
6191
6203
6192 Please use :hg:`commit --amend` instead of rollback to correct
6204 Please use :hg:`commit --amend` instead of rollback to correct
6193 mistakes in the last commit.
6205 mistakes in the last commit.
6194
6206
6195 This command should be used with care. There is only one level of
6207 This command should be used with care. There is only one level of
6196 rollback, and there is no way to undo a rollback. It will also
6208 rollback, and there is no way to undo a rollback. It will also
6197 restore the dirstate at the time of the last transaction, losing
6209 restore the dirstate at the time of the last transaction, losing
6198 any dirstate changes since that time. This command does not alter
6210 any dirstate changes since that time. This command does not alter
6199 the working directory.
6211 the working directory.
6200
6212
6201 Transactions are used to encapsulate the effects of all commands
6213 Transactions are used to encapsulate the effects of all commands
6202 that create new changesets or propagate existing changesets into a
6214 that create new changesets or propagate existing changesets into a
6203 repository.
6215 repository.
6204
6216
6205 .. container:: verbose
6217 .. container:: verbose
6206
6218
6207 For example, the following commands are transactional, and their
6219 For example, the following commands are transactional, and their
6208 effects can be rolled back:
6220 effects can be rolled back:
6209
6221
6210 - commit
6222 - commit
6211 - import
6223 - import
6212 - pull
6224 - pull
6213 - push (with this repository as the destination)
6225 - push (with this repository as the destination)
6214 - unbundle
6226 - unbundle
6215
6227
6216 To avoid permanent data loss, rollback will refuse to rollback a
6228 To avoid permanent data loss, rollback will refuse to rollback a
6217 commit transaction if it isn't checked out. Use --force to
6229 commit transaction if it isn't checked out. Use --force to
6218 override this protection.
6230 override this protection.
6219
6231
6220 The rollback command can be entirely disabled by setting the
6232 The rollback command can be entirely disabled by setting the
6221 ``ui.rollback`` configuration setting to false. If you're here
6233 ``ui.rollback`` configuration setting to false. If you're here
6222 because you want to use rollback and it's disabled, you can
6234 because you want to use rollback and it's disabled, you can
6223 re-enable the command by setting ``ui.rollback`` to true.
6235 re-enable the command by setting ``ui.rollback`` to true.
6224
6236
6225 This command is not intended for use on public repositories. Once
6237 This command is not intended for use on public repositories. Once
6226 changes are visible for pull by other users, rolling a transaction
6238 changes are visible for pull by other users, rolling a transaction
6227 back locally is ineffective (someone else may already have pulled
6239 back locally is ineffective (someone else may already have pulled
6228 the changes). Furthermore, a race is possible with readers of the
6240 the changes). Furthermore, a race is possible with readers of the
6229 repository; for example an in-progress pull from the repository
6241 repository; for example an in-progress pull from the repository
6230 may fail if a rollback is performed.
6242 may fail if a rollback is performed.
6231
6243
6232 Returns 0 on success, 1 if no rollback data is available.
6244 Returns 0 on success, 1 if no rollback data is available.
6233 """
6245 """
6234 if not ui.configbool(b'ui', b'rollback'):
6246 if not ui.configbool(b'ui', b'rollback'):
6235 raise error.Abort(
6247 raise error.Abort(
6236 _(b'rollback is disabled because it is unsafe'),
6248 _(b'rollback is disabled because it is unsafe'),
6237 hint=b'see `hg help -v rollback` for information',
6249 hint=b'see `hg help -v rollback` for information',
6238 )
6250 )
6239 return repo.rollback(dryrun=opts.get('dry_run'), force=opts.get('force'))
6251 return repo.rollback(dryrun=opts.get('dry_run'), force=opts.get('force'))
6240
6252
6241
6253
6242 @command(
6254 @command(
6243 b'root',
6255 b'root',
6244 [] + formatteropts,
6256 [] + formatteropts,
6245 intents={INTENT_READONLY},
6257 intents={INTENT_READONLY},
6246 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6258 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6247 )
6259 )
6248 def root(ui, repo, **opts):
6260 def root(ui, repo, **opts):
6249 """print the root (top) of the current working directory
6261 """print the root (top) of the current working directory
6250
6262
6251 Print the root directory of the current repository.
6263 Print the root directory of the current repository.
6252
6264
6253 .. container:: verbose
6265 .. container:: verbose
6254
6266
6255 Template:
6267 Template:
6256
6268
6257 The following keywords are supported in addition to the common template
6269 The following keywords are supported in addition to the common template
6258 keywords and functions. See also :hg:`help templates`.
6270 keywords and functions. See also :hg:`help templates`.
6259
6271
6260 :hgpath: String. Path to the .hg directory.
6272 :hgpath: String. Path to the .hg directory.
6261 :storepath: String. Path to the directory holding versioned data.
6273 :storepath: String. Path to the directory holding versioned data.
6262
6274
6263 Returns 0 on success.
6275 Returns 0 on success.
6264 """
6276 """
6265 opts = pycompat.byteskwargs(opts)
6277 opts = pycompat.byteskwargs(opts)
6266 with ui.formatter(b'root', opts) as fm:
6278 with ui.formatter(b'root', opts) as fm:
6267 fm.startitem()
6279 fm.startitem()
6268 fm.write(b'reporoot', b'%s\n', repo.root)
6280 fm.write(b'reporoot', b'%s\n', repo.root)
6269 fm.data(hgpath=repo.path, storepath=repo.spath)
6281 fm.data(hgpath=repo.path, storepath=repo.spath)
6270
6282
6271
6283
6272 @command(
6284 @command(
6273 b'serve',
6285 b'serve',
6274 [
6286 [
6275 (
6287 (
6276 b'A',
6288 b'A',
6277 b'accesslog',
6289 b'accesslog',
6278 b'',
6290 b'',
6279 _(b'name of access log file to write to'),
6291 _(b'name of access log file to write to'),
6280 _(b'FILE'),
6292 _(b'FILE'),
6281 ),
6293 ),
6282 (b'd', b'daemon', None, _(b'run server in background')),
6294 (b'd', b'daemon', None, _(b'run server in background')),
6283 (b'', b'daemon-postexec', [], _(b'used internally by daemon mode')),
6295 (b'', b'daemon-postexec', [], _(b'used internally by daemon mode')),
6284 (
6296 (
6285 b'E',
6297 b'E',
6286 b'errorlog',
6298 b'errorlog',
6287 b'',
6299 b'',
6288 _(b'name of error log file to write to'),
6300 _(b'name of error log file to write to'),
6289 _(b'FILE'),
6301 _(b'FILE'),
6290 ),
6302 ),
6291 # use string type, then we can check if something was passed
6303 # use string type, then we can check if something was passed
6292 (
6304 (
6293 b'p',
6305 b'p',
6294 b'port',
6306 b'port',
6295 b'',
6307 b'',
6296 _(b'port to listen on (default: 8000)'),
6308 _(b'port to listen on (default: 8000)'),
6297 _(b'PORT'),
6309 _(b'PORT'),
6298 ),
6310 ),
6299 (
6311 (
6300 b'a',
6312 b'a',
6301 b'address',
6313 b'address',
6302 b'',
6314 b'',
6303 _(b'address to listen on (default: all interfaces)'),
6315 _(b'address to listen on (default: all interfaces)'),
6304 _(b'ADDR'),
6316 _(b'ADDR'),
6305 ),
6317 ),
6306 (
6318 (
6307 b'',
6319 b'',
6308 b'prefix',
6320 b'prefix',
6309 b'',
6321 b'',
6310 _(b'prefix path to serve from (default: server root)'),
6322 _(b'prefix path to serve from (default: server root)'),
6311 _(b'PREFIX'),
6323 _(b'PREFIX'),
6312 ),
6324 ),
6313 (
6325 (
6314 b'n',
6326 b'n',
6315 b'name',
6327 b'name',
6316 b'',
6328 b'',
6317 _(b'name to show in web pages (default: working directory)'),
6329 _(b'name to show in web pages (default: working directory)'),
6318 _(b'NAME'),
6330 _(b'NAME'),
6319 ),
6331 ),
6320 (
6332 (
6321 b'',
6333 b'',
6322 b'web-conf',
6334 b'web-conf',
6323 b'',
6335 b'',
6324 _(b"name of the hgweb config file (see 'hg help hgweb')"),
6336 _(b"name of the hgweb config file (see 'hg help hgweb')"),
6325 _(b'FILE'),
6337 _(b'FILE'),
6326 ),
6338 ),
6327 (
6339 (
6328 b'',
6340 b'',
6329 b'webdir-conf',
6341 b'webdir-conf',
6330 b'',
6342 b'',
6331 _(b'name of the hgweb config file (DEPRECATED)'),
6343 _(b'name of the hgweb config file (DEPRECATED)'),
6332 _(b'FILE'),
6344 _(b'FILE'),
6333 ),
6345 ),
6334 (
6346 (
6335 b'',
6347 b'',
6336 b'pid-file',
6348 b'pid-file',
6337 b'',
6349 b'',
6338 _(b'name of file to write process ID to'),
6350 _(b'name of file to write process ID to'),
6339 _(b'FILE'),
6351 _(b'FILE'),
6340 ),
6352 ),
6341 (b'', b'stdio', None, _(b'for remote clients (ADVANCED)')),
6353 (b'', b'stdio', None, _(b'for remote clients (ADVANCED)')),
6342 (
6354 (
6343 b'',
6355 b'',
6344 b'cmdserver',
6356 b'cmdserver',
6345 b'',
6357 b'',
6346 _(b'for remote clients (ADVANCED)'),
6358 _(b'for remote clients (ADVANCED)'),
6347 _(b'MODE'),
6359 _(b'MODE'),
6348 ),
6360 ),
6349 (b't', b'templates', b'', _(b'web templates to use'), _(b'TEMPLATE')),
6361 (b't', b'templates', b'', _(b'web templates to use'), _(b'TEMPLATE')),
6350 (b'', b'style', b'', _(b'template style to use'), _(b'STYLE')),
6362 (b'', b'style', b'', _(b'template style to use'), _(b'STYLE')),
6351 (b'6', b'ipv6', None, _(b'use IPv6 in addition to IPv4')),
6363 (b'6', b'ipv6', None, _(b'use IPv6 in addition to IPv4')),
6352 (b'', b'certificate', b'', _(b'SSL certificate file'), _(b'FILE')),
6364 (b'', b'certificate', b'', _(b'SSL certificate file'), _(b'FILE')),
6353 (b'', b'print-url', None, _(b'start and print only the URL')),
6365 (b'', b'print-url', None, _(b'start and print only the URL')),
6354 ]
6366 ]
6355 + subrepoopts,
6367 + subrepoopts,
6356 _(b'[OPTION]...'),
6368 _(b'[OPTION]...'),
6357 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
6369 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
6358 helpbasic=True,
6370 helpbasic=True,
6359 optionalrepo=True,
6371 optionalrepo=True,
6360 )
6372 )
6361 def serve(ui, repo, **opts):
6373 def serve(ui, repo, **opts):
6362 """start stand-alone webserver
6374 """start stand-alone webserver
6363
6375
6364 Start a local HTTP repository browser and pull server. You can use
6376 Start a local HTTP repository browser and pull server. You can use
6365 this for ad-hoc sharing and browsing of repositories. It is
6377 this for ad-hoc sharing and browsing of repositories. It is
6366 recommended to use a real web server to serve a repository for
6378 recommended to use a real web server to serve a repository for
6367 longer periods of time.
6379 longer periods of time.
6368
6380
6369 Please note that the server does not implement access control.
6381 Please note that the server does not implement access control.
6370 This means that, by default, anybody can read from the server and
6382 This means that, by default, anybody can read from the server and
6371 nobody can write to it by default. Set the ``web.allow-push``
6383 nobody can write to it by default. Set the ``web.allow-push``
6372 option to ``*`` to allow everybody to push to the server. You
6384 option to ``*`` to allow everybody to push to the server. You
6373 should use a real web server if you need to authenticate users.
6385 should use a real web server if you need to authenticate users.
6374
6386
6375 By default, the server logs accesses to stdout and errors to
6387 By default, the server logs accesses to stdout and errors to
6376 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
6388 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
6377 files.
6389 files.
6378
6390
6379 To have the server choose a free port number to listen on, specify
6391 To have the server choose a free port number to listen on, specify
6380 a port number of 0; in this case, the server will print the port
6392 a port number of 0; in this case, the server will print the port
6381 number it uses.
6393 number it uses.
6382
6394
6383 Returns 0 on success.
6395 Returns 0 on success.
6384 """
6396 """
6385
6397
6386 cmdutil.check_incompatible_arguments(opts, 'stdio', ['cmdserver'])
6398 cmdutil.check_incompatible_arguments(opts, 'stdio', ['cmdserver'])
6387 opts = pycompat.byteskwargs(opts)
6399 opts = pycompat.byteskwargs(opts)
6388 if opts[b"print_url"] and ui.verbose:
6400 if opts[b"print_url"] and ui.verbose:
6389 raise error.InputError(_(b"cannot use --print-url with --verbose"))
6401 raise error.InputError(_(b"cannot use --print-url with --verbose"))
6390
6402
6391 if opts[b"stdio"]:
6403 if opts[b"stdio"]:
6392 if repo is None:
6404 if repo is None:
6393 raise error.RepoError(
6405 raise error.RepoError(
6394 _(b"there is no Mercurial repository here (.hg not found)")
6406 _(b"there is no Mercurial repository here (.hg not found)")
6395 )
6407 )
6396 s = wireprotoserver.sshserver(ui, repo)
6408 s = wireprotoserver.sshserver(ui, repo)
6397 s.serve_forever()
6409 s.serve_forever()
6398 return
6410 return
6399
6411
6400 service = server.createservice(ui, repo, opts)
6412 service = server.createservice(ui, repo, opts)
6401 return server.runservice(opts, initfn=service.init, runfn=service.run)
6413 return server.runservice(opts, initfn=service.init, runfn=service.run)
6402
6414
6403
6415
6404 @command(
6416 @command(
6405 b'shelve',
6417 b'shelve',
6406 [
6418 [
6407 (
6419 (
6408 b'A',
6420 b'A',
6409 b'addremove',
6421 b'addremove',
6410 None,
6422 None,
6411 _(b'mark new/missing files as added/removed before shelving'),
6423 _(b'mark new/missing files as added/removed before shelving'),
6412 ),
6424 ),
6413 (b'u', b'unknown', None, _(b'store unknown files in the shelve')),
6425 (b'u', b'unknown', None, _(b'store unknown files in the shelve')),
6414 (b'', b'cleanup', None, _(b'delete all shelved changes')),
6426 (b'', b'cleanup', None, _(b'delete all shelved changes')),
6415 (
6427 (
6416 b'',
6428 b'',
6417 b'date',
6429 b'date',
6418 b'',
6430 b'',
6419 _(b'shelve with the specified commit date'),
6431 _(b'shelve with the specified commit date'),
6420 _(b'DATE'),
6432 _(b'DATE'),
6421 ),
6433 ),
6422 (b'd', b'delete', None, _(b'delete the named shelved change(s)')),
6434 (b'd', b'delete', None, _(b'delete the named shelved change(s)')),
6423 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
6435 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
6424 (
6436 (
6425 b'k',
6437 b'k',
6426 b'keep',
6438 b'keep',
6427 False,
6439 False,
6428 _(b'shelve, but keep changes in the working directory'),
6440 _(b'shelve, but keep changes in the working directory'),
6429 ),
6441 ),
6430 (b'l', b'list', None, _(b'list current shelves')),
6442 (b'l', b'list', None, _(b'list current shelves')),
6431 (b'm', b'message', b'', _(b'use text as shelve message'), _(b'TEXT')),
6443 (b'm', b'message', b'', _(b'use text as shelve message'), _(b'TEXT')),
6432 (
6444 (
6433 b'n',
6445 b'n',
6434 b'name',
6446 b'name',
6435 b'',
6447 b'',
6436 _(b'use the given name for the shelved commit'),
6448 _(b'use the given name for the shelved commit'),
6437 _(b'NAME'),
6449 _(b'NAME'),
6438 ),
6450 ),
6439 (
6451 (
6440 b'p',
6452 b'p',
6441 b'patch',
6453 b'patch',
6442 None,
6454 None,
6443 _(
6455 _(
6444 b'output patches for changes (provide the names of the shelved '
6456 b'output patches for changes (provide the names of the shelved '
6445 b'changes as positional arguments)'
6457 b'changes as positional arguments)'
6446 ),
6458 ),
6447 ),
6459 ),
6448 (b'i', b'interactive', None, _(b'interactive mode')),
6460 (b'i', b'interactive', None, _(b'interactive mode')),
6449 (
6461 (
6450 b'',
6462 b'',
6451 b'stat',
6463 b'stat',
6452 None,
6464 None,
6453 _(
6465 _(
6454 b'output diffstat-style summary of changes (provide the names of '
6466 b'output diffstat-style summary of changes (provide the names of '
6455 b'the shelved changes as positional arguments)'
6467 b'the shelved changes as positional arguments)'
6456 ),
6468 ),
6457 ),
6469 ),
6458 ]
6470 ]
6459 + cmdutil.walkopts,
6471 + cmdutil.walkopts,
6460 _(b'hg shelve [OPTION]... [FILE]...'),
6472 _(b'hg shelve [OPTION]... [FILE]...'),
6461 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6473 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6462 )
6474 )
6463 def shelve(ui, repo, *pats, **opts):
6475 def shelve(ui, repo, *pats, **opts):
6464 """save and set aside changes from the working directory
6476 """save and set aside changes from the working directory
6465
6477
6466 Shelving takes files that "hg status" reports as not clean, saves
6478 Shelving takes files that "hg status" reports as not clean, saves
6467 the modifications to a bundle (a shelved change), and reverts the
6479 the modifications to a bundle (a shelved change), and reverts the
6468 files so that their state in the working directory becomes clean.
6480 files so that their state in the working directory becomes clean.
6469
6481
6470 To restore these changes to the working directory, using "hg
6482 To restore these changes to the working directory, using "hg
6471 unshelve"; this will work even if you switch to a different
6483 unshelve"; this will work even if you switch to a different
6472 commit.
6484 commit.
6473
6485
6474 When no files are specified, "hg shelve" saves all not-clean
6486 When no files are specified, "hg shelve" saves all not-clean
6475 files. If specific files or directories are named, only changes to
6487 files. If specific files or directories are named, only changes to
6476 those files are shelved.
6488 those files are shelved.
6477
6489
6478 In bare shelve (when no files are specified, without interactive,
6490 In bare shelve (when no files are specified, without interactive,
6479 include and exclude option), shelving remembers information if the
6491 include and exclude option), shelving remembers information if the
6480 working directory was on newly created branch, in other words working
6492 working directory was on newly created branch, in other words working
6481 directory was on different branch than its first parent. In this
6493 directory was on different branch than its first parent. In this
6482 situation unshelving restores branch information to the working directory.
6494 situation unshelving restores branch information to the working directory.
6483
6495
6484 Each shelved change has a name that makes it easier to find later.
6496 Each shelved change has a name that makes it easier to find later.
6485 The name of a shelved change defaults to being based on the active
6497 The name of a shelved change defaults to being based on the active
6486 bookmark, or if there is no active bookmark, the current named
6498 bookmark, or if there is no active bookmark, the current named
6487 branch. To specify a different name, use ``--name``.
6499 branch. To specify a different name, use ``--name``.
6488
6500
6489 To see a list of existing shelved changes, use the ``--list``
6501 To see a list of existing shelved changes, use the ``--list``
6490 option. For each shelved change, this will print its name, age,
6502 option. For each shelved change, this will print its name, age,
6491 and description; use ``--patch`` or ``--stat`` for more details.
6503 and description; use ``--patch`` or ``--stat`` for more details.
6492
6504
6493 To delete specific shelved changes, use ``--delete``. To delete
6505 To delete specific shelved changes, use ``--delete``. To delete
6494 all shelved changes, use ``--cleanup``.
6506 all shelved changes, use ``--cleanup``.
6495 """
6507 """
6496 opts = pycompat.byteskwargs(opts)
6508 opts = pycompat.byteskwargs(opts)
6497 allowables = [
6509 allowables = [
6498 (b'addremove', {b'create'}), # 'create' is pseudo action
6510 (b'addremove', {b'create'}), # 'create' is pseudo action
6499 (b'unknown', {b'create'}),
6511 (b'unknown', {b'create'}),
6500 (b'cleanup', {b'cleanup'}),
6512 (b'cleanup', {b'cleanup'}),
6501 # ('date', {'create'}), # ignored for passing '--date "0 0"' in tests
6513 # ('date', {'create'}), # ignored for passing '--date "0 0"' in tests
6502 (b'delete', {b'delete'}),
6514 (b'delete', {b'delete'}),
6503 (b'edit', {b'create'}),
6515 (b'edit', {b'create'}),
6504 (b'keep', {b'create'}),
6516 (b'keep', {b'create'}),
6505 (b'list', {b'list'}),
6517 (b'list', {b'list'}),
6506 (b'message', {b'create'}),
6518 (b'message', {b'create'}),
6507 (b'name', {b'create'}),
6519 (b'name', {b'create'}),
6508 (b'patch', {b'patch', b'list'}),
6520 (b'patch', {b'patch', b'list'}),
6509 (b'stat', {b'stat', b'list'}),
6521 (b'stat', {b'stat', b'list'}),
6510 ]
6522 ]
6511
6523
6512 def checkopt(opt):
6524 def checkopt(opt):
6513 if opts.get(opt):
6525 if opts.get(opt):
6514 for i, allowable in allowables:
6526 for i, allowable in allowables:
6515 if opts[i] and opt not in allowable:
6527 if opts[i] and opt not in allowable:
6516 raise error.InputError(
6528 raise error.InputError(
6517 _(
6529 _(
6518 b"options '--%s' and '--%s' may not be "
6530 b"options '--%s' and '--%s' may not be "
6519 b"used together"
6531 b"used together"
6520 )
6532 )
6521 % (opt, i)
6533 % (opt, i)
6522 )
6534 )
6523 return True
6535 return True
6524
6536
6525 if checkopt(b'cleanup'):
6537 if checkopt(b'cleanup'):
6526 if pats:
6538 if pats:
6527 raise error.InputError(
6539 raise error.InputError(
6528 _(b"cannot specify names when using '--cleanup'")
6540 _(b"cannot specify names when using '--cleanup'")
6529 )
6541 )
6530 return shelvemod.cleanupcmd(ui, repo)
6542 return shelvemod.cleanupcmd(ui, repo)
6531 elif checkopt(b'delete'):
6543 elif checkopt(b'delete'):
6532 return shelvemod.deletecmd(ui, repo, pats)
6544 return shelvemod.deletecmd(ui, repo, pats)
6533 elif checkopt(b'list'):
6545 elif checkopt(b'list'):
6534 return shelvemod.listcmd(ui, repo, pats, opts)
6546 return shelvemod.listcmd(ui, repo, pats, opts)
6535 elif checkopt(b'patch') or checkopt(b'stat'):
6547 elif checkopt(b'patch') or checkopt(b'stat'):
6536 return shelvemod.patchcmds(ui, repo, pats, opts)
6548 return shelvemod.patchcmds(ui, repo, pats, opts)
6537 else:
6549 else:
6538 return shelvemod.createcmd(ui, repo, pats, opts)
6550 return shelvemod.createcmd(ui, repo, pats, opts)
6539
6551
6540
6552
6541 _NOTTERSE = b'nothing'
6553 _NOTTERSE = b'nothing'
6542
6554
6543
6555
6544 @command(
6556 @command(
6545 b'status|st',
6557 b'status|st',
6546 [
6558 [
6547 (b'A', b'all', None, _(b'show status of all files')),
6559 (b'A', b'all', None, _(b'show status of all files')),
6548 (b'm', b'modified', None, _(b'show only modified files')),
6560 (b'm', b'modified', None, _(b'show only modified files')),
6549 (b'a', b'added', None, _(b'show only added files')),
6561 (b'a', b'added', None, _(b'show only added files')),
6550 (b'r', b'removed', None, _(b'show only removed files')),
6562 (b'r', b'removed', None, _(b'show only removed files')),
6551 (b'd', b'deleted', None, _(b'show only missing files')),
6563 (b'd', b'deleted', None, _(b'show only missing files')),
6552 (b'c', b'clean', None, _(b'show only files without changes')),
6564 (b'c', b'clean', None, _(b'show only files without changes')),
6553 (b'u', b'unknown', None, _(b'show only unknown (not tracked) files')),
6565 (b'u', b'unknown', None, _(b'show only unknown (not tracked) files')),
6554 (b'i', b'ignored', None, _(b'show only ignored files')),
6566 (b'i', b'ignored', None, _(b'show only ignored files')),
6555 (b'n', b'no-status', None, _(b'hide status prefix')),
6567 (b'n', b'no-status', None, _(b'hide status prefix')),
6556 (b't', b'terse', _NOTTERSE, _(b'show the terse output (EXPERIMENTAL)')),
6568 (b't', b'terse', _NOTTERSE, _(b'show the terse output (EXPERIMENTAL)')),
6557 (
6569 (
6558 b'C',
6570 b'C',
6559 b'copies',
6571 b'copies',
6560 None,
6572 None,
6561 _(b'show source of copied files (DEFAULT: ui.statuscopies)'),
6573 _(b'show source of copied files (DEFAULT: ui.statuscopies)'),
6562 ),
6574 ),
6563 (
6575 (
6564 b'0',
6576 b'0',
6565 b'print0',
6577 b'print0',
6566 None,
6578 None,
6567 _(b'end filenames with NUL, for use with xargs'),
6579 _(b'end filenames with NUL, for use with xargs'),
6568 ),
6580 ),
6569 (b'', b'rev', [], _(b'show difference from revision'), _(b'REV')),
6581 (b'', b'rev', [], _(b'show difference from revision'), _(b'REV')),
6570 (
6582 (
6571 b'',
6583 b'',
6572 b'change',
6584 b'change',
6573 b'',
6585 b'',
6574 _(b'list the changed files of a revision'),
6586 _(b'list the changed files of a revision'),
6575 _(b'REV'),
6587 _(b'REV'),
6576 ),
6588 ),
6577 ]
6589 ]
6578 + walkopts
6590 + walkopts
6579 + subrepoopts
6591 + subrepoopts
6580 + formatteropts,
6592 + formatteropts,
6581 _(b'[OPTION]... [FILE]...'),
6593 _(b'[OPTION]... [FILE]...'),
6582 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6594 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6583 helpbasic=True,
6595 helpbasic=True,
6584 inferrepo=True,
6596 inferrepo=True,
6585 intents={INTENT_READONLY},
6597 intents={INTENT_READONLY},
6586 )
6598 )
6587 def status(ui, repo, *pats, **opts):
6599 def status(ui, repo, *pats, **opts):
6588 """show changed files in the working directory
6600 """show changed files in the working directory
6589
6601
6590 Show status of files in the repository. If names are given, only
6602 Show status of files in the repository. If names are given, only
6591 files that match are shown. Files that are clean or ignored or
6603 files that match are shown. Files that are clean or ignored or
6592 the source of a copy/move operation, are not listed unless
6604 the source of a copy/move operation, are not listed unless
6593 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
6605 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
6594 Unless options described with "show only ..." are given, the
6606 Unless options described with "show only ..." are given, the
6595 options -mardu are used.
6607 options -mardu are used.
6596
6608
6597 Option -q/--quiet hides untracked (unknown and ignored) files
6609 Option -q/--quiet hides untracked (unknown and ignored) files
6598 unless explicitly requested with -u/--unknown or -i/--ignored.
6610 unless explicitly requested with -u/--unknown or -i/--ignored.
6599
6611
6600 .. note::
6612 .. note::
6601
6613
6602 :hg:`status` may appear to disagree with diff if permissions have
6614 :hg:`status` may appear to disagree with diff if permissions have
6603 changed or a merge has occurred. The standard diff format does
6615 changed or a merge has occurred. The standard diff format does
6604 not report permission changes and diff only reports changes
6616 not report permission changes and diff only reports changes
6605 relative to one merge parent.
6617 relative to one merge parent.
6606
6618
6607 If one revision is given, it is used as the base revision.
6619 If one revision is given, it is used as the base revision.
6608 If two revisions are given, the differences between them are
6620 If two revisions are given, the differences between them are
6609 shown. The --change option can also be used as a shortcut to list
6621 shown. The --change option can also be used as a shortcut to list
6610 the changed files of a revision from its first parent.
6622 the changed files of a revision from its first parent.
6611
6623
6612 The codes used to show the status of files are::
6624 The codes used to show the status of files are::
6613
6625
6614 M = modified
6626 M = modified
6615 A = added
6627 A = added
6616 R = removed
6628 R = removed
6617 C = clean
6629 C = clean
6618 ! = missing (deleted by non-hg command, but still tracked)
6630 ! = missing (deleted by non-hg command, but still tracked)
6619 ? = not tracked
6631 ? = not tracked
6620 I = ignored
6632 I = ignored
6621 = origin of the previous file (with --copies)
6633 = origin of the previous file (with --copies)
6622
6634
6623 .. container:: verbose
6635 .. container:: verbose
6624
6636
6625 The -t/--terse option abbreviates the output by showing only the directory
6637 The -t/--terse option abbreviates the output by showing only the directory
6626 name if all the files in it share the same status. The option takes an
6638 name if all the files in it share the same status. The option takes an
6627 argument indicating the statuses to abbreviate: 'm' for 'modified', 'a'
6639 argument indicating the statuses to abbreviate: 'm' for 'modified', 'a'
6628 for 'added', 'r' for 'removed', 'd' for 'deleted', 'u' for 'unknown', 'i'
6640 for 'added', 'r' for 'removed', 'd' for 'deleted', 'u' for 'unknown', 'i'
6629 for 'ignored' and 'c' for clean.
6641 for 'ignored' and 'c' for clean.
6630
6642
6631 It abbreviates only those statuses which are passed. Note that clean and
6643 It abbreviates only those statuses which are passed. Note that clean and
6632 ignored files are not displayed with '--terse ic' unless the -c/--clean
6644 ignored files are not displayed with '--terse ic' unless the -c/--clean
6633 and -i/--ignored options are also used.
6645 and -i/--ignored options are also used.
6634
6646
6635 The -v/--verbose option shows information when the repository is in an
6647 The -v/--verbose option shows information when the repository is in an
6636 unfinished merge, shelve, rebase state etc. You can have this behavior
6648 unfinished merge, shelve, rebase state etc. You can have this behavior
6637 turned on by default by enabling the ``commands.status.verbose`` option.
6649 turned on by default by enabling the ``commands.status.verbose`` option.
6638
6650
6639 You can skip displaying some of these states by setting
6651 You can skip displaying some of these states by setting
6640 ``commands.status.skipstates`` to one or more of: 'bisect', 'graft',
6652 ``commands.status.skipstates`` to one or more of: 'bisect', 'graft',
6641 'histedit', 'merge', 'rebase', or 'unshelve'.
6653 'histedit', 'merge', 'rebase', or 'unshelve'.
6642
6654
6643 Template:
6655 Template:
6644
6656
6645 The following keywords are supported in addition to the common template
6657 The following keywords are supported in addition to the common template
6646 keywords and functions. See also :hg:`help templates`.
6658 keywords and functions. See also :hg:`help templates`.
6647
6659
6648 :path: String. Repository-absolute path of the file.
6660 :path: String. Repository-absolute path of the file.
6649 :source: String. Repository-absolute path of the file originated from.
6661 :source: String. Repository-absolute path of the file originated from.
6650 Available if ``--copies`` is specified.
6662 Available if ``--copies`` is specified.
6651 :status: String. Character denoting file's status.
6663 :status: String. Character denoting file's status.
6652
6664
6653 Examples:
6665 Examples:
6654
6666
6655 - show changes in the working directory relative to a
6667 - show changes in the working directory relative to a
6656 changeset::
6668 changeset::
6657
6669
6658 hg status --rev 9353
6670 hg status --rev 9353
6659
6671
6660 - show changes in the working directory relative to the
6672 - show changes in the working directory relative to the
6661 current directory (see :hg:`help patterns` for more information)::
6673 current directory (see :hg:`help patterns` for more information)::
6662
6674
6663 hg status re:
6675 hg status re:
6664
6676
6665 - show all changes including copies in an existing changeset::
6677 - show all changes including copies in an existing changeset::
6666
6678
6667 hg status --copies --change 9353
6679 hg status --copies --change 9353
6668
6680
6669 - get a NUL separated list of added files, suitable for xargs::
6681 - get a NUL separated list of added files, suitable for xargs::
6670
6682
6671 hg status -an0
6683 hg status -an0
6672
6684
6673 - show more information about the repository status, abbreviating
6685 - show more information about the repository status, abbreviating
6674 added, removed, modified, deleted, and untracked paths::
6686 added, removed, modified, deleted, and untracked paths::
6675
6687
6676 hg status -v -t mardu
6688 hg status -v -t mardu
6677
6689
6678 Returns 0 on success.
6690 Returns 0 on success.
6679
6691
6680 """
6692 """
6681
6693
6682 cmdutil.check_at_most_one_arg(opts, 'rev', 'change')
6694 cmdutil.check_at_most_one_arg(opts, 'rev', 'change')
6683 opts = pycompat.byteskwargs(opts)
6695 opts = pycompat.byteskwargs(opts)
6684 revs = opts.get(b'rev')
6696 revs = opts.get(b'rev')
6685 change = opts.get(b'change')
6697 change = opts.get(b'change')
6686 terse = opts.get(b'terse')
6698 terse = opts.get(b'terse')
6687 if terse is _NOTTERSE:
6699 if terse is _NOTTERSE:
6688 if revs:
6700 if revs:
6689 terse = b''
6701 terse = b''
6690 else:
6702 else:
6691 terse = ui.config(b'commands', b'status.terse')
6703 terse = ui.config(b'commands', b'status.terse')
6692
6704
6693 if revs and terse:
6705 if revs and terse:
6694 msg = _(b'cannot use --terse with --rev')
6706 msg = _(b'cannot use --terse with --rev')
6695 raise error.InputError(msg)
6707 raise error.InputError(msg)
6696 elif change:
6708 elif change:
6697 repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
6709 repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
6698 ctx2 = scmutil.revsingle(repo, change, None)
6710 ctx2 = scmutil.revsingle(repo, change, None)
6699 ctx1 = ctx2.p1()
6711 ctx1 = ctx2.p1()
6700 else:
6712 else:
6701 repo = scmutil.unhidehashlikerevs(repo, revs, b'nowarn')
6713 repo = scmutil.unhidehashlikerevs(repo, revs, b'nowarn')
6702 ctx1, ctx2 = scmutil.revpair(repo, revs)
6714 ctx1, ctx2 = scmutil.revpair(repo, revs)
6703
6715
6704 forcerelativevalue = None
6716 forcerelativevalue = None
6705 if ui.hasconfig(b'commands', b'status.relative'):
6717 if ui.hasconfig(b'commands', b'status.relative'):
6706 forcerelativevalue = ui.configbool(b'commands', b'status.relative')
6718 forcerelativevalue = ui.configbool(b'commands', b'status.relative')
6707 uipathfn = scmutil.getuipathfn(
6719 uipathfn = scmutil.getuipathfn(
6708 repo,
6720 repo,
6709 legacyrelativevalue=bool(pats),
6721 legacyrelativevalue=bool(pats),
6710 forcerelativevalue=forcerelativevalue,
6722 forcerelativevalue=forcerelativevalue,
6711 )
6723 )
6712
6724
6713 if opts.get(b'print0'):
6725 if opts.get(b'print0'):
6714 end = b'\0'
6726 end = b'\0'
6715 else:
6727 else:
6716 end = b'\n'
6728 end = b'\n'
6717 states = b'modified added removed deleted unknown ignored clean'.split()
6729 states = b'modified added removed deleted unknown ignored clean'.split()
6718 show = [k for k in states if opts.get(k)]
6730 show = [k for k in states if opts.get(k)]
6719 if opts.get(b'all'):
6731 if opts.get(b'all'):
6720 show += ui.quiet and (states[:4] + [b'clean']) or states
6732 show += ui.quiet and (states[:4] + [b'clean']) or states
6721
6733
6722 if not show:
6734 if not show:
6723 if ui.quiet:
6735 if ui.quiet:
6724 show = states[:4]
6736 show = states[:4]
6725 else:
6737 else:
6726 show = states[:5]
6738 show = states[:5]
6727
6739
6728 m = scmutil.match(ctx2, pats, opts)
6740 m = scmutil.match(ctx2, pats, opts)
6729 if terse:
6741 if terse:
6730 # we need to compute clean and unknown to terse
6742 # we need to compute clean and unknown to terse
6731 stat = repo.status(
6743 stat = repo.status(
6732 ctx1.node(),
6744 ctx1.node(),
6733 ctx2.node(),
6745 ctx2.node(),
6734 m,
6746 m,
6735 b'ignored' in show or b'i' in terse,
6747 b'ignored' in show or b'i' in terse,
6736 clean=True,
6748 clean=True,
6737 unknown=True,
6749 unknown=True,
6738 listsubrepos=opts.get(b'subrepos'),
6750 listsubrepos=opts.get(b'subrepos'),
6739 )
6751 )
6740
6752
6741 stat = cmdutil.tersedir(stat, terse)
6753 stat = cmdutil.tersedir(stat, terse)
6742 else:
6754 else:
6743 stat = repo.status(
6755 stat = repo.status(
6744 ctx1.node(),
6756 ctx1.node(),
6745 ctx2.node(),
6757 ctx2.node(),
6746 m,
6758 m,
6747 b'ignored' in show,
6759 b'ignored' in show,
6748 b'clean' in show,
6760 b'clean' in show,
6749 b'unknown' in show,
6761 b'unknown' in show,
6750 opts.get(b'subrepos'),
6762 opts.get(b'subrepos'),
6751 )
6763 )
6752
6764
6753 changestates = zip(
6765 changestates = zip(
6754 states,
6766 states,
6755 pycompat.iterbytestr(b'MAR!?IC'),
6767 pycompat.iterbytestr(b'MAR!?IC'),
6756 [getattr(stat, s.decode('utf8')) for s in states],
6768 [getattr(stat, s.decode('utf8')) for s in states],
6757 )
6769 )
6758
6770
6759 copy = {}
6771 copy = {}
6760 if (
6772 if (
6761 opts.get(b'all')
6773 opts.get(b'all')
6762 or opts.get(b'copies')
6774 or opts.get(b'copies')
6763 or ui.configbool(b'ui', b'statuscopies')
6775 or ui.configbool(b'ui', b'statuscopies')
6764 ) and not opts.get(b'no_status'):
6776 ) and not opts.get(b'no_status'):
6765 copy = copies.pathcopies(ctx1, ctx2, m)
6777 copy = copies.pathcopies(ctx1, ctx2, m)
6766
6778
6767 morestatus = None
6779 morestatus = None
6768 if (
6780 if (
6769 (ui.verbose or ui.configbool(b'commands', b'status.verbose'))
6781 (ui.verbose or ui.configbool(b'commands', b'status.verbose'))
6770 and not ui.plain()
6782 and not ui.plain()
6771 and not opts.get(b'print0')
6783 and not opts.get(b'print0')
6772 ):
6784 ):
6773 morestatus = cmdutil.readmorestatus(repo)
6785 morestatus = cmdutil.readmorestatus(repo)
6774
6786
6775 ui.pager(b'status')
6787 ui.pager(b'status')
6776 fm = ui.formatter(b'status', opts)
6788 fm = ui.formatter(b'status', opts)
6777 fmt = b'%s' + end
6789 fmt = b'%s' + end
6778 showchar = not opts.get(b'no_status')
6790 showchar = not opts.get(b'no_status')
6779
6791
6780 for state, char, files in changestates:
6792 for state, char, files in changestates:
6781 if state in show:
6793 if state in show:
6782 label = b'status.' + state
6794 label = b'status.' + state
6783 for f in files:
6795 for f in files:
6784 fm.startitem()
6796 fm.startitem()
6785 fm.context(ctx=ctx2)
6797 fm.context(ctx=ctx2)
6786 fm.data(itemtype=b'file', path=f)
6798 fm.data(itemtype=b'file', path=f)
6787 fm.condwrite(showchar, b'status', b'%s ', char, label=label)
6799 fm.condwrite(showchar, b'status', b'%s ', char, label=label)
6788 fm.plain(fmt % uipathfn(f), label=label)
6800 fm.plain(fmt % uipathfn(f), label=label)
6789 if f in copy:
6801 if f in copy:
6790 fm.data(source=copy[f])
6802 fm.data(source=copy[f])
6791 fm.plain(
6803 fm.plain(
6792 (b' %s' + end) % uipathfn(copy[f]),
6804 (b' %s' + end) % uipathfn(copy[f]),
6793 label=b'status.copied',
6805 label=b'status.copied',
6794 )
6806 )
6795 if morestatus:
6807 if morestatus:
6796 morestatus.formatfile(f, fm)
6808 morestatus.formatfile(f, fm)
6797
6809
6798 if morestatus:
6810 if morestatus:
6799 morestatus.formatfooter(fm)
6811 morestatus.formatfooter(fm)
6800 fm.end()
6812 fm.end()
6801
6813
6802
6814
6803 @command(
6815 @command(
6804 b'summary|sum',
6816 b'summary|sum',
6805 [(b'', b'remote', None, _(b'check for push and pull'))],
6817 [(b'', b'remote', None, _(b'check for push and pull'))],
6806 b'[--remote]',
6818 b'[--remote]',
6807 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6819 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6808 helpbasic=True,
6820 helpbasic=True,
6809 intents={INTENT_READONLY},
6821 intents={INTENT_READONLY},
6810 )
6822 )
6811 def summary(ui, repo, **opts):
6823 def summary(ui, repo, **opts):
6812 """summarize working directory state
6824 """summarize working directory state
6813
6825
6814 This generates a brief summary of the working directory state,
6826 This generates a brief summary of the working directory state,
6815 including parents, branch, commit status, phase and available updates.
6827 including parents, branch, commit status, phase and available updates.
6816
6828
6817 With the --remote option, this will check the default paths for
6829 With the --remote option, this will check the default paths for
6818 incoming and outgoing changes. This can be time-consuming.
6830 incoming and outgoing changes. This can be time-consuming.
6819
6831
6820 Returns 0 on success.
6832 Returns 0 on success.
6821 """
6833 """
6822
6834
6823 opts = pycompat.byteskwargs(opts)
6835 opts = pycompat.byteskwargs(opts)
6824 ui.pager(b'summary')
6836 ui.pager(b'summary')
6825 ctx = repo[None]
6837 ctx = repo[None]
6826 parents = ctx.parents()
6838 parents = ctx.parents()
6827 pnode = parents[0].node()
6839 pnode = parents[0].node()
6828 marks = []
6840 marks = []
6829
6841
6830 try:
6842 try:
6831 ms = mergestatemod.mergestate.read(repo)
6843 ms = mergestatemod.mergestate.read(repo)
6832 except error.UnsupportedMergeRecords as e:
6844 except error.UnsupportedMergeRecords as e:
6833 s = b' '.join(e.recordtypes)
6845 s = b' '.join(e.recordtypes)
6834 ui.warn(
6846 ui.warn(
6835 _(b'warning: merge state has unsupported record types: %s\n') % s
6847 _(b'warning: merge state has unsupported record types: %s\n') % s
6836 )
6848 )
6837 unresolved = []
6849 unresolved = []
6838 else:
6850 else:
6839 unresolved = list(ms.unresolved())
6851 unresolved = list(ms.unresolved())
6840
6852
6841 for p in parents:
6853 for p in parents:
6842 # label with log.changeset (instead of log.parent) since this
6854 # label with log.changeset (instead of log.parent) since this
6843 # shows a working directory parent *changeset*:
6855 # shows a working directory parent *changeset*:
6844 # i18n: column positioning for "hg summary"
6856 # i18n: column positioning for "hg summary"
6845 ui.write(
6857 ui.write(
6846 _(b'parent: %d:%s ') % (p.rev(), p),
6858 _(b'parent: %d:%s ') % (p.rev(), p),
6847 label=logcmdutil.changesetlabels(p),
6859 label=logcmdutil.changesetlabels(p),
6848 )
6860 )
6849 ui.write(b' '.join(p.tags()), label=b'log.tag')
6861 ui.write(b' '.join(p.tags()), label=b'log.tag')
6850 if p.bookmarks():
6862 if p.bookmarks():
6851 marks.extend(p.bookmarks())
6863 marks.extend(p.bookmarks())
6852 if p.rev() == -1:
6864 if p.rev() == -1:
6853 if not len(repo):
6865 if not len(repo):
6854 ui.write(_(b' (empty repository)'))
6866 ui.write(_(b' (empty repository)'))
6855 else:
6867 else:
6856 ui.write(_(b' (no revision checked out)'))
6868 ui.write(_(b' (no revision checked out)'))
6857 if p.obsolete():
6869 if p.obsolete():
6858 ui.write(_(b' (obsolete)'))
6870 ui.write(_(b' (obsolete)'))
6859 if p.isunstable():
6871 if p.isunstable():
6860 instabilities = (
6872 instabilities = (
6861 ui.label(instability, b'trouble.%s' % instability)
6873 ui.label(instability, b'trouble.%s' % instability)
6862 for instability in p.instabilities()
6874 for instability in p.instabilities()
6863 )
6875 )
6864 ui.write(b' (' + b', '.join(instabilities) + b')')
6876 ui.write(b' (' + b', '.join(instabilities) + b')')
6865 ui.write(b'\n')
6877 ui.write(b'\n')
6866 if p.description():
6878 if p.description():
6867 ui.status(
6879 ui.status(
6868 b' ' + p.description().splitlines()[0].strip() + b'\n',
6880 b' ' + p.description().splitlines()[0].strip() + b'\n',
6869 label=b'log.summary',
6881 label=b'log.summary',
6870 )
6882 )
6871
6883
6872 branch = ctx.branch()
6884 branch = ctx.branch()
6873 bheads = repo.branchheads(branch)
6885 bheads = repo.branchheads(branch)
6874 # i18n: column positioning for "hg summary"
6886 # i18n: column positioning for "hg summary"
6875 m = _(b'branch: %s\n') % branch
6887 m = _(b'branch: %s\n') % branch
6876 if branch != b'default':
6888 if branch != b'default':
6877 ui.write(m, label=b'log.branch')
6889 ui.write(m, label=b'log.branch')
6878 else:
6890 else:
6879 ui.status(m, label=b'log.branch')
6891 ui.status(m, label=b'log.branch')
6880
6892
6881 if marks:
6893 if marks:
6882 active = repo._activebookmark
6894 active = repo._activebookmark
6883 # i18n: column positioning for "hg summary"
6895 # i18n: column positioning for "hg summary"
6884 ui.write(_(b'bookmarks:'), label=b'log.bookmark')
6896 ui.write(_(b'bookmarks:'), label=b'log.bookmark')
6885 if active is not None:
6897 if active is not None:
6886 if active in marks:
6898 if active in marks:
6887 ui.write(b' *' + active, label=bookmarks.activebookmarklabel)
6899 ui.write(b' *' + active, label=bookmarks.activebookmarklabel)
6888 marks.remove(active)
6900 marks.remove(active)
6889 else:
6901 else:
6890 ui.write(b' [%s]' % active, label=bookmarks.activebookmarklabel)
6902 ui.write(b' [%s]' % active, label=bookmarks.activebookmarklabel)
6891 for m in marks:
6903 for m in marks:
6892 ui.write(b' ' + m, label=b'log.bookmark')
6904 ui.write(b' ' + m, label=b'log.bookmark')
6893 ui.write(b'\n', label=b'log.bookmark')
6905 ui.write(b'\n', label=b'log.bookmark')
6894
6906
6895 status = repo.status(unknown=True)
6907 status = repo.status(unknown=True)
6896
6908
6897 c = repo.dirstate.copies()
6909 c = repo.dirstate.copies()
6898 copied, renamed = [], []
6910 copied, renamed = [], []
6899 for d, s in pycompat.iteritems(c):
6911 for d, s in pycompat.iteritems(c):
6900 if s in status.removed:
6912 if s in status.removed:
6901 status.removed.remove(s)
6913 status.removed.remove(s)
6902 renamed.append(d)
6914 renamed.append(d)
6903 else:
6915 else:
6904 copied.append(d)
6916 copied.append(d)
6905 if d in status.added:
6917 if d in status.added:
6906 status.added.remove(d)
6918 status.added.remove(d)
6907
6919
6908 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
6920 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
6909
6921
6910 labels = [
6922 labels = [
6911 (ui.label(_(b'%d modified'), b'status.modified'), status.modified),
6923 (ui.label(_(b'%d modified'), b'status.modified'), status.modified),
6912 (ui.label(_(b'%d added'), b'status.added'), status.added),
6924 (ui.label(_(b'%d added'), b'status.added'), status.added),
6913 (ui.label(_(b'%d removed'), b'status.removed'), status.removed),
6925 (ui.label(_(b'%d removed'), b'status.removed'), status.removed),
6914 (ui.label(_(b'%d renamed'), b'status.copied'), renamed),
6926 (ui.label(_(b'%d renamed'), b'status.copied'), renamed),
6915 (ui.label(_(b'%d copied'), b'status.copied'), copied),
6927 (ui.label(_(b'%d copied'), b'status.copied'), copied),
6916 (ui.label(_(b'%d deleted'), b'status.deleted'), status.deleted),
6928 (ui.label(_(b'%d deleted'), b'status.deleted'), status.deleted),
6917 (ui.label(_(b'%d unknown'), b'status.unknown'), status.unknown),
6929 (ui.label(_(b'%d unknown'), b'status.unknown'), status.unknown),
6918 (ui.label(_(b'%d unresolved'), b'resolve.unresolved'), unresolved),
6930 (ui.label(_(b'%d unresolved'), b'resolve.unresolved'), unresolved),
6919 (ui.label(_(b'%d subrepos'), b'status.modified'), subs),
6931 (ui.label(_(b'%d subrepos'), b'status.modified'), subs),
6920 ]
6932 ]
6921 t = []
6933 t = []
6922 for l, s in labels:
6934 for l, s in labels:
6923 if s:
6935 if s:
6924 t.append(l % len(s))
6936 t.append(l % len(s))
6925
6937
6926 t = b', '.join(t)
6938 t = b', '.join(t)
6927 cleanworkdir = False
6939 cleanworkdir = False
6928
6940
6929 if repo.vfs.exists(b'graftstate'):
6941 if repo.vfs.exists(b'graftstate'):
6930 t += _(b' (graft in progress)')
6942 t += _(b' (graft in progress)')
6931 if repo.vfs.exists(b'updatestate'):
6943 if repo.vfs.exists(b'updatestate'):
6932 t += _(b' (interrupted update)')
6944 t += _(b' (interrupted update)')
6933 elif len(parents) > 1:
6945 elif len(parents) > 1:
6934 t += _(b' (merge)')
6946 t += _(b' (merge)')
6935 elif branch != parents[0].branch():
6947 elif branch != parents[0].branch():
6936 t += _(b' (new branch)')
6948 t += _(b' (new branch)')
6937 elif parents[0].closesbranch() and pnode in repo.branchheads(
6949 elif parents[0].closesbranch() and pnode in repo.branchheads(
6938 branch, closed=True
6950 branch, closed=True
6939 ):
6951 ):
6940 t += _(b' (head closed)')
6952 t += _(b' (head closed)')
6941 elif not (
6953 elif not (
6942 status.modified
6954 status.modified
6943 or status.added
6955 or status.added
6944 or status.removed
6956 or status.removed
6945 or renamed
6957 or renamed
6946 or copied
6958 or copied
6947 or subs
6959 or subs
6948 ):
6960 ):
6949 t += _(b' (clean)')
6961 t += _(b' (clean)')
6950 cleanworkdir = True
6962 cleanworkdir = True
6951 elif pnode not in bheads:
6963 elif pnode not in bheads:
6952 t += _(b' (new branch head)')
6964 t += _(b' (new branch head)')
6953
6965
6954 if parents:
6966 if parents:
6955 pendingphase = max(p.phase() for p in parents)
6967 pendingphase = max(p.phase() for p in parents)
6956 else:
6968 else:
6957 pendingphase = phases.public
6969 pendingphase = phases.public
6958
6970
6959 if pendingphase > phases.newcommitphase(ui):
6971 if pendingphase > phases.newcommitphase(ui):
6960 t += b' (%s)' % phases.phasenames[pendingphase]
6972 t += b' (%s)' % phases.phasenames[pendingphase]
6961
6973
6962 if cleanworkdir:
6974 if cleanworkdir:
6963 # i18n: column positioning for "hg summary"
6975 # i18n: column positioning for "hg summary"
6964 ui.status(_(b'commit: %s\n') % t.strip())
6976 ui.status(_(b'commit: %s\n') % t.strip())
6965 else:
6977 else:
6966 # i18n: column positioning for "hg summary"
6978 # i18n: column positioning for "hg summary"
6967 ui.write(_(b'commit: %s\n') % t.strip())
6979 ui.write(_(b'commit: %s\n') % t.strip())
6968
6980
6969 # all ancestors of branch heads - all ancestors of parent = new csets
6981 # all ancestors of branch heads - all ancestors of parent = new csets
6970 new = len(
6982 new = len(
6971 repo.changelog.findmissing([pctx.node() for pctx in parents], bheads)
6983 repo.changelog.findmissing([pctx.node() for pctx in parents], bheads)
6972 )
6984 )
6973
6985
6974 if new == 0:
6986 if new == 0:
6975 # i18n: column positioning for "hg summary"
6987 # i18n: column positioning for "hg summary"
6976 ui.status(_(b'update: (current)\n'))
6988 ui.status(_(b'update: (current)\n'))
6977 elif pnode not in bheads:
6989 elif pnode not in bheads:
6978 # i18n: column positioning for "hg summary"
6990 # i18n: column positioning for "hg summary"
6979 ui.write(_(b'update: %d new changesets (update)\n') % new)
6991 ui.write(_(b'update: %d new changesets (update)\n') % new)
6980 else:
6992 else:
6981 # i18n: column positioning for "hg summary"
6993 # i18n: column positioning for "hg summary"
6982 ui.write(
6994 ui.write(
6983 _(b'update: %d new changesets, %d branch heads (merge)\n')
6995 _(b'update: %d new changesets, %d branch heads (merge)\n')
6984 % (new, len(bheads))
6996 % (new, len(bheads))
6985 )
6997 )
6986
6998
6987 t = []
6999 t = []
6988 draft = len(repo.revs(b'draft()'))
7000 draft = len(repo.revs(b'draft()'))
6989 if draft:
7001 if draft:
6990 t.append(_(b'%d draft') % draft)
7002 t.append(_(b'%d draft') % draft)
6991 secret = len(repo.revs(b'secret()'))
7003 secret = len(repo.revs(b'secret()'))
6992 if secret:
7004 if secret:
6993 t.append(_(b'%d secret') % secret)
7005 t.append(_(b'%d secret') % secret)
6994
7006
6995 if draft or secret:
7007 if draft or secret:
6996 ui.status(_(b'phases: %s\n') % b', '.join(t))
7008 ui.status(_(b'phases: %s\n') % b', '.join(t))
6997
7009
6998 if obsolete.isenabled(repo, obsolete.createmarkersopt):
7010 if obsolete.isenabled(repo, obsolete.createmarkersopt):
6999 for trouble in (b"orphan", b"contentdivergent", b"phasedivergent"):
7011 for trouble in (b"orphan", b"contentdivergent", b"phasedivergent"):
7000 numtrouble = len(repo.revs(trouble + b"()"))
7012 numtrouble = len(repo.revs(trouble + b"()"))
7001 # We write all the possibilities to ease translation
7013 # We write all the possibilities to ease translation
7002 troublemsg = {
7014 troublemsg = {
7003 b"orphan": _(b"orphan: %d changesets"),
7015 b"orphan": _(b"orphan: %d changesets"),
7004 b"contentdivergent": _(b"content-divergent: %d changesets"),
7016 b"contentdivergent": _(b"content-divergent: %d changesets"),
7005 b"phasedivergent": _(b"phase-divergent: %d changesets"),
7017 b"phasedivergent": _(b"phase-divergent: %d changesets"),
7006 }
7018 }
7007 if numtrouble > 0:
7019 if numtrouble > 0:
7008 ui.status(troublemsg[trouble] % numtrouble + b"\n")
7020 ui.status(troublemsg[trouble] % numtrouble + b"\n")
7009
7021
7010 cmdutil.summaryhooks(ui, repo)
7022 cmdutil.summaryhooks(ui, repo)
7011
7023
7012 if opts.get(b'remote'):
7024 if opts.get(b'remote'):
7013 needsincoming, needsoutgoing = True, True
7025 needsincoming, needsoutgoing = True, True
7014 else:
7026 else:
7015 needsincoming, needsoutgoing = False, False
7027 needsincoming, needsoutgoing = False, False
7016 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
7028 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
7017 if i:
7029 if i:
7018 needsincoming = True
7030 needsincoming = True
7019 if o:
7031 if o:
7020 needsoutgoing = True
7032 needsoutgoing = True
7021 if not needsincoming and not needsoutgoing:
7033 if not needsincoming and not needsoutgoing:
7022 return
7034 return
7023
7035
7024 def getincoming():
7036 def getincoming():
7025 source, branches = hg.parseurl(ui.expandpath(b'default'))
7037 source, branches = hg.parseurl(ui.expandpath(b'default'))
7026 sbranch = branches[0]
7038 sbranch = branches[0]
7027 try:
7039 try:
7028 other = hg.peer(repo, {}, source)
7040 other = hg.peer(repo, {}, source)
7029 except error.RepoError:
7041 except error.RepoError:
7030 if opts.get(b'remote'):
7042 if opts.get(b'remote'):
7031 raise
7043 raise
7032 return source, sbranch, None, None, None
7044 return source, sbranch, None, None, None
7033 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
7045 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
7034 if revs:
7046 if revs:
7035 revs = [other.lookup(rev) for rev in revs]
7047 revs = [other.lookup(rev) for rev in revs]
7036 ui.debug(b'comparing with %s\n' % util.hidepassword(source))
7048 ui.debug(b'comparing with %s\n' % util.hidepassword(source))
7037 repo.ui.pushbuffer()
7049 repo.ui.pushbuffer()
7038 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
7050 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
7039 repo.ui.popbuffer()
7051 repo.ui.popbuffer()
7040 return source, sbranch, other, commoninc, commoninc[1]
7052 return source, sbranch, other, commoninc, commoninc[1]
7041
7053
7042 if needsincoming:
7054 if needsincoming:
7043 source, sbranch, sother, commoninc, incoming = getincoming()
7055 source, sbranch, sother, commoninc, incoming = getincoming()
7044 else:
7056 else:
7045 source = sbranch = sother = commoninc = incoming = None
7057 source = sbranch = sother = commoninc = incoming = None
7046
7058
7047 def getoutgoing():
7059 def getoutgoing():
7048 dest, branches = hg.parseurl(ui.expandpath(b'default-push', b'default'))
7060 dest, branches = hg.parseurl(ui.expandpath(b'default-push', b'default'))
7049 dbranch = branches[0]
7061 dbranch = branches[0]
7050 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
7062 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
7051 if source != dest:
7063 if source != dest:
7052 try:
7064 try:
7053 dother = hg.peer(repo, {}, dest)
7065 dother = hg.peer(repo, {}, dest)
7054 except error.RepoError:
7066 except error.RepoError:
7055 if opts.get(b'remote'):
7067 if opts.get(b'remote'):
7056 raise
7068 raise
7057 return dest, dbranch, None, None
7069 return dest, dbranch, None, None
7058 ui.debug(b'comparing with %s\n' % util.hidepassword(dest))
7070 ui.debug(b'comparing with %s\n' % util.hidepassword(dest))
7059 elif sother is None:
7071 elif sother is None:
7060 # there is no explicit destination peer, but source one is invalid
7072 # there is no explicit destination peer, but source one is invalid
7061 return dest, dbranch, None, None
7073 return dest, dbranch, None, None
7062 else:
7074 else:
7063 dother = sother
7075 dother = sother
7064 if source != dest or (sbranch is not None and sbranch != dbranch):
7076 if source != dest or (sbranch is not None and sbranch != dbranch):
7065 common = None
7077 common = None
7066 else:
7078 else:
7067 common = commoninc
7079 common = commoninc
7068 if revs:
7080 if revs:
7069 revs = [repo.lookup(rev) for rev in revs]
7081 revs = [repo.lookup(rev) for rev in revs]
7070 repo.ui.pushbuffer()
7082 repo.ui.pushbuffer()
7071 outgoing = discovery.findcommonoutgoing(
7083 outgoing = discovery.findcommonoutgoing(
7072 repo, dother, onlyheads=revs, commoninc=common
7084 repo, dother, onlyheads=revs, commoninc=common
7073 )
7085 )
7074 repo.ui.popbuffer()
7086 repo.ui.popbuffer()
7075 return dest, dbranch, dother, outgoing
7087 return dest, dbranch, dother, outgoing
7076
7088
7077 if needsoutgoing:
7089 if needsoutgoing:
7078 dest, dbranch, dother, outgoing = getoutgoing()
7090 dest, dbranch, dother, outgoing = getoutgoing()
7079 else:
7091 else:
7080 dest = dbranch = dother = outgoing = None
7092 dest = dbranch = dother = outgoing = None
7081
7093
7082 if opts.get(b'remote'):
7094 if opts.get(b'remote'):
7083 t = []
7095 t = []
7084 if incoming:
7096 if incoming:
7085 t.append(_(b'1 or more incoming'))
7097 t.append(_(b'1 or more incoming'))
7086 o = outgoing.missing
7098 o = outgoing.missing
7087 if o:
7099 if o:
7088 t.append(_(b'%d outgoing') % len(o))
7100 t.append(_(b'%d outgoing') % len(o))
7089 other = dother or sother
7101 other = dother or sother
7090 if b'bookmarks' in other.listkeys(b'namespaces'):
7102 if b'bookmarks' in other.listkeys(b'namespaces'):
7091 counts = bookmarks.summary(repo, other)
7103 counts = bookmarks.summary(repo, other)
7092 if counts[0] > 0:
7104 if counts[0] > 0:
7093 t.append(_(b'%d incoming bookmarks') % counts[0])
7105 t.append(_(b'%d incoming bookmarks') % counts[0])
7094 if counts[1] > 0:
7106 if counts[1] > 0:
7095 t.append(_(b'%d outgoing bookmarks') % counts[1])
7107 t.append(_(b'%d outgoing bookmarks') % counts[1])
7096
7108
7097 if t:
7109 if t:
7098 # i18n: column positioning for "hg summary"
7110 # i18n: column positioning for "hg summary"
7099 ui.write(_(b'remote: %s\n') % (b', '.join(t)))
7111 ui.write(_(b'remote: %s\n') % (b', '.join(t)))
7100 else:
7112 else:
7101 # i18n: column positioning for "hg summary"
7113 # i18n: column positioning for "hg summary"
7102 ui.status(_(b'remote: (synced)\n'))
7114 ui.status(_(b'remote: (synced)\n'))
7103
7115
7104 cmdutil.summaryremotehooks(
7116 cmdutil.summaryremotehooks(
7105 ui,
7117 ui,
7106 repo,
7118 repo,
7107 opts,
7119 opts,
7108 (
7120 (
7109 (source, sbranch, sother, commoninc),
7121 (source, sbranch, sother, commoninc),
7110 (dest, dbranch, dother, outgoing),
7122 (dest, dbranch, dother, outgoing),
7111 ),
7123 ),
7112 )
7124 )
7113
7125
7114
7126
7115 @command(
7127 @command(
7116 b'tag',
7128 b'tag',
7117 [
7129 [
7118 (b'f', b'force', None, _(b'force tag')),
7130 (b'f', b'force', None, _(b'force tag')),
7119 (b'l', b'local', None, _(b'make the tag local')),
7131 (b'l', b'local', None, _(b'make the tag local')),
7120 (b'r', b'rev', b'', _(b'revision to tag'), _(b'REV')),
7132 (b'r', b'rev', b'', _(b'revision to tag'), _(b'REV')),
7121 (b'', b'remove', None, _(b'remove a tag')),
7133 (b'', b'remove', None, _(b'remove a tag')),
7122 # -l/--local is already there, commitopts cannot be used
7134 # -l/--local is already there, commitopts cannot be used
7123 (b'e', b'edit', None, _(b'invoke editor on commit messages')),
7135 (b'e', b'edit', None, _(b'invoke editor on commit messages')),
7124 (b'm', b'message', b'', _(b'use text as commit message'), _(b'TEXT')),
7136 (b'm', b'message', b'', _(b'use text as commit message'), _(b'TEXT')),
7125 ]
7137 ]
7126 + commitopts2,
7138 + commitopts2,
7127 _(b'[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'),
7139 _(b'[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'),
7128 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
7140 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
7129 )
7141 )
7130 def tag(ui, repo, name1, *names, **opts):
7142 def tag(ui, repo, name1, *names, **opts):
7131 """add one or more tags for the current or given revision
7143 """add one or more tags for the current or given revision
7132
7144
7133 Name a particular revision using <name>.
7145 Name a particular revision using <name>.
7134
7146
7135 Tags are used to name particular revisions of the repository and are
7147 Tags are used to name particular revisions of the repository and are
7136 very useful to compare different revisions, to go back to significant
7148 very useful to compare different revisions, to go back to significant
7137 earlier versions or to mark branch points as releases, etc. Changing
7149 earlier versions or to mark branch points as releases, etc. Changing
7138 an existing tag is normally disallowed; use -f/--force to override.
7150 an existing tag is normally disallowed; use -f/--force to override.
7139
7151
7140 If no revision is given, the parent of the working directory is
7152 If no revision is given, the parent of the working directory is
7141 used.
7153 used.
7142
7154
7143 To facilitate version control, distribution, and merging of tags,
7155 To facilitate version control, distribution, and merging of tags,
7144 they are stored as a file named ".hgtags" which is managed similarly
7156 they are stored as a file named ".hgtags" which is managed similarly
7145 to other project files and can be hand-edited if necessary. This
7157 to other project files and can be hand-edited if necessary. This
7146 also means that tagging creates a new commit. The file
7158 also means that tagging creates a new commit. The file
7147 ".hg/localtags" is used for local tags (not shared among
7159 ".hg/localtags" is used for local tags (not shared among
7148 repositories).
7160 repositories).
7149
7161
7150 Tag commits are usually made at the head of a branch. If the parent
7162 Tag commits are usually made at the head of a branch. If the parent
7151 of the working directory is not a branch head, :hg:`tag` aborts; use
7163 of the working directory is not a branch head, :hg:`tag` aborts; use
7152 -f/--force to force the tag commit to be based on a non-head
7164 -f/--force to force the tag commit to be based on a non-head
7153 changeset.
7165 changeset.
7154
7166
7155 See :hg:`help dates` for a list of formats valid for -d/--date.
7167 See :hg:`help dates` for a list of formats valid for -d/--date.
7156
7168
7157 Since tag names have priority over branch names during revision
7169 Since tag names have priority over branch names during revision
7158 lookup, using an existing branch name as a tag name is discouraged.
7170 lookup, using an existing branch name as a tag name is discouraged.
7159
7171
7160 Returns 0 on success.
7172 Returns 0 on success.
7161 """
7173 """
7162 cmdutil.check_incompatible_arguments(opts, 'remove', ['rev'])
7174 cmdutil.check_incompatible_arguments(opts, 'remove', ['rev'])
7163 opts = pycompat.byteskwargs(opts)
7175 opts = pycompat.byteskwargs(opts)
7164 with repo.wlock(), repo.lock():
7176 with repo.wlock(), repo.lock():
7165 rev_ = b"."
7177 rev_ = b"."
7166 names = [t.strip() for t in (name1,) + names]
7178 names = [t.strip() for t in (name1,) + names]
7167 if len(names) != len(set(names)):
7179 if len(names) != len(set(names)):
7168 raise error.InputError(_(b'tag names must be unique'))
7180 raise error.InputError(_(b'tag names must be unique'))
7169 for n in names:
7181 for n in names:
7170 scmutil.checknewlabel(repo, n, b'tag')
7182 scmutil.checknewlabel(repo, n, b'tag')
7171 if not n:
7183 if not n:
7172 raise error.InputError(
7184 raise error.InputError(
7173 _(b'tag names cannot consist entirely of whitespace')
7185 _(b'tag names cannot consist entirely of whitespace')
7174 )
7186 )
7175 if opts.get(b'rev'):
7187 if opts.get(b'rev'):
7176 rev_ = opts[b'rev']
7188 rev_ = opts[b'rev']
7177 message = opts.get(b'message')
7189 message = opts.get(b'message')
7178 if opts.get(b'remove'):
7190 if opts.get(b'remove'):
7179 if opts.get(b'local'):
7191 if opts.get(b'local'):
7180 expectedtype = b'local'
7192 expectedtype = b'local'
7181 else:
7193 else:
7182 expectedtype = b'global'
7194 expectedtype = b'global'
7183
7195
7184 for n in names:
7196 for n in names:
7185 if repo.tagtype(n) == b'global':
7197 if repo.tagtype(n) == b'global':
7186 alltags = tagsmod.findglobaltags(ui, repo)
7198 alltags = tagsmod.findglobaltags(ui, repo)
7187 if alltags[n][0] == nullid:
7199 if alltags[n][0] == nullid:
7188 raise error.InputError(
7200 raise error.InputError(
7189 _(b"tag '%s' is already removed") % n
7201 _(b"tag '%s' is already removed") % n
7190 )
7202 )
7191 if not repo.tagtype(n):
7203 if not repo.tagtype(n):
7192 raise error.InputError(_(b"tag '%s' does not exist") % n)
7204 raise error.InputError(_(b"tag '%s' does not exist") % n)
7193 if repo.tagtype(n) != expectedtype:
7205 if repo.tagtype(n) != expectedtype:
7194 if expectedtype == b'global':
7206 if expectedtype == b'global':
7195 raise error.InputError(
7207 raise error.InputError(
7196 _(b"tag '%s' is not a global tag") % n
7208 _(b"tag '%s' is not a global tag") % n
7197 )
7209 )
7198 else:
7210 else:
7199 raise error.InputError(
7211 raise error.InputError(
7200 _(b"tag '%s' is not a local tag") % n
7212 _(b"tag '%s' is not a local tag") % n
7201 )
7213 )
7202 rev_ = b'null'
7214 rev_ = b'null'
7203 if not message:
7215 if not message:
7204 # we don't translate commit messages
7216 # we don't translate commit messages
7205 message = b'Removed tag %s' % b', '.join(names)
7217 message = b'Removed tag %s' % b', '.join(names)
7206 elif not opts.get(b'force'):
7218 elif not opts.get(b'force'):
7207 for n in names:
7219 for n in names:
7208 if n in repo.tags():
7220 if n in repo.tags():
7209 raise error.InputError(
7221 raise error.InputError(
7210 _(b"tag '%s' already exists (use -f to force)") % n
7222 _(b"tag '%s' already exists (use -f to force)") % n
7211 )
7223 )
7212 if not opts.get(b'local'):
7224 if not opts.get(b'local'):
7213 p1, p2 = repo.dirstate.parents()
7225 p1, p2 = repo.dirstate.parents()
7214 if p2 != nullid:
7226 if p2 != nullid:
7215 raise error.StateError(_(b'uncommitted merge'))
7227 raise error.StateError(_(b'uncommitted merge'))
7216 bheads = repo.branchheads()
7228 bheads = repo.branchheads()
7217 if not opts.get(b'force') and bheads and p1 not in bheads:
7229 if not opts.get(b'force') and bheads and p1 not in bheads:
7218 raise error.InputError(
7230 raise error.InputError(
7219 _(
7231 _(
7220 b'working directory is not at a branch head '
7232 b'working directory is not at a branch head '
7221 b'(use -f to force)'
7233 b'(use -f to force)'
7222 )
7234 )
7223 )
7235 )
7224 node = scmutil.revsingle(repo, rev_).node()
7236 node = scmutil.revsingle(repo, rev_).node()
7225
7237
7226 if not message:
7238 if not message:
7227 # we don't translate commit messages
7239 # we don't translate commit messages
7228 message = b'Added tag %s for changeset %s' % (
7240 message = b'Added tag %s for changeset %s' % (
7229 b', '.join(names),
7241 b', '.join(names),
7230 short(node),
7242 short(node),
7231 )
7243 )
7232
7244
7233 date = opts.get(b'date')
7245 date = opts.get(b'date')
7234 if date:
7246 if date:
7235 date = dateutil.parsedate(date)
7247 date = dateutil.parsedate(date)
7236
7248
7237 if opts.get(b'remove'):
7249 if opts.get(b'remove'):
7238 editform = b'tag.remove'
7250 editform = b'tag.remove'
7239 else:
7251 else:
7240 editform = b'tag.add'
7252 editform = b'tag.add'
7241 editor = cmdutil.getcommiteditor(
7253 editor = cmdutil.getcommiteditor(
7242 editform=editform, **pycompat.strkwargs(opts)
7254 editform=editform, **pycompat.strkwargs(opts)
7243 )
7255 )
7244
7256
7245 # don't allow tagging the null rev
7257 # don't allow tagging the null rev
7246 if (
7258 if (
7247 not opts.get(b'remove')
7259 not opts.get(b'remove')
7248 and scmutil.revsingle(repo, rev_).rev() == nullrev
7260 and scmutil.revsingle(repo, rev_).rev() == nullrev
7249 ):
7261 ):
7250 raise error.InputError(_(b"cannot tag null revision"))
7262 raise error.InputError(_(b"cannot tag null revision"))
7251
7263
7252 tagsmod.tag(
7264 tagsmod.tag(
7253 repo,
7265 repo,
7254 names,
7266 names,
7255 node,
7267 node,
7256 message,
7268 message,
7257 opts.get(b'local'),
7269 opts.get(b'local'),
7258 opts.get(b'user'),
7270 opts.get(b'user'),
7259 date,
7271 date,
7260 editor=editor,
7272 editor=editor,
7261 )
7273 )
7262
7274
7263
7275
7264 @command(
7276 @command(
7265 b'tags',
7277 b'tags',
7266 formatteropts,
7278 formatteropts,
7267 b'',
7279 b'',
7268 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
7280 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
7269 intents={INTENT_READONLY},
7281 intents={INTENT_READONLY},
7270 )
7282 )
7271 def tags(ui, repo, **opts):
7283 def tags(ui, repo, **opts):
7272 """list repository tags
7284 """list repository tags
7273
7285
7274 This lists both regular and local tags. When the -v/--verbose
7286 This lists both regular and local tags. When the -v/--verbose
7275 switch is used, a third column "local" is printed for local tags.
7287 switch is used, a third column "local" is printed for local tags.
7276 When the -q/--quiet switch is used, only the tag name is printed.
7288 When the -q/--quiet switch is used, only the tag name is printed.
7277
7289
7278 .. container:: verbose
7290 .. container:: verbose
7279
7291
7280 Template:
7292 Template:
7281
7293
7282 The following keywords are supported in addition to the common template
7294 The following keywords are supported in addition to the common template
7283 keywords and functions such as ``{tag}``. See also
7295 keywords and functions such as ``{tag}``. See also
7284 :hg:`help templates`.
7296 :hg:`help templates`.
7285
7297
7286 :type: String. ``local`` for local tags.
7298 :type: String. ``local`` for local tags.
7287
7299
7288 Returns 0 on success.
7300 Returns 0 on success.
7289 """
7301 """
7290
7302
7291 opts = pycompat.byteskwargs(opts)
7303 opts = pycompat.byteskwargs(opts)
7292 ui.pager(b'tags')
7304 ui.pager(b'tags')
7293 fm = ui.formatter(b'tags', opts)
7305 fm = ui.formatter(b'tags', opts)
7294 hexfunc = fm.hexfunc
7306 hexfunc = fm.hexfunc
7295
7307
7296 for t, n in reversed(repo.tagslist()):
7308 for t, n in reversed(repo.tagslist()):
7297 hn = hexfunc(n)
7309 hn = hexfunc(n)
7298 label = b'tags.normal'
7310 label = b'tags.normal'
7299 tagtype = b''
7311 tagtype = b''
7300 if repo.tagtype(t) == b'local':
7312 if repo.tagtype(t) == b'local':
7301 label = b'tags.local'
7313 label = b'tags.local'
7302 tagtype = b'local'
7314 tagtype = b'local'
7303
7315
7304 fm.startitem()
7316 fm.startitem()
7305 fm.context(repo=repo)
7317 fm.context(repo=repo)
7306 fm.write(b'tag', b'%s', t, label=label)
7318 fm.write(b'tag', b'%s', t, label=label)
7307 fmt = b" " * (30 - encoding.colwidth(t)) + b' %5d:%s'
7319 fmt = b" " * (30 - encoding.colwidth(t)) + b' %5d:%s'
7308 fm.condwrite(
7320 fm.condwrite(
7309 not ui.quiet,
7321 not ui.quiet,
7310 b'rev node',
7322 b'rev node',
7311 fmt,
7323 fmt,
7312 repo.changelog.rev(n),
7324 repo.changelog.rev(n),
7313 hn,
7325 hn,
7314 label=label,
7326 label=label,
7315 )
7327 )
7316 fm.condwrite(
7328 fm.condwrite(
7317 ui.verbose and tagtype, b'type', b' %s', tagtype, label=label
7329 ui.verbose and tagtype, b'type', b' %s', tagtype, label=label
7318 )
7330 )
7319 fm.plain(b'\n')
7331 fm.plain(b'\n')
7320 fm.end()
7332 fm.end()
7321
7333
7322
7334
7323 @command(
7335 @command(
7324 b'tip',
7336 b'tip',
7325 [
7337 [
7326 (b'p', b'patch', None, _(b'show patch')),
7338 (b'p', b'patch', None, _(b'show patch')),
7327 (b'g', b'git', None, _(b'use git extended diff format')),
7339 (b'g', b'git', None, _(b'use git extended diff format')),
7328 ]
7340 ]
7329 + templateopts,
7341 + templateopts,
7330 _(b'[-p] [-g]'),
7342 _(b'[-p] [-g]'),
7331 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
7343 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
7332 )
7344 )
7333 def tip(ui, repo, **opts):
7345 def tip(ui, repo, **opts):
7334 """show the tip revision (DEPRECATED)
7346 """show the tip revision (DEPRECATED)
7335
7347
7336 The tip revision (usually just called the tip) is the changeset
7348 The tip revision (usually just called the tip) is the changeset
7337 most recently added to the repository (and therefore the most
7349 most recently added to the repository (and therefore the most
7338 recently changed head).
7350 recently changed head).
7339
7351
7340 If you have just made a commit, that commit will be the tip. If
7352 If you have just made a commit, that commit will be the tip. If
7341 you have just pulled changes from another repository, the tip of
7353 you have just pulled changes from another repository, the tip of
7342 that repository becomes the current tip. The "tip" tag is special
7354 that repository becomes the current tip. The "tip" tag is special
7343 and cannot be renamed or assigned to a different changeset.
7355 and cannot be renamed or assigned to a different changeset.
7344
7356
7345 This command is deprecated, please use :hg:`heads` instead.
7357 This command is deprecated, please use :hg:`heads` instead.
7346
7358
7347 Returns 0 on success.
7359 Returns 0 on success.
7348 """
7360 """
7349 opts = pycompat.byteskwargs(opts)
7361 opts = pycompat.byteskwargs(opts)
7350 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
7362 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
7351 displayer.show(repo[b'tip'])
7363 displayer.show(repo[b'tip'])
7352 displayer.close()
7364 displayer.close()
7353
7365
7354
7366
7355 @command(
7367 @command(
7356 b'unbundle',
7368 b'unbundle',
7357 [
7369 [
7358 (
7370 (
7359 b'u',
7371 b'u',
7360 b'update',
7372 b'update',
7361 None,
7373 None,
7362 _(b'update to new branch head if changesets were unbundled'),
7374 _(b'update to new branch head if changesets were unbundled'),
7363 )
7375 )
7364 ],
7376 ],
7365 _(b'[-u] FILE...'),
7377 _(b'[-u] FILE...'),
7366 helpcategory=command.CATEGORY_IMPORT_EXPORT,
7378 helpcategory=command.CATEGORY_IMPORT_EXPORT,
7367 )
7379 )
7368 def unbundle(ui, repo, fname1, *fnames, **opts):
7380 def unbundle(ui, repo, fname1, *fnames, **opts):
7369 """apply one or more bundle files
7381 """apply one or more bundle files
7370
7382
7371 Apply one or more bundle files generated by :hg:`bundle`.
7383 Apply one or more bundle files generated by :hg:`bundle`.
7372
7384
7373 Returns 0 on success, 1 if an update has unresolved files.
7385 Returns 0 on success, 1 if an update has unresolved files.
7374 """
7386 """
7375 fnames = (fname1,) + fnames
7387 fnames = (fname1,) + fnames
7376
7388
7377 with repo.lock():
7389 with repo.lock():
7378 for fname in fnames:
7390 for fname in fnames:
7379 f = hg.openpath(ui, fname)
7391 f = hg.openpath(ui, fname)
7380 gen = exchange.readbundle(ui, f, fname)
7392 gen = exchange.readbundle(ui, f, fname)
7381 if isinstance(gen, streamclone.streamcloneapplier):
7393 if isinstance(gen, streamclone.streamcloneapplier):
7382 raise error.InputError(
7394 raise error.InputError(
7383 _(
7395 _(
7384 b'packed bundles cannot be applied with '
7396 b'packed bundles cannot be applied with '
7385 b'"hg unbundle"'
7397 b'"hg unbundle"'
7386 ),
7398 ),
7387 hint=_(b'use "hg debugapplystreamclonebundle"'),
7399 hint=_(b'use "hg debugapplystreamclonebundle"'),
7388 )
7400 )
7389 url = b'bundle:' + fname
7401 url = b'bundle:' + fname
7390 try:
7402 try:
7391 txnname = b'unbundle'
7403 txnname = b'unbundle'
7392 if not isinstance(gen, bundle2.unbundle20):
7404 if not isinstance(gen, bundle2.unbundle20):
7393 txnname = b'unbundle\n%s' % util.hidepassword(url)
7405 txnname = b'unbundle\n%s' % util.hidepassword(url)
7394 with repo.transaction(txnname) as tr:
7406 with repo.transaction(txnname) as tr:
7395 op = bundle2.applybundle(
7407 op = bundle2.applybundle(
7396 repo, gen, tr, source=b'unbundle', url=url
7408 repo, gen, tr, source=b'unbundle', url=url
7397 )
7409 )
7398 except error.BundleUnknownFeatureError as exc:
7410 except error.BundleUnknownFeatureError as exc:
7399 raise error.Abort(
7411 raise error.Abort(
7400 _(b'%s: unknown bundle feature, %s') % (fname, exc),
7412 _(b'%s: unknown bundle feature, %s') % (fname, exc),
7401 hint=_(
7413 hint=_(
7402 b"see https://mercurial-scm.org/"
7414 b"see https://mercurial-scm.org/"
7403 b"wiki/BundleFeature for more "
7415 b"wiki/BundleFeature for more "
7404 b"information"
7416 b"information"
7405 ),
7417 ),
7406 )
7418 )
7407 modheads = bundle2.combinechangegroupresults(op)
7419 modheads = bundle2.combinechangegroupresults(op)
7408
7420
7409 return postincoming(ui, repo, modheads, opts.get('update'), None, None)
7421 return postincoming(ui, repo, modheads, opts.get('update'), None, None)
7410
7422
7411
7423
7412 @command(
7424 @command(
7413 b'unshelve',
7425 b'unshelve',
7414 [
7426 [
7415 (b'a', b'abort', None, _(b'abort an incomplete unshelve operation')),
7427 (b'a', b'abort', None, _(b'abort an incomplete unshelve operation')),
7416 (
7428 (
7417 b'c',
7429 b'c',
7418 b'continue',
7430 b'continue',
7419 None,
7431 None,
7420 _(b'continue an incomplete unshelve operation'),
7432 _(b'continue an incomplete unshelve operation'),
7421 ),
7433 ),
7422 (b'i', b'interactive', None, _(b'use interactive mode (EXPERIMENTAL)')),
7434 (b'i', b'interactive', None, _(b'use interactive mode (EXPERIMENTAL)')),
7423 (b'k', b'keep', None, _(b'keep shelve after unshelving')),
7435 (b'k', b'keep', None, _(b'keep shelve after unshelving')),
7424 (
7436 (
7425 b'n',
7437 b'n',
7426 b'name',
7438 b'name',
7427 b'',
7439 b'',
7428 _(b'restore shelved change with given name'),
7440 _(b'restore shelved change with given name'),
7429 _(b'NAME'),
7441 _(b'NAME'),
7430 ),
7442 ),
7431 (b't', b'tool', b'', _(b'specify merge tool')),
7443 (b't', b'tool', b'', _(b'specify merge tool')),
7432 (
7444 (
7433 b'',
7445 b'',
7434 b'date',
7446 b'date',
7435 b'',
7447 b'',
7436 _(b'set date for temporary commits (DEPRECATED)'),
7448 _(b'set date for temporary commits (DEPRECATED)'),
7437 _(b'DATE'),
7449 _(b'DATE'),
7438 ),
7450 ),
7439 ],
7451 ],
7440 _(b'hg unshelve [OPTION]... [[-n] SHELVED]'),
7452 _(b'hg unshelve [OPTION]... [[-n] SHELVED]'),
7441 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
7453 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
7442 )
7454 )
7443 def unshelve(ui, repo, *shelved, **opts):
7455 def unshelve(ui, repo, *shelved, **opts):
7444 """restore a shelved change to the working directory
7456 """restore a shelved change to the working directory
7445
7457
7446 This command accepts an optional name of a shelved change to
7458 This command accepts an optional name of a shelved change to
7447 restore. If none is given, the most recent shelved change is used.
7459 restore. If none is given, the most recent shelved change is used.
7448
7460
7449 If a shelved change is applied successfully, the bundle that
7461 If a shelved change is applied successfully, the bundle that
7450 contains the shelved changes is moved to a backup location
7462 contains the shelved changes is moved to a backup location
7451 (.hg/shelve-backup).
7463 (.hg/shelve-backup).
7452
7464
7453 Since you can restore a shelved change on top of an arbitrary
7465 Since you can restore a shelved change on top of an arbitrary
7454 commit, it is possible that unshelving will result in a conflict
7466 commit, it is possible that unshelving will result in a conflict
7455 between your changes and the commits you are unshelving onto. If
7467 between your changes and the commits you are unshelving onto. If
7456 this occurs, you must resolve the conflict, then use
7468 this occurs, you must resolve the conflict, then use
7457 ``--continue`` to complete the unshelve operation. (The bundle
7469 ``--continue`` to complete the unshelve operation. (The bundle
7458 will not be moved until you successfully complete the unshelve.)
7470 will not be moved until you successfully complete the unshelve.)
7459
7471
7460 (Alternatively, you can use ``--abort`` to abandon an unshelve
7472 (Alternatively, you can use ``--abort`` to abandon an unshelve
7461 that causes a conflict. This reverts the unshelved changes, and
7473 that causes a conflict. This reverts the unshelved changes, and
7462 leaves the bundle in place.)
7474 leaves the bundle in place.)
7463
7475
7464 If bare shelved change (without interactive, include and exclude
7476 If bare shelved change (without interactive, include and exclude
7465 option) was done on newly created branch it would restore branch
7477 option) was done on newly created branch it would restore branch
7466 information to the working directory.
7478 information to the working directory.
7467
7479
7468 After a successful unshelve, the shelved changes are stored in a
7480 After a successful unshelve, the shelved changes are stored in a
7469 backup directory. Only the N most recent backups are kept. N
7481 backup directory. Only the N most recent backups are kept. N
7470 defaults to 10 but can be overridden using the ``shelve.maxbackups``
7482 defaults to 10 but can be overridden using the ``shelve.maxbackups``
7471 configuration option.
7483 configuration option.
7472
7484
7473 .. container:: verbose
7485 .. container:: verbose
7474
7486
7475 Timestamp in seconds is used to decide order of backups. More
7487 Timestamp in seconds is used to decide order of backups. More
7476 than ``maxbackups`` backups are kept, if same timestamp
7488 than ``maxbackups`` backups are kept, if same timestamp
7477 prevents from deciding exact order of them, for safety.
7489 prevents from deciding exact order of them, for safety.
7478
7490
7479 Selected changes can be unshelved with ``--interactive`` flag.
7491 Selected changes can be unshelved with ``--interactive`` flag.
7480 The working directory is updated with the selected changes, and
7492 The working directory is updated with the selected changes, and
7481 only the unselected changes remain shelved.
7493 only the unselected changes remain shelved.
7482 Note: The whole shelve is applied to working directory first before
7494 Note: The whole shelve is applied to working directory first before
7483 running interactively. So, this will bring up all the conflicts between
7495 running interactively. So, this will bring up all the conflicts between
7484 working directory and the shelve, irrespective of which changes will be
7496 working directory and the shelve, irrespective of which changes will be
7485 unshelved.
7497 unshelved.
7486 """
7498 """
7487 with repo.wlock():
7499 with repo.wlock():
7488 return shelvemod.unshelvecmd(ui, repo, *shelved, **opts)
7500 return shelvemod.unshelvecmd(ui, repo, *shelved, **opts)
7489
7501
7490
7502
7491 statemod.addunfinished(
7503 statemod.addunfinished(
7492 b'unshelve',
7504 b'unshelve',
7493 fname=b'shelvedstate',
7505 fname=b'shelvedstate',
7494 continueflag=True,
7506 continueflag=True,
7495 abortfunc=shelvemod.hgabortunshelve,
7507 abortfunc=shelvemod.hgabortunshelve,
7496 continuefunc=shelvemod.hgcontinueunshelve,
7508 continuefunc=shelvemod.hgcontinueunshelve,
7497 cmdmsg=_(b'unshelve already in progress'),
7509 cmdmsg=_(b'unshelve already in progress'),
7498 )
7510 )
7499
7511
7500
7512
7501 @command(
7513 @command(
7502 b'update|up|checkout|co',
7514 b'update|up|checkout|co',
7503 [
7515 [
7504 (b'C', b'clean', None, _(b'discard uncommitted changes (no backup)')),
7516 (b'C', b'clean', None, _(b'discard uncommitted changes (no backup)')),
7505 (b'c', b'check', None, _(b'require clean working directory')),
7517 (b'c', b'check', None, _(b'require clean working directory')),
7506 (b'm', b'merge', None, _(b'merge uncommitted changes')),
7518 (b'm', b'merge', None, _(b'merge uncommitted changes')),
7507 (b'd', b'date', b'', _(b'tipmost revision matching date'), _(b'DATE')),
7519 (b'd', b'date', b'', _(b'tipmost revision matching date'), _(b'DATE')),
7508 (b'r', b'rev', b'', _(b'revision'), _(b'REV')),
7520 (b'r', b'rev', b'', _(b'revision'), _(b'REV')),
7509 ]
7521 ]
7510 + mergetoolopts,
7522 + mergetoolopts,
7511 _(b'[-C|-c|-m] [-d DATE] [[-r] REV]'),
7523 _(b'[-C|-c|-m] [-d DATE] [[-r] REV]'),
7512 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
7524 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
7513 helpbasic=True,
7525 helpbasic=True,
7514 )
7526 )
7515 def update(ui, repo, node=None, **opts):
7527 def update(ui, repo, node=None, **opts):
7516 """update working directory (or switch revisions)
7528 """update working directory (or switch revisions)
7517
7529
7518 Update the repository's working directory to the specified
7530 Update the repository's working directory to the specified
7519 changeset. If no changeset is specified, update to the tip of the
7531 changeset. If no changeset is specified, update to the tip of the
7520 current named branch and move the active bookmark (see :hg:`help
7532 current named branch and move the active bookmark (see :hg:`help
7521 bookmarks`).
7533 bookmarks`).
7522
7534
7523 Update sets the working directory's parent revision to the specified
7535 Update sets the working directory's parent revision to the specified
7524 changeset (see :hg:`help parents`).
7536 changeset (see :hg:`help parents`).
7525
7537
7526 If the changeset is not a descendant or ancestor of the working
7538 If the changeset is not a descendant or ancestor of the working
7527 directory's parent and there are uncommitted changes, the update is
7539 directory's parent and there are uncommitted changes, the update is
7528 aborted. With the -c/--check option, the working directory is checked
7540 aborted. With the -c/--check option, the working directory is checked
7529 for uncommitted changes; if none are found, the working directory is
7541 for uncommitted changes; if none are found, the working directory is
7530 updated to the specified changeset.
7542 updated to the specified changeset.
7531
7543
7532 .. container:: verbose
7544 .. container:: verbose
7533
7545
7534 The -C/--clean, -c/--check, and -m/--merge options control what
7546 The -C/--clean, -c/--check, and -m/--merge options control what
7535 happens if the working directory contains uncommitted changes.
7547 happens if the working directory contains uncommitted changes.
7536 At most of one of them can be specified.
7548 At most of one of them can be specified.
7537
7549
7538 1. If no option is specified, and if
7550 1. If no option is specified, and if
7539 the requested changeset is an ancestor or descendant of
7551 the requested changeset is an ancestor or descendant of
7540 the working directory's parent, the uncommitted changes
7552 the working directory's parent, the uncommitted changes
7541 are merged into the requested changeset and the merged
7553 are merged into the requested changeset and the merged
7542 result is left uncommitted. If the requested changeset is
7554 result is left uncommitted. If the requested changeset is
7543 not an ancestor or descendant (that is, it is on another
7555 not an ancestor or descendant (that is, it is on another
7544 branch), the update is aborted and the uncommitted changes
7556 branch), the update is aborted and the uncommitted changes
7545 are preserved.
7557 are preserved.
7546
7558
7547 2. With the -m/--merge option, the update is allowed even if the
7559 2. With the -m/--merge option, the update is allowed even if the
7548 requested changeset is not an ancestor or descendant of
7560 requested changeset is not an ancestor or descendant of
7549 the working directory's parent.
7561 the working directory's parent.
7550
7562
7551 3. With the -c/--check option, the update is aborted and the
7563 3. With the -c/--check option, the update is aborted and the
7552 uncommitted changes are preserved.
7564 uncommitted changes are preserved.
7553
7565
7554 4. With the -C/--clean option, uncommitted changes are discarded and
7566 4. With the -C/--clean option, uncommitted changes are discarded and
7555 the working directory is updated to the requested changeset.
7567 the working directory is updated to the requested changeset.
7556
7568
7557 To cancel an uncommitted merge (and lose your changes), use
7569 To cancel an uncommitted merge (and lose your changes), use
7558 :hg:`merge --abort`.
7570 :hg:`merge --abort`.
7559
7571
7560 Use null as the changeset to remove the working directory (like
7572 Use null as the changeset to remove the working directory (like
7561 :hg:`clone -U`).
7573 :hg:`clone -U`).
7562
7574
7563 If you want to revert just one file to an older revision, use
7575 If you want to revert just one file to an older revision, use
7564 :hg:`revert [-r REV] NAME`.
7576 :hg:`revert [-r REV] NAME`.
7565
7577
7566 See :hg:`help dates` for a list of formats valid for -d/--date.
7578 See :hg:`help dates` for a list of formats valid for -d/--date.
7567
7579
7568 Returns 0 on success, 1 if there are unresolved files.
7580 Returns 0 on success, 1 if there are unresolved files.
7569 """
7581 """
7570 cmdutil.check_at_most_one_arg(opts, 'clean', 'check', 'merge')
7582 cmdutil.check_at_most_one_arg(opts, 'clean', 'check', 'merge')
7571 rev = opts.get('rev')
7583 rev = opts.get('rev')
7572 date = opts.get('date')
7584 date = opts.get('date')
7573 clean = opts.get('clean')
7585 clean = opts.get('clean')
7574 check = opts.get('check')
7586 check = opts.get('check')
7575 merge = opts.get('merge')
7587 merge = opts.get('merge')
7576 if rev and node:
7588 if rev and node:
7577 raise error.InputError(_(b"please specify just one revision"))
7589 raise error.InputError(_(b"please specify just one revision"))
7578
7590
7579 if ui.configbool(b'commands', b'update.requiredest'):
7591 if ui.configbool(b'commands', b'update.requiredest'):
7580 if not node and not rev and not date:
7592 if not node and not rev and not date:
7581 raise error.InputError(
7593 raise error.InputError(
7582 _(b'you must specify a destination'),
7594 _(b'you must specify a destination'),
7583 hint=_(b'for example: hg update ".::"'),
7595 hint=_(b'for example: hg update ".::"'),
7584 )
7596 )
7585
7597
7586 if rev is None or rev == b'':
7598 if rev is None or rev == b'':
7587 rev = node
7599 rev = node
7588
7600
7589 if date and rev is not None:
7601 if date and rev is not None:
7590 raise error.InputError(_(b"you can't specify a revision and a date"))
7602 raise error.InputError(_(b"you can't specify a revision and a date"))
7591
7603
7592 updatecheck = None
7604 updatecheck = None
7593 if check:
7605 if check:
7594 updatecheck = b'abort'
7606 updatecheck = b'abort'
7595 elif merge:
7607 elif merge:
7596 updatecheck = b'none'
7608 updatecheck = b'none'
7597
7609
7598 with repo.wlock():
7610 with repo.wlock():
7599 cmdutil.clearunfinished(repo)
7611 cmdutil.clearunfinished(repo)
7600 if date:
7612 if date:
7601 rev = cmdutil.finddate(ui, repo, date)
7613 rev = cmdutil.finddate(ui, repo, date)
7602
7614
7603 # if we defined a bookmark, we have to remember the original name
7615 # if we defined a bookmark, we have to remember the original name
7604 brev = rev
7616 brev = rev
7605 if rev:
7617 if rev:
7606 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
7618 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
7607 ctx = scmutil.revsingle(repo, rev, default=None)
7619 ctx = scmutil.revsingle(repo, rev, default=None)
7608 rev = ctx.rev()
7620 rev = ctx.rev()
7609 hidden = ctx.hidden()
7621 hidden = ctx.hidden()
7610 overrides = {(b'ui', b'forcemerge'): opts.get('tool', b'')}
7622 overrides = {(b'ui', b'forcemerge'): opts.get('tool', b'')}
7611 with ui.configoverride(overrides, b'update'):
7623 with ui.configoverride(overrides, b'update'):
7612 ret = hg.updatetotally(
7624 ret = hg.updatetotally(
7613 ui, repo, rev, brev, clean=clean, updatecheck=updatecheck
7625 ui, repo, rev, brev, clean=clean, updatecheck=updatecheck
7614 )
7626 )
7615 if hidden:
7627 if hidden:
7616 ctxstr = ctx.hex()[:12]
7628 ctxstr = ctx.hex()[:12]
7617 ui.warn(_(b"updated to hidden changeset %s\n") % ctxstr)
7629 ui.warn(_(b"updated to hidden changeset %s\n") % ctxstr)
7618
7630
7619 if ctx.obsolete():
7631 if ctx.obsolete():
7620 obsfatemsg = obsutil._getfilteredreason(repo, ctxstr, ctx)
7632 obsfatemsg = obsutil._getfilteredreason(repo, ctxstr, ctx)
7621 ui.warn(b"(%s)\n" % obsfatemsg)
7633 ui.warn(b"(%s)\n" % obsfatemsg)
7622 return ret
7634 return ret
7623
7635
7624
7636
7625 @command(
7637 @command(
7626 b'verify',
7638 b'verify',
7627 [(b'', b'full', False, b'perform more checks (EXPERIMENTAL)')],
7639 [(b'', b'full', False, b'perform more checks (EXPERIMENTAL)')],
7628 helpcategory=command.CATEGORY_MAINTENANCE,
7640 helpcategory=command.CATEGORY_MAINTENANCE,
7629 )
7641 )
7630 def verify(ui, repo, **opts):
7642 def verify(ui, repo, **opts):
7631 """verify the integrity of the repository
7643 """verify the integrity of the repository
7632
7644
7633 Verify the integrity of the current repository.
7645 Verify the integrity of the current repository.
7634
7646
7635 This will perform an extensive check of the repository's
7647 This will perform an extensive check of the repository's
7636 integrity, validating the hashes and checksums of each entry in
7648 integrity, validating the hashes and checksums of each entry in
7637 the changelog, manifest, and tracked files, as well as the
7649 the changelog, manifest, and tracked files, as well as the
7638 integrity of their crosslinks and indices.
7650 integrity of their crosslinks and indices.
7639
7651
7640 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
7652 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
7641 for more information about recovery from corruption of the
7653 for more information about recovery from corruption of the
7642 repository.
7654 repository.
7643
7655
7644 Returns 0 on success, 1 if errors are encountered.
7656 Returns 0 on success, 1 if errors are encountered.
7645 """
7657 """
7646 opts = pycompat.byteskwargs(opts)
7658 opts = pycompat.byteskwargs(opts)
7647
7659
7648 level = None
7660 level = None
7649 if opts[b'full']:
7661 if opts[b'full']:
7650 level = verifymod.VERIFY_FULL
7662 level = verifymod.VERIFY_FULL
7651 return hg.verify(repo, level)
7663 return hg.verify(repo, level)
7652
7664
7653
7665
7654 @command(
7666 @command(
7655 b'version',
7667 b'version',
7656 [] + formatteropts,
7668 [] + formatteropts,
7657 helpcategory=command.CATEGORY_HELP,
7669 helpcategory=command.CATEGORY_HELP,
7658 norepo=True,
7670 norepo=True,
7659 intents={INTENT_READONLY},
7671 intents={INTENT_READONLY},
7660 )
7672 )
7661 def version_(ui, **opts):
7673 def version_(ui, **opts):
7662 """output version and copyright information
7674 """output version and copyright information
7663
7675
7664 .. container:: verbose
7676 .. container:: verbose
7665
7677
7666 Template:
7678 Template:
7667
7679
7668 The following keywords are supported. See also :hg:`help templates`.
7680 The following keywords are supported. See also :hg:`help templates`.
7669
7681
7670 :extensions: List of extensions.
7682 :extensions: List of extensions.
7671 :ver: String. Version number.
7683 :ver: String. Version number.
7672
7684
7673 And each entry of ``{extensions}`` provides the following sub-keywords
7685 And each entry of ``{extensions}`` provides the following sub-keywords
7674 in addition to ``{ver}``.
7686 in addition to ``{ver}``.
7675
7687
7676 :bundled: Boolean. True if included in the release.
7688 :bundled: Boolean. True if included in the release.
7677 :name: String. Extension name.
7689 :name: String. Extension name.
7678 """
7690 """
7679 opts = pycompat.byteskwargs(opts)
7691 opts = pycompat.byteskwargs(opts)
7680 if ui.verbose:
7692 if ui.verbose:
7681 ui.pager(b'version')
7693 ui.pager(b'version')
7682 fm = ui.formatter(b"version", opts)
7694 fm = ui.formatter(b"version", opts)
7683 fm.startitem()
7695 fm.startitem()
7684 fm.write(
7696 fm.write(
7685 b"ver", _(b"Mercurial Distributed SCM (version %s)\n"), util.version()
7697 b"ver", _(b"Mercurial Distributed SCM (version %s)\n"), util.version()
7686 )
7698 )
7687 license = _(
7699 license = _(
7688 b"(see https://mercurial-scm.org for more information)\n"
7700 b"(see https://mercurial-scm.org for more information)\n"
7689 b"\nCopyright (C) 2005-2020 Matt Mackall and others\n"
7701 b"\nCopyright (C) 2005-2020 Matt Mackall and others\n"
7690 b"This is free software; see the source for copying conditions. "
7702 b"This is free software; see the source for copying conditions. "
7691 b"There is NO\nwarranty; "
7703 b"There is NO\nwarranty; "
7692 b"not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
7704 b"not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
7693 )
7705 )
7694 if not ui.quiet:
7706 if not ui.quiet:
7695 fm.plain(license)
7707 fm.plain(license)
7696
7708
7697 if ui.verbose:
7709 if ui.verbose:
7698 fm.plain(_(b"\nEnabled extensions:\n\n"))
7710 fm.plain(_(b"\nEnabled extensions:\n\n"))
7699 # format names and versions into columns
7711 # format names and versions into columns
7700 names = []
7712 names = []
7701 vers = []
7713 vers = []
7702 isinternals = []
7714 isinternals = []
7703 for name, module in sorted(extensions.extensions()):
7715 for name, module in sorted(extensions.extensions()):
7704 names.append(name)
7716 names.append(name)
7705 vers.append(extensions.moduleversion(module) or None)
7717 vers.append(extensions.moduleversion(module) or None)
7706 isinternals.append(extensions.ismoduleinternal(module))
7718 isinternals.append(extensions.ismoduleinternal(module))
7707 fn = fm.nested(b"extensions", tmpl=b'{name}\n')
7719 fn = fm.nested(b"extensions", tmpl=b'{name}\n')
7708 if names:
7720 if names:
7709 namefmt = b" %%-%ds " % max(len(n) for n in names)
7721 namefmt = b" %%-%ds " % max(len(n) for n in names)
7710 places = [_(b"external"), _(b"internal")]
7722 places = [_(b"external"), _(b"internal")]
7711 for n, v, p in zip(names, vers, isinternals):
7723 for n, v, p in zip(names, vers, isinternals):
7712 fn.startitem()
7724 fn.startitem()
7713 fn.condwrite(ui.verbose, b"name", namefmt, n)
7725 fn.condwrite(ui.verbose, b"name", namefmt, n)
7714 if ui.verbose:
7726 if ui.verbose:
7715 fn.plain(b"%s " % places[p])
7727 fn.plain(b"%s " % places[p])
7716 fn.data(bundled=p)
7728 fn.data(bundled=p)
7717 fn.condwrite(ui.verbose and v, b"ver", b"%s", v)
7729 fn.condwrite(ui.verbose and v, b"ver", b"%s", v)
7718 if ui.verbose:
7730 if ui.verbose:
7719 fn.plain(b"\n")
7731 fn.plain(b"\n")
7720 fn.end()
7732 fn.end()
7721 fm.end()
7733 fm.end()
7722
7734
7723
7735
7724 def loadcmdtable(ui, name, cmdtable):
7736 def loadcmdtable(ui, name, cmdtable):
7725 """Load command functions from specified cmdtable"""
7737 """Load command functions from specified cmdtable"""
7726 overrides = [cmd for cmd in cmdtable if cmd in table]
7738 overrides = [cmd for cmd in cmdtable if cmd in table]
7727 if overrides:
7739 if overrides:
7728 ui.warn(
7740 ui.warn(
7729 _(b"extension '%s' overrides commands: %s\n")
7741 _(b"extension '%s' overrides commands: %s\n")
7730 % (name, b" ".join(overrides))
7742 % (name, b" ".join(overrides))
7731 )
7743 )
7732 table.update(cmdtable)
7744 table.update(cmdtable)
@@ -1,40 +1,43 b''
1 == New Features ==
1 == New Features ==
2
2
3 * There is a new config section for templates used by hg commands. It
3 * There is a new config section for templates used by hg commands. It
4 is called `[command-templates]`. Some existing config options have
4 is called `[command-templates]`. Some existing config options have
5 been deprecated in favor of config options in the new
5 been deprecated in favor of config options in the new
6 section. These are: `ui.logtemplate` to `command-templates.log`,
6 section. These are: `ui.logtemplate` to `command-templates.log`,
7 `ui.graphnodetemplate` to `command-templates.graphnode`,
7 `ui.graphnodetemplate` to `command-templates.graphnode`,
8 `ui.mergemarkertemplate` to `command-templates.mergemarker`,
8 `ui.mergemarkertemplate` to `command-templates.mergemarker`,
9 `ui.pre-merge-tool-output-template` to
9 `ui.pre-merge-tool-output-template` to
10 `command-templates.pre-merge-tool-output`.
10 `command-templates.pre-merge-tool-output`.
11
11
12 * There is a new set of config options for the template used for the
12 * There is a new set of config options for the template used for the
13 one-line commit summary displayed by various commands, such as `hg
13 one-line commit summary displayed by various commands, such as `hg
14 rebase`. The main one is `command-templates.oneline-summary`. That
14 rebase`. The main one is `command-templates.oneline-summary`. That
15 can be overridden per command with
15 can be overridden per command with
16 `command-templates.oneline-summary.<command>`, where `<command>`
16 `command-templates.oneline-summary.<command>`, where `<command>`
17 can be e.g. `rebase`. As part of this effort, the default format
17 can be e.g. `rebase`. As part of this effort, the default format
18 from `hg rebase` was reorganized a bit.
18 from `hg rebase` was reorganized a bit.
19
19
20 * `hg strip`, from the strip extension, is now a core command, `hg
20 * `hg strip`, from the strip extension, is now a core command, `hg
21 debugstrip`. The extension remains for compatibility.
21 debugstrip`. The extension remains for compatibility.
22
22
23 * `hg diff` now supports `--from <rev>` and `--to <rev>` arguments as
24 clearer alternatives to `-r <revs>`.
25
23 * The memory footprint per changeset during pull/unbundle
26 * The memory footprint per changeset during pull/unbundle
24 operations has been further reduced.
27 operations has been further reduced.
25
28
26 == New Experimental Features ==
29 == New Experimental Features ==
27
30
28
31
29
32
30 == Bug Fixes ==
33 == Bug Fixes ==
31
34
32
35
33
36
34 == Backwards Compatibility Changes ==
37 == Backwards Compatibility Changes ==
35
38
36
39
37
40
38 == Internal API Changes ==
41 == Internal API Changes ==
39
42
40
43
@@ -1,439 +1,439 b''
1 Show all commands except debug commands
1 Show all commands except debug commands
2 $ hg debugcomplete
2 $ hg debugcomplete
3 abort
3 abort
4 add
4 add
5 addremove
5 addremove
6 annotate
6 annotate
7 archive
7 archive
8 backout
8 backout
9 bisect
9 bisect
10 bookmarks
10 bookmarks
11 branch
11 branch
12 branches
12 branches
13 bundle
13 bundle
14 cat
14 cat
15 clone
15 clone
16 commit
16 commit
17 config
17 config
18 continue
18 continue
19 copy
19 copy
20 diff
20 diff
21 export
21 export
22 files
22 files
23 forget
23 forget
24 graft
24 graft
25 grep
25 grep
26 heads
26 heads
27 help
27 help
28 identify
28 identify
29 import
29 import
30 incoming
30 incoming
31 init
31 init
32 locate
32 locate
33 log
33 log
34 manifest
34 manifest
35 merge
35 merge
36 outgoing
36 outgoing
37 parents
37 parents
38 paths
38 paths
39 phase
39 phase
40 pull
40 pull
41 push
41 push
42 recover
42 recover
43 remove
43 remove
44 rename
44 rename
45 resolve
45 resolve
46 revert
46 revert
47 rollback
47 rollback
48 root
48 root
49 serve
49 serve
50 shelve
50 shelve
51 status
51 status
52 summary
52 summary
53 tag
53 tag
54 tags
54 tags
55 tip
55 tip
56 unbundle
56 unbundle
57 unshelve
57 unshelve
58 update
58 update
59 verify
59 verify
60 version
60 version
61
61
62 Show all commands that start with "a"
62 Show all commands that start with "a"
63 $ hg debugcomplete a
63 $ hg debugcomplete a
64 abort
64 abort
65 add
65 add
66 addremove
66 addremove
67 annotate
67 annotate
68 archive
68 archive
69
69
70 Do not show debug commands if there are other candidates
70 Do not show debug commands if there are other candidates
71 $ hg debugcomplete d
71 $ hg debugcomplete d
72 diff
72 diff
73
73
74 Show debug commands if there are no other candidates
74 Show debug commands if there are no other candidates
75 $ hg debugcomplete debug
75 $ hg debugcomplete debug
76 debugancestor
76 debugancestor
77 debugantivirusrunning
77 debugantivirusrunning
78 debugapplystreamclonebundle
78 debugapplystreamclonebundle
79 debugbackupbundle
79 debugbackupbundle
80 debugbuilddag
80 debugbuilddag
81 debugbundle
81 debugbundle
82 debugcapabilities
82 debugcapabilities
83 debugchangedfiles
83 debugchangedfiles
84 debugcheckstate
84 debugcheckstate
85 debugcolor
85 debugcolor
86 debugcommands
86 debugcommands
87 debugcomplete
87 debugcomplete
88 debugconfig
88 debugconfig
89 debugcreatestreamclonebundle
89 debugcreatestreamclonebundle
90 debugdag
90 debugdag
91 debugdata
91 debugdata
92 debugdate
92 debugdate
93 debugdeltachain
93 debugdeltachain
94 debugdirstate
94 debugdirstate
95 debugdiscovery
95 debugdiscovery
96 debugdownload
96 debugdownload
97 debugextensions
97 debugextensions
98 debugfileset
98 debugfileset
99 debugformat
99 debugformat
100 debugfsinfo
100 debugfsinfo
101 debuggetbundle
101 debuggetbundle
102 debugignore
102 debugignore
103 debugindex
103 debugindex
104 debugindexdot
104 debugindexdot
105 debugindexstats
105 debugindexstats
106 debuginstall
106 debuginstall
107 debugknown
107 debugknown
108 debuglabelcomplete
108 debuglabelcomplete
109 debuglocks
109 debuglocks
110 debugmanifestfulltextcache
110 debugmanifestfulltextcache
111 debugmergestate
111 debugmergestate
112 debugnamecomplete
112 debugnamecomplete
113 debugnodemap
113 debugnodemap
114 debugobsolete
114 debugobsolete
115 debugp1copies
115 debugp1copies
116 debugp2copies
116 debugp2copies
117 debugpathcomplete
117 debugpathcomplete
118 debugpathcopies
118 debugpathcopies
119 debugpeer
119 debugpeer
120 debugpickmergetool
120 debugpickmergetool
121 debugpushkey
121 debugpushkey
122 debugpvec
122 debugpvec
123 debugrebuilddirstate
123 debugrebuilddirstate
124 debugrebuildfncache
124 debugrebuildfncache
125 debugrename
125 debugrename
126 debugrequires
126 debugrequires
127 debugrevlog
127 debugrevlog
128 debugrevlogindex
128 debugrevlogindex
129 debugrevspec
129 debugrevspec
130 debugserve
130 debugserve
131 debugsetparents
131 debugsetparents
132 debugsidedata
132 debugsidedata
133 debugssl
133 debugssl
134 debugstrip
134 debugstrip
135 debugsub
135 debugsub
136 debugsuccessorssets
136 debugsuccessorssets
137 debugtagscache
137 debugtagscache
138 debugtemplate
138 debugtemplate
139 debuguigetpass
139 debuguigetpass
140 debuguiprompt
140 debuguiprompt
141 debugupdatecaches
141 debugupdatecaches
142 debugupgraderepo
142 debugupgraderepo
143 debugwalk
143 debugwalk
144 debugwhyunstable
144 debugwhyunstable
145 debugwireargs
145 debugwireargs
146 debugwireproto
146 debugwireproto
147
147
148 Do not show the alias of a debug command if there are other candidates
148 Do not show the alias of a debug command if there are other candidates
149 (this should hide rawcommit)
149 (this should hide rawcommit)
150 $ hg debugcomplete r
150 $ hg debugcomplete r
151 recover
151 recover
152 remove
152 remove
153 rename
153 rename
154 resolve
154 resolve
155 revert
155 revert
156 rollback
156 rollback
157 root
157 root
158 Show the alias of a debug command if there are no other candidates
158 Show the alias of a debug command if there are no other candidates
159 $ hg debugcomplete rawc
159 $ hg debugcomplete rawc
160
160
161
161
162 Show the global options
162 Show the global options
163 $ hg debugcomplete --options | sort
163 $ hg debugcomplete --options | sort
164 --color
164 --color
165 --config
165 --config
166 --cwd
166 --cwd
167 --debug
167 --debug
168 --debugger
168 --debugger
169 --encoding
169 --encoding
170 --encodingmode
170 --encodingmode
171 --help
171 --help
172 --hidden
172 --hidden
173 --noninteractive
173 --noninteractive
174 --pager
174 --pager
175 --profile
175 --profile
176 --quiet
176 --quiet
177 --repository
177 --repository
178 --time
178 --time
179 --traceback
179 --traceback
180 --verbose
180 --verbose
181 --version
181 --version
182 -R
182 -R
183 -h
183 -h
184 -q
184 -q
185 -v
185 -v
186 -y
186 -y
187
187
188 Show the options for the "serve" command
188 Show the options for the "serve" command
189 $ hg debugcomplete --options serve | sort
189 $ hg debugcomplete --options serve | sort
190 --accesslog
190 --accesslog
191 --address
191 --address
192 --certificate
192 --certificate
193 --cmdserver
193 --cmdserver
194 --color
194 --color
195 --config
195 --config
196 --cwd
196 --cwd
197 --daemon
197 --daemon
198 --daemon-postexec
198 --daemon-postexec
199 --debug
199 --debug
200 --debugger
200 --debugger
201 --encoding
201 --encoding
202 --encodingmode
202 --encodingmode
203 --errorlog
203 --errorlog
204 --help
204 --help
205 --hidden
205 --hidden
206 --ipv6
206 --ipv6
207 --name
207 --name
208 --noninteractive
208 --noninteractive
209 --pager
209 --pager
210 --pid-file
210 --pid-file
211 --port
211 --port
212 --prefix
212 --prefix
213 --print-url
213 --print-url
214 --profile
214 --profile
215 --quiet
215 --quiet
216 --repository
216 --repository
217 --stdio
217 --stdio
218 --style
218 --style
219 --subrepos
219 --subrepos
220 --templates
220 --templates
221 --time
221 --time
222 --traceback
222 --traceback
223 --verbose
223 --verbose
224 --version
224 --version
225 --web-conf
225 --web-conf
226 -6
226 -6
227 -A
227 -A
228 -E
228 -E
229 -R
229 -R
230 -S
230 -S
231 -a
231 -a
232 -d
232 -d
233 -h
233 -h
234 -n
234 -n
235 -p
235 -p
236 -q
236 -q
237 -t
237 -t
238 -v
238 -v
239 -y
239 -y
240
240
241 Show an error if we use --options with an ambiguous abbreviation
241 Show an error if we use --options with an ambiguous abbreviation
242 $ hg debugcomplete --options s
242 $ hg debugcomplete --options s
243 hg: command 's' is ambiguous:
243 hg: command 's' is ambiguous:
244 serve shelve showconfig status summary
244 serve shelve showconfig status summary
245 [255]
245 [255]
246
246
247 Show all commands + options
247 Show all commands + options
248 $ hg debugcommands
248 $ hg debugcommands
249 abort: dry-run
249 abort: dry-run
250 add: include, exclude, subrepos, dry-run
250 add: include, exclude, subrepos, dry-run
251 addremove: similarity, subrepos, include, exclude, dry-run
251 addremove: similarity, subrepos, include, exclude, dry-run
252 annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, include, exclude, template
252 annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, include, exclude, template
253 archive: no-decode, prefix, rev, type, subrepos, include, exclude
253 archive: no-decode, prefix, rev, type, subrepos, include, exclude
254 backout: merge, commit, no-commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user
254 backout: merge, commit, no-commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user
255 bisect: reset, good, bad, skip, extend, command, noupdate
255 bisect: reset, good, bad, skip, extend, command, noupdate
256 bookmarks: force, rev, delete, rename, inactive, list, template
256 bookmarks: force, rev, delete, rename, inactive, list, template
257 branch: force, clean, rev
257 branch: force, clean, rev
258 branches: active, closed, rev, template
258 branches: active, closed, rev, template
259 bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
259 bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
260 cat: output, rev, decode, include, exclude, template
260 cat: output, rev, decode, include, exclude, template
261 clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure
261 clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure
262 commit: addremove, close-branch, amend, secret, edit, force-close-branch, interactive, include, exclude, message, logfile, date, user, subrepos
262 commit: addremove, close-branch, amend, secret, edit, force-close-branch, interactive, include, exclude, message, logfile, date, user, subrepos
263 config: untrusted, edit, local, shared, non-shared, global, template
263 config: untrusted, edit, local, shared, non-shared, global, template
264 continue: dry-run
264 continue: dry-run
265 copy: forget, after, at-rev, force, include, exclude, dry-run
265 copy: forget, after, at-rev, force, include, exclude, dry-run
266 debugancestor:
266 debugancestor:
267 debugantivirusrunning:
267 debugantivirusrunning:
268 debugapplystreamclonebundle:
268 debugapplystreamclonebundle:
269 debugbackupbundle: recover, patch, git, limit, no-merges, stat, graph, style, template
269 debugbackupbundle: recover, patch, git, limit, no-merges, stat, graph, style, template
270 debugbuilddag: mergeable-file, overwritten-file, new-file
270 debugbuilddag: mergeable-file, overwritten-file, new-file
271 debugbundle: all, part-type, spec
271 debugbundle: all, part-type, spec
272 debugcapabilities:
272 debugcapabilities:
273 debugchangedfiles:
273 debugchangedfiles:
274 debugcheckstate:
274 debugcheckstate:
275 debugcolor: style
275 debugcolor: style
276 debugcommands:
276 debugcommands:
277 debugcomplete: options
277 debugcomplete: options
278 debugcreatestreamclonebundle:
278 debugcreatestreamclonebundle:
279 debugdag: tags, branches, dots, spaces
279 debugdag: tags, branches, dots, spaces
280 debugdata: changelog, manifest, dir
280 debugdata: changelog, manifest, dir
281 debugdate: extended
281 debugdate: extended
282 debugdeltachain: changelog, manifest, dir, template
282 debugdeltachain: changelog, manifest, dir, template
283 debugdirstate: nodates, dates, datesort
283 debugdirstate: nodates, dates, datesort
284 debugdiscovery: old, nonheads, rev, seed, ssh, remotecmd, insecure
284 debugdiscovery: old, nonheads, rev, seed, ssh, remotecmd, insecure
285 debugdownload: output
285 debugdownload: output
286 debugextensions: template
286 debugextensions: template
287 debugfileset: rev, all-files, show-matcher, show-stage
287 debugfileset: rev, all-files, show-matcher, show-stage
288 debugformat: template
288 debugformat: template
289 debugfsinfo:
289 debugfsinfo:
290 debuggetbundle: head, common, type
290 debuggetbundle: head, common, type
291 debugignore:
291 debugignore:
292 debugindex: changelog, manifest, dir, template
292 debugindex: changelog, manifest, dir, template
293 debugindexdot: changelog, manifest, dir
293 debugindexdot: changelog, manifest, dir
294 debugindexstats:
294 debugindexstats:
295 debuginstall: template
295 debuginstall: template
296 debugknown:
296 debugknown:
297 debuglabelcomplete:
297 debuglabelcomplete:
298 debuglocks: force-lock, force-wlock, set-lock, set-wlock
298 debuglocks: force-lock, force-wlock, set-lock, set-wlock
299 debugmanifestfulltextcache: clear, add
299 debugmanifestfulltextcache: clear, add
300 debugmergestate: style, template
300 debugmergestate: style, template
301 debugnamecomplete:
301 debugnamecomplete:
302 debugnodemap: dump-new, dump-disk, check, metadata
302 debugnodemap: dump-new, dump-disk, check, metadata
303 debugobsolete: flags, record-parents, rev, exclusive, index, delete, date, user, template
303 debugobsolete: flags, record-parents, rev, exclusive, index, delete, date, user, template
304 debugp1copies: rev
304 debugp1copies: rev
305 debugp2copies: rev
305 debugp2copies: rev
306 debugpathcomplete: full, normal, added, removed
306 debugpathcomplete: full, normal, added, removed
307 debugpathcopies: include, exclude
307 debugpathcopies: include, exclude
308 debugpeer:
308 debugpeer:
309 debugpickmergetool: rev, changedelete, include, exclude, tool
309 debugpickmergetool: rev, changedelete, include, exclude, tool
310 debugpushkey:
310 debugpushkey:
311 debugpvec:
311 debugpvec:
312 debugrebuilddirstate: rev, minimal
312 debugrebuilddirstate: rev, minimal
313 debugrebuildfncache:
313 debugrebuildfncache:
314 debugrename: rev
314 debugrename: rev
315 debugrequires:
315 debugrequires:
316 debugrevlog: changelog, manifest, dir, dump
316 debugrevlog: changelog, manifest, dir, dump
317 debugrevlogindex: changelog, manifest, dir, format
317 debugrevlogindex: changelog, manifest, dir, format
318 debugrevspec: optimize, show-revs, show-set, show-stage, no-optimized, verify-optimized
318 debugrevspec: optimize, show-revs, show-set, show-stage, no-optimized, verify-optimized
319 debugserve: sshstdio, logiofd, logiofile
319 debugserve: sshstdio, logiofd, logiofile
320 debugsetparents:
320 debugsetparents:
321 debugsidedata: changelog, manifest, dir
321 debugsidedata: changelog, manifest, dir
322 debugssl:
322 debugssl:
323 debugstrip: rev, force, no-backup, nobackup, , keep, bookmark, soft
323 debugstrip: rev, force, no-backup, nobackup, , keep, bookmark, soft
324 debugsub: rev
324 debugsub: rev
325 debugsuccessorssets: closest
325 debugsuccessorssets: closest
326 debugtagscache:
326 debugtagscache:
327 debugtemplate: rev, define
327 debugtemplate: rev, define
328 debuguigetpass: prompt
328 debuguigetpass: prompt
329 debuguiprompt: prompt
329 debuguiprompt: prompt
330 debugupdatecaches:
330 debugupdatecaches:
331 debugupgraderepo: optimize, run, backup, changelog, manifest, filelogs
331 debugupgraderepo: optimize, run, backup, changelog, manifest, filelogs
332 debugwalk: include, exclude
332 debugwalk: include, exclude
333 debugwhyunstable:
333 debugwhyunstable:
334 debugwireargs: three, four, five, ssh, remotecmd, insecure
334 debugwireargs: three, four, five, ssh, remotecmd, insecure
335 debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, remotecmd, insecure
335 debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, remotecmd, insecure
336 diff: rev, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
336 diff: rev, from, to, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
337 export: bookmark, output, switch-parent, rev, text, git, binary, nodates, template
337 export: bookmark, output, switch-parent, rev, text, git, binary, nodates, template
338 files: rev, print0, include, exclude, template, subrepos
338 files: rev, print0, include, exclude, template, subrepos
339 forget: interactive, include, exclude, dry-run
339 forget: interactive, include, exclude, dry-run
340 graft: rev, base, continue, stop, abort, edit, log, no-commit, force, currentdate, currentuser, date, user, tool, dry-run
340 graft: rev, base, continue, stop, abort, edit, log, no-commit, force, currentdate, currentuser, date, user, tool, dry-run
341 grep: print0, all, diff, text, follow, ignore-case, files-with-matches, line-number, rev, all-files, user, date, template, include, exclude
341 grep: print0, all, diff, text, follow, ignore-case, files-with-matches, line-number, rev, all-files, user, date, template, include, exclude
342 heads: rev, topo, active, closed, style, template
342 heads: rev, topo, active, closed, style, template
343 help: extension, command, keyword, system
343 help: extension, command, keyword, system
344 identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, template
344 identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, template
345 import: strip, base, secret, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity
345 import: strip, base, secret, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity
346 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
346 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
347 init: ssh, remotecmd, insecure
347 init: ssh, remotecmd, insecure
348 locate: rev, print0, fullpath, include, exclude
348 locate: rev, print0, fullpath, include, exclude
349 log: follow, follow-first, date, copies, keyword, rev, line-range, removed, only-merges, user, only-branch, branch, bookmark, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
349 log: follow, follow-first, date, copies, keyword, rev, line-range, removed, only-merges, user, only-branch, branch, bookmark, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
350 manifest: rev, all, template
350 manifest: rev, all, template
351 merge: force, rev, preview, abort, tool
351 merge: force, rev, preview, abort, tool
352 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
352 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
353 parents: rev, style, template
353 parents: rev, style, template
354 paths: template
354 paths: template
355 phase: public, draft, secret, force, rev
355 phase: public, draft, secret, force, rev
356 pull: update, force, confirm, rev, bookmark, branch, ssh, remotecmd, insecure
356 pull: update, force, confirm, rev, bookmark, branch, ssh, remotecmd, insecure
357 push: force, rev, bookmark, all-bookmarks, branch, new-branch, pushvars, publish, ssh, remotecmd, insecure
357 push: force, rev, bookmark, all-bookmarks, branch, new-branch, pushvars, publish, ssh, remotecmd, insecure
358 recover: verify
358 recover: verify
359 remove: after, force, subrepos, include, exclude, dry-run
359 remove: after, force, subrepos, include, exclude, dry-run
360 rename: after, at-rev, force, include, exclude, dry-run
360 rename: after, at-rev, force, include, exclude, dry-run
361 resolve: all, list, mark, unmark, no-status, re-merge, tool, include, exclude, template
361 resolve: all, list, mark, unmark, no-status, re-merge, tool, include, exclude, template
362 revert: all, date, rev, no-backup, interactive, include, exclude, dry-run
362 revert: all, date, rev, no-backup, interactive, include, exclude, dry-run
363 rollback: dry-run, force
363 rollback: dry-run, force
364 root: template
364 root: template
365 serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, print-url, subrepos
365 serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, print-url, subrepos
366 shelve: addremove, unknown, cleanup, date, delete, edit, keep, list, message, name, patch, interactive, stat, include, exclude
366 shelve: addremove, unknown, cleanup, date, delete, edit, keep, list, message, name, patch, interactive, stat, include, exclude
367 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template
367 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template
368 summary: remote
368 summary: remote
369 tag: force, local, rev, remove, edit, message, date, user
369 tag: force, local, rev, remove, edit, message, date, user
370 tags: template
370 tags: template
371 tip: patch, git, style, template
371 tip: patch, git, style, template
372 unbundle: update
372 unbundle: update
373 unshelve: abort, continue, interactive, keep, name, tool, date
373 unshelve: abort, continue, interactive, keep, name, tool, date
374 update: clean, check, merge, date, rev, tool
374 update: clean, check, merge, date, rev, tool
375 verify: full
375 verify: full
376 version: template
376 version: template
377
377
378 $ hg init a
378 $ hg init a
379 $ cd a
379 $ cd a
380 $ echo fee > fee
380 $ echo fee > fee
381 $ hg ci -q -Amfee
381 $ hg ci -q -Amfee
382 $ hg tag fee
382 $ hg tag fee
383 $ mkdir fie
383 $ mkdir fie
384 $ echo dead > fie/dead
384 $ echo dead > fie/dead
385 $ echo live > fie/live
385 $ echo live > fie/live
386 $ hg bookmark fo
386 $ hg bookmark fo
387 $ hg branch -q fie
387 $ hg branch -q fie
388 $ hg ci -q -Amfie
388 $ hg ci -q -Amfie
389 $ echo fo > fo
389 $ echo fo > fo
390 $ hg branch -qf default
390 $ hg branch -qf default
391 $ hg ci -q -Amfo
391 $ hg ci -q -Amfo
392 $ echo Fum > Fum
392 $ echo Fum > Fum
393 $ hg ci -q -AmFum
393 $ hg ci -q -AmFum
394 $ hg bookmark Fum
394 $ hg bookmark Fum
395
395
396 Test debugpathcomplete
396 Test debugpathcomplete
397
397
398 $ hg debugpathcomplete f
398 $ hg debugpathcomplete f
399 fee
399 fee
400 fie
400 fie
401 fo
401 fo
402 $ hg debugpathcomplete -f f
402 $ hg debugpathcomplete -f f
403 fee
403 fee
404 fie/dead
404 fie/dead
405 fie/live
405 fie/live
406 fo
406 fo
407
407
408 $ hg rm Fum
408 $ hg rm Fum
409 $ hg debugpathcomplete -r F
409 $ hg debugpathcomplete -r F
410 Fum
410 Fum
411
411
412 Test debugnamecomplete
412 Test debugnamecomplete
413
413
414 $ hg debugnamecomplete
414 $ hg debugnamecomplete
415 Fum
415 Fum
416 default
416 default
417 fee
417 fee
418 fie
418 fie
419 fo
419 fo
420 tip
420 tip
421 $ hg debugnamecomplete f
421 $ hg debugnamecomplete f
422 fee
422 fee
423 fie
423 fie
424 fo
424 fo
425
425
426 Test debuglabelcomplete, a deprecated name for debugnamecomplete that is still
426 Test debuglabelcomplete, a deprecated name for debugnamecomplete that is still
427 used for completions in some shells.
427 used for completions in some shells.
428
428
429 $ hg debuglabelcomplete
429 $ hg debuglabelcomplete
430 Fum
430 Fum
431 default
431 default
432 fee
432 fee
433 fie
433 fie
434 fo
434 fo
435 tip
435 tip
436 $ hg debuglabelcomplete f
436 $ hg debuglabelcomplete f
437 fee
437 fee
438 fie
438 fie
439 fo
439 fo
@@ -1,144 +1,197 b''
1 Testing diff --change
1 Testing diff --change, --from, --to
2
2
3 $ hg init a
3 $ hg init a
4 $ cd a
4 $ cd a
5
5
6 $ echo "first" > file.txt
6 $ echo "first" > file.txt
7 $ hg add file.txt
7 $ hg add file.txt
8 $ hg commit -m 'first commit' # 0
8 $ hg commit -m 'first commit' # 0
9
9
10 $ echo "second" > file.txt
10 $ echo "second" > file.txt
11 $ hg commit -m 'second commit' # 1
11 $ hg commit -m 'second commit' # 1
12
12
13 $ echo "third" > file.txt
13 $ echo "third" > file.txt
14 $ hg commit -m 'third commit' # 2
14 $ hg commit -m 'third commit' # 2
15
15
16 $ hg diff --nodates --change 1
16 $ hg diff --nodates --change 1
17 diff -r 4bb65dda5db4 -r e9b286083166 file.txt
17 diff -r 4bb65dda5db4 -r e9b286083166 file.txt
18 --- a/file.txt
18 --- a/file.txt
19 +++ b/file.txt
19 +++ b/file.txt
20 @@ -1,1 +1,1 @@
20 @@ -1,1 +1,1 @@
21 -first
21 -first
22 +second
22 +second
23
23
24 $ hg diff --change e9b286083166
24 $ hg diff --change e9b286083166
25 diff -r 4bb65dda5db4 -r e9b286083166 file.txt
25 diff -r 4bb65dda5db4 -r e9b286083166 file.txt
26 --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
26 --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
27 +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
27 +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
28 @@ -1,1 +1,1 @@
28 @@ -1,1 +1,1 @@
29 -first
29 -first
30 +second
30 +second
31
31
32 Test --from and --to
33
34 $ hg diff --from . --rev .
35 abort: cannot specify both --from and --rev
36 [10]
37 $ hg diff --to . --rev .
38 abort: cannot specify both --to and --rev
39 [10]
40 $ hg diff --from . --change .
41 abort: cannot specify both --from and --change
42 [10]
43 $ hg diff --to . --change .
44 abort: cannot specify both --to and --change
45 [10]
46 $ echo dirty > file.txt
47 $ hg diff --from .
48 diff -r bf5ff72eb7e0 file.txt
49 --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
50 +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
51 @@ -1,1 +1,1 @@
52 -third
53 +dirty
54 $ hg diff --from . --reverse
55 diff -r bf5ff72eb7e0 file.txt
56 --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
57 +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
58 @@ -1,1 +1,1 @@
59 -dirty
60 +third
61 $ hg diff --to .
62 diff -r bf5ff72eb7e0 file.txt
63 --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
64 +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
65 @@ -1,1 +1,1 @@
66 -dirty
67 +third
68 $ hg diff --from 0 --to 2
69 diff -r 4bb65dda5db4 -r bf5ff72eb7e0 file.txt
70 --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
71 +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
72 @@ -1,1 +1,1 @@
73 -first
74 +third
75 $ hg diff --from 2 --to 0
76 diff -r bf5ff72eb7e0 -r 4bb65dda5db4 file.txt
77 --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
78 +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
79 @@ -1,1 +1,1 @@
80 -third
81 +first
82 $ hg co -C .
83 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
84
32 $ cd ..
85 $ cd ..
33
86
34 Test dumb revspecs: top-level "x:y", "x:", ":y" and ":" ranges should be handled
87 Test dumb revspecs: top-level "x:y", "x:", ":y" and ":" ranges should be handled
35 as pairs even if x == y, but not for "f(x:y)" nor "x::y" (issue3474, issue4774)
88 as pairs even if x == y, but not for "f(x:y)" nor "x::y" (issue3474, issue4774)
36
89
37 $ hg clone -q a dumbspec
90 $ hg clone -q a dumbspec
38 $ cd dumbspec
91 $ cd dumbspec
39 $ echo "wdir" > file.txt
92 $ echo "wdir" > file.txt
40
93
41 $ hg diff -r 2:2
94 $ hg diff -r 2:2
42 $ hg diff -r 2:.
95 $ hg diff -r 2:.
43 $ hg diff -r 2:
96 $ hg diff -r 2:
44 $ hg diff -r :0
97 $ hg diff -r :0
45 $ hg diff -r '2:first(2:2)'
98 $ hg diff -r '2:first(2:2)'
46 $ hg diff -r 'first(2:2)' --nodates
99 $ hg diff -r 'first(2:2)' --nodates
47 diff -r bf5ff72eb7e0 file.txt
100 diff -r bf5ff72eb7e0 file.txt
48 --- a/file.txt
101 --- a/file.txt
49 +++ b/file.txt
102 +++ b/file.txt
50 @@ -1,1 +1,1 @@
103 @@ -1,1 +1,1 @@
51 -third
104 -third
52 +wdir
105 +wdir
53 $ hg diff -r '(2:2)' --nodates
106 $ hg diff -r '(2:2)' --nodates
54 diff -r bf5ff72eb7e0 file.txt
107 diff -r bf5ff72eb7e0 file.txt
55 --- a/file.txt
108 --- a/file.txt
56 +++ b/file.txt
109 +++ b/file.txt
57 @@ -1,1 +1,1 @@
110 @@ -1,1 +1,1 @@
58 -third
111 -third
59 +wdir
112 +wdir
60 $ hg diff -r 2::2 --nodates
113 $ hg diff -r 2::2 --nodates
61 diff -r bf5ff72eb7e0 file.txt
114 diff -r bf5ff72eb7e0 file.txt
62 --- a/file.txt
115 --- a/file.txt
63 +++ b/file.txt
116 +++ b/file.txt
64 @@ -1,1 +1,1 @@
117 @@ -1,1 +1,1 @@
65 -third
118 -third
66 +wdir
119 +wdir
67 $ hg diff -r "2 and 1"
120 $ hg diff -r "2 and 1"
68 abort: empty revision range
121 abort: empty revision range
69 [255]
122 [255]
70
123
71 $ cd ..
124 $ cd ..
72
125
73 $ hg clone -qr0 a dumbspec-rev0
126 $ hg clone -qr0 a dumbspec-rev0
74 $ cd dumbspec-rev0
127 $ cd dumbspec-rev0
75 $ echo "wdir" > file.txt
128 $ echo "wdir" > file.txt
76
129
77 $ hg diff -r :
130 $ hg diff -r :
78 $ hg diff -r 'first(:)' --nodates
131 $ hg diff -r 'first(:)' --nodates
79 diff -r 4bb65dda5db4 file.txt
132 diff -r 4bb65dda5db4 file.txt
80 --- a/file.txt
133 --- a/file.txt
81 +++ b/file.txt
134 +++ b/file.txt
82 @@ -1,1 +1,1 @@
135 @@ -1,1 +1,1 @@
83 -first
136 -first
84 +wdir
137 +wdir
85
138
86 $ cd ..
139 $ cd ..
87
140
88 Testing diff --change when merge:
141 Testing diff --change when merge:
89
142
90 $ cd a
143 $ cd a
91
144
92 $ for i in 1 2 3 4 5 6 7 8 9 10; do
145 $ for i in 1 2 3 4 5 6 7 8 9 10; do
93 > echo $i >> file.txt
146 > echo $i >> file.txt
94 > done
147 > done
95 $ hg commit -m "lots of text" # 3
148 $ hg commit -m "lots of text" # 3
96
149
97 $ sed -e 's,^2$,x,' file.txt > file.txt.tmp
150 $ sed -e 's,^2$,x,' file.txt > file.txt.tmp
98 $ mv file.txt.tmp file.txt
151 $ mv file.txt.tmp file.txt
99 $ hg commit -m "change 2 to x" # 4
152 $ hg commit -m "change 2 to x" # 4
100
153
101 $ hg up -r 3
154 $ hg up -r 3
102 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
155 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
103 $ sed -e 's,^8$,y,' file.txt > file.txt.tmp
156 $ sed -e 's,^8$,y,' file.txt > file.txt.tmp
104 $ mv file.txt.tmp file.txt
157 $ mv file.txt.tmp file.txt
105 $ hg commit -m "change 8 to y"
158 $ hg commit -m "change 8 to y"
106 created new head
159 created new head
107
160
108 $ hg up -C -r 4
161 $ hg up -C -r 4
109 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
162 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
110 $ hg merge -r 5
163 $ hg merge -r 5
111 merging file.txt
164 merging file.txt
112 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
165 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
113 (branch merge, don't forget to commit)
166 (branch merge, don't forget to commit)
114 $ hg commit -m "merge 8 to y" # 6
167 $ hg commit -m "merge 8 to y" # 6
115
168
116 $ hg diff --change 5
169 $ hg diff --change 5
117 diff -r ae119d680c82 -r 9085c5c02e52 file.txt
170 diff -r ae119d680c82 -r 9085c5c02e52 file.txt
118 --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
171 --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
119 +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
172 +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
120 @@ -6,6 +6,6 @@
173 @@ -6,6 +6,6 @@
121 5
174 5
122 6
175 6
123 7
176 7
124 -8
177 -8
125 +y
178 +y
126 9
179 9
127 10
180 10
128
181
129 must be similar to 'hg diff --change 5':
182 must be similar to 'hg diff --change 5':
130
183
131 $ hg diff -c 6
184 $ hg diff -c 6
132 diff -r 273b50f17c6d -r 979ca961fd2e file.txt
185 diff -r 273b50f17c6d -r 979ca961fd2e file.txt
133 --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
186 --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
134 +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
187 +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
135 @@ -6,6 +6,6 @@
188 @@ -6,6 +6,6 @@
136 5
189 5
137 6
190 6
138 7
191 7
139 -8
192 -8
140 +y
193 +y
141 9
194 9
142 10
195 10
143
196
144 $ cd ..
197 $ cd ..
@@ -1,3919 +1,3921 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 another revision into working directory
17 merge merge another revision into working directory
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 another revision into working directory
38 merge merge another revision into working directory
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 Extra extensions will be printed in help output in a non-reliable order since
47 Extra extensions will be printed in help output in a non-reliable order since
48 the extension is unknown.
48 the extension is unknown.
49 #if no-extraextensions
49 #if no-extraextensions
50
50
51 $ hg help
51 $ hg help
52 Mercurial Distributed SCM
52 Mercurial Distributed SCM
53
53
54 list of commands:
54 list of commands:
55
55
56 Repository creation:
56 Repository creation:
57
57
58 clone make a copy of an existing repository
58 clone make a copy of an existing repository
59 init create a new repository in the given directory
59 init create a new repository in the given directory
60
60
61 Remote repository management:
61 Remote repository management:
62
62
63 incoming show new changesets found in source
63 incoming show new changesets found in source
64 outgoing show changesets not found in the destination
64 outgoing show changesets not found in the destination
65 paths show aliases for remote repositories
65 paths show aliases for remote repositories
66 pull pull changes from the specified source
66 pull pull changes from the specified source
67 push push changes to the specified destination
67 push push changes to the specified destination
68 serve start stand-alone webserver
68 serve start stand-alone webserver
69
69
70 Change creation:
70 Change creation:
71
71
72 commit commit the specified files or all outstanding changes
72 commit commit the specified files or all outstanding changes
73
73
74 Change manipulation:
74 Change manipulation:
75
75
76 backout reverse effect of earlier changeset
76 backout reverse effect of earlier changeset
77 graft copy changes from other branches onto the current branch
77 graft copy changes from other branches onto the current branch
78 merge merge another revision into working directory
78 merge merge another revision into working directory
79
79
80 Change organization:
80 Change organization:
81
81
82 bookmarks create a new bookmark or list existing bookmarks
82 bookmarks create a new bookmark or list existing bookmarks
83 branch set or show the current branch name
83 branch set or show the current branch name
84 branches list repository named branches
84 branches list repository named branches
85 phase set or show the current phase name
85 phase set or show the current phase name
86 tag add one or more tags for the current or given revision
86 tag add one or more tags for the current or given revision
87 tags list repository tags
87 tags list repository tags
88
88
89 File content management:
89 File content management:
90
90
91 annotate show changeset information by line for each file
91 annotate show changeset information by line for each file
92 cat output the current or given revision of files
92 cat output the current or given revision of files
93 copy mark files as copied for the next commit
93 copy mark files as copied for the next commit
94 diff diff repository (or selected files)
94 diff diff repository (or selected files)
95 grep search for a pattern in specified files
95 grep search for a pattern in specified files
96
96
97 Change navigation:
97 Change navigation:
98
98
99 bisect subdivision search of changesets
99 bisect subdivision search of changesets
100 heads show branch heads
100 heads show branch heads
101 identify identify the working directory or specified revision
101 identify identify the working directory or specified revision
102 log show revision history of entire repository or files
102 log show revision history of entire repository or files
103
103
104 Working directory management:
104 Working directory management:
105
105
106 add add the specified files on the next commit
106 add add the specified files on the next commit
107 addremove add all new files, delete all missing files
107 addremove add all new files, delete all missing files
108 files list tracked files
108 files list tracked files
109 forget forget the specified files on the next commit
109 forget forget the specified files on the next commit
110 remove remove the specified files on the next commit
110 remove remove the specified files on the next commit
111 rename rename files; equivalent of copy + remove
111 rename rename files; equivalent of copy + remove
112 resolve redo merges or set/view the merge status of files
112 resolve redo merges or set/view the merge status of files
113 revert restore files to their checkout state
113 revert restore files to their checkout state
114 root print the root (top) of the current working directory
114 root print the root (top) of the current working directory
115 shelve save and set aside changes from the working directory
115 shelve save and set aside changes from the working directory
116 status show changed files in the working directory
116 status show changed files in the working directory
117 summary summarize working directory state
117 summary summarize working directory state
118 unshelve restore a shelved change to the working directory
118 unshelve restore a shelved change to the working directory
119 update update working directory (or switch revisions)
119 update update working directory (or switch revisions)
120
120
121 Change import/export:
121 Change import/export:
122
122
123 archive create an unversioned archive of a repository revision
123 archive create an unversioned archive of a repository revision
124 bundle create a bundle file
124 bundle create a bundle file
125 export dump the header and diffs for one or more changesets
125 export dump the header and diffs for one or more changesets
126 import import an ordered set of patches
126 import import an ordered set of patches
127 unbundle apply one or more bundle files
127 unbundle apply one or more bundle files
128
128
129 Repository maintenance:
129 Repository maintenance:
130
130
131 manifest output the current or given revision of the project manifest
131 manifest output the current or given revision of the project manifest
132 recover roll back an interrupted transaction
132 recover roll back an interrupted transaction
133 verify verify the integrity of the repository
133 verify verify the integrity of the repository
134
134
135 Help:
135 Help:
136
136
137 config show combined config settings from all hgrc files
137 config show combined config settings from all hgrc files
138 help show help for a given topic or a help overview
138 help show help for a given topic or a help overview
139 version output version and copyright information
139 version output version and copyright information
140
140
141 additional help topics:
141 additional help topics:
142
142
143 Mercurial identifiers:
143 Mercurial identifiers:
144
144
145 filesets Specifying File Sets
145 filesets Specifying File Sets
146 hgignore Syntax for Mercurial Ignore Files
146 hgignore Syntax for Mercurial Ignore Files
147 patterns File Name Patterns
147 patterns File Name Patterns
148 revisions Specifying Revisions
148 revisions Specifying Revisions
149 urls URL Paths
149 urls URL Paths
150
150
151 Mercurial output:
151 Mercurial output:
152
152
153 color Colorizing Outputs
153 color Colorizing Outputs
154 dates Date Formats
154 dates Date Formats
155 diffs Diff Formats
155 diffs Diff Formats
156 templating Template Usage
156 templating Template Usage
157
157
158 Mercurial configuration:
158 Mercurial configuration:
159
159
160 config Configuration Files
160 config Configuration Files
161 environment Environment Variables
161 environment Environment Variables
162 extensions Using Additional Features
162 extensions Using Additional Features
163 flags Command-line flags
163 flags Command-line flags
164 hgweb Configuring hgweb
164 hgweb Configuring hgweb
165 merge-tools Merge Tools
165 merge-tools Merge Tools
166 pager Pager Support
166 pager Pager Support
167
167
168 Concepts:
168 Concepts:
169
169
170 bundlespec Bundle File Formats
170 bundlespec Bundle File Formats
171 glossary Glossary
171 glossary Glossary
172 phases Working with Phases
172 phases Working with Phases
173 subrepos Subrepositories
173 subrepos Subrepositories
174
174
175 Miscellaneous:
175 Miscellaneous:
176
176
177 deprecated Deprecated Features
177 deprecated Deprecated Features
178 internals Technical implementation topics
178 internals Technical implementation topics
179 scripting Using Mercurial from scripts and automation
179 scripting Using Mercurial from scripts and automation
180
180
181 (use 'hg help -v' to show built-in aliases and global options)
181 (use 'hg help -v' to show built-in aliases and global options)
182
182
183 $ hg -q help
183 $ hg -q help
184 Repository creation:
184 Repository creation:
185
185
186 clone make a copy of an existing repository
186 clone make a copy of an existing repository
187 init create a new repository in the given directory
187 init create a new repository in the given directory
188
188
189 Remote repository management:
189 Remote repository management:
190
190
191 incoming show new changesets found in source
191 incoming show new changesets found in source
192 outgoing show changesets not found in the destination
192 outgoing show changesets not found in the destination
193 paths show aliases for remote repositories
193 paths show aliases for remote repositories
194 pull pull changes from the specified source
194 pull pull changes from the specified source
195 push push changes to the specified destination
195 push push changes to the specified destination
196 serve start stand-alone webserver
196 serve start stand-alone webserver
197
197
198 Change creation:
198 Change creation:
199
199
200 commit commit the specified files or all outstanding changes
200 commit commit the specified files or all outstanding changes
201
201
202 Change manipulation:
202 Change manipulation:
203
203
204 backout reverse effect of earlier changeset
204 backout reverse effect of earlier changeset
205 graft copy changes from other branches onto the current branch
205 graft copy changes from other branches onto the current branch
206 merge merge another revision into working directory
206 merge merge another revision into working directory
207
207
208 Change organization:
208 Change organization:
209
209
210 bookmarks create a new bookmark or list existing bookmarks
210 bookmarks create a new bookmark or list existing bookmarks
211 branch set or show the current branch name
211 branch set or show the current branch name
212 branches list repository named branches
212 branches list repository named branches
213 phase set or show the current phase name
213 phase set or show the current phase name
214 tag add one or more tags for the current or given revision
214 tag add one or more tags for the current or given revision
215 tags list repository tags
215 tags list repository tags
216
216
217 File content management:
217 File content management:
218
218
219 annotate show changeset information by line for each file
219 annotate show changeset information by line for each file
220 cat output the current or given revision of files
220 cat output the current or given revision of files
221 copy mark files as copied for the next commit
221 copy mark files as copied for the next commit
222 diff diff repository (or selected files)
222 diff diff repository (or selected files)
223 grep search for a pattern in specified files
223 grep search for a pattern in specified files
224
224
225 Change navigation:
225 Change navigation:
226
226
227 bisect subdivision search of changesets
227 bisect subdivision search of changesets
228 heads show branch heads
228 heads show branch heads
229 identify identify the working directory or specified revision
229 identify identify the working directory or specified revision
230 log show revision history of entire repository or files
230 log show revision history of entire repository or files
231
231
232 Working directory management:
232 Working directory management:
233
233
234 add add the specified files on the next commit
234 add add the specified files on the next commit
235 addremove add all new files, delete all missing files
235 addremove add all new files, delete all missing files
236 files list tracked files
236 files list tracked files
237 forget forget the specified files on the next commit
237 forget forget the specified files on the next commit
238 remove remove the specified files on the next commit
238 remove remove the specified files on the next commit
239 rename rename files; equivalent of copy + remove
239 rename rename files; equivalent of copy + remove
240 resolve redo merges or set/view the merge status of files
240 resolve redo merges or set/view the merge status of files
241 revert restore files to their checkout state
241 revert restore files to their checkout state
242 root print the root (top) of the current working directory
242 root print the root (top) of the current working directory
243 shelve save and set aside changes from the working directory
243 shelve save and set aside changes from the working directory
244 status show changed files in the working directory
244 status show changed files in the working directory
245 summary summarize working directory state
245 summary summarize working directory state
246 unshelve restore a shelved change to the working directory
246 unshelve restore a shelved change to the working directory
247 update update working directory (or switch revisions)
247 update update working directory (or switch revisions)
248
248
249 Change import/export:
249 Change import/export:
250
250
251 archive create an unversioned archive of a repository revision
251 archive create an unversioned archive of a repository revision
252 bundle create a bundle file
252 bundle create a bundle file
253 export dump the header and diffs for one or more changesets
253 export dump the header and diffs for one or more changesets
254 import import an ordered set of patches
254 import import an ordered set of patches
255 unbundle apply one or more bundle files
255 unbundle apply one or more bundle files
256
256
257 Repository maintenance:
257 Repository maintenance:
258
258
259 manifest output the current or given revision of the project manifest
259 manifest output the current or given revision of the project manifest
260 recover roll back an interrupted transaction
260 recover roll back an interrupted transaction
261 verify verify the integrity of the repository
261 verify verify the integrity of the repository
262
262
263 Help:
263 Help:
264
264
265 config show combined config settings from all hgrc files
265 config show combined config settings from all hgrc files
266 help show help for a given topic or a help overview
266 help show help for a given topic or a help overview
267 version output version and copyright information
267 version output version and copyright information
268
268
269 additional help topics:
269 additional help topics:
270
270
271 Mercurial identifiers:
271 Mercurial identifiers:
272
272
273 filesets Specifying File Sets
273 filesets Specifying File Sets
274 hgignore Syntax for Mercurial Ignore Files
274 hgignore Syntax for Mercurial Ignore Files
275 patterns File Name Patterns
275 patterns File Name Patterns
276 revisions Specifying Revisions
276 revisions Specifying Revisions
277 urls URL Paths
277 urls URL Paths
278
278
279 Mercurial output:
279 Mercurial output:
280
280
281 color Colorizing Outputs
281 color Colorizing Outputs
282 dates Date Formats
282 dates Date Formats
283 diffs Diff Formats
283 diffs Diff Formats
284 templating Template Usage
284 templating Template Usage
285
285
286 Mercurial configuration:
286 Mercurial configuration:
287
287
288 config Configuration Files
288 config Configuration Files
289 environment Environment Variables
289 environment Environment Variables
290 extensions Using Additional Features
290 extensions Using Additional Features
291 flags Command-line flags
291 flags Command-line flags
292 hgweb Configuring hgweb
292 hgweb Configuring hgweb
293 merge-tools Merge Tools
293 merge-tools Merge Tools
294 pager Pager Support
294 pager Pager Support
295
295
296 Concepts:
296 Concepts:
297
297
298 bundlespec Bundle File Formats
298 bundlespec Bundle File Formats
299 glossary Glossary
299 glossary Glossary
300 phases Working with Phases
300 phases Working with Phases
301 subrepos Subrepositories
301 subrepos Subrepositories
302
302
303 Miscellaneous:
303 Miscellaneous:
304
304
305 deprecated Deprecated Features
305 deprecated Deprecated Features
306 internals Technical implementation topics
306 internals Technical implementation topics
307 scripting Using Mercurial from scripts and automation
307 scripting Using Mercurial from scripts and automation
308
308
309 Test extension help:
309 Test extension help:
310 $ hg help extensions --config extensions.rebase= --config extensions.children=
310 $ hg help extensions --config extensions.rebase= --config extensions.children=
311 Using Additional Features
311 Using Additional Features
312 """""""""""""""""""""""""
312 """""""""""""""""""""""""
313
313
314 Mercurial has the ability to add new features through the use of
314 Mercurial has the ability to add new features through the use of
315 extensions. Extensions may add new commands, add options to existing
315 extensions. Extensions may add new commands, add options to existing
316 commands, change the default behavior of commands, or implement hooks.
316 commands, change the default behavior of commands, or implement hooks.
317
317
318 To enable the "foo" extension, either shipped with Mercurial or in the
318 To enable the "foo" extension, either shipped with Mercurial or in the
319 Python search path, create an entry for it in your configuration file,
319 Python search path, create an entry for it in your configuration file,
320 like this:
320 like this:
321
321
322 [extensions]
322 [extensions]
323 foo =
323 foo =
324
324
325 You may also specify the full path to an extension:
325 You may also specify the full path to an extension:
326
326
327 [extensions]
327 [extensions]
328 myfeature = ~/.hgext/myfeature.py
328 myfeature = ~/.hgext/myfeature.py
329
329
330 See 'hg help config' for more information on configuration files.
330 See 'hg help config' for more information on configuration files.
331
331
332 Extensions are not loaded by default for a variety of reasons: they can
332 Extensions are not loaded by default for a variety of reasons: they can
333 increase startup overhead; they may be meant for advanced usage only; they
333 increase startup overhead; they may be meant for advanced usage only; they
334 may provide potentially dangerous abilities (such as letting you destroy
334 may provide potentially dangerous abilities (such as letting you destroy
335 or modify history); they might not be ready for prime time; or they may
335 or modify history); they might not be ready for prime time; or they may
336 alter some usual behaviors of stock Mercurial. It is thus up to the user
336 alter some usual behaviors of stock Mercurial. It is thus up to the user
337 to activate extensions as needed.
337 to activate extensions as needed.
338
338
339 To explicitly disable an extension enabled in a configuration file of
339 To explicitly disable an extension enabled in a configuration file of
340 broader scope, prepend its path with !:
340 broader scope, prepend its path with !:
341
341
342 [extensions]
342 [extensions]
343 # disabling extension bar residing in /path/to/extension/bar.py
343 # disabling extension bar residing in /path/to/extension/bar.py
344 bar = !/path/to/extension/bar.py
344 bar = !/path/to/extension/bar.py
345 # ditto, but no path was supplied for extension baz
345 # ditto, but no path was supplied for extension baz
346 baz = !
346 baz = !
347
347
348 enabled extensions:
348 enabled extensions:
349
349
350 children command to display child changesets (DEPRECATED)
350 children command to display child changesets (DEPRECATED)
351 rebase command to move sets of revisions to a different ancestor
351 rebase command to move sets of revisions to a different ancestor
352
352
353 disabled extensions:
353 disabled extensions:
354
354
355 acl hooks for controlling repository access
355 acl hooks for controlling repository access
356 blackbox log repository events to a blackbox for debugging
356 blackbox log repository events to a blackbox for debugging
357 bugzilla hooks for integrating with the Bugzilla bug tracker
357 bugzilla hooks for integrating with the Bugzilla bug tracker
358 censor erase file content at a given revision
358 censor erase file content at a given revision
359 churn command to display statistics about repository history
359 churn command to display statistics about repository history
360 clonebundles advertise pre-generated bundles to seed clones
360 clonebundles advertise pre-generated bundles to seed clones
361 closehead close arbitrary heads without checking them out first
361 closehead close arbitrary heads without checking them out first
362 convert import revisions from foreign VCS repositories into
362 convert import revisions from foreign VCS repositories into
363 Mercurial
363 Mercurial
364 eol automatically manage newlines in repository files
364 eol automatically manage newlines in repository files
365 extdiff command to allow external programs to compare revisions
365 extdiff command to allow external programs to compare revisions
366 factotum http authentication with factotum
366 factotum http authentication with factotum
367 fastexport export repositories as git fast-import stream
367 fastexport export repositories as git fast-import stream
368 githelp try mapping git commands to Mercurial commands
368 githelp try mapping git commands to Mercurial commands
369 gpg commands to sign and verify changesets
369 gpg commands to sign and verify changesets
370 hgk browse the repository in a graphical way
370 hgk browse the repository in a graphical way
371 highlight syntax highlighting for hgweb (requires Pygments)
371 highlight syntax highlighting for hgweb (requires Pygments)
372 histedit interactive history editing
372 histedit interactive history editing
373 keyword expand keywords in tracked files
373 keyword expand keywords in tracked files
374 largefiles track large binary files
374 largefiles track large binary files
375 mq manage a stack of patches
375 mq manage a stack of patches
376 notify hooks for sending email push notifications
376 notify hooks for sending email push notifications
377 patchbomb command to send changesets as (a series of) patch emails
377 patchbomb command to send changesets as (a series of) patch emails
378 purge command to delete untracked files from the working
378 purge command to delete untracked files from the working
379 directory
379 directory
380 relink recreates hardlinks between repository clones
380 relink recreates hardlinks between repository clones
381 schemes extend schemes with shortcuts to repository swarms
381 schemes extend schemes with shortcuts to repository swarms
382 share share a common history between several working directories
382 share share a common history between several working directories
383 transplant command to transplant changesets from another branch
383 transplant command to transplant changesets from another branch
384 win32mbcs allow the use of MBCS paths with problematic encodings
384 win32mbcs allow the use of MBCS paths with problematic encodings
385 zeroconf discover and advertise repositories on the local network
385 zeroconf discover and advertise repositories on the local network
386
386
387 #endif
387 #endif
388
388
389 Verify that deprecated extensions are included if --verbose:
389 Verify that deprecated extensions are included if --verbose:
390
390
391 $ hg -v help extensions | grep children
391 $ hg -v help extensions | grep children
392 children command to display child changesets (DEPRECATED)
392 children command to display child changesets (DEPRECATED)
393
393
394 Verify that extension keywords appear in help templates
394 Verify that extension keywords appear in help templates
395
395
396 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
396 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
397
397
398 Test short command list with verbose option
398 Test short command list with verbose option
399
399
400 $ hg -v help shortlist
400 $ hg -v help shortlist
401 Mercurial Distributed SCM
401 Mercurial Distributed SCM
402
402
403 basic commands:
403 basic commands:
404
404
405 abort abort an unfinished operation (EXPERIMENTAL)
405 abort abort an unfinished operation (EXPERIMENTAL)
406 add add the specified files on the next commit
406 add add the specified files on the next commit
407 annotate, blame
407 annotate, blame
408 show changeset information by line for each file
408 show changeset information by line for each file
409 clone make a copy of an existing repository
409 clone make a copy of an existing repository
410 commit, ci commit the specified files or all outstanding changes
410 commit, ci commit the specified files or all outstanding changes
411 continue resumes an interrupted operation (EXPERIMENTAL)
411 continue resumes an interrupted operation (EXPERIMENTAL)
412 diff diff repository (or selected files)
412 diff diff repository (or selected files)
413 export dump the header and diffs for one or more changesets
413 export dump the header and diffs for one or more changesets
414 forget forget the specified files on the next commit
414 forget forget the specified files on the next commit
415 init create a new repository in the given directory
415 init create a new repository in the given directory
416 log, history show revision history of entire repository or files
416 log, history show revision history of entire repository or files
417 merge merge another revision into working directory
417 merge merge another revision into working directory
418 pull pull changes from the specified source
418 pull pull changes from the specified source
419 push push changes to the specified destination
419 push push changes to the specified destination
420 remove, rm remove the specified files on the next commit
420 remove, rm remove the specified files on the next commit
421 serve start stand-alone webserver
421 serve start stand-alone webserver
422 status, st show changed files in the working directory
422 status, st show changed files in the working directory
423 summary, sum summarize working directory state
423 summary, sum summarize working directory state
424 update, up, checkout, co
424 update, up, checkout, co
425 update working directory (or switch revisions)
425 update working directory (or switch revisions)
426
426
427 global options ([+] can be repeated):
427 global options ([+] can be repeated):
428
428
429 -R --repository REPO repository root directory or name of overlay bundle
429 -R --repository REPO repository root directory or name of overlay bundle
430 file
430 file
431 --cwd DIR change working directory
431 --cwd DIR change working directory
432 -y --noninteractive do not prompt, automatically pick the first choice for
432 -y --noninteractive do not prompt, automatically pick the first choice for
433 all prompts
433 all prompts
434 -q --quiet suppress output
434 -q --quiet suppress output
435 -v --verbose enable additional output
435 -v --verbose enable additional output
436 --color TYPE when to colorize (boolean, always, auto, never, or
436 --color TYPE when to colorize (boolean, always, auto, never, or
437 debug)
437 debug)
438 --config CONFIG [+] set/override config option (use 'section.name=value')
438 --config CONFIG [+] set/override config option (use 'section.name=value')
439 --debug enable debugging output
439 --debug enable debugging output
440 --debugger start debugger
440 --debugger start debugger
441 --encoding ENCODE set the charset encoding (default: ascii)
441 --encoding ENCODE set the charset encoding (default: ascii)
442 --encodingmode MODE set the charset encoding mode (default: strict)
442 --encodingmode MODE set the charset encoding mode (default: strict)
443 --traceback always print a traceback on exception
443 --traceback always print a traceback on exception
444 --time time how long the command takes
444 --time time how long the command takes
445 --profile print command execution profile
445 --profile print command execution profile
446 --version output version information and exit
446 --version output version information and exit
447 -h --help display help and exit
447 -h --help display help and exit
448 --hidden consider hidden changesets
448 --hidden consider hidden changesets
449 --pager TYPE when to paginate (boolean, always, auto, or never)
449 --pager TYPE when to paginate (boolean, always, auto, or never)
450 (default: auto)
450 (default: auto)
451
451
452 (use 'hg help' for the full list of commands)
452 (use 'hg help' for the full list of commands)
453
453
454 $ hg add -h
454 $ hg add -h
455 hg add [OPTION]... [FILE]...
455 hg add [OPTION]... [FILE]...
456
456
457 add the specified files on the next commit
457 add the specified files on the next commit
458
458
459 Schedule files to be version controlled and added to the repository.
459 Schedule files to be version controlled and added to the repository.
460
460
461 The files will be added to the repository at the next commit. To undo an
461 The files will be added to the repository at the next commit. To undo an
462 add before that, see 'hg forget'.
462 add before that, see 'hg forget'.
463
463
464 If no names are given, add all files to the repository (except files
464 If no names are given, add all files to the repository (except files
465 matching ".hgignore").
465 matching ".hgignore").
466
466
467 Returns 0 if all files are successfully added.
467 Returns 0 if all files are successfully added.
468
468
469 options ([+] can be repeated):
469 options ([+] can be repeated):
470
470
471 -I --include PATTERN [+] include names matching the given patterns
471 -I --include PATTERN [+] include names matching the given patterns
472 -X --exclude PATTERN [+] exclude names matching the given patterns
472 -X --exclude PATTERN [+] exclude names matching the given patterns
473 -S --subrepos recurse into subrepositories
473 -S --subrepos recurse into subrepositories
474 -n --dry-run do not perform actions, just print output
474 -n --dry-run do not perform actions, just print output
475
475
476 (some details hidden, use --verbose to show complete help)
476 (some details hidden, use --verbose to show complete help)
477
477
478 Verbose help for add
478 Verbose help for add
479
479
480 $ hg add -hv
480 $ hg add -hv
481 hg add [OPTION]... [FILE]...
481 hg add [OPTION]... [FILE]...
482
482
483 add the specified files on the next commit
483 add the specified files on the next commit
484
484
485 Schedule files to be version controlled and added to the repository.
485 Schedule files to be version controlled and added to the repository.
486
486
487 The files will be added to the repository at the next commit. To undo an
487 The files will be added to the repository at the next commit. To undo an
488 add before that, see 'hg forget'.
488 add before that, see 'hg forget'.
489
489
490 If no names are given, add all files to the repository (except files
490 If no names are given, add all files to the repository (except files
491 matching ".hgignore").
491 matching ".hgignore").
492
492
493 Examples:
493 Examples:
494
494
495 - New (unknown) files are added automatically by 'hg add':
495 - New (unknown) files are added automatically by 'hg add':
496
496
497 $ ls
497 $ ls
498 foo.c
498 foo.c
499 $ hg status
499 $ hg status
500 ? foo.c
500 ? foo.c
501 $ hg add
501 $ hg add
502 adding foo.c
502 adding foo.c
503 $ hg status
503 $ hg status
504 A foo.c
504 A foo.c
505
505
506 - Specific files to be added can be specified:
506 - Specific files to be added can be specified:
507
507
508 $ ls
508 $ ls
509 bar.c foo.c
509 bar.c foo.c
510 $ hg status
510 $ hg status
511 ? bar.c
511 ? bar.c
512 ? foo.c
512 ? foo.c
513 $ hg add bar.c
513 $ hg add bar.c
514 $ hg status
514 $ hg status
515 A bar.c
515 A bar.c
516 ? foo.c
516 ? foo.c
517
517
518 Returns 0 if all files are successfully added.
518 Returns 0 if all files are successfully added.
519
519
520 options ([+] can be repeated):
520 options ([+] can be repeated):
521
521
522 -I --include PATTERN [+] include names matching the given patterns
522 -I --include PATTERN [+] include names matching the given patterns
523 -X --exclude PATTERN [+] exclude names matching the given patterns
523 -X --exclude PATTERN [+] exclude names matching the given patterns
524 -S --subrepos recurse into subrepositories
524 -S --subrepos recurse into subrepositories
525 -n --dry-run do not perform actions, just print output
525 -n --dry-run do not perform actions, just print output
526
526
527 global options ([+] can be repeated):
527 global options ([+] can be repeated):
528
528
529 -R --repository REPO repository root directory or name of overlay bundle
529 -R --repository REPO repository root directory or name of overlay bundle
530 file
530 file
531 --cwd DIR change working directory
531 --cwd DIR change working directory
532 -y --noninteractive do not prompt, automatically pick the first choice for
532 -y --noninteractive do not prompt, automatically pick the first choice for
533 all prompts
533 all prompts
534 -q --quiet suppress output
534 -q --quiet suppress output
535 -v --verbose enable additional output
535 -v --verbose enable additional output
536 --color TYPE when to colorize (boolean, always, auto, never, or
536 --color TYPE when to colorize (boolean, always, auto, never, or
537 debug)
537 debug)
538 --config CONFIG [+] set/override config option (use 'section.name=value')
538 --config CONFIG [+] set/override config option (use 'section.name=value')
539 --debug enable debugging output
539 --debug enable debugging output
540 --debugger start debugger
540 --debugger start debugger
541 --encoding ENCODE set the charset encoding (default: ascii)
541 --encoding ENCODE set the charset encoding (default: ascii)
542 --encodingmode MODE set the charset encoding mode (default: strict)
542 --encodingmode MODE set the charset encoding mode (default: strict)
543 --traceback always print a traceback on exception
543 --traceback always print a traceback on exception
544 --time time how long the command takes
544 --time time how long the command takes
545 --profile print command execution profile
545 --profile print command execution profile
546 --version output version information and exit
546 --version output version information and exit
547 -h --help display help and exit
547 -h --help display help and exit
548 --hidden consider hidden changesets
548 --hidden consider hidden changesets
549 --pager TYPE when to paginate (boolean, always, auto, or never)
549 --pager TYPE when to paginate (boolean, always, auto, or never)
550 (default: auto)
550 (default: auto)
551
551
552 Test the textwidth config option
552 Test the textwidth config option
553
553
554 $ hg root -h --config ui.textwidth=50
554 $ hg root -h --config ui.textwidth=50
555 hg root
555 hg root
556
556
557 print the root (top) of the current working
557 print the root (top) of the current working
558 directory
558 directory
559
559
560 Print the root directory of the current
560 Print the root directory of the current
561 repository.
561 repository.
562
562
563 Returns 0 on success.
563 Returns 0 on success.
564
564
565 options:
565 options:
566
566
567 -T --template TEMPLATE display with template
567 -T --template TEMPLATE display with template
568
568
569 (some details hidden, use --verbose to show
569 (some details hidden, use --verbose to show
570 complete help)
570 complete help)
571
571
572 Test help option with version option
572 Test help option with version option
573
573
574 $ hg add -h --version
574 $ hg add -h --version
575 Mercurial Distributed SCM (version *) (glob)
575 Mercurial Distributed SCM (version *) (glob)
576 (see https://mercurial-scm.org for more information)
576 (see https://mercurial-scm.org for more information)
577
577
578 Copyright (C) 2005-* Matt Mackall and others (glob)
578 Copyright (C) 2005-* Matt Mackall and others (glob)
579 This is free software; see the source for copying conditions. There is NO
579 This is free software; see the source for copying conditions. There is NO
580 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
580 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
581
581
582 $ hg add --skjdfks
582 $ hg add --skjdfks
583 hg add: option --skjdfks not recognized
583 hg add: option --skjdfks not recognized
584 hg add [OPTION]... [FILE]...
584 hg add [OPTION]... [FILE]...
585
585
586 add the specified files on the next commit
586 add the specified files on the next commit
587
587
588 options ([+] can be repeated):
588 options ([+] can be repeated):
589
589
590 -I --include PATTERN [+] include names matching the given patterns
590 -I --include PATTERN [+] include names matching the given patterns
591 -X --exclude PATTERN [+] exclude names matching the given patterns
591 -X --exclude PATTERN [+] exclude names matching the given patterns
592 -S --subrepos recurse into subrepositories
592 -S --subrepos recurse into subrepositories
593 -n --dry-run do not perform actions, just print output
593 -n --dry-run do not perform actions, just print output
594
594
595 (use 'hg add -h' to show more help)
595 (use 'hg add -h' to show more help)
596 [255]
596 [255]
597
597
598 Test ambiguous command help
598 Test ambiguous command help
599
599
600 $ hg help ad
600 $ hg help ad
601 list of commands:
601 list of commands:
602
602
603 add add the specified files on the next commit
603 add add the specified files on the next commit
604 addremove add all new files, delete all missing files
604 addremove add all new files, delete all missing files
605
605
606 (use 'hg help -v ad' to show built-in aliases and global options)
606 (use 'hg help -v ad' to show built-in aliases and global options)
607
607
608 Test command without options
608 Test command without options
609
609
610 $ hg help verify
610 $ hg help verify
611 hg verify
611 hg verify
612
612
613 verify the integrity of the repository
613 verify the integrity of the repository
614
614
615 Verify the integrity of the current repository.
615 Verify the integrity of the current repository.
616
616
617 This will perform an extensive check of the repository's integrity,
617 This will perform an extensive check of the repository's integrity,
618 validating the hashes and checksums of each entry in the changelog,
618 validating the hashes and checksums of each entry in the changelog,
619 manifest, and tracked files, as well as the integrity of their crosslinks
619 manifest, and tracked files, as well as the integrity of their crosslinks
620 and indices.
620 and indices.
621
621
622 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
622 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
623 information about recovery from corruption of the repository.
623 information about recovery from corruption of the repository.
624
624
625 Returns 0 on success, 1 if errors are encountered.
625 Returns 0 on success, 1 if errors are encountered.
626
626
627 options:
627 options:
628
628
629 (some details hidden, use --verbose to show complete help)
629 (some details hidden, use --verbose to show complete help)
630
630
631 $ hg help diff
631 $ hg help diff
632 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
632 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
633
633
634 diff repository (or selected files)
634 diff repository (or selected files)
635
635
636 Show differences between revisions for the specified files.
636 Show differences between revisions for the specified files.
637
637
638 Differences between files are shown using the unified diff format.
638 Differences between files are shown using the unified diff format.
639
639
640 Note:
640 Note:
641 'hg diff' may generate unexpected results for merges, as it will
641 'hg diff' may generate unexpected results for merges, as it will
642 default to comparing against the working directory's first parent
642 default to comparing against the working directory's first parent
643 changeset if no revisions are specified.
643 changeset if no revisions are specified.
644
644
645 When two revision arguments are given, then changes are shown between
645 When two revision arguments are given, then changes are shown between
646 those revisions. If only one revision is specified then that revision is
646 those revisions. If only one revision is specified then that revision is
647 compared to the working directory, and, when no revisions are specified,
647 compared to the working directory, and, when no revisions are specified,
648 the working directory files are compared to its first parent.
648 the working directory files are compared to its first parent.
649
649
650 Alternatively you can specify -c/--change with a revision to see the
650 Alternatively you can specify -c/--change with a revision to see the
651 changes in that changeset relative to its first parent.
651 changes in that changeset relative to its first parent.
652
652
653 Without the -a/--text option, diff will avoid generating diffs of files it
653 Without the -a/--text option, diff will avoid generating diffs of files it
654 detects as binary. With -a, diff will generate a diff anyway, probably
654 detects as binary. With -a, diff will generate a diff anyway, probably
655 with undesirable results.
655 with undesirable results.
656
656
657 Use the -g/--git option to generate diffs in the git extended diff format.
657 Use the -g/--git option to generate diffs in the git extended diff format.
658 For more information, read 'hg help diffs'.
658 For more information, read 'hg help diffs'.
659
659
660 Returns 0 on success.
660 Returns 0 on success.
661
661
662 options ([+] can be repeated):
662 options ([+] can be repeated):
663
663
664 -r --rev REV [+] revision
664 -r --rev REV [+] revision
665 --from REV revision to diff from
666 --to REV revision to diff to
665 -c --change REV change made by revision
667 -c --change REV change made by revision
666 -a --text treat all files as text
668 -a --text treat all files as text
667 -g --git use git extended diff format
669 -g --git use git extended diff format
668 --binary generate binary diffs in git mode (default)
670 --binary generate binary diffs in git mode (default)
669 --nodates omit dates from diff headers
671 --nodates omit dates from diff headers
670 --noprefix omit a/ and b/ prefixes from filenames
672 --noprefix omit a/ and b/ prefixes from filenames
671 -p --show-function show which function each change is in
673 -p --show-function show which function each change is in
672 --reverse produce a diff that undoes the changes
674 --reverse produce a diff that undoes the changes
673 -w --ignore-all-space ignore white space when comparing lines
675 -w --ignore-all-space ignore white space when comparing lines
674 -b --ignore-space-change ignore changes in the amount of white space
676 -b --ignore-space-change ignore changes in the amount of white space
675 -B --ignore-blank-lines ignore changes whose lines are all blank
677 -B --ignore-blank-lines ignore changes whose lines are all blank
676 -Z --ignore-space-at-eol ignore changes in whitespace at EOL
678 -Z --ignore-space-at-eol ignore changes in whitespace at EOL
677 -U --unified NUM number of lines of context to show
679 -U --unified NUM number of lines of context to show
678 --stat output diffstat-style summary of changes
680 --stat output diffstat-style summary of changes
679 --root DIR produce diffs relative to subdirectory
681 --root DIR produce diffs relative to subdirectory
680 -I --include PATTERN [+] include names matching the given patterns
682 -I --include PATTERN [+] include names matching the given patterns
681 -X --exclude PATTERN [+] exclude names matching the given patterns
683 -X --exclude PATTERN [+] exclude names matching the given patterns
682 -S --subrepos recurse into subrepositories
684 -S --subrepos recurse into subrepositories
683
685
684 (some details hidden, use --verbose to show complete help)
686 (some details hidden, use --verbose to show complete help)
685
687
686 $ hg help status
688 $ hg help status
687 hg status [OPTION]... [FILE]...
689 hg status [OPTION]... [FILE]...
688
690
689 aliases: st
691 aliases: st
690
692
691 show changed files in the working directory
693 show changed files in the working directory
692
694
693 Show status of files in the repository. If names are given, only files
695 Show status of files in the repository. If names are given, only files
694 that match are shown. Files that are clean or ignored or the source of a
696 that match are shown. Files that are clean or ignored or the source of a
695 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
697 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
696 -C/--copies or -A/--all are given. Unless options described with "show
698 -C/--copies or -A/--all are given. Unless options described with "show
697 only ..." are given, the options -mardu are used.
699 only ..." are given, the options -mardu are used.
698
700
699 Option -q/--quiet hides untracked (unknown and ignored) files unless
701 Option -q/--quiet hides untracked (unknown and ignored) files unless
700 explicitly requested with -u/--unknown or -i/--ignored.
702 explicitly requested with -u/--unknown or -i/--ignored.
701
703
702 Note:
704 Note:
703 'hg status' may appear to disagree with diff if permissions have
705 'hg status' may appear to disagree with diff if permissions have
704 changed or a merge has occurred. The standard diff format does not
706 changed or a merge has occurred. The standard diff format does not
705 report permission changes and diff only reports changes relative to one
707 report permission changes and diff only reports changes relative to one
706 merge parent.
708 merge parent.
707
709
708 If one revision is given, it is used as the base revision. If two
710 If one revision is given, it is used as the base revision. If two
709 revisions are given, the differences between them are shown. The --change
711 revisions are given, the differences between them are shown. The --change
710 option can also be used as a shortcut to list the changed files of a
712 option can also be used as a shortcut to list the changed files of a
711 revision from its first parent.
713 revision from its first parent.
712
714
713 The codes used to show the status of files are:
715 The codes used to show the status of files are:
714
716
715 M = modified
717 M = modified
716 A = added
718 A = added
717 R = removed
719 R = removed
718 C = clean
720 C = clean
719 ! = missing (deleted by non-hg command, but still tracked)
721 ! = missing (deleted by non-hg command, but still tracked)
720 ? = not tracked
722 ? = not tracked
721 I = ignored
723 I = ignored
722 = origin of the previous file (with --copies)
724 = origin of the previous file (with --copies)
723
725
724 Returns 0 on success.
726 Returns 0 on success.
725
727
726 options ([+] can be repeated):
728 options ([+] can be repeated):
727
729
728 -A --all show status of all files
730 -A --all show status of all files
729 -m --modified show only modified files
731 -m --modified show only modified files
730 -a --added show only added files
732 -a --added show only added files
731 -r --removed show only removed files
733 -r --removed show only removed files
732 -d --deleted show only missing files
734 -d --deleted show only missing files
733 -c --clean show only files without changes
735 -c --clean show only files without changes
734 -u --unknown show only unknown (not tracked) files
736 -u --unknown show only unknown (not tracked) files
735 -i --ignored show only ignored files
737 -i --ignored show only ignored files
736 -n --no-status hide status prefix
738 -n --no-status hide status prefix
737 -C --copies show source of copied files
739 -C --copies show source of copied files
738 -0 --print0 end filenames with NUL, for use with xargs
740 -0 --print0 end filenames with NUL, for use with xargs
739 --rev REV [+] show difference from revision
741 --rev REV [+] show difference from revision
740 --change REV list the changed files of a revision
742 --change REV list the changed files of a revision
741 -I --include PATTERN [+] include names matching the given patterns
743 -I --include PATTERN [+] include names matching the given patterns
742 -X --exclude PATTERN [+] exclude names matching the given patterns
744 -X --exclude PATTERN [+] exclude names matching the given patterns
743 -S --subrepos recurse into subrepositories
745 -S --subrepos recurse into subrepositories
744 -T --template TEMPLATE display with template
746 -T --template TEMPLATE display with template
745
747
746 (some details hidden, use --verbose to show complete help)
748 (some details hidden, use --verbose to show complete help)
747
749
748 $ hg -q help status
750 $ hg -q help status
749 hg status [OPTION]... [FILE]...
751 hg status [OPTION]... [FILE]...
750
752
751 show changed files in the working directory
753 show changed files in the working directory
752
754
753 $ hg help foo
755 $ hg help foo
754 abort: no such help topic: foo
756 abort: no such help topic: foo
755 (try 'hg help --keyword foo')
757 (try 'hg help --keyword foo')
756 [255]
758 [255]
757
759
758 $ hg skjdfks
760 $ hg skjdfks
759 hg: unknown command 'skjdfks'
761 hg: unknown command 'skjdfks'
760 (use 'hg help' for a list of commands)
762 (use 'hg help' for a list of commands)
761 [255]
763 [255]
762
764
763 Typoed command gives suggestion
765 Typoed command gives suggestion
764 $ hg puls
766 $ hg puls
765 hg: unknown command 'puls'
767 hg: unknown command 'puls'
766 (did you mean one of pull, push?)
768 (did you mean one of pull, push?)
767 [255]
769 [255]
768
770
769 Not enabled extension gets suggested
771 Not enabled extension gets suggested
770
772
771 $ hg rebase
773 $ hg rebase
772 hg: unknown command 'rebase'
774 hg: unknown command 'rebase'
773 'rebase' is provided by the following extension:
775 'rebase' is provided by the following extension:
774
776
775 rebase command to move sets of revisions to a different ancestor
777 rebase command to move sets of revisions to a different ancestor
776
778
777 (use 'hg help extensions' for information on enabling extensions)
779 (use 'hg help extensions' for information on enabling extensions)
778 [255]
780 [255]
779
781
780 Disabled extension gets suggested
782 Disabled extension gets suggested
781 $ hg --config extensions.rebase=! rebase
783 $ hg --config extensions.rebase=! rebase
782 hg: unknown command 'rebase'
784 hg: unknown command 'rebase'
783 'rebase' is provided by the following extension:
785 'rebase' is provided by the following extension:
784
786
785 rebase command to move sets of revisions to a different ancestor
787 rebase command to move sets of revisions to a different ancestor
786
788
787 (use 'hg help extensions' for information on enabling extensions)
789 (use 'hg help extensions' for information on enabling extensions)
788 [255]
790 [255]
789
791
790 Checking that help adapts based on the config:
792 Checking that help adapts based on the config:
791
793
792 $ hg help diff --config ui.tweakdefaults=true | egrep -e '^ *(-g|config)'
794 $ hg help diff --config ui.tweakdefaults=true | egrep -e '^ *(-g|config)'
793 -g --[no-]git use git extended diff format (default: on from
795 -g --[no-]git use git extended diff format (default: on from
794 config)
796 config)
795
797
796 Make sure that we don't run afoul of the help system thinking that
798 Make sure that we don't run afoul of the help system thinking that
797 this is a section and erroring out weirdly.
799 this is a section and erroring out weirdly.
798
800
799 $ hg .log
801 $ hg .log
800 hg: unknown command '.log'
802 hg: unknown command '.log'
801 (did you mean log?)
803 (did you mean log?)
802 [255]
804 [255]
803
805
804 $ hg log.
806 $ hg log.
805 hg: unknown command 'log.'
807 hg: unknown command 'log.'
806 (did you mean log?)
808 (did you mean log?)
807 [255]
809 [255]
808 $ hg pu.lh
810 $ hg pu.lh
809 hg: unknown command 'pu.lh'
811 hg: unknown command 'pu.lh'
810 (did you mean one of pull, push?)
812 (did you mean one of pull, push?)
811 [255]
813 [255]
812
814
813 $ cat > helpext.py <<EOF
815 $ cat > helpext.py <<EOF
814 > import os
816 > import os
815 > from mercurial import commands, fancyopts, registrar
817 > from mercurial import commands, fancyopts, registrar
816 >
818 >
817 > def func(arg):
819 > def func(arg):
818 > return '%sfoo' % arg
820 > return '%sfoo' % arg
819 > class customopt(fancyopts.customopt):
821 > class customopt(fancyopts.customopt):
820 > def newstate(self, oldstate, newparam, abort):
822 > def newstate(self, oldstate, newparam, abort):
821 > return '%sbar' % oldstate
823 > return '%sbar' % oldstate
822 > cmdtable = {}
824 > cmdtable = {}
823 > command = registrar.command(cmdtable)
825 > command = registrar.command(cmdtable)
824 >
826 >
825 > @command(b'nohelp',
827 > @command(b'nohelp',
826 > [(b'', b'longdesc', 3, b'x'*67),
828 > [(b'', b'longdesc', 3, b'x'*67),
827 > (b'n', b'', None, b'normal desc'),
829 > (b'n', b'', None, b'normal desc'),
828 > (b'', b'newline', b'', b'line1\nline2'),
830 > (b'', b'newline', b'', b'line1\nline2'),
829 > (b'', b'default-off', False, b'enable X'),
831 > (b'', b'default-off', False, b'enable X'),
830 > (b'', b'default-on', True, b'enable Y'),
832 > (b'', b'default-on', True, b'enable Y'),
831 > (b'', b'callableopt', func, b'adds foo'),
833 > (b'', b'callableopt', func, b'adds foo'),
832 > (b'', b'customopt', customopt(''), b'adds bar'),
834 > (b'', b'customopt', customopt(''), b'adds bar'),
833 > (b'', b'customopt-withdefault', customopt('foo'), b'adds bar')],
835 > (b'', b'customopt-withdefault', customopt('foo'), b'adds bar')],
834 > b'hg nohelp',
836 > b'hg nohelp',
835 > norepo=True)
837 > norepo=True)
836 > @command(b'debugoptADV', [(b'', b'aopt', None, b'option is (ADVANCED)')])
838 > @command(b'debugoptADV', [(b'', b'aopt', None, b'option is (ADVANCED)')])
837 > @command(b'debugoptDEP', [(b'', b'dopt', None, b'option is (DEPRECATED)')])
839 > @command(b'debugoptDEP', [(b'', b'dopt', None, b'option is (DEPRECATED)')])
838 > @command(b'debugoptEXP', [(b'', b'eopt', None, b'option is (EXPERIMENTAL)')])
840 > @command(b'debugoptEXP', [(b'', b'eopt', None, b'option is (EXPERIMENTAL)')])
839 > def nohelp(ui, *args, **kwargs):
841 > def nohelp(ui, *args, **kwargs):
840 > pass
842 > pass
841 >
843 >
842 > @command(b'hashelp', [], b'hg hashelp', norepo=True)
844 > @command(b'hashelp', [], b'hg hashelp', norepo=True)
843 > def hashelp(ui, *args, **kwargs):
845 > def hashelp(ui, *args, **kwargs):
844 > """Extension command's help"""
846 > """Extension command's help"""
845 >
847 >
846 > def uisetup(ui):
848 > def uisetup(ui):
847 > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext')
849 > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext')
848 > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext')
850 > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext')
849 > ui.setconfig(b'alias', b'hgalias:doc', b'My doc', b'helpext')
851 > ui.setconfig(b'alias', b'hgalias:doc', b'My doc', b'helpext')
850 > ui.setconfig(b'alias', b'hgalias:category', b'navigation', b'helpext')
852 > ui.setconfig(b'alias', b'hgalias:category', b'navigation', b'helpext')
851 > ui.setconfig(b'alias', b'hgaliasnodoc', b'summary', b'helpext')
853 > ui.setconfig(b'alias', b'hgaliasnodoc', b'summary', b'helpext')
852 >
854 >
853 > EOF
855 > EOF
854 $ echo '[extensions]' >> $HGRCPATH
856 $ echo '[extensions]' >> $HGRCPATH
855 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
857 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
856
858
857 Test for aliases
859 Test for aliases
858
860
859 $ hg help | grep hgalias
861 $ hg help | grep hgalias
860 hgalias My doc
862 hgalias My doc
861
863
862 $ hg help hgalias
864 $ hg help hgalias
863 hg hgalias [--remote]
865 hg hgalias [--remote]
864
866
865 alias for: hg summary
867 alias for: hg summary
866
868
867 My doc
869 My doc
868
870
869 defined by: helpext
871 defined by: helpext
870
872
871 options:
873 options:
872
874
873 --remote check for push and pull
875 --remote check for push and pull
874
876
875 (some details hidden, use --verbose to show complete help)
877 (some details hidden, use --verbose to show complete help)
876 $ hg help hgaliasnodoc
878 $ hg help hgaliasnodoc
877 hg hgaliasnodoc [--remote]
879 hg hgaliasnodoc [--remote]
878
880
879 alias for: hg summary
881 alias for: hg summary
880
882
881 summarize working directory state
883 summarize working directory state
882
884
883 This generates a brief summary of the working directory state, including
885 This generates a brief summary of the working directory state, including
884 parents, branch, commit status, phase and available updates.
886 parents, branch, commit status, phase and available updates.
885
887
886 With the --remote option, this will check the default paths for incoming
888 With the --remote option, this will check the default paths for incoming
887 and outgoing changes. This can be time-consuming.
889 and outgoing changes. This can be time-consuming.
888
890
889 Returns 0 on success.
891 Returns 0 on success.
890
892
891 defined by: helpext
893 defined by: helpext
892
894
893 options:
895 options:
894
896
895 --remote check for push and pull
897 --remote check for push and pull
896
898
897 (some details hidden, use --verbose to show complete help)
899 (some details hidden, use --verbose to show complete help)
898
900
899 $ hg help shellalias
901 $ hg help shellalias
900 hg shellalias
902 hg shellalias
901
903
902 shell alias for: echo hi
904 shell alias for: echo hi
903
905
904 (no help text available)
906 (no help text available)
905
907
906 defined by: helpext
908 defined by: helpext
907
909
908 (some details hidden, use --verbose to show complete help)
910 (some details hidden, use --verbose to show complete help)
909
911
910 Test command with no help text
912 Test command with no help text
911
913
912 $ hg help nohelp
914 $ hg help nohelp
913 hg nohelp
915 hg nohelp
914
916
915 (no help text available)
917 (no help text available)
916
918
917 options:
919 options:
918
920
919 --longdesc VALUE
921 --longdesc VALUE
920 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
922 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
921 xxxxxxxxxxxxxxxxxxxxxxx (default: 3)
923 xxxxxxxxxxxxxxxxxxxxxxx (default: 3)
922 -n -- normal desc
924 -n -- normal desc
923 --newline VALUE line1 line2
925 --newline VALUE line1 line2
924 --default-off enable X
926 --default-off enable X
925 --[no-]default-on enable Y (default: on)
927 --[no-]default-on enable Y (default: on)
926 --callableopt VALUE adds foo
928 --callableopt VALUE adds foo
927 --customopt VALUE adds bar
929 --customopt VALUE adds bar
928 --customopt-withdefault VALUE adds bar (default: foo)
930 --customopt-withdefault VALUE adds bar (default: foo)
929
931
930 (some details hidden, use --verbose to show complete help)
932 (some details hidden, use --verbose to show complete help)
931
933
932 Test that default list of commands includes extension commands that have help,
934 Test that default list of commands includes extension commands that have help,
933 but not those that don't, except in verbose mode, when a keyword is passed, or
935 but not those that don't, except in verbose mode, when a keyword is passed, or
934 when help about the extension is requested.
936 when help about the extension is requested.
935
937
936 #if no-extraextensions
938 #if no-extraextensions
937
939
938 $ hg help | grep hashelp
940 $ hg help | grep hashelp
939 hashelp Extension command's help
941 hashelp Extension command's help
940 $ hg help | grep nohelp
942 $ hg help | grep nohelp
941 [1]
943 [1]
942 $ hg help -v | grep nohelp
944 $ hg help -v | grep nohelp
943 nohelp (no help text available)
945 nohelp (no help text available)
944
946
945 $ hg help -k nohelp
947 $ hg help -k nohelp
946 Commands:
948 Commands:
947
949
948 nohelp hg nohelp
950 nohelp hg nohelp
949
951
950 Extension Commands:
952 Extension Commands:
951
953
952 nohelp (no help text available)
954 nohelp (no help text available)
953
955
954 $ hg help helpext
956 $ hg help helpext
955 helpext extension - no help text available
957 helpext extension - no help text available
956
958
957 list of commands:
959 list of commands:
958
960
959 hashelp Extension command's help
961 hashelp Extension command's help
960 nohelp (no help text available)
962 nohelp (no help text available)
961
963
962 (use 'hg help -v helpext' to show built-in aliases and global options)
964 (use 'hg help -v helpext' to show built-in aliases and global options)
963
965
964 #endif
966 #endif
965
967
966 Test list of internal help commands
968 Test list of internal help commands
967
969
968 $ hg help debug
970 $ hg help debug
969 debug commands (internal and unsupported):
971 debug commands (internal and unsupported):
970
972
971 debugancestor
973 debugancestor
972 find the ancestor revision of two revisions in a given index
974 find the ancestor revision of two revisions in a given index
973 debugantivirusrunning
975 debugantivirusrunning
974 attempt to trigger an antivirus scanner to see if one is active
976 attempt to trigger an antivirus scanner to see if one is active
975 debugapplystreamclonebundle
977 debugapplystreamclonebundle
976 apply a stream clone bundle file
978 apply a stream clone bundle file
977 debugbackupbundle
979 debugbackupbundle
978 lists the changesets available in backup bundles
980 lists the changesets available in backup bundles
979 debugbuilddag
981 debugbuilddag
980 builds a repo with a given DAG from scratch in the current
982 builds a repo with a given DAG from scratch in the current
981 empty repo
983 empty repo
982 debugbundle lists the contents of a bundle
984 debugbundle lists the contents of a bundle
983 debugcapabilities
985 debugcapabilities
984 lists the capabilities of a remote peer
986 lists the capabilities of a remote peer
985 debugchangedfiles
987 debugchangedfiles
986 list the stored files changes for a revision
988 list the stored files changes for a revision
987 debugcheckstate
989 debugcheckstate
988 validate the correctness of the current dirstate
990 validate the correctness of the current dirstate
989 debugcolor show available color, effects or style
991 debugcolor show available color, effects or style
990 debugcommands
992 debugcommands
991 list all available commands and options
993 list all available commands and options
992 debugcomplete
994 debugcomplete
993 returns the completion list associated with the given command
995 returns the completion list associated with the given command
994 debugcreatestreamclonebundle
996 debugcreatestreamclonebundle
995 create a stream clone bundle file
997 create a stream clone bundle file
996 debugdag format the changelog or an index DAG as a concise textual
998 debugdag format the changelog or an index DAG as a concise textual
997 description
999 description
998 debugdata dump the contents of a data file revision
1000 debugdata dump the contents of a data file revision
999 debugdate parse and display a date
1001 debugdate parse and display a date
1000 debugdeltachain
1002 debugdeltachain
1001 dump information about delta chains in a revlog
1003 dump information about delta chains in a revlog
1002 debugdirstate
1004 debugdirstate
1003 show the contents of the current dirstate
1005 show the contents of the current dirstate
1004 debugdiscovery
1006 debugdiscovery
1005 runs the changeset discovery protocol in isolation
1007 runs the changeset discovery protocol in isolation
1006 debugdownload
1008 debugdownload
1007 download a resource using Mercurial logic and config
1009 download a resource using Mercurial logic and config
1008 debugextensions
1010 debugextensions
1009 show information about active extensions
1011 show information about active extensions
1010 debugfileset parse and apply a fileset specification
1012 debugfileset parse and apply a fileset specification
1011 debugformat display format information about the current repository
1013 debugformat display format information about the current repository
1012 debugfsinfo show information detected about current filesystem
1014 debugfsinfo show information detected about current filesystem
1013 debuggetbundle
1015 debuggetbundle
1014 retrieves a bundle from a repo
1016 retrieves a bundle from a repo
1015 debugignore display the combined ignore pattern and information about
1017 debugignore display the combined ignore pattern and information about
1016 ignored files
1018 ignored files
1017 debugindex dump index data for a storage primitive
1019 debugindex dump index data for a storage primitive
1018 debugindexdot
1020 debugindexdot
1019 dump an index DAG as a graphviz dot file
1021 dump an index DAG as a graphviz dot file
1020 debugindexstats
1022 debugindexstats
1021 show stats related to the changelog index
1023 show stats related to the changelog index
1022 debuginstall test Mercurial installation
1024 debuginstall test Mercurial installation
1023 debugknown test whether node ids are known to a repo
1025 debugknown test whether node ids are known to a repo
1024 debuglocks show or modify state of locks
1026 debuglocks show or modify state of locks
1025 debugmanifestfulltextcache
1027 debugmanifestfulltextcache
1026 show, clear or amend the contents of the manifest fulltext
1028 show, clear or amend the contents of the manifest fulltext
1027 cache
1029 cache
1028 debugmergestate
1030 debugmergestate
1029 print merge state
1031 print merge state
1030 debugnamecomplete
1032 debugnamecomplete
1031 complete "names" - tags, open branch names, bookmark names
1033 complete "names" - tags, open branch names, bookmark names
1032 debugnodemap write and inspect on disk nodemap
1034 debugnodemap write and inspect on disk nodemap
1033 debugobsolete
1035 debugobsolete
1034 create arbitrary obsolete marker
1036 create arbitrary obsolete marker
1035 debugoptADV (no help text available)
1037 debugoptADV (no help text available)
1036 debugoptDEP (no help text available)
1038 debugoptDEP (no help text available)
1037 debugoptEXP (no help text available)
1039 debugoptEXP (no help text available)
1038 debugp1copies
1040 debugp1copies
1039 dump copy information compared to p1
1041 dump copy information compared to p1
1040 debugp2copies
1042 debugp2copies
1041 dump copy information compared to p2
1043 dump copy information compared to p2
1042 debugpathcomplete
1044 debugpathcomplete
1043 complete part or all of a tracked path
1045 complete part or all of a tracked path
1044 debugpathcopies
1046 debugpathcopies
1045 show copies between two revisions
1047 show copies between two revisions
1046 debugpeer establish a connection to a peer repository
1048 debugpeer establish a connection to a peer repository
1047 debugpickmergetool
1049 debugpickmergetool
1048 examine which merge tool is chosen for specified file
1050 examine which merge tool is chosen for specified file
1049 debugpushkey access the pushkey key/value protocol
1051 debugpushkey access the pushkey key/value protocol
1050 debugpvec (no help text available)
1052 debugpvec (no help text available)
1051 debugrebuilddirstate
1053 debugrebuilddirstate
1052 rebuild the dirstate as it would look like for the given
1054 rebuild the dirstate as it would look like for the given
1053 revision
1055 revision
1054 debugrebuildfncache
1056 debugrebuildfncache
1055 rebuild the fncache file
1057 rebuild the fncache file
1056 debugrename dump rename information
1058 debugrename dump rename information
1057 debugrequires
1059 debugrequires
1058 print the current repo requirements
1060 print the current repo requirements
1059 debugrevlog show data and statistics about a revlog
1061 debugrevlog show data and statistics about a revlog
1060 debugrevlogindex
1062 debugrevlogindex
1061 dump the contents of a revlog index
1063 dump the contents of a revlog index
1062 debugrevspec parse and apply a revision specification
1064 debugrevspec parse and apply a revision specification
1063 debugserve run a server with advanced settings
1065 debugserve run a server with advanced settings
1064 debugsetparents
1066 debugsetparents
1065 manually set the parents of the current working directory
1067 manually set the parents of the current working directory
1066 debugsidedata
1068 debugsidedata
1067 dump the side data for a cl/manifest/file revision
1069 dump the side data for a cl/manifest/file revision
1068 debugssl test a secure connection to a server
1070 debugssl test a secure connection to a server
1069 debugstrip strip changesets and all their descendants from the repository
1071 debugstrip strip changesets and all their descendants from the repository
1070 debugsub (no help text available)
1072 debugsub (no help text available)
1071 debugsuccessorssets
1073 debugsuccessorssets
1072 show set of successors for revision
1074 show set of successors for revision
1073 debugtagscache
1075 debugtagscache
1074 display the contents of .hg/cache/hgtagsfnodes1
1076 display the contents of .hg/cache/hgtagsfnodes1
1075 debugtemplate
1077 debugtemplate
1076 parse and apply a template
1078 parse and apply a template
1077 debuguigetpass
1079 debuguigetpass
1078 show prompt to type password
1080 show prompt to type password
1079 debuguiprompt
1081 debuguiprompt
1080 show plain prompt
1082 show plain prompt
1081 debugupdatecaches
1083 debugupdatecaches
1082 warm all known caches in the repository
1084 warm all known caches in the repository
1083 debugupgraderepo
1085 debugupgraderepo
1084 upgrade a repository to use different features
1086 upgrade a repository to use different features
1085 debugwalk show how files match on given patterns
1087 debugwalk show how files match on given patterns
1086 debugwhyunstable
1088 debugwhyunstable
1087 explain instabilities of a changeset
1089 explain instabilities of a changeset
1088 debugwireargs
1090 debugwireargs
1089 (no help text available)
1091 (no help text available)
1090 debugwireproto
1092 debugwireproto
1091 send wire protocol commands to a server
1093 send wire protocol commands to a server
1092
1094
1093 (use 'hg help -v debug' to show built-in aliases and global options)
1095 (use 'hg help -v debug' to show built-in aliases and global options)
1094
1096
1095 internals topic renders index of available sub-topics
1097 internals topic renders index of available sub-topics
1096
1098
1097 $ hg help internals
1099 $ hg help internals
1098 Technical implementation topics
1100 Technical implementation topics
1099 """""""""""""""""""""""""""""""
1101 """""""""""""""""""""""""""""""
1100
1102
1101 To access a subtopic, use "hg help internals.{subtopic-name}"
1103 To access a subtopic, use "hg help internals.{subtopic-name}"
1102
1104
1103 bid-merge Bid Merge Algorithm
1105 bid-merge Bid Merge Algorithm
1104 bundle2 Bundle2
1106 bundle2 Bundle2
1105 bundles Bundles
1107 bundles Bundles
1106 cbor CBOR
1108 cbor CBOR
1107 censor Censor
1109 censor Censor
1108 changegroups Changegroups
1110 changegroups Changegroups
1109 config Config Registrar
1111 config Config Registrar
1110 extensions Extension API
1112 extensions Extension API
1111 mergestate Mergestate
1113 mergestate Mergestate
1112 requirements Repository Requirements
1114 requirements Repository Requirements
1113 revlogs Revision Logs
1115 revlogs Revision Logs
1114 wireprotocol Wire Protocol
1116 wireprotocol Wire Protocol
1115 wireprotocolrpc
1117 wireprotocolrpc
1116 Wire Protocol RPC
1118 Wire Protocol RPC
1117 wireprotocolv2
1119 wireprotocolv2
1118 Wire Protocol Version 2
1120 Wire Protocol Version 2
1119
1121
1120 sub-topics can be accessed
1122 sub-topics can be accessed
1121
1123
1122 $ hg help internals.changegroups
1124 $ hg help internals.changegroups
1123 Changegroups
1125 Changegroups
1124 """"""""""""
1126 """"""""""""
1125
1127
1126 Changegroups are representations of repository revlog data, specifically
1128 Changegroups are representations of repository revlog data, specifically
1127 the changelog data, root/flat manifest data, treemanifest data, and
1129 the changelog data, root/flat manifest data, treemanifest data, and
1128 filelogs.
1130 filelogs.
1129
1131
1130 There are 3 versions of changegroups: "1", "2", and "3". From a high-
1132 There are 3 versions of changegroups: "1", "2", and "3". From a high-
1131 level, versions "1" and "2" are almost exactly the same, with the only
1133 level, versions "1" and "2" are almost exactly the same, with the only
1132 difference being an additional item in the *delta header*. Version "3"
1134 difference being an additional item in the *delta header*. Version "3"
1133 adds support for storage flags in the *delta header* and optionally
1135 adds support for storage flags in the *delta header* and optionally
1134 exchanging treemanifests (enabled by setting an option on the
1136 exchanging treemanifests (enabled by setting an option on the
1135 "changegroup" part in the bundle2).
1137 "changegroup" part in the bundle2).
1136
1138
1137 Changegroups when not exchanging treemanifests consist of 3 logical
1139 Changegroups when not exchanging treemanifests consist of 3 logical
1138 segments:
1140 segments:
1139
1141
1140 +---------------------------------+
1142 +---------------------------------+
1141 | | | |
1143 | | | |
1142 | changeset | manifest | filelogs |
1144 | changeset | manifest | filelogs |
1143 | | | |
1145 | | | |
1144 | | | |
1146 | | | |
1145 +---------------------------------+
1147 +---------------------------------+
1146
1148
1147 When exchanging treemanifests, there are 4 logical segments:
1149 When exchanging treemanifests, there are 4 logical segments:
1148
1150
1149 +-------------------------------------------------+
1151 +-------------------------------------------------+
1150 | | | | |
1152 | | | | |
1151 | changeset | root | treemanifests | filelogs |
1153 | changeset | root | treemanifests | filelogs |
1152 | | manifest | | |
1154 | | manifest | | |
1153 | | | | |
1155 | | | | |
1154 +-------------------------------------------------+
1156 +-------------------------------------------------+
1155
1157
1156 The principle building block of each segment is a *chunk*. A *chunk* is a
1158 The principle building block of each segment is a *chunk*. A *chunk* is a
1157 framed piece of data:
1159 framed piece of data:
1158
1160
1159 +---------------------------------------+
1161 +---------------------------------------+
1160 | | |
1162 | | |
1161 | length | data |
1163 | length | data |
1162 | (4 bytes) | (<length - 4> bytes) |
1164 | (4 bytes) | (<length - 4> bytes) |
1163 | | |
1165 | | |
1164 +---------------------------------------+
1166 +---------------------------------------+
1165
1167
1166 All integers are big-endian signed integers. Each chunk starts with a
1168 All integers are big-endian signed integers. Each chunk starts with a
1167 32-bit integer indicating the length of the entire chunk (including the
1169 32-bit integer indicating the length of the entire chunk (including the
1168 length field itself).
1170 length field itself).
1169
1171
1170 There is a special case chunk that has a value of 0 for the length
1172 There is a special case chunk that has a value of 0 for the length
1171 ("0x00000000"). We call this an *empty chunk*.
1173 ("0x00000000"). We call this an *empty chunk*.
1172
1174
1173 Delta Groups
1175 Delta Groups
1174 ============
1176 ============
1175
1177
1176 A *delta group* expresses the content of a revlog as a series of deltas,
1178 A *delta group* expresses the content of a revlog as a series of deltas,
1177 or patches against previous revisions.
1179 or patches against previous revisions.
1178
1180
1179 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
1181 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
1180 to signal the end of the delta group:
1182 to signal the end of the delta group:
1181
1183
1182 +------------------------------------------------------------------------+
1184 +------------------------------------------------------------------------+
1183 | | | | | |
1185 | | | | | |
1184 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
1186 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
1185 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
1187 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
1186 | | | | | |
1188 | | | | | |
1187 +------------------------------------------------------------------------+
1189 +------------------------------------------------------------------------+
1188
1190
1189 Each *chunk*'s data consists of the following:
1191 Each *chunk*'s data consists of the following:
1190
1192
1191 +---------------------------------------+
1193 +---------------------------------------+
1192 | | |
1194 | | |
1193 | delta header | delta data |
1195 | delta header | delta data |
1194 | (various by version) | (various) |
1196 | (various by version) | (various) |
1195 | | |
1197 | | |
1196 +---------------------------------------+
1198 +---------------------------------------+
1197
1199
1198 The *delta data* is a series of *delta*s that describe a diff from an
1200 The *delta data* is a series of *delta*s that describe a diff from an
1199 existing entry (either that the recipient already has, or previously
1201 existing entry (either that the recipient already has, or previously
1200 specified in the bundle/changegroup).
1202 specified in the bundle/changegroup).
1201
1203
1202 The *delta header* is different between versions "1", "2", and "3" of the
1204 The *delta header* is different between versions "1", "2", and "3" of the
1203 changegroup format.
1205 changegroup format.
1204
1206
1205 Version 1 (headerlen=80):
1207 Version 1 (headerlen=80):
1206
1208
1207 +------------------------------------------------------+
1209 +------------------------------------------------------+
1208 | | | | |
1210 | | | | |
1209 | node | p1 node | p2 node | link node |
1211 | node | p1 node | p2 node | link node |
1210 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1212 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1211 | | | | |
1213 | | | | |
1212 +------------------------------------------------------+
1214 +------------------------------------------------------+
1213
1215
1214 Version 2 (headerlen=100):
1216 Version 2 (headerlen=100):
1215
1217
1216 +------------------------------------------------------------------+
1218 +------------------------------------------------------------------+
1217 | | | | | |
1219 | | | | | |
1218 | node | p1 node | p2 node | base node | link node |
1220 | node | p1 node | p2 node | base node | link node |
1219 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1221 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1220 | | | | | |
1222 | | | | | |
1221 +------------------------------------------------------------------+
1223 +------------------------------------------------------------------+
1222
1224
1223 Version 3 (headerlen=102):
1225 Version 3 (headerlen=102):
1224
1226
1225 +------------------------------------------------------------------------------+
1227 +------------------------------------------------------------------------------+
1226 | | | | | | |
1228 | | | | | | |
1227 | node | p1 node | p2 node | base node | link node | flags |
1229 | node | p1 node | p2 node | base node | link node | flags |
1228 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
1230 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
1229 | | | | | | |
1231 | | | | | | |
1230 +------------------------------------------------------------------------------+
1232 +------------------------------------------------------------------------------+
1231
1233
1232 The *delta data* consists of "chunklen - 4 - headerlen" bytes, which
1234 The *delta data* consists of "chunklen - 4 - headerlen" bytes, which
1233 contain a series of *delta*s, densely packed (no separators). These deltas
1235 contain a series of *delta*s, densely packed (no separators). These deltas
1234 describe a diff from an existing entry (either that the recipient already
1236 describe a diff from an existing entry (either that the recipient already
1235 has, or previously specified in the bundle/changegroup). The format is
1237 has, or previously specified in the bundle/changegroup). The format is
1236 described more fully in "hg help internals.bdiff", but briefly:
1238 described more fully in "hg help internals.bdiff", but briefly:
1237
1239
1238 +---------------------------------------------------------------+
1240 +---------------------------------------------------------------+
1239 | | | | |
1241 | | | | |
1240 | start offset | end offset | new length | content |
1242 | start offset | end offset | new length | content |
1241 | (4 bytes) | (4 bytes) | (4 bytes) | (<new length> bytes) |
1243 | (4 bytes) | (4 bytes) | (4 bytes) | (<new length> bytes) |
1242 | | | | |
1244 | | | | |
1243 +---------------------------------------------------------------+
1245 +---------------------------------------------------------------+
1244
1246
1245 Please note that the length field in the delta data does *not* include
1247 Please note that the length field in the delta data does *not* include
1246 itself.
1248 itself.
1247
1249
1248 In version 1, the delta is always applied against the previous node from
1250 In version 1, the delta is always applied against the previous node from
1249 the changegroup or the first parent if this is the first entry in the
1251 the changegroup or the first parent if this is the first entry in the
1250 changegroup.
1252 changegroup.
1251
1253
1252 In version 2 and up, the delta base node is encoded in the entry in the
1254 In version 2 and up, the delta base node is encoded in the entry in the
1253 changegroup. This allows the delta to be expressed against any parent,
1255 changegroup. This allows the delta to be expressed against any parent,
1254 which can result in smaller deltas and more efficient encoding of data.
1256 which can result in smaller deltas and more efficient encoding of data.
1255
1257
1256 The *flags* field holds bitwise flags affecting the processing of revision
1258 The *flags* field holds bitwise flags affecting the processing of revision
1257 data. The following flags are defined:
1259 data. The following flags are defined:
1258
1260
1259 32768
1261 32768
1260 Censored revision. The revision's fulltext has been replaced by censor
1262 Censored revision. The revision's fulltext has been replaced by censor
1261 metadata. May only occur on file revisions.
1263 metadata. May only occur on file revisions.
1262
1264
1263 16384
1265 16384
1264 Ellipsis revision. Revision hash does not match data (likely due to
1266 Ellipsis revision. Revision hash does not match data (likely due to
1265 rewritten parents).
1267 rewritten parents).
1266
1268
1267 8192
1269 8192
1268 Externally stored. The revision fulltext contains "key:value" "\n"
1270 Externally stored. The revision fulltext contains "key:value" "\n"
1269 delimited metadata defining an object stored elsewhere. Used by the LFS
1271 delimited metadata defining an object stored elsewhere. Used by the LFS
1270 extension.
1272 extension.
1271
1273
1272 For historical reasons, the integer values are identical to revlog version
1274 For historical reasons, the integer values are identical to revlog version
1273 1 per-revision storage flags and correspond to bits being set in this
1275 1 per-revision storage flags and correspond to bits being set in this
1274 2-byte field. Bits were allocated starting from the most-significant bit,
1276 2-byte field. Bits were allocated starting from the most-significant bit,
1275 hence the reverse ordering and allocation of these flags.
1277 hence the reverse ordering and allocation of these flags.
1276
1278
1277 Changeset Segment
1279 Changeset Segment
1278 =================
1280 =================
1279
1281
1280 The *changeset segment* consists of a single *delta group* holding
1282 The *changeset segment* consists of a single *delta group* holding
1281 changelog data. The *empty chunk* at the end of the *delta group* denotes
1283 changelog data. The *empty chunk* at the end of the *delta group* denotes
1282 the boundary to the *manifest segment*.
1284 the boundary to the *manifest segment*.
1283
1285
1284 Manifest Segment
1286 Manifest Segment
1285 ================
1287 ================
1286
1288
1287 The *manifest segment* consists of a single *delta group* holding manifest
1289 The *manifest segment* consists of a single *delta group* holding manifest
1288 data. If treemanifests are in use, it contains only the manifest for the
1290 data. If treemanifests are in use, it contains only the manifest for the
1289 root directory of the repository. Otherwise, it contains the entire
1291 root directory of the repository. Otherwise, it contains the entire
1290 manifest data. The *empty chunk* at the end of the *delta group* denotes
1292 manifest data. The *empty chunk* at the end of the *delta group* denotes
1291 the boundary to the next segment (either the *treemanifests segment* or
1293 the boundary to the next segment (either the *treemanifests segment* or
1292 the *filelogs segment*, depending on version and the request options).
1294 the *filelogs segment*, depending on version and the request options).
1293
1295
1294 Treemanifests Segment
1296 Treemanifests Segment
1295 ---------------------
1297 ---------------------
1296
1298
1297 The *treemanifests segment* only exists in changegroup version "3", and
1299 The *treemanifests segment* only exists in changegroup version "3", and
1298 only if the 'treemanifest' param is part of the bundle2 changegroup part
1300 only if the 'treemanifest' param is part of the bundle2 changegroup part
1299 (it is not possible to use changegroup version 3 outside of bundle2).
1301 (it is not possible to use changegroup version 3 outside of bundle2).
1300 Aside from the filenames in the *treemanifests segment* containing a
1302 Aside from the filenames in the *treemanifests segment* containing a
1301 trailing "/" character, it behaves identically to the *filelogs segment*
1303 trailing "/" character, it behaves identically to the *filelogs segment*
1302 (see below). The final sub-segment is followed by an *empty chunk*
1304 (see below). The final sub-segment is followed by an *empty chunk*
1303 (logically, a sub-segment with filename size 0). This denotes the boundary
1305 (logically, a sub-segment with filename size 0). This denotes the boundary
1304 to the *filelogs segment*.
1306 to the *filelogs segment*.
1305
1307
1306 Filelogs Segment
1308 Filelogs Segment
1307 ================
1309 ================
1308
1310
1309 The *filelogs segment* consists of multiple sub-segments, each
1311 The *filelogs segment* consists of multiple sub-segments, each
1310 corresponding to an individual file whose data is being described:
1312 corresponding to an individual file whose data is being described:
1311
1313
1312 +--------------------------------------------------+
1314 +--------------------------------------------------+
1313 | | | | | |
1315 | | | | | |
1314 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
1316 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
1315 | | | | | (4 bytes) |
1317 | | | | | (4 bytes) |
1316 | | | | | |
1318 | | | | | |
1317 +--------------------------------------------------+
1319 +--------------------------------------------------+
1318
1320
1319 The final filelog sub-segment is followed by an *empty chunk* (logically,
1321 The final filelog sub-segment is followed by an *empty chunk* (logically,
1320 a sub-segment with filename size 0). This denotes the end of the segment
1322 a sub-segment with filename size 0). This denotes the end of the segment
1321 and of the overall changegroup.
1323 and of the overall changegroup.
1322
1324
1323 Each filelog sub-segment consists of the following:
1325 Each filelog sub-segment consists of the following:
1324
1326
1325 +------------------------------------------------------+
1327 +------------------------------------------------------+
1326 | | | |
1328 | | | |
1327 | filename length | filename | delta group |
1329 | filename length | filename | delta group |
1328 | (4 bytes) | (<length - 4> bytes) | (various) |
1330 | (4 bytes) | (<length - 4> bytes) | (various) |
1329 | | | |
1331 | | | |
1330 +------------------------------------------------------+
1332 +------------------------------------------------------+
1331
1333
1332 That is, a *chunk* consisting of the filename (not terminated or padded)
1334 That is, a *chunk* consisting of the filename (not terminated or padded)
1333 followed by N chunks constituting the *delta group* for this file. The
1335 followed by N chunks constituting the *delta group* for this file. The
1334 *empty chunk* at the end of each *delta group* denotes the boundary to the
1336 *empty chunk* at the end of each *delta group* denotes the boundary to the
1335 next filelog sub-segment.
1337 next filelog sub-segment.
1336
1338
1337 non-existent subtopics print an error
1339 non-existent subtopics print an error
1338
1340
1339 $ hg help internals.foo
1341 $ hg help internals.foo
1340 abort: no such help topic: internals.foo
1342 abort: no such help topic: internals.foo
1341 (try 'hg help --keyword foo')
1343 (try 'hg help --keyword foo')
1342 [255]
1344 [255]
1343
1345
1344 test advanced, deprecated and experimental options are hidden in command help
1346 test advanced, deprecated and experimental options are hidden in command help
1345 $ hg help debugoptADV
1347 $ hg help debugoptADV
1346 hg debugoptADV
1348 hg debugoptADV
1347
1349
1348 (no help text available)
1350 (no help text available)
1349
1351
1350 options:
1352 options:
1351
1353
1352 (some details hidden, use --verbose to show complete help)
1354 (some details hidden, use --verbose to show complete help)
1353 $ hg help debugoptDEP
1355 $ hg help debugoptDEP
1354 hg debugoptDEP
1356 hg debugoptDEP
1355
1357
1356 (no help text available)
1358 (no help text available)
1357
1359
1358 options:
1360 options:
1359
1361
1360 (some details hidden, use --verbose to show complete help)
1362 (some details hidden, use --verbose to show complete help)
1361
1363
1362 $ hg help debugoptEXP
1364 $ hg help debugoptEXP
1363 hg debugoptEXP
1365 hg debugoptEXP
1364
1366
1365 (no help text available)
1367 (no help text available)
1366
1368
1367 options:
1369 options:
1368
1370
1369 (some details hidden, use --verbose to show complete help)
1371 (some details hidden, use --verbose to show complete help)
1370
1372
1371 test advanced, deprecated and experimental options are shown with -v
1373 test advanced, deprecated and experimental options are shown with -v
1372 $ hg help -v debugoptADV | grep aopt
1374 $ hg help -v debugoptADV | grep aopt
1373 --aopt option is (ADVANCED)
1375 --aopt option is (ADVANCED)
1374 $ hg help -v debugoptDEP | grep dopt
1376 $ hg help -v debugoptDEP | grep dopt
1375 --dopt option is (DEPRECATED)
1377 --dopt option is (DEPRECATED)
1376 $ hg help -v debugoptEXP | grep eopt
1378 $ hg help -v debugoptEXP | grep eopt
1377 --eopt option is (EXPERIMENTAL)
1379 --eopt option is (EXPERIMENTAL)
1378
1380
1379 #if gettext
1381 #if gettext
1380 test deprecated option is hidden with translation with untranslated description
1382 test deprecated option is hidden with translation with untranslated description
1381 (use many globy for not failing on changed transaction)
1383 (use many globy for not failing on changed transaction)
1382 $ LANGUAGE=sv hg help debugoptDEP
1384 $ LANGUAGE=sv hg help debugoptDEP
1383 hg debugoptDEP
1385 hg debugoptDEP
1384
1386
1385 (*) (glob)
1387 (*) (glob)
1386
1388
1387 options:
1389 options:
1388
1390
1389 (some details hidden, use --verbose to show complete help)
1391 (some details hidden, use --verbose to show complete help)
1390 #endif
1392 #endif
1391
1393
1392 Test commands that collide with topics (issue4240)
1394 Test commands that collide with topics (issue4240)
1393
1395
1394 $ hg config -hq
1396 $ hg config -hq
1395 hg config [-u] [NAME]...
1397 hg config [-u] [NAME]...
1396
1398
1397 show combined config settings from all hgrc files
1399 show combined config settings from all hgrc files
1398 $ hg showconfig -hq
1400 $ hg showconfig -hq
1399 hg config [-u] [NAME]...
1401 hg config [-u] [NAME]...
1400
1402
1401 show combined config settings from all hgrc files
1403 show combined config settings from all hgrc files
1402
1404
1403 Test a help topic
1405 Test a help topic
1404
1406
1405 $ hg help dates
1407 $ hg help dates
1406 Date Formats
1408 Date Formats
1407 """"""""""""
1409 """"""""""""
1408
1410
1409 Some commands allow the user to specify a date, e.g.:
1411 Some commands allow the user to specify a date, e.g.:
1410
1412
1411 - backout, commit, import, tag: Specify the commit date.
1413 - backout, commit, import, tag: Specify the commit date.
1412 - log, revert, update: Select revision(s) by date.
1414 - log, revert, update: Select revision(s) by date.
1413
1415
1414 Many date formats are valid. Here are some examples:
1416 Many date formats are valid. Here are some examples:
1415
1417
1416 - "Wed Dec 6 13:18:29 2006" (local timezone assumed)
1418 - "Wed Dec 6 13:18:29 2006" (local timezone assumed)
1417 - "Dec 6 13:18 -0600" (year assumed, time offset provided)
1419 - "Dec 6 13:18 -0600" (year assumed, time offset provided)
1418 - "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
1420 - "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
1419 - "Dec 6" (midnight)
1421 - "Dec 6" (midnight)
1420 - "13:18" (today assumed)
1422 - "13:18" (today assumed)
1421 - "3:39" (3:39AM assumed)
1423 - "3:39" (3:39AM assumed)
1422 - "3:39pm" (15:39)
1424 - "3:39pm" (15:39)
1423 - "2006-12-06 13:18:29" (ISO 8601 format)
1425 - "2006-12-06 13:18:29" (ISO 8601 format)
1424 - "2006-12-6 13:18"
1426 - "2006-12-6 13:18"
1425 - "2006-12-6"
1427 - "2006-12-6"
1426 - "12-6"
1428 - "12-6"
1427 - "12/6"
1429 - "12/6"
1428 - "12/6/6" (Dec 6 2006)
1430 - "12/6/6" (Dec 6 2006)
1429 - "today" (midnight)
1431 - "today" (midnight)
1430 - "yesterday" (midnight)
1432 - "yesterday" (midnight)
1431 - "now" - right now
1433 - "now" - right now
1432
1434
1433 Lastly, there is Mercurial's internal format:
1435 Lastly, there is Mercurial's internal format:
1434
1436
1435 - "1165411109 0" (Wed Dec 6 13:18:29 2006 UTC)
1437 - "1165411109 0" (Wed Dec 6 13:18:29 2006 UTC)
1436
1438
1437 This is the internal representation format for dates. The first number is
1439 This is the internal representation format for dates. The first number is
1438 the number of seconds since the epoch (1970-01-01 00:00 UTC). The second
1440 the number of seconds since the epoch (1970-01-01 00:00 UTC). The second
1439 is the offset of the local timezone, in seconds west of UTC (negative if
1441 is the offset of the local timezone, in seconds west of UTC (negative if
1440 the timezone is east of UTC).
1442 the timezone is east of UTC).
1441
1443
1442 The log command also accepts date ranges:
1444 The log command also accepts date ranges:
1443
1445
1444 - "<DATE" - at or before a given date/time
1446 - "<DATE" - at or before a given date/time
1445 - ">DATE" - on or after a given date/time
1447 - ">DATE" - on or after a given date/time
1446 - "DATE to DATE" - a date range, inclusive
1448 - "DATE to DATE" - a date range, inclusive
1447 - "-DAYS" - within a given number of days from today
1449 - "-DAYS" - within a given number of days from today
1448
1450
1449 Test repeated config section name
1451 Test repeated config section name
1450
1452
1451 $ hg help config.host
1453 $ hg help config.host
1452 "http_proxy.host"
1454 "http_proxy.host"
1453 Host name and (optional) port of the proxy server, for example
1455 Host name and (optional) port of the proxy server, for example
1454 "myproxy:8000".
1456 "myproxy:8000".
1455
1457
1456 "smtp.host"
1458 "smtp.host"
1457 Host name of mail server, e.g. "mail.example.com".
1459 Host name of mail server, e.g. "mail.example.com".
1458
1460
1459
1461
1460 Test section name with dot
1462 Test section name with dot
1461
1463
1462 $ hg help config.ui.username
1464 $ hg help config.ui.username
1463 "ui.username"
1465 "ui.username"
1464 The committer of a changeset created when running "commit". Typically
1466 The committer of a changeset created when running "commit". Typically
1465 a person's name and email address, e.g. "Fred Widget
1467 a person's name and email address, e.g. "Fred Widget
1466 <fred@example.com>". Environment variables in the username are
1468 <fred@example.com>". Environment variables in the username are
1467 expanded.
1469 expanded.
1468
1470
1469 (default: "$EMAIL" or "username@hostname". If the username in hgrc is
1471 (default: "$EMAIL" or "username@hostname". If the username in hgrc is
1470 empty, e.g. if the system admin set "username =" in the system hgrc,
1472 empty, e.g. if the system admin set "username =" in the system hgrc,
1471 it has to be specified manually or in a different hgrc file)
1473 it has to be specified manually or in a different hgrc file)
1472
1474
1473
1475
1474 $ hg help config.annotate.git
1476 $ hg help config.annotate.git
1475 abort: help section not found: config.annotate.git
1477 abort: help section not found: config.annotate.git
1476 [255]
1478 [255]
1477
1479
1478 $ hg help config.update.check
1480 $ hg help config.update.check
1479 "commands.update.check"
1481 "commands.update.check"
1480 Determines what level of checking 'hg update' will perform before
1482 Determines what level of checking 'hg update' will perform before
1481 moving to a destination revision. Valid values are "abort", "none",
1483 moving to a destination revision. Valid values are "abort", "none",
1482 "linear", and "noconflict". "abort" always fails if the working
1484 "linear", and "noconflict". "abort" always fails if the working
1483 directory has uncommitted changes. "none" performs no checking, and
1485 directory has uncommitted changes. "none" performs no checking, and
1484 may result in a merge with uncommitted changes. "linear" allows any
1486 may result in a merge with uncommitted changes. "linear" allows any
1485 update as long as it follows a straight line in the revision history,
1487 update as long as it follows a straight line in the revision history,
1486 and may trigger a merge with uncommitted changes. "noconflict" will
1488 and may trigger a merge with uncommitted changes. "noconflict" will
1487 allow any update which would not trigger a merge with uncommitted
1489 allow any update which would not trigger a merge with uncommitted
1488 changes, if any are present. (default: "linear")
1490 changes, if any are present. (default: "linear")
1489
1491
1490
1492
1491 $ hg help config.commands.update.check
1493 $ hg help config.commands.update.check
1492 "commands.update.check"
1494 "commands.update.check"
1493 Determines what level of checking 'hg update' will perform before
1495 Determines what level of checking 'hg update' will perform before
1494 moving to a destination revision. Valid values are "abort", "none",
1496 moving to a destination revision. Valid values are "abort", "none",
1495 "linear", and "noconflict". "abort" always fails if the working
1497 "linear", and "noconflict". "abort" always fails if the working
1496 directory has uncommitted changes. "none" performs no checking, and
1498 directory has uncommitted changes. "none" performs no checking, and
1497 may result in a merge with uncommitted changes. "linear" allows any
1499 may result in a merge with uncommitted changes. "linear" allows any
1498 update as long as it follows a straight line in the revision history,
1500 update as long as it follows a straight line in the revision history,
1499 and may trigger a merge with uncommitted changes. "noconflict" will
1501 and may trigger a merge with uncommitted changes. "noconflict" will
1500 allow any update which would not trigger a merge with uncommitted
1502 allow any update which would not trigger a merge with uncommitted
1501 changes, if any are present. (default: "linear")
1503 changes, if any are present. (default: "linear")
1502
1504
1503
1505
1504 $ hg help config.ommands.update.check
1506 $ hg help config.ommands.update.check
1505 abort: help section not found: config.ommands.update.check
1507 abort: help section not found: config.ommands.update.check
1506 [255]
1508 [255]
1507
1509
1508 Unrelated trailing paragraphs shouldn't be included
1510 Unrelated trailing paragraphs shouldn't be included
1509
1511
1510 $ hg help config.extramsg | grep '^$'
1512 $ hg help config.extramsg | grep '^$'
1511
1513
1512
1514
1513 Test capitalized section name
1515 Test capitalized section name
1514
1516
1515 $ hg help scripting.HGPLAIN > /dev/null
1517 $ hg help scripting.HGPLAIN > /dev/null
1516
1518
1517 Help subsection:
1519 Help subsection:
1518
1520
1519 $ hg help config.charsets |grep "Email example:" > /dev/null
1521 $ hg help config.charsets |grep "Email example:" > /dev/null
1520 [1]
1522 [1]
1521
1523
1522 Show nested definitions
1524 Show nested definitions
1523 ("profiling.type"[break]"ls"[break]"stat"[break])
1525 ("profiling.type"[break]"ls"[break]"stat"[break])
1524
1526
1525 $ hg help config.type | egrep '^$'|wc -l
1527 $ hg help config.type | egrep '^$'|wc -l
1526 \s*3 (re)
1528 \s*3 (re)
1527
1529
1528 $ hg help config.profiling.type.ls
1530 $ hg help config.profiling.type.ls
1529 "profiling.type.ls"
1531 "profiling.type.ls"
1530 Use Python's built-in instrumenting profiler. This profiler works on
1532 Use Python's built-in instrumenting profiler. This profiler works on
1531 all platforms, but each line number it reports is the first line of
1533 all platforms, but each line number it reports is the first line of
1532 a function. This restriction makes it difficult to identify the
1534 a function. This restriction makes it difficult to identify the
1533 expensive parts of a non-trivial function.
1535 expensive parts of a non-trivial function.
1534
1536
1535
1537
1536 Separate sections from subsections
1538 Separate sections from subsections
1537
1539
1538 $ hg help config.format | egrep '^ ("|-)|^\s*$' | uniq
1540 $ hg help config.format | egrep '^ ("|-)|^\s*$' | uniq
1539 "format"
1541 "format"
1540 --------
1542 --------
1541
1543
1542 "usegeneraldelta"
1544 "usegeneraldelta"
1543
1545
1544 "dotencode"
1546 "dotencode"
1545
1547
1546 "usefncache"
1548 "usefncache"
1547
1549
1548 "usestore"
1550 "usestore"
1549
1551
1550 "sparse-revlog"
1552 "sparse-revlog"
1551
1553
1552 "revlog-compression"
1554 "revlog-compression"
1553
1555
1554 "bookmarks-in-store"
1556 "bookmarks-in-store"
1555
1557
1556 "profiling"
1558 "profiling"
1557 -----------
1559 -----------
1558
1560
1559 "format"
1561 "format"
1560
1562
1561 "progress"
1563 "progress"
1562 ----------
1564 ----------
1563
1565
1564 "format"
1566 "format"
1565
1567
1566
1568
1567 Last item in help config.*:
1569 Last item in help config.*:
1568
1570
1569 $ hg help config.`hg help config|grep '^ "'| \
1571 $ hg help config.`hg help config|grep '^ "'| \
1570 > tail -1|sed 's![ "]*!!g'`| \
1572 > tail -1|sed 's![ "]*!!g'`| \
1571 > grep 'hg help -c config' > /dev/null
1573 > grep 'hg help -c config' > /dev/null
1572 [1]
1574 [1]
1573
1575
1574 note to use help -c for general hg help config:
1576 note to use help -c for general hg help config:
1575
1577
1576 $ hg help config |grep 'hg help -c config' > /dev/null
1578 $ hg help config |grep 'hg help -c config' > /dev/null
1577
1579
1578 Test templating help
1580 Test templating help
1579
1581
1580 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1582 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1581 desc String. The text of the changeset description.
1583 desc String. The text of the changeset description.
1582 diffstat String. Statistics of changes with the following format:
1584 diffstat String. Statistics of changes with the following format:
1583 firstline Any text. Returns the first line of text.
1585 firstline Any text. Returns the first line of text.
1584 nonempty Any text. Returns '(none)' if the string is empty.
1586 nonempty Any text. Returns '(none)' if the string is empty.
1585
1587
1586 Test deprecated items
1588 Test deprecated items
1587
1589
1588 $ hg help -v templating | grep currentbookmark
1590 $ hg help -v templating | grep currentbookmark
1589 currentbookmark
1591 currentbookmark
1590 $ hg help templating | (grep currentbookmark || true)
1592 $ hg help templating | (grep currentbookmark || true)
1591
1593
1592 Test help hooks
1594 Test help hooks
1593
1595
1594 $ cat > helphook1.py <<EOF
1596 $ cat > helphook1.py <<EOF
1595 > from mercurial import help
1597 > from mercurial import help
1596 >
1598 >
1597 > def rewrite(ui, topic, doc):
1599 > def rewrite(ui, topic, doc):
1598 > return doc + b'\nhelphook1\n'
1600 > return doc + b'\nhelphook1\n'
1599 >
1601 >
1600 > def extsetup(ui):
1602 > def extsetup(ui):
1601 > help.addtopichook(b'revisions', rewrite)
1603 > help.addtopichook(b'revisions', rewrite)
1602 > EOF
1604 > EOF
1603 $ cat > helphook2.py <<EOF
1605 $ cat > helphook2.py <<EOF
1604 > from mercurial import help
1606 > from mercurial import help
1605 >
1607 >
1606 > def rewrite(ui, topic, doc):
1608 > def rewrite(ui, topic, doc):
1607 > return doc + b'\nhelphook2\n'
1609 > return doc + b'\nhelphook2\n'
1608 >
1610 >
1609 > def extsetup(ui):
1611 > def extsetup(ui):
1610 > help.addtopichook(b'revisions', rewrite)
1612 > help.addtopichook(b'revisions', rewrite)
1611 > EOF
1613 > EOF
1612 $ echo '[extensions]' >> $HGRCPATH
1614 $ echo '[extensions]' >> $HGRCPATH
1613 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1615 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1614 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1616 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1615 $ hg help revsets | grep helphook
1617 $ hg help revsets | grep helphook
1616 helphook1
1618 helphook1
1617 helphook2
1619 helphook2
1618
1620
1619 help -c should only show debug --debug
1621 help -c should only show debug --debug
1620
1622
1621 $ hg help -c --debug|egrep debug|wc -l|egrep '^\s*0\s*$'
1623 $ hg help -c --debug|egrep debug|wc -l|egrep '^\s*0\s*$'
1622 [1]
1624 [1]
1623
1625
1624 help -c should only show deprecated for -v
1626 help -c should only show deprecated for -v
1625
1627
1626 $ hg help -c -v|egrep DEPRECATED|wc -l|egrep '^\s*0\s*$'
1628 $ hg help -c -v|egrep DEPRECATED|wc -l|egrep '^\s*0\s*$'
1627 [1]
1629 [1]
1628
1630
1629 Test -s / --system
1631 Test -s / --system
1630
1632
1631 $ hg help config.files -s windows |grep 'etc/mercurial' | \
1633 $ hg help config.files -s windows |grep 'etc/mercurial' | \
1632 > wc -l | sed -e 's/ //g'
1634 > wc -l | sed -e 's/ //g'
1633 0
1635 0
1634 $ hg help config.files --system unix | grep 'USER' | \
1636 $ hg help config.files --system unix | grep 'USER' | \
1635 > wc -l | sed -e 's/ //g'
1637 > wc -l | sed -e 's/ //g'
1636 0
1638 0
1637
1639
1638 Test -e / -c / -k combinations
1640 Test -e / -c / -k combinations
1639
1641
1640 $ hg help -c|egrep '^[A-Z].*:|^ debug'
1642 $ hg help -c|egrep '^[A-Z].*:|^ debug'
1641 Commands:
1643 Commands:
1642 $ hg help -e|egrep '^[A-Z].*:|^ debug'
1644 $ hg help -e|egrep '^[A-Z].*:|^ debug'
1643 Extensions:
1645 Extensions:
1644 $ hg help -k|egrep '^[A-Z].*:|^ debug'
1646 $ hg help -k|egrep '^[A-Z].*:|^ debug'
1645 Topics:
1647 Topics:
1646 Commands:
1648 Commands:
1647 Extensions:
1649 Extensions:
1648 Extension Commands:
1650 Extension Commands:
1649 $ hg help -c schemes
1651 $ hg help -c schemes
1650 abort: no such help topic: schemes
1652 abort: no such help topic: schemes
1651 (try 'hg help --keyword schemes')
1653 (try 'hg help --keyword schemes')
1652 [255]
1654 [255]
1653 $ hg help -e schemes |head -1
1655 $ hg help -e schemes |head -1
1654 schemes extension - extend schemes with shortcuts to repository swarms
1656 schemes extension - extend schemes with shortcuts to repository swarms
1655 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1657 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1656 Commands:
1658 Commands:
1657 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1659 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1658 Extensions:
1660 Extensions:
1659 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1661 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1660 Extensions:
1662 Extensions:
1661 Commands:
1663 Commands:
1662 $ hg help -c commit > /dev/null
1664 $ hg help -c commit > /dev/null
1663 $ hg help -e -c commit > /dev/null
1665 $ hg help -e -c commit > /dev/null
1664 $ hg help -e commit
1666 $ hg help -e commit
1665 abort: no such help topic: commit
1667 abort: no such help topic: commit
1666 (try 'hg help --keyword commit')
1668 (try 'hg help --keyword commit')
1667 [255]
1669 [255]
1668
1670
1669 Test keyword search help
1671 Test keyword search help
1670
1672
1671 $ cat > prefixedname.py <<EOF
1673 $ cat > prefixedname.py <<EOF
1672 > '''matched against word "clone"
1674 > '''matched against word "clone"
1673 > '''
1675 > '''
1674 > EOF
1676 > EOF
1675 $ echo '[extensions]' >> $HGRCPATH
1677 $ echo '[extensions]' >> $HGRCPATH
1676 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1678 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1677 $ hg help -k clone
1679 $ hg help -k clone
1678 Topics:
1680 Topics:
1679
1681
1680 config Configuration Files
1682 config Configuration Files
1681 extensions Using Additional Features
1683 extensions Using Additional Features
1682 glossary Glossary
1684 glossary Glossary
1683 phases Working with Phases
1685 phases Working with Phases
1684 subrepos Subrepositories
1686 subrepos Subrepositories
1685 urls URL Paths
1687 urls URL Paths
1686
1688
1687 Commands:
1689 Commands:
1688
1690
1689 bookmarks create a new bookmark or list existing bookmarks
1691 bookmarks create a new bookmark or list existing bookmarks
1690 clone make a copy of an existing repository
1692 clone make a copy of an existing repository
1691 paths show aliases for remote repositories
1693 paths show aliases for remote repositories
1692 pull pull changes from the specified source
1694 pull pull changes from the specified source
1693 update update working directory (or switch revisions)
1695 update update working directory (or switch revisions)
1694
1696
1695 Extensions:
1697 Extensions:
1696
1698
1697 clonebundles advertise pre-generated bundles to seed clones
1699 clonebundles advertise pre-generated bundles to seed clones
1698 narrow create clones which fetch history data for subset of files
1700 narrow create clones which fetch history data for subset of files
1699 (EXPERIMENTAL)
1701 (EXPERIMENTAL)
1700 prefixedname matched against word "clone"
1702 prefixedname matched against word "clone"
1701 relink recreates hardlinks between repository clones
1703 relink recreates hardlinks between repository clones
1702
1704
1703 Extension Commands:
1705 Extension Commands:
1704
1706
1705 qclone clone main and patch repository at same time
1707 qclone clone main and patch repository at same time
1706
1708
1707 Test unfound topic
1709 Test unfound topic
1708
1710
1709 $ hg help nonexistingtopicthatwillneverexisteverever
1711 $ hg help nonexistingtopicthatwillneverexisteverever
1710 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1712 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1711 (try 'hg help --keyword nonexistingtopicthatwillneverexisteverever')
1713 (try 'hg help --keyword nonexistingtopicthatwillneverexisteverever')
1712 [255]
1714 [255]
1713
1715
1714 Test unfound keyword
1716 Test unfound keyword
1715
1717
1716 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1718 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1717 abort: no matches
1719 abort: no matches
1718 (try 'hg help' for a list of topics)
1720 (try 'hg help' for a list of topics)
1719 [255]
1721 [255]
1720
1722
1721 Test omit indicating for help
1723 Test omit indicating for help
1722
1724
1723 $ cat > addverboseitems.py <<EOF
1725 $ cat > addverboseitems.py <<EOF
1724 > r'''extension to test omit indicating.
1726 > r'''extension to test omit indicating.
1725 >
1727 >
1726 > This paragraph is never omitted (for extension)
1728 > This paragraph is never omitted (for extension)
1727 >
1729 >
1728 > .. container:: verbose
1730 > .. container:: verbose
1729 >
1731 >
1730 > This paragraph is omitted,
1732 > This paragraph is omitted,
1731 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1733 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1732 >
1734 >
1733 > This paragraph is never omitted, too (for extension)
1735 > This paragraph is never omitted, too (for extension)
1734 > '''
1736 > '''
1735 > from __future__ import absolute_import
1737 > from __future__ import absolute_import
1736 > from mercurial import commands, help
1738 > from mercurial import commands, help
1737 > testtopic = br"""This paragraph is never omitted (for topic).
1739 > testtopic = br"""This paragraph is never omitted (for topic).
1738 >
1740 >
1739 > .. container:: verbose
1741 > .. container:: verbose
1740 >
1742 >
1741 > This paragraph is omitted,
1743 > This paragraph is omitted,
1742 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1744 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1743 >
1745 >
1744 > This paragraph is never omitted, too (for topic)
1746 > This paragraph is never omitted, too (for topic)
1745 > """
1747 > """
1746 > def extsetup(ui):
1748 > def extsetup(ui):
1747 > help.helptable.append(([b"topic-containing-verbose"],
1749 > help.helptable.append(([b"topic-containing-verbose"],
1748 > b"This is the topic to test omit indicating.",
1750 > b"This is the topic to test omit indicating.",
1749 > lambda ui: testtopic))
1751 > lambda ui: testtopic))
1750 > EOF
1752 > EOF
1751 $ echo '[extensions]' >> $HGRCPATH
1753 $ echo '[extensions]' >> $HGRCPATH
1752 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1754 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1753 $ hg help addverboseitems
1755 $ hg help addverboseitems
1754 addverboseitems extension - extension to test omit indicating.
1756 addverboseitems extension - extension to test omit indicating.
1755
1757
1756 This paragraph is never omitted (for extension)
1758 This paragraph is never omitted (for extension)
1757
1759
1758 This paragraph is never omitted, too (for extension)
1760 This paragraph is never omitted, too (for extension)
1759
1761
1760 (some details hidden, use --verbose to show complete help)
1762 (some details hidden, use --verbose to show complete help)
1761
1763
1762 no commands defined
1764 no commands defined
1763 $ hg help -v addverboseitems
1765 $ hg help -v addverboseitems
1764 addverboseitems extension - extension to test omit indicating.
1766 addverboseitems extension - extension to test omit indicating.
1765
1767
1766 This paragraph is never omitted (for extension)
1768 This paragraph is never omitted (for extension)
1767
1769
1768 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1770 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1769 extension)
1771 extension)
1770
1772
1771 This paragraph is never omitted, too (for extension)
1773 This paragraph is never omitted, too (for extension)
1772
1774
1773 no commands defined
1775 no commands defined
1774 $ hg help topic-containing-verbose
1776 $ hg help topic-containing-verbose
1775 This is the topic to test omit indicating.
1777 This is the topic to test omit indicating.
1776 """"""""""""""""""""""""""""""""""""""""""
1778 """"""""""""""""""""""""""""""""""""""""""
1777
1779
1778 This paragraph is never omitted (for topic).
1780 This paragraph is never omitted (for topic).
1779
1781
1780 This paragraph is never omitted, too (for topic)
1782 This paragraph is never omitted, too (for topic)
1781
1783
1782 (some details hidden, use --verbose to show complete help)
1784 (some details hidden, use --verbose to show complete help)
1783 $ hg help -v topic-containing-verbose
1785 $ hg help -v topic-containing-verbose
1784 This is the topic to test omit indicating.
1786 This is the topic to test omit indicating.
1785 """"""""""""""""""""""""""""""""""""""""""
1787 """"""""""""""""""""""""""""""""""""""""""
1786
1788
1787 This paragraph is never omitted (for topic).
1789 This paragraph is never omitted (for topic).
1788
1790
1789 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1791 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1790 topic)
1792 topic)
1791
1793
1792 This paragraph is never omitted, too (for topic)
1794 This paragraph is never omitted, too (for topic)
1793
1795
1794 Test section lookup
1796 Test section lookup
1795
1797
1796 $ hg help revset.merge
1798 $ hg help revset.merge
1797 "merge()"
1799 "merge()"
1798 Changeset is a merge changeset.
1800 Changeset is a merge changeset.
1799
1801
1800 $ hg help glossary.dag
1802 $ hg help glossary.dag
1801 DAG
1803 DAG
1802 The repository of changesets of a distributed version control system
1804 The repository of changesets of a distributed version control system
1803 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1805 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1804 of nodes and edges, where nodes correspond to changesets and edges
1806 of nodes and edges, where nodes correspond to changesets and edges
1805 imply a parent -> child relation. This graph can be visualized by
1807 imply a parent -> child relation. This graph can be visualized by
1806 graphical tools such as 'hg log --graph'. In Mercurial, the DAG is
1808 graphical tools such as 'hg log --graph'. In Mercurial, the DAG is
1807 limited by the requirement for children to have at most two parents.
1809 limited by the requirement for children to have at most two parents.
1808
1810
1809
1811
1810 $ hg help hgrc.paths
1812 $ hg help hgrc.paths
1811 "paths"
1813 "paths"
1812 -------
1814 -------
1813
1815
1814 Assigns symbolic names and behavior to repositories.
1816 Assigns symbolic names and behavior to repositories.
1815
1817
1816 Options are symbolic names defining the URL or directory that is the
1818 Options are symbolic names defining the URL or directory that is the
1817 location of the repository. Example:
1819 location of the repository. Example:
1818
1820
1819 [paths]
1821 [paths]
1820 my_server = https://example.com/my_repo
1822 my_server = https://example.com/my_repo
1821 local_path = /home/me/repo
1823 local_path = /home/me/repo
1822
1824
1823 These symbolic names can be used from the command line. To pull from
1825 These symbolic names can be used from the command line. To pull from
1824 "my_server": 'hg pull my_server'. To push to "local_path": 'hg push
1826 "my_server": 'hg pull my_server'. To push to "local_path": 'hg push
1825 local_path'.
1827 local_path'.
1826
1828
1827 Options containing colons (":") denote sub-options that can influence
1829 Options containing colons (":") denote sub-options that can influence
1828 behavior for that specific path. Example:
1830 behavior for that specific path. Example:
1829
1831
1830 [paths]
1832 [paths]
1831 my_server = https://example.com/my_path
1833 my_server = https://example.com/my_path
1832 my_server:pushurl = ssh://example.com/my_path
1834 my_server:pushurl = ssh://example.com/my_path
1833
1835
1834 The following sub-options can be defined:
1836 The following sub-options can be defined:
1835
1837
1836 "pushurl"
1838 "pushurl"
1837 The URL to use for push operations. If not defined, the location
1839 The URL to use for push operations. If not defined, the location
1838 defined by the path's main entry is used.
1840 defined by the path's main entry is used.
1839
1841
1840 "pushrev"
1842 "pushrev"
1841 A revset defining which revisions to push by default.
1843 A revset defining which revisions to push by default.
1842
1844
1843 When 'hg push' is executed without a "-r" argument, the revset defined
1845 When 'hg push' is executed without a "-r" argument, the revset defined
1844 by this sub-option is evaluated to determine what to push.
1846 by this sub-option is evaluated to determine what to push.
1845
1847
1846 For example, a value of "." will push the working directory's revision
1848 For example, a value of "." will push the working directory's revision
1847 by default.
1849 by default.
1848
1850
1849 Revsets specifying bookmarks will not result in the bookmark being
1851 Revsets specifying bookmarks will not result in the bookmark being
1850 pushed.
1852 pushed.
1851
1853
1852 The following special named paths exist:
1854 The following special named paths exist:
1853
1855
1854 "default"
1856 "default"
1855 The URL or directory to use when no source or remote is specified.
1857 The URL or directory to use when no source or remote is specified.
1856
1858
1857 'hg clone' will automatically define this path to the location the
1859 'hg clone' will automatically define this path to the location the
1858 repository was cloned from.
1860 repository was cloned from.
1859
1861
1860 "default-push"
1862 "default-push"
1861 (deprecated) The URL or directory for the default 'hg push' location.
1863 (deprecated) The URL or directory for the default 'hg push' location.
1862 "default:pushurl" should be used instead.
1864 "default:pushurl" should be used instead.
1863
1865
1864 $ hg help glossary.mcguffin
1866 $ hg help glossary.mcguffin
1865 abort: help section not found: glossary.mcguffin
1867 abort: help section not found: glossary.mcguffin
1866 [255]
1868 [255]
1867
1869
1868 $ hg help glossary.mc.guffin
1870 $ hg help glossary.mc.guffin
1869 abort: help section not found: glossary.mc.guffin
1871 abort: help section not found: glossary.mc.guffin
1870 [255]
1872 [255]
1871
1873
1872 $ hg help template.files
1874 $ hg help template.files
1873 files List of strings. All files modified, added, or removed by
1875 files List of strings. All files modified, added, or removed by
1874 this changeset.
1876 this changeset.
1875 files(pattern)
1877 files(pattern)
1876 All files of the current changeset matching the pattern. See
1878 All files of the current changeset matching the pattern. See
1877 'hg help patterns'.
1879 'hg help patterns'.
1878
1880
1879 Test section lookup by translated message
1881 Test section lookup by translated message
1880
1882
1881 str.lower() instead of encoding.lower(str) on translated message might
1883 str.lower() instead of encoding.lower(str) on translated message might
1882 make message meaningless, because some encoding uses 0x41(A) - 0x5a(Z)
1884 make message meaningless, because some encoding uses 0x41(A) - 0x5a(Z)
1883 as the second or later byte of multi-byte character.
1885 as the second or later byte of multi-byte character.
1884
1886
1885 For example, "\x8bL\x98^" (translation of "record" in ja_JP.cp932)
1887 For example, "\x8bL\x98^" (translation of "record" in ja_JP.cp932)
1886 contains 0x4c (L). str.lower() replaces 0x4c(L) by 0x6c(l) and this
1888 contains 0x4c (L). str.lower() replaces 0x4c(L) by 0x6c(l) and this
1887 replacement makes message meaningless.
1889 replacement makes message meaningless.
1888
1890
1889 This tests that section lookup by translated string isn't broken by
1891 This tests that section lookup by translated string isn't broken by
1890 such str.lower().
1892 such str.lower().
1891
1893
1892 $ "$PYTHON" <<EOF
1894 $ "$PYTHON" <<EOF
1893 > def escape(s):
1895 > def escape(s):
1894 > return b''.join(b'\\u%x' % ord(uc) for uc in s.decode('cp932'))
1896 > return b''.join(b'\\u%x' % ord(uc) for uc in s.decode('cp932'))
1895 > # translation of "record" in ja_JP.cp932
1897 > # translation of "record" in ja_JP.cp932
1896 > upper = b"\x8bL\x98^"
1898 > upper = b"\x8bL\x98^"
1897 > # str.lower()-ed section name should be treated as different one
1899 > # str.lower()-ed section name should be treated as different one
1898 > lower = b"\x8bl\x98^"
1900 > lower = b"\x8bl\x98^"
1899 > with open('ambiguous.py', 'wb') as fp:
1901 > with open('ambiguous.py', 'wb') as fp:
1900 > fp.write(b"""# ambiguous section names in ja_JP.cp932
1902 > fp.write(b"""# ambiguous section names in ja_JP.cp932
1901 > u'''summary of extension
1903 > u'''summary of extension
1902 >
1904 >
1903 > %s
1905 > %s
1904 > ----
1906 > ----
1905 >
1907 >
1906 > Upper name should show only this message
1908 > Upper name should show only this message
1907 >
1909 >
1908 > %s
1910 > %s
1909 > ----
1911 > ----
1910 >
1912 >
1911 > Lower name should show only this message
1913 > Lower name should show only this message
1912 >
1914 >
1913 > subsequent section
1915 > subsequent section
1914 > ------------------
1916 > ------------------
1915 >
1917 >
1916 > This should be hidden at 'hg help ambiguous' with section name.
1918 > This should be hidden at 'hg help ambiguous' with section name.
1917 > '''
1919 > '''
1918 > """ % (escape(upper), escape(lower)))
1920 > """ % (escape(upper), escape(lower)))
1919 > EOF
1921 > EOF
1920
1922
1921 $ cat >> $HGRCPATH <<EOF
1923 $ cat >> $HGRCPATH <<EOF
1922 > [extensions]
1924 > [extensions]
1923 > ambiguous = ./ambiguous.py
1925 > ambiguous = ./ambiguous.py
1924 > EOF
1926 > EOF
1925
1927
1926 $ "$PYTHON" <<EOF | sh
1928 $ "$PYTHON" <<EOF | sh
1927 > from mercurial.utils import procutil
1929 > from mercurial.utils import procutil
1928 > upper = b"\x8bL\x98^"
1930 > upper = b"\x8bL\x98^"
1929 > procutil.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % upper)
1931 > procutil.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % upper)
1930 > EOF
1932 > EOF
1931 \x8bL\x98^ (esc)
1933 \x8bL\x98^ (esc)
1932 ----
1934 ----
1933
1935
1934 Upper name should show only this message
1936 Upper name should show only this message
1935
1937
1936
1938
1937 $ "$PYTHON" <<EOF | sh
1939 $ "$PYTHON" <<EOF | sh
1938 > from mercurial.utils import procutil
1940 > from mercurial.utils import procutil
1939 > lower = b"\x8bl\x98^"
1941 > lower = b"\x8bl\x98^"
1940 > procutil.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % lower)
1942 > procutil.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % lower)
1941 > EOF
1943 > EOF
1942 \x8bl\x98^ (esc)
1944 \x8bl\x98^ (esc)
1943 ----
1945 ----
1944
1946
1945 Lower name should show only this message
1947 Lower name should show only this message
1946
1948
1947
1949
1948 $ cat >> $HGRCPATH <<EOF
1950 $ cat >> $HGRCPATH <<EOF
1949 > [extensions]
1951 > [extensions]
1950 > ambiguous = !
1952 > ambiguous = !
1951 > EOF
1953 > EOF
1952
1954
1953 Show help content of disabled extensions
1955 Show help content of disabled extensions
1954
1956
1955 $ cat >> $HGRCPATH <<EOF
1957 $ cat >> $HGRCPATH <<EOF
1956 > [extensions]
1958 > [extensions]
1957 > ambiguous = !./ambiguous.py
1959 > ambiguous = !./ambiguous.py
1958 > EOF
1960 > EOF
1959 $ hg help -e ambiguous
1961 $ hg help -e ambiguous
1960 ambiguous extension - (no help text available)
1962 ambiguous extension - (no help text available)
1961
1963
1962 (use 'hg help extensions' for information on enabling extensions)
1964 (use 'hg help extensions' for information on enabling extensions)
1963
1965
1964 Test dynamic list of merge tools only shows up once
1966 Test dynamic list of merge tools only shows up once
1965 $ hg help merge-tools
1967 $ hg help merge-tools
1966 Merge Tools
1968 Merge Tools
1967 """""""""""
1969 """""""""""
1968
1970
1969 To merge files Mercurial uses merge tools.
1971 To merge files Mercurial uses merge tools.
1970
1972
1971 A merge tool combines two different versions of a file into a merged file.
1973 A merge tool combines two different versions of a file into a merged file.
1972 Merge tools are given the two files and the greatest common ancestor of
1974 Merge tools are given the two files and the greatest common ancestor of
1973 the two file versions, so they can determine the changes made on both
1975 the two file versions, so they can determine the changes made on both
1974 branches.
1976 branches.
1975
1977
1976 Merge tools are used both for 'hg resolve', 'hg merge', 'hg update', 'hg
1978 Merge tools are used both for 'hg resolve', 'hg merge', 'hg update', 'hg
1977 backout' and in several extensions.
1979 backout' and in several extensions.
1978
1980
1979 Usually, the merge tool tries to automatically reconcile the files by
1981 Usually, the merge tool tries to automatically reconcile the files by
1980 combining all non-overlapping changes that occurred separately in the two
1982 combining all non-overlapping changes that occurred separately in the two
1981 different evolutions of the same initial base file. Furthermore, some
1983 different evolutions of the same initial base file. Furthermore, some
1982 interactive merge programs make it easier to manually resolve conflicting
1984 interactive merge programs make it easier to manually resolve conflicting
1983 merges, either in a graphical way, or by inserting some conflict markers.
1985 merges, either in a graphical way, or by inserting some conflict markers.
1984 Mercurial does not include any interactive merge programs but relies on
1986 Mercurial does not include any interactive merge programs but relies on
1985 external tools for that.
1987 external tools for that.
1986
1988
1987 Available merge tools
1989 Available merge tools
1988 =====================
1990 =====================
1989
1991
1990 External merge tools and their properties are configured in the merge-
1992 External merge tools and their properties are configured in the merge-
1991 tools configuration section - see hgrc(5) - but they can often just be
1993 tools configuration section - see hgrc(5) - but they can often just be
1992 named by their executable.
1994 named by their executable.
1993
1995
1994 A merge tool is generally usable if its executable can be found on the
1996 A merge tool is generally usable if its executable can be found on the
1995 system and if it can handle the merge. The executable is found if it is an
1997 system and if it can handle the merge. The executable is found if it is an
1996 absolute or relative executable path or the name of an application in the
1998 absolute or relative executable path or the name of an application in the
1997 executable search path. The tool is assumed to be able to handle the merge
1999 executable search path. The tool is assumed to be able to handle the merge
1998 if it can handle symlinks if the file is a symlink, if it can handle
2000 if it can handle symlinks if the file is a symlink, if it can handle
1999 binary files if the file is binary, and if a GUI is available if the tool
2001 binary files if the file is binary, and if a GUI is available if the tool
2000 requires a GUI.
2002 requires a GUI.
2001
2003
2002 There are some internal merge tools which can be used. The internal merge
2004 There are some internal merge tools which can be used. The internal merge
2003 tools are:
2005 tools are:
2004
2006
2005 ":dump"
2007 ":dump"
2006 Creates three versions of the files to merge, containing the contents of
2008 Creates three versions of the files to merge, containing the contents of
2007 local, other and base. These files can then be used to perform a merge
2009 local, other and base. These files can then be used to perform a merge
2008 manually. If the file to be merged is named "a.txt", these files will
2010 manually. If the file to be merged is named "a.txt", these files will
2009 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
2011 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
2010 they will be placed in the same directory as "a.txt".
2012 they will be placed in the same directory as "a.txt".
2011
2013
2012 This implies premerge. Therefore, files aren't dumped, if premerge runs
2014 This implies premerge. Therefore, files aren't dumped, if premerge runs
2013 successfully. Use :forcedump to forcibly write files out.
2015 successfully. Use :forcedump to forcibly write files out.
2014
2016
2015 (actual capabilities: binary, symlink)
2017 (actual capabilities: binary, symlink)
2016
2018
2017 ":fail"
2019 ":fail"
2018 Rather than attempting to merge files that were modified on both
2020 Rather than attempting to merge files that were modified on both
2019 branches, it marks them as unresolved. The resolve command must be used
2021 branches, it marks them as unresolved. The resolve command must be used
2020 to resolve these conflicts.
2022 to resolve these conflicts.
2021
2023
2022 (actual capabilities: binary, symlink)
2024 (actual capabilities: binary, symlink)
2023
2025
2024 ":forcedump"
2026 ":forcedump"
2025 Creates three versions of the files as same as :dump, but omits
2027 Creates three versions of the files as same as :dump, but omits
2026 premerge.
2028 premerge.
2027
2029
2028 (actual capabilities: binary, symlink)
2030 (actual capabilities: binary, symlink)
2029
2031
2030 ":local"
2032 ":local"
2031 Uses the local 'p1()' version of files as the merged version.
2033 Uses the local 'p1()' version of files as the merged version.
2032
2034
2033 (actual capabilities: binary, symlink)
2035 (actual capabilities: binary, symlink)
2034
2036
2035 ":merge"
2037 ":merge"
2036 Uses the internal non-interactive simple merge algorithm for merging
2038 Uses the internal non-interactive simple merge algorithm for merging
2037 files. It will fail if there are any conflicts and leave markers in the
2039 files. It will fail if there are any conflicts and leave markers in the
2038 partially merged file. Markers will have two sections, one for each side
2040 partially merged file. Markers will have two sections, one for each side
2039 of merge.
2041 of merge.
2040
2042
2041 ":merge-local"
2043 ":merge-local"
2042 Like :merge, but resolve all conflicts non-interactively in favor of the
2044 Like :merge, but resolve all conflicts non-interactively in favor of the
2043 local 'p1()' changes.
2045 local 'p1()' changes.
2044
2046
2045 ":merge-other"
2047 ":merge-other"
2046 Like :merge, but resolve all conflicts non-interactively in favor of the
2048 Like :merge, but resolve all conflicts non-interactively in favor of the
2047 other 'p2()' changes.
2049 other 'p2()' changes.
2048
2050
2049 ":merge3"
2051 ":merge3"
2050 Uses the internal non-interactive simple merge algorithm for merging
2052 Uses the internal non-interactive simple merge algorithm for merging
2051 files. It will fail if there are any conflicts and leave markers in the
2053 files. It will fail if there are any conflicts and leave markers in the
2052 partially merged file. Marker will have three sections, one from each
2054 partially merged file. Marker will have three sections, one from each
2053 side of the merge and one for the base content.
2055 side of the merge and one for the base content.
2054
2056
2055 ":other"
2057 ":other"
2056 Uses the other 'p2()' version of files as the merged version.
2058 Uses the other 'p2()' version of files as the merged version.
2057
2059
2058 (actual capabilities: binary, symlink)
2060 (actual capabilities: binary, symlink)
2059
2061
2060 ":prompt"
2062 ":prompt"
2061 Asks the user which of the local 'p1()' or the other 'p2()' version to
2063 Asks the user which of the local 'p1()' or the other 'p2()' version to
2062 keep as the merged version.
2064 keep as the merged version.
2063
2065
2064 (actual capabilities: binary, symlink)
2066 (actual capabilities: binary, symlink)
2065
2067
2066 ":tagmerge"
2068 ":tagmerge"
2067 Uses the internal tag merge algorithm (experimental).
2069 Uses the internal tag merge algorithm (experimental).
2068
2070
2069 ":union"
2071 ":union"
2070 Uses the internal non-interactive simple merge algorithm for merging
2072 Uses the internal non-interactive simple merge algorithm for merging
2071 files. It will use both left and right sides for conflict regions. No
2073 files. It will use both left and right sides for conflict regions. No
2072 markers are inserted.
2074 markers are inserted.
2073
2075
2074 Internal tools are always available and do not require a GUI but will by
2076 Internal tools are always available and do not require a GUI but will by
2075 default not handle symlinks or binary files. See next section for detail
2077 default not handle symlinks or binary files. See next section for detail
2076 about "actual capabilities" described above.
2078 about "actual capabilities" described above.
2077
2079
2078 Choosing a merge tool
2080 Choosing a merge tool
2079 =====================
2081 =====================
2080
2082
2081 Mercurial uses these rules when deciding which merge tool to use:
2083 Mercurial uses these rules when deciding which merge tool to use:
2082
2084
2083 1. If a tool has been specified with the --tool option to merge or
2085 1. If a tool has been specified with the --tool option to merge or
2084 resolve, it is used. If it is the name of a tool in the merge-tools
2086 resolve, it is used. If it is the name of a tool in the merge-tools
2085 configuration, its configuration is used. Otherwise the specified tool
2087 configuration, its configuration is used. Otherwise the specified tool
2086 must be executable by the shell.
2088 must be executable by the shell.
2087 2. If the "HGMERGE" environment variable is present, its value is used and
2089 2. If the "HGMERGE" environment variable is present, its value is used and
2088 must be executable by the shell.
2090 must be executable by the shell.
2089 3. If the filename of the file to be merged matches any of the patterns in
2091 3. If the filename of the file to be merged matches any of the patterns in
2090 the merge-patterns configuration section, the first usable merge tool
2092 the merge-patterns configuration section, the first usable merge tool
2091 corresponding to a matching pattern is used.
2093 corresponding to a matching pattern is used.
2092 4. If ui.merge is set it will be considered next. If the value is not the
2094 4. If ui.merge is set it will be considered next. If the value is not the
2093 name of a configured tool, the specified value is used and must be
2095 name of a configured tool, the specified value is used and must be
2094 executable by the shell. Otherwise the named tool is used if it is
2096 executable by the shell. Otherwise the named tool is used if it is
2095 usable.
2097 usable.
2096 5. If any usable merge tools are present in the merge-tools configuration
2098 5. If any usable merge tools are present in the merge-tools configuration
2097 section, the one with the highest priority is used.
2099 section, the one with the highest priority is used.
2098 6. If a program named "hgmerge" can be found on the system, it is used -
2100 6. If a program named "hgmerge" can be found on the system, it is used -
2099 but it will by default not be used for symlinks and binary files.
2101 but it will by default not be used for symlinks and binary files.
2100 7. If the file to be merged is not binary and is not a symlink, then
2102 7. If the file to be merged is not binary and is not a symlink, then
2101 internal ":merge" is used.
2103 internal ":merge" is used.
2102 8. Otherwise, ":prompt" is used.
2104 8. Otherwise, ":prompt" is used.
2103
2105
2104 For historical reason, Mercurial treats merge tools as below while
2106 For historical reason, Mercurial treats merge tools as below while
2105 examining rules above.
2107 examining rules above.
2106
2108
2107 step specified via binary symlink
2109 step specified via binary symlink
2108 ----------------------------------
2110 ----------------------------------
2109 1. --tool o/o o/o
2111 1. --tool o/o o/o
2110 2. HGMERGE o/o o/o
2112 2. HGMERGE o/o o/o
2111 3. merge-patterns o/o(*) x/?(*)
2113 3. merge-patterns o/o(*) x/?(*)
2112 4. ui.merge x/?(*) x/?(*)
2114 4. ui.merge x/?(*) x/?(*)
2113
2115
2114 Each capability column indicates Mercurial behavior for internal/external
2116 Each capability column indicates Mercurial behavior for internal/external
2115 merge tools at examining each rule.
2117 merge tools at examining each rule.
2116
2118
2117 - "o": "assume that a tool has capability"
2119 - "o": "assume that a tool has capability"
2118 - "x": "assume that a tool does not have capability"
2120 - "x": "assume that a tool does not have capability"
2119 - "?": "check actual capability of a tool"
2121 - "?": "check actual capability of a tool"
2120
2122
2121 If "merge.strict-capability-check" configuration is true, Mercurial checks
2123 If "merge.strict-capability-check" configuration is true, Mercurial checks
2122 capabilities of merge tools strictly in (*) cases above (= each capability
2124 capabilities of merge tools strictly in (*) cases above (= each capability
2123 column becomes "?/?"). It is false by default for backward compatibility.
2125 column becomes "?/?"). It is false by default for backward compatibility.
2124
2126
2125 Note:
2127 Note:
2126 After selecting a merge program, Mercurial will by default attempt to
2128 After selecting a merge program, Mercurial will by default attempt to
2127 merge the files using a simple merge algorithm first. Only if it
2129 merge the files using a simple merge algorithm first. Only if it
2128 doesn't succeed because of conflicting changes will Mercurial actually
2130 doesn't succeed because of conflicting changes will Mercurial actually
2129 execute the merge program. Whether to use the simple merge algorithm
2131 execute the merge program. Whether to use the simple merge algorithm
2130 first can be controlled by the premerge setting of the merge tool.
2132 first can be controlled by the premerge setting of the merge tool.
2131 Premerge is enabled by default unless the file is binary or a symlink.
2133 Premerge is enabled by default unless the file is binary or a symlink.
2132
2134
2133 See the merge-tools and ui sections of hgrc(5) for details on the
2135 See the merge-tools and ui sections of hgrc(5) for details on the
2134 configuration of merge tools.
2136 configuration of merge tools.
2135
2137
2136 Compression engines listed in `hg help bundlespec`
2138 Compression engines listed in `hg help bundlespec`
2137
2139
2138 $ hg help bundlespec | grep gzip
2140 $ hg help bundlespec | grep gzip
2139 "v1" bundles can only use the "gzip", "bzip2", and "none" compression
2141 "v1" bundles can only use the "gzip", "bzip2", and "none" compression
2140 An algorithm that produces smaller bundles than "gzip".
2142 An algorithm that produces smaller bundles than "gzip".
2141 This engine will likely produce smaller bundles than "gzip" but will be
2143 This engine will likely produce smaller bundles than "gzip" but will be
2142 "gzip"
2144 "gzip"
2143 better compression than "gzip". It also frequently yields better (?)
2145 better compression than "gzip". It also frequently yields better (?)
2144
2146
2145 Test usage of section marks in help documents
2147 Test usage of section marks in help documents
2146
2148
2147 $ cd "$TESTDIR"/../doc
2149 $ cd "$TESTDIR"/../doc
2148 $ "$PYTHON" check-seclevel.py
2150 $ "$PYTHON" check-seclevel.py
2149 $ cd $TESTTMP
2151 $ cd $TESTTMP
2150
2152
2151 #if serve
2153 #if serve
2152
2154
2153 Test the help pages in hgweb.
2155 Test the help pages in hgweb.
2154
2156
2155 Dish up an empty repo; serve it cold.
2157 Dish up an empty repo; serve it cold.
2156
2158
2157 $ hg init "$TESTTMP/test"
2159 $ hg init "$TESTTMP/test"
2158 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
2160 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
2159 $ cat hg.pid >> $DAEMON_PIDS
2161 $ cat hg.pid >> $DAEMON_PIDS
2160
2162
2161 $ get-with-headers.py $LOCALIP:$HGPORT "help"
2163 $ get-with-headers.py $LOCALIP:$HGPORT "help"
2162 200 Script output follows
2164 200 Script output follows
2163
2165
2164 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2166 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2165 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2167 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2166 <head>
2168 <head>
2167 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2169 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2168 <meta name="robots" content="index, nofollow" />
2170 <meta name="robots" content="index, nofollow" />
2169 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2171 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2170 <script type="text/javascript" src="/static/mercurial.js"></script>
2172 <script type="text/javascript" src="/static/mercurial.js"></script>
2171
2173
2172 <title>Help: Index</title>
2174 <title>Help: Index</title>
2173 </head>
2175 </head>
2174 <body>
2176 <body>
2175
2177
2176 <div class="container">
2178 <div class="container">
2177 <div class="menu">
2179 <div class="menu">
2178 <div class="logo">
2180 <div class="logo">
2179 <a href="https://mercurial-scm.org/">
2181 <a href="https://mercurial-scm.org/">
2180 <img src="/static/hglogo.png" alt="mercurial" /></a>
2182 <img src="/static/hglogo.png" alt="mercurial" /></a>
2181 </div>
2183 </div>
2182 <ul>
2184 <ul>
2183 <li><a href="/shortlog">log</a></li>
2185 <li><a href="/shortlog">log</a></li>
2184 <li><a href="/graph">graph</a></li>
2186 <li><a href="/graph">graph</a></li>
2185 <li><a href="/tags">tags</a></li>
2187 <li><a href="/tags">tags</a></li>
2186 <li><a href="/bookmarks">bookmarks</a></li>
2188 <li><a href="/bookmarks">bookmarks</a></li>
2187 <li><a href="/branches">branches</a></li>
2189 <li><a href="/branches">branches</a></li>
2188 </ul>
2190 </ul>
2189 <ul>
2191 <ul>
2190 <li class="active">help</li>
2192 <li class="active">help</li>
2191 </ul>
2193 </ul>
2192 </div>
2194 </div>
2193
2195
2194 <div class="main">
2196 <div class="main">
2195 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2197 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2196
2198
2197 <form class="search" action="/log">
2199 <form class="search" action="/log">
2198
2200
2199 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2201 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2200 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2202 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2201 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2203 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2202 </form>
2204 </form>
2203 <table class="bigtable">
2205 <table class="bigtable">
2204 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
2206 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
2205
2207
2206 <tr><td>
2208 <tr><td>
2207 <a href="/help/bundlespec">
2209 <a href="/help/bundlespec">
2208 bundlespec
2210 bundlespec
2209 </a>
2211 </a>
2210 </td><td>
2212 </td><td>
2211 Bundle File Formats
2213 Bundle File Formats
2212 </td></tr>
2214 </td></tr>
2213 <tr><td>
2215 <tr><td>
2214 <a href="/help/color">
2216 <a href="/help/color">
2215 color
2217 color
2216 </a>
2218 </a>
2217 </td><td>
2219 </td><td>
2218 Colorizing Outputs
2220 Colorizing Outputs
2219 </td></tr>
2221 </td></tr>
2220 <tr><td>
2222 <tr><td>
2221 <a href="/help/config">
2223 <a href="/help/config">
2222 config
2224 config
2223 </a>
2225 </a>
2224 </td><td>
2226 </td><td>
2225 Configuration Files
2227 Configuration Files
2226 </td></tr>
2228 </td></tr>
2227 <tr><td>
2229 <tr><td>
2228 <a href="/help/dates">
2230 <a href="/help/dates">
2229 dates
2231 dates
2230 </a>
2232 </a>
2231 </td><td>
2233 </td><td>
2232 Date Formats
2234 Date Formats
2233 </td></tr>
2235 </td></tr>
2234 <tr><td>
2236 <tr><td>
2235 <a href="/help/deprecated">
2237 <a href="/help/deprecated">
2236 deprecated
2238 deprecated
2237 </a>
2239 </a>
2238 </td><td>
2240 </td><td>
2239 Deprecated Features
2241 Deprecated Features
2240 </td></tr>
2242 </td></tr>
2241 <tr><td>
2243 <tr><td>
2242 <a href="/help/diffs">
2244 <a href="/help/diffs">
2243 diffs
2245 diffs
2244 </a>
2246 </a>
2245 </td><td>
2247 </td><td>
2246 Diff Formats
2248 Diff Formats
2247 </td></tr>
2249 </td></tr>
2248 <tr><td>
2250 <tr><td>
2249 <a href="/help/environment">
2251 <a href="/help/environment">
2250 environment
2252 environment
2251 </a>
2253 </a>
2252 </td><td>
2254 </td><td>
2253 Environment Variables
2255 Environment Variables
2254 </td></tr>
2256 </td></tr>
2255 <tr><td>
2257 <tr><td>
2256 <a href="/help/extensions">
2258 <a href="/help/extensions">
2257 extensions
2259 extensions
2258 </a>
2260 </a>
2259 </td><td>
2261 </td><td>
2260 Using Additional Features
2262 Using Additional Features
2261 </td></tr>
2263 </td></tr>
2262 <tr><td>
2264 <tr><td>
2263 <a href="/help/filesets">
2265 <a href="/help/filesets">
2264 filesets
2266 filesets
2265 </a>
2267 </a>
2266 </td><td>
2268 </td><td>
2267 Specifying File Sets
2269 Specifying File Sets
2268 </td></tr>
2270 </td></tr>
2269 <tr><td>
2271 <tr><td>
2270 <a href="/help/flags">
2272 <a href="/help/flags">
2271 flags
2273 flags
2272 </a>
2274 </a>
2273 </td><td>
2275 </td><td>
2274 Command-line flags
2276 Command-line flags
2275 </td></tr>
2277 </td></tr>
2276 <tr><td>
2278 <tr><td>
2277 <a href="/help/glossary">
2279 <a href="/help/glossary">
2278 glossary
2280 glossary
2279 </a>
2281 </a>
2280 </td><td>
2282 </td><td>
2281 Glossary
2283 Glossary
2282 </td></tr>
2284 </td></tr>
2283 <tr><td>
2285 <tr><td>
2284 <a href="/help/hgignore">
2286 <a href="/help/hgignore">
2285 hgignore
2287 hgignore
2286 </a>
2288 </a>
2287 </td><td>
2289 </td><td>
2288 Syntax for Mercurial Ignore Files
2290 Syntax for Mercurial Ignore Files
2289 </td></tr>
2291 </td></tr>
2290 <tr><td>
2292 <tr><td>
2291 <a href="/help/hgweb">
2293 <a href="/help/hgweb">
2292 hgweb
2294 hgweb
2293 </a>
2295 </a>
2294 </td><td>
2296 </td><td>
2295 Configuring hgweb
2297 Configuring hgweb
2296 </td></tr>
2298 </td></tr>
2297 <tr><td>
2299 <tr><td>
2298 <a href="/help/internals">
2300 <a href="/help/internals">
2299 internals
2301 internals
2300 </a>
2302 </a>
2301 </td><td>
2303 </td><td>
2302 Technical implementation topics
2304 Technical implementation topics
2303 </td></tr>
2305 </td></tr>
2304 <tr><td>
2306 <tr><td>
2305 <a href="/help/merge-tools">
2307 <a href="/help/merge-tools">
2306 merge-tools
2308 merge-tools
2307 </a>
2309 </a>
2308 </td><td>
2310 </td><td>
2309 Merge Tools
2311 Merge Tools
2310 </td></tr>
2312 </td></tr>
2311 <tr><td>
2313 <tr><td>
2312 <a href="/help/pager">
2314 <a href="/help/pager">
2313 pager
2315 pager
2314 </a>
2316 </a>
2315 </td><td>
2317 </td><td>
2316 Pager Support
2318 Pager Support
2317 </td></tr>
2319 </td></tr>
2318 <tr><td>
2320 <tr><td>
2319 <a href="/help/patterns">
2321 <a href="/help/patterns">
2320 patterns
2322 patterns
2321 </a>
2323 </a>
2322 </td><td>
2324 </td><td>
2323 File Name Patterns
2325 File Name Patterns
2324 </td></tr>
2326 </td></tr>
2325 <tr><td>
2327 <tr><td>
2326 <a href="/help/phases">
2328 <a href="/help/phases">
2327 phases
2329 phases
2328 </a>
2330 </a>
2329 </td><td>
2331 </td><td>
2330 Working with Phases
2332 Working with Phases
2331 </td></tr>
2333 </td></tr>
2332 <tr><td>
2334 <tr><td>
2333 <a href="/help/revisions">
2335 <a href="/help/revisions">
2334 revisions
2336 revisions
2335 </a>
2337 </a>
2336 </td><td>
2338 </td><td>
2337 Specifying Revisions
2339 Specifying Revisions
2338 </td></tr>
2340 </td></tr>
2339 <tr><td>
2341 <tr><td>
2340 <a href="/help/scripting">
2342 <a href="/help/scripting">
2341 scripting
2343 scripting
2342 </a>
2344 </a>
2343 </td><td>
2345 </td><td>
2344 Using Mercurial from scripts and automation
2346 Using Mercurial from scripts and automation
2345 </td></tr>
2347 </td></tr>
2346 <tr><td>
2348 <tr><td>
2347 <a href="/help/subrepos">
2349 <a href="/help/subrepos">
2348 subrepos
2350 subrepos
2349 </a>
2351 </a>
2350 </td><td>
2352 </td><td>
2351 Subrepositories
2353 Subrepositories
2352 </td></tr>
2354 </td></tr>
2353 <tr><td>
2355 <tr><td>
2354 <a href="/help/templating">
2356 <a href="/help/templating">
2355 templating
2357 templating
2356 </a>
2358 </a>
2357 </td><td>
2359 </td><td>
2358 Template Usage
2360 Template Usage
2359 </td></tr>
2361 </td></tr>
2360 <tr><td>
2362 <tr><td>
2361 <a href="/help/urls">
2363 <a href="/help/urls">
2362 urls
2364 urls
2363 </a>
2365 </a>
2364 </td><td>
2366 </td><td>
2365 URL Paths
2367 URL Paths
2366 </td></tr>
2368 </td></tr>
2367 <tr><td>
2369 <tr><td>
2368 <a href="/help/topic-containing-verbose">
2370 <a href="/help/topic-containing-verbose">
2369 topic-containing-verbose
2371 topic-containing-verbose
2370 </a>
2372 </a>
2371 </td><td>
2373 </td><td>
2372 This is the topic to test omit indicating.
2374 This is the topic to test omit indicating.
2373 </td></tr>
2375 </td></tr>
2374
2376
2375
2377
2376 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
2378 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
2377
2379
2378 <tr><td>
2380 <tr><td>
2379 <a href="/help/abort">
2381 <a href="/help/abort">
2380 abort
2382 abort
2381 </a>
2383 </a>
2382 </td><td>
2384 </td><td>
2383 abort an unfinished operation (EXPERIMENTAL)
2385 abort an unfinished operation (EXPERIMENTAL)
2384 </td></tr>
2386 </td></tr>
2385 <tr><td>
2387 <tr><td>
2386 <a href="/help/add">
2388 <a href="/help/add">
2387 add
2389 add
2388 </a>
2390 </a>
2389 </td><td>
2391 </td><td>
2390 add the specified files on the next commit
2392 add the specified files on the next commit
2391 </td></tr>
2393 </td></tr>
2392 <tr><td>
2394 <tr><td>
2393 <a href="/help/annotate">
2395 <a href="/help/annotate">
2394 annotate
2396 annotate
2395 </a>
2397 </a>
2396 </td><td>
2398 </td><td>
2397 show changeset information by line for each file
2399 show changeset information by line for each file
2398 </td></tr>
2400 </td></tr>
2399 <tr><td>
2401 <tr><td>
2400 <a href="/help/clone">
2402 <a href="/help/clone">
2401 clone
2403 clone
2402 </a>
2404 </a>
2403 </td><td>
2405 </td><td>
2404 make a copy of an existing repository
2406 make a copy of an existing repository
2405 </td></tr>
2407 </td></tr>
2406 <tr><td>
2408 <tr><td>
2407 <a href="/help/commit">
2409 <a href="/help/commit">
2408 commit
2410 commit
2409 </a>
2411 </a>
2410 </td><td>
2412 </td><td>
2411 commit the specified files or all outstanding changes
2413 commit the specified files or all outstanding changes
2412 </td></tr>
2414 </td></tr>
2413 <tr><td>
2415 <tr><td>
2414 <a href="/help/continue">
2416 <a href="/help/continue">
2415 continue
2417 continue
2416 </a>
2418 </a>
2417 </td><td>
2419 </td><td>
2418 resumes an interrupted operation (EXPERIMENTAL)
2420 resumes an interrupted operation (EXPERIMENTAL)
2419 </td></tr>
2421 </td></tr>
2420 <tr><td>
2422 <tr><td>
2421 <a href="/help/diff">
2423 <a href="/help/diff">
2422 diff
2424 diff
2423 </a>
2425 </a>
2424 </td><td>
2426 </td><td>
2425 diff repository (or selected files)
2427 diff repository (or selected files)
2426 </td></tr>
2428 </td></tr>
2427 <tr><td>
2429 <tr><td>
2428 <a href="/help/export">
2430 <a href="/help/export">
2429 export
2431 export
2430 </a>
2432 </a>
2431 </td><td>
2433 </td><td>
2432 dump the header and diffs for one or more changesets
2434 dump the header and diffs for one or more changesets
2433 </td></tr>
2435 </td></tr>
2434 <tr><td>
2436 <tr><td>
2435 <a href="/help/forget">
2437 <a href="/help/forget">
2436 forget
2438 forget
2437 </a>
2439 </a>
2438 </td><td>
2440 </td><td>
2439 forget the specified files on the next commit
2441 forget the specified files on the next commit
2440 </td></tr>
2442 </td></tr>
2441 <tr><td>
2443 <tr><td>
2442 <a href="/help/init">
2444 <a href="/help/init">
2443 init
2445 init
2444 </a>
2446 </a>
2445 </td><td>
2447 </td><td>
2446 create a new repository in the given directory
2448 create a new repository in the given directory
2447 </td></tr>
2449 </td></tr>
2448 <tr><td>
2450 <tr><td>
2449 <a href="/help/log">
2451 <a href="/help/log">
2450 log
2452 log
2451 </a>
2453 </a>
2452 </td><td>
2454 </td><td>
2453 show revision history of entire repository or files
2455 show revision history of entire repository or files
2454 </td></tr>
2456 </td></tr>
2455 <tr><td>
2457 <tr><td>
2456 <a href="/help/merge">
2458 <a href="/help/merge">
2457 merge
2459 merge
2458 </a>
2460 </a>
2459 </td><td>
2461 </td><td>
2460 merge another revision into working directory
2462 merge another revision into working directory
2461 </td></tr>
2463 </td></tr>
2462 <tr><td>
2464 <tr><td>
2463 <a href="/help/pull">
2465 <a href="/help/pull">
2464 pull
2466 pull
2465 </a>
2467 </a>
2466 </td><td>
2468 </td><td>
2467 pull changes from the specified source
2469 pull changes from the specified source
2468 </td></tr>
2470 </td></tr>
2469 <tr><td>
2471 <tr><td>
2470 <a href="/help/push">
2472 <a href="/help/push">
2471 push
2473 push
2472 </a>
2474 </a>
2473 </td><td>
2475 </td><td>
2474 push changes to the specified destination
2476 push changes to the specified destination
2475 </td></tr>
2477 </td></tr>
2476 <tr><td>
2478 <tr><td>
2477 <a href="/help/remove">
2479 <a href="/help/remove">
2478 remove
2480 remove
2479 </a>
2481 </a>
2480 </td><td>
2482 </td><td>
2481 remove the specified files on the next commit
2483 remove the specified files on the next commit
2482 </td></tr>
2484 </td></tr>
2483 <tr><td>
2485 <tr><td>
2484 <a href="/help/serve">
2486 <a href="/help/serve">
2485 serve
2487 serve
2486 </a>
2488 </a>
2487 </td><td>
2489 </td><td>
2488 start stand-alone webserver
2490 start stand-alone webserver
2489 </td></tr>
2491 </td></tr>
2490 <tr><td>
2492 <tr><td>
2491 <a href="/help/status">
2493 <a href="/help/status">
2492 status
2494 status
2493 </a>
2495 </a>
2494 </td><td>
2496 </td><td>
2495 show changed files in the working directory
2497 show changed files in the working directory
2496 </td></tr>
2498 </td></tr>
2497 <tr><td>
2499 <tr><td>
2498 <a href="/help/summary">
2500 <a href="/help/summary">
2499 summary
2501 summary
2500 </a>
2502 </a>
2501 </td><td>
2503 </td><td>
2502 summarize working directory state
2504 summarize working directory state
2503 </td></tr>
2505 </td></tr>
2504 <tr><td>
2506 <tr><td>
2505 <a href="/help/update">
2507 <a href="/help/update">
2506 update
2508 update
2507 </a>
2509 </a>
2508 </td><td>
2510 </td><td>
2509 update working directory (or switch revisions)
2511 update working directory (or switch revisions)
2510 </td></tr>
2512 </td></tr>
2511
2513
2512
2514
2513
2515
2514 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
2516 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
2515
2517
2516 <tr><td>
2518 <tr><td>
2517 <a href="/help/addremove">
2519 <a href="/help/addremove">
2518 addremove
2520 addremove
2519 </a>
2521 </a>
2520 </td><td>
2522 </td><td>
2521 add all new files, delete all missing files
2523 add all new files, delete all missing files
2522 </td></tr>
2524 </td></tr>
2523 <tr><td>
2525 <tr><td>
2524 <a href="/help/archive">
2526 <a href="/help/archive">
2525 archive
2527 archive
2526 </a>
2528 </a>
2527 </td><td>
2529 </td><td>
2528 create an unversioned archive of a repository revision
2530 create an unversioned archive of a repository revision
2529 </td></tr>
2531 </td></tr>
2530 <tr><td>
2532 <tr><td>
2531 <a href="/help/backout">
2533 <a href="/help/backout">
2532 backout
2534 backout
2533 </a>
2535 </a>
2534 </td><td>
2536 </td><td>
2535 reverse effect of earlier changeset
2537 reverse effect of earlier changeset
2536 </td></tr>
2538 </td></tr>
2537 <tr><td>
2539 <tr><td>
2538 <a href="/help/bisect">
2540 <a href="/help/bisect">
2539 bisect
2541 bisect
2540 </a>
2542 </a>
2541 </td><td>
2543 </td><td>
2542 subdivision search of changesets
2544 subdivision search of changesets
2543 </td></tr>
2545 </td></tr>
2544 <tr><td>
2546 <tr><td>
2545 <a href="/help/bookmarks">
2547 <a href="/help/bookmarks">
2546 bookmarks
2548 bookmarks
2547 </a>
2549 </a>
2548 </td><td>
2550 </td><td>
2549 create a new bookmark or list existing bookmarks
2551 create a new bookmark or list existing bookmarks
2550 </td></tr>
2552 </td></tr>
2551 <tr><td>
2553 <tr><td>
2552 <a href="/help/branch">
2554 <a href="/help/branch">
2553 branch
2555 branch
2554 </a>
2556 </a>
2555 </td><td>
2557 </td><td>
2556 set or show the current branch name
2558 set or show the current branch name
2557 </td></tr>
2559 </td></tr>
2558 <tr><td>
2560 <tr><td>
2559 <a href="/help/branches">
2561 <a href="/help/branches">
2560 branches
2562 branches
2561 </a>
2563 </a>
2562 </td><td>
2564 </td><td>
2563 list repository named branches
2565 list repository named branches
2564 </td></tr>
2566 </td></tr>
2565 <tr><td>
2567 <tr><td>
2566 <a href="/help/bundle">
2568 <a href="/help/bundle">
2567 bundle
2569 bundle
2568 </a>
2570 </a>
2569 </td><td>
2571 </td><td>
2570 create a bundle file
2572 create a bundle file
2571 </td></tr>
2573 </td></tr>
2572 <tr><td>
2574 <tr><td>
2573 <a href="/help/cat">
2575 <a href="/help/cat">
2574 cat
2576 cat
2575 </a>
2577 </a>
2576 </td><td>
2578 </td><td>
2577 output the current or given revision of files
2579 output the current or given revision of files
2578 </td></tr>
2580 </td></tr>
2579 <tr><td>
2581 <tr><td>
2580 <a href="/help/config">
2582 <a href="/help/config">
2581 config
2583 config
2582 </a>
2584 </a>
2583 </td><td>
2585 </td><td>
2584 show combined config settings from all hgrc files
2586 show combined config settings from all hgrc files
2585 </td></tr>
2587 </td></tr>
2586 <tr><td>
2588 <tr><td>
2587 <a href="/help/copy">
2589 <a href="/help/copy">
2588 copy
2590 copy
2589 </a>
2591 </a>
2590 </td><td>
2592 </td><td>
2591 mark files as copied for the next commit
2593 mark files as copied for the next commit
2592 </td></tr>
2594 </td></tr>
2593 <tr><td>
2595 <tr><td>
2594 <a href="/help/files">
2596 <a href="/help/files">
2595 files
2597 files
2596 </a>
2598 </a>
2597 </td><td>
2599 </td><td>
2598 list tracked files
2600 list tracked files
2599 </td></tr>
2601 </td></tr>
2600 <tr><td>
2602 <tr><td>
2601 <a href="/help/graft">
2603 <a href="/help/graft">
2602 graft
2604 graft
2603 </a>
2605 </a>
2604 </td><td>
2606 </td><td>
2605 copy changes from other branches onto the current branch
2607 copy changes from other branches onto the current branch
2606 </td></tr>
2608 </td></tr>
2607 <tr><td>
2609 <tr><td>
2608 <a href="/help/grep">
2610 <a href="/help/grep">
2609 grep
2611 grep
2610 </a>
2612 </a>
2611 </td><td>
2613 </td><td>
2612 search for a pattern in specified files
2614 search for a pattern in specified files
2613 </td></tr>
2615 </td></tr>
2614 <tr><td>
2616 <tr><td>
2615 <a href="/help/hashelp">
2617 <a href="/help/hashelp">
2616 hashelp
2618 hashelp
2617 </a>
2619 </a>
2618 </td><td>
2620 </td><td>
2619 Extension command's help
2621 Extension command's help
2620 </td></tr>
2622 </td></tr>
2621 <tr><td>
2623 <tr><td>
2622 <a href="/help/heads">
2624 <a href="/help/heads">
2623 heads
2625 heads
2624 </a>
2626 </a>
2625 </td><td>
2627 </td><td>
2626 show branch heads
2628 show branch heads
2627 </td></tr>
2629 </td></tr>
2628 <tr><td>
2630 <tr><td>
2629 <a href="/help/help">
2631 <a href="/help/help">
2630 help
2632 help
2631 </a>
2633 </a>
2632 </td><td>
2634 </td><td>
2633 show help for a given topic or a help overview
2635 show help for a given topic or a help overview
2634 </td></tr>
2636 </td></tr>
2635 <tr><td>
2637 <tr><td>
2636 <a href="/help/hgalias">
2638 <a href="/help/hgalias">
2637 hgalias
2639 hgalias
2638 </a>
2640 </a>
2639 </td><td>
2641 </td><td>
2640 My doc
2642 My doc
2641 </td></tr>
2643 </td></tr>
2642 <tr><td>
2644 <tr><td>
2643 <a href="/help/hgaliasnodoc">
2645 <a href="/help/hgaliasnodoc">
2644 hgaliasnodoc
2646 hgaliasnodoc
2645 </a>
2647 </a>
2646 </td><td>
2648 </td><td>
2647 summarize working directory state
2649 summarize working directory state
2648 </td></tr>
2650 </td></tr>
2649 <tr><td>
2651 <tr><td>
2650 <a href="/help/identify">
2652 <a href="/help/identify">
2651 identify
2653 identify
2652 </a>
2654 </a>
2653 </td><td>
2655 </td><td>
2654 identify the working directory or specified revision
2656 identify the working directory or specified revision
2655 </td></tr>
2657 </td></tr>
2656 <tr><td>
2658 <tr><td>
2657 <a href="/help/import">
2659 <a href="/help/import">
2658 import
2660 import
2659 </a>
2661 </a>
2660 </td><td>
2662 </td><td>
2661 import an ordered set of patches
2663 import an ordered set of patches
2662 </td></tr>
2664 </td></tr>
2663 <tr><td>
2665 <tr><td>
2664 <a href="/help/incoming">
2666 <a href="/help/incoming">
2665 incoming
2667 incoming
2666 </a>
2668 </a>
2667 </td><td>
2669 </td><td>
2668 show new changesets found in source
2670 show new changesets found in source
2669 </td></tr>
2671 </td></tr>
2670 <tr><td>
2672 <tr><td>
2671 <a href="/help/manifest">
2673 <a href="/help/manifest">
2672 manifest
2674 manifest
2673 </a>
2675 </a>
2674 </td><td>
2676 </td><td>
2675 output the current or given revision of the project manifest
2677 output the current or given revision of the project manifest
2676 </td></tr>
2678 </td></tr>
2677 <tr><td>
2679 <tr><td>
2678 <a href="/help/nohelp">
2680 <a href="/help/nohelp">
2679 nohelp
2681 nohelp
2680 </a>
2682 </a>
2681 </td><td>
2683 </td><td>
2682 (no help text available)
2684 (no help text available)
2683 </td></tr>
2685 </td></tr>
2684 <tr><td>
2686 <tr><td>
2685 <a href="/help/outgoing">
2687 <a href="/help/outgoing">
2686 outgoing
2688 outgoing
2687 </a>
2689 </a>
2688 </td><td>
2690 </td><td>
2689 show changesets not found in the destination
2691 show changesets not found in the destination
2690 </td></tr>
2692 </td></tr>
2691 <tr><td>
2693 <tr><td>
2692 <a href="/help/paths">
2694 <a href="/help/paths">
2693 paths
2695 paths
2694 </a>
2696 </a>
2695 </td><td>
2697 </td><td>
2696 show aliases for remote repositories
2698 show aliases for remote repositories
2697 </td></tr>
2699 </td></tr>
2698 <tr><td>
2700 <tr><td>
2699 <a href="/help/phase">
2701 <a href="/help/phase">
2700 phase
2702 phase
2701 </a>
2703 </a>
2702 </td><td>
2704 </td><td>
2703 set or show the current phase name
2705 set or show the current phase name
2704 </td></tr>
2706 </td></tr>
2705 <tr><td>
2707 <tr><td>
2706 <a href="/help/recover">
2708 <a href="/help/recover">
2707 recover
2709 recover
2708 </a>
2710 </a>
2709 </td><td>
2711 </td><td>
2710 roll back an interrupted transaction
2712 roll back an interrupted transaction
2711 </td></tr>
2713 </td></tr>
2712 <tr><td>
2714 <tr><td>
2713 <a href="/help/rename">
2715 <a href="/help/rename">
2714 rename
2716 rename
2715 </a>
2717 </a>
2716 </td><td>
2718 </td><td>
2717 rename files; equivalent of copy + remove
2719 rename files; equivalent of copy + remove
2718 </td></tr>
2720 </td></tr>
2719 <tr><td>
2721 <tr><td>
2720 <a href="/help/resolve">
2722 <a href="/help/resolve">
2721 resolve
2723 resolve
2722 </a>
2724 </a>
2723 </td><td>
2725 </td><td>
2724 redo merges or set/view the merge status of files
2726 redo merges or set/view the merge status of files
2725 </td></tr>
2727 </td></tr>
2726 <tr><td>
2728 <tr><td>
2727 <a href="/help/revert">
2729 <a href="/help/revert">
2728 revert
2730 revert
2729 </a>
2731 </a>
2730 </td><td>
2732 </td><td>
2731 restore files to their checkout state
2733 restore files to their checkout state
2732 </td></tr>
2734 </td></tr>
2733 <tr><td>
2735 <tr><td>
2734 <a href="/help/root">
2736 <a href="/help/root">
2735 root
2737 root
2736 </a>
2738 </a>
2737 </td><td>
2739 </td><td>
2738 print the root (top) of the current working directory
2740 print the root (top) of the current working directory
2739 </td></tr>
2741 </td></tr>
2740 <tr><td>
2742 <tr><td>
2741 <a href="/help/shellalias">
2743 <a href="/help/shellalias">
2742 shellalias
2744 shellalias
2743 </a>
2745 </a>
2744 </td><td>
2746 </td><td>
2745 (no help text available)
2747 (no help text available)
2746 </td></tr>
2748 </td></tr>
2747 <tr><td>
2749 <tr><td>
2748 <a href="/help/shelve">
2750 <a href="/help/shelve">
2749 shelve
2751 shelve
2750 </a>
2752 </a>
2751 </td><td>
2753 </td><td>
2752 save and set aside changes from the working directory
2754 save and set aside changes from the working directory
2753 </td></tr>
2755 </td></tr>
2754 <tr><td>
2756 <tr><td>
2755 <a href="/help/tag">
2757 <a href="/help/tag">
2756 tag
2758 tag
2757 </a>
2759 </a>
2758 </td><td>
2760 </td><td>
2759 add one or more tags for the current or given revision
2761 add one or more tags for the current or given revision
2760 </td></tr>
2762 </td></tr>
2761 <tr><td>
2763 <tr><td>
2762 <a href="/help/tags">
2764 <a href="/help/tags">
2763 tags
2765 tags
2764 </a>
2766 </a>
2765 </td><td>
2767 </td><td>
2766 list repository tags
2768 list repository tags
2767 </td></tr>
2769 </td></tr>
2768 <tr><td>
2770 <tr><td>
2769 <a href="/help/unbundle">
2771 <a href="/help/unbundle">
2770 unbundle
2772 unbundle
2771 </a>
2773 </a>
2772 </td><td>
2774 </td><td>
2773 apply one or more bundle files
2775 apply one or more bundle files
2774 </td></tr>
2776 </td></tr>
2775 <tr><td>
2777 <tr><td>
2776 <a href="/help/unshelve">
2778 <a href="/help/unshelve">
2777 unshelve
2779 unshelve
2778 </a>
2780 </a>
2779 </td><td>
2781 </td><td>
2780 restore a shelved change to the working directory
2782 restore a shelved change to the working directory
2781 </td></tr>
2783 </td></tr>
2782 <tr><td>
2784 <tr><td>
2783 <a href="/help/verify">
2785 <a href="/help/verify">
2784 verify
2786 verify
2785 </a>
2787 </a>
2786 </td><td>
2788 </td><td>
2787 verify the integrity of the repository
2789 verify the integrity of the repository
2788 </td></tr>
2790 </td></tr>
2789 <tr><td>
2791 <tr><td>
2790 <a href="/help/version">
2792 <a href="/help/version">
2791 version
2793 version
2792 </a>
2794 </a>
2793 </td><td>
2795 </td><td>
2794 output version and copyright information
2796 output version and copyright information
2795 </td></tr>
2797 </td></tr>
2796
2798
2797
2799
2798 </table>
2800 </table>
2799 </div>
2801 </div>
2800 </div>
2802 </div>
2801
2803
2802
2804
2803
2805
2804 </body>
2806 </body>
2805 </html>
2807 </html>
2806
2808
2807
2809
2808 $ get-with-headers.py $LOCALIP:$HGPORT "help/add"
2810 $ get-with-headers.py $LOCALIP:$HGPORT "help/add"
2809 200 Script output follows
2811 200 Script output follows
2810
2812
2811 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2813 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2812 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2814 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2813 <head>
2815 <head>
2814 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2816 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2815 <meta name="robots" content="index, nofollow" />
2817 <meta name="robots" content="index, nofollow" />
2816 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2818 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2817 <script type="text/javascript" src="/static/mercurial.js"></script>
2819 <script type="text/javascript" src="/static/mercurial.js"></script>
2818
2820
2819 <title>Help: add</title>
2821 <title>Help: add</title>
2820 </head>
2822 </head>
2821 <body>
2823 <body>
2822
2824
2823 <div class="container">
2825 <div class="container">
2824 <div class="menu">
2826 <div class="menu">
2825 <div class="logo">
2827 <div class="logo">
2826 <a href="https://mercurial-scm.org/">
2828 <a href="https://mercurial-scm.org/">
2827 <img src="/static/hglogo.png" alt="mercurial" /></a>
2829 <img src="/static/hglogo.png" alt="mercurial" /></a>
2828 </div>
2830 </div>
2829 <ul>
2831 <ul>
2830 <li><a href="/shortlog">log</a></li>
2832 <li><a href="/shortlog">log</a></li>
2831 <li><a href="/graph">graph</a></li>
2833 <li><a href="/graph">graph</a></li>
2832 <li><a href="/tags">tags</a></li>
2834 <li><a href="/tags">tags</a></li>
2833 <li><a href="/bookmarks">bookmarks</a></li>
2835 <li><a href="/bookmarks">bookmarks</a></li>
2834 <li><a href="/branches">branches</a></li>
2836 <li><a href="/branches">branches</a></li>
2835 </ul>
2837 </ul>
2836 <ul>
2838 <ul>
2837 <li class="active"><a href="/help">help</a></li>
2839 <li class="active"><a href="/help">help</a></li>
2838 </ul>
2840 </ul>
2839 </div>
2841 </div>
2840
2842
2841 <div class="main">
2843 <div class="main">
2842 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2844 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2843 <h3>Help: add</h3>
2845 <h3>Help: add</h3>
2844
2846
2845 <form class="search" action="/log">
2847 <form class="search" action="/log">
2846
2848
2847 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2849 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2848 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2850 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2849 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2851 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2850 </form>
2852 </form>
2851 <div id="doc">
2853 <div id="doc">
2852 <p>
2854 <p>
2853 hg add [OPTION]... [FILE]...
2855 hg add [OPTION]... [FILE]...
2854 </p>
2856 </p>
2855 <p>
2857 <p>
2856 add the specified files on the next commit
2858 add the specified files on the next commit
2857 </p>
2859 </p>
2858 <p>
2860 <p>
2859 Schedule files to be version controlled and added to the
2861 Schedule files to be version controlled and added to the
2860 repository.
2862 repository.
2861 </p>
2863 </p>
2862 <p>
2864 <p>
2863 The files will be added to the repository at the next commit. To
2865 The files will be added to the repository at the next commit. To
2864 undo an add before that, see 'hg forget'.
2866 undo an add before that, see 'hg forget'.
2865 </p>
2867 </p>
2866 <p>
2868 <p>
2867 If no names are given, add all files to the repository (except
2869 If no names are given, add all files to the repository (except
2868 files matching &quot;.hgignore&quot;).
2870 files matching &quot;.hgignore&quot;).
2869 </p>
2871 </p>
2870 <p>
2872 <p>
2871 Examples:
2873 Examples:
2872 </p>
2874 </p>
2873 <ul>
2875 <ul>
2874 <li> New (unknown) files are added automatically by 'hg add':
2876 <li> New (unknown) files are added automatically by 'hg add':
2875 <pre>
2877 <pre>
2876 \$ ls (re)
2878 \$ ls (re)
2877 foo.c
2879 foo.c
2878 \$ hg status (re)
2880 \$ hg status (re)
2879 ? foo.c
2881 ? foo.c
2880 \$ hg add (re)
2882 \$ hg add (re)
2881 adding foo.c
2883 adding foo.c
2882 \$ hg status (re)
2884 \$ hg status (re)
2883 A foo.c
2885 A foo.c
2884 </pre>
2886 </pre>
2885 <li> Specific files to be added can be specified:
2887 <li> Specific files to be added can be specified:
2886 <pre>
2888 <pre>
2887 \$ ls (re)
2889 \$ ls (re)
2888 bar.c foo.c
2890 bar.c foo.c
2889 \$ hg status (re)
2891 \$ hg status (re)
2890 ? bar.c
2892 ? bar.c
2891 ? foo.c
2893 ? foo.c
2892 \$ hg add bar.c (re)
2894 \$ hg add bar.c (re)
2893 \$ hg status (re)
2895 \$ hg status (re)
2894 A bar.c
2896 A bar.c
2895 ? foo.c
2897 ? foo.c
2896 </pre>
2898 </pre>
2897 </ul>
2899 </ul>
2898 <p>
2900 <p>
2899 Returns 0 if all files are successfully added.
2901 Returns 0 if all files are successfully added.
2900 </p>
2902 </p>
2901 <p>
2903 <p>
2902 options ([+] can be repeated):
2904 options ([+] can be repeated):
2903 </p>
2905 </p>
2904 <table>
2906 <table>
2905 <tr><td>-I</td>
2907 <tr><td>-I</td>
2906 <td>--include PATTERN [+]</td>
2908 <td>--include PATTERN [+]</td>
2907 <td>include names matching the given patterns</td></tr>
2909 <td>include names matching the given patterns</td></tr>
2908 <tr><td>-X</td>
2910 <tr><td>-X</td>
2909 <td>--exclude PATTERN [+]</td>
2911 <td>--exclude PATTERN [+]</td>
2910 <td>exclude names matching the given patterns</td></tr>
2912 <td>exclude names matching the given patterns</td></tr>
2911 <tr><td>-S</td>
2913 <tr><td>-S</td>
2912 <td>--subrepos</td>
2914 <td>--subrepos</td>
2913 <td>recurse into subrepositories</td></tr>
2915 <td>recurse into subrepositories</td></tr>
2914 <tr><td>-n</td>
2916 <tr><td>-n</td>
2915 <td>--dry-run</td>
2917 <td>--dry-run</td>
2916 <td>do not perform actions, just print output</td></tr>
2918 <td>do not perform actions, just print output</td></tr>
2917 </table>
2919 </table>
2918 <p>
2920 <p>
2919 global options ([+] can be repeated):
2921 global options ([+] can be repeated):
2920 </p>
2922 </p>
2921 <table>
2923 <table>
2922 <tr><td>-R</td>
2924 <tr><td>-R</td>
2923 <td>--repository REPO</td>
2925 <td>--repository REPO</td>
2924 <td>repository root directory or name of overlay bundle file</td></tr>
2926 <td>repository root directory or name of overlay bundle file</td></tr>
2925 <tr><td></td>
2927 <tr><td></td>
2926 <td>--cwd DIR</td>
2928 <td>--cwd DIR</td>
2927 <td>change working directory</td></tr>
2929 <td>change working directory</td></tr>
2928 <tr><td>-y</td>
2930 <tr><td>-y</td>
2929 <td>--noninteractive</td>
2931 <td>--noninteractive</td>
2930 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2932 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2931 <tr><td>-q</td>
2933 <tr><td>-q</td>
2932 <td>--quiet</td>
2934 <td>--quiet</td>
2933 <td>suppress output</td></tr>
2935 <td>suppress output</td></tr>
2934 <tr><td>-v</td>
2936 <tr><td>-v</td>
2935 <td>--verbose</td>
2937 <td>--verbose</td>
2936 <td>enable additional output</td></tr>
2938 <td>enable additional output</td></tr>
2937 <tr><td></td>
2939 <tr><td></td>
2938 <td>--color TYPE</td>
2940 <td>--color TYPE</td>
2939 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
2941 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
2940 <tr><td></td>
2942 <tr><td></td>
2941 <td>--config CONFIG [+]</td>
2943 <td>--config CONFIG [+]</td>
2942 <td>set/override config option (use 'section.name=value')</td></tr>
2944 <td>set/override config option (use 'section.name=value')</td></tr>
2943 <tr><td></td>
2945 <tr><td></td>
2944 <td>--debug</td>
2946 <td>--debug</td>
2945 <td>enable debugging output</td></tr>
2947 <td>enable debugging output</td></tr>
2946 <tr><td></td>
2948 <tr><td></td>
2947 <td>--debugger</td>
2949 <td>--debugger</td>
2948 <td>start debugger</td></tr>
2950 <td>start debugger</td></tr>
2949 <tr><td></td>
2951 <tr><td></td>
2950 <td>--encoding ENCODE</td>
2952 <td>--encoding ENCODE</td>
2951 <td>set the charset encoding (default: ascii)</td></tr>
2953 <td>set the charset encoding (default: ascii)</td></tr>
2952 <tr><td></td>
2954 <tr><td></td>
2953 <td>--encodingmode MODE</td>
2955 <td>--encodingmode MODE</td>
2954 <td>set the charset encoding mode (default: strict)</td></tr>
2956 <td>set the charset encoding mode (default: strict)</td></tr>
2955 <tr><td></td>
2957 <tr><td></td>
2956 <td>--traceback</td>
2958 <td>--traceback</td>
2957 <td>always print a traceback on exception</td></tr>
2959 <td>always print a traceback on exception</td></tr>
2958 <tr><td></td>
2960 <tr><td></td>
2959 <td>--time</td>
2961 <td>--time</td>
2960 <td>time how long the command takes</td></tr>
2962 <td>time how long the command takes</td></tr>
2961 <tr><td></td>
2963 <tr><td></td>
2962 <td>--profile</td>
2964 <td>--profile</td>
2963 <td>print command execution profile</td></tr>
2965 <td>print command execution profile</td></tr>
2964 <tr><td></td>
2966 <tr><td></td>
2965 <td>--version</td>
2967 <td>--version</td>
2966 <td>output version information and exit</td></tr>
2968 <td>output version information and exit</td></tr>
2967 <tr><td>-h</td>
2969 <tr><td>-h</td>
2968 <td>--help</td>
2970 <td>--help</td>
2969 <td>display help and exit</td></tr>
2971 <td>display help and exit</td></tr>
2970 <tr><td></td>
2972 <tr><td></td>
2971 <td>--hidden</td>
2973 <td>--hidden</td>
2972 <td>consider hidden changesets</td></tr>
2974 <td>consider hidden changesets</td></tr>
2973 <tr><td></td>
2975 <tr><td></td>
2974 <td>--pager TYPE</td>
2976 <td>--pager TYPE</td>
2975 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
2977 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
2976 </table>
2978 </table>
2977
2979
2978 </div>
2980 </div>
2979 </div>
2981 </div>
2980 </div>
2982 </div>
2981
2983
2982
2984
2983
2985
2984 </body>
2986 </body>
2985 </html>
2987 </html>
2986
2988
2987
2989
2988 $ get-with-headers.py $LOCALIP:$HGPORT "help/remove"
2990 $ get-with-headers.py $LOCALIP:$HGPORT "help/remove"
2989 200 Script output follows
2991 200 Script output follows
2990
2992
2991 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2993 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2992 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2994 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2993 <head>
2995 <head>
2994 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2996 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2995 <meta name="robots" content="index, nofollow" />
2997 <meta name="robots" content="index, nofollow" />
2996 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2998 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2997 <script type="text/javascript" src="/static/mercurial.js"></script>
2999 <script type="text/javascript" src="/static/mercurial.js"></script>
2998
3000
2999 <title>Help: remove</title>
3001 <title>Help: remove</title>
3000 </head>
3002 </head>
3001 <body>
3003 <body>
3002
3004
3003 <div class="container">
3005 <div class="container">
3004 <div class="menu">
3006 <div class="menu">
3005 <div class="logo">
3007 <div class="logo">
3006 <a href="https://mercurial-scm.org/">
3008 <a href="https://mercurial-scm.org/">
3007 <img src="/static/hglogo.png" alt="mercurial" /></a>
3009 <img src="/static/hglogo.png" alt="mercurial" /></a>
3008 </div>
3010 </div>
3009 <ul>
3011 <ul>
3010 <li><a href="/shortlog">log</a></li>
3012 <li><a href="/shortlog">log</a></li>
3011 <li><a href="/graph">graph</a></li>
3013 <li><a href="/graph">graph</a></li>
3012 <li><a href="/tags">tags</a></li>
3014 <li><a href="/tags">tags</a></li>
3013 <li><a href="/bookmarks">bookmarks</a></li>
3015 <li><a href="/bookmarks">bookmarks</a></li>
3014 <li><a href="/branches">branches</a></li>
3016 <li><a href="/branches">branches</a></li>
3015 </ul>
3017 </ul>
3016 <ul>
3018 <ul>
3017 <li class="active"><a href="/help">help</a></li>
3019 <li class="active"><a href="/help">help</a></li>
3018 </ul>
3020 </ul>
3019 </div>
3021 </div>
3020
3022
3021 <div class="main">
3023 <div class="main">
3022 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3024 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3023 <h3>Help: remove</h3>
3025 <h3>Help: remove</h3>
3024
3026
3025 <form class="search" action="/log">
3027 <form class="search" action="/log">
3026
3028
3027 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3029 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3028 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3030 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3029 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3031 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3030 </form>
3032 </form>
3031 <div id="doc">
3033 <div id="doc">
3032 <p>
3034 <p>
3033 hg remove [OPTION]... FILE...
3035 hg remove [OPTION]... FILE...
3034 </p>
3036 </p>
3035 <p>
3037 <p>
3036 aliases: rm
3038 aliases: rm
3037 </p>
3039 </p>
3038 <p>
3040 <p>
3039 remove the specified files on the next commit
3041 remove the specified files on the next commit
3040 </p>
3042 </p>
3041 <p>
3043 <p>
3042 Schedule the indicated files for removal from the current branch.
3044 Schedule the indicated files for removal from the current branch.
3043 </p>
3045 </p>
3044 <p>
3046 <p>
3045 This command schedules the files to be removed at the next commit.
3047 This command schedules the files to be removed at the next commit.
3046 To undo a remove before that, see 'hg revert'. To undo added
3048 To undo a remove before that, see 'hg revert'. To undo added
3047 files, see 'hg forget'.
3049 files, see 'hg forget'.
3048 </p>
3050 </p>
3049 <p>
3051 <p>
3050 -A/--after can be used to remove only files that have already
3052 -A/--after can be used to remove only files that have already
3051 been deleted, -f/--force can be used to force deletion, and -Af
3053 been deleted, -f/--force can be used to force deletion, and -Af
3052 can be used to remove files from the next revision without
3054 can be used to remove files from the next revision without
3053 deleting them from the working directory.
3055 deleting them from the working directory.
3054 </p>
3056 </p>
3055 <p>
3057 <p>
3056 The following table details the behavior of remove for different
3058 The following table details the behavior of remove for different
3057 file states (columns) and option combinations (rows). The file
3059 file states (columns) and option combinations (rows). The file
3058 states are Added [A], Clean [C], Modified [M] and Missing [!]
3060 states are Added [A], Clean [C], Modified [M] and Missing [!]
3059 (as reported by 'hg status'). The actions are Warn, Remove
3061 (as reported by 'hg status'). The actions are Warn, Remove
3060 (from branch) and Delete (from disk):
3062 (from branch) and Delete (from disk):
3061 </p>
3063 </p>
3062 <table>
3064 <table>
3063 <tr><td>opt/state</td>
3065 <tr><td>opt/state</td>
3064 <td>A</td>
3066 <td>A</td>
3065 <td>C</td>
3067 <td>C</td>
3066 <td>M</td>
3068 <td>M</td>
3067 <td>!</td></tr>
3069 <td>!</td></tr>
3068 <tr><td>none</td>
3070 <tr><td>none</td>
3069 <td>W</td>
3071 <td>W</td>
3070 <td>RD</td>
3072 <td>RD</td>
3071 <td>W</td>
3073 <td>W</td>
3072 <td>R</td></tr>
3074 <td>R</td></tr>
3073 <tr><td>-f</td>
3075 <tr><td>-f</td>
3074 <td>R</td>
3076 <td>R</td>
3075 <td>RD</td>
3077 <td>RD</td>
3076 <td>RD</td>
3078 <td>RD</td>
3077 <td>R</td></tr>
3079 <td>R</td></tr>
3078 <tr><td>-A</td>
3080 <tr><td>-A</td>
3079 <td>W</td>
3081 <td>W</td>
3080 <td>W</td>
3082 <td>W</td>
3081 <td>W</td>
3083 <td>W</td>
3082 <td>R</td></tr>
3084 <td>R</td></tr>
3083 <tr><td>-Af</td>
3085 <tr><td>-Af</td>
3084 <td>R</td>
3086 <td>R</td>
3085 <td>R</td>
3087 <td>R</td>
3086 <td>R</td>
3088 <td>R</td>
3087 <td>R</td></tr>
3089 <td>R</td></tr>
3088 </table>
3090 </table>
3089 <p>
3091 <p>
3090 <b>Note:</b>
3092 <b>Note:</b>
3091 </p>
3093 </p>
3092 <p>
3094 <p>
3093 'hg remove' never deletes files in Added [A] state from the
3095 'hg remove' never deletes files in Added [A] state from the
3094 working directory, not even if &quot;--force&quot; is specified.
3096 working directory, not even if &quot;--force&quot; is specified.
3095 </p>
3097 </p>
3096 <p>
3098 <p>
3097 Returns 0 on success, 1 if any warnings encountered.
3099 Returns 0 on success, 1 if any warnings encountered.
3098 </p>
3100 </p>
3099 <p>
3101 <p>
3100 options ([+] can be repeated):
3102 options ([+] can be repeated):
3101 </p>
3103 </p>
3102 <table>
3104 <table>
3103 <tr><td>-A</td>
3105 <tr><td>-A</td>
3104 <td>--after</td>
3106 <td>--after</td>
3105 <td>record delete for missing files</td></tr>
3107 <td>record delete for missing files</td></tr>
3106 <tr><td>-f</td>
3108 <tr><td>-f</td>
3107 <td>--force</td>
3109 <td>--force</td>
3108 <td>forget added files, delete modified files</td></tr>
3110 <td>forget added files, delete modified files</td></tr>
3109 <tr><td>-S</td>
3111 <tr><td>-S</td>
3110 <td>--subrepos</td>
3112 <td>--subrepos</td>
3111 <td>recurse into subrepositories</td></tr>
3113 <td>recurse into subrepositories</td></tr>
3112 <tr><td>-I</td>
3114 <tr><td>-I</td>
3113 <td>--include PATTERN [+]</td>
3115 <td>--include PATTERN [+]</td>
3114 <td>include names matching the given patterns</td></tr>
3116 <td>include names matching the given patterns</td></tr>
3115 <tr><td>-X</td>
3117 <tr><td>-X</td>
3116 <td>--exclude PATTERN [+]</td>
3118 <td>--exclude PATTERN [+]</td>
3117 <td>exclude names matching the given patterns</td></tr>
3119 <td>exclude names matching the given patterns</td></tr>
3118 <tr><td>-n</td>
3120 <tr><td>-n</td>
3119 <td>--dry-run</td>
3121 <td>--dry-run</td>
3120 <td>do not perform actions, just print output</td></tr>
3122 <td>do not perform actions, just print output</td></tr>
3121 </table>
3123 </table>
3122 <p>
3124 <p>
3123 global options ([+] can be repeated):
3125 global options ([+] can be repeated):
3124 </p>
3126 </p>
3125 <table>
3127 <table>
3126 <tr><td>-R</td>
3128 <tr><td>-R</td>
3127 <td>--repository REPO</td>
3129 <td>--repository REPO</td>
3128 <td>repository root directory or name of overlay bundle file</td></tr>
3130 <td>repository root directory or name of overlay bundle file</td></tr>
3129 <tr><td></td>
3131 <tr><td></td>
3130 <td>--cwd DIR</td>
3132 <td>--cwd DIR</td>
3131 <td>change working directory</td></tr>
3133 <td>change working directory</td></tr>
3132 <tr><td>-y</td>
3134 <tr><td>-y</td>
3133 <td>--noninteractive</td>
3135 <td>--noninteractive</td>
3134 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
3136 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
3135 <tr><td>-q</td>
3137 <tr><td>-q</td>
3136 <td>--quiet</td>
3138 <td>--quiet</td>
3137 <td>suppress output</td></tr>
3139 <td>suppress output</td></tr>
3138 <tr><td>-v</td>
3140 <tr><td>-v</td>
3139 <td>--verbose</td>
3141 <td>--verbose</td>
3140 <td>enable additional output</td></tr>
3142 <td>enable additional output</td></tr>
3141 <tr><td></td>
3143 <tr><td></td>
3142 <td>--color TYPE</td>
3144 <td>--color TYPE</td>
3143 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
3145 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
3144 <tr><td></td>
3146 <tr><td></td>
3145 <td>--config CONFIG [+]</td>
3147 <td>--config CONFIG [+]</td>
3146 <td>set/override config option (use 'section.name=value')</td></tr>
3148 <td>set/override config option (use 'section.name=value')</td></tr>
3147 <tr><td></td>
3149 <tr><td></td>
3148 <td>--debug</td>
3150 <td>--debug</td>
3149 <td>enable debugging output</td></tr>
3151 <td>enable debugging output</td></tr>
3150 <tr><td></td>
3152 <tr><td></td>
3151 <td>--debugger</td>
3153 <td>--debugger</td>
3152 <td>start debugger</td></tr>
3154 <td>start debugger</td></tr>
3153 <tr><td></td>
3155 <tr><td></td>
3154 <td>--encoding ENCODE</td>
3156 <td>--encoding ENCODE</td>
3155 <td>set the charset encoding (default: ascii)</td></tr>
3157 <td>set the charset encoding (default: ascii)</td></tr>
3156 <tr><td></td>
3158 <tr><td></td>
3157 <td>--encodingmode MODE</td>
3159 <td>--encodingmode MODE</td>
3158 <td>set the charset encoding mode (default: strict)</td></tr>
3160 <td>set the charset encoding mode (default: strict)</td></tr>
3159 <tr><td></td>
3161 <tr><td></td>
3160 <td>--traceback</td>
3162 <td>--traceback</td>
3161 <td>always print a traceback on exception</td></tr>
3163 <td>always print a traceback on exception</td></tr>
3162 <tr><td></td>
3164 <tr><td></td>
3163 <td>--time</td>
3165 <td>--time</td>
3164 <td>time how long the command takes</td></tr>
3166 <td>time how long the command takes</td></tr>
3165 <tr><td></td>
3167 <tr><td></td>
3166 <td>--profile</td>
3168 <td>--profile</td>
3167 <td>print command execution profile</td></tr>
3169 <td>print command execution profile</td></tr>
3168 <tr><td></td>
3170 <tr><td></td>
3169 <td>--version</td>
3171 <td>--version</td>
3170 <td>output version information and exit</td></tr>
3172 <td>output version information and exit</td></tr>
3171 <tr><td>-h</td>
3173 <tr><td>-h</td>
3172 <td>--help</td>
3174 <td>--help</td>
3173 <td>display help and exit</td></tr>
3175 <td>display help and exit</td></tr>
3174 <tr><td></td>
3176 <tr><td></td>
3175 <td>--hidden</td>
3177 <td>--hidden</td>
3176 <td>consider hidden changesets</td></tr>
3178 <td>consider hidden changesets</td></tr>
3177 <tr><td></td>
3179 <tr><td></td>
3178 <td>--pager TYPE</td>
3180 <td>--pager TYPE</td>
3179 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
3181 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
3180 </table>
3182 </table>
3181
3183
3182 </div>
3184 </div>
3183 </div>
3185 </div>
3184 </div>
3186 </div>
3185
3187
3186
3188
3187
3189
3188 </body>
3190 </body>
3189 </html>
3191 </html>
3190
3192
3191
3193
3192 $ get-with-headers.py $LOCALIP:$HGPORT "help/dates"
3194 $ get-with-headers.py $LOCALIP:$HGPORT "help/dates"
3193 200 Script output follows
3195 200 Script output follows
3194
3196
3195 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3197 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3196 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3198 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3197 <head>
3199 <head>
3198 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3200 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3199 <meta name="robots" content="index, nofollow" />
3201 <meta name="robots" content="index, nofollow" />
3200 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3202 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3201 <script type="text/javascript" src="/static/mercurial.js"></script>
3203 <script type="text/javascript" src="/static/mercurial.js"></script>
3202
3204
3203 <title>Help: dates</title>
3205 <title>Help: dates</title>
3204 </head>
3206 </head>
3205 <body>
3207 <body>
3206
3208
3207 <div class="container">
3209 <div class="container">
3208 <div class="menu">
3210 <div class="menu">
3209 <div class="logo">
3211 <div class="logo">
3210 <a href="https://mercurial-scm.org/">
3212 <a href="https://mercurial-scm.org/">
3211 <img src="/static/hglogo.png" alt="mercurial" /></a>
3213 <img src="/static/hglogo.png" alt="mercurial" /></a>
3212 </div>
3214 </div>
3213 <ul>
3215 <ul>
3214 <li><a href="/shortlog">log</a></li>
3216 <li><a href="/shortlog">log</a></li>
3215 <li><a href="/graph">graph</a></li>
3217 <li><a href="/graph">graph</a></li>
3216 <li><a href="/tags">tags</a></li>
3218 <li><a href="/tags">tags</a></li>
3217 <li><a href="/bookmarks">bookmarks</a></li>
3219 <li><a href="/bookmarks">bookmarks</a></li>
3218 <li><a href="/branches">branches</a></li>
3220 <li><a href="/branches">branches</a></li>
3219 </ul>
3221 </ul>
3220 <ul>
3222 <ul>
3221 <li class="active"><a href="/help">help</a></li>
3223 <li class="active"><a href="/help">help</a></li>
3222 </ul>
3224 </ul>
3223 </div>
3225 </div>
3224
3226
3225 <div class="main">
3227 <div class="main">
3226 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3228 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3227 <h3>Help: dates</h3>
3229 <h3>Help: dates</h3>
3228
3230
3229 <form class="search" action="/log">
3231 <form class="search" action="/log">
3230
3232
3231 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3233 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3232 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3234 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3233 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3235 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3234 </form>
3236 </form>
3235 <div id="doc">
3237 <div id="doc">
3236 <h1>Date Formats</h1>
3238 <h1>Date Formats</h1>
3237 <p>
3239 <p>
3238 Some commands allow the user to specify a date, e.g.:
3240 Some commands allow the user to specify a date, e.g.:
3239 </p>
3241 </p>
3240 <ul>
3242 <ul>
3241 <li> backout, commit, import, tag: Specify the commit date.
3243 <li> backout, commit, import, tag: Specify the commit date.
3242 <li> log, revert, update: Select revision(s) by date.
3244 <li> log, revert, update: Select revision(s) by date.
3243 </ul>
3245 </ul>
3244 <p>
3246 <p>
3245 Many date formats are valid. Here are some examples:
3247 Many date formats are valid. Here are some examples:
3246 </p>
3248 </p>
3247 <ul>
3249 <ul>
3248 <li> &quot;Wed Dec 6 13:18:29 2006&quot; (local timezone assumed)
3250 <li> &quot;Wed Dec 6 13:18:29 2006&quot; (local timezone assumed)
3249 <li> &quot;Dec 6 13:18 -0600&quot; (year assumed, time offset provided)
3251 <li> &quot;Dec 6 13:18 -0600&quot; (year assumed, time offset provided)
3250 <li> &quot;Dec 6 13:18 UTC&quot; (UTC and GMT are aliases for +0000)
3252 <li> &quot;Dec 6 13:18 UTC&quot; (UTC and GMT are aliases for +0000)
3251 <li> &quot;Dec 6&quot; (midnight)
3253 <li> &quot;Dec 6&quot; (midnight)
3252 <li> &quot;13:18&quot; (today assumed)
3254 <li> &quot;13:18&quot; (today assumed)
3253 <li> &quot;3:39&quot; (3:39AM assumed)
3255 <li> &quot;3:39&quot; (3:39AM assumed)
3254 <li> &quot;3:39pm&quot; (15:39)
3256 <li> &quot;3:39pm&quot; (15:39)
3255 <li> &quot;2006-12-06 13:18:29&quot; (ISO 8601 format)
3257 <li> &quot;2006-12-06 13:18:29&quot; (ISO 8601 format)
3256 <li> &quot;2006-12-6 13:18&quot;
3258 <li> &quot;2006-12-6 13:18&quot;
3257 <li> &quot;2006-12-6&quot;
3259 <li> &quot;2006-12-6&quot;
3258 <li> &quot;12-6&quot;
3260 <li> &quot;12-6&quot;
3259 <li> &quot;12/6&quot;
3261 <li> &quot;12/6&quot;
3260 <li> &quot;12/6/6&quot; (Dec 6 2006)
3262 <li> &quot;12/6/6&quot; (Dec 6 2006)
3261 <li> &quot;today&quot; (midnight)
3263 <li> &quot;today&quot; (midnight)
3262 <li> &quot;yesterday&quot; (midnight)
3264 <li> &quot;yesterday&quot; (midnight)
3263 <li> &quot;now&quot; - right now
3265 <li> &quot;now&quot; - right now
3264 </ul>
3266 </ul>
3265 <p>
3267 <p>
3266 Lastly, there is Mercurial's internal format:
3268 Lastly, there is Mercurial's internal format:
3267 </p>
3269 </p>
3268 <ul>
3270 <ul>
3269 <li> &quot;1165411109 0&quot; (Wed Dec 6 13:18:29 2006 UTC)
3271 <li> &quot;1165411109 0&quot; (Wed Dec 6 13:18:29 2006 UTC)
3270 </ul>
3272 </ul>
3271 <p>
3273 <p>
3272 This is the internal representation format for dates. The first number
3274 This is the internal representation format for dates. The first number
3273 is the number of seconds since the epoch (1970-01-01 00:00 UTC). The
3275 is the number of seconds since the epoch (1970-01-01 00:00 UTC). The
3274 second is the offset of the local timezone, in seconds west of UTC
3276 second is the offset of the local timezone, in seconds west of UTC
3275 (negative if the timezone is east of UTC).
3277 (negative if the timezone is east of UTC).
3276 </p>
3278 </p>
3277 <p>
3279 <p>
3278 The log command also accepts date ranges:
3280 The log command also accepts date ranges:
3279 </p>
3281 </p>
3280 <ul>
3282 <ul>
3281 <li> &quot;&lt;DATE&quot; - at or before a given date/time
3283 <li> &quot;&lt;DATE&quot; - at or before a given date/time
3282 <li> &quot;&gt;DATE&quot; - on or after a given date/time
3284 <li> &quot;&gt;DATE&quot; - on or after a given date/time
3283 <li> &quot;DATE to DATE&quot; - a date range, inclusive
3285 <li> &quot;DATE to DATE&quot; - a date range, inclusive
3284 <li> &quot;-DAYS&quot; - within a given number of days from today
3286 <li> &quot;-DAYS&quot; - within a given number of days from today
3285 </ul>
3287 </ul>
3286
3288
3287 </div>
3289 </div>
3288 </div>
3290 </div>
3289 </div>
3291 </div>
3290
3292
3291
3293
3292
3294
3293 </body>
3295 </body>
3294 </html>
3296 </html>
3295
3297
3296
3298
3297 $ get-with-headers.py $LOCALIP:$HGPORT "help/pager"
3299 $ get-with-headers.py $LOCALIP:$HGPORT "help/pager"
3298 200 Script output follows
3300 200 Script output follows
3299
3301
3300 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3302 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3301 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3303 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3302 <head>
3304 <head>
3303 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3305 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3304 <meta name="robots" content="index, nofollow" />
3306 <meta name="robots" content="index, nofollow" />
3305 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3307 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3306 <script type="text/javascript" src="/static/mercurial.js"></script>
3308 <script type="text/javascript" src="/static/mercurial.js"></script>
3307
3309
3308 <title>Help: pager</title>
3310 <title>Help: pager</title>
3309 </head>
3311 </head>
3310 <body>
3312 <body>
3311
3313
3312 <div class="container">
3314 <div class="container">
3313 <div class="menu">
3315 <div class="menu">
3314 <div class="logo">
3316 <div class="logo">
3315 <a href="https://mercurial-scm.org/">
3317 <a href="https://mercurial-scm.org/">
3316 <img src="/static/hglogo.png" alt="mercurial" /></a>
3318 <img src="/static/hglogo.png" alt="mercurial" /></a>
3317 </div>
3319 </div>
3318 <ul>
3320 <ul>
3319 <li><a href="/shortlog">log</a></li>
3321 <li><a href="/shortlog">log</a></li>
3320 <li><a href="/graph">graph</a></li>
3322 <li><a href="/graph">graph</a></li>
3321 <li><a href="/tags">tags</a></li>
3323 <li><a href="/tags">tags</a></li>
3322 <li><a href="/bookmarks">bookmarks</a></li>
3324 <li><a href="/bookmarks">bookmarks</a></li>
3323 <li><a href="/branches">branches</a></li>
3325 <li><a href="/branches">branches</a></li>
3324 </ul>
3326 </ul>
3325 <ul>
3327 <ul>
3326 <li class="active"><a href="/help">help</a></li>
3328 <li class="active"><a href="/help">help</a></li>
3327 </ul>
3329 </ul>
3328 </div>
3330 </div>
3329
3331
3330 <div class="main">
3332 <div class="main">
3331 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3333 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3332 <h3>Help: pager</h3>
3334 <h3>Help: pager</h3>
3333
3335
3334 <form class="search" action="/log">
3336 <form class="search" action="/log">
3335
3337
3336 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3338 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3337 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3339 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3338 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3340 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3339 </form>
3341 </form>
3340 <div id="doc">
3342 <div id="doc">
3341 <h1>Pager Support</h1>
3343 <h1>Pager Support</h1>
3342 <p>
3344 <p>
3343 Some Mercurial commands can produce a lot of output, and Mercurial will
3345 Some Mercurial commands can produce a lot of output, and Mercurial will
3344 attempt to use a pager to make those commands more pleasant.
3346 attempt to use a pager to make those commands more pleasant.
3345 </p>
3347 </p>
3346 <p>
3348 <p>
3347 To set the pager that should be used, set the application variable:
3349 To set the pager that should be used, set the application variable:
3348 </p>
3350 </p>
3349 <pre>
3351 <pre>
3350 [pager]
3352 [pager]
3351 pager = less -FRX
3353 pager = less -FRX
3352 </pre>
3354 </pre>
3353 <p>
3355 <p>
3354 If no pager is set in the user or repository configuration, Mercurial uses the
3356 If no pager is set in the user or repository configuration, Mercurial uses the
3355 environment variable $PAGER. If $PAGER is not set, pager.pager from the default
3357 environment variable $PAGER. If $PAGER is not set, pager.pager from the default
3356 or system configuration is used. If none of these are set, a default pager will
3358 or system configuration is used. If none of these are set, a default pager will
3357 be used, typically 'less' on Unix and 'more' on Windows.
3359 be used, typically 'less' on Unix and 'more' on Windows.
3358 </p>
3360 </p>
3359 <p>
3361 <p>
3360 You can disable the pager for certain commands by adding them to the
3362 You can disable the pager for certain commands by adding them to the
3361 pager.ignore list:
3363 pager.ignore list:
3362 </p>
3364 </p>
3363 <pre>
3365 <pre>
3364 [pager]
3366 [pager]
3365 ignore = version, help, update
3367 ignore = version, help, update
3366 </pre>
3368 </pre>
3367 <p>
3369 <p>
3368 To ignore global commands like 'hg version' or 'hg help', you have
3370 To ignore global commands like 'hg version' or 'hg help', you have
3369 to specify them in your user configuration file.
3371 to specify them in your user configuration file.
3370 </p>
3372 </p>
3371 <p>
3373 <p>
3372 To control whether the pager is used at all for an individual command,
3374 To control whether the pager is used at all for an individual command,
3373 you can use --pager=&lt;value&gt;:
3375 you can use --pager=&lt;value&gt;:
3374 </p>
3376 </p>
3375 <ul>
3377 <ul>
3376 <li> use as needed: 'auto'.
3378 <li> use as needed: 'auto'.
3377 <li> require the pager: 'yes' or 'on'.
3379 <li> require the pager: 'yes' or 'on'.
3378 <li> suppress the pager: 'no' or 'off' (any unrecognized value will also work).
3380 <li> suppress the pager: 'no' or 'off' (any unrecognized value will also work).
3379 </ul>
3381 </ul>
3380 <p>
3382 <p>
3381 To globally turn off all attempts to use a pager, set:
3383 To globally turn off all attempts to use a pager, set:
3382 </p>
3384 </p>
3383 <pre>
3385 <pre>
3384 [ui]
3386 [ui]
3385 paginate = never
3387 paginate = never
3386 </pre>
3388 </pre>
3387 <p>
3389 <p>
3388 which will prevent the pager from running.
3390 which will prevent the pager from running.
3389 </p>
3391 </p>
3390
3392
3391 </div>
3393 </div>
3392 </div>
3394 </div>
3393 </div>
3395 </div>
3394
3396
3395
3397
3396
3398
3397 </body>
3399 </body>
3398 </html>
3400 </html>
3399
3401
3400
3402
3401 Sub-topic indexes rendered properly
3403 Sub-topic indexes rendered properly
3402
3404
3403 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals"
3405 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals"
3404 200 Script output follows
3406 200 Script output follows
3405
3407
3406 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3408 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3407 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3409 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3408 <head>
3410 <head>
3409 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3411 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3410 <meta name="robots" content="index, nofollow" />
3412 <meta name="robots" content="index, nofollow" />
3411 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3413 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3412 <script type="text/javascript" src="/static/mercurial.js"></script>
3414 <script type="text/javascript" src="/static/mercurial.js"></script>
3413
3415
3414 <title>Help: internals</title>
3416 <title>Help: internals</title>
3415 </head>
3417 </head>
3416 <body>
3418 <body>
3417
3419
3418 <div class="container">
3420 <div class="container">
3419 <div class="menu">
3421 <div class="menu">
3420 <div class="logo">
3422 <div class="logo">
3421 <a href="https://mercurial-scm.org/">
3423 <a href="https://mercurial-scm.org/">
3422 <img src="/static/hglogo.png" alt="mercurial" /></a>
3424 <img src="/static/hglogo.png" alt="mercurial" /></a>
3423 </div>
3425 </div>
3424 <ul>
3426 <ul>
3425 <li><a href="/shortlog">log</a></li>
3427 <li><a href="/shortlog">log</a></li>
3426 <li><a href="/graph">graph</a></li>
3428 <li><a href="/graph">graph</a></li>
3427 <li><a href="/tags">tags</a></li>
3429 <li><a href="/tags">tags</a></li>
3428 <li><a href="/bookmarks">bookmarks</a></li>
3430 <li><a href="/bookmarks">bookmarks</a></li>
3429 <li><a href="/branches">branches</a></li>
3431 <li><a href="/branches">branches</a></li>
3430 </ul>
3432 </ul>
3431 <ul>
3433 <ul>
3432 <li><a href="/help">help</a></li>
3434 <li><a href="/help">help</a></li>
3433 </ul>
3435 </ul>
3434 </div>
3436 </div>
3435
3437
3436 <div class="main">
3438 <div class="main">
3437 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3439 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3438
3440
3439 <form class="search" action="/log">
3441 <form class="search" action="/log">
3440
3442
3441 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3443 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3442 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3444 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3443 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3445 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3444 </form>
3446 </form>
3445 <table class="bigtable">
3447 <table class="bigtable">
3446 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
3448 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
3447
3449
3448 <tr><td>
3450 <tr><td>
3449 <a href="/help/internals.bid-merge">
3451 <a href="/help/internals.bid-merge">
3450 bid-merge
3452 bid-merge
3451 </a>
3453 </a>
3452 </td><td>
3454 </td><td>
3453 Bid Merge Algorithm
3455 Bid Merge Algorithm
3454 </td></tr>
3456 </td></tr>
3455 <tr><td>
3457 <tr><td>
3456 <a href="/help/internals.bundle2">
3458 <a href="/help/internals.bundle2">
3457 bundle2
3459 bundle2
3458 </a>
3460 </a>
3459 </td><td>
3461 </td><td>
3460 Bundle2
3462 Bundle2
3461 </td></tr>
3463 </td></tr>
3462 <tr><td>
3464 <tr><td>
3463 <a href="/help/internals.bundles">
3465 <a href="/help/internals.bundles">
3464 bundles
3466 bundles
3465 </a>
3467 </a>
3466 </td><td>
3468 </td><td>
3467 Bundles
3469 Bundles
3468 </td></tr>
3470 </td></tr>
3469 <tr><td>
3471 <tr><td>
3470 <a href="/help/internals.cbor">
3472 <a href="/help/internals.cbor">
3471 cbor
3473 cbor
3472 </a>
3474 </a>
3473 </td><td>
3475 </td><td>
3474 CBOR
3476 CBOR
3475 </td></tr>
3477 </td></tr>
3476 <tr><td>
3478 <tr><td>
3477 <a href="/help/internals.censor">
3479 <a href="/help/internals.censor">
3478 censor
3480 censor
3479 </a>
3481 </a>
3480 </td><td>
3482 </td><td>
3481 Censor
3483 Censor
3482 </td></tr>
3484 </td></tr>
3483 <tr><td>
3485 <tr><td>
3484 <a href="/help/internals.changegroups">
3486 <a href="/help/internals.changegroups">
3485 changegroups
3487 changegroups
3486 </a>
3488 </a>
3487 </td><td>
3489 </td><td>
3488 Changegroups
3490 Changegroups
3489 </td></tr>
3491 </td></tr>
3490 <tr><td>
3492 <tr><td>
3491 <a href="/help/internals.config">
3493 <a href="/help/internals.config">
3492 config
3494 config
3493 </a>
3495 </a>
3494 </td><td>
3496 </td><td>
3495 Config Registrar
3497 Config Registrar
3496 </td></tr>
3498 </td></tr>
3497 <tr><td>
3499 <tr><td>
3498 <a href="/help/internals.extensions">
3500 <a href="/help/internals.extensions">
3499 extensions
3501 extensions
3500 </a>
3502 </a>
3501 </td><td>
3503 </td><td>
3502 Extension API
3504 Extension API
3503 </td></tr>
3505 </td></tr>
3504 <tr><td>
3506 <tr><td>
3505 <a href="/help/internals.mergestate">
3507 <a href="/help/internals.mergestate">
3506 mergestate
3508 mergestate
3507 </a>
3509 </a>
3508 </td><td>
3510 </td><td>
3509 Mergestate
3511 Mergestate
3510 </td></tr>
3512 </td></tr>
3511 <tr><td>
3513 <tr><td>
3512 <a href="/help/internals.requirements">
3514 <a href="/help/internals.requirements">
3513 requirements
3515 requirements
3514 </a>
3516 </a>
3515 </td><td>
3517 </td><td>
3516 Repository Requirements
3518 Repository Requirements
3517 </td></tr>
3519 </td></tr>
3518 <tr><td>
3520 <tr><td>
3519 <a href="/help/internals.revlogs">
3521 <a href="/help/internals.revlogs">
3520 revlogs
3522 revlogs
3521 </a>
3523 </a>
3522 </td><td>
3524 </td><td>
3523 Revision Logs
3525 Revision Logs
3524 </td></tr>
3526 </td></tr>
3525 <tr><td>
3527 <tr><td>
3526 <a href="/help/internals.wireprotocol">
3528 <a href="/help/internals.wireprotocol">
3527 wireprotocol
3529 wireprotocol
3528 </a>
3530 </a>
3529 </td><td>
3531 </td><td>
3530 Wire Protocol
3532 Wire Protocol
3531 </td></tr>
3533 </td></tr>
3532 <tr><td>
3534 <tr><td>
3533 <a href="/help/internals.wireprotocolrpc">
3535 <a href="/help/internals.wireprotocolrpc">
3534 wireprotocolrpc
3536 wireprotocolrpc
3535 </a>
3537 </a>
3536 </td><td>
3538 </td><td>
3537 Wire Protocol RPC
3539 Wire Protocol RPC
3538 </td></tr>
3540 </td></tr>
3539 <tr><td>
3541 <tr><td>
3540 <a href="/help/internals.wireprotocolv2">
3542 <a href="/help/internals.wireprotocolv2">
3541 wireprotocolv2
3543 wireprotocolv2
3542 </a>
3544 </a>
3543 </td><td>
3545 </td><td>
3544 Wire Protocol Version 2
3546 Wire Protocol Version 2
3545 </td></tr>
3547 </td></tr>
3546
3548
3547
3549
3548
3550
3549
3551
3550
3552
3551 </table>
3553 </table>
3552 </div>
3554 </div>
3553 </div>
3555 </div>
3554
3556
3555
3557
3556
3558
3557 </body>
3559 </body>
3558 </html>
3560 </html>
3559
3561
3560
3562
3561 Sub-topic topics rendered properly
3563 Sub-topic topics rendered properly
3562
3564
3563 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals.changegroups"
3565 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals.changegroups"
3564 200 Script output follows
3566 200 Script output follows
3565
3567
3566 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3568 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3567 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3569 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3568 <head>
3570 <head>
3569 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3571 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3570 <meta name="robots" content="index, nofollow" />
3572 <meta name="robots" content="index, nofollow" />
3571 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3573 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3572 <script type="text/javascript" src="/static/mercurial.js"></script>
3574 <script type="text/javascript" src="/static/mercurial.js"></script>
3573
3575
3574 <title>Help: internals.changegroups</title>
3576 <title>Help: internals.changegroups</title>
3575 </head>
3577 </head>
3576 <body>
3578 <body>
3577
3579
3578 <div class="container">
3580 <div class="container">
3579 <div class="menu">
3581 <div class="menu">
3580 <div class="logo">
3582 <div class="logo">
3581 <a href="https://mercurial-scm.org/">
3583 <a href="https://mercurial-scm.org/">
3582 <img src="/static/hglogo.png" alt="mercurial" /></a>
3584 <img src="/static/hglogo.png" alt="mercurial" /></a>
3583 </div>
3585 </div>
3584 <ul>
3586 <ul>
3585 <li><a href="/shortlog">log</a></li>
3587 <li><a href="/shortlog">log</a></li>
3586 <li><a href="/graph">graph</a></li>
3588 <li><a href="/graph">graph</a></li>
3587 <li><a href="/tags">tags</a></li>
3589 <li><a href="/tags">tags</a></li>
3588 <li><a href="/bookmarks">bookmarks</a></li>
3590 <li><a href="/bookmarks">bookmarks</a></li>
3589 <li><a href="/branches">branches</a></li>
3591 <li><a href="/branches">branches</a></li>
3590 </ul>
3592 </ul>
3591 <ul>
3593 <ul>
3592 <li class="active"><a href="/help">help</a></li>
3594 <li class="active"><a href="/help">help</a></li>
3593 </ul>
3595 </ul>
3594 </div>
3596 </div>
3595
3597
3596 <div class="main">
3598 <div class="main">
3597 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3599 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3598 <h3>Help: internals.changegroups</h3>
3600 <h3>Help: internals.changegroups</h3>
3599
3601
3600 <form class="search" action="/log">
3602 <form class="search" action="/log">
3601
3603
3602 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3604 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3603 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3605 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3604 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3606 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3605 </form>
3607 </form>
3606 <div id="doc">
3608 <div id="doc">
3607 <h1>Changegroups</h1>
3609 <h1>Changegroups</h1>
3608 <p>
3610 <p>
3609 Changegroups are representations of repository revlog data, specifically
3611 Changegroups are representations of repository revlog data, specifically
3610 the changelog data, root/flat manifest data, treemanifest data, and
3612 the changelog data, root/flat manifest data, treemanifest data, and
3611 filelogs.
3613 filelogs.
3612 </p>
3614 </p>
3613 <p>
3615 <p>
3614 There are 3 versions of changegroups: &quot;1&quot;, &quot;2&quot;, and &quot;3&quot;. From a
3616 There are 3 versions of changegroups: &quot;1&quot;, &quot;2&quot;, and &quot;3&quot;. From a
3615 high-level, versions &quot;1&quot; and &quot;2&quot; are almost exactly the same, with the
3617 high-level, versions &quot;1&quot; and &quot;2&quot; are almost exactly the same, with the
3616 only difference being an additional item in the *delta header*. Version
3618 only difference being an additional item in the *delta header*. Version
3617 &quot;3&quot; adds support for storage flags in the *delta header* and optionally
3619 &quot;3&quot; adds support for storage flags in the *delta header* and optionally
3618 exchanging treemanifests (enabled by setting an option on the
3620 exchanging treemanifests (enabled by setting an option on the
3619 &quot;changegroup&quot; part in the bundle2).
3621 &quot;changegroup&quot; part in the bundle2).
3620 </p>
3622 </p>
3621 <p>
3623 <p>
3622 Changegroups when not exchanging treemanifests consist of 3 logical
3624 Changegroups when not exchanging treemanifests consist of 3 logical
3623 segments:
3625 segments:
3624 </p>
3626 </p>
3625 <pre>
3627 <pre>
3626 +---------------------------------+
3628 +---------------------------------+
3627 | | | |
3629 | | | |
3628 | changeset | manifest | filelogs |
3630 | changeset | manifest | filelogs |
3629 | | | |
3631 | | | |
3630 | | | |
3632 | | | |
3631 +---------------------------------+
3633 +---------------------------------+
3632 </pre>
3634 </pre>
3633 <p>
3635 <p>
3634 When exchanging treemanifests, there are 4 logical segments:
3636 When exchanging treemanifests, there are 4 logical segments:
3635 </p>
3637 </p>
3636 <pre>
3638 <pre>
3637 +-------------------------------------------------+
3639 +-------------------------------------------------+
3638 | | | | |
3640 | | | | |
3639 | changeset | root | treemanifests | filelogs |
3641 | changeset | root | treemanifests | filelogs |
3640 | | manifest | | |
3642 | | manifest | | |
3641 | | | | |
3643 | | | | |
3642 +-------------------------------------------------+
3644 +-------------------------------------------------+
3643 </pre>
3645 </pre>
3644 <p>
3646 <p>
3645 The principle building block of each segment is a *chunk*. A *chunk*
3647 The principle building block of each segment is a *chunk*. A *chunk*
3646 is a framed piece of data:
3648 is a framed piece of data:
3647 </p>
3649 </p>
3648 <pre>
3650 <pre>
3649 +---------------------------------------+
3651 +---------------------------------------+
3650 | | |
3652 | | |
3651 | length | data |
3653 | length | data |
3652 | (4 bytes) | (&lt;length - 4&gt; bytes) |
3654 | (4 bytes) | (&lt;length - 4&gt; bytes) |
3653 | | |
3655 | | |
3654 +---------------------------------------+
3656 +---------------------------------------+
3655 </pre>
3657 </pre>
3656 <p>
3658 <p>
3657 All integers are big-endian signed integers. Each chunk starts with a 32-bit
3659 All integers are big-endian signed integers. Each chunk starts with a 32-bit
3658 integer indicating the length of the entire chunk (including the length field
3660 integer indicating the length of the entire chunk (including the length field
3659 itself).
3661 itself).
3660 </p>
3662 </p>
3661 <p>
3663 <p>
3662 There is a special case chunk that has a value of 0 for the length
3664 There is a special case chunk that has a value of 0 for the length
3663 (&quot;0x00000000&quot;). We call this an *empty chunk*.
3665 (&quot;0x00000000&quot;). We call this an *empty chunk*.
3664 </p>
3666 </p>
3665 <h2>Delta Groups</h2>
3667 <h2>Delta Groups</h2>
3666 <p>
3668 <p>
3667 A *delta group* expresses the content of a revlog as a series of deltas,
3669 A *delta group* expresses the content of a revlog as a series of deltas,
3668 or patches against previous revisions.
3670 or patches against previous revisions.
3669 </p>
3671 </p>
3670 <p>
3672 <p>
3671 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
3673 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
3672 to signal the end of the delta group:
3674 to signal the end of the delta group:
3673 </p>
3675 </p>
3674 <pre>
3676 <pre>
3675 +------------------------------------------------------------------------+
3677 +------------------------------------------------------------------------+
3676 | | | | | |
3678 | | | | | |
3677 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
3679 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
3678 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
3680 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
3679 | | | | | |
3681 | | | | | |
3680 +------------------------------------------------------------------------+
3682 +------------------------------------------------------------------------+
3681 </pre>
3683 </pre>
3682 <p>
3684 <p>
3683 Each *chunk*'s data consists of the following:
3685 Each *chunk*'s data consists of the following:
3684 </p>
3686 </p>
3685 <pre>
3687 <pre>
3686 +---------------------------------------+
3688 +---------------------------------------+
3687 | | |
3689 | | |
3688 | delta header | delta data |
3690 | delta header | delta data |
3689 | (various by version) | (various) |
3691 | (various by version) | (various) |
3690 | | |
3692 | | |
3691 +---------------------------------------+
3693 +---------------------------------------+
3692 </pre>
3694 </pre>
3693 <p>
3695 <p>
3694 The *delta data* is a series of *delta*s that describe a diff from an existing
3696 The *delta data* is a series of *delta*s that describe a diff from an existing
3695 entry (either that the recipient already has, or previously specified in the
3697 entry (either that the recipient already has, or previously specified in the
3696 bundle/changegroup).
3698 bundle/changegroup).
3697 </p>
3699 </p>
3698 <p>
3700 <p>
3699 The *delta header* is different between versions &quot;1&quot;, &quot;2&quot;, and
3701 The *delta header* is different between versions &quot;1&quot;, &quot;2&quot;, and
3700 &quot;3&quot; of the changegroup format.
3702 &quot;3&quot; of the changegroup format.
3701 </p>
3703 </p>
3702 <p>
3704 <p>
3703 Version 1 (headerlen=80):
3705 Version 1 (headerlen=80):
3704 </p>
3706 </p>
3705 <pre>
3707 <pre>
3706 +------------------------------------------------------+
3708 +------------------------------------------------------+
3707 | | | | |
3709 | | | | |
3708 | node | p1 node | p2 node | link node |
3710 | node | p1 node | p2 node | link node |
3709 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3711 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3710 | | | | |
3712 | | | | |
3711 +------------------------------------------------------+
3713 +------------------------------------------------------+
3712 </pre>
3714 </pre>
3713 <p>
3715 <p>
3714 Version 2 (headerlen=100):
3716 Version 2 (headerlen=100):
3715 </p>
3717 </p>
3716 <pre>
3718 <pre>
3717 +------------------------------------------------------------------+
3719 +------------------------------------------------------------------+
3718 | | | | | |
3720 | | | | | |
3719 | node | p1 node | p2 node | base node | link node |
3721 | node | p1 node | p2 node | base node | link node |
3720 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3722 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3721 | | | | | |
3723 | | | | | |
3722 +------------------------------------------------------------------+
3724 +------------------------------------------------------------------+
3723 </pre>
3725 </pre>
3724 <p>
3726 <p>
3725 Version 3 (headerlen=102):
3727 Version 3 (headerlen=102):
3726 </p>
3728 </p>
3727 <pre>
3729 <pre>
3728 +------------------------------------------------------------------------------+
3730 +------------------------------------------------------------------------------+
3729 | | | | | | |
3731 | | | | | | |
3730 | node | p1 node | p2 node | base node | link node | flags |
3732 | node | p1 node | p2 node | base node | link node | flags |
3731 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
3733 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
3732 | | | | | | |
3734 | | | | | | |
3733 +------------------------------------------------------------------------------+
3735 +------------------------------------------------------------------------------+
3734 </pre>
3736 </pre>
3735 <p>
3737 <p>
3736 The *delta data* consists of &quot;chunklen - 4 - headerlen&quot; bytes, which contain a
3738 The *delta data* consists of &quot;chunklen - 4 - headerlen&quot; bytes, which contain a
3737 series of *delta*s, densely packed (no separators). These deltas describe a diff
3739 series of *delta*s, densely packed (no separators). These deltas describe a diff
3738 from an existing entry (either that the recipient already has, or previously
3740 from an existing entry (either that the recipient already has, or previously
3739 specified in the bundle/changegroup). The format is described more fully in
3741 specified in the bundle/changegroup). The format is described more fully in
3740 &quot;hg help internals.bdiff&quot;, but briefly:
3742 &quot;hg help internals.bdiff&quot;, but briefly:
3741 </p>
3743 </p>
3742 <pre>
3744 <pre>
3743 +---------------------------------------------------------------+
3745 +---------------------------------------------------------------+
3744 | | | | |
3746 | | | | |
3745 | start offset | end offset | new length | content |
3747 | start offset | end offset | new length | content |
3746 | (4 bytes) | (4 bytes) | (4 bytes) | (&lt;new length&gt; bytes) |
3748 | (4 bytes) | (4 bytes) | (4 bytes) | (&lt;new length&gt; bytes) |
3747 | | | | |
3749 | | | | |
3748 +---------------------------------------------------------------+
3750 +---------------------------------------------------------------+
3749 </pre>
3751 </pre>
3750 <p>
3752 <p>
3751 Please note that the length field in the delta data does *not* include itself.
3753 Please note that the length field in the delta data does *not* include itself.
3752 </p>
3754 </p>
3753 <p>
3755 <p>
3754 In version 1, the delta is always applied against the previous node from
3756 In version 1, the delta is always applied against the previous node from
3755 the changegroup or the first parent if this is the first entry in the
3757 the changegroup or the first parent if this is the first entry in the
3756 changegroup.
3758 changegroup.
3757 </p>
3759 </p>
3758 <p>
3760 <p>
3759 In version 2 and up, the delta base node is encoded in the entry in the
3761 In version 2 and up, the delta base node is encoded in the entry in the
3760 changegroup. This allows the delta to be expressed against any parent,
3762 changegroup. This allows the delta to be expressed against any parent,
3761 which can result in smaller deltas and more efficient encoding of data.
3763 which can result in smaller deltas and more efficient encoding of data.
3762 </p>
3764 </p>
3763 <p>
3765 <p>
3764 The *flags* field holds bitwise flags affecting the processing of revision
3766 The *flags* field holds bitwise flags affecting the processing of revision
3765 data. The following flags are defined:
3767 data. The following flags are defined:
3766 </p>
3768 </p>
3767 <dl>
3769 <dl>
3768 <dt>32768
3770 <dt>32768
3769 <dd>Censored revision. The revision's fulltext has been replaced by censor metadata. May only occur on file revisions.
3771 <dd>Censored revision. The revision's fulltext has been replaced by censor metadata. May only occur on file revisions.
3770 <dt>16384
3772 <dt>16384
3771 <dd>Ellipsis revision. Revision hash does not match data (likely due to rewritten parents).
3773 <dd>Ellipsis revision. Revision hash does not match data (likely due to rewritten parents).
3772 <dt>8192
3774 <dt>8192
3773 <dd>Externally stored. The revision fulltext contains &quot;key:value&quot; &quot;\n&quot; delimited metadata defining an object stored elsewhere. Used by the LFS extension.
3775 <dd>Externally stored. The revision fulltext contains &quot;key:value&quot; &quot;\n&quot; delimited metadata defining an object stored elsewhere. Used by the LFS extension.
3774 </dl>
3776 </dl>
3775 <p>
3777 <p>
3776 For historical reasons, the integer values are identical to revlog version 1
3778 For historical reasons, the integer values are identical to revlog version 1
3777 per-revision storage flags and correspond to bits being set in this 2-byte
3779 per-revision storage flags and correspond to bits being set in this 2-byte
3778 field. Bits were allocated starting from the most-significant bit, hence the
3780 field. Bits were allocated starting from the most-significant bit, hence the
3779 reverse ordering and allocation of these flags.
3781 reverse ordering and allocation of these flags.
3780 </p>
3782 </p>
3781 <h2>Changeset Segment</h2>
3783 <h2>Changeset Segment</h2>
3782 <p>
3784 <p>
3783 The *changeset segment* consists of a single *delta group* holding
3785 The *changeset segment* consists of a single *delta group* holding
3784 changelog data. The *empty chunk* at the end of the *delta group* denotes
3786 changelog data. The *empty chunk* at the end of the *delta group* denotes
3785 the boundary to the *manifest segment*.
3787 the boundary to the *manifest segment*.
3786 </p>
3788 </p>
3787 <h2>Manifest Segment</h2>
3789 <h2>Manifest Segment</h2>
3788 <p>
3790 <p>
3789 The *manifest segment* consists of a single *delta group* holding manifest
3791 The *manifest segment* consists of a single *delta group* holding manifest
3790 data. If treemanifests are in use, it contains only the manifest for the
3792 data. If treemanifests are in use, it contains only the manifest for the
3791 root directory of the repository. Otherwise, it contains the entire
3793 root directory of the repository. Otherwise, it contains the entire
3792 manifest data. The *empty chunk* at the end of the *delta group* denotes
3794 manifest data. The *empty chunk* at the end of the *delta group* denotes
3793 the boundary to the next segment (either the *treemanifests segment* or the
3795 the boundary to the next segment (either the *treemanifests segment* or the
3794 *filelogs segment*, depending on version and the request options).
3796 *filelogs segment*, depending on version and the request options).
3795 </p>
3797 </p>
3796 <h3>Treemanifests Segment</h3>
3798 <h3>Treemanifests Segment</h3>
3797 <p>
3799 <p>
3798 The *treemanifests segment* only exists in changegroup version &quot;3&quot;, and
3800 The *treemanifests segment* only exists in changegroup version &quot;3&quot;, and
3799 only if the 'treemanifest' param is part of the bundle2 changegroup part
3801 only if the 'treemanifest' param is part of the bundle2 changegroup part
3800 (it is not possible to use changegroup version 3 outside of bundle2).
3802 (it is not possible to use changegroup version 3 outside of bundle2).
3801 Aside from the filenames in the *treemanifests segment* containing a
3803 Aside from the filenames in the *treemanifests segment* containing a
3802 trailing &quot;/&quot; character, it behaves identically to the *filelogs segment*
3804 trailing &quot;/&quot; character, it behaves identically to the *filelogs segment*
3803 (see below). The final sub-segment is followed by an *empty chunk* (logically,
3805 (see below). The final sub-segment is followed by an *empty chunk* (logically,
3804 a sub-segment with filename size 0). This denotes the boundary to the
3806 a sub-segment with filename size 0). This denotes the boundary to the
3805 *filelogs segment*.
3807 *filelogs segment*.
3806 </p>
3808 </p>
3807 <h2>Filelogs Segment</h2>
3809 <h2>Filelogs Segment</h2>
3808 <p>
3810 <p>
3809 The *filelogs segment* consists of multiple sub-segments, each
3811 The *filelogs segment* consists of multiple sub-segments, each
3810 corresponding to an individual file whose data is being described:
3812 corresponding to an individual file whose data is being described:
3811 </p>
3813 </p>
3812 <pre>
3814 <pre>
3813 +--------------------------------------------------+
3815 +--------------------------------------------------+
3814 | | | | | |
3816 | | | | | |
3815 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
3817 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
3816 | | | | | (4 bytes) |
3818 | | | | | (4 bytes) |
3817 | | | | | |
3819 | | | | | |
3818 +--------------------------------------------------+
3820 +--------------------------------------------------+
3819 </pre>
3821 </pre>
3820 <p>
3822 <p>
3821 The final filelog sub-segment is followed by an *empty chunk* (logically,
3823 The final filelog sub-segment is followed by an *empty chunk* (logically,
3822 a sub-segment with filename size 0). This denotes the end of the segment
3824 a sub-segment with filename size 0). This denotes the end of the segment
3823 and of the overall changegroup.
3825 and of the overall changegroup.
3824 </p>
3826 </p>
3825 <p>
3827 <p>
3826 Each filelog sub-segment consists of the following:
3828 Each filelog sub-segment consists of the following:
3827 </p>
3829 </p>
3828 <pre>
3830 <pre>
3829 +------------------------------------------------------+
3831 +------------------------------------------------------+
3830 | | | |
3832 | | | |
3831 | filename length | filename | delta group |
3833 | filename length | filename | delta group |
3832 | (4 bytes) | (&lt;length - 4&gt; bytes) | (various) |
3834 | (4 bytes) | (&lt;length - 4&gt; bytes) | (various) |
3833 | | | |
3835 | | | |
3834 +------------------------------------------------------+
3836 +------------------------------------------------------+
3835 </pre>
3837 </pre>
3836 <p>
3838 <p>
3837 That is, a *chunk* consisting of the filename (not terminated or padded)
3839 That is, a *chunk* consisting of the filename (not terminated or padded)
3838 followed by N chunks constituting the *delta group* for this file. The
3840 followed by N chunks constituting the *delta group* for this file. The
3839 *empty chunk* at the end of each *delta group* denotes the boundary to the
3841 *empty chunk* at the end of each *delta group* denotes the boundary to the
3840 next filelog sub-segment.
3842 next filelog sub-segment.
3841 </p>
3843 </p>
3842
3844
3843 </div>
3845 </div>
3844 </div>
3846 </div>
3845 </div>
3847 </div>
3846
3848
3847
3849
3848
3850
3849 </body>
3851 </body>
3850 </html>
3852 </html>
3851
3853
3852
3854
3853 $ get-with-headers.py 127.0.0.1:$HGPORT "help/unknowntopic"
3855 $ get-with-headers.py 127.0.0.1:$HGPORT "help/unknowntopic"
3854 404 Not Found
3856 404 Not Found
3855
3857
3856 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3858 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3857 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3859 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3858 <head>
3860 <head>
3859 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3861 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3860 <meta name="robots" content="index, nofollow" />
3862 <meta name="robots" content="index, nofollow" />
3861 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3863 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3862 <script type="text/javascript" src="/static/mercurial.js"></script>
3864 <script type="text/javascript" src="/static/mercurial.js"></script>
3863
3865
3864 <title>test: error</title>
3866 <title>test: error</title>
3865 </head>
3867 </head>
3866 <body>
3868 <body>
3867
3869
3868 <div class="container">
3870 <div class="container">
3869 <div class="menu">
3871 <div class="menu">
3870 <div class="logo">
3872 <div class="logo">
3871 <a href="https://mercurial-scm.org/">
3873 <a href="https://mercurial-scm.org/">
3872 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial" /></a>
3874 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial" /></a>
3873 </div>
3875 </div>
3874 <ul>
3876 <ul>
3875 <li><a href="/shortlog">log</a></li>
3877 <li><a href="/shortlog">log</a></li>
3876 <li><a href="/graph">graph</a></li>
3878 <li><a href="/graph">graph</a></li>
3877 <li><a href="/tags">tags</a></li>
3879 <li><a href="/tags">tags</a></li>
3878 <li><a href="/bookmarks">bookmarks</a></li>
3880 <li><a href="/bookmarks">bookmarks</a></li>
3879 <li><a href="/branches">branches</a></li>
3881 <li><a href="/branches">branches</a></li>
3880 </ul>
3882 </ul>
3881 <ul>
3883 <ul>
3882 <li><a href="/help">help</a></li>
3884 <li><a href="/help">help</a></li>
3883 </ul>
3885 </ul>
3884 </div>
3886 </div>
3885
3887
3886 <div class="main">
3888 <div class="main">
3887
3889
3888 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3890 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3889 <h3>error</h3>
3891 <h3>error</h3>
3890
3892
3891
3893
3892 <form class="search" action="/log">
3894 <form class="search" action="/log">
3893
3895
3894 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3896 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3895 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3897 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3896 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3898 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3897 </form>
3899 </form>
3898
3900
3899 <div class="description">
3901 <div class="description">
3900 <p>
3902 <p>
3901 An error occurred while processing your request:
3903 An error occurred while processing your request:
3902 </p>
3904 </p>
3903 <p>
3905 <p>
3904 Not Found
3906 Not Found
3905 </p>
3907 </p>
3906 </div>
3908 </div>
3907 </div>
3909 </div>
3908 </div>
3910 </div>
3909
3911
3910
3912
3911
3913
3912 </body>
3914 </body>
3913 </html>
3915 </html>
3914
3916
3915 [1]
3917 [1]
3916
3918
3917 $ killdaemons.py
3919 $ killdaemons.py
3918
3920
3919 #endif
3921 #endif
General Comments 0
You need to be logged in to leave comments. Login now