##// END OF EJS Templates
push: support config option to require revs be specified when running push...
Kyle Lippincott -
r43433:5617b748 default
parent child Browse files
Show More
@@ -1,7800 +1,7803 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 difflib
10 import difflib
11 import errno
11 import errno
12 import os
12 import os
13 import re
13 import re
14 import sys
14 import sys
15
15
16 from .i18n import _
16 from .i18n import _
17 from .node import (
17 from .node import (
18 hex,
18 hex,
19 nullid,
19 nullid,
20 nullrev,
20 nullrev,
21 short,
21 short,
22 wdirhex,
22 wdirhex,
23 wdirrev,
23 wdirrev,
24 )
24 )
25 from .pycompat import open
25 from .pycompat import open
26 from . import (
26 from . import (
27 archival,
27 archival,
28 bookmarks,
28 bookmarks,
29 bundle2,
29 bundle2,
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 hbisect,
44 hbisect,
45 help,
45 help,
46 hg,
46 hg,
47 logcmdutil,
47 logcmdutil,
48 merge as mergemod,
48 merge as mergemod,
49 narrowspec,
49 narrowspec,
50 obsolete,
50 obsolete,
51 obsutil,
51 obsutil,
52 patch,
52 patch,
53 phases,
53 phases,
54 pycompat,
54 pycompat,
55 rcutil,
55 rcutil,
56 registrar,
56 registrar,
57 revsetlang,
57 revsetlang,
58 rewriteutil,
58 rewriteutil,
59 scmutil,
59 scmutil,
60 server,
60 server,
61 shelve as shelvemod,
61 shelve as shelvemod,
62 state as statemod,
62 state as statemod,
63 streamclone,
63 streamclone,
64 tags as tagsmod,
64 tags as tagsmod,
65 ui as uimod,
65 ui as uimod,
66 util,
66 util,
67 verify as verifymod,
67 verify as verifymod,
68 wireprotoserver,
68 wireprotoserver,
69 )
69 )
70 from .utils import (
70 from .utils import (
71 dateutil,
71 dateutil,
72 stringutil,
72 stringutil,
73 )
73 )
74
74
75 table = {}
75 table = {}
76 table.update(debugcommandsmod.command._table)
76 table.update(debugcommandsmod.command._table)
77
77
78 command = registrar.command(table)
78 command = registrar.command(table)
79 INTENT_READONLY = registrar.INTENT_READONLY
79 INTENT_READONLY = registrar.INTENT_READONLY
80
80
81 # common command options
81 # common command options
82
82
83 globalopts = [
83 globalopts = [
84 (
84 (
85 b'R',
85 b'R',
86 b'repository',
86 b'repository',
87 b'',
87 b'',
88 _(b'repository root directory or name of overlay bundle file'),
88 _(b'repository root directory or name of overlay bundle file'),
89 _(b'REPO'),
89 _(b'REPO'),
90 ),
90 ),
91 (b'', b'cwd', b'', _(b'change working directory'), _(b'DIR')),
91 (b'', b'cwd', b'', _(b'change working directory'), _(b'DIR')),
92 (
92 (
93 b'y',
93 b'y',
94 b'noninteractive',
94 b'noninteractive',
95 None,
95 None,
96 _(
96 _(
97 b'do not prompt, automatically pick the first choice for all prompts'
97 b'do not prompt, automatically pick the first choice for all prompts'
98 ),
98 ),
99 ),
99 ),
100 (b'q', b'quiet', None, _(b'suppress output')),
100 (b'q', b'quiet', None, _(b'suppress output')),
101 (b'v', b'verbose', None, _(b'enable additional output')),
101 (b'v', b'verbose', None, _(b'enable additional output')),
102 (
102 (
103 b'',
103 b'',
104 b'color',
104 b'color',
105 b'',
105 b'',
106 # i18n: 'always', 'auto', 'never', and 'debug' are keywords
106 # i18n: 'always', 'auto', 'never', and 'debug' are keywords
107 # and should not be translated
107 # and should not be translated
108 _(b"when to colorize (boolean, always, auto, never, or debug)"),
108 _(b"when to colorize (boolean, always, auto, never, or debug)"),
109 _(b'TYPE'),
109 _(b'TYPE'),
110 ),
110 ),
111 (
111 (
112 b'',
112 b'',
113 b'config',
113 b'config',
114 [],
114 [],
115 _(b'set/override config option (use \'section.name=value\')'),
115 _(b'set/override config option (use \'section.name=value\')'),
116 _(b'CONFIG'),
116 _(b'CONFIG'),
117 ),
117 ),
118 (b'', b'debug', None, _(b'enable debugging output')),
118 (b'', b'debug', None, _(b'enable debugging output')),
119 (b'', b'debugger', None, _(b'start debugger')),
119 (b'', b'debugger', None, _(b'start debugger')),
120 (
120 (
121 b'',
121 b'',
122 b'encoding',
122 b'encoding',
123 encoding.encoding,
123 encoding.encoding,
124 _(b'set the charset encoding'),
124 _(b'set the charset encoding'),
125 _(b'ENCODE'),
125 _(b'ENCODE'),
126 ),
126 ),
127 (
127 (
128 b'',
128 b'',
129 b'encodingmode',
129 b'encodingmode',
130 encoding.encodingmode,
130 encoding.encodingmode,
131 _(b'set the charset encoding mode'),
131 _(b'set the charset encoding mode'),
132 _(b'MODE'),
132 _(b'MODE'),
133 ),
133 ),
134 (b'', b'traceback', None, _(b'always print a traceback on exception')),
134 (b'', b'traceback', None, _(b'always print a traceback on exception')),
135 (b'', b'time', None, _(b'time how long the command takes')),
135 (b'', b'time', None, _(b'time how long the command takes')),
136 (b'', b'profile', None, _(b'print command execution profile')),
136 (b'', b'profile', None, _(b'print command execution profile')),
137 (b'', b'version', None, _(b'output version information and exit')),
137 (b'', b'version', None, _(b'output version information and exit')),
138 (b'h', b'help', None, _(b'display help and exit')),
138 (b'h', b'help', None, _(b'display help and exit')),
139 (b'', b'hidden', False, _(b'consider hidden changesets')),
139 (b'', b'hidden', False, _(b'consider hidden changesets')),
140 (
140 (
141 b'',
141 b'',
142 b'pager',
142 b'pager',
143 b'auto',
143 b'auto',
144 _(b"when to paginate (boolean, always, auto, or never)"),
144 _(b"when to paginate (boolean, always, auto, or never)"),
145 _(b'TYPE'),
145 _(b'TYPE'),
146 ),
146 ),
147 ]
147 ]
148
148
149 dryrunopts = cmdutil.dryrunopts
149 dryrunopts = cmdutil.dryrunopts
150 remoteopts = cmdutil.remoteopts
150 remoteopts = cmdutil.remoteopts
151 walkopts = cmdutil.walkopts
151 walkopts = cmdutil.walkopts
152 commitopts = cmdutil.commitopts
152 commitopts = cmdutil.commitopts
153 commitopts2 = cmdutil.commitopts2
153 commitopts2 = cmdutil.commitopts2
154 commitopts3 = cmdutil.commitopts3
154 commitopts3 = cmdutil.commitopts3
155 formatteropts = cmdutil.formatteropts
155 formatteropts = cmdutil.formatteropts
156 templateopts = cmdutil.templateopts
156 templateopts = cmdutil.templateopts
157 logopts = cmdutil.logopts
157 logopts = cmdutil.logopts
158 diffopts = cmdutil.diffopts
158 diffopts = cmdutil.diffopts
159 diffwsopts = cmdutil.diffwsopts
159 diffwsopts = cmdutil.diffwsopts
160 diffopts2 = cmdutil.diffopts2
160 diffopts2 = cmdutil.diffopts2
161 mergetoolopts = cmdutil.mergetoolopts
161 mergetoolopts = cmdutil.mergetoolopts
162 similarityopts = cmdutil.similarityopts
162 similarityopts = cmdutil.similarityopts
163 subrepoopts = cmdutil.subrepoopts
163 subrepoopts = cmdutil.subrepoopts
164 debugrevlogopts = cmdutil.debugrevlogopts
164 debugrevlogopts = cmdutil.debugrevlogopts
165
165
166 # Commands start here, listed alphabetically
166 # Commands start here, listed alphabetically
167
167
168
168
169 @command(
169 @command(
170 b'abort',
170 b'abort',
171 dryrunopts,
171 dryrunopts,
172 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
172 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
173 helpbasic=True,
173 helpbasic=True,
174 )
174 )
175 def abort(ui, repo, **opts):
175 def abort(ui, repo, **opts):
176 """abort an unfinished operation (EXPERIMENTAL)
176 """abort an unfinished operation (EXPERIMENTAL)
177
177
178 Aborts a multistep operation like graft, histedit, rebase, merge,
178 Aborts a multistep operation like graft, histedit, rebase, merge,
179 and unshelve if they are in an unfinished state.
179 and unshelve if they are in an unfinished state.
180
180
181 use --dry-run/-n to dry run the command.
181 use --dry-run/-n to dry run the command.
182 """
182 """
183 dryrun = opts.get(r'dry_run')
183 dryrun = opts.get(r'dry_run')
184 abortstate = cmdutil.getunfinishedstate(repo)
184 abortstate = cmdutil.getunfinishedstate(repo)
185 if not abortstate:
185 if not abortstate:
186 raise error.Abort(_(b'no operation in progress'))
186 raise error.Abort(_(b'no operation in progress'))
187 if not abortstate.abortfunc:
187 if not abortstate.abortfunc:
188 raise error.Abort(
188 raise error.Abort(
189 (
189 (
190 _(b"%s in progress but does not support 'hg abort'")
190 _(b"%s in progress but does not support 'hg abort'")
191 % (abortstate._opname)
191 % (abortstate._opname)
192 ),
192 ),
193 hint=abortstate.hint(),
193 hint=abortstate.hint(),
194 )
194 )
195 if dryrun:
195 if dryrun:
196 ui.status(
196 ui.status(
197 _(b'%s in progress, will be aborted\n') % (abortstate._opname)
197 _(b'%s in progress, will be aborted\n') % (abortstate._opname)
198 )
198 )
199 return
199 return
200 return abortstate.abortfunc(ui, repo)
200 return abortstate.abortfunc(ui, repo)
201
201
202
202
203 @command(
203 @command(
204 b'add',
204 b'add',
205 walkopts + subrepoopts + dryrunopts,
205 walkopts + subrepoopts + dryrunopts,
206 _(b'[OPTION]... [FILE]...'),
206 _(b'[OPTION]... [FILE]...'),
207 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
207 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
208 helpbasic=True,
208 helpbasic=True,
209 inferrepo=True,
209 inferrepo=True,
210 )
210 )
211 def add(ui, repo, *pats, **opts):
211 def add(ui, repo, *pats, **opts):
212 """add the specified files on the next commit
212 """add the specified files on the next commit
213
213
214 Schedule files to be version controlled and added to the
214 Schedule files to be version controlled and added to the
215 repository.
215 repository.
216
216
217 The files will be added to the repository at the next commit. To
217 The files will be added to the repository at the next commit. To
218 undo an add before that, see :hg:`forget`.
218 undo an add before that, see :hg:`forget`.
219
219
220 If no names are given, add all files to the repository (except
220 If no names are given, add all files to the repository (except
221 files matching ``.hgignore``).
221 files matching ``.hgignore``).
222
222
223 .. container:: verbose
223 .. container:: verbose
224
224
225 Examples:
225 Examples:
226
226
227 - New (unknown) files are added
227 - New (unknown) files are added
228 automatically by :hg:`add`::
228 automatically by :hg:`add`::
229
229
230 $ ls
230 $ ls
231 foo.c
231 foo.c
232 $ hg status
232 $ hg status
233 ? foo.c
233 ? foo.c
234 $ hg add
234 $ hg add
235 adding foo.c
235 adding foo.c
236 $ hg status
236 $ hg status
237 A foo.c
237 A foo.c
238
238
239 - Specific files to be added can be specified::
239 - Specific files to be added can be specified::
240
240
241 $ ls
241 $ ls
242 bar.c foo.c
242 bar.c foo.c
243 $ hg status
243 $ hg status
244 ? bar.c
244 ? bar.c
245 ? foo.c
245 ? foo.c
246 $ hg add bar.c
246 $ hg add bar.c
247 $ hg status
247 $ hg status
248 A bar.c
248 A bar.c
249 ? foo.c
249 ? foo.c
250
250
251 Returns 0 if all files are successfully added.
251 Returns 0 if all files are successfully added.
252 """
252 """
253
253
254 m = scmutil.match(repo[None], pats, pycompat.byteskwargs(opts))
254 m = scmutil.match(repo[None], pats, pycompat.byteskwargs(opts))
255 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
255 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
256 rejected = cmdutil.add(ui, repo, m, b"", uipathfn, False, **opts)
256 rejected = cmdutil.add(ui, repo, m, b"", uipathfn, False, **opts)
257 return rejected and 1 or 0
257 return rejected and 1 or 0
258
258
259
259
260 @command(
260 @command(
261 b'addremove',
261 b'addremove',
262 similarityopts + subrepoopts + walkopts + dryrunopts,
262 similarityopts + subrepoopts + walkopts + dryrunopts,
263 _(b'[OPTION]... [FILE]...'),
263 _(b'[OPTION]... [FILE]...'),
264 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
264 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
265 inferrepo=True,
265 inferrepo=True,
266 )
266 )
267 def addremove(ui, repo, *pats, **opts):
267 def addremove(ui, repo, *pats, **opts):
268 """add all new files, delete all missing files
268 """add all new files, delete all missing files
269
269
270 Add all new files and remove all missing files from the
270 Add all new files and remove all missing files from the
271 repository.
271 repository.
272
272
273 Unless names are given, new files are ignored if they match any of
273 Unless names are given, new files are ignored if they match any of
274 the patterns in ``.hgignore``. As with add, these changes take
274 the patterns in ``.hgignore``. As with add, these changes take
275 effect at the next commit.
275 effect at the next commit.
276
276
277 Use the -s/--similarity option to detect renamed files. This
277 Use the -s/--similarity option to detect renamed files. This
278 option takes a percentage between 0 (disabled) and 100 (files must
278 option takes a percentage between 0 (disabled) and 100 (files must
279 be identical) as its parameter. With a parameter greater than 0,
279 be identical) as its parameter. With a parameter greater than 0,
280 this compares every removed file with every added file and records
280 this compares every removed file with every added file and records
281 those similar enough as renames. Detecting renamed files this way
281 those similar enough as renames. Detecting renamed files this way
282 can be expensive. After using this option, :hg:`status -C` can be
282 can be expensive. After using this option, :hg:`status -C` can be
283 used to check which files were identified as moved or renamed. If
283 used to check which files were identified as moved or renamed. If
284 not specified, -s/--similarity defaults to 100 and only renames of
284 not specified, -s/--similarity defaults to 100 and only renames of
285 identical files are detected.
285 identical files are detected.
286
286
287 .. container:: verbose
287 .. container:: verbose
288
288
289 Examples:
289 Examples:
290
290
291 - A number of files (bar.c and foo.c) are new,
291 - A number of files (bar.c and foo.c) are new,
292 while foobar.c has been removed (without using :hg:`remove`)
292 while foobar.c has been removed (without using :hg:`remove`)
293 from the repository::
293 from the repository::
294
294
295 $ ls
295 $ ls
296 bar.c foo.c
296 bar.c foo.c
297 $ hg status
297 $ hg status
298 ! foobar.c
298 ! foobar.c
299 ? bar.c
299 ? bar.c
300 ? foo.c
300 ? foo.c
301 $ hg addremove
301 $ hg addremove
302 adding bar.c
302 adding bar.c
303 adding foo.c
303 adding foo.c
304 removing foobar.c
304 removing foobar.c
305 $ hg status
305 $ hg status
306 A bar.c
306 A bar.c
307 A foo.c
307 A foo.c
308 R foobar.c
308 R foobar.c
309
309
310 - A file foobar.c was moved to foo.c without using :hg:`rename`.
310 - A file foobar.c was moved to foo.c without using :hg:`rename`.
311 Afterwards, it was edited slightly::
311 Afterwards, it was edited slightly::
312
312
313 $ ls
313 $ ls
314 foo.c
314 foo.c
315 $ hg status
315 $ hg status
316 ! foobar.c
316 ! foobar.c
317 ? foo.c
317 ? foo.c
318 $ hg addremove --similarity 90
318 $ hg addremove --similarity 90
319 removing foobar.c
319 removing foobar.c
320 adding foo.c
320 adding foo.c
321 recording removal of foobar.c as rename to foo.c (94% similar)
321 recording removal of foobar.c as rename to foo.c (94% similar)
322 $ hg status -C
322 $ hg status -C
323 A foo.c
323 A foo.c
324 foobar.c
324 foobar.c
325 R foobar.c
325 R foobar.c
326
326
327 Returns 0 if all files are successfully added.
327 Returns 0 if all files are successfully added.
328 """
328 """
329 opts = pycompat.byteskwargs(opts)
329 opts = pycompat.byteskwargs(opts)
330 if not opts.get(b'similarity'):
330 if not opts.get(b'similarity'):
331 opts[b'similarity'] = b'100'
331 opts[b'similarity'] = b'100'
332 matcher = scmutil.match(repo[None], pats, opts)
332 matcher = scmutil.match(repo[None], pats, opts)
333 relative = scmutil.anypats(pats, opts)
333 relative = scmutil.anypats(pats, opts)
334 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=relative)
334 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=relative)
335 return scmutil.addremove(repo, matcher, b"", uipathfn, opts)
335 return scmutil.addremove(repo, matcher, b"", uipathfn, opts)
336
336
337
337
338 @command(
338 @command(
339 b'annotate|blame',
339 b'annotate|blame',
340 [
340 [
341 (b'r', b'rev', b'', _(b'annotate the specified revision'), _(b'REV')),
341 (b'r', b'rev', b'', _(b'annotate the specified revision'), _(b'REV')),
342 (
342 (
343 b'',
343 b'',
344 b'follow',
344 b'follow',
345 None,
345 None,
346 _(b'follow copies/renames and list the filename (DEPRECATED)'),
346 _(b'follow copies/renames and list the filename (DEPRECATED)'),
347 ),
347 ),
348 (b'', b'no-follow', None, _(b"don't follow copies and renames")),
348 (b'', b'no-follow', None, _(b"don't follow copies and renames")),
349 (b'a', b'text', None, _(b'treat all files as text')),
349 (b'a', b'text', None, _(b'treat all files as text')),
350 (b'u', b'user', None, _(b'list the author (long with -v)')),
350 (b'u', b'user', None, _(b'list the author (long with -v)')),
351 (b'f', b'file', None, _(b'list the filename')),
351 (b'f', b'file', None, _(b'list the filename')),
352 (b'd', b'date', None, _(b'list the date (short with -q)')),
352 (b'd', b'date', None, _(b'list the date (short with -q)')),
353 (b'n', b'number', None, _(b'list the revision number (default)')),
353 (b'n', b'number', None, _(b'list the revision number (default)')),
354 (b'c', b'changeset', None, _(b'list the changeset')),
354 (b'c', b'changeset', None, _(b'list the changeset')),
355 (
355 (
356 b'l',
356 b'l',
357 b'line-number',
357 b'line-number',
358 None,
358 None,
359 _(b'show line number at the first appearance'),
359 _(b'show line number at the first appearance'),
360 ),
360 ),
361 (
361 (
362 b'',
362 b'',
363 b'skip',
363 b'skip',
364 [],
364 [],
365 _(b'revision to not display (EXPERIMENTAL)'),
365 _(b'revision to not display (EXPERIMENTAL)'),
366 _(b'REV'),
366 _(b'REV'),
367 ),
367 ),
368 ]
368 ]
369 + diffwsopts
369 + diffwsopts
370 + walkopts
370 + walkopts
371 + formatteropts,
371 + formatteropts,
372 _(b'[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
372 _(b'[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
373 helpcategory=command.CATEGORY_FILE_CONTENTS,
373 helpcategory=command.CATEGORY_FILE_CONTENTS,
374 helpbasic=True,
374 helpbasic=True,
375 inferrepo=True,
375 inferrepo=True,
376 )
376 )
377 def annotate(ui, repo, *pats, **opts):
377 def annotate(ui, repo, *pats, **opts):
378 """show changeset information by line for each file
378 """show changeset information by line for each file
379
379
380 List changes in files, showing the revision id responsible for
380 List changes in files, showing the revision id responsible for
381 each line.
381 each line.
382
382
383 This command is useful for discovering when a change was made and
383 This command is useful for discovering when a change was made and
384 by whom.
384 by whom.
385
385
386 If you include --file, --user, or --date, the revision number is
386 If you include --file, --user, or --date, the revision number is
387 suppressed unless you also include --number.
387 suppressed unless you also include --number.
388
388
389 Without the -a/--text option, annotate will avoid processing files
389 Without the -a/--text option, annotate will avoid processing files
390 it detects as binary. With -a, annotate will annotate the file
390 it detects as binary. With -a, annotate will annotate the file
391 anyway, although the results will probably be neither useful
391 anyway, although the results will probably be neither useful
392 nor desirable.
392 nor desirable.
393
393
394 .. container:: verbose
394 .. container:: verbose
395
395
396 Template:
396 Template:
397
397
398 The following keywords are supported in addition to the common template
398 The following keywords are supported in addition to the common template
399 keywords and functions. See also :hg:`help templates`.
399 keywords and functions. See also :hg:`help templates`.
400
400
401 :lines: List of lines with annotation data.
401 :lines: List of lines with annotation data.
402 :path: String. Repository-absolute path of the specified file.
402 :path: String. Repository-absolute path of the specified file.
403
403
404 And each entry of ``{lines}`` provides the following sub-keywords in
404 And each entry of ``{lines}`` provides the following sub-keywords in
405 addition to ``{date}``, ``{node}``, ``{rev}``, ``{user}``, etc.
405 addition to ``{date}``, ``{node}``, ``{rev}``, ``{user}``, etc.
406
406
407 :line: String. Line content.
407 :line: String. Line content.
408 :lineno: Integer. Line number at that revision.
408 :lineno: Integer. Line number at that revision.
409 :path: String. Repository-absolute path of the file at that revision.
409 :path: String. Repository-absolute path of the file at that revision.
410
410
411 See :hg:`help templates.operators` for the list expansion syntax.
411 See :hg:`help templates.operators` for the list expansion syntax.
412
412
413 Returns 0 on success.
413 Returns 0 on success.
414 """
414 """
415 opts = pycompat.byteskwargs(opts)
415 opts = pycompat.byteskwargs(opts)
416 if not pats:
416 if not pats:
417 raise error.Abort(_(b'at least one filename or pattern is required'))
417 raise error.Abort(_(b'at least one filename or pattern is required'))
418
418
419 if opts.get(b'follow'):
419 if opts.get(b'follow'):
420 # --follow is deprecated and now just an alias for -f/--file
420 # --follow is deprecated and now just an alias for -f/--file
421 # to mimic the behavior of Mercurial before version 1.5
421 # to mimic the behavior of Mercurial before version 1.5
422 opts[b'file'] = True
422 opts[b'file'] = True
423
423
424 if (
424 if (
425 not opts.get(b'user')
425 not opts.get(b'user')
426 and not opts.get(b'changeset')
426 and not opts.get(b'changeset')
427 and not opts.get(b'date')
427 and not opts.get(b'date')
428 and not opts.get(b'file')
428 and not opts.get(b'file')
429 ):
429 ):
430 opts[b'number'] = True
430 opts[b'number'] = True
431
431
432 linenumber = opts.get(b'line_number') is not None
432 linenumber = opts.get(b'line_number') is not None
433 if (
433 if (
434 linenumber
434 linenumber
435 and (not opts.get(b'changeset'))
435 and (not opts.get(b'changeset'))
436 and (not opts.get(b'number'))
436 and (not opts.get(b'number'))
437 ):
437 ):
438 raise error.Abort(_(b'at least one of -n/-c is required for -l'))
438 raise error.Abort(_(b'at least one of -n/-c is required for -l'))
439
439
440 rev = opts.get(b'rev')
440 rev = opts.get(b'rev')
441 if rev:
441 if rev:
442 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
442 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
443 ctx = scmutil.revsingle(repo, rev)
443 ctx = scmutil.revsingle(repo, rev)
444
444
445 ui.pager(b'annotate')
445 ui.pager(b'annotate')
446 rootfm = ui.formatter(b'annotate', opts)
446 rootfm = ui.formatter(b'annotate', opts)
447 if ui.debugflag:
447 if ui.debugflag:
448 shorthex = pycompat.identity
448 shorthex = pycompat.identity
449 else:
449 else:
450
450
451 def shorthex(h):
451 def shorthex(h):
452 return h[:12]
452 return h[:12]
453
453
454 if ui.quiet:
454 if ui.quiet:
455 datefunc = dateutil.shortdate
455 datefunc = dateutil.shortdate
456 else:
456 else:
457 datefunc = dateutil.datestr
457 datefunc = dateutil.datestr
458 if ctx.rev() is None:
458 if ctx.rev() is None:
459 if opts.get(b'changeset'):
459 if opts.get(b'changeset'):
460 # omit "+" suffix which is appended to node hex
460 # omit "+" suffix which is appended to node hex
461 def formatrev(rev):
461 def formatrev(rev):
462 if rev == wdirrev:
462 if rev == wdirrev:
463 return b'%d' % ctx.p1().rev()
463 return b'%d' % ctx.p1().rev()
464 else:
464 else:
465 return b'%d' % rev
465 return b'%d' % rev
466
466
467 else:
467 else:
468
468
469 def formatrev(rev):
469 def formatrev(rev):
470 if rev == wdirrev:
470 if rev == wdirrev:
471 return b'%d+' % ctx.p1().rev()
471 return b'%d+' % ctx.p1().rev()
472 else:
472 else:
473 return b'%d ' % rev
473 return b'%d ' % rev
474
474
475 def formathex(h):
475 def formathex(h):
476 if h == wdirhex:
476 if h == wdirhex:
477 return b'%s+' % shorthex(hex(ctx.p1().node()))
477 return b'%s+' % shorthex(hex(ctx.p1().node()))
478 else:
478 else:
479 return b'%s ' % shorthex(h)
479 return b'%s ' % shorthex(h)
480
480
481 else:
481 else:
482 formatrev = b'%d'.__mod__
482 formatrev = b'%d'.__mod__
483 formathex = shorthex
483 formathex = shorthex
484
484
485 opmap = [
485 opmap = [
486 (b'user', b' ', lambda x: x.fctx.user(), ui.shortuser),
486 (b'user', b' ', lambda x: x.fctx.user(), ui.shortuser),
487 (b'rev', b' ', lambda x: scmutil.intrev(x.fctx), formatrev),
487 (b'rev', b' ', lambda x: scmutil.intrev(x.fctx), formatrev),
488 (b'node', b' ', lambda x: hex(scmutil.binnode(x.fctx)), formathex),
488 (b'node', b' ', lambda x: hex(scmutil.binnode(x.fctx)), formathex),
489 (b'date', b' ', lambda x: x.fctx.date(), util.cachefunc(datefunc)),
489 (b'date', b' ', lambda x: x.fctx.date(), util.cachefunc(datefunc)),
490 (b'path', b' ', lambda x: x.fctx.path(), pycompat.bytestr),
490 (b'path', b' ', lambda x: x.fctx.path(), pycompat.bytestr),
491 (b'lineno', b':', lambda x: x.lineno, pycompat.bytestr),
491 (b'lineno', b':', lambda x: x.lineno, pycompat.bytestr),
492 ]
492 ]
493 opnamemap = {
493 opnamemap = {
494 b'rev': b'number',
494 b'rev': b'number',
495 b'node': b'changeset',
495 b'node': b'changeset',
496 b'path': b'file',
496 b'path': b'file',
497 b'lineno': b'line_number',
497 b'lineno': b'line_number',
498 }
498 }
499
499
500 if rootfm.isplain():
500 if rootfm.isplain():
501
501
502 def makefunc(get, fmt):
502 def makefunc(get, fmt):
503 return lambda x: fmt(get(x))
503 return lambda x: fmt(get(x))
504
504
505 else:
505 else:
506
506
507 def makefunc(get, fmt):
507 def makefunc(get, fmt):
508 return get
508 return get
509
509
510 datahint = rootfm.datahint()
510 datahint = rootfm.datahint()
511 funcmap = [
511 funcmap = [
512 (makefunc(get, fmt), sep)
512 (makefunc(get, fmt), sep)
513 for fn, sep, get, fmt in opmap
513 for fn, sep, get, fmt in opmap
514 if opts.get(opnamemap.get(fn, fn)) or fn in datahint
514 if opts.get(opnamemap.get(fn, fn)) or fn in datahint
515 ]
515 ]
516 funcmap[0] = (funcmap[0][0], b'') # no separator in front of first column
516 funcmap[0] = (funcmap[0][0], b'') # no separator in front of first column
517 fields = b' '.join(
517 fields = b' '.join(
518 fn
518 fn
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
522
523 def bad(x, y):
523 def bad(x, y):
524 raise error.Abort(b"%s: %s" % (x, y))
524 raise error.Abort(b"%s: %s" % (x, y))
525
525
526 m = scmutil.match(ctx, pats, opts, badfn=bad)
526 m = scmutil.match(ctx, pats, opts, badfn=bad)
527
527
528 follow = not opts.get(b'no_follow')
528 follow = not opts.get(b'no_follow')
529 diffopts = patch.difffeatureopts(
529 diffopts = patch.difffeatureopts(
530 ui, opts, section=b'annotate', whitespace=True
530 ui, opts, section=b'annotate', whitespace=True
531 )
531 )
532 skiprevs = opts.get(b'skip')
532 skiprevs = opts.get(b'skip')
533 if skiprevs:
533 if skiprevs:
534 skiprevs = scmutil.revrange(repo, skiprevs)
534 skiprevs = scmutil.revrange(repo, skiprevs)
535
535
536 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
536 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
537 for abs in ctx.walk(m):
537 for abs in ctx.walk(m):
538 fctx = ctx[abs]
538 fctx = ctx[abs]
539 rootfm.startitem()
539 rootfm.startitem()
540 rootfm.data(path=abs)
540 rootfm.data(path=abs)
541 if not opts.get(b'text') and fctx.isbinary():
541 if not opts.get(b'text') and fctx.isbinary():
542 rootfm.plain(_(b"%s: binary file\n") % uipathfn(abs))
542 rootfm.plain(_(b"%s: binary file\n") % uipathfn(abs))
543 continue
543 continue
544
544
545 fm = rootfm.nested(b'lines', tmpl=b'{rev}: {line}')
545 fm = rootfm.nested(b'lines', tmpl=b'{rev}: {line}')
546 lines = fctx.annotate(
546 lines = fctx.annotate(
547 follow=follow, skiprevs=skiprevs, diffopts=diffopts
547 follow=follow, skiprevs=skiprevs, diffopts=diffopts
548 )
548 )
549 if not lines:
549 if not lines:
550 fm.end()
550 fm.end()
551 continue
551 continue
552 formats = []
552 formats = []
553 pieces = []
553 pieces = []
554
554
555 for f, sep in funcmap:
555 for f, sep in funcmap:
556 l = [f(n) for n in lines]
556 l = [f(n) for n in lines]
557 if fm.isplain():
557 if fm.isplain():
558 sizes = [encoding.colwidth(x) for x in l]
558 sizes = [encoding.colwidth(x) for x in l]
559 ml = max(sizes)
559 ml = max(sizes)
560 formats.append([sep + b' ' * (ml - w) + b'%s' for w in sizes])
560 formats.append([sep + b' ' * (ml - w) + b'%s' for w in sizes])
561 else:
561 else:
562 formats.append([b'%s' for x in l])
562 formats.append([b'%s' for x in l])
563 pieces.append(l)
563 pieces.append(l)
564
564
565 for f, p, n in zip(zip(*formats), zip(*pieces), lines):
565 for f, p, n in zip(zip(*formats), zip(*pieces), lines):
566 fm.startitem()
566 fm.startitem()
567 fm.context(fctx=n.fctx)
567 fm.context(fctx=n.fctx)
568 fm.write(fields, b"".join(f), *p)
568 fm.write(fields, b"".join(f), *p)
569 if n.skip:
569 if n.skip:
570 fmt = b"* %s"
570 fmt = b"* %s"
571 else:
571 else:
572 fmt = b": %s"
572 fmt = b": %s"
573 fm.write(b'line', fmt, n.text)
573 fm.write(b'line', fmt, n.text)
574
574
575 if not lines[-1].text.endswith(b'\n'):
575 if not lines[-1].text.endswith(b'\n'):
576 fm.plain(b'\n')
576 fm.plain(b'\n')
577 fm.end()
577 fm.end()
578
578
579 rootfm.end()
579 rootfm.end()
580
580
581
581
582 @command(
582 @command(
583 b'archive',
583 b'archive',
584 [
584 [
585 (b'', b'no-decode', None, _(b'do not pass files through decoders')),
585 (b'', b'no-decode', None, _(b'do not pass files through decoders')),
586 (
586 (
587 b'p',
587 b'p',
588 b'prefix',
588 b'prefix',
589 b'',
589 b'',
590 _(b'directory prefix for files in archive'),
590 _(b'directory prefix for files in archive'),
591 _(b'PREFIX'),
591 _(b'PREFIX'),
592 ),
592 ),
593 (b'r', b'rev', b'', _(b'revision to distribute'), _(b'REV')),
593 (b'r', b'rev', b'', _(b'revision to distribute'), _(b'REV')),
594 (b't', b'type', b'', _(b'type of distribution to create'), _(b'TYPE')),
594 (b't', b'type', b'', _(b'type of distribution to create'), _(b'TYPE')),
595 ]
595 ]
596 + subrepoopts
596 + subrepoopts
597 + walkopts,
597 + walkopts,
598 _(b'[OPTION]... DEST'),
598 _(b'[OPTION]... DEST'),
599 helpcategory=command.CATEGORY_IMPORT_EXPORT,
599 helpcategory=command.CATEGORY_IMPORT_EXPORT,
600 )
600 )
601 def archive(ui, repo, dest, **opts):
601 def archive(ui, repo, dest, **opts):
602 '''create an unversioned archive of a repository revision
602 '''create an unversioned archive of a repository revision
603
603
604 By default, the revision used is the parent of the working
604 By default, the revision used is the parent of the working
605 directory; use -r/--rev to specify a different revision.
605 directory; use -r/--rev to specify a different revision.
606
606
607 The archive type is automatically detected based on file
607 The archive type is automatically detected based on file
608 extension (to override, use -t/--type).
608 extension (to override, use -t/--type).
609
609
610 .. container:: verbose
610 .. container:: verbose
611
611
612 Examples:
612 Examples:
613
613
614 - create a zip file containing the 1.0 release::
614 - create a zip file containing the 1.0 release::
615
615
616 hg archive -r 1.0 project-1.0.zip
616 hg archive -r 1.0 project-1.0.zip
617
617
618 - create a tarball excluding .hg files::
618 - create a tarball excluding .hg files::
619
619
620 hg archive project.tar.gz -X ".hg*"
620 hg archive project.tar.gz -X ".hg*"
621
621
622 Valid types are:
622 Valid types are:
623
623
624 :``files``: a directory full of files (default)
624 :``files``: a directory full of files (default)
625 :``tar``: tar archive, uncompressed
625 :``tar``: tar archive, uncompressed
626 :``tbz2``: tar archive, compressed using bzip2
626 :``tbz2``: tar archive, compressed using bzip2
627 :``tgz``: tar archive, compressed using gzip
627 :``tgz``: tar archive, compressed using gzip
628 :``txz``: tar archive, compressed using lzma (only in Python 3)
628 :``txz``: tar archive, compressed using lzma (only in Python 3)
629 :``uzip``: zip archive, uncompressed
629 :``uzip``: zip archive, uncompressed
630 :``zip``: zip archive, compressed using deflate
630 :``zip``: zip archive, compressed using deflate
631
631
632 The exact name of the destination archive or directory is given
632 The exact name of the destination archive or directory is given
633 using a format string; see :hg:`help export` for details.
633 using a format string; see :hg:`help export` for details.
634
634
635 Each member added to an archive file has a directory prefix
635 Each member added to an archive file has a directory prefix
636 prepended. Use -p/--prefix to specify a format string for the
636 prepended. Use -p/--prefix to specify a format string for the
637 prefix. The default is the basename of the archive, with suffixes
637 prefix. The default is the basename of the archive, with suffixes
638 removed.
638 removed.
639
639
640 Returns 0 on success.
640 Returns 0 on success.
641 '''
641 '''
642
642
643 opts = pycompat.byteskwargs(opts)
643 opts = pycompat.byteskwargs(opts)
644 rev = opts.get(b'rev')
644 rev = opts.get(b'rev')
645 if rev:
645 if rev:
646 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
646 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
647 ctx = scmutil.revsingle(repo, rev)
647 ctx = scmutil.revsingle(repo, rev)
648 if not ctx:
648 if not ctx:
649 raise error.Abort(_(b'no working directory: please specify a revision'))
649 raise error.Abort(_(b'no working directory: please specify a revision'))
650 node = ctx.node()
650 node = ctx.node()
651 dest = cmdutil.makefilename(ctx, dest)
651 dest = cmdutil.makefilename(ctx, dest)
652 if os.path.realpath(dest) == repo.root:
652 if os.path.realpath(dest) == repo.root:
653 raise error.Abort(_(b'repository root cannot be destination'))
653 raise error.Abort(_(b'repository root cannot be destination'))
654
654
655 kind = opts.get(b'type') or archival.guesskind(dest) or b'files'
655 kind = opts.get(b'type') or archival.guesskind(dest) or b'files'
656 prefix = opts.get(b'prefix')
656 prefix = opts.get(b'prefix')
657
657
658 if dest == b'-':
658 if dest == b'-':
659 if kind == b'files':
659 if kind == b'files':
660 raise error.Abort(_(b'cannot archive plain files to stdout'))
660 raise error.Abort(_(b'cannot archive plain files to stdout'))
661 dest = cmdutil.makefileobj(ctx, dest)
661 dest = cmdutil.makefileobj(ctx, dest)
662 if not prefix:
662 if not prefix:
663 prefix = os.path.basename(repo.root) + b'-%h'
663 prefix = os.path.basename(repo.root) + b'-%h'
664
664
665 prefix = cmdutil.makefilename(ctx, prefix)
665 prefix = cmdutil.makefilename(ctx, prefix)
666 match = scmutil.match(ctx, [], opts)
666 match = scmutil.match(ctx, [], opts)
667 archival.archive(
667 archival.archive(
668 repo,
668 repo,
669 dest,
669 dest,
670 node,
670 node,
671 kind,
671 kind,
672 not opts.get(b'no_decode'),
672 not opts.get(b'no_decode'),
673 match,
673 match,
674 prefix,
674 prefix,
675 subrepos=opts.get(b'subrepos'),
675 subrepos=opts.get(b'subrepos'),
676 )
676 )
677
677
678
678
679 @command(
679 @command(
680 b'backout',
680 b'backout',
681 [
681 [
682 (
682 (
683 b'',
683 b'',
684 b'merge',
684 b'merge',
685 None,
685 None,
686 _(b'merge with old dirstate parent after backout'),
686 _(b'merge with old dirstate parent after backout'),
687 ),
687 ),
688 (
688 (
689 b'',
689 b'',
690 b'commit',
690 b'commit',
691 None,
691 None,
692 _(b'commit if no conflicts were encountered (DEPRECATED)'),
692 _(b'commit if no conflicts were encountered (DEPRECATED)'),
693 ),
693 ),
694 (b'', b'no-commit', None, _(b'do not commit')),
694 (b'', b'no-commit', None, _(b'do not commit')),
695 (
695 (
696 b'',
696 b'',
697 b'parent',
697 b'parent',
698 b'',
698 b'',
699 _(b'parent to choose when backing out merge (DEPRECATED)'),
699 _(b'parent to choose when backing out merge (DEPRECATED)'),
700 _(b'REV'),
700 _(b'REV'),
701 ),
701 ),
702 (b'r', b'rev', b'', _(b'revision to backout'), _(b'REV')),
702 (b'r', b'rev', b'', _(b'revision to backout'), _(b'REV')),
703 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
703 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
704 ]
704 ]
705 + mergetoolopts
705 + mergetoolopts
706 + walkopts
706 + walkopts
707 + commitopts
707 + commitopts
708 + commitopts2,
708 + commitopts2,
709 _(b'[OPTION]... [-r] REV'),
709 _(b'[OPTION]... [-r] REV'),
710 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
710 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
711 )
711 )
712 def backout(ui, repo, node=None, rev=None, **opts):
712 def backout(ui, repo, node=None, rev=None, **opts):
713 '''reverse effect of earlier changeset
713 '''reverse effect of earlier changeset
714
714
715 Prepare a new changeset with the effect of REV undone in the
715 Prepare a new changeset with the effect of REV undone in the
716 current working directory. If no conflicts were encountered,
716 current working directory. If no conflicts were encountered,
717 it will be committed immediately.
717 it will be committed immediately.
718
718
719 If REV is the parent of the working directory, then this new changeset
719 If REV is the parent of the working directory, then this new changeset
720 is committed automatically (unless --no-commit is specified).
720 is committed automatically (unless --no-commit is specified).
721
721
722 .. note::
722 .. note::
723
723
724 :hg:`backout` cannot be used to fix either an unwanted or
724 :hg:`backout` cannot be used to fix either an unwanted or
725 incorrect merge.
725 incorrect merge.
726
726
727 .. container:: verbose
727 .. container:: verbose
728
728
729 Examples:
729 Examples:
730
730
731 - Reverse the effect of the parent of the working directory.
731 - Reverse the effect of the parent of the working directory.
732 This backout will be committed immediately::
732 This backout will be committed immediately::
733
733
734 hg backout -r .
734 hg backout -r .
735
735
736 - Reverse the effect of previous bad revision 23::
736 - Reverse the effect of previous bad revision 23::
737
737
738 hg backout -r 23
738 hg backout -r 23
739
739
740 - Reverse the effect of previous bad revision 23 and
740 - Reverse the effect of previous bad revision 23 and
741 leave changes uncommitted::
741 leave changes uncommitted::
742
742
743 hg backout -r 23 --no-commit
743 hg backout -r 23 --no-commit
744 hg commit -m "Backout revision 23"
744 hg commit -m "Backout revision 23"
745
745
746 By default, the pending changeset will have one parent,
746 By default, the pending changeset will have one parent,
747 maintaining a linear history. With --merge, the pending
747 maintaining a linear history. With --merge, the pending
748 changeset will instead have two parents: the old parent of the
748 changeset will instead have two parents: the old parent of the
749 working directory and a new child of REV that simply undoes REV.
749 working directory and a new child of REV that simply undoes REV.
750
750
751 Before version 1.7, the behavior without --merge was equivalent
751 Before version 1.7, the behavior without --merge was equivalent
752 to specifying --merge followed by :hg:`update --clean .` to
752 to specifying --merge followed by :hg:`update --clean .` to
753 cancel the merge and leave the child of REV as a head to be
753 cancel the merge and leave the child of REV as a head to be
754 merged separately.
754 merged separately.
755
755
756 See :hg:`help dates` for a list of formats valid for -d/--date.
756 See :hg:`help dates` for a list of formats valid for -d/--date.
757
757
758 See :hg:`help revert` for a way to restore files to the state
758 See :hg:`help revert` for a way to restore files to the state
759 of another revision.
759 of another revision.
760
760
761 Returns 0 on success, 1 if nothing to backout or there are unresolved
761 Returns 0 on success, 1 if nothing to backout or there are unresolved
762 files.
762 files.
763 '''
763 '''
764 with repo.wlock(), repo.lock():
764 with repo.wlock(), repo.lock():
765 return _dobackout(ui, repo, node, rev, **opts)
765 return _dobackout(ui, repo, node, rev, **opts)
766
766
767
767
768 def _dobackout(ui, repo, node=None, rev=None, **opts):
768 def _dobackout(ui, repo, node=None, rev=None, **opts):
769 opts = pycompat.byteskwargs(opts)
769 opts = pycompat.byteskwargs(opts)
770 if opts.get(b'commit') and opts.get(b'no_commit'):
770 if opts.get(b'commit') and opts.get(b'no_commit'):
771 raise error.Abort(_(b"cannot use --commit with --no-commit"))
771 raise error.Abort(_(b"cannot use --commit with --no-commit"))
772 if opts.get(b'merge') and opts.get(b'no_commit'):
772 if opts.get(b'merge') and opts.get(b'no_commit'):
773 raise error.Abort(_(b"cannot use --merge with --no-commit"))
773 raise error.Abort(_(b"cannot use --merge with --no-commit"))
774
774
775 if rev and node:
775 if rev and node:
776 raise error.Abort(_(b"please specify just one revision"))
776 raise error.Abort(_(b"please specify just one revision"))
777
777
778 if not rev:
778 if not rev:
779 rev = node
779 rev = node
780
780
781 if not rev:
781 if not rev:
782 raise error.Abort(_(b"please specify a revision to backout"))
782 raise error.Abort(_(b"please specify a revision to backout"))
783
783
784 date = opts.get(b'date')
784 date = opts.get(b'date')
785 if date:
785 if date:
786 opts[b'date'] = dateutil.parsedate(date)
786 opts[b'date'] = dateutil.parsedate(date)
787
787
788 cmdutil.checkunfinished(repo)
788 cmdutil.checkunfinished(repo)
789 cmdutil.bailifchanged(repo)
789 cmdutil.bailifchanged(repo)
790 node = scmutil.revsingle(repo, rev).node()
790 node = scmutil.revsingle(repo, rev).node()
791
791
792 op1, op2 = repo.dirstate.parents()
792 op1, op2 = repo.dirstate.parents()
793 if not repo.changelog.isancestor(node, op1):
793 if not repo.changelog.isancestor(node, op1):
794 raise error.Abort(_(b'cannot backout change that is not an ancestor'))
794 raise error.Abort(_(b'cannot backout change that is not an ancestor'))
795
795
796 p1, p2 = repo.changelog.parents(node)
796 p1, p2 = repo.changelog.parents(node)
797 if p1 == nullid:
797 if p1 == nullid:
798 raise error.Abort(_(b'cannot backout a change with no parents'))
798 raise error.Abort(_(b'cannot backout a change with no parents'))
799 if p2 != nullid:
799 if p2 != nullid:
800 if not opts.get(b'parent'):
800 if not opts.get(b'parent'):
801 raise error.Abort(_(b'cannot backout a merge changeset'))
801 raise error.Abort(_(b'cannot backout a merge changeset'))
802 p = repo.lookup(opts[b'parent'])
802 p = repo.lookup(opts[b'parent'])
803 if p not in (p1, p2):
803 if p not in (p1, p2):
804 raise error.Abort(
804 raise error.Abort(
805 _(b'%s is not a parent of %s') % (short(p), short(node))
805 _(b'%s is not a parent of %s') % (short(p), short(node))
806 )
806 )
807 parent = p
807 parent = p
808 else:
808 else:
809 if opts.get(b'parent'):
809 if opts.get(b'parent'):
810 raise error.Abort(_(b'cannot use --parent on non-merge changeset'))
810 raise error.Abort(_(b'cannot use --parent on non-merge changeset'))
811 parent = p1
811 parent = p1
812
812
813 # the backout should appear on the same branch
813 # the backout should appear on the same branch
814 branch = repo.dirstate.branch()
814 branch = repo.dirstate.branch()
815 bheads = repo.branchheads(branch)
815 bheads = repo.branchheads(branch)
816 rctx = scmutil.revsingle(repo, hex(parent))
816 rctx = scmutil.revsingle(repo, hex(parent))
817 if not opts.get(b'merge') and op1 != node:
817 if not opts.get(b'merge') and op1 != node:
818 with dirstateguard.dirstateguard(repo, b'backout'):
818 with dirstateguard.dirstateguard(repo, b'backout'):
819 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
819 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
820 with ui.configoverride(overrides, b'backout'):
820 with ui.configoverride(overrides, b'backout'):
821 stats = mergemod.update(
821 stats = mergemod.update(
822 repo,
822 repo,
823 parent,
823 parent,
824 branchmerge=True,
824 branchmerge=True,
825 force=True,
825 force=True,
826 ancestor=node,
826 ancestor=node,
827 mergeancestor=False,
827 mergeancestor=False,
828 )
828 )
829 repo.setparents(op1, op2)
829 repo.setparents(op1, op2)
830 hg._showstats(repo, stats)
830 hg._showstats(repo, stats)
831 if stats.unresolvedcount:
831 if stats.unresolvedcount:
832 repo.ui.status(
832 repo.ui.status(
833 _(b"use 'hg resolve' to retry unresolved file merges\n")
833 _(b"use 'hg resolve' to retry unresolved file merges\n")
834 )
834 )
835 return 1
835 return 1
836 else:
836 else:
837 hg.clean(repo, node, show_stats=False)
837 hg.clean(repo, node, show_stats=False)
838 repo.dirstate.setbranch(branch)
838 repo.dirstate.setbranch(branch)
839 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
839 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
840
840
841 if opts.get(b'no_commit'):
841 if opts.get(b'no_commit'):
842 msg = _(b"changeset %s backed out, don't forget to commit.\n")
842 msg = _(b"changeset %s backed out, don't forget to commit.\n")
843 ui.status(msg % short(node))
843 ui.status(msg % short(node))
844 return 0
844 return 0
845
845
846 def commitfunc(ui, repo, message, match, opts):
846 def commitfunc(ui, repo, message, match, opts):
847 editform = b'backout'
847 editform = b'backout'
848 e = cmdutil.getcommiteditor(
848 e = cmdutil.getcommiteditor(
849 editform=editform, **pycompat.strkwargs(opts)
849 editform=editform, **pycompat.strkwargs(opts)
850 )
850 )
851 if not message:
851 if not message:
852 # we don't translate commit messages
852 # we don't translate commit messages
853 message = b"Backed out changeset %s" % short(node)
853 message = b"Backed out changeset %s" % short(node)
854 e = cmdutil.getcommiteditor(edit=True, editform=editform)
854 e = cmdutil.getcommiteditor(edit=True, editform=editform)
855 return repo.commit(
855 return repo.commit(
856 message, opts.get(b'user'), opts.get(b'date'), match, editor=e
856 message, opts.get(b'user'), opts.get(b'date'), match, editor=e
857 )
857 )
858
858
859 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
859 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
860 if not newnode:
860 if not newnode:
861 ui.status(_(b"nothing changed\n"))
861 ui.status(_(b"nothing changed\n"))
862 return 1
862 return 1
863 cmdutil.commitstatus(repo, newnode, branch, bheads)
863 cmdutil.commitstatus(repo, newnode, branch, bheads)
864
864
865 def nice(node):
865 def nice(node):
866 return b'%d:%s' % (repo.changelog.rev(node), short(node))
866 return b'%d:%s' % (repo.changelog.rev(node), short(node))
867
867
868 ui.status(
868 ui.status(
869 _(b'changeset %s backs out changeset %s\n')
869 _(b'changeset %s backs out changeset %s\n')
870 % (nice(repo.changelog.tip()), nice(node))
870 % (nice(repo.changelog.tip()), nice(node))
871 )
871 )
872 if opts.get(b'merge') and op1 != node:
872 if opts.get(b'merge') and op1 != node:
873 hg.clean(repo, op1, show_stats=False)
873 hg.clean(repo, op1, show_stats=False)
874 ui.status(
874 ui.status(
875 _(b'merging with changeset %s\n') % nice(repo.changelog.tip())
875 _(b'merging with changeset %s\n') % nice(repo.changelog.tip())
876 )
876 )
877 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
877 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
878 with ui.configoverride(overrides, b'backout'):
878 with ui.configoverride(overrides, b'backout'):
879 return hg.merge(repo, hex(repo.changelog.tip()))
879 return hg.merge(repo, hex(repo.changelog.tip()))
880 return 0
880 return 0
881
881
882
882
883 @command(
883 @command(
884 b'bisect',
884 b'bisect',
885 [
885 [
886 (b'r', b'reset', False, _(b'reset bisect state')),
886 (b'r', b'reset', False, _(b'reset bisect state')),
887 (b'g', b'good', False, _(b'mark changeset good')),
887 (b'g', b'good', False, _(b'mark changeset good')),
888 (b'b', b'bad', False, _(b'mark changeset bad')),
888 (b'b', b'bad', False, _(b'mark changeset bad')),
889 (b's', b'skip', False, _(b'skip testing changeset')),
889 (b's', b'skip', False, _(b'skip testing changeset')),
890 (b'e', b'extend', False, _(b'extend the bisect range')),
890 (b'e', b'extend', False, _(b'extend the bisect range')),
891 (
891 (
892 b'c',
892 b'c',
893 b'command',
893 b'command',
894 b'',
894 b'',
895 _(b'use command to check changeset state'),
895 _(b'use command to check changeset state'),
896 _(b'CMD'),
896 _(b'CMD'),
897 ),
897 ),
898 (b'U', b'noupdate', False, _(b'do not update to target')),
898 (b'U', b'noupdate', False, _(b'do not update to target')),
899 ],
899 ],
900 _(b"[-gbsr] [-U] [-c CMD] [REV]"),
900 _(b"[-gbsr] [-U] [-c CMD] [REV]"),
901 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
901 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
902 )
902 )
903 def bisect(
903 def bisect(
904 ui,
904 ui,
905 repo,
905 repo,
906 rev=None,
906 rev=None,
907 extra=None,
907 extra=None,
908 command=None,
908 command=None,
909 reset=None,
909 reset=None,
910 good=None,
910 good=None,
911 bad=None,
911 bad=None,
912 skip=None,
912 skip=None,
913 extend=None,
913 extend=None,
914 noupdate=None,
914 noupdate=None,
915 ):
915 ):
916 """subdivision search of changesets
916 """subdivision search of changesets
917
917
918 This command helps to find changesets which introduce problems. To
918 This command helps to find changesets which introduce problems. To
919 use, mark the earliest changeset you know exhibits the problem as
919 use, mark the earliest changeset you know exhibits the problem as
920 bad, then mark the latest changeset which is free from the problem
920 bad, then mark the latest changeset which is free from the problem
921 as good. Bisect will update your working directory to a revision
921 as good. Bisect will update your working directory to a revision
922 for testing (unless the -U/--noupdate option is specified). Once
922 for testing (unless the -U/--noupdate option is specified). Once
923 you have performed tests, mark the working directory as good or
923 you have performed tests, mark the working directory as good or
924 bad, and bisect will either update to another candidate changeset
924 bad, and bisect will either update to another candidate changeset
925 or announce that it has found the bad revision.
925 or announce that it has found the bad revision.
926
926
927 As a shortcut, you can also use the revision argument to mark a
927 As a shortcut, you can also use the revision argument to mark a
928 revision as good or bad without checking it out first.
928 revision as good or bad without checking it out first.
929
929
930 If you supply a command, it will be used for automatic bisection.
930 If you supply a command, it will be used for automatic bisection.
931 The environment variable HG_NODE will contain the ID of the
931 The environment variable HG_NODE will contain the ID of the
932 changeset being tested. The exit status of the command will be
932 changeset being tested. The exit status of the command will be
933 used to mark revisions as good or bad: status 0 means good, 125
933 used to mark revisions as good or bad: status 0 means good, 125
934 means to skip the revision, 127 (command not found) will abort the
934 means to skip the revision, 127 (command not found) will abort the
935 bisection, and any other non-zero exit status means the revision
935 bisection, and any other non-zero exit status means the revision
936 is bad.
936 is bad.
937
937
938 .. container:: verbose
938 .. container:: verbose
939
939
940 Some examples:
940 Some examples:
941
941
942 - start a bisection with known bad revision 34, and good revision 12::
942 - start a bisection with known bad revision 34, and good revision 12::
943
943
944 hg bisect --bad 34
944 hg bisect --bad 34
945 hg bisect --good 12
945 hg bisect --good 12
946
946
947 - advance the current bisection by marking current revision as good or
947 - advance the current bisection by marking current revision as good or
948 bad::
948 bad::
949
949
950 hg bisect --good
950 hg bisect --good
951 hg bisect --bad
951 hg bisect --bad
952
952
953 - mark the current revision, or a known revision, to be skipped (e.g. if
953 - mark the current revision, or a known revision, to be skipped (e.g. if
954 that revision is not usable because of another issue)::
954 that revision is not usable because of another issue)::
955
955
956 hg bisect --skip
956 hg bisect --skip
957 hg bisect --skip 23
957 hg bisect --skip 23
958
958
959 - skip all revisions that do not touch directories ``foo`` or ``bar``::
959 - skip all revisions that do not touch directories ``foo`` or ``bar``::
960
960
961 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
961 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
962
962
963 - forget the current bisection::
963 - forget the current bisection::
964
964
965 hg bisect --reset
965 hg bisect --reset
966
966
967 - use 'make && make tests' to automatically find the first broken
967 - use 'make && make tests' to automatically find the first broken
968 revision::
968 revision::
969
969
970 hg bisect --reset
970 hg bisect --reset
971 hg bisect --bad 34
971 hg bisect --bad 34
972 hg bisect --good 12
972 hg bisect --good 12
973 hg bisect --command "make && make tests"
973 hg bisect --command "make && make tests"
974
974
975 - see all changesets whose states are already known in the current
975 - see all changesets whose states are already known in the current
976 bisection::
976 bisection::
977
977
978 hg log -r "bisect(pruned)"
978 hg log -r "bisect(pruned)"
979
979
980 - see the changeset currently being bisected (especially useful
980 - see the changeset currently being bisected (especially useful
981 if running with -U/--noupdate)::
981 if running with -U/--noupdate)::
982
982
983 hg log -r "bisect(current)"
983 hg log -r "bisect(current)"
984
984
985 - see all changesets that took part in the current bisection::
985 - see all changesets that took part in the current bisection::
986
986
987 hg log -r "bisect(range)"
987 hg log -r "bisect(range)"
988
988
989 - you can even get a nice graph::
989 - you can even get a nice graph::
990
990
991 hg log --graph -r "bisect(range)"
991 hg log --graph -r "bisect(range)"
992
992
993 See :hg:`help revisions.bisect` for more about the `bisect()` predicate.
993 See :hg:`help revisions.bisect` for more about the `bisect()` predicate.
994
994
995 Returns 0 on success.
995 Returns 0 on success.
996 """
996 """
997 # backward compatibility
997 # backward compatibility
998 if rev in b"good bad reset init".split():
998 if rev in b"good bad reset init".split():
999 ui.warn(_(b"(use of 'hg bisect <cmd>' is deprecated)\n"))
999 ui.warn(_(b"(use of 'hg bisect <cmd>' is deprecated)\n"))
1000 cmd, rev, extra = rev, extra, None
1000 cmd, rev, extra = rev, extra, None
1001 if cmd == b"good":
1001 if cmd == b"good":
1002 good = True
1002 good = True
1003 elif cmd == b"bad":
1003 elif cmd == b"bad":
1004 bad = True
1004 bad = True
1005 else:
1005 else:
1006 reset = True
1006 reset = True
1007 elif extra:
1007 elif extra:
1008 raise error.Abort(_(b'incompatible arguments'))
1008 raise error.Abort(_(b'incompatible arguments'))
1009
1009
1010 incompatibles = {
1010 incompatibles = {
1011 b'--bad': bad,
1011 b'--bad': bad,
1012 b'--command': bool(command),
1012 b'--command': bool(command),
1013 b'--extend': extend,
1013 b'--extend': extend,
1014 b'--good': good,
1014 b'--good': good,
1015 b'--reset': reset,
1015 b'--reset': reset,
1016 b'--skip': skip,
1016 b'--skip': skip,
1017 }
1017 }
1018
1018
1019 enabled = [x for x in incompatibles if incompatibles[x]]
1019 enabled = [x for x in incompatibles if incompatibles[x]]
1020
1020
1021 if len(enabled) > 1:
1021 if len(enabled) > 1:
1022 raise error.Abort(
1022 raise error.Abort(
1023 _(b'%s and %s are incompatible') % tuple(sorted(enabled)[0:2])
1023 _(b'%s and %s are incompatible') % tuple(sorted(enabled)[0:2])
1024 )
1024 )
1025
1025
1026 if reset:
1026 if reset:
1027 hbisect.resetstate(repo)
1027 hbisect.resetstate(repo)
1028 return
1028 return
1029
1029
1030 state = hbisect.load_state(repo)
1030 state = hbisect.load_state(repo)
1031
1031
1032 # update state
1032 # update state
1033 if good or bad or skip:
1033 if good or bad or skip:
1034 if rev:
1034 if rev:
1035 nodes = [repo[i].node() for i in scmutil.revrange(repo, [rev])]
1035 nodes = [repo[i].node() for i in scmutil.revrange(repo, [rev])]
1036 else:
1036 else:
1037 nodes = [repo.lookup(b'.')]
1037 nodes = [repo.lookup(b'.')]
1038 if good:
1038 if good:
1039 state[b'good'] += nodes
1039 state[b'good'] += nodes
1040 elif bad:
1040 elif bad:
1041 state[b'bad'] += nodes
1041 state[b'bad'] += nodes
1042 elif skip:
1042 elif skip:
1043 state[b'skip'] += nodes
1043 state[b'skip'] += nodes
1044 hbisect.save_state(repo, state)
1044 hbisect.save_state(repo, state)
1045 if not (state[b'good'] and state[b'bad']):
1045 if not (state[b'good'] and state[b'bad']):
1046 return
1046 return
1047
1047
1048 def mayupdate(repo, node, show_stats=True):
1048 def mayupdate(repo, node, show_stats=True):
1049 """common used update sequence"""
1049 """common used update sequence"""
1050 if noupdate:
1050 if noupdate:
1051 return
1051 return
1052 cmdutil.checkunfinished(repo)
1052 cmdutil.checkunfinished(repo)
1053 cmdutil.bailifchanged(repo)
1053 cmdutil.bailifchanged(repo)
1054 return hg.clean(repo, node, show_stats=show_stats)
1054 return hg.clean(repo, node, show_stats=show_stats)
1055
1055
1056 displayer = logcmdutil.changesetdisplayer(ui, repo, {})
1056 displayer = logcmdutil.changesetdisplayer(ui, repo, {})
1057
1057
1058 if command:
1058 if command:
1059 changesets = 1
1059 changesets = 1
1060 if noupdate:
1060 if noupdate:
1061 try:
1061 try:
1062 node = state[b'current'][0]
1062 node = state[b'current'][0]
1063 except LookupError:
1063 except LookupError:
1064 raise error.Abort(
1064 raise error.Abort(
1065 _(
1065 _(
1066 b'current bisect revision is unknown - '
1066 b'current bisect revision is unknown - '
1067 b'start a new bisect to fix'
1067 b'start a new bisect to fix'
1068 )
1068 )
1069 )
1069 )
1070 else:
1070 else:
1071 node, p2 = repo.dirstate.parents()
1071 node, p2 = repo.dirstate.parents()
1072 if p2 != nullid:
1072 if p2 != nullid:
1073 raise error.Abort(_(b'current bisect revision is a merge'))
1073 raise error.Abort(_(b'current bisect revision is a merge'))
1074 if rev:
1074 if rev:
1075 node = repo[scmutil.revsingle(repo, rev, node)].node()
1075 node = repo[scmutil.revsingle(repo, rev, node)].node()
1076 try:
1076 try:
1077 while changesets:
1077 while changesets:
1078 # update state
1078 # update state
1079 state[b'current'] = [node]
1079 state[b'current'] = [node]
1080 hbisect.save_state(repo, state)
1080 hbisect.save_state(repo, state)
1081 status = ui.system(
1081 status = ui.system(
1082 command,
1082 command,
1083 environ={b'HG_NODE': hex(node)},
1083 environ={b'HG_NODE': hex(node)},
1084 blockedtag=b'bisect_check',
1084 blockedtag=b'bisect_check',
1085 )
1085 )
1086 if status == 125:
1086 if status == 125:
1087 transition = b"skip"
1087 transition = b"skip"
1088 elif status == 0:
1088 elif status == 0:
1089 transition = b"good"
1089 transition = b"good"
1090 # status < 0 means process was killed
1090 # status < 0 means process was killed
1091 elif status == 127:
1091 elif status == 127:
1092 raise error.Abort(_(b"failed to execute %s") % command)
1092 raise error.Abort(_(b"failed to execute %s") % command)
1093 elif status < 0:
1093 elif status < 0:
1094 raise error.Abort(_(b"%s killed") % command)
1094 raise error.Abort(_(b"%s killed") % command)
1095 else:
1095 else:
1096 transition = b"bad"
1096 transition = b"bad"
1097 state[transition].append(node)
1097 state[transition].append(node)
1098 ctx = repo[node]
1098 ctx = repo[node]
1099 ui.status(
1099 ui.status(
1100 _(b'changeset %d:%s: %s\n') % (ctx.rev(), ctx, transition)
1100 _(b'changeset %d:%s: %s\n') % (ctx.rev(), ctx, transition)
1101 )
1101 )
1102 hbisect.checkstate(state)
1102 hbisect.checkstate(state)
1103 # bisect
1103 # bisect
1104 nodes, changesets, bgood = hbisect.bisect(repo, state)
1104 nodes, changesets, bgood = hbisect.bisect(repo, state)
1105 # update to next check
1105 # update to next check
1106 node = nodes[0]
1106 node = nodes[0]
1107 mayupdate(repo, node, show_stats=False)
1107 mayupdate(repo, node, show_stats=False)
1108 finally:
1108 finally:
1109 state[b'current'] = [node]
1109 state[b'current'] = [node]
1110 hbisect.save_state(repo, state)
1110 hbisect.save_state(repo, state)
1111 hbisect.printresult(ui, repo, state, displayer, nodes, bgood)
1111 hbisect.printresult(ui, repo, state, displayer, nodes, bgood)
1112 return
1112 return
1113
1113
1114 hbisect.checkstate(state)
1114 hbisect.checkstate(state)
1115
1115
1116 # actually bisect
1116 # actually bisect
1117 nodes, changesets, good = hbisect.bisect(repo, state)
1117 nodes, changesets, good = hbisect.bisect(repo, state)
1118 if extend:
1118 if extend:
1119 if not changesets:
1119 if not changesets:
1120 extendnode = hbisect.extendrange(repo, state, nodes, good)
1120 extendnode = hbisect.extendrange(repo, state, nodes, good)
1121 if extendnode is not None:
1121 if extendnode is not None:
1122 ui.write(
1122 ui.write(
1123 _(b"Extending search to changeset %d:%s\n")
1123 _(b"Extending search to changeset %d:%s\n")
1124 % (extendnode.rev(), extendnode)
1124 % (extendnode.rev(), extendnode)
1125 )
1125 )
1126 state[b'current'] = [extendnode.node()]
1126 state[b'current'] = [extendnode.node()]
1127 hbisect.save_state(repo, state)
1127 hbisect.save_state(repo, state)
1128 return mayupdate(repo, extendnode.node())
1128 return mayupdate(repo, extendnode.node())
1129 raise error.Abort(_(b"nothing to extend"))
1129 raise error.Abort(_(b"nothing to extend"))
1130
1130
1131 if changesets == 0:
1131 if changesets == 0:
1132 hbisect.printresult(ui, repo, state, displayer, nodes, good)
1132 hbisect.printresult(ui, repo, state, displayer, nodes, good)
1133 else:
1133 else:
1134 assert len(nodes) == 1 # only a single node can be tested next
1134 assert len(nodes) == 1 # only a single node can be tested next
1135 node = nodes[0]
1135 node = nodes[0]
1136 # compute the approximate number of remaining tests
1136 # compute the approximate number of remaining tests
1137 tests, size = 0, 2
1137 tests, size = 0, 2
1138 while size <= changesets:
1138 while size <= changesets:
1139 tests, size = tests + 1, size * 2
1139 tests, size = tests + 1, size * 2
1140 rev = repo.changelog.rev(node)
1140 rev = repo.changelog.rev(node)
1141 ui.write(
1141 ui.write(
1142 _(
1142 _(
1143 b"Testing changeset %d:%s "
1143 b"Testing changeset %d:%s "
1144 b"(%d changesets remaining, ~%d tests)\n"
1144 b"(%d changesets remaining, ~%d tests)\n"
1145 )
1145 )
1146 % (rev, short(node), changesets, tests)
1146 % (rev, short(node), changesets, tests)
1147 )
1147 )
1148 state[b'current'] = [node]
1148 state[b'current'] = [node]
1149 hbisect.save_state(repo, state)
1149 hbisect.save_state(repo, state)
1150 return mayupdate(repo, node)
1150 return mayupdate(repo, node)
1151
1151
1152
1152
1153 @command(
1153 @command(
1154 b'bookmarks|bookmark',
1154 b'bookmarks|bookmark',
1155 [
1155 [
1156 (b'f', b'force', False, _(b'force')),
1156 (b'f', b'force', False, _(b'force')),
1157 (b'r', b'rev', b'', _(b'revision for bookmark action'), _(b'REV')),
1157 (b'r', b'rev', b'', _(b'revision for bookmark action'), _(b'REV')),
1158 (b'd', b'delete', False, _(b'delete a given bookmark')),
1158 (b'd', b'delete', False, _(b'delete a given bookmark')),
1159 (b'm', b'rename', b'', _(b'rename a given bookmark'), _(b'OLD')),
1159 (b'm', b'rename', b'', _(b'rename a given bookmark'), _(b'OLD')),
1160 (b'i', b'inactive', False, _(b'mark a bookmark inactive')),
1160 (b'i', b'inactive', False, _(b'mark a bookmark inactive')),
1161 (b'l', b'list', False, _(b'list existing bookmarks')),
1161 (b'l', b'list', False, _(b'list existing bookmarks')),
1162 ]
1162 ]
1163 + formatteropts,
1163 + formatteropts,
1164 _(b'hg bookmarks [OPTIONS]... [NAME]...'),
1164 _(b'hg bookmarks [OPTIONS]... [NAME]...'),
1165 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
1165 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
1166 )
1166 )
1167 def bookmark(ui, repo, *names, **opts):
1167 def bookmark(ui, repo, *names, **opts):
1168 '''create a new bookmark or list existing bookmarks
1168 '''create a new bookmark or list existing bookmarks
1169
1169
1170 Bookmarks are labels on changesets to help track lines of development.
1170 Bookmarks are labels on changesets to help track lines of development.
1171 Bookmarks are unversioned and can be moved, renamed and deleted.
1171 Bookmarks are unversioned and can be moved, renamed and deleted.
1172 Deleting or moving a bookmark has no effect on the associated changesets.
1172 Deleting or moving a bookmark has no effect on the associated changesets.
1173
1173
1174 Creating or updating to a bookmark causes it to be marked as 'active'.
1174 Creating or updating to a bookmark causes it to be marked as 'active'.
1175 The active bookmark is indicated with a '*'.
1175 The active bookmark is indicated with a '*'.
1176 When a commit is made, the active bookmark will advance to the new commit.
1176 When a commit is made, the active bookmark will advance to the new commit.
1177 A plain :hg:`update` will also advance an active bookmark, if possible.
1177 A plain :hg:`update` will also advance an active bookmark, if possible.
1178 Updating away from a bookmark will cause it to be deactivated.
1178 Updating away from a bookmark will cause it to be deactivated.
1179
1179
1180 Bookmarks can be pushed and pulled between repositories (see
1180 Bookmarks can be pushed and pulled between repositories (see
1181 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
1181 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
1182 diverged, a new 'divergent bookmark' of the form 'name@path' will
1182 diverged, a new 'divergent bookmark' of the form 'name@path' will
1183 be created. Using :hg:`merge` will resolve the divergence.
1183 be created. Using :hg:`merge` will resolve the divergence.
1184
1184
1185 Specifying bookmark as '.' to -m/-d/-l options is equivalent to specifying
1185 Specifying bookmark as '.' to -m/-d/-l options is equivalent to specifying
1186 the active bookmark's name.
1186 the active bookmark's name.
1187
1187
1188 A bookmark named '@' has the special property that :hg:`clone` will
1188 A bookmark named '@' has the special property that :hg:`clone` will
1189 check it out by default if it exists.
1189 check it out by default if it exists.
1190
1190
1191 .. container:: verbose
1191 .. container:: verbose
1192
1192
1193 Template:
1193 Template:
1194
1194
1195 The following keywords are supported in addition to the common template
1195 The following keywords are supported in addition to the common template
1196 keywords and functions such as ``{bookmark}``. See also
1196 keywords and functions such as ``{bookmark}``. See also
1197 :hg:`help templates`.
1197 :hg:`help templates`.
1198
1198
1199 :active: Boolean. True if the bookmark is active.
1199 :active: Boolean. True if the bookmark is active.
1200
1200
1201 Examples:
1201 Examples:
1202
1202
1203 - create an active bookmark for a new line of development::
1203 - create an active bookmark for a new line of development::
1204
1204
1205 hg book new-feature
1205 hg book new-feature
1206
1206
1207 - create an inactive bookmark as a place marker::
1207 - create an inactive bookmark as a place marker::
1208
1208
1209 hg book -i reviewed
1209 hg book -i reviewed
1210
1210
1211 - create an inactive bookmark on another changeset::
1211 - create an inactive bookmark on another changeset::
1212
1212
1213 hg book -r .^ tested
1213 hg book -r .^ tested
1214
1214
1215 - rename bookmark turkey to dinner::
1215 - rename bookmark turkey to dinner::
1216
1216
1217 hg book -m turkey dinner
1217 hg book -m turkey dinner
1218
1218
1219 - move the '@' bookmark from another branch::
1219 - move the '@' bookmark from another branch::
1220
1220
1221 hg book -f @
1221 hg book -f @
1222
1222
1223 - print only the active bookmark name::
1223 - print only the active bookmark name::
1224
1224
1225 hg book -ql .
1225 hg book -ql .
1226 '''
1226 '''
1227 opts = pycompat.byteskwargs(opts)
1227 opts = pycompat.byteskwargs(opts)
1228 force = opts.get(b'force')
1228 force = opts.get(b'force')
1229 rev = opts.get(b'rev')
1229 rev = opts.get(b'rev')
1230 inactive = opts.get(b'inactive') # meaning add/rename to inactive bookmark
1230 inactive = opts.get(b'inactive') # meaning add/rename to inactive bookmark
1231
1231
1232 selactions = [k for k in [b'delete', b'rename', b'list'] if opts.get(k)]
1232 selactions = [k for k in [b'delete', b'rename', b'list'] if opts.get(k)]
1233 if len(selactions) > 1:
1233 if len(selactions) > 1:
1234 raise error.Abort(
1234 raise error.Abort(
1235 _(b'--%s and --%s are incompatible') % tuple(selactions[:2])
1235 _(b'--%s and --%s are incompatible') % tuple(selactions[:2])
1236 )
1236 )
1237 if selactions:
1237 if selactions:
1238 action = selactions[0]
1238 action = selactions[0]
1239 elif names or rev:
1239 elif names or rev:
1240 action = b'add'
1240 action = b'add'
1241 elif inactive:
1241 elif inactive:
1242 action = b'inactive' # meaning deactivate
1242 action = b'inactive' # meaning deactivate
1243 else:
1243 else:
1244 action = b'list'
1244 action = b'list'
1245
1245
1246 if rev and action in {b'delete', b'rename', b'list'}:
1246 if rev and action in {b'delete', b'rename', b'list'}:
1247 raise error.Abort(_(b"--rev is incompatible with --%s") % action)
1247 raise error.Abort(_(b"--rev is incompatible with --%s") % action)
1248 if inactive and action in {b'delete', b'list'}:
1248 if inactive and action in {b'delete', b'list'}:
1249 raise error.Abort(_(b"--inactive is incompatible with --%s") % action)
1249 raise error.Abort(_(b"--inactive is incompatible with --%s") % action)
1250 if not names and action in {b'add', b'delete'}:
1250 if not names and action in {b'add', b'delete'}:
1251 raise error.Abort(_(b"bookmark name required"))
1251 raise error.Abort(_(b"bookmark name required"))
1252
1252
1253 if action in {b'add', b'delete', b'rename', b'inactive'}:
1253 if action in {b'add', b'delete', b'rename', b'inactive'}:
1254 with repo.wlock(), repo.lock(), repo.transaction(b'bookmark') as tr:
1254 with repo.wlock(), repo.lock(), repo.transaction(b'bookmark') as tr:
1255 if action == b'delete':
1255 if action == b'delete':
1256 names = pycompat.maplist(repo._bookmarks.expandname, names)
1256 names = pycompat.maplist(repo._bookmarks.expandname, names)
1257 bookmarks.delete(repo, tr, names)
1257 bookmarks.delete(repo, tr, names)
1258 elif action == b'rename':
1258 elif action == b'rename':
1259 if not names:
1259 if not names:
1260 raise error.Abort(_(b"new bookmark name required"))
1260 raise error.Abort(_(b"new bookmark name required"))
1261 elif len(names) > 1:
1261 elif len(names) > 1:
1262 raise error.Abort(_(b"only one new bookmark name allowed"))
1262 raise error.Abort(_(b"only one new bookmark name allowed"))
1263 oldname = repo._bookmarks.expandname(opts[b'rename'])
1263 oldname = repo._bookmarks.expandname(opts[b'rename'])
1264 bookmarks.rename(repo, tr, oldname, names[0], force, inactive)
1264 bookmarks.rename(repo, tr, oldname, names[0], force, inactive)
1265 elif action == b'add':
1265 elif action == b'add':
1266 bookmarks.addbookmarks(repo, tr, names, rev, force, inactive)
1266 bookmarks.addbookmarks(repo, tr, names, rev, force, inactive)
1267 elif action == b'inactive':
1267 elif action == b'inactive':
1268 if len(repo._bookmarks) == 0:
1268 if len(repo._bookmarks) == 0:
1269 ui.status(_(b"no bookmarks set\n"))
1269 ui.status(_(b"no bookmarks set\n"))
1270 elif not repo._activebookmark:
1270 elif not repo._activebookmark:
1271 ui.status(_(b"no active bookmark\n"))
1271 ui.status(_(b"no active bookmark\n"))
1272 else:
1272 else:
1273 bookmarks.deactivate(repo)
1273 bookmarks.deactivate(repo)
1274 elif action == b'list':
1274 elif action == b'list':
1275 names = pycompat.maplist(repo._bookmarks.expandname, names)
1275 names = pycompat.maplist(repo._bookmarks.expandname, names)
1276 with ui.formatter(b'bookmarks', opts) as fm:
1276 with ui.formatter(b'bookmarks', opts) as fm:
1277 bookmarks.printbookmarks(ui, repo, fm, names)
1277 bookmarks.printbookmarks(ui, repo, fm, names)
1278 else:
1278 else:
1279 raise error.ProgrammingError(b'invalid action: %s' % action)
1279 raise error.ProgrammingError(b'invalid action: %s' % action)
1280
1280
1281
1281
1282 @command(
1282 @command(
1283 b'branch',
1283 b'branch',
1284 [
1284 [
1285 (
1285 (
1286 b'f',
1286 b'f',
1287 b'force',
1287 b'force',
1288 None,
1288 None,
1289 _(b'set branch name even if it shadows an existing branch'),
1289 _(b'set branch name even if it shadows an existing branch'),
1290 ),
1290 ),
1291 (b'C', b'clean', None, _(b'reset branch name to parent branch name')),
1291 (b'C', b'clean', None, _(b'reset branch name to parent branch name')),
1292 (
1292 (
1293 b'r',
1293 b'r',
1294 b'rev',
1294 b'rev',
1295 [],
1295 [],
1296 _(b'change branches of the given revs (EXPERIMENTAL)'),
1296 _(b'change branches of the given revs (EXPERIMENTAL)'),
1297 ),
1297 ),
1298 ],
1298 ],
1299 _(b'[-fC] [NAME]'),
1299 _(b'[-fC] [NAME]'),
1300 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
1300 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
1301 )
1301 )
1302 def branch(ui, repo, label=None, **opts):
1302 def branch(ui, repo, label=None, **opts):
1303 """set or show the current branch name
1303 """set or show the current branch name
1304
1304
1305 .. note::
1305 .. note::
1306
1306
1307 Branch names are permanent and global. Use :hg:`bookmark` to create a
1307 Branch names are permanent and global. Use :hg:`bookmark` to create a
1308 light-weight bookmark instead. See :hg:`help glossary` for more
1308 light-weight bookmark instead. See :hg:`help glossary` for more
1309 information about named branches and bookmarks.
1309 information about named branches and bookmarks.
1310
1310
1311 With no argument, show the current branch name. With one argument,
1311 With no argument, show the current branch name. With one argument,
1312 set the working directory branch name (the branch will not exist
1312 set the working directory branch name (the branch will not exist
1313 in the repository until the next commit). Standard practice
1313 in the repository until the next commit). Standard practice
1314 recommends that primary development take place on the 'default'
1314 recommends that primary development take place on the 'default'
1315 branch.
1315 branch.
1316
1316
1317 Unless -f/--force is specified, branch will not let you set a
1317 Unless -f/--force is specified, branch will not let you set a
1318 branch name that already exists.
1318 branch name that already exists.
1319
1319
1320 Use -C/--clean to reset the working directory branch to that of
1320 Use -C/--clean to reset the working directory branch to that of
1321 the parent of the working directory, negating a previous branch
1321 the parent of the working directory, negating a previous branch
1322 change.
1322 change.
1323
1323
1324 Use the command :hg:`update` to switch to an existing branch. Use
1324 Use the command :hg:`update` to switch to an existing branch. Use
1325 :hg:`commit --close-branch` to mark this branch head as closed.
1325 :hg:`commit --close-branch` to mark this branch head as closed.
1326 When all heads of a branch are closed, the branch will be
1326 When all heads of a branch are closed, the branch will be
1327 considered closed.
1327 considered closed.
1328
1328
1329 Returns 0 on success.
1329 Returns 0 on success.
1330 """
1330 """
1331 opts = pycompat.byteskwargs(opts)
1331 opts = pycompat.byteskwargs(opts)
1332 revs = opts.get(b'rev')
1332 revs = opts.get(b'rev')
1333 if label:
1333 if label:
1334 label = label.strip()
1334 label = label.strip()
1335
1335
1336 if not opts.get(b'clean') and not label:
1336 if not opts.get(b'clean') and not label:
1337 if revs:
1337 if revs:
1338 raise error.Abort(_(b"no branch name specified for the revisions"))
1338 raise error.Abort(_(b"no branch name specified for the revisions"))
1339 ui.write(b"%s\n" % repo.dirstate.branch())
1339 ui.write(b"%s\n" % repo.dirstate.branch())
1340 return
1340 return
1341
1341
1342 with repo.wlock():
1342 with repo.wlock():
1343 if opts.get(b'clean'):
1343 if opts.get(b'clean'):
1344 label = repo[b'.'].branch()
1344 label = repo[b'.'].branch()
1345 repo.dirstate.setbranch(label)
1345 repo.dirstate.setbranch(label)
1346 ui.status(_(b'reset working directory to branch %s\n') % label)
1346 ui.status(_(b'reset working directory to branch %s\n') % label)
1347 elif label:
1347 elif label:
1348
1348
1349 scmutil.checknewlabel(repo, label, b'branch')
1349 scmutil.checknewlabel(repo, label, b'branch')
1350 if revs:
1350 if revs:
1351 return cmdutil.changebranch(ui, repo, revs, label)
1351 return cmdutil.changebranch(ui, repo, revs, label)
1352
1352
1353 if not opts.get(b'force') and label in repo.branchmap():
1353 if not opts.get(b'force') and label in repo.branchmap():
1354 if label not in [p.branch() for p in repo[None].parents()]:
1354 if label not in [p.branch() for p in repo[None].parents()]:
1355 raise error.Abort(
1355 raise error.Abort(
1356 _(b'a branch of the same name already exists'),
1356 _(b'a branch of the same name already exists'),
1357 # i18n: "it" refers to an existing branch
1357 # i18n: "it" refers to an existing branch
1358 hint=_(b"use 'hg update' to switch to it"),
1358 hint=_(b"use 'hg update' to switch to it"),
1359 )
1359 )
1360
1360
1361 repo.dirstate.setbranch(label)
1361 repo.dirstate.setbranch(label)
1362 ui.status(_(b'marked working directory as branch %s\n') % label)
1362 ui.status(_(b'marked working directory as branch %s\n') % label)
1363
1363
1364 # find any open named branches aside from default
1364 # find any open named branches aside from default
1365 for n, h, t, c in repo.branchmap().iterbranches():
1365 for n, h, t, c in repo.branchmap().iterbranches():
1366 if n != b"default" and not c:
1366 if n != b"default" and not c:
1367 return 0
1367 return 0
1368 ui.status(
1368 ui.status(
1369 _(
1369 _(
1370 b'(branches are permanent and global, '
1370 b'(branches are permanent and global, '
1371 b'did you want a bookmark?)\n'
1371 b'did you want a bookmark?)\n'
1372 )
1372 )
1373 )
1373 )
1374
1374
1375
1375
1376 @command(
1376 @command(
1377 b'branches',
1377 b'branches',
1378 [
1378 [
1379 (
1379 (
1380 b'a',
1380 b'a',
1381 b'active',
1381 b'active',
1382 False,
1382 False,
1383 _(b'show only branches that have unmerged heads (DEPRECATED)'),
1383 _(b'show only branches that have unmerged heads (DEPRECATED)'),
1384 ),
1384 ),
1385 (b'c', b'closed', False, _(b'show normal and closed branches')),
1385 (b'c', b'closed', False, _(b'show normal and closed branches')),
1386 (b'r', b'rev', [], _(b'show branch name(s) of the given rev')),
1386 (b'r', b'rev', [], _(b'show branch name(s) of the given rev')),
1387 ]
1387 ]
1388 + formatteropts,
1388 + formatteropts,
1389 _(b'[-c]'),
1389 _(b'[-c]'),
1390 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
1390 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
1391 intents={INTENT_READONLY},
1391 intents={INTENT_READONLY},
1392 )
1392 )
1393 def branches(ui, repo, active=False, closed=False, **opts):
1393 def branches(ui, repo, active=False, closed=False, **opts):
1394 """list repository named branches
1394 """list repository named branches
1395
1395
1396 List the repository's named branches, indicating which ones are
1396 List the repository's named branches, indicating which ones are
1397 inactive. If -c/--closed is specified, also list branches which have
1397 inactive. If -c/--closed is specified, also list branches which have
1398 been marked closed (see :hg:`commit --close-branch`).
1398 been marked closed (see :hg:`commit --close-branch`).
1399
1399
1400 Use the command :hg:`update` to switch to an existing branch.
1400 Use the command :hg:`update` to switch to an existing branch.
1401
1401
1402 .. container:: verbose
1402 .. container:: verbose
1403
1403
1404 Template:
1404 Template:
1405
1405
1406 The following keywords are supported in addition to the common template
1406 The following keywords are supported in addition to the common template
1407 keywords and functions such as ``{branch}``. See also
1407 keywords and functions such as ``{branch}``. See also
1408 :hg:`help templates`.
1408 :hg:`help templates`.
1409
1409
1410 :active: Boolean. True if the branch is active.
1410 :active: Boolean. True if the branch is active.
1411 :closed: Boolean. True if the branch is closed.
1411 :closed: Boolean. True if the branch is closed.
1412 :current: Boolean. True if it is the current branch.
1412 :current: Boolean. True if it is the current branch.
1413
1413
1414 Returns 0.
1414 Returns 0.
1415 """
1415 """
1416
1416
1417 opts = pycompat.byteskwargs(opts)
1417 opts = pycompat.byteskwargs(opts)
1418 revs = opts.get(b'rev')
1418 revs = opts.get(b'rev')
1419 selectedbranches = None
1419 selectedbranches = None
1420 if revs:
1420 if revs:
1421 revs = scmutil.revrange(repo, revs)
1421 revs = scmutil.revrange(repo, revs)
1422 getbi = repo.revbranchcache().branchinfo
1422 getbi = repo.revbranchcache().branchinfo
1423 selectedbranches = {getbi(r)[0] for r in revs}
1423 selectedbranches = {getbi(r)[0] for r in revs}
1424
1424
1425 ui.pager(b'branches')
1425 ui.pager(b'branches')
1426 fm = ui.formatter(b'branches', opts)
1426 fm = ui.formatter(b'branches', opts)
1427 hexfunc = fm.hexfunc
1427 hexfunc = fm.hexfunc
1428
1428
1429 allheads = set(repo.heads())
1429 allheads = set(repo.heads())
1430 branches = []
1430 branches = []
1431 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1431 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1432 if selectedbranches is not None and tag not in selectedbranches:
1432 if selectedbranches is not None and tag not in selectedbranches:
1433 continue
1433 continue
1434 isactive = False
1434 isactive = False
1435 if not isclosed:
1435 if not isclosed:
1436 openheads = set(repo.branchmap().iteropen(heads))
1436 openheads = set(repo.branchmap().iteropen(heads))
1437 isactive = bool(openheads & allheads)
1437 isactive = bool(openheads & allheads)
1438 branches.append((tag, repo[tip], isactive, not isclosed))
1438 branches.append((tag, repo[tip], isactive, not isclosed))
1439 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]), reverse=True)
1439 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]), reverse=True)
1440
1440
1441 for tag, ctx, isactive, isopen in branches:
1441 for tag, ctx, isactive, isopen in branches:
1442 if active and not isactive:
1442 if active and not isactive:
1443 continue
1443 continue
1444 if isactive:
1444 if isactive:
1445 label = b'branches.active'
1445 label = b'branches.active'
1446 notice = b''
1446 notice = b''
1447 elif not isopen:
1447 elif not isopen:
1448 if not closed:
1448 if not closed:
1449 continue
1449 continue
1450 label = b'branches.closed'
1450 label = b'branches.closed'
1451 notice = _(b' (closed)')
1451 notice = _(b' (closed)')
1452 else:
1452 else:
1453 label = b'branches.inactive'
1453 label = b'branches.inactive'
1454 notice = _(b' (inactive)')
1454 notice = _(b' (inactive)')
1455 current = tag == repo.dirstate.branch()
1455 current = tag == repo.dirstate.branch()
1456 if current:
1456 if current:
1457 label = b'branches.current'
1457 label = b'branches.current'
1458
1458
1459 fm.startitem()
1459 fm.startitem()
1460 fm.write(b'branch', b'%s', tag, label=label)
1460 fm.write(b'branch', b'%s', tag, label=label)
1461 rev = ctx.rev()
1461 rev = ctx.rev()
1462 padsize = max(31 - len(b"%d" % rev) - encoding.colwidth(tag), 0)
1462 padsize = max(31 - len(b"%d" % rev) - encoding.colwidth(tag), 0)
1463 fmt = b' ' * padsize + b' %d:%s'
1463 fmt = b' ' * padsize + b' %d:%s'
1464 fm.condwrite(
1464 fm.condwrite(
1465 not ui.quiet,
1465 not ui.quiet,
1466 b'rev node',
1466 b'rev node',
1467 fmt,
1467 fmt,
1468 rev,
1468 rev,
1469 hexfunc(ctx.node()),
1469 hexfunc(ctx.node()),
1470 label=b'log.changeset changeset.%s' % ctx.phasestr(),
1470 label=b'log.changeset changeset.%s' % ctx.phasestr(),
1471 )
1471 )
1472 fm.context(ctx=ctx)
1472 fm.context(ctx=ctx)
1473 fm.data(active=isactive, closed=not isopen, current=current)
1473 fm.data(active=isactive, closed=not isopen, current=current)
1474 if not ui.quiet:
1474 if not ui.quiet:
1475 fm.plain(notice)
1475 fm.plain(notice)
1476 fm.plain(b'\n')
1476 fm.plain(b'\n')
1477 fm.end()
1477 fm.end()
1478
1478
1479
1479
1480 @command(
1480 @command(
1481 b'bundle',
1481 b'bundle',
1482 [
1482 [
1483 (
1483 (
1484 b'f',
1484 b'f',
1485 b'force',
1485 b'force',
1486 None,
1486 None,
1487 _(b'run even when the destination is unrelated'),
1487 _(b'run even when the destination is unrelated'),
1488 ),
1488 ),
1489 (
1489 (
1490 b'r',
1490 b'r',
1491 b'rev',
1491 b'rev',
1492 [],
1492 [],
1493 _(b'a changeset intended to be added to the destination'),
1493 _(b'a changeset intended to be added to the destination'),
1494 _(b'REV'),
1494 _(b'REV'),
1495 ),
1495 ),
1496 (
1496 (
1497 b'b',
1497 b'b',
1498 b'branch',
1498 b'branch',
1499 [],
1499 [],
1500 _(b'a specific branch you would like to bundle'),
1500 _(b'a specific branch you would like to bundle'),
1501 _(b'BRANCH'),
1501 _(b'BRANCH'),
1502 ),
1502 ),
1503 (
1503 (
1504 b'',
1504 b'',
1505 b'base',
1505 b'base',
1506 [],
1506 [],
1507 _(b'a base changeset assumed to be available at the destination'),
1507 _(b'a base changeset assumed to be available at the destination'),
1508 _(b'REV'),
1508 _(b'REV'),
1509 ),
1509 ),
1510 (b'a', b'all', None, _(b'bundle all changesets in the repository')),
1510 (b'a', b'all', None, _(b'bundle all changesets in the repository')),
1511 (
1511 (
1512 b't',
1512 b't',
1513 b'type',
1513 b'type',
1514 b'bzip2',
1514 b'bzip2',
1515 _(b'bundle compression type to use'),
1515 _(b'bundle compression type to use'),
1516 _(b'TYPE'),
1516 _(b'TYPE'),
1517 ),
1517 ),
1518 ]
1518 ]
1519 + remoteopts,
1519 + remoteopts,
1520 _(b'[-f] [-t BUNDLESPEC] [-a] [-r REV]... [--base REV]... FILE [DEST]'),
1520 _(b'[-f] [-t BUNDLESPEC] [-a] [-r REV]... [--base REV]... FILE [DEST]'),
1521 helpcategory=command.CATEGORY_IMPORT_EXPORT,
1521 helpcategory=command.CATEGORY_IMPORT_EXPORT,
1522 )
1522 )
1523 def bundle(ui, repo, fname, dest=None, **opts):
1523 def bundle(ui, repo, fname, dest=None, **opts):
1524 """create a bundle file
1524 """create a bundle file
1525
1525
1526 Generate a bundle file containing data to be transferred to another
1526 Generate a bundle file containing data to be transferred to another
1527 repository.
1527 repository.
1528
1528
1529 To create a bundle containing all changesets, use -a/--all
1529 To create a bundle containing all changesets, use -a/--all
1530 (or --base null). Otherwise, hg assumes the destination will have
1530 (or --base null). Otherwise, hg assumes the destination will have
1531 all the nodes you specify with --base parameters. Otherwise, hg
1531 all the nodes you specify with --base parameters. Otherwise, hg
1532 will assume the repository has all the nodes in destination, or
1532 will assume the repository has all the nodes in destination, or
1533 default-push/default if no destination is specified, where destination
1533 default-push/default if no destination is specified, where destination
1534 is the repository you provide through DEST option.
1534 is the repository you provide through DEST option.
1535
1535
1536 You can change bundle format with the -t/--type option. See
1536 You can change bundle format with the -t/--type option. See
1537 :hg:`help bundlespec` for documentation on this format. By default,
1537 :hg:`help bundlespec` for documentation on this format. By default,
1538 the most appropriate format is used and compression defaults to
1538 the most appropriate format is used and compression defaults to
1539 bzip2.
1539 bzip2.
1540
1540
1541 The bundle file can then be transferred using conventional means
1541 The bundle file can then be transferred using conventional means
1542 and applied to another repository with the unbundle or pull
1542 and applied to another repository with the unbundle or pull
1543 command. This is useful when direct push and pull are not
1543 command. This is useful when direct push and pull are not
1544 available or when exporting an entire repository is undesirable.
1544 available or when exporting an entire repository is undesirable.
1545
1545
1546 Applying bundles preserves all changeset contents including
1546 Applying bundles preserves all changeset contents including
1547 permissions, copy/rename information, and revision history.
1547 permissions, copy/rename information, and revision history.
1548
1548
1549 Returns 0 on success, 1 if no changes found.
1549 Returns 0 on success, 1 if no changes found.
1550 """
1550 """
1551 opts = pycompat.byteskwargs(opts)
1551 opts = pycompat.byteskwargs(opts)
1552 revs = None
1552 revs = None
1553 if b'rev' in opts:
1553 if b'rev' in opts:
1554 revstrings = opts[b'rev']
1554 revstrings = opts[b'rev']
1555 revs = scmutil.revrange(repo, revstrings)
1555 revs = scmutil.revrange(repo, revstrings)
1556 if revstrings and not revs:
1556 if revstrings and not revs:
1557 raise error.Abort(_(b'no commits to bundle'))
1557 raise error.Abort(_(b'no commits to bundle'))
1558
1558
1559 bundletype = opts.get(b'type', b'bzip2').lower()
1559 bundletype = opts.get(b'type', b'bzip2').lower()
1560 try:
1560 try:
1561 bundlespec = exchange.parsebundlespec(repo, bundletype, strict=False)
1561 bundlespec = exchange.parsebundlespec(repo, bundletype, strict=False)
1562 except error.UnsupportedBundleSpecification as e:
1562 except error.UnsupportedBundleSpecification as e:
1563 raise error.Abort(
1563 raise error.Abort(
1564 pycompat.bytestr(e),
1564 pycompat.bytestr(e),
1565 hint=_(b"see 'hg help bundlespec' for supported values for --type"),
1565 hint=_(b"see 'hg help bundlespec' for supported values for --type"),
1566 )
1566 )
1567 cgversion = bundlespec.contentopts[b"cg.version"]
1567 cgversion = bundlespec.contentopts[b"cg.version"]
1568
1568
1569 # Packed bundles are a pseudo bundle format for now.
1569 # Packed bundles are a pseudo bundle format for now.
1570 if cgversion == b's1':
1570 if cgversion == b's1':
1571 raise error.Abort(
1571 raise error.Abort(
1572 _(b'packed bundles cannot be produced by "hg bundle"'),
1572 _(b'packed bundles cannot be produced by "hg bundle"'),
1573 hint=_(b"use 'hg debugcreatestreamclonebundle'"),
1573 hint=_(b"use 'hg debugcreatestreamclonebundle'"),
1574 )
1574 )
1575
1575
1576 if opts.get(b'all'):
1576 if opts.get(b'all'):
1577 if dest:
1577 if dest:
1578 raise error.Abort(
1578 raise error.Abort(
1579 _(b"--all is incompatible with specifying a destination")
1579 _(b"--all is incompatible with specifying a destination")
1580 )
1580 )
1581 if opts.get(b'base'):
1581 if opts.get(b'base'):
1582 ui.warn(_(b"ignoring --base because --all was specified\n"))
1582 ui.warn(_(b"ignoring --base because --all was specified\n"))
1583 base = [nullrev]
1583 base = [nullrev]
1584 else:
1584 else:
1585 base = scmutil.revrange(repo, opts.get(b'base'))
1585 base = scmutil.revrange(repo, opts.get(b'base'))
1586 if cgversion not in changegroup.supportedoutgoingversions(repo):
1586 if cgversion not in changegroup.supportedoutgoingversions(repo):
1587 raise error.Abort(
1587 raise error.Abort(
1588 _(b"repository does not support bundle version %s") % cgversion
1588 _(b"repository does not support bundle version %s") % cgversion
1589 )
1589 )
1590
1590
1591 if base:
1591 if base:
1592 if dest:
1592 if dest:
1593 raise error.Abort(
1593 raise error.Abort(
1594 _(b"--base is incompatible with specifying a destination")
1594 _(b"--base is incompatible with specifying a destination")
1595 )
1595 )
1596 common = [repo[rev].node() for rev in base]
1596 common = [repo[rev].node() for rev in base]
1597 heads = [repo[r].node() for r in revs] if revs else None
1597 heads = [repo[r].node() for r in revs] if revs else None
1598 outgoing = discovery.outgoing(repo, common, heads)
1598 outgoing = discovery.outgoing(repo, common, heads)
1599 else:
1599 else:
1600 dest = ui.expandpath(dest or b'default-push', dest or b'default')
1600 dest = ui.expandpath(dest or b'default-push', dest or b'default')
1601 dest, branches = hg.parseurl(dest, opts.get(b'branch'))
1601 dest, branches = hg.parseurl(dest, opts.get(b'branch'))
1602 other = hg.peer(repo, opts, dest)
1602 other = hg.peer(repo, opts, dest)
1603 revs = [repo[r].hex() for r in revs]
1603 revs = [repo[r].hex() for r in revs]
1604 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1604 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1605 heads = revs and pycompat.maplist(repo.lookup, revs) or revs
1605 heads = revs and pycompat.maplist(repo.lookup, revs) or revs
1606 outgoing = discovery.findcommonoutgoing(
1606 outgoing = discovery.findcommonoutgoing(
1607 repo,
1607 repo,
1608 other,
1608 other,
1609 onlyheads=heads,
1609 onlyheads=heads,
1610 force=opts.get(b'force'),
1610 force=opts.get(b'force'),
1611 portable=True,
1611 portable=True,
1612 )
1612 )
1613
1613
1614 if not outgoing.missing:
1614 if not outgoing.missing:
1615 scmutil.nochangesfound(ui, repo, not base and outgoing.excluded)
1615 scmutil.nochangesfound(ui, repo, not base and outgoing.excluded)
1616 return 1
1616 return 1
1617
1617
1618 if cgversion == b'01': # bundle1
1618 if cgversion == b'01': # bundle1
1619 bversion = b'HG10' + bundlespec.wirecompression
1619 bversion = b'HG10' + bundlespec.wirecompression
1620 bcompression = None
1620 bcompression = None
1621 elif cgversion in (b'02', b'03'):
1621 elif cgversion in (b'02', b'03'):
1622 bversion = b'HG20'
1622 bversion = b'HG20'
1623 bcompression = bundlespec.wirecompression
1623 bcompression = bundlespec.wirecompression
1624 else:
1624 else:
1625 raise error.ProgrammingError(
1625 raise error.ProgrammingError(
1626 b'bundle: unexpected changegroup version %s' % cgversion
1626 b'bundle: unexpected changegroup version %s' % cgversion
1627 )
1627 )
1628
1628
1629 # TODO compression options should be derived from bundlespec parsing.
1629 # TODO compression options should be derived from bundlespec parsing.
1630 # This is a temporary hack to allow adjusting bundle compression
1630 # This is a temporary hack to allow adjusting bundle compression
1631 # level without a) formalizing the bundlespec changes to declare it
1631 # level without a) formalizing the bundlespec changes to declare it
1632 # b) introducing a command flag.
1632 # b) introducing a command flag.
1633 compopts = {}
1633 compopts = {}
1634 complevel = ui.configint(
1634 complevel = ui.configint(
1635 b'experimental', b'bundlecomplevel.' + bundlespec.compression
1635 b'experimental', b'bundlecomplevel.' + bundlespec.compression
1636 )
1636 )
1637 if complevel is None:
1637 if complevel is None:
1638 complevel = ui.configint(b'experimental', b'bundlecomplevel')
1638 complevel = ui.configint(b'experimental', b'bundlecomplevel')
1639 if complevel is not None:
1639 if complevel is not None:
1640 compopts[b'level'] = complevel
1640 compopts[b'level'] = complevel
1641
1641
1642 # Allow overriding the bundling of obsmarker in phases through
1642 # Allow overriding the bundling of obsmarker in phases through
1643 # configuration while we don't have a bundle version that include them
1643 # configuration while we don't have a bundle version that include them
1644 if repo.ui.configbool(b'experimental', b'evolution.bundle-obsmarker'):
1644 if repo.ui.configbool(b'experimental', b'evolution.bundle-obsmarker'):
1645 bundlespec.contentopts[b'obsolescence'] = True
1645 bundlespec.contentopts[b'obsolescence'] = True
1646 if repo.ui.configbool(b'experimental', b'bundle-phases'):
1646 if repo.ui.configbool(b'experimental', b'bundle-phases'):
1647 bundlespec.contentopts[b'phases'] = True
1647 bundlespec.contentopts[b'phases'] = True
1648
1648
1649 bundle2.writenewbundle(
1649 bundle2.writenewbundle(
1650 ui,
1650 ui,
1651 repo,
1651 repo,
1652 b'bundle',
1652 b'bundle',
1653 fname,
1653 fname,
1654 bversion,
1654 bversion,
1655 outgoing,
1655 outgoing,
1656 bundlespec.contentopts,
1656 bundlespec.contentopts,
1657 compression=bcompression,
1657 compression=bcompression,
1658 compopts=compopts,
1658 compopts=compopts,
1659 )
1659 )
1660
1660
1661
1661
1662 @command(
1662 @command(
1663 b'cat',
1663 b'cat',
1664 [
1664 [
1665 (
1665 (
1666 b'o',
1666 b'o',
1667 b'output',
1667 b'output',
1668 b'',
1668 b'',
1669 _(b'print output to file with formatted name'),
1669 _(b'print output to file with formatted name'),
1670 _(b'FORMAT'),
1670 _(b'FORMAT'),
1671 ),
1671 ),
1672 (b'r', b'rev', b'', _(b'print the given revision'), _(b'REV')),
1672 (b'r', b'rev', b'', _(b'print the given revision'), _(b'REV')),
1673 (b'', b'decode', None, _(b'apply any matching decode filter')),
1673 (b'', b'decode', None, _(b'apply any matching decode filter')),
1674 ]
1674 ]
1675 + walkopts
1675 + walkopts
1676 + formatteropts,
1676 + formatteropts,
1677 _(b'[OPTION]... FILE...'),
1677 _(b'[OPTION]... FILE...'),
1678 helpcategory=command.CATEGORY_FILE_CONTENTS,
1678 helpcategory=command.CATEGORY_FILE_CONTENTS,
1679 inferrepo=True,
1679 inferrepo=True,
1680 intents={INTENT_READONLY},
1680 intents={INTENT_READONLY},
1681 )
1681 )
1682 def cat(ui, repo, file1, *pats, **opts):
1682 def cat(ui, repo, file1, *pats, **opts):
1683 """output the current or given revision of files
1683 """output the current or given revision of files
1684
1684
1685 Print the specified files as they were at the given revision. If
1685 Print the specified files as they were at the given revision. If
1686 no revision is given, the parent of the working directory is used.
1686 no revision is given, the parent of the working directory is used.
1687
1687
1688 Output may be to a file, in which case the name of the file is
1688 Output may be to a file, in which case the name of the file is
1689 given using a template string. See :hg:`help templates`. In addition
1689 given using a template string. See :hg:`help templates`. In addition
1690 to the common template keywords, the following formatting rules are
1690 to the common template keywords, the following formatting rules are
1691 supported:
1691 supported:
1692
1692
1693 :``%%``: literal "%" character
1693 :``%%``: literal "%" character
1694 :``%s``: basename of file being printed
1694 :``%s``: basename of file being printed
1695 :``%d``: dirname of file being printed, or '.' if in repository root
1695 :``%d``: dirname of file being printed, or '.' if in repository root
1696 :``%p``: root-relative path name of file being printed
1696 :``%p``: root-relative path name of file being printed
1697 :``%H``: changeset hash (40 hexadecimal digits)
1697 :``%H``: changeset hash (40 hexadecimal digits)
1698 :``%R``: changeset revision number
1698 :``%R``: changeset revision number
1699 :``%h``: short-form changeset hash (12 hexadecimal digits)
1699 :``%h``: short-form changeset hash (12 hexadecimal digits)
1700 :``%r``: zero-padded changeset revision number
1700 :``%r``: zero-padded changeset revision number
1701 :``%b``: basename of the exporting repository
1701 :``%b``: basename of the exporting repository
1702 :``\\``: literal "\\" character
1702 :``\\``: literal "\\" character
1703
1703
1704 .. container:: verbose
1704 .. container:: verbose
1705
1705
1706 Template:
1706 Template:
1707
1707
1708 The following keywords are supported in addition to the common template
1708 The following keywords are supported in addition to the common template
1709 keywords and functions. See also :hg:`help templates`.
1709 keywords and functions. See also :hg:`help templates`.
1710
1710
1711 :data: String. File content.
1711 :data: String. File content.
1712 :path: String. Repository-absolute path of the file.
1712 :path: String. Repository-absolute path of the file.
1713
1713
1714 Returns 0 on success.
1714 Returns 0 on success.
1715 """
1715 """
1716 opts = pycompat.byteskwargs(opts)
1716 opts = pycompat.byteskwargs(opts)
1717 rev = opts.get(b'rev')
1717 rev = opts.get(b'rev')
1718 if rev:
1718 if rev:
1719 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
1719 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
1720 ctx = scmutil.revsingle(repo, rev)
1720 ctx = scmutil.revsingle(repo, rev)
1721 m = scmutil.match(ctx, (file1,) + pats, opts)
1721 m = scmutil.match(ctx, (file1,) + pats, opts)
1722 fntemplate = opts.pop(b'output', b'')
1722 fntemplate = opts.pop(b'output', b'')
1723 if cmdutil.isstdiofilename(fntemplate):
1723 if cmdutil.isstdiofilename(fntemplate):
1724 fntemplate = b''
1724 fntemplate = b''
1725
1725
1726 if fntemplate:
1726 if fntemplate:
1727 fm = formatter.nullformatter(ui, b'cat', opts)
1727 fm = formatter.nullformatter(ui, b'cat', opts)
1728 else:
1728 else:
1729 ui.pager(b'cat')
1729 ui.pager(b'cat')
1730 fm = ui.formatter(b'cat', opts)
1730 fm = ui.formatter(b'cat', opts)
1731 with fm:
1731 with fm:
1732 return cmdutil.cat(
1732 return cmdutil.cat(
1733 ui, repo, ctx, m, fm, fntemplate, b'', **pycompat.strkwargs(opts)
1733 ui, repo, ctx, m, fm, fntemplate, b'', **pycompat.strkwargs(opts)
1734 )
1734 )
1735
1735
1736
1736
1737 @command(
1737 @command(
1738 b'clone',
1738 b'clone',
1739 [
1739 [
1740 (
1740 (
1741 b'U',
1741 b'U',
1742 b'noupdate',
1742 b'noupdate',
1743 None,
1743 None,
1744 _(
1744 _(
1745 b'the clone will include an empty working '
1745 b'the clone will include an empty working '
1746 b'directory (only a repository)'
1746 b'directory (only a repository)'
1747 ),
1747 ),
1748 ),
1748 ),
1749 (
1749 (
1750 b'u',
1750 b'u',
1751 b'updaterev',
1751 b'updaterev',
1752 b'',
1752 b'',
1753 _(b'revision, tag, or branch to check out'),
1753 _(b'revision, tag, or branch to check out'),
1754 _(b'REV'),
1754 _(b'REV'),
1755 ),
1755 ),
1756 (
1756 (
1757 b'r',
1757 b'r',
1758 b'rev',
1758 b'rev',
1759 [],
1759 [],
1760 _(
1760 _(
1761 b'do not clone everything, but include this changeset'
1761 b'do not clone everything, but include this changeset'
1762 b' and its ancestors'
1762 b' and its ancestors'
1763 ),
1763 ),
1764 _(b'REV'),
1764 _(b'REV'),
1765 ),
1765 ),
1766 (
1766 (
1767 b'b',
1767 b'b',
1768 b'branch',
1768 b'branch',
1769 [],
1769 [],
1770 _(
1770 _(
1771 b'do not clone everything, but include this branch\'s'
1771 b'do not clone everything, but include this branch\'s'
1772 b' changesets and their ancestors'
1772 b' changesets and their ancestors'
1773 ),
1773 ),
1774 _(b'BRANCH'),
1774 _(b'BRANCH'),
1775 ),
1775 ),
1776 (b'', b'pull', None, _(b'use pull protocol to copy metadata')),
1776 (b'', b'pull', None, _(b'use pull protocol to copy metadata')),
1777 (b'', b'uncompressed', None, _(b'an alias to --stream (DEPRECATED)')),
1777 (b'', b'uncompressed', None, _(b'an alias to --stream (DEPRECATED)')),
1778 (b'', b'stream', None, _(b'clone with minimal data processing')),
1778 (b'', b'stream', None, _(b'clone with minimal data processing')),
1779 ]
1779 ]
1780 + remoteopts,
1780 + remoteopts,
1781 _(b'[OPTION]... SOURCE [DEST]'),
1781 _(b'[OPTION]... SOURCE [DEST]'),
1782 helpcategory=command.CATEGORY_REPO_CREATION,
1782 helpcategory=command.CATEGORY_REPO_CREATION,
1783 helpbasic=True,
1783 helpbasic=True,
1784 norepo=True,
1784 norepo=True,
1785 )
1785 )
1786 def clone(ui, source, dest=None, **opts):
1786 def clone(ui, source, dest=None, **opts):
1787 """make a copy of an existing repository
1787 """make a copy of an existing repository
1788
1788
1789 Create a copy of an existing repository in a new directory.
1789 Create a copy of an existing repository in a new directory.
1790
1790
1791 If no destination directory name is specified, it defaults to the
1791 If no destination directory name is specified, it defaults to the
1792 basename of the source.
1792 basename of the source.
1793
1793
1794 The location of the source is added to the new repository's
1794 The location of the source is added to the new repository's
1795 ``.hg/hgrc`` file, as the default to be used for future pulls.
1795 ``.hg/hgrc`` file, as the default to be used for future pulls.
1796
1796
1797 Only local paths and ``ssh://`` URLs are supported as
1797 Only local paths and ``ssh://`` URLs are supported as
1798 destinations. For ``ssh://`` destinations, no working directory or
1798 destinations. For ``ssh://`` destinations, no working directory or
1799 ``.hg/hgrc`` will be created on the remote side.
1799 ``.hg/hgrc`` will be created on the remote side.
1800
1800
1801 If the source repository has a bookmark called '@' set, that
1801 If the source repository has a bookmark called '@' set, that
1802 revision will be checked out in the new repository by default.
1802 revision will be checked out in the new repository by default.
1803
1803
1804 To check out a particular version, use -u/--update, or
1804 To check out a particular version, use -u/--update, or
1805 -U/--noupdate to create a clone with no working directory.
1805 -U/--noupdate to create a clone with no working directory.
1806
1806
1807 To pull only a subset of changesets, specify one or more revisions
1807 To pull only a subset of changesets, specify one or more revisions
1808 identifiers with -r/--rev or branches with -b/--branch. The
1808 identifiers with -r/--rev or branches with -b/--branch. The
1809 resulting clone will contain only the specified changesets and
1809 resulting clone will contain only the specified changesets and
1810 their ancestors. These options (or 'clone src#rev dest') imply
1810 their ancestors. These options (or 'clone src#rev dest') imply
1811 --pull, even for local source repositories.
1811 --pull, even for local source repositories.
1812
1812
1813 In normal clone mode, the remote normalizes repository data into a common
1813 In normal clone mode, the remote normalizes repository data into a common
1814 exchange format and the receiving end translates this data into its local
1814 exchange format and the receiving end translates this data into its local
1815 storage format. --stream activates a different clone mode that essentially
1815 storage format. --stream activates a different clone mode that essentially
1816 copies repository files from the remote with minimal data processing. This
1816 copies repository files from the remote with minimal data processing. This
1817 significantly reduces the CPU cost of a clone both remotely and locally.
1817 significantly reduces the CPU cost of a clone both remotely and locally.
1818 However, it often increases the transferred data size by 30-40%. This can
1818 However, it often increases the transferred data size by 30-40%. This can
1819 result in substantially faster clones where I/O throughput is plentiful,
1819 result in substantially faster clones where I/O throughput is plentiful,
1820 especially for larger repositories. A side-effect of --stream clones is
1820 especially for larger repositories. A side-effect of --stream clones is
1821 that storage settings and requirements on the remote are applied locally:
1821 that storage settings and requirements on the remote are applied locally:
1822 a modern client may inherit legacy or inefficient storage used by the
1822 a modern client may inherit legacy or inefficient storage used by the
1823 remote or a legacy Mercurial client may not be able to clone from a
1823 remote or a legacy Mercurial client may not be able to clone from a
1824 modern Mercurial remote.
1824 modern Mercurial remote.
1825
1825
1826 .. note::
1826 .. note::
1827
1827
1828 Specifying a tag will include the tagged changeset but not the
1828 Specifying a tag will include the tagged changeset but not the
1829 changeset containing the tag.
1829 changeset containing the tag.
1830
1830
1831 .. container:: verbose
1831 .. container:: verbose
1832
1832
1833 For efficiency, hardlinks are used for cloning whenever the
1833 For efficiency, hardlinks are used for cloning whenever the
1834 source and destination are on the same filesystem (note this
1834 source and destination are on the same filesystem (note this
1835 applies only to the repository data, not to the working
1835 applies only to the repository data, not to the working
1836 directory). Some filesystems, such as AFS, implement hardlinking
1836 directory). Some filesystems, such as AFS, implement hardlinking
1837 incorrectly, but do not report errors. In these cases, use the
1837 incorrectly, but do not report errors. In these cases, use the
1838 --pull option to avoid hardlinking.
1838 --pull option to avoid hardlinking.
1839
1839
1840 Mercurial will update the working directory to the first applicable
1840 Mercurial will update the working directory to the first applicable
1841 revision from this list:
1841 revision from this list:
1842
1842
1843 a) null if -U or the source repository has no changesets
1843 a) null if -U or the source repository has no changesets
1844 b) if -u . and the source repository is local, the first parent of
1844 b) if -u . and the source repository is local, the first parent of
1845 the source repository's working directory
1845 the source repository's working directory
1846 c) the changeset specified with -u (if a branch name, this means the
1846 c) the changeset specified with -u (if a branch name, this means the
1847 latest head of that branch)
1847 latest head of that branch)
1848 d) the changeset specified with -r
1848 d) the changeset specified with -r
1849 e) the tipmost head specified with -b
1849 e) the tipmost head specified with -b
1850 f) the tipmost head specified with the url#branch source syntax
1850 f) the tipmost head specified with the url#branch source syntax
1851 g) the revision marked with the '@' bookmark, if present
1851 g) the revision marked with the '@' bookmark, if present
1852 h) the tipmost head of the default branch
1852 h) the tipmost head of the default branch
1853 i) tip
1853 i) tip
1854
1854
1855 When cloning from servers that support it, Mercurial may fetch
1855 When cloning from servers that support it, Mercurial may fetch
1856 pre-generated data from a server-advertised URL or inline from the
1856 pre-generated data from a server-advertised URL or inline from the
1857 same stream. When this is done, hooks operating on incoming changesets
1857 same stream. When this is done, hooks operating on incoming changesets
1858 and changegroups may fire more than once, once for each pre-generated
1858 and changegroups may fire more than once, once for each pre-generated
1859 bundle and as well as for any additional remaining data. In addition,
1859 bundle and as well as for any additional remaining data. In addition,
1860 if an error occurs, the repository may be rolled back to a partial
1860 if an error occurs, the repository may be rolled back to a partial
1861 clone. This behavior may change in future releases.
1861 clone. This behavior may change in future releases.
1862 See :hg:`help -e clonebundles` for more.
1862 See :hg:`help -e clonebundles` for more.
1863
1863
1864 Examples:
1864 Examples:
1865
1865
1866 - clone a remote repository to a new directory named hg/::
1866 - clone a remote repository to a new directory named hg/::
1867
1867
1868 hg clone https://www.mercurial-scm.org/repo/hg/
1868 hg clone https://www.mercurial-scm.org/repo/hg/
1869
1869
1870 - create a lightweight local clone::
1870 - create a lightweight local clone::
1871
1871
1872 hg clone project/ project-feature/
1872 hg clone project/ project-feature/
1873
1873
1874 - clone from an absolute path on an ssh server (note double-slash)::
1874 - clone from an absolute path on an ssh server (note double-slash)::
1875
1875
1876 hg clone ssh://user@server//home/projects/alpha/
1876 hg clone ssh://user@server//home/projects/alpha/
1877
1877
1878 - do a streaming clone while checking out a specified version::
1878 - do a streaming clone while checking out a specified version::
1879
1879
1880 hg clone --stream http://server/repo -u 1.5
1880 hg clone --stream http://server/repo -u 1.5
1881
1881
1882 - create a repository without changesets after a particular revision::
1882 - create a repository without changesets after a particular revision::
1883
1883
1884 hg clone -r 04e544 experimental/ good/
1884 hg clone -r 04e544 experimental/ good/
1885
1885
1886 - clone (and track) a particular named branch::
1886 - clone (and track) a particular named branch::
1887
1887
1888 hg clone https://www.mercurial-scm.org/repo/hg/#stable
1888 hg clone https://www.mercurial-scm.org/repo/hg/#stable
1889
1889
1890 See :hg:`help urls` for details on specifying URLs.
1890 See :hg:`help urls` for details on specifying URLs.
1891
1891
1892 Returns 0 on success.
1892 Returns 0 on success.
1893 """
1893 """
1894 opts = pycompat.byteskwargs(opts)
1894 opts = pycompat.byteskwargs(opts)
1895 if opts.get(b'noupdate') and opts.get(b'updaterev'):
1895 if opts.get(b'noupdate') and opts.get(b'updaterev'):
1896 raise error.Abort(_(b"cannot specify both --noupdate and --updaterev"))
1896 raise error.Abort(_(b"cannot specify both --noupdate and --updaterev"))
1897
1897
1898 # --include/--exclude can come from narrow or sparse.
1898 # --include/--exclude can come from narrow or sparse.
1899 includepats, excludepats = None, None
1899 includepats, excludepats = None, None
1900
1900
1901 # hg.clone() differentiates between None and an empty set. So make sure
1901 # hg.clone() differentiates between None and an empty set. So make sure
1902 # patterns are sets if narrow is requested without patterns.
1902 # patterns are sets if narrow is requested without patterns.
1903 if opts.get(b'narrow'):
1903 if opts.get(b'narrow'):
1904 includepats = set()
1904 includepats = set()
1905 excludepats = set()
1905 excludepats = set()
1906
1906
1907 if opts.get(b'include'):
1907 if opts.get(b'include'):
1908 includepats = narrowspec.parsepatterns(opts.get(b'include'))
1908 includepats = narrowspec.parsepatterns(opts.get(b'include'))
1909 if opts.get(b'exclude'):
1909 if opts.get(b'exclude'):
1910 excludepats = narrowspec.parsepatterns(opts.get(b'exclude'))
1910 excludepats = narrowspec.parsepatterns(opts.get(b'exclude'))
1911
1911
1912 r = hg.clone(
1912 r = hg.clone(
1913 ui,
1913 ui,
1914 opts,
1914 opts,
1915 source,
1915 source,
1916 dest,
1916 dest,
1917 pull=opts.get(b'pull'),
1917 pull=opts.get(b'pull'),
1918 stream=opts.get(b'stream') or opts.get(b'uncompressed'),
1918 stream=opts.get(b'stream') or opts.get(b'uncompressed'),
1919 revs=opts.get(b'rev'),
1919 revs=opts.get(b'rev'),
1920 update=opts.get(b'updaterev') or not opts.get(b'noupdate'),
1920 update=opts.get(b'updaterev') or not opts.get(b'noupdate'),
1921 branch=opts.get(b'branch'),
1921 branch=opts.get(b'branch'),
1922 shareopts=opts.get(b'shareopts'),
1922 shareopts=opts.get(b'shareopts'),
1923 storeincludepats=includepats,
1923 storeincludepats=includepats,
1924 storeexcludepats=excludepats,
1924 storeexcludepats=excludepats,
1925 depth=opts.get(b'depth') or None,
1925 depth=opts.get(b'depth') or None,
1926 )
1926 )
1927
1927
1928 return r is None
1928 return r is None
1929
1929
1930
1930
1931 @command(
1931 @command(
1932 b'commit|ci',
1932 b'commit|ci',
1933 [
1933 [
1934 (
1934 (
1935 b'A',
1935 b'A',
1936 b'addremove',
1936 b'addremove',
1937 None,
1937 None,
1938 _(b'mark new/missing files as added/removed before committing'),
1938 _(b'mark new/missing files as added/removed before committing'),
1939 ),
1939 ),
1940 (b'', b'close-branch', None, _(b'mark a branch head as closed')),
1940 (b'', b'close-branch', None, _(b'mark a branch head as closed')),
1941 (b'', b'amend', None, _(b'amend the parent of the working directory')),
1941 (b'', b'amend', None, _(b'amend the parent of the working directory')),
1942 (b's', b'secret', None, _(b'use the secret phase for committing')),
1942 (b's', b'secret', None, _(b'use the secret phase for committing')),
1943 (b'e', b'edit', None, _(b'invoke editor on commit messages')),
1943 (b'e', b'edit', None, _(b'invoke editor on commit messages')),
1944 (
1944 (
1945 b'',
1945 b'',
1946 b'force-close-branch',
1946 b'force-close-branch',
1947 None,
1947 None,
1948 _(b'forcibly close branch from a non-head changeset (ADVANCED)'),
1948 _(b'forcibly close branch from a non-head changeset (ADVANCED)'),
1949 ),
1949 ),
1950 (b'i', b'interactive', None, _(b'use interactive mode')),
1950 (b'i', b'interactive', None, _(b'use interactive mode')),
1951 ]
1951 ]
1952 + walkopts
1952 + walkopts
1953 + commitopts
1953 + commitopts
1954 + commitopts2
1954 + commitopts2
1955 + subrepoopts,
1955 + subrepoopts,
1956 _(b'[OPTION]... [FILE]...'),
1956 _(b'[OPTION]... [FILE]...'),
1957 helpcategory=command.CATEGORY_COMMITTING,
1957 helpcategory=command.CATEGORY_COMMITTING,
1958 helpbasic=True,
1958 helpbasic=True,
1959 inferrepo=True,
1959 inferrepo=True,
1960 )
1960 )
1961 def commit(ui, repo, *pats, **opts):
1961 def commit(ui, repo, *pats, **opts):
1962 """commit the specified files or all outstanding changes
1962 """commit the specified files or all outstanding changes
1963
1963
1964 Commit changes to the given files into the repository. Unlike a
1964 Commit changes to the given files into the repository. Unlike a
1965 centralized SCM, this operation is a local operation. See
1965 centralized SCM, this operation is a local operation. See
1966 :hg:`push` for a way to actively distribute your changes.
1966 :hg:`push` for a way to actively distribute your changes.
1967
1967
1968 If a list of files is omitted, all changes reported by :hg:`status`
1968 If a list of files is omitted, all changes reported by :hg:`status`
1969 will be committed.
1969 will be committed.
1970
1970
1971 If you are committing the result of a merge, do not provide any
1971 If you are committing the result of a merge, do not provide any
1972 filenames or -I/-X filters.
1972 filenames or -I/-X filters.
1973
1973
1974 If no commit message is specified, Mercurial starts your
1974 If no commit message is specified, Mercurial starts your
1975 configured editor where you can enter a message. In case your
1975 configured editor where you can enter a message. In case your
1976 commit fails, you will find a backup of your message in
1976 commit fails, you will find a backup of your message in
1977 ``.hg/last-message.txt``.
1977 ``.hg/last-message.txt``.
1978
1978
1979 The --close-branch flag can be used to mark the current branch
1979 The --close-branch flag can be used to mark the current branch
1980 head closed. When all heads of a branch are closed, the branch
1980 head closed. When all heads of a branch are closed, the branch
1981 will be considered closed and no longer listed.
1981 will be considered closed and no longer listed.
1982
1982
1983 The --amend flag can be used to amend the parent of the
1983 The --amend flag can be used to amend the parent of the
1984 working directory with a new commit that contains the changes
1984 working directory with a new commit that contains the changes
1985 in the parent in addition to those currently reported by :hg:`status`,
1985 in the parent in addition to those currently reported by :hg:`status`,
1986 if there are any. The old commit is stored in a backup bundle in
1986 if there are any. The old commit is stored in a backup bundle in
1987 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1987 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1988 on how to restore it).
1988 on how to restore it).
1989
1989
1990 Message, user and date are taken from the amended commit unless
1990 Message, user and date are taken from the amended commit unless
1991 specified. When a message isn't specified on the command line,
1991 specified. When a message isn't specified on the command line,
1992 the editor will open with the message of the amended commit.
1992 the editor will open with the message of the amended commit.
1993
1993
1994 It is not possible to amend public changesets (see :hg:`help phases`)
1994 It is not possible to amend public changesets (see :hg:`help phases`)
1995 or changesets that have children.
1995 or changesets that have children.
1996
1996
1997 See :hg:`help dates` for a list of formats valid for -d/--date.
1997 See :hg:`help dates` for a list of formats valid for -d/--date.
1998
1998
1999 Returns 0 on success, 1 if nothing changed.
1999 Returns 0 on success, 1 if nothing changed.
2000
2000
2001 .. container:: verbose
2001 .. container:: verbose
2002
2002
2003 Examples:
2003 Examples:
2004
2004
2005 - commit all files ending in .py::
2005 - commit all files ending in .py::
2006
2006
2007 hg commit --include "set:**.py"
2007 hg commit --include "set:**.py"
2008
2008
2009 - commit all non-binary files::
2009 - commit all non-binary files::
2010
2010
2011 hg commit --exclude "set:binary()"
2011 hg commit --exclude "set:binary()"
2012
2012
2013 - amend the current commit and set the date to now::
2013 - amend the current commit and set the date to now::
2014
2014
2015 hg commit --amend --date now
2015 hg commit --amend --date now
2016 """
2016 """
2017 with repo.wlock(), repo.lock():
2017 with repo.wlock(), repo.lock():
2018 return _docommit(ui, repo, *pats, **opts)
2018 return _docommit(ui, repo, *pats, **opts)
2019
2019
2020
2020
2021 def _docommit(ui, repo, *pats, **opts):
2021 def _docommit(ui, repo, *pats, **opts):
2022 if opts.get(r'interactive'):
2022 if opts.get(r'interactive'):
2023 opts.pop(r'interactive')
2023 opts.pop(r'interactive')
2024 ret = cmdutil.dorecord(
2024 ret = cmdutil.dorecord(
2025 ui, repo, commit, None, False, cmdutil.recordfilter, *pats, **opts
2025 ui, repo, commit, None, False, cmdutil.recordfilter, *pats, **opts
2026 )
2026 )
2027 # ret can be 0 (no changes to record) or the value returned by
2027 # ret can be 0 (no changes to record) or the value returned by
2028 # commit(), 1 if nothing changed or None on success.
2028 # commit(), 1 if nothing changed or None on success.
2029 return 1 if ret == 0 else ret
2029 return 1 if ret == 0 else ret
2030
2030
2031 opts = pycompat.byteskwargs(opts)
2031 opts = pycompat.byteskwargs(opts)
2032 if opts.get(b'subrepos'):
2032 if opts.get(b'subrepos'):
2033 if opts.get(b'amend'):
2033 if opts.get(b'amend'):
2034 raise error.Abort(_(b'cannot amend with --subrepos'))
2034 raise error.Abort(_(b'cannot amend with --subrepos'))
2035 # Let --subrepos on the command line override config setting.
2035 # Let --subrepos on the command line override config setting.
2036 ui.setconfig(b'ui', b'commitsubrepos', True, b'commit')
2036 ui.setconfig(b'ui', b'commitsubrepos', True, b'commit')
2037
2037
2038 cmdutil.checkunfinished(repo, commit=True)
2038 cmdutil.checkunfinished(repo, commit=True)
2039
2039
2040 branch = repo[None].branch()
2040 branch = repo[None].branch()
2041 bheads = repo.branchheads(branch)
2041 bheads = repo.branchheads(branch)
2042
2042
2043 extra = {}
2043 extra = {}
2044 if opts.get(b'close_branch') or opts.get(b'force_close_branch'):
2044 if opts.get(b'close_branch') or opts.get(b'force_close_branch'):
2045 extra[b'close'] = b'1'
2045 extra[b'close'] = b'1'
2046
2046
2047 if repo[b'.'].closesbranch():
2047 if repo[b'.'].closesbranch():
2048 raise error.Abort(
2048 raise error.Abort(
2049 _(b'current revision is already a branch closing head')
2049 _(b'current revision is already a branch closing head')
2050 )
2050 )
2051 elif not bheads:
2051 elif not bheads:
2052 raise error.Abort(_(b'branch "%s" has no heads to close') % branch)
2052 raise error.Abort(_(b'branch "%s" has no heads to close') % branch)
2053 elif (
2053 elif (
2054 branch == repo[b'.'].branch()
2054 branch == repo[b'.'].branch()
2055 and repo[b'.'].node() not in bheads
2055 and repo[b'.'].node() not in bheads
2056 and not opts.get(b'force_close_branch')
2056 and not opts.get(b'force_close_branch')
2057 ):
2057 ):
2058 hint = _(
2058 hint = _(
2059 b'use --force-close-branch to close branch from a non-head'
2059 b'use --force-close-branch to close branch from a non-head'
2060 b' changeset'
2060 b' changeset'
2061 )
2061 )
2062 raise error.Abort(_(b'can only close branch heads'), hint=hint)
2062 raise error.Abort(_(b'can only close branch heads'), hint=hint)
2063 elif opts.get(b'amend'):
2063 elif opts.get(b'amend'):
2064 if (
2064 if (
2065 repo[b'.'].p1().branch() != branch
2065 repo[b'.'].p1().branch() != branch
2066 and repo[b'.'].p2().branch() != branch
2066 and repo[b'.'].p2().branch() != branch
2067 ):
2067 ):
2068 raise error.Abort(_(b'can only close branch heads'))
2068 raise error.Abort(_(b'can only close branch heads'))
2069
2069
2070 if opts.get(b'amend'):
2070 if opts.get(b'amend'):
2071 if ui.configbool(b'ui', b'commitsubrepos'):
2071 if ui.configbool(b'ui', b'commitsubrepos'):
2072 raise error.Abort(_(b'cannot amend with ui.commitsubrepos enabled'))
2072 raise error.Abort(_(b'cannot amend with ui.commitsubrepos enabled'))
2073
2073
2074 old = repo[b'.']
2074 old = repo[b'.']
2075 rewriteutil.precheck(repo, [old.rev()], b'amend')
2075 rewriteutil.precheck(repo, [old.rev()], b'amend')
2076
2076
2077 # Currently histedit gets confused if an amend happens while histedit
2077 # Currently histedit gets confused if an amend happens while histedit
2078 # is in progress. Since we have a checkunfinished command, we are
2078 # is in progress. Since we have a checkunfinished command, we are
2079 # temporarily honoring it.
2079 # temporarily honoring it.
2080 #
2080 #
2081 # Note: eventually this guard will be removed. Please do not expect
2081 # Note: eventually this guard will be removed. Please do not expect
2082 # this behavior to remain.
2082 # this behavior to remain.
2083 if not obsolete.isenabled(repo, obsolete.createmarkersopt):
2083 if not obsolete.isenabled(repo, obsolete.createmarkersopt):
2084 cmdutil.checkunfinished(repo)
2084 cmdutil.checkunfinished(repo)
2085
2085
2086 node = cmdutil.amend(ui, repo, old, extra, pats, opts)
2086 node = cmdutil.amend(ui, repo, old, extra, pats, opts)
2087 if node == old.node():
2087 if node == old.node():
2088 ui.status(_(b"nothing changed\n"))
2088 ui.status(_(b"nothing changed\n"))
2089 return 1
2089 return 1
2090 else:
2090 else:
2091
2091
2092 def commitfunc(ui, repo, message, match, opts):
2092 def commitfunc(ui, repo, message, match, opts):
2093 overrides = {}
2093 overrides = {}
2094 if opts.get(b'secret'):
2094 if opts.get(b'secret'):
2095 overrides[(b'phases', b'new-commit')] = b'secret'
2095 overrides[(b'phases', b'new-commit')] = b'secret'
2096
2096
2097 baseui = repo.baseui
2097 baseui = repo.baseui
2098 with baseui.configoverride(overrides, b'commit'):
2098 with baseui.configoverride(overrides, b'commit'):
2099 with ui.configoverride(overrides, b'commit'):
2099 with ui.configoverride(overrides, b'commit'):
2100 editform = cmdutil.mergeeditform(
2100 editform = cmdutil.mergeeditform(
2101 repo[None], b'commit.normal'
2101 repo[None], b'commit.normal'
2102 )
2102 )
2103 editor = cmdutil.getcommiteditor(
2103 editor = cmdutil.getcommiteditor(
2104 editform=editform, **pycompat.strkwargs(opts)
2104 editform=editform, **pycompat.strkwargs(opts)
2105 )
2105 )
2106 return repo.commit(
2106 return repo.commit(
2107 message,
2107 message,
2108 opts.get(b'user'),
2108 opts.get(b'user'),
2109 opts.get(b'date'),
2109 opts.get(b'date'),
2110 match,
2110 match,
2111 editor=editor,
2111 editor=editor,
2112 extra=extra,
2112 extra=extra,
2113 )
2113 )
2114
2114
2115 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
2115 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
2116
2116
2117 if not node:
2117 if not node:
2118 stat = cmdutil.postcommitstatus(repo, pats, opts)
2118 stat = cmdutil.postcommitstatus(repo, pats, opts)
2119 if stat[3]:
2119 if stat[3]:
2120 ui.status(
2120 ui.status(
2121 _(
2121 _(
2122 b"nothing changed (%d missing files, see "
2122 b"nothing changed (%d missing files, see "
2123 b"'hg status')\n"
2123 b"'hg status')\n"
2124 )
2124 )
2125 % len(stat[3])
2125 % len(stat[3])
2126 )
2126 )
2127 else:
2127 else:
2128 ui.status(_(b"nothing changed\n"))
2128 ui.status(_(b"nothing changed\n"))
2129 return 1
2129 return 1
2130
2130
2131 cmdutil.commitstatus(repo, node, branch, bheads, opts)
2131 cmdutil.commitstatus(repo, node, branch, bheads, opts)
2132
2132
2133 if not ui.quiet and ui.configbool(b'commands', b'commit.post-status'):
2133 if not ui.quiet and ui.configbool(b'commands', b'commit.post-status'):
2134 status(
2134 status(
2135 ui,
2135 ui,
2136 repo,
2136 repo,
2137 modified=True,
2137 modified=True,
2138 added=True,
2138 added=True,
2139 removed=True,
2139 removed=True,
2140 deleted=True,
2140 deleted=True,
2141 unknown=True,
2141 unknown=True,
2142 subrepos=opts.get(b'subrepos'),
2142 subrepos=opts.get(b'subrepos'),
2143 )
2143 )
2144
2144
2145
2145
2146 @command(
2146 @command(
2147 b'config|showconfig|debugconfig',
2147 b'config|showconfig|debugconfig',
2148 [
2148 [
2149 (b'u', b'untrusted', None, _(b'show untrusted configuration options')),
2149 (b'u', b'untrusted', None, _(b'show untrusted configuration options')),
2150 (b'e', b'edit', None, _(b'edit user config')),
2150 (b'e', b'edit', None, _(b'edit user config')),
2151 (b'l', b'local', None, _(b'edit repository config')),
2151 (b'l', b'local', None, _(b'edit repository config')),
2152 (b'g', b'global', None, _(b'edit global config')),
2152 (b'g', b'global', None, _(b'edit global config')),
2153 ]
2153 ]
2154 + formatteropts,
2154 + formatteropts,
2155 _(b'[-u] [NAME]...'),
2155 _(b'[-u] [NAME]...'),
2156 helpcategory=command.CATEGORY_HELP,
2156 helpcategory=command.CATEGORY_HELP,
2157 optionalrepo=True,
2157 optionalrepo=True,
2158 intents={INTENT_READONLY},
2158 intents={INTENT_READONLY},
2159 )
2159 )
2160 def config(ui, repo, *values, **opts):
2160 def config(ui, repo, *values, **opts):
2161 """show combined config settings from all hgrc files
2161 """show combined config settings from all hgrc files
2162
2162
2163 With no arguments, print names and values of all config items.
2163 With no arguments, print names and values of all config items.
2164
2164
2165 With one argument of the form section.name, print just the value
2165 With one argument of the form section.name, print just the value
2166 of that config item.
2166 of that config item.
2167
2167
2168 With multiple arguments, print names and values of all config
2168 With multiple arguments, print names and values of all config
2169 items with matching section names or section.names.
2169 items with matching section names or section.names.
2170
2170
2171 With --edit, start an editor on the user-level config file. With
2171 With --edit, start an editor on the user-level config file. With
2172 --global, edit the system-wide config file. With --local, edit the
2172 --global, edit the system-wide config file. With --local, edit the
2173 repository-level config file.
2173 repository-level config file.
2174
2174
2175 With --debug, the source (filename and line number) is printed
2175 With --debug, the source (filename and line number) is printed
2176 for each config item.
2176 for each config item.
2177
2177
2178 See :hg:`help config` for more information about config files.
2178 See :hg:`help config` for more information about config files.
2179
2179
2180 .. container:: verbose
2180 .. container:: verbose
2181
2181
2182 Template:
2182 Template:
2183
2183
2184 The following keywords are supported. See also :hg:`help templates`.
2184 The following keywords are supported. See also :hg:`help templates`.
2185
2185
2186 :name: String. Config name.
2186 :name: String. Config name.
2187 :source: String. Filename and line number where the item is defined.
2187 :source: String. Filename and line number where the item is defined.
2188 :value: String. Config value.
2188 :value: String. Config value.
2189
2189
2190 Returns 0 on success, 1 if NAME does not exist.
2190 Returns 0 on success, 1 if NAME does not exist.
2191
2191
2192 """
2192 """
2193
2193
2194 opts = pycompat.byteskwargs(opts)
2194 opts = pycompat.byteskwargs(opts)
2195 if opts.get(b'edit') or opts.get(b'local') or opts.get(b'global'):
2195 if opts.get(b'edit') or opts.get(b'local') or opts.get(b'global'):
2196 if opts.get(b'local') and opts.get(b'global'):
2196 if opts.get(b'local') and opts.get(b'global'):
2197 raise error.Abort(_(b"can't use --local and --global together"))
2197 raise error.Abort(_(b"can't use --local and --global together"))
2198
2198
2199 if opts.get(b'local'):
2199 if opts.get(b'local'):
2200 if not repo:
2200 if not repo:
2201 raise error.Abort(_(b"can't use --local outside a repository"))
2201 raise error.Abort(_(b"can't use --local outside a repository"))
2202 paths = [repo.vfs.join(b'hgrc')]
2202 paths = [repo.vfs.join(b'hgrc')]
2203 elif opts.get(b'global'):
2203 elif opts.get(b'global'):
2204 paths = rcutil.systemrcpath()
2204 paths = rcutil.systemrcpath()
2205 else:
2205 else:
2206 paths = rcutil.userrcpath()
2206 paths = rcutil.userrcpath()
2207
2207
2208 for f in paths:
2208 for f in paths:
2209 if os.path.exists(f):
2209 if os.path.exists(f):
2210 break
2210 break
2211 else:
2211 else:
2212 if opts.get(b'global'):
2212 if opts.get(b'global'):
2213 samplehgrc = uimod.samplehgrcs[b'global']
2213 samplehgrc = uimod.samplehgrcs[b'global']
2214 elif opts.get(b'local'):
2214 elif opts.get(b'local'):
2215 samplehgrc = uimod.samplehgrcs[b'local']
2215 samplehgrc = uimod.samplehgrcs[b'local']
2216 else:
2216 else:
2217 samplehgrc = uimod.samplehgrcs[b'user']
2217 samplehgrc = uimod.samplehgrcs[b'user']
2218
2218
2219 f = paths[0]
2219 f = paths[0]
2220 fp = open(f, b"wb")
2220 fp = open(f, b"wb")
2221 fp.write(util.tonativeeol(samplehgrc))
2221 fp.write(util.tonativeeol(samplehgrc))
2222 fp.close()
2222 fp.close()
2223
2223
2224 editor = ui.geteditor()
2224 editor = ui.geteditor()
2225 ui.system(
2225 ui.system(
2226 b"%s \"%s\"" % (editor, f),
2226 b"%s \"%s\"" % (editor, f),
2227 onerr=error.Abort,
2227 onerr=error.Abort,
2228 errprefix=_(b"edit failed"),
2228 errprefix=_(b"edit failed"),
2229 blockedtag=b'config_edit',
2229 blockedtag=b'config_edit',
2230 )
2230 )
2231 return
2231 return
2232 ui.pager(b'config')
2232 ui.pager(b'config')
2233 fm = ui.formatter(b'config', opts)
2233 fm = ui.formatter(b'config', opts)
2234 for t, f in rcutil.rccomponents():
2234 for t, f in rcutil.rccomponents():
2235 if t == b'path':
2235 if t == b'path':
2236 ui.debug(b'read config from: %s\n' % f)
2236 ui.debug(b'read config from: %s\n' % f)
2237 elif t == b'items':
2237 elif t == b'items':
2238 for section, name, value, source in f:
2238 for section, name, value, source in f:
2239 ui.debug(b'set config by: %s\n' % source)
2239 ui.debug(b'set config by: %s\n' % source)
2240 else:
2240 else:
2241 raise error.ProgrammingError(b'unknown rctype: %s' % t)
2241 raise error.ProgrammingError(b'unknown rctype: %s' % t)
2242 untrusted = bool(opts.get(b'untrusted'))
2242 untrusted = bool(opts.get(b'untrusted'))
2243
2243
2244 selsections = selentries = []
2244 selsections = selentries = []
2245 if values:
2245 if values:
2246 selsections = [v for v in values if b'.' not in v]
2246 selsections = [v for v in values if b'.' not in v]
2247 selentries = [v for v in values if b'.' in v]
2247 selentries = [v for v in values if b'.' in v]
2248 uniquesel = len(selentries) == 1 and not selsections
2248 uniquesel = len(selentries) == 1 and not selsections
2249 selsections = set(selsections)
2249 selsections = set(selsections)
2250 selentries = set(selentries)
2250 selentries = set(selentries)
2251
2251
2252 matched = False
2252 matched = False
2253 for section, name, value in ui.walkconfig(untrusted=untrusted):
2253 for section, name, value in ui.walkconfig(untrusted=untrusted):
2254 source = ui.configsource(section, name, untrusted)
2254 source = ui.configsource(section, name, untrusted)
2255 value = pycompat.bytestr(value)
2255 value = pycompat.bytestr(value)
2256 defaultvalue = ui.configdefault(section, name)
2256 defaultvalue = ui.configdefault(section, name)
2257 if fm.isplain():
2257 if fm.isplain():
2258 source = source or b'none'
2258 source = source or b'none'
2259 value = value.replace(b'\n', b'\\n')
2259 value = value.replace(b'\n', b'\\n')
2260 entryname = section + b'.' + name
2260 entryname = section + b'.' + name
2261 if values and not (section in selsections or entryname in selentries):
2261 if values and not (section in selsections or entryname in selentries):
2262 continue
2262 continue
2263 fm.startitem()
2263 fm.startitem()
2264 fm.condwrite(ui.debugflag, b'source', b'%s: ', source)
2264 fm.condwrite(ui.debugflag, b'source', b'%s: ', source)
2265 if uniquesel:
2265 if uniquesel:
2266 fm.data(name=entryname)
2266 fm.data(name=entryname)
2267 fm.write(b'value', b'%s\n', value)
2267 fm.write(b'value', b'%s\n', value)
2268 else:
2268 else:
2269 fm.write(b'name value', b'%s=%s\n', entryname, value)
2269 fm.write(b'name value', b'%s=%s\n', entryname, value)
2270 fm.data(defaultvalue=defaultvalue)
2270 fm.data(defaultvalue=defaultvalue)
2271 matched = True
2271 matched = True
2272 fm.end()
2272 fm.end()
2273 if matched:
2273 if matched:
2274 return 0
2274 return 0
2275 return 1
2275 return 1
2276
2276
2277
2277
2278 @command(
2278 @command(
2279 b'continue',
2279 b'continue',
2280 dryrunopts,
2280 dryrunopts,
2281 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
2281 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
2282 helpbasic=True,
2282 helpbasic=True,
2283 )
2283 )
2284 def continuecmd(ui, repo, **opts):
2284 def continuecmd(ui, repo, **opts):
2285 """resumes an interrupted operation (EXPERIMENTAL)
2285 """resumes an interrupted operation (EXPERIMENTAL)
2286
2286
2287 Finishes a multistep operation like graft, histedit, rebase, merge,
2287 Finishes a multistep operation like graft, histedit, rebase, merge,
2288 and unshelve if they are in an interrupted state.
2288 and unshelve if they are in an interrupted state.
2289
2289
2290 use --dry-run/-n to dry run the command.
2290 use --dry-run/-n to dry run the command.
2291 """
2291 """
2292 dryrun = opts.get(r'dry_run')
2292 dryrun = opts.get(r'dry_run')
2293 contstate = cmdutil.getunfinishedstate(repo)
2293 contstate = cmdutil.getunfinishedstate(repo)
2294 if not contstate:
2294 if not contstate:
2295 raise error.Abort(_(b'no operation in progress'))
2295 raise error.Abort(_(b'no operation in progress'))
2296 if not contstate.continuefunc:
2296 if not contstate.continuefunc:
2297 raise error.Abort(
2297 raise error.Abort(
2298 (
2298 (
2299 _(b"%s in progress but does not support 'hg continue'")
2299 _(b"%s in progress but does not support 'hg continue'")
2300 % (contstate._opname)
2300 % (contstate._opname)
2301 ),
2301 ),
2302 hint=contstate.continuemsg(),
2302 hint=contstate.continuemsg(),
2303 )
2303 )
2304 if dryrun:
2304 if dryrun:
2305 ui.status(_(b'%s in progress, will be resumed\n') % (contstate._opname))
2305 ui.status(_(b'%s in progress, will be resumed\n') % (contstate._opname))
2306 return
2306 return
2307 return contstate.continuefunc(ui, repo)
2307 return contstate.continuefunc(ui, repo)
2308
2308
2309
2309
2310 @command(
2310 @command(
2311 b'copy|cp',
2311 b'copy|cp',
2312 [
2312 [
2313 (b'A', b'after', None, _(b'record a copy that has already occurred')),
2313 (b'A', b'after', None, _(b'record a copy that has already occurred')),
2314 (
2314 (
2315 b'f',
2315 b'f',
2316 b'force',
2316 b'force',
2317 None,
2317 None,
2318 _(b'forcibly copy over an existing managed file'),
2318 _(b'forcibly copy over an existing managed file'),
2319 ),
2319 ),
2320 ]
2320 ]
2321 + walkopts
2321 + walkopts
2322 + dryrunopts,
2322 + dryrunopts,
2323 _(b'[OPTION]... SOURCE... DEST'),
2323 _(b'[OPTION]... SOURCE... DEST'),
2324 helpcategory=command.CATEGORY_FILE_CONTENTS,
2324 helpcategory=command.CATEGORY_FILE_CONTENTS,
2325 )
2325 )
2326 def copy(ui, repo, *pats, **opts):
2326 def copy(ui, repo, *pats, **opts):
2327 """mark files as copied for the next commit
2327 """mark files as copied for the next commit
2328
2328
2329 Mark dest as having copies of source files. If dest is a
2329 Mark dest as having copies of source files. If dest is a
2330 directory, copies are put in that directory. If dest is a file,
2330 directory, copies are put in that directory. If dest is a file,
2331 the source must be a single file.
2331 the source must be a single file.
2332
2332
2333 By default, this command copies the contents of files as they
2333 By default, this command copies the contents of files as they
2334 exist in the working directory. If invoked with -A/--after, the
2334 exist in the working directory. If invoked with -A/--after, the
2335 operation is recorded, but no copying is performed.
2335 operation is recorded, but no copying is performed.
2336
2336
2337 This command takes effect with the next commit. To undo a copy
2337 This command takes effect with the next commit. To undo a copy
2338 before that, see :hg:`revert`.
2338 before that, see :hg:`revert`.
2339
2339
2340 Returns 0 on success, 1 if errors are encountered.
2340 Returns 0 on success, 1 if errors are encountered.
2341 """
2341 """
2342 opts = pycompat.byteskwargs(opts)
2342 opts = pycompat.byteskwargs(opts)
2343 with repo.wlock(False):
2343 with repo.wlock(False):
2344 return cmdutil.copy(ui, repo, pats, opts)
2344 return cmdutil.copy(ui, repo, pats, opts)
2345
2345
2346
2346
2347 @command(
2347 @command(
2348 b'debugcommands',
2348 b'debugcommands',
2349 [],
2349 [],
2350 _(b'[COMMAND]'),
2350 _(b'[COMMAND]'),
2351 helpcategory=command.CATEGORY_HELP,
2351 helpcategory=command.CATEGORY_HELP,
2352 norepo=True,
2352 norepo=True,
2353 )
2353 )
2354 def debugcommands(ui, cmd=b'', *args):
2354 def debugcommands(ui, cmd=b'', *args):
2355 """list all available commands and options"""
2355 """list all available commands and options"""
2356 for cmd, vals in sorted(pycompat.iteritems(table)):
2356 for cmd, vals in sorted(pycompat.iteritems(table)):
2357 cmd = cmd.split(b'|')[0]
2357 cmd = cmd.split(b'|')[0]
2358 opts = b', '.join([i[1] for i in vals[1]])
2358 opts = b', '.join([i[1] for i in vals[1]])
2359 ui.write(b'%s: %s\n' % (cmd, opts))
2359 ui.write(b'%s: %s\n' % (cmd, opts))
2360
2360
2361
2361
2362 @command(
2362 @command(
2363 b'debugcomplete',
2363 b'debugcomplete',
2364 [(b'o', b'options', None, _(b'show the command options'))],
2364 [(b'o', b'options', None, _(b'show the command options'))],
2365 _(b'[-o] CMD'),
2365 _(b'[-o] CMD'),
2366 helpcategory=command.CATEGORY_HELP,
2366 helpcategory=command.CATEGORY_HELP,
2367 norepo=True,
2367 norepo=True,
2368 )
2368 )
2369 def debugcomplete(ui, cmd=b'', **opts):
2369 def debugcomplete(ui, cmd=b'', **opts):
2370 """returns the completion list associated with the given command"""
2370 """returns the completion list associated with the given command"""
2371
2371
2372 if opts.get(r'options'):
2372 if opts.get(r'options'):
2373 options = []
2373 options = []
2374 otables = [globalopts]
2374 otables = [globalopts]
2375 if cmd:
2375 if cmd:
2376 aliases, entry = cmdutil.findcmd(cmd, table, False)
2376 aliases, entry = cmdutil.findcmd(cmd, table, False)
2377 otables.append(entry[1])
2377 otables.append(entry[1])
2378 for t in otables:
2378 for t in otables:
2379 for o in t:
2379 for o in t:
2380 if b"(DEPRECATED)" in o[3]:
2380 if b"(DEPRECATED)" in o[3]:
2381 continue
2381 continue
2382 if o[0]:
2382 if o[0]:
2383 options.append(b'-%s' % o[0])
2383 options.append(b'-%s' % o[0])
2384 options.append(b'--%s' % o[1])
2384 options.append(b'--%s' % o[1])
2385 ui.write(b"%s\n" % b"\n".join(options))
2385 ui.write(b"%s\n" % b"\n".join(options))
2386 return
2386 return
2387
2387
2388 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
2388 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
2389 if ui.verbose:
2389 if ui.verbose:
2390 cmdlist = [b' '.join(c[0]) for c in cmdlist.values()]
2390 cmdlist = [b' '.join(c[0]) for c in cmdlist.values()]
2391 ui.write(b"%s\n" % b"\n".join(sorted(cmdlist)))
2391 ui.write(b"%s\n" % b"\n".join(sorted(cmdlist)))
2392
2392
2393
2393
2394 @command(
2394 @command(
2395 b'diff',
2395 b'diff',
2396 [
2396 [
2397 (b'r', b'rev', [], _(b'revision'), _(b'REV')),
2397 (b'r', b'rev', [], _(b'revision'), _(b'REV')),
2398 (b'c', b'change', b'', _(b'change made by revision'), _(b'REV')),
2398 (b'c', b'change', b'', _(b'change made by revision'), _(b'REV')),
2399 ]
2399 ]
2400 + diffopts
2400 + diffopts
2401 + diffopts2
2401 + diffopts2
2402 + walkopts
2402 + walkopts
2403 + subrepoopts,
2403 + subrepoopts,
2404 _(b'[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
2404 _(b'[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
2405 helpcategory=command.CATEGORY_FILE_CONTENTS,
2405 helpcategory=command.CATEGORY_FILE_CONTENTS,
2406 helpbasic=True,
2406 helpbasic=True,
2407 inferrepo=True,
2407 inferrepo=True,
2408 intents={INTENT_READONLY},
2408 intents={INTENT_READONLY},
2409 )
2409 )
2410 def diff(ui, repo, *pats, **opts):
2410 def diff(ui, repo, *pats, **opts):
2411 """diff repository (or selected files)
2411 """diff repository (or selected files)
2412
2412
2413 Show differences between revisions for the specified files.
2413 Show differences between revisions for the specified files.
2414
2414
2415 Differences between files are shown using the unified diff format.
2415 Differences between files are shown using the unified diff format.
2416
2416
2417 .. note::
2417 .. note::
2418
2418
2419 :hg:`diff` may generate unexpected results for merges, as it will
2419 :hg:`diff` may generate unexpected results for merges, as it will
2420 default to comparing against the working directory's first
2420 default to comparing against the working directory's first
2421 parent changeset if no revisions are specified.
2421 parent changeset if no revisions are specified.
2422
2422
2423 When two revision arguments are given, then changes are shown
2423 When two revision arguments are given, then changes are shown
2424 between those revisions. If only one revision is specified then
2424 between those revisions. If only one revision is specified then
2425 that revision is compared to the working directory, and, when no
2425 that revision is compared to the working directory, and, when no
2426 revisions are specified, the working directory files are compared
2426 revisions are specified, the working directory files are compared
2427 to its first parent.
2427 to its first parent.
2428
2428
2429 Alternatively you can specify -c/--change with a revision to see
2429 Alternatively you can specify -c/--change with a revision to see
2430 the changes in that changeset relative to its first parent.
2430 the changes in that changeset relative to its first parent.
2431
2431
2432 Without the -a/--text option, diff will avoid generating diffs of
2432 Without the -a/--text option, diff will avoid generating diffs of
2433 files it detects as binary. With -a, diff will generate a diff
2433 files it detects as binary. With -a, diff will generate a diff
2434 anyway, probably with undesirable results.
2434 anyway, probably with undesirable results.
2435
2435
2436 Use the -g/--git option to generate diffs in the git extended diff
2436 Use the -g/--git option to generate diffs in the git extended diff
2437 format. For more information, read :hg:`help diffs`.
2437 format. For more information, read :hg:`help diffs`.
2438
2438
2439 .. container:: verbose
2439 .. container:: verbose
2440
2440
2441 Examples:
2441 Examples:
2442
2442
2443 - compare a file in the current working directory to its parent::
2443 - compare a file in the current working directory to its parent::
2444
2444
2445 hg diff foo.c
2445 hg diff foo.c
2446
2446
2447 - compare two historical versions of a directory, with rename info::
2447 - compare two historical versions of a directory, with rename info::
2448
2448
2449 hg diff --git -r 1.0:1.2 lib/
2449 hg diff --git -r 1.0:1.2 lib/
2450
2450
2451 - get change stats relative to the last change on some date::
2451 - get change stats relative to the last change on some date::
2452
2452
2453 hg diff --stat -r "date('may 2')"
2453 hg diff --stat -r "date('may 2')"
2454
2454
2455 - diff all newly-added files that contain a keyword::
2455 - diff all newly-added files that contain a keyword::
2456
2456
2457 hg diff "set:added() and grep(GNU)"
2457 hg diff "set:added() and grep(GNU)"
2458
2458
2459 - compare a revision and its parents::
2459 - compare a revision and its parents::
2460
2460
2461 hg diff -c 9353 # compare against first parent
2461 hg diff -c 9353 # compare against first parent
2462 hg diff -r 9353^:9353 # same using revset syntax
2462 hg diff -r 9353^:9353 # same using revset syntax
2463 hg diff -r 9353^2:9353 # compare against the second parent
2463 hg diff -r 9353^2:9353 # compare against the second parent
2464
2464
2465 Returns 0 on success.
2465 Returns 0 on success.
2466 """
2466 """
2467
2467
2468 opts = pycompat.byteskwargs(opts)
2468 opts = pycompat.byteskwargs(opts)
2469 revs = opts.get(b'rev')
2469 revs = opts.get(b'rev')
2470 change = opts.get(b'change')
2470 change = opts.get(b'change')
2471 stat = opts.get(b'stat')
2471 stat = opts.get(b'stat')
2472 reverse = opts.get(b'reverse')
2472 reverse = opts.get(b'reverse')
2473
2473
2474 if revs and change:
2474 if revs and change:
2475 msg = _(b'cannot specify --rev and --change at the same time')
2475 msg = _(b'cannot specify --rev and --change at the same time')
2476 raise error.Abort(msg)
2476 raise error.Abort(msg)
2477 elif change:
2477 elif change:
2478 repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
2478 repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
2479 ctx2 = scmutil.revsingle(repo, change, None)
2479 ctx2 = scmutil.revsingle(repo, change, None)
2480 ctx1 = ctx2.p1()
2480 ctx1 = ctx2.p1()
2481 else:
2481 else:
2482 repo = scmutil.unhidehashlikerevs(repo, revs, b'nowarn')
2482 repo = scmutil.unhidehashlikerevs(repo, revs, b'nowarn')
2483 ctx1, ctx2 = scmutil.revpair(repo, revs)
2483 ctx1, ctx2 = scmutil.revpair(repo, revs)
2484 node1, node2 = ctx1.node(), ctx2.node()
2484 node1, node2 = ctx1.node(), ctx2.node()
2485
2485
2486 if reverse:
2486 if reverse:
2487 node1, node2 = node2, node1
2487 node1, node2 = node2, node1
2488
2488
2489 diffopts = patch.diffallopts(ui, opts)
2489 diffopts = patch.diffallopts(ui, opts)
2490 m = scmutil.match(ctx2, pats, opts)
2490 m = scmutil.match(ctx2, pats, opts)
2491 m = repo.narrowmatch(m)
2491 m = repo.narrowmatch(m)
2492 ui.pager(b'diff')
2492 ui.pager(b'diff')
2493 logcmdutil.diffordiffstat(
2493 logcmdutil.diffordiffstat(
2494 ui,
2494 ui,
2495 repo,
2495 repo,
2496 diffopts,
2496 diffopts,
2497 node1,
2497 node1,
2498 node2,
2498 node2,
2499 m,
2499 m,
2500 stat=stat,
2500 stat=stat,
2501 listsubrepos=opts.get(b'subrepos'),
2501 listsubrepos=opts.get(b'subrepos'),
2502 root=opts.get(b'root'),
2502 root=opts.get(b'root'),
2503 )
2503 )
2504
2504
2505
2505
2506 @command(
2506 @command(
2507 b'export',
2507 b'export',
2508 [
2508 [
2509 (
2509 (
2510 b'B',
2510 b'B',
2511 b'bookmark',
2511 b'bookmark',
2512 b'',
2512 b'',
2513 _(b'export changes only reachable by given bookmark'),
2513 _(b'export changes only reachable by given bookmark'),
2514 _(b'BOOKMARK'),
2514 _(b'BOOKMARK'),
2515 ),
2515 ),
2516 (
2516 (
2517 b'o',
2517 b'o',
2518 b'output',
2518 b'output',
2519 b'',
2519 b'',
2520 _(b'print output to file with formatted name'),
2520 _(b'print output to file with formatted name'),
2521 _(b'FORMAT'),
2521 _(b'FORMAT'),
2522 ),
2522 ),
2523 (b'', b'switch-parent', None, _(b'diff against the second parent')),
2523 (b'', b'switch-parent', None, _(b'diff against the second parent')),
2524 (b'r', b'rev', [], _(b'revisions to export'), _(b'REV')),
2524 (b'r', b'rev', [], _(b'revisions to export'), _(b'REV')),
2525 ]
2525 ]
2526 + diffopts
2526 + diffopts
2527 + formatteropts,
2527 + formatteropts,
2528 _(b'[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'),
2528 _(b'[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'),
2529 helpcategory=command.CATEGORY_IMPORT_EXPORT,
2529 helpcategory=command.CATEGORY_IMPORT_EXPORT,
2530 helpbasic=True,
2530 helpbasic=True,
2531 intents={INTENT_READONLY},
2531 intents={INTENT_READONLY},
2532 )
2532 )
2533 def export(ui, repo, *changesets, **opts):
2533 def export(ui, repo, *changesets, **opts):
2534 """dump the header and diffs for one or more changesets
2534 """dump the header and diffs for one or more changesets
2535
2535
2536 Print the changeset header and diffs for one or more revisions.
2536 Print the changeset header and diffs for one or more revisions.
2537 If no revision is given, the parent of the working directory is used.
2537 If no revision is given, the parent of the working directory is used.
2538
2538
2539 The information shown in the changeset header is: author, date,
2539 The information shown in the changeset header is: author, date,
2540 branch name (if non-default), changeset hash, parent(s) and commit
2540 branch name (if non-default), changeset hash, parent(s) and commit
2541 comment.
2541 comment.
2542
2542
2543 .. note::
2543 .. note::
2544
2544
2545 :hg:`export` may generate unexpected diff output for merge
2545 :hg:`export` may generate unexpected diff output for merge
2546 changesets, as it will compare the merge changeset against its
2546 changesets, as it will compare the merge changeset against its
2547 first parent only.
2547 first parent only.
2548
2548
2549 Output may be to a file, in which case the name of the file is
2549 Output may be to a file, in which case the name of the file is
2550 given using a template string. See :hg:`help templates`. In addition
2550 given using a template string. See :hg:`help templates`. In addition
2551 to the common template keywords, the following formatting rules are
2551 to the common template keywords, the following formatting rules are
2552 supported:
2552 supported:
2553
2553
2554 :``%%``: literal "%" character
2554 :``%%``: literal "%" character
2555 :``%H``: changeset hash (40 hexadecimal digits)
2555 :``%H``: changeset hash (40 hexadecimal digits)
2556 :``%N``: number of patches being generated
2556 :``%N``: number of patches being generated
2557 :``%R``: changeset revision number
2557 :``%R``: changeset revision number
2558 :``%b``: basename of the exporting repository
2558 :``%b``: basename of the exporting repository
2559 :``%h``: short-form changeset hash (12 hexadecimal digits)
2559 :``%h``: short-form changeset hash (12 hexadecimal digits)
2560 :``%m``: first line of the commit message (only alphanumeric characters)
2560 :``%m``: first line of the commit message (only alphanumeric characters)
2561 :``%n``: zero-padded sequence number, starting at 1
2561 :``%n``: zero-padded sequence number, starting at 1
2562 :``%r``: zero-padded changeset revision number
2562 :``%r``: zero-padded changeset revision number
2563 :``\\``: literal "\\" character
2563 :``\\``: literal "\\" character
2564
2564
2565 Without the -a/--text option, export will avoid generating diffs
2565 Without the -a/--text option, export will avoid generating diffs
2566 of files it detects as binary. With -a, export will generate a
2566 of files it detects as binary. With -a, export will generate a
2567 diff anyway, probably with undesirable results.
2567 diff anyway, probably with undesirable results.
2568
2568
2569 With -B/--bookmark changesets reachable by the given bookmark are
2569 With -B/--bookmark changesets reachable by the given bookmark are
2570 selected.
2570 selected.
2571
2571
2572 Use the -g/--git option to generate diffs in the git extended diff
2572 Use the -g/--git option to generate diffs in the git extended diff
2573 format. See :hg:`help diffs` for more information.
2573 format. See :hg:`help diffs` for more information.
2574
2574
2575 With the --switch-parent option, the diff will be against the
2575 With the --switch-parent option, the diff will be against the
2576 second parent. It can be useful to review a merge.
2576 second parent. It can be useful to review a merge.
2577
2577
2578 .. container:: verbose
2578 .. container:: verbose
2579
2579
2580 Template:
2580 Template:
2581
2581
2582 The following keywords are supported in addition to the common template
2582 The following keywords are supported in addition to the common template
2583 keywords and functions. See also :hg:`help templates`.
2583 keywords and functions. See also :hg:`help templates`.
2584
2584
2585 :diff: String. Diff content.
2585 :diff: String. Diff content.
2586 :parents: List of strings. Parent nodes of the changeset.
2586 :parents: List of strings. Parent nodes of the changeset.
2587
2587
2588 Examples:
2588 Examples:
2589
2589
2590 - use export and import to transplant a bugfix to the current
2590 - use export and import to transplant a bugfix to the current
2591 branch::
2591 branch::
2592
2592
2593 hg export -r 9353 | hg import -
2593 hg export -r 9353 | hg import -
2594
2594
2595 - export all the changesets between two revisions to a file with
2595 - export all the changesets between two revisions to a file with
2596 rename information::
2596 rename information::
2597
2597
2598 hg export --git -r 123:150 > changes.txt
2598 hg export --git -r 123:150 > changes.txt
2599
2599
2600 - split outgoing changes into a series of patches with
2600 - split outgoing changes into a series of patches with
2601 descriptive names::
2601 descriptive names::
2602
2602
2603 hg export -r "outgoing()" -o "%n-%m.patch"
2603 hg export -r "outgoing()" -o "%n-%m.patch"
2604
2604
2605 Returns 0 on success.
2605 Returns 0 on success.
2606 """
2606 """
2607 opts = pycompat.byteskwargs(opts)
2607 opts = pycompat.byteskwargs(opts)
2608 bookmark = opts.get(b'bookmark')
2608 bookmark = opts.get(b'bookmark')
2609 changesets += tuple(opts.get(b'rev', []))
2609 changesets += tuple(opts.get(b'rev', []))
2610
2610
2611 if bookmark and changesets:
2611 if bookmark and changesets:
2612 raise error.Abort(_(b"-r and -B are mutually exclusive"))
2612 raise error.Abort(_(b"-r and -B are mutually exclusive"))
2613
2613
2614 if bookmark:
2614 if bookmark:
2615 if bookmark not in repo._bookmarks:
2615 if bookmark not in repo._bookmarks:
2616 raise error.Abort(_(b"bookmark '%s' not found") % bookmark)
2616 raise error.Abort(_(b"bookmark '%s' not found") % bookmark)
2617
2617
2618 revs = scmutil.bookmarkrevs(repo, bookmark)
2618 revs = scmutil.bookmarkrevs(repo, bookmark)
2619 else:
2619 else:
2620 if not changesets:
2620 if not changesets:
2621 changesets = [b'.']
2621 changesets = [b'.']
2622
2622
2623 repo = scmutil.unhidehashlikerevs(repo, changesets, b'nowarn')
2623 repo = scmutil.unhidehashlikerevs(repo, changesets, b'nowarn')
2624 revs = scmutil.revrange(repo, changesets)
2624 revs = scmutil.revrange(repo, changesets)
2625
2625
2626 if not revs:
2626 if not revs:
2627 raise error.Abort(_(b"export requires at least one changeset"))
2627 raise error.Abort(_(b"export requires at least one changeset"))
2628 if len(revs) > 1:
2628 if len(revs) > 1:
2629 ui.note(_(b'exporting patches:\n'))
2629 ui.note(_(b'exporting patches:\n'))
2630 else:
2630 else:
2631 ui.note(_(b'exporting patch:\n'))
2631 ui.note(_(b'exporting patch:\n'))
2632
2632
2633 fntemplate = opts.get(b'output')
2633 fntemplate = opts.get(b'output')
2634 if cmdutil.isstdiofilename(fntemplate):
2634 if cmdutil.isstdiofilename(fntemplate):
2635 fntemplate = b''
2635 fntemplate = b''
2636
2636
2637 if fntemplate:
2637 if fntemplate:
2638 fm = formatter.nullformatter(ui, b'export', opts)
2638 fm = formatter.nullformatter(ui, b'export', opts)
2639 else:
2639 else:
2640 ui.pager(b'export')
2640 ui.pager(b'export')
2641 fm = ui.formatter(b'export', opts)
2641 fm = ui.formatter(b'export', opts)
2642 with fm:
2642 with fm:
2643 cmdutil.export(
2643 cmdutil.export(
2644 repo,
2644 repo,
2645 revs,
2645 revs,
2646 fm,
2646 fm,
2647 fntemplate=fntemplate,
2647 fntemplate=fntemplate,
2648 switch_parent=opts.get(b'switch_parent'),
2648 switch_parent=opts.get(b'switch_parent'),
2649 opts=patch.diffallopts(ui, opts),
2649 opts=patch.diffallopts(ui, opts),
2650 )
2650 )
2651
2651
2652
2652
2653 @command(
2653 @command(
2654 b'files',
2654 b'files',
2655 [
2655 [
2656 (
2656 (
2657 b'r',
2657 b'r',
2658 b'rev',
2658 b'rev',
2659 b'',
2659 b'',
2660 _(b'search the repository as it is in REV'),
2660 _(b'search the repository as it is in REV'),
2661 _(b'REV'),
2661 _(b'REV'),
2662 ),
2662 ),
2663 (
2663 (
2664 b'0',
2664 b'0',
2665 b'print0',
2665 b'print0',
2666 None,
2666 None,
2667 _(b'end filenames with NUL, for use with xargs'),
2667 _(b'end filenames with NUL, for use with xargs'),
2668 ),
2668 ),
2669 ]
2669 ]
2670 + walkopts
2670 + walkopts
2671 + formatteropts
2671 + formatteropts
2672 + subrepoopts,
2672 + subrepoopts,
2673 _(b'[OPTION]... [FILE]...'),
2673 _(b'[OPTION]... [FILE]...'),
2674 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
2674 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
2675 intents={INTENT_READONLY},
2675 intents={INTENT_READONLY},
2676 )
2676 )
2677 def files(ui, repo, *pats, **opts):
2677 def files(ui, repo, *pats, **opts):
2678 """list tracked files
2678 """list tracked files
2679
2679
2680 Print files under Mercurial control in the working directory or
2680 Print files under Mercurial control in the working directory or
2681 specified revision for given files (excluding removed files).
2681 specified revision for given files (excluding removed files).
2682 Files can be specified as filenames or filesets.
2682 Files can be specified as filenames or filesets.
2683
2683
2684 If no files are given to match, this command prints the names
2684 If no files are given to match, this command prints the names
2685 of all files under Mercurial control.
2685 of all files under Mercurial control.
2686
2686
2687 .. container:: verbose
2687 .. container:: verbose
2688
2688
2689 Template:
2689 Template:
2690
2690
2691 The following keywords are supported in addition to the common template
2691 The following keywords are supported in addition to the common template
2692 keywords and functions. See also :hg:`help templates`.
2692 keywords and functions. See also :hg:`help templates`.
2693
2693
2694 :flags: String. Character denoting file's symlink and executable bits.
2694 :flags: String. Character denoting file's symlink and executable bits.
2695 :path: String. Repository-absolute path of the file.
2695 :path: String. Repository-absolute path of the file.
2696 :size: Integer. Size of the file in bytes.
2696 :size: Integer. Size of the file in bytes.
2697
2697
2698 Examples:
2698 Examples:
2699
2699
2700 - list all files under the current directory::
2700 - list all files under the current directory::
2701
2701
2702 hg files .
2702 hg files .
2703
2703
2704 - shows sizes and flags for current revision::
2704 - shows sizes and flags for current revision::
2705
2705
2706 hg files -vr .
2706 hg files -vr .
2707
2707
2708 - list all files named README::
2708 - list all files named README::
2709
2709
2710 hg files -I "**/README"
2710 hg files -I "**/README"
2711
2711
2712 - list all binary files::
2712 - list all binary files::
2713
2713
2714 hg files "set:binary()"
2714 hg files "set:binary()"
2715
2715
2716 - find files containing a regular expression::
2716 - find files containing a regular expression::
2717
2717
2718 hg files "set:grep('bob')"
2718 hg files "set:grep('bob')"
2719
2719
2720 - search tracked file contents with xargs and grep::
2720 - search tracked file contents with xargs and grep::
2721
2721
2722 hg files -0 | xargs -0 grep foo
2722 hg files -0 | xargs -0 grep foo
2723
2723
2724 See :hg:`help patterns` and :hg:`help filesets` for more information
2724 See :hg:`help patterns` and :hg:`help filesets` for more information
2725 on specifying file patterns.
2725 on specifying file patterns.
2726
2726
2727 Returns 0 if a match is found, 1 otherwise.
2727 Returns 0 if a match is found, 1 otherwise.
2728
2728
2729 """
2729 """
2730
2730
2731 opts = pycompat.byteskwargs(opts)
2731 opts = pycompat.byteskwargs(opts)
2732 rev = opts.get(b'rev')
2732 rev = opts.get(b'rev')
2733 if rev:
2733 if rev:
2734 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
2734 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
2735 ctx = scmutil.revsingle(repo, rev, None)
2735 ctx = scmutil.revsingle(repo, rev, None)
2736
2736
2737 end = b'\n'
2737 end = b'\n'
2738 if opts.get(b'print0'):
2738 if opts.get(b'print0'):
2739 end = b'\0'
2739 end = b'\0'
2740 fmt = b'%s' + end
2740 fmt = b'%s' + end
2741
2741
2742 m = scmutil.match(ctx, pats, opts)
2742 m = scmutil.match(ctx, pats, opts)
2743 ui.pager(b'files')
2743 ui.pager(b'files')
2744 uipathfn = scmutil.getuipathfn(ctx.repo(), legacyrelativevalue=True)
2744 uipathfn = scmutil.getuipathfn(ctx.repo(), legacyrelativevalue=True)
2745 with ui.formatter(b'files', opts) as fm:
2745 with ui.formatter(b'files', opts) as fm:
2746 return cmdutil.files(
2746 return cmdutil.files(
2747 ui, ctx, m, uipathfn, fm, fmt, opts.get(b'subrepos')
2747 ui, ctx, m, uipathfn, fm, fmt, opts.get(b'subrepos')
2748 )
2748 )
2749
2749
2750
2750
2751 @command(
2751 @command(
2752 b'forget',
2752 b'forget',
2753 [(b'i', b'interactive', None, _(b'use interactive mode')),]
2753 [(b'i', b'interactive', None, _(b'use interactive mode')),]
2754 + walkopts
2754 + walkopts
2755 + dryrunopts,
2755 + dryrunopts,
2756 _(b'[OPTION]... FILE...'),
2756 _(b'[OPTION]... FILE...'),
2757 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
2757 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
2758 helpbasic=True,
2758 helpbasic=True,
2759 inferrepo=True,
2759 inferrepo=True,
2760 )
2760 )
2761 def forget(ui, repo, *pats, **opts):
2761 def forget(ui, repo, *pats, **opts):
2762 """forget the specified files on the next commit
2762 """forget the specified files on the next commit
2763
2763
2764 Mark the specified files so they will no longer be tracked
2764 Mark the specified files so they will no longer be tracked
2765 after the next commit.
2765 after the next commit.
2766
2766
2767 This only removes files from the current branch, not from the
2767 This only removes files from the current branch, not from the
2768 entire project history, and it does not delete them from the
2768 entire project history, and it does not delete them from the
2769 working directory.
2769 working directory.
2770
2770
2771 To delete the file from the working directory, see :hg:`remove`.
2771 To delete the file from the working directory, see :hg:`remove`.
2772
2772
2773 To undo a forget before the next commit, see :hg:`add`.
2773 To undo a forget before the next commit, see :hg:`add`.
2774
2774
2775 .. container:: verbose
2775 .. container:: verbose
2776
2776
2777 Examples:
2777 Examples:
2778
2778
2779 - forget newly-added binary files::
2779 - forget newly-added binary files::
2780
2780
2781 hg forget "set:added() and binary()"
2781 hg forget "set:added() and binary()"
2782
2782
2783 - forget files that would be excluded by .hgignore::
2783 - forget files that would be excluded by .hgignore::
2784
2784
2785 hg forget "set:hgignore()"
2785 hg forget "set:hgignore()"
2786
2786
2787 Returns 0 on success.
2787 Returns 0 on success.
2788 """
2788 """
2789
2789
2790 opts = pycompat.byteskwargs(opts)
2790 opts = pycompat.byteskwargs(opts)
2791 if not pats:
2791 if not pats:
2792 raise error.Abort(_(b'no files specified'))
2792 raise error.Abort(_(b'no files specified'))
2793
2793
2794 m = scmutil.match(repo[None], pats, opts)
2794 m = scmutil.match(repo[None], pats, opts)
2795 dryrun, interactive = opts.get(b'dry_run'), opts.get(b'interactive')
2795 dryrun, interactive = opts.get(b'dry_run'), opts.get(b'interactive')
2796 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
2796 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
2797 rejected = cmdutil.forget(
2797 rejected = cmdutil.forget(
2798 ui,
2798 ui,
2799 repo,
2799 repo,
2800 m,
2800 m,
2801 prefix=b"",
2801 prefix=b"",
2802 uipathfn=uipathfn,
2802 uipathfn=uipathfn,
2803 explicitonly=False,
2803 explicitonly=False,
2804 dryrun=dryrun,
2804 dryrun=dryrun,
2805 interactive=interactive,
2805 interactive=interactive,
2806 )[0]
2806 )[0]
2807 return rejected and 1 or 0
2807 return rejected and 1 or 0
2808
2808
2809
2809
2810 @command(
2810 @command(
2811 b'graft',
2811 b'graft',
2812 [
2812 [
2813 (b'r', b'rev', [], _(b'revisions to graft'), _(b'REV')),
2813 (b'r', b'rev', [], _(b'revisions to graft'), _(b'REV')),
2814 (
2814 (
2815 b'',
2815 b'',
2816 b'base',
2816 b'base',
2817 b'',
2817 b'',
2818 _(b'base revision when doing the graft merge (ADVANCED)'),
2818 _(b'base revision when doing the graft merge (ADVANCED)'),
2819 _(b'REV'),
2819 _(b'REV'),
2820 ),
2820 ),
2821 (b'c', b'continue', False, _(b'resume interrupted graft')),
2821 (b'c', b'continue', False, _(b'resume interrupted graft')),
2822 (b'', b'stop', False, _(b'stop interrupted graft')),
2822 (b'', b'stop', False, _(b'stop interrupted graft')),
2823 (b'', b'abort', False, _(b'abort interrupted graft')),
2823 (b'', b'abort', False, _(b'abort interrupted graft')),
2824 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
2824 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
2825 (b'', b'log', None, _(b'append graft info to log message')),
2825 (b'', b'log', None, _(b'append graft info to log message')),
2826 (
2826 (
2827 b'',
2827 b'',
2828 b'no-commit',
2828 b'no-commit',
2829 None,
2829 None,
2830 _(b"don't commit, just apply the changes in working directory"),
2830 _(b"don't commit, just apply the changes in working directory"),
2831 ),
2831 ),
2832 (b'f', b'force', False, _(b'force graft')),
2832 (b'f', b'force', False, _(b'force graft')),
2833 (
2833 (
2834 b'D',
2834 b'D',
2835 b'currentdate',
2835 b'currentdate',
2836 False,
2836 False,
2837 _(b'record the current date as commit date'),
2837 _(b'record the current date as commit date'),
2838 ),
2838 ),
2839 (
2839 (
2840 b'U',
2840 b'U',
2841 b'currentuser',
2841 b'currentuser',
2842 False,
2842 False,
2843 _(b'record the current user as committer'),
2843 _(b'record the current user as committer'),
2844 ),
2844 ),
2845 ]
2845 ]
2846 + commitopts2
2846 + commitopts2
2847 + mergetoolopts
2847 + mergetoolopts
2848 + dryrunopts,
2848 + dryrunopts,
2849 _(b'[OPTION]... [-r REV]... REV...'),
2849 _(b'[OPTION]... [-r REV]... REV...'),
2850 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
2850 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
2851 )
2851 )
2852 def graft(ui, repo, *revs, **opts):
2852 def graft(ui, repo, *revs, **opts):
2853 '''copy changes from other branches onto the current branch
2853 '''copy changes from other branches onto the current branch
2854
2854
2855 This command uses Mercurial's merge logic to copy individual
2855 This command uses Mercurial's merge logic to copy individual
2856 changes from other branches without merging branches in the
2856 changes from other branches without merging branches in the
2857 history graph. This is sometimes known as 'backporting' or
2857 history graph. This is sometimes known as 'backporting' or
2858 'cherry-picking'. By default, graft will copy user, date, and
2858 'cherry-picking'. By default, graft will copy user, date, and
2859 description from the source changesets.
2859 description from the source changesets.
2860
2860
2861 Changesets that are ancestors of the current revision, that have
2861 Changesets that are ancestors of the current revision, that have
2862 already been grafted, or that are merges will be skipped.
2862 already been grafted, or that are merges will be skipped.
2863
2863
2864 If --log is specified, log messages will have a comment appended
2864 If --log is specified, log messages will have a comment appended
2865 of the form::
2865 of the form::
2866
2866
2867 (grafted from CHANGESETHASH)
2867 (grafted from CHANGESETHASH)
2868
2868
2869 If --force is specified, revisions will be grafted even if they
2869 If --force is specified, revisions will be grafted even if they
2870 are already ancestors of, or have been grafted to, the destination.
2870 are already ancestors of, or have been grafted to, the destination.
2871 This is useful when the revisions have since been backed out.
2871 This is useful when the revisions have since been backed out.
2872
2872
2873 If a graft merge results in conflicts, the graft process is
2873 If a graft merge results in conflicts, the graft process is
2874 interrupted so that the current merge can be manually resolved.
2874 interrupted so that the current merge can be manually resolved.
2875 Once all conflicts are addressed, the graft process can be
2875 Once all conflicts are addressed, the graft process can be
2876 continued with the -c/--continue option.
2876 continued with the -c/--continue option.
2877
2877
2878 The -c/--continue option reapplies all the earlier options.
2878 The -c/--continue option reapplies all the earlier options.
2879
2879
2880 .. container:: verbose
2880 .. container:: verbose
2881
2881
2882 The --base option exposes more of how graft internally uses merge with a
2882 The --base option exposes more of how graft internally uses merge with a
2883 custom base revision. --base can be used to specify another ancestor than
2883 custom base revision. --base can be used to specify another ancestor than
2884 the first and only parent.
2884 the first and only parent.
2885
2885
2886 The command::
2886 The command::
2887
2887
2888 hg graft -r 345 --base 234
2888 hg graft -r 345 --base 234
2889
2889
2890 is thus pretty much the same as::
2890 is thus pretty much the same as::
2891
2891
2892 hg diff -r 234 -r 345 | hg import
2892 hg diff -r 234 -r 345 | hg import
2893
2893
2894 but using merge to resolve conflicts and track moved files.
2894 but using merge to resolve conflicts and track moved files.
2895
2895
2896 The result of a merge can thus be backported as a single commit by
2896 The result of a merge can thus be backported as a single commit by
2897 specifying one of the merge parents as base, and thus effectively
2897 specifying one of the merge parents as base, and thus effectively
2898 grafting the changes from the other side.
2898 grafting the changes from the other side.
2899
2899
2900 It is also possible to collapse multiple changesets and clean up history
2900 It is also possible to collapse multiple changesets and clean up history
2901 by specifying another ancestor as base, much like rebase --collapse
2901 by specifying another ancestor as base, much like rebase --collapse
2902 --keep.
2902 --keep.
2903
2903
2904 The commit message can be tweaked after the fact using commit --amend .
2904 The commit message can be tweaked after the fact using commit --amend .
2905
2905
2906 For using non-ancestors as the base to backout changes, see the backout
2906 For using non-ancestors as the base to backout changes, see the backout
2907 command and the hidden --parent option.
2907 command and the hidden --parent option.
2908
2908
2909 .. container:: verbose
2909 .. container:: verbose
2910
2910
2911 Examples:
2911 Examples:
2912
2912
2913 - copy a single change to the stable branch and edit its description::
2913 - copy a single change to the stable branch and edit its description::
2914
2914
2915 hg update stable
2915 hg update stable
2916 hg graft --edit 9393
2916 hg graft --edit 9393
2917
2917
2918 - graft a range of changesets with one exception, updating dates::
2918 - graft a range of changesets with one exception, updating dates::
2919
2919
2920 hg graft -D "2085::2093 and not 2091"
2920 hg graft -D "2085::2093 and not 2091"
2921
2921
2922 - continue a graft after resolving conflicts::
2922 - continue a graft after resolving conflicts::
2923
2923
2924 hg graft -c
2924 hg graft -c
2925
2925
2926 - show the source of a grafted changeset::
2926 - show the source of a grafted changeset::
2927
2927
2928 hg log --debug -r .
2928 hg log --debug -r .
2929
2929
2930 - show revisions sorted by date::
2930 - show revisions sorted by date::
2931
2931
2932 hg log -r "sort(all(), date)"
2932 hg log -r "sort(all(), date)"
2933
2933
2934 - backport the result of a merge as a single commit::
2934 - backport the result of a merge as a single commit::
2935
2935
2936 hg graft -r 123 --base 123^
2936 hg graft -r 123 --base 123^
2937
2937
2938 - land a feature branch as one changeset::
2938 - land a feature branch as one changeset::
2939
2939
2940 hg up -cr default
2940 hg up -cr default
2941 hg graft -r featureX --base "ancestor('featureX', 'default')"
2941 hg graft -r featureX --base "ancestor('featureX', 'default')"
2942
2942
2943 See :hg:`help revisions` for more about specifying revisions.
2943 See :hg:`help revisions` for more about specifying revisions.
2944
2944
2945 Returns 0 on successful completion.
2945 Returns 0 on successful completion.
2946 '''
2946 '''
2947 with repo.wlock():
2947 with repo.wlock():
2948 return _dograft(ui, repo, *revs, **opts)
2948 return _dograft(ui, repo, *revs, **opts)
2949
2949
2950
2950
2951 def _dograft(ui, repo, *revs, **opts):
2951 def _dograft(ui, repo, *revs, **opts):
2952 opts = pycompat.byteskwargs(opts)
2952 opts = pycompat.byteskwargs(opts)
2953 if revs and opts.get(b'rev'):
2953 if revs and opts.get(b'rev'):
2954 ui.warn(
2954 ui.warn(
2955 _(
2955 _(
2956 b'warning: inconsistent use of --rev might give unexpected '
2956 b'warning: inconsistent use of --rev might give unexpected '
2957 b'revision ordering!\n'
2957 b'revision ordering!\n'
2958 )
2958 )
2959 )
2959 )
2960
2960
2961 revs = list(revs)
2961 revs = list(revs)
2962 revs.extend(opts.get(b'rev'))
2962 revs.extend(opts.get(b'rev'))
2963 basectx = None
2963 basectx = None
2964 if opts.get(b'base'):
2964 if opts.get(b'base'):
2965 basectx = scmutil.revsingle(repo, opts[b'base'], None)
2965 basectx = scmutil.revsingle(repo, opts[b'base'], None)
2966 # a dict of data to be stored in state file
2966 # a dict of data to be stored in state file
2967 statedata = {}
2967 statedata = {}
2968 # list of new nodes created by ongoing graft
2968 # list of new nodes created by ongoing graft
2969 statedata[b'newnodes'] = []
2969 statedata[b'newnodes'] = []
2970
2970
2971 if opts.get(b'user') and opts.get(b'currentuser'):
2971 if opts.get(b'user') and opts.get(b'currentuser'):
2972 raise error.Abort(_(b'--user and --currentuser are mutually exclusive'))
2972 raise error.Abort(_(b'--user and --currentuser are mutually exclusive'))
2973 if opts.get(b'date') and opts.get(b'currentdate'):
2973 if opts.get(b'date') and opts.get(b'currentdate'):
2974 raise error.Abort(_(b'--date and --currentdate are mutually exclusive'))
2974 raise error.Abort(_(b'--date and --currentdate are mutually exclusive'))
2975 if not opts.get(b'user') and opts.get(b'currentuser'):
2975 if not opts.get(b'user') and opts.get(b'currentuser'):
2976 opts[b'user'] = ui.username()
2976 opts[b'user'] = ui.username()
2977 if not opts.get(b'date') and opts.get(b'currentdate'):
2977 if not opts.get(b'date') and opts.get(b'currentdate'):
2978 opts[b'date'] = b"%d %d" % dateutil.makedate()
2978 opts[b'date'] = b"%d %d" % dateutil.makedate()
2979
2979
2980 editor = cmdutil.getcommiteditor(
2980 editor = cmdutil.getcommiteditor(
2981 editform=b'graft', **pycompat.strkwargs(opts)
2981 editform=b'graft', **pycompat.strkwargs(opts)
2982 )
2982 )
2983
2983
2984 cont = False
2984 cont = False
2985 if opts.get(b'no_commit'):
2985 if opts.get(b'no_commit'):
2986 if opts.get(b'edit'):
2986 if opts.get(b'edit'):
2987 raise error.Abort(
2987 raise error.Abort(
2988 _(b"cannot specify --no-commit and --edit together")
2988 _(b"cannot specify --no-commit and --edit together")
2989 )
2989 )
2990 if opts.get(b'currentuser'):
2990 if opts.get(b'currentuser'):
2991 raise error.Abort(
2991 raise error.Abort(
2992 _(b"cannot specify --no-commit and --currentuser together")
2992 _(b"cannot specify --no-commit and --currentuser together")
2993 )
2993 )
2994 if opts.get(b'currentdate'):
2994 if opts.get(b'currentdate'):
2995 raise error.Abort(
2995 raise error.Abort(
2996 _(b"cannot specify --no-commit and --currentdate together")
2996 _(b"cannot specify --no-commit and --currentdate together")
2997 )
2997 )
2998 if opts.get(b'log'):
2998 if opts.get(b'log'):
2999 raise error.Abort(
2999 raise error.Abort(
3000 _(b"cannot specify --no-commit and --log together")
3000 _(b"cannot specify --no-commit and --log together")
3001 )
3001 )
3002
3002
3003 graftstate = statemod.cmdstate(repo, b'graftstate')
3003 graftstate = statemod.cmdstate(repo, b'graftstate')
3004
3004
3005 if opts.get(b'stop'):
3005 if opts.get(b'stop'):
3006 if opts.get(b'continue'):
3006 if opts.get(b'continue'):
3007 raise error.Abort(
3007 raise error.Abort(
3008 _(b"cannot use '--continue' and '--stop' together")
3008 _(b"cannot use '--continue' and '--stop' together")
3009 )
3009 )
3010 if opts.get(b'abort'):
3010 if opts.get(b'abort'):
3011 raise error.Abort(_(b"cannot use '--abort' and '--stop' together"))
3011 raise error.Abort(_(b"cannot use '--abort' and '--stop' together"))
3012
3012
3013 if any(
3013 if any(
3014 (
3014 (
3015 opts.get(b'edit'),
3015 opts.get(b'edit'),
3016 opts.get(b'log'),
3016 opts.get(b'log'),
3017 opts.get(b'user'),
3017 opts.get(b'user'),
3018 opts.get(b'date'),
3018 opts.get(b'date'),
3019 opts.get(b'currentdate'),
3019 opts.get(b'currentdate'),
3020 opts.get(b'currentuser'),
3020 opts.get(b'currentuser'),
3021 opts.get(b'rev'),
3021 opts.get(b'rev'),
3022 )
3022 )
3023 ):
3023 ):
3024 raise error.Abort(_(b"cannot specify any other flag with '--stop'"))
3024 raise error.Abort(_(b"cannot specify any other flag with '--stop'"))
3025 return _stopgraft(ui, repo, graftstate)
3025 return _stopgraft(ui, repo, graftstate)
3026 elif opts.get(b'abort'):
3026 elif opts.get(b'abort'):
3027 if opts.get(b'continue'):
3027 if opts.get(b'continue'):
3028 raise error.Abort(
3028 raise error.Abort(
3029 _(b"cannot use '--continue' and '--abort' together")
3029 _(b"cannot use '--continue' and '--abort' together")
3030 )
3030 )
3031 if any(
3031 if any(
3032 (
3032 (
3033 opts.get(b'edit'),
3033 opts.get(b'edit'),
3034 opts.get(b'log'),
3034 opts.get(b'log'),
3035 opts.get(b'user'),
3035 opts.get(b'user'),
3036 opts.get(b'date'),
3036 opts.get(b'date'),
3037 opts.get(b'currentdate'),
3037 opts.get(b'currentdate'),
3038 opts.get(b'currentuser'),
3038 opts.get(b'currentuser'),
3039 opts.get(b'rev'),
3039 opts.get(b'rev'),
3040 )
3040 )
3041 ):
3041 ):
3042 raise error.Abort(
3042 raise error.Abort(
3043 _(b"cannot specify any other flag with '--abort'")
3043 _(b"cannot specify any other flag with '--abort'")
3044 )
3044 )
3045
3045
3046 return cmdutil.abortgraft(ui, repo, graftstate)
3046 return cmdutil.abortgraft(ui, repo, graftstate)
3047 elif opts.get(b'continue'):
3047 elif opts.get(b'continue'):
3048 cont = True
3048 cont = True
3049 if revs:
3049 if revs:
3050 raise error.Abort(_(b"can't specify --continue and revisions"))
3050 raise error.Abort(_(b"can't specify --continue and revisions"))
3051 # read in unfinished revisions
3051 # read in unfinished revisions
3052 if graftstate.exists():
3052 if graftstate.exists():
3053 statedata = cmdutil.readgraftstate(repo, graftstate)
3053 statedata = cmdutil.readgraftstate(repo, graftstate)
3054 if statedata.get(b'date'):
3054 if statedata.get(b'date'):
3055 opts[b'date'] = statedata[b'date']
3055 opts[b'date'] = statedata[b'date']
3056 if statedata.get(b'user'):
3056 if statedata.get(b'user'):
3057 opts[b'user'] = statedata[b'user']
3057 opts[b'user'] = statedata[b'user']
3058 if statedata.get(b'log'):
3058 if statedata.get(b'log'):
3059 opts[b'log'] = True
3059 opts[b'log'] = True
3060 if statedata.get(b'no_commit'):
3060 if statedata.get(b'no_commit'):
3061 opts[b'no_commit'] = statedata.get(b'no_commit')
3061 opts[b'no_commit'] = statedata.get(b'no_commit')
3062 nodes = statedata[b'nodes']
3062 nodes = statedata[b'nodes']
3063 revs = [repo[node].rev() for node in nodes]
3063 revs = [repo[node].rev() for node in nodes]
3064 else:
3064 else:
3065 cmdutil.wrongtooltocontinue(repo, _(b'graft'))
3065 cmdutil.wrongtooltocontinue(repo, _(b'graft'))
3066 else:
3066 else:
3067 if not revs:
3067 if not revs:
3068 raise error.Abort(_(b'no revisions specified'))
3068 raise error.Abort(_(b'no revisions specified'))
3069 cmdutil.checkunfinished(repo)
3069 cmdutil.checkunfinished(repo)
3070 cmdutil.bailifchanged(repo)
3070 cmdutil.bailifchanged(repo)
3071 revs = scmutil.revrange(repo, revs)
3071 revs = scmutil.revrange(repo, revs)
3072
3072
3073 skipped = set()
3073 skipped = set()
3074 if basectx is None:
3074 if basectx is None:
3075 # check for merges
3075 # check for merges
3076 for rev in repo.revs(b'%ld and merge()', revs):
3076 for rev in repo.revs(b'%ld and merge()', revs):
3077 ui.warn(_(b'skipping ungraftable merge revision %d\n') % rev)
3077 ui.warn(_(b'skipping ungraftable merge revision %d\n') % rev)
3078 skipped.add(rev)
3078 skipped.add(rev)
3079 revs = [r for r in revs if r not in skipped]
3079 revs = [r for r in revs if r not in skipped]
3080 if not revs:
3080 if not revs:
3081 return -1
3081 return -1
3082 if basectx is not None and len(revs) != 1:
3082 if basectx is not None and len(revs) != 1:
3083 raise error.Abort(_(b'only one revision allowed with --base '))
3083 raise error.Abort(_(b'only one revision allowed with --base '))
3084
3084
3085 # Don't check in the --continue case, in effect retaining --force across
3085 # Don't check in the --continue case, in effect retaining --force across
3086 # --continues. That's because without --force, any revisions we decided to
3086 # --continues. That's because without --force, any revisions we decided to
3087 # skip would have been filtered out here, so they wouldn't have made their
3087 # skip would have been filtered out here, so they wouldn't have made their
3088 # way to the graftstate. With --force, any revisions we would have otherwise
3088 # way to the graftstate. With --force, any revisions we would have otherwise
3089 # skipped would not have been filtered out, and if they hadn't been applied
3089 # skipped would not have been filtered out, and if they hadn't been applied
3090 # already, they'd have been in the graftstate.
3090 # already, they'd have been in the graftstate.
3091 if not (cont or opts.get(b'force')) and basectx is None:
3091 if not (cont or opts.get(b'force')) and basectx is None:
3092 # check for ancestors of dest branch
3092 # check for ancestors of dest branch
3093 crev = repo[b'.'].rev()
3093 crev = repo[b'.'].rev()
3094 ancestors = repo.changelog.ancestors([crev], inclusive=True)
3094 ancestors = repo.changelog.ancestors([crev], inclusive=True)
3095 # XXX make this lazy in the future
3095 # XXX make this lazy in the future
3096 # don't mutate while iterating, create a copy
3096 # don't mutate while iterating, create a copy
3097 for rev in list(revs):
3097 for rev in list(revs):
3098 if rev in ancestors:
3098 if rev in ancestors:
3099 ui.warn(
3099 ui.warn(
3100 _(b'skipping ancestor revision %d:%s\n') % (rev, repo[rev])
3100 _(b'skipping ancestor revision %d:%s\n') % (rev, repo[rev])
3101 )
3101 )
3102 # XXX remove on list is slow
3102 # XXX remove on list is slow
3103 revs.remove(rev)
3103 revs.remove(rev)
3104 if not revs:
3104 if not revs:
3105 return -1
3105 return -1
3106
3106
3107 # analyze revs for earlier grafts
3107 # analyze revs for earlier grafts
3108 ids = {}
3108 ids = {}
3109 for ctx in repo.set(b"%ld", revs):
3109 for ctx in repo.set(b"%ld", revs):
3110 ids[ctx.hex()] = ctx.rev()
3110 ids[ctx.hex()] = ctx.rev()
3111 n = ctx.extra().get(b'source')
3111 n = ctx.extra().get(b'source')
3112 if n:
3112 if n:
3113 ids[n] = ctx.rev()
3113 ids[n] = ctx.rev()
3114
3114
3115 # check ancestors for earlier grafts
3115 # check ancestors for earlier grafts
3116 ui.debug(b'scanning for duplicate grafts\n')
3116 ui.debug(b'scanning for duplicate grafts\n')
3117
3117
3118 # The only changesets we can be sure doesn't contain grafts of any
3118 # The only changesets we can be sure doesn't contain grafts of any
3119 # revs, are the ones that are common ancestors of *all* revs:
3119 # revs, are the ones that are common ancestors of *all* revs:
3120 for rev in repo.revs(b'only(%d,ancestor(%ld))', crev, revs):
3120 for rev in repo.revs(b'only(%d,ancestor(%ld))', crev, revs):
3121 ctx = repo[rev]
3121 ctx = repo[rev]
3122 n = ctx.extra().get(b'source')
3122 n = ctx.extra().get(b'source')
3123 if n in ids:
3123 if n in ids:
3124 try:
3124 try:
3125 r = repo[n].rev()
3125 r = repo[n].rev()
3126 except error.RepoLookupError:
3126 except error.RepoLookupError:
3127 r = None
3127 r = None
3128 if r in revs:
3128 if r in revs:
3129 ui.warn(
3129 ui.warn(
3130 _(
3130 _(
3131 b'skipping revision %d:%s '
3131 b'skipping revision %d:%s '
3132 b'(already grafted to %d:%s)\n'
3132 b'(already grafted to %d:%s)\n'
3133 )
3133 )
3134 % (r, repo[r], rev, ctx)
3134 % (r, repo[r], rev, ctx)
3135 )
3135 )
3136 revs.remove(r)
3136 revs.remove(r)
3137 elif ids[n] in revs:
3137 elif ids[n] in revs:
3138 if r is None:
3138 if r is None:
3139 ui.warn(
3139 ui.warn(
3140 _(
3140 _(
3141 b'skipping already grafted revision %d:%s '
3141 b'skipping already grafted revision %d:%s '
3142 b'(%d:%s also has unknown origin %s)\n'
3142 b'(%d:%s also has unknown origin %s)\n'
3143 )
3143 )
3144 % (ids[n], repo[ids[n]], rev, ctx, n[:12])
3144 % (ids[n], repo[ids[n]], rev, ctx, n[:12])
3145 )
3145 )
3146 else:
3146 else:
3147 ui.warn(
3147 ui.warn(
3148 _(
3148 _(
3149 b'skipping already grafted revision %d:%s '
3149 b'skipping already grafted revision %d:%s '
3150 b'(%d:%s also has origin %d:%s)\n'
3150 b'(%d:%s also has origin %d:%s)\n'
3151 )
3151 )
3152 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12])
3152 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12])
3153 )
3153 )
3154 revs.remove(ids[n])
3154 revs.remove(ids[n])
3155 elif ctx.hex() in ids:
3155 elif ctx.hex() in ids:
3156 r = ids[ctx.hex()]
3156 r = ids[ctx.hex()]
3157 if r in revs:
3157 if r in revs:
3158 ui.warn(
3158 ui.warn(
3159 _(
3159 _(
3160 b'skipping already grafted revision %d:%s '
3160 b'skipping already grafted revision %d:%s '
3161 b'(was grafted from %d:%s)\n'
3161 b'(was grafted from %d:%s)\n'
3162 )
3162 )
3163 % (r, repo[r], rev, ctx)
3163 % (r, repo[r], rev, ctx)
3164 )
3164 )
3165 revs.remove(r)
3165 revs.remove(r)
3166 if not revs:
3166 if not revs:
3167 return -1
3167 return -1
3168
3168
3169 if opts.get(b'no_commit'):
3169 if opts.get(b'no_commit'):
3170 statedata[b'no_commit'] = True
3170 statedata[b'no_commit'] = True
3171 for pos, ctx in enumerate(repo.set(b"%ld", revs)):
3171 for pos, ctx in enumerate(repo.set(b"%ld", revs)):
3172 desc = b'%d:%s "%s"' % (
3172 desc = b'%d:%s "%s"' % (
3173 ctx.rev(),
3173 ctx.rev(),
3174 ctx,
3174 ctx,
3175 ctx.description().split(b'\n', 1)[0],
3175 ctx.description().split(b'\n', 1)[0],
3176 )
3176 )
3177 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
3177 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
3178 if names:
3178 if names:
3179 desc += b' (%s)' % b' '.join(names)
3179 desc += b' (%s)' % b' '.join(names)
3180 ui.status(_(b'grafting %s\n') % desc)
3180 ui.status(_(b'grafting %s\n') % desc)
3181 if opts.get(b'dry_run'):
3181 if opts.get(b'dry_run'):
3182 continue
3182 continue
3183
3183
3184 source = ctx.extra().get(b'source')
3184 source = ctx.extra().get(b'source')
3185 extra = {}
3185 extra = {}
3186 if source:
3186 if source:
3187 extra[b'source'] = source
3187 extra[b'source'] = source
3188 extra[b'intermediate-source'] = ctx.hex()
3188 extra[b'intermediate-source'] = ctx.hex()
3189 else:
3189 else:
3190 extra[b'source'] = ctx.hex()
3190 extra[b'source'] = ctx.hex()
3191 user = ctx.user()
3191 user = ctx.user()
3192 if opts.get(b'user'):
3192 if opts.get(b'user'):
3193 user = opts[b'user']
3193 user = opts[b'user']
3194 statedata[b'user'] = user
3194 statedata[b'user'] = user
3195 date = ctx.date()
3195 date = ctx.date()
3196 if opts.get(b'date'):
3196 if opts.get(b'date'):
3197 date = opts[b'date']
3197 date = opts[b'date']
3198 statedata[b'date'] = date
3198 statedata[b'date'] = date
3199 message = ctx.description()
3199 message = ctx.description()
3200 if opts.get(b'log'):
3200 if opts.get(b'log'):
3201 message += b'\n(grafted from %s)' % ctx.hex()
3201 message += b'\n(grafted from %s)' % ctx.hex()
3202 statedata[b'log'] = True
3202 statedata[b'log'] = True
3203
3203
3204 # we don't merge the first commit when continuing
3204 # we don't merge the first commit when continuing
3205 if not cont:
3205 if not cont:
3206 # perform the graft merge with p1(rev) as 'ancestor'
3206 # perform the graft merge with p1(rev) as 'ancestor'
3207 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
3207 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
3208 base = ctx.p1() if basectx is None else basectx
3208 base = ctx.p1() if basectx is None else basectx
3209 with ui.configoverride(overrides, b'graft'):
3209 with ui.configoverride(overrides, b'graft'):
3210 stats = mergemod.graft(repo, ctx, base, [b'local', b'graft'])
3210 stats = mergemod.graft(repo, ctx, base, [b'local', b'graft'])
3211 # report any conflicts
3211 # report any conflicts
3212 if stats.unresolvedcount > 0:
3212 if stats.unresolvedcount > 0:
3213 # write out state for --continue
3213 # write out state for --continue
3214 nodes = [repo[rev].hex() for rev in revs[pos:]]
3214 nodes = [repo[rev].hex() for rev in revs[pos:]]
3215 statedata[b'nodes'] = nodes
3215 statedata[b'nodes'] = nodes
3216 stateversion = 1
3216 stateversion = 1
3217 graftstate.save(stateversion, statedata)
3217 graftstate.save(stateversion, statedata)
3218 hint = _(b"use 'hg resolve' and 'hg graft --continue'")
3218 hint = _(b"use 'hg resolve' and 'hg graft --continue'")
3219 raise error.Abort(
3219 raise error.Abort(
3220 _(b"unresolved conflicts, can't continue"), hint=hint
3220 _(b"unresolved conflicts, can't continue"), hint=hint
3221 )
3221 )
3222 else:
3222 else:
3223 cont = False
3223 cont = False
3224
3224
3225 # commit if --no-commit is false
3225 # commit if --no-commit is false
3226 if not opts.get(b'no_commit'):
3226 if not opts.get(b'no_commit'):
3227 node = repo.commit(
3227 node = repo.commit(
3228 text=message, user=user, date=date, extra=extra, editor=editor
3228 text=message, user=user, date=date, extra=extra, editor=editor
3229 )
3229 )
3230 if node is None:
3230 if node is None:
3231 ui.warn(
3231 ui.warn(
3232 _(b'note: graft of %d:%s created no changes to commit\n')
3232 _(b'note: graft of %d:%s created no changes to commit\n')
3233 % (ctx.rev(), ctx)
3233 % (ctx.rev(), ctx)
3234 )
3234 )
3235 # checking that newnodes exist because old state files won't have it
3235 # checking that newnodes exist because old state files won't have it
3236 elif statedata.get(b'newnodes') is not None:
3236 elif statedata.get(b'newnodes') is not None:
3237 statedata[b'newnodes'].append(node)
3237 statedata[b'newnodes'].append(node)
3238
3238
3239 # remove state when we complete successfully
3239 # remove state when we complete successfully
3240 if not opts.get(b'dry_run'):
3240 if not opts.get(b'dry_run'):
3241 graftstate.delete()
3241 graftstate.delete()
3242
3242
3243 return 0
3243 return 0
3244
3244
3245
3245
3246 def _stopgraft(ui, repo, graftstate):
3246 def _stopgraft(ui, repo, graftstate):
3247 """stop the interrupted graft"""
3247 """stop the interrupted graft"""
3248 if not graftstate.exists():
3248 if not graftstate.exists():
3249 raise error.Abort(_(b"no interrupted graft found"))
3249 raise error.Abort(_(b"no interrupted graft found"))
3250 pctx = repo[b'.']
3250 pctx = repo[b'.']
3251 hg.updaterepo(repo, pctx.node(), overwrite=True)
3251 hg.updaterepo(repo, pctx.node(), overwrite=True)
3252 graftstate.delete()
3252 graftstate.delete()
3253 ui.status(_(b"stopped the interrupted graft\n"))
3253 ui.status(_(b"stopped the interrupted graft\n"))
3254 ui.status(_(b"working directory is now at %s\n") % pctx.hex()[:12])
3254 ui.status(_(b"working directory is now at %s\n") % pctx.hex()[:12])
3255 return 0
3255 return 0
3256
3256
3257
3257
3258 statemod.addunfinished(
3258 statemod.addunfinished(
3259 b'graft',
3259 b'graft',
3260 fname=b'graftstate',
3260 fname=b'graftstate',
3261 clearable=True,
3261 clearable=True,
3262 stopflag=True,
3262 stopflag=True,
3263 continueflag=True,
3263 continueflag=True,
3264 abortfunc=cmdutil.hgabortgraft,
3264 abortfunc=cmdutil.hgabortgraft,
3265 cmdhint=_(b"use 'hg graft --continue' or 'hg graft --stop' to stop"),
3265 cmdhint=_(b"use 'hg graft --continue' or 'hg graft --stop' to stop"),
3266 )
3266 )
3267
3267
3268
3268
3269 @command(
3269 @command(
3270 b'grep',
3270 b'grep',
3271 [
3271 [
3272 (b'0', b'print0', None, _(b'end fields with NUL')),
3272 (b'0', b'print0', None, _(b'end fields with NUL')),
3273 (b'', b'all', None, _(b'print all revisions that match (DEPRECATED) ')),
3273 (b'', b'all', None, _(b'print all revisions that match (DEPRECATED) ')),
3274 (
3274 (
3275 b'',
3275 b'',
3276 b'diff',
3276 b'diff',
3277 None,
3277 None,
3278 _(
3278 _(
3279 b'print all revisions when the term was introduced '
3279 b'print all revisions when the term was introduced '
3280 b'or removed'
3280 b'or removed'
3281 ),
3281 ),
3282 ),
3282 ),
3283 (b'a', b'text', None, _(b'treat all files as text')),
3283 (b'a', b'text', None, _(b'treat all files as text')),
3284 (
3284 (
3285 b'f',
3285 b'f',
3286 b'follow',
3286 b'follow',
3287 None,
3287 None,
3288 _(
3288 _(
3289 b'follow changeset history,'
3289 b'follow changeset history,'
3290 b' or file history across copies and renames'
3290 b' or file history across copies and renames'
3291 ),
3291 ),
3292 ),
3292 ),
3293 (b'i', b'ignore-case', None, _(b'ignore case when matching')),
3293 (b'i', b'ignore-case', None, _(b'ignore case when matching')),
3294 (
3294 (
3295 b'l',
3295 b'l',
3296 b'files-with-matches',
3296 b'files-with-matches',
3297 None,
3297 None,
3298 _(b'print only filenames and revisions that match'),
3298 _(b'print only filenames and revisions that match'),
3299 ),
3299 ),
3300 (b'n', b'line-number', None, _(b'print matching line numbers')),
3300 (b'n', b'line-number', None, _(b'print matching line numbers')),
3301 (
3301 (
3302 b'r',
3302 b'r',
3303 b'rev',
3303 b'rev',
3304 [],
3304 [],
3305 _(b'only search files changed within revision range'),
3305 _(b'only search files changed within revision range'),
3306 _(b'REV'),
3306 _(b'REV'),
3307 ),
3307 ),
3308 (
3308 (
3309 b'',
3309 b'',
3310 b'all-files',
3310 b'all-files',
3311 None,
3311 None,
3312 _(
3312 _(
3313 b'include all files in the changeset while grepping (EXPERIMENTAL)'
3313 b'include all files in the changeset while grepping (EXPERIMENTAL)'
3314 ),
3314 ),
3315 ),
3315 ),
3316 (b'u', b'user', None, _(b'list the author (long with -v)')),
3316 (b'u', b'user', None, _(b'list the author (long with -v)')),
3317 (b'd', b'date', None, _(b'list the date (short with -q)')),
3317 (b'd', b'date', None, _(b'list the date (short with -q)')),
3318 ]
3318 ]
3319 + formatteropts
3319 + formatteropts
3320 + walkopts,
3320 + walkopts,
3321 _(b'[OPTION]... PATTERN [FILE]...'),
3321 _(b'[OPTION]... PATTERN [FILE]...'),
3322 helpcategory=command.CATEGORY_FILE_CONTENTS,
3322 helpcategory=command.CATEGORY_FILE_CONTENTS,
3323 inferrepo=True,
3323 inferrepo=True,
3324 intents={INTENT_READONLY},
3324 intents={INTENT_READONLY},
3325 )
3325 )
3326 def grep(ui, repo, pattern, *pats, **opts):
3326 def grep(ui, repo, pattern, *pats, **opts):
3327 """search revision history for a pattern in specified files
3327 """search revision history for a pattern in specified files
3328
3328
3329 Search revision history for a regular expression in the specified
3329 Search revision history for a regular expression in the specified
3330 files or the entire project.
3330 files or the entire project.
3331
3331
3332 By default, grep prints the most recent revision number for each
3332 By default, grep prints the most recent revision number for each
3333 file in which it finds a match. To get it to print every revision
3333 file in which it finds a match. To get it to print every revision
3334 that contains a change in match status ("-" for a match that becomes
3334 that contains a change in match status ("-" for a match that becomes
3335 a non-match, or "+" for a non-match that becomes a match), use the
3335 a non-match, or "+" for a non-match that becomes a match), use the
3336 --diff flag.
3336 --diff flag.
3337
3337
3338 PATTERN can be any Python (roughly Perl-compatible) regular
3338 PATTERN can be any Python (roughly Perl-compatible) regular
3339 expression.
3339 expression.
3340
3340
3341 If no FILEs are specified (and -f/--follow isn't set), all files in
3341 If no FILEs are specified (and -f/--follow isn't set), all files in
3342 the repository are searched, including those that don't exist in the
3342 the repository are searched, including those that don't exist in the
3343 current branch or have been deleted in a prior changeset.
3343 current branch or have been deleted in a prior changeset.
3344
3344
3345 .. container:: verbose
3345 .. container:: verbose
3346
3346
3347 Template:
3347 Template:
3348
3348
3349 The following keywords are supported in addition to the common template
3349 The following keywords are supported in addition to the common template
3350 keywords and functions. See also :hg:`help templates`.
3350 keywords and functions. See also :hg:`help templates`.
3351
3351
3352 :change: String. Character denoting insertion ``+`` or removal ``-``.
3352 :change: String. Character denoting insertion ``+`` or removal ``-``.
3353 Available if ``--diff`` is specified.
3353 Available if ``--diff`` is specified.
3354 :lineno: Integer. Line number of the match.
3354 :lineno: Integer. Line number of the match.
3355 :path: String. Repository-absolute path of the file.
3355 :path: String. Repository-absolute path of the file.
3356 :texts: List of text chunks.
3356 :texts: List of text chunks.
3357
3357
3358 And each entry of ``{texts}`` provides the following sub-keywords.
3358 And each entry of ``{texts}`` provides the following sub-keywords.
3359
3359
3360 :matched: Boolean. True if the chunk matches the specified pattern.
3360 :matched: Boolean. True if the chunk matches the specified pattern.
3361 :text: String. Chunk content.
3361 :text: String. Chunk content.
3362
3362
3363 See :hg:`help templates.operators` for the list expansion syntax.
3363 See :hg:`help templates.operators` for the list expansion syntax.
3364
3364
3365 Returns 0 if a match is found, 1 otherwise.
3365 Returns 0 if a match is found, 1 otherwise.
3366 """
3366 """
3367 opts = pycompat.byteskwargs(opts)
3367 opts = pycompat.byteskwargs(opts)
3368 diff = opts.get(b'all') or opts.get(b'diff')
3368 diff = opts.get(b'all') or opts.get(b'diff')
3369 all_files = opts.get(b'all_files')
3369 all_files = opts.get(b'all_files')
3370 if diff and opts.get(b'all_files'):
3370 if diff and opts.get(b'all_files'):
3371 raise error.Abort(_(b'--diff and --all-files are mutually exclusive'))
3371 raise error.Abort(_(b'--diff and --all-files are mutually exclusive'))
3372 # TODO: remove "not opts.get('rev')" if --all-files -rMULTIREV gets working
3372 # TODO: remove "not opts.get('rev')" if --all-files -rMULTIREV gets working
3373 if opts.get(b'all_files') is None and not opts.get(b'rev') and not diff:
3373 if opts.get(b'all_files') is None and not opts.get(b'rev') and not diff:
3374 # experimental config: commands.grep.all-files
3374 # experimental config: commands.grep.all-files
3375 opts[b'all_files'] = ui.configbool(b'commands', b'grep.all-files')
3375 opts[b'all_files'] = ui.configbool(b'commands', b'grep.all-files')
3376 plaingrep = opts.get(b'all_files') and not opts.get(b'rev')
3376 plaingrep = opts.get(b'all_files') and not opts.get(b'rev')
3377 if plaingrep:
3377 if plaingrep:
3378 opts[b'rev'] = [b'wdir()']
3378 opts[b'rev'] = [b'wdir()']
3379
3379
3380 reflags = re.M
3380 reflags = re.M
3381 if opts.get(b'ignore_case'):
3381 if opts.get(b'ignore_case'):
3382 reflags |= re.I
3382 reflags |= re.I
3383 try:
3383 try:
3384 regexp = util.re.compile(pattern, reflags)
3384 regexp = util.re.compile(pattern, reflags)
3385 except re.error as inst:
3385 except re.error as inst:
3386 ui.warn(
3386 ui.warn(
3387 _(b"grep: invalid match pattern: %s\n") % pycompat.bytestr(inst)
3387 _(b"grep: invalid match pattern: %s\n") % pycompat.bytestr(inst)
3388 )
3388 )
3389 return 1
3389 return 1
3390 sep, eol = b':', b'\n'
3390 sep, eol = b':', b'\n'
3391 if opts.get(b'print0'):
3391 if opts.get(b'print0'):
3392 sep = eol = b'\0'
3392 sep = eol = b'\0'
3393
3393
3394 getfile = util.lrucachefunc(repo.file)
3394 getfile = util.lrucachefunc(repo.file)
3395
3395
3396 def matchlines(body):
3396 def matchlines(body):
3397 begin = 0
3397 begin = 0
3398 linenum = 0
3398 linenum = 0
3399 while begin < len(body):
3399 while begin < len(body):
3400 match = regexp.search(body, begin)
3400 match = regexp.search(body, begin)
3401 if not match:
3401 if not match:
3402 break
3402 break
3403 mstart, mend = match.span()
3403 mstart, mend = match.span()
3404 linenum += body.count(b'\n', begin, mstart) + 1
3404 linenum += body.count(b'\n', begin, mstart) + 1
3405 lstart = body.rfind(b'\n', begin, mstart) + 1 or begin
3405 lstart = body.rfind(b'\n', begin, mstart) + 1 or begin
3406 begin = body.find(b'\n', mend) + 1 or len(body) + 1
3406 begin = body.find(b'\n', mend) + 1 or len(body) + 1
3407 lend = begin - 1
3407 lend = begin - 1
3408 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
3408 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
3409
3409
3410 class linestate(object):
3410 class linestate(object):
3411 def __init__(self, line, linenum, colstart, colend):
3411 def __init__(self, line, linenum, colstart, colend):
3412 self.line = line
3412 self.line = line
3413 self.linenum = linenum
3413 self.linenum = linenum
3414 self.colstart = colstart
3414 self.colstart = colstart
3415 self.colend = colend
3415 self.colend = colend
3416
3416
3417 def __hash__(self):
3417 def __hash__(self):
3418 return hash((self.linenum, self.line))
3418 return hash((self.linenum, self.line))
3419
3419
3420 def __eq__(self, other):
3420 def __eq__(self, other):
3421 return self.line == other.line
3421 return self.line == other.line
3422
3422
3423 def findpos(self):
3423 def findpos(self):
3424 """Iterate all (start, end) indices of matches"""
3424 """Iterate all (start, end) indices of matches"""
3425 yield self.colstart, self.colend
3425 yield self.colstart, self.colend
3426 p = self.colend
3426 p = self.colend
3427 while p < len(self.line):
3427 while p < len(self.line):
3428 m = regexp.search(self.line, p)
3428 m = regexp.search(self.line, p)
3429 if not m:
3429 if not m:
3430 break
3430 break
3431 yield m.span()
3431 yield m.span()
3432 p = m.end()
3432 p = m.end()
3433
3433
3434 matches = {}
3434 matches = {}
3435 copies = {}
3435 copies = {}
3436
3436
3437 def grepbody(fn, rev, body):
3437 def grepbody(fn, rev, body):
3438 matches[rev].setdefault(fn, [])
3438 matches[rev].setdefault(fn, [])
3439 m = matches[rev][fn]
3439 m = matches[rev][fn]
3440 for lnum, cstart, cend, line in matchlines(body):
3440 for lnum, cstart, cend, line in matchlines(body):
3441 s = linestate(line, lnum, cstart, cend)
3441 s = linestate(line, lnum, cstart, cend)
3442 m.append(s)
3442 m.append(s)
3443
3443
3444 def difflinestates(a, b):
3444 def difflinestates(a, b):
3445 sm = difflib.SequenceMatcher(None, a, b)
3445 sm = difflib.SequenceMatcher(None, a, b)
3446 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
3446 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
3447 if tag == r'insert':
3447 if tag == r'insert':
3448 for i in pycompat.xrange(blo, bhi):
3448 for i in pycompat.xrange(blo, bhi):
3449 yield (b'+', b[i])
3449 yield (b'+', b[i])
3450 elif tag == r'delete':
3450 elif tag == r'delete':
3451 for i in pycompat.xrange(alo, ahi):
3451 for i in pycompat.xrange(alo, ahi):
3452 yield (b'-', a[i])
3452 yield (b'-', a[i])
3453 elif tag == r'replace':
3453 elif tag == r'replace':
3454 for i in pycompat.xrange(alo, ahi):
3454 for i in pycompat.xrange(alo, ahi):
3455 yield (b'-', a[i])
3455 yield (b'-', a[i])
3456 for i in pycompat.xrange(blo, bhi):
3456 for i in pycompat.xrange(blo, bhi):
3457 yield (b'+', b[i])
3457 yield (b'+', b[i])
3458
3458
3459 uipathfn = scmutil.getuipathfn(repo)
3459 uipathfn = scmutil.getuipathfn(repo)
3460
3460
3461 def display(fm, fn, ctx, pstates, states):
3461 def display(fm, fn, ctx, pstates, states):
3462 rev = scmutil.intrev(ctx)
3462 rev = scmutil.intrev(ctx)
3463 if fm.isplain():
3463 if fm.isplain():
3464 formatuser = ui.shortuser
3464 formatuser = ui.shortuser
3465 else:
3465 else:
3466 formatuser = pycompat.bytestr
3466 formatuser = pycompat.bytestr
3467 if ui.quiet:
3467 if ui.quiet:
3468 datefmt = b'%Y-%m-%d'
3468 datefmt = b'%Y-%m-%d'
3469 else:
3469 else:
3470 datefmt = b'%a %b %d %H:%M:%S %Y %1%2'
3470 datefmt = b'%a %b %d %H:%M:%S %Y %1%2'
3471 found = False
3471 found = False
3472
3472
3473 @util.cachefunc
3473 @util.cachefunc
3474 def binary():
3474 def binary():
3475 flog = getfile(fn)
3475 flog = getfile(fn)
3476 try:
3476 try:
3477 return stringutil.binary(flog.read(ctx.filenode(fn)))
3477 return stringutil.binary(flog.read(ctx.filenode(fn)))
3478 except error.WdirUnsupported:
3478 except error.WdirUnsupported:
3479 return ctx[fn].isbinary()
3479 return ctx[fn].isbinary()
3480
3480
3481 fieldnamemap = {b'linenumber': b'lineno'}
3481 fieldnamemap = {b'linenumber': b'lineno'}
3482 if diff:
3482 if diff:
3483 iter = difflinestates(pstates, states)
3483 iter = difflinestates(pstates, states)
3484 else:
3484 else:
3485 iter = [(b'', l) for l in states]
3485 iter = [(b'', l) for l in states]
3486 for change, l in iter:
3486 for change, l in iter:
3487 fm.startitem()
3487 fm.startitem()
3488 fm.context(ctx=ctx)
3488 fm.context(ctx=ctx)
3489 fm.data(node=fm.hexfunc(scmutil.binnode(ctx)), path=fn)
3489 fm.data(node=fm.hexfunc(scmutil.binnode(ctx)), path=fn)
3490 fm.plain(uipathfn(fn), label=b'grep.filename')
3490 fm.plain(uipathfn(fn), label=b'grep.filename')
3491
3491
3492 cols = [
3492 cols = [
3493 (b'rev', b'%d', rev, not plaingrep, b''),
3493 (b'rev', b'%d', rev, not plaingrep, b''),
3494 (
3494 (
3495 b'linenumber',
3495 b'linenumber',
3496 b'%d',
3496 b'%d',
3497 l.linenum,
3497 l.linenum,
3498 opts.get(b'line_number'),
3498 opts.get(b'line_number'),
3499 b'',
3499 b'',
3500 ),
3500 ),
3501 ]
3501 ]
3502 if diff:
3502 if diff:
3503 cols.append(
3503 cols.append(
3504 (
3504 (
3505 b'change',
3505 b'change',
3506 b'%s',
3506 b'%s',
3507 change,
3507 change,
3508 True,
3508 True,
3509 b'grep.inserted '
3509 b'grep.inserted '
3510 if change == b'+'
3510 if change == b'+'
3511 else b'grep.deleted ',
3511 else b'grep.deleted ',
3512 )
3512 )
3513 )
3513 )
3514 cols.extend(
3514 cols.extend(
3515 [
3515 [
3516 (
3516 (
3517 b'user',
3517 b'user',
3518 b'%s',
3518 b'%s',
3519 formatuser(ctx.user()),
3519 formatuser(ctx.user()),
3520 opts.get(b'user'),
3520 opts.get(b'user'),
3521 b'',
3521 b'',
3522 ),
3522 ),
3523 (
3523 (
3524 b'date',
3524 b'date',
3525 b'%s',
3525 b'%s',
3526 fm.formatdate(ctx.date(), datefmt),
3526 fm.formatdate(ctx.date(), datefmt),
3527 opts.get(b'date'),
3527 opts.get(b'date'),
3528 b'',
3528 b'',
3529 ),
3529 ),
3530 ]
3530 ]
3531 )
3531 )
3532 for name, fmt, data, cond, extra_label in cols:
3532 for name, fmt, data, cond, extra_label in cols:
3533 if cond:
3533 if cond:
3534 fm.plain(sep, label=b'grep.sep')
3534 fm.plain(sep, label=b'grep.sep')
3535 field = fieldnamemap.get(name, name)
3535 field = fieldnamemap.get(name, name)
3536 label = extra_label + (b'grep.%s' % name)
3536 label = extra_label + (b'grep.%s' % name)
3537 fm.condwrite(cond, field, fmt, data, label=label)
3537 fm.condwrite(cond, field, fmt, data, label=label)
3538 if not opts.get(b'files_with_matches'):
3538 if not opts.get(b'files_with_matches'):
3539 fm.plain(sep, label=b'grep.sep')
3539 fm.plain(sep, label=b'grep.sep')
3540 if not opts.get(b'text') and binary():
3540 if not opts.get(b'text') and binary():
3541 fm.plain(_(b" Binary file matches"))
3541 fm.plain(_(b" Binary file matches"))
3542 else:
3542 else:
3543 displaymatches(fm.nested(b'texts', tmpl=b'{text}'), l)
3543 displaymatches(fm.nested(b'texts', tmpl=b'{text}'), l)
3544 fm.plain(eol)
3544 fm.plain(eol)
3545 found = True
3545 found = True
3546 if opts.get(b'files_with_matches'):
3546 if opts.get(b'files_with_matches'):
3547 break
3547 break
3548 return found
3548 return found
3549
3549
3550 def displaymatches(fm, l):
3550 def displaymatches(fm, l):
3551 p = 0
3551 p = 0
3552 for s, e in l.findpos():
3552 for s, e in l.findpos():
3553 if p < s:
3553 if p < s:
3554 fm.startitem()
3554 fm.startitem()
3555 fm.write(b'text', b'%s', l.line[p:s])
3555 fm.write(b'text', b'%s', l.line[p:s])
3556 fm.data(matched=False)
3556 fm.data(matched=False)
3557 fm.startitem()
3557 fm.startitem()
3558 fm.write(b'text', b'%s', l.line[s:e], label=b'grep.match')
3558 fm.write(b'text', b'%s', l.line[s:e], label=b'grep.match')
3559 fm.data(matched=True)
3559 fm.data(matched=True)
3560 p = e
3560 p = e
3561 if p < len(l.line):
3561 if p < len(l.line):
3562 fm.startitem()
3562 fm.startitem()
3563 fm.write(b'text', b'%s', l.line[p:])
3563 fm.write(b'text', b'%s', l.line[p:])
3564 fm.data(matched=False)
3564 fm.data(matched=False)
3565 fm.end()
3565 fm.end()
3566
3566
3567 skip = set()
3567 skip = set()
3568 revfiles = {}
3568 revfiles = {}
3569 match = scmutil.match(repo[None], pats, opts)
3569 match = scmutil.match(repo[None], pats, opts)
3570 found = False
3570 found = False
3571 follow = opts.get(b'follow')
3571 follow = opts.get(b'follow')
3572
3572
3573 getrenamed = scmutil.getrenamedfn(repo)
3573 getrenamed = scmutil.getrenamedfn(repo)
3574
3574
3575 def prep(ctx, fns):
3575 def prep(ctx, fns):
3576 rev = ctx.rev()
3576 rev = ctx.rev()
3577 pctx = ctx.p1()
3577 pctx = ctx.p1()
3578 parent = pctx.rev()
3578 parent = pctx.rev()
3579 matches.setdefault(rev, {})
3579 matches.setdefault(rev, {})
3580 matches.setdefault(parent, {})
3580 matches.setdefault(parent, {})
3581 files = revfiles.setdefault(rev, [])
3581 files = revfiles.setdefault(rev, [])
3582 for fn in fns:
3582 for fn in fns:
3583 flog = getfile(fn)
3583 flog = getfile(fn)
3584 try:
3584 try:
3585 fnode = ctx.filenode(fn)
3585 fnode = ctx.filenode(fn)
3586 except error.LookupError:
3586 except error.LookupError:
3587 continue
3587 continue
3588
3588
3589 copy = None
3589 copy = None
3590 if follow:
3590 if follow:
3591 copy = getrenamed(fn, rev)
3591 copy = getrenamed(fn, rev)
3592 if copy:
3592 if copy:
3593 copies.setdefault(rev, {})[fn] = copy
3593 copies.setdefault(rev, {})[fn] = copy
3594 if fn in skip:
3594 if fn in skip:
3595 skip.add(copy)
3595 skip.add(copy)
3596 if fn in skip:
3596 if fn in skip:
3597 continue
3597 continue
3598 files.append(fn)
3598 files.append(fn)
3599
3599
3600 if fn not in matches[rev]:
3600 if fn not in matches[rev]:
3601 try:
3601 try:
3602 content = flog.read(fnode)
3602 content = flog.read(fnode)
3603 except error.WdirUnsupported:
3603 except error.WdirUnsupported:
3604 content = ctx[fn].data()
3604 content = ctx[fn].data()
3605 grepbody(fn, rev, content)
3605 grepbody(fn, rev, content)
3606
3606
3607 pfn = copy or fn
3607 pfn = copy or fn
3608 if pfn not in matches[parent]:
3608 if pfn not in matches[parent]:
3609 try:
3609 try:
3610 fnode = pctx.filenode(pfn)
3610 fnode = pctx.filenode(pfn)
3611 grepbody(pfn, parent, flog.read(fnode))
3611 grepbody(pfn, parent, flog.read(fnode))
3612 except error.LookupError:
3612 except error.LookupError:
3613 pass
3613 pass
3614
3614
3615 ui.pager(b'grep')
3615 ui.pager(b'grep')
3616 fm = ui.formatter(b'grep', opts)
3616 fm = ui.formatter(b'grep', opts)
3617 for ctx in cmdutil.walkchangerevs(repo, match, opts, prep):
3617 for ctx in cmdutil.walkchangerevs(repo, match, opts, prep):
3618 rev = ctx.rev()
3618 rev = ctx.rev()
3619 parent = ctx.p1().rev()
3619 parent = ctx.p1().rev()
3620 for fn in sorted(revfiles.get(rev, [])):
3620 for fn in sorted(revfiles.get(rev, [])):
3621 states = matches[rev][fn]
3621 states = matches[rev][fn]
3622 copy = copies.get(rev, {}).get(fn)
3622 copy = copies.get(rev, {}).get(fn)
3623 if fn in skip:
3623 if fn in skip:
3624 if copy:
3624 if copy:
3625 skip.add(copy)
3625 skip.add(copy)
3626 continue
3626 continue
3627 pstates = matches.get(parent, {}).get(copy or fn, [])
3627 pstates = matches.get(parent, {}).get(copy or fn, [])
3628 if pstates or states:
3628 if pstates or states:
3629 r = display(fm, fn, ctx, pstates, states)
3629 r = display(fm, fn, ctx, pstates, states)
3630 found = found or r
3630 found = found or r
3631 if r and not diff and not all_files:
3631 if r and not diff and not all_files:
3632 skip.add(fn)
3632 skip.add(fn)
3633 if copy:
3633 if copy:
3634 skip.add(copy)
3634 skip.add(copy)
3635 del revfiles[rev]
3635 del revfiles[rev]
3636 # We will keep the matches dict for the duration of the window
3636 # We will keep the matches dict for the duration of the window
3637 # clear the matches dict once the window is over
3637 # clear the matches dict once the window is over
3638 if not revfiles:
3638 if not revfiles:
3639 matches.clear()
3639 matches.clear()
3640 fm.end()
3640 fm.end()
3641
3641
3642 return not found
3642 return not found
3643
3643
3644
3644
3645 @command(
3645 @command(
3646 b'heads',
3646 b'heads',
3647 [
3647 [
3648 (
3648 (
3649 b'r',
3649 b'r',
3650 b'rev',
3650 b'rev',
3651 b'',
3651 b'',
3652 _(b'show only heads which are descendants of STARTREV'),
3652 _(b'show only heads which are descendants of STARTREV'),
3653 _(b'STARTREV'),
3653 _(b'STARTREV'),
3654 ),
3654 ),
3655 (b't', b'topo', False, _(b'show topological heads only')),
3655 (b't', b'topo', False, _(b'show topological heads only')),
3656 (
3656 (
3657 b'a',
3657 b'a',
3658 b'active',
3658 b'active',
3659 False,
3659 False,
3660 _(b'show active branchheads only (DEPRECATED)'),
3660 _(b'show active branchheads only (DEPRECATED)'),
3661 ),
3661 ),
3662 (b'c', b'closed', False, _(b'show normal and closed branch heads')),
3662 (b'c', b'closed', False, _(b'show normal and closed branch heads')),
3663 ]
3663 ]
3664 + templateopts,
3664 + templateopts,
3665 _(b'[-ct] [-r STARTREV] [REV]...'),
3665 _(b'[-ct] [-r STARTREV] [REV]...'),
3666 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
3666 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
3667 intents={INTENT_READONLY},
3667 intents={INTENT_READONLY},
3668 )
3668 )
3669 def heads(ui, repo, *branchrevs, **opts):
3669 def heads(ui, repo, *branchrevs, **opts):
3670 """show branch heads
3670 """show branch heads
3671
3671
3672 With no arguments, show all open branch heads in the repository.
3672 With no arguments, show all open branch heads in the repository.
3673 Branch heads are changesets that have no descendants on the
3673 Branch heads are changesets that have no descendants on the
3674 same branch. They are where development generally takes place and
3674 same branch. They are where development generally takes place and
3675 are the usual targets for update and merge operations.
3675 are the usual targets for update and merge operations.
3676
3676
3677 If one or more REVs are given, only open branch heads on the
3677 If one or more REVs are given, only open branch heads on the
3678 branches associated with the specified changesets are shown. This
3678 branches associated with the specified changesets are shown. This
3679 means that you can use :hg:`heads .` to see the heads on the
3679 means that you can use :hg:`heads .` to see the heads on the
3680 currently checked-out branch.
3680 currently checked-out branch.
3681
3681
3682 If -c/--closed is specified, also show branch heads marked closed
3682 If -c/--closed is specified, also show branch heads marked closed
3683 (see :hg:`commit --close-branch`).
3683 (see :hg:`commit --close-branch`).
3684
3684
3685 If STARTREV is specified, only those heads that are descendants of
3685 If STARTREV is specified, only those heads that are descendants of
3686 STARTREV will be displayed.
3686 STARTREV will be displayed.
3687
3687
3688 If -t/--topo is specified, named branch mechanics will be ignored and only
3688 If -t/--topo is specified, named branch mechanics will be ignored and only
3689 topological heads (changesets with no children) will be shown.
3689 topological heads (changesets with no children) will be shown.
3690
3690
3691 Returns 0 if matching heads are found, 1 if not.
3691 Returns 0 if matching heads are found, 1 if not.
3692 """
3692 """
3693
3693
3694 opts = pycompat.byteskwargs(opts)
3694 opts = pycompat.byteskwargs(opts)
3695 start = None
3695 start = None
3696 rev = opts.get(b'rev')
3696 rev = opts.get(b'rev')
3697 if rev:
3697 if rev:
3698 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
3698 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
3699 start = scmutil.revsingle(repo, rev, None).node()
3699 start = scmutil.revsingle(repo, rev, None).node()
3700
3700
3701 if opts.get(b'topo'):
3701 if opts.get(b'topo'):
3702 heads = [repo[h] for h in repo.heads(start)]
3702 heads = [repo[h] for h in repo.heads(start)]
3703 else:
3703 else:
3704 heads = []
3704 heads = []
3705 for branch in repo.branchmap():
3705 for branch in repo.branchmap():
3706 heads += repo.branchheads(branch, start, opts.get(b'closed'))
3706 heads += repo.branchheads(branch, start, opts.get(b'closed'))
3707 heads = [repo[h] for h in heads]
3707 heads = [repo[h] for h in heads]
3708
3708
3709 if branchrevs:
3709 if branchrevs:
3710 branches = set(
3710 branches = set(
3711 repo[r].branch() for r in scmutil.revrange(repo, branchrevs)
3711 repo[r].branch() for r in scmutil.revrange(repo, branchrevs)
3712 )
3712 )
3713 heads = [h for h in heads if h.branch() in branches]
3713 heads = [h for h in heads if h.branch() in branches]
3714
3714
3715 if opts.get(b'active') and branchrevs:
3715 if opts.get(b'active') and branchrevs:
3716 dagheads = repo.heads(start)
3716 dagheads = repo.heads(start)
3717 heads = [h for h in heads if h.node() in dagheads]
3717 heads = [h for h in heads if h.node() in dagheads]
3718
3718
3719 if branchrevs:
3719 if branchrevs:
3720 haveheads = set(h.branch() for h in heads)
3720 haveheads = set(h.branch() for h in heads)
3721 if branches - haveheads:
3721 if branches - haveheads:
3722 headless = b', '.join(b for b in branches - haveheads)
3722 headless = b', '.join(b for b in branches - haveheads)
3723 msg = _(b'no open branch heads found on branches %s')
3723 msg = _(b'no open branch heads found on branches %s')
3724 if opts.get(b'rev'):
3724 if opts.get(b'rev'):
3725 msg += _(b' (started at %s)') % opts[b'rev']
3725 msg += _(b' (started at %s)') % opts[b'rev']
3726 ui.warn((msg + b'\n') % headless)
3726 ui.warn((msg + b'\n') % headless)
3727
3727
3728 if not heads:
3728 if not heads:
3729 return 1
3729 return 1
3730
3730
3731 ui.pager(b'heads')
3731 ui.pager(b'heads')
3732 heads = sorted(heads, key=lambda x: -(x.rev()))
3732 heads = sorted(heads, key=lambda x: -(x.rev()))
3733 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
3733 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
3734 for ctx in heads:
3734 for ctx in heads:
3735 displayer.show(ctx)
3735 displayer.show(ctx)
3736 displayer.close()
3736 displayer.close()
3737
3737
3738
3738
3739 @command(
3739 @command(
3740 b'help',
3740 b'help',
3741 [
3741 [
3742 (b'e', b'extension', None, _(b'show only help for extensions')),
3742 (b'e', b'extension', None, _(b'show only help for extensions')),
3743 (b'c', b'command', None, _(b'show only help for commands')),
3743 (b'c', b'command', None, _(b'show only help for commands')),
3744 (b'k', b'keyword', None, _(b'show topics matching keyword')),
3744 (b'k', b'keyword', None, _(b'show topics matching keyword')),
3745 (
3745 (
3746 b's',
3746 b's',
3747 b'system',
3747 b'system',
3748 [],
3748 [],
3749 _(b'show help for specific platform(s)'),
3749 _(b'show help for specific platform(s)'),
3750 _(b'PLATFORM'),
3750 _(b'PLATFORM'),
3751 ),
3751 ),
3752 ],
3752 ],
3753 _(b'[-eck] [-s PLATFORM] [TOPIC]'),
3753 _(b'[-eck] [-s PLATFORM] [TOPIC]'),
3754 helpcategory=command.CATEGORY_HELP,
3754 helpcategory=command.CATEGORY_HELP,
3755 norepo=True,
3755 norepo=True,
3756 intents={INTENT_READONLY},
3756 intents={INTENT_READONLY},
3757 )
3757 )
3758 def help_(ui, name=None, **opts):
3758 def help_(ui, name=None, **opts):
3759 """show help for a given topic or a help overview
3759 """show help for a given topic or a help overview
3760
3760
3761 With no arguments, print a list of commands with short help messages.
3761 With no arguments, print a list of commands with short help messages.
3762
3762
3763 Given a topic, extension, or command name, print help for that
3763 Given a topic, extension, or command name, print help for that
3764 topic.
3764 topic.
3765
3765
3766 Returns 0 if successful.
3766 Returns 0 if successful.
3767 """
3767 """
3768
3768
3769 keep = opts.get(r'system') or []
3769 keep = opts.get(r'system') or []
3770 if len(keep) == 0:
3770 if len(keep) == 0:
3771 if pycompat.sysplatform.startswith(b'win'):
3771 if pycompat.sysplatform.startswith(b'win'):
3772 keep.append(b'windows')
3772 keep.append(b'windows')
3773 elif pycompat.sysplatform == b'OpenVMS':
3773 elif pycompat.sysplatform == b'OpenVMS':
3774 keep.append(b'vms')
3774 keep.append(b'vms')
3775 elif pycompat.sysplatform == b'plan9':
3775 elif pycompat.sysplatform == b'plan9':
3776 keep.append(b'plan9')
3776 keep.append(b'plan9')
3777 else:
3777 else:
3778 keep.append(b'unix')
3778 keep.append(b'unix')
3779 keep.append(pycompat.sysplatform.lower())
3779 keep.append(pycompat.sysplatform.lower())
3780 if ui.verbose:
3780 if ui.verbose:
3781 keep.append(b'verbose')
3781 keep.append(b'verbose')
3782
3782
3783 commands = sys.modules[__name__]
3783 commands = sys.modules[__name__]
3784 formatted = help.formattedhelp(ui, commands, name, keep=keep, **opts)
3784 formatted = help.formattedhelp(ui, commands, name, keep=keep, **opts)
3785 ui.pager(b'help')
3785 ui.pager(b'help')
3786 ui.write(formatted)
3786 ui.write(formatted)
3787
3787
3788
3788
3789 @command(
3789 @command(
3790 b'identify|id',
3790 b'identify|id',
3791 [
3791 [
3792 (b'r', b'rev', b'', _(b'identify the specified revision'), _(b'REV')),
3792 (b'r', b'rev', b'', _(b'identify the specified revision'), _(b'REV')),
3793 (b'n', b'num', None, _(b'show local revision number')),
3793 (b'n', b'num', None, _(b'show local revision number')),
3794 (b'i', b'id', None, _(b'show global revision id')),
3794 (b'i', b'id', None, _(b'show global revision id')),
3795 (b'b', b'branch', None, _(b'show branch')),
3795 (b'b', b'branch', None, _(b'show branch')),
3796 (b't', b'tags', None, _(b'show tags')),
3796 (b't', b'tags', None, _(b'show tags')),
3797 (b'B', b'bookmarks', None, _(b'show bookmarks')),
3797 (b'B', b'bookmarks', None, _(b'show bookmarks')),
3798 ]
3798 ]
3799 + remoteopts
3799 + remoteopts
3800 + formatteropts,
3800 + formatteropts,
3801 _(b'[-nibtB] [-r REV] [SOURCE]'),
3801 _(b'[-nibtB] [-r REV] [SOURCE]'),
3802 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
3802 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
3803 optionalrepo=True,
3803 optionalrepo=True,
3804 intents={INTENT_READONLY},
3804 intents={INTENT_READONLY},
3805 )
3805 )
3806 def identify(
3806 def identify(
3807 ui,
3807 ui,
3808 repo,
3808 repo,
3809 source=None,
3809 source=None,
3810 rev=None,
3810 rev=None,
3811 num=None,
3811 num=None,
3812 id=None,
3812 id=None,
3813 branch=None,
3813 branch=None,
3814 tags=None,
3814 tags=None,
3815 bookmarks=None,
3815 bookmarks=None,
3816 **opts
3816 **opts
3817 ):
3817 ):
3818 """identify the working directory or specified revision
3818 """identify the working directory or specified revision
3819
3819
3820 Print a summary identifying the repository state at REV using one or
3820 Print a summary identifying the repository state at REV using one or
3821 two parent hash identifiers, followed by a "+" if the working
3821 two parent hash identifiers, followed by a "+" if the working
3822 directory has uncommitted changes, the branch name (if not default),
3822 directory has uncommitted changes, the branch name (if not default),
3823 a list of tags, and a list of bookmarks.
3823 a list of tags, and a list of bookmarks.
3824
3824
3825 When REV is not given, print a summary of the current state of the
3825 When REV is not given, print a summary of the current state of the
3826 repository including the working directory. Specify -r. to get information
3826 repository including the working directory. Specify -r. to get information
3827 of the working directory parent without scanning uncommitted changes.
3827 of the working directory parent without scanning uncommitted changes.
3828
3828
3829 Specifying a path to a repository root or Mercurial bundle will
3829 Specifying a path to a repository root or Mercurial bundle will
3830 cause lookup to operate on that repository/bundle.
3830 cause lookup to operate on that repository/bundle.
3831
3831
3832 .. container:: verbose
3832 .. container:: verbose
3833
3833
3834 Template:
3834 Template:
3835
3835
3836 The following keywords are supported in addition to the common template
3836 The following keywords are supported in addition to the common template
3837 keywords and functions. See also :hg:`help templates`.
3837 keywords and functions. See also :hg:`help templates`.
3838
3838
3839 :dirty: String. Character ``+`` denoting if the working directory has
3839 :dirty: String. Character ``+`` denoting if the working directory has
3840 uncommitted changes.
3840 uncommitted changes.
3841 :id: String. One or two nodes, optionally followed by ``+``.
3841 :id: String. One or two nodes, optionally followed by ``+``.
3842 :parents: List of strings. Parent nodes of the changeset.
3842 :parents: List of strings. Parent nodes of the changeset.
3843
3843
3844 Examples:
3844 Examples:
3845
3845
3846 - generate a build identifier for the working directory::
3846 - generate a build identifier for the working directory::
3847
3847
3848 hg id --id > build-id.dat
3848 hg id --id > build-id.dat
3849
3849
3850 - find the revision corresponding to a tag::
3850 - find the revision corresponding to a tag::
3851
3851
3852 hg id -n -r 1.3
3852 hg id -n -r 1.3
3853
3853
3854 - check the most recent revision of a remote repository::
3854 - check the most recent revision of a remote repository::
3855
3855
3856 hg id -r tip https://www.mercurial-scm.org/repo/hg/
3856 hg id -r tip https://www.mercurial-scm.org/repo/hg/
3857
3857
3858 See :hg:`log` for generating more information about specific revisions,
3858 See :hg:`log` for generating more information about specific revisions,
3859 including full hash identifiers.
3859 including full hash identifiers.
3860
3860
3861 Returns 0 if successful.
3861 Returns 0 if successful.
3862 """
3862 """
3863
3863
3864 opts = pycompat.byteskwargs(opts)
3864 opts = pycompat.byteskwargs(opts)
3865 if not repo and not source:
3865 if not repo and not source:
3866 raise error.Abort(
3866 raise error.Abort(
3867 _(b"there is no Mercurial repository here (.hg not found)")
3867 _(b"there is no Mercurial repository here (.hg not found)")
3868 )
3868 )
3869
3869
3870 default = not (num or id or branch or tags or bookmarks)
3870 default = not (num or id or branch or tags or bookmarks)
3871 output = []
3871 output = []
3872 revs = []
3872 revs = []
3873
3873
3874 if source:
3874 if source:
3875 source, branches = hg.parseurl(ui.expandpath(source))
3875 source, branches = hg.parseurl(ui.expandpath(source))
3876 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
3876 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
3877 repo = peer.local()
3877 repo = peer.local()
3878 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
3878 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
3879
3879
3880 fm = ui.formatter(b'identify', opts)
3880 fm = ui.formatter(b'identify', opts)
3881 fm.startitem()
3881 fm.startitem()
3882
3882
3883 if not repo:
3883 if not repo:
3884 if num or branch or tags:
3884 if num or branch or tags:
3885 raise error.Abort(
3885 raise error.Abort(
3886 _(b"can't query remote revision number, branch, or tags")
3886 _(b"can't query remote revision number, branch, or tags")
3887 )
3887 )
3888 if not rev and revs:
3888 if not rev and revs:
3889 rev = revs[0]
3889 rev = revs[0]
3890 if not rev:
3890 if not rev:
3891 rev = b"tip"
3891 rev = b"tip"
3892
3892
3893 remoterev = peer.lookup(rev)
3893 remoterev = peer.lookup(rev)
3894 hexrev = fm.hexfunc(remoterev)
3894 hexrev = fm.hexfunc(remoterev)
3895 if default or id:
3895 if default or id:
3896 output = [hexrev]
3896 output = [hexrev]
3897 fm.data(id=hexrev)
3897 fm.data(id=hexrev)
3898
3898
3899 @util.cachefunc
3899 @util.cachefunc
3900 def getbms():
3900 def getbms():
3901 bms = []
3901 bms = []
3902
3902
3903 if b'bookmarks' in peer.listkeys(b'namespaces'):
3903 if b'bookmarks' in peer.listkeys(b'namespaces'):
3904 hexremoterev = hex(remoterev)
3904 hexremoterev = hex(remoterev)
3905 bms = [
3905 bms = [
3906 bm
3906 bm
3907 for bm, bmr in pycompat.iteritems(
3907 for bm, bmr in pycompat.iteritems(
3908 peer.listkeys(b'bookmarks')
3908 peer.listkeys(b'bookmarks')
3909 )
3909 )
3910 if bmr == hexremoterev
3910 if bmr == hexremoterev
3911 ]
3911 ]
3912
3912
3913 return sorted(bms)
3913 return sorted(bms)
3914
3914
3915 if fm.isplain():
3915 if fm.isplain():
3916 if bookmarks:
3916 if bookmarks:
3917 output.extend(getbms())
3917 output.extend(getbms())
3918 elif default and not ui.quiet:
3918 elif default and not ui.quiet:
3919 # multiple bookmarks for a single parent separated by '/'
3919 # multiple bookmarks for a single parent separated by '/'
3920 bm = b'/'.join(getbms())
3920 bm = b'/'.join(getbms())
3921 if bm:
3921 if bm:
3922 output.append(bm)
3922 output.append(bm)
3923 else:
3923 else:
3924 fm.data(node=hex(remoterev))
3924 fm.data(node=hex(remoterev))
3925 if bookmarks or b'bookmarks' in fm.datahint():
3925 if bookmarks or b'bookmarks' in fm.datahint():
3926 fm.data(bookmarks=fm.formatlist(getbms(), name=b'bookmark'))
3926 fm.data(bookmarks=fm.formatlist(getbms(), name=b'bookmark'))
3927 else:
3927 else:
3928 if rev:
3928 if rev:
3929 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
3929 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
3930 ctx = scmutil.revsingle(repo, rev, None)
3930 ctx = scmutil.revsingle(repo, rev, None)
3931
3931
3932 if ctx.rev() is None:
3932 if ctx.rev() is None:
3933 ctx = repo[None]
3933 ctx = repo[None]
3934 parents = ctx.parents()
3934 parents = ctx.parents()
3935 taglist = []
3935 taglist = []
3936 for p in parents:
3936 for p in parents:
3937 taglist.extend(p.tags())
3937 taglist.extend(p.tags())
3938
3938
3939 dirty = b""
3939 dirty = b""
3940 if ctx.dirty(missing=True, merge=False, branch=False):
3940 if ctx.dirty(missing=True, merge=False, branch=False):
3941 dirty = b'+'
3941 dirty = b'+'
3942 fm.data(dirty=dirty)
3942 fm.data(dirty=dirty)
3943
3943
3944 hexoutput = [fm.hexfunc(p.node()) for p in parents]
3944 hexoutput = [fm.hexfunc(p.node()) for p in parents]
3945 if default or id:
3945 if default or id:
3946 output = [b"%s%s" % (b'+'.join(hexoutput), dirty)]
3946 output = [b"%s%s" % (b'+'.join(hexoutput), dirty)]
3947 fm.data(id=b"%s%s" % (b'+'.join(hexoutput), dirty))
3947 fm.data(id=b"%s%s" % (b'+'.join(hexoutput), dirty))
3948
3948
3949 if num:
3949 if num:
3950 numoutput = [b"%d" % p.rev() for p in parents]
3950 numoutput = [b"%d" % p.rev() for p in parents]
3951 output.append(b"%s%s" % (b'+'.join(numoutput), dirty))
3951 output.append(b"%s%s" % (b'+'.join(numoutput), dirty))
3952
3952
3953 fm.data(
3953 fm.data(
3954 parents=fm.formatlist(
3954 parents=fm.formatlist(
3955 [fm.hexfunc(p.node()) for p in parents], name=b'node'
3955 [fm.hexfunc(p.node()) for p in parents], name=b'node'
3956 )
3956 )
3957 )
3957 )
3958 else:
3958 else:
3959 hexoutput = fm.hexfunc(ctx.node())
3959 hexoutput = fm.hexfunc(ctx.node())
3960 if default or id:
3960 if default or id:
3961 output = [hexoutput]
3961 output = [hexoutput]
3962 fm.data(id=hexoutput)
3962 fm.data(id=hexoutput)
3963
3963
3964 if num:
3964 if num:
3965 output.append(pycompat.bytestr(ctx.rev()))
3965 output.append(pycompat.bytestr(ctx.rev()))
3966 taglist = ctx.tags()
3966 taglist = ctx.tags()
3967
3967
3968 if default and not ui.quiet:
3968 if default and not ui.quiet:
3969 b = ctx.branch()
3969 b = ctx.branch()
3970 if b != b'default':
3970 if b != b'default':
3971 output.append(b"(%s)" % b)
3971 output.append(b"(%s)" % b)
3972
3972
3973 # multiple tags for a single parent separated by '/'
3973 # multiple tags for a single parent separated by '/'
3974 t = b'/'.join(taglist)
3974 t = b'/'.join(taglist)
3975 if t:
3975 if t:
3976 output.append(t)
3976 output.append(t)
3977
3977
3978 # multiple bookmarks for a single parent separated by '/'
3978 # multiple bookmarks for a single parent separated by '/'
3979 bm = b'/'.join(ctx.bookmarks())
3979 bm = b'/'.join(ctx.bookmarks())
3980 if bm:
3980 if bm:
3981 output.append(bm)
3981 output.append(bm)
3982 else:
3982 else:
3983 if branch:
3983 if branch:
3984 output.append(ctx.branch())
3984 output.append(ctx.branch())
3985
3985
3986 if tags:
3986 if tags:
3987 output.extend(taglist)
3987 output.extend(taglist)
3988
3988
3989 if bookmarks:
3989 if bookmarks:
3990 output.extend(ctx.bookmarks())
3990 output.extend(ctx.bookmarks())
3991
3991
3992 fm.data(node=ctx.hex())
3992 fm.data(node=ctx.hex())
3993 fm.data(branch=ctx.branch())
3993 fm.data(branch=ctx.branch())
3994 fm.data(tags=fm.formatlist(taglist, name=b'tag', sep=b':'))
3994 fm.data(tags=fm.formatlist(taglist, name=b'tag', sep=b':'))
3995 fm.data(bookmarks=fm.formatlist(ctx.bookmarks(), name=b'bookmark'))
3995 fm.data(bookmarks=fm.formatlist(ctx.bookmarks(), name=b'bookmark'))
3996 fm.context(ctx=ctx)
3996 fm.context(ctx=ctx)
3997
3997
3998 fm.plain(b"%s\n" % b' '.join(output))
3998 fm.plain(b"%s\n" % b' '.join(output))
3999 fm.end()
3999 fm.end()
4000
4000
4001
4001
4002 @command(
4002 @command(
4003 b'import|patch',
4003 b'import|patch',
4004 [
4004 [
4005 (
4005 (
4006 b'p',
4006 b'p',
4007 b'strip',
4007 b'strip',
4008 1,
4008 1,
4009 _(
4009 _(
4010 b'directory strip option for patch. This has the same '
4010 b'directory strip option for patch. This has the same '
4011 b'meaning as the corresponding patch option'
4011 b'meaning as the corresponding patch option'
4012 ),
4012 ),
4013 _(b'NUM'),
4013 _(b'NUM'),
4014 ),
4014 ),
4015 (b'b', b'base', b'', _(b'base path (DEPRECATED)'), _(b'PATH')),
4015 (b'b', b'base', b'', _(b'base path (DEPRECATED)'), _(b'PATH')),
4016 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
4016 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
4017 (
4017 (
4018 b'f',
4018 b'f',
4019 b'force',
4019 b'force',
4020 None,
4020 None,
4021 _(b'skip check for outstanding uncommitted changes (DEPRECATED)'),
4021 _(b'skip check for outstanding uncommitted changes (DEPRECATED)'),
4022 ),
4022 ),
4023 (
4023 (
4024 b'',
4024 b'',
4025 b'no-commit',
4025 b'no-commit',
4026 None,
4026 None,
4027 _(b"don't commit, just update the working directory"),
4027 _(b"don't commit, just update the working directory"),
4028 ),
4028 ),
4029 (
4029 (
4030 b'',
4030 b'',
4031 b'bypass',
4031 b'bypass',
4032 None,
4032 None,
4033 _(b"apply patch without touching the working directory"),
4033 _(b"apply patch without touching the working directory"),
4034 ),
4034 ),
4035 (b'', b'partial', None, _(b'commit even if some hunks fail')),
4035 (b'', b'partial', None, _(b'commit even if some hunks fail')),
4036 (b'', b'exact', None, _(b'abort if patch would apply lossily')),
4036 (b'', b'exact', None, _(b'abort if patch would apply lossily')),
4037 (b'', b'prefix', b'', _(b'apply patch to subdirectory'), _(b'DIR')),
4037 (b'', b'prefix', b'', _(b'apply patch to subdirectory'), _(b'DIR')),
4038 (
4038 (
4039 b'',
4039 b'',
4040 b'import-branch',
4040 b'import-branch',
4041 None,
4041 None,
4042 _(b'use any branch information in patch (implied by --exact)'),
4042 _(b'use any branch information in patch (implied by --exact)'),
4043 ),
4043 ),
4044 ]
4044 ]
4045 + commitopts
4045 + commitopts
4046 + commitopts2
4046 + commitopts2
4047 + similarityopts,
4047 + similarityopts,
4048 _(b'[OPTION]... PATCH...'),
4048 _(b'[OPTION]... PATCH...'),
4049 helpcategory=command.CATEGORY_IMPORT_EXPORT,
4049 helpcategory=command.CATEGORY_IMPORT_EXPORT,
4050 )
4050 )
4051 def import_(ui, repo, patch1=None, *patches, **opts):
4051 def import_(ui, repo, patch1=None, *patches, **opts):
4052 """import an ordered set of patches
4052 """import an ordered set of patches
4053
4053
4054 Import a list of patches and commit them individually (unless
4054 Import a list of patches and commit them individually (unless
4055 --no-commit is specified).
4055 --no-commit is specified).
4056
4056
4057 To read a patch from standard input (stdin), use "-" as the patch
4057 To read a patch from standard input (stdin), use "-" as the patch
4058 name. If a URL is specified, the patch will be downloaded from
4058 name. If a URL is specified, the patch will be downloaded from
4059 there.
4059 there.
4060
4060
4061 Import first applies changes to the working directory (unless
4061 Import first applies changes to the working directory (unless
4062 --bypass is specified), import will abort if there are outstanding
4062 --bypass is specified), import will abort if there are outstanding
4063 changes.
4063 changes.
4064
4064
4065 Use --bypass to apply and commit patches directly to the
4065 Use --bypass to apply and commit patches directly to the
4066 repository, without affecting the working directory. Without
4066 repository, without affecting the working directory. Without
4067 --exact, patches will be applied on top of the working directory
4067 --exact, patches will be applied on top of the working directory
4068 parent revision.
4068 parent revision.
4069
4069
4070 You can import a patch straight from a mail message. Even patches
4070 You can import a patch straight from a mail message. Even patches
4071 as attachments work (to use the body part, it must have type
4071 as attachments work (to use the body part, it must have type
4072 text/plain or text/x-patch). From and Subject headers of email
4072 text/plain or text/x-patch). From and Subject headers of email
4073 message are used as default committer and commit message. All
4073 message are used as default committer and commit message. All
4074 text/plain body parts before first diff are added to the commit
4074 text/plain body parts before first diff are added to the commit
4075 message.
4075 message.
4076
4076
4077 If the imported patch was generated by :hg:`export`, user and
4077 If the imported patch was generated by :hg:`export`, user and
4078 description from patch override values from message headers and
4078 description from patch override values from message headers and
4079 body. Values given on command line with -m/--message and -u/--user
4079 body. Values given on command line with -m/--message and -u/--user
4080 override these.
4080 override these.
4081
4081
4082 If --exact is specified, import will set the working directory to
4082 If --exact is specified, import will set the working directory to
4083 the parent of each patch before applying it, and will abort if the
4083 the parent of each patch before applying it, and will abort if the
4084 resulting changeset has a different ID than the one recorded in
4084 resulting changeset has a different ID than the one recorded in
4085 the patch. This will guard against various ways that portable
4085 the patch. This will guard against various ways that portable
4086 patch formats and mail systems might fail to transfer Mercurial
4086 patch formats and mail systems might fail to transfer Mercurial
4087 data or metadata. See :hg:`bundle` for lossless transmission.
4087 data or metadata. See :hg:`bundle` for lossless transmission.
4088
4088
4089 Use --partial to ensure a changeset will be created from the patch
4089 Use --partial to ensure a changeset will be created from the patch
4090 even if some hunks fail to apply. Hunks that fail to apply will be
4090 even if some hunks fail to apply. Hunks that fail to apply will be
4091 written to a <target-file>.rej file. Conflicts can then be resolved
4091 written to a <target-file>.rej file. Conflicts can then be resolved
4092 by hand before :hg:`commit --amend` is run to update the created
4092 by hand before :hg:`commit --amend` is run to update the created
4093 changeset. This flag exists to let people import patches that
4093 changeset. This flag exists to let people import patches that
4094 partially apply without losing the associated metadata (author,
4094 partially apply without losing the associated metadata (author,
4095 date, description, ...).
4095 date, description, ...).
4096
4096
4097 .. note::
4097 .. note::
4098
4098
4099 When no hunks apply cleanly, :hg:`import --partial` will create
4099 When no hunks apply cleanly, :hg:`import --partial` will create
4100 an empty changeset, importing only the patch metadata.
4100 an empty changeset, importing only the patch metadata.
4101
4101
4102 With -s/--similarity, hg will attempt to discover renames and
4102 With -s/--similarity, hg will attempt to discover renames and
4103 copies in the patch in the same way as :hg:`addremove`.
4103 copies in the patch in the same way as :hg:`addremove`.
4104
4104
4105 It is possible to use external patch programs to perform the patch
4105 It is possible to use external patch programs to perform the patch
4106 by setting the ``ui.patch`` configuration option. For the default
4106 by setting the ``ui.patch`` configuration option. For the default
4107 internal tool, the fuzz can also be configured via ``patch.fuzz``.
4107 internal tool, the fuzz can also be configured via ``patch.fuzz``.
4108 See :hg:`help config` for more information about configuration
4108 See :hg:`help config` for more information about configuration
4109 files and how to use these options.
4109 files and how to use these options.
4110
4110
4111 See :hg:`help dates` for a list of formats valid for -d/--date.
4111 See :hg:`help dates` for a list of formats valid for -d/--date.
4112
4112
4113 .. container:: verbose
4113 .. container:: verbose
4114
4114
4115 Examples:
4115 Examples:
4116
4116
4117 - import a traditional patch from a website and detect renames::
4117 - import a traditional patch from a website and detect renames::
4118
4118
4119 hg import -s 80 http://example.com/bugfix.patch
4119 hg import -s 80 http://example.com/bugfix.patch
4120
4120
4121 - import a changeset from an hgweb server::
4121 - import a changeset from an hgweb server::
4122
4122
4123 hg import https://www.mercurial-scm.org/repo/hg/rev/5ca8c111e9aa
4123 hg import https://www.mercurial-scm.org/repo/hg/rev/5ca8c111e9aa
4124
4124
4125 - import all the patches in an Unix-style mbox::
4125 - import all the patches in an Unix-style mbox::
4126
4126
4127 hg import incoming-patches.mbox
4127 hg import incoming-patches.mbox
4128
4128
4129 - import patches from stdin::
4129 - import patches from stdin::
4130
4130
4131 hg import -
4131 hg import -
4132
4132
4133 - attempt to exactly restore an exported changeset (not always
4133 - attempt to exactly restore an exported changeset (not always
4134 possible)::
4134 possible)::
4135
4135
4136 hg import --exact proposed-fix.patch
4136 hg import --exact proposed-fix.patch
4137
4137
4138 - use an external tool to apply a patch which is too fuzzy for
4138 - use an external tool to apply a patch which is too fuzzy for
4139 the default internal tool.
4139 the default internal tool.
4140
4140
4141 hg import --config ui.patch="patch --merge" fuzzy.patch
4141 hg import --config ui.patch="patch --merge" fuzzy.patch
4142
4142
4143 - change the default fuzzing from 2 to a less strict 7
4143 - change the default fuzzing from 2 to a less strict 7
4144
4144
4145 hg import --config ui.fuzz=7 fuzz.patch
4145 hg import --config ui.fuzz=7 fuzz.patch
4146
4146
4147 Returns 0 on success, 1 on partial success (see --partial).
4147 Returns 0 on success, 1 on partial success (see --partial).
4148 """
4148 """
4149
4149
4150 opts = pycompat.byteskwargs(opts)
4150 opts = pycompat.byteskwargs(opts)
4151 if not patch1:
4151 if not patch1:
4152 raise error.Abort(_(b'need at least one patch to import'))
4152 raise error.Abort(_(b'need at least one patch to import'))
4153
4153
4154 patches = (patch1,) + patches
4154 patches = (patch1,) + patches
4155
4155
4156 date = opts.get(b'date')
4156 date = opts.get(b'date')
4157 if date:
4157 if date:
4158 opts[b'date'] = dateutil.parsedate(date)
4158 opts[b'date'] = dateutil.parsedate(date)
4159
4159
4160 exact = opts.get(b'exact')
4160 exact = opts.get(b'exact')
4161 update = not opts.get(b'bypass')
4161 update = not opts.get(b'bypass')
4162 if not update and opts.get(b'no_commit'):
4162 if not update and opts.get(b'no_commit'):
4163 raise error.Abort(_(b'cannot use --no-commit with --bypass'))
4163 raise error.Abort(_(b'cannot use --no-commit with --bypass'))
4164 try:
4164 try:
4165 sim = float(opts.get(b'similarity') or 0)
4165 sim = float(opts.get(b'similarity') or 0)
4166 except ValueError:
4166 except ValueError:
4167 raise error.Abort(_(b'similarity must be a number'))
4167 raise error.Abort(_(b'similarity must be a number'))
4168 if sim < 0 or sim > 100:
4168 if sim < 0 or sim > 100:
4169 raise error.Abort(_(b'similarity must be between 0 and 100'))
4169 raise error.Abort(_(b'similarity must be between 0 and 100'))
4170 if sim and not update:
4170 if sim and not update:
4171 raise error.Abort(_(b'cannot use --similarity with --bypass'))
4171 raise error.Abort(_(b'cannot use --similarity with --bypass'))
4172 if exact:
4172 if exact:
4173 if opts.get(b'edit'):
4173 if opts.get(b'edit'):
4174 raise error.Abort(_(b'cannot use --exact with --edit'))
4174 raise error.Abort(_(b'cannot use --exact with --edit'))
4175 if opts.get(b'prefix'):
4175 if opts.get(b'prefix'):
4176 raise error.Abort(_(b'cannot use --exact with --prefix'))
4176 raise error.Abort(_(b'cannot use --exact with --prefix'))
4177
4177
4178 base = opts[b"base"]
4178 base = opts[b"base"]
4179 msgs = []
4179 msgs = []
4180 ret = 0
4180 ret = 0
4181
4181
4182 with repo.wlock():
4182 with repo.wlock():
4183 if update:
4183 if update:
4184 cmdutil.checkunfinished(repo)
4184 cmdutil.checkunfinished(repo)
4185 if exact or not opts.get(b'force'):
4185 if exact or not opts.get(b'force'):
4186 cmdutil.bailifchanged(repo)
4186 cmdutil.bailifchanged(repo)
4187
4187
4188 if not opts.get(b'no_commit'):
4188 if not opts.get(b'no_commit'):
4189 lock = repo.lock
4189 lock = repo.lock
4190 tr = lambda: repo.transaction(b'import')
4190 tr = lambda: repo.transaction(b'import')
4191 dsguard = util.nullcontextmanager
4191 dsguard = util.nullcontextmanager
4192 else:
4192 else:
4193 lock = util.nullcontextmanager
4193 lock = util.nullcontextmanager
4194 tr = util.nullcontextmanager
4194 tr = util.nullcontextmanager
4195 dsguard = lambda: dirstateguard.dirstateguard(repo, b'import')
4195 dsguard = lambda: dirstateguard.dirstateguard(repo, b'import')
4196 with lock(), tr(), dsguard():
4196 with lock(), tr(), dsguard():
4197 parents = repo[None].parents()
4197 parents = repo[None].parents()
4198 for patchurl in patches:
4198 for patchurl in patches:
4199 if patchurl == b'-':
4199 if patchurl == b'-':
4200 ui.status(_(b'applying patch from stdin\n'))
4200 ui.status(_(b'applying patch from stdin\n'))
4201 patchfile = ui.fin
4201 patchfile = ui.fin
4202 patchurl = b'stdin' # for error message
4202 patchurl = b'stdin' # for error message
4203 else:
4203 else:
4204 patchurl = os.path.join(base, patchurl)
4204 patchurl = os.path.join(base, patchurl)
4205 ui.status(_(b'applying %s\n') % patchurl)
4205 ui.status(_(b'applying %s\n') % patchurl)
4206 patchfile = hg.openpath(ui, patchurl, sendaccept=False)
4206 patchfile = hg.openpath(ui, patchurl, sendaccept=False)
4207
4207
4208 haspatch = False
4208 haspatch = False
4209 for hunk in patch.split(patchfile):
4209 for hunk in patch.split(patchfile):
4210 with patch.extract(ui, hunk) as patchdata:
4210 with patch.extract(ui, hunk) as patchdata:
4211 msg, node, rej = cmdutil.tryimportone(
4211 msg, node, rej = cmdutil.tryimportone(
4212 ui, repo, patchdata, parents, opts, msgs, hg.clean
4212 ui, repo, patchdata, parents, opts, msgs, hg.clean
4213 )
4213 )
4214 if msg:
4214 if msg:
4215 haspatch = True
4215 haspatch = True
4216 ui.note(msg + b'\n')
4216 ui.note(msg + b'\n')
4217 if update or exact:
4217 if update or exact:
4218 parents = repo[None].parents()
4218 parents = repo[None].parents()
4219 else:
4219 else:
4220 parents = [repo[node]]
4220 parents = [repo[node]]
4221 if rej:
4221 if rej:
4222 ui.write_err(_(b"patch applied partially\n"))
4222 ui.write_err(_(b"patch applied partially\n"))
4223 ui.write_err(
4223 ui.write_err(
4224 _(
4224 _(
4225 b"(fix the .rej files and run "
4225 b"(fix the .rej files and run "
4226 b"`hg commit --amend`)\n"
4226 b"`hg commit --amend`)\n"
4227 )
4227 )
4228 )
4228 )
4229 ret = 1
4229 ret = 1
4230 break
4230 break
4231
4231
4232 if not haspatch:
4232 if not haspatch:
4233 raise error.Abort(_(b'%s: no diffs found') % patchurl)
4233 raise error.Abort(_(b'%s: no diffs found') % patchurl)
4234
4234
4235 if msgs:
4235 if msgs:
4236 repo.savecommitmessage(b'\n* * *\n'.join(msgs))
4236 repo.savecommitmessage(b'\n* * *\n'.join(msgs))
4237 return ret
4237 return ret
4238
4238
4239
4239
4240 @command(
4240 @command(
4241 b'incoming|in',
4241 b'incoming|in',
4242 [
4242 [
4243 (
4243 (
4244 b'f',
4244 b'f',
4245 b'force',
4245 b'force',
4246 None,
4246 None,
4247 _(b'run even if remote repository is unrelated'),
4247 _(b'run even if remote repository is unrelated'),
4248 ),
4248 ),
4249 (b'n', b'newest-first', None, _(b'show newest record first')),
4249 (b'n', b'newest-first', None, _(b'show newest record first')),
4250 (b'', b'bundle', b'', _(b'file to store the bundles into'), _(b'FILE')),
4250 (b'', b'bundle', b'', _(b'file to store the bundles into'), _(b'FILE')),
4251 (
4251 (
4252 b'r',
4252 b'r',
4253 b'rev',
4253 b'rev',
4254 [],
4254 [],
4255 _(b'a remote changeset intended to be added'),
4255 _(b'a remote changeset intended to be added'),
4256 _(b'REV'),
4256 _(b'REV'),
4257 ),
4257 ),
4258 (b'B', b'bookmarks', False, _(b"compare bookmarks")),
4258 (b'B', b'bookmarks', False, _(b"compare bookmarks")),
4259 (
4259 (
4260 b'b',
4260 b'b',
4261 b'branch',
4261 b'branch',
4262 [],
4262 [],
4263 _(b'a specific branch you would like to pull'),
4263 _(b'a specific branch you would like to pull'),
4264 _(b'BRANCH'),
4264 _(b'BRANCH'),
4265 ),
4265 ),
4266 ]
4266 ]
4267 + logopts
4267 + logopts
4268 + remoteopts
4268 + remoteopts
4269 + subrepoopts,
4269 + subrepoopts,
4270 _(b'[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'),
4270 _(b'[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'),
4271 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
4271 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
4272 )
4272 )
4273 def incoming(ui, repo, source=b"default", **opts):
4273 def incoming(ui, repo, source=b"default", **opts):
4274 """show new changesets found in source
4274 """show new changesets found in source
4275
4275
4276 Show new changesets found in the specified path/URL or the default
4276 Show new changesets found in the specified path/URL or the default
4277 pull location. These are the changesets that would have been pulled
4277 pull location. These are the changesets that would have been pulled
4278 by :hg:`pull` at the time you issued this command.
4278 by :hg:`pull` at the time you issued this command.
4279
4279
4280 See pull for valid source format details.
4280 See pull for valid source format details.
4281
4281
4282 .. container:: verbose
4282 .. container:: verbose
4283
4283
4284 With -B/--bookmarks, the result of bookmark comparison between
4284 With -B/--bookmarks, the result of bookmark comparison between
4285 local and remote repositories is displayed. With -v/--verbose,
4285 local and remote repositories is displayed. With -v/--verbose,
4286 status is also displayed for each bookmark like below::
4286 status is also displayed for each bookmark like below::
4287
4287
4288 BM1 01234567890a added
4288 BM1 01234567890a added
4289 BM2 1234567890ab advanced
4289 BM2 1234567890ab advanced
4290 BM3 234567890abc diverged
4290 BM3 234567890abc diverged
4291 BM4 34567890abcd changed
4291 BM4 34567890abcd changed
4292
4292
4293 The action taken locally when pulling depends on the
4293 The action taken locally when pulling depends on the
4294 status of each bookmark:
4294 status of each bookmark:
4295
4295
4296 :``added``: pull will create it
4296 :``added``: pull will create it
4297 :``advanced``: pull will update it
4297 :``advanced``: pull will update it
4298 :``diverged``: pull will create a divergent bookmark
4298 :``diverged``: pull will create a divergent bookmark
4299 :``changed``: result depends on remote changesets
4299 :``changed``: result depends on remote changesets
4300
4300
4301 From the point of view of pulling behavior, bookmark
4301 From the point of view of pulling behavior, bookmark
4302 existing only in the remote repository are treated as ``added``,
4302 existing only in the remote repository are treated as ``added``,
4303 even if it is in fact locally deleted.
4303 even if it is in fact locally deleted.
4304
4304
4305 .. container:: verbose
4305 .. container:: verbose
4306
4306
4307 For remote repository, using --bundle avoids downloading the
4307 For remote repository, using --bundle avoids downloading the
4308 changesets twice if the incoming is followed by a pull.
4308 changesets twice if the incoming is followed by a pull.
4309
4309
4310 Examples:
4310 Examples:
4311
4311
4312 - show incoming changes with patches and full description::
4312 - show incoming changes with patches and full description::
4313
4313
4314 hg incoming -vp
4314 hg incoming -vp
4315
4315
4316 - show incoming changes excluding merges, store a bundle::
4316 - show incoming changes excluding merges, store a bundle::
4317
4317
4318 hg in -vpM --bundle incoming.hg
4318 hg in -vpM --bundle incoming.hg
4319 hg pull incoming.hg
4319 hg pull incoming.hg
4320
4320
4321 - briefly list changes inside a bundle::
4321 - briefly list changes inside a bundle::
4322
4322
4323 hg in changes.hg -T "{desc|firstline}\\n"
4323 hg in changes.hg -T "{desc|firstline}\\n"
4324
4324
4325 Returns 0 if there are incoming changes, 1 otherwise.
4325 Returns 0 if there are incoming changes, 1 otherwise.
4326 """
4326 """
4327 opts = pycompat.byteskwargs(opts)
4327 opts = pycompat.byteskwargs(opts)
4328 if opts.get(b'graph'):
4328 if opts.get(b'graph'):
4329 logcmdutil.checkunsupportedgraphflags([], opts)
4329 logcmdutil.checkunsupportedgraphflags([], opts)
4330
4330
4331 def display(other, chlist, displayer):
4331 def display(other, chlist, displayer):
4332 revdag = logcmdutil.graphrevs(other, chlist, opts)
4332 revdag = logcmdutil.graphrevs(other, chlist, opts)
4333 logcmdutil.displaygraph(
4333 logcmdutil.displaygraph(
4334 ui, repo, revdag, displayer, graphmod.asciiedges
4334 ui, repo, revdag, displayer, graphmod.asciiedges
4335 )
4335 )
4336
4336
4337 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
4337 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
4338 return 0
4338 return 0
4339
4339
4340 if opts.get(b'bundle') and opts.get(b'subrepos'):
4340 if opts.get(b'bundle') and opts.get(b'subrepos'):
4341 raise error.Abort(_(b'cannot combine --bundle and --subrepos'))
4341 raise error.Abort(_(b'cannot combine --bundle and --subrepos'))
4342
4342
4343 if opts.get(b'bookmarks'):
4343 if opts.get(b'bookmarks'):
4344 source, branches = hg.parseurl(
4344 source, branches = hg.parseurl(
4345 ui.expandpath(source), opts.get(b'branch')
4345 ui.expandpath(source), opts.get(b'branch')
4346 )
4346 )
4347 other = hg.peer(repo, opts, source)
4347 other = hg.peer(repo, opts, source)
4348 if b'bookmarks' not in other.listkeys(b'namespaces'):
4348 if b'bookmarks' not in other.listkeys(b'namespaces'):
4349 ui.warn(_(b"remote doesn't support bookmarks\n"))
4349 ui.warn(_(b"remote doesn't support bookmarks\n"))
4350 return 0
4350 return 0
4351 ui.pager(b'incoming')
4351 ui.pager(b'incoming')
4352 ui.status(_(b'comparing with %s\n') % util.hidepassword(source))
4352 ui.status(_(b'comparing with %s\n') % util.hidepassword(source))
4353 return bookmarks.incoming(ui, repo, other)
4353 return bookmarks.incoming(ui, repo, other)
4354
4354
4355 repo._subtoppath = ui.expandpath(source)
4355 repo._subtoppath = ui.expandpath(source)
4356 try:
4356 try:
4357 return hg.incoming(ui, repo, source, opts)
4357 return hg.incoming(ui, repo, source, opts)
4358 finally:
4358 finally:
4359 del repo._subtoppath
4359 del repo._subtoppath
4360
4360
4361
4361
4362 @command(
4362 @command(
4363 b'init',
4363 b'init',
4364 remoteopts,
4364 remoteopts,
4365 _(b'[-e CMD] [--remotecmd CMD] [DEST]'),
4365 _(b'[-e CMD] [--remotecmd CMD] [DEST]'),
4366 helpcategory=command.CATEGORY_REPO_CREATION,
4366 helpcategory=command.CATEGORY_REPO_CREATION,
4367 helpbasic=True,
4367 helpbasic=True,
4368 norepo=True,
4368 norepo=True,
4369 )
4369 )
4370 def init(ui, dest=b".", **opts):
4370 def init(ui, dest=b".", **opts):
4371 """create a new repository in the given directory
4371 """create a new repository in the given directory
4372
4372
4373 Initialize a new repository in the given directory. If the given
4373 Initialize a new repository in the given directory. If the given
4374 directory does not exist, it will be created.
4374 directory does not exist, it will be created.
4375
4375
4376 If no directory is given, the current directory is used.
4376 If no directory is given, the current directory is used.
4377
4377
4378 It is possible to specify an ``ssh://`` URL as the destination.
4378 It is possible to specify an ``ssh://`` URL as the destination.
4379 See :hg:`help urls` for more information.
4379 See :hg:`help urls` for more information.
4380
4380
4381 Returns 0 on success.
4381 Returns 0 on success.
4382 """
4382 """
4383 opts = pycompat.byteskwargs(opts)
4383 opts = pycompat.byteskwargs(opts)
4384 hg.peer(ui, opts, ui.expandpath(dest), create=True)
4384 hg.peer(ui, opts, ui.expandpath(dest), create=True)
4385
4385
4386
4386
4387 @command(
4387 @command(
4388 b'locate',
4388 b'locate',
4389 [
4389 [
4390 (
4390 (
4391 b'r',
4391 b'r',
4392 b'rev',
4392 b'rev',
4393 b'',
4393 b'',
4394 _(b'search the repository as it is in REV'),
4394 _(b'search the repository as it is in REV'),
4395 _(b'REV'),
4395 _(b'REV'),
4396 ),
4396 ),
4397 (
4397 (
4398 b'0',
4398 b'0',
4399 b'print0',
4399 b'print0',
4400 None,
4400 None,
4401 _(b'end filenames with NUL, for use with xargs'),
4401 _(b'end filenames with NUL, for use with xargs'),
4402 ),
4402 ),
4403 (
4403 (
4404 b'f',
4404 b'f',
4405 b'fullpath',
4405 b'fullpath',
4406 None,
4406 None,
4407 _(b'print complete paths from the filesystem root'),
4407 _(b'print complete paths from the filesystem root'),
4408 ),
4408 ),
4409 ]
4409 ]
4410 + walkopts,
4410 + walkopts,
4411 _(b'[OPTION]... [PATTERN]...'),
4411 _(b'[OPTION]... [PATTERN]...'),
4412 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
4412 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
4413 )
4413 )
4414 def locate(ui, repo, *pats, **opts):
4414 def locate(ui, repo, *pats, **opts):
4415 """locate files matching specific patterns (DEPRECATED)
4415 """locate files matching specific patterns (DEPRECATED)
4416
4416
4417 Print files under Mercurial control in the working directory whose
4417 Print files under Mercurial control in the working directory whose
4418 names match the given patterns.
4418 names match the given patterns.
4419
4419
4420 By default, this command searches all directories in the working
4420 By default, this command searches all directories in the working
4421 directory. To search just the current directory and its
4421 directory. To search just the current directory and its
4422 subdirectories, use "--include .".
4422 subdirectories, use "--include .".
4423
4423
4424 If no patterns are given to match, this command prints the names
4424 If no patterns are given to match, this command prints the names
4425 of all files under Mercurial control in the working directory.
4425 of all files under Mercurial control in the working directory.
4426
4426
4427 If you want to feed the output of this command into the "xargs"
4427 If you want to feed the output of this command into the "xargs"
4428 command, use the -0 option to both this command and "xargs". This
4428 command, use the -0 option to both this command and "xargs". This
4429 will avoid the problem of "xargs" treating single filenames that
4429 will avoid the problem of "xargs" treating single filenames that
4430 contain whitespace as multiple filenames.
4430 contain whitespace as multiple filenames.
4431
4431
4432 See :hg:`help files` for a more versatile command.
4432 See :hg:`help files` for a more versatile command.
4433
4433
4434 Returns 0 if a match is found, 1 otherwise.
4434 Returns 0 if a match is found, 1 otherwise.
4435 """
4435 """
4436 opts = pycompat.byteskwargs(opts)
4436 opts = pycompat.byteskwargs(opts)
4437 if opts.get(b'print0'):
4437 if opts.get(b'print0'):
4438 end = b'\0'
4438 end = b'\0'
4439 else:
4439 else:
4440 end = b'\n'
4440 end = b'\n'
4441 ctx = scmutil.revsingle(repo, opts.get(b'rev'), None)
4441 ctx = scmutil.revsingle(repo, opts.get(b'rev'), None)
4442
4442
4443 ret = 1
4443 ret = 1
4444 m = scmutil.match(
4444 m = scmutil.match(
4445 ctx, pats, opts, default=b'relglob', badfn=lambda x, y: False
4445 ctx, pats, opts, default=b'relglob', badfn=lambda x, y: False
4446 )
4446 )
4447
4447
4448 ui.pager(b'locate')
4448 ui.pager(b'locate')
4449 if ctx.rev() is None:
4449 if ctx.rev() is None:
4450 # When run on the working copy, "locate" includes removed files, so
4450 # When run on the working copy, "locate" includes removed files, so
4451 # we get the list of files from the dirstate.
4451 # we get the list of files from the dirstate.
4452 filesgen = sorted(repo.dirstate.matches(m))
4452 filesgen = sorted(repo.dirstate.matches(m))
4453 else:
4453 else:
4454 filesgen = ctx.matches(m)
4454 filesgen = ctx.matches(m)
4455 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=bool(pats))
4455 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=bool(pats))
4456 for abs in filesgen:
4456 for abs in filesgen:
4457 if opts.get(b'fullpath'):
4457 if opts.get(b'fullpath'):
4458 ui.write(repo.wjoin(abs), end)
4458 ui.write(repo.wjoin(abs), end)
4459 else:
4459 else:
4460 ui.write(uipathfn(abs), end)
4460 ui.write(uipathfn(abs), end)
4461 ret = 0
4461 ret = 0
4462
4462
4463 return ret
4463 return ret
4464
4464
4465
4465
4466 @command(
4466 @command(
4467 b'log|history',
4467 b'log|history',
4468 [
4468 [
4469 (
4469 (
4470 b'f',
4470 b'f',
4471 b'follow',
4471 b'follow',
4472 None,
4472 None,
4473 _(
4473 _(
4474 b'follow changeset history, or file history across copies and renames'
4474 b'follow changeset history, or file history across copies and renames'
4475 ),
4475 ),
4476 ),
4476 ),
4477 (
4477 (
4478 b'',
4478 b'',
4479 b'follow-first',
4479 b'follow-first',
4480 None,
4480 None,
4481 _(b'only follow the first parent of merge changesets (DEPRECATED)'),
4481 _(b'only follow the first parent of merge changesets (DEPRECATED)'),
4482 ),
4482 ),
4483 (
4483 (
4484 b'd',
4484 b'd',
4485 b'date',
4485 b'date',
4486 b'',
4486 b'',
4487 _(b'show revisions matching date spec'),
4487 _(b'show revisions matching date spec'),
4488 _(b'DATE'),
4488 _(b'DATE'),
4489 ),
4489 ),
4490 (b'C', b'copies', None, _(b'show copied files')),
4490 (b'C', b'copies', None, _(b'show copied files')),
4491 (
4491 (
4492 b'k',
4492 b'k',
4493 b'keyword',
4493 b'keyword',
4494 [],
4494 [],
4495 _(b'do case-insensitive search for a given text'),
4495 _(b'do case-insensitive search for a given text'),
4496 _(b'TEXT'),
4496 _(b'TEXT'),
4497 ),
4497 ),
4498 (
4498 (
4499 b'r',
4499 b'r',
4500 b'rev',
4500 b'rev',
4501 [],
4501 [],
4502 _(b'show the specified revision or revset'),
4502 _(b'show the specified revision or revset'),
4503 _(b'REV'),
4503 _(b'REV'),
4504 ),
4504 ),
4505 (
4505 (
4506 b'L',
4506 b'L',
4507 b'line-range',
4507 b'line-range',
4508 [],
4508 [],
4509 _(b'follow line range of specified file (EXPERIMENTAL)'),
4509 _(b'follow line range of specified file (EXPERIMENTAL)'),
4510 _(b'FILE,RANGE'),
4510 _(b'FILE,RANGE'),
4511 ),
4511 ),
4512 (
4512 (
4513 b'',
4513 b'',
4514 b'removed',
4514 b'removed',
4515 None,
4515 None,
4516 _(b'include revisions where files were removed'),
4516 _(b'include revisions where files were removed'),
4517 ),
4517 ),
4518 (
4518 (
4519 b'm',
4519 b'm',
4520 b'only-merges',
4520 b'only-merges',
4521 None,
4521 None,
4522 _(b'show only merges (DEPRECATED) (use -r "merge()" instead)'),
4522 _(b'show only merges (DEPRECATED) (use -r "merge()" instead)'),
4523 ),
4523 ),
4524 (b'u', b'user', [], _(b'revisions committed by user'), _(b'USER')),
4524 (b'u', b'user', [], _(b'revisions committed by user'), _(b'USER')),
4525 (
4525 (
4526 b'',
4526 b'',
4527 b'only-branch',
4527 b'only-branch',
4528 [],
4528 [],
4529 _(
4529 _(
4530 b'show only changesets within the given named branch (DEPRECATED)'
4530 b'show only changesets within the given named branch (DEPRECATED)'
4531 ),
4531 ),
4532 _(b'BRANCH'),
4532 _(b'BRANCH'),
4533 ),
4533 ),
4534 (
4534 (
4535 b'b',
4535 b'b',
4536 b'branch',
4536 b'branch',
4537 [],
4537 [],
4538 _(b'show changesets within the given named branch'),
4538 _(b'show changesets within the given named branch'),
4539 _(b'BRANCH'),
4539 _(b'BRANCH'),
4540 ),
4540 ),
4541 (
4541 (
4542 b'P',
4542 b'P',
4543 b'prune',
4543 b'prune',
4544 [],
4544 [],
4545 _(b'do not display revision or any of its ancestors'),
4545 _(b'do not display revision or any of its ancestors'),
4546 _(b'REV'),
4546 _(b'REV'),
4547 ),
4547 ),
4548 ]
4548 ]
4549 + logopts
4549 + logopts
4550 + walkopts,
4550 + walkopts,
4551 _(b'[OPTION]... [FILE]'),
4551 _(b'[OPTION]... [FILE]'),
4552 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
4552 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
4553 helpbasic=True,
4553 helpbasic=True,
4554 inferrepo=True,
4554 inferrepo=True,
4555 intents={INTENT_READONLY},
4555 intents={INTENT_READONLY},
4556 )
4556 )
4557 def log(ui, repo, *pats, **opts):
4557 def log(ui, repo, *pats, **opts):
4558 """show revision history of entire repository or files
4558 """show revision history of entire repository or files
4559
4559
4560 Print the revision history of the specified files or the entire
4560 Print the revision history of the specified files or the entire
4561 project.
4561 project.
4562
4562
4563 If no revision range is specified, the default is ``tip:0`` unless
4563 If no revision range is specified, the default is ``tip:0`` unless
4564 --follow is set, in which case the working directory parent is
4564 --follow is set, in which case the working directory parent is
4565 used as the starting revision.
4565 used as the starting revision.
4566
4566
4567 File history is shown without following rename or copy history of
4567 File history is shown without following rename or copy history of
4568 files. Use -f/--follow with a filename to follow history across
4568 files. Use -f/--follow with a filename to follow history across
4569 renames and copies. --follow without a filename will only show
4569 renames and copies. --follow without a filename will only show
4570 ancestors of the starting revision.
4570 ancestors of the starting revision.
4571
4571
4572 By default this command prints revision number and changeset id,
4572 By default this command prints revision number and changeset id,
4573 tags, non-trivial parents, user, date and time, and a summary for
4573 tags, non-trivial parents, user, date and time, and a summary for
4574 each commit. When the -v/--verbose switch is used, the list of
4574 each commit. When the -v/--verbose switch is used, the list of
4575 changed files and full commit message are shown.
4575 changed files and full commit message are shown.
4576
4576
4577 With --graph the revisions are shown as an ASCII art DAG with the most
4577 With --graph the revisions are shown as an ASCII art DAG with the most
4578 recent changeset at the top.
4578 recent changeset at the top.
4579 'o' is a changeset, '@' is a working directory parent, '_' closes a branch,
4579 'o' is a changeset, '@' is a working directory parent, '_' closes a branch,
4580 'x' is obsolete, '*' is unstable, and '+' represents a fork where the
4580 'x' is obsolete, '*' is unstable, and '+' represents a fork where the
4581 changeset from the lines below is a parent of the 'o' merge on the same
4581 changeset from the lines below is a parent of the 'o' merge on the same
4582 line.
4582 line.
4583 Paths in the DAG are represented with '|', '/' and so forth. ':' in place
4583 Paths in the DAG are represented with '|', '/' and so forth. ':' in place
4584 of a '|' indicates one or more revisions in a path are omitted.
4584 of a '|' indicates one or more revisions in a path are omitted.
4585
4585
4586 .. container:: verbose
4586 .. container:: verbose
4587
4587
4588 Use -L/--line-range FILE,M:N options to follow the history of lines
4588 Use -L/--line-range FILE,M:N options to follow the history of lines
4589 from M to N in FILE. With -p/--patch only diff hunks affecting
4589 from M to N in FILE. With -p/--patch only diff hunks affecting
4590 specified line range will be shown. This option requires --follow;
4590 specified line range will be shown. This option requires --follow;
4591 it can be specified multiple times. Currently, this option is not
4591 it can be specified multiple times. Currently, this option is not
4592 compatible with --graph. This option is experimental.
4592 compatible with --graph. This option is experimental.
4593
4593
4594 .. note::
4594 .. note::
4595
4595
4596 :hg:`log --patch` may generate unexpected diff output for merge
4596 :hg:`log --patch` may generate unexpected diff output for merge
4597 changesets, as it will only compare the merge changeset against
4597 changesets, as it will only compare the merge changeset against
4598 its first parent. Also, only files different from BOTH parents
4598 its first parent. Also, only files different from BOTH parents
4599 will appear in files:.
4599 will appear in files:.
4600
4600
4601 .. note::
4601 .. note::
4602
4602
4603 For performance reasons, :hg:`log FILE` may omit duplicate changes
4603 For performance reasons, :hg:`log FILE` may omit duplicate changes
4604 made on branches and will not show removals or mode changes. To
4604 made on branches and will not show removals or mode changes. To
4605 see all such changes, use the --removed switch.
4605 see all such changes, use the --removed switch.
4606
4606
4607 .. container:: verbose
4607 .. container:: verbose
4608
4608
4609 .. note::
4609 .. note::
4610
4610
4611 The history resulting from -L/--line-range options depends on diff
4611 The history resulting from -L/--line-range options depends on diff
4612 options; for instance if white-spaces are ignored, respective changes
4612 options; for instance if white-spaces are ignored, respective changes
4613 with only white-spaces in specified line range will not be listed.
4613 with only white-spaces in specified line range will not be listed.
4614
4614
4615 .. container:: verbose
4615 .. container:: verbose
4616
4616
4617 Some examples:
4617 Some examples:
4618
4618
4619 - changesets with full descriptions and file lists::
4619 - changesets with full descriptions and file lists::
4620
4620
4621 hg log -v
4621 hg log -v
4622
4622
4623 - changesets ancestral to the working directory::
4623 - changesets ancestral to the working directory::
4624
4624
4625 hg log -f
4625 hg log -f
4626
4626
4627 - last 10 commits on the current branch::
4627 - last 10 commits on the current branch::
4628
4628
4629 hg log -l 10 -b .
4629 hg log -l 10 -b .
4630
4630
4631 - changesets showing all modifications of a file, including removals::
4631 - changesets showing all modifications of a file, including removals::
4632
4632
4633 hg log --removed file.c
4633 hg log --removed file.c
4634
4634
4635 - all changesets that touch a directory, with diffs, excluding merges::
4635 - all changesets that touch a directory, with diffs, excluding merges::
4636
4636
4637 hg log -Mp lib/
4637 hg log -Mp lib/
4638
4638
4639 - all revision numbers that match a keyword::
4639 - all revision numbers that match a keyword::
4640
4640
4641 hg log -k bug --template "{rev}\\n"
4641 hg log -k bug --template "{rev}\\n"
4642
4642
4643 - the full hash identifier of the working directory parent::
4643 - the full hash identifier of the working directory parent::
4644
4644
4645 hg log -r . --template "{node}\\n"
4645 hg log -r . --template "{node}\\n"
4646
4646
4647 - list available log templates::
4647 - list available log templates::
4648
4648
4649 hg log -T list
4649 hg log -T list
4650
4650
4651 - check if a given changeset is included in a tagged release::
4651 - check if a given changeset is included in a tagged release::
4652
4652
4653 hg log -r "a21ccf and ancestor(1.9)"
4653 hg log -r "a21ccf and ancestor(1.9)"
4654
4654
4655 - find all changesets by some user in a date range::
4655 - find all changesets by some user in a date range::
4656
4656
4657 hg log -k alice -d "may 2008 to jul 2008"
4657 hg log -k alice -d "may 2008 to jul 2008"
4658
4658
4659 - summary of all changesets after the last tag::
4659 - summary of all changesets after the last tag::
4660
4660
4661 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4661 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4662
4662
4663 - changesets touching lines 13 to 23 for file.c::
4663 - changesets touching lines 13 to 23 for file.c::
4664
4664
4665 hg log -L file.c,13:23
4665 hg log -L file.c,13:23
4666
4666
4667 - changesets touching lines 13 to 23 for file.c and lines 2 to 6 of
4667 - changesets touching lines 13 to 23 for file.c and lines 2 to 6 of
4668 main.c with patch::
4668 main.c with patch::
4669
4669
4670 hg log -L file.c,13:23 -L main.c,2:6 -p
4670 hg log -L file.c,13:23 -L main.c,2:6 -p
4671
4671
4672 See :hg:`help dates` for a list of formats valid for -d/--date.
4672 See :hg:`help dates` for a list of formats valid for -d/--date.
4673
4673
4674 See :hg:`help revisions` for more about specifying and ordering
4674 See :hg:`help revisions` for more about specifying and ordering
4675 revisions.
4675 revisions.
4676
4676
4677 See :hg:`help templates` for more about pre-packaged styles and
4677 See :hg:`help templates` for more about pre-packaged styles and
4678 specifying custom templates. The default template used by the log
4678 specifying custom templates. The default template used by the log
4679 command can be customized via the ``ui.logtemplate`` configuration
4679 command can be customized via the ``ui.logtemplate`` configuration
4680 setting.
4680 setting.
4681
4681
4682 Returns 0 on success.
4682 Returns 0 on success.
4683
4683
4684 """
4684 """
4685 opts = pycompat.byteskwargs(opts)
4685 opts = pycompat.byteskwargs(opts)
4686 linerange = opts.get(b'line_range')
4686 linerange = opts.get(b'line_range')
4687
4687
4688 if linerange and not opts.get(b'follow'):
4688 if linerange and not opts.get(b'follow'):
4689 raise error.Abort(_(b'--line-range requires --follow'))
4689 raise error.Abort(_(b'--line-range requires --follow'))
4690
4690
4691 if linerange and pats:
4691 if linerange and pats:
4692 # TODO: take pats as patterns with no line-range filter
4692 # TODO: take pats as patterns with no line-range filter
4693 raise error.Abort(
4693 raise error.Abort(
4694 _(b'FILE arguments are not compatible with --line-range option')
4694 _(b'FILE arguments are not compatible with --line-range option')
4695 )
4695 )
4696
4696
4697 repo = scmutil.unhidehashlikerevs(repo, opts.get(b'rev'), b'nowarn')
4697 repo = scmutil.unhidehashlikerevs(repo, opts.get(b'rev'), b'nowarn')
4698 revs, differ = logcmdutil.getrevs(repo, pats, opts)
4698 revs, differ = logcmdutil.getrevs(repo, pats, opts)
4699 if linerange:
4699 if linerange:
4700 # TODO: should follow file history from logcmdutil._initialrevs(),
4700 # TODO: should follow file history from logcmdutil._initialrevs(),
4701 # then filter the result by logcmdutil._makerevset() and --limit
4701 # then filter the result by logcmdutil._makerevset() and --limit
4702 revs, differ = logcmdutil.getlinerangerevs(repo, revs, opts)
4702 revs, differ = logcmdutil.getlinerangerevs(repo, revs, opts)
4703
4703
4704 getcopies = None
4704 getcopies = None
4705 if opts.get(b'copies'):
4705 if opts.get(b'copies'):
4706 endrev = None
4706 endrev = None
4707 if revs:
4707 if revs:
4708 endrev = revs.max() + 1
4708 endrev = revs.max() + 1
4709 getcopies = scmutil.getcopiesfn(repo, endrev=endrev)
4709 getcopies = scmutil.getcopiesfn(repo, endrev=endrev)
4710
4710
4711 ui.pager(b'log')
4711 ui.pager(b'log')
4712 displayer = logcmdutil.changesetdisplayer(
4712 displayer = logcmdutil.changesetdisplayer(
4713 ui, repo, opts, differ, buffered=True
4713 ui, repo, opts, differ, buffered=True
4714 )
4714 )
4715 if opts.get(b'graph'):
4715 if opts.get(b'graph'):
4716 displayfn = logcmdutil.displaygraphrevs
4716 displayfn = logcmdutil.displaygraphrevs
4717 else:
4717 else:
4718 displayfn = logcmdutil.displayrevs
4718 displayfn = logcmdutil.displayrevs
4719 displayfn(ui, repo, revs, displayer, getcopies)
4719 displayfn(ui, repo, revs, displayer, getcopies)
4720
4720
4721
4721
4722 @command(
4722 @command(
4723 b'manifest',
4723 b'manifest',
4724 [
4724 [
4725 (b'r', b'rev', b'', _(b'revision to display'), _(b'REV')),
4725 (b'r', b'rev', b'', _(b'revision to display'), _(b'REV')),
4726 (b'', b'all', False, _(b"list files from all revisions")),
4726 (b'', b'all', False, _(b"list files from all revisions")),
4727 ]
4727 ]
4728 + formatteropts,
4728 + formatteropts,
4729 _(b'[-r REV]'),
4729 _(b'[-r REV]'),
4730 helpcategory=command.CATEGORY_MAINTENANCE,
4730 helpcategory=command.CATEGORY_MAINTENANCE,
4731 intents={INTENT_READONLY},
4731 intents={INTENT_READONLY},
4732 )
4732 )
4733 def manifest(ui, repo, node=None, rev=None, **opts):
4733 def manifest(ui, repo, node=None, rev=None, **opts):
4734 """output the current or given revision of the project manifest
4734 """output the current or given revision of the project manifest
4735
4735
4736 Print a list of version controlled files for the given revision.
4736 Print a list of version controlled files for the given revision.
4737 If no revision is given, the first parent of the working directory
4737 If no revision is given, the first parent of the working directory
4738 is used, or the null revision if no revision is checked out.
4738 is used, or the null revision if no revision is checked out.
4739
4739
4740 With -v, print file permissions, symlink and executable bits.
4740 With -v, print file permissions, symlink and executable bits.
4741 With --debug, print file revision hashes.
4741 With --debug, print file revision hashes.
4742
4742
4743 If option --all is specified, the list of all files from all revisions
4743 If option --all is specified, the list of all files from all revisions
4744 is printed. This includes deleted and renamed files.
4744 is printed. This includes deleted and renamed files.
4745
4745
4746 Returns 0 on success.
4746 Returns 0 on success.
4747 """
4747 """
4748 opts = pycompat.byteskwargs(opts)
4748 opts = pycompat.byteskwargs(opts)
4749 fm = ui.formatter(b'manifest', opts)
4749 fm = ui.formatter(b'manifest', opts)
4750
4750
4751 if opts.get(b'all'):
4751 if opts.get(b'all'):
4752 if rev or node:
4752 if rev or node:
4753 raise error.Abort(_(b"can't specify a revision with --all"))
4753 raise error.Abort(_(b"can't specify a revision with --all"))
4754
4754
4755 res = set()
4755 res = set()
4756 for rev in repo:
4756 for rev in repo:
4757 ctx = repo[rev]
4757 ctx = repo[rev]
4758 res |= set(ctx.files())
4758 res |= set(ctx.files())
4759
4759
4760 ui.pager(b'manifest')
4760 ui.pager(b'manifest')
4761 for f in sorted(res):
4761 for f in sorted(res):
4762 fm.startitem()
4762 fm.startitem()
4763 fm.write(b"path", b'%s\n', f)
4763 fm.write(b"path", b'%s\n', f)
4764 fm.end()
4764 fm.end()
4765 return
4765 return
4766
4766
4767 if rev and node:
4767 if rev and node:
4768 raise error.Abort(_(b"please specify just one revision"))
4768 raise error.Abort(_(b"please specify just one revision"))
4769
4769
4770 if not node:
4770 if not node:
4771 node = rev
4771 node = rev
4772
4772
4773 char = {b'l': b'@', b'x': b'*', b'': b'', b't': b'd'}
4773 char = {b'l': b'@', b'x': b'*', b'': b'', b't': b'd'}
4774 mode = {b'l': b'644', b'x': b'755', b'': b'644', b't': b'755'}
4774 mode = {b'l': b'644', b'x': b'755', b'': b'644', b't': b'755'}
4775 if node:
4775 if node:
4776 repo = scmutil.unhidehashlikerevs(repo, [node], b'nowarn')
4776 repo = scmutil.unhidehashlikerevs(repo, [node], b'nowarn')
4777 ctx = scmutil.revsingle(repo, node)
4777 ctx = scmutil.revsingle(repo, node)
4778 mf = ctx.manifest()
4778 mf = ctx.manifest()
4779 ui.pager(b'manifest')
4779 ui.pager(b'manifest')
4780 for f in ctx:
4780 for f in ctx:
4781 fm.startitem()
4781 fm.startitem()
4782 fm.context(ctx=ctx)
4782 fm.context(ctx=ctx)
4783 fl = ctx[f].flags()
4783 fl = ctx[f].flags()
4784 fm.condwrite(ui.debugflag, b'hash', b'%s ', hex(mf[f]))
4784 fm.condwrite(ui.debugflag, b'hash', b'%s ', hex(mf[f]))
4785 fm.condwrite(ui.verbose, b'mode type', b'%s %1s ', mode[fl], char[fl])
4785 fm.condwrite(ui.verbose, b'mode type', b'%s %1s ', mode[fl], char[fl])
4786 fm.write(b'path', b'%s\n', f)
4786 fm.write(b'path', b'%s\n', f)
4787 fm.end()
4787 fm.end()
4788
4788
4789
4789
4790 @command(
4790 @command(
4791 b'merge',
4791 b'merge',
4792 [
4792 [
4793 (
4793 (
4794 b'f',
4794 b'f',
4795 b'force',
4795 b'force',
4796 None,
4796 None,
4797 _(b'force a merge including outstanding changes (DEPRECATED)'),
4797 _(b'force a merge including outstanding changes (DEPRECATED)'),
4798 ),
4798 ),
4799 (b'r', b'rev', b'', _(b'revision to merge'), _(b'REV')),
4799 (b'r', b'rev', b'', _(b'revision to merge'), _(b'REV')),
4800 (
4800 (
4801 b'P',
4801 b'P',
4802 b'preview',
4802 b'preview',
4803 None,
4803 None,
4804 _(b'review revisions to merge (no merge is performed)'),
4804 _(b'review revisions to merge (no merge is performed)'),
4805 ),
4805 ),
4806 (b'', b'abort', None, _(b'abort the ongoing merge')),
4806 (b'', b'abort', None, _(b'abort the ongoing merge')),
4807 ]
4807 ]
4808 + mergetoolopts,
4808 + mergetoolopts,
4809 _(b'[-P] [[-r] REV]'),
4809 _(b'[-P] [[-r] REV]'),
4810 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
4810 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
4811 helpbasic=True,
4811 helpbasic=True,
4812 )
4812 )
4813 def merge(ui, repo, node=None, **opts):
4813 def merge(ui, repo, node=None, **opts):
4814 """merge another revision into working directory
4814 """merge another revision into working directory
4815
4815
4816 The current working directory is updated with all changes made in
4816 The current working directory is updated with all changes made in
4817 the requested revision since the last common predecessor revision.
4817 the requested revision since the last common predecessor revision.
4818
4818
4819 Files that changed between either parent are marked as changed for
4819 Files that changed between either parent are marked as changed for
4820 the next commit and a commit must be performed before any further
4820 the next commit and a commit must be performed before any further
4821 updates to the repository are allowed. The next commit will have
4821 updates to the repository are allowed. The next commit will have
4822 two parents.
4822 two parents.
4823
4823
4824 ``--tool`` can be used to specify the merge tool used for file
4824 ``--tool`` can be used to specify the merge tool used for file
4825 merges. It overrides the HGMERGE environment variable and your
4825 merges. It overrides the HGMERGE environment variable and your
4826 configuration files. See :hg:`help merge-tools` for options.
4826 configuration files. See :hg:`help merge-tools` for options.
4827
4827
4828 If no revision is specified, the working directory's parent is a
4828 If no revision is specified, the working directory's parent is a
4829 head revision, and the current branch contains exactly one other
4829 head revision, and the current branch contains exactly one other
4830 head, the other head is merged with by default. Otherwise, an
4830 head, the other head is merged with by default. Otherwise, an
4831 explicit revision with which to merge must be provided.
4831 explicit revision with which to merge must be provided.
4832
4832
4833 See :hg:`help resolve` for information on handling file conflicts.
4833 See :hg:`help resolve` for information on handling file conflicts.
4834
4834
4835 To undo an uncommitted merge, use :hg:`merge --abort` which
4835 To undo an uncommitted merge, use :hg:`merge --abort` which
4836 will check out a clean copy of the original merge parent, losing
4836 will check out a clean copy of the original merge parent, losing
4837 all changes.
4837 all changes.
4838
4838
4839 Returns 0 on success, 1 if there are unresolved files.
4839 Returns 0 on success, 1 if there are unresolved files.
4840 """
4840 """
4841
4841
4842 opts = pycompat.byteskwargs(opts)
4842 opts = pycompat.byteskwargs(opts)
4843 abort = opts.get(b'abort')
4843 abort = opts.get(b'abort')
4844 if abort and repo.dirstate.p2() == nullid:
4844 if abort and repo.dirstate.p2() == nullid:
4845 cmdutil.wrongtooltocontinue(repo, _(b'merge'))
4845 cmdutil.wrongtooltocontinue(repo, _(b'merge'))
4846 if abort:
4846 if abort:
4847 state = cmdutil.getunfinishedstate(repo)
4847 state = cmdutil.getunfinishedstate(repo)
4848 if state and state._opname != b'merge':
4848 if state and state._opname != b'merge':
4849 raise error.Abort(
4849 raise error.Abort(
4850 _(b'cannot abort merge with %s in progress') % (state._opname),
4850 _(b'cannot abort merge with %s in progress') % (state._opname),
4851 hint=state.hint(),
4851 hint=state.hint(),
4852 )
4852 )
4853 if node:
4853 if node:
4854 raise error.Abort(_(b"cannot specify a node with --abort"))
4854 raise error.Abort(_(b"cannot specify a node with --abort"))
4855 if opts.get(b'rev'):
4855 if opts.get(b'rev'):
4856 raise error.Abort(_(b"cannot specify both --rev and --abort"))
4856 raise error.Abort(_(b"cannot specify both --rev and --abort"))
4857 if opts.get(b'preview'):
4857 if opts.get(b'preview'):
4858 raise error.Abort(_(b"cannot specify --preview with --abort"))
4858 raise error.Abort(_(b"cannot specify --preview with --abort"))
4859 if opts.get(b'rev') and node:
4859 if opts.get(b'rev') and node:
4860 raise error.Abort(_(b"please specify just one revision"))
4860 raise error.Abort(_(b"please specify just one revision"))
4861 if not node:
4861 if not node:
4862 node = opts.get(b'rev')
4862 node = opts.get(b'rev')
4863
4863
4864 if node:
4864 if node:
4865 node = scmutil.revsingle(repo, node).node()
4865 node = scmutil.revsingle(repo, node).node()
4866
4866
4867 if not node and not abort:
4867 if not node and not abort:
4868 node = repo[destutil.destmerge(repo)].node()
4868 node = repo[destutil.destmerge(repo)].node()
4869
4869
4870 if opts.get(b'preview'):
4870 if opts.get(b'preview'):
4871 # find nodes that are ancestors of p2 but not of p1
4871 # find nodes that are ancestors of p2 but not of p1
4872 p1 = repo.lookup(b'.')
4872 p1 = repo.lookup(b'.')
4873 p2 = node
4873 p2 = node
4874 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4874 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4875
4875
4876 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
4876 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
4877 for node in nodes:
4877 for node in nodes:
4878 displayer.show(repo[node])
4878 displayer.show(repo[node])
4879 displayer.close()
4879 displayer.close()
4880 return 0
4880 return 0
4881
4881
4882 # ui.forcemerge is an internal variable, do not document
4882 # ui.forcemerge is an internal variable, do not document
4883 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
4883 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
4884 with ui.configoverride(overrides, b'merge'):
4884 with ui.configoverride(overrides, b'merge'):
4885 force = opts.get(b'force')
4885 force = opts.get(b'force')
4886 labels = [b'working copy', b'merge rev']
4886 labels = [b'working copy', b'merge rev']
4887 return hg.merge(
4887 return hg.merge(
4888 repo,
4888 repo,
4889 node,
4889 node,
4890 force=force,
4890 force=force,
4891 mergeforce=force,
4891 mergeforce=force,
4892 labels=labels,
4892 labels=labels,
4893 abort=abort,
4893 abort=abort,
4894 )
4894 )
4895
4895
4896
4896
4897 statemod.addunfinished(
4897 statemod.addunfinished(
4898 b'merge',
4898 b'merge',
4899 fname=None,
4899 fname=None,
4900 clearable=True,
4900 clearable=True,
4901 allowcommit=True,
4901 allowcommit=True,
4902 cmdmsg=_(b'outstanding uncommitted merge'),
4902 cmdmsg=_(b'outstanding uncommitted merge'),
4903 abortfunc=hg.abortmerge,
4903 abortfunc=hg.abortmerge,
4904 statushint=_(
4904 statushint=_(
4905 b'To continue: hg commit\nTo abort: hg merge --abort'
4905 b'To continue: hg commit\nTo abort: hg merge --abort'
4906 ),
4906 ),
4907 cmdhint=_(b"use 'hg commit' or 'hg merge --abort'"),
4907 cmdhint=_(b"use 'hg commit' or 'hg merge --abort'"),
4908 )
4908 )
4909
4909
4910
4910
4911 @command(
4911 @command(
4912 b'outgoing|out',
4912 b'outgoing|out',
4913 [
4913 [
4914 (
4914 (
4915 b'f',
4915 b'f',
4916 b'force',
4916 b'force',
4917 None,
4917 None,
4918 _(b'run even when the destination is unrelated'),
4918 _(b'run even when the destination is unrelated'),
4919 ),
4919 ),
4920 (
4920 (
4921 b'r',
4921 b'r',
4922 b'rev',
4922 b'rev',
4923 [],
4923 [],
4924 _(b'a changeset intended to be included in the destination'),
4924 _(b'a changeset intended to be included in the destination'),
4925 _(b'REV'),
4925 _(b'REV'),
4926 ),
4926 ),
4927 (b'n', b'newest-first', None, _(b'show newest record first')),
4927 (b'n', b'newest-first', None, _(b'show newest record first')),
4928 (b'B', b'bookmarks', False, _(b'compare bookmarks')),
4928 (b'B', b'bookmarks', False, _(b'compare bookmarks')),
4929 (
4929 (
4930 b'b',
4930 b'b',
4931 b'branch',
4931 b'branch',
4932 [],
4932 [],
4933 _(b'a specific branch you would like to push'),
4933 _(b'a specific branch you would like to push'),
4934 _(b'BRANCH'),
4934 _(b'BRANCH'),
4935 ),
4935 ),
4936 ]
4936 ]
4937 + logopts
4937 + logopts
4938 + remoteopts
4938 + remoteopts
4939 + subrepoopts,
4939 + subrepoopts,
4940 _(b'[-M] [-p] [-n] [-f] [-r REV]... [DEST]'),
4940 _(b'[-M] [-p] [-n] [-f] [-r REV]... [DEST]'),
4941 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
4941 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
4942 )
4942 )
4943 def outgoing(ui, repo, dest=None, **opts):
4943 def outgoing(ui, repo, dest=None, **opts):
4944 """show changesets not found in the destination
4944 """show changesets not found in the destination
4945
4945
4946 Show changesets not found in the specified destination repository
4946 Show changesets not found in the specified destination repository
4947 or the default push location. These are the changesets that would
4947 or the default push location. These are the changesets that would
4948 be pushed if a push was requested.
4948 be pushed if a push was requested.
4949
4949
4950 See pull for details of valid destination formats.
4950 See pull for details of valid destination formats.
4951
4951
4952 .. container:: verbose
4952 .. container:: verbose
4953
4953
4954 With -B/--bookmarks, the result of bookmark comparison between
4954 With -B/--bookmarks, the result of bookmark comparison between
4955 local and remote repositories is displayed. With -v/--verbose,
4955 local and remote repositories is displayed. With -v/--verbose,
4956 status is also displayed for each bookmark like below::
4956 status is also displayed for each bookmark like below::
4957
4957
4958 BM1 01234567890a added
4958 BM1 01234567890a added
4959 BM2 deleted
4959 BM2 deleted
4960 BM3 234567890abc advanced
4960 BM3 234567890abc advanced
4961 BM4 34567890abcd diverged
4961 BM4 34567890abcd diverged
4962 BM5 4567890abcde changed
4962 BM5 4567890abcde changed
4963
4963
4964 The action taken when pushing depends on the
4964 The action taken when pushing depends on the
4965 status of each bookmark:
4965 status of each bookmark:
4966
4966
4967 :``added``: push with ``-B`` will create it
4967 :``added``: push with ``-B`` will create it
4968 :``deleted``: push with ``-B`` will delete it
4968 :``deleted``: push with ``-B`` will delete it
4969 :``advanced``: push will update it
4969 :``advanced``: push will update it
4970 :``diverged``: push with ``-B`` will update it
4970 :``diverged``: push with ``-B`` will update it
4971 :``changed``: push with ``-B`` will update it
4971 :``changed``: push with ``-B`` will update it
4972
4972
4973 From the point of view of pushing behavior, bookmarks
4973 From the point of view of pushing behavior, bookmarks
4974 existing only in the remote repository are treated as
4974 existing only in the remote repository are treated as
4975 ``deleted``, even if it is in fact added remotely.
4975 ``deleted``, even if it is in fact added remotely.
4976
4976
4977 Returns 0 if there are outgoing changes, 1 otherwise.
4977 Returns 0 if there are outgoing changes, 1 otherwise.
4978 """
4978 """
4979 # hg._outgoing() needs to re-resolve the path in order to handle #branch
4979 # hg._outgoing() needs to re-resolve the path in order to handle #branch
4980 # style URLs, so don't overwrite dest.
4980 # style URLs, so don't overwrite dest.
4981 path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
4981 path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
4982 if not path:
4982 if not path:
4983 raise error.Abort(
4983 raise error.Abort(
4984 _(b'default repository not configured!'),
4984 _(b'default repository not configured!'),
4985 hint=_(b"see 'hg help config.paths'"),
4985 hint=_(b"see 'hg help config.paths'"),
4986 )
4986 )
4987
4987
4988 opts = pycompat.byteskwargs(opts)
4988 opts = pycompat.byteskwargs(opts)
4989 if opts.get(b'graph'):
4989 if opts.get(b'graph'):
4990 logcmdutil.checkunsupportedgraphflags([], opts)
4990 logcmdutil.checkunsupportedgraphflags([], opts)
4991 o, other = hg._outgoing(ui, repo, dest, opts)
4991 o, other = hg._outgoing(ui, repo, dest, opts)
4992 if not o:
4992 if not o:
4993 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4993 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4994 return
4994 return
4995
4995
4996 revdag = logcmdutil.graphrevs(repo, o, opts)
4996 revdag = logcmdutil.graphrevs(repo, o, opts)
4997 ui.pager(b'outgoing')
4997 ui.pager(b'outgoing')
4998 displayer = logcmdutil.changesetdisplayer(ui, repo, opts, buffered=True)
4998 displayer = logcmdutil.changesetdisplayer(ui, repo, opts, buffered=True)
4999 logcmdutil.displaygraph(
4999 logcmdutil.displaygraph(
5000 ui, repo, revdag, displayer, graphmod.asciiedges
5000 ui, repo, revdag, displayer, graphmod.asciiedges
5001 )
5001 )
5002 cmdutil.outgoinghooks(ui, repo, other, opts, o)
5002 cmdutil.outgoinghooks(ui, repo, other, opts, o)
5003 return 0
5003 return 0
5004
5004
5005 if opts.get(b'bookmarks'):
5005 if opts.get(b'bookmarks'):
5006 dest = path.pushloc or path.loc
5006 dest = path.pushloc or path.loc
5007 other = hg.peer(repo, opts, dest)
5007 other = hg.peer(repo, opts, dest)
5008 if b'bookmarks' not in other.listkeys(b'namespaces'):
5008 if b'bookmarks' not in other.listkeys(b'namespaces'):
5009 ui.warn(_(b"remote doesn't support bookmarks\n"))
5009 ui.warn(_(b"remote doesn't support bookmarks\n"))
5010 return 0
5010 return 0
5011 ui.status(_(b'comparing with %s\n') % util.hidepassword(dest))
5011 ui.status(_(b'comparing with %s\n') % util.hidepassword(dest))
5012 ui.pager(b'outgoing')
5012 ui.pager(b'outgoing')
5013 return bookmarks.outgoing(ui, repo, other)
5013 return bookmarks.outgoing(ui, repo, other)
5014
5014
5015 repo._subtoppath = path.pushloc or path.loc
5015 repo._subtoppath = path.pushloc or path.loc
5016 try:
5016 try:
5017 return hg.outgoing(ui, repo, dest, opts)
5017 return hg.outgoing(ui, repo, dest, opts)
5018 finally:
5018 finally:
5019 del repo._subtoppath
5019 del repo._subtoppath
5020
5020
5021
5021
5022 @command(
5022 @command(
5023 b'parents',
5023 b'parents',
5024 [
5024 [
5025 (
5025 (
5026 b'r',
5026 b'r',
5027 b'rev',
5027 b'rev',
5028 b'',
5028 b'',
5029 _(b'show parents of the specified revision'),
5029 _(b'show parents of the specified revision'),
5030 _(b'REV'),
5030 _(b'REV'),
5031 ),
5031 ),
5032 ]
5032 ]
5033 + templateopts,
5033 + templateopts,
5034 _(b'[-r REV] [FILE]'),
5034 _(b'[-r REV] [FILE]'),
5035 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
5035 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
5036 inferrepo=True,
5036 inferrepo=True,
5037 )
5037 )
5038 def parents(ui, repo, file_=None, **opts):
5038 def parents(ui, repo, file_=None, **opts):
5039 """show the parents of the working directory or revision (DEPRECATED)
5039 """show the parents of the working directory or revision (DEPRECATED)
5040
5040
5041 Print the working directory's parent revisions. If a revision is
5041 Print the working directory's parent revisions. If a revision is
5042 given via -r/--rev, the parent of that revision will be printed.
5042 given via -r/--rev, the parent of that revision will be printed.
5043 If a file argument is given, the revision in which the file was
5043 If a file argument is given, the revision in which the file was
5044 last changed (before the working directory revision or the
5044 last changed (before the working directory revision or the
5045 argument to --rev if given) is printed.
5045 argument to --rev if given) is printed.
5046
5046
5047 This command is equivalent to::
5047 This command is equivalent to::
5048
5048
5049 hg log -r "p1()+p2()" or
5049 hg log -r "p1()+p2()" or
5050 hg log -r "p1(REV)+p2(REV)" or
5050 hg log -r "p1(REV)+p2(REV)" or
5051 hg log -r "max(::p1() and file(FILE))+max(::p2() and file(FILE))" or
5051 hg log -r "max(::p1() and file(FILE))+max(::p2() and file(FILE))" or
5052 hg log -r "max(::p1(REV) and file(FILE))+max(::p2(REV) and file(FILE))"
5052 hg log -r "max(::p1(REV) and file(FILE))+max(::p2(REV) and file(FILE))"
5053
5053
5054 See :hg:`summary` and :hg:`help revsets` for related information.
5054 See :hg:`summary` and :hg:`help revsets` for related information.
5055
5055
5056 Returns 0 on success.
5056 Returns 0 on success.
5057 """
5057 """
5058
5058
5059 opts = pycompat.byteskwargs(opts)
5059 opts = pycompat.byteskwargs(opts)
5060 rev = opts.get(b'rev')
5060 rev = opts.get(b'rev')
5061 if rev:
5061 if rev:
5062 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
5062 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
5063 ctx = scmutil.revsingle(repo, rev, None)
5063 ctx = scmutil.revsingle(repo, rev, None)
5064
5064
5065 if file_:
5065 if file_:
5066 m = scmutil.match(ctx, (file_,), opts)
5066 m = scmutil.match(ctx, (file_,), opts)
5067 if m.anypats() or len(m.files()) != 1:
5067 if m.anypats() or len(m.files()) != 1:
5068 raise error.Abort(_(b'can only specify an explicit filename'))
5068 raise error.Abort(_(b'can only specify an explicit filename'))
5069 file_ = m.files()[0]
5069 file_ = m.files()[0]
5070 filenodes = []
5070 filenodes = []
5071 for cp in ctx.parents():
5071 for cp in ctx.parents():
5072 if not cp:
5072 if not cp:
5073 continue
5073 continue
5074 try:
5074 try:
5075 filenodes.append(cp.filenode(file_))
5075 filenodes.append(cp.filenode(file_))
5076 except error.LookupError:
5076 except error.LookupError:
5077 pass
5077 pass
5078 if not filenodes:
5078 if not filenodes:
5079 raise error.Abort(_(b"'%s' not found in manifest!") % file_)
5079 raise error.Abort(_(b"'%s' not found in manifest!") % file_)
5080 p = []
5080 p = []
5081 for fn in filenodes:
5081 for fn in filenodes:
5082 fctx = repo.filectx(file_, fileid=fn)
5082 fctx = repo.filectx(file_, fileid=fn)
5083 p.append(fctx.node())
5083 p.append(fctx.node())
5084 else:
5084 else:
5085 p = [cp.node() for cp in ctx.parents()]
5085 p = [cp.node() for cp in ctx.parents()]
5086
5086
5087 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
5087 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
5088 for n in p:
5088 for n in p:
5089 if n != nullid:
5089 if n != nullid:
5090 displayer.show(repo[n])
5090 displayer.show(repo[n])
5091 displayer.close()
5091 displayer.close()
5092
5092
5093
5093
5094 @command(
5094 @command(
5095 b'paths',
5095 b'paths',
5096 formatteropts,
5096 formatteropts,
5097 _(b'[NAME]'),
5097 _(b'[NAME]'),
5098 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
5098 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
5099 optionalrepo=True,
5099 optionalrepo=True,
5100 intents={INTENT_READONLY},
5100 intents={INTENT_READONLY},
5101 )
5101 )
5102 def paths(ui, repo, search=None, **opts):
5102 def paths(ui, repo, search=None, **opts):
5103 """show aliases for remote repositories
5103 """show aliases for remote repositories
5104
5104
5105 Show definition of symbolic path name NAME. If no name is given,
5105 Show definition of symbolic path name NAME. If no name is given,
5106 show definition of all available names.
5106 show definition of all available names.
5107
5107
5108 Option -q/--quiet suppresses all output when searching for NAME
5108 Option -q/--quiet suppresses all output when searching for NAME
5109 and shows only the path names when listing all definitions.
5109 and shows only the path names when listing all definitions.
5110
5110
5111 Path names are defined in the [paths] section of your
5111 Path names are defined in the [paths] section of your
5112 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
5112 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
5113 repository, ``.hg/hgrc`` is used, too.
5113 repository, ``.hg/hgrc`` is used, too.
5114
5114
5115 The path names ``default`` and ``default-push`` have a special
5115 The path names ``default`` and ``default-push`` have a special
5116 meaning. When performing a push or pull operation, they are used
5116 meaning. When performing a push or pull operation, they are used
5117 as fallbacks if no location is specified on the command-line.
5117 as fallbacks if no location is specified on the command-line.
5118 When ``default-push`` is set, it will be used for push and
5118 When ``default-push`` is set, it will be used for push and
5119 ``default`` will be used for pull; otherwise ``default`` is used
5119 ``default`` will be used for pull; otherwise ``default`` is used
5120 as the fallback for both. When cloning a repository, the clone
5120 as the fallback for both. When cloning a repository, the clone
5121 source is written as ``default`` in ``.hg/hgrc``.
5121 source is written as ``default`` in ``.hg/hgrc``.
5122
5122
5123 .. note::
5123 .. note::
5124
5124
5125 ``default`` and ``default-push`` apply to all inbound (e.g.
5125 ``default`` and ``default-push`` apply to all inbound (e.g.
5126 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email`
5126 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email`
5127 and :hg:`bundle`) operations.
5127 and :hg:`bundle`) operations.
5128
5128
5129 See :hg:`help urls` for more information.
5129 See :hg:`help urls` for more information.
5130
5130
5131 .. container:: verbose
5131 .. container:: verbose
5132
5132
5133 Template:
5133 Template:
5134
5134
5135 The following keywords are supported. See also :hg:`help templates`.
5135 The following keywords are supported. See also :hg:`help templates`.
5136
5136
5137 :name: String. Symbolic name of the path alias.
5137 :name: String. Symbolic name of the path alias.
5138 :pushurl: String. URL for push operations.
5138 :pushurl: String. URL for push operations.
5139 :url: String. URL or directory path for the other operations.
5139 :url: String. URL or directory path for the other operations.
5140
5140
5141 Returns 0 on success.
5141 Returns 0 on success.
5142 """
5142 """
5143
5143
5144 opts = pycompat.byteskwargs(opts)
5144 opts = pycompat.byteskwargs(opts)
5145 ui.pager(b'paths')
5145 ui.pager(b'paths')
5146 if search:
5146 if search:
5147 pathitems = [
5147 pathitems = [
5148 (name, path)
5148 (name, path)
5149 for name, path in pycompat.iteritems(ui.paths)
5149 for name, path in pycompat.iteritems(ui.paths)
5150 if name == search
5150 if name == search
5151 ]
5151 ]
5152 else:
5152 else:
5153 pathitems = sorted(pycompat.iteritems(ui.paths))
5153 pathitems = sorted(pycompat.iteritems(ui.paths))
5154
5154
5155 fm = ui.formatter(b'paths', opts)
5155 fm = ui.formatter(b'paths', opts)
5156 if fm.isplain():
5156 if fm.isplain():
5157 hidepassword = util.hidepassword
5157 hidepassword = util.hidepassword
5158 else:
5158 else:
5159 hidepassword = bytes
5159 hidepassword = bytes
5160 if ui.quiet:
5160 if ui.quiet:
5161 namefmt = b'%s\n'
5161 namefmt = b'%s\n'
5162 else:
5162 else:
5163 namefmt = b'%s = '
5163 namefmt = b'%s = '
5164 showsubopts = not search and not ui.quiet
5164 showsubopts = not search and not ui.quiet
5165
5165
5166 for name, path in pathitems:
5166 for name, path in pathitems:
5167 fm.startitem()
5167 fm.startitem()
5168 fm.condwrite(not search, b'name', namefmt, name)
5168 fm.condwrite(not search, b'name', namefmt, name)
5169 fm.condwrite(not ui.quiet, b'url', b'%s\n', hidepassword(path.rawloc))
5169 fm.condwrite(not ui.quiet, b'url', b'%s\n', hidepassword(path.rawloc))
5170 for subopt, value in sorted(path.suboptions.items()):
5170 for subopt, value in sorted(path.suboptions.items()):
5171 assert subopt not in (b'name', b'url')
5171 assert subopt not in (b'name', b'url')
5172 if showsubopts:
5172 if showsubopts:
5173 fm.plain(b'%s:%s = ' % (name, subopt))
5173 fm.plain(b'%s:%s = ' % (name, subopt))
5174 fm.condwrite(showsubopts, subopt, b'%s\n', value)
5174 fm.condwrite(showsubopts, subopt, b'%s\n', value)
5175
5175
5176 fm.end()
5176 fm.end()
5177
5177
5178 if search and not pathitems:
5178 if search and not pathitems:
5179 if not ui.quiet:
5179 if not ui.quiet:
5180 ui.warn(_(b"not found!\n"))
5180 ui.warn(_(b"not found!\n"))
5181 return 1
5181 return 1
5182 else:
5182 else:
5183 return 0
5183 return 0
5184
5184
5185
5185
5186 @command(
5186 @command(
5187 b'phase',
5187 b'phase',
5188 [
5188 [
5189 (b'p', b'public', False, _(b'set changeset phase to public')),
5189 (b'p', b'public', False, _(b'set changeset phase to public')),
5190 (b'd', b'draft', False, _(b'set changeset phase to draft')),
5190 (b'd', b'draft', False, _(b'set changeset phase to draft')),
5191 (b's', b'secret', False, _(b'set changeset phase to secret')),
5191 (b's', b'secret', False, _(b'set changeset phase to secret')),
5192 (b'f', b'force', False, _(b'allow to move boundary backward')),
5192 (b'f', b'force', False, _(b'allow to move boundary backward')),
5193 (b'r', b'rev', [], _(b'target revision'), _(b'REV')),
5193 (b'r', b'rev', [], _(b'target revision'), _(b'REV')),
5194 ],
5194 ],
5195 _(b'[-p|-d|-s] [-f] [-r] [REV...]'),
5195 _(b'[-p|-d|-s] [-f] [-r] [REV...]'),
5196 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
5196 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
5197 )
5197 )
5198 def phase(ui, repo, *revs, **opts):
5198 def phase(ui, repo, *revs, **opts):
5199 """set or show the current phase name
5199 """set or show the current phase name
5200
5200
5201 With no argument, show the phase name of the current revision(s).
5201 With no argument, show the phase name of the current revision(s).
5202
5202
5203 With one of -p/--public, -d/--draft or -s/--secret, change the
5203 With one of -p/--public, -d/--draft or -s/--secret, change the
5204 phase value of the specified revisions.
5204 phase value of the specified revisions.
5205
5205
5206 Unless -f/--force is specified, :hg:`phase` won't move changesets from a
5206 Unless -f/--force is specified, :hg:`phase` won't move changesets from a
5207 lower phase to a higher phase. Phases are ordered as follows::
5207 lower phase to a higher phase. Phases are ordered as follows::
5208
5208
5209 public < draft < secret
5209 public < draft < secret
5210
5210
5211 Returns 0 on success, 1 if some phases could not be changed.
5211 Returns 0 on success, 1 if some phases could not be changed.
5212
5212
5213 (For more information about the phases concept, see :hg:`help phases`.)
5213 (For more information about the phases concept, see :hg:`help phases`.)
5214 """
5214 """
5215 opts = pycompat.byteskwargs(opts)
5215 opts = pycompat.byteskwargs(opts)
5216 # search for a unique phase argument
5216 # search for a unique phase argument
5217 targetphase = None
5217 targetphase = None
5218 for idx, name in enumerate(phases.cmdphasenames):
5218 for idx, name in enumerate(phases.cmdphasenames):
5219 if opts[name]:
5219 if opts[name]:
5220 if targetphase is not None:
5220 if targetphase is not None:
5221 raise error.Abort(_(b'only one phase can be specified'))
5221 raise error.Abort(_(b'only one phase can be specified'))
5222 targetphase = idx
5222 targetphase = idx
5223
5223
5224 # look for specified revision
5224 # look for specified revision
5225 revs = list(revs)
5225 revs = list(revs)
5226 revs.extend(opts[b'rev'])
5226 revs.extend(opts[b'rev'])
5227 if not revs:
5227 if not revs:
5228 # display both parents as the second parent phase can influence
5228 # display both parents as the second parent phase can influence
5229 # the phase of a merge commit
5229 # the phase of a merge commit
5230 revs = [c.rev() for c in repo[None].parents()]
5230 revs = [c.rev() for c in repo[None].parents()]
5231
5231
5232 revs = scmutil.revrange(repo, revs)
5232 revs = scmutil.revrange(repo, revs)
5233
5233
5234 ret = 0
5234 ret = 0
5235 if targetphase is None:
5235 if targetphase is None:
5236 # display
5236 # display
5237 for r in revs:
5237 for r in revs:
5238 ctx = repo[r]
5238 ctx = repo[r]
5239 ui.write(b'%i: %s\n' % (ctx.rev(), ctx.phasestr()))
5239 ui.write(b'%i: %s\n' % (ctx.rev(), ctx.phasestr()))
5240 else:
5240 else:
5241 with repo.lock(), repo.transaction(b"phase") as tr:
5241 with repo.lock(), repo.transaction(b"phase") as tr:
5242 # set phase
5242 # set phase
5243 if not revs:
5243 if not revs:
5244 raise error.Abort(_(b'empty revision set'))
5244 raise error.Abort(_(b'empty revision set'))
5245 nodes = [repo[r].node() for r in revs]
5245 nodes = [repo[r].node() for r in revs]
5246 # moving revision from public to draft may hide them
5246 # moving revision from public to draft may hide them
5247 # We have to check result on an unfiltered repository
5247 # We have to check result on an unfiltered repository
5248 unfi = repo.unfiltered()
5248 unfi = repo.unfiltered()
5249 getphase = unfi._phasecache.phase
5249 getphase = unfi._phasecache.phase
5250 olddata = [getphase(unfi, r) for r in unfi]
5250 olddata = [getphase(unfi, r) for r in unfi]
5251 phases.advanceboundary(repo, tr, targetphase, nodes)
5251 phases.advanceboundary(repo, tr, targetphase, nodes)
5252 if opts[b'force']:
5252 if opts[b'force']:
5253 phases.retractboundary(repo, tr, targetphase, nodes)
5253 phases.retractboundary(repo, tr, targetphase, nodes)
5254 getphase = unfi._phasecache.phase
5254 getphase = unfi._phasecache.phase
5255 newdata = [getphase(unfi, r) for r in unfi]
5255 newdata = [getphase(unfi, r) for r in unfi]
5256 changes = sum(newdata[r] != olddata[r] for r in unfi)
5256 changes = sum(newdata[r] != olddata[r] for r in unfi)
5257 cl = unfi.changelog
5257 cl = unfi.changelog
5258 rejected = [n for n in nodes if newdata[cl.rev(n)] < targetphase]
5258 rejected = [n for n in nodes if newdata[cl.rev(n)] < targetphase]
5259 if rejected:
5259 if rejected:
5260 ui.warn(
5260 ui.warn(
5261 _(
5261 _(
5262 b'cannot move %i changesets to a higher '
5262 b'cannot move %i changesets to a higher '
5263 b'phase, use --force\n'
5263 b'phase, use --force\n'
5264 )
5264 )
5265 % len(rejected)
5265 % len(rejected)
5266 )
5266 )
5267 ret = 1
5267 ret = 1
5268 if changes:
5268 if changes:
5269 msg = _(b'phase changed for %i changesets\n') % changes
5269 msg = _(b'phase changed for %i changesets\n') % changes
5270 if ret:
5270 if ret:
5271 ui.status(msg)
5271 ui.status(msg)
5272 else:
5272 else:
5273 ui.note(msg)
5273 ui.note(msg)
5274 else:
5274 else:
5275 ui.warn(_(b'no phases changed\n'))
5275 ui.warn(_(b'no phases changed\n'))
5276 return ret
5276 return ret
5277
5277
5278
5278
5279 def postincoming(ui, repo, modheads, optupdate, checkout, brev):
5279 def postincoming(ui, repo, modheads, optupdate, checkout, brev):
5280 """Run after a changegroup has been added via pull/unbundle
5280 """Run after a changegroup has been added via pull/unbundle
5281
5281
5282 This takes arguments below:
5282 This takes arguments below:
5283
5283
5284 :modheads: change of heads by pull/unbundle
5284 :modheads: change of heads by pull/unbundle
5285 :optupdate: updating working directory is needed or not
5285 :optupdate: updating working directory is needed or not
5286 :checkout: update destination revision (or None to default destination)
5286 :checkout: update destination revision (or None to default destination)
5287 :brev: a name, which might be a bookmark to be activated after updating
5287 :brev: a name, which might be a bookmark to be activated after updating
5288 """
5288 """
5289 if modheads == 0:
5289 if modheads == 0:
5290 return
5290 return
5291 if optupdate:
5291 if optupdate:
5292 try:
5292 try:
5293 return hg.updatetotally(ui, repo, checkout, brev)
5293 return hg.updatetotally(ui, repo, checkout, brev)
5294 except error.UpdateAbort as inst:
5294 except error.UpdateAbort as inst:
5295 msg = _(b"not updating: %s") % stringutil.forcebytestr(inst)
5295 msg = _(b"not updating: %s") % stringutil.forcebytestr(inst)
5296 hint = inst.hint
5296 hint = inst.hint
5297 raise error.UpdateAbort(msg, hint=hint)
5297 raise error.UpdateAbort(msg, hint=hint)
5298 if modheads is not None and modheads > 1:
5298 if modheads is not None and modheads > 1:
5299 currentbranchheads = len(repo.branchheads())
5299 currentbranchheads = len(repo.branchheads())
5300 if currentbranchheads == modheads:
5300 if currentbranchheads == modheads:
5301 ui.status(
5301 ui.status(
5302 _(b"(run 'hg heads' to see heads, 'hg merge' to merge)\n")
5302 _(b"(run 'hg heads' to see heads, 'hg merge' to merge)\n")
5303 )
5303 )
5304 elif currentbranchheads > 1:
5304 elif currentbranchheads > 1:
5305 ui.status(
5305 ui.status(
5306 _(b"(run 'hg heads .' to see heads, 'hg merge' to merge)\n")
5306 _(b"(run 'hg heads .' to see heads, 'hg merge' to merge)\n")
5307 )
5307 )
5308 else:
5308 else:
5309 ui.status(_(b"(run 'hg heads' to see heads)\n"))
5309 ui.status(_(b"(run 'hg heads' to see heads)\n"))
5310 elif not ui.configbool(b'commands', b'update.requiredest'):
5310 elif not ui.configbool(b'commands', b'update.requiredest'):
5311 ui.status(_(b"(run 'hg update' to get a working copy)\n"))
5311 ui.status(_(b"(run 'hg update' to get a working copy)\n"))
5312
5312
5313
5313
5314 @command(
5314 @command(
5315 b'pull',
5315 b'pull',
5316 [
5316 [
5317 (
5317 (
5318 b'u',
5318 b'u',
5319 b'update',
5319 b'update',
5320 None,
5320 None,
5321 _(b'update to new branch head if new descendants were pulled'),
5321 _(b'update to new branch head if new descendants were pulled'),
5322 ),
5322 ),
5323 (
5323 (
5324 b'f',
5324 b'f',
5325 b'force',
5325 b'force',
5326 None,
5326 None,
5327 _(b'run even when remote repository is unrelated'),
5327 _(b'run even when remote repository is unrelated'),
5328 ),
5328 ),
5329 (
5329 (
5330 b'r',
5330 b'r',
5331 b'rev',
5331 b'rev',
5332 [],
5332 [],
5333 _(b'a remote changeset intended to be added'),
5333 _(b'a remote changeset intended to be added'),
5334 _(b'REV'),
5334 _(b'REV'),
5335 ),
5335 ),
5336 (b'B', b'bookmark', [], _(b"bookmark to pull"), _(b'BOOKMARK')),
5336 (b'B', b'bookmark', [], _(b"bookmark to pull"), _(b'BOOKMARK')),
5337 (
5337 (
5338 b'b',
5338 b'b',
5339 b'branch',
5339 b'branch',
5340 [],
5340 [],
5341 _(b'a specific branch you would like to pull'),
5341 _(b'a specific branch you would like to pull'),
5342 _(b'BRANCH'),
5342 _(b'BRANCH'),
5343 ),
5343 ),
5344 ]
5344 ]
5345 + remoteopts,
5345 + remoteopts,
5346 _(b'[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'),
5346 _(b'[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'),
5347 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
5347 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
5348 helpbasic=True,
5348 helpbasic=True,
5349 )
5349 )
5350 def pull(ui, repo, source=b"default", **opts):
5350 def pull(ui, repo, source=b"default", **opts):
5351 """pull changes from the specified source
5351 """pull changes from the specified source
5352
5352
5353 Pull changes from a remote repository to a local one.
5353 Pull changes from a remote repository to a local one.
5354
5354
5355 This finds all changes from the repository at the specified path
5355 This finds all changes from the repository at the specified path
5356 or URL and adds them to a local repository (the current one unless
5356 or URL and adds them to a local repository (the current one unless
5357 -R is specified). By default, this does not update the copy of the
5357 -R is specified). By default, this does not update the copy of the
5358 project in the working directory.
5358 project in the working directory.
5359
5359
5360 When cloning from servers that support it, Mercurial may fetch
5360 When cloning from servers that support it, Mercurial may fetch
5361 pre-generated data. When this is done, hooks operating on incoming
5361 pre-generated data. When this is done, hooks operating on incoming
5362 changesets and changegroups may fire more than once, once for each
5362 changesets and changegroups may fire more than once, once for each
5363 pre-generated bundle and as well as for any additional remaining
5363 pre-generated bundle and as well as for any additional remaining
5364 data. See :hg:`help -e clonebundles` for more.
5364 data. See :hg:`help -e clonebundles` for more.
5365
5365
5366 Use :hg:`incoming` if you want to see what would have been added
5366 Use :hg:`incoming` if you want to see what would have been added
5367 by a pull at the time you issued this command. If you then decide
5367 by a pull at the time you issued this command. If you then decide
5368 to add those changes to the repository, you should use :hg:`pull
5368 to add those changes to the repository, you should use :hg:`pull
5369 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
5369 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
5370
5370
5371 If SOURCE is omitted, the 'default' path will be used.
5371 If SOURCE is omitted, the 'default' path will be used.
5372 See :hg:`help urls` for more information.
5372 See :hg:`help urls` for more information.
5373
5373
5374 Specifying bookmark as ``.`` is equivalent to specifying the active
5374 Specifying bookmark as ``.`` is equivalent to specifying the active
5375 bookmark's name.
5375 bookmark's name.
5376
5376
5377 Returns 0 on success, 1 if an update had unresolved files.
5377 Returns 0 on success, 1 if an update had unresolved files.
5378 """
5378 """
5379
5379
5380 opts = pycompat.byteskwargs(opts)
5380 opts = pycompat.byteskwargs(opts)
5381 if ui.configbool(b'commands', b'update.requiredest') and opts.get(
5381 if ui.configbool(b'commands', b'update.requiredest') and opts.get(
5382 b'update'
5382 b'update'
5383 ):
5383 ):
5384 msg = _(b'update destination required by configuration')
5384 msg = _(b'update destination required by configuration')
5385 hint = _(b'use hg pull followed by hg update DEST')
5385 hint = _(b'use hg pull followed by hg update DEST')
5386 raise error.Abort(msg, hint=hint)
5386 raise error.Abort(msg, hint=hint)
5387
5387
5388 source, branches = hg.parseurl(ui.expandpath(source), opts.get(b'branch'))
5388 source, branches = hg.parseurl(ui.expandpath(source), opts.get(b'branch'))
5389 ui.status(_(b'pulling from %s\n') % util.hidepassword(source))
5389 ui.status(_(b'pulling from %s\n') % util.hidepassword(source))
5390 other = hg.peer(repo, opts, source)
5390 other = hg.peer(repo, opts, source)
5391 try:
5391 try:
5392 revs, checkout = hg.addbranchrevs(
5392 revs, checkout = hg.addbranchrevs(
5393 repo, other, branches, opts.get(b'rev')
5393 repo, other, branches, opts.get(b'rev')
5394 )
5394 )
5395
5395
5396 pullopargs = {}
5396 pullopargs = {}
5397
5397
5398 nodes = None
5398 nodes = None
5399 if opts.get(b'bookmark') or revs:
5399 if opts.get(b'bookmark') or revs:
5400 # The list of bookmark used here is the same used to actually update
5400 # The list of bookmark used here is the same used to actually update
5401 # the bookmark names, to avoid the race from issue 4689 and we do
5401 # the bookmark names, to avoid the race from issue 4689 and we do
5402 # all lookup and bookmark queries in one go so they see the same
5402 # all lookup and bookmark queries in one go so they see the same
5403 # version of the server state (issue 4700).
5403 # version of the server state (issue 4700).
5404 nodes = []
5404 nodes = []
5405 fnodes = []
5405 fnodes = []
5406 revs = revs or []
5406 revs = revs or []
5407 if revs and not other.capable(b'lookup'):
5407 if revs and not other.capable(b'lookup'):
5408 err = _(
5408 err = _(
5409 b"other repository doesn't support revision lookup, "
5409 b"other repository doesn't support revision lookup, "
5410 b"so a rev cannot be specified."
5410 b"so a rev cannot be specified."
5411 )
5411 )
5412 raise error.Abort(err)
5412 raise error.Abort(err)
5413 with other.commandexecutor() as e:
5413 with other.commandexecutor() as e:
5414 fremotebookmarks = e.callcommand(
5414 fremotebookmarks = e.callcommand(
5415 b'listkeys', {b'namespace': b'bookmarks'}
5415 b'listkeys', {b'namespace': b'bookmarks'}
5416 )
5416 )
5417 for r in revs:
5417 for r in revs:
5418 fnodes.append(e.callcommand(b'lookup', {b'key': r}))
5418 fnodes.append(e.callcommand(b'lookup', {b'key': r}))
5419 remotebookmarks = fremotebookmarks.result()
5419 remotebookmarks = fremotebookmarks.result()
5420 remotebookmarks = bookmarks.unhexlifybookmarks(remotebookmarks)
5420 remotebookmarks = bookmarks.unhexlifybookmarks(remotebookmarks)
5421 pullopargs[b'remotebookmarks'] = remotebookmarks
5421 pullopargs[b'remotebookmarks'] = remotebookmarks
5422 for b in opts.get(b'bookmark', []):
5422 for b in opts.get(b'bookmark', []):
5423 b = repo._bookmarks.expandname(b)
5423 b = repo._bookmarks.expandname(b)
5424 if b not in remotebookmarks:
5424 if b not in remotebookmarks:
5425 raise error.Abort(_(b'remote bookmark %s not found!') % b)
5425 raise error.Abort(_(b'remote bookmark %s not found!') % b)
5426 nodes.append(remotebookmarks[b])
5426 nodes.append(remotebookmarks[b])
5427 for i, rev in enumerate(revs):
5427 for i, rev in enumerate(revs):
5428 node = fnodes[i].result()
5428 node = fnodes[i].result()
5429 nodes.append(node)
5429 nodes.append(node)
5430 if rev == checkout:
5430 if rev == checkout:
5431 checkout = node
5431 checkout = node
5432
5432
5433 wlock = util.nullcontextmanager()
5433 wlock = util.nullcontextmanager()
5434 if opts.get(b'update'):
5434 if opts.get(b'update'):
5435 wlock = repo.wlock()
5435 wlock = repo.wlock()
5436 with wlock:
5436 with wlock:
5437 pullopargs.update(opts.get(b'opargs', {}))
5437 pullopargs.update(opts.get(b'opargs', {}))
5438 modheads = exchange.pull(
5438 modheads = exchange.pull(
5439 repo,
5439 repo,
5440 other,
5440 other,
5441 heads=nodes,
5441 heads=nodes,
5442 force=opts.get(b'force'),
5442 force=opts.get(b'force'),
5443 bookmarks=opts.get(b'bookmark', ()),
5443 bookmarks=opts.get(b'bookmark', ()),
5444 opargs=pullopargs,
5444 opargs=pullopargs,
5445 ).cgresult
5445 ).cgresult
5446
5446
5447 # brev is a name, which might be a bookmark to be activated at
5447 # brev is a name, which might be a bookmark to be activated at
5448 # the end of the update. In other words, it is an explicit
5448 # the end of the update. In other words, it is an explicit
5449 # destination of the update
5449 # destination of the update
5450 brev = None
5450 brev = None
5451
5451
5452 if checkout:
5452 if checkout:
5453 checkout = repo.unfiltered().changelog.rev(checkout)
5453 checkout = repo.unfiltered().changelog.rev(checkout)
5454
5454
5455 # order below depends on implementation of
5455 # order below depends on implementation of
5456 # hg.addbranchrevs(). opts['bookmark'] is ignored,
5456 # hg.addbranchrevs(). opts['bookmark'] is ignored,
5457 # because 'checkout' is determined without it.
5457 # because 'checkout' is determined without it.
5458 if opts.get(b'rev'):
5458 if opts.get(b'rev'):
5459 brev = opts[b'rev'][0]
5459 brev = opts[b'rev'][0]
5460 elif opts.get(b'branch'):
5460 elif opts.get(b'branch'):
5461 brev = opts[b'branch'][0]
5461 brev = opts[b'branch'][0]
5462 else:
5462 else:
5463 brev = branches[0]
5463 brev = branches[0]
5464 repo._subtoppath = source
5464 repo._subtoppath = source
5465 try:
5465 try:
5466 ret = postincoming(
5466 ret = postincoming(
5467 ui, repo, modheads, opts.get(b'update'), checkout, brev
5467 ui, repo, modheads, opts.get(b'update'), checkout, brev
5468 )
5468 )
5469 except error.FilteredRepoLookupError as exc:
5469 except error.FilteredRepoLookupError as exc:
5470 msg = _(b'cannot update to target: %s') % exc.args[0]
5470 msg = _(b'cannot update to target: %s') % exc.args[0]
5471 exc.args = (msg,) + exc.args[1:]
5471 exc.args = (msg,) + exc.args[1:]
5472 raise
5472 raise
5473 finally:
5473 finally:
5474 del repo._subtoppath
5474 del repo._subtoppath
5475
5475
5476 finally:
5476 finally:
5477 other.close()
5477 other.close()
5478 return ret
5478 return ret
5479
5479
5480
5480
5481 @command(
5481 @command(
5482 b'push',
5482 b'push',
5483 [
5483 [
5484 (b'f', b'force', None, _(b'force push')),
5484 (b'f', b'force', None, _(b'force push')),
5485 (
5485 (
5486 b'r',
5486 b'r',
5487 b'rev',
5487 b'rev',
5488 [],
5488 [],
5489 _(b'a changeset intended to be included in the destination'),
5489 _(b'a changeset intended to be included in the destination'),
5490 _(b'REV'),
5490 _(b'REV'),
5491 ),
5491 ),
5492 (b'B', b'bookmark', [], _(b"bookmark to push"), _(b'BOOKMARK')),
5492 (b'B', b'bookmark', [], _(b"bookmark to push"), _(b'BOOKMARK')),
5493 (
5493 (
5494 b'b',
5494 b'b',
5495 b'branch',
5495 b'branch',
5496 [],
5496 [],
5497 _(b'a specific branch you would like to push'),
5497 _(b'a specific branch you would like to push'),
5498 _(b'BRANCH'),
5498 _(b'BRANCH'),
5499 ),
5499 ),
5500 (b'', b'new-branch', False, _(b'allow pushing a new branch')),
5500 (b'', b'new-branch', False, _(b'allow pushing a new branch')),
5501 (
5501 (
5502 b'',
5502 b'',
5503 b'pushvars',
5503 b'pushvars',
5504 [],
5504 [],
5505 _(b'variables that can be sent to server (ADVANCED)'),
5505 _(b'variables that can be sent to server (ADVANCED)'),
5506 ),
5506 ),
5507 (
5507 (
5508 b'',
5508 b'',
5509 b'publish',
5509 b'publish',
5510 False,
5510 False,
5511 _(b'push the changeset as public (EXPERIMENTAL)'),
5511 _(b'push the changeset as public (EXPERIMENTAL)'),
5512 ),
5512 ),
5513 ]
5513 ]
5514 + remoteopts,
5514 + remoteopts,
5515 _(b'[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'),
5515 _(b'[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'),
5516 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
5516 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
5517 helpbasic=True,
5517 helpbasic=True,
5518 )
5518 )
5519 def push(ui, repo, dest=None, **opts):
5519 def push(ui, repo, dest=None, **opts):
5520 """push changes to the specified destination
5520 """push changes to the specified destination
5521
5521
5522 Push changesets from the local repository to the specified
5522 Push changesets from the local repository to the specified
5523 destination.
5523 destination.
5524
5524
5525 This operation is symmetrical to pull: it is identical to a pull
5525 This operation is symmetrical to pull: it is identical to a pull
5526 in the destination repository from the current one.
5526 in the destination repository from the current one.
5527
5527
5528 By default, push will not allow creation of new heads at the
5528 By default, push will not allow creation of new heads at the
5529 destination, since multiple heads would make it unclear which head
5529 destination, since multiple heads would make it unclear which head
5530 to use. In this situation, it is recommended to pull and merge
5530 to use. In this situation, it is recommended to pull and merge
5531 before pushing.
5531 before pushing.
5532
5532
5533 Use --new-branch if you want to allow push to create a new named
5533 Use --new-branch if you want to allow push to create a new named
5534 branch that is not present at the destination. This allows you to
5534 branch that is not present at the destination. This allows you to
5535 only create a new branch without forcing other changes.
5535 only create a new branch without forcing other changes.
5536
5536
5537 .. note::
5537 .. note::
5538
5538
5539 Extra care should be taken with the -f/--force option,
5539 Extra care should be taken with the -f/--force option,
5540 which will push all new heads on all branches, an action which will
5540 which will push all new heads on all branches, an action which will
5541 almost always cause confusion for collaborators.
5541 almost always cause confusion for collaborators.
5542
5542
5543 If -r/--rev is used, the specified revision and all its ancestors
5543 If -r/--rev is used, the specified revision and all its ancestors
5544 will be pushed to the remote repository.
5544 will be pushed to the remote repository.
5545
5545
5546 If -B/--bookmark is used, the specified bookmarked revision, its
5546 If -B/--bookmark is used, the specified bookmarked revision, its
5547 ancestors, and the bookmark will be pushed to the remote
5547 ancestors, and the bookmark will be pushed to the remote
5548 repository. Specifying ``.`` is equivalent to specifying the active
5548 repository. Specifying ``.`` is equivalent to specifying the active
5549 bookmark's name.
5549 bookmark's name.
5550
5550
5551 Please see :hg:`help urls` for important details about ``ssh://``
5551 Please see :hg:`help urls` for important details about ``ssh://``
5552 URLs. If DESTINATION is omitted, a default path will be used.
5552 URLs. If DESTINATION is omitted, a default path will be used.
5553
5553
5554 .. container:: verbose
5554 .. container:: verbose
5555
5555
5556 The --pushvars option sends strings to the server that become
5556 The --pushvars option sends strings to the server that become
5557 environment variables prepended with ``HG_USERVAR_``. For example,
5557 environment variables prepended with ``HG_USERVAR_``. For example,
5558 ``--pushvars ENABLE_FEATURE=true``, provides the server side hooks with
5558 ``--pushvars ENABLE_FEATURE=true``, provides the server side hooks with
5559 ``HG_USERVAR_ENABLE_FEATURE=true`` as part of their environment.
5559 ``HG_USERVAR_ENABLE_FEATURE=true`` as part of their environment.
5560
5560
5561 pushvars can provide for user-overridable hooks as well as set debug
5561 pushvars can provide for user-overridable hooks as well as set debug
5562 levels. One example is having a hook that blocks commits containing
5562 levels. One example is having a hook that blocks commits containing
5563 conflict markers, but enables the user to override the hook if the file
5563 conflict markers, but enables the user to override the hook if the file
5564 is using conflict markers for testing purposes or the file format has
5564 is using conflict markers for testing purposes or the file format has
5565 strings that look like conflict markers.
5565 strings that look like conflict markers.
5566
5566
5567 By default, servers will ignore `--pushvars`. To enable it add the
5567 By default, servers will ignore `--pushvars`. To enable it add the
5568 following to your configuration file::
5568 following to your configuration file::
5569
5569
5570 [push]
5570 [push]
5571 pushvars.server = true
5571 pushvars.server = true
5572
5572
5573 Returns 0 if push was successful, 1 if nothing to push.
5573 Returns 0 if push was successful, 1 if nothing to push.
5574 """
5574 """
5575
5575
5576 opts = pycompat.byteskwargs(opts)
5576 opts = pycompat.byteskwargs(opts)
5577 if opts.get(b'bookmark'):
5577 if opts.get(b'bookmark'):
5578 ui.setconfig(b'bookmarks', b'pushing', opts[b'bookmark'], b'push')
5578 ui.setconfig(b'bookmarks', b'pushing', opts[b'bookmark'], b'push')
5579 for b in opts[b'bookmark']:
5579 for b in opts[b'bookmark']:
5580 # translate -B options to -r so changesets get pushed
5580 # translate -B options to -r so changesets get pushed
5581 b = repo._bookmarks.expandname(b)
5581 b = repo._bookmarks.expandname(b)
5582 if b in repo._bookmarks:
5582 if b in repo._bookmarks:
5583 opts.setdefault(b'rev', []).append(b)
5583 opts.setdefault(b'rev', []).append(b)
5584 else:
5584 else:
5585 # if we try to push a deleted bookmark, translate it to null
5585 # if we try to push a deleted bookmark, translate it to null
5586 # this lets simultaneous -r, -b options continue working
5586 # this lets simultaneous -r, -b options continue working
5587 opts.setdefault(b'rev', []).append(b"null")
5587 opts.setdefault(b'rev', []).append(b"null")
5588
5588
5589 path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
5589 path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
5590 if not path:
5590 if not path:
5591 raise error.Abort(
5591 raise error.Abort(
5592 _(b'default repository not configured!'),
5592 _(b'default repository not configured!'),
5593 hint=_(b"see 'hg help config.paths'"),
5593 hint=_(b"see 'hg help config.paths'"),
5594 )
5594 )
5595 dest = path.pushloc or path.loc
5595 dest = path.pushloc or path.loc
5596 branches = (path.branch, opts.get(b'branch') or [])
5596 branches = (path.branch, opts.get(b'branch') or [])
5597 ui.status(_(b'pushing to %s\n') % util.hidepassword(dest))
5597 ui.status(_(b'pushing to %s\n') % util.hidepassword(dest))
5598 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get(b'rev'))
5598 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get(b'rev'))
5599 other = hg.peer(repo, opts, dest)
5599 other = hg.peer(repo, opts, dest)
5600
5600
5601 if revs:
5601 if revs:
5602 revs = [repo[r].node() for r in scmutil.revrange(repo, revs)]
5602 revs = [repo[r].node() for r in scmutil.revrange(repo, revs)]
5603 if not revs:
5603 if not revs:
5604 raise error.Abort(
5604 raise error.Abort(
5605 _(b"specified revisions evaluate to an empty set"),
5605 _(b"specified revisions evaluate to an empty set"),
5606 hint=_(b"use different revision arguments"),
5606 hint=_(b"use different revision arguments"),
5607 )
5607 )
5608 elif path.pushrev:
5608 elif path.pushrev:
5609 # It doesn't make any sense to specify ancestor revisions. So limit
5609 # It doesn't make any sense to specify ancestor revisions. So limit
5610 # to DAG heads to make discovery simpler.
5610 # to DAG heads to make discovery simpler.
5611 expr = revsetlang.formatspec(b'heads(%r)', path.pushrev)
5611 expr = revsetlang.formatspec(b'heads(%r)', path.pushrev)
5612 revs = scmutil.revrange(repo, [expr])
5612 revs = scmutil.revrange(repo, [expr])
5613 revs = [repo[rev].node() for rev in revs]
5613 revs = [repo[rev].node() for rev in revs]
5614 if not revs:
5614 if not revs:
5615 raise error.Abort(
5615 raise error.Abort(
5616 _(b'default push revset for path evaluates to an empty set')
5616 _(b'default push revset for path evaluates to an empty set')
5617 )
5617 )
5618 elif ui.configbool(b'commands', b'push.require-revs'):
5619 raise error.Abort(_(b'no revisions specified to push'),
5620 hint=_(b'did you mean "hg push -r ."?'))
5618
5621
5619 repo._subtoppath = dest
5622 repo._subtoppath = dest
5620 try:
5623 try:
5621 # push subrepos depth-first for coherent ordering
5624 # push subrepos depth-first for coherent ordering
5622 c = repo[b'.']
5625 c = repo[b'.']
5623 subs = c.substate # only repos that are committed
5626 subs = c.substate # only repos that are committed
5624 for s in sorted(subs):
5627 for s in sorted(subs):
5625 result = c.sub(s).push(opts)
5628 result = c.sub(s).push(opts)
5626 if result == 0:
5629 if result == 0:
5627 return not result
5630 return not result
5628 finally:
5631 finally:
5629 del repo._subtoppath
5632 del repo._subtoppath
5630
5633
5631 opargs = dict(opts.get(b'opargs', {})) # copy opargs since we may mutate it
5634 opargs = dict(opts.get(b'opargs', {})) # copy opargs since we may mutate it
5632 opargs.setdefault(b'pushvars', []).extend(opts.get(b'pushvars', []))
5635 opargs.setdefault(b'pushvars', []).extend(opts.get(b'pushvars', []))
5633
5636
5634 pushop = exchange.push(
5637 pushop = exchange.push(
5635 repo,
5638 repo,
5636 other,
5639 other,
5637 opts.get(b'force'),
5640 opts.get(b'force'),
5638 revs=revs,
5641 revs=revs,
5639 newbranch=opts.get(b'new_branch'),
5642 newbranch=opts.get(b'new_branch'),
5640 bookmarks=opts.get(b'bookmark', ()),
5643 bookmarks=opts.get(b'bookmark', ()),
5641 publish=opts.get(b'publish'),
5644 publish=opts.get(b'publish'),
5642 opargs=opargs,
5645 opargs=opargs,
5643 )
5646 )
5644
5647
5645 result = not pushop.cgresult
5648 result = not pushop.cgresult
5646
5649
5647 if pushop.bkresult is not None:
5650 if pushop.bkresult is not None:
5648 if pushop.bkresult == 2:
5651 if pushop.bkresult == 2:
5649 result = 2
5652 result = 2
5650 elif not result and pushop.bkresult:
5653 elif not result and pushop.bkresult:
5651 result = 2
5654 result = 2
5652
5655
5653 return result
5656 return result
5654
5657
5655
5658
5656 @command(
5659 @command(
5657 b'recover',
5660 b'recover',
5658 [(b'', b'verify', True, b"run `hg verify` after succesful recover"),],
5661 [(b'', b'verify', True, b"run `hg verify` after succesful recover"),],
5659 helpcategory=command.CATEGORY_MAINTENANCE,
5662 helpcategory=command.CATEGORY_MAINTENANCE,
5660 )
5663 )
5661 def recover(ui, repo, **opts):
5664 def recover(ui, repo, **opts):
5662 """roll back an interrupted transaction
5665 """roll back an interrupted transaction
5663
5666
5664 Recover from an interrupted commit or pull.
5667 Recover from an interrupted commit or pull.
5665
5668
5666 This command tries to fix the repository status after an
5669 This command tries to fix the repository status after an
5667 interrupted operation. It should only be necessary when Mercurial
5670 interrupted operation. It should only be necessary when Mercurial
5668 suggests it.
5671 suggests it.
5669
5672
5670 Returns 0 if successful, 1 if nothing to recover or verify fails.
5673 Returns 0 if successful, 1 if nothing to recover or verify fails.
5671 """
5674 """
5672 ret = repo.recover()
5675 ret = repo.recover()
5673 if ret:
5676 if ret:
5674 if opts[r'verify']:
5677 if opts[r'verify']:
5675 return hg.verify(repo)
5678 return hg.verify(repo)
5676 else:
5679 else:
5677 msg = _(
5680 msg = _(
5678 b"(verify step skipped, run `hg verify` to check your "
5681 b"(verify step skipped, run `hg verify` to check your "
5679 b"repository content)\n"
5682 b"repository content)\n"
5680 )
5683 )
5681 ui.warn(msg)
5684 ui.warn(msg)
5682 return 0
5685 return 0
5683 return 1
5686 return 1
5684
5687
5685
5688
5686 @command(
5689 @command(
5687 b'remove|rm',
5690 b'remove|rm',
5688 [
5691 [
5689 (b'A', b'after', None, _(b'record delete for missing files')),
5692 (b'A', b'after', None, _(b'record delete for missing files')),
5690 (b'f', b'force', None, _(b'forget added files, delete modified files')),
5693 (b'f', b'force', None, _(b'forget added files, delete modified files')),
5691 ]
5694 ]
5692 + subrepoopts
5695 + subrepoopts
5693 + walkopts
5696 + walkopts
5694 + dryrunopts,
5697 + dryrunopts,
5695 _(b'[OPTION]... FILE...'),
5698 _(b'[OPTION]... FILE...'),
5696 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
5699 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
5697 helpbasic=True,
5700 helpbasic=True,
5698 inferrepo=True,
5701 inferrepo=True,
5699 )
5702 )
5700 def remove(ui, repo, *pats, **opts):
5703 def remove(ui, repo, *pats, **opts):
5701 """remove the specified files on the next commit
5704 """remove the specified files on the next commit
5702
5705
5703 Schedule the indicated files for removal from the current branch.
5706 Schedule the indicated files for removal from the current branch.
5704
5707
5705 This command schedules the files to be removed at the next commit.
5708 This command schedules the files to be removed at the next commit.
5706 To undo a remove before that, see :hg:`revert`. To undo added
5709 To undo a remove before that, see :hg:`revert`. To undo added
5707 files, see :hg:`forget`.
5710 files, see :hg:`forget`.
5708
5711
5709 .. container:: verbose
5712 .. container:: verbose
5710
5713
5711 -A/--after can be used to remove only files that have already
5714 -A/--after can be used to remove only files that have already
5712 been deleted, -f/--force can be used to force deletion, and -Af
5715 been deleted, -f/--force can be used to force deletion, and -Af
5713 can be used to remove files from the next revision without
5716 can be used to remove files from the next revision without
5714 deleting them from the working directory.
5717 deleting them from the working directory.
5715
5718
5716 The following table details the behavior of remove for different
5719 The following table details the behavior of remove for different
5717 file states (columns) and option combinations (rows). The file
5720 file states (columns) and option combinations (rows). The file
5718 states are Added [A], Clean [C], Modified [M] and Missing [!]
5721 states are Added [A], Clean [C], Modified [M] and Missing [!]
5719 (as reported by :hg:`status`). The actions are Warn, Remove
5722 (as reported by :hg:`status`). The actions are Warn, Remove
5720 (from branch) and Delete (from disk):
5723 (from branch) and Delete (from disk):
5721
5724
5722 ========= == == == ==
5725 ========= == == == ==
5723 opt/state A C M !
5726 opt/state A C M !
5724 ========= == == == ==
5727 ========= == == == ==
5725 none W RD W R
5728 none W RD W R
5726 -f R RD RD R
5729 -f R RD RD R
5727 -A W W W R
5730 -A W W W R
5728 -Af R R R R
5731 -Af R R R R
5729 ========= == == == ==
5732 ========= == == == ==
5730
5733
5731 .. note::
5734 .. note::
5732
5735
5733 :hg:`remove` never deletes files in Added [A] state from the
5736 :hg:`remove` never deletes files in Added [A] state from the
5734 working directory, not even if ``--force`` is specified.
5737 working directory, not even if ``--force`` is specified.
5735
5738
5736 Returns 0 on success, 1 if any warnings encountered.
5739 Returns 0 on success, 1 if any warnings encountered.
5737 """
5740 """
5738
5741
5739 opts = pycompat.byteskwargs(opts)
5742 opts = pycompat.byteskwargs(opts)
5740 after, force = opts.get(b'after'), opts.get(b'force')
5743 after, force = opts.get(b'after'), opts.get(b'force')
5741 dryrun = opts.get(b'dry_run')
5744 dryrun = opts.get(b'dry_run')
5742 if not pats and not after:
5745 if not pats and not after:
5743 raise error.Abort(_(b'no files specified'))
5746 raise error.Abort(_(b'no files specified'))
5744
5747
5745 m = scmutil.match(repo[None], pats, opts)
5748 m = scmutil.match(repo[None], pats, opts)
5746 subrepos = opts.get(b'subrepos')
5749 subrepos = opts.get(b'subrepos')
5747 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
5750 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
5748 return cmdutil.remove(
5751 return cmdutil.remove(
5749 ui, repo, m, b"", uipathfn, after, force, subrepos, dryrun=dryrun
5752 ui, repo, m, b"", uipathfn, after, force, subrepos, dryrun=dryrun
5750 )
5753 )
5751
5754
5752
5755
5753 @command(
5756 @command(
5754 b'rename|move|mv',
5757 b'rename|move|mv',
5755 [
5758 [
5756 (b'A', b'after', None, _(b'record a rename that has already occurred')),
5759 (b'A', b'after', None, _(b'record a rename that has already occurred')),
5757 (
5760 (
5758 b'f',
5761 b'f',
5759 b'force',
5762 b'force',
5760 None,
5763 None,
5761 _(b'forcibly move over an existing managed file'),
5764 _(b'forcibly move over an existing managed file'),
5762 ),
5765 ),
5763 ]
5766 ]
5764 + walkopts
5767 + walkopts
5765 + dryrunopts,
5768 + dryrunopts,
5766 _(b'[OPTION]... SOURCE... DEST'),
5769 _(b'[OPTION]... SOURCE... DEST'),
5767 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
5770 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
5768 )
5771 )
5769 def rename(ui, repo, *pats, **opts):
5772 def rename(ui, repo, *pats, **opts):
5770 """rename files; equivalent of copy + remove
5773 """rename files; equivalent of copy + remove
5771
5774
5772 Mark dest as copies of sources; mark sources for deletion. If dest
5775 Mark dest as copies of sources; mark sources for deletion. If dest
5773 is a directory, copies are put in that directory. If dest is a
5776 is a directory, copies are put in that directory. If dest is a
5774 file, there can only be one source.
5777 file, there can only be one source.
5775
5778
5776 By default, this command copies the contents of files as they
5779 By default, this command copies the contents of files as they
5777 exist in the working directory. If invoked with -A/--after, the
5780 exist in the working directory. If invoked with -A/--after, the
5778 operation is recorded, but no copying is performed.
5781 operation is recorded, but no copying is performed.
5779
5782
5780 This command takes effect at the next commit. To undo a rename
5783 This command takes effect at the next commit. To undo a rename
5781 before that, see :hg:`revert`.
5784 before that, see :hg:`revert`.
5782
5785
5783 Returns 0 on success, 1 if errors are encountered.
5786 Returns 0 on success, 1 if errors are encountered.
5784 """
5787 """
5785 opts = pycompat.byteskwargs(opts)
5788 opts = pycompat.byteskwargs(opts)
5786 with repo.wlock(False):
5789 with repo.wlock(False):
5787 return cmdutil.copy(ui, repo, pats, opts, rename=True)
5790 return cmdutil.copy(ui, repo, pats, opts, rename=True)
5788
5791
5789
5792
5790 @command(
5793 @command(
5791 b'resolve',
5794 b'resolve',
5792 [
5795 [
5793 (b'a', b'all', None, _(b'select all unresolved files')),
5796 (b'a', b'all', None, _(b'select all unresolved files')),
5794 (b'l', b'list', None, _(b'list state of files needing merge')),
5797 (b'l', b'list', None, _(b'list state of files needing merge')),
5795 (b'm', b'mark', None, _(b'mark files as resolved')),
5798 (b'm', b'mark', None, _(b'mark files as resolved')),
5796 (b'u', b'unmark', None, _(b'mark files as unresolved')),
5799 (b'u', b'unmark', None, _(b'mark files as unresolved')),
5797 (b'n', b'no-status', None, _(b'hide status prefix')),
5800 (b'n', b'no-status', None, _(b'hide status prefix')),
5798 (b'', b're-merge', None, _(b're-merge files')),
5801 (b'', b're-merge', None, _(b're-merge files')),
5799 ]
5802 ]
5800 + mergetoolopts
5803 + mergetoolopts
5801 + walkopts
5804 + walkopts
5802 + formatteropts,
5805 + formatteropts,
5803 _(b'[OPTION]... [FILE]...'),
5806 _(b'[OPTION]... [FILE]...'),
5804 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
5807 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
5805 inferrepo=True,
5808 inferrepo=True,
5806 )
5809 )
5807 def resolve(ui, repo, *pats, **opts):
5810 def resolve(ui, repo, *pats, **opts):
5808 """redo merges or set/view the merge status of files
5811 """redo merges or set/view the merge status of files
5809
5812
5810 Merges with unresolved conflicts are often the result of
5813 Merges with unresolved conflicts are often the result of
5811 non-interactive merging using the ``internal:merge`` configuration
5814 non-interactive merging using the ``internal:merge`` configuration
5812 setting, or a command-line merge tool like ``diff3``. The resolve
5815 setting, or a command-line merge tool like ``diff3``. The resolve
5813 command is used to manage the files involved in a merge, after
5816 command is used to manage the files involved in a merge, after
5814 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
5817 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
5815 working directory must have two parents). See :hg:`help
5818 working directory must have two parents). See :hg:`help
5816 merge-tools` for information on configuring merge tools.
5819 merge-tools` for information on configuring merge tools.
5817
5820
5818 The resolve command can be used in the following ways:
5821 The resolve command can be used in the following ways:
5819
5822
5820 - :hg:`resolve [--re-merge] [--tool TOOL] FILE...`: attempt to re-merge
5823 - :hg:`resolve [--re-merge] [--tool TOOL] FILE...`: attempt to re-merge
5821 the specified files, discarding any previous merge attempts. Re-merging
5824 the specified files, discarding any previous merge attempts. Re-merging
5822 is not performed for files already marked as resolved. Use ``--all/-a``
5825 is not performed for files already marked as resolved. Use ``--all/-a``
5823 to select all unresolved files. ``--tool`` can be used to specify
5826 to select all unresolved files. ``--tool`` can be used to specify
5824 the merge tool used for the given files. It overrides the HGMERGE
5827 the merge tool used for the given files. It overrides the HGMERGE
5825 environment variable and your configuration files. Previous file
5828 environment variable and your configuration files. Previous file
5826 contents are saved with a ``.orig`` suffix.
5829 contents are saved with a ``.orig`` suffix.
5827
5830
5828 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
5831 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
5829 (e.g. after having manually fixed-up the files). The default is
5832 (e.g. after having manually fixed-up the files). The default is
5830 to mark all unresolved files.
5833 to mark all unresolved files.
5831
5834
5832 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
5835 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
5833 default is to mark all resolved files.
5836 default is to mark all resolved files.
5834
5837
5835 - :hg:`resolve -l`: list files which had or still have conflicts.
5838 - :hg:`resolve -l`: list files which had or still have conflicts.
5836 In the printed list, ``U`` = unresolved and ``R`` = resolved.
5839 In the printed list, ``U`` = unresolved and ``R`` = resolved.
5837 You can use ``set:unresolved()`` or ``set:resolved()`` to filter
5840 You can use ``set:unresolved()`` or ``set:resolved()`` to filter
5838 the list. See :hg:`help filesets` for details.
5841 the list. See :hg:`help filesets` for details.
5839
5842
5840 .. note::
5843 .. note::
5841
5844
5842 Mercurial will not let you commit files with unresolved merge
5845 Mercurial will not let you commit files with unresolved merge
5843 conflicts. You must use :hg:`resolve -m ...` before you can
5846 conflicts. You must use :hg:`resolve -m ...` before you can
5844 commit after a conflicting merge.
5847 commit after a conflicting merge.
5845
5848
5846 .. container:: verbose
5849 .. container:: verbose
5847
5850
5848 Template:
5851 Template:
5849
5852
5850 The following keywords are supported in addition to the common template
5853 The following keywords are supported in addition to the common template
5851 keywords and functions. See also :hg:`help templates`.
5854 keywords and functions. See also :hg:`help templates`.
5852
5855
5853 :mergestatus: String. Character denoting merge conflicts, ``U`` or ``R``.
5856 :mergestatus: String. Character denoting merge conflicts, ``U`` or ``R``.
5854 :path: String. Repository-absolute path of the file.
5857 :path: String. Repository-absolute path of the file.
5855
5858
5856 Returns 0 on success, 1 if any files fail a resolve attempt.
5859 Returns 0 on success, 1 if any files fail a resolve attempt.
5857 """
5860 """
5858
5861
5859 opts = pycompat.byteskwargs(opts)
5862 opts = pycompat.byteskwargs(opts)
5860 confirm = ui.configbool(b'commands', b'resolve.confirm')
5863 confirm = ui.configbool(b'commands', b'resolve.confirm')
5861 flaglist = b'all mark unmark list no_status re_merge'.split()
5864 flaglist = b'all mark unmark list no_status re_merge'.split()
5862 all, mark, unmark, show, nostatus, remerge = [opts.get(o) for o in flaglist]
5865 all, mark, unmark, show, nostatus, remerge = [opts.get(o) for o in flaglist]
5863
5866
5864 actioncount = len(list(filter(None, [show, mark, unmark, remerge])))
5867 actioncount = len(list(filter(None, [show, mark, unmark, remerge])))
5865 if actioncount > 1:
5868 if actioncount > 1:
5866 raise error.Abort(_(b"too many actions specified"))
5869 raise error.Abort(_(b"too many actions specified"))
5867 elif actioncount == 0 and ui.configbool(
5870 elif actioncount == 0 and ui.configbool(
5868 b'commands', b'resolve.explicit-re-merge'
5871 b'commands', b'resolve.explicit-re-merge'
5869 ):
5872 ):
5870 hint = _(b'use --mark, --unmark, --list or --re-merge')
5873 hint = _(b'use --mark, --unmark, --list or --re-merge')
5871 raise error.Abort(_(b'no action specified'), hint=hint)
5874 raise error.Abort(_(b'no action specified'), hint=hint)
5872 if pats and all:
5875 if pats and all:
5873 raise error.Abort(_(b"can't specify --all and patterns"))
5876 raise error.Abort(_(b"can't specify --all and patterns"))
5874 if not (all or pats or show or mark or unmark):
5877 if not (all or pats or show or mark or unmark):
5875 raise error.Abort(
5878 raise error.Abort(
5876 _(b'no files or directories specified'),
5879 _(b'no files or directories specified'),
5877 hint=b'use --all to re-merge all unresolved files',
5880 hint=b'use --all to re-merge all unresolved files',
5878 )
5881 )
5879
5882
5880 if confirm:
5883 if confirm:
5881 if all:
5884 if all:
5882 if ui.promptchoice(
5885 if ui.promptchoice(
5883 _(b're-merge all unresolved files (yn)?$$ &Yes $$ &No')
5886 _(b're-merge all unresolved files (yn)?$$ &Yes $$ &No')
5884 ):
5887 ):
5885 raise error.Abort(_(b'user quit'))
5888 raise error.Abort(_(b'user quit'))
5886 if mark and not pats:
5889 if mark and not pats:
5887 if ui.promptchoice(
5890 if ui.promptchoice(
5888 _(
5891 _(
5889 b'mark all unresolved files as resolved (yn)?'
5892 b'mark all unresolved files as resolved (yn)?'
5890 b'$$ &Yes $$ &No'
5893 b'$$ &Yes $$ &No'
5891 )
5894 )
5892 ):
5895 ):
5893 raise error.Abort(_(b'user quit'))
5896 raise error.Abort(_(b'user quit'))
5894 if unmark and not pats:
5897 if unmark and not pats:
5895 if ui.promptchoice(
5898 if ui.promptchoice(
5896 _(
5899 _(
5897 b'mark all resolved files as unresolved (yn)?'
5900 b'mark all resolved files as unresolved (yn)?'
5898 b'$$ &Yes $$ &No'
5901 b'$$ &Yes $$ &No'
5899 )
5902 )
5900 ):
5903 ):
5901 raise error.Abort(_(b'user quit'))
5904 raise error.Abort(_(b'user quit'))
5902
5905
5903 uipathfn = scmutil.getuipathfn(repo)
5906 uipathfn = scmutil.getuipathfn(repo)
5904
5907
5905 if show:
5908 if show:
5906 ui.pager(b'resolve')
5909 ui.pager(b'resolve')
5907 fm = ui.formatter(b'resolve', opts)
5910 fm = ui.formatter(b'resolve', opts)
5908 ms = mergemod.mergestate.read(repo)
5911 ms = mergemod.mergestate.read(repo)
5909 wctx = repo[None]
5912 wctx = repo[None]
5910 m = scmutil.match(wctx, pats, opts)
5913 m = scmutil.match(wctx, pats, opts)
5911
5914
5912 # Labels and keys based on merge state. Unresolved path conflicts show
5915 # Labels and keys based on merge state. Unresolved path conflicts show
5913 # as 'P'. Resolved path conflicts show as 'R', the same as normal
5916 # as 'P'. Resolved path conflicts show as 'R', the same as normal
5914 # resolved conflicts.
5917 # resolved conflicts.
5915 mergestateinfo = {
5918 mergestateinfo = {
5916 mergemod.MERGE_RECORD_UNRESOLVED: (b'resolve.unresolved', b'U'),
5919 mergemod.MERGE_RECORD_UNRESOLVED: (b'resolve.unresolved', b'U'),
5917 mergemod.MERGE_RECORD_RESOLVED: (b'resolve.resolved', b'R'),
5920 mergemod.MERGE_RECORD_RESOLVED: (b'resolve.resolved', b'R'),
5918 mergemod.MERGE_RECORD_UNRESOLVED_PATH: (
5921 mergemod.MERGE_RECORD_UNRESOLVED_PATH: (
5919 b'resolve.unresolved',
5922 b'resolve.unresolved',
5920 b'P',
5923 b'P',
5921 ),
5924 ),
5922 mergemod.MERGE_RECORD_RESOLVED_PATH: (b'resolve.resolved', b'R'),
5925 mergemod.MERGE_RECORD_RESOLVED_PATH: (b'resolve.resolved', b'R'),
5923 mergemod.MERGE_RECORD_DRIVER_RESOLVED: (
5926 mergemod.MERGE_RECORD_DRIVER_RESOLVED: (
5924 b'resolve.driverresolved',
5927 b'resolve.driverresolved',
5925 b'D',
5928 b'D',
5926 ),
5929 ),
5927 }
5930 }
5928
5931
5929 for f in ms:
5932 for f in ms:
5930 if not m(f):
5933 if not m(f):
5931 continue
5934 continue
5932
5935
5933 label, key = mergestateinfo[ms[f]]
5936 label, key = mergestateinfo[ms[f]]
5934 fm.startitem()
5937 fm.startitem()
5935 fm.context(ctx=wctx)
5938 fm.context(ctx=wctx)
5936 fm.condwrite(not nostatus, b'mergestatus', b'%s ', key, label=label)
5939 fm.condwrite(not nostatus, b'mergestatus', b'%s ', key, label=label)
5937 fm.data(path=f)
5940 fm.data(path=f)
5938 fm.plain(b'%s\n' % uipathfn(f), label=label)
5941 fm.plain(b'%s\n' % uipathfn(f), label=label)
5939 fm.end()
5942 fm.end()
5940 return 0
5943 return 0
5941
5944
5942 with repo.wlock():
5945 with repo.wlock():
5943 ms = mergemod.mergestate.read(repo)
5946 ms = mergemod.mergestate.read(repo)
5944
5947
5945 if not (ms.active() or repo.dirstate.p2() != nullid):
5948 if not (ms.active() or repo.dirstate.p2() != nullid):
5946 raise error.Abort(
5949 raise error.Abort(
5947 _(b'resolve command not applicable when not merging')
5950 _(b'resolve command not applicable when not merging')
5948 )
5951 )
5949
5952
5950 wctx = repo[None]
5953 wctx = repo[None]
5951
5954
5952 if (
5955 if (
5953 ms.mergedriver
5956 ms.mergedriver
5954 and ms.mdstate() == mergemod.MERGE_DRIVER_STATE_UNMARKED
5957 and ms.mdstate() == mergemod.MERGE_DRIVER_STATE_UNMARKED
5955 ):
5958 ):
5956 proceed = mergemod.driverpreprocess(repo, ms, wctx)
5959 proceed = mergemod.driverpreprocess(repo, ms, wctx)
5957 ms.commit()
5960 ms.commit()
5958 # allow mark and unmark to go through
5961 # allow mark and unmark to go through
5959 if not mark and not unmark and not proceed:
5962 if not mark and not unmark and not proceed:
5960 return 1
5963 return 1
5961
5964
5962 m = scmutil.match(wctx, pats, opts)
5965 m = scmutil.match(wctx, pats, opts)
5963 ret = 0
5966 ret = 0
5964 didwork = False
5967 didwork = False
5965 runconclude = False
5968 runconclude = False
5966
5969
5967 tocomplete = []
5970 tocomplete = []
5968 hasconflictmarkers = []
5971 hasconflictmarkers = []
5969 if mark:
5972 if mark:
5970 markcheck = ui.config(b'commands', b'resolve.mark-check')
5973 markcheck = ui.config(b'commands', b'resolve.mark-check')
5971 if markcheck not in [b'warn', b'abort']:
5974 if markcheck not in [b'warn', b'abort']:
5972 # Treat all invalid / unrecognized values as 'none'.
5975 # Treat all invalid / unrecognized values as 'none'.
5973 markcheck = False
5976 markcheck = False
5974 for f in ms:
5977 for f in ms:
5975 if not m(f):
5978 if not m(f):
5976 continue
5979 continue
5977
5980
5978 didwork = True
5981 didwork = True
5979
5982
5980 # don't let driver-resolved files be marked, and run the conclude
5983 # don't let driver-resolved files be marked, and run the conclude
5981 # step if asked to resolve
5984 # step if asked to resolve
5982 if ms[f] == mergemod.MERGE_RECORD_DRIVER_RESOLVED:
5985 if ms[f] == mergemod.MERGE_RECORD_DRIVER_RESOLVED:
5983 exact = m.exact(f)
5986 exact = m.exact(f)
5984 if mark:
5987 if mark:
5985 if exact:
5988 if exact:
5986 ui.warn(
5989 ui.warn(
5987 _(b'not marking %s as it is driver-resolved\n')
5990 _(b'not marking %s as it is driver-resolved\n')
5988 % uipathfn(f)
5991 % uipathfn(f)
5989 )
5992 )
5990 elif unmark:
5993 elif unmark:
5991 if exact:
5994 if exact:
5992 ui.warn(
5995 ui.warn(
5993 _(b'not unmarking %s as it is driver-resolved\n')
5996 _(b'not unmarking %s as it is driver-resolved\n')
5994 % uipathfn(f)
5997 % uipathfn(f)
5995 )
5998 )
5996 else:
5999 else:
5997 runconclude = True
6000 runconclude = True
5998 continue
6001 continue
5999
6002
6000 # path conflicts must be resolved manually
6003 # path conflicts must be resolved manually
6001 if ms[f] in (
6004 if ms[f] in (
6002 mergemod.MERGE_RECORD_UNRESOLVED_PATH,
6005 mergemod.MERGE_RECORD_UNRESOLVED_PATH,
6003 mergemod.MERGE_RECORD_RESOLVED_PATH,
6006 mergemod.MERGE_RECORD_RESOLVED_PATH,
6004 ):
6007 ):
6005 if mark:
6008 if mark:
6006 ms.mark(f, mergemod.MERGE_RECORD_RESOLVED_PATH)
6009 ms.mark(f, mergemod.MERGE_RECORD_RESOLVED_PATH)
6007 elif unmark:
6010 elif unmark:
6008 ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED_PATH)
6011 ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED_PATH)
6009 elif ms[f] == mergemod.MERGE_RECORD_UNRESOLVED_PATH:
6012 elif ms[f] == mergemod.MERGE_RECORD_UNRESOLVED_PATH:
6010 ui.warn(
6013 ui.warn(
6011 _(b'%s: path conflict must be resolved manually\n')
6014 _(b'%s: path conflict must be resolved manually\n')
6012 % uipathfn(f)
6015 % uipathfn(f)
6013 )
6016 )
6014 continue
6017 continue
6015
6018
6016 if mark:
6019 if mark:
6017 if markcheck:
6020 if markcheck:
6018 fdata = repo.wvfs.tryread(f)
6021 fdata = repo.wvfs.tryread(f)
6019 if (
6022 if (
6020 filemerge.hasconflictmarkers(fdata)
6023 filemerge.hasconflictmarkers(fdata)
6021 and ms[f] != mergemod.MERGE_RECORD_RESOLVED
6024 and ms[f] != mergemod.MERGE_RECORD_RESOLVED
6022 ):
6025 ):
6023 hasconflictmarkers.append(f)
6026 hasconflictmarkers.append(f)
6024 ms.mark(f, mergemod.MERGE_RECORD_RESOLVED)
6027 ms.mark(f, mergemod.MERGE_RECORD_RESOLVED)
6025 elif unmark:
6028 elif unmark:
6026 ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED)
6029 ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED)
6027 else:
6030 else:
6028 # backup pre-resolve (merge uses .orig for its own purposes)
6031 # backup pre-resolve (merge uses .orig for its own purposes)
6029 a = repo.wjoin(f)
6032 a = repo.wjoin(f)
6030 try:
6033 try:
6031 util.copyfile(a, a + b".resolve")
6034 util.copyfile(a, a + b".resolve")
6032 except (IOError, OSError) as inst:
6035 except (IOError, OSError) as inst:
6033 if inst.errno != errno.ENOENT:
6036 if inst.errno != errno.ENOENT:
6034 raise
6037 raise
6035
6038
6036 try:
6039 try:
6037 # preresolve file
6040 # preresolve file
6038 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
6041 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
6039 with ui.configoverride(overrides, b'resolve'):
6042 with ui.configoverride(overrides, b'resolve'):
6040 complete, r = ms.preresolve(f, wctx)
6043 complete, r = ms.preresolve(f, wctx)
6041 if not complete:
6044 if not complete:
6042 tocomplete.append(f)
6045 tocomplete.append(f)
6043 elif r:
6046 elif r:
6044 ret = 1
6047 ret = 1
6045 finally:
6048 finally:
6046 ms.commit()
6049 ms.commit()
6047
6050
6048 # replace filemerge's .orig file with our resolve file, but only
6051 # replace filemerge's .orig file with our resolve file, but only
6049 # for merges that are complete
6052 # for merges that are complete
6050 if complete:
6053 if complete:
6051 try:
6054 try:
6052 util.rename(
6055 util.rename(
6053 a + b".resolve", scmutil.backuppath(ui, repo, f)
6056 a + b".resolve", scmutil.backuppath(ui, repo, f)
6054 )
6057 )
6055 except OSError as inst:
6058 except OSError as inst:
6056 if inst.errno != errno.ENOENT:
6059 if inst.errno != errno.ENOENT:
6057 raise
6060 raise
6058
6061
6059 if hasconflictmarkers:
6062 if hasconflictmarkers:
6060 ui.warn(
6063 ui.warn(
6061 _(
6064 _(
6062 b'warning: the following files still have conflict '
6065 b'warning: the following files still have conflict '
6063 b'markers:\n'
6066 b'markers:\n'
6064 )
6067 )
6065 + b''.join(
6068 + b''.join(
6066 b' ' + uipathfn(f) + b'\n' for f in hasconflictmarkers
6069 b' ' + uipathfn(f) + b'\n' for f in hasconflictmarkers
6067 )
6070 )
6068 )
6071 )
6069 if markcheck == b'abort' and not all and not pats:
6072 if markcheck == b'abort' and not all and not pats:
6070 raise error.Abort(
6073 raise error.Abort(
6071 _(b'conflict markers detected'),
6074 _(b'conflict markers detected'),
6072 hint=_(b'use --all to mark anyway'),
6075 hint=_(b'use --all to mark anyway'),
6073 )
6076 )
6074
6077
6075 for f in tocomplete:
6078 for f in tocomplete:
6076 try:
6079 try:
6077 # resolve file
6080 # resolve file
6078 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
6081 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
6079 with ui.configoverride(overrides, b'resolve'):
6082 with ui.configoverride(overrides, b'resolve'):
6080 r = ms.resolve(f, wctx)
6083 r = ms.resolve(f, wctx)
6081 if r:
6084 if r:
6082 ret = 1
6085 ret = 1
6083 finally:
6086 finally:
6084 ms.commit()
6087 ms.commit()
6085
6088
6086 # replace filemerge's .orig file with our resolve file
6089 # replace filemerge's .orig file with our resolve file
6087 a = repo.wjoin(f)
6090 a = repo.wjoin(f)
6088 try:
6091 try:
6089 util.rename(a + b".resolve", scmutil.backuppath(ui, repo, f))
6092 util.rename(a + b".resolve", scmutil.backuppath(ui, repo, f))
6090 except OSError as inst:
6093 except OSError as inst:
6091 if inst.errno != errno.ENOENT:
6094 if inst.errno != errno.ENOENT:
6092 raise
6095 raise
6093
6096
6094 ms.commit()
6097 ms.commit()
6095 ms.recordactions()
6098 ms.recordactions()
6096
6099
6097 if not didwork and pats:
6100 if not didwork and pats:
6098 hint = None
6101 hint = None
6099 if not any([p for p in pats if p.find(b':') >= 0]):
6102 if not any([p for p in pats if p.find(b':') >= 0]):
6100 pats = [b'path:%s' % p for p in pats]
6103 pats = [b'path:%s' % p for p in pats]
6101 m = scmutil.match(wctx, pats, opts)
6104 m = scmutil.match(wctx, pats, opts)
6102 for f in ms:
6105 for f in ms:
6103 if not m(f):
6106 if not m(f):
6104 continue
6107 continue
6105
6108
6106 def flag(o):
6109 def flag(o):
6107 if o == b're_merge':
6110 if o == b're_merge':
6108 return b'--re-merge '
6111 return b'--re-merge '
6109 return b'-%s ' % o[0:1]
6112 return b'-%s ' % o[0:1]
6110
6113
6111 flags = b''.join([flag(o) for o in flaglist if opts.get(o)])
6114 flags = b''.join([flag(o) for o in flaglist if opts.get(o)])
6112 hint = _(b"(try: hg resolve %s%s)\n") % (
6115 hint = _(b"(try: hg resolve %s%s)\n") % (
6113 flags,
6116 flags,
6114 b' '.join(pats),
6117 b' '.join(pats),
6115 )
6118 )
6116 break
6119 break
6117 ui.warn(_(b"arguments do not match paths that need resolving\n"))
6120 ui.warn(_(b"arguments do not match paths that need resolving\n"))
6118 if hint:
6121 if hint:
6119 ui.warn(hint)
6122 ui.warn(hint)
6120 elif ms.mergedriver and ms.mdstate() != b's':
6123 elif ms.mergedriver and ms.mdstate() != b's':
6121 # run conclude step when either a driver-resolved file is requested
6124 # run conclude step when either a driver-resolved file is requested
6122 # or there are no driver-resolved files
6125 # or there are no driver-resolved files
6123 # we can't use 'ret' to determine whether any files are unresolved
6126 # we can't use 'ret' to determine whether any files are unresolved
6124 # because we might not have tried to resolve some
6127 # because we might not have tried to resolve some
6125 if (runconclude or not list(ms.driverresolved())) and not list(
6128 if (runconclude or not list(ms.driverresolved())) and not list(
6126 ms.unresolved()
6129 ms.unresolved()
6127 ):
6130 ):
6128 proceed = mergemod.driverconclude(repo, ms, wctx)
6131 proceed = mergemod.driverconclude(repo, ms, wctx)
6129 ms.commit()
6132 ms.commit()
6130 if not proceed:
6133 if not proceed:
6131 return 1
6134 return 1
6132
6135
6133 # Nudge users into finishing an unfinished operation
6136 # Nudge users into finishing an unfinished operation
6134 unresolvedf = list(ms.unresolved())
6137 unresolvedf = list(ms.unresolved())
6135 driverresolvedf = list(ms.driverresolved())
6138 driverresolvedf = list(ms.driverresolved())
6136 if not unresolvedf and not driverresolvedf:
6139 if not unresolvedf and not driverresolvedf:
6137 ui.status(_(b'(no more unresolved files)\n'))
6140 ui.status(_(b'(no more unresolved files)\n'))
6138 cmdutil.checkafterresolved(repo)
6141 cmdutil.checkafterresolved(repo)
6139 elif not unresolvedf:
6142 elif not unresolvedf:
6140 ui.status(
6143 ui.status(
6141 _(
6144 _(
6142 b'(no more unresolved files -- '
6145 b'(no more unresolved files -- '
6143 b'run "hg resolve --all" to conclude)\n'
6146 b'run "hg resolve --all" to conclude)\n'
6144 )
6147 )
6145 )
6148 )
6146
6149
6147 return ret
6150 return ret
6148
6151
6149
6152
6150 @command(
6153 @command(
6151 b'revert',
6154 b'revert',
6152 [
6155 [
6153 (b'a', b'all', None, _(b'revert all changes when no arguments given')),
6156 (b'a', b'all', None, _(b'revert all changes when no arguments given')),
6154 (b'd', b'date', b'', _(b'tipmost revision matching date'), _(b'DATE')),
6157 (b'd', b'date', b'', _(b'tipmost revision matching date'), _(b'DATE')),
6155 (b'r', b'rev', b'', _(b'revert to the specified revision'), _(b'REV')),
6158 (b'r', b'rev', b'', _(b'revert to the specified revision'), _(b'REV')),
6156 (b'C', b'no-backup', None, _(b'do not save backup copies of files')),
6159 (b'C', b'no-backup', None, _(b'do not save backup copies of files')),
6157 (b'i', b'interactive', None, _(b'interactively select the changes')),
6160 (b'i', b'interactive', None, _(b'interactively select the changes')),
6158 ]
6161 ]
6159 + walkopts
6162 + walkopts
6160 + dryrunopts,
6163 + dryrunopts,
6161 _(b'[OPTION]... [-r REV] [NAME]...'),
6164 _(b'[OPTION]... [-r REV] [NAME]...'),
6162 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6165 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6163 )
6166 )
6164 def revert(ui, repo, *pats, **opts):
6167 def revert(ui, repo, *pats, **opts):
6165 """restore files to their checkout state
6168 """restore files to their checkout state
6166
6169
6167 .. note::
6170 .. note::
6168
6171
6169 To check out earlier revisions, you should use :hg:`update REV`.
6172 To check out earlier revisions, you should use :hg:`update REV`.
6170 To cancel an uncommitted merge (and lose your changes),
6173 To cancel an uncommitted merge (and lose your changes),
6171 use :hg:`merge --abort`.
6174 use :hg:`merge --abort`.
6172
6175
6173 With no revision specified, revert the specified files or directories
6176 With no revision specified, revert the specified files or directories
6174 to the contents they had in the parent of the working directory.
6177 to the contents they had in the parent of the working directory.
6175 This restores the contents of files to an unmodified
6178 This restores the contents of files to an unmodified
6176 state and unschedules adds, removes, copies, and renames. If the
6179 state and unschedules adds, removes, copies, and renames. If the
6177 working directory has two parents, you must explicitly specify a
6180 working directory has two parents, you must explicitly specify a
6178 revision.
6181 revision.
6179
6182
6180 Using the -r/--rev or -d/--date options, revert the given files or
6183 Using the -r/--rev or -d/--date options, revert the given files or
6181 directories to their states as of a specific revision. Because
6184 directories to their states as of a specific revision. Because
6182 revert does not change the working directory parents, this will
6185 revert does not change the working directory parents, this will
6183 cause these files to appear modified. This can be helpful to "back
6186 cause these files to appear modified. This can be helpful to "back
6184 out" some or all of an earlier change. See :hg:`backout` for a
6187 out" some or all of an earlier change. See :hg:`backout` for a
6185 related method.
6188 related method.
6186
6189
6187 Modified files are saved with a .orig suffix before reverting.
6190 Modified files are saved with a .orig suffix before reverting.
6188 To disable these backups, use --no-backup. It is possible to store
6191 To disable these backups, use --no-backup. It is possible to store
6189 the backup files in a custom directory relative to the root of the
6192 the backup files in a custom directory relative to the root of the
6190 repository by setting the ``ui.origbackuppath`` configuration
6193 repository by setting the ``ui.origbackuppath`` configuration
6191 option.
6194 option.
6192
6195
6193 See :hg:`help dates` for a list of formats valid for -d/--date.
6196 See :hg:`help dates` for a list of formats valid for -d/--date.
6194
6197
6195 See :hg:`help backout` for a way to reverse the effect of an
6198 See :hg:`help backout` for a way to reverse the effect of an
6196 earlier changeset.
6199 earlier changeset.
6197
6200
6198 Returns 0 on success.
6201 Returns 0 on success.
6199 """
6202 """
6200
6203
6201 opts = pycompat.byteskwargs(opts)
6204 opts = pycompat.byteskwargs(opts)
6202 if opts.get(b"date"):
6205 if opts.get(b"date"):
6203 if opts.get(b"rev"):
6206 if opts.get(b"rev"):
6204 raise error.Abort(_(b"you can't specify a revision and a date"))
6207 raise error.Abort(_(b"you can't specify a revision and a date"))
6205 opts[b"rev"] = cmdutil.finddate(ui, repo, opts[b"date"])
6208 opts[b"rev"] = cmdutil.finddate(ui, repo, opts[b"date"])
6206
6209
6207 parent, p2 = repo.dirstate.parents()
6210 parent, p2 = repo.dirstate.parents()
6208 if not opts.get(b'rev') and p2 != nullid:
6211 if not opts.get(b'rev') and p2 != nullid:
6209 # revert after merge is a trap for new users (issue2915)
6212 # revert after merge is a trap for new users (issue2915)
6210 raise error.Abort(
6213 raise error.Abort(
6211 _(b'uncommitted merge with no revision specified'),
6214 _(b'uncommitted merge with no revision specified'),
6212 hint=_(b"use 'hg update' or see 'hg help revert'"),
6215 hint=_(b"use 'hg update' or see 'hg help revert'"),
6213 )
6216 )
6214
6217
6215 rev = opts.get(b'rev')
6218 rev = opts.get(b'rev')
6216 if rev:
6219 if rev:
6217 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
6220 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
6218 ctx = scmutil.revsingle(repo, rev)
6221 ctx = scmutil.revsingle(repo, rev)
6219
6222
6220 if not (
6223 if not (
6221 pats
6224 pats
6222 or opts.get(b'include')
6225 or opts.get(b'include')
6223 or opts.get(b'exclude')
6226 or opts.get(b'exclude')
6224 or opts.get(b'all')
6227 or opts.get(b'all')
6225 or opts.get(b'interactive')
6228 or opts.get(b'interactive')
6226 ):
6229 ):
6227 msg = _(b"no files or directories specified")
6230 msg = _(b"no files or directories specified")
6228 if p2 != nullid:
6231 if p2 != nullid:
6229 hint = _(
6232 hint = _(
6230 b"uncommitted merge, use --all to discard all changes,"
6233 b"uncommitted merge, use --all to discard all changes,"
6231 b" or 'hg update -C .' to abort the merge"
6234 b" or 'hg update -C .' to abort the merge"
6232 )
6235 )
6233 raise error.Abort(msg, hint=hint)
6236 raise error.Abort(msg, hint=hint)
6234 dirty = any(repo.status())
6237 dirty = any(repo.status())
6235 node = ctx.node()
6238 node = ctx.node()
6236 if node != parent:
6239 if node != parent:
6237 if dirty:
6240 if dirty:
6238 hint = (
6241 hint = (
6239 _(
6242 _(
6240 b"uncommitted changes, use --all to discard all"
6243 b"uncommitted changes, use --all to discard all"
6241 b" changes, or 'hg update %d' to update"
6244 b" changes, or 'hg update %d' to update"
6242 )
6245 )
6243 % ctx.rev()
6246 % ctx.rev()
6244 )
6247 )
6245 else:
6248 else:
6246 hint = (
6249 hint = (
6247 _(
6250 _(
6248 b"use --all to revert all files,"
6251 b"use --all to revert all files,"
6249 b" or 'hg update %d' to update"
6252 b" or 'hg update %d' to update"
6250 )
6253 )
6251 % ctx.rev()
6254 % ctx.rev()
6252 )
6255 )
6253 elif dirty:
6256 elif dirty:
6254 hint = _(b"uncommitted changes, use --all to discard all changes")
6257 hint = _(b"uncommitted changes, use --all to discard all changes")
6255 else:
6258 else:
6256 hint = _(b"use --all to revert all files")
6259 hint = _(b"use --all to revert all files")
6257 raise error.Abort(msg, hint=hint)
6260 raise error.Abort(msg, hint=hint)
6258
6261
6259 return cmdutil.revert(
6262 return cmdutil.revert(
6260 ui, repo, ctx, (parent, p2), *pats, **pycompat.strkwargs(opts)
6263 ui, repo, ctx, (parent, p2), *pats, **pycompat.strkwargs(opts)
6261 )
6264 )
6262
6265
6263
6266
6264 @command(
6267 @command(
6265 b'rollback',
6268 b'rollback',
6266 dryrunopts + [(b'f', b'force', False, _(b'ignore safety measures'))],
6269 dryrunopts + [(b'f', b'force', False, _(b'ignore safety measures'))],
6267 helpcategory=command.CATEGORY_MAINTENANCE,
6270 helpcategory=command.CATEGORY_MAINTENANCE,
6268 )
6271 )
6269 def rollback(ui, repo, **opts):
6272 def rollback(ui, repo, **opts):
6270 """roll back the last transaction (DANGEROUS) (DEPRECATED)
6273 """roll back the last transaction (DANGEROUS) (DEPRECATED)
6271
6274
6272 Please use :hg:`commit --amend` instead of rollback to correct
6275 Please use :hg:`commit --amend` instead of rollback to correct
6273 mistakes in the last commit.
6276 mistakes in the last commit.
6274
6277
6275 This command should be used with care. There is only one level of
6278 This command should be used with care. There is only one level of
6276 rollback, and there is no way to undo a rollback. It will also
6279 rollback, and there is no way to undo a rollback. It will also
6277 restore the dirstate at the time of the last transaction, losing
6280 restore the dirstate at the time of the last transaction, losing
6278 any dirstate changes since that time. This command does not alter
6281 any dirstate changes since that time. This command does not alter
6279 the working directory.
6282 the working directory.
6280
6283
6281 Transactions are used to encapsulate the effects of all commands
6284 Transactions are used to encapsulate the effects of all commands
6282 that create new changesets or propagate existing changesets into a
6285 that create new changesets or propagate existing changesets into a
6283 repository.
6286 repository.
6284
6287
6285 .. container:: verbose
6288 .. container:: verbose
6286
6289
6287 For example, the following commands are transactional, and their
6290 For example, the following commands are transactional, and their
6288 effects can be rolled back:
6291 effects can be rolled back:
6289
6292
6290 - commit
6293 - commit
6291 - import
6294 - import
6292 - pull
6295 - pull
6293 - push (with this repository as the destination)
6296 - push (with this repository as the destination)
6294 - unbundle
6297 - unbundle
6295
6298
6296 To avoid permanent data loss, rollback will refuse to rollback a
6299 To avoid permanent data loss, rollback will refuse to rollback a
6297 commit transaction if it isn't checked out. Use --force to
6300 commit transaction if it isn't checked out. Use --force to
6298 override this protection.
6301 override this protection.
6299
6302
6300 The rollback command can be entirely disabled by setting the
6303 The rollback command can be entirely disabled by setting the
6301 ``ui.rollback`` configuration setting to false. If you're here
6304 ``ui.rollback`` configuration setting to false. If you're here
6302 because you want to use rollback and it's disabled, you can
6305 because you want to use rollback and it's disabled, you can
6303 re-enable the command by setting ``ui.rollback`` to true.
6306 re-enable the command by setting ``ui.rollback`` to true.
6304
6307
6305 This command is not intended for use on public repositories. Once
6308 This command is not intended for use on public repositories. Once
6306 changes are visible for pull by other users, rolling a transaction
6309 changes are visible for pull by other users, rolling a transaction
6307 back locally is ineffective (someone else may already have pulled
6310 back locally is ineffective (someone else may already have pulled
6308 the changes). Furthermore, a race is possible with readers of the
6311 the changes). Furthermore, a race is possible with readers of the
6309 repository; for example an in-progress pull from the repository
6312 repository; for example an in-progress pull from the repository
6310 may fail if a rollback is performed.
6313 may fail if a rollback is performed.
6311
6314
6312 Returns 0 on success, 1 if no rollback data is available.
6315 Returns 0 on success, 1 if no rollback data is available.
6313 """
6316 """
6314 if not ui.configbool(b'ui', b'rollback'):
6317 if not ui.configbool(b'ui', b'rollback'):
6315 raise error.Abort(
6318 raise error.Abort(
6316 _(b'rollback is disabled because it is unsafe'),
6319 _(b'rollback is disabled because it is unsafe'),
6317 hint=b'see `hg help -v rollback` for information',
6320 hint=b'see `hg help -v rollback` for information',
6318 )
6321 )
6319 return repo.rollback(dryrun=opts.get(r'dry_run'), force=opts.get(r'force'))
6322 return repo.rollback(dryrun=opts.get(r'dry_run'), force=opts.get(r'force'))
6320
6323
6321
6324
6322 @command(
6325 @command(
6323 b'root',
6326 b'root',
6324 [] + formatteropts,
6327 [] + formatteropts,
6325 intents={INTENT_READONLY},
6328 intents={INTENT_READONLY},
6326 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6329 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6327 )
6330 )
6328 def root(ui, repo, **opts):
6331 def root(ui, repo, **opts):
6329 """print the root (top) of the current working directory
6332 """print the root (top) of the current working directory
6330
6333
6331 Print the root directory of the current repository.
6334 Print the root directory of the current repository.
6332
6335
6333 .. container:: verbose
6336 .. container:: verbose
6334
6337
6335 Template:
6338 Template:
6336
6339
6337 The following keywords are supported in addition to the common template
6340 The following keywords are supported in addition to the common template
6338 keywords and functions. See also :hg:`help templates`.
6341 keywords and functions. See also :hg:`help templates`.
6339
6342
6340 :hgpath: String. Path to the .hg directory.
6343 :hgpath: String. Path to the .hg directory.
6341 :storepath: String. Path to the directory holding versioned data.
6344 :storepath: String. Path to the directory holding versioned data.
6342
6345
6343 Returns 0 on success.
6346 Returns 0 on success.
6344 """
6347 """
6345 opts = pycompat.byteskwargs(opts)
6348 opts = pycompat.byteskwargs(opts)
6346 with ui.formatter(b'root', opts) as fm:
6349 with ui.formatter(b'root', opts) as fm:
6347 fm.startitem()
6350 fm.startitem()
6348 fm.write(b'reporoot', b'%s\n', repo.root)
6351 fm.write(b'reporoot', b'%s\n', repo.root)
6349 fm.data(hgpath=repo.path, storepath=repo.spath)
6352 fm.data(hgpath=repo.path, storepath=repo.spath)
6350
6353
6351
6354
6352 @command(
6355 @command(
6353 b'serve',
6356 b'serve',
6354 [
6357 [
6355 (
6358 (
6356 b'A',
6359 b'A',
6357 b'accesslog',
6360 b'accesslog',
6358 b'',
6361 b'',
6359 _(b'name of access log file to write to'),
6362 _(b'name of access log file to write to'),
6360 _(b'FILE'),
6363 _(b'FILE'),
6361 ),
6364 ),
6362 (b'd', b'daemon', None, _(b'run server in background')),
6365 (b'd', b'daemon', None, _(b'run server in background')),
6363 (b'', b'daemon-postexec', [], _(b'used internally by daemon mode')),
6366 (b'', b'daemon-postexec', [], _(b'used internally by daemon mode')),
6364 (
6367 (
6365 b'E',
6368 b'E',
6366 b'errorlog',
6369 b'errorlog',
6367 b'',
6370 b'',
6368 _(b'name of error log file to write to'),
6371 _(b'name of error log file to write to'),
6369 _(b'FILE'),
6372 _(b'FILE'),
6370 ),
6373 ),
6371 # use string type, then we can check if something was passed
6374 # use string type, then we can check if something was passed
6372 (
6375 (
6373 b'p',
6376 b'p',
6374 b'port',
6377 b'port',
6375 b'',
6378 b'',
6376 _(b'port to listen on (default: 8000)'),
6379 _(b'port to listen on (default: 8000)'),
6377 _(b'PORT'),
6380 _(b'PORT'),
6378 ),
6381 ),
6379 (
6382 (
6380 b'a',
6383 b'a',
6381 b'address',
6384 b'address',
6382 b'',
6385 b'',
6383 _(b'address to listen on (default: all interfaces)'),
6386 _(b'address to listen on (default: all interfaces)'),
6384 _(b'ADDR'),
6387 _(b'ADDR'),
6385 ),
6388 ),
6386 (
6389 (
6387 b'',
6390 b'',
6388 b'prefix',
6391 b'prefix',
6389 b'',
6392 b'',
6390 _(b'prefix path to serve from (default: server root)'),
6393 _(b'prefix path to serve from (default: server root)'),
6391 _(b'PREFIX'),
6394 _(b'PREFIX'),
6392 ),
6395 ),
6393 (
6396 (
6394 b'n',
6397 b'n',
6395 b'name',
6398 b'name',
6396 b'',
6399 b'',
6397 _(b'name to show in web pages (default: working directory)'),
6400 _(b'name to show in web pages (default: working directory)'),
6398 _(b'NAME'),
6401 _(b'NAME'),
6399 ),
6402 ),
6400 (
6403 (
6401 b'',
6404 b'',
6402 b'web-conf',
6405 b'web-conf',
6403 b'',
6406 b'',
6404 _(b"name of the hgweb config file (see 'hg help hgweb')"),
6407 _(b"name of the hgweb config file (see 'hg help hgweb')"),
6405 _(b'FILE'),
6408 _(b'FILE'),
6406 ),
6409 ),
6407 (
6410 (
6408 b'',
6411 b'',
6409 b'webdir-conf',
6412 b'webdir-conf',
6410 b'',
6413 b'',
6411 _(b'name of the hgweb config file (DEPRECATED)'),
6414 _(b'name of the hgweb config file (DEPRECATED)'),
6412 _(b'FILE'),
6415 _(b'FILE'),
6413 ),
6416 ),
6414 (
6417 (
6415 b'',
6418 b'',
6416 b'pid-file',
6419 b'pid-file',
6417 b'',
6420 b'',
6418 _(b'name of file to write process ID to'),
6421 _(b'name of file to write process ID to'),
6419 _(b'FILE'),
6422 _(b'FILE'),
6420 ),
6423 ),
6421 (b'', b'stdio', None, _(b'for remote clients (ADVANCED)')),
6424 (b'', b'stdio', None, _(b'for remote clients (ADVANCED)')),
6422 (
6425 (
6423 b'',
6426 b'',
6424 b'cmdserver',
6427 b'cmdserver',
6425 b'',
6428 b'',
6426 _(b'for remote clients (ADVANCED)'),
6429 _(b'for remote clients (ADVANCED)'),
6427 _(b'MODE'),
6430 _(b'MODE'),
6428 ),
6431 ),
6429 (b't', b'templates', b'', _(b'web templates to use'), _(b'TEMPLATE')),
6432 (b't', b'templates', b'', _(b'web templates to use'), _(b'TEMPLATE')),
6430 (b'', b'style', b'', _(b'template style to use'), _(b'STYLE')),
6433 (b'', b'style', b'', _(b'template style to use'), _(b'STYLE')),
6431 (b'6', b'ipv6', None, _(b'use IPv6 in addition to IPv4')),
6434 (b'6', b'ipv6', None, _(b'use IPv6 in addition to IPv4')),
6432 (b'', b'certificate', b'', _(b'SSL certificate file'), _(b'FILE')),
6435 (b'', b'certificate', b'', _(b'SSL certificate file'), _(b'FILE')),
6433 (b'', b'print-url', None, _(b'start and print only the URL')),
6436 (b'', b'print-url', None, _(b'start and print only the URL')),
6434 ]
6437 ]
6435 + subrepoopts,
6438 + subrepoopts,
6436 _(b'[OPTION]...'),
6439 _(b'[OPTION]...'),
6437 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
6440 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
6438 helpbasic=True,
6441 helpbasic=True,
6439 optionalrepo=True,
6442 optionalrepo=True,
6440 )
6443 )
6441 def serve(ui, repo, **opts):
6444 def serve(ui, repo, **opts):
6442 """start stand-alone webserver
6445 """start stand-alone webserver
6443
6446
6444 Start a local HTTP repository browser and pull server. You can use
6447 Start a local HTTP repository browser and pull server. You can use
6445 this for ad-hoc sharing and browsing of repositories. It is
6448 this for ad-hoc sharing and browsing of repositories. It is
6446 recommended to use a real web server to serve a repository for
6449 recommended to use a real web server to serve a repository for
6447 longer periods of time.
6450 longer periods of time.
6448
6451
6449 Please note that the server does not implement access control.
6452 Please note that the server does not implement access control.
6450 This means that, by default, anybody can read from the server and
6453 This means that, by default, anybody can read from the server and
6451 nobody can write to it by default. Set the ``web.allow-push``
6454 nobody can write to it by default. Set the ``web.allow-push``
6452 option to ``*`` to allow everybody to push to the server. You
6455 option to ``*`` to allow everybody to push to the server. You
6453 should use a real web server if you need to authenticate users.
6456 should use a real web server if you need to authenticate users.
6454
6457
6455 By default, the server logs accesses to stdout and errors to
6458 By default, the server logs accesses to stdout and errors to
6456 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
6459 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
6457 files.
6460 files.
6458
6461
6459 To have the server choose a free port number to listen on, specify
6462 To have the server choose a free port number to listen on, specify
6460 a port number of 0; in this case, the server will print the port
6463 a port number of 0; in this case, the server will print the port
6461 number it uses.
6464 number it uses.
6462
6465
6463 Returns 0 on success.
6466 Returns 0 on success.
6464 """
6467 """
6465
6468
6466 opts = pycompat.byteskwargs(opts)
6469 opts = pycompat.byteskwargs(opts)
6467 if opts[b"stdio"] and opts[b"cmdserver"]:
6470 if opts[b"stdio"] and opts[b"cmdserver"]:
6468 raise error.Abort(_(b"cannot use --stdio with --cmdserver"))
6471 raise error.Abort(_(b"cannot use --stdio with --cmdserver"))
6469 if opts[b"print_url"] and ui.verbose:
6472 if opts[b"print_url"] and ui.verbose:
6470 raise error.Abort(_(b"cannot use --print-url with --verbose"))
6473 raise error.Abort(_(b"cannot use --print-url with --verbose"))
6471
6474
6472 if opts[b"stdio"]:
6475 if opts[b"stdio"]:
6473 if repo is None:
6476 if repo is None:
6474 raise error.RepoError(
6477 raise error.RepoError(
6475 _(b"there is no Mercurial repository here (.hg not found)")
6478 _(b"there is no Mercurial repository here (.hg not found)")
6476 )
6479 )
6477 s = wireprotoserver.sshserver(ui, repo)
6480 s = wireprotoserver.sshserver(ui, repo)
6478 s.serve_forever()
6481 s.serve_forever()
6479
6482
6480 service = server.createservice(ui, repo, opts)
6483 service = server.createservice(ui, repo, opts)
6481 return server.runservice(opts, initfn=service.init, runfn=service.run)
6484 return server.runservice(opts, initfn=service.init, runfn=service.run)
6482
6485
6483
6486
6484 @command(
6487 @command(
6485 b'shelve',
6488 b'shelve',
6486 [
6489 [
6487 (
6490 (
6488 b'A',
6491 b'A',
6489 b'addremove',
6492 b'addremove',
6490 None,
6493 None,
6491 _(b'mark new/missing files as added/removed before shelving'),
6494 _(b'mark new/missing files as added/removed before shelving'),
6492 ),
6495 ),
6493 (b'u', b'unknown', None, _(b'store unknown files in the shelve')),
6496 (b'u', b'unknown', None, _(b'store unknown files in the shelve')),
6494 (b'', b'cleanup', None, _(b'delete all shelved changes')),
6497 (b'', b'cleanup', None, _(b'delete all shelved changes')),
6495 (
6498 (
6496 b'',
6499 b'',
6497 b'date',
6500 b'date',
6498 b'',
6501 b'',
6499 _(b'shelve with the specified commit date'),
6502 _(b'shelve with the specified commit date'),
6500 _(b'DATE'),
6503 _(b'DATE'),
6501 ),
6504 ),
6502 (b'd', b'delete', None, _(b'delete the named shelved change(s)')),
6505 (b'd', b'delete', None, _(b'delete the named shelved change(s)')),
6503 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
6506 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
6504 (
6507 (
6505 b'k',
6508 b'k',
6506 b'keep',
6509 b'keep',
6507 False,
6510 False,
6508 _(b'shelve, but keep changes in the working directory'),
6511 _(b'shelve, but keep changes in the working directory'),
6509 ),
6512 ),
6510 (b'l', b'list', None, _(b'list current shelves')),
6513 (b'l', b'list', None, _(b'list current shelves')),
6511 (b'm', b'message', b'', _(b'use text as shelve message'), _(b'TEXT')),
6514 (b'm', b'message', b'', _(b'use text as shelve message'), _(b'TEXT')),
6512 (
6515 (
6513 b'n',
6516 b'n',
6514 b'name',
6517 b'name',
6515 b'',
6518 b'',
6516 _(b'use the given name for the shelved commit'),
6519 _(b'use the given name for the shelved commit'),
6517 _(b'NAME'),
6520 _(b'NAME'),
6518 ),
6521 ),
6519 (
6522 (
6520 b'p',
6523 b'p',
6521 b'patch',
6524 b'patch',
6522 None,
6525 None,
6523 _(
6526 _(
6524 b'output patches for changes (provide the names of the shelved '
6527 b'output patches for changes (provide the names of the shelved '
6525 b'changes as positional arguments)'
6528 b'changes as positional arguments)'
6526 ),
6529 ),
6527 ),
6530 ),
6528 (b'i', b'interactive', None, _(b'interactive mode')),
6531 (b'i', b'interactive', None, _(b'interactive mode')),
6529 (
6532 (
6530 b'',
6533 b'',
6531 b'stat',
6534 b'stat',
6532 None,
6535 None,
6533 _(
6536 _(
6534 b'output diffstat-style summary of changes (provide the names of '
6537 b'output diffstat-style summary of changes (provide the names of '
6535 b'the shelved changes as positional arguments)'
6538 b'the shelved changes as positional arguments)'
6536 ),
6539 ),
6537 ),
6540 ),
6538 ]
6541 ]
6539 + cmdutil.walkopts,
6542 + cmdutil.walkopts,
6540 _(b'hg shelve [OPTION]... [FILE]...'),
6543 _(b'hg shelve [OPTION]... [FILE]...'),
6541 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6544 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6542 )
6545 )
6543 def shelve(ui, repo, *pats, **opts):
6546 def shelve(ui, repo, *pats, **opts):
6544 '''save and set aside changes from the working directory
6547 '''save and set aside changes from the working directory
6545
6548
6546 Shelving takes files that "hg status" reports as not clean, saves
6549 Shelving takes files that "hg status" reports as not clean, saves
6547 the modifications to a bundle (a shelved change), and reverts the
6550 the modifications to a bundle (a shelved change), and reverts the
6548 files so that their state in the working directory becomes clean.
6551 files so that their state in the working directory becomes clean.
6549
6552
6550 To restore these changes to the working directory, using "hg
6553 To restore these changes to the working directory, using "hg
6551 unshelve"; this will work even if you switch to a different
6554 unshelve"; this will work even if you switch to a different
6552 commit.
6555 commit.
6553
6556
6554 When no files are specified, "hg shelve" saves all not-clean
6557 When no files are specified, "hg shelve" saves all not-clean
6555 files. If specific files or directories are named, only changes to
6558 files. If specific files or directories are named, only changes to
6556 those files are shelved.
6559 those files are shelved.
6557
6560
6558 In bare shelve (when no files are specified, without interactive,
6561 In bare shelve (when no files are specified, without interactive,
6559 include and exclude option), shelving remembers information if the
6562 include and exclude option), shelving remembers information if the
6560 working directory was on newly created branch, in other words working
6563 working directory was on newly created branch, in other words working
6561 directory was on different branch than its first parent. In this
6564 directory was on different branch than its first parent. In this
6562 situation unshelving restores branch information to the working directory.
6565 situation unshelving restores branch information to the working directory.
6563
6566
6564 Each shelved change has a name that makes it easier to find later.
6567 Each shelved change has a name that makes it easier to find later.
6565 The name of a shelved change defaults to being based on the active
6568 The name of a shelved change defaults to being based on the active
6566 bookmark, or if there is no active bookmark, the current named
6569 bookmark, or if there is no active bookmark, the current named
6567 branch. To specify a different name, use ``--name``.
6570 branch. To specify a different name, use ``--name``.
6568
6571
6569 To see a list of existing shelved changes, use the ``--list``
6572 To see a list of existing shelved changes, use the ``--list``
6570 option. For each shelved change, this will print its name, age,
6573 option. For each shelved change, this will print its name, age,
6571 and description; use ``--patch`` or ``--stat`` for more details.
6574 and description; use ``--patch`` or ``--stat`` for more details.
6572
6575
6573 To delete specific shelved changes, use ``--delete``. To delete
6576 To delete specific shelved changes, use ``--delete``. To delete
6574 all shelved changes, use ``--cleanup``.
6577 all shelved changes, use ``--cleanup``.
6575 '''
6578 '''
6576 opts = pycompat.byteskwargs(opts)
6579 opts = pycompat.byteskwargs(opts)
6577 allowables = [
6580 allowables = [
6578 (b'addremove', {b'create'}), # 'create' is pseudo action
6581 (b'addremove', {b'create'}), # 'create' is pseudo action
6579 (b'unknown', {b'create'}),
6582 (b'unknown', {b'create'}),
6580 (b'cleanup', {b'cleanup'}),
6583 (b'cleanup', {b'cleanup'}),
6581 # ('date', {'create'}), # ignored for passing '--date "0 0"' in tests
6584 # ('date', {'create'}), # ignored for passing '--date "0 0"' in tests
6582 (b'delete', {b'delete'}),
6585 (b'delete', {b'delete'}),
6583 (b'edit', {b'create'}),
6586 (b'edit', {b'create'}),
6584 (b'keep', {b'create'}),
6587 (b'keep', {b'create'}),
6585 (b'list', {b'list'}),
6588 (b'list', {b'list'}),
6586 (b'message', {b'create'}),
6589 (b'message', {b'create'}),
6587 (b'name', {b'create'}),
6590 (b'name', {b'create'}),
6588 (b'patch', {b'patch', b'list'}),
6591 (b'patch', {b'patch', b'list'}),
6589 (b'stat', {b'stat', b'list'}),
6592 (b'stat', {b'stat', b'list'}),
6590 ]
6593 ]
6591
6594
6592 def checkopt(opt):
6595 def checkopt(opt):
6593 if opts.get(opt):
6596 if opts.get(opt):
6594 for i, allowable in allowables:
6597 for i, allowable in allowables:
6595 if opts[i] and opt not in allowable:
6598 if opts[i] and opt not in allowable:
6596 raise error.Abort(
6599 raise error.Abort(
6597 _(
6600 _(
6598 b"options '--%s' and '--%s' may not be "
6601 b"options '--%s' and '--%s' may not be "
6599 b"used together"
6602 b"used together"
6600 )
6603 )
6601 % (opt, i)
6604 % (opt, i)
6602 )
6605 )
6603 return True
6606 return True
6604
6607
6605 if checkopt(b'cleanup'):
6608 if checkopt(b'cleanup'):
6606 if pats:
6609 if pats:
6607 raise error.Abort(_(b"cannot specify names when using '--cleanup'"))
6610 raise error.Abort(_(b"cannot specify names when using '--cleanup'"))
6608 return shelvemod.cleanupcmd(ui, repo)
6611 return shelvemod.cleanupcmd(ui, repo)
6609 elif checkopt(b'delete'):
6612 elif checkopt(b'delete'):
6610 return shelvemod.deletecmd(ui, repo, pats)
6613 return shelvemod.deletecmd(ui, repo, pats)
6611 elif checkopt(b'list'):
6614 elif checkopt(b'list'):
6612 return shelvemod.listcmd(ui, repo, pats, opts)
6615 return shelvemod.listcmd(ui, repo, pats, opts)
6613 elif checkopt(b'patch') or checkopt(b'stat'):
6616 elif checkopt(b'patch') or checkopt(b'stat'):
6614 return shelvemod.patchcmds(ui, repo, pats, opts)
6617 return shelvemod.patchcmds(ui, repo, pats, opts)
6615 else:
6618 else:
6616 return shelvemod.createcmd(ui, repo, pats, opts)
6619 return shelvemod.createcmd(ui, repo, pats, opts)
6617
6620
6618
6621
6619 _NOTTERSE = b'nothing'
6622 _NOTTERSE = b'nothing'
6620
6623
6621
6624
6622 @command(
6625 @command(
6623 b'status|st',
6626 b'status|st',
6624 [
6627 [
6625 (b'A', b'all', None, _(b'show status of all files')),
6628 (b'A', b'all', None, _(b'show status of all files')),
6626 (b'm', b'modified', None, _(b'show only modified files')),
6629 (b'm', b'modified', None, _(b'show only modified files')),
6627 (b'a', b'added', None, _(b'show only added files')),
6630 (b'a', b'added', None, _(b'show only added files')),
6628 (b'r', b'removed', None, _(b'show only removed files')),
6631 (b'r', b'removed', None, _(b'show only removed files')),
6629 (b'd', b'deleted', None, _(b'show only deleted (but tracked) files')),
6632 (b'd', b'deleted', None, _(b'show only deleted (but tracked) files')),
6630 (b'c', b'clean', None, _(b'show only files without changes')),
6633 (b'c', b'clean', None, _(b'show only files without changes')),
6631 (b'u', b'unknown', None, _(b'show only unknown (not tracked) files')),
6634 (b'u', b'unknown', None, _(b'show only unknown (not tracked) files')),
6632 (b'i', b'ignored', None, _(b'show only ignored files')),
6635 (b'i', b'ignored', None, _(b'show only ignored files')),
6633 (b'n', b'no-status', None, _(b'hide status prefix')),
6636 (b'n', b'no-status', None, _(b'hide status prefix')),
6634 (b't', b'terse', _NOTTERSE, _(b'show the terse output (EXPERIMENTAL)')),
6637 (b't', b'terse', _NOTTERSE, _(b'show the terse output (EXPERIMENTAL)')),
6635 (b'C', b'copies', None, _(b'show source of copied files')),
6638 (b'C', b'copies', None, _(b'show source of copied files')),
6636 (
6639 (
6637 b'0',
6640 b'0',
6638 b'print0',
6641 b'print0',
6639 None,
6642 None,
6640 _(b'end filenames with NUL, for use with xargs'),
6643 _(b'end filenames with NUL, for use with xargs'),
6641 ),
6644 ),
6642 (b'', b'rev', [], _(b'show difference from revision'), _(b'REV')),
6645 (b'', b'rev', [], _(b'show difference from revision'), _(b'REV')),
6643 (
6646 (
6644 b'',
6647 b'',
6645 b'change',
6648 b'change',
6646 b'',
6649 b'',
6647 _(b'list the changed files of a revision'),
6650 _(b'list the changed files of a revision'),
6648 _(b'REV'),
6651 _(b'REV'),
6649 ),
6652 ),
6650 ]
6653 ]
6651 + walkopts
6654 + walkopts
6652 + subrepoopts
6655 + subrepoopts
6653 + formatteropts,
6656 + formatteropts,
6654 _(b'[OPTION]... [FILE]...'),
6657 _(b'[OPTION]... [FILE]...'),
6655 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6658 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6656 helpbasic=True,
6659 helpbasic=True,
6657 inferrepo=True,
6660 inferrepo=True,
6658 intents={INTENT_READONLY},
6661 intents={INTENT_READONLY},
6659 )
6662 )
6660 def status(ui, repo, *pats, **opts):
6663 def status(ui, repo, *pats, **opts):
6661 """show changed files in the working directory
6664 """show changed files in the working directory
6662
6665
6663 Show status of files in the repository. If names are given, only
6666 Show status of files in the repository. If names are given, only
6664 files that match are shown. Files that are clean or ignored or
6667 files that match are shown. Files that are clean or ignored or
6665 the source of a copy/move operation, are not listed unless
6668 the source of a copy/move operation, are not listed unless
6666 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
6669 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
6667 Unless options described with "show only ..." are given, the
6670 Unless options described with "show only ..." are given, the
6668 options -mardu are used.
6671 options -mardu are used.
6669
6672
6670 Option -q/--quiet hides untracked (unknown and ignored) files
6673 Option -q/--quiet hides untracked (unknown and ignored) files
6671 unless explicitly requested with -u/--unknown or -i/--ignored.
6674 unless explicitly requested with -u/--unknown or -i/--ignored.
6672
6675
6673 .. note::
6676 .. note::
6674
6677
6675 :hg:`status` may appear to disagree with diff if permissions have
6678 :hg:`status` may appear to disagree with diff if permissions have
6676 changed or a merge has occurred. The standard diff format does
6679 changed or a merge has occurred. The standard diff format does
6677 not report permission changes and diff only reports changes
6680 not report permission changes and diff only reports changes
6678 relative to one merge parent.
6681 relative to one merge parent.
6679
6682
6680 If one revision is given, it is used as the base revision.
6683 If one revision is given, it is used as the base revision.
6681 If two revisions are given, the differences between them are
6684 If two revisions are given, the differences between them are
6682 shown. The --change option can also be used as a shortcut to list
6685 shown. The --change option can also be used as a shortcut to list
6683 the changed files of a revision from its first parent.
6686 the changed files of a revision from its first parent.
6684
6687
6685 The codes used to show the status of files are::
6688 The codes used to show the status of files are::
6686
6689
6687 M = modified
6690 M = modified
6688 A = added
6691 A = added
6689 R = removed
6692 R = removed
6690 C = clean
6693 C = clean
6691 ! = missing (deleted by non-hg command, but still tracked)
6694 ! = missing (deleted by non-hg command, but still tracked)
6692 ? = not tracked
6695 ? = not tracked
6693 I = ignored
6696 I = ignored
6694 = origin of the previous file (with --copies)
6697 = origin of the previous file (with --copies)
6695
6698
6696 .. container:: verbose
6699 .. container:: verbose
6697
6700
6698 The -t/--terse option abbreviates the output by showing only the directory
6701 The -t/--terse option abbreviates the output by showing only the directory
6699 name if all the files in it share the same status. The option takes an
6702 name if all the files in it share the same status. The option takes an
6700 argument indicating the statuses to abbreviate: 'm' for 'modified', 'a'
6703 argument indicating the statuses to abbreviate: 'm' for 'modified', 'a'
6701 for 'added', 'r' for 'removed', 'd' for 'deleted', 'u' for 'unknown', 'i'
6704 for 'added', 'r' for 'removed', 'd' for 'deleted', 'u' for 'unknown', 'i'
6702 for 'ignored' and 'c' for clean.
6705 for 'ignored' and 'c' for clean.
6703
6706
6704 It abbreviates only those statuses which are passed. Note that clean and
6707 It abbreviates only those statuses which are passed. Note that clean and
6705 ignored files are not displayed with '--terse ic' unless the -c/--clean
6708 ignored files are not displayed with '--terse ic' unless the -c/--clean
6706 and -i/--ignored options are also used.
6709 and -i/--ignored options are also used.
6707
6710
6708 The -v/--verbose option shows information when the repository is in an
6711 The -v/--verbose option shows information when the repository is in an
6709 unfinished merge, shelve, rebase state etc. You can have this behavior
6712 unfinished merge, shelve, rebase state etc. You can have this behavior
6710 turned on by default by enabling the ``commands.status.verbose`` option.
6713 turned on by default by enabling the ``commands.status.verbose`` option.
6711
6714
6712 You can skip displaying some of these states by setting
6715 You can skip displaying some of these states by setting
6713 ``commands.status.skipstates`` to one or more of: 'bisect', 'graft',
6716 ``commands.status.skipstates`` to one or more of: 'bisect', 'graft',
6714 'histedit', 'merge', 'rebase', or 'unshelve'.
6717 'histedit', 'merge', 'rebase', or 'unshelve'.
6715
6718
6716 Template:
6719 Template:
6717
6720
6718 The following keywords are supported in addition to the common template
6721 The following keywords are supported in addition to the common template
6719 keywords and functions. See also :hg:`help templates`.
6722 keywords and functions. See also :hg:`help templates`.
6720
6723
6721 :path: String. Repository-absolute path of the file.
6724 :path: String. Repository-absolute path of the file.
6722 :source: String. Repository-absolute path of the file originated from.
6725 :source: String. Repository-absolute path of the file originated from.
6723 Available if ``--copies`` is specified.
6726 Available if ``--copies`` is specified.
6724 :status: String. Character denoting file's status.
6727 :status: String. Character denoting file's status.
6725
6728
6726 Examples:
6729 Examples:
6727
6730
6728 - show changes in the working directory relative to a
6731 - show changes in the working directory relative to a
6729 changeset::
6732 changeset::
6730
6733
6731 hg status --rev 9353
6734 hg status --rev 9353
6732
6735
6733 - show changes in the working directory relative to the
6736 - show changes in the working directory relative to the
6734 current directory (see :hg:`help patterns` for more information)::
6737 current directory (see :hg:`help patterns` for more information)::
6735
6738
6736 hg status re:
6739 hg status re:
6737
6740
6738 - show all changes including copies in an existing changeset::
6741 - show all changes including copies in an existing changeset::
6739
6742
6740 hg status --copies --change 9353
6743 hg status --copies --change 9353
6741
6744
6742 - get a NUL separated list of added files, suitable for xargs::
6745 - get a NUL separated list of added files, suitable for xargs::
6743
6746
6744 hg status -an0
6747 hg status -an0
6745
6748
6746 - show more information about the repository status, abbreviating
6749 - show more information about the repository status, abbreviating
6747 added, removed, modified, deleted, and untracked paths::
6750 added, removed, modified, deleted, and untracked paths::
6748
6751
6749 hg status -v -t mardu
6752 hg status -v -t mardu
6750
6753
6751 Returns 0 on success.
6754 Returns 0 on success.
6752
6755
6753 """
6756 """
6754
6757
6755 opts = pycompat.byteskwargs(opts)
6758 opts = pycompat.byteskwargs(opts)
6756 revs = opts.get(b'rev')
6759 revs = opts.get(b'rev')
6757 change = opts.get(b'change')
6760 change = opts.get(b'change')
6758 terse = opts.get(b'terse')
6761 terse = opts.get(b'terse')
6759 if terse is _NOTTERSE:
6762 if terse is _NOTTERSE:
6760 if revs:
6763 if revs:
6761 terse = b''
6764 terse = b''
6762 else:
6765 else:
6763 terse = ui.config(b'commands', b'status.terse')
6766 terse = ui.config(b'commands', b'status.terse')
6764
6767
6765 if revs and change:
6768 if revs and change:
6766 msg = _(b'cannot specify --rev and --change at the same time')
6769 msg = _(b'cannot specify --rev and --change at the same time')
6767 raise error.Abort(msg)
6770 raise error.Abort(msg)
6768 elif revs and terse:
6771 elif revs and terse:
6769 msg = _(b'cannot use --terse with --rev')
6772 msg = _(b'cannot use --terse with --rev')
6770 raise error.Abort(msg)
6773 raise error.Abort(msg)
6771 elif change:
6774 elif change:
6772 repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
6775 repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
6773 ctx2 = scmutil.revsingle(repo, change, None)
6776 ctx2 = scmutil.revsingle(repo, change, None)
6774 ctx1 = ctx2.p1()
6777 ctx1 = ctx2.p1()
6775 else:
6778 else:
6776 repo = scmutil.unhidehashlikerevs(repo, revs, b'nowarn')
6779 repo = scmutil.unhidehashlikerevs(repo, revs, b'nowarn')
6777 ctx1, ctx2 = scmutil.revpair(repo, revs)
6780 ctx1, ctx2 = scmutil.revpair(repo, revs)
6778
6781
6779 forcerelativevalue = None
6782 forcerelativevalue = None
6780 if ui.hasconfig(b'commands', b'status.relative'):
6783 if ui.hasconfig(b'commands', b'status.relative'):
6781 forcerelativevalue = ui.configbool(b'commands', b'status.relative')
6784 forcerelativevalue = ui.configbool(b'commands', b'status.relative')
6782 uipathfn = scmutil.getuipathfn(
6785 uipathfn = scmutil.getuipathfn(
6783 repo,
6786 repo,
6784 legacyrelativevalue=bool(pats),
6787 legacyrelativevalue=bool(pats),
6785 forcerelativevalue=forcerelativevalue,
6788 forcerelativevalue=forcerelativevalue,
6786 )
6789 )
6787
6790
6788 if opts.get(b'print0'):
6791 if opts.get(b'print0'):
6789 end = b'\0'
6792 end = b'\0'
6790 else:
6793 else:
6791 end = b'\n'
6794 end = b'\n'
6792 copy = {}
6795 copy = {}
6793 states = b'modified added removed deleted unknown ignored clean'.split()
6796 states = b'modified added removed deleted unknown ignored clean'.split()
6794 show = [k for k in states if opts.get(k)]
6797 show = [k for k in states if opts.get(k)]
6795 if opts.get(b'all'):
6798 if opts.get(b'all'):
6796 show += ui.quiet and (states[:4] + [b'clean']) or states
6799 show += ui.quiet and (states[:4] + [b'clean']) or states
6797
6800
6798 if not show:
6801 if not show:
6799 if ui.quiet:
6802 if ui.quiet:
6800 show = states[:4]
6803 show = states[:4]
6801 else:
6804 else:
6802 show = states[:5]
6805 show = states[:5]
6803
6806
6804 m = scmutil.match(ctx2, pats, opts)
6807 m = scmutil.match(ctx2, pats, opts)
6805 if terse:
6808 if terse:
6806 # we need to compute clean and unknown to terse
6809 # we need to compute clean and unknown to terse
6807 stat = repo.status(
6810 stat = repo.status(
6808 ctx1.node(),
6811 ctx1.node(),
6809 ctx2.node(),
6812 ctx2.node(),
6810 m,
6813 m,
6811 b'ignored' in show or b'i' in terse,
6814 b'ignored' in show or b'i' in terse,
6812 clean=True,
6815 clean=True,
6813 unknown=True,
6816 unknown=True,
6814 listsubrepos=opts.get(b'subrepos'),
6817 listsubrepos=opts.get(b'subrepos'),
6815 )
6818 )
6816
6819
6817 stat = cmdutil.tersedir(stat, terse)
6820 stat = cmdutil.tersedir(stat, terse)
6818 else:
6821 else:
6819 stat = repo.status(
6822 stat = repo.status(
6820 ctx1.node(),
6823 ctx1.node(),
6821 ctx2.node(),
6824 ctx2.node(),
6822 m,
6825 m,
6823 b'ignored' in show,
6826 b'ignored' in show,
6824 b'clean' in show,
6827 b'clean' in show,
6825 b'unknown' in show,
6828 b'unknown' in show,
6826 opts.get(b'subrepos'),
6829 opts.get(b'subrepos'),
6827 )
6830 )
6828
6831
6829 changestates = zip(states, pycompat.iterbytestr(b'MAR!?IC'), stat)
6832 changestates = zip(states, pycompat.iterbytestr(b'MAR!?IC'), stat)
6830
6833
6831 if (
6834 if (
6832 opts.get(b'all')
6835 opts.get(b'all')
6833 or opts.get(b'copies')
6836 or opts.get(b'copies')
6834 or ui.configbool(b'ui', b'statuscopies')
6837 or ui.configbool(b'ui', b'statuscopies')
6835 ) and not opts.get(b'no_status'):
6838 ) and not opts.get(b'no_status'):
6836 copy = copies.pathcopies(ctx1, ctx2, m)
6839 copy = copies.pathcopies(ctx1, ctx2, m)
6837
6840
6838 ui.pager(b'status')
6841 ui.pager(b'status')
6839 fm = ui.formatter(b'status', opts)
6842 fm = ui.formatter(b'status', opts)
6840 fmt = b'%s' + end
6843 fmt = b'%s' + end
6841 showchar = not opts.get(b'no_status')
6844 showchar = not opts.get(b'no_status')
6842
6845
6843 for state, char, files in changestates:
6846 for state, char, files in changestates:
6844 if state in show:
6847 if state in show:
6845 label = b'status.' + state
6848 label = b'status.' + state
6846 for f in files:
6849 for f in files:
6847 fm.startitem()
6850 fm.startitem()
6848 fm.context(ctx=ctx2)
6851 fm.context(ctx=ctx2)
6849 fm.data(path=f)
6852 fm.data(path=f)
6850 fm.condwrite(showchar, b'status', b'%s ', char, label=label)
6853 fm.condwrite(showchar, b'status', b'%s ', char, label=label)
6851 fm.plain(fmt % uipathfn(f), label=label)
6854 fm.plain(fmt % uipathfn(f), label=label)
6852 if f in copy:
6855 if f in copy:
6853 fm.data(source=copy[f])
6856 fm.data(source=copy[f])
6854 fm.plain(
6857 fm.plain(
6855 (b' %s' + end) % uipathfn(copy[f]),
6858 (b' %s' + end) % uipathfn(copy[f]),
6856 label=b'status.copied',
6859 label=b'status.copied',
6857 )
6860 )
6858
6861
6859 if (
6862 if (
6860 ui.verbose or ui.configbool(b'commands', b'status.verbose')
6863 ui.verbose or ui.configbool(b'commands', b'status.verbose')
6861 ) and not ui.plain():
6864 ) and not ui.plain():
6862 cmdutil.morestatus(repo, fm)
6865 cmdutil.morestatus(repo, fm)
6863 fm.end()
6866 fm.end()
6864
6867
6865
6868
6866 @command(
6869 @command(
6867 b'summary|sum',
6870 b'summary|sum',
6868 [(b'', b'remote', None, _(b'check for push and pull'))],
6871 [(b'', b'remote', None, _(b'check for push and pull'))],
6869 b'[--remote]',
6872 b'[--remote]',
6870 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6873 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6871 helpbasic=True,
6874 helpbasic=True,
6872 intents={INTENT_READONLY},
6875 intents={INTENT_READONLY},
6873 )
6876 )
6874 def summary(ui, repo, **opts):
6877 def summary(ui, repo, **opts):
6875 """summarize working directory state
6878 """summarize working directory state
6876
6879
6877 This generates a brief summary of the working directory state,
6880 This generates a brief summary of the working directory state,
6878 including parents, branch, commit status, phase and available updates.
6881 including parents, branch, commit status, phase and available updates.
6879
6882
6880 With the --remote option, this will check the default paths for
6883 With the --remote option, this will check the default paths for
6881 incoming and outgoing changes. This can be time-consuming.
6884 incoming and outgoing changes. This can be time-consuming.
6882
6885
6883 Returns 0 on success.
6886 Returns 0 on success.
6884 """
6887 """
6885
6888
6886 opts = pycompat.byteskwargs(opts)
6889 opts = pycompat.byteskwargs(opts)
6887 ui.pager(b'summary')
6890 ui.pager(b'summary')
6888 ctx = repo[None]
6891 ctx = repo[None]
6889 parents = ctx.parents()
6892 parents = ctx.parents()
6890 pnode = parents[0].node()
6893 pnode = parents[0].node()
6891 marks = []
6894 marks = []
6892
6895
6893 try:
6896 try:
6894 ms = mergemod.mergestate.read(repo)
6897 ms = mergemod.mergestate.read(repo)
6895 except error.UnsupportedMergeRecords as e:
6898 except error.UnsupportedMergeRecords as e:
6896 s = b' '.join(e.recordtypes)
6899 s = b' '.join(e.recordtypes)
6897 ui.warn(
6900 ui.warn(
6898 _(b'warning: merge state has unsupported record types: %s\n') % s
6901 _(b'warning: merge state has unsupported record types: %s\n') % s
6899 )
6902 )
6900 unresolved = []
6903 unresolved = []
6901 else:
6904 else:
6902 unresolved = list(ms.unresolved())
6905 unresolved = list(ms.unresolved())
6903
6906
6904 for p in parents:
6907 for p in parents:
6905 # label with log.changeset (instead of log.parent) since this
6908 # label with log.changeset (instead of log.parent) since this
6906 # shows a working directory parent *changeset*:
6909 # shows a working directory parent *changeset*:
6907 # i18n: column positioning for "hg summary"
6910 # i18n: column positioning for "hg summary"
6908 ui.write(
6911 ui.write(
6909 _(b'parent: %d:%s ') % (p.rev(), p),
6912 _(b'parent: %d:%s ') % (p.rev(), p),
6910 label=logcmdutil.changesetlabels(p),
6913 label=logcmdutil.changesetlabels(p),
6911 )
6914 )
6912 ui.write(b' '.join(p.tags()), label=b'log.tag')
6915 ui.write(b' '.join(p.tags()), label=b'log.tag')
6913 if p.bookmarks():
6916 if p.bookmarks():
6914 marks.extend(p.bookmarks())
6917 marks.extend(p.bookmarks())
6915 if p.rev() == -1:
6918 if p.rev() == -1:
6916 if not len(repo):
6919 if not len(repo):
6917 ui.write(_(b' (empty repository)'))
6920 ui.write(_(b' (empty repository)'))
6918 else:
6921 else:
6919 ui.write(_(b' (no revision checked out)'))
6922 ui.write(_(b' (no revision checked out)'))
6920 if p.obsolete():
6923 if p.obsolete():
6921 ui.write(_(b' (obsolete)'))
6924 ui.write(_(b' (obsolete)'))
6922 if p.isunstable():
6925 if p.isunstable():
6923 instabilities = (
6926 instabilities = (
6924 ui.label(instability, b'trouble.%s' % instability)
6927 ui.label(instability, b'trouble.%s' % instability)
6925 for instability in p.instabilities()
6928 for instability in p.instabilities()
6926 )
6929 )
6927 ui.write(b' (' + b', '.join(instabilities) + b')')
6930 ui.write(b' (' + b', '.join(instabilities) + b')')
6928 ui.write(b'\n')
6931 ui.write(b'\n')
6929 if p.description():
6932 if p.description():
6930 ui.status(
6933 ui.status(
6931 b' ' + p.description().splitlines()[0].strip() + b'\n',
6934 b' ' + p.description().splitlines()[0].strip() + b'\n',
6932 label=b'log.summary',
6935 label=b'log.summary',
6933 )
6936 )
6934
6937
6935 branch = ctx.branch()
6938 branch = ctx.branch()
6936 bheads = repo.branchheads(branch)
6939 bheads = repo.branchheads(branch)
6937 # i18n: column positioning for "hg summary"
6940 # i18n: column positioning for "hg summary"
6938 m = _(b'branch: %s\n') % branch
6941 m = _(b'branch: %s\n') % branch
6939 if branch != b'default':
6942 if branch != b'default':
6940 ui.write(m, label=b'log.branch')
6943 ui.write(m, label=b'log.branch')
6941 else:
6944 else:
6942 ui.status(m, label=b'log.branch')
6945 ui.status(m, label=b'log.branch')
6943
6946
6944 if marks:
6947 if marks:
6945 active = repo._activebookmark
6948 active = repo._activebookmark
6946 # i18n: column positioning for "hg summary"
6949 # i18n: column positioning for "hg summary"
6947 ui.write(_(b'bookmarks:'), label=b'log.bookmark')
6950 ui.write(_(b'bookmarks:'), label=b'log.bookmark')
6948 if active is not None:
6951 if active is not None:
6949 if active in marks:
6952 if active in marks:
6950 ui.write(b' *' + active, label=bookmarks.activebookmarklabel)
6953 ui.write(b' *' + active, label=bookmarks.activebookmarklabel)
6951 marks.remove(active)
6954 marks.remove(active)
6952 else:
6955 else:
6953 ui.write(b' [%s]' % active, label=bookmarks.activebookmarklabel)
6956 ui.write(b' [%s]' % active, label=bookmarks.activebookmarklabel)
6954 for m in marks:
6957 for m in marks:
6955 ui.write(b' ' + m, label=b'log.bookmark')
6958 ui.write(b' ' + m, label=b'log.bookmark')
6956 ui.write(b'\n', label=b'log.bookmark')
6959 ui.write(b'\n', label=b'log.bookmark')
6957
6960
6958 status = repo.status(unknown=True)
6961 status = repo.status(unknown=True)
6959
6962
6960 c = repo.dirstate.copies()
6963 c = repo.dirstate.copies()
6961 copied, renamed = [], []
6964 copied, renamed = [], []
6962 for d, s in pycompat.iteritems(c):
6965 for d, s in pycompat.iteritems(c):
6963 if s in status.removed:
6966 if s in status.removed:
6964 status.removed.remove(s)
6967 status.removed.remove(s)
6965 renamed.append(d)
6968 renamed.append(d)
6966 else:
6969 else:
6967 copied.append(d)
6970 copied.append(d)
6968 if d in status.added:
6971 if d in status.added:
6969 status.added.remove(d)
6972 status.added.remove(d)
6970
6973
6971 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
6974 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
6972
6975
6973 labels = [
6976 labels = [
6974 (ui.label(_(b'%d modified'), b'status.modified'), status.modified),
6977 (ui.label(_(b'%d modified'), b'status.modified'), status.modified),
6975 (ui.label(_(b'%d added'), b'status.added'), status.added),
6978 (ui.label(_(b'%d added'), b'status.added'), status.added),
6976 (ui.label(_(b'%d removed'), b'status.removed'), status.removed),
6979 (ui.label(_(b'%d removed'), b'status.removed'), status.removed),
6977 (ui.label(_(b'%d renamed'), b'status.copied'), renamed),
6980 (ui.label(_(b'%d renamed'), b'status.copied'), renamed),
6978 (ui.label(_(b'%d copied'), b'status.copied'), copied),
6981 (ui.label(_(b'%d copied'), b'status.copied'), copied),
6979 (ui.label(_(b'%d deleted'), b'status.deleted'), status.deleted),
6982 (ui.label(_(b'%d deleted'), b'status.deleted'), status.deleted),
6980 (ui.label(_(b'%d unknown'), b'status.unknown'), status.unknown),
6983 (ui.label(_(b'%d unknown'), b'status.unknown'), status.unknown),
6981 (ui.label(_(b'%d unresolved'), b'resolve.unresolved'), unresolved),
6984 (ui.label(_(b'%d unresolved'), b'resolve.unresolved'), unresolved),
6982 (ui.label(_(b'%d subrepos'), b'status.modified'), subs),
6985 (ui.label(_(b'%d subrepos'), b'status.modified'), subs),
6983 ]
6986 ]
6984 t = []
6987 t = []
6985 for l, s in labels:
6988 for l, s in labels:
6986 if s:
6989 if s:
6987 t.append(l % len(s))
6990 t.append(l % len(s))
6988
6991
6989 t = b', '.join(t)
6992 t = b', '.join(t)
6990 cleanworkdir = False
6993 cleanworkdir = False
6991
6994
6992 if repo.vfs.exists(b'graftstate'):
6995 if repo.vfs.exists(b'graftstate'):
6993 t += _(b' (graft in progress)')
6996 t += _(b' (graft in progress)')
6994 if repo.vfs.exists(b'updatestate'):
6997 if repo.vfs.exists(b'updatestate'):
6995 t += _(b' (interrupted update)')
6998 t += _(b' (interrupted update)')
6996 elif len(parents) > 1:
6999 elif len(parents) > 1:
6997 t += _(b' (merge)')
7000 t += _(b' (merge)')
6998 elif branch != parents[0].branch():
7001 elif branch != parents[0].branch():
6999 t += _(b' (new branch)')
7002 t += _(b' (new branch)')
7000 elif parents[0].closesbranch() and pnode in repo.branchheads(
7003 elif parents[0].closesbranch() and pnode in repo.branchheads(
7001 branch, closed=True
7004 branch, closed=True
7002 ):
7005 ):
7003 t += _(b' (head closed)')
7006 t += _(b' (head closed)')
7004 elif not (
7007 elif not (
7005 status.modified
7008 status.modified
7006 or status.added
7009 or status.added
7007 or status.removed
7010 or status.removed
7008 or renamed
7011 or renamed
7009 or copied
7012 or copied
7010 or subs
7013 or subs
7011 ):
7014 ):
7012 t += _(b' (clean)')
7015 t += _(b' (clean)')
7013 cleanworkdir = True
7016 cleanworkdir = True
7014 elif pnode not in bheads:
7017 elif pnode not in bheads:
7015 t += _(b' (new branch head)')
7018 t += _(b' (new branch head)')
7016
7019
7017 if parents:
7020 if parents:
7018 pendingphase = max(p.phase() for p in parents)
7021 pendingphase = max(p.phase() for p in parents)
7019 else:
7022 else:
7020 pendingphase = phases.public
7023 pendingphase = phases.public
7021
7024
7022 if pendingphase > phases.newcommitphase(ui):
7025 if pendingphase > phases.newcommitphase(ui):
7023 t += b' (%s)' % phases.phasenames[pendingphase]
7026 t += b' (%s)' % phases.phasenames[pendingphase]
7024
7027
7025 if cleanworkdir:
7028 if cleanworkdir:
7026 # i18n: column positioning for "hg summary"
7029 # i18n: column positioning for "hg summary"
7027 ui.status(_(b'commit: %s\n') % t.strip())
7030 ui.status(_(b'commit: %s\n') % t.strip())
7028 else:
7031 else:
7029 # i18n: column positioning for "hg summary"
7032 # i18n: column positioning for "hg summary"
7030 ui.write(_(b'commit: %s\n') % t.strip())
7033 ui.write(_(b'commit: %s\n') % t.strip())
7031
7034
7032 # all ancestors of branch heads - all ancestors of parent = new csets
7035 # all ancestors of branch heads - all ancestors of parent = new csets
7033 new = len(
7036 new = len(
7034 repo.changelog.findmissing([pctx.node() for pctx in parents], bheads)
7037 repo.changelog.findmissing([pctx.node() for pctx in parents], bheads)
7035 )
7038 )
7036
7039
7037 if new == 0:
7040 if new == 0:
7038 # i18n: column positioning for "hg summary"
7041 # i18n: column positioning for "hg summary"
7039 ui.status(_(b'update: (current)\n'))
7042 ui.status(_(b'update: (current)\n'))
7040 elif pnode not in bheads:
7043 elif pnode not in bheads:
7041 # i18n: column positioning for "hg summary"
7044 # i18n: column positioning for "hg summary"
7042 ui.write(_(b'update: %d new changesets (update)\n') % new)
7045 ui.write(_(b'update: %d new changesets (update)\n') % new)
7043 else:
7046 else:
7044 # i18n: column positioning for "hg summary"
7047 # i18n: column positioning for "hg summary"
7045 ui.write(
7048 ui.write(
7046 _(b'update: %d new changesets, %d branch heads (merge)\n')
7049 _(b'update: %d new changesets, %d branch heads (merge)\n')
7047 % (new, len(bheads))
7050 % (new, len(bheads))
7048 )
7051 )
7049
7052
7050 t = []
7053 t = []
7051 draft = len(repo.revs(b'draft()'))
7054 draft = len(repo.revs(b'draft()'))
7052 if draft:
7055 if draft:
7053 t.append(_(b'%d draft') % draft)
7056 t.append(_(b'%d draft') % draft)
7054 secret = len(repo.revs(b'secret()'))
7057 secret = len(repo.revs(b'secret()'))
7055 if secret:
7058 if secret:
7056 t.append(_(b'%d secret') % secret)
7059 t.append(_(b'%d secret') % secret)
7057
7060
7058 if draft or secret:
7061 if draft or secret:
7059 ui.status(_(b'phases: %s\n') % b', '.join(t))
7062 ui.status(_(b'phases: %s\n') % b', '.join(t))
7060
7063
7061 if obsolete.isenabled(repo, obsolete.createmarkersopt):
7064 if obsolete.isenabled(repo, obsolete.createmarkersopt):
7062 for trouble in (b"orphan", b"contentdivergent", b"phasedivergent"):
7065 for trouble in (b"orphan", b"contentdivergent", b"phasedivergent"):
7063 numtrouble = len(repo.revs(trouble + b"()"))
7066 numtrouble = len(repo.revs(trouble + b"()"))
7064 # We write all the possibilities to ease translation
7067 # We write all the possibilities to ease translation
7065 troublemsg = {
7068 troublemsg = {
7066 b"orphan": _(b"orphan: %d changesets"),
7069 b"orphan": _(b"orphan: %d changesets"),
7067 b"contentdivergent": _(b"content-divergent: %d changesets"),
7070 b"contentdivergent": _(b"content-divergent: %d changesets"),
7068 b"phasedivergent": _(b"phase-divergent: %d changesets"),
7071 b"phasedivergent": _(b"phase-divergent: %d changesets"),
7069 }
7072 }
7070 if numtrouble > 0:
7073 if numtrouble > 0:
7071 ui.status(troublemsg[trouble] % numtrouble + b"\n")
7074 ui.status(troublemsg[trouble] % numtrouble + b"\n")
7072
7075
7073 cmdutil.summaryhooks(ui, repo)
7076 cmdutil.summaryhooks(ui, repo)
7074
7077
7075 if opts.get(b'remote'):
7078 if opts.get(b'remote'):
7076 needsincoming, needsoutgoing = True, True
7079 needsincoming, needsoutgoing = True, True
7077 else:
7080 else:
7078 needsincoming, needsoutgoing = False, False
7081 needsincoming, needsoutgoing = False, False
7079 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
7082 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
7080 if i:
7083 if i:
7081 needsincoming = True
7084 needsincoming = True
7082 if o:
7085 if o:
7083 needsoutgoing = True
7086 needsoutgoing = True
7084 if not needsincoming and not needsoutgoing:
7087 if not needsincoming and not needsoutgoing:
7085 return
7088 return
7086
7089
7087 def getincoming():
7090 def getincoming():
7088 source, branches = hg.parseurl(ui.expandpath(b'default'))
7091 source, branches = hg.parseurl(ui.expandpath(b'default'))
7089 sbranch = branches[0]
7092 sbranch = branches[0]
7090 try:
7093 try:
7091 other = hg.peer(repo, {}, source)
7094 other = hg.peer(repo, {}, source)
7092 except error.RepoError:
7095 except error.RepoError:
7093 if opts.get(b'remote'):
7096 if opts.get(b'remote'):
7094 raise
7097 raise
7095 return source, sbranch, None, None, None
7098 return source, sbranch, None, None, None
7096 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
7099 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
7097 if revs:
7100 if revs:
7098 revs = [other.lookup(rev) for rev in revs]
7101 revs = [other.lookup(rev) for rev in revs]
7099 ui.debug(b'comparing with %s\n' % util.hidepassword(source))
7102 ui.debug(b'comparing with %s\n' % util.hidepassword(source))
7100 repo.ui.pushbuffer()
7103 repo.ui.pushbuffer()
7101 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
7104 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
7102 repo.ui.popbuffer()
7105 repo.ui.popbuffer()
7103 return source, sbranch, other, commoninc, commoninc[1]
7106 return source, sbranch, other, commoninc, commoninc[1]
7104
7107
7105 if needsincoming:
7108 if needsincoming:
7106 source, sbranch, sother, commoninc, incoming = getincoming()
7109 source, sbranch, sother, commoninc, incoming = getincoming()
7107 else:
7110 else:
7108 source = sbranch = sother = commoninc = incoming = None
7111 source = sbranch = sother = commoninc = incoming = None
7109
7112
7110 def getoutgoing():
7113 def getoutgoing():
7111 dest, branches = hg.parseurl(ui.expandpath(b'default-push', b'default'))
7114 dest, branches = hg.parseurl(ui.expandpath(b'default-push', b'default'))
7112 dbranch = branches[0]
7115 dbranch = branches[0]
7113 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
7116 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
7114 if source != dest:
7117 if source != dest:
7115 try:
7118 try:
7116 dother = hg.peer(repo, {}, dest)
7119 dother = hg.peer(repo, {}, dest)
7117 except error.RepoError:
7120 except error.RepoError:
7118 if opts.get(b'remote'):
7121 if opts.get(b'remote'):
7119 raise
7122 raise
7120 return dest, dbranch, None, None
7123 return dest, dbranch, None, None
7121 ui.debug(b'comparing with %s\n' % util.hidepassword(dest))
7124 ui.debug(b'comparing with %s\n' % util.hidepassword(dest))
7122 elif sother is None:
7125 elif sother is None:
7123 # there is no explicit destination peer, but source one is invalid
7126 # there is no explicit destination peer, but source one is invalid
7124 return dest, dbranch, None, None
7127 return dest, dbranch, None, None
7125 else:
7128 else:
7126 dother = sother
7129 dother = sother
7127 if source != dest or (sbranch is not None and sbranch != dbranch):
7130 if source != dest or (sbranch is not None and sbranch != dbranch):
7128 common = None
7131 common = None
7129 else:
7132 else:
7130 common = commoninc
7133 common = commoninc
7131 if revs:
7134 if revs:
7132 revs = [repo.lookup(rev) for rev in revs]
7135 revs = [repo.lookup(rev) for rev in revs]
7133 repo.ui.pushbuffer()
7136 repo.ui.pushbuffer()
7134 outgoing = discovery.findcommonoutgoing(
7137 outgoing = discovery.findcommonoutgoing(
7135 repo, dother, onlyheads=revs, commoninc=common
7138 repo, dother, onlyheads=revs, commoninc=common
7136 )
7139 )
7137 repo.ui.popbuffer()
7140 repo.ui.popbuffer()
7138 return dest, dbranch, dother, outgoing
7141 return dest, dbranch, dother, outgoing
7139
7142
7140 if needsoutgoing:
7143 if needsoutgoing:
7141 dest, dbranch, dother, outgoing = getoutgoing()
7144 dest, dbranch, dother, outgoing = getoutgoing()
7142 else:
7145 else:
7143 dest = dbranch = dother = outgoing = None
7146 dest = dbranch = dother = outgoing = None
7144
7147
7145 if opts.get(b'remote'):
7148 if opts.get(b'remote'):
7146 t = []
7149 t = []
7147 if incoming:
7150 if incoming:
7148 t.append(_(b'1 or more incoming'))
7151 t.append(_(b'1 or more incoming'))
7149 o = outgoing.missing
7152 o = outgoing.missing
7150 if o:
7153 if o:
7151 t.append(_(b'%d outgoing') % len(o))
7154 t.append(_(b'%d outgoing') % len(o))
7152 other = dother or sother
7155 other = dother or sother
7153 if b'bookmarks' in other.listkeys(b'namespaces'):
7156 if b'bookmarks' in other.listkeys(b'namespaces'):
7154 counts = bookmarks.summary(repo, other)
7157 counts = bookmarks.summary(repo, other)
7155 if counts[0] > 0:
7158 if counts[0] > 0:
7156 t.append(_(b'%d incoming bookmarks') % counts[0])
7159 t.append(_(b'%d incoming bookmarks') % counts[0])
7157 if counts[1] > 0:
7160 if counts[1] > 0:
7158 t.append(_(b'%d outgoing bookmarks') % counts[1])
7161 t.append(_(b'%d outgoing bookmarks') % counts[1])
7159
7162
7160 if t:
7163 if t:
7161 # i18n: column positioning for "hg summary"
7164 # i18n: column positioning for "hg summary"
7162 ui.write(_(b'remote: %s\n') % (b', '.join(t)))
7165 ui.write(_(b'remote: %s\n') % (b', '.join(t)))
7163 else:
7166 else:
7164 # i18n: column positioning for "hg summary"
7167 # i18n: column positioning for "hg summary"
7165 ui.status(_(b'remote: (synced)\n'))
7168 ui.status(_(b'remote: (synced)\n'))
7166
7169
7167 cmdutil.summaryremotehooks(
7170 cmdutil.summaryremotehooks(
7168 ui,
7171 ui,
7169 repo,
7172 repo,
7170 opts,
7173 opts,
7171 (
7174 (
7172 (source, sbranch, sother, commoninc),
7175 (source, sbranch, sother, commoninc),
7173 (dest, dbranch, dother, outgoing),
7176 (dest, dbranch, dother, outgoing),
7174 ),
7177 ),
7175 )
7178 )
7176
7179
7177
7180
7178 @command(
7181 @command(
7179 b'tag',
7182 b'tag',
7180 [
7183 [
7181 (b'f', b'force', None, _(b'force tag')),
7184 (b'f', b'force', None, _(b'force tag')),
7182 (b'l', b'local', None, _(b'make the tag local')),
7185 (b'l', b'local', None, _(b'make the tag local')),
7183 (b'r', b'rev', b'', _(b'revision to tag'), _(b'REV')),
7186 (b'r', b'rev', b'', _(b'revision to tag'), _(b'REV')),
7184 (b'', b'remove', None, _(b'remove a tag')),
7187 (b'', b'remove', None, _(b'remove a tag')),
7185 # -l/--local is already there, commitopts cannot be used
7188 # -l/--local is already there, commitopts cannot be used
7186 (b'e', b'edit', None, _(b'invoke editor on commit messages')),
7189 (b'e', b'edit', None, _(b'invoke editor on commit messages')),
7187 (b'm', b'message', b'', _(b'use text as commit message'), _(b'TEXT')),
7190 (b'm', b'message', b'', _(b'use text as commit message'), _(b'TEXT')),
7188 ]
7191 ]
7189 + commitopts2,
7192 + commitopts2,
7190 _(b'[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'),
7193 _(b'[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'),
7191 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
7194 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
7192 )
7195 )
7193 def tag(ui, repo, name1, *names, **opts):
7196 def tag(ui, repo, name1, *names, **opts):
7194 """add one or more tags for the current or given revision
7197 """add one or more tags for the current or given revision
7195
7198
7196 Name a particular revision using <name>.
7199 Name a particular revision using <name>.
7197
7200
7198 Tags are used to name particular revisions of the repository and are
7201 Tags are used to name particular revisions of the repository and are
7199 very useful to compare different revisions, to go back to significant
7202 very useful to compare different revisions, to go back to significant
7200 earlier versions or to mark branch points as releases, etc. Changing
7203 earlier versions or to mark branch points as releases, etc. Changing
7201 an existing tag is normally disallowed; use -f/--force to override.
7204 an existing tag is normally disallowed; use -f/--force to override.
7202
7205
7203 If no revision is given, the parent of the working directory is
7206 If no revision is given, the parent of the working directory is
7204 used.
7207 used.
7205
7208
7206 To facilitate version control, distribution, and merging of tags,
7209 To facilitate version control, distribution, and merging of tags,
7207 they are stored as a file named ".hgtags" which is managed similarly
7210 they are stored as a file named ".hgtags" which is managed similarly
7208 to other project files and can be hand-edited if necessary. This
7211 to other project files and can be hand-edited if necessary. This
7209 also means that tagging creates a new commit. The file
7212 also means that tagging creates a new commit. The file
7210 ".hg/localtags" is used for local tags (not shared among
7213 ".hg/localtags" is used for local tags (not shared among
7211 repositories).
7214 repositories).
7212
7215
7213 Tag commits are usually made at the head of a branch. If the parent
7216 Tag commits are usually made at the head of a branch. If the parent
7214 of the working directory is not a branch head, :hg:`tag` aborts; use
7217 of the working directory is not a branch head, :hg:`tag` aborts; use
7215 -f/--force to force the tag commit to be based on a non-head
7218 -f/--force to force the tag commit to be based on a non-head
7216 changeset.
7219 changeset.
7217
7220
7218 See :hg:`help dates` for a list of formats valid for -d/--date.
7221 See :hg:`help dates` for a list of formats valid for -d/--date.
7219
7222
7220 Since tag names have priority over branch names during revision
7223 Since tag names have priority over branch names during revision
7221 lookup, using an existing branch name as a tag name is discouraged.
7224 lookup, using an existing branch name as a tag name is discouraged.
7222
7225
7223 Returns 0 on success.
7226 Returns 0 on success.
7224 """
7227 """
7225 opts = pycompat.byteskwargs(opts)
7228 opts = pycompat.byteskwargs(opts)
7226 with repo.wlock(), repo.lock():
7229 with repo.wlock(), repo.lock():
7227 rev_ = b"."
7230 rev_ = b"."
7228 names = [t.strip() for t in (name1,) + names]
7231 names = [t.strip() for t in (name1,) + names]
7229 if len(names) != len(set(names)):
7232 if len(names) != len(set(names)):
7230 raise error.Abort(_(b'tag names must be unique'))
7233 raise error.Abort(_(b'tag names must be unique'))
7231 for n in names:
7234 for n in names:
7232 scmutil.checknewlabel(repo, n, b'tag')
7235 scmutil.checknewlabel(repo, n, b'tag')
7233 if not n:
7236 if not n:
7234 raise error.Abort(
7237 raise error.Abort(
7235 _(b'tag names cannot consist entirely of whitespace')
7238 _(b'tag names cannot consist entirely of whitespace')
7236 )
7239 )
7237 if opts.get(b'rev') and opts.get(b'remove'):
7240 if opts.get(b'rev') and opts.get(b'remove'):
7238 raise error.Abort(_(b"--rev and --remove are incompatible"))
7241 raise error.Abort(_(b"--rev and --remove are incompatible"))
7239 if opts.get(b'rev'):
7242 if opts.get(b'rev'):
7240 rev_ = opts[b'rev']
7243 rev_ = opts[b'rev']
7241 message = opts.get(b'message')
7244 message = opts.get(b'message')
7242 if opts.get(b'remove'):
7245 if opts.get(b'remove'):
7243 if opts.get(b'local'):
7246 if opts.get(b'local'):
7244 expectedtype = b'local'
7247 expectedtype = b'local'
7245 else:
7248 else:
7246 expectedtype = b'global'
7249 expectedtype = b'global'
7247
7250
7248 for n in names:
7251 for n in names:
7249 if repo.tagtype(n) == b'global':
7252 if repo.tagtype(n) == b'global':
7250 alltags = tagsmod.findglobaltags(ui, repo)
7253 alltags = tagsmod.findglobaltags(ui, repo)
7251 if alltags[n][0] == nullid:
7254 if alltags[n][0] == nullid:
7252 raise error.Abort(_(b"tag '%s' is already removed") % n)
7255 raise error.Abort(_(b"tag '%s' is already removed") % n)
7253 if not repo.tagtype(n):
7256 if not repo.tagtype(n):
7254 raise error.Abort(_(b"tag '%s' does not exist") % n)
7257 raise error.Abort(_(b"tag '%s' does not exist") % n)
7255 if repo.tagtype(n) != expectedtype:
7258 if repo.tagtype(n) != expectedtype:
7256 if expectedtype == b'global':
7259 if expectedtype == b'global':
7257 raise error.Abort(
7260 raise error.Abort(
7258 _(b"tag '%s' is not a global tag") % n
7261 _(b"tag '%s' is not a global tag") % n
7259 )
7262 )
7260 else:
7263 else:
7261 raise error.Abort(_(b"tag '%s' is not a local tag") % n)
7264 raise error.Abort(_(b"tag '%s' is not a local tag") % n)
7262 rev_ = b'null'
7265 rev_ = b'null'
7263 if not message:
7266 if not message:
7264 # we don't translate commit messages
7267 # we don't translate commit messages
7265 message = b'Removed tag %s' % b', '.join(names)
7268 message = b'Removed tag %s' % b', '.join(names)
7266 elif not opts.get(b'force'):
7269 elif not opts.get(b'force'):
7267 for n in names:
7270 for n in names:
7268 if n in repo.tags():
7271 if n in repo.tags():
7269 raise error.Abort(
7272 raise error.Abort(
7270 _(b"tag '%s' already exists (use -f to force)") % n
7273 _(b"tag '%s' already exists (use -f to force)") % n
7271 )
7274 )
7272 if not opts.get(b'local'):
7275 if not opts.get(b'local'):
7273 p1, p2 = repo.dirstate.parents()
7276 p1, p2 = repo.dirstate.parents()
7274 if p2 != nullid:
7277 if p2 != nullid:
7275 raise error.Abort(_(b'uncommitted merge'))
7278 raise error.Abort(_(b'uncommitted merge'))
7276 bheads = repo.branchheads()
7279 bheads = repo.branchheads()
7277 if not opts.get(b'force') and bheads and p1 not in bheads:
7280 if not opts.get(b'force') and bheads and p1 not in bheads:
7278 raise error.Abort(
7281 raise error.Abort(
7279 _(
7282 _(
7280 b'working directory is not at a branch head '
7283 b'working directory is not at a branch head '
7281 b'(use -f to force)'
7284 b'(use -f to force)'
7282 )
7285 )
7283 )
7286 )
7284 node = scmutil.revsingle(repo, rev_).node()
7287 node = scmutil.revsingle(repo, rev_).node()
7285
7288
7286 if not message:
7289 if not message:
7287 # we don't translate commit messages
7290 # we don't translate commit messages
7288 message = b'Added tag %s for changeset %s' % (
7291 message = b'Added tag %s for changeset %s' % (
7289 b', '.join(names),
7292 b', '.join(names),
7290 short(node),
7293 short(node),
7291 )
7294 )
7292
7295
7293 date = opts.get(b'date')
7296 date = opts.get(b'date')
7294 if date:
7297 if date:
7295 date = dateutil.parsedate(date)
7298 date = dateutil.parsedate(date)
7296
7299
7297 if opts.get(b'remove'):
7300 if opts.get(b'remove'):
7298 editform = b'tag.remove'
7301 editform = b'tag.remove'
7299 else:
7302 else:
7300 editform = b'tag.add'
7303 editform = b'tag.add'
7301 editor = cmdutil.getcommiteditor(
7304 editor = cmdutil.getcommiteditor(
7302 editform=editform, **pycompat.strkwargs(opts)
7305 editform=editform, **pycompat.strkwargs(opts)
7303 )
7306 )
7304
7307
7305 # don't allow tagging the null rev
7308 # don't allow tagging the null rev
7306 if (
7309 if (
7307 not opts.get(b'remove')
7310 not opts.get(b'remove')
7308 and scmutil.revsingle(repo, rev_).rev() == nullrev
7311 and scmutil.revsingle(repo, rev_).rev() == nullrev
7309 ):
7312 ):
7310 raise error.Abort(_(b"cannot tag null revision"))
7313 raise error.Abort(_(b"cannot tag null revision"))
7311
7314
7312 tagsmod.tag(
7315 tagsmod.tag(
7313 repo,
7316 repo,
7314 names,
7317 names,
7315 node,
7318 node,
7316 message,
7319 message,
7317 opts.get(b'local'),
7320 opts.get(b'local'),
7318 opts.get(b'user'),
7321 opts.get(b'user'),
7319 date,
7322 date,
7320 editor=editor,
7323 editor=editor,
7321 )
7324 )
7322
7325
7323
7326
7324 @command(
7327 @command(
7325 b'tags',
7328 b'tags',
7326 formatteropts,
7329 formatteropts,
7327 b'',
7330 b'',
7328 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
7331 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
7329 intents={INTENT_READONLY},
7332 intents={INTENT_READONLY},
7330 )
7333 )
7331 def tags(ui, repo, **opts):
7334 def tags(ui, repo, **opts):
7332 """list repository tags
7335 """list repository tags
7333
7336
7334 This lists both regular and local tags. When the -v/--verbose
7337 This lists both regular and local tags. When the -v/--verbose
7335 switch is used, a third column "local" is printed for local tags.
7338 switch is used, a third column "local" is printed for local tags.
7336 When the -q/--quiet switch is used, only the tag name is printed.
7339 When the -q/--quiet switch is used, only the tag name is printed.
7337
7340
7338 .. container:: verbose
7341 .. container:: verbose
7339
7342
7340 Template:
7343 Template:
7341
7344
7342 The following keywords are supported in addition to the common template
7345 The following keywords are supported in addition to the common template
7343 keywords and functions such as ``{tag}``. See also
7346 keywords and functions such as ``{tag}``. See also
7344 :hg:`help templates`.
7347 :hg:`help templates`.
7345
7348
7346 :type: String. ``local`` for local tags.
7349 :type: String. ``local`` for local tags.
7347
7350
7348 Returns 0 on success.
7351 Returns 0 on success.
7349 """
7352 """
7350
7353
7351 opts = pycompat.byteskwargs(opts)
7354 opts = pycompat.byteskwargs(opts)
7352 ui.pager(b'tags')
7355 ui.pager(b'tags')
7353 fm = ui.formatter(b'tags', opts)
7356 fm = ui.formatter(b'tags', opts)
7354 hexfunc = fm.hexfunc
7357 hexfunc = fm.hexfunc
7355
7358
7356 for t, n in reversed(repo.tagslist()):
7359 for t, n in reversed(repo.tagslist()):
7357 hn = hexfunc(n)
7360 hn = hexfunc(n)
7358 label = b'tags.normal'
7361 label = b'tags.normal'
7359 tagtype = b''
7362 tagtype = b''
7360 if repo.tagtype(t) == b'local':
7363 if repo.tagtype(t) == b'local':
7361 label = b'tags.local'
7364 label = b'tags.local'
7362 tagtype = b'local'
7365 tagtype = b'local'
7363
7366
7364 fm.startitem()
7367 fm.startitem()
7365 fm.context(repo=repo)
7368 fm.context(repo=repo)
7366 fm.write(b'tag', b'%s', t, label=label)
7369 fm.write(b'tag', b'%s', t, label=label)
7367 fmt = b" " * (30 - encoding.colwidth(t)) + b' %5d:%s'
7370 fmt = b" " * (30 - encoding.colwidth(t)) + b' %5d:%s'
7368 fm.condwrite(
7371 fm.condwrite(
7369 not ui.quiet,
7372 not ui.quiet,
7370 b'rev node',
7373 b'rev node',
7371 fmt,
7374 fmt,
7372 repo.changelog.rev(n),
7375 repo.changelog.rev(n),
7373 hn,
7376 hn,
7374 label=label,
7377 label=label,
7375 )
7378 )
7376 fm.condwrite(
7379 fm.condwrite(
7377 ui.verbose and tagtype, b'type', b' %s', tagtype, label=label
7380 ui.verbose and tagtype, b'type', b' %s', tagtype, label=label
7378 )
7381 )
7379 fm.plain(b'\n')
7382 fm.plain(b'\n')
7380 fm.end()
7383 fm.end()
7381
7384
7382
7385
7383 @command(
7386 @command(
7384 b'tip',
7387 b'tip',
7385 [
7388 [
7386 (b'p', b'patch', None, _(b'show patch')),
7389 (b'p', b'patch', None, _(b'show patch')),
7387 (b'g', b'git', None, _(b'use git extended diff format')),
7390 (b'g', b'git', None, _(b'use git extended diff format')),
7388 ]
7391 ]
7389 + templateopts,
7392 + templateopts,
7390 _(b'[-p] [-g]'),
7393 _(b'[-p] [-g]'),
7391 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
7394 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
7392 )
7395 )
7393 def tip(ui, repo, **opts):
7396 def tip(ui, repo, **opts):
7394 """show the tip revision (DEPRECATED)
7397 """show the tip revision (DEPRECATED)
7395
7398
7396 The tip revision (usually just called the tip) is the changeset
7399 The tip revision (usually just called the tip) is the changeset
7397 most recently added to the repository (and therefore the most
7400 most recently added to the repository (and therefore the most
7398 recently changed head).
7401 recently changed head).
7399
7402
7400 If you have just made a commit, that commit will be the tip. If
7403 If you have just made a commit, that commit will be the tip. If
7401 you have just pulled changes from another repository, the tip of
7404 you have just pulled changes from another repository, the tip of
7402 that repository becomes the current tip. The "tip" tag is special
7405 that repository becomes the current tip. The "tip" tag is special
7403 and cannot be renamed or assigned to a different changeset.
7406 and cannot be renamed or assigned to a different changeset.
7404
7407
7405 This command is deprecated, please use :hg:`heads` instead.
7408 This command is deprecated, please use :hg:`heads` instead.
7406
7409
7407 Returns 0 on success.
7410 Returns 0 on success.
7408 """
7411 """
7409 opts = pycompat.byteskwargs(opts)
7412 opts = pycompat.byteskwargs(opts)
7410 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
7413 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
7411 displayer.show(repo[b'tip'])
7414 displayer.show(repo[b'tip'])
7412 displayer.close()
7415 displayer.close()
7413
7416
7414
7417
7415 @command(
7418 @command(
7416 b'unbundle',
7419 b'unbundle',
7417 [
7420 [
7418 (
7421 (
7419 b'u',
7422 b'u',
7420 b'update',
7423 b'update',
7421 None,
7424 None,
7422 _(b'update to new branch head if changesets were unbundled'),
7425 _(b'update to new branch head if changesets were unbundled'),
7423 )
7426 )
7424 ],
7427 ],
7425 _(b'[-u] FILE...'),
7428 _(b'[-u] FILE...'),
7426 helpcategory=command.CATEGORY_IMPORT_EXPORT,
7429 helpcategory=command.CATEGORY_IMPORT_EXPORT,
7427 )
7430 )
7428 def unbundle(ui, repo, fname1, *fnames, **opts):
7431 def unbundle(ui, repo, fname1, *fnames, **opts):
7429 """apply one or more bundle files
7432 """apply one or more bundle files
7430
7433
7431 Apply one or more bundle files generated by :hg:`bundle`.
7434 Apply one or more bundle files generated by :hg:`bundle`.
7432
7435
7433 Returns 0 on success, 1 if an update has unresolved files.
7436 Returns 0 on success, 1 if an update has unresolved files.
7434 """
7437 """
7435 fnames = (fname1,) + fnames
7438 fnames = (fname1,) + fnames
7436
7439
7437 with repo.lock():
7440 with repo.lock():
7438 for fname in fnames:
7441 for fname in fnames:
7439 f = hg.openpath(ui, fname)
7442 f = hg.openpath(ui, fname)
7440 gen = exchange.readbundle(ui, f, fname)
7443 gen = exchange.readbundle(ui, f, fname)
7441 if isinstance(gen, streamclone.streamcloneapplier):
7444 if isinstance(gen, streamclone.streamcloneapplier):
7442 raise error.Abort(
7445 raise error.Abort(
7443 _(
7446 _(
7444 b'packed bundles cannot be applied with '
7447 b'packed bundles cannot be applied with '
7445 b'"hg unbundle"'
7448 b'"hg unbundle"'
7446 ),
7449 ),
7447 hint=_(b'use "hg debugapplystreamclonebundle"'),
7450 hint=_(b'use "hg debugapplystreamclonebundle"'),
7448 )
7451 )
7449 url = b'bundle:' + fname
7452 url = b'bundle:' + fname
7450 try:
7453 try:
7451 txnname = b'unbundle'
7454 txnname = b'unbundle'
7452 if not isinstance(gen, bundle2.unbundle20):
7455 if not isinstance(gen, bundle2.unbundle20):
7453 txnname = b'unbundle\n%s' % util.hidepassword(url)
7456 txnname = b'unbundle\n%s' % util.hidepassword(url)
7454 with repo.transaction(txnname) as tr:
7457 with repo.transaction(txnname) as tr:
7455 op = bundle2.applybundle(
7458 op = bundle2.applybundle(
7456 repo, gen, tr, source=b'unbundle', url=url
7459 repo, gen, tr, source=b'unbundle', url=url
7457 )
7460 )
7458 except error.BundleUnknownFeatureError as exc:
7461 except error.BundleUnknownFeatureError as exc:
7459 raise error.Abort(
7462 raise error.Abort(
7460 _(b'%s: unknown bundle feature, %s') % (fname, exc),
7463 _(b'%s: unknown bundle feature, %s') % (fname, exc),
7461 hint=_(
7464 hint=_(
7462 b"see https://mercurial-scm.org/"
7465 b"see https://mercurial-scm.org/"
7463 b"wiki/BundleFeature for more "
7466 b"wiki/BundleFeature for more "
7464 b"information"
7467 b"information"
7465 ),
7468 ),
7466 )
7469 )
7467 modheads = bundle2.combinechangegroupresults(op)
7470 modheads = bundle2.combinechangegroupresults(op)
7468
7471
7469 return postincoming(ui, repo, modheads, opts.get(r'update'), None, None)
7472 return postincoming(ui, repo, modheads, opts.get(r'update'), None, None)
7470
7473
7471
7474
7472 @command(
7475 @command(
7473 b'unshelve',
7476 b'unshelve',
7474 [
7477 [
7475 (b'a', b'abort', None, _(b'abort an incomplete unshelve operation')),
7478 (b'a', b'abort', None, _(b'abort an incomplete unshelve operation')),
7476 (
7479 (
7477 b'c',
7480 b'c',
7478 b'continue',
7481 b'continue',
7479 None,
7482 None,
7480 _(b'continue an incomplete unshelve operation'),
7483 _(b'continue an incomplete unshelve operation'),
7481 ),
7484 ),
7482 (b'i', b'interactive', None, _(b'use interactive mode (EXPERIMENTAL)')),
7485 (b'i', b'interactive', None, _(b'use interactive mode (EXPERIMENTAL)')),
7483 (b'k', b'keep', None, _(b'keep shelve after unshelving')),
7486 (b'k', b'keep', None, _(b'keep shelve after unshelving')),
7484 (
7487 (
7485 b'n',
7488 b'n',
7486 b'name',
7489 b'name',
7487 b'',
7490 b'',
7488 _(b'restore shelved change with given name'),
7491 _(b'restore shelved change with given name'),
7489 _(b'NAME'),
7492 _(b'NAME'),
7490 ),
7493 ),
7491 (b't', b'tool', b'', _(b'specify merge tool')),
7494 (b't', b'tool', b'', _(b'specify merge tool')),
7492 (
7495 (
7493 b'',
7496 b'',
7494 b'date',
7497 b'date',
7495 b'',
7498 b'',
7496 _(b'set date for temporary commits (DEPRECATED)'),
7499 _(b'set date for temporary commits (DEPRECATED)'),
7497 _(b'DATE'),
7500 _(b'DATE'),
7498 ),
7501 ),
7499 ],
7502 ],
7500 _(b'hg unshelve [OPTION]... [FILE]... [-n SHELVED]'),
7503 _(b'hg unshelve [OPTION]... [FILE]... [-n SHELVED]'),
7501 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
7504 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
7502 )
7505 )
7503 def unshelve(ui, repo, *shelved, **opts):
7506 def unshelve(ui, repo, *shelved, **opts):
7504 """restore a shelved change to the working directory
7507 """restore a shelved change to the working directory
7505
7508
7506 This command accepts an optional name of a shelved change to
7509 This command accepts an optional name of a shelved change to
7507 restore. If none is given, the most recent shelved change is used.
7510 restore. If none is given, the most recent shelved change is used.
7508
7511
7509 If a shelved change is applied successfully, the bundle that
7512 If a shelved change is applied successfully, the bundle that
7510 contains the shelved changes is moved to a backup location
7513 contains the shelved changes is moved to a backup location
7511 (.hg/shelve-backup).
7514 (.hg/shelve-backup).
7512
7515
7513 Since you can restore a shelved change on top of an arbitrary
7516 Since you can restore a shelved change on top of an arbitrary
7514 commit, it is possible that unshelving will result in a conflict
7517 commit, it is possible that unshelving will result in a conflict
7515 between your changes and the commits you are unshelving onto. If
7518 between your changes and the commits you are unshelving onto. If
7516 this occurs, you must resolve the conflict, then use
7519 this occurs, you must resolve the conflict, then use
7517 ``--continue`` to complete the unshelve operation. (The bundle
7520 ``--continue`` to complete the unshelve operation. (The bundle
7518 will not be moved until you successfully complete the unshelve.)
7521 will not be moved until you successfully complete the unshelve.)
7519
7522
7520 (Alternatively, you can use ``--abort`` to abandon an unshelve
7523 (Alternatively, you can use ``--abort`` to abandon an unshelve
7521 that causes a conflict. This reverts the unshelved changes, and
7524 that causes a conflict. This reverts the unshelved changes, and
7522 leaves the bundle in place.)
7525 leaves the bundle in place.)
7523
7526
7524 If bare shelved change (when no files are specified, without interactive,
7527 If bare shelved change (when no files are specified, without interactive,
7525 include and exclude option) was done on newly created branch it would
7528 include and exclude option) was done on newly created branch it would
7526 restore branch information to the working directory.
7529 restore branch information to the working directory.
7527
7530
7528 After a successful unshelve, the shelved changes are stored in a
7531 After a successful unshelve, the shelved changes are stored in a
7529 backup directory. Only the N most recent backups are kept. N
7532 backup directory. Only the N most recent backups are kept. N
7530 defaults to 10 but can be overridden using the ``shelve.maxbackups``
7533 defaults to 10 but can be overridden using the ``shelve.maxbackups``
7531 configuration option.
7534 configuration option.
7532
7535
7533 .. container:: verbose
7536 .. container:: verbose
7534
7537
7535 Timestamp in seconds is used to decide order of backups. More
7538 Timestamp in seconds is used to decide order of backups. More
7536 than ``maxbackups`` backups are kept, if same timestamp
7539 than ``maxbackups`` backups are kept, if same timestamp
7537 prevents from deciding exact order of them, for safety.
7540 prevents from deciding exact order of them, for safety.
7538
7541
7539 Selected changes can be unshelved with ``--interactive`` flag.
7542 Selected changes can be unshelved with ``--interactive`` flag.
7540 The working directory is updated with the selected changes, and
7543 The working directory is updated with the selected changes, and
7541 only the unselected changes remain shelved.
7544 only the unselected changes remain shelved.
7542 Note: The whole shelve is applied to working directory first before
7545 Note: The whole shelve is applied to working directory first before
7543 running interactively. So, this will bring up all the conflicts between
7546 running interactively. So, this will bring up all the conflicts between
7544 working directory and the shelve, irrespective of which changes will be
7547 working directory and the shelve, irrespective of which changes will be
7545 unshelved.
7548 unshelved.
7546 """
7549 """
7547 with repo.wlock():
7550 with repo.wlock():
7548 return shelvemod.dounshelve(ui, repo, *shelved, **opts)
7551 return shelvemod.dounshelve(ui, repo, *shelved, **opts)
7549
7552
7550
7553
7551 statemod.addunfinished(
7554 statemod.addunfinished(
7552 b'unshelve',
7555 b'unshelve',
7553 fname=b'shelvedstate',
7556 fname=b'shelvedstate',
7554 continueflag=True,
7557 continueflag=True,
7555 abortfunc=shelvemod.hgabortunshelve,
7558 abortfunc=shelvemod.hgabortunshelve,
7556 continuefunc=shelvemod.hgcontinueunshelve,
7559 continuefunc=shelvemod.hgcontinueunshelve,
7557 cmdmsg=_(b'unshelve already in progress'),
7560 cmdmsg=_(b'unshelve already in progress'),
7558 )
7561 )
7559
7562
7560
7563
7561 @command(
7564 @command(
7562 b'update|up|checkout|co',
7565 b'update|up|checkout|co',
7563 [
7566 [
7564 (b'C', b'clean', None, _(b'discard uncommitted changes (no backup)')),
7567 (b'C', b'clean', None, _(b'discard uncommitted changes (no backup)')),
7565 (b'c', b'check', None, _(b'require clean working directory')),
7568 (b'c', b'check', None, _(b'require clean working directory')),
7566 (b'm', b'merge', None, _(b'merge uncommitted changes')),
7569 (b'm', b'merge', None, _(b'merge uncommitted changes')),
7567 (b'd', b'date', b'', _(b'tipmost revision matching date'), _(b'DATE')),
7570 (b'd', b'date', b'', _(b'tipmost revision matching date'), _(b'DATE')),
7568 (b'r', b'rev', b'', _(b'revision'), _(b'REV')),
7571 (b'r', b'rev', b'', _(b'revision'), _(b'REV')),
7569 ]
7572 ]
7570 + mergetoolopts,
7573 + mergetoolopts,
7571 _(b'[-C|-c|-m] [-d DATE] [[-r] REV]'),
7574 _(b'[-C|-c|-m] [-d DATE] [[-r] REV]'),
7572 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
7575 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
7573 helpbasic=True,
7576 helpbasic=True,
7574 )
7577 )
7575 def update(ui, repo, node=None, **opts):
7578 def update(ui, repo, node=None, **opts):
7576 """update working directory (or switch revisions)
7579 """update working directory (or switch revisions)
7577
7580
7578 Update the repository's working directory to the specified
7581 Update the repository's working directory to the specified
7579 changeset. If no changeset is specified, update to the tip of the
7582 changeset. If no changeset is specified, update to the tip of the
7580 current named branch and move the active bookmark (see :hg:`help
7583 current named branch and move the active bookmark (see :hg:`help
7581 bookmarks`).
7584 bookmarks`).
7582
7585
7583 Update sets the working directory's parent revision to the specified
7586 Update sets the working directory's parent revision to the specified
7584 changeset (see :hg:`help parents`).
7587 changeset (see :hg:`help parents`).
7585
7588
7586 If the changeset is not a descendant or ancestor of the working
7589 If the changeset is not a descendant or ancestor of the working
7587 directory's parent and there are uncommitted changes, the update is
7590 directory's parent and there are uncommitted changes, the update is
7588 aborted. With the -c/--check option, the working directory is checked
7591 aborted. With the -c/--check option, the working directory is checked
7589 for uncommitted changes; if none are found, the working directory is
7592 for uncommitted changes; if none are found, the working directory is
7590 updated to the specified changeset.
7593 updated to the specified changeset.
7591
7594
7592 .. container:: verbose
7595 .. container:: verbose
7593
7596
7594 The -C/--clean, -c/--check, and -m/--merge options control what
7597 The -C/--clean, -c/--check, and -m/--merge options control what
7595 happens if the working directory contains uncommitted changes.
7598 happens if the working directory contains uncommitted changes.
7596 At most of one of them can be specified.
7599 At most of one of them can be specified.
7597
7600
7598 1. If no option is specified, and if
7601 1. If no option is specified, and if
7599 the requested changeset is an ancestor or descendant of
7602 the requested changeset is an ancestor or descendant of
7600 the working directory's parent, the uncommitted changes
7603 the working directory's parent, the uncommitted changes
7601 are merged into the requested changeset and the merged
7604 are merged into the requested changeset and the merged
7602 result is left uncommitted. If the requested changeset is
7605 result is left uncommitted. If the requested changeset is
7603 not an ancestor or descendant (that is, it is on another
7606 not an ancestor or descendant (that is, it is on another
7604 branch), the update is aborted and the uncommitted changes
7607 branch), the update is aborted and the uncommitted changes
7605 are preserved.
7608 are preserved.
7606
7609
7607 2. With the -m/--merge option, the update is allowed even if the
7610 2. With the -m/--merge option, the update is allowed even if the
7608 requested changeset is not an ancestor or descendant of
7611 requested changeset is not an ancestor or descendant of
7609 the working directory's parent.
7612 the working directory's parent.
7610
7613
7611 3. With the -c/--check option, the update is aborted and the
7614 3. With the -c/--check option, the update is aborted and the
7612 uncommitted changes are preserved.
7615 uncommitted changes are preserved.
7613
7616
7614 4. With the -C/--clean option, uncommitted changes are discarded and
7617 4. With the -C/--clean option, uncommitted changes are discarded and
7615 the working directory is updated to the requested changeset.
7618 the working directory is updated to the requested changeset.
7616
7619
7617 To cancel an uncommitted merge (and lose your changes), use
7620 To cancel an uncommitted merge (and lose your changes), use
7618 :hg:`merge --abort`.
7621 :hg:`merge --abort`.
7619
7622
7620 Use null as the changeset to remove the working directory (like
7623 Use null as the changeset to remove the working directory (like
7621 :hg:`clone -U`).
7624 :hg:`clone -U`).
7622
7625
7623 If you want to revert just one file to an older revision, use
7626 If you want to revert just one file to an older revision, use
7624 :hg:`revert [-r REV] NAME`.
7627 :hg:`revert [-r REV] NAME`.
7625
7628
7626 See :hg:`help dates` for a list of formats valid for -d/--date.
7629 See :hg:`help dates` for a list of formats valid for -d/--date.
7627
7630
7628 Returns 0 on success, 1 if there are unresolved files.
7631 Returns 0 on success, 1 if there are unresolved files.
7629 """
7632 """
7630 rev = opts.get(r'rev')
7633 rev = opts.get(r'rev')
7631 date = opts.get(r'date')
7634 date = opts.get(r'date')
7632 clean = opts.get(r'clean')
7635 clean = opts.get(r'clean')
7633 check = opts.get(r'check')
7636 check = opts.get(r'check')
7634 merge = opts.get(r'merge')
7637 merge = opts.get(r'merge')
7635 if rev and node:
7638 if rev and node:
7636 raise error.Abort(_(b"please specify just one revision"))
7639 raise error.Abort(_(b"please specify just one revision"))
7637
7640
7638 if ui.configbool(b'commands', b'update.requiredest'):
7641 if ui.configbool(b'commands', b'update.requiredest'):
7639 if not node and not rev and not date:
7642 if not node and not rev and not date:
7640 raise error.Abort(
7643 raise error.Abort(
7641 _(b'you must specify a destination'),
7644 _(b'you must specify a destination'),
7642 hint=_(b'for example: hg update ".::"'),
7645 hint=_(b'for example: hg update ".::"'),
7643 )
7646 )
7644
7647
7645 if rev is None or rev == b'':
7648 if rev is None or rev == b'':
7646 rev = node
7649 rev = node
7647
7650
7648 if date and rev is not None:
7651 if date and rev is not None:
7649 raise error.Abort(_(b"you can't specify a revision and a date"))
7652 raise error.Abort(_(b"you can't specify a revision and a date"))
7650
7653
7651 if len([x for x in (clean, check, merge) if x]) > 1:
7654 if len([x for x in (clean, check, merge) if x]) > 1:
7652 raise error.Abort(
7655 raise error.Abort(
7653 _(
7656 _(
7654 b"can only specify one of -C/--clean, -c/--check, "
7657 b"can only specify one of -C/--clean, -c/--check, "
7655 b"or -m/--merge"
7658 b"or -m/--merge"
7656 )
7659 )
7657 )
7660 )
7658
7661
7659 updatecheck = None
7662 updatecheck = None
7660 if check:
7663 if check:
7661 updatecheck = b'abort'
7664 updatecheck = b'abort'
7662 elif merge:
7665 elif merge:
7663 updatecheck = b'none'
7666 updatecheck = b'none'
7664
7667
7665 with repo.wlock():
7668 with repo.wlock():
7666 cmdutil.clearunfinished(repo)
7669 cmdutil.clearunfinished(repo)
7667 if date:
7670 if date:
7668 rev = cmdutil.finddate(ui, repo, date)
7671 rev = cmdutil.finddate(ui, repo, date)
7669
7672
7670 # if we defined a bookmark, we have to remember the original name
7673 # if we defined a bookmark, we have to remember the original name
7671 brev = rev
7674 brev = rev
7672 if rev:
7675 if rev:
7673 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
7676 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
7674 ctx = scmutil.revsingle(repo, rev, default=None)
7677 ctx = scmutil.revsingle(repo, rev, default=None)
7675 rev = ctx.rev()
7678 rev = ctx.rev()
7676 hidden = ctx.hidden()
7679 hidden = ctx.hidden()
7677 overrides = {(b'ui', b'forcemerge'): opts.get(r'tool', b'')}
7680 overrides = {(b'ui', b'forcemerge'): opts.get(r'tool', b'')}
7678 with ui.configoverride(overrides, b'update'):
7681 with ui.configoverride(overrides, b'update'):
7679 ret = hg.updatetotally(
7682 ret = hg.updatetotally(
7680 ui, repo, rev, brev, clean=clean, updatecheck=updatecheck
7683 ui, repo, rev, brev, clean=clean, updatecheck=updatecheck
7681 )
7684 )
7682 if hidden:
7685 if hidden:
7683 ctxstr = ctx.hex()[:12]
7686 ctxstr = ctx.hex()[:12]
7684 ui.warn(_(b"updated to hidden changeset %s\n") % ctxstr)
7687 ui.warn(_(b"updated to hidden changeset %s\n") % ctxstr)
7685
7688
7686 if ctx.obsolete():
7689 if ctx.obsolete():
7687 obsfatemsg = obsutil._getfilteredreason(repo, ctxstr, ctx)
7690 obsfatemsg = obsutil._getfilteredreason(repo, ctxstr, ctx)
7688 ui.warn(b"(%s)\n" % obsfatemsg)
7691 ui.warn(b"(%s)\n" % obsfatemsg)
7689 return ret
7692 return ret
7690
7693
7691
7694
7692 @command(
7695 @command(
7693 b'verify',
7696 b'verify',
7694 [(b'', b'full', False, b'perform more checks (EXPERIMENTAL)')],
7697 [(b'', b'full', False, b'perform more checks (EXPERIMENTAL)')],
7695 helpcategory=command.CATEGORY_MAINTENANCE,
7698 helpcategory=command.CATEGORY_MAINTENANCE,
7696 )
7699 )
7697 def verify(ui, repo, **opts):
7700 def verify(ui, repo, **opts):
7698 """verify the integrity of the repository
7701 """verify the integrity of the repository
7699
7702
7700 Verify the integrity of the current repository.
7703 Verify the integrity of the current repository.
7701
7704
7702 This will perform an extensive check of the repository's
7705 This will perform an extensive check of the repository's
7703 integrity, validating the hashes and checksums of each entry in
7706 integrity, validating the hashes and checksums of each entry in
7704 the changelog, manifest, and tracked files, as well as the
7707 the changelog, manifest, and tracked files, as well as the
7705 integrity of their crosslinks and indices.
7708 integrity of their crosslinks and indices.
7706
7709
7707 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
7710 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
7708 for more information about recovery from corruption of the
7711 for more information about recovery from corruption of the
7709 repository.
7712 repository.
7710
7713
7711 Returns 0 on success, 1 if errors are encountered.
7714 Returns 0 on success, 1 if errors are encountered.
7712 """
7715 """
7713 opts = pycompat.byteskwargs(opts)
7716 opts = pycompat.byteskwargs(opts)
7714
7717
7715 level = None
7718 level = None
7716 if opts[b'full']:
7719 if opts[b'full']:
7717 level = verifymod.VERIFY_FULL
7720 level = verifymod.VERIFY_FULL
7718 return hg.verify(repo, level)
7721 return hg.verify(repo, level)
7719
7722
7720
7723
7721 @command(
7724 @command(
7722 b'version',
7725 b'version',
7723 [] + formatteropts,
7726 [] + formatteropts,
7724 helpcategory=command.CATEGORY_HELP,
7727 helpcategory=command.CATEGORY_HELP,
7725 norepo=True,
7728 norepo=True,
7726 intents={INTENT_READONLY},
7729 intents={INTENT_READONLY},
7727 )
7730 )
7728 def version_(ui, **opts):
7731 def version_(ui, **opts):
7729 """output version and copyright information
7732 """output version and copyright information
7730
7733
7731 .. container:: verbose
7734 .. container:: verbose
7732
7735
7733 Template:
7736 Template:
7734
7737
7735 The following keywords are supported. See also :hg:`help templates`.
7738 The following keywords are supported. See also :hg:`help templates`.
7736
7739
7737 :extensions: List of extensions.
7740 :extensions: List of extensions.
7738 :ver: String. Version number.
7741 :ver: String. Version number.
7739
7742
7740 And each entry of ``{extensions}`` provides the following sub-keywords
7743 And each entry of ``{extensions}`` provides the following sub-keywords
7741 in addition to ``{ver}``.
7744 in addition to ``{ver}``.
7742
7745
7743 :bundled: Boolean. True if included in the release.
7746 :bundled: Boolean. True if included in the release.
7744 :name: String. Extension name.
7747 :name: String. Extension name.
7745 """
7748 """
7746 opts = pycompat.byteskwargs(opts)
7749 opts = pycompat.byteskwargs(opts)
7747 if ui.verbose:
7750 if ui.verbose:
7748 ui.pager(b'version')
7751 ui.pager(b'version')
7749 fm = ui.formatter(b"version", opts)
7752 fm = ui.formatter(b"version", opts)
7750 fm.startitem()
7753 fm.startitem()
7751 fm.write(
7754 fm.write(
7752 b"ver", _(b"Mercurial Distributed SCM (version %s)\n"), util.version()
7755 b"ver", _(b"Mercurial Distributed SCM (version %s)\n"), util.version()
7753 )
7756 )
7754 license = _(
7757 license = _(
7755 b"(see https://mercurial-scm.org for more information)\n"
7758 b"(see https://mercurial-scm.org for more information)\n"
7756 b"\nCopyright (C) 2005-2019 Matt Mackall and others\n"
7759 b"\nCopyright (C) 2005-2019 Matt Mackall and others\n"
7757 b"This is free software; see the source for copying conditions. "
7760 b"This is free software; see the source for copying conditions. "
7758 b"There is NO\nwarranty; "
7761 b"There is NO\nwarranty; "
7759 b"not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
7762 b"not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
7760 )
7763 )
7761 if not ui.quiet:
7764 if not ui.quiet:
7762 fm.plain(license)
7765 fm.plain(license)
7763
7766
7764 if ui.verbose:
7767 if ui.verbose:
7765 fm.plain(_(b"\nEnabled extensions:\n\n"))
7768 fm.plain(_(b"\nEnabled extensions:\n\n"))
7766 # format names and versions into columns
7769 # format names and versions into columns
7767 names = []
7770 names = []
7768 vers = []
7771 vers = []
7769 isinternals = []
7772 isinternals = []
7770 for name, module in extensions.extensions():
7773 for name, module in extensions.extensions():
7771 names.append(name)
7774 names.append(name)
7772 vers.append(extensions.moduleversion(module) or None)
7775 vers.append(extensions.moduleversion(module) or None)
7773 isinternals.append(extensions.ismoduleinternal(module))
7776 isinternals.append(extensions.ismoduleinternal(module))
7774 fn = fm.nested(b"extensions", tmpl=b'{name}\n')
7777 fn = fm.nested(b"extensions", tmpl=b'{name}\n')
7775 if names:
7778 if names:
7776 namefmt = b" %%-%ds " % max(len(n) for n in names)
7779 namefmt = b" %%-%ds " % max(len(n) for n in names)
7777 places = [_(b"external"), _(b"internal")]
7780 places = [_(b"external"), _(b"internal")]
7778 for n, v, p in zip(names, vers, isinternals):
7781 for n, v, p in zip(names, vers, isinternals):
7779 fn.startitem()
7782 fn.startitem()
7780 fn.condwrite(ui.verbose, b"name", namefmt, n)
7783 fn.condwrite(ui.verbose, b"name", namefmt, n)
7781 if ui.verbose:
7784 if ui.verbose:
7782 fn.plain(b"%s " % places[p])
7785 fn.plain(b"%s " % places[p])
7783 fn.data(bundled=p)
7786 fn.data(bundled=p)
7784 fn.condwrite(ui.verbose and v, b"ver", b"%s", v)
7787 fn.condwrite(ui.verbose and v, b"ver", b"%s", v)
7785 if ui.verbose:
7788 if ui.verbose:
7786 fn.plain(b"\n")
7789 fn.plain(b"\n")
7787 fn.end()
7790 fn.end()
7788 fm.end()
7791 fm.end()
7789
7792
7790
7793
7791 def loadcmdtable(ui, name, cmdtable):
7794 def loadcmdtable(ui, name, cmdtable):
7792 """Load command functions from specified cmdtable
7795 """Load command functions from specified cmdtable
7793 """
7796 """
7794 overrides = [cmd for cmd in cmdtable if cmd in table]
7797 overrides = [cmd for cmd in cmdtable if cmd in table]
7795 if overrides:
7798 if overrides:
7796 ui.warn(
7799 ui.warn(
7797 _(b"extension '%s' overrides commands: %s\n")
7800 _(b"extension '%s' overrides commands: %s\n")
7798 % (name, b" ".join(overrides))
7801 % (name, b" ".join(overrides))
7799 )
7802 )
7800 table.update(cmdtable)
7803 table.update(cmdtable)
@@ -1,1540 +1,1543 b''
1 # configitems.py - centralized declaration of configuration option
1 # configitems.py - centralized declaration of configuration option
2 #
2 #
3 # Copyright 2017 Pierre-Yves David <pierre-yves.david@octobus.net>
3 # Copyright 2017 Pierre-Yves David <pierre-yves.david@octobus.net>
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 functools
10 import functools
11 import re
11 import re
12
12
13 from . import (
13 from . import (
14 encoding,
14 encoding,
15 error,
15 error,
16 )
16 )
17
17
18
18
19 def loadconfigtable(ui, extname, configtable):
19 def loadconfigtable(ui, extname, configtable):
20 """update config item known to the ui with the extension ones"""
20 """update config item known to the ui with the extension ones"""
21 for section, items in sorted(configtable.items()):
21 for section, items in sorted(configtable.items()):
22 knownitems = ui._knownconfig.setdefault(section, itemregister())
22 knownitems = ui._knownconfig.setdefault(section, itemregister())
23 knownkeys = set(knownitems)
23 knownkeys = set(knownitems)
24 newkeys = set(items)
24 newkeys = set(items)
25 for key in sorted(knownkeys & newkeys):
25 for key in sorted(knownkeys & newkeys):
26 msg = b"extension '%s' overwrite config item '%s.%s'"
26 msg = b"extension '%s' overwrite config item '%s.%s'"
27 msg %= (extname, section, key)
27 msg %= (extname, section, key)
28 ui.develwarn(msg, config=b'warn-config')
28 ui.develwarn(msg, config=b'warn-config')
29
29
30 knownitems.update(items)
30 knownitems.update(items)
31
31
32
32
33 class configitem(object):
33 class configitem(object):
34 """represent a known config item
34 """represent a known config item
35
35
36 :section: the official config section where to find this item,
36 :section: the official config section where to find this item,
37 :name: the official name within the section,
37 :name: the official name within the section,
38 :default: default value for this item,
38 :default: default value for this item,
39 :alias: optional list of tuples as alternatives,
39 :alias: optional list of tuples as alternatives,
40 :generic: this is a generic definition, match name using regular expression.
40 :generic: this is a generic definition, match name using regular expression.
41 """
41 """
42
42
43 def __init__(
43 def __init__(
44 self,
44 self,
45 section,
45 section,
46 name,
46 name,
47 default=None,
47 default=None,
48 alias=(),
48 alias=(),
49 generic=False,
49 generic=False,
50 priority=0,
50 priority=0,
51 experimental=False,
51 experimental=False,
52 ):
52 ):
53 self.section = section
53 self.section = section
54 self.name = name
54 self.name = name
55 self.default = default
55 self.default = default
56 self.alias = list(alias)
56 self.alias = list(alias)
57 self.generic = generic
57 self.generic = generic
58 self.priority = priority
58 self.priority = priority
59 self.experimental = experimental
59 self.experimental = experimental
60 self._re = None
60 self._re = None
61 if generic:
61 if generic:
62 self._re = re.compile(self.name)
62 self._re = re.compile(self.name)
63
63
64
64
65 class itemregister(dict):
65 class itemregister(dict):
66 """A specialized dictionary that can handle wild-card selection"""
66 """A specialized dictionary that can handle wild-card selection"""
67
67
68 def __init__(self):
68 def __init__(self):
69 super(itemregister, self).__init__()
69 super(itemregister, self).__init__()
70 self._generics = set()
70 self._generics = set()
71
71
72 def update(self, other):
72 def update(self, other):
73 super(itemregister, self).update(other)
73 super(itemregister, self).update(other)
74 self._generics.update(other._generics)
74 self._generics.update(other._generics)
75
75
76 def __setitem__(self, key, item):
76 def __setitem__(self, key, item):
77 super(itemregister, self).__setitem__(key, item)
77 super(itemregister, self).__setitem__(key, item)
78 if item.generic:
78 if item.generic:
79 self._generics.add(item)
79 self._generics.add(item)
80
80
81 def get(self, key):
81 def get(self, key):
82 baseitem = super(itemregister, self).get(key)
82 baseitem = super(itemregister, self).get(key)
83 if baseitem is not None and not baseitem.generic:
83 if baseitem is not None and not baseitem.generic:
84 return baseitem
84 return baseitem
85
85
86 # search for a matching generic item
86 # search for a matching generic item
87 generics = sorted(self._generics, key=(lambda x: (x.priority, x.name)))
87 generics = sorted(self._generics, key=(lambda x: (x.priority, x.name)))
88 for item in generics:
88 for item in generics:
89 # we use 'match' instead of 'search' to make the matching simpler
89 # we use 'match' instead of 'search' to make the matching simpler
90 # for people unfamiliar with regular expression. Having the match
90 # for people unfamiliar with regular expression. Having the match
91 # rooted to the start of the string will produce less surprising
91 # rooted to the start of the string will produce less surprising
92 # result for user writing simple regex for sub-attribute.
92 # result for user writing simple regex for sub-attribute.
93 #
93 #
94 # For example using "color\..*" match produces an unsurprising
94 # For example using "color\..*" match produces an unsurprising
95 # result, while using search could suddenly match apparently
95 # result, while using search could suddenly match apparently
96 # unrelated configuration that happens to contains "color."
96 # unrelated configuration that happens to contains "color."
97 # anywhere. This is a tradeoff where we favor requiring ".*" on
97 # anywhere. This is a tradeoff where we favor requiring ".*" on
98 # some match to avoid the need to prefix most pattern with "^".
98 # some match to avoid the need to prefix most pattern with "^".
99 # The "^" seems more error prone.
99 # The "^" seems more error prone.
100 if item._re.match(key):
100 if item._re.match(key):
101 return item
101 return item
102
102
103 return None
103 return None
104
104
105
105
106 coreitems = {}
106 coreitems = {}
107
107
108
108
109 def _register(configtable, *args, **kwargs):
109 def _register(configtable, *args, **kwargs):
110 item = configitem(*args, **kwargs)
110 item = configitem(*args, **kwargs)
111 section = configtable.setdefault(item.section, itemregister())
111 section = configtable.setdefault(item.section, itemregister())
112 if item.name in section:
112 if item.name in section:
113 msg = b"duplicated config item registration for '%s.%s'"
113 msg = b"duplicated config item registration for '%s.%s'"
114 raise error.ProgrammingError(msg % (item.section, item.name))
114 raise error.ProgrammingError(msg % (item.section, item.name))
115 section[item.name] = item
115 section[item.name] = item
116
116
117
117
118 # special value for case where the default is derived from other values
118 # special value for case where the default is derived from other values
119 dynamicdefault = object()
119 dynamicdefault = object()
120
120
121 # Registering actual config items
121 # Registering actual config items
122
122
123
123
124 def getitemregister(configtable):
124 def getitemregister(configtable):
125 f = functools.partial(_register, configtable)
125 f = functools.partial(_register, configtable)
126 # export pseudo enum as configitem.*
126 # export pseudo enum as configitem.*
127 f.dynamicdefault = dynamicdefault
127 f.dynamicdefault = dynamicdefault
128 return f
128 return f
129
129
130
130
131 coreconfigitem = getitemregister(coreitems)
131 coreconfigitem = getitemregister(coreitems)
132
132
133
133
134 def _registerdiffopts(section, configprefix=b''):
134 def _registerdiffopts(section, configprefix=b''):
135 coreconfigitem(
135 coreconfigitem(
136 section, configprefix + b'nodates', default=False,
136 section, configprefix + b'nodates', default=False,
137 )
137 )
138 coreconfigitem(
138 coreconfigitem(
139 section, configprefix + b'showfunc', default=False,
139 section, configprefix + b'showfunc', default=False,
140 )
140 )
141 coreconfigitem(
141 coreconfigitem(
142 section, configprefix + b'unified', default=None,
142 section, configprefix + b'unified', default=None,
143 )
143 )
144 coreconfigitem(
144 coreconfigitem(
145 section, configprefix + b'git', default=False,
145 section, configprefix + b'git', default=False,
146 )
146 )
147 coreconfigitem(
147 coreconfigitem(
148 section, configprefix + b'ignorews', default=False,
148 section, configprefix + b'ignorews', default=False,
149 )
149 )
150 coreconfigitem(
150 coreconfigitem(
151 section, configprefix + b'ignorewsamount', default=False,
151 section, configprefix + b'ignorewsamount', default=False,
152 )
152 )
153 coreconfigitem(
153 coreconfigitem(
154 section, configprefix + b'ignoreblanklines', default=False,
154 section, configprefix + b'ignoreblanklines', default=False,
155 )
155 )
156 coreconfigitem(
156 coreconfigitem(
157 section, configprefix + b'ignorewseol', default=False,
157 section, configprefix + b'ignorewseol', default=False,
158 )
158 )
159 coreconfigitem(
159 coreconfigitem(
160 section, configprefix + b'nobinary', default=False,
160 section, configprefix + b'nobinary', default=False,
161 )
161 )
162 coreconfigitem(
162 coreconfigitem(
163 section, configprefix + b'noprefix', default=False,
163 section, configprefix + b'noprefix', default=False,
164 )
164 )
165 coreconfigitem(
165 coreconfigitem(
166 section, configprefix + b'word-diff', default=False,
166 section, configprefix + b'word-diff', default=False,
167 )
167 )
168
168
169
169
170 coreconfigitem(
170 coreconfigitem(
171 b'alias', b'.*', default=dynamicdefault, generic=True,
171 b'alias', b'.*', default=dynamicdefault, generic=True,
172 )
172 )
173 coreconfigitem(
173 coreconfigitem(
174 b'auth', b'cookiefile', default=None,
174 b'auth', b'cookiefile', default=None,
175 )
175 )
176 _registerdiffopts(section=b'annotate')
176 _registerdiffopts(section=b'annotate')
177 # bookmarks.pushing: internal hack for discovery
177 # bookmarks.pushing: internal hack for discovery
178 coreconfigitem(
178 coreconfigitem(
179 b'bookmarks', b'pushing', default=list,
179 b'bookmarks', b'pushing', default=list,
180 )
180 )
181 # bundle.mainreporoot: internal hack for bundlerepo
181 # bundle.mainreporoot: internal hack for bundlerepo
182 coreconfigitem(
182 coreconfigitem(
183 b'bundle', b'mainreporoot', default=b'',
183 b'bundle', b'mainreporoot', default=b'',
184 )
184 )
185 coreconfigitem(
185 coreconfigitem(
186 b'censor', b'policy', default=b'abort', experimental=True,
186 b'censor', b'policy', default=b'abort', experimental=True,
187 )
187 )
188 coreconfigitem(
188 coreconfigitem(
189 b'chgserver', b'idletimeout', default=3600,
189 b'chgserver', b'idletimeout', default=3600,
190 )
190 )
191 coreconfigitem(
191 coreconfigitem(
192 b'chgserver', b'skiphash', default=False,
192 b'chgserver', b'skiphash', default=False,
193 )
193 )
194 coreconfigitem(
194 coreconfigitem(
195 b'cmdserver', b'log', default=None,
195 b'cmdserver', b'log', default=None,
196 )
196 )
197 coreconfigitem(
197 coreconfigitem(
198 b'cmdserver', b'max-log-files', default=7,
198 b'cmdserver', b'max-log-files', default=7,
199 )
199 )
200 coreconfigitem(
200 coreconfigitem(
201 b'cmdserver', b'max-log-size', default=b'1 MB',
201 b'cmdserver', b'max-log-size', default=b'1 MB',
202 )
202 )
203 coreconfigitem(
203 coreconfigitem(
204 b'cmdserver', b'max-repo-cache', default=0, experimental=True,
204 b'cmdserver', b'max-repo-cache', default=0, experimental=True,
205 )
205 )
206 coreconfigitem(
206 coreconfigitem(
207 b'cmdserver', b'message-encodings', default=list, experimental=True,
207 b'cmdserver', b'message-encodings', default=list, experimental=True,
208 )
208 )
209 coreconfigitem(
209 coreconfigitem(
210 b'cmdserver',
210 b'cmdserver',
211 b'track-log',
211 b'track-log',
212 default=lambda: [b'chgserver', b'cmdserver', b'repocache'],
212 default=lambda: [b'chgserver', b'cmdserver', b'repocache'],
213 )
213 )
214 coreconfigitem(
214 coreconfigitem(
215 b'color', b'.*', default=None, generic=True,
215 b'color', b'.*', default=None, generic=True,
216 )
216 )
217 coreconfigitem(
217 coreconfigitem(
218 b'color', b'mode', default=b'auto',
218 b'color', b'mode', default=b'auto',
219 )
219 )
220 coreconfigitem(
220 coreconfigitem(
221 b'color', b'pagermode', default=dynamicdefault,
221 b'color', b'pagermode', default=dynamicdefault,
222 )
222 )
223 _registerdiffopts(section=b'commands', configprefix=b'commit.interactive.')
223 _registerdiffopts(section=b'commands', configprefix=b'commit.interactive.')
224 coreconfigitem(
224 coreconfigitem(
225 b'commands', b'commit.post-status', default=False,
225 b'commands', b'commit.post-status', default=False,
226 )
226 )
227 coreconfigitem(
227 coreconfigitem(
228 b'commands', b'grep.all-files', default=False, experimental=True,
228 b'commands', b'grep.all-files', default=False, experimental=True,
229 )
229 )
230 coreconfigitem(
230 coreconfigitem(
231 b'commands', b'push.require-revs', default=False,
232 )
233 coreconfigitem(
231 b'commands', b'resolve.confirm', default=False,
234 b'commands', b'resolve.confirm', default=False,
232 )
235 )
233 coreconfigitem(
236 coreconfigitem(
234 b'commands', b'resolve.explicit-re-merge', default=False,
237 b'commands', b'resolve.explicit-re-merge', default=False,
235 )
238 )
236 coreconfigitem(
239 coreconfigitem(
237 b'commands', b'resolve.mark-check', default=b'none',
240 b'commands', b'resolve.mark-check', default=b'none',
238 )
241 )
239 _registerdiffopts(section=b'commands', configprefix=b'revert.interactive.')
242 _registerdiffopts(section=b'commands', configprefix=b'revert.interactive.')
240 coreconfigitem(
243 coreconfigitem(
241 b'commands', b'show.aliasprefix', default=list,
244 b'commands', b'show.aliasprefix', default=list,
242 )
245 )
243 coreconfigitem(
246 coreconfigitem(
244 b'commands', b'status.relative', default=False,
247 b'commands', b'status.relative', default=False,
245 )
248 )
246 coreconfigitem(
249 coreconfigitem(
247 b'commands', b'status.skipstates', default=[], experimental=True,
250 b'commands', b'status.skipstates', default=[], experimental=True,
248 )
251 )
249 coreconfigitem(
252 coreconfigitem(
250 b'commands', b'status.terse', default=b'',
253 b'commands', b'status.terse', default=b'',
251 )
254 )
252 coreconfigitem(
255 coreconfigitem(
253 b'commands', b'status.verbose', default=False,
256 b'commands', b'status.verbose', default=False,
254 )
257 )
255 coreconfigitem(
258 coreconfigitem(
256 b'commands', b'update.check', default=None,
259 b'commands', b'update.check', default=None,
257 )
260 )
258 coreconfigitem(
261 coreconfigitem(
259 b'commands', b'update.requiredest', default=False,
262 b'commands', b'update.requiredest', default=False,
260 )
263 )
261 coreconfigitem(
264 coreconfigitem(
262 b'committemplate', b'.*', default=None, generic=True,
265 b'committemplate', b'.*', default=None, generic=True,
263 )
266 )
264 coreconfigitem(
267 coreconfigitem(
265 b'convert', b'bzr.saverev', default=True,
268 b'convert', b'bzr.saverev', default=True,
266 )
269 )
267 coreconfigitem(
270 coreconfigitem(
268 b'convert', b'cvsps.cache', default=True,
271 b'convert', b'cvsps.cache', default=True,
269 )
272 )
270 coreconfigitem(
273 coreconfigitem(
271 b'convert', b'cvsps.fuzz', default=60,
274 b'convert', b'cvsps.fuzz', default=60,
272 )
275 )
273 coreconfigitem(
276 coreconfigitem(
274 b'convert', b'cvsps.logencoding', default=None,
277 b'convert', b'cvsps.logencoding', default=None,
275 )
278 )
276 coreconfigitem(
279 coreconfigitem(
277 b'convert', b'cvsps.mergefrom', default=None,
280 b'convert', b'cvsps.mergefrom', default=None,
278 )
281 )
279 coreconfigitem(
282 coreconfigitem(
280 b'convert', b'cvsps.mergeto', default=None,
283 b'convert', b'cvsps.mergeto', default=None,
281 )
284 )
282 coreconfigitem(
285 coreconfigitem(
283 b'convert', b'git.committeractions', default=lambda: [b'messagedifferent'],
286 b'convert', b'git.committeractions', default=lambda: [b'messagedifferent'],
284 )
287 )
285 coreconfigitem(
288 coreconfigitem(
286 b'convert', b'git.extrakeys', default=list,
289 b'convert', b'git.extrakeys', default=list,
287 )
290 )
288 coreconfigitem(
291 coreconfigitem(
289 b'convert', b'git.findcopiesharder', default=False,
292 b'convert', b'git.findcopiesharder', default=False,
290 )
293 )
291 coreconfigitem(
294 coreconfigitem(
292 b'convert', b'git.remoteprefix', default=b'remote',
295 b'convert', b'git.remoteprefix', default=b'remote',
293 )
296 )
294 coreconfigitem(
297 coreconfigitem(
295 b'convert', b'git.renamelimit', default=400,
298 b'convert', b'git.renamelimit', default=400,
296 )
299 )
297 coreconfigitem(
300 coreconfigitem(
298 b'convert', b'git.saverev', default=True,
301 b'convert', b'git.saverev', default=True,
299 )
302 )
300 coreconfigitem(
303 coreconfigitem(
301 b'convert', b'git.similarity', default=50,
304 b'convert', b'git.similarity', default=50,
302 )
305 )
303 coreconfigitem(
306 coreconfigitem(
304 b'convert', b'git.skipsubmodules', default=False,
307 b'convert', b'git.skipsubmodules', default=False,
305 )
308 )
306 coreconfigitem(
309 coreconfigitem(
307 b'convert', b'hg.clonebranches', default=False,
310 b'convert', b'hg.clonebranches', default=False,
308 )
311 )
309 coreconfigitem(
312 coreconfigitem(
310 b'convert', b'hg.ignoreerrors', default=False,
313 b'convert', b'hg.ignoreerrors', default=False,
311 )
314 )
312 coreconfigitem(
315 coreconfigitem(
313 b'convert', b'hg.preserve-hash', default=False,
316 b'convert', b'hg.preserve-hash', default=False,
314 )
317 )
315 coreconfigitem(
318 coreconfigitem(
316 b'convert', b'hg.revs', default=None,
319 b'convert', b'hg.revs', default=None,
317 )
320 )
318 coreconfigitem(
321 coreconfigitem(
319 b'convert', b'hg.saverev', default=False,
322 b'convert', b'hg.saverev', default=False,
320 )
323 )
321 coreconfigitem(
324 coreconfigitem(
322 b'convert', b'hg.sourcename', default=None,
325 b'convert', b'hg.sourcename', default=None,
323 )
326 )
324 coreconfigitem(
327 coreconfigitem(
325 b'convert', b'hg.startrev', default=None,
328 b'convert', b'hg.startrev', default=None,
326 )
329 )
327 coreconfigitem(
330 coreconfigitem(
328 b'convert', b'hg.tagsbranch', default=b'default',
331 b'convert', b'hg.tagsbranch', default=b'default',
329 )
332 )
330 coreconfigitem(
333 coreconfigitem(
331 b'convert', b'hg.usebranchnames', default=True,
334 b'convert', b'hg.usebranchnames', default=True,
332 )
335 )
333 coreconfigitem(
336 coreconfigitem(
334 b'convert', b'ignoreancestorcheck', default=False, experimental=True,
337 b'convert', b'ignoreancestorcheck', default=False, experimental=True,
335 )
338 )
336 coreconfigitem(
339 coreconfigitem(
337 b'convert', b'localtimezone', default=False,
340 b'convert', b'localtimezone', default=False,
338 )
341 )
339 coreconfigitem(
342 coreconfigitem(
340 b'convert', b'p4.encoding', default=dynamicdefault,
343 b'convert', b'p4.encoding', default=dynamicdefault,
341 )
344 )
342 coreconfigitem(
345 coreconfigitem(
343 b'convert', b'p4.startrev', default=0,
346 b'convert', b'p4.startrev', default=0,
344 )
347 )
345 coreconfigitem(
348 coreconfigitem(
346 b'convert', b'skiptags', default=False,
349 b'convert', b'skiptags', default=False,
347 )
350 )
348 coreconfigitem(
351 coreconfigitem(
349 b'convert', b'svn.debugsvnlog', default=True,
352 b'convert', b'svn.debugsvnlog', default=True,
350 )
353 )
351 coreconfigitem(
354 coreconfigitem(
352 b'convert', b'svn.trunk', default=None,
355 b'convert', b'svn.trunk', default=None,
353 )
356 )
354 coreconfigitem(
357 coreconfigitem(
355 b'convert', b'svn.tags', default=None,
358 b'convert', b'svn.tags', default=None,
356 )
359 )
357 coreconfigitem(
360 coreconfigitem(
358 b'convert', b'svn.branches', default=None,
361 b'convert', b'svn.branches', default=None,
359 )
362 )
360 coreconfigitem(
363 coreconfigitem(
361 b'convert', b'svn.startrev', default=0,
364 b'convert', b'svn.startrev', default=0,
362 )
365 )
363 coreconfigitem(
366 coreconfigitem(
364 b'debug', b'dirstate.delaywrite', default=0,
367 b'debug', b'dirstate.delaywrite', default=0,
365 )
368 )
366 coreconfigitem(
369 coreconfigitem(
367 b'defaults', b'.*', default=None, generic=True,
370 b'defaults', b'.*', default=None, generic=True,
368 )
371 )
369 coreconfigitem(
372 coreconfigitem(
370 b'devel', b'all-warnings', default=False,
373 b'devel', b'all-warnings', default=False,
371 )
374 )
372 coreconfigitem(
375 coreconfigitem(
373 b'devel', b'bundle2.debug', default=False,
376 b'devel', b'bundle2.debug', default=False,
374 )
377 )
375 coreconfigitem(
378 coreconfigitem(
376 b'devel', b'bundle.delta', default=b'',
379 b'devel', b'bundle.delta', default=b'',
377 )
380 )
378 coreconfigitem(
381 coreconfigitem(
379 b'devel', b'cache-vfs', default=None,
382 b'devel', b'cache-vfs', default=None,
380 )
383 )
381 coreconfigitem(
384 coreconfigitem(
382 b'devel', b'check-locks', default=False,
385 b'devel', b'check-locks', default=False,
383 )
386 )
384 coreconfigitem(
387 coreconfigitem(
385 b'devel', b'check-relroot', default=False,
388 b'devel', b'check-relroot', default=False,
386 )
389 )
387 coreconfigitem(
390 coreconfigitem(
388 b'devel', b'default-date', default=None,
391 b'devel', b'default-date', default=None,
389 )
392 )
390 coreconfigitem(
393 coreconfigitem(
391 b'devel', b'deprec-warn', default=False,
394 b'devel', b'deprec-warn', default=False,
392 )
395 )
393 coreconfigitem(
396 coreconfigitem(
394 b'devel', b'disableloaddefaultcerts', default=False,
397 b'devel', b'disableloaddefaultcerts', default=False,
395 )
398 )
396 coreconfigitem(
399 coreconfigitem(
397 b'devel', b'warn-empty-changegroup', default=False,
400 b'devel', b'warn-empty-changegroup', default=False,
398 )
401 )
399 coreconfigitem(
402 coreconfigitem(
400 b'devel', b'legacy.exchange', default=list,
403 b'devel', b'legacy.exchange', default=list,
401 )
404 )
402 coreconfigitem(
405 coreconfigitem(
403 b'devel', b'servercafile', default=b'',
406 b'devel', b'servercafile', default=b'',
404 )
407 )
405 coreconfigitem(
408 coreconfigitem(
406 b'devel', b'serverexactprotocol', default=b'',
409 b'devel', b'serverexactprotocol', default=b'',
407 )
410 )
408 coreconfigitem(
411 coreconfigitem(
409 b'devel', b'serverrequirecert', default=False,
412 b'devel', b'serverrequirecert', default=False,
410 )
413 )
411 coreconfigitem(
414 coreconfigitem(
412 b'devel', b'strip-obsmarkers', default=True,
415 b'devel', b'strip-obsmarkers', default=True,
413 )
416 )
414 coreconfigitem(
417 coreconfigitem(
415 b'devel', b'warn-config', default=None,
418 b'devel', b'warn-config', default=None,
416 )
419 )
417 coreconfigitem(
420 coreconfigitem(
418 b'devel', b'warn-config-default', default=None,
421 b'devel', b'warn-config-default', default=None,
419 )
422 )
420 coreconfigitem(
423 coreconfigitem(
421 b'devel', b'user.obsmarker', default=None,
424 b'devel', b'user.obsmarker', default=None,
422 )
425 )
423 coreconfigitem(
426 coreconfigitem(
424 b'devel', b'warn-config-unknown', default=None,
427 b'devel', b'warn-config-unknown', default=None,
425 )
428 )
426 coreconfigitem(
429 coreconfigitem(
427 b'devel', b'debug.copies', default=False,
430 b'devel', b'debug.copies', default=False,
428 )
431 )
429 coreconfigitem(
432 coreconfigitem(
430 b'devel', b'debug.extensions', default=False,
433 b'devel', b'debug.extensions', default=False,
431 )
434 )
432 coreconfigitem(
435 coreconfigitem(
433 b'devel', b'debug.peer-request', default=False,
436 b'devel', b'debug.peer-request', default=False,
434 )
437 )
435 coreconfigitem(
438 coreconfigitem(
436 b'devel', b'discovery.randomize', default=True,
439 b'devel', b'discovery.randomize', default=True,
437 )
440 )
438 _registerdiffopts(section=b'diff')
441 _registerdiffopts(section=b'diff')
439 coreconfigitem(
442 coreconfigitem(
440 b'email', b'bcc', default=None,
443 b'email', b'bcc', default=None,
441 )
444 )
442 coreconfigitem(
445 coreconfigitem(
443 b'email', b'cc', default=None,
446 b'email', b'cc', default=None,
444 )
447 )
445 coreconfigitem(
448 coreconfigitem(
446 b'email', b'charsets', default=list,
449 b'email', b'charsets', default=list,
447 )
450 )
448 coreconfigitem(
451 coreconfigitem(
449 b'email', b'from', default=None,
452 b'email', b'from', default=None,
450 )
453 )
451 coreconfigitem(
454 coreconfigitem(
452 b'email', b'method', default=b'smtp',
455 b'email', b'method', default=b'smtp',
453 )
456 )
454 coreconfigitem(
457 coreconfigitem(
455 b'email', b'reply-to', default=None,
458 b'email', b'reply-to', default=None,
456 )
459 )
457 coreconfigitem(
460 coreconfigitem(
458 b'email', b'to', default=None,
461 b'email', b'to', default=None,
459 )
462 )
460 coreconfigitem(
463 coreconfigitem(
461 b'experimental', b'archivemetatemplate', default=dynamicdefault,
464 b'experimental', b'archivemetatemplate', default=dynamicdefault,
462 )
465 )
463 coreconfigitem(
466 coreconfigitem(
464 b'experimental', b'auto-publish', default=b'publish',
467 b'experimental', b'auto-publish', default=b'publish',
465 )
468 )
466 coreconfigitem(
469 coreconfigitem(
467 b'experimental', b'bundle-phases', default=False,
470 b'experimental', b'bundle-phases', default=False,
468 )
471 )
469 coreconfigitem(
472 coreconfigitem(
470 b'experimental', b'bundle2-advertise', default=True,
473 b'experimental', b'bundle2-advertise', default=True,
471 )
474 )
472 coreconfigitem(
475 coreconfigitem(
473 b'experimental', b'bundle2-output-capture', default=False,
476 b'experimental', b'bundle2-output-capture', default=False,
474 )
477 )
475 coreconfigitem(
478 coreconfigitem(
476 b'experimental', b'bundle2.pushback', default=False,
479 b'experimental', b'bundle2.pushback', default=False,
477 )
480 )
478 coreconfigitem(
481 coreconfigitem(
479 b'experimental', b'bundle2lazylocking', default=False,
482 b'experimental', b'bundle2lazylocking', default=False,
480 )
483 )
481 coreconfigitem(
484 coreconfigitem(
482 b'experimental', b'bundlecomplevel', default=None,
485 b'experimental', b'bundlecomplevel', default=None,
483 )
486 )
484 coreconfigitem(
487 coreconfigitem(
485 b'experimental', b'bundlecomplevel.bzip2', default=None,
488 b'experimental', b'bundlecomplevel.bzip2', default=None,
486 )
489 )
487 coreconfigitem(
490 coreconfigitem(
488 b'experimental', b'bundlecomplevel.gzip', default=None,
491 b'experimental', b'bundlecomplevel.gzip', default=None,
489 )
492 )
490 coreconfigitem(
493 coreconfigitem(
491 b'experimental', b'bundlecomplevel.none', default=None,
494 b'experimental', b'bundlecomplevel.none', default=None,
492 )
495 )
493 coreconfigitem(
496 coreconfigitem(
494 b'experimental', b'bundlecomplevel.zstd', default=None,
497 b'experimental', b'bundlecomplevel.zstd', default=None,
495 )
498 )
496 coreconfigitem(
499 coreconfigitem(
497 b'experimental', b'changegroup3', default=False,
500 b'experimental', b'changegroup3', default=False,
498 )
501 )
499 coreconfigitem(
502 coreconfigitem(
500 b'experimental', b'cleanup-as-archived', default=False,
503 b'experimental', b'cleanup-as-archived', default=False,
501 )
504 )
502 coreconfigitem(
505 coreconfigitem(
503 b'experimental', b'clientcompressionengines', default=list,
506 b'experimental', b'clientcompressionengines', default=list,
504 )
507 )
505 coreconfigitem(
508 coreconfigitem(
506 b'experimental', b'copytrace', default=b'on',
509 b'experimental', b'copytrace', default=b'on',
507 )
510 )
508 coreconfigitem(
511 coreconfigitem(
509 b'experimental', b'copytrace.movecandidateslimit', default=100,
512 b'experimental', b'copytrace.movecandidateslimit', default=100,
510 )
513 )
511 coreconfigitem(
514 coreconfigitem(
512 b'experimental', b'copytrace.sourcecommitlimit', default=100,
515 b'experimental', b'copytrace.sourcecommitlimit', default=100,
513 )
516 )
514 coreconfigitem(
517 coreconfigitem(
515 b'experimental', b'copies.read-from', default=b"filelog-only",
518 b'experimental', b'copies.read-from', default=b"filelog-only",
516 )
519 )
517 coreconfigitem(
520 coreconfigitem(
518 b'experimental', b'copies.write-to', default=b'filelog-only',
521 b'experimental', b'copies.write-to', default=b'filelog-only',
519 )
522 )
520 coreconfigitem(
523 coreconfigitem(
521 b'experimental', b'crecordtest', default=None,
524 b'experimental', b'crecordtest', default=None,
522 )
525 )
523 coreconfigitem(
526 coreconfigitem(
524 b'experimental', b'directaccess', default=False,
527 b'experimental', b'directaccess', default=False,
525 )
528 )
526 coreconfigitem(
529 coreconfigitem(
527 b'experimental', b'directaccess.revnums', default=False,
530 b'experimental', b'directaccess.revnums', default=False,
528 )
531 )
529 coreconfigitem(
532 coreconfigitem(
530 b'experimental', b'editortmpinhg', default=False,
533 b'experimental', b'editortmpinhg', default=False,
531 )
534 )
532 coreconfigitem(
535 coreconfigitem(
533 b'experimental', b'evolution', default=list,
536 b'experimental', b'evolution', default=list,
534 )
537 )
535 coreconfigitem(
538 coreconfigitem(
536 b'experimental',
539 b'experimental',
537 b'evolution.allowdivergence',
540 b'evolution.allowdivergence',
538 default=False,
541 default=False,
539 alias=[(b'experimental', b'allowdivergence')],
542 alias=[(b'experimental', b'allowdivergence')],
540 )
543 )
541 coreconfigitem(
544 coreconfigitem(
542 b'experimental', b'evolution.allowunstable', default=None,
545 b'experimental', b'evolution.allowunstable', default=None,
543 )
546 )
544 coreconfigitem(
547 coreconfigitem(
545 b'experimental', b'evolution.createmarkers', default=None,
548 b'experimental', b'evolution.createmarkers', default=None,
546 )
549 )
547 coreconfigitem(
550 coreconfigitem(
548 b'experimental',
551 b'experimental',
549 b'evolution.effect-flags',
552 b'evolution.effect-flags',
550 default=True,
553 default=True,
551 alias=[(b'experimental', b'effect-flags')],
554 alias=[(b'experimental', b'effect-flags')],
552 )
555 )
553 coreconfigitem(
556 coreconfigitem(
554 b'experimental', b'evolution.exchange', default=None,
557 b'experimental', b'evolution.exchange', default=None,
555 )
558 )
556 coreconfigitem(
559 coreconfigitem(
557 b'experimental', b'evolution.bundle-obsmarker', default=False,
560 b'experimental', b'evolution.bundle-obsmarker', default=False,
558 )
561 )
559 coreconfigitem(
562 coreconfigitem(
560 b'experimental', b'log.topo', default=False,
563 b'experimental', b'log.topo', default=False,
561 )
564 )
562 coreconfigitem(
565 coreconfigitem(
563 b'experimental', b'evolution.report-instabilities', default=True,
566 b'experimental', b'evolution.report-instabilities', default=True,
564 )
567 )
565 coreconfigitem(
568 coreconfigitem(
566 b'experimental', b'evolution.track-operation', default=True,
569 b'experimental', b'evolution.track-operation', default=True,
567 )
570 )
568 # repo-level config to exclude a revset visibility
571 # repo-level config to exclude a revset visibility
569 #
572 #
570 # The target use case is to use `share` to expose different subset of the same
573 # The target use case is to use `share` to expose different subset of the same
571 # repository, especially server side. See also `server.view`.
574 # repository, especially server side. See also `server.view`.
572 coreconfigitem(
575 coreconfigitem(
573 b'experimental', b'extra-filter-revs', default=None,
576 b'experimental', b'extra-filter-revs', default=None,
574 )
577 )
575 coreconfigitem(
578 coreconfigitem(
576 b'experimental', b'maxdeltachainspan', default=-1,
579 b'experimental', b'maxdeltachainspan', default=-1,
577 )
580 )
578 coreconfigitem(
581 coreconfigitem(
579 b'experimental', b'mergetempdirprefix', default=None,
582 b'experimental', b'mergetempdirprefix', default=None,
580 )
583 )
581 coreconfigitem(
584 coreconfigitem(
582 b'experimental', b'mmapindexthreshold', default=None,
585 b'experimental', b'mmapindexthreshold', default=None,
583 )
586 )
584 coreconfigitem(
587 coreconfigitem(
585 b'experimental', b'narrow', default=False,
588 b'experimental', b'narrow', default=False,
586 )
589 )
587 coreconfigitem(
590 coreconfigitem(
588 b'experimental', b'nonnormalparanoidcheck', default=False,
591 b'experimental', b'nonnormalparanoidcheck', default=False,
589 )
592 )
590 coreconfigitem(
593 coreconfigitem(
591 b'experimental', b'exportableenviron', default=list,
594 b'experimental', b'exportableenviron', default=list,
592 )
595 )
593 coreconfigitem(
596 coreconfigitem(
594 b'experimental', b'extendedheader.index', default=None,
597 b'experimental', b'extendedheader.index', default=None,
595 )
598 )
596 coreconfigitem(
599 coreconfigitem(
597 b'experimental', b'extendedheader.similarity', default=False,
600 b'experimental', b'extendedheader.similarity', default=False,
598 )
601 )
599 coreconfigitem(
602 coreconfigitem(
600 b'experimental', b'graphshorten', default=False,
603 b'experimental', b'graphshorten', default=False,
601 )
604 )
602 coreconfigitem(
605 coreconfigitem(
603 b'experimental', b'graphstyle.parent', default=dynamicdefault,
606 b'experimental', b'graphstyle.parent', default=dynamicdefault,
604 )
607 )
605 coreconfigitem(
608 coreconfigitem(
606 b'experimental', b'graphstyle.missing', default=dynamicdefault,
609 b'experimental', b'graphstyle.missing', default=dynamicdefault,
607 )
610 )
608 coreconfigitem(
611 coreconfigitem(
609 b'experimental', b'graphstyle.grandparent', default=dynamicdefault,
612 b'experimental', b'graphstyle.grandparent', default=dynamicdefault,
610 )
613 )
611 coreconfigitem(
614 coreconfigitem(
612 b'experimental', b'hook-track-tags', default=False,
615 b'experimental', b'hook-track-tags', default=False,
613 )
616 )
614 coreconfigitem(
617 coreconfigitem(
615 b'experimental', b'httppeer.advertise-v2', default=False,
618 b'experimental', b'httppeer.advertise-v2', default=False,
616 )
619 )
617 coreconfigitem(
620 coreconfigitem(
618 b'experimental', b'httppeer.v2-encoder-order', default=None,
621 b'experimental', b'httppeer.v2-encoder-order', default=None,
619 )
622 )
620 coreconfigitem(
623 coreconfigitem(
621 b'experimental', b'httppostargs', default=False,
624 b'experimental', b'httppostargs', default=False,
622 )
625 )
623 coreconfigitem(
626 coreconfigitem(
624 b'experimental', b'mergedriver', default=None,
627 b'experimental', b'mergedriver', default=None,
625 )
628 )
626 coreconfigitem(b'experimental', b'nointerrupt', default=False)
629 coreconfigitem(b'experimental', b'nointerrupt', default=False)
627 coreconfigitem(b'experimental', b'nointerrupt-interactiveonly', default=True)
630 coreconfigitem(b'experimental', b'nointerrupt-interactiveonly', default=True)
628
631
629 coreconfigitem(
632 coreconfigitem(
630 b'experimental', b'obsmarkers-exchange-debug', default=False,
633 b'experimental', b'obsmarkers-exchange-debug', default=False,
631 )
634 )
632 coreconfigitem(
635 coreconfigitem(
633 b'experimental', b'remotenames', default=False,
636 b'experimental', b'remotenames', default=False,
634 )
637 )
635 coreconfigitem(
638 coreconfigitem(
636 b'experimental', b'removeemptydirs', default=True,
639 b'experimental', b'removeemptydirs', default=True,
637 )
640 )
638 coreconfigitem(
641 coreconfigitem(
639 b'experimental', b'revert.interactive.select-to-keep', default=False,
642 b'experimental', b'revert.interactive.select-to-keep', default=False,
640 )
643 )
641 coreconfigitem(
644 coreconfigitem(
642 b'experimental', b'revisions.prefixhexnode', default=False,
645 b'experimental', b'revisions.prefixhexnode', default=False,
643 )
646 )
644 coreconfigitem(
647 coreconfigitem(
645 b'experimental', b'revlogv2', default=None,
648 b'experimental', b'revlogv2', default=None,
646 )
649 )
647 coreconfigitem(
650 coreconfigitem(
648 b'experimental', b'revisions.disambiguatewithin', default=None,
651 b'experimental', b'revisions.disambiguatewithin', default=None,
649 )
652 )
650 coreconfigitem(
653 coreconfigitem(
651 b'experimental', b'server.filesdata.recommended-batch-size', default=50000,
654 b'experimental', b'server.filesdata.recommended-batch-size', default=50000,
652 )
655 )
653 coreconfigitem(
656 coreconfigitem(
654 b'experimental',
657 b'experimental',
655 b'server.manifestdata.recommended-batch-size',
658 b'server.manifestdata.recommended-batch-size',
656 default=100000,
659 default=100000,
657 )
660 )
658 coreconfigitem(
661 coreconfigitem(
659 b'experimental', b'server.stream-narrow-clones', default=False,
662 b'experimental', b'server.stream-narrow-clones', default=False,
660 )
663 )
661 coreconfigitem(
664 coreconfigitem(
662 b'experimental', b'single-head-per-branch', default=False,
665 b'experimental', b'single-head-per-branch', default=False,
663 )
666 )
664 coreconfigitem(
667 coreconfigitem(
665 b'experimental',
668 b'experimental',
666 b'single-head-per-branch:account-closed-heads',
669 b'single-head-per-branch:account-closed-heads',
667 default=False,
670 default=False,
668 )
671 )
669 coreconfigitem(
672 coreconfigitem(
670 b'experimental', b'sshserver.support-v2', default=False,
673 b'experimental', b'sshserver.support-v2', default=False,
671 )
674 )
672 coreconfigitem(
675 coreconfigitem(
673 b'experimental', b'sparse-read', default=False,
676 b'experimental', b'sparse-read', default=False,
674 )
677 )
675 coreconfigitem(
678 coreconfigitem(
676 b'experimental', b'sparse-read.density-threshold', default=0.50,
679 b'experimental', b'sparse-read.density-threshold', default=0.50,
677 )
680 )
678 coreconfigitem(
681 coreconfigitem(
679 b'experimental', b'sparse-read.min-gap-size', default=b'65K',
682 b'experimental', b'sparse-read.min-gap-size', default=b'65K',
680 )
683 )
681 coreconfigitem(
684 coreconfigitem(
682 b'experimental', b'treemanifest', default=False,
685 b'experimental', b'treemanifest', default=False,
683 )
686 )
684 coreconfigitem(
687 coreconfigitem(
685 b'experimental', b'update.atomic-file', default=False,
688 b'experimental', b'update.atomic-file', default=False,
686 )
689 )
687 coreconfigitem(
690 coreconfigitem(
688 b'experimental', b'sshpeer.advertise-v2', default=False,
691 b'experimental', b'sshpeer.advertise-v2', default=False,
689 )
692 )
690 coreconfigitem(
693 coreconfigitem(
691 b'experimental', b'web.apiserver', default=False,
694 b'experimental', b'web.apiserver', default=False,
692 )
695 )
693 coreconfigitem(
696 coreconfigitem(
694 b'experimental', b'web.api.http-v2', default=False,
697 b'experimental', b'web.api.http-v2', default=False,
695 )
698 )
696 coreconfigitem(
699 coreconfigitem(
697 b'experimental', b'web.api.debugreflect', default=False,
700 b'experimental', b'web.api.debugreflect', default=False,
698 )
701 )
699 coreconfigitem(
702 coreconfigitem(
700 b'experimental', b'worker.wdir-get-thread-safe', default=False,
703 b'experimental', b'worker.wdir-get-thread-safe', default=False,
701 )
704 )
702 coreconfigitem(
705 coreconfigitem(
703 b'experimental', b'xdiff', default=False,
706 b'experimental', b'xdiff', default=False,
704 )
707 )
705 coreconfigitem(
708 coreconfigitem(
706 b'extensions', b'.*', default=None, generic=True,
709 b'extensions', b'.*', default=None, generic=True,
707 )
710 )
708 coreconfigitem(
711 coreconfigitem(
709 b'extdata', b'.*', default=None, generic=True,
712 b'extdata', b'.*', default=None, generic=True,
710 )
713 )
711 coreconfigitem(
714 coreconfigitem(
712 b'format', b'bookmarks-in-store', default=False,
715 b'format', b'bookmarks-in-store', default=False,
713 )
716 )
714 coreconfigitem(
717 coreconfigitem(
715 b'format', b'chunkcachesize', default=None, experimental=True,
718 b'format', b'chunkcachesize', default=None, experimental=True,
716 )
719 )
717 coreconfigitem(
720 coreconfigitem(
718 b'format', b'dotencode', default=True,
721 b'format', b'dotencode', default=True,
719 )
722 )
720 coreconfigitem(
723 coreconfigitem(
721 b'format', b'generaldelta', default=False, experimental=True,
724 b'format', b'generaldelta', default=False, experimental=True,
722 )
725 )
723 coreconfigitem(
726 coreconfigitem(
724 b'format', b'manifestcachesize', default=None, experimental=True,
727 b'format', b'manifestcachesize', default=None, experimental=True,
725 )
728 )
726 coreconfigitem(
729 coreconfigitem(
727 b'format', b'maxchainlen', default=dynamicdefault, experimental=True,
730 b'format', b'maxchainlen', default=dynamicdefault, experimental=True,
728 )
731 )
729 coreconfigitem(
732 coreconfigitem(
730 b'format', b'obsstore-version', default=None,
733 b'format', b'obsstore-version', default=None,
731 )
734 )
732 coreconfigitem(
735 coreconfigitem(
733 b'format', b'sparse-revlog', default=True,
736 b'format', b'sparse-revlog', default=True,
734 )
737 )
735 coreconfigitem(
738 coreconfigitem(
736 b'format',
739 b'format',
737 b'revlog-compression',
740 b'revlog-compression',
738 default=b'zlib',
741 default=b'zlib',
739 alias=[(b'experimental', b'format.compression')],
742 alias=[(b'experimental', b'format.compression')],
740 )
743 )
741 coreconfigitem(
744 coreconfigitem(
742 b'format', b'usefncache', default=True,
745 b'format', b'usefncache', default=True,
743 )
746 )
744 coreconfigitem(
747 coreconfigitem(
745 b'format', b'usegeneraldelta', default=True,
748 b'format', b'usegeneraldelta', default=True,
746 )
749 )
747 coreconfigitem(
750 coreconfigitem(
748 b'format', b'usestore', default=True,
751 b'format', b'usestore', default=True,
749 )
752 )
750 coreconfigitem(
753 coreconfigitem(
751 b'format',
754 b'format',
752 b'exp-use-copies-side-data-changeset',
755 b'exp-use-copies-side-data-changeset',
753 default=False,
756 default=False,
754 experimental=True,
757 experimental=True,
755 )
758 )
756 coreconfigitem(
759 coreconfigitem(
757 b'format', b'use-side-data', default=False, experimental=True,
760 b'format', b'use-side-data', default=False, experimental=True,
758 )
761 )
759 coreconfigitem(
762 coreconfigitem(
760 b'format', b'internal-phase', default=False, experimental=True,
763 b'format', b'internal-phase', default=False, experimental=True,
761 )
764 )
762 coreconfigitem(
765 coreconfigitem(
763 b'fsmonitor', b'warn_when_unused', default=True,
766 b'fsmonitor', b'warn_when_unused', default=True,
764 )
767 )
765 coreconfigitem(
768 coreconfigitem(
766 b'fsmonitor', b'warn_update_file_count', default=50000,
769 b'fsmonitor', b'warn_update_file_count', default=50000,
767 )
770 )
768 coreconfigitem(
771 coreconfigitem(
769 b'help', br'hidden-command\..*', default=False, generic=True,
772 b'help', br'hidden-command\..*', default=False, generic=True,
770 )
773 )
771 coreconfigitem(
774 coreconfigitem(
772 b'help', br'hidden-topic\..*', default=False, generic=True,
775 b'help', br'hidden-topic\..*', default=False, generic=True,
773 )
776 )
774 coreconfigitem(
777 coreconfigitem(
775 b'hooks', b'.*', default=dynamicdefault, generic=True,
778 b'hooks', b'.*', default=dynamicdefault, generic=True,
776 )
779 )
777 coreconfigitem(
780 coreconfigitem(
778 b'hgweb-paths', b'.*', default=list, generic=True,
781 b'hgweb-paths', b'.*', default=list, generic=True,
779 )
782 )
780 coreconfigitem(
783 coreconfigitem(
781 b'hostfingerprints', b'.*', default=list, generic=True,
784 b'hostfingerprints', b'.*', default=list, generic=True,
782 )
785 )
783 coreconfigitem(
786 coreconfigitem(
784 b'hostsecurity', b'ciphers', default=None,
787 b'hostsecurity', b'ciphers', default=None,
785 )
788 )
786 coreconfigitem(
789 coreconfigitem(
787 b'hostsecurity', b'disabletls10warning', default=False,
790 b'hostsecurity', b'disabletls10warning', default=False,
788 )
791 )
789 coreconfigitem(
792 coreconfigitem(
790 b'hostsecurity', b'minimumprotocol', default=dynamicdefault,
793 b'hostsecurity', b'minimumprotocol', default=dynamicdefault,
791 )
794 )
792 coreconfigitem(
795 coreconfigitem(
793 b'hostsecurity',
796 b'hostsecurity',
794 b'.*:minimumprotocol$',
797 b'.*:minimumprotocol$',
795 default=dynamicdefault,
798 default=dynamicdefault,
796 generic=True,
799 generic=True,
797 )
800 )
798 coreconfigitem(
801 coreconfigitem(
799 b'hostsecurity', b'.*:ciphers$', default=dynamicdefault, generic=True,
802 b'hostsecurity', b'.*:ciphers$', default=dynamicdefault, generic=True,
800 )
803 )
801 coreconfigitem(
804 coreconfigitem(
802 b'hostsecurity', b'.*:fingerprints$', default=list, generic=True,
805 b'hostsecurity', b'.*:fingerprints$', default=list, generic=True,
803 )
806 )
804 coreconfigitem(
807 coreconfigitem(
805 b'hostsecurity', b'.*:verifycertsfile$', default=None, generic=True,
808 b'hostsecurity', b'.*:verifycertsfile$', default=None, generic=True,
806 )
809 )
807
810
808 coreconfigitem(
811 coreconfigitem(
809 b'http_proxy', b'always', default=False,
812 b'http_proxy', b'always', default=False,
810 )
813 )
811 coreconfigitem(
814 coreconfigitem(
812 b'http_proxy', b'host', default=None,
815 b'http_proxy', b'host', default=None,
813 )
816 )
814 coreconfigitem(
817 coreconfigitem(
815 b'http_proxy', b'no', default=list,
818 b'http_proxy', b'no', default=list,
816 )
819 )
817 coreconfigitem(
820 coreconfigitem(
818 b'http_proxy', b'passwd', default=None,
821 b'http_proxy', b'passwd', default=None,
819 )
822 )
820 coreconfigitem(
823 coreconfigitem(
821 b'http_proxy', b'user', default=None,
824 b'http_proxy', b'user', default=None,
822 )
825 )
823
826
824 coreconfigitem(
827 coreconfigitem(
825 b'http', b'timeout', default=None,
828 b'http', b'timeout', default=None,
826 )
829 )
827
830
828 coreconfigitem(
831 coreconfigitem(
829 b'logtoprocess', b'commandexception', default=None,
832 b'logtoprocess', b'commandexception', default=None,
830 )
833 )
831 coreconfigitem(
834 coreconfigitem(
832 b'logtoprocess', b'commandfinish', default=None,
835 b'logtoprocess', b'commandfinish', default=None,
833 )
836 )
834 coreconfigitem(
837 coreconfigitem(
835 b'logtoprocess', b'command', default=None,
838 b'logtoprocess', b'command', default=None,
836 )
839 )
837 coreconfigitem(
840 coreconfigitem(
838 b'logtoprocess', b'develwarn', default=None,
841 b'logtoprocess', b'develwarn', default=None,
839 )
842 )
840 coreconfigitem(
843 coreconfigitem(
841 b'logtoprocess', b'uiblocked', default=None,
844 b'logtoprocess', b'uiblocked', default=None,
842 )
845 )
843 coreconfigitem(
846 coreconfigitem(
844 b'merge', b'checkunknown', default=b'abort',
847 b'merge', b'checkunknown', default=b'abort',
845 )
848 )
846 coreconfigitem(
849 coreconfigitem(
847 b'merge', b'checkignored', default=b'abort',
850 b'merge', b'checkignored', default=b'abort',
848 )
851 )
849 coreconfigitem(
852 coreconfigitem(
850 b'experimental', b'merge.checkpathconflicts', default=False,
853 b'experimental', b'merge.checkpathconflicts', default=False,
851 )
854 )
852 coreconfigitem(
855 coreconfigitem(
853 b'merge', b'followcopies', default=True,
856 b'merge', b'followcopies', default=True,
854 )
857 )
855 coreconfigitem(
858 coreconfigitem(
856 b'merge', b'on-failure', default=b'continue',
859 b'merge', b'on-failure', default=b'continue',
857 )
860 )
858 coreconfigitem(
861 coreconfigitem(
859 b'merge', b'preferancestor', default=lambda: [b'*'], experimental=True,
862 b'merge', b'preferancestor', default=lambda: [b'*'], experimental=True,
860 )
863 )
861 coreconfigitem(
864 coreconfigitem(
862 b'merge', b'strict-capability-check', default=False,
865 b'merge', b'strict-capability-check', default=False,
863 )
866 )
864 coreconfigitem(
867 coreconfigitem(
865 b'merge-tools', b'.*', default=None, generic=True,
868 b'merge-tools', b'.*', default=None, generic=True,
866 )
869 )
867 coreconfigitem(
870 coreconfigitem(
868 b'merge-tools',
871 b'merge-tools',
869 br'.*\.args$',
872 br'.*\.args$',
870 default=b"$local $base $other",
873 default=b"$local $base $other",
871 generic=True,
874 generic=True,
872 priority=-1,
875 priority=-1,
873 )
876 )
874 coreconfigitem(
877 coreconfigitem(
875 b'merge-tools', br'.*\.binary$', default=False, generic=True, priority=-1,
878 b'merge-tools', br'.*\.binary$', default=False, generic=True, priority=-1,
876 )
879 )
877 coreconfigitem(
880 coreconfigitem(
878 b'merge-tools', br'.*\.check$', default=list, generic=True, priority=-1,
881 b'merge-tools', br'.*\.check$', default=list, generic=True, priority=-1,
879 )
882 )
880 coreconfigitem(
883 coreconfigitem(
881 b'merge-tools',
884 b'merge-tools',
882 br'.*\.checkchanged$',
885 br'.*\.checkchanged$',
883 default=False,
886 default=False,
884 generic=True,
887 generic=True,
885 priority=-1,
888 priority=-1,
886 )
889 )
887 coreconfigitem(
890 coreconfigitem(
888 b'merge-tools',
891 b'merge-tools',
889 br'.*\.executable$',
892 br'.*\.executable$',
890 default=dynamicdefault,
893 default=dynamicdefault,
891 generic=True,
894 generic=True,
892 priority=-1,
895 priority=-1,
893 )
896 )
894 coreconfigitem(
897 coreconfigitem(
895 b'merge-tools', br'.*\.fixeol$', default=False, generic=True, priority=-1,
898 b'merge-tools', br'.*\.fixeol$', default=False, generic=True, priority=-1,
896 )
899 )
897 coreconfigitem(
900 coreconfigitem(
898 b'merge-tools', br'.*\.gui$', default=False, generic=True, priority=-1,
901 b'merge-tools', br'.*\.gui$', default=False, generic=True, priority=-1,
899 )
902 )
900 coreconfigitem(
903 coreconfigitem(
901 b'merge-tools',
904 b'merge-tools',
902 br'.*\.mergemarkers$',
905 br'.*\.mergemarkers$',
903 default=b'basic',
906 default=b'basic',
904 generic=True,
907 generic=True,
905 priority=-1,
908 priority=-1,
906 )
909 )
907 coreconfigitem(
910 coreconfigitem(
908 b'merge-tools',
911 b'merge-tools',
909 br'.*\.mergemarkertemplate$',
912 br'.*\.mergemarkertemplate$',
910 default=dynamicdefault, # take from ui.mergemarkertemplate
913 default=dynamicdefault, # take from ui.mergemarkertemplate
911 generic=True,
914 generic=True,
912 priority=-1,
915 priority=-1,
913 )
916 )
914 coreconfigitem(
917 coreconfigitem(
915 b'merge-tools', br'.*\.priority$', default=0, generic=True, priority=-1,
918 b'merge-tools', br'.*\.priority$', default=0, generic=True, priority=-1,
916 )
919 )
917 coreconfigitem(
920 coreconfigitem(
918 b'merge-tools',
921 b'merge-tools',
919 br'.*\.premerge$',
922 br'.*\.premerge$',
920 default=dynamicdefault,
923 default=dynamicdefault,
921 generic=True,
924 generic=True,
922 priority=-1,
925 priority=-1,
923 )
926 )
924 coreconfigitem(
927 coreconfigitem(
925 b'merge-tools', br'.*\.symlink$', default=False, generic=True, priority=-1,
928 b'merge-tools', br'.*\.symlink$', default=False, generic=True, priority=-1,
926 )
929 )
927 coreconfigitem(
930 coreconfigitem(
928 b'pager', b'attend-.*', default=dynamicdefault, generic=True,
931 b'pager', b'attend-.*', default=dynamicdefault, generic=True,
929 )
932 )
930 coreconfigitem(
933 coreconfigitem(
931 b'pager', b'ignore', default=list,
934 b'pager', b'ignore', default=list,
932 )
935 )
933 coreconfigitem(
936 coreconfigitem(
934 b'pager', b'pager', default=dynamicdefault,
937 b'pager', b'pager', default=dynamicdefault,
935 )
938 )
936 coreconfigitem(
939 coreconfigitem(
937 b'patch', b'eol', default=b'strict',
940 b'patch', b'eol', default=b'strict',
938 )
941 )
939 coreconfigitem(
942 coreconfigitem(
940 b'patch', b'fuzz', default=2,
943 b'patch', b'fuzz', default=2,
941 )
944 )
942 coreconfigitem(
945 coreconfigitem(
943 b'paths', b'default', default=None,
946 b'paths', b'default', default=None,
944 )
947 )
945 coreconfigitem(
948 coreconfigitem(
946 b'paths', b'default-push', default=None,
949 b'paths', b'default-push', default=None,
947 )
950 )
948 coreconfigitem(
951 coreconfigitem(
949 b'paths', b'.*', default=None, generic=True,
952 b'paths', b'.*', default=None, generic=True,
950 )
953 )
951 coreconfigitem(
954 coreconfigitem(
952 b'phases', b'checksubrepos', default=b'follow',
955 b'phases', b'checksubrepos', default=b'follow',
953 )
956 )
954 coreconfigitem(
957 coreconfigitem(
955 b'phases', b'new-commit', default=b'draft',
958 b'phases', b'new-commit', default=b'draft',
956 )
959 )
957 coreconfigitem(
960 coreconfigitem(
958 b'phases', b'publish', default=True,
961 b'phases', b'publish', default=True,
959 )
962 )
960 coreconfigitem(
963 coreconfigitem(
961 b'profiling', b'enabled', default=False,
964 b'profiling', b'enabled', default=False,
962 )
965 )
963 coreconfigitem(
966 coreconfigitem(
964 b'profiling', b'format', default=b'text',
967 b'profiling', b'format', default=b'text',
965 )
968 )
966 coreconfigitem(
969 coreconfigitem(
967 b'profiling', b'freq', default=1000,
970 b'profiling', b'freq', default=1000,
968 )
971 )
969 coreconfigitem(
972 coreconfigitem(
970 b'profiling', b'limit', default=30,
973 b'profiling', b'limit', default=30,
971 )
974 )
972 coreconfigitem(
975 coreconfigitem(
973 b'profiling', b'nested', default=0,
976 b'profiling', b'nested', default=0,
974 )
977 )
975 coreconfigitem(
978 coreconfigitem(
976 b'profiling', b'output', default=None,
979 b'profiling', b'output', default=None,
977 )
980 )
978 coreconfigitem(
981 coreconfigitem(
979 b'profiling', b'showmax', default=0.999,
982 b'profiling', b'showmax', default=0.999,
980 )
983 )
981 coreconfigitem(
984 coreconfigitem(
982 b'profiling', b'showmin', default=dynamicdefault,
985 b'profiling', b'showmin', default=dynamicdefault,
983 )
986 )
984 coreconfigitem(
987 coreconfigitem(
985 b'profiling', b'showtime', default=True,
988 b'profiling', b'showtime', default=True,
986 )
989 )
987 coreconfigitem(
990 coreconfigitem(
988 b'profiling', b'sort', default=b'inlinetime',
991 b'profiling', b'sort', default=b'inlinetime',
989 )
992 )
990 coreconfigitem(
993 coreconfigitem(
991 b'profiling', b'statformat', default=b'hotpath',
994 b'profiling', b'statformat', default=b'hotpath',
992 )
995 )
993 coreconfigitem(
996 coreconfigitem(
994 b'profiling', b'time-track', default=dynamicdefault,
997 b'profiling', b'time-track', default=dynamicdefault,
995 )
998 )
996 coreconfigitem(
999 coreconfigitem(
997 b'profiling', b'type', default=b'stat',
1000 b'profiling', b'type', default=b'stat',
998 )
1001 )
999 coreconfigitem(
1002 coreconfigitem(
1000 b'progress', b'assume-tty', default=False,
1003 b'progress', b'assume-tty', default=False,
1001 )
1004 )
1002 coreconfigitem(
1005 coreconfigitem(
1003 b'progress', b'changedelay', default=1,
1006 b'progress', b'changedelay', default=1,
1004 )
1007 )
1005 coreconfigitem(
1008 coreconfigitem(
1006 b'progress', b'clear-complete', default=True,
1009 b'progress', b'clear-complete', default=True,
1007 )
1010 )
1008 coreconfigitem(
1011 coreconfigitem(
1009 b'progress', b'debug', default=False,
1012 b'progress', b'debug', default=False,
1010 )
1013 )
1011 coreconfigitem(
1014 coreconfigitem(
1012 b'progress', b'delay', default=3,
1015 b'progress', b'delay', default=3,
1013 )
1016 )
1014 coreconfigitem(
1017 coreconfigitem(
1015 b'progress', b'disable', default=False,
1018 b'progress', b'disable', default=False,
1016 )
1019 )
1017 coreconfigitem(
1020 coreconfigitem(
1018 b'progress', b'estimateinterval', default=60.0,
1021 b'progress', b'estimateinterval', default=60.0,
1019 )
1022 )
1020 coreconfigitem(
1023 coreconfigitem(
1021 b'progress',
1024 b'progress',
1022 b'format',
1025 b'format',
1023 default=lambda: [b'topic', b'bar', b'number', b'estimate'],
1026 default=lambda: [b'topic', b'bar', b'number', b'estimate'],
1024 )
1027 )
1025 coreconfigitem(
1028 coreconfigitem(
1026 b'progress', b'refresh', default=0.1,
1029 b'progress', b'refresh', default=0.1,
1027 )
1030 )
1028 coreconfigitem(
1031 coreconfigitem(
1029 b'progress', b'width', default=dynamicdefault,
1032 b'progress', b'width', default=dynamicdefault,
1030 )
1033 )
1031 coreconfigitem(
1034 coreconfigitem(
1032 b'push', b'pushvars.server', default=False,
1035 b'push', b'pushvars.server', default=False,
1033 )
1036 )
1034 coreconfigitem(
1037 coreconfigitem(
1035 b'rewrite',
1038 b'rewrite',
1036 b'backup-bundle',
1039 b'backup-bundle',
1037 default=True,
1040 default=True,
1038 alias=[(b'ui', b'history-editing-backup')],
1041 alias=[(b'ui', b'history-editing-backup')],
1039 )
1042 )
1040 coreconfigitem(
1043 coreconfigitem(
1041 b'rewrite', b'update-timestamp', default=False,
1044 b'rewrite', b'update-timestamp', default=False,
1042 )
1045 )
1043 coreconfigitem(
1046 coreconfigitem(
1044 b'storage', b'new-repo-backend', default=b'revlogv1', experimental=True,
1047 b'storage', b'new-repo-backend', default=b'revlogv1', experimental=True,
1045 )
1048 )
1046 coreconfigitem(
1049 coreconfigitem(
1047 b'storage',
1050 b'storage',
1048 b'revlog.optimize-delta-parent-choice',
1051 b'revlog.optimize-delta-parent-choice',
1049 default=True,
1052 default=True,
1050 alias=[(b'format', b'aggressivemergedeltas')],
1053 alias=[(b'format', b'aggressivemergedeltas')],
1051 )
1054 )
1052 coreconfigitem(
1055 coreconfigitem(
1053 b'storage', b'revlog.reuse-external-delta', default=True,
1056 b'storage', b'revlog.reuse-external-delta', default=True,
1054 )
1057 )
1055 coreconfigitem(
1058 coreconfigitem(
1056 b'storage', b'revlog.reuse-external-delta-parent', default=None,
1059 b'storage', b'revlog.reuse-external-delta-parent', default=None,
1057 )
1060 )
1058 coreconfigitem(
1061 coreconfigitem(
1059 b'storage', b'revlog.zlib.level', default=None,
1062 b'storage', b'revlog.zlib.level', default=None,
1060 )
1063 )
1061 coreconfigitem(
1064 coreconfigitem(
1062 b'storage', b'revlog.zstd.level', default=None,
1065 b'storage', b'revlog.zstd.level', default=None,
1063 )
1066 )
1064 coreconfigitem(
1067 coreconfigitem(
1065 b'server', b'bookmarks-pushkey-compat', default=True,
1068 b'server', b'bookmarks-pushkey-compat', default=True,
1066 )
1069 )
1067 coreconfigitem(
1070 coreconfigitem(
1068 b'server', b'bundle1', default=True,
1071 b'server', b'bundle1', default=True,
1069 )
1072 )
1070 coreconfigitem(
1073 coreconfigitem(
1071 b'server', b'bundle1gd', default=None,
1074 b'server', b'bundle1gd', default=None,
1072 )
1075 )
1073 coreconfigitem(
1076 coreconfigitem(
1074 b'server', b'bundle1.pull', default=None,
1077 b'server', b'bundle1.pull', default=None,
1075 )
1078 )
1076 coreconfigitem(
1079 coreconfigitem(
1077 b'server', b'bundle1gd.pull', default=None,
1080 b'server', b'bundle1gd.pull', default=None,
1078 )
1081 )
1079 coreconfigitem(
1082 coreconfigitem(
1080 b'server', b'bundle1.push', default=None,
1083 b'server', b'bundle1.push', default=None,
1081 )
1084 )
1082 coreconfigitem(
1085 coreconfigitem(
1083 b'server', b'bundle1gd.push', default=None,
1086 b'server', b'bundle1gd.push', default=None,
1084 )
1087 )
1085 coreconfigitem(
1088 coreconfigitem(
1086 b'server',
1089 b'server',
1087 b'bundle2.stream',
1090 b'bundle2.stream',
1088 default=True,
1091 default=True,
1089 alias=[(b'experimental', b'bundle2.stream')],
1092 alias=[(b'experimental', b'bundle2.stream')],
1090 )
1093 )
1091 coreconfigitem(
1094 coreconfigitem(
1092 b'server', b'compressionengines', default=list,
1095 b'server', b'compressionengines', default=list,
1093 )
1096 )
1094 coreconfigitem(
1097 coreconfigitem(
1095 b'server', b'concurrent-push-mode', default=b'strict',
1098 b'server', b'concurrent-push-mode', default=b'strict',
1096 )
1099 )
1097 coreconfigitem(
1100 coreconfigitem(
1098 b'server', b'disablefullbundle', default=False,
1101 b'server', b'disablefullbundle', default=False,
1099 )
1102 )
1100 coreconfigitem(
1103 coreconfigitem(
1101 b'server', b'maxhttpheaderlen', default=1024,
1104 b'server', b'maxhttpheaderlen', default=1024,
1102 )
1105 )
1103 coreconfigitem(
1106 coreconfigitem(
1104 b'server', b'pullbundle', default=False,
1107 b'server', b'pullbundle', default=False,
1105 )
1108 )
1106 coreconfigitem(
1109 coreconfigitem(
1107 b'server', b'preferuncompressed', default=False,
1110 b'server', b'preferuncompressed', default=False,
1108 )
1111 )
1109 coreconfigitem(
1112 coreconfigitem(
1110 b'server', b'streamunbundle', default=False,
1113 b'server', b'streamunbundle', default=False,
1111 )
1114 )
1112 coreconfigitem(
1115 coreconfigitem(
1113 b'server', b'uncompressed', default=True,
1116 b'server', b'uncompressed', default=True,
1114 )
1117 )
1115 coreconfigitem(
1118 coreconfigitem(
1116 b'server', b'uncompressedallowsecret', default=False,
1119 b'server', b'uncompressedallowsecret', default=False,
1117 )
1120 )
1118 coreconfigitem(
1121 coreconfigitem(
1119 b'server', b'view', default=b'served',
1122 b'server', b'view', default=b'served',
1120 )
1123 )
1121 coreconfigitem(
1124 coreconfigitem(
1122 b'server', b'validate', default=False,
1125 b'server', b'validate', default=False,
1123 )
1126 )
1124 coreconfigitem(
1127 coreconfigitem(
1125 b'server', b'zliblevel', default=-1,
1128 b'server', b'zliblevel', default=-1,
1126 )
1129 )
1127 coreconfigitem(
1130 coreconfigitem(
1128 b'server', b'zstdlevel', default=3,
1131 b'server', b'zstdlevel', default=3,
1129 )
1132 )
1130 coreconfigitem(
1133 coreconfigitem(
1131 b'share', b'pool', default=None,
1134 b'share', b'pool', default=None,
1132 )
1135 )
1133 coreconfigitem(
1136 coreconfigitem(
1134 b'share', b'poolnaming', default=b'identity',
1137 b'share', b'poolnaming', default=b'identity',
1135 )
1138 )
1136 coreconfigitem(
1139 coreconfigitem(
1137 b'shelve', b'maxbackups', default=10,
1140 b'shelve', b'maxbackups', default=10,
1138 )
1141 )
1139 coreconfigitem(
1142 coreconfigitem(
1140 b'smtp', b'host', default=None,
1143 b'smtp', b'host', default=None,
1141 )
1144 )
1142 coreconfigitem(
1145 coreconfigitem(
1143 b'smtp', b'local_hostname', default=None,
1146 b'smtp', b'local_hostname', default=None,
1144 )
1147 )
1145 coreconfigitem(
1148 coreconfigitem(
1146 b'smtp', b'password', default=None,
1149 b'smtp', b'password', default=None,
1147 )
1150 )
1148 coreconfigitem(
1151 coreconfigitem(
1149 b'smtp', b'port', default=dynamicdefault,
1152 b'smtp', b'port', default=dynamicdefault,
1150 )
1153 )
1151 coreconfigitem(
1154 coreconfigitem(
1152 b'smtp', b'tls', default=b'none',
1155 b'smtp', b'tls', default=b'none',
1153 )
1156 )
1154 coreconfigitem(
1157 coreconfigitem(
1155 b'smtp', b'username', default=None,
1158 b'smtp', b'username', default=None,
1156 )
1159 )
1157 coreconfigitem(
1160 coreconfigitem(
1158 b'sparse', b'missingwarning', default=True, experimental=True,
1161 b'sparse', b'missingwarning', default=True, experimental=True,
1159 )
1162 )
1160 coreconfigitem(
1163 coreconfigitem(
1161 b'subrepos',
1164 b'subrepos',
1162 b'allowed',
1165 b'allowed',
1163 default=dynamicdefault, # to make backporting simpler
1166 default=dynamicdefault, # to make backporting simpler
1164 )
1167 )
1165 coreconfigitem(
1168 coreconfigitem(
1166 b'subrepos', b'hg:allowed', default=dynamicdefault,
1169 b'subrepos', b'hg:allowed', default=dynamicdefault,
1167 )
1170 )
1168 coreconfigitem(
1171 coreconfigitem(
1169 b'subrepos', b'git:allowed', default=dynamicdefault,
1172 b'subrepos', b'git:allowed', default=dynamicdefault,
1170 )
1173 )
1171 coreconfigitem(
1174 coreconfigitem(
1172 b'subrepos', b'svn:allowed', default=dynamicdefault,
1175 b'subrepos', b'svn:allowed', default=dynamicdefault,
1173 )
1176 )
1174 coreconfigitem(
1177 coreconfigitem(
1175 b'templates', b'.*', default=None, generic=True,
1178 b'templates', b'.*', default=None, generic=True,
1176 )
1179 )
1177 coreconfigitem(
1180 coreconfigitem(
1178 b'templateconfig', b'.*', default=dynamicdefault, generic=True,
1181 b'templateconfig', b'.*', default=dynamicdefault, generic=True,
1179 )
1182 )
1180 coreconfigitem(
1183 coreconfigitem(
1181 b'trusted', b'groups', default=list,
1184 b'trusted', b'groups', default=list,
1182 )
1185 )
1183 coreconfigitem(
1186 coreconfigitem(
1184 b'trusted', b'users', default=list,
1187 b'trusted', b'users', default=list,
1185 )
1188 )
1186 coreconfigitem(
1189 coreconfigitem(
1187 b'ui', b'_usedassubrepo', default=False,
1190 b'ui', b'_usedassubrepo', default=False,
1188 )
1191 )
1189 coreconfigitem(
1192 coreconfigitem(
1190 b'ui', b'allowemptycommit', default=False,
1193 b'ui', b'allowemptycommit', default=False,
1191 )
1194 )
1192 coreconfigitem(
1195 coreconfigitem(
1193 b'ui', b'archivemeta', default=True,
1196 b'ui', b'archivemeta', default=True,
1194 )
1197 )
1195 coreconfigitem(
1198 coreconfigitem(
1196 b'ui', b'askusername', default=False,
1199 b'ui', b'askusername', default=False,
1197 )
1200 )
1198 coreconfigitem(
1201 coreconfigitem(
1199 b'ui', b'clonebundlefallback', default=False,
1202 b'ui', b'clonebundlefallback', default=False,
1200 )
1203 )
1201 coreconfigitem(
1204 coreconfigitem(
1202 b'ui', b'clonebundleprefers', default=list,
1205 b'ui', b'clonebundleprefers', default=list,
1203 )
1206 )
1204 coreconfigitem(
1207 coreconfigitem(
1205 b'ui', b'clonebundles', default=True,
1208 b'ui', b'clonebundles', default=True,
1206 )
1209 )
1207 coreconfigitem(
1210 coreconfigitem(
1208 b'ui', b'color', default=b'auto',
1211 b'ui', b'color', default=b'auto',
1209 )
1212 )
1210 coreconfigitem(
1213 coreconfigitem(
1211 b'ui', b'commitsubrepos', default=False,
1214 b'ui', b'commitsubrepos', default=False,
1212 )
1215 )
1213 coreconfigitem(
1216 coreconfigitem(
1214 b'ui', b'debug', default=False,
1217 b'ui', b'debug', default=False,
1215 )
1218 )
1216 coreconfigitem(
1219 coreconfigitem(
1217 b'ui', b'debugger', default=None,
1220 b'ui', b'debugger', default=None,
1218 )
1221 )
1219 coreconfigitem(
1222 coreconfigitem(
1220 b'ui', b'editor', default=dynamicdefault,
1223 b'ui', b'editor', default=dynamicdefault,
1221 )
1224 )
1222 coreconfigitem(
1225 coreconfigitem(
1223 b'ui', b'fallbackencoding', default=None,
1226 b'ui', b'fallbackencoding', default=None,
1224 )
1227 )
1225 coreconfigitem(
1228 coreconfigitem(
1226 b'ui', b'forcecwd', default=None,
1229 b'ui', b'forcecwd', default=None,
1227 )
1230 )
1228 coreconfigitem(
1231 coreconfigitem(
1229 b'ui', b'forcemerge', default=None,
1232 b'ui', b'forcemerge', default=None,
1230 )
1233 )
1231 coreconfigitem(
1234 coreconfigitem(
1232 b'ui', b'formatdebug', default=False,
1235 b'ui', b'formatdebug', default=False,
1233 )
1236 )
1234 coreconfigitem(
1237 coreconfigitem(
1235 b'ui', b'formatjson', default=False,
1238 b'ui', b'formatjson', default=False,
1236 )
1239 )
1237 coreconfigitem(
1240 coreconfigitem(
1238 b'ui', b'formatted', default=None,
1241 b'ui', b'formatted', default=None,
1239 )
1242 )
1240 coreconfigitem(
1243 coreconfigitem(
1241 b'ui', b'graphnodetemplate', default=None,
1244 b'ui', b'graphnodetemplate', default=None,
1242 )
1245 )
1243 coreconfigitem(
1246 coreconfigitem(
1244 b'ui', b'interactive', default=None,
1247 b'ui', b'interactive', default=None,
1245 )
1248 )
1246 coreconfigitem(
1249 coreconfigitem(
1247 b'ui', b'interface', default=None,
1250 b'ui', b'interface', default=None,
1248 )
1251 )
1249 coreconfigitem(
1252 coreconfigitem(
1250 b'ui', b'interface.chunkselector', default=None,
1253 b'ui', b'interface.chunkselector', default=None,
1251 )
1254 )
1252 coreconfigitem(
1255 coreconfigitem(
1253 b'ui', b'large-file-limit', default=10000000,
1256 b'ui', b'large-file-limit', default=10000000,
1254 )
1257 )
1255 coreconfigitem(
1258 coreconfigitem(
1256 b'ui', b'logblockedtimes', default=False,
1259 b'ui', b'logblockedtimes', default=False,
1257 )
1260 )
1258 coreconfigitem(
1261 coreconfigitem(
1259 b'ui', b'logtemplate', default=None,
1262 b'ui', b'logtemplate', default=None,
1260 )
1263 )
1261 coreconfigitem(
1264 coreconfigitem(
1262 b'ui', b'merge', default=None,
1265 b'ui', b'merge', default=None,
1263 )
1266 )
1264 coreconfigitem(
1267 coreconfigitem(
1265 b'ui', b'mergemarkers', default=b'basic',
1268 b'ui', b'mergemarkers', default=b'basic',
1266 )
1269 )
1267 coreconfigitem(
1270 coreconfigitem(
1268 b'ui',
1271 b'ui',
1269 b'mergemarkertemplate',
1272 b'mergemarkertemplate',
1270 default=(
1273 default=(
1271 b'{node|short} '
1274 b'{node|short} '
1272 b'{ifeq(tags, "tip", "", '
1275 b'{ifeq(tags, "tip", "", '
1273 b'ifeq(tags, "", "", "{tags} "))}'
1276 b'ifeq(tags, "", "", "{tags} "))}'
1274 b'{if(bookmarks, "{bookmarks} ")}'
1277 b'{if(bookmarks, "{bookmarks} ")}'
1275 b'{ifeq(branch, "default", "", "{branch} ")}'
1278 b'{ifeq(branch, "default", "", "{branch} ")}'
1276 b'- {author|user}: {desc|firstline}'
1279 b'- {author|user}: {desc|firstline}'
1277 ),
1280 ),
1278 )
1281 )
1279 coreconfigitem(
1282 coreconfigitem(
1280 b'ui', b'message-output', default=b'stdio',
1283 b'ui', b'message-output', default=b'stdio',
1281 )
1284 )
1282 coreconfigitem(
1285 coreconfigitem(
1283 b'ui', b'nontty', default=False,
1286 b'ui', b'nontty', default=False,
1284 )
1287 )
1285 coreconfigitem(
1288 coreconfigitem(
1286 b'ui', b'origbackuppath', default=None,
1289 b'ui', b'origbackuppath', default=None,
1287 )
1290 )
1288 coreconfigitem(
1291 coreconfigitem(
1289 b'ui', b'paginate', default=True,
1292 b'ui', b'paginate', default=True,
1290 )
1293 )
1291 coreconfigitem(
1294 coreconfigitem(
1292 b'ui', b'patch', default=None,
1295 b'ui', b'patch', default=None,
1293 )
1296 )
1294 coreconfigitem(
1297 coreconfigitem(
1295 b'ui', b'pre-merge-tool-output-template', default=None,
1298 b'ui', b'pre-merge-tool-output-template', default=None,
1296 )
1299 )
1297 coreconfigitem(
1300 coreconfigitem(
1298 b'ui', b'portablefilenames', default=b'warn',
1301 b'ui', b'portablefilenames', default=b'warn',
1299 )
1302 )
1300 coreconfigitem(
1303 coreconfigitem(
1301 b'ui', b'promptecho', default=False,
1304 b'ui', b'promptecho', default=False,
1302 )
1305 )
1303 coreconfigitem(
1306 coreconfigitem(
1304 b'ui', b'quiet', default=False,
1307 b'ui', b'quiet', default=False,
1305 )
1308 )
1306 coreconfigitem(
1309 coreconfigitem(
1307 b'ui', b'quietbookmarkmove', default=False,
1310 b'ui', b'quietbookmarkmove', default=False,
1308 )
1311 )
1309 coreconfigitem(
1312 coreconfigitem(
1310 b'ui', b'relative-paths', default=b'legacy',
1313 b'ui', b'relative-paths', default=b'legacy',
1311 )
1314 )
1312 coreconfigitem(
1315 coreconfigitem(
1313 b'ui', b'remotecmd', default=b'hg',
1316 b'ui', b'remotecmd', default=b'hg',
1314 )
1317 )
1315 coreconfigitem(
1318 coreconfigitem(
1316 b'ui', b'report_untrusted', default=True,
1319 b'ui', b'report_untrusted', default=True,
1317 )
1320 )
1318 coreconfigitem(
1321 coreconfigitem(
1319 b'ui', b'rollback', default=True,
1322 b'ui', b'rollback', default=True,
1320 )
1323 )
1321 coreconfigitem(
1324 coreconfigitem(
1322 b'ui', b'signal-safe-lock', default=True,
1325 b'ui', b'signal-safe-lock', default=True,
1323 )
1326 )
1324 coreconfigitem(
1327 coreconfigitem(
1325 b'ui', b'slash', default=False,
1328 b'ui', b'slash', default=False,
1326 )
1329 )
1327 coreconfigitem(
1330 coreconfigitem(
1328 b'ui', b'ssh', default=b'ssh',
1331 b'ui', b'ssh', default=b'ssh',
1329 )
1332 )
1330 coreconfigitem(
1333 coreconfigitem(
1331 b'ui', b'ssherrorhint', default=None,
1334 b'ui', b'ssherrorhint', default=None,
1332 )
1335 )
1333 coreconfigitem(
1336 coreconfigitem(
1334 b'ui', b'statuscopies', default=False,
1337 b'ui', b'statuscopies', default=False,
1335 )
1338 )
1336 coreconfigitem(
1339 coreconfigitem(
1337 b'ui', b'strict', default=False,
1340 b'ui', b'strict', default=False,
1338 )
1341 )
1339 coreconfigitem(
1342 coreconfigitem(
1340 b'ui', b'style', default=b'',
1343 b'ui', b'style', default=b'',
1341 )
1344 )
1342 coreconfigitem(
1345 coreconfigitem(
1343 b'ui', b'supportcontact', default=None,
1346 b'ui', b'supportcontact', default=None,
1344 )
1347 )
1345 coreconfigitem(
1348 coreconfigitem(
1346 b'ui', b'textwidth', default=78,
1349 b'ui', b'textwidth', default=78,
1347 )
1350 )
1348 coreconfigitem(
1351 coreconfigitem(
1349 b'ui', b'timeout', default=b'600',
1352 b'ui', b'timeout', default=b'600',
1350 )
1353 )
1351 coreconfigitem(
1354 coreconfigitem(
1352 b'ui', b'timeout.warn', default=0,
1355 b'ui', b'timeout.warn', default=0,
1353 )
1356 )
1354 coreconfigitem(
1357 coreconfigitem(
1355 b'ui', b'traceback', default=False,
1358 b'ui', b'traceback', default=False,
1356 )
1359 )
1357 coreconfigitem(
1360 coreconfigitem(
1358 b'ui', b'tweakdefaults', default=False,
1361 b'ui', b'tweakdefaults', default=False,
1359 )
1362 )
1360 coreconfigitem(b'ui', b'username', alias=[(b'ui', b'user')])
1363 coreconfigitem(b'ui', b'username', alias=[(b'ui', b'user')])
1361 coreconfigitem(
1364 coreconfigitem(
1362 b'ui', b'verbose', default=False,
1365 b'ui', b'verbose', default=False,
1363 )
1366 )
1364 coreconfigitem(
1367 coreconfigitem(
1365 b'verify', b'skipflags', default=None,
1368 b'verify', b'skipflags', default=None,
1366 )
1369 )
1367 coreconfigitem(
1370 coreconfigitem(
1368 b'web', b'allowbz2', default=False,
1371 b'web', b'allowbz2', default=False,
1369 )
1372 )
1370 coreconfigitem(
1373 coreconfigitem(
1371 b'web', b'allowgz', default=False,
1374 b'web', b'allowgz', default=False,
1372 )
1375 )
1373 coreconfigitem(
1376 coreconfigitem(
1374 b'web', b'allow-pull', alias=[(b'web', b'allowpull')], default=True,
1377 b'web', b'allow-pull', alias=[(b'web', b'allowpull')], default=True,
1375 )
1378 )
1376 coreconfigitem(
1379 coreconfigitem(
1377 b'web', b'allow-push', alias=[(b'web', b'allow_push')], default=list,
1380 b'web', b'allow-push', alias=[(b'web', b'allow_push')], default=list,
1378 )
1381 )
1379 coreconfigitem(
1382 coreconfigitem(
1380 b'web', b'allowzip', default=False,
1383 b'web', b'allowzip', default=False,
1381 )
1384 )
1382 coreconfigitem(
1385 coreconfigitem(
1383 b'web', b'archivesubrepos', default=False,
1386 b'web', b'archivesubrepos', default=False,
1384 )
1387 )
1385 coreconfigitem(
1388 coreconfigitem(
1386 b'web', b'cache', default=True,
1389 b'web', b'cache', default=True,
1387 )
1390 )
1388 coreconfigitem(
1391 coreconfigitem(
1389 b'web', b'comparisoncontext', default=5,
1392 b'web', b'comparisoncontext', default=5,
1390 )
1393 )
1391 coreconfigitem(
1394 coreconfigitem(
1392 b'web', b'contact', default=None,
1395 b'web', b'contact', default=None,
1393 )
1396 )
1394 coreconfigitem(
1397 coreconfigitem(
1395 b'web', b'deny_push', default=list,
1398 b'web', b'deny_push', default=list,
1396 )
1399 )
1397 coreconfigitem(
1400 coreconfigitem(
1398 b'web', b'guessmime', default=False,
1401 b'web', b'guessmime', default=False,
1399 )
1402 )
1400 coreconfigitem(
1403 coreconfigitem(
1401 b'web', b'hidden', default=False,
1404 b'web', b'hidden', default=False,
1402 )
1405 )
1403 coreconfigitem(
1406 coreconfigitem(
1404 b'web', b'labels', default=list,
1407 b'web', b'labels', default=list,
1405 )
1408 )
1406 coreconfigitem(
1409 coreconfigitem(
1407 b'web', b'logoimg', default=b'hglogo.png',
1410 b'web', b'logoimg', default=b'hglogo.png',
1408 )
1411 )
1409 coreconfigitem(
1412 coreconfigitem(
1410 b'web', b'logourl', default=b'https://mercurial-scm.org/',
1413 b'web', b'logourl', default=b'https://mercurial-scm.org/',
1411 )
1414 )
1412 coreconfigitem(
1415 coreconfigitem(
1413 b'web', b'accesslog', default=b'-',
1416 b'web', b'accesslog', default=b'-',
1414 )
1417 )
1415 coreconfigitem(
1418 coreconfigitem(
1416 b'web', b'address', default=b'',
1419 b'web', b'address', default=b'',
1417 )
1420 )
1418 coreconfigitem(
1421 coreconfigitem(
1419 b'web', b'allow-archive', alias=[(b'web', b'allow_archive')], default=list,
1422 b'web', b'allow-archive', alias=[(b'web', b'allow_archive')], default=list,
1420 )
1423 )
1421 coreconfigitem(
1424 coreconfigitem(
1422 b'web', b'allow_read', default=list,
1425 b'web', b'allow_read', default=list,
1423 )
1426 )
1424 coreconfigitem(
1427 coreconfigitem(
1425 b'web', b'baseurl', default=None,
1428 b'web', b'baseurl', default=None,
1426 )
1429 )
1427 coreconfigitem(
1430 coreconfigitem(
1428 b'web', b'cacerts', default=None,
1431 b'web', b'cacerts', default=None,
1429 )
1432 )
1430 coreconfigitem(
1433 coreconfigitem(
1431 b'web', b'certificate', default=None,
1434 b'web', b'certificate', default=None,
1432 )
1435 )
1433 coreconfigitem(
1436 coreconfigitem(
1434 b'web', b'collapse', default=False,
1437 b'web', b'collapse', default=False,
1435 )
1438 )
1436 coreconfigitem(
1439 coreconfigitem(
1437 b'web', b'csp', default=None,
1440 b'web', b'csp', default=None,
1438 )
1441 )
1439 coreconfigitem(
1442 coreconfigitem(
1440 b'web', b'deny_read', default=list,
1443 b'web', b'deny_read', default=list,
1441 )
1444 )
1442 coreconfigitem(
1445 coreconfigitem(
1443 b'web', b'descend', default=True,
1446 b'web', b'descend', default=True,
1444 )
1447 )
1445 coreconfigitem(
1448 coreconfigitem(
1446 b'web', b'description', default=b"",
1449 b'web', b'description', default=b"",
1447 )
1450 )
1448 coreconfigitem(
1451 coreconfigitem(
1449 b'web', b'encoding', default=lambda: encoding.encoding,
1452 b'web', b'encoding', default=lambda: encoding.encoding,
1450 )
1453 )
1451 coreconfigitem(
1454 coreconfigitem(
1452 b'web', b'errorlog', default=b'-',
1455 b'web', b'errorlog', default=b'-',
1453 )
1456 )
1454 coreconfigitem(
1457 coreconfigitem(
1455 b'web', b'ipv6', default=False,
1458 b'web', b'ipv6', default=False,
1456 )
1459 )
1457 coreconfigitem(
1460 coreconfigitem(
1458 b'web', b'maxchanges', default=10,
1461 b'web', b'maxchanges', default=10,
1459 )
1462 )
1460 coreconfigitem(
1463 coreconfigitem(
1461 b'web', b'maxfiles', default=10,
1464 b'web', b'maxfiles', default=10,
1462 )
1465 )
1463 coreconfigitem(
1466 coreconfigitem(
1464 b'web', b'maxshortchanges', default=60,
1467 b'web', b'maxshortchanges', default=60,
1465 )
1468 )
1466 coreconfigitem(
1469 coreconfigitem(
1467 b'web', b'motd', default=b'',
1470 b'web', b'motd', default=b'',
1468 )
1471 )
1469 coreconfigitem(
1472 coreconfigitem(
1470 b'web', b'name', default=dynamicdefault,
1473 b'web', b'name', default=dynamicdefault,
1471 )
1474 )
1472 coreconfigitem(
1475 coreconfigitem(
1473 b'web', b'port', default=8000,
1476 b'web', b'port', default=8000,
1474 )
1477 )
1475 coreconfigitem(
1478 coreconfigitem(
1476 b'web', b'prefix', default=b'',
1479 b'web', b'prefix', default=b'',
1477 )
1480 )
1478 coreconfigitem(
1481 coreconfigitem(
1479 b'web', b'push_ssl', default=True,
1482 b'web', b'push_ssl', default=True,
1480 )
1483 )
1481 coreconfigitem(
1484 coreconfigitem(
1482 b'web', b'refreshinterval', default=20,
1485 b'web', b'refreshinterval', default=20,
1483 )
1486 )
1484 coreconfigitem(
1487 coreconfigitem(
1485 b'web', b'server-header', default=None,
1488 b'web', b'server-header', default=None,
1486 )
1489 )
1487 coreconfigitem(
1490 coreconfigitem(
1488 b'web', b'static', default=None,
1491 b'web', b'static', default=None,
1489 )
1492 )
1490 coreconfigitem(
1493 coreconfigitem(
1491 b'web', b'staticurl', default=None,
1494 b'web', b'staticurl', default=None,
1492 )
1495 )
1493 coreconfigitem(
1496 coreconfigitem(
1494 b'web', b'stripes', default=1,
1497 b'web', b'stripes', default=1,
1495 )
1498 )
1496 coreconfigitem(
1499 coreconfigitem(
1497 b'web', b'style', default=b'paper',
1500 b'web', b'style', default=b'paper',
1498 )
1501 )
1499 coreconfigitem(
1502 coreconfigitem(
1500 b'web', b'templates', default=None,
1503 b'web', b'templates', default=None,
1501 )
1504 )
1502 coreconfigitem(
1505 coreconfigitem(
1503 b'web', b'view', default=b'served', experimental=True,
1506 b'web', b'view', default=b'served', experimental=True,
1504 )
1507 )
1505 coreconfigitem(
1508 coreconfigitem(
1506 b'worker', b'backgroundclose', default=dynamicdefault,
1509 b'worker', b'backgroundclose', default=dynamicdefault,
1507 )
1510 )
1508 # Windows defaults to a limit of 512 open files. A buffer of 128
1511 # Windows defaults to a limit of 512 open files. A buffer of 128
1509 # should give us enough headway.
1512 # should give us enough headway.
1510 coreconfigitem(
1513 coreconfigitem(
1511 b'worker', b'backgroundclosemaxqueue', default=384,
1514 b'worker', b'backgroundclosemaxqueue', default=384,
1512 )
1515 )
1513 coreconfigitem(
1516 coreconfigitem(
1514 b'worker', b'backgroundcloseminfilecount', default=2048,
1517 b'worker', b'backgroundcloseminfilecount', default=2048,
1515 )
1518 )
1516 coreconfigitem(
1519 coreconfigitem(
1517 b'worker', b'backgroundclosethreadcount', default=4,
1520 b'worker', b'backgroundclosethreadcount', default=4,
1518 )
1521 )
1519 coreconfigitem(
1522 coreconfigitem(
1520 b'worker', b'enabled', default=True,
1523 b'worker', b'enabled', default=True,
1521 )
1524 )
1522 coreconfigitem(
1525 coreconfigitem(
1523 b'worker', b'numcpus', default=None,
1526 b'worker', b'numcpus', default=None,
1524 )
1527 )
1525
1528
1526 # Rebase related configuration moved to core because other extension are doing
1529 # Rebase related configuration moved to core because other extension are doing
1527 # strange things. For example, shelve import the extensions to reuse some bit
1530 # strange things. For example, shelve import the extensions to reuse some bit
1528 # without formally loading it.
1531 # without formally loading it.
1529 coreconfigitem(
1532 coreconfigitem(
1530 b'commands', b'rebase.requiredest', default=False,
1533 b'commands', b'rebase.requiredest', default=False,
1531 )
1534 )
1532 coreconfigitem(
1535 coreconfigitem(
1533 b'experimental', b'rebaseskipobsolete', default=True,
1536 b'experimental', b'rebaseskipobsolete', default=True,
1534 )
1537 )
1535 coreconfigitem(
1538 coreconfigitem(
1536 b'rebase', b'singletransaction', default=False,
1539 b'rebase', b'singletransaction', default=False,
1537 )
1540 )
1538 coreconfigitem(
1541 coreconfigitem(
1539 b'rebase', b'experimental.inmemory', default=False,
1542 b'rebase', b'experimental.inmemory', default=False,
1540 )
1543 )
@@ -1,2862 +1,2870 b''
1 The Mercurial system uses a set of configuration files to control
1 The Mercurial system uses a set of configuration files to control
2 aspects of its behavior.
2 aspects of its behavior.
3
3
4 Troubleshooting
4 Troubleshooting
5 ===============
5 ===============
6
6
7 If you're having problems with your configuration,
7 If you're having problems with your configuration,
8 :hg:`config --debug` can help you understand what is introducing
8 :hg:`config --debug` can help you understand what is introducing
9 a setting into your environment.
9 a setting into your environment.
10
10
11 See :hg:`help config.syntax` and :hg:`help config.files`
11 See :hg:`help config.syntax` and :hg:`help config.files`
12 for information about how and where to override things.
12 for information about how and where to override things.
13
13
14 Structure
14 Structure
15 =========
15 =========
16
16
17 The configuration files use a simple ini-file format. A configuration
17 The configuration files use a simple ini-file format. A configuration
18 file consists of sections, led by a ``[section]`` header and followed
18 file consists of sections, led by a ``[section]`` header and followed
19 by ``name = value`` entries::
19 by ``name = value`` entries::
20
20
21 [ui]
21 [ui]
22 username = Firstname Lastname <firstname.lastname@example.net>
22 username = Firstname Lastname <firstname.lastname@example.net>
23 verbose = True
23 verbose = True
24
24
25 The above entries will be referred to as ``ui.username`` and
25 The above entries will be referred to as ``ui.username`` and
26 ``ui.verbose``, respectively. See :hg:`help config.syntax`.
26 ``ui.verbose``, respectively. See :hg:`help config.syntax`.
27
27
28 Files
28 Files
29 =====
29 =====
30
30
31 Mercurial reads configuration data from several files, if they exist.
31 Mercurial reads configuration data from several files, if they exist.
32 These files do not exist by default and you will have to create the
32 These files do not exist by default and you will have to create the
33 appropriate configuration files yourself:
33 appropriate configuration files yourself:
34
34
35 Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
35 Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
36
36
37 Global configuration like the username setting is typically put into:
37 Global configuration like the username setting is typically put into:
38
38
39 .. container:: windows
39 .. container:: windows
40
40
41 - ``%USERPROFILE%\mercurial.ini`` (on Windows)
41 - ``%USERPROFILE%\mercurial.ini`` (on Windows)
42
42
43 .. container:: unix.plan9
43 .. container:: unix.plan9
44
44
45 - ``$HOME/.hgrc`` (on Unix, Plan9)
45 - ``$HOME/.hgrc`` (on Unix, Plan9)
46
46
47 The names of these files depend on the system on which Mercurial is
47 The names of these files depend on the system on which Mercurial is
48 installed. ``*.rc`` files from a single directory are read in
48 installed. ``*.rc`` files from a single directory are read in
49 alphabetical order, later ones overriding earlier ones. Where multiple
49 alphabetical order, later ones overriding earlier ones. Where multiple
50 paths are given below, settings from earlier paths override later
50 paths are given below, settings from earlier paths override later
51 ones.
51 ones.
52
52
53 .. container:: verbose.unix
53 .. container:: verbose.unix
54
54
55 On Unix, the following files are consulted:
55 On Unix, the following files are consulted:
56
56
57 - ``<repo>/.hg/hgrc`` (per-repository)
57 - ``<repo>/.hg/hgrc`` (per-repository)
58 - ``$HOME/.hgrc`` (per-user)
58 - ``$HOME/.hgrc`` (per-user)
59 - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
59 - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
60 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
60 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
61 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
61 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
62 - ``/etc/mercurial/hgrc`` (per-system)
62 - ``/etc/mercurial/hgrc`` (per-system)
63 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
63 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
64 - ``<internal>/default.d/*.rc`` (defaults)
64 - ``<internal>/default.d/*.rc`` (defaults)
65
65
66 .. container:: verbose.windows
66 .. container:: verbose.windows
67
67
68 On Windows, the following files are consulted:
68 On Windows, the following files are consulted:
69
69
70 - ``<repo>/.hg/hgrc`` (per-repository)
70 - ``<repo>/.hg/hgrc`` (per-repository)
71 - ``%USERPROFILE%\.hgrc`` (per-user)
71 - ``%USERPROFILE%\.hgrc`` (per-user)
72 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
72 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
73 - ``%HOME%\.hgrc`` (per-user)
73 - ``%HOME%\.hgrc`` (per-user)
74 - ``%HOME%\Mercurial.ini`` (per-user)
74 - ``%HOME%\Mercurial.ini`` (per-user)
75 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
75 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
76 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
76 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
77 - ``<install-dir>\Mercurial.ini`` (per-installation)
77 - ``<install-dir>\Mercurial.ini`` (per-installation)
78 - ``<internal>/default.d/*.rc`` (defaults)
78 - ``<internal>/default.d/*.rc`` (defaults)
79
79
80 .. note::
80 .. note::
81
81
82 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
82 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
83 is used when running 32-bit Python on 64-bit Windows.
83 is used when running 32-bit Python on 64-bit Windows.
84
84
85 .. container:: windows
85 .. container:: windows
86
86
87 On Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``.
87 On Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``.
88
88
89 .. container:: verbose.plan9
89 .. container:: verbose.plan9
90
90
91 On Plan9, the following files are consulted:
91 On Plan9, the following files are consulted:
92
92
93 - ``<repo>/.hg/hgrc`` (per-repository)
93 - ``<repo>/.hg/hgrc`` (per-repository)
94 - ``$home/lib/hgrc`` (per-user)
94 - ``$home/lib/hgrc`` (per-user)
95 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
95 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
96 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
96 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
97 - ``/lib/mercurial/hgrc`` (per-system)
97 - ``/lib/mercurial/hgrc`` (per-system)
98 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
98 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
99 - ``<internal>/default.d/*.rc`` (defaults)
99 - ``<internal>/default.d/*.rc`` (defaults)
100
100
101 Per-repository configuration options only apply in a
101 Per-repository configuration options only apply in a
102 particular repository. This file is not version-controlled, and
102 particular repository. This file is not version-controlled, and
103 will not get transferred during a "clone" operation. Options in
103 will not get transferred during a "clone" operation. Options in
104 this file override options in all other configuration files.
104 this file override options in all other configuration files.
105
105
106 .. container:: unix.plan9
106 .. container:: unix.plan9
107
107
108 On Plan 9 and Unix, most of this file will be ignored if it doesn't
108 On Plan 9 and Unix, most of this file will be ignored if it doesn't
109 belong to a trusted user or to a trusted group. See
109 belong to a trusted user or to a trusted group. See
110 :hg:`help config.trusted` for more details.
110 :hg:`help config.trusted` for more details.
111
111
112 Per-user configuration file(s) are for the user running Mercurial. Options
112 Per-user configuration file(s) are for the user running Mercurial. Options
113 in these files apply to all Mercurial commands executed by this user in any
113 in these files apply to all Mercurial commands executed by this user in any
114 directory. Options in these files override per-system and per-installation
114 directory. Options in these files override per-system and per-installation
115 options.
115 options.
116
116
117 Per-installation configuration files are searched for in the
117 Per-installation configuration files are searched for in the
118 directory where Mercurial is installed. ``<install-root>`` is the
118 directory where Mercurial is installed. ``<install-root>`` is the
119 parent directory of the **hg** executable (or symlink) being run.
119 parent directory of the **hg** executable (or symlink) being run.
120
120
121 .. container:: unix.plan9
121 .. container:: unix.plan9
122
122
123 For example, if installed in ``/shared/tools/bin/hg``, Mercurial
123 For example, if installed in ``/shared/tools/bin/hg``, Mercurial
124 will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
124 will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
125 files apply to all Mercurial commands executed by any user in any
125 files apply to all Mercurial commands executed by any user in any
126 directory.
126 directory.
127
127
128 Per-installation configuration files are for the system on
128 Per-installation configuration files are for the system on
129 which Mercurial is running. Options in these files apply to all
129 which Mercurial is running. Options in these files apply to all
130 Mercurial commands executed by any user in any directory. Registry
130 Mercurial commands executed by any user in any directory. Registry
131 keys contain PATH-like strings, every part of which must reference
131 keys contain PATH-like strings, every part of which must reference
132 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
132 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
133 be read. Mercurial checks each of these locations in the specified
133 be read. Mercurial checks each of these locations in the specified
134 order until one or more configuration files are detected.
134 order until one or more configuration files are detected.
135
135
136 Per-system configuration files are for the system on which Mercurial
136 Per-system configuration files are for the system on which Mercurial
137 is running. Options in these files apply to all Mercurial commands
137 is running. Options in these files apply to all Mercurial commands
138 executed by any user in any directory. Options in these files
138 executed by any user in any directory. Options in these files
139 override per-installation options.
139 override per-installation options.
140
140
141 Mercurial comes with some default configuration. The default configuration
141 Mercurial comes with some default configuration. The default configuration
142 files are installed with Mercurial and will be overwritten on upgrades. Default
142 files are installed with Mercurial and will be overwritten on upgrades. Default
143 configuration files should never be edited by users or administrators but can
143 configuration files should never be edited by users or administrators but can
144 be overridden in other configuration files. So far the directory only contains
144 be overridden in other configuration files. So far the directory only contains
145 merge tool configuration but packagers can also put other default configuration
145 merge tool configuration but packagers can also put other default configuration
146 there.
146 there.
147
147
148 Syntax
148 Syntax
149 ======
149 ======
150
150
151 A configuration file consists of sections, led by a ``[section]`` header
151 A configuration file consists of sections, led by a ``[section]`` header
152 and followed by ``name = value`` entries (sometimes called
152 and followed by ``name = value`` entries (sometimes called
153 ``configuration keys``)::
153 ``configuration keys``)::
154
154
155 [spam]
155 [spam]
156 eggs=ham
156 eggs=ham
157 green=
157 green=
158 eggs
158 eggs
159
159
160 Each line contains one entry. If the lines that follow are indented,
160 Each line contains one entry. If the lines that follow are indented,
161 they are treated as continuations of that entry. Leading whitespace is
161 they are treated as continuations of that entry. Leading whitespace is
162 removed from values. Empty lines are skipped. Lines beginning with
162 removed from values. Empty lines are skipped. Lines beginning with
163 ``#`` or ``;`` are ignored and may be used to provide comments.
163 ``#`` or ``;`` are ignored and may be used to provide comments.
164
164
165 Configuration keys can be set multiple times, in which case Mercurial
165 Configuration keys can be set multiple times, in which case Mercurial
166 will use the value that was configured last. As an example::
166 will use the value that was configured last. As an example::
167
167
168 [spam]
168 [spam]
169 eggs=large
169 eggs=large
170 ham=serrano
170 ham=serrano
171 eggs=small
171 eggs=small
172
172
173 This would set the configuration key named ``eggs`` to ``small``.
173 This would set the configuration key named ``eggs`` to ``small``.
174
174
175 It is also possible to define a section multiple times. A section can
175 It is also possible to define a section multiple times. A section can
176 be redefined on the same and/or on different configuration files. For
176 be redefined on the same and/or on different configuration files. For
177 example::
177 example::
178
178
179 [foo]
179 [foo]
180 eggs=large
180 eggs=large
181 ham=serrano
181 ham=serrano
182 eggs=small
182 eggs=small
183
183
184 [bar]
184 [bar]
185 eggs=ham
185 eggs=ham
186 green=
186 green=
187 eggs
187 eggs
188
188
189 [foo]
189 [foo]
190 ham=prosciutto
190 ham=prosciutto
191 eggs=medium
191 eggs=medium
192 bread=toasted
192 bread=toasted
193
193
194 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
194 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
195 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
195 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
196 respectively. As you can see there only thing that matters is the last
196 respectively. As you can see there only thing that matters is the last
197 value that was set for each of the configuration keys.
197 value that was set for each of the configuration keys.
198
198
199 If a configuration key is set multiple times in different
199 If a configuration key is set multiple times in different
200 configuration files the final value will depend on the order in which
200 configuration files the final value will depend on the order in which
201 the different configuration files are read, with settings from earlier
201 the different configuration files are read, with settings from earlier
202 paths overriding later ones as described on the ``Files`` section
202 paths overriding later ones as described on the ``Files`` section
203 above.
203 above.
204
204
205 A line of the form ``%include file`` will include ``file`` into the
205 A line of the form ``%include file`` will include ``file`` into the
206 current configuration file. The inclusion is recursive, which means
206 current configuration file. The inclusion is recursive, which means
207 that included files can include other files. Filenames are relative to
207 that included files can include other files. Filenames are relative to
208 the configuration file in which the ``%include`` directive is found.
208 the configuration file in which the ``%include`` directive is found.
209 Environment variables and ``~user`` constructs are expanded in
209 Environment variables and ``~user`` constructs are expanded in
210 ``file``. This lets you do something like::
210 ``file``. This lets you do something like::
211
211
212 %include ~/.hgrc.d/$HOST.rc
212 %include ~/.hgrc.d/$HOST.rc
213
213
214 to include a different configuration file on each computer you use.
214 to include a different configuration file on each computer you use.
215
215
216 A line with ``%unset name`` will remove ``name`` from the current
216 A line with ``%unset name`` will remove ``name`` from the current
217 section, if it has been set previously.
217 section, if it has been set previously.
218
218
219 The values are either free-form text strings, lists of text strings,
219 The values are either free-form text strings, lists of text strings,
220 or Boolean values. Boolean values can be set to true using any of "1",
220 or Boolean values. Boolean values can be set to true using any of "1",
221 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
221 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
222 (all case insensitive).
222 (all case insensitive).
223
223
224 List values are separated by whitespace or comma, except when values are
224 List values are separated by whitespace or comma, except when values are
225 placed in double quotation marks::
225 placed in double quotation marks::
226
226
227 allow_read = "John Doe, PhD", brian, betty
227 allow_read = "John Doe, PhD", brian, betty
228
228
229 Quotation marks can be escaped by prefixing them with a backslash. Only
229 Quotation marks can be escaped by prefixing them with a backslash. Only
230 quotation marks at the beginning of a word is counted as a quotation
230 quotation marks at the beginning of a word is counted as a quotation
231 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
231 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
232
232
233 Sections
233 Sections
234 ========
234 ========
235
235
236 This section describes the different sections that may appear in a
236 This section describes the different sections that may appear in a
237 Mercurial configuration file, the purpose of each section, its possible
237 Mercurial configuration file, the purpose of each section, its possible
238 keys, and their possible values.
238 keys, and their possible values.
239
239
240 ``alias``
240 ``alias``
241 ---------
241 ---------
242
242
243 Defines command aliases.
243 Defines command aliases.
244
244
245 Aliases allow you to define your own commands in terms of other
245 Aliases allow you to define your own commands in terms of other
246 commands (or aliases), optionally including arguments. Positional
246 commands (or aliases), optionally including arguments. Positional
247 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
247 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
248 are expanded by Mercurial before execution. Positional arguments not
248 are expanded by Mercurial before execution. Positional arguments not
249 already used by ``$N`` in the definition are put at the end of the
249 already used by ``$N`` in the definition are put at the end of the
250 command to be executed.
250 command to be executed.
251
251
252 Alias definitions consist of lines of the form::
252 Alias definitions consist of lines of the form::
253
253
254 <alias> = <command> [<argument>]...
254 <alias> = <command> [<argument>]...
255
255
256 For example, this definition::
256 For example, this definition::
257
257
258 latest = log --limit 5
258 latest = log --limit 5
259
259
260 creates a new command ``latest`` that shows only the five most recent
260 creates a new command ``latest`` that shows only the five most recent
261 changesets. You can define subsequent aliases using earlier ones::
261 changesets. You can define subsequent aliases using earlier ones::
262
262
263 stable5 = latest -b stable
263 stable5 = latest -b stable
264
264
265 .. note::
265 .. note::
266
266
267 It is possible to create aliases with the same names as
267 It is possible to create aliases with the same names as
268 existing commands, which will then override the original
268 existing commands, which will then override the original
269 definitions. This is almost always a bad idea!
269 definitions. This is almost always a bad idea!
270
270
271 An alias can start with an exclamation point (``!``) to make it a
271 An alias can start with an exclamation point (``!``) to make it a
272 shell alias. A shell alias is executed with the shell and will let you
272 shell alias. A shell alias is executed with the shell and will let you
273 run arbitrary commands. As an example, ::
273 run arbitrary commands. As an example, ::
274
274
275 echo = !echo $@
275 echo = !echo $@
276
276
277 will let you do ``hg echo foo`` to have ``foo`` printed in your
277 will let you do ``hg echo foo`` to have ``foo`` printed in your
278 terminal. A better example might be::
278 terminal. A better example might be::
279
279
280 purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
280 purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
281
281
282 which will make ``hg purge`` delete all unknown files in the
282 which will make ``hg purge`` delete all unknown files in the
283 repository in the same manner as the purge extension.
283 repository in the same manner as the purge extension.
284
284
285 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
285 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
286 expand to the command arguments. Unmatched arguments are
286 expand to the command arguments. Unmatched arguments are
287 removed. ``$0`` expands to the alias name and ``$@`` expands to all
287 removed. ``$0`` expands to the alias name and ``$@`` expands to all
288 arguments separated by a space. ``"$@"`` (with quotes) expands to all
288 arguments separated by a space. ``"$@"`` (with quotes) expands to all
289 arguments quoted individually and separated by a space. These expansions
289 arguments quoted individually and separated by a space. These expansions
290 happen before the command is passed to the shell.
290 happen before the command is passed to the shell.
291
291
292 Shell aliases are executed in an environment where ``$HG`` expands to
292 Shell aliases are executed in an environment where ``$HG`` expands to
293 the path of the Mercurial that was used to execute the alias. This is
293 the path of the Mercurial that was used to execute the alias. This is
294 useful when you want to call further Mercurial commands in a shell
294 useful when you want to call further Mercurial commands in a shell
295 alias, as was done above for the purge alias. In addition,
295 alias, as was done above for the purge alias. In addition,
296 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
296 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
297 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
297 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
298
298
299 .. note::
299 .. note::
300
300
301 Some global configuration options such as ``-R`` are
301 Some global configuration options such as ``-R`` are
302 processed before shell aliases and will thus not be passed to
302 processed before shell aliases and will thus not be passed to
303 aliases.
303 aliases.
304
304
305
305
306 ``annotate``
306 ``annotate``
307 ------------
307 ------------
308
308
309 Settings used when displaying file annotations. All values are
309 Settings used when displaying file annotations. All values are
310 Booleans and default to False. See :hg:`help config.diff` for
310 Booleans and default to False. See :hg:`help config.diff` for
311 related options for the diff command.
311 related options for the diff command.
312
312
313 ``ignorews``
313 ``ignorews``
314 Ignore white space when comparing lines.
314 Ignore white space when comparing lines.
315
315
316 ``ignorewseol``
316 ``ignorewseol``
317 Ignore white space at the end of a line when comparing lines.
317 Ignore white space at the end of a line when comparing lines.
318
318
319 ``ignorewsamount``
319 ``ignorewsamount``
320 Ignore changes in the amount of white space.
320 Ignore changes in the amount of white space.
321
321
322 ``ignoreblanklines``
322 ``ignoreblanklines``
323 Ignore changes whose lines are all blank.
323 Ignore changes whose lines are all blank.
324
324
325
325
326 ``auth``
326 ``auth``
327 --------
327 --------
328
328
329 Authentication credentials and other authentication-like configuration
329 Authentication credentials and other authentication-like configuration
330 for HTTP connections. This section allows you to store usernames and
330 for HTTP connections. This section allows you to store usernames and
331 passwords for use when logging *into* HTTP servers. See
331 passwords for use when logging *into* HTTP servers. See
332 :hg:`help config.web` if you want to configure *who* can login to
332 :hg:`help config.web` if you want to configure *who* can login to
333 your HTTP server.
333 your HTTP server.
334
334
335 The following options apply to all hosts.
335 The following options apply to all hosts.
336
336
337 ``cookiefile``
337 ``cookiefile``
338 Path to a file containing HTTP cookie lines. Cookies matching a
338 Path to a file containing HTTP cookie lines. Cookies matching a
339 host will be sent automatically.
339 host will be sent automatically.
340
340
341 The file format uses the Mozilla cookies.txt format, which defines cookies
341 The file format uses the Mozilla cookies.txt format, which defines cookies
342 on their own lines. Each line contains 7 fields delimited by the tab
342 on their own lines. Each line contains 7 fields delimited by the tab
343 character (domain, is_domain_cookie, path, is_secure, expires, name,
343 character (domain, is_domain_cookie, path, is_secure, expires, name,
344 value). For more info, do an Internet search for "Netscape cookies.txt
344 value). For more info, do an Internet search for "Netscape cookies.txt
345 format."
345 format."
346
346
347 Note: the cookies parser does not handle port numbers on domains. You
347 Note: the cookies parser does not handle port numbers on domains. You
348 will need to remove ports from the domain for the cookie to be recognized.
348 will need to remove ports from the domain for the cookie to be recognized.
349 This could result in a cookie being disclosed to an unwanted server.
349 This could result in a cookie being disclosed to an unwanted server.
350
350
351 The cookies file is read-only.
351 The cookies file is read-only.
352
352
353 Other options in this section are grouped by name and have the following
353 Other options in this section are grouped by name and have the following
354 format::
354 format::
355
355
356 <name>.<argument> = <value>
356 <name>.<argument> = <value>
357
357
358 where ``<name>`` is used to group arguments into authentication
358 where ``<name>`` is used to group arguments into authentication
359 entries. Example::
359 entries. Example::
360
360
361 foo.prefix = hg.intevation.de/mercurial
361 foo.prefix = hg.intevation.de/mercurial
362 foo.username = foo
362 foo.username = foo
363 foo.password = bar
363 foo.password = bar
364 foo.schemes = http https
364 foo.schemes = http https
365
365
366 bar.prefix = secure.example.org
366 bar.prefix = secure.example.org
367 bar.key = path/to/file.key
367 bar.key = path/to/file.key
368 bar.cert = path/to/file.cert
368 bar.cert = path/to/file.cert
369 bar.schemes = https
369 bar.schemes = https
370
370
371 Supported arguments:
371 Supported arguments:
372
372
373 ``prefix``
373 ``prefix``
374 Either ``*`` or a URI prefix with or without the scheme part.
374 Either ``*`` or a URI prefix with or without the scheme part.
375 The authentication entry with the longest matching prefix is used
375 The authentication entry with the longest matching prefix is used
376 (where ``*`` matches everything and counts as a match of length
376 (where ``*`` matches everything and counts as a match of length
377 1). If the prefix doesn't include a scheme, the match is performed
377 1). If the prefix doesn't include a scheme, the match is performed
378 against the URI with its scheme stripped as well, and the schemes
378 against the URI with its scheme stripped as well, and the schemes
379 argument, q.v., is then subsequently consulted.
379 argument, q.v., is then subsequently consulted.
380
380
381 ``username``
381 ``username``
382 Optional. Username to authenticate with. If not given, and the
382 Optional. Username to authenticate with. If not given, and the
383 remote site requires basic or digest authentication, the user will
383 remote site requires basic or digest authentication, the user will
384 be prompted for it. Environment variables are expanded in the
384 be prompted for it. Environment variables are expanded in the
385 username letting you do ``foo.username = $USER``. If the URI
385 username letting you do ``foo.username = $USER``. If the URI
386 includes a username, only ``[auth]`` entries with a matching
386 includes a username, only ``[auth]`` entries with a matching
387 username or without a username will be considered.
387 username or without a username will be considered.
388
388
389 ``password``
389 ``password``
390 Optional. Password to authenticate with. If not given, and the
390 Optional. Password to authenticate with. If not given, and the
391 remote site requires basic or digest authentication, the user
391 remote site requires basic or digest authentication, the user
392 will be prompted for it.
392 will be prompted for it.
393
393
394 ``key``
394 ``key``
395 Optional. PEM encoded client certificate key file. Environment
395 Optional. PEM encoded client certificate key file. Environment
396 variables are expanded in the filename.
396 variables are expanded in the filename.
397
397
398 ``cert``
398 ``cert``
399 Optional. PEM encoded client certificate chain file. Environment
399 Optional. PEM encoded client certificate chain file. Environment
400 variables are expanded in the filename.
400 variables are expanded in the filename.
401
401
402 ``schemes``
402 ``schemes``
403 Optional. Space separated list of URI schemes to use this
403 Optional. Space separated list of URI schemes to use this
404 authentication entry with. Only used if the prefix doesn't include
404 authentication entry with. Only used if the prefix doesn't include
405 a scheme. Supported schemes are http and https. They will match
405 a scheme. Supported schemes are http and https. They will match
406 static-http and static-https respectively, as well.
406 static-http and static-https respectively, as well.
407 (default: https)
407 (default: https)
408
408
409 If no suitable authentication entry is found, the user is prompted
409 If no suitable authentication entry is found, the user is prompted
410 for credentials as usual if required by the remote.
410 for credentials as usual if required by the remote.
411
411
412 ``color``
412 ``color``
413 ---------
413 ---------
414
414
415 Configure the Mercurial color mode. For details about how to define your custom
415 Configure the Mercurial color mode. For details about how to define your custom
416 effect and style see :hg:`help color`.
416 effect and style see :hg:`help color`.
417
417
418 ``mode``
418 ``mode``
419 String: control the method used to output color. One of ``auto``, ``ansi``,
419 String: control the method used to output color. One of ``auto``, ``ansi``,
420 ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will
420 ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will
421 use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a
421 use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a
422 terminal. Any invalid value will disable color.
422 terminal. Any invalid value will disable color.
423
423
424 ``pagermode``
424 ``pagermode``
425 String: optional override of ``color.mode`` used with pager.
425 String: optional override of ``color.mode`` used with pager.
426
426
427 On some systems, terminfo mode may cause problems when using
427 On some systems, terminfo mode may cause problems when using
428 color with ``less -R`` as a pager program. less with the -R option
428 color with ``less -R`` as a pager program. less with the -R option
429 will only display ECMA-48 color codes, and terminfo mode may sometimes
429 will only display ECMA-48 color codes, and terminfo mode may sometimes
430 emit codes that less doesn't understand. You can work around this by
430 emit codes that less doesn't understand. You can work around this by
431 either using ansi mode (or auto mode), or by using less -r (which will
431 either using ansi mode (or auto mode), or by using less -r (which will
432 pass through all terminal control codes, not just color control
432 pass through all terminal control codes, not just color control
433 codes).
433 codes).
434
434
435 On some systems (such as MSYS in Windows), the terminal may support
435 On some systems (such as MSYS in Windows), the terminal may support
436 a different color mode than the pager program.
436 a different color mode than the pager program.
437
437
438 ``commands``
438 ``commands``
439 ------------
439 ------------
440
440
441 ``commit.post-status``
441 ``commit.post-status``
442 Show status of files in the working directory after successful commit.
442 Show status of files in the working directory after successful commit.
443 (default: False)
443 (default: False)
444
444
445 ``push.require-revs``
446 Require revisions to push be specified using one or more mechanisms such as
447 specifying them positionally on the command line, using ``-r``, ``-b``,
448 and/or ``-B`` on the command line, or using ``paths.<path>:pushrev`` in the
449 configuration. If this is enabled and revisions are not specified, the
450 command aborts.
451 (default: False)
452
445 ``resolve.confirm``
453 ``resolve.confirm``
446 Confirm before performing action if no filename is passed.
454 Confirm before performing action if no filename is passed.
447 (default: False)
455 (default: False)
448
456
449 ``resolve.explicit-re-merge``
457 ``resolve.explicit-re-merge``
450 Require uses of ``hg resolve`` to specify which action it should perform,
458 Require uses of ``hg resolve`` to specify which action it should perform,
451 instead of re-merging files by default.
459 instead of re-merging files by default.
452 (default: False)
460 (default: False)
453
461
454 ``resolve.mark-check``
462 ``resolve.mark-check``
455 Determines what level of checking :hg:`resolve --mark` will perform before
463 Determines what level of checking :hg:`resolve --mark` will perform before
456 marking files as resolved. Valid values are ``none`, ``warn``, and
464 marking files as resolved. Valid values are ``none`, ``warn``, and
457 ``abort``. ``warn`` will output a warning listing the file(s) that still
465 ``abort``. ``warn`` will output a warning listing the file(s) that still
458 have conflict markers in them, but will still mark everything resolved.
466 have conflict markers in them, but will still mark everything resolved.
459 ``abort`` will output the same warning but will not mark things as resolved.
467 ``abort`` will output the same warning but will not mark things as resolved.
460 If --all is passed and this is set to ``abort``, only a warning will be
468 If --all is passed and this is set to ``abort``, only a warning will be
461 shown (an error will not be raised).
469 shown (an error will not be raised).
462 (default: ``none``)
470 (default: ``none``)
463
471
464 ``status.relative``
472 ``status.relative``
465 Make paths in :hg:`status` output relative to the current directory.
473 Make paths in :hg:`status` output relative to the current directory.
466 (default: False)
474 (default: False)
467
475
468 ``status.terse``
476 ``status.terse``
469 Default value for the --terse flag, which condenses status output.
477 Default value for the --terse flag, which condenses status output.
470 (default: empty)
478 (default: empty)
471
479
472 ``update.check``
480 ``update.check``
473 Determines what level of checking :hg:`update` will perform before moving
481 Determines what level of checking :hg:`update` will perform before moving
474 to a destination revision. Valid values are ``abort``, ``none``,
482 to a destination revision. Valid values are ``abort``, ``none``,
475 ``linear``, and ``noconflict``. ``abort`` always fails if the working
483 ``linear``, and ``noconflict``. ``abort`` always fails if the working
476 directory has uncommitted changes. ``none`` performs no checking, and may
484 directory has uncommitted changes. ``none`` performs no checking, and may
477 result in a merge with uncommitted changes. ``linear`` allows any update
485 result in a merge with uncommitted changes. ``linear`` allows any update
478 as long as it follows a straight line in the revision history, and may
486 as long as it follows a straight line in the revision history, and may
479 trigger a merge with uncommitted changes. ``noconflict`` will allow any
487 trigger a merge with uncommitted changes. ``noconflict`` will allow any
480 update which would not trigger a merge with uncommitted changes, if any
488 update which would not trigger a merge with uncommitted changes, if any
481 are present.
489 are present.
482 (default: ``linear``)
490 (default: ``linear``)
483
491
484 ``update.requiredest``
492 ``update.requiredest``
485 Require that the user pass a destination when running :hg:`update`.
493 Require that the user pass a destination when running :hg:`update`.
486 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
494 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
487 will be disallowed.
495 will be disallowed.
488 (default: False)
496 (default: False)
489
497
490 ``committemplate``
498 ``committemplate``
491 ------------------
499 ------------------
492
500
493 ``changeset``
501 ``changeset``
494 String: configuration in this section is used as the template to
502 String: configuration in this section is used as the template to
495 customize the text shown in the editor when committing.
503 customize the text shown in the editor when committing.
496
504
497 In addition to pre-defined template keywords, commit log specific one
505 In addition to pre-defined template keywords, commit log specific one
498 below can be used for customization:
506 below can be used for customization:
499
507
500 ``extramsg``
508 ``extramsg``
501 String: Extra message (typically 'Leave message empty to abort
509 String: Extra message (typically 'Leave message empty to abort
502 commit.'). This may be changed by some commands or extensions.
510 commit.'). This may be changed by some commands or extensions.
503
511
504 For example, the template configuration below shows as same text as
512 For example, the template configuration below shows as same text as
505 one shown by default::
513 one shown by default::
506
514
507 [committemplate]
515 [committemplate]
508 changeset = {desc}\n\n
516 changeset = {desc}\n\n
509 HG: Enter commit message. Lines beginning with 'HG:' are removed.
517 HG: Enter commit message. Lines beginning with 'HG:' are removed.
510 HG: {extramsg}
518 HG: {extramsg}
511 HG: --
519 HG: --
512 HG: user: {author}\n{ifeq(p2rev, "-1", "",
520 HG: user: {author}\n{ifeq(p2rev, "-1", "",
513 "HG: branch merge\n")
521 "HG: branch merge\n")
514 }HG: branch '{branch}'\n{if(activebookmark,
522 }HG: branch '{branch}'\n{if(activebookmark,
515 "HG: bookmark '{activebookmark}'\n") }{subrepos %
523 "HG: bookmark '{activebookmark}'\n") }{subrepos %
516 "HG: subrepo {subrepo}\n" }{file_adds %
524 "HG: subrepo {subrepo}\n" }{file_adds %
517 "HG: added {file}\n" }{file_mods %
525 "HG: added {file}\n" }{file_mods %
518 "HG: changed {file}\n" }{file_dels %
526 "HG: changed {file}\n" }{file_dels %
519 "HG: removed {file}\n" }{if(files, "",
527 "HG: removed {file}\n" }{if(files, "",
520 "HG: no files changed\n")}
528 "HG: no files changed\n")}
521
529
522 ``diff()``
530 ``diff()``
523 String: show the diff (see :hg:`help templates` for detail)
531 String: show the diff (see :hg:`help templates` for detail)
524
532
525 Sometimes it is helpful to show the diff of the changeset in the editor without
533 Sometimes it is helpful to show the diff of the changeset in the editor without
526 having to prefix 'HG: ' to each line so that highlighting works correctly. For
534 having to prefix 'HG: ' to each line so that highlighting works correctly. For
527 this, Mercurial provides a special string which will ignore everything below
535 this, Mercurial provides a special string which will ignore everything below
528 it::
536 it::
529
537
530 HG: ------------------------ >8 ------------------------
538 HG: ------------------------ >8 ------------------------
531
539
532 For example, the template configuration below will show the diff below the
540 For example, the template configuration below will show the diff below the
533 extra message::
541 extra message::
534
542
535 [committemplate]
543 [committemplate]
536 changeset = {desc}\n\n
544 changeset = {desc}\n\n
537 HG: Enter commit message. Lines beginning with 'HG:' are removed.
545 HG: Enter commit message. Lines beginning with 'HG:' are removed.
538 HG: {extramsg}
546 HG: {extramsg}
539 HG: ------------------------ >8 ------------------------
547 HG: ------------------------ >8 ------------------------
540 HG: Do not touch the line above.
548 HG: Do not touch the line above.
541 HG: Everything below will be removed.
549 HG: Everything below will be removed.
542 {diff()}
550 {diff()}
543
551
544 .. note::
552 .. note::
545
553
546 For some problematic encodings (see :hg:`help win32mbcs` for
554 For some problematic encodings (see :hg:`help win32mbcs` for
547 detail), this customization should be configured carefully, to
555 detail), this customization should be configured carefully, to
548 avoid showing broken characters.
556 avoid showing broken characters.
549
557
550 For example, if a multibyte character ending with backslash (0x5c) is
558 For example, if a multibyte character ending with backslash (0x5c) is
551 followed by the ASCII character 'n' in the customized template,
559 followed by the ASCII character 'n' in the customized template,
552 the sequence of backslash and 'n' is treated as line-feed unexpectedly
560 the sequence of backslash and 'n' is treated as line-feed unexpectedly
553 (and the multibyte character is broken, too).
561 (and the multibyte character is broken, too).
554
562
555 Customized template is used for commands below (``--edit`` may be
563 Customized template is used for commands below (``--edit`` may be
556 required):
564 required):
557
565
558 - :hg:`backout`
566 - :hg:`backout`
559 - :hg:`commit`
567 - :hg:`commit`
560 - :hg:`fetch` (for merge commit only)
568 - :hg:`fetch` (for merge commit only)
561 - :hg:`graft`
569 - :hg:`graft`
562 - :hg:`histedit`
570 - :hg:`histedit`
563 - :hg:`import`
571 - :hg:`import`
564 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
572 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
565 - :hg:`rebase`
573 - :hg:`rebase`
566 - :hg:`shelve`
574 - :hg:`shelve`
567 - :hg:`sign`
575 - :hg:`sign`
568 - :hg:`tag`
576 - :hg:`tag`
569 - :hg:`transplant`
577 - :hg:`transplant`
570
578
571 Configuring items below instead of ``changeset`` allows showing
579 Configuring items below instead of ``changeset`` allows showing
572 customized message only for specific actions, or showing different
580 customized message only for specific actions, or showing different
573 messages for each action.
581 messages for each action.
574
582
575 - ``changeset.backout`` for :hg:`backout`
583 - ``changeset.backout`` for :hg:`backout`
576 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
584 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
577 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
585 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
578 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
586 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
579 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
587 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
580 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
588 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
581 - ``changeset.gpg.sign`` for :hg:`sign`
589 - ``changeset.gpg.sign`` for :hg:`sign`
582 - ``changeset.graft`` for :hg:`graft`
590 - ``changeset.graft`` for :hg:`graft`
583 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
591 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
584 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
592 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
585 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
593 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
586 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
594 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
587 - ``changeset.import.bypass`` for :hg:`import --bypass`
595 - ``changeset.import.bypass`` for :hg:`import --bypass`
588 - ``changeset.import.normal.merge`` for :hg:`import` on merges
596 - ``changeset.import.normal.merge`` for :hg:`import` on merges
589 - ``changeset.import.normal.normal`` for :hg:`import` on other
597 - ``changeset.import.normal.normal`` for :hg:`import` on other
590 - ``changeset.mq.qnew`` for :hg:`qnew`
598 - ``changeset.mq.qnew`` for :hg:`qnew`
591 - ``changeset.mq.qfold`` for :hg:`qfold`
599 - ``changeset.mq.qfold`` for :hg:`qfold`
592 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
600 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
593 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
601 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
594 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
602 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
595 - ``changeset.rebase.normal`` for :hg:`rebase` on other
603 - ``changeset.rebase.normal`` for :hg:`rebase` on other
596 - ``changeset.shelve.shelve`` for :hg:`shelve`
604 - ``changeset.shelve.shelve`` for :hg:`shelve`
597 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
605 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
598 - ``changeset.tag.remove`` for :hg:`tag --remove`
606 - ``changeset.tag.remove`` for :hg:`tag --remove`
599 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
607 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
600 - ``changeset.transplant.normal`` for :hg:`transplant` on other
608 - ``changeset.transplant.normal`` for :hg:`transplant` on other
601
609
602 These dot-separated lists of names are treated as hierarchical ones.
610 These dot-separated lists of names are treated as hierarchical ones.
603 For example, ``changeset.tag.remove`` customizes the commit message
611 For example, ``changeset.tag.remove`` customizes the commit message
604 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
612 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
605 commit message for :hg:`tag` regardless of ``--remove`` option.
613 commit message for :hg:`tag` regardless of ``--remove`` option.
606
614
607 When the external editor is invoked for a commit, the corresponding
615 When the external editor is invoked for a commit, the corresponding
608 dot-separated list of names without the ``changeset.`` prefix
616 dot-separated list of names without the ``changeset.`` prefix
609 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
617 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
610 variable.
618 variable.
611
619
612 In this section, items other than ``changeset`` can be referred from
620 In this section, items other than ``changeset`` can be referred from
613 others. For example, the configuration to list committed files up
621 others. For example, the configuration to list committed files up
614 below can be referred as ``{listupfiles}``::
622 below can be referred as ``{listupfiles}``::
615
623
616 [committemplate]
624 [committemplate]
617 listupfiles = {file_adds %
625 listupfiles = {file_adds %
618 "HG: added {file}\n" }{file_mods %
626 "HG: added {file}\n" }{file_mods %
619 "HG: changed {file}\n" }{file_dels %
627 "HG: changed {file}\n" }{file_dels %
620 "HG: removed {file}\n" }{if(files, "",
628 "HG: removed {file}\n" }{if(files, "",
621 "HG: no files changed\n")}
629 "HG: no files changed\n")}
622
630
623 ``decode/encode``
631 ``decode/encode``
624 -----------------
632 -----------------
625
633
626 Filters for transforming files on checkout/checkin. This would
634 Filters for transforming files on checkout/checkin. This would
627 typically be used for newline processing or other
635 typically be used for newline processing or other
628 localization/canonicalization of files.
636 localization/canonicalization of files.
629
637
630 Filters consist of a filter pattern followed by a filter command.
638 Filters consist of a filter pattern followed by a filter command.
631 Filter patterns are globs by default, rooted at the repository root.
639 Filter patterns are globs by default, rooted at the repository root.
632 For example, to match any file ending in ``.txt`` in the root
640 For example, to match any file ending in ``.txt`` in the root
633 directory only, use the pattern ``*.txt``. To match any file ending
641 directory only, use the pattern ``*.txt``. To match any file ending
634 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
642 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
635 For each file only the first matching filter applies.
643 For each file only the first matching filter applies.
636
644
637 The filter command can start with a specifier, either ``pipe:`` or
645 The filter command can start with a specifier, either ``pipe:`` or
638 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
646 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
639
647
640 A ``pipe:`` command must accept data on stdin and return the transformed
648 A ``pipe:`` command must accept data on stdin and return the transformed
641 data on stdout.
649 data on stdout.
642
650
643 Pipe example::
651 Pipe example::
644
652
645 [encode]
653 [encode]
646 # uncompress gzip files on checkin to improve delta compression
654 # uncompress gzip files on checkin to improve delta compression
647 # note: not necessarily a good idea, just an example
655 # note: not necessarily a good idea, just an example
648 *.gz = pipe: gunzip
656 *.gz = pipe: gunzip
649
657
650 [decode]
658 [decode]
651 # recompress gzip files when writing them to the working dir (we
659 # recompress gzip files when writing them to the working dir (we
652 # can safely omit "pipe:", because it's the default)
660 # can safely omit "pipe:", because it's the default)
653 *.gz = gzip
661 *.gz = gzip
654
662
655 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
663 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
656 with the name of a temporary file that contains the data to be
664 with the name of a temporary file that contains the data to be
657 filtered by the command. The string ``OUTFILE`` is replaced with the name
665 filtered by the command. The string ``OUTFILE`` is replaced with the name
658 of an empty temporary file, where the filtered data must be written by
666 of an empty temporary file, where the filtered data must be written by
659 the command.
667 the command.
660
668
661 .. container:: windows
669 .. container:: windows
662
670
663 .. note::
671 .. note::
664
672
665 The tempfile mechanism is recommended for Windows systems,
673 The tempfile mechanism is recommended for Windows systems,
666 where the standard shell I/O redirection operators often have
674 where the standard shell I/O redirection operators often have
667 strange effects and may corrupt the contents of your files.
675 strange effects and may corrupt the contents of your files.
668
676
669 This filter mechanism is used internally by the ``eol`` extension to
677 This filter mechanism is used internally by the ``eol`` extension to
670 translate line ending characters between Windows (CRLF) and Unix (LF)
678 translate line ending characters between Windows (CRLF) and Unix (LF)
671 format. We suggest you use the ``eol`` extension for convenience.
679 format. We suggest you use the ``eol`` extension for convenience.
672
680
673
681
674 ``defaults``
682 ``defaults``
675 ------------
683 ------------
676
684
677 (defaults are deprecated. Don't use them. Use aliases instead.)
685 (defaults are deprecated. Don't use them. Use aliases instead.)
678
686
679 Use the ``[defaults]`` section to define command defaults, i.e. the
687 Use the ``[defaults]`` section to define command defaults, i.e. the
680 default options/arguments to pass to the specified commands.
688 default options/arguments to pass to the specified commands.
681
689
682 The following example makes :hg:`log` run in verbose mode, and
690 The following example makes :hg:`log` run in verbose mode, and
683 :hg:`status` show only the modified files, by default::
691 :hg:`status` show only the modified files, by default::
684
692
685 [defaults]
693 [defaults]
686 log = -v
694 log = -v
687 status = -m
695 status = -m
688
696
689 The actual commands, instead of their aliases, must be used when
697 The actual commands, instead of their aliases, must be used when
690 defining command defaults. The command defaults will also be applied
698 defining command defaults. The command defaults will also be applied
691 to the aliases of the commands defined.
699 to the aliases of the commands defined.
692
700
693
701
694 ``diff``
702 ``diff``
695 --------
703 --------
696
704
697 Settings used when displaying diffs. Everything except for ``unified``
705 Settings used when displaying diffs. Everything except for ``unified``
698 is a Boolean and defaults to False. See :hg:`help config.annotate`
706 is a Boolean and defaults to False. See :hg:`help config.annotate`
699 for related options for the annotate command.
707 for related options for the annotate command.
700
708
701 ``git``
709 ``git``
702 Use git extended diff format.
710 Use git extended diff format.
703
711
704 ``nobinary``
712 ``nobinary``
705 Omit git binary patches.
713 Omit git binary patches.
706
714
707 ``nodates``
715 ``nodates``
708 Don't include dates in diff headers.
716 Don't include dates in diff headers.
709
717
710 ``noprefix``
718 ``noprefix``
711 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
719 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
712
720
713 ``showfunc``
721 ``showfunc``
714 Show which function each change is in.
722 Show which function each change is in.
715
723
716 ``ignorews``
724 ``ignorews``
717 Ignore white space when comparing lines.
725 Ignore white space when comparing lines.
718
726
719 ``ignorewsamount``
727 ``ignorewsamount``
720 Ignore changes in the amount of white space.
728 Ignore changes in the amount of white space.
721
729
722 ``ignoreblanklines``
730 ``ignoreblanklines``
723 Ignore changes whose lines are all blank.
731 Ignore changes whose lines are all blank.
724
732
725 ``unified``
733 ``unified``
726 Number of lines of context to show.
734 Number of lines of context to show.
727
735
728 ``word-diff``
736 ``word-diff``
729 Highlight changed words.
737 Highlight changed words.
730
738
731 ``email``
739 ``email``
732 ---------
740 ---------
733
741
734 Settings for extensions that send email messages.
742 Settings for extensions that send email messages.
735
743
736 ``from``
744 ``from``
737 Optional. Email address to use in "From" header and SMTP envelope
745 Optional. Email address to use in "From" header and SMTP envelope
738 of outgoing messages.
746 of outgoing messages.
739
747
740 ``to``
748 ``to``
741 Optional. Comma-separated list of recipients' email addresses.
749 Optional. Comma-separated list of recipients' email addresses.
742
750
743 ``cc``
751 ``cc``
744 Optional. Comma-separated list of carbon copy recipients'
752 Optional. Comma-separated list of carbon copy recipients'
745 email addresses.
753 email addresses.
746
754
747 ``bcc``
755 ``bcc``
748 Optional. Comma-separated list of blind carbon copy recipients'
756 Optional. Comma-separated list of blind carbon copy recipients'
749 email addresses.
757 email addresses.
750
758
751 ``method``
759 ``method``
752 Optional. Method to use to send email messages. If value is ``smtp``
760 Optional. Method to use to send email messages. If value is ``smtp``
753 (default), use SMTP (see the ``[smtp]`` section for configuration).
761 (default), use SMTP (see the ``[smtp]`` section for configuration).
754 Otherwise, use as name of program to run that acts like sendmail
762 Otherwise, use as name of program to run that acts like sendmail
755 (takes ``-f`` option for sender, list of recipients on command line,
763 (takes ``-f`` option for sender, list of recipients on command line,
756 message on stdin). Normally, setting this to ``sendmail`` or
764 message on stdin). Normally, setting this to ``sendmail`` or
757 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
765 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
758
766
759 ``charsets``
767 ``charsets``
760 Optional. Comma-separated list of character sets considered
768 Optional. Comma-separated list of character sets considered
761 convenient for recipients. Addresses, headers, and parts not
769 convenient for recipients. Addresses, headers, and parts not
762 containing patches of outgoing messages will be encoded in the
770 containing patches of outgoing messages will be encoded in the
763 first character set to which conversion from local encoding
771 first character set to which conversion from local encoding
764 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
772 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
765 conversion fails, the text in question is sent as is.
773 conversion fails, the text in question is sent as is.
766 (default: '')
774 (default: '')
767
775
768 Order of outgoing email character sets:
776 Order of outgoing email character sets:
769
777
770 1. ``us-ascii``: always first, regardless of settings
778 1. ``us-ascii``: always first, regardless of settings
771 2. ``email.charsets``: in order given by user
779 2. ``email.charsets``: in order given by user
772 3. ``ui.fallbackencoding``: if not in email.charsets
780 3. ``ui.fallbackencoding``: if not in email.charsets
773 4. ``$HGENCODING``: if not in email.charsets
781 4. ``$HGENCODING``: if not in email.charsets
774 5. ``utf-8``: always last, regardless of settings
782 5. ``utf-8``: always last, regardless of settings
775
783
776 Email example::
784 Email example::
777
785
778 [email]
786 [email]
779 from = Joseph User <joe.user@example.com>
787 from = Joseph User <joe.user@example.com>
780 method = /usr/sbin/sendmail
788 method = /usr/sbin/sendmail
781 # charsets for western Europeans
789 # charsets for western Europeans
782 # us-ascii, utf-8 omitted, as they are tried first and last
790 # us-ascii, utf-8 omitted, as they are tried first and last
783 charsets = iso-8859-1, iso-8859-15, windows-1252
791 charsets = iso-8859-1, iso-8859-15, windows-1252
784
792
785
793
786 ``extensions``
794 ``extensions``
787 --------------
795 --------------
788
796
789 Mercurial has an extension mechanism for adding new features. To
797 Mercurial has an extension mechanism for adding new features. To
790 enable an extension, create an entry for it in this section.
798 enable an extension, create an entry for it in this section.
791
799
792 If you know that the extension is already in Python's search path,
800 If you know that the extension is already in Python's search path,
793 you can give the name of the module, followed by ``=``, with nothing
801 you can give the name of the module, followed by ``=``, with nothing
794 after the ``=``.
802 after the ``=``.
795
803
796 Otherwise, give a name that you choose, followed by ``=``, followed by
804 Otherwise, give a name that you choose, followed by ``=``, followed by
797 the path to the ``.py`` file (including the file name extension) that
805 the path to the ``.py`` file (including the file name extension) that
798 defines the extension.
806 defines the extension.
799
807
800 To explicitly disable an extension that is enabled in an hgrc of
808 To explicitly disable an extension that is enabled in an hgrc of
801 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
809 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
802 or ``foo = !`` when path is not supplied.
810 or ``foo = !`` when path is not supplied.
803
811
804 Example for ``~/.hgrc``::
812 Example for ``~/.hgrc``::
805
813
806 [extensions]
814 [extensions]
807 # (the churn extension will get loaded from Mercurial's path)
815 # (the churn extension will get loaded from Mercurial's path)
808 churn =
816 churn =
809 # (this extension will get loaded from the file specified)
817 # (this extension will get loaded from the file specified)
810 myfeature = ~/.hgext/myfeature.py
818 myfeature = ~/.hgext/myfeature.py
811
819
812
820
813 ``format``
821 ``format``
814 ----------
822 ----------
815
823
816 Configuration that controls the repository format. Newer format options are more
824 Configuration that controls the repository format. Newer format options are more
817 powerful but incompatible with some older versions of Mercurial. Format options
825 powerful but incompatible with some older versions of Mercurial. Format options
818 are considered at repository initialization only. You need to make a new clone
826 are considered at repository initialization only. You need to make a new clone
819 for config change to be taken into account.
827 for config change to be taken into account.
820
828
821 For more details about repository format and version compatibility, see
829 For more details about repository format and version compatibility, see
822 https://www.mercurial-scm.org/wiki/MissingRequirement
830 https://www.mercurial-scm.org/wiki/MissingRequirement
823
831
824 ``usegeneraldelta``
832 ``usegeneraldelta``
825 Enable or disable the "generaldelta" repository format which improves
833 Enable or disable the "generaldelta" repository format which improves
826 repository compression by allowing "revlog" to store delta against arbitrary
834 repository compression by allowing "revlog" to store delta against arbitrary
827 revision instead of the previous stored one. This provides significant
835 revision instead of the previous stored one. This provides significant
828 improvement for repositories with branches.
836 improvement for repositories with branches.
829
837
830 Repositories with this on-disk format require Mercurial version 1.9.
838 Repositories with this on-disk format require Mercurial version 1.9.
831
839
832 Enabled by default.
840 Enabled by default.
833
841
834 ``dotencode``
842 ``dotencode``
835 Enable or disable the "dotencode" repository format which enhances
843 Enable or disable the "dotencode" repository format which enhances
836 the "fncache" repository format (which has to be enabled to use
844 the "fncache" repository format (which has to be enabled to use
837 dotencode) to avoid issues with filenames starting with ._ on
845 dotencode) to avoid issues with filenames starting with ._ on
838 Mac OS X and spaces on Windows.
846 Mac OS X and spaces on Windows.
839
847
840 Repositories with this on-disk format require Mercurial version 1.7.
848 Repositories with this on-disk format require Mercurial version 1.7.
841
849
842 Enabled by default.
850 Enabled by default.
843
851
844 ``usefncache``
852 ``usefncache``
845 Enable or disable the "fncache" repository format which enhances
853 Enable or disable the "fncache" repository format which enhances
846 the "store" repository format (which has to be enabled to use
854 the "store" repository format (which has to be enabled to use
847 fncache) to allow longer filenames and avoids using Windows
855 fncache) to allow longer filenames and avoids using Windows
848 reserved names, e.g. "nul".
856 reserved names, e.g. "nul".
849
857
850 Repositories with this on-disk format require Mercurial version 1.1.
858 Repositories with this on-disk format require Mercurial version 1.1.
851
859
852 Enabled by default.
860 Enabled by default.
853
861
854 ``usestore``
862 ``usestore``
855 Enable or disable the "store" repository format which improves
863 Enable or disable the "store" repository format which improves
856 compatibility with systems that fold case or otherwise mangle
864 compatibility with systems that fold case or otherwise mangle
857 filenames. Disabling this option will allow you to store longer filenames
865 filenames. Disabling this option will allow you to store longer filenames
858 in some situations at the expense of compatibility.
866 in some situations at the expense of compatibility.
859
867
860 Repositories with this on-disk format require Mercurial version 0.9.4.
868 Repositories with this on-disk format require Mercurial version 0.9.4.
861
869
862 Enabled by default.
870 Enabled by default.
863
871
864 ``sparse-revlog``
872 ``sparse-revlog``
865 Enable or disable the ``sparse-revlog`` delta strategy. This format improves
873 Enable or disable the ``sparse-revlog`` delta strategy. This format improves
866 delta re-use inside revlog. For very branchy repositories, it results in a
874 delta re-use inside revlog. For very branchy repositories, it results in a
867 smaller store. For repositories with many revisions, it also helps
875 smaller store. For repositories with many revisions, it also helps
868 performance (by using shortened delta chains.)
876 performance (by using shortened delta chains.)
869
877
870 Repositories with this on-disk format require Mercurial version 4.7
878 Repositories with this on-disk format require Mercurial version 4.7
871
879
872 Enabled by default.
880 Enabled by default.
873
881
874 ``revlog-compression``
882 ``revlog-compression``
875 Compression algorithm used by revlog. Supported value are `zlib` and `zstd`.
883 Compression algorithm used by revlog. Supported value are `zlib` and `zstd`.
876 The `zlib` engine is the historical default of Mercurial. `zstd` is a newer
884 The `zlib` engine is the historical default of Mercurial. `zstd` is a newer
877 format that is usually a net win over `zlib` operating faster at better
885 format that is usually a net win over `zlib` operating faster at better
878 compression rate. Use `zstd` to reduce CPU usage.
886 compression rate. Use `zstd` to reduce CPU usage.
879
887
880 On some system, Mercurial installation may lack `zstd` supports. Default is `zlib`.
888 On some system, Mercurial installation may lack `zstd` supports. Default is `zlib`.
881
889
882 ``bookmarks-in-store``
890 ``bookmarks-in-store``
883 Store bookmarks in .hg/store/. This means that bookmarks are shared when
891 Store bookmarks in .hg/store/. This means that bookmarks are shared when
884 using `hg share` regardless of the `-B` option.
892 using `hg share` regardless of the `-B` option.
885
893
886 Repositories with this on-disk format require Mercurial version 5.1.
894 Repositories with this on-disk format require Mercurial version 5.1.
887
895
888 Disabled by default.
896 Disabled by default.
889
897
890
898
891 ``graph``
899 ``graph``
892 ---------
900 ---------
893
901
894 Web graph view configuration. This section let you change graph
902 Web graph view configuration. This section let you change graph
895 elements display properties by branches, for instance to make the
903 elements display properties by branches, for instance to make the
896 ``default`` branch stand out.
904 ``default`` branch stand out.
897
905
898 Each line has the following format::
906 Each line has the following format::
899
907
900 <branch>.<argument> = <value>
908 <branch>.<argument> = <value>
901
909
902 where ``<branch>`` is the name of the branch being
910 where ``<branch>`` is the name of the branch being
903 customized. Example::
911 customized. Example::
904
912
905 [graph]
913 [graph]
906 # 2px width
914 # 2px width
907 default.width = 2
915 default.width = 2
908 # red color
916 # red color
909 default.color = FF0000
917 default.color = FF0000
910
918
911 Supported arguments:
919 Supported arguments:
912
920
913 ``width``
921 ``width``
914 Set branch edges width in pixels.
922 Set branch edges width in pixels.
915
923
916 ``color``
924 ``color``
917 Set branch edges color in hexadecimal RGB notation.
925 Set branch edges color in hexadecimal RGB notation.
918
926
919 ``hooks``
927 ``hooks``
920 ---------
928 ---------
921
929
922 Commands or Python functions that get automatically executed by
930 Commands or Python functions that get automatically executed by
923 various actions such as starting or finishing a commit. Multiple
931 various actions such as starting or finishing a commit. Multiple
924 hooks can be run for the same action by appending a suffix to the
932 hooks can be run for the same action by appending a suffix to the
925 action. Overriding a site-wide hook can be done by changing its
933 action. Overriding a site-wide hook can be done by changing its
926 value or setting it to an empty string. Hooks can be prioritized
934 value or setting it to an empty string. Hooks can be prioritized
927 by adding a prefix of ``priority.`` to the hook name on a new line
935 by adding a prefix of ``priority.`` to the hook name on a new line
928 and setting the priority. The default priority is 0.
936 and setting the priority. The default priority is 0.
929
937
930 Example ``.hg/hgrc``::
938 Example ``.hg/hgrc``::
931
939
932 [hooks]
940 [hooks]
933 # update working directory after adding changesets
941 # update working directory after adding changesets
934 changegroup.update = hg update
942 changegroup.update = hg update
935 # do not use the site-wide hook
943 # do not use the site-wide hook
936 incoming =
944 incoming =
937 incoming.email = /my/email/hook
945 incoming.email = /my/email/hook
938 incoming.autobuild = /my/build/hook
946 incoming.autobuild = /my/build/hook
939 # force autobuild hook to run before other incoming hooks
947 # force autobuild hook to run before other incoming hooks
940 priority.incoming.autobuild = 1
948 priority.incoming.autobuild = 1
941
949
942 Most hooks are run with environment variables set that give useful
950 Most hooks are run with environment variables set that give useful
943 additional information. For each hook below, the environment variables
951 additional information. For each hook below, the environment variables
944 it is passed are listed with names in the form ``$HG_foo``. The
952 it is passed are listed with names in the form ``$HG_foo``. The
945 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
953 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
946 They contain the type of hook which triggered the run and the full name
954 They contain the type of hook which triggered the run and the full name
947 of the hook in the config, respectively. In the example above, this will
955 of the hook in the config, respectively. In the example above, this will
948 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
956 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
949
957
950 .. container:: windows
958 .. container:: windows
951
959
952 Some basic Unix syntax can be enabled for portability, including ``$VAR``
960 Some basic Unix syntax can be enabled for portability, including ``$VAR``
953 and ``${VAR}`` style variables. A ``~`` followed by ``\`` or ``/`` will
961 and ``${VAR}`` style variables. A ``~`` followed by ``\`` or ``/`` will
954 be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion
962 be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion
955 on Unix. To use a literal ``$`` or ``~``, it must be escaped with a back
963 on Unix. To use a literal ``$`` or ``~``, it must be escaped with a back
956 slash or inside of a strong quote. Strong quotes will be replaced by
964 slash or inside of a strong quote. Strong quotes will be replaced by
957 double quotes after processing.
965 double quotes after processing.
958
966
959 This feature is enabled by adding a prefix of ``tonative.`` to the hook
967 This feature is enabled by adding a prefix of ``tonative.`` to the hook
960 name on a new line, and setting it to ``True``. For example::
968 name on a new line, and setting it to ``True``. For example::
961
969
962 [hooks]
970 [hooks]
963 incoming.autobuild = /my/build/hook
971 incoming.autobuild = /my/build/hook
964 # enable translation to cmd.exe syntax for autobuild hook
972 # enable translation to cmd.exe syntax for autobuild hook
965 tonative.incoming.autobuild = True
973 tonative.incoming.autobuild = True
966
974
967 ``changegroup``
975 ``changegroup``
968 Run after a changegroup has been added via push, pull or unbundle. The ID of
976 Run after a changegroup has been added via push, pull or unbundle. The ID of
969 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
977 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
970 The URL from which changes came is in ``$HG_URL``.
978 The URL from which changes came is in ``$HG_URL``.
971
979
972 ``commit``
980 ``commit``
973 Run after a changeset has been created in the local repository. The ID
981 Run after a changeset has been created in the local repository. The ID
974 of the newly created changeset is in ``$HG_NODE``. Parent changeset
982 of the newly created changeset is in ``$HG_NODE``. Parent changeset
975 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
983 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
976
984
977 ``incoming``
985 ``incoming``
978 Run after a changeset has been pulled, pushed, or unbundled into
986 Run after a changeset has been pulled, pushed, or unbundled into
979 the local repository. The ID of the newly arrived changeset is in
987 the local repository. The ID of the newly arrived changeset is in
980 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
988 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
981
989
982 ``outgoing``
990 ``outgoing``
983 Run after sending changes from the local repository to another. The ID of
991 Run after sending changes from the local repository to another. The ID of
984 first changeset sent is in ``$HG_NODE``. The source of operation is in
992 first changeset sent is in ``$HG_NODE``. The source of operation is in
985 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
993 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
986
994
987 ``post-<command>``
995 ``post-<command>``
988 Run after successful invocations of the associated command. The
996 Run after successful invocations of the associated command. The
989 contents of the command line are passed as ``$HG_ARGS`` and the result
997 contents of the command line are passed as ``$HG_ARGS`` and the result
990 code in ``$HG_RESULT``. Parsed command line arguments are passed as
998 code in ``$HG_RESULT``. Parsed command line arguments are passed as
991 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
999 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
992 the python data internally passed to <command>. ``$HG_OPTS`` is a
1000 the python data internally passed to <command>. ``$HG_OPTS`` is a
993 dictionary of options (with unspecified options set to their defaults).
1001 dictionary of options (with unspecified options set to their defaults).
994 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
1002 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
995
1003
996 ``fail-<command>``
1004 ``fail-<command>``
997 Run after a failed invocation of an associated command. The contents
1005 Run after a failed invocation of an associated command. The contents
998 of the command line are passed as ``$HG_ARGS``. Parsed command line
1006 of the command line are passed as ``$HG_ARGS``. Parsed command line
999 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
1007 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
1000 string representations of the python data internally passed to
1008 string representations of the python data internally passed to
1001 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
1009 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
1002 options set to their defaults). ``$HG_PATS`` is a list of arguments.
1010 options set to their defaults). ``$HG_PATS`` is a list of arguments.
1003 Hook failure is ignored.
1011 Hook failure is ignored.
1004
1012
1005 ``pre-<command>``
1013 ``pre-<command>``
1006 Run before executing the associated command. The contents of the
1014 Run before executing the associated command. The contents of the
1007 command line are passed as ``$HG_ARGS``. Parsed command line arguments
1015 command line are passed as ``$HG_ARGS``. Parsed command line arguments
1008 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
1016 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
1009 representations of the data internally passed to <command>. ``$HG_OPTS``
1017 representations of the data internally passed to <command>. ``$HG_OPTS``
1010 is a dictionary of options (with unspecified options set to their
1018 is a dictionary of options (with unspecified options set to their
1011 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
1019 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
1012 failure, the command doesn't execute and Mercurial returns the failure
1020 failure, the command doesn't execute and Mercurial returns the failure
1013 code.
1021 code.
1014
1022
1015 ``prechangegroup``
1023 ``prechangegroup``
1016 Run before a changegroup is added via push, pull or unbundle. Exit
1024 Run before a changegroup is added via push, pull or unbundle. Exit
1017 status 0 allows the changegroup to proceed. A non-zero status will
1025 status 0 allows the changegroup to proceed. A non-zero status will
1018 cause the push, pull or unbundle to fail. The URL from which changes
1026 cause the push, pull or unbundle to fail. The URL from which changes
1019 will come is in ``$HG_URL``.
1027 will come is in ``$HG_URL``.
1020
1028
1021 ``precommit``
1029 ``precommit``
1022 Run before starting a local commit. Exit status 0 allows the
1030 Run before starting a local commit. Exit status 0 allows the
1023 commit to proceed. A non-zero status will cause the commit to fail.
1031 commit to proceed. A non-zero status will cause the commit to fail.
1024 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1032 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1025
1033
1026 ``prelistkeys``
1034 ``prelistkeys``
1027 Run before listing pushkeys (like bookmarks) in the
1035 Run before listing pushkeys (like bookmarks) in the
1028 repository. A non-zero status will cause failure. The key namespace is
1036 repository. A non-zero status will cause failure. The key namespace is
1029 in ``$HG_NAMESPACE``.
1037 in ``$HG_NAMESPACE``.
1030
1038
1031 ``preoutgoing``
1039 ``preoutgoing``
1032 Run before collecting changes to send from the local repository to
1040 Run before collecting changes to send from the local repository to
1033 another. A non-zero status will cause failure. This lets you prevent
1041 another. A non-zero status will cause failure. This lets you prevent
1034 pull over HTTP or SSH. It can also prevent propagating commits (via
1042 pull over HTTP or SSH. It can also prevent propagating commits (via
1035 local pull, push (outbound) or bundle commands), but not completely,
1043 local pull, push (outbound) or bundle commands), but not completely,
1036 since you can just copy files instead. The source of operation is in
1044 since you can just copy files instead. The source of operation is in
1037 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
1045 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
1038 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
1046 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
1039 is happening on behalf of a repository on same system.
1047 is happening on behalf of a repository on same system.
1040
1048
1041 ``prepushkey``
1049 ``prepushkey``
1042 Run before a pushkey (like a bookmark) is added to the
1050 Run before a pushkey (like a bookmark) is added to the
1043 repository. A non-zero status will cause the key to be rejected. The
1051 repository. A non-zero status will cause the key to be rejected. The
1044 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
1052 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
1045 the old value (if any) is in ``$HG_OLD``, and the new value is in
1053 the old value (if any) is in ``$HG_OLD``, and the new value is in
1046 ``$HG_NEW``.
1054 ``$HG_NEW``.
1047
1055
1048 ``pretag``
1056 ``pretag``
1049 Run before creating a tag. Exit status 0 allows the tag to be
1057 Run before creating a tag. Exit status 0 allows the tag to be
1050 created. A non-zero status will cause the tag to fail. The ID of the
1058 created. A non-zero status will cause the tag to fail. The ID of the
1051 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
1059 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
1052 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
1060 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
1053
1061
1054 ``pretxnopen``
1062 ``pretxnopen``
1055 Run before any new repository transaction is open. The reason for the
1063 Run before any new repository transaction is open. The reason for the
1056 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
1064 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
1057 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
1065 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
1058 transaction from being opened.
1066 transaction from being opened.
1059
1067
1060 ``pretxnclose``
1068 ``pretxnclose``
1061 Run right before the transaction is actually finalized. Any repository change
1069 Run right before the transaction is actually finalized. Any repository change
1062 will be visible to the hook program. This lets you validate the transaction
1070 will be visible to the hook program. This lets you validate the transaction
1063 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1071 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1064 status will cause the transaction to be rolled back. The reason for the
1072 status will cause the transaction to be rolled back. The reason for the
1065 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
1073 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
1066 the transaction will be in ``HG_TXNID``. The rest of the available data will
1074 the transaction will be in ``HG_TXNID``. The rest of the available data will
1067 vary according the transaction type. New changesets will add ``$HG_NODE``
1075 vary according the transaction type. New changesets will add ``$HG_NODE``
1068 (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
1076 (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
1069 added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables. Bookmark and
1077 added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables. Bookmark and
1070 phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
1078 phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
1071 respectively, etc.
1079 respectively, etc.
1072
1080
1073 ``pretxnclose-bookmark``
1081 ``pretxnclose-bookmark``
1074 Run right before a bookmark change is actually finalized. Any repository
1082 Run right before a bookmark change is actually finalized. Any repository
1075 change will be visible to the hook program. This lets you validate the
1083 change will be visible to the hook program. This lets you validate the
1076 transaction content or change it. Exit status 0 allows the commit to
1084 transaction content or change it. Exit status 0 allows the commit to
1077 proceed. A non-zero status will cause the transaction to be rolled back.
1085 proceed. A non-zero status will cause the transaction to be rolled back.
1078 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
1086 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
1079 bookmark location will be available in ``$HG_NODE`` while the previous
1087 bookmark location will be available in ``$HG_NODE`` while the previous
1080 location will be available in ``$HG_OLDNODE``. In case of a bookmark
1088 location will be available in ``$HG_OLDNODE``. In case of a bookmark
1081 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1089 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1082 will be empty.
1090 will be empty.
1083 In addition, the reason for the transaction opening will be in
1091 In addition, the reason for the transaction opening will be in
1084 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1092 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1085 ``HG_TXNID``.
1093 ``HG_TXNID``.
1086
1094
1087 ``pretxnclose-phase``
1095 ``pretxnclose-phase``
1088 Run right before a phase change is actually finalized. Any repository change
1096 Run right before a phase change is actually finalized. Any repository change
1089 will be visible to the hook program. This lets you validate the transaction
1097 will be visible to the hook program. This lets you validate the transaction
1090 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1098 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1091 status will cause the transaction to be rolled back. The hook is called
1099 status will cause the transaction to be rolled back. The hook is called
1092 multiple times, once for each revision affected by a phase change.
1100 multiple times, once for each revision affected by a phase change.
1093 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1101 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1094 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1102 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1095 will be empty. In addition, the reason for the transaction opening will be in
1103 will be empty. In addition, the reason for the transaction opening will be in
1096 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1104 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1097 ``HG_TXNID``. The hook is also run for newly added revisions. In this case
1105 ``HG_TXNID``. The hook is also run for newly added revisions. In this case
1098 the ``$HG_OLDPHASE`` entry will be empty.
1106 the ``$HG_OLDPHASE`` entry will be empty.
1099
1107
1100 ``txnclose``
1108 ``txnclose``
1101 Run after any repository transaction has been committed. At this
1109 Run after any repository transaction has been committed. At this
1102 point, the transaction can no longer be rolled back. The hook will run
1110 point, the transaction can no longer be rolled back. The hook will run
1103 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1111 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1104 details about available variables.
1112 details about available variables.
1105
1113
1106 ``txnclose-bookmark``
1114 ``txnclose-bookmark``
1107 Run after any bookmark change has been committed. At this point, the
1115 Run after any bookmark change has been committed. At this point, the
1108 transaction can no longer be rolled back. The hook will run after the lock
1116 transaction can no longer be rolled back. The hook will run after the lock
1109 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1117 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1110 about available variables.
1118 about available variables.
1111
1119
1112 ``txnclose-phase``
1120 ``txnclose-phase``
1113 Run after any phase change has been committed. At this point, the
1121 Run after any phase change has been committed. At this point, the
1114 transaction can no longer be rolled back. The hook will run after the lock
1122 transaction can no longer be rolled back. The hook will run after the lock
1115 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1123 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1116 available variables.
1124 available variables.
1117
1125
1118 ``txnabort``
1126 ``txnabort``
1119 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1127 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1120 for details about available variables.
1128 for details about available variables.
1121
1129
1122 ``pretxnchangegroup``
1130 ``pretxnchangegroup``
1123 Run after a changegroup has been added via push, pull or unbundle, but before
1131 Run after a changegroup has been added via push, pull or unbundle, but before
1124 the transaction has been committed. The changegroup is visible to the hook
1132 the transaction has been committed. The changegroup is visible to the hook
1125 program. This allows validation of incoming changes before accepting them.
1133 program. This allows validation of incoming changes before accepting them.
1126 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1134 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1127 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1135 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1128 status will cause the transaction to be rolled back, and the push, pull or
1136 status will cause the transaction to be rolled back, and the push, pull or
1129 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1137 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1130
1138
1131 ``pretxncommit``
1139 ``pretxncommit``
1132 Run after a changeset has been created, but before the transaction is
1140 Run after a changeset has been created, but before the transaction is
1133 committed. The changeset is visible to the hook program. This allows
1141 committed. The changeset is visible to the hook program. This allows
1134 validation of the commit message and changes. Exit status 0 allows the
1142 validation of the commit message and changes. Exit status 0 allows the
1135 commit to proceed. A non-zero status will cause the transaction to
1143 commit to proceed. A non-zero status will cause the transaction to
1136 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1144 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1137 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1145 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1138
1146
1139 ``preupdate``
1147 ``preupdate``
1140 Run before updating the working directory. Exit status 0 allows
1148 Run before updating the working directory. Exit status 0 allows
1141 the update to proceed. A non-zero status will prevent the update.
1149 the update to proceed. A non-zero status will prevent the update.
1142 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1150 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1143 merge, the ID of second new parent is in ``$HG_PARENT2``.
1151 merge, the ID of second new parent is in ``$HG_PARENT2``.
1144
1152
1145 ``listkeys``
1153 ``listkeys``
1146 Run after listing pushkeys (like bookmarks) in the repository. The
1154 Run after listing pushkeys (like bookmarks) in the repository. The
1147 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1155 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1148 dictionary containing the keys and values.
1156 dictionary containing the keys and values.
1149
1157
1150 ``pushkey``
1158 ``pushkey``
1151 Run after a pushkey (like a bookmark) is added to the
1159 Run after a pushkey (like a bookmark) is added to the
1152 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1160 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1153 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1161 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1154 value is in ``$HG_NEW``.
1162 value is in ``$HG_NEW``.
1155
1163
1156 ``tag``
1164 ``tag``
1157 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1165 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1158 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1166 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1159 the repository if ``$HG_LOCAL=0``.
1167 the repository if ``$HG_LOCAL=0``.
1160
1168
1161 ``update``
1169 ``update``
1162 Run after updating the working directory. The changeset ID of first
1170 Run after updating the working directory. The changeset ID of first
1163 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1171 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1164 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1172 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1165 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1173 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1166
1174
1167 .. note::
1175 .. note::
1168
1176
1169 It is generally better to use standard hooks rather than the
1177 It is generally better to use standard hooks rather than the
1170 generic pre- and post- command hooks, as they are guaranteed to be
1178 generic pre- and post- command hooks, as they are guaranteed to be
1171 called in the appropriate contexts for influencing transactions.
1179 called in the appropriate contexts for influencing transactions.
1172 Also, hooks like "commit" will be called in all contexts that
1180 Also, hooks like "commit" will be called in all contexts that
1173 generate a commit (e.g. tag) and not just the commit command.
1181 generate a commit (e.g. tag) and not just the commit command.
1174
1182
1175 .. note::
1183 .. note::
1176
1184
1177 Environment variables with empty values may not be passed to
1185 Environment variables with empty values may not be passed to
1178 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1186 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1179 will have an empty value under Unix-like platforms for non-merge
1187 will have an empty value under Unix-like platforms for non-merge
1180 changesets, while it will not be available at all under Windows.
1188 changesets, while it will not be available at all under Windows.
1181
1189
1182 The syntax for Python hooks is as follows::
1190 The syntax for Python hooks is as follows::
1183
1191
1184 hookname = python:modulename.submodule.callable
1192 hookname = python:modulename.submodule.callable
1185 hookname = python:/path/to/python/module.py:callable
1193 hookname = python:/path/to/python/module.py:callable
1186
1194
1187 Python hooks are run within the Mercurial process. Each hook is
1195 Python hooks are run within the Mercurial process. Each hook is
1188 called with at least three keyword arguments: a ui object (keyword
1196 called with at least three keyword arguments: a ui object (keyword
1189 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1197 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1190 keyword that tells what kind of hook is used. Arguments listed as
1198 keyword that tells what kind of hook is used. Arguments listed as
1191 environment variables above are passed as keyword arguments, with no
1199 environment variables above are passed as keyword arguments, with no
1192 ``HG_`` prefix, and names in lower case.
1200 ``HG_`` prefix, and names in lower case.
1193
1201
1194 If a Python hook returns a "true" value or raises an exception, this
1202 If a Python hook returns a "true" value or raises an exception, this
1195 is treated as a failure.
1203 is treated as a failure.
1196
1204
1197
1205
1198 ``hostfingerprints``
1206 ``hostfingerprints``
1199 --------------------
1207 --------------------
1200
1208
1201 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1209 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1202
1210
1203 Fingerprints of the certificates of known HTTPS servers.
1211 Fingerprints of the certificates of known HTTPS servers.
1204
1212
1205 A HTTPS connection to a server with a fingerprint configured here will
1213 A HTTPS connection to a server with a fingerprint configured here will
1206 only succeed if the servers certificate matches the fingerprint.
1214 only succeed if the servers certificate matches the fingerprint.
1207 This is very similar to how ssh known hosts works.
1215 This is very similar to how ssh known hosts works.
1208
1216
1209 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1217 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1210 Multiple values can be specified (separated by spaces or commas). This can
1218 Multiple values can be specified (separated by spaces or commas). This can
1211 be used to define both old and new fingerprints while a host transitions
1219 be used to define both old and new fingerprints while a host transitions
1212 to a new certificate.
1220 to a new certificate.
1213
1221
1214 The CA chain and web.cacerts is not used for servers with a fingerprint.
1222 The CA chain and web.cacerts is not used for servers with a fingerprint.
1215
1223
1216 For example::
1224 For example::
1217
1225
1218 [hostfingerprints]
1226 [hostfingerprints]
1219 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1227 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1220 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1228 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1221
1229
1222 ``hostsecurity``
1230 ``hostsecurity``
1223 ----------------
1231 ----------------
1224
1232
1225 Used to specify global and per-host security settings for connecting to
1233 Used to specify global and per-host security settings for connecting to
1226 other machines.
1234 other machines.
1227
1235
1228 The following options control default behavior for all hosts.
1236 The following options control default behavior for all hosts.
1229
1237
1230 ``ciphers``
1238 ``ciphers``
1231 Defines the cryptographic ciphers to use for connections.
1239 Defines the cryptographic ciphers to use for connections.
1232
1240
1233 Value must be a valid OpenSSL Cipher List Format as documented at
1241 Value must be a valid OpenSSL Cipher List Format as documented at
1234 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1242 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1235
1243
1236 This setting is for advanced users only. Setting to incorrect values
1244 This setting is for advanced users only. Setting to incorrect values
1237 can significantly lower connection security or decrease performance.
1245 can significantly lower connection security or decrease performance.
1238 You have been warned.
1246 You have been warned.
1239
1247
1240 This option requires Python 2.7.
1248 This option requires Python 2.7.
1241
1249
1242 ``minimumprotocol``
1250 ``minimumprotocol``
1243 Defines the minimum channel encryption protocol to use.
1251 Defines the minimum channel encryption protocol to use.
1244
1252
1245 By default, the highest version of TLS supported by both client and server
1253 By default, the highest version of TLS supported by both client and server
1246 is used.
1254 is used.
1247
1255
1248 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1256 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1249
1257
1250 When running on an old Python version, only ``tls1.0`` is allowed since
1258 When running on an old Python version, only ``tls1.0`` is allowed since
1251 old versions of Python only support up to TLS 1.0.
1259 old versions of Python only support up to TLS 1.0.
1252
1260
1253 When running a Python that supports modern TLS versions, the default is
1261 When running a Python that supports modern TLS versions, the default is
1254 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1262 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1255 weakens security and should only be used as a feature of last resort if
1263 weakens security and should only be used as a feature of last resort if
1256 a server does not support TLS 1.1+.
1264 a server does not support TLS 1.1+.
1257
1265
1258 Options in the ``[hostsecurity]`` section can have the form
1266 Options in the ``[hostsecurity]`` section can have the form
1259 ``hostname``:``setting``. This allows multiple settings to be defined on a
1267 ``hostname``:``setting``. This allows multiple settings to be defined on a
1260 per-host basis.
1268 per-host basis.
1261
1269
1262 The following per-host settings can be defined.
1270 The following per-host settings can be defined.
1263
1271
1264 ``ciphers``
1272 ``ciphers``
1265 This behaves like ``ciphers`` as described above except it only applies
1273 This behaves like ``ciphers`` as described above except it only applies
1266 to the host on which it is defined.
1274 to the host on which it is defined.
1267
1275
1268 ``fingerprints``
1276 ``fingerprints``
1269 A list of hashes of the DER encoded peer/remote certificate. Values have
1277 A list of hashes of the DER encoded peer/remote certificate. Values have
1270 the form ``algorithm``:``fingerprint``. e.g.
1278 the form ``algorithm``:``fingerprint``. e.g.
1271 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1279 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1272 In addition, colons (``:``) can appear in the fingerprint part.
1280 In addition, colons (``:``) can appear in the fingerprint part.
1273
1281
1274 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1282 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1275 ``sha512``.
1283 ``sha512``.
1276
1284
1277 Use of ``sha256`` or ``sha512`` is preferred.
1285 Use of ``sha256`` or ``sha512`` is preferred.
1278
1286
1279 If a fingerprint is specified, the CA chain is not validated for this
1287 If a fingerprint is specified, the CA chain is not validated for this
1280 host and Mercurial will require the remote certificate to match one
1288 host and Mercurial will require the remote certificate to match one
1281 of the fingerprints specified. This means if the server updates its
1289 of the fingerprints specified. This means if the server updates its
1282 certificate, Mercurial will abort until a new fingerprint is defined.
1290 certificate, Mercurial will abort until a new fingerprint is defined.
1283 This can provide stronger security than traditional CA-based validation
1291 This can provide stronger security than traditional CA-based validation
1284 at the expense of convenience.
1292 at the expense of convenience.
1285
1293
1286 This option takes precedence over ``verifycertsfile``.
1294 This option takes precedence over ``verifycertsfile``.
1287
1295
1288 ``minimumprotocol``
1296 ``minimumprotocol``
1289 This behaves like ``minimumprotocol`` as described above except it
1297 This behaves like ``minimumprotocol`` as described above except it
1290 only applies to the host on which it is defined.
1298 only applies to the host on which it is defined.
1291
1299
1292 ``verifycertsfile``
1300 ``verifycertsfile``
1293 Path to file a containing a list of PEM encoded certificates used to
1301 Path to file a containing a list of PEM encoded certificates used to
1294 verify the server certificate. Environment variables and ``~user``
1302 verify the server certificate. Environment variables and ``~user``
1295 constructs are expanded in the filename.
1303 constructs are expanded in the filename.
1296
1304
1297 The server certificate or the certificate's certificate authority (CA)
1305 The server certificate or the certificate's certificate authority (CA)
1298 must match a certificate from this file or certificate verification
1306 must match a certificate from this file or certificate verification
1299 will fail and connections to the server will be refused.
1307 will fail and connections to the server will be refused.
1300
1308
1301 If defined, only certificates provided by this file will be used:
1309 If defined, only certificates provided by this file will be used:
1302 ``web.cacerts`` and any system/default certificates will not be
1310 ``web.cacerts`` and any system/default certificates will not be
1303 used.
1311 used.
1304
1312
1305 This option has no effect if the per-host ``fingerprints`` option
1313 This option has no effect if the per-host ``fingerprints`` option
1306 is set.
1314 is set.
1307
1315
1308 The format of the file is as follows::
1316 The format of the file is as follows::
1309
1317
1310 -----BEGIN CERTIFICATE-----
1318 -----BEGIN CERTIFICATE-----
1311 ... (certificate in base64 PEM encoding) ...
1319 ... (certificate in base64 PEM encoding) ...
1312 -----END CERTIFICATE-----
1320 -----END CERTIFICATE-----
1313 -----BEGIN CERTIFICATE-----
1321 -----BEGIN CERTIFICATE-----
1314 ... (certificate in base64 PEM encoding) ...
1322 ... (certificate in base64 PEM encoding) ...
1315 -----END CERTIFICATE-----
1323 -----END CERTIFICATE-----
1316
1324
1317 For example::
1325 For example::
1318
1326
1319 [hostsecurity]
1327 [hostsecurity]
1320 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1328 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1321 hg2.example.com:fingerprints = sha1:914f1aff87249c09b6859b88b1906d30756491ca, sha1:fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1329 hg2.example.com:fingerprints = sha1:914f1aff87249c09b6859b88b1906d30756491ca, sha1:fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1322 hg3.example.com:fingerprints = sha256:9a:b0:dc:e2:75:ad:8a:b7:84:58:e5:1f:07:32:f1:87:e6:bd:24:22:af:b7:ce:8e:9c:b4:10:cf:b9:f4:0e:d2
1330 hg3.example.com:fingerprints = sha256:9a:b0:dc:e2:75:ad:8a:b7:84:58:e5:1f:07:32:f1:87:e6:bd:24:22:af:b7:ce:8e:9c:b4:10:cf:b9:f4:0e:d2
1323 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1331 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1324
1332
1325 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1333 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1326 when connecting to ``hg.example.com``::
1334 when connecting to ``hg.example.com``::
1327
1335
1328 [hostsecurity]
1336 [hostsecurity]
1329 minimumprotocol = tls1.2
1337 minimumprotocol = tls1.2
1330 hg.example.com:minimumprotocol = tls1.1
1338 hg.example.com:minimumprotocol = tls1.1
1331
1339
1332 ``http_proxy``
1340 ``http_proxy``
1333 --------------
1341 --------------
1334
1342
1335 Used to access web-based Mercurial repositories through a HTTP
1343 Used to access web-based Mercurial repositories through a HTTP
1336 proxy.
1344 proxy.
1337
1345
1338 ``host``
1346 ``host``
1339 Host name and (optional) port of the proxy server, for example
1347 Host name and (optional) port of the proxy server, for example
1340 "myproxy:8000".
1348 "myproxy:8000".
1341
1349
1342 ``no``
1350 ``no``
1343 Optional. Comma-separated list of host names that should bypass
1351 Optional. Comma-separated list of host names that should bypass
1344 the proxy.
1352 the proxy.
1345
1353
1346 ``passwd``
1354 ``passwd``
1347 Optional. Password to authenticate with at the proxy server.
1355 Optional. Password to authenticate with at the proxy server.
1348
1356
1349 ``user``
1357 ``user``
1350 Optional. User name to authenticate with at the proxy server.
1358 Optional. User name to authenticate with at the proxy server.
1351
1359
1352 ``always``
1360 ``always``
1353 Optional. Always use the proxy, even for localhost and any entries
1361 Optional. Always use the proxy, even for localhost and any entries
1354 in ``http_proxy.no``. (default: False)
1362 in ``http_proxy.no``. (default: False)
1355
1363
1356 ``http``
1364 ``http``
1357 ----------
1365 ----------
1358
1366
1359 Used to configure access to Mercurial repositories via HTTP.
1367 Used to configure access to Mercurial repositories via HTTP.
1360
1368
1361 ``timeout``
1369 ``timeout``
1362 If set, blocking operations will timeout after that many seconds.
1370 If set, blocking operations will timeout after that many seconds.
1363 (default: None)
1371 (default: None)
1364
1372
1365 ``merge``
1373 ``merge``
1366 ---------
1374 ---------
1367
1375
1368 This section specifies behavior during merges and updates.
1376 This section specifies behavior during merges and updates.
1369
1377
1370 ``checkignored``
1378 ``checkignored``
1371 Controls behavior when an ignored file on disk has the same name as a tracked
1379 Controls behavior when an ignored file on disk has the same name as a tracked
1372 file in the changeset being merged or updated to, and has different
1380 file in the changeset being merged or updated to, and has different
1373 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1381 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1374 abort on such files. With ``warn``, warn on such files and back them up as
1382 abort on such files. With ``warn``, warn on such files and back them up as
1375 ``.orig``. With ``ignore``, don't print a warning and back them up as
1383 ``.orig``. With ``ignore``, don't print a warning and back them up as
1376 ``.orig``. (default: ``abort``)
1384 ``.orig``. (default: ``abort``)
1377
1385
1378 ``checkunknown``
1386 ``checkunknown``
1379 Controls behavior when an unknown file that isn't ignored has the same name
1387 Controls behavior when an unknown file that isn't ignored has the same name
1380 as a tracked file in the changeset being merged or updated to, and has
1388 as a tracked file in the changeset being merged or updated to, and has
1381 different contents. Similar to ``merge.checkignored``, except for files that
1389 different contents. Similar to ``merge.checkignored``, except for files that
1382 are not ignored. (default: ``abort``)
1390 are not ignored. (default: ``abort``)
1383
1391
1384 ``on-failure``
1392 ``on-failure``
1385 When set to ``continue`` (the default), the merge process attempts to
1393 When set to ``continue`` (the default), the merge process attempts to
1386 merge all unresolved files using the merge chosen tool, regardless of
1394 merge all unresolved files using the merge chosen tool, regardless of
1387 whether previous file merge attempts during the process succeeded or not.
1395 whether previous file merge attempts during the process succeeded or not.
1388 Setting this to ``prompt`` will prompt after any merge failure continue
1396 Setting this to ``prompt`` will prompt after any merge failure continue
1389 or halt the merge process. Setting this to ``halt`` will automatically
1397 or halt the merge process. Setting this to ``halt`` will automatically
1390 halt the merge process on any merge tool failure. The merge process
1398 halt the merge process on any merge tool failure. The merge process
1391 can be restarted by using the ``resolve`` command. When a merge is
1399 can be restarted by using the ``resolve`` command. When a merge is
1392 halted, the repository is left in a normal ``unresolved`` merge state.
1400 halted, the repository is left in a normal ``unresolved`` merge state.
1393 (default: ``continue``)
1401 (default: ``continue``)
1394
1402
1395 ``strict-capability-check``
1403 ``strict-capability-check``
1396 Whether capabilities of internal merge tools are checked strictly
1404 Whether capabilities of internal merge tools are checked strictly
1397 or not, while examining rules to decide merge tool to be used.
1405 or not, while examining rules to decide merge tool to be used.
1398 (default: False)
1406 (default: False)
1399
1407
1400 ``merge-patterns``
1408 ``merge-patterns``
1401 ------------------
1409 ------------------
1402
1410
1403 This section specifies merge tools to associate with particular file
1411 This section specifies merge tools to associate with particular file
1404 patterns. Tools matched here will take precedence over the default
1412 patterns. Tools matched here will take precedence over the default
1405 merge tool. Patterns are globs by default, rooted at the repository
1413 merge tool. Patterns are globs by default, rooted at the repository
1406 root.
1414 root.
1407
1415
1408 Example::
1416 Example::
1409
1417
1410 [merge-patterns]
1418 [merge-patterns]
1411 **.c = kdiff3
1419 **.c = kdiff3
1412 **.jpg = myimgmerge
1420 **.jpg = myimgmerge
1413
1421
1414 ``merge-tools``
1422 ``merge-tools``
1415 ---------------
1423 ---------------
1416
1424
1417 This section configures external merge tools to use for file-level
1425 This section configures external merge tools to use for file-level
1418 merges. This section has likely been preconfigured at install time.
1426 merges. This section has likely been preconfigured at install time.
1419 Use :hg:`config merge-tools` to check the existing configuration.
1427 Use :hg:`config merge-tools` to check the existing configuration.
1420 Also see :hg:`help merge-tools` for more details.
1428 Also see :hg:`help merge-tools` for more details.
1421
1429
1422 Example ``~/.hgrc``::
1430 Example ``~/.hgrc``::
1423
1431
1424 [merge-tools]
1432 [merge-tools]
1425 # Override stock tool location
1433 # Override stock tool location
1426 kdiff3.executable = ~/bin/kdiff3
1434 kdiff3.executable = ~/bin/kdiff3
1427 # Specify command line
1435 # Specify command line
1428 kdiff3.args = $base $local $other -o $output
1436 kdiff3.args = $base $local $other -o $output
1429 # Give higher priority
1437 # Give higher priority
1430 kdiff3.priority = 1
1438 kdiff3.priority = 1
1431
1439
1432 # Changing the priority of preconfigured tool
1440 # Changing the priority of preconfigured tool
1433 meld.priority = 0
1441 meld.priority = 0
1434
1442
1435 # Disable a preconfigured tool
1443 # Disable a preconfigured tool
1436 vimdiff.disabled = yes
1444 vimdiff.disabled = yes
1437
1445
1438 # Define new tool
1446 # Define new tool
1439 myHtmlTool.args = -m $local $other $base $output
1447 myHtmlTool.args = -m $local $other $base $output
1440 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1448 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1441 myHtmlTool.priority = 1
1449 myHtmlTool.priority = 1
1442
1450
1443 Supported arguments:
1451 Supported arguments:
1444
1452
1445 ``priority``
1453 ``priority``
1446 The priority in which to evaluate this tool.
1454 The priority in which to evaluate this tool.
1447 (default: 0)
1455 (default: 0)
1448
1456
1449 ``executable``
1457 ``executable``
1450 Either just the name of the executable or its pathname.
1458 Either just the name of the executable or its pathname.
1451
1459
1452 .. container:: windows
1460 .. container:: windows
1453
1461
1454 On Windows, the path can use environment variables with ${ProgramFiles}
1462 On Windows, the path can use environment variables with ${ProgramFiles}
1455 syntax.
1463 syntax.
1456
1464
1457 (default: the tool name)
1465 (default: the tool name)
1458
1466
1459 ``args``
1467 ``args``
1460 The arguments to pass to the tool executable. You can refer to the
1468 The arguments to pass to the tool executable. You can refer to the
1461 files being merged as well as the output file through these
1469 files being merged as well as the output file through these
1462 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1470 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1463
1471
1464 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1472 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1465 being performed. During an update or merge, ``$local`` represents the original
1473 being performed. During an update or merge, ``$local`` represents the original
1466 state of the file, while ``$other`` represents the commit you are updating to or
1474 state of the file, while ``$other`` represents the commit you are updating to or
1467 the commit you are merging with. During a rebase, ``$local`` represents the
1475 the commit you are merging with. During a rebase, ``$local`` represents the
1468 destination of the rebase, and ``$other`` represents the commit being rebased.
1476 destination of the rebase, and ``$other`` represents the commit being rebased.
1469
1477
1470 Some operations define custom labels to assist with identifying the revisions,
1478 Some operations define custom labels to assist with identifying the revisions,
1471 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1479 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1472 labels are not available, these will be ``local``, ``other``, and ``base``,
1480 labels are not available, these will be ``local``, ``other``, and ``base``,
1473 respectively.
1481 respectively.
1474 (default: ``$local $base $other``)
1482 (default: ``$local $base $other``)
1475
1483
1476 ``premerge``
1484 ``premerge``
1477 Attempt to run internal non-interactive 3-way merge tool before
1485 Attempt to run internal non-interactive 3-way merge tool before
1478 launching external tool. Options are ``true``, ``false``, ``keep`` or
1486 launching external tool. Options are ``true``, ``false``, ``keep`` or
1479 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1487 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1480 premerge fails. The ``keep-merge3`` will do the same but include information
1488 premerge fails. The ``keep-merge3`` will do the same but include information
1481 about the base of the merge in the marker (see internal :merge3 in
1489 about the base of the merge in the marker (see internal :merge3 in
1482 :hg:`help merge-tools`).
1490 :hg:`help merge-tools`).
1483 (default: True)
1491 (default: True)
1484
1492
1485 ``binary``
1493 ``binary``
1486 This tool can merge binary files. (default: False, unless tool
1494 This tool can merge binary files. (default: False, unless tool
1487 was selected by file pattern match)
1495 was selected by file pattern match)
1488
1496
1489 ``symlink``
1497 ``symlink``
1490 This tool can merge symlinks. (default: False)
1498 This tool can merge symlinks. (default: False)
1491
1499
1492 ``check``
1500 ``check``
1493 A list of merge success-checking options:
1501 A list of merge success-checking options:
1494
1502
1495 ``changed``
1503 ``changed``
1496 Ask whether merge was successful when the merged file shows no changes.
1504 Ask whether merge was successful when the merged file shows no changes.
1497 ``conflicts``
1505 ``conflicts``
1498 Check whether there are conflicts even though the tool reported success.
1506 Check whether there are conflicts even though the tool reported success.
1499 ``prompt``
1507 ``prompt``
1500 Always prompt for merge success, regardless of success reported by tool.
1508 Always prompt for merge success, regardless of success reported by tool.
1501
1509
1502 ``fixeol``
1510 ``fixeol``
1503 Attempt to fix up EOL changes caused by the merge tool.
1511 Attempt to fix up EOL changes caused by the merge tool.
1504 (default: False)
1512 (default: False)
1505
1513
1506 ``gui``
1514 ``gui``
1507 This tool requires a graphical interface to run. (default: False)
1515 This tool requires a graphical interface to run. (default: False)
1508
1516
1509 ``mergemarkers``
1517 ``mergemarkers``
1510 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1518 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1511 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1519 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1512 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1520 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1513 markers generated during premerge will be ``detailed`` if either this option or
1521 markers generated during premerge will be ``detailed`` if either this option or
1514 the corresponding option in the ``[ui]`` section is ``detailed``.
1522 the corresponding option in the ``[ui]`` section is ``detailed``.
1515 (default: ``basic``)
1523 (default: ``basic``)
1516
1524
1517 ``mergemarkertemplate``
1525 ``mergemarkertemplate``
1518 This setting can be used to override ``mergemarkertemplate`` from the ``[ui]``
1526 This setting can be used to override ``mergemarkertemplate`` from the ``[ui]``
1519 section on a per-tool basis; this applies to the ``$label``-prefixed variables
1527 section on a per-tool basis; this applies to the ``$label``-prefixed variables
1520 and to the conflict markers that are generated if ``premerge`` is ``keep` or
1528 and to the conflict markers that are generated if ``premerge`` is ``keep` or
1521 ``keep-merge3``. See the corresponding variable in ``[ui]`` for more
1529 ``keep-merge3``. See the corresponding variable in ``[ui]`` for more
1522 information.
1530 information.
1523
1531
1524 .. container:: windows
1532 .. container:: windows
1525
1533
1526 ``regkey``
1534 ``regkey``
1527 Windows registry key which describes install location of this
1535 Windows registry key which describes install location of this
1528 tool. Mercurial will search for this key first under
1536 tool. Mercurial will search for this key first under
1529 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1537 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1530 (default: None)
1538 (default: None)
1531
1539
1532 ``regkeyalt``
1540 ``regkeyalt``
1533 An alternate Windows registry key to try if the first key is not
1541 An alternate Windows registry key to try if the first key is not
1534 found. The alternate key uses the same ``regname`` and ``regappend``
1542 found. The alternate key uses the same ``regname`` and ``regappend``
1535 semantics of the primary key. The most common use for this key
1543 semantics of the primary key. The most common use for this key
1536 is to search for 32bit applications on 64bit operating systems.
1544 is to search for 32bit applications on 64bit operating systems.
1537 (default: None)
1545 (default: None)
1538
1546
1539 ``regname``
1547 ``regname``
1540 Name of value to read from specified registry key.
1548 Name of value to read from specified registry key.
1541 (default: the unnamed (default) value)
1549 (default: the unnamed (default) value)
1542
1550
1543 ``regappend``
1551 ``regappend``
1544 String to append to the value read from the registry, typically
1552 String to append to the value read from the registry, typically
1545 the executable name of the tool.
1553 the executable name of the tool.
1546 (default: None)
1554 (default: None)
1547
1555
1548 ``pager``
1556 ``pager``
1549 ---------
1557 ---------
1550
1558
1551 Setting used to control when to paginate and with what external tool. See
1559 Setting used to control when to paginate and with what external tool. See
1552 :hg:`help pager` for details.
1560 :hg:`help pager` for details.
1553
1561
1554 ``pager``
1562 ``pager``
1555 Define the external tool used as pager.
1563 Define the external tool used as pager.
1556
1564
1557 If no pager is set, Mercurial uses the environment variable $PAGER.
1565 If no pager is set, Mercurial uses the environment variable $PAGER.
1558 If neither pager.pager, nor $PAGER is set, a default pager will be
1566 If neither pager.pager, nor $PAGER is set, a default pager will be
1559 used, typically `less` on Unix and `more` on Windows. Example::
1567 used, typically `less` on Unix and `more` on Windows. Example::
1560
1568
1561 [pager]
1569 [pager]
1562 pager = less -FRX
1570 pager = less -FRX
1563
1571
1564 ``ignore``
1572 ``ignore``
1565 List of commands to disable the pager for. Example::
1573 List of commands to disable the pager for. Example::
1566
1574
1567 [pager]
1575 [pager]
1568 ignore = version, help, update
1576 ignore = version, help, update
1569
1577
1570 ``patch``
1578 ``patch``
1571 ---------
1579 ---------
1572
1580
1573 Settings used when applying patches, for instance through the 'import'
1581 Settings used when applying patches, for instance through the 'import'
1574 command or with Mercurial Queues extension.
1582 command or with Mercurial Queues extension.
1575
1583
1576 ``eol``
1584 ``eol``
1577 When set to 'strict' patch content and patched files end of lines
1585 When set to 'strict' patch content and patched files end of lines
1578 are preserved. When set to ``lf`` or ``crlf``, both files end of
1586 are preserved. When set to ``lf`` or ``crlf``, both files end of
1579 lines are ignored when patching and the result line endings are
1587 lines are ignored when patching and the result line endings are
1580 normalized to either LF (Unix) or CRLF (Windows). When set to
1588 normalized to either LF (Unix) or CRLF (Windows). When set to
1581 ``auto``, end of lines are again ignored while patching but line
1589 ``auto``, end of lines are again ignored while patching but line
1582 endings in patched files are normalized to their original setting
1590 endings in patched files are normalized to their original setting
1583 on a per-file basis. If target file does not exist or has no end
1591 on a per-file basis. If target file does not exist or has no end
1584 of line, patch line endings are preserved.
1592 of line, patch line endings are preserved.
1585 (default: strict)
1593 (default: strict)
1586
1594
1587 ``fuzz``
1595 ``fuzz``
1588 The number of lines of 'fuzz' to allow when applying patches. This
1596 The number of lines of 'fuzz' to allow when applying patches. This
1589 controls how much context the patcher is allowed to ignore when
1597 controls how much context the patcher is allowed to ignore when
1590 trying to apply a patch.
1598 trying to apply a patch.
1591 (default: 2)
1599 (default: 2)
1592
1600
1593 ``paths``
1601 ``paths``
1594 ---------
1602 ---------
1595
1603
1596 Assigns symbolic names and behavior to repositories.
1604 Assigns symbolic names and behavior to repositories.
1597
1605
1598 Options are symbolic names defining the URL or directory that is the
1606 Options are symbolic names defining the URL or directory that is the
1599 location of the repository. Example::
1607 location of the repository. Example::
1600
1608
1601 [paths]
1609 [paths]
1602 my_server = https://example.com/my_repo
1610 my_server = https://example.com/my_repo
1603 local_path = /home/me/repo
1611 local_path = /home/me/repo
1604
1612
1605 These symbolic names can be used from the command line. To pull
1613 These symbolic names can be used from the command line. To pull
1606 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1614 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1607 :hg:`push local_path`.
1615 :hg:`push local_path`.
1608
1616
1609 Options containing colons (``:``) denote sub-options that can influence
1617 Options containing colons (``:``) denote sub-options that can influence
1610 behavior for that specific path. Example::
1618 behavior for that specific path. Example::
1611
1619
1612 [paths]
1620 [paths]
1613 my_server = https://example.com/my_path
1621 my_server = https://example.com/my_path
1614 my_server:pushurl = ssh://example.com/my_path
1622 my_server:pushurl = ssh://example.com/my_path
1615
1623
1616 The following sub-options can be defined:
1624 The following sub-options can be defined:
1617
1625
1618 ``pushurl``
1626 ``pushurl``
1619 The URL to use for push operations. If not defined, the location
1627 The URL to use for push operations. If not defined, the location
1620 defined by the path's main entry is used.
1628 defined by the path's main entry is used.
1621
1629
1622 ``pushrev``
1630 ``pushrev``
1623 A revset defining which revisions to push by default.
1631 A revset defining which revisions to push by default.
1624
1632
1625 When :hg:`push` is executed without a ``-r`` argument, the revset
1633 When :hg:`push` is executed without a ``-r`` argument, the revset
1626 defined by this sub-option is evaluated to determine what to push.
1634 defined by this sub-option is evaluated to determine what to push.
1627
1635
1628 For example, a value of ``.`` will push the working directory's
1636 For example, a value of ``.`` will push the working directory's
1629 revision by default.
1637 revision by default.
1630
1638
1631 Revsets specifying bookmarks will not result in the bookmark being
1639 Revsets specifying bookmarks will not result in the bookmark being
1632 pushed.
1640 pushed.
1633
1641
1634 The following special named paths exist:
1642 The following special named paths exist:
1635
1643
1636 ``default``
1644 ``default``
1637 The URL or directory to use when no source or remote is specified.
1645 The URL or directory to use when no source or remote is specified.
1638
1646
1639 :hg:`clone` will automatically define this path to the location the
1647 :hg:`clone` will automatically define this path to the location the
1640 repository was cloned from.
1648 repository was cloned from.
1641
1649
1642 ``default-push``
1650 ``default-push``
1643 (deprecated) The URL or directory for the default :hg:`push` location.
1651 (deprecated) The URL or directory for the default :hg:`push` location.
1644 ``default:pushurl`` should be used instead.
1652 ``default:pushurl`` should be used instead.
1645
1653
1646 ``phases``
1654 ``phases``
1647 ----------
1655 ----------
1648
1656
1649 Specifies default handling of phases. See :hg:`help phases` for more
1657 Specifies default handling of phases. See :hg:`help phases` for more
1650 information about working with phases.
1658 information about working with phases.
1651
1659
1652 ``publish``
1660 ``publish``
1653 Controls draft phase behavior when working as a server. When true,
1661 Controls draft phase behavior when working as a server. When true,
1654 pushed changesets are set to public in both client and server and
1662 pushed changesets are set to public in both client and server and
1655 pulled or cloned changesets are set to public in the client.
1663 pulled or cloned changesets are set to public in the client.
1656 (default: True)
1664 (default: True)
1657
1665
1658 ``new-commit``
1666 ``new-commit``
1659 Phase of newly-created commits.
1667 Phase of newly-created commits.
1660 (default: draft)
1668 (default: draft)
1661
1669
1662 ``checksubrepos``
1670 ``checksubrepos``
1663 Check the phase of the current revision of each subrepository. Allowed
1671 Check the phase of the current revision of each subrepository. Allowed
1664 values are "ignore", "follow" and "abort". For settings other than
1672 values are "ignore", "follow" and "abort". For settings other than
1665 "ignore", the phase of the current revision of each subrepository is
1673 "ignore", the phase of the current revision of each subrepository is
1666 checked before committing the parent repository. If any of those phases is
1674 checked before committing the parent repository. If any of those phases is
1667 greater than the phase of the parent repository (e.g. if a subrepo is in a
1675 greater than the phase of the parent repository (e.g. if a subrepo is in a
1668 "secret" phase while the parent repo is in "draft" phase), the commit is
1676 "secret" phase while the parent repo is in "draft" phase), the commit is
1669 either aborted (if checksubrepos is set to "abort") or the higher phase is
1677 either aborted (if checksubrepos is set to "abort") or the higher phase is
1670 used for the parent repository commit (if set to "follow").
1678 used for the parent repository commit (if set to "follow").
1671 (default: follow)
1679 (default: follow)
1672
1680
1673
1681
1674 ``profiling``
1682 ``profiling``
1675 -------------
1683 -------------
1676
1684
1677 Specifies profiling type, format, and file output. Two profilers are
1685 Specifies profiling type, format, and file output. Two profilers are
1678 supported: an instrumenting profiler (named ``ls``), and a sampling
1686 supported: an instrumenting profiler (named ``ls``), and a sampling
1679 profiler (named ``stat``).
1687 profiler (named ``stat``).
1680
1688
1681 In this section description, 'profiling data' stands for the raw data
1689 In this section description, 'profiling data' stands for the raw data
1682 collected during profiling, while 'profiling report' stands for a
1690 collected during profiling, while 'profiling report' stands for a
1683 statistical text report generated from the profiling data.
1691 statistical text report generated from the profiling data.
1684
1692
1685 ``enabled``
1693 ``enabled``
1686 Enable the profiler.
1694 Enable the profiler.
1687 (default: false)
1695 (default: false)
1688
1696
1689 This is equivalent to passing ``--profile`` on the command line.
1697 This is equivalent to passing ``--profile`` on the command line.
1690
1698
1691 ``type``
1699 ``type``
1692 The type of profiler to use.
1700 The type of profiler to use.
1693 (default: stat)
1701 (default: stat)
1694
1702
1695 ``ls``
1703 ``ls``
1696 Use Python's built-in instrumenting profiler. This profiler
1704 Use Python's built-in instrumenting profiler. This profiler
1697 works on all platforms, but each line number it reports is the
1705 works on all platforms, but each line number it reports is the
1698 first line of a function. This restriction makes it difficult to
1706 first line of a function. This restriction makes it difficult to
1699 identify the expensive parts of a non-trivial function.
1707 identify the expensive parts of a non-trivial function.
1700 ``stat``
1708 ``stat``
1701 Use a statistical profiler, statprof. This profiler is most
1709 Use a statistical profiler, statprof. This profiler is most
1702 useful for profiling commands that run for longer than about 0.1
1710 useful for profiling commands that run for longer than about 0.1
1703 seconds.
1711 seconds.
1704
1712
1705 ``format``
1713 ``format``
1706 Profiling format. Specific to the ``ls`` instrumenting profiler.
1714 Profiling format. Specific to the ``ls`` instrumenting profiler.
1707 (default: text)
1715 (default: text)
1708
1716
1709 ``text``
1717 ``text``
1710 Generate a profiling report. When saving to a file, it should be
1718 Generate a profiling report. When saving to a file, it should be
1711 noted that only the report is saved, and the profiling data is
1719 noted that only the report is saved, and the profiling data is
1712 not kept.
1720 not kept.
1713 ``kcachegrind``
1721 ``kcachegrind``
1714 Format profiling data for kcachegrind use: when saving to a
1722 Format profiling data for kcachegrind use: when saving to a
1715 file, the generated file can directly be loaded into
1723 file, the generated file can directly be loaded into
1716 kcachegrind.
1724 kcachegrind.
1717
1725
1718 ``statformat``
1726 ``statformat``
1719 Profiling format for the ``stat`` profiler.
1727 Profiling format for the ``stat`` profiler.
1720 (default: hotpath)
1728 (default: hotpath)
1721
1729
1722 ``hotpath``
1730 ``hotpath``
1723 Show a tree-based display containing the hot path of execution (where
1731 Show a tree-based display containing the hot path of execution (where
1724 most time was spent).
1732 most time was spent).
1725 ``bymethod``
1733 ``bymethod``
1726 Show a table of methods ordered by how frequently they are active.
1734 Show a table of methods ordered by how frequently they are active.
1727 ``byline``
1735 ``byline``
1728 Show a table of lines in files ordered by how frequently they are active.
1736 Show a table of lines in files ordered by how frequently they are active.
1729 ``json``
1737 ``json``
1730 Render profiling data as JSON.
1738 Render profiling data as JSON.
1731
1739
1732 ``frequency``
1740 ``frequency``
1733 Sampling frequency. Specific to the ``stat`` sampling profiler.
1741 Sampling frequency. Specific to the ``stat`` sampling profiler.
1734 (default: 1000)
1742 (default: 1000)
1735
1743
1736 ``output``
1744 ``output``
1737 File path where profiling data or report should be saved. If the
1745 File path where profiling data or report should be saved. If the
1738 file exists, it is replaced. (default: None, data is printed on
1746 file exists, it is replaced. (default: None, data is printed on
1739 stderr)
1747 stderr)
1740
1748
1741 ``sort``
1749 ``sort``
1742 Sort field. Specific to the ``ls`` instrumenting profiler.
1750 Sort field. Specific to the ``ls`` instrumenting profiler.
1743 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1751 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1744 ``inlinetime``.
1752 ``inlinetime``.
1745 (default: inlinetime)
1753 (default: inlinetime)
1746
1754
1747 ``time-track``
1755 ``time-track``
1748 Control if the stat profiler track ``cpu`` or ``real`` time.
1756 Control if the stat profiler track ``cpu`` or ``real`` time.
1749 (default: ``cpu`` on Windows, otherwise ``real``)
1757 (default: ``cpu`` on Windows, otherwise ``real``)
1750
1758
1751 ``limit``
1759 ``limit``
1752 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1760 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1753 (default: 30)
1761 (default: 30)
1754
1762
1755 ``nested``
1763 ``nested``
1756 Show at most this number of lines of drill-down info after each main entry.
1764 Show at most this number of lines of drill-down info after each main entry.
1757 This can help explain the difference between Total and Inline.
1765 This can help explain the difference between Total and Inline.
1758 Specific to the ``ls`` instrumenting profiler.
1766 Specific to the ``ls`` instrumenting profiler.
1759 (default: 0)
1767 (default: 0)
1760
1768
1761 ``showmin``
1769 ``showmin``
1762 Minimum fraction of samples an entry must have for it to be displayed.
1770 Minimum fraction of samples an entry must have for it to be displayed.
1763 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1771 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1764 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1772 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1765
1773
1766 Only used by the ``stat`` profiler.
1774 Only used by the ``stat`` profiler.
1767
1775
1768 For the ``hotpath`` format, default is ``0.05``.
1776 For the ``hotpath`` format, default is ``0.05``.
1769 For the ``chrome`` format, default is ``0.005``.
1777 For the ``chrome`` format, default is ``0.005``.
1770
1778
1771 The option is unused on other formats.
1779 The option is unused on other formats.
1772
1780
1773 ``showmax``
1781 ``showmax``
1774 Maximum fraction of samples an entry can have before it is ignored in
1782 Maximum fraction of samples an entry can have before it is ignored in
1775 display. Values format is the same as ``showmin``.
1783 display. Values format is the same as ``showmin``.
1776
1784
1777 Only used by the ``stat`` profiler.
1785 Only used by the ``stat`` profiler.
1778
1786
1779 For the ``chrome`` format, default is ``0.999``.
1787 For the ``chrome`` format, default is ``0.999``.
1780
1788
1781 The option is unused on other formats.
1789 The option is unused on other formats.
1782
1790
1783 ``showtime``
1791 ``showtime``
1784 Show time taken as absolute durations, in addition to percentages.
1792 Show time taken as absolute durations, in addition to percentages.
1785 Only used by the ``hotpath`` format.
1793 Only used by the ``hotpath`` format.
1786 (default: true)
1794 (default: true)
1787
1795
1788 ``progress``
1796 ``progress``
1789 ------------
1797 ------------
1790
1798
1791 Mercurial commands can draw progress bars that are as informative as
1799 Mercurial commands can draw progress bars that are as informative as
1792 possible. Some progress bars only offer indeterminate information, while others
1800 possible. Some progress bars only offer indeterminate information, while others
1793 have a definite end point.
1801 have a definite end point.
1794
1802
1795 ``debug``
1803 ``debug``
1796 Whether to print debug info when updating the progress bar. (default: False)
1804 Whether to print debug info when updating the progress bar. (default: False)
1797
1805
1798 ``delay``
1806 ``delay``
1799 Number of seconds (float) before showing the progress bar. (default: 3)
1807 Number of seconds (float) before showing the progress bar. (default: 3)
1800
1808
1801 ``changedelay``
1809 ``changedelay``
1802 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1810 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1803 that value will be used instead. (default: 1)
1811 that value will be used instead. (default: 1)
1804
1812
1805 ``estimateinterval``
1813 ``estimateinterval``
1806 Maximum sampling interval in seconds for speed and estimated time
1814 Maximum sampling interval in seconds for speed and estimated time
1807 calculation. (default: 60)
1815 calculation. (default: 60)
1808
1816
1809 ``refresh``
1817 ``refresh``
1810 Time in seconds between refreshes of the progress bar. (default: 0.1)
1818 Time in seconds between refreshes of the progress bar. (default: 0.1)
1811
1819
1812 ``format``
1820 ``format``
1813 Format of the progress bar.
1821 Format of the progress bar.
1814
1822
1815 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1823 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1816 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1824 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1817 last 20 characters of the item, but this can be changed by adding either
1825 last 20 characters of the item, but this can be changed by adding either
1818 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1826 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1819 first num characters.
1827 first num characters.
1820
1828
1821 (default: topic bar number estimate)
1829 (default: topic bar number estimate)
1822
1830
1823 ``width``
1831 ``width``
1824 If set, the maximum width of the progress information (that is, min(width,
1832 If set, the maximum width of the progress information (that is, min(width,
1825 term width) will be used).
1833 term width) will be used).
1826
1834
1827 ``clear-complete``
1835 ``clear-complete``
1828 Clear the progress bar after it's done. (default: True)
1836 Clear the progress bar after it's done. (default: True)
1829
1837
1830 ``disable``
1838 ``disable``
1831 If true, don't show a progress bar.
1839 If true, don't show a progress bar.
1832
1840
1833 ``assume-tty``
1841 ``assume-tty``
1834 If true, ALWAYS show a progress bar, unless disable is given.
1842 If true, ALWAYS show a progress bar, unless disable is given.
1835
1843
1836 ``rebase``
1844 ``rebase``
1837 ----------
1845 ----------
1838
1846
1839 ``evolution.allowdivergence``
1847 ``evolution.allowdivergence``
1840 Default to False, when True allow creating divergence when performing
1848 Default to False, when True allow creating divergence when performing
1841 rebase of obsolete changesets.
1849 rebase of obsolete changesets.
1842
1850
1843 ``revsetalias``
1851 ``revsetalias``
1844 ---------------
1852 ---------------
1845
1853
1846 Alias definitions for revsets. See :hg:`help revsets` for details.
1854 Alias definitions for revsets. See :hg:`help revsets` for details.
1847
1855
1848 ``rewrite``
1856 ``rewrite``
1849 -----------
1857 -----------
1850
1858
1851 ``backup-bundle``
1859 ``backup-bundle``
1852 Whether to save stripped changesets to a bundle file. (default: True)
1860 Whether to save stripped changesets to a bundle file. (default: True)
1853
1861
1854 ``update-timestamp``
1862 ``update-timestamp``
1855 If true, updates the date and time of the changeset to current. It is only
1863 If true, updates the date and time of the changeset to current. It is only
1856 applicable for `hg amend`, `hg commit --amend` and `hg uncommit` in the
1864 applicable for `hg amend`, `hg commit --amend` and `hg uncommit` in the
1857 current version.
1865 current version.
1858
1866
1859 ``storage``
1867 ``storage``
1860 -----------
1868 -----------
1861
1869
1862 Control the strategy Mercurial uses internally to store history. Options in this
1870 Control the strategy Mercurial uses internally to store history. Options in this
1863 category impact performance and repository size.
1871 category impact performance and repository size.
1864
1872
1865 ``revlog.optimize-delta-parent-choice``
1873 ``revlog.optimize-delta-parent-choice``
1866 When storing a merge revision, both parents will be equally considered as
1874 When storing a merge revision, both parents will be equally considered as
1867 a possible delta base. This results in better delta selection and improved
1875 a possible delta base. This results in better delta selection and improved
1868 revlog compression. This option is enabled by default.
1876 revlog compression. This option is enabled by default.
1869
1877
1870 Turning this option off can result in large increase of repository size for
1878 Turning this option off can result in large increase of repository size for
1871 repository with many merges.
1879 repository with many merges.
1872
1880
1873 ``revlog.reuse-external-delta-parent``
1881 ``revlog.reuse-external-delta-parent``
1874 Control the order in which delta parents are considered when adding new
1882 Control the order in which delta parents are considered when adding new
1875 revisions from an external source.
1883 revisions from an external source.
1876 (typically: apply bundle from `hg pull` or `hg push`).
1884 (typically: apply bundle from `hg pull` or `hg push`).
1877
1885
1878 New revisions are usually provided as a delta against other revisions. By
1886 New revisions are usually provided as a delta against other revisions. By
1879 default, Mercurial will try to reuse this delta first, therefore using the
1887 default, Mercurial will try to reuse this delta first, therefore using the
1880 same "delta parent" as the source. Directly using delta's from the source
1888 same "delta parent" as the source. Directly using delta's from the source
1881 reduces CPU usage and usually speeds up operation. However, in some case,
1889 reduces CPU usage and usually speeds up operation. However, in some case,
1882 the source might have sub-optimal delta bases and forcing their reevaluation
1890 the source might have sub-optimal delta bases and forcing their reevaluation
1883 is useful. For example, pushes from an old client could have sub-optimal
1891 is useful. For example, pushes from an old client could have sub-optimal
1884 delta's parent that the server want to optimize. (lack of general delta, bad
1892 delta's parent that the server want to optimize. (lack of general delta, bad
1885 parents, choice, lack of sparse-revlog, etc).
1893 parents, choice, lack of sparse-revlog, etc).
1886
1894
1887 This option is enabled by default. Turning it off will ensure bad delta
1895 This option is enabled by default. Turning it off will ensure bad delta
1888 parent choices from older client do not propagate to this repository, at
1896 parent choices from older client do not propagate to this repository, at
1889 the cost of a small increase in CPU consumption.
1897 the cost of a small increase in CPU consumption.
1890
1898
1891 Note: this option only control the order in which delta parents are
1899 Note: this option only control the order in which delta parents are
1892 considered. Even when disabled, the existing delta from the source will be
1900 considered. Even when disabled, the existing delta from the source will be
1893 reused if the same delta parent is selected.
1901 reused if the same delta parent is selected.
1894
1902
1895 ``revlog.reuse-external-delta``
1903 ``revlog.reuse-external-delta``
1896 Control the reuse of delta from external source.
1904 Control the reuse of delta from external source.
1897 (typically: apply bundle from `hg pull` or `hg push`).
1905 (typically: apply bundle from `hg pull` or `hg push`).
1898
1906
1899 New revisions are usually provided as a delta against another revision. By
1907 New revisions are usually provided as a delta against another revision. By
1900 default, Mercurial will not recompute the same delta again, trusting
1908 default, Mercurial will not recompute the same delta again, trusting
1901 externally provided deltas. There have been rare cases of small adjustment
1909 externally provided deltas. There have been rare cases of small adjustment
1902 to the diffing algorithm in the past. So in some rare case, recomputing
1910 to the diffing algorithm in the past. So in some rare case, recomputing
1903 delta provided by ancient clients can provides better results. Disabling
1911 delta provided by ancient clients can provides better results. Disabling
1904 this option means going through a full delta recomputation for all incoming
1912 this option means going through a full delta recomputation for all incoming
1905 revisions. It means a large increase in CPU usage and will slow operations
1913 revisions. It means a large increase in CPU usage and will slow operations
1906 down.
1914 down.
1907
1915
1908 This option is enabled by default. When disabled, it also disables the
1916 This option is enabled by default. When disabled, it also disables the
1909 related ``storage.revlog.reuse-external-delta-parent`` option.
1917 related ``storage.revlog.reuse-external-delta-parent`` option.
1910
1918
1911 ``revlog.zlib.level``
1919 ``revlog.zlib.level``
1912 Zlib compression level used when storing data into the repository. Accepted
1920 Zlib compression level used when storing data into the repository. Accepted
1913 Value range from 1 (lowest compression) to 9 (highest compression). Zlib
1921 Value range from 1 (lowest compression) to 9 (highest compression). Zlib
1914 default value is 6.
1922 default value is 6.
1915
1923
1916
1924
1917 ``revlog.zstd.level``
1925 ``revlog.zstd.level``
1918 zstd compression level used when storing data into the repository. Accepted
1926 zstd compression level used when storing data into the repository. Accepted
1919 Value range from 1 (lowest compression) to 22 (highest compression).
1927 Value range from 1 (lowest compression) to 22 (highest compression).
1920 (default 3)
1928 (default 3)
1921
1929
1922 ``server``
1930 ``server``
1923 ----------
1931 ----------
1924
1932
1925 Controls generic server settings.
1933 Controls generic server settings.
1926
1934
1927 ``bookmarks-pushkey-compat``
1935 ``bookmarks-pushkey-compat``
1928 Trigger pushkey hook when being pushed bookmark updates. This config exist
1936 Trigger pushkey hook when being pushed bookmark updates. This config exist
1929 for compatibility purpose (default to True)
1937 for compatibility purpose (default to True)
1930
1938
1931 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
1939 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
1932 movement we recommend you migrate them to ``txnclose-bookmark`` and
1940 movement we recommend you migrate them to ``txnclose-bookmark`` and
1933 ``pretxnclose-bookmark``.
1941 ``pretxnclose-bookmark``.
1934
1942
1935 ``compressionengines``
1943 ``compressionengines``
1936 List of compression engines and their relative priority to advertise
1944 List of compression engines and their relative priority to advertise
1937 to clients.
1945 to clients.
1938
1946
1939 The order of compression engines determines their priority, the first
1947 The order of compression engines determines their priority, the first
1940 having the highest priority. If a compression engine is not listed
1948 having the highest priority. If a compression engine is not listed
1941 here, it won't be advertised to clients.
1949 here, it won't be advertised to clients.
1942
1950
1943 If not set (the default), built-in defaults are used. Run
1951 If not set (the default), built-in defaults are used. Run
1944 :hg:`debuginstall` to list available compression engines and their
1952 :hg:`debuginstall` to list available compression engines and their
1945 default wire protocol priority.
1953 default wire protocol priority.
1946
1954
1947 Older Mercurial clients only support zlib compression and this setting
1955 Older Mercurial clients only support zlib compression and this setting
1948 has no effect for legacy clients.
1956 has no effect for legacy clients.
1949
1957
1950 ``uncompressed``
1958 ``uncompressed``
1951 Whether to allow clients to clone a repository using the
1959 Whether to allow clients to clone a repository using the
1952 uncompressed streaming protocol. This transfers about 40% more
1960 uncompressed streaming protocol. This transfers about 40% more
1953 data than a regular clone, but uses less memory and CPU on both
1961 data than a regular clone, but uses less memory and CPU on both
1954 server and client. Over a LAN (100 Mbps or better) or a very fast
1962 server and client. Over a LAN (100 Mbps or better) or a very fast
1955 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1963 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1956 regular clone. Over most WAN connections (anything slower than
1964 regular clone. Over most WAN connections (anything slower than
1957 about 6 Mbps), uncompressed streaming is slower, because of the
1965 about 6 Mbps), uncompressed streaming is slower, because of the
1958 extra data transfer overhead. This mode will also temporarily hold
1966 extra data transfer overhead. This mode will also temporarily hold
1959 the write lock while determining what data to transfer.
1967 the write lock while determining what data to transfer.
1960 (default: True)
1968 (default: True)
1961
1969
1962 ``uncompressedallowsecret``
1970 ``uncompressedallowsecret``
1963 Whether to allow stream clones when the repository contains secret
1971 Whether to allow stream clones when the repository contains secret
1964 changesets. (default: False)
1972 changesets. (default: False)
1965
1973
1966 ``preferuncompressed``
1974 ``preferuncompressed``
1967 When set, clients will try to use the uncompressed streaming
1975 When set, clients will try to use the uncompressed streaming
1968 protocol. (default: False)
1976 protocol. (default: False)
1969
1977
1970 ``disablefullbundle``
1978 ``disablefullbundle``
1971 When set, servers will refuse attempts to do pull-based clones.
1979 When set, servers will refuse attempts to do pull-based clones.
1972 If this option is set, ``preferuncompressed`` and/or clone bundles
1980 If this option is set, ``preferuncompressed`` and/or clone bundles
1973 are highly recommended. Partial clones will still be allowed.
1981 are highly recommended. Partial clones will still be allowed.
1974 (default: False)
1982 (default: False)
1975
1983
1976 ``streamunbundle``
1984 ``streamunbundle``
1977 When set, servers will apply data sent from the client directly,
1985 When set, servers will apply data sent from the client directly,
1978 otherwise it will be written to a temporary file first. This option
1986 otherwise it will be written to a temporary file first. This option
1979 effectively prevents concurrent pushes.
1987 effectively prevents concurrent pushes.
1980
1988
1981 ``pullbundle``
1989 ``pullbundle``
1982 When set, the server will check pullbundle.manifest for bundles
1990 When set, the server will check pullbundle.manifest for bundles
1983 covering the requested heads and common nodes. The first matching
1991 covering the requested heads and common nodes. The first matching
1984 entry will be streamed to the client.
1992 entry will be streamed to the client.
1985
1993
1986 For HTTP transport, the stream will still use zlib compression
1994 For HTTP transport, the stream will still use zlib compression
1987 for older clients.
1995 for older clients.
1988
1996
1989 ``concurrent-push-mode``
1997 ``concurrent-push-mode``
1990 Level of allowed race condition between two pushing clients.
1998 Level of allowed race condition between two pushing clients.
1991
1999
1992 - 'strict': push is abort if another client touched the repository
2000 - 'strict': push is abort if another client touched the repository
1993 while the push was preparing. (default)
2001 while the push was preparing. (default)
1994 - 'check-related': push is only aborted if it affects head that got also
2002 - 'check-related': push is only aborted if it affects head that got also
1995 affected while the push was preparing.
2003 affected while the push was preparing.
1996
2004
1997 This requires compatible client (version 4.3 and later). Old client will
2005 This requires compatible client (version 4.3 and later). Old client will
1998 use 'strict'.
2006 use 'strict'.
1999
2007
2000 ``validate``
2008 ``validate``
2001 Whether to validate the completeness of pushed changesets by
2009 Whether to validate the completeness of pushed changesets by
2002 checking that all new file revisions specified in manifests are
2010 checking that all new file revisions specified in manifests are
2003 present. (default: False)
2011 present. (default: False)
2004
2012
2005 ``maxhttpheaderlen``
2013 ``maxhttpheaderlen``
2006 Instruct HTTP clients not to send request headers longer than this
2014 Instruct HTTP clients not to send request headers longer than this
2007 many bytes. (default: 1024)
2015 many bytes. (default: 1024)
2008
2016
2009 ``bundle1``
2017 ``bundle1``
2010 Whether to allow clients to push and pull using the legacy bundle1
2018 Whether to allow clients to push and pull using the legacy bundle1
2011 exchange format. (default: True)
2019 exchange format. (default: True)
2012
2020
2013 ``bundle1gd``
2021 ``bundle1gd``
2014 Like ``bundle1`` but only used if the repository is using the
2022 Like ``bundle1`` but only used if the repository is using the
2015 *generaldelta* storage format. (default: True)
2023 *generaldelta* storage format. (default: True)
2016
2024
2017 ``bundle1.push``
2025 ``bundle1.push``
2018 Whether to allow clients to push using the legacy bundle1 exchange
2026 Whether to allow clients to push using the legacy bundle1 exchange
2019 format. (default: True)
2027 format. (default: True)
2020
2028
2021 ``bundle1gd.push``
2029 ``bundle1gd.push``
2022 Like ``bundle1.push`` but only used if the repository is using the
2030 Like ``bundle1.push`` but only used if the repository is using the
2023 *generaldelta* storage format. (default: True)
2031 *generaldelta* storage format. (default: True)
2024
2032
2025 ``bundle1.pull``
2033 ``bundle1.pull``
2026 Whether to allow clients to pull using the legacy bundle1 exchange
2034 Whether to allow clients to pull using the legacy bundle1 exchange
2027 format. (default: True)
2035 format. (default: True)
2028
2036
2029 ``bundle1gd.pull``
2037 ``bundle1gd.pull``
2030 Like ``bundle1.pull`` but only used if the repository is using the
2038 Like ``bundle1.pull`` but only used if the repository is using the
2031 *generaldelta* storage format. (default: True)
2039 *generaldelta* storage format. (default: True)
2032
2040
2033 Large repositories using the *generaldelta* storage format should
2041 Large repositories using the *generaldelta* storage format should
2034 consider setting this option because converting *generaldelta*
2042 consider setting this option because converting *generaldelta*
2035 repositories to the exchange format required by the bundle1 data
2043 repositories to the exchange format required by the bundle1 data
2036 format can consume a lot of CPU.
2044 format can consume a lot of CPU.
2037
2045
2038 ``bundle2.stream``
2046 ``bundle2.stream``
2039 Whether to allow clients to pull using the bundle2 streaming protocol.
2047 Whether to allow clients to pull using the bundle2 streaming protocol.
2040 (default: True)
2048 (default: True)
2041
2049
2042 ``zliblevel``
2050 ``zliblevel``
2043 Integer between ``-1`` and ``9`` that controls the zlib compression level
2051 Integer between ``-1`` and ``9`` that controls the zlib compression level
2044 for wire protocol commands that send zlib compressed output (notably the
2052 for wire protocol commands that send zlib compressed output (notably the
2045 commands that send repository history data).
2053 commands that send repository history data).
2046
2054
2047 The default (``-1``) uses the default zlib compression level, which is
2055 The default (``-1``) uses the default zlib compression level, which is
2048 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
2056 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
2049 maximum compression.
2057 maximum compression.
2050
2058
2051 Setting this option allows server operators to make trade-offs between
2059 Setting this option allows server operators to make trade-offs between
2052 bandwidth and CPU used. Lowering the compression lowers CPU utilization
2060 bandwidth and CPU used. Lowering the compression lowers CPU utilization
2053 but sends more bytes to clients.
2061 but sends more bytes to clients.
2054
2062
2055 This option only impacts the HTTP server.
2063 This option only impacts the HTTP server.
2056
2064
2057 ``zstdlevel``
2065 ``zstdlevel``
2058 Integer between ``1`` and ``22`` that controls the zstd compression level
2066 Integer between ``1`` and ``22`` that controls the zstd compression level
2059 for wire protocol commands. ``1`` is the minimal amount of compression and
2067 for wire protocol commands. ``1`` is the minimal amount of compression and
2060 ``22`` is the highest amount of compression.
2068 ``22`` is the highest amount of compression.
2061
2069
2062 The default (``3``) should be significantly faster than zlib while likely
2070 The default (``3``) should be significantly faster than zlib while likely
2063 delivering better compression ratios.
2071 delivering better compression ratios.
2064
2072
2065 This option only impacts the HTTP server.
2073 This option only impacts the HTTP server.
2066
2074
2067 See also ``server.zliblevel``.
2075 See also ``server.zliblevel``.
2068
2076
2069 ``view``
2077 ``view``
2070 Repository filter used when exchanging revisions with the peer.
2078 Repository filter used when exchanging revisions with the peer.
2071
2079
2072 The default view (``served``) excludes secret and hidden changesets.
2080 The default view (``served``) excludes secret and hidden changesets.
2073 Another useful value is ``immutable`` (no draft, secret or hidden
2081 Another useful value is ``immutable`` (no draft, secret or hidden
2074 changesets). (EXPERIMENTAL)
2082 changesets). (EXPERIMENTAL)
2075
2083
2076 ``smtp``
2084 ``smtp``
2077 --------
2085 --------
2078
2086
2079 Configuration for extensions that need to send email messages.
2087 Configuration for extensions that need to send email messages.
2080
2088
2081 ``host``
2089 ``host``
2082 Host name of mail server, e.g. "mail.example.com".
2090 Host name of mail server, e.g. "mail.example.com".
2083
2091
2084 ``port``
2092 ``port``
2085 Optional. Port to connect to on mail server. (default: 465 if
2093 Optional. Port to connect to on mail server. (default: 465 if
2086 ``tls`` is smtps; 25 otherwise)
2094 ``tls`` is smtps; 25 otherwise)
2087
2095
2088 ``tls``
2096 ``tls``
2089 Optional. Method to enable TLS when connecting to mail server: starttls,
2097 Optional. Method to enable TLS when connecting to mail server: starttls,
2090 smtps or none. (default: none)
2098 smtps or none. (default: none)
2091
2099
2092 ``username``
2100 ``username``
2093 Optional. User name for authenticating with the SMTP server.
2101 Optional. User name for authenticating with the SMTP server.
2094 (default: None)
2102 (default: None)
2095
2103
2096 ``password``
2104 ``password``
2097 Optional. Password for authenticating with the SMTP server. If not
2105 Optional. Password for authenticating with the SMTP server. If not
2098 specified, interactive sessions will prompt the user for a
2106 specified, interactive sessions will prompt the user for a
2099 password; non-interactive sessions will fail. (default: None)
2107 password; non-interactive sessions will fail. (default: None)
2100
2108
2101 ``local_hostname``
2109 ``local_hostname``
2102 Optional. The hostname that the sender can use to identify
2110 Optional. The hostname that the sender can use to identify
2103 itself to the MTA.
2111 itself to the MTA.
2104
2112
2105
2113
2106 ``subpaths``
2114 ``subpaths``
2107 ------------
2115 ------------
2108
2116
2109 Subrepository source URLs can go stale if a remote server changes name
2117 Subrepository source URLs can go stale if a remote server changes name
2110 or becomes temporarily unavailable. This section lets you define
2118 or becomes temporarily unavailable. This section lets you define
2111 rewrite rules of the form::
2119 rewrite rules of the form::
2112
2120
2113 <pattern> = <replacement>
2121 <pattern> = <replacement>
2114
2122
2115 where ``pattern`` is a regular expression matching a subrepository
2123 where ``pattern`` is a regular expression matching a subrepository
2116 source URL and ``replacement`` is the replacement string used to
2124 source URL and ``replacement`` is the replacement string used to
2117 rewrite it. Groups can be matched in ``pattern`` and referenced in
2125 rewrite it. Groups can be matched in ``pattern`` and referenced in
2118 ``replacements``. For instance::
2126 ``replacements``. For instance::
2119
2127
2120 http://server/(.*)-hg/ = http://hg.server/\1/
2128 http://server/(.*)-hg/ = http://hg.server/\1/
2121
2129
2122 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
2130 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
2123
2131
2124 Relative subrepository paths are first made absolute, and the
2132 Relative subrepository paths are first made absolute, and the
2125 rewrite rules are then applied on the full (absolute) path. If ``pattern``
2133 rewrite rules are then applied on the full (absolute) path. If ``pattern``
2126 doesn't match the full path, an attempt is made to apply it on the
2134 doesn't match the full path, an attempt is made to apply it on the
2127 relative path alone. The rules are applied in definition order.
2135 relative path alone. The rules are applied in definition order.
2128
2136
2129 ``subrepos``
2137 ``subrepos``
2130 ------------
2138 ------------
2131
2139
2132 This section contains options that control the behavior of the
2140 This section contains options that control the behavior of the
2133 subrepositories feature. See also :hg:`help subrepos`.
2141 subrepositories feature. See also :hg:`help subrepos`.
2134
2142
2135 Security note: auditing in Mercurial is known to be insufficient to
2143 Security note: auditing in Mercurial is known to be insufficient to
2136 prevent clone-time code execution with carefully constructed Git
2144 prevent clone-time code execution with carefully constructed Git
2137 subrepos. It is unknown if a similar detect is present in Subversion
2145 subrepos. It is unknown if a similar detect is present in Subversion
2138 subrepos. Both Git and Subversion subrepos are disabled by default
2146 subrepos. Both Git and Subversion subrepos are disabled by default
2139 out of security concerns. These subrepo types can be enabled using
2147 out of security concerns. These subrepo types can be enabled using
2140 the respective options below.
2148 the respective options below.
2141
2149
2142 ``allowed``
2150 ``allowed``
2143 Whether subrepositories are allowed in the working directory.
2151 Whether subrepositories are allowed in the working directory.
2144
2152
2145 When false, commands involving subrepositories (like :hg:`update`)
2153 When false, commands involving subrepositories (like :hg:`update`)
2146 will fail for all subrepository types.
2154 will fail for all subrepository types.
2147 (default: true)
2155 (default: true)
2148
2156
2149 ``hg:allowed``
2157 ``hg:allowed``
2150 Whether Mercurial subrepositories are allowed in the working
2158 Whether Mercurial subrepositories are allowed in the working
2151 directory. This option only has an effect if ``subrepos.allowed``
2159 directory. This option only has an effect if ``subrepos.allowed``
2152 is true.
2160 is true.
2153 (default: true)
2161 (default: true)
2154
2162
2155 ``git:allowed``
2163 ``git:allowed``
2156 Whether Git subrepositories are allowed in the working directory.
2164 Whether Git subrepositories are allowed in the working directory.
2157 This option only has an effect if ``subrepos.allowed`` is true.
2165 This option only has an effect if ``subrepos.allowed`` is true.
2158
2166
2159 See the security note above before enabling Git subrepos.
2167 See the security note above before enabling Git subrepos.
2160 (default: false)
2168 (default: false)
2161
2169
2162 ``svn:allowed``
2170 ``svn:allowed``
2163 Whether Subversion subrepositories are allowed in the working
2171 Whether Subversion subrepositories are allowed in the working
2164 directory. This option only has an effect if ``subrepos.allowed``
2172 directory. This option only has an effect if ``subrepos.allowed``
2165 is true.
2173 is true.
2166
2174
2167 See the security note above before enabling Subversion subrepos.
2175 See the security note above before enabling Subversion subrepos.
2168 (default: false)
2176 (default: false)
2169
2177
2170 ``templatealias``
2178 ``templatealias``
2171 -----------------
2179 -----------------
2172
2180
2173 Alias definitions for templates. See :hg:`help templates` for details.
2181 Alias definitions for templates. See :hg:`help templates` for details.
2174
2182
2175 ``templates``
2183 ``templates``
2176 -------------
2184 -------------
2177
2185
2178 Use the ``[templates]`` section to define template strings.
2186 Use the ``[templates]`` section to define template strings.
2179 See :hg:`help templates` for details.
2187 See :hg:`help templates` for details.
2180
2188
2181 ``trusted``
2189 ``trusted``
2182 -----------
2190 -----------
2183
2191
2184 Mercurial will not use the settings in the
2192 Mercurial will not use the settings in the
2185 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
2193 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
2186 user or to a trusted group, as various hgrc features allow arbitrary
2194 user or to a trusted group, as various hgrc features allow arbitrary
2187 commands to be run. This issue is often encountered when configuring
2195 commands to be run. This issue is often encountered when configuring
2188 hooks or extensions for shared repositories or servers. However,
2196 hooks or extensions for shared repositories or servers. However,
2189 the web interface will use some safe settings from the ``[web]``
2197 the web interface will use some safe settings from the ``[web]``
2190 section.
2198 section.
2191
2199
2192 This section specifies what users and groups are trusted. The
2200 This section specifies what users and groups are trusted. The
2193 current user is always trusted. To trust everybody, list a user or a
2201 current user is always trusted. To trust everybody, list a user or a
2194 group with name ``*``. These settings must be placed in an
2202 group with name ``*``. These settings must be placed in an
2195 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2203 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2196 user or service running Mercurial.
2204 user or service running Mercurial.
2197
2205
2198 ``users``
2206 ``users``
2199 Comma-separated list of trusted users.
2207 Comma-separated list of trusted users.
2200
2208
2201 ``groups``
2209 ``groups``
2202 Comma-separated list of trusted groups.
2210 Comma-separated list of trusted groups.
2203
2211
2204
2212
2205 ``ui``
2213 ``ui``
2206 ------
2214 ------
2207
2215
2208 User interface controls.
2216 User interface controls.
2209
2217
2210 ``archivemeta``
2218 ``archivemeta``
2211 Whether to include the .hg_archival.txt file containing meta data
2219 Whether to include the .hg_archival.txt file containing meta data
2212 (hashes for the repository base and for tip) in archives created
2220 (hashes for the repository base and for tip) in archives created
2213 by the :hg:`archive` command or downloaded via hgweb.
2221 by the :hg:`archive` command or downloaded via hgweb.
2214 (default: True)
2222 (default: True)
2215
2223
2216 ``askusername``
2224 ``askusername``
2217 Whether to prompt for a username when committing. If True, and
2225 Whether to prompt for a username when committing. If True, and
2218 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2226 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2219 be prompted to enter a username. If no username is entered, the
2227 be prompted to enter a username. If no username is entered, the
2220 default ``USER@HOST`` is used instead.
2228 default ``USER@HOST`` is used instead.
2221 (default: False)
2229 (default: False)
2222
2230
2223 ``clonebundles``
2231 ``clonebundles``
2224 Whether the "clone bundles" feature is enabled.
2232 Whether the "clone bundles" feature is enabled.
2225
2233
2226 When enabled, :hg:`clone` may download and apply a server-advertised
2234 When enabled, :hg:`clone` may download and apply a server-advertised
2227 bundle file from a URL instead of using the normal exchange mechanism.
2235 bundle file from a URL instead of using the normal exchange mechanism.
2228
2236
2229 This can likely result in faster and more reliable clones.
2237 This can likely result in faster and more reliable clones.
2230
2238
2231 (default: True)
2239 (default: True)
2232
2240
2233 ``clonebundlefallback``
2241 ``clonebundlefallback``
2234 Whether failure to apply an advertised "clone bundle" from a server
2242 Whether failure to apply an advertised "clone bundle" from a server
2235 should result in fallback to a regular clone.
2243 should result in fallback to a regular clone.
2236
2244
2237 This is disabled by default because servers advertising "clone
2245 This is disabled by default because servers advertising "clone
2238 bundles" often do so to reduce server load. If advertised bundles
2246 bundles" often do so to reduce server load. If advertised bundles
2239 start mass failing and clients automatically fall back to a regular
2247 start mass failing and clients automatically fall back to a regular
2240 clone, this would add significant and unexpected load to the server
2248 clone, this would add significant and unexpected load to the server
2241 since the server is expecting clone operations to be offloaded to
2249 since the server is expecting clone operations to be offloaded to
2242 pre-generated bundles. Failing fast (the default behavior) ensures
2250 pre-generated bundles. Failing fast (the default behavior) ensures
2243 clients don't overwhelm the server when "clone bundle" application
2251 clients don't overwhelm the server when "clone bundle" application
2244 fails.
2252 fails.
2245
2253
2246 (default: False)
2254 (default: False)
2247
2255
2248 ``clonebundleprefers``
2256 ``clonebundleprefers``
2249 Defines preferences for which "clone bundles" to use.
2257 Defines preferences for which "clone bundles" to use.
2250
2258
2251 Servers advertising "clone bundles" may advertise multiple available
2259 Servers advertising "clone bundles" may advertise multiple available
2252 bundles. Each bundle may have different attributes, such as the bundle
2260 bundles. Each bundle may have different attributes, such as the bundle
2253 type and compression format. This option is used to prefer a particular
2261 type and compression format. This option is used to prefer a particular
2254 bundle over another.
2262 bundle over another.
2255
2263
2256 The following keys are defined by Mercurial:
2264 The following keys are defined by Mercurial:
2257
2265
2258 BUNDLESPEC
2266 BUNDLESPEC
2259 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2267 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2260 e.g. ``gzip-v2`` or ``bzip2-v1``.
2268 e.g. ``gzip-v2`` or ``bzip2-v1``.
2261
2269
2262 COMPRESSION
2270 COMPRESSION
2263 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2271 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2264
2272
2265 Server operators may define custom keys.
2273 Server operators may define custom keys.
2266
2274
2267 Example values: ``COMPRESSION=bzip2``,
2275 Example values: ``COMPRESSION=bzip2``,
2268 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2276 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2269
2277
2270 By default, the first bundle advertised by the server is used.
2278 By default, the first bundle advertised by the server is used.
2271
2279
2272 ``color``
2280 ``color``
2273 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2281 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2274 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2282 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2275 seems possible. See :hg:`help color` for details.
2283 seems possible. See :hg:`help color` for details.
2276
2284
2277 ``commitsubrepos``
2285 ``commitsubrepos``
2278 Whether to commit modified subrepositories when committing the
2286 Whether to commit modified subrepositories when committing the
2279 parent repository. If False and one subrepository has uncommitted
2287 parent repository. If False and one subrepository has uncommitted
2280 changes, abort the commit.
2288 changes, abort the commit.
2281 (default: False)
2289 (default: False)
2282
2290
2283 ``debug``
2291 ``debug``
2284 Print debugging information. (default: False)
2292 Print debugging information. (default: False)
2285
2293
2286 ``editor``
2294 ``editor``
2287 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2295 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2288
2296
2289 ``fallbackencoding``
2297 ``fallbackencoding``
2290 Encoding to try if it's not possible to decode the changelog using
2298 Encoding to try if it's not possible to decode the changelog using
2291 UTF-8. (default: ISO-8859-1)
2299 UTF-8. (default: ISO-8859-1)
2292
2300
2293 ``graphnodetemplate``
2301 ``graphnodetemplate``
2294 The template used to print changeset nodes in an ASCII revision graph.
2302 The template used to print changeset nodes in an ASCII revision graph.
2295 (default: ``{graphnode}``)
2303 (default: ``{graphnode}``)
2296
2304
2297 ``ignore``
2305 ``ignore``
2298 A file to read per-user ignore patterns from. This file should be
2306 A file to read per-user ignore patterns from. This file should be
2299 in the same format as a repository-wide .hgignore file. Filenames
2307 in the same format as a repository-wide .hgignore file. Filenames
2300 are relative to the repository root. This option supports hook syntax,
2308 are relative to the repository root. This option supports hook syntax,
2301 so if you want to specify multiple ignore files, you can do so by
2309 so if you want to specify multiple ignore files, you can do so by
2302 setting something like ``ignore.other = ~/.hgignore2``. For details
2310 setting something like ``ignore.other = ~/.hgignore2``. For details
2303 of the ignore file format, see the ``hgignore(5)`` man page.
2311 of the ignore file format, see the ``hgignore(5)`` man page.
2304
2312
2305 ``interactive``
2313 ``interactive``
2306 Allow to prompt the user. (default: True)
2314 Allow to prompt the user. (default: True)
2307
2315
2308 ``interface``
2316 ``interface``
2309 Select the default interface for interactive features (default: text).
2317 Select the default interface for interactive features (default: text).
2310 Possible values are 'text' and 'curses'.
2318 Possible values are 'text' and 'curses'.
2311
2319
2312 ``interface.chunkselector``
2320 ``interface.chunkselector``
2313 Select the interface for change recording (e.g. :hg:`commit -i`).
2321 Select the interface for change recording (e.g. :hg:`commit -i`).
2314 Possible values are 'text' and 'curses'.
2322 Possible values are 'text' and 'curses'.
2315 This config overrides the interface specified by ui.interface.
2323 This config overrides the interface specified by ui.interface.
2316
2324
2317 ``large-file-limit``
2325 ``large-file-limit``
2318 Largest file size that gives no memory use warning.
2326 Largest file size that gives no memory use warning.
2319 Possible values are integers or 0 to disable the check.
2327 Possible values are integers or 0 to disable the check.
2320 (default: 10000000)
2328 (default: 10000000)
2321
2329
2322 ``logtemplate``
2330 ``logtemplate``
2323 Template string for commands that print changesets.
2331 Template string for commands that print changesets.
2324
2332
2325 ``merge``
2333 ``merge``
2326 The conflict resolution program to use during a manual merge.
2334 The conflict resolution program to use during a manual merge.
2327 For more information on merge tools see :hg:`help merge-tools`.
2335 For more information on merge tools see :hg:`help merge-tools`.
2328 For configuring merge tools see the ``[merge-tools]`` section.
2336 For configuring merge tools see the ``[merge-tools]`` section.
2329
2337
2330 ``mergemarkers``
2338 ``mergemarkers``
2331 Sets the merge conflict marker label styling. The ``detailed``
2339 Sets the merge conflict marker label styling. The ``detailed``
2332 style uses the ``mergemarkertemplate`` setting to style the labels.
2340 style uses the ``mergemarkertemplate`` setting to style the labels.
2333 The ``basic`` style just uses 'local' and 'other' as the marker label.
2341 The ``basic`` style just uses 'local' and 'other' as the marker label.
2334 One of ``basic`` or ``detailed``.
2342 One of ``basic`` or ``detailed``.
2335 (default: ``basic``)
2343 (default: ``basic``)
2336
2344
2337 ``mergemarkertemplate``
2345 ``mergemarkertemplate``
2338 The template used to print the commit description next to each conflict
2346 The template used to print the commit description next to each conflict
2339 marker during merge conflicts. See :hg:`help templates` for the template
2347 marker during merge conflicts. See :hg:`help templates` for the template
2340 format.
2348 format.
2341
2349
2342 Defaults to showing the hash, tags, branches, bookmarks, author, and
2350 Defaults to showing the hash, tags, branches, bookmarks, author, and
2343 the first line of the commit description.
2351 the first line of the commit description.
2344
2352
2345 If you use non-ASCII characters in names for tags, branches, bookmarks,
2353 If you use non-ASCII characters in names for tags, branches, bookmarks,
2346 authors, and/or commit descriptions, you must pay attention to encodings of
2354 authors, and/or commit descriptions, you must pay attention to encodings of
2347 managed files. At template expansion, non-ASCII characters use the encoding
2355 managed files. At template expansion, non-ASCII characters use the encoding
2348 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2356 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2349 environment variables that govern your locale. If the encoding of the merge
2357 environment variables that govern your locale. If the encoding of the merge
2350 markers is different from the encoding of the merged files,
2358 markers is different from the encoding of the merged files,
2351 serious problems may occur.
2359 serious problems may occur.
2352
2360
2353 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2361 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2354
2362
2355 ``message-output``
2363 ``message-output``
2356 Where to write status and error messages. (default: ``stdio``)
2364 Where to write status and error messages. (default: ``stdio``)
2357
2365
2358 ``stderr``
2366 ``stderr``
2359 Everything to stderr.
2367 Everything to stderr.
2360 ``stdio``
2368 ``stdio``
2361 Status to stdout, and error to stderr.
2369 Status to stdout, and error to stderr.
2362
2370
2363 ``origbackuppath``
2371 ``origbackuppath``
2364 The path to a directory used to store generated .orig files. If the path is
2372 The path to a directory used to store generated .orig files. If the path is
2365 not a directory, one will be created. If set, files stored in this
2373 not a directory, one will be created. If set, files stored in this
2366 directory have the same name as the original file and do not have a .orig
2374 directory have the same name as the original file and do not have a .orig
2367 suffix.
2375 suffix.
2368
2376
2369 ``paginate``
2377 ``paginate``
2370 Control the pagination of command output (default: True). See :hg:`help pager`
2378 Control the pagination of command output (default: True). See :hg:`help pager`
2371 for details.
2379 for details.
2372
2380
2373 ``patch``
2381 ``patch``
2374 An optional external tool that ``hg import`` and some extensions
2382 An optional external tool that ``hg import`` and some extensions
2375 will use for applying patches. By default Mercurial uses an
2383 will use for applying patches. By default Mercurial uses an
2376 internal patch utility. The external tool must work as the common
2384 internal patch utility. The external tool must work as the common
2377 Unix ``patch`` program. In particular, it must accept a ``-p``
2385 Unix ``patch`` program. In particular, it must accept a ``-p``
2378 argument to strip patch headers, a ``-d`` argument to specify the
2386 argument to strip patch headers, a ``-d`` argument to specify the
2379 current directory, a file name to patch, and a patch file to take
2387 current directory, a file name to patch, and a patch file to take
2380 from stdin.
2388 from stdin.
2381
2389
2382 It is possible to specify a patch tool together with extra
2390 It is possible to specify a patch tool together with extra
2383 arguments. For example, setting this option to ``patch --merge``
2391 arguments. For example, setting this option to ``patch --merge``
2384 will use the ``patch`` program with its 2-way merge option.
2392 will use the ``patch`` program with its 2-way merge option.
2385
2393
2386 ``portablefilenames``
2394 ``portablefilenames``
2387 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2395 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2388 (default: ``warn``)
2396 (default: ``warn``)
2389
2397
2390 ``warn``
2398 ``warn``
2391 Print a warning message on POSIX platforms, if a file with a non-portable
2399 Print a warning message on POSIX platforms, if a file with a non-portable
2392 filename is added (e.g. a file with a name that can't be created on
2400 filename is added (e.g. a file with a name that can't be created on
2393 Windows because it contains reserved parts like ``AUX``, reserved
2401 Windows because it contains reserved parts like ``AUX``, reserved
2394 characters like ``:``, or would cause a case collision with an existing
2402 characters like ``:``, or would cause a case collision with an existing
2395 file).
2403 file).
2396
2404
2397 ``ignore``
2405 ``ignore``
2398 Don't print a warning.
2406 Don't print a warning.
2399
2407
2400 ``abort``
2408 ``abort``
2401 The command is aborted.
2409 The command is aborted.
2402
2410
2403 ``true``
2411 ``true``
2404 Alias for ``warn``.
2412 Alias for ``warn``.
2405
2413
2406 ``false``
2414 ``false``
2407 Alias for ``ignore``.
2415 Alias for ``ignore``.
2408
2416
2409 .. container:: windows
2417 .. container:: windows
2410
2418
2411 On Windows, this configuration option is ignored and the command aborted.
2419 On Windows, this configuration option is ignored and the command aborted.
2412
2420
2413 ``pre-merge-tool-output-template``
2421 ``pre-merge-tool-output-template``
2414 A template that is printed before executing an external merge tool. This can
2422 A template that is printed before executing an external merge tool. This can
2415 be used to print out additional context that might be useful to have during
2423 be used to print out additional context that might be useful to have during
2416 the conflict resolution, such as the description of the various commits
2424 the conflict resolution, such as the description of the various commits
2417 involved or bookmarks/tags.
2425 involved or bookmarks/tags.
2418
2426
2419 Additional information is available in the ``local`, ``base``, and ``other``
2427 Additional information is available in the ``local`, ``base``, and ``other``
2420 dicts. For example: ``{local.label}``, ``{base.name}``, or
2428 dicts. For example: ``{local.label}``, ``{base.name}``, or
2421 ``{other.islink}``.
2429 ``{other.islink}``.
2422
2430
2423 ``quiet``
2431 ``quiet``
2424 Reduce the amount of output printed.
2432 Reduce the amount of output printed.
2425 (default: False)
2433 (default: False)
2426
2434
2427 ``relative-paths``
2435 ``relative-paths``
2428 Prefer relative paths in the UI.
2436 Prefer relative paths in the UI.
2429
2437
2430 ``remotecmd``
2438 ``remotecmd``
2431 Remote command to use for clone/push/pull operations.
2439 Remote command to use for clone/push/pull operations.
2432 (default: ``hg``)
2440 (default: ``hg``)
2433
2441
2434 ``report_untrusted``
2442 ``report_untrusted``
2435 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2443 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2436 trusted user or group.
2444 trusted user or group.
2437 (default: True)
2445 (default: True)
2438
2446
2439 ``slash``
2447 ``slash``
2440 (Deprecated. Use ``slashpath`` template filter instead.)
2448 (Deprecated. Use ``slashpath`` template filter instead.)
2441
2449
2442 Display paths using a slash (``/``) as the path separator. This
2450 Display paths using a slash (``/``) as the path separator. This
2443 only makes a difference on systems where the default path
2451 only makes a difference on systems where the default path
2444 separator is not the slash character (e.g. Windows uses the
2452 separator is not the slash character (e.g. Windows uses the
2445 backslash character (``\``)).
2453 backslash character (``\``)).
2446 (default: False)
2454 (default: False)
2447
2455
2448 ``statuscopies``
2456 ``statuscopies``
2449 Display copies in the status command.
2457 Display copies in the status command.
2450
2458
2451 ``ssh``
2459 ``ssh``
2452 Command to use for SSH connections. (default: ``ssh``)
2460 Command to use for SSH connections. (default: ``ssh``)
2453
2461
2454 ``ssherrorhint``
2462 ``ssherrorhint``
2455 A hint shown to the user in the case of SSH error (e.g.
2463 A hint shown to the user in the case of SSH error (e.g.
2456 ``Please see http://company/internalwiki/ssh.html``)
2464 ``Please see http://company/internalwiki/ssh.html``)
2457
2465
2458 ``strict``
2466 ``strict``
2459 Require exact command names, instead of allowing unambiguous
2467 Require exact command names, instead of allowing unambiguous
2460 abbreviations. (default: False)
2468 abbreviations. (default: False)
2461
2469
2462 ``style``
2470 ``style``
2463 Name of style to use for command output.
2471 Name of style to use for command output.
2464
2472
2465 ``supportcontact``
2473 ``supportcontact``
2466 A URL where users should report a Mercurial traceback. Use this if you are a
2474 A URL where users should report a Mercurial traceback. Use this if you are a
2467 large organisation with its own Mercurial deployment process and crash
2475 large organisation with its own Mercurial deployment process and crash
2468 reports should be addressed to your internal support.
2476 reports should be addressed to your internal support.
2469
2477
2470 ``textwidth``
2478 ``textwidth``
2471 Maximum width of help text. A longer line generated by ``hg help`` or
2479 Maximum width of help text. A longer line generated by ``hg help`` or
2472 ``hg subcommand --help`` will be broken after white space to get this
2480 ``hg subcommand --help`` will be broken after white space to get this
2473 width or the terminal width, whichever comes first.
2481 width or the terminal width, whichever comes first.
2474 A non-positive value will disable this and the terminal width will be
2482 A non-positive value will disable this and the terminal width will be
2475 used. (default: 78)
2483 used. (default: 78)
2476
2484
2477 ``timeout``
2485 ``timeout``
2478 The timeout used when a lock is held (in seconds), a negative value
2486 The timeout used when a lock is held (in seconds), a negative value
2479 means no timeout. (default: 600)
2487 means no timeout. (default: 600)
2480
2488
2481 ``timeout.warn``
2489 ``timeout.warn``
2482 Time (in seconds) before a warning is printed about held lock. A negative
2490 Time (in seconds) before a warning is printed about held lock. A negative
2483 value means no warning. (default: 0)
2491 value means no warning. (default: 0)
2484
2492
2485 ``traceback``
2493 ``traceback``
2486 Mercurial always prints a traceback when an unknown exception
2494 Mercurial always prints a traceback when an unknown exception
2487 occurs. Setting this to True will make Mercurial print a traceback
2495 occurs. Setting this to True will make Mercurial print a traceback
2488 on all exceptions, even those recognized by Mercurial (such as
2496 on all exceptions, even those recognized by Mercurial (such as
2489 IOError or MemoryError). (default: False)
2497 IOError or MemoryError). (default: False)
2490
2498
2491 ``tweakdefaults``
2499 ``tweakdefaults``
2492
2500
2493 By default Mercurial's behavior changes very little from release
2501 By default Mercurial's behavior changes very little from release
2494 to release, but over time the recommended config settings
2502 to release, but over time the recommended config settings
2495 shift. Enable this config to opt in to get automatic tweaks to
2503 shift. Enable this config to opt in to get automatic tweaks to
2496 Mercurial's behavior over time. This config setting will have no
2504 Mercurial's behavior over time. This config setting will have no
2497 effect if ``HGPLAIN`` is set or ``HGPLAINEXCEPT`` is set and does
2505 effect if ``HGPLAIN`` is set or ``HGPLAINEXCEPT`` is set and does
2498 not include ``tweakdefaults``. (default: False)
2506 not include ``tweakdefaults``. (default: False)
2499
2507
2500 It currently means::
2508 It currently means::
2501
2509
2502 .. tweakdefaultsmarker
2510 .. tweakdefaultsmarker
2503
2511
2504 ``username``
2512 ``username``
2505 The committer of a changeset created when running "commit".
2513 The committer of a changeset created when running "commit".
2506 Typically a person's name and email address, e.g. ``Fred Widget
2514 Typically a person's name and email address, e.g. ``Fred Widget
2507 <fred@example.com>``. Environment variables in the
2515 <fred@example.com>``. Environment variables in the
2508 username are expanded.
2516 username are expanded.
2509
2517
2510 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2518 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2511 hgrc is empty, e.g. if the system admin set ``username =`` in the
2519 hgrc is empty, e.g. if the system admin set ``username =`` in the
2512 system hgrc, it has to be specified manually or in a different
2520 system hgrc, it has to be specified manually or in a different
2513 hgrc file)
2521 hgrc file)
2514
2522
2515 ``verbose``
2523 ``verbose``
2516 Increase the amount of output printed. (default: False)
2524 Increase the amount of output printed. (default: False)
2517
2525
2518
2526
2519 ``web``
2527 ``web``
2520 -------
2528 -------
2521
2529
2522 Web interface configuration. The settings in this section apply to
2530 Web interface configuration. The settings in this section apply to
2523 both the builtin webserver (started by :hg:`serve`) and the script you
2531 both the builtin webserver (started by :hg:`serve`) and the script you
2524 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2532 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2525 and WSGI).
2533 and WSGI).
2526
2534
2527 The Mercurial webserver does no authentication (it does not prompt for
2535 The Mercurial webserver does no authentication (it does not prompt for
2528 usernames and passwords to validate *who* users are), but it does do
2536 usernames and passwords to validate *who* users are), but it does do
2529 authorization (it grants or denies access for *authenticated users*
2537 authorization (it grants or denies access for *authenticated users*
2530 based on settings in this section). You must either configure your
2538 based on settings in this section). You must either configure your
2531 webserver to do authentication for you, or disable the authorization
2539 webserver to do authentication for you, or disable the authorization
2532 checks.
2540 checks.
2533
2541
2534 For a quick setup in a trusted environment, e.g., a private LAN, where
2542 For a quick setup in a trusted environment, e.g., a private LAN, where
2535 you want it to accept pushes from anybody, you can use the following
2543 you want it to accept pushes from anybody, you can use the following
2536 command line::
2544 command line::
2537
2545
2538 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2546 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2539
2547
2540 Note that this will allow anybody to push anything to the server and
2548 Note that this will allow anybody to push anything to the server and
2541 that this should not be used for public servers.
2549 that this should not be used for public servers.
2542
2550
2543 The full set of options is:
2551 The full set of options is:
2544
2552
2545 ``accesslog``
2553 ``accesslog``
2546 Where to output the access log. (default: stdout)
2554 Where to output the access log. (default: stdout)
2547
2555
2548 ``address``
2556 ``address``
2549 Interface address to bind to. (default: all)
2557 Interface address to bind to. (default: all)
2550
2558
2551 ``allow-archive``
2559 ``allow-archive``
2552 List of archive format (bz2, gz, zip) allowed for downloading.
2560 List of archive format (bz2, gz, zip) allowed for downloading.
2553 (default: empty)
2561 (default: empty)
2554
2562
2555 ``allowbz2``
2563 ``allowbz2``
2556 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2564 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2557 revisions.
2565 revisions.
2558 (default: False)
2566 (default: False)
2559
2567
2560 ``allowgz``
2568 ``allowgz``
2561 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2569 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2562 revisions.
2570 revisions.
2563 (default: False)
2571 (default: False)
2564
2572
2565 ``allow-pull``
2573 ``allow-pull``
2566 Whether to allow pulling from the repository. (default: True)
2574 Whether to allow pulling from the repository. (default: True)
2567
2575
2568 ``allow-push``
2576 ``allow-push``
2569 Whether to allow pushing to the repository. If empty or not set,
2577 Whether to allow pushing to the repository. If empty or not set,
2570 pushing is not allowed. If the special value ``*``, any remote
2578 pushing is not allowed. If the special value ``*``, any remote
2571 user can push, including unauthenticated users. Otherwise, the
2579 user can push, including unauthenticated users. Otherwise, the
2572 remote user must have been authenticated, and the authenticated
2580 remote user must have been authenticated, and the authenticated
2573 user name must be present in this list. The contents of the
2581 user name must be present in this list. The contents of the
2574 allow-push list are examined after the deny_push list.
2582 allow-push list are examined after the deny_push list.
2575
2583
2576 ``allow_read``
2584 ``allow_read``
2577 If the user has not already been denied repository access due to
2585 If the user has not already been denied repository access due to
2578 the contents of deny_read, this list determines whether to grant
2586 the contents of deny_read, this list determines whether to grant
2579 repository access to the user. If this list is not empty, and the
2587 repository access to the user. If this list is not empty, and the
2580 user is unauthenticated or not present in the list, then access is
2588 user is unauthenticated or not present in the list, then access is
2581 denied for the user. If the list is empty or not set, then access
2589 denied for the user. If the list is empty or not set, then access
2582 is permitted to all users by default. Setting allow_read to the
2590 is permitted to all users by default. Setting allow_read to the
2583 special value ``*`` is equivalent to it not being set (i.e. access
2591 special value ``*`` is equivalent to it not being set (i.e. access
2584 is permitted to all users). The contents of the allow_read list are
2592 is permitted to all users). The contents of the allow_read list are
2585 examined after the deny_read list.
2593 examined after the deny_read list.
2586
2594
2587 ``allowzip``
2595 ``allowzip``
2588 (DEPRECATED) Whether to allow .zip downloading of repository
2596 (DEPRECATED) Whether to allow .zip downloading of repository
2589 revisions. This feature creates temporary files.
2597 revisions. This feature creates temporary files.
2590 (default: False)
2598 (default: False)
2591
2599
2592 ``archivesubrepos``
2600 ``archivesubrepos``
2593 Whether to recurse into subrepositories when archiving.
2601 Whether to recurse into subrepositories when archiving.
2594 (default: False)
2602 (default: False)
2595
2603
2596 ``baseurl``
2604 ``baseurl``
2597 Base URL to use when publishing URLs in other locations, so
2605 Base URL to use when publishing URLs in other locations, so
2598 third-party tools like email notification hooks can construct
2606 third-party tools like email notification hooks can construct
2599 URLs. Example: ``http://hgserver/repos/``.
2607 URLs. Example: ``http://hgserver/repos/``.
2600
2608
2601 ``cacerts``
2609 ``cacerts``
2602 Path to file containing a list of PEM encoded certificate
2610 Path to file containing a list of PEM encoded certificate
2603 authority certificates. Environment variables and ``~user``
2611 authority certificates. Environment variables and ``~user``
2604 constructs are expanded in the filename. If specified on the
2612 constructs are expanded in the filename. If specified on the
2605 client, then it will verify the identity of remote HTTPS servers
2613 client, then it will verify the identity of remote HTTPS servers
2606 with these certificates.
2614 with these certificates.
2607
2615
2608 To disable SSL verification temporarily, specify ``--insecure`` from
2616 To disable SSL verification temporarily, specify ``--insecure`` from
2609 command line.
2617 command line.
2610
2618
2611 You can use OpenSSL's CA certificate file if your platform has
2619 You can use OpenSSL's CA certificate file if your platform has
2612 one. On most Linux systems this will be
2620 one. On most Linux systems this will be
2613 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2621 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2614 generate this file manually. The form must be as follows::
2622 generate this file manually. The form must be as follows::
2615
2623
2616 -----BEGIN CERTIFICATE-----
2624 -----BEGIN CERTIFICATE-----
2617 ... (certificate in base64 PEM encoding) ...
2625 ... (certificate in base64 PEM encoding) ...
2618 -----END CERTIFICATE-----
2626 -----END CERTIFICATE-----
2619 -----BEGIN CERTIFICATE-----
2627 -----BEGIN CERTIFICATE-----
2620 ... (certificate in base64 PEM encoding) ...
2628 ... (certificate in base64 PEM encoding) ...
2621 -----END CERTIFICATE-----
2629 -----END CERTIFICATE-----
2622
2630
2623 ``cache``
2631 ``cache``
2624 Whether to support caching in hgweb. (default: True)
2632 Whether to support caching in hgweb. (default: True)
2625
2633
2626 ``certificate``
2634 ``certificate``
2627 Certificate to use when running :hg:`serve`.
2635 Certificate to use when running :hg:`serve`.
2628
2636
2629 ``collapse``
2637 ``collapse``
2630 With ``descend`` enabled, repositories in subdirectories are shown at
2638 With ``descend`` enabled, repositories in subdirectories are shown at
2631 a single level alongside repositories in the current path. With
2639 a single level alongside repositories in the current path. With
2632 ``collapse`` also enabled, repositories residing at a deeper level than
2640 ``collapse`` also enabled, repositories residing at a deeper level than
2633 the current path are grouped behind navigable directory entries that
2641 the current path are grouped behind navigable directory entries that
2634 lead to the locations of these repositories. In effect, this setting
2642 lead to the locations of these repositories. In effect, this setting
2635 collapses each collection of repositories found within a subdirectory
2643 collapses each collection of repositories found within a subdirectory
2636 into a single entry for that subdirectory. (default: False)
2644 into a single entry for that subdirectory. (default: False)
2637
2645
2638 ``comparisoncontext``
2646 ``comparisoncontext``
2639 Number of lines of context to show in side-by-side file comparison. If
2647 Number of lines of context to show in side-by-side file comparison. If
2640 negative or the value ``full``, whole files are shown. (default: 5)
2648 negative or the value ``full``, whole files are shown. (default: 5)
2641
2649
2642 This setting can be overridden by a ``context`` request parameter to the
2650 This setting can be overridden by a ``context`` request parameter to the
2643 ``comparison`` command, taking the same values.
2651 ``comparison`` command, taking the same values.
2644
2652
2645 ``contact``
2653 ``contact``
2646 Name or email address of the person in charge of the repository.
2654 Name or email address of the person in charge of the repository.
2647 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2655 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2648
2656
2649 ``csp``
2657 ``csp``
2650 Send a ``Content-Security-Policy`` HTTP header with this value.
2658 Send a ``Content-Security-Policy`` HTTP header with this value.
2651
2659
2652 The value may contain a special string ``%nonce%``, which will be replaced
2660 The value may contain a special string ``%nonce%``, which will be replaced
2653 by a randomly-generated one-time use value. If the value contains
2661 by a randomly-generated one-time use value. If the value contains
2654 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2662 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2655 one-time property of the nonce. This nonce will also be inserted into
2663 one-time property of the nonce. This nonce will also be inserted into
2656 ``<script>`` elements containing inline JavaScript.
2664 ``<script>`` elements containing inline JavaScript.
2657
2665
2658 Note: lots of HTML content sent by the server is derived from repository
2666 Note: lots of HTML content sent by the server is derived from repository
2659 data. Please consider the potential for malicious repository data to
2667 data. Please consider the potential for malicious repository data to
2660 "inject" itself into generated HTML content as part of your security
2668 "inject" itself into generated HTML content as part of your security
2661 threat model.
2669 threat model.
2662
2670
2663 ``deny_push``
2671 ``deny_push``
2664 Whether to deny pushing to the repository. If empty or not set,
2672 Whether to deny pushing to the repository. If empty or not set,
2665 push is not denied. If the special value ``*``, all remote users are
2673 push is not denied. If the special value ``*``, all remote users are
2666 denied push. Otherwise, unauthenticated users are all denied, and
2674 denied push. Otherwise, unauthenticated users are all denied, and
2667 any authenticated user name present in this list is also denied. The
2675 any authenticated user name present in this list is also denied. The
2668 contents of the deny_push list are examined before the allow-push list.
2676 contents of the deny_push list are examined before the allow-push list.
2669
2677
2670 ``deny_read``
2678 ``deny_read``
2671 Whether to deny reading/viewing of the repository. If this list is
2679 Whether to deny reading/viewing of the repository. If this list is
2672 not empty, unauthenticated users are all denied, and any
2680 not empty, unauthenticated users are all denied, and any
2673 authenticated user name present in this list is also denied access to
2681 authenticated user name present in this list is also denied access to
2674 the repository. If set to the special value ``*``, all remote users
2682 the repository. If set to the special value ``*``, all remote users
2675 are denied access (rarely needed ;). If deny_read is empty or not set,
2683 are denied access (rarely needed ;). If deny_read is empty or not set,
2676 the determination of repository access depends on the presence and
2684 the determination of repository access depends on the presence and
2677 content of the allow_read list (see description). If both
2685 content of the allow_read list (see description). If both
2678 deny_read and allow_read are empty or not set, then access is
2686 deny_read and allow_read are empty or not set, then access is
2679 permitted to all users by default. If the repository is being
2687 permitted to all users by default. If the repository is being
2680 served via hgwebdir, denied users will not be able to see it in
2688 served via hgwebdir, denied users will not be able to see it in
2681 the list of repositories. The contents of the deny_read list have
2689 the list of repositories. The contents of the deny_read list have
2682 priority over (are examined before) the contents of the allow_read
2690 priority over (are examined before) the contents of the allow_read
2683 list.
2691 list.
2684
2692
2685 ``descend``
2693 ``descend``
2686 hgwebdir indexes will not descend into subdirectories. Only repositories
2694 hgwebdir indexes will not descend into subdirectories. Only repositories
2687 directly in the current path will be shown (other repositories are still
2695 directly in the current path will be shown (other repositories are still
2688 available from the index corresponding to their containing path).
2696 available from the index corresponding to their containing path).
2689
2697
2690 ``description``
2698 ``description``
2691 Textual description of the repository's purpose or contents.
2699 Textual description of the repository's purpose or contents.
2692 (default: "unknown")
2700 (default: "unknown")
2693
2701
2694 ``encoding``
2702 ``encoding``
2695 Character encoding name. (default: the current locale charset)
2703 Character encoding name. (default: the current locale charset)
2696 Example: "UTF-8".
2704 Example: "UTF-8".
2697
2705
2698 ``errorlog``
2706 ``errorlog``
2699 Where to output the error log. (default: stderr)
2707 Where to output the error log. (default: stderr)
2700
2708
2701 ``guessmime``
2709 ``guessmime``
2702 Control MIME types for raw download of file content.
2710 Control MIME types for raw download of file content.
2703 Set to True to let hgweb guess the content type from the file
2711 Set to True to let hgweb guess the content type from the file
2704 extension. This will serve HTML files as ``text/html`` and might
2712 extension. This will serve HTML files as ``text/html`` and might
2705 allow cross-site scripting attacks when serving untrusted
2713 allow cross-site scripting attacks when serving untrusted
2706 repositories. (default: False)
2714 repositories. (default: False)
2707
2715
2708 ``hidden``
2716 ``hidden``
2709 Whether to hide the repository in the hgwebdir index.
2717 Whether to hide the repository in the hgwebdir index.
2710 (default: False)
2718 (default: False)
2711
2719
2712 ``ipv6``
2720 ``ipv6``
2713 Whether to use IPv6. (default: False)
2721 Whether to use IPv6. (default: False)
2714
2722
2715 ``labels``
2723 ``labels``
2716 List of string *labels* associated with the repository.
2724 List of string *labels* associated with the repository.
2717
2725
2718 Labels are exposed as a template keyword and can be used to customize
2726 Labels are exposed as a template keyword and can be used to customize
2719 output. e.g. the ``index`` template can group or filter repositories
2727 output. e.g. the ``index`` template can group or filter repositories
2720 by labels and the ``summary`` template can display additional content
2728 by labels and the ``summary`` template can display additional content
2721 if a specific label is present.
2729 if a specific label is present.
2722
2730
2723 ``logoimg``
2731 ``logoimg``
2724 File name of the logo image that some templates display on each page.
2732 File name of the logo image that some templates display on each page.
2725 The file name is relative to ``staticurl``. That is, the full path to
2733 The file name is relative to ``staticurl``. That is, the full path to
2726 the logo image is "staticurl/logoimg".
2734 the logo image is "staticurl/logoimg".
2727 If unset, ``hglogo.png`` will be used.
2735 If unset, ``hglogo.png`` will be used.
2728
2736
2729 ``logourl``
2737 ``logourl``
2730 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2738 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2731 will be used.
2739 will be used.
2732
2740
2733 ``maxchanges``
2741 ``maxchanges``
2734 Maximum number of changes to list on the changelog. (default: 10)
2742 Maximum number of changes to list on the changelog. (default: 10)
2735
2743
2736 ``maxfiles``
2744 ``maxfiles``
2737 Maximum number of files to list per changeset. (default: 10)
2745 Maximum number of files to list per changeset. (default: 10)
2738
2746
2739 ``maxshortchanges``
2747 ``maxshortchanges``
2740 Maximum number of changes to list on the shortlog, graph or filelog
2748 Maximum number of changes to list on the shortlog, graph or filelog
2741 pages. (default: 60)
2749 pages. (default: 60)
2742
2750
2743 ``name``
2751 ``name``
2744 Repository name to use in the web interface.
2752 Repository name to use in the web interface.
2745 (default: current working directory)
2753 (default: current working directory)
2746
2754
2747 ``port``
2755 ``port``
2748 Port to listen on. (default: 8000)
2756 Port to listen on. (default: 8000)
2749
2757
2750 ``prefix``
2758 ``prefix``
2751 Prefix path to serve from. (default: '' (server root))
2759 Prefix path to serve from. (default: '' (server root))
2752
2760
2753 ``push_ssl``
2761 ``push_ssl``
2754 Whether to require that inbound pushes be transported over SSL to
2762 Whether to require that inbound pushes be transported over SSL to
2755 prevent password sniffing. (default: True)
2763 prevent password sniffing. (default: True)
2756
2764
2757 ``refreshinterval``
2765 ``refreshinterval``
2758 How frequently directory listings re-scan the filesystem for new
2766 How frequently directory listings re-scan the filesystem for new
2759 repositories, in seconds. This is relevant when wildcards are used
2767 repositories, in seconds. This is relevant when wildcards are used
2760 to define paths. Depending on how much filesystem traversal is
2768 to define paths. Depending on how much filesystem traversal is
2761 required, refreshing may negatively impact performance.
2769 required, refreshing may negatively impact performance.
2762
2770
2763 Values less than or equal to 0 always refresh.
2771 Values less than or equal to 0 always refresh.
2764 (default: 20)
2772 (default: 20)
2765
2773
2766 ``server-header``
2774 ``server-header``
2767 Value for HTTP ``Server`` response header.
2775 Value for HTTP ``Server`` response header.
2768
2776
2769 ``static``
2777 ``static``
2770 Directory where static files are served from.
2778 Directory where static files are served from.
2771
2779
2772 ``staticurl``
2780 ``staticurl``
2773 Base URL to use for static files. If unset, static files (e.g. the
2781 Base URL to use for static files. If unset, static files (e.g. the
2774 hgicon.png favicon) will be served by the CGI script itself. Use
2782 hgicon.png favicon) will be served by the CGI script itself. Use
2775 this setting to serve them directly with the HTTP server.
2783 this setting to serve them directly with the HTTP server.
2776 Example: ``http://hgserver/static/``.
2784 Example: ``http://hgserver/static/``.
2777
2785
2778 ``stripes``
2786 ``stripes``
2779 How many lines a "zebra stripe" should span in multi-line output.
2787 How many lines a "zebra stripe" should span in multi-line output.
2780 Set to 0 to disable. (default: 1)
2788 Set to 0 to disable. (default: 1)
2781
2789
2782 ``style``
2790 ``style``
2783 Which template map style to use. The available options are the names of
2791 Which template map style to use. The available options are the names of
2784 subdirectories in the HTML templates path. (default: ``paper``)
2792 subdirectories in the HTML templates path. (default: ``paper``)
2785 Example: ``monoblue``.
2793 Example: ``monoblue``.
2786
2794
2787 ``templates``
2795 ``templates``
2788 Where to find the HTML templates. The default path to the HTML templates
2796 Where to find the HTML templates. The default path to the HTML templates
2789 can be obtained from ``hg debuginstall``.
2797 can be obtained from ``hg debuginstall``.
2790
2798
2791 ``websub``
2799 ``websub``
2792 ----------
2800 ----------
2793
2801
2794 Web substitution filter definition. You can use this section to
2802 Web substitution filter definition. You can use this section to
2795 define a set of regular expression substitution patterns which
2803 define a set of regular expression substitution patterns which
2796 let you automatically modify the hgweb server output.
2804 let you automatically modify the hgweb server output.
2797
2805
2798 The default hgweb templates only apply these substitution patterns
2806 The default hgweb templates only apply these substitution patterns
2799 on the revision description fields. You can apply them anywhere
2807 on the revision description fields. You can apply them anywhere
2800 you want when you create your own templates by adding calls to the
2808 you want when you create your own templates by adding calls to the
2801 "websub" filter (usually after calling the "escape" filter).
2809 "websub" filter (usually after calling the "escape" filter).
2802
2810
2803 This can be used, for example, to convert issue references to links
2811 This can be used, for example, to convert issue references to links
2804 to your issue tracker, or to convert "markdown-like" syntax into
2812 to your issue tracker, or to convert "markdown-like" syntax into
2805 HTML (see the examples below).
2813 HTML (see the examples below).
2806
2814
2807 Each entry in this section names a substitution filter.
2815 Each entry in this section names a substitution filter.
2808 The value of each entry defines the substitution expression itself.
2816 The value of each entry defines the substitution expression itself.
2809 The websub expressions follow the old interhg extension syntax,
2817 The websub expressions follow the old interhg extension syntax,
2810 which in turn imitates the Unix sed replacement syntax::
2818 which in turn imitates the Unix sed replacement syntax::
2811
2819
2812 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2820 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2813
2821
2814 You can use any separator other than "/". The final "i" is optional
2822 You can use any separator other than "/". The final "i" is optional
2815 and indicates that the search must be case insensitive.
2823 and indicates that the search must be case insensitive.
2816
2824
2817 Examples::
2825 Examples::
2818
2826
2819 [websub]
2827 [websub]
2820 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2828 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2821 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2829 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2822 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2830 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2823
2831
2824 ``worker``
2832 ``worker``
2825 ----------
2833 ----------
2826
2834
2827 Parallel master/worker configuration. We currently perform working
2835 Parallel master/worker configuration. We currently perform working
2828 directory updates in parallel on Unix-like systems, which greatly
2836 directory updates in parallel on Unix-like systems, which greatly
2829 helps performance.
2837 helps performance.
2830
2838
2831 ``enabled``
2839 ``enabled``
2832 Whether to enable workers code to be used.
2840 Whether to enable workers code to be used.
2833 (default: true)
2841 (default: true)
2834
2842
2835 ``numcpus``
2843 ``numcpus``
2836 Number of CPUs to use for parallel operations. A zero or
2844 Number of CPUs to use for parallel operations. A zero or
2837 negative value is treated as ``use the default``.
2845 negative value is treated as ``use the default``.
2838 (default: 4 or the number of CPUs on the system, whichever is larger)
2846 (default: 4 or the number of CPUs on the system, whichever is larger)
2839
2847
2840 ``backgroundclose``
2848 ``backgroundclose``
2841 Whether to enable closing file handles on background threads during certain
2849 Whether to enable closing file handles on background threads during certain
2842 operations. Some platforms aren't very efficient at closing file
2850 operations. Some platforms aren't very efficient at closing file
2843 handles that have been written or appended to. By performing file closing
2851 handles that have been written or appended to. By performing file closing
2844 on background threads, file write rate can increase substantially.
2852 on background threads, file write rate can increase substantially.
2845 (default: true on Windows, false elsewhere)
2853 (default: true on Windows, false elsewhere)
2846
2854
2847 ``backgroundcloseminfilecount``
2855 ``backgroundcloseminfilecount``
2848 Minimum number of files required to trigger background file closing.
2856 Minimum number of files required to trigger background file closing.
2849 Operations not writing this many files won't start background close
2857 Operations not writing this many files won't start background close
2850 threads.
2858 threads.
2851 (default: 2048)
2859 (default: 2048)
2852
2860
2853 ``backgroundclosemaxqueue``
2861 ``backgroundclosemaxqueue``
2854 The maximum number of opened file handles waiting to be closed in the
2862 The maximum number of opened file handles waiting to be closed in the
2855 background. This option only has an effect if ``backgroundclose`` is
2863 background. This option only has an effect if ``backgroundclose`` is
2856 enabled.
2864 enabled.
2857 (default: 384)
2865 (default: 384)
2858
2866
2859 ``backgroundclosethreadcount``
2867 ``backgroundclosethreadcount``
2860 Number of threads to process background file closes. Only relevant if
2868 Number of threads to process background file closes. Only relevant if
2861 ``backgroundclose`` is enabled.
2869 ``backgroundclose`` is enabled.
2862 (default: 4)
2870 (default: 4)
@@ -1,350 +1,402 b''
1 ==================================
1 ==================================
2 Basic testing for the push command
2 Basic testing for the push command
3 ==================================
3 ==================================
4
4
5 Testing of the '--rev' flag
5 Testing of the '--rev' flag
6 ===========================
6 ===========================
7
7
8 $ hg init test-revflag
8 $ hg init test-revflag
9 $ hg -R test-revflag unbundle "$TESTDIR/bundles/remote.hg"
9 $ hg -R test-revflag unbundle "$TESTDIR/bundles/remote.hg"
10 adding changesets
10 adding changesets
11 adding manifests
11 adding manifests
12 adding file changes
12 adding file changes
13 added 9 changesets with 7 changes to 4 files (+1 heads)
13 added 9 changesets with 7 changes to 4 files (+1 heads)
14 new changesets bfaf4b5cbf01:916f1afdef90 (9 drafts)
14 new changesets bfaf4b5cbf01:916f1afdef90 (9 drafts)
15 (run 'hg heads' to see heads, 'hg merge' to merge)
15 (run 'hg heads' to see heads, 'hg merge' to merge)
16
16
17 $ for i in 0 1 2 3 4 5 6 7 8; do
17 $ for i in 0 1 2 3 4 5 6 7 8; do
18 > echo
18 > echo
19 > hg init test-revflag-"$i"
19 > hg init test-revflag-"$i"
20 > hg -R test-revflag push -r "$i" test-revflag-"$i"
20 > hg -R test-revflag push -r "$i" test-revflag-"$i"
21 > hg -R test-revflag-"$i" verify
21 > hg -R test-revflag-"$i" verify
22 > done
22 > done
23
23
24 pushing to test-revflag-0
24 pushing to test-revflag-0
25 searching for changes
25 searching for changes
26 adding changesets
26 adding changesets
27 adding manifests
27 adding manifests
28 adding file changes
28 adding file changes
29 added 1 changesets with 1 changes to 1 files
29 added 1 changesets with 1 changes to 1 files
30 checking changesets
30 checking changesets
31 checking manifests
31 checking manifests
32 crosschecking files in changesets and manifests
32 crosschecking files in changesets and manifests
33 checking files
33 checking files
34 checked 1 changesets with 1 changes to 1 files
34 checked 1 changesets with 1 changes to 1 files
35
35
36 pushing to test-revflag-1
36 pushing to test-revflag-1
37 searching for changes
37 searching for changes
38 adding changesets
38 adding changesets
39 adding manifests
39 adding manifests
40 adding file changes
40 adding file changes
41 added 2 changesets with 2 changes to 1 files
41 added 2 changesets with 2 changes to 1 files
42 checking changesets
42 checking changesets
43 checking manifests
43 checking manifests
44 crosschecking files in changesets and manifests
44 crosschecking files in changesets and manifests
45 checking files
45 checking files
46 checked 2 changesets with 2 changes to 1 files
46 checked 2 changesets with 2 changes to 1 files
47
47
48 pushing to test-revflag-2
48 pushing to test-revflag-2
49 searching for changes
49 searching for changes
50 adding changesets
50 adding changesets
51 adding manifests
51 adding manifests
52 adding file changes
52 adding file changes
53 added 3 changesets with 3 changes to 1 files
53 added 3 changesets with 3 changes to 1 files
54 checking changesets
54 checking changesets
55 checking manifests
55 checking manifests
56 crosschecking files in changesets and manifests
56 crosschecking files in changesets and manifests
57 checking files
57 checking files
58 checked 3 changesets with 3 changes to 1 files
58 checked 3 changesets with 3 changes to 1 files
59
59
60 pushing to test-revflag-3
60 pushing to test-revflag-3
61 searching for changes
61 searching for changes
62 adding changesets
62 adding changesets
63 adding manifests
63 adding manifests
64 adding file changes
64 adding file changes
65 added 4 changesets with 4 changes to 1 files
65 added 4 changesets with 4 changes to 1 files
66 checking changesets
66 checking changesets
67 checking manifests
67 checking manifests
68 crosschecking files in changesets and manifests
68 crosschecking files in changesets and manifests
69 checking files
69 checking files
70 checked 4 changesets with 4 changes to 1 files
70 checked 4 changesets with 4 changes to 1 files
71
71
72 pushing to test-revflag-4
72 pushing to test-revflag-4
73 searching for changes
73 searching for changes
74 adding changesets
74 adding changesets
75 adding manifests
75 adding manifests
76 adding file changes
76 adding file changes
77 added 2 changesets with 2 changes to 1 files
77 added 2 changesets with 2 changes to 1 files
78 checking changesets
78 checking changesets
79 checking manifests
79 checking manifests
80 crosschecking files in changesets and manifests
80 crosschecking files in changesets and manifests
81 checking files
81 checking files
82 checked 2 changesets with 2 changes to 1 files
82 checked 2 changesets with 2 changes to 1 files
83
83
84 pushing to test-revflag-5
84 pushing to test-revflag-5
85 searching for changes
85 searching for changes
86 adding changesets
86 adding changesets
87 adding manifests
87 adding manifests
88 adding file changes
88 adding file changes
89 added 3 changesets with 3 changes to 1 files
89 added 3 changesets with 3 changes to 1 files
90 checking changesets
90 checking changesets
91 checking manifests
91 checking manifests
92 crosschecking files in changesets and manifests
92 crosschecking files in changesets and manifests
93 checking files
93 checking files
94 checked 3 changesets with 3 changes to 1 files
94 checked 3 changesets with 3 changes to 1 files
95
95
96 pushing to test-revflag-6
96 pushing to test-revflag-6
97 searching for changes
97 searching for changes
98 adding changesets
98 adding changesets
99 adding manifests
99 adding manifests
100 adding file changes
100 adding file changes
101 added 4 changesets with 5 changes to 2 files
101 added 4 changesets with 5 changes to 2 files
102 checking changesets
102 checking changesets
103 checking manifests
103 checking manifests
104 crosschecking files in changesets and manifests
104 crosschecking files in changesets and manifests
105 checking files
105 checking files
106 checked 4 changesets with 5 changes to 2 files
106 checked 4 changesets with 5 changes to 2 files
107
107
108 pushing to test-revflag-7
108 pushing to test-revflag-7
109 searching for changes
109 searching for changes
110 adding changesets
110 adding changesets
111 adding manifests
111 adding manifests
112 adding file changes
112 adding file changes
113 added 5 changesets with 6 changes to 3 files
113 added 5 changesets with 6 changes to 3 files
114 checking changesets
114 checking changesets
115 checking manifests
115 checking manifests
116 crosschecking files in changesets and manifests
116 crosschecking files in changesets and manifests
117 checking files
117 checking files
118 checked 5 changesets with 6 changes to 3 files
118 checked 5 changesets with 6 changes to 3 files
119
119
120 pushing to test-revflag-8
120 pushing to test-revflag-8
121 searching for changes
121 searching for changes
122 adding changesets
122 adding changesets
123 adding manifests
123 adding manifests
124 adding file changes
124 adding file changes
125 added 5 changesets with 5 changes to 2 files
125 added 5 changesets with 5 changes to 2 files
126 checking changesets
126 checking changesets
127 checking manifests
127 checking manifests
128 crosschecking files in changesets and manifests
128 crosschecking files in changesets and manifests
129 checking files
129 checking files
130 checked 5 changesets with 5 changes to 2 files
130 checked 5 changesets with 5 changes to 2 files
131
131
132 $ cd test-revflag-8
132 $ cd test-revflag-8
133
133
134 $ hg pull ../test-revflag-7
134 $ hg pull ../test-revflag-7
135 pulling from ../test-revflag-7
135 pulling from ../test-revflag-7
136 searching for changes
136 searching for changes
137 adding changesets
137 adding changesets
138 adding manifests
138 adding manifests
139 adding file changes
139 adding file changes
140 added 4 changesets with 2 changes to 3 files (+1 heads)
140 added 4 changesets with 2 changes to 3 files (+1 heads)
141 new changesets c70afb1ee985:faa2e4234c7a
141 new changesets c70afb1ee985:faa2e4234c7a
142 (run 'hg heads' to see heads, 'hg merge' to merge)
142 (run 'hg heads' to see heads, 'hg merge' to merge)
143
143
144 $ hg verify
144 $ hg verify
145 checking changesets
145 checking changesets
146 checking manifests
146 checking manifests
147 crosschecking files in changesets and manifests
147 crosschecking files in changesets and manifests
148 checking files
148 checking files
149 checked 9 changesets with 7 changes to 4 files
149 checked 9 changesets with 7 changes to 4 files
150
150
151 $ cd ..
151 $ cd ..
152
152
153 Test server side validation during push
153 Test server side validation during push
154 =======================================
154 =======================================
155
155
156 $ hg init test-validation
156 $ hg init test-validation
157 $ cd test-validation
157 $ cd test-validation
158
158
159 $ cat > .hg/hgrc <<EOF
159 $ cat > .hg/hgrc <<EOF
160 > [server]
160 > [server]
161 > validate=1
161 > validate=1
162 > EOF
162 > EOF
163
163
164 $ echo alpha > alpha
164 $ echo alpha > alpha
165 $ echo beta > beta
165 $ echo beta > beta
166 $ hg addr
166 $ hg addr
167 adding alpha
167 adding alpha
168 adding beta
168 adding beta
169 $ hg ci -m 1
169 $ hg ci -m 1
170
170
171 $ cd ..
171 $ cd ..
172 $ hg clone test-validation test-validation-clone
172 $ hg clone test-validation test-validation-clone
173 updating to branch default
173 updating to branch default
174 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
174 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
175
175
176 #if reporevlogstore
176 #if reporevlogstore
177
177
178 Test spurious filelog entries:
178 Test spurious filelog entries:
179
179
180 $ cd test-validation-clone
180 $ cd test-validation-clone
181 $ echo blah >> beta
181 $ echo blah >> beta
182 $ cp .hg/store/data/beta.i tmp1
182 $ cp .hg/store/data/beta.i tmp1
183 $ hg ci -m 2
183 $ hg ci -m 2
184 $ cp .hg/store/data/beta.i tmp2
184 $ cp .hg/store/data/beta.i tmp2
185 $ hg -q rollback
185 $ hg -q rollback
186 $ mv tmp2 .hg/store/data/beta.i
186 $ mv tmp2 .hg/store/data/beta.i
187 $ echo blah >> beta
187 $ echo blah >> beta
188 $ hg ci -m '2 (corrupt)'
188 $ hg ci -m '2 (corrupt)'
189
189
190 Expected to fail:
190 Expected to fail:
191
191
192 $ hg verify
192 $ hg verify
193 checking changesets
193 checking changesets
194 checking manifests
194 checking manifests
195 crosschecking files in changesets and manifests
195 crosschecking files in changesets and manifests
196 checking files
196 checking files
197 beta@1: dddc47b3ba30 not in manifests
197 beta@1: dddc47b3ba30 not in manifests
198 checked 2 changesets with 4 changes to 2 files
198 checked 2 changesets with 4 changes to 2 files
199 1 integrity errors encountered!
199 1 integrity errors encountered!
200 (first damaged changeset appears to be 1)
200 (first damaged changeset appears to be 1)
201 [1]
201 [1]
202
202
203 $ hg push
203 $ hg push
204 pushing to $TESTTMP/test-validation
204 pushing to $TESTTMP/test-validation
205 searching for changes
205 searching for changes
206 adding changesets
206 adding changesets
207 adding manifests
207 adding manifests
208 adding file changes
208 adding file changes
209 transaction abort!
209 transaction abort!
210 rollback completed
210 rollback completed
211 abort: received spurious file revlog entry
211 abort: received spurious file revlog entry
212 [255]
212 [255]
213
213
214 $ hg -q rollback
214 $ hg -q rollback
215 $ mv tmp1 .hg/store/data/beta.i
215 $ mv tmp1 .hg/store/data/beta.i
216 $ echo beta > beta
216 $ echo beta > beta
217
217
218 Test missing filelog entries:
218 Test missing filelog entries:
219
219
220 $ cp .hg/store/data/beta.i tmp
220 $ cp .hg/store/data/beta.i tmp
221 $ echo blah >> beta
221 $ echo blah >> beta
222 $ hg ci -m '2 (corrupt)'
222 $ hg ci -m '2 (corrupt)'
223 $ mv tmp .hg/store/data/beta.i
223 $ mv tmp .hg/store/data/beta.i
224
224
225 Expected to fail:
225 Expected to fail:
226
226
227 $ hg verify
227 $ hg verify
228 checking changesets
228 checking changesets
229 checking manifests
229 checking manifests
230 crosschecking files in changesets and manifests
230 crosschecking files in changesets and manifests
231 checking files
231 checking files
232 beta@1: manifest refers to unknown revision dddc47b3ba30
232 beta@1: manifest refers to unknown revision dddc47b3ba30
233 checked 2 changesets with 2 changes to 2 files
233 checked 2 changesets with 2 changes to 2 files
234 1 integrity errors encountered!
234 1 integrity errors encountered!
235 (first damaged changeset appears to be 1)
235 (first damaged changeset appears to be 1)
236 [1]
236 [1]
237
237
238 $ hg push
238 $ hg push
239 pushing to $TESTTMP/test-validation
239 pushing to $TESTTMP/test-validation
240 searching for changes
240 searching for changes
241 adding changesets
241 adding changesets
242 adding manifests
242 adding manifests
243 adding file changes
243 adding file changes
244 transaction abort!
244 transaction abort!
245 rollback completed
245 rollback completed
246 abort: missing file data for beta:dddc47b3ba30e54484720ce0f4f768a0f4b6efb9 - run hg verify
246 abort: missing file data for beta:dddc47b3ba30e54484720ce0f4f768a0f4b6efb9 - run hg verify
247 [255]
247 [255]
248
248
249 $ cd ..
249 $ cd ..
250
250
251 #endif
251 #endif
252
252
253 Test push hook locking
253 Test push hook locking
254 =====================
254 =====================
255
255
256 $ hg init 1
256 $ hg init 1
257
257
258 $ echo '[ui]' >> 1/.hg/hgrc
258 $ echo '[ui]' >> 1/.hg/hgrc
259 $ echo 'timeout = 10' >> 1/.hg/hgrc
259 $ echo 'timeout = 10' >> 1/.hg/hgrc
260
260
261 $ echo foo > 1/foo
261 $ echo foo > 1/foo
262 $ hg --cwd 1 ci -A -m foo
262 $ hg --cwd 1 ci -A -m foo
263 adding foo
263 adding foo
264
264
265 $ hg clone 1 2
265 $ hg clone 1 2
266 updating to branch default
266 updating to branch default
267 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
267 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
268
268
269 $ hg clone 2 3
269 $ hg clone 2 3
270 updating to branch default
270 updating to branch default
271 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
271 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
272
272
273 $ cat <<EOF > $TESTTMP/debuglocks-pretxn-hook.sh
273 $ cat <<EOF > $TESTTMP/debuglocks-pretxn-hook.sh
274 > hg debuglocks
274 > hg debuglocks
275 > true
275 > true
276 > EOF
276 > EOF
277 $ echo '[hooks]' >> 2/.hg/hgrc
277 $ echo '[hooks]' >> 2/.hg/hgrc
278 $ echo "pretxnchangegroup.a = sh $TESTTMP/debuglocks-pretxn-hook.sh" >> 2/.hg/hgrc
278 $ echo "pretxnchangegroup.a = sh $TESTTMP/debuglocks-pretxn-hook.sh" >> 2/.hg/hgrc
279 $ echo 'changegroup.push = hg push -qf ../1' >> 2/.hg/hgrc
279 $ echo 'changegroup.push = hg push -qf ../1' >> 2/.hg/hgrc
280
280
281 $ echo bar >> 3/foo
281 $ echo bar >> 3/foo
282 $ hg --cwd 3 ci -m bar
282 $ hg --cwd 3 ci -m bar
283
283
284 $ hg --cwd 3 push ../2 --config devel.legacy.exchange=bundle1
284 $ hg --cwd 3 push ../2 --config devel.legacy.exchange=bundle1
285 pushing to ../2
285 pushing to ../2
286 searching for changes
286 searching for changes
287 adding changesets
287 adding changesets
288 adding manifests
288 adding manifests
289 adding file changes
289 adding file changes
290 lock: user *, process * (*s) (glob)
290 lock: user *, process * (*s) (glob)
291 wlock: free
291 wlock: free
292 added 1 changesets with 1 changes to 1 files
292 added 1 changesets with 1 changes to 1 files
293
293
294 $ hg --cwd 1 --config extensions.strip= strip tip -q
294 $ hg --cwd 1 --config extensions.strip= strip tip -q
295 $ hg --cwd 2 --config extensions.strip= strip tip -q
295 $ hg --cwd 2 --config extensions.strip= strip tip -q
296 $ hg --cwd 3 push ../2 # bundle2+
296 $ hg --cwd 3 push ../2 # bundle2+
297 pushing to ../2
297 pushing to ../2
298 searching for changes
298 searching for changes
299 adding changesets
299 adding changesets
300 adding manifests
300 adding manifests
301 adding file changes
301 adding file changes
302 lock: user *, process * (*s) (glob)
302 lock: user *, process * (*s) (glob)
303 wlock: user *, process * (*s) (glob)
303 wlock: user *, process * (*s) (glob)
304 added 1 changesets with 1 changes to 1 files
304 added 1 changesets with 1 changes to 1 files
305
305
306 Test bare push with multiple race checking options
306 Test bare push with multiple race checking options
307 --------------------------------------------------
307 --------------------------------------------------
308
308
309 $ hg init test-bare-push-no-concurrency
309 $ hg init test-bare-push-no-concurrency
310 $ hg init test-bare-push-unrelated-concurrency
310 $ hg init test-bare-push-unrelated-concurrency
311 $ hg -R test-revflag push -r 0 test-bare-push-no-concurrency --config server.concurrent-push-mode=strict
311 $ hg -R test-revflag push -r 0 test-bare-push-no-concurrency --config server.concurrent-push-mode=strict
312 pushing to test-bare-push-no-concurrency
312 pushing to test-bare-push-no-concurrency
313 searching for changes
313 searching for changes
314 adding changesets
314 adding changesets
315 adding manifests
315 adding manifests
316 adding file changes
316 adding file changes
317 added 1 changesets with 1 changes to 1 files
317 added 1 changesets with 1 changes to 1 files
318 $ hg -R test-revflag push -r 0 test-bare-push-unrelated-concurrency --config server.concurrent-push-mode=check-related
318 $ hg -R test-revflag push -r 0 test-bare-push-unrelated-concurrency --config server.concurrent-push-mode=check-related
319 pushing to test-bare-push-unrelated-concurrency
319 pushing to test-bare-push-unrelated-concurrency
320 searching for changes
320 searching for changes
321 adding changesets
321 adding changesets
322 adding manifests
322 adding manifests
323 adding file changes
323 adding file changes
324 added 1 changesets with 1 changes to 1 files
324 added 1 changesets with 1 changes to 1 files
325
325
326 SEC: check for unsafe ssh url
326 SEC: check for unsafe ssh url
327
327
328 $ cat >> $HGRCPATH << EOF
328 $ cat >> $HGRCPATH << EOF
329 > [ui]
329 > [ui]
330 > ssh = sh -c "read l; read l; read l"
330 > ssh = sh -c "read l; read l; read l"
331 > EOF
331 > EOF
332
332
333 $ hg -R test-revflag push 'ssh://-oProxyCommand=touch${IFS}owned/path'
333 $ hg -R test-revflag push 'ssh://-oProxyCommand=touch${IFS}owned/path'
334 pushing to ssh://-oProxyCommand%3Dtouch%24%7BIFS%7Downed/path
334 pushing to ssh://-oProxyCommand%3Dtouch%24%7BIFS%7Downed/path
335 abort: potentially unsafe url: 'ssh://-oProxyCommand=touch${IFS}owned/path'
335 abort: potentially unsafe url: 'ssh://-oProxyCommand=touch${IFS}owned/path'
336 [255]
336 [255]
337 $ hg -R test-revflag push 'ssh://%2DoProxyCommand=touch${IFS}owned/path'
337 $ hg -R test-revflag push 'ssh://%2DoProxyCommand=touch${IFS}owned/path'
338 pushing to ssh://-oProxyCommand%3Dtouch%24%7BIFS%7Downed/path
338 pushing to ssh://-oProxyCommand%3Dtouch%24%7BIFS%7Downed/path
339 abort: potentially unsafe url: 'ssh://-oProxyCommand=touch${IFS}owned/path'
339 abort: potentially unsafe url: 'ssh://-oProxyCommand=touch${IFS}owned/path'
340 [255]
340 [255]
341 $ hg -R test-revflag push 'ssh://fakehost|touch${IFS}owned/path'
341 $ hg -R test-revflag push 'ssh://fakehost|touch${IFS}owned/path'
342 pushing to ssh://fakehost%7Ctouch%24%7BIFS%7Downed/path
342 pushing to ssh://fakehost%7Ctouch%24%7BIFS%7Downed/path
343 abort: no suitable response from remote hg!
343 abort: no suitable response from remote hg!
344 [255]
344 [255]
345 $ hg -R test-revflag push 'ssh://fakehost%7Ctouch%20owned/path'
345 $ hg -R test-revflag push 'ssh://fakehost%7Ctouch%20owned/path'
346 pushing to ssh://fakehost%7Ctouch%20owned/path
346 pushing to ssh://fakehost%7Ctouch%20owned/path
347 abort: no suitable response from remote hg!
347 abort: no suitable response from remote hg!
348 [255]
348 [255]
349
349
350 $ [ ! -f owned ] || echo 'you got owned'
350 $ [ ! -f owned ] || echo 'you got owned'
351
352 Test `commands.push.require-revs`
353 ---------------------------------
354
355 $ hg clone -q test-revflag test-require-revs-source
356 $ hg init test-require-revs-dest
357 $ cd test-require-revs-source
358 $ cat >> .hg/hgrc << EOF
359 > [paths]
360 > default = ../test-require-revs-dest
361 > [commands]
362 > push.require-revs=1
363 > EOF
364 $ hg push
365 pushing to $TESTTMP/test-require-revs-dest
366 abort: no revisions specified to push
367 (did you mean "hg push -r ."?)
368 [255]
369 $ hg push -r 0
370 pushing to $TESTTMP/test-require-revs-dest
371 searching for changes
372 adding changesets
373 adding manifests
374 adding file changes
375 added 1 changesets with 1 changes to 1 files
376 $ hg bookmark -r 0 push-this-bookmark
377 (test that -B (bookmark) works for specifying "revs")
378 $ hg push -B push-this-bookmark
379 pushing to $TESTTMP/test-require-revs-dest
380 searching for changes
381 no changes found
382 exporting bookmark push-this-bookmark
383 [1]
384 (test that -b (branch) works for specifying "revs")
385 $ hg push -b default
386 pushing to $TESTTMP/test-require-revs-dest
387 searching for changes
388 abort: push creates new remote head [0-9a-f]+! (re)
389 (merge or see 'hg help push' for details about pushing new heads)
390 [255]
391 (demonstrate that even though we don't have anything to exchange, we're still
392 showing the error)
393 $ hg push
394 pushing to $TESTTMP/test-require-revs-dest
395 abort: no revisions specified to push
396 (did you mean "hg push -r ."?)
397 [255]
398 $ hg push --config paths.default:pushrev=0
399 pushing to $TESTTMP/test-require-revs-dest
400 searching for changes
401 no changes found
402 [1]
General Comments 0
You need to be logged in to leave comments. Login now