##// END OF EJS Templates
status: add a config knob for setting default of --terse...
Augie Fackler -
r38112:18424aee default
parent child Browse files
Show More
@@ -1,5692 +1,5699 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 )
22 )
23 from . import (
23 from . import (
24 archival,
24 archival,
25 bookmarks,
25 bookmarks,
26 bundle2,
26 bundle2,
27 changegroup,
27 changegroup,
28 cmdutil,
28 cmdutil,
29 copies,
29 copies,
30 debugcommands as debugcommandsmod,
30 debugcommands as debugcommandsmod,
31 destutil,
31 destutil,
32 dirstateguard,
32 dirstateguard,
33 discovery,
33 discovery,
34 encoding,
34 encoding,
35 error,
35 error,
36 exchange,
36 exchange,
37 extensions,
37 extensions,
38 formatter,
38 formatter,
39 graphmod,
39 graphmod,
40 hbisect,
40 hbisect,
41 help,
41 help,
42 hg,
42 hg,
43 lock as lockmod,
43 lock as lockmod,
44 logcmdutil,
44 logcmdutil,
45 merge as mergemod,
45 merge as mergemod,
46 obsolete,
46 obsolete,
47 obsutil,
47 obsutil,
48 patch,
48 patch,
49 phases,
49 phases,
50 pycompat,
50 pycompat,
51 rcutil,
51 rcutil,
52 registrar,
52 registrar,
53 repair,
53 repair,
54 revsetlang,
54 revsetlang,
55 rewriteutil,
55 rewriteutil,
56 scmutil,
56 scmutil,
57 server,
57 server,
58 streamclone,
58 streamclone,
59 tags as tagsmod,
59 tags as tagsmod,
60 templatekw,
60 templatekw,
61 ui as uimod,
61 ui as uimod,
62 util,
62 util,
63 wireprotoserver,
63 wireprotoserver,
64 )
64 )
65 from .utils import (
65 from .utils import (
66 dateutil,
66 dateutil,
67 procutil,
67 procutil,
68 stringutil,
68 stringutil,
69 )
69 )
70
70
71 release = lockmod.release
71 release = lockmod.release
72
72
73 table = {}
73 table = {}
74 table.update(debugcommandsmod.command._table)
74 table.update(debugcommandsmod.command._table)
75
75
76 command = registrar.command(table)
76 command = registrar.command(table)
77 INTENT_READONLY = registrar.INTENT_READONLY
77 INTENT_READONLY = registrar.INTENT_READONLY
78
78
79 # common command options
79 # common command options
80
80
81 globalopts = [
81 globalopts = [
82 ('R', 'repository', '',
82 ('R', 'repository', '',
83 _('repository root directory or name of overlay bundle file'),
83 _('repository root directory or name of overlay bundle file'),
84 _('REPO')),
84 _('REPO')),
85 ('', 'cwd', '',
85 ('', 'cwd', '',
86 _('change working directory'), _('DIR')),
86 _('change working directory'), _('DIR')),
87 ('y', 'noninteractive', None,
87 ('y', 'noninteractive', None,
88 _('do not prompt, automatically pick the first choice for all prompts')),
88 _('do not prompt, automatically pick the first choice for all prompts')),
89 ('q', 'quiet', None, _('suppress output')),
89 ('q', 'quiet', None, _('suppress output')),
90 ('v', 'verbose', None, _('enable additional output')),
90 ('v', 'verbose', None, _('enable additional output')),
91 ('', 'color', '',
91 ('', 'color', '',
92 # i18n: 'always', 'auto', 'never', and 'debug' are keywords
92 # i18n: 'always', 'auto', 'never', and 'debug' are keywords
93 # and should not be translated
93 # and should not be translated
94 _("when to colorize (boolean, always, auto, never, or debug)"),
94 _("when to colorize (boolean, always, auto, never, or debug)"),
95 _('TYPE')),
95 _('TYPE')),
96 ('', 'config', [],
96 ('', 'config', [],
97 _('set/override config option (use \'section.name=value\')'),
97 _('set/override config option (use \'section.name=value\')'),
98 _('CONFIG')),
98 _('CONFIG')),
99 ('', 'debug', None, _('enable debugging output')),
99 ('', 'debug', None, _('enable debugging output')),
100 ('', 'debugger', None, _('start debugger')),
100 ('', 'debugger', None, _('start debugger')),
101 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
101 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
102 _('ENCODE')),
102 _('ENCODE')),
103 ('', 'encodingmode', encoding.encodingmode,
103 ('', 'encodingmode', encoding.encodingmode,
104 _('set the charset encoding mode'), _('MODE')),
104 _('set the charset encoding mode'), _('MODE')),
105 ('', 'traceback', None, _('always print a traceback on exception')),
105 ('', 'traceback', None, _('always print a traceback on exception')),
106 ('', 'time', None, _('time how long the command takes')),
106 ('', 'time', None, _('time how long the command takes')),
107 ('', 'profile', None, _('print command execution profile')),
107 ('', 'profile', None, _('print command execution profile')),
108 ('', 'version', None, _('output version information and exit')),
108 ('', 'version', None, _('output version information and exit')),
109 ('h', 'help', None, _('display help and exit')),
109 ('h', 'help', None, _('display help and exit')),
110 ('', 'hidden', False, _('consider hidden changesets')),
110 ('', 'hidden', False, _('consider hidden changesets')),
111 ('', 'pager', 'auto',
111 ('', 'pager', 'auto',
112 _("when to paginate (boolean, always, auto, or never)"), _('TYPE')),
112 _("when to paginate (boolean, always, auto, or never)"), _('TYPE')),
113 ]
113 ]
114
114
115 dryrunopts = cmdutil.dryrunopts
115 dryrunopts = cmdutil.dryrunopts
116 remoteopts = cmdutil.remoteopts
116 remoteopts = cmdutil.remoteopts
117 walkopts = cmdutil.walkopts
117 walkopts = cmdutil.walkopts
118 commitopts = cmdutil.commitopts
118 commitopts = cmdutil.commitopts
119 commitopts2 = cmdutil.commitopts2
119 commitopts2 = cmdutil.commitopts2
120 formatteropts = cmdutil.formatteropts
120 formatteropts = cmdutil.formatteropts
121 templateopts = cmdutil.templateopts
121 templateopts = cmdutil.templateopts
122 logopts = cmdutil.logopts
122 logopts = cmdutil.logopts
123 diffopts = cmdutil.diffopts
123 diffopts = cmdutil.diffopts
124 diffwsopts = cmdutil.diffwsopts
124 diffwsopts = cmdutil.diffwsopts
125 diffopts2 = cmdutil.diffopts2
125 diffopts2 = cmdutil.diffopts2
126 mergetoolopts = cmdutil.mergetoolopts
126 mergetoolopts = cmdutil.mergetoolopts
127 similarityopts = cmdutil.similarityopts
127 similarityopts = cmdutil.similarityopts
128 subrepoopts = cmdutil.subrepoopts
128 subrepoopts = cmdutil.subrepoopts
129 debugrevlogopts = cmdutil.debugrevlogopts
129 debugrevlogopts = cmdutil.debugrevlogopts
130
130
131 # Commands start here, listed alphabetically
131 # Commands start here, listed alphabetically
132
132
133 @command('^add',
133 @command('^add',
134 walkopts + subrepoopts + dryrunopts,
134 walkopts + subrepoopts + dryrunopts,
135 _('[OPTION]... [FILE]...'),
135 _('[OPTION]... [FILE]...'),
136 inferrepo=True)
136 inferrepo=True)
137 def add(ui, repo, *pats, **opts):
137 def add(ui, repo, *pats, **opts):
138 """add the specified files on the next commit
138 """add the specified files on the next commit
139
139
140 Schedule files to be version controlled and added to the
140 Schedule files to be version controlled and added to the
141 repository.
141 repository.
142
142
143 The files will be added to the repository at the next commit. To
143 The files will be added to the repository at the next commit. To
144 undo an add before that, see :hg:`forget`.
144 undo an add before that, see :hg:`forget`.
145
145
146 If no names are given, add all files to the repository (except
146 If no names are given, add all files to the repository (except
147 files matching ``.hgignore``).
147 files matching ``.hgignore``).
148
148
149 .. container:: verbose
149 .. container:: verbose
150
150
151 Examples:
151 Examples:
152
152
153 - New (unknown) files are added
153 - New (unknown) files are added
154 automatically by :hg:`add`::
154 automatically by :hg:`add`::
155
155
156 $ ls
156 $ ls
157 foo.c
157 foo.c
158 $ hg status
158 $ hg status
159 ? foo.c
159 ? foo.c
160 $ hg add
160 $ hg add
161 adding foo.c
161 adding foo.c
162 $ hg status
162 $ hg status
163 A foo.c
163 A foo.c
164
164
165 - Specific files to be added can be specified::
165 - Specific files to be added can be specified::
166
166
167 $ ls
167 $ ls
168 bar.c foo.c
168 bar.c foo.c
169 $ hg status
169 $ hg status
170 ? bar.c
170 ? bar.c
171 ? foo.c
171 ? foo.c
172 $ hg add bar.c
172 $ hg add bar.c
173 $ hg status
173 $ hg status
174 A bar.c
174 A bar.c
175 ? foo.c
175 ? foo.c
176
176
177 Returns 0 if all files are successfully added.
177 Returns 0 if all files are successfully added.
178 """
178 """
179
179
180 m = scmutil.match(repo[None], pats, pycompat.byteskwargs(opts))
180 m = scmutil.match(repo[None], pats, pycompat.byteskwargs(opts))
181 rejected = cmdutil.add(ui, repo, m, "", False, **opts)
181 rejected = cmdutil.add(ui, repo, m, "", False, **opts)
182 return rejected and 1 or 0
182 return rejected and 1 or 0
183
183
184 @command('addremove',
184 @command('addremove',
185 similarityopts + subrepoopts + walkopts + dryrunopts,
185 similarityopts + subrepoopts + walkopts + dryrunopts,
186 _('[OPTION]... [FILE]...'),
186 _('[OPTION]... [FILE]...'),
187 inferrepo=True)
187 inferrepo=True)
188 def addremove(ui, repo, *pats, **opts):
188 def addremove(ui, repo, *pats, **opts):
189 """add all new files, delete all missing files
189 """add all new files, delete all missing files
190
190
191 Add all new files and remove all missing files from the
191 Add all new files and remove all missing files from the
192 repository.
192 repository.
193
193
194 Unless names are given, new files are ignored if they match any of
194 Unless names are given, new files are ignored if they match any of
195 the patterns in ``.hgignore``. As with add, these changes take
195 the patterns in ``.hgignore``. As with add, these changes take
196 effect at the next commit.
196 effect at the next commit.
197
197
198 Use the -s/--similarity option to detect renamed files. This
198 Use the -s/--similarity option to detect renamed files. This
199 option takes a percentage between 0 (disabled) and 100 (files must
199 option takes a percentage between 0 (disabled) and 100 (files must
200 be identical) as its parameter. With a parameter greater than 0,
200 be identical) as its parameter. With a parameter greater than 0,
201 this compares every removed file with every added file and records
201 this compares every removed file with every added file and records
202 those similar enough as renames. Detecting renamed files this way
202 those similar enough as renames. Detecting renamed files this way
203 can be expensive. After using this option, :hg:`status -C` can be
203 can be expensive. After using this option, :hg:`status -C` can be
204 used to check which files were identified as moved or renamed. If
204 used to check which files were identified as moved or renamed. If
205 not specified, -s/--similarity defaults to 100 and only renames of
205 not specified, -s/--similarity defaults to 100 and only renames of
206 identical files are detected.
206 identical files are detected.
207
207
208 .. container:: verbose
208 .. container:: verbose
209
209
210 Examples:
210 Examples:
211
211
212 - A number of files (bar.c and foo.c) are new,
212 - A number of files (bar.c and foo.c) are new,
213 while foobar.c has been removed (without using :hg:`remove`)
213 while foobar.c has been removed (without using :hg:`remove`)
214 from the repository::
214 from the repository::
215
215
216 $ ls
216 $ ls
217 bar.c foo.c
217 bar.c foo.c
218 $ hg status
218 $ hg status
219 ! foobar.c
219 ! foobar.c
220 ? bar.c
220 ? bar.c
221 ? foo.c
221 ? foo.c
222 $ hg addremove
222 $ hg addremove
223 adding bar.c
223 adding bar.c
224 adding foo.c
224 adding foo.c
225 removing foobar.c
225 removing foobar.c
226 $ hg status
226 $ hg status
227 A bar.c
227 A bar.c
228 A foo.c
228 A foo.c
229 R foobar.c
229 R foobar.c
230
230
231 - A file foobar.c was moved to foo.c without using :hg:`rename`.
231 - A file foobar.c was moved to foo.c without using :hg:`rename`.
232 Afterwards, it was edited slightly::
232 Afterwards, it was edited slightly::
233
233
234 $ ls
234 $ ls
235 foo.c
235 foo.c
236 $ hg status
236 $ hg status
237 ! foobar.c
237 ! foobar.c
238 ? foo.c
238 ? foo.c
239 $ hg addremove --similarity 90
239 $ hg addremove --similarity 90
240 removing foobar.c
240 removing foobar.c
241 adding foo.c
241 adding foo.c
242 recording removal of foobar.c as rename to foo.c (94% similar)
242 recording removal of foobar.c as rename to foo.c (94% similar)
243 $ hg status -C
243 $ hg status -C
244 A foo.c
244 A foo.c
245 foobar.c
245 foobar.c
246 R foobar.c
246 R foobar.c
247
247
248 Returns 0 if all files are successfully added.
248 Returns 0 if all files are successfully added.
249 """
249 """
250 opts = pycompat.byteskwargs(opts)
250 opts = pycompat.byteskwargs(opts)
251 if not opts.get('similarity'):
251 if not opts.get('similarity'):
252 opts['similarity'] = '100'
252 opts['similarity'] = '100'
253 matcher = scmutil.match(repo[None], pats, opts)
253 matcher = scmutil.match(repo[None], pats, opts)
254 return scmutil.addremove(repo, matcher, "", opts)
254 return scmutil.addremove(repo, matcher, "", opts)
255
255
256 @command('^annotate|blame',
256 @command('^annotate|blame',
257 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
257 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
258 ('', 'follow', None,
258 ('', 'follow', None,
259 _('follow copies/renames and list the filename (DEPRECATED)')),
259 _('follow copies/renames and list the filename (DEPRECATED)')),
260 ('', 'no-follow', None, _("don't follow copies and renames")),
260 ('', 'no-follow', None, _("don't follow copies and renames")),
261 ('a', 'text', None, _('treat all files as text')),
261 ('a', 'text', None, _('treat all files as text')),
262 ('u', 'user', None, _('list the author (long with -v)')),
262 ('u', 'user', None, _('list the author (long with -v)')),
263 ('f', 'file', None, _('list the filename')),
263 ('f', 'file', None, _('list the filename')),
264 ('d', 'date', None, _('list the date (short with -q)')),
264 ('d', 'date', None, _('list the date (short with -q)')),
265 ('n', 'number', None, _('list the revision number (default)')),
265 ('n', 'number', None, _('list the revision number (default)')),
266 ('c', 'changeset', None, _('list the changeset')),
266 ('c', 'changeset', None, _('list the changeset')),
267 ('l', 'line-number', None, _('show line number at the first appearance')),
267 ('l', 'line-number', None, _('show line number at the first appearance')),
268 ('', 'skip', [], _('revision to not display (EXPERIMENTAL)'), _('REV')),
268 ('', 'skip', [], _('revision to not display (EXPERIMENTAL)'), _('REV')),
269 ] + diffwsopts + walkopts + formatteropts,
269 ] + diffwsopts + walkopts + formatteropts,
270 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
270 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
271 inferrepo=True)
271 inferrepo=True)
272 def annotate(ui, repo, *pats, **opts):
272 def annotate(ui, repo, *pats, **opts):
273 """show changeset information by line for each file
273 """show changeset information by line for each file
274
274
275 List changes in files, showing the revision id responsible for
275 List changes in files, showing the revision id responsible for
276 each line.
276 each line.
277
277
278 This command is useful for discovering when a change was made and
278 This command is useful for discovering when a change was made and
279 by whom.
279 by whom.
280
280
281 If you include --file, --user, or --date, the revision number is
281 If you include --file, --user, or --date, the revision number is
282 suppressed unless you also include --number.
282 suppressed unless you also include --number.
283
283
284 Without the -a/--text option, annotate will avoid processing files
284 Without the -a/--text option, annotate will avoid processing files
285 it detects as binary. With -a, annotate will annotate the file
285 it detects as binary. With -a, annotate will annotate the file
286 anyway, although the results will probably be neither useful
286 anyway, although the results will probably be neither useful
287 nor desirable.
287 nor desirable.
288
288
289 Returns 0 on success.
289 Returns 0 on success.
290 """
290 """
291 opts = pycompat.byteskwargs(opts)
291 opts = pycompat.byteskwargs(opts)
292 if not pats:
292 if not pats:
293 raise error.Abort(_('at least one filename or pattern is required'))
293 raise error.Abort(_('at least one filename or pattern is required'))
294
294
295 if opts.get('follow'):
295 if opts.get('follow'):
296 # --follow is deprecated and now just an alias for -f/--file
296 # --follow is deprecated and now just an alias for -f/--file
297 # to mimic the behavior of Mercurial before version 1.5
297 # to mimic the behavior of Mercurial before version 1.5
298 opts['file'] = True
298 opts['file'] = True
299
299
300 rev = opts.get('rev')
300 rev = opts.get('rev')
301 if rev:
301 if rev:
302 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
302 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
303 ctx = scmutil.revsingle(repo, rev)
303 ctx = scmutil.revsingle(repo, rev)
304
304
305 rootfm = ui.formatter('annotate', opts)
305 rootfm = ui.formatter('annotate', opts)
306 if ui.quiet:
306 if ui.quiet:
307 datefunc = dateutil.shortdate
307 datefunc = dateutil.shortdate
308 else:
308 else:
309 datefunc = dateutil.datestr
309 datefunc = dateutil.datestr
310 if ctx.rev() is None:
310 if ctx.rev() is None:
311 def hexfn(node):
311 def hexfn(node):
312 if node is None:
312 if node is None:
313 return None
313 return None
314 else:
314 else:
315 return rootfm.hexfunc(node)
315 return rootfm.hexfunc(node)
316 if opts.get('changeset'):
316 if opts.get('changeset'):
317 # omit "+" suffix which is appended to node hex
317 # omit "+" suffix which is appended to node hex
318 def formatrev(rev):
318 def formatrev(rev):
319 if rev is None:
319 if rev is None:
320 return '%d' % ctx.p1().rev()
320 return '%d' % ctx.p1().rev()
321 else:
321 else:
322 return '%d' % rev
322 return '%d' % rev
323 else:
323 else:
324 def formatrev(rev):
324 def formatrev(rev):
325 if rev is None:
325 if rev is None:
326 return '%d+' % ctx.p1().rev()
326 return '%d+' % ctx.p1().rev()
327 else:
327 else:
328 return '%d ' % rev
328 return '%d ' % rev
329 def formathex(hex):
329 def formathex(hex):
330 if hex is None:
330 if hex is None:
331 return '%s+' % rootfm.hexfunc(ctx.p1().node())
331 return '%s+' % rootfm.hexfunc(ctx.p1().node())
332 else:
332 else:
333 return '%s ' % hex
333 return '%s ' % hex
334 else:
334 else:
335 hexfn = rootfm.hexfunc
335 hexfn = rootfm.hexfunc
336 formatrev = formathex = pycompat.bytestr
336 formatrev = formathex = pycompat.bytestr
337
337
338 opmap = [('user', ' ', lambda x: x.fctx.user(), ui.shortuser),
338 opmap = [('user', ' ', lambda x: x.fctx.user(), ui.shortuser),
339 ('number', ' ', lambda x: x.fctx.rev(), formatrev),
339 ('number', ' ', lambda x: x.fctx.rev(), formatrev),
340 ('changeset', ' ', lambda x: hexfn(x.fctx.node()), formathex),
340 ('changeset', ' ', lambda x: hexfn(x.fctx.node()), formathex),
341 ('date', ' ', lambda x: x.fctx.date(), util.cachefunc(datefunc)),
341 ('date', ' ', lambda x: x.fctx.date(), util.cachefunc(datefunc)),
342 ('file', ' ', lambda x: x.fctx.path(), pycompat.bytestr),
342 ('file', ' ', lambda x: x.fctx.path(), pycompat.bytestr),
343 ('line_number', ':', lambda x: x.lineno, pycompat.bytestr),
343 ('line_number', ':', lambda x: x.lineno, pycompat.bytestr),
344 ]
344 ]
345 fieldnamemap = {'number': 'rev', 'changeset': 'node'}
345 fieldnamemap = {'number': 'rev', 'changeset': 'node'}
346
346
347 if (not opts.get('user') and not opts.get('changeset')
347 if (not opts.get('user') and not opts.get('changeset')
348 and not opts.get('date') and not opts.get('file')):
348 and not opts.get('date') and not opts.get('file')):
349 opts['number'] = True
349 opts['number'] = True
350
350
351 linenumber = opts.get('line_number') is not None
351 linenumber = opts.get('line_number') is not None
352 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
352 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
353 raise error.Abort(_('at least one of -n/-c is required for -l'))
353 raise error.Abort(_('at least one of -n/-c is required for -l'))
354
354
355 ui.pager('annotate')
355 ui.pager('annotate')
356
356
357 if rootfm.isplain():
357 if rootfm.isplain():
358 def makefunc(get, fmt):
358 def makefunc(get, fmt):
359 return lambda x: fmt(get(x))
359 return lambda x: fmt(get(x))
360 else:
360 else:
361 def makefunc(get, fmt):
361 def makefunc(get, fmt):
362 return get
362 return get
363 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap
363 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap
364 if opts.get(op)]
364 if opts.get(op)]
365 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
365 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
366 fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap
366 fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap
367 if opts.get(op))
367 if opts.get(op))
368
368
369 def bad(x, y):
369 def bad(x, y):
370 raise error.Abort("%s: %s" % (x, y))
370 raise error.Abort("%s: %s" % (x, y))
371
371
372 m = scmutil.match(ctx, pats, opts, badfn=bad)
372 m = scmutil.match(ctx, pats, opts, badfn=bad)
373
373
374 follow = not opts.get('no_follow')
374 follow = not opts.get('no_follow')
375 diffopts = patch.difffeatureopts(ui, opts, section='annotate',
375 diffopts = patch.difffeatureopts(ui, opts, section='annotate',
376 whitespace=True)
376 whitespace=True)
377 skiprevs = opts.get('skip')
377 skiprevs = opts.get('skip')
378 if skiprevs:
378 if skiprevs:
379 skiprevs = scmutil.revrange(repo, skiprevs)
379 skiprevs = scmutil.revrange(repo, skiprevs)
380
380
381 for abs in ctx.walk(m):
381 for abs in ctx.walk(m):
382 fctx = ctx[abs]
382 fctx = ctx[abs]
383 rootfm.startitem()
383 rootfm.startitem()
384 rootfm.data(abspath=abs, path=m.rel(abs))
384 rootfm.data(abspath=abs, path=m.rel(abs))
385 if not opts.get('text') and fctx.isbinary():
385 if not opts.get('text') and fctx.isbinary():
386 rootfm.plain(_("%s: binary file\n")
386 rootfm.plain(_("%s: binary file\n")
387 % ((pats and m.rel(abs)) or abs))
387 % ((pats and m.rel(abs)) or abs))
388 continue
388 continue
389
389
390 fm = rootfm.nested('lines', tmpl='{rev}: {line}')
390 fm = rootfm.nested('lines', tmpl='{rev}: {line}')
391 lines = fctx.annotate(follow=follow, skiprevs=skiprevs,
391 lines = fctx.annotate(follow=follow, skiprevs=skiprevs,
392 diffopts=diffopts)
392 diffopts=diffopts)
393 if not lines:
393 if not lines:
394 fm.end()
394 fm.end()
395 continue
395 continue
396 formats = []
396 formats = []
397 pieces = []
397 pieces = []
398
398
399 for f, sep in funcmap:
399 for f, sep in funcmap:
400 l = [f(n) for n in lines]
400 l = [f(n) for n in lines]
401 if fm.isplain():
401 if fm.isplain():
402 sizes = [encoding.colwidth(x) for x in l]
402 sizes = [encoding.colwidth(x) for x in l]
403 ml = max(sizes)
403 ml = max(sizes)
404 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes])
404 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes])
405 else:
405 else:
406 formats.append(['%s' for x in l])
406 formats.append(['%s' for x in l])
407 pieces.append(l)
407 pieces.append(l)
408
408
409 for f, p, n in zip(zip(*formats), zip(*pieces), lines):
409 for f, p, n in zip(zip(*formats), zip(*pieces), lines):
410 fm.startitem()
410 fm.startitem()
411 fm.context(fctx=n.fctx)
411 fm.context(fctx=n.fctx)
412 fm.write(fields, "".join(f), *p)
412 fm.write(fields, "".join(f), *p)
413 if n.skip:
413 if n.skip:
414 fmt = "* %s"
414 fmt = "* %s"
415 else:
415 else:
416 fmt = ": %s"
416 fmt = ": %s"
417 fm.write('line', fmt, n.text)
417 fm.write('line', fmt, n.text)
418
418
419 if not lines[-1].text.endswith('\n'):
419 if not lines[-1].text.endswith('\n'):
420 fm.plain('\n')
420 fm.plain('\n')
421 fm.end()
421 fm.end()
422
422
423 rootfm.end()
423 rootfm.end()
424
424
425 @command('archive',
425 @command('archive',
426 [('', 'no-decode', None, _('do not pass files through decoders')),
426 [('', 'no-decode', None, _('do not pass files through decoders')),
427 ('p', 'prefix', '', _('directory prefix for files in archive'),
427 ('p', 'prefix', '', _('directory prefix for files in archive'),
428 _('PREFIX')),
428 _('PREFIX')),
429 ('r', 'rev', '', _('revision to distribute'), _('REV')),
429 ('r', 'rev', '', _('revision to distribute'), _('REV')),
430 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
430 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
431 ] + subrepoopts + walkopts,
431 ] + subrepoopts + walkopts,
432 _('[OPTION]... DEST'))
432 _('[OPTION]... DEST'))
433 def archive(ui, repo, dest, **opts):
433 def archive(ui, repo, dest, **opts):
434 '''create an unversioned archive of a repository revision
434 '''create an unversioned archive of a repository revision
435
435
436 By default, the revision used is the parent of the working
436 By default, the revision used is the parent of the working
437 directory; use -r/--rev to specify a different revision.
437 directory; use -r/--rev to specify a different revision.
438
438
439 The archive type is automatically detected based on file
439 The archive type is automatically detected based on file
440 extension (to override, use -t/--type).
440 extension (to override, use -t/--type).
441
441
442 .. container:: verbose
442 .. container:: verbose
443
443
444 Examples:
444 Examples:
445
445
446 - create a zip file containing the 1.0 release::
446 - create a zip file containing the 1.0 release::
447
447
448 hg archive -r 1.0 project-1.0.zip
448 hg archive -r 1.0 project-1.0.zip
449
449
450 - create a tarball excluding .hg files::
450 - create a tarball excluding .hg files::
451
451
452 hg archive project.tar.gz -X ".hg*"
452 hg archive project.tar.gz -X ".hg*"
453
453
454 Valid types are:
454 Valid types are:
455
455
456 :``files``: a directory full of files (default)
456 :``files``: a directory full of files (default)
457 :``tar``: tar archive, uncompressed
457 :``tar``: tar archive, uncompressed
458 :``tbz2``: tar archive, compressed using bzip2
458 :``tbz2``: tar archive, compressed using bzip2
459 :``tgz``: tar archive, compressed using gzip
459 :``tgz``: tar archive, compressed using gzip
460 :``uzip``: zip archive, uncompressed
460 :``uzip``: zip archive, uncompressed
461 :``zip``: zip archive, compressed using deflate
461 :``zip``: zip archive, compressed using deflate
462
462
463 The exact name of the destination archive or directory is given
463 The exact name of the destination archive or directory is given
464 using a format string; see :hg:`help export` for details.
464 using a format string; see :hg:`help export` for details.
465
465
466 Each member added to an archive file has a directory prefix
466 Each member added to an archive file has a directory prefix
467 prepended. Use -p/--prefix to specify a format string for the
467 prepended. Use -p/--prefix to specify a format string for the
468 prefix. The default is the basename of the archive, with suffixes
468 prefix. The default is the basename of the archive, with suffixes
469 removed.
469 removed.
470
470
471 Returns 0 on success.
471 Returns 0 on success.
472 '''
472 '''
473
473
474 opts = pycompat.byteskwargs(opts)
474 opts = pycompat.byteskwargs(opts)
475 rev = opts.get('rev')
475 rev = opts.get('rev')
476 if rev:
476 if rev:
477 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
477 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
478 ctx = scmutil.revsingle(repo, rev)
478 ctx = scmutil.revsingle(repo, rev)
479 if not ctx:
479 if not ctx:
480 raise error.Abort(_('no working directory: please specify a revision'))
480 raise error.Abort(_('no working directory: please specify a revision'))
481 node = ctx.node()
481 node = ctx.node()
482 dest = cmdutil.makefilename(ctx, dest)
482 dest = cmdutil.makefilename(ctx, dest)
483 if os.path.realpath(dest) == repo.root:
483 if os.path.realpath(dest) == repo.root:
484 raise error.Abort(_('repository root cannot be destination'))
484 raise error.Abort(_('repository root cannot be destination'))
485
485
486 kind = opts.get('type') or archival.guesskind(dest) or 'files'
486 kind = opts.get('type') or archival.guesskind(dest) or 'files'
487 prefix = opts.get('prefix')
487 prefix = opts.get('prefix')
488
488
489 if dest == '-':
489 if dest == '-':
490 if kind == 'files':
490 if kind == 'files':
491 raise error.Abort(_('cannot archive plain files to stdout'))
491 raise error.Abort(_('cannot archive plain files to stdout'))
492 dest = cmdutil.makefileobj(ctx, dest)
492 dest = cmdutil.makefileobj(ctx, dest)
493 if not prefix:
493 if not prefix:
494 prefix = os.path.basename(repo.root) + '-%h'
494 prefix = os.path.basename(repo.root) + '-%h'
495
495
496 prefix = cmdutil.makefilename(ctx, prefix)
496 prefix = cmdutil.makefilename(ctx, prefix)
497 match = scmutil.match(ctx, [], opts)
497 match = scmutil.match(ctx, [], opts)
498 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
498 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
499 match, prefix, subrepos=opts.get('subrepos'))
499 match, prefix, subrepos=opts.get('subrepos'))
500
500
501 @command('backout',
501 @command('backout',
502 [('', 'merge', None, _('merge with old dirstate parent after backout')),
502 [('', 'merge', None, _('merge with old dirstate parent after backout')),
503 ('', 'commit', None,
503 ('', 'commit', None,
504 _('commit if no conflicts were encountered (DEPRECATED)')),
504 _('commit if no conflicts were encountered (DEPRECATED)')),
505 ('', 'no-commit', None, _('do not commit')),
505 ('', 'no-commit', None, _('do not commit')),
506 ('', 'parent', '',
506 ('', 'parent', '',
507 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
507 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
508 ('r', 'rev', '', _('revision to backout'), _('REV')),
508 ('r', 'rev', '', _('revision to backout'), _('REV')),
509 ('e', 'edit', False, _('invoke editor on commit messages')),
509 ('e', 'edit', False, _('invoke editor on commit messages')),
510 ] + mergetoolopts + walkopts + commitopts + commitopts2,
510 ] + mergetoolopts + walkopts + commitopts + commitopts2,
511 _('[OPTION]... [-r] REV'))
511 _('[OPTION]... [-r] REV'))
512 def backout(ui, repo, node=None, rev=None, **opts):
512 def backout(ui, repo, node=None, rev=None, **opts):
513 '''reverse effect of earlier changeset
513 '''reverse effect of earlier changeset
514
514
515 Prepare a new changeset with the effect of REV undone in the
515 Prepare a new changeset with the effect of REV undone in the
516 current working directory. If no conflicts were encountered,
516 current working directory. If no conflicts were encountered,
517 it will be committed immediately.
517 it will be committed immediately.
518
518
519 If REV is the parent of the working directory, then this new changeset
519 If REV is the parent of the working directory, then this new changeset
520 is committed automatically (unless --no-commit is specified).
520 is committed automatically (unless --no-commit is specified).
521
521
522 .. note::
522 .. note::
523
523
524 :hg:`backout` cannot be used to fix either an unwanted or
524 :hg:`backout` cannot be used to fix either an unwanted or
525 incorrect merge.
525 incorrect merge.
526
526
527 .. container:: verbose
527 .. container:: verbose
528
528
529 Examples:
529 Examples:
530
530
531 - Reverse the effect of the parent of the working directory.
531 - Reverse the effect of the parent of the working directory.
532 This backout will be committed immediately::
532 This backout will be committed immediately::
533
533
534 hg backout -r .
534 hg backout -r .
535
535
536 - Reverse the effect of previous bad revision 23::
536 - Reverse the effect of previous bad revision 23::
537
537
538 hg backout -r 23
538 hg backout -r 23
539
539
540 - Reverse the effect of previous bad revision 23 and
540 - Reverse the effect of previous bad revision 23 and
541 leave changes uncommitted::
541 leave changes uncommitted::
542
542
543 hg backout -r 23 --no-commit
543 hg backout -r 23 --no-commit
544 hg commit -m "Backout revision 23"
544 hg commit -m "Backout revision 23"
545
545
546 By default, the pending changeset will have one parent,
546 By default, the pending changeset will have one parent,
547 maintaining a linear history. With --merge, the pending
547 maintaining a linear history. With --merge, the pending
548 changeset will instead have two parents: the old parent of the
548 changeset will instead have two parents: the old parent of the
549 working directory and a new child of REV that simply undoes REV.
549 working directory and a new child of REV that simply undoes REV.
550
550
551 Before version 1.7, the behavior without --merge was equivalent
551 Before version 1.7, the behavior without --merge was equivalent
552 to specifying --merge followed by :hg:`update --clean .` to
552 to specifying --merge followed by :hg:`update --clean .` to
553 cancel the merge and leave the child of REV as a head to be
553 cancel the merge and leave the child of REV as a head to be
554 merged separately.
554 merged separately.
555
555
556 See :hg:`help dates` for a list of formats valid for -d/--date.
556 See :hg:`help dates` for a list of formats valid for -d/--date.
557
557
558 See :hg:`help revert` for a way to restore files to the state
558 See :hg:`help revert` for a way to restore files to the state
559 of another revision.
559 of another revision.
560
560
561 Returns 0 on success, 1 if nothing to backout or there are unresolved
561 Returns 0 on success, 1 if nothing to backout or there are unresolved
562 files.
562 files.
563 '''
563 '''
564 wlock = lock = None
564 wlock = lock = None
565 try:
565 try:
566 wlock = repo.wlock()
566 wlock = repo.wlock()
567 lock = repo.lock()
567 lock = repo.lock()
568 return _dobackout(ui, repo, node, rev, **opts)
568 return _dobackout(ui, repo, node, rev, **opts)
569 finally:
569 finally:
570 release(lock, wlock)
570 release(lock, wlock)
571
571
572 def _dobackout(ui, repo, node=None, rev=None, **opts):
572 def _dobackout(ui, repo, node=None, rev=None, **opts):
573 opts = pycompat.byteskwargs(opts)
573 opts = pycompat.byteskwargs(opts)
574 if opts.get('commit') and opts.get('no_commit'):
574 if opts.get('commit') and opts.get('no_commit'):
575 raise error.Abort(_("cannot use --commit with --no-commit"))
575 raise error.Abort(_("cannot use --commit with --no-commit"))
576 if opts.get('merge') and opts.get('no_commit'):
576 if opts.get('merge') and opts.get('no_commit'):
577 raise error.Abort(_("cannot use --merge with --no-commit"))
577 raise error.Abort(_("cannot use --merge with --no-commit"))
578
578
579 if rev and node:
579 if rev and node:
580 raise error.Abort(_("please specify just one revision"))
580 raise error.Abort(_("please specify just one revision"))
581
581
582 if not rev:
582 if not rev:
583 rev = node
583 rev = node
584
584
585 if not rev:
585 if not rev:
586 raise error.Abort(_("please specify a revision to backout"))
586 raise error.Abort(_("please specify a revision to backout"))
587
587
588 date = opts.get('date')
588 date = opts.get('date')
589 if date:
589 if date:
590 opts['date'] = dateutil.parsedate(date)
590 opts['date'] = dateutil.parsedate(date)
591
591
592 cmdutil.checkunfinished(repo)
592 cmdutil.checkunfinished(repo)
593 cmdutil.bailifchanged(repo)
593 cmdutil.bailifchanged(repo)
594 node = scmutil.revsingle(repo, rev).node()
594 node = scmutil.revsingle(repo, rev).node()
595
595
596 op1, op2 = repo.dirstate.parents()
596 op1, op2 = repo.dirstate.parents()
597 if not repo.changelog.isancestor(node, op1):
597 if not repo.changelog.isancestor(node, op1):
598 raise error.Abort(_('cannot backout change that is not an ancestor'))
598 raise error.Abort(_('cannot backout change that is not an ancestor'))
599
599
600 p1, p2 = repo.changelog.parents(node)
600 p1, p2 = repo.changelog.parents(node)
601 if p1 == nullid:
601 if p1 == nullid:
602 raise error.Abort(_('cannot backout a change with no parents'))
602 raise error.Abort(_('cannot backout a change with no parents'))
603 if p2 != nullid:
603 if p2 != nullid:
604 if not opts.get('parent'):
604 if not opts.get('parent'):
605 raise error.Abort(_('cannot backout a merge changeset'))
605 raise error.Abort(_('cannot backout a merge changeset'))
606 p = repo.lookup(opts['parent'])
606 p = repo.lookup(opts['parent'])
607 if p not in (p1, p2):
607 if p not in (p1, p2):
608 raise error.Abort(_('%s is not a parent of %s') %
608 raise error.Abort(_('%s is not a parent of %s') %
609 (short(p), short(node)))
609 (short(p), short(node)))
610 parent = p
610 parent = p
611 else:
611 else:
612 if opts.get('parent'):
612 if opts.get('parent'):
613 raise error.Abort(_('cannot use --parent on non-merge changeset'))
613 raise error.Abort(_('cannot use --parent on non-merge changeset'))
614 parent = p1
614 parent = p1
615
615
616 # the backout should appear on the same branch
616 # the backout should appear on the same branch
617 branch = repo.dirstate.branch()
617 branch = repo.dirstate.branch()
618 bheads = repo.branchheads(branch)
618 bheads = repo.branchheads(branch)
619 rctx = scmutil.revsingle(repo, hex(parent))
619 rctx = scmutil.revsingle(repo, hex(parent))
620 if not opts.get('merge') and op1 != node:
620 if not opts.get('merge') and op1 != node:
621 dsguard = dirstateguard.dirstateguard(repo, 'backout')
621 dsguard = dirstateguard.dirstateguard(repo, 'backout')
622 try:
622 try:
623 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
623 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
624 'backout')
624 'backout')
625 stats = mergemod.update(repo, parent, True, True, node, False)
625 stats = mergemod.update(repo, parent, True, True, node, False)
626 repo.setparents(op1, op2)
626 repo.setparents(op1, op2)
627 dsguard.close()
627 dsguard.close()
628 hg._showstats(repo, stats)
628 hg._showstats(repo, stats)
629 if stats.unresolvedcount:
629 if stats.unresolvedcount:
630 repo.ui.status(_("use 'hg resolve' to retry unresolved "
630 repo.ui.status(_("use 'hg resolve' to retry unresolved "
631 "file merges\n"))
631 "file merges\n"))
632 return 1
632 return 1
633 finally:
633 finally:
634 ui.setconfig('ui', 'forcemerge', '', '')
634 ui.setconfig('ui', 'forcemerge', '', '')
635 lockmod.release(dsguard)
635 lockmod.release(dsguard)
636 else:
636 else:
637 hg.clean(repo, node, show_stats=False)
637 hg.clean(repo, node, show_stats=False)
638 repo.dirstate.setbranch(branch)
638 repo.dirstate.setbranch(branch)
639 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
639 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
640
640
641 if opts.get('no_commit'):
641 if opts.get('no_commit'):
642 msg = _("changeset %s backed out, "
642 msg = _("changeset %s backed out, "
643 "don't forget to commit.\n")
643 "don't forget to commit.\n")
644 ui.status(msg % short(node))
644 ui.status(msg % short(node))
645 return 0
645 return 0
646
646
647 def commitfunc(ui, repo, message, match, opts):
647 def commitfunc(ui, repo, message, match, opts):
648 editform = 'backout'
648 editform = 'backout'
649 e = cmdutil.getcommiteditor(editform=editform,
649 e = cmdutil.getcommiteditor(editform=editform,
650 **pycompat.strkwargs(opts))
650 **pycompat.strkwargs(opts))
651 if not message:
651 if not message:
652 # we don't translate commit messages
652 # we don't translate commit messages
653 message = "Backed out changeset %s" % short(node)
653 message = "Backed out changeset %s" % short(node)
654 e = cmdutil.getcommiteditor(edit=True, editform=editform)
654 e = cmdutil.getcommiteditor(edit=True, editform=editform)
655 return repo.commit(message, opts.get('user'), opts.get('date'),
655 return repo.commit(message, opts.get('user'), opts.get('date'),
656 match, editor=e)
656 match, editor=e)
657 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
657 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
658 if not newnode:
658 if not newnode:
659 ui.status(_("nothing changed\n"))
659 ui.status(_("nothing changed\n"))
660 return 1
660 return 1
661 cmdutil.commitstatus(repo, newnode, branch, bheads)
661 cmdutil.commitstatus(repo, newnode, branch, bheads)
662
662
663 def nice(node):
663 def nice(node):
664 return '%d:%s' % (repo.changelog.rev(node), short(node))
664 return '%d:%s' % (repo.changelog.rev(node), short(node))
665 ui.status(_('changeset %s backs out changeset %s\n') %
665 ui.status(_('changeset %s backs out changeset %s\n') %
666 (nice(repo.changelog.tip()), nice(node)))
666 (nice(repo.changelog.tip()), nice(node)))
667 if opts.get('merge') and op1 != node:
667 if opts.get('merge') and op1 != node:
668 hg.clean(repo, op1, show_stats=False)
668 hg.clean(repo, op1, show_stats=False)
669 ui.status(_('merging with changeset %s\n')
669 ui.status(_('merging with changeset %s\n')
670 % nice(repo.changelog.tip()))
670 % nice(repo.changelog.tip()))
671 try:
671 try:
672 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
672 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
673 'backout')
673 'backout')
674 return hg.merge(repo, hex(repo.changelog.tip()))
674 return hg.merge(repo, hex(repo.changelog.tip()))
675 finally:
675 finally:
676 ui.setconfig('ui', 'forcemerge', '', '')
676 ui.setconfig('ui', 'forcemerge', '', '')
677 return 0
677 return 0
678
678
679 @command('bisect',
679 @command('bisect',
680 [('r', 'reset', False, _('reset bisect state')),
680 [('r', 'reset', False, _('reset bisect state')),
681 ('g', 'good', False, _('mark changeset good')),
681 ('g', 'good', False, _('mark changeset good')),
682 ('b', 'bad', False, _('mark changeset bad')),
682 ('b', 'bad', False, _('mark changeset bad')),
683 ('s', 'skip', False, _('skip testing changeset')),
683 ('s', 'skip', False, _('skip testing changeset')),
684 ('e', 'extend', False, _('extend the bisect range')),
684 ('e', 'extend', False, _('extend the bisect range')),
685 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
685 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
686 ('U', 'noupdate', False, _('do not update to target'))],
686 ('U', 'noupdate', False, _('do not update to target'))],
687 _("[-gbsr] [-U] [-c CMD] [REV]"))
687 _("[-gbsr] [-U] [-c CMD] [REV]"))
688 def bisect(ui, repo, rev=None, extra=None, command=None,
688 def bisect(ui, repo, rev=None, extra=None, command=None,
689 reset=None, good=None, bad=None, skip=None, extend=None,
689 reset=None, good=None, bad=None, skip=None, extend=None,
690 noupdate=None):
690 noupdate=None):
691 """subdivision search of changesets
691 """subdivision search of changesets
692
692
693 This command helps to find changesets which introduce problems. To
693 This command helps to find changesets which introduce problems. To
694 use, mark the earliest changeset you know exhibits the problem as
694 use, mark the earliest changeset you know exhibits the problem as
695 bad, then mark the latest changeset which is free from the problem
695 bad, then mark the latest changeset which is free from the problem
696 as good. Bisect will update your working directory to a revision
696 as good. Bisect will update your working directory to a revision
697 for testing (unless the -U/--noupdate option is specified). Once
697 for testing (unless the -U/--noupdate option is specified). Once
698 you have performed tests, mark the working directory as good or
698 you have performed tests, mark the working directory as good or
699 bad, and bisect will either update to another candidate changeset
699 bad, and bisect will either update to another candidate changeset
700 or announce that it has found the bad revision.
700 or announce that it has found the bad revision.
701
701
702 As a shortcut, you can also use the revision argument to mark a
702 As a shortcut, you can also use the revision argument to mark a
703 revision as good or bad without checking it out first.
703 revision as good or bad without checking it out first.
704
704
705 If you supply a command, it will be used for automatic bisection.
705 If you supply a command, it will be used for automatic bisection.
706 The environment variable HG_NODE will contain the ID of the
706 The environment variable HG_NODE will contain the ID of the
707 changeset being tested. The exit status of the command will be
707 changeset being tested. The exit status of the command will be
708 used to mark revisions as good or bad: status 0 means good, 125
708 used to mark revisions as good or bad: status 0 means good, 125
709 means to skip the revision, 127 (command not found) will abort the
709 means to skip the revision, 127 (command not found) will abort the
710 bisection, and any other non-zero exit status means the revision
710 bisection, and any other non-zero exit status means the revision
711 is bad.
711 is bad.
712
712
713 .. container:: verbose
713 .. container:: verbose
714
714
715 Some examples:
715 Some examples:
716
716
717 - start a bisection with known bad revision 34, and good revision 12::
717 - start a bisection with known bad revision 34, and good revision 12::
718
718
719 hg bisect --bad 34
719 hg bisect --bad 34
720 hg bisect --good 12
720 hg bisect --good 12
721
721
722 - advance the current bisection by marking current revision as good or
722 - advance the current bisection by marking current revision as good or
723 bad::
723 bad::
724
724
725 hg bisect --good
725 hg bisect --good
726 hg bisect --bad
726 hg bisect --bad
727
727
728 - mark the current revision, or a known revision, to be skipped (e.g. if
728 - mark the current revision, or a known revision, to be skipped (e.g. if
729 that revision is not usable because of another issue)::
729 that revision is not usable because of another issue)::
730
730
731 hg bisect --skip
731 hg bisect --skip
732 hg bisect --skip 23
732 hg bisect --skip 23
733
733
734 - skip all revisions that do not touch directories ``foo`` or ``bar``::
734 - skip all revisions that do not touch directories ``foo`` or ``bar``::
735
735
736 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
736 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
737
737
738 - forget the current bisection::
738 - forget the current bisection::
739
739
740 hg bisect --reset
740 hg bisect --reset
741
741
742 - use 'make && make tests' to automatically find the first broken
742 - use 'make && make tests' to automatically find the first broken
743 revision::
743 revision::
744
744
745 hg bisect --reset
745 hg bisect --reset
746 hg bisect --bad 34
746 hg bisect --bad 34
747 hg bisect --good 12
747 hg bisect --good 12
748 hg bisect --command "make && make tests"
748 hg bisect --command "make && make tests"
749
749
750 - see all changesets whose states are already known in the current
750 - see all changesets whose states are already known in the current
751 bisection::
751 bisection::
752
752
753 hg log -r "bisect(pruned)"
753 hg log -r "bisect(pruned)"
754
754
755 - see the changeset currently being bisected (especially useful
755 - see the changeset currently being bisected (especially useful
756 if running with -U/--noupdate)::
756 if running with -U/--noupdate)::
757
757
758 hg log -r "bisect(current)"
758 hg log -r "bisect(current)"
759
759
760 - see all changesets that took part in the current bisection::
760 - see all changesets that took part in the current bisection::
761
761
762 hg log -r "bisect(range)"
762 hg log -r "bisect(range)"
763
763
764 - you can even get a nice graph::
764 - you can even get a nice graph::
765
765
766 hg log --graph -r "bisect(range)"
766 hg log --graph -r "bisect(range)"
767
767
768 See :hg:`help revisions.bisect` for more about the `bisect()` predicate.
768 See :hg:`help revisions.bisect` for more about the `bisect()` predicate.
769
769
770 Returns 0 on success.
770 Returns 0 on success.
771 """
771 """
772 # backward compatibility
772 # backward compatibility
773 if rev in "good bad reset init".split():
773 if rev in "good bad reset init".split():
774 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
774 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
775 cmd, rev, extra = rev, extra, None
775 cmd, rev, extra = rev, extra, None
776 if cmd == "good":
776 if cmd == "good":
777 good = True
777 good = True
778 elif cmd == "bad":
778 elif cmd == "bad":
779 bad = True
779 bad = True
780 else:
780 else:
781 reset = True
781 reset = True
782 elif extra:
782 elif extra:
783 raise error.Abort(_('incompatible arguments'))
783 raise error.Abort(_('incompatible arguments'))
784
784
785 incompatibles = {
785 incompatibles = {
786 '--bad': bad,
786 '--bad': bad,
787 '--command': bool(command),
787 '--command': bool(command),
788 '--extend': extend,
788 '--extend': extend,
789 '--good': good,
789 '--good': good,
790 '--reset': reset,
790 '--reset': reset,
791 '--skip': skip,
791 '--skip': skip,
792 }
792 }
793
793
794 enabled = [x for x in incompatibles if incompatibles[x]]
794 enabled = [x for x in incompatibles if incompatibles[x]]
795
795
796 if len(enabled) > 1:
796 if len(enabled) > 1:
797 raise error.Abort(_('%s and %s are incompatible') %
797 raise error.Abort(_('%s and %s are incompatible') %
798 tuple(sorted(enabled)[0:2]))
798 tuple(sorted(enabled)[0:2]))
799
799
800 if reset:
800 if reset:
801 hbisect.resetstate(repo)
801 hbisect.resetstate(repo)
802 return
802 return
803
803
804 state = hbisect.load_state(repo)
804 state = hbisect.load_state(repo)
805
805
806 # update state
806 # update state
807 if good or bad or skip:
807 if good or bad or skip:
808 if rev:
808 if rev:
809 nodes = [repo[i].node() for i in scmutil.revrange(repo, [rev])]
809 nodes = [repo[i].node() for i in scmutil.revrange(repo, [rev])]
810 else:
810 else:
811 nodes = [repo.lookup('.')]
811 nodes = [repo.lookup('.')]
812 if good:
812 if good:
813 state['good'] += nodes
813 state['good'] += nodes
814 elif bad:
814 elif bad:
815 state['bad'] += nodes
815 state['bad'] += nodes
816 elif skip:
816 elif skip:
817 state['skip'] += nodes
817 state['skip'] += nodes
818 hbisect.save_state(repo, state)
818 hbisect.save_state(repo, state)
819 if not (state['good'] and state['bad']):
819 if not (state['good'] and state['bad']):
820 return
820 return
821
821
822 def mayupdate(repo, node, show_stats=True):
822 def mayupdate(repo, node, show_stats=True):
823 """common used update sequence"""
823 """common used update sequence"""
824 if noupdate:
824 if noupdate:
825 return
825 return
826 cmdutil.checkunfinished(repo)
826 cmdutil.checkunfinished(repo)
827 cmdutil.bailifchanged(repo)
827 cmdutil.bailifchanged(repo)
828 return hg.clean(repo, node, show_stats=show_stats)
828 return hg.clean(repo, node, show_stats=show_stats)
829
829
830 displayer = logcmdutil.changesetdisplayer(ui, repo, {})
830 displayer = logcmdutil.changesetdisplayer(ui, repo, {})
831
831
832 if command:
832 if command:
833 changesets = 1
833 changesets = 1
834 if noupdate:
834 if noupdate:
835 try:
835 try:
836 node = state['current'][0]
836 node = state['current'][0]
837 except LookupError:
837 except LookupError:
838 raise error.Abort(_('current bisect revision is unknown - '
838 raise error.Abort(_('current bisect revision is unknown - '
839 'start a new bisect to fix'))
839 'start a new bisect to fix'))
840 else:
840 else:
841 node, p2 = repo.dirstate.parents()
841 node, p2 = repo.dirstate.parents()
842 if p2 != nullid:
842 if p2 != nullid:
843 raise error.Abort(_('current bisect revision is a merge'))
843 raise error.Abort(_('current bisect revision is a merge'))
844 if rev:
844 if rev:
845 node = repo[scmutil.revsingle(repo, rev, node)].node()
845 node = repo[scmutil.revsingle(repo, rev, node)].node()
846 try:
846 try:
847 while changesets:
847 while changesets:
848 # update state
848 # update state
849 state['current'] = [node]
849 state['current'] = [node]
850 hbisect.save_state(repo, state)
850 hbisect.save_state(repo, state)
851 status = ui.system(command, environ={'HG_NODE': hex(node)},
851 status = ui.system(command, environ={'HG_NODE': hex(node)},
852 blockedtag='bisect_check')
852 blockedtag='bisect_check')
853 if status == 125:
853 if status == 125:
854 transition = "skip"
854 transition = "skip"
855 elif status == 0:
855 elif status == 0:
856 transition = "good"
856 transition = "good"
857 # status < 0 means process was killed
857 # status < 0 means process was killed
858 elif status == 127:
858 elif status == 127:
859 raise error.Abort(_("failed to execute %s") % command)
859 raise error.Abort(_("failed to execute %s") % command)
860 elif status < 0:
860 elif status < 0:
861 raise error.Abort(_("%s killed") % command)
861 raise error.Abort(_("%s killed") % command)
862 else:
862 else:
863 transition = "bad"
863 transition = "bad"
864 state[transition].append(node)
864 state[transition].append(node)
865 ctx = repo[node]
865 ctx = repo[node]
866 ui.status(_('changeset %d:%s: %s\n') % (ctx.rev(), ctx,
866 ui.status(_('changeset %d:%s: %s\n') % (ctx.rev(), ctx,
867 transition))
867 transition))
868 hbisect.checkstate(state)
868 hbisect.checkstate(state)
869 # bisect
869 # bisect
870 nodes, changesets, bgood = hbisect.bisect(repo, state)
870 nodes, changesets, bgood = hbisect.bisect(repo, state)
871 # update to next check
871 # update to next check
872 node = nodes[0]
872 node = nodes[0]
873 mayupdate(repo, node, show_stats=False)
873 mayupdate(repo, node, show_stats=False)
874 finally:
874 finally:
875 state['current'] = [node]
875 state['current'] = [node]
876 hbisect.save_state(repo, state)
876 hbisect.save_state(repo, state)
877 hbisect.printresult(ui, repo, state, displayer, nodes, bgood)
877 hbisect.printresult(ui, repo, state, displayer, nodes, bgood)
878 return
878 return
879
879
880 hbisect.checkstate(state)
880 hbisect.checkstate(state)
881
881
882 # actually bisect
882 # actually bisect
883 nodes, changesets, good = hbisect.bisect(repo, state)
883 nodes, changesets, good = hbisect.bisect(repo, state)
884 if extend:
884 if extend:
885 if not changesets:
885 if not changesets:
886 extendnode = hbisect.extendrange(repo, state, nodes, good)
886 extendnode = hbisect.extendrange(repo, state, nodes, good)
887 if extendnode is not None:
887 if extendnode is not None:
888 ui.write(_("Extending search to changeset %d:%s\n")
888 ui.write(_("Extending search to changeset %d:%s\n")
889 % (extendnode.rev(), extendnode))
889 % (extendnode.rev(), extendnode))
890 state['current'] = [extendnode.node()]
890 state['current'] = [extendnode.node()]
891 hbisect.save_state(repo, state)
891 hbisect.save_state(repo, state)
892 return mayupdate(repo, extendnode.node())
892 return mayupdate(repo, extendnode.node())
893 raise error.Abort(_("nothing to extend"))
893 raise error.Abort(_("nothing to extend"))
894
894
895 if changesets == 0:
895 if changesets == 0:
896 hbisect.printresult(ui, repo, state, displayer, nodes, good)
896 hbisect.printresult(ui, repo, state, displayer, nodes, good)
897 else:
897 else:
898 assert len(nodes) == 1 # only a single node can be tested next
898 assert len(nodes) == 1 # only a single node can be tested next
899 node = nodes[0]
899 node = nodes[0]
900 # compute the approximate number of remaining tests
900 # compute the approximate number of remaining tests
901 tests, size = 0, 2
901 tests, size = 0, 2
902 while size <= changesets:
902 while size <= changesets:
903 tests, size = tests + 1, size * 2
903 tests, size = tests + 1, size * 2
904 rev = repo.changelog.rev(node)
904 rev = repo.changelog.rev(node)
905 ui.write(_("Testing changeset %d:%s "
905 ui.write(_("Testing changeset %d:%s "
906 "(%d changesets remaining, ~%d tests)\n")
906 "(%d changesets remaining, ~%d tests)\n")
907 % (rev, short(node), changesets, tests))
907 % (rev, short(node), changesets, tests))
908 state['current'] = [node]
908 state['current'] = [node]
909 hbisect.save_state(repo, state)
909 hbisect.save_state(repo, state)
910 return mayupdate(repo, node)
910 return mayupdate(repo, node)
911
911
912 @command('bookmarks|bookmark',
912 @command('bookmarks|bookmark',
913 [('f', 'force', False, _('force')),
913 [('f', 'force', False, _('force')),
914 ('r', 'rev', '', _('revision for bookmark action'), _('REV')),
914 ('r', 'rev', '', _('revision for bookmark action'), _('REV')),
915 ('d', 'delete', False, _('delete a given bookmark')),
915 ('d', 'delete', False, _('delete a given bookmark')),
916 ('m', 'rename', '', _('rename a given bookmark'), _('OLD')),
916 ('m', 'rename', '', _('rename a given bookmark'), _('OLD')),
917 ('i', 'inactive', False, _('mark a bookmark inactive')),
917 ('i', 'inactive', False, _('mark a bookmark inactive')),
918 ] + formatteropts,
918 ] + formatteropts,
919 _('hg bookmarks [OPTIONS]... [NAME]...'))
919 _('hg bookmarks [OPTIONS]... [NAME]...'))
920 def bookmark(ui, repo, *names, **opts):
920 def bookmark(ui, repo, *names, **opts):
921 '''create a new bookmark or list existing bookmarks
921 '''create a new bookmark or list existing bookmarks
922
922
923 Bookmarks are labels on changesets to help track lines of development.
923 Bookmarks are labels on changesets to help track lines of development.
924 Bookmarks are unversioned and can be moved, renamed and deleted.
924 Bookmarks are unversioned and can be moved, renamed and deleted.
925 Deleting or moving a bookmark has no effect on the associated changesets.
925 Deleting or moving a bookmark has no effect on the associated changesets.
926
926
927 Creating or updating to a bookmark causes it to be marked as 'active'.
927 Creating or updating to a bookmark causes it to be marked as 'active'.
928 The active bookmark is indicated with a '*'.
928 The active bookmark is indicated with a '*'.
929 When a commit is made, the active bookmark will advance to the new commit.
929 When a commit is made, the active bookmark will advance to the new commit.
930 A plain :hg:`update` will also advance an active bookmark, if possible.
930 A plain :hg:`update` will also advance an active bookmark, if possible.
931 Updating away from a bookmark will cause it to be deactivated.
931 Updating away from a bookmark will cause it to be deactivated.
932
932
933 Bookmarks can be pushed and pulled between repositories (see
933 Bookmarks can be pushed and pulled between repositories (see
934 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
934 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
935 diverged, a new 'divergent bookmark' of the form 'name@path' will
935 diverged, a new 'divergent bookmark' of the form 'name@path' will
936 be created. Using :hg:`merge` will resolve the divergence.
936 be created. Using :hg:`merge` will resolve the divergence.
937
937
938 Specifying bookmark as '.' to -m or -d options is equivalent to specifying
938 Specifying bookmark as '.' to -m or -d options is equivalent to specifying
939 the active bookmark's name.
939 the active bookmark's name.
940
940
941 A bookmark named '@' has the special property that :hg:`clone` will
941 A bookmark named '@' has the special property that :hg:`clone` will
942 check it out by default if it exists.
942 check it out by default if it exists.
943
943
944 .. container:: verbose
944 .. container:: verbose
945
945
946 Examples:
946 Examples:
947
947
948 - create an active bookmark for a new line of development::
948 - create an active bookmark for a new line of development::
949
949
950 hg book new-feature
950 hg book new-feature
951
951
952 - create an inactive bookmark as a place marker::
952 - create an inactive bookmark as a place marker::
953
953
954 hg book -i reviewed
954 hg book -i reviewed
955
955
956 - create an inactive bookmark on another changeset::
956 - create an inactive bookmark on another changeset::
957
957
958 hg book -r .^ tested
958 hg book -r .^ tested
959
959
960 - rename bookmark turkey to dinner::
960 - rename bookmark turkey to dinner::
961
961
962 hg book -m turkey dinner
962 hg book -m turkey dinner
963
963
964 - move the '@' bookmark from another branch::
964 - move the '@' bookmark from another branch::
965
965
966 hg book -f @
966 hg book -f @
967 '''
967 '''
968 force = opts.get(r'force')
968 force = opts.get(r'force')
969 rev = opts.get(r'rev')
969 rev = opts.get(r'rev')
970 delete = opts.get(r'delete')
970 delete = opts.get(r'delete')
971 rename = opts.get(r'rename')
971 rename = opts.get(r'rename')
972 inactive = opts.get(r'inactive')
972 inactive = opts.get(r'inactive')
973
973
974 if delete and rename:
974 if delete and rename:
975 raise error.Abort(_("--delete and --rename are incompatible"))
975 raise error.Abort(_("--delete and --rename are incompatible"))
976 if delete and rev:
976 if delete and rev:
977 raise error.Abort(_("--rev is incompatible with --delete"))
977 raise error.Abort(_("--rev is incompatible with --delete"))
978 if rename and rev:
978 if rename and rev:
979 raise error.Abort(_("--rev is incompatible with --rename"))
979 raise error.Abort(_("--rev is incompatible with --rename"))
980 if not names and (delete or rev):
980 if not names and (delete or rev):
981 raise error.Abort(_("bookmark name required"))
981 raise error.Abort(_("bookmark name required"))
982
982
983 if delete or rename or names or inactive:
983 if delete or rename or names or inactive:
984 with repo.wlock(), repo.lock(), repo.transaction('bookmark') as tr:
984 with repo.wlock(), repo.lock(), repo.transaction('bookmark') as tr:
985 if delete:
985 if delete:
986 names = pycompat.maplist(repo._bookmarks.expandname, names)
986 names = pycompat.maplist(repo._bookmarks.expandname, names)
987 bookmarks.delete(repo, tr, names)
987 bookmarks.delete(repo, tr, names)
988 elif rename:
988 elif rename:
989 if not names:
989 if not names:
990 raise error.Abort(_("new bookmark name required"))
990 raise error.Abort(_("new bookmark name required"))
991 elif len(names) > 1:
991 elif len(names) > 1:
992 raise error.Abort(_("only one new bookmark name allowed"))
992 raise error.Abort(_("only one new bookmark name allowed"))
993 rename = repo._bookmarks.expandname(rename)
993 rename = repo._bookmarks.expandname(rename)
994 bookmarks.rename(repo, tr, rename, names[0], force, inactive)
994 bookmarks.rename(repo, tr, rename, names[0], force, inactive)
995 elif names:
995 elif names:
996 bookmarks.addbookmarks(repo, tr, names, rev, force, inactive)
996 bookmarks.addbookmarks(repo, tr, names, rev, force, inactive)
997 elif inactive:
997 elif inactive:
998 if len(repo._bookmarks) == 0:
998 if len(repo._bookmarks) == 0:
999 ui.status(_("no bookmarks set\n"))
999 ui.status(_("no bookmarks set\n"))
1000 elif not repo._activebookmark:
1000 elif not repo._activebookmark:
1001 ui.status(_("no active bookmark\n"))
1001 ui.status(_("no active bookmark\n"))
1002 else:
1002 else:
1003 bookmarks.deactivate(repo)
1003 bookmarks.deactivate(repo)
1004 else: # show bookmarks
1004 else: # show bookmarks
1005 bookmarks.printbookmarks(ui, repo, **opts)
1005 bookmarks.printbookmarks(ui, repo, **opts)
1006
1006
1007 @command('branch',
1007 @command('branch',
1008 [('f', 'force', None,
1008 [('f', 'force', None,
1009 _('set branch name even if it shadows an existing branch')),
1009 _('set branch name even if it shadows an existing branch')),
1010 ('C', 'clean', None, _('reset branch name to parent branch name')),
1010 ('C', 'clean', None, _('reset branch name to parent branch name')),
1011 ('r', 'rev', [], _('change branches of the given revs (EXPERIMENTAL)')),
1011 ('r', 'rev', [], _('change branches of the given revs (EXPERIMENTAL)')),
1012 ],
1012 ],
1013 _('[-fC] [NAME]'))
1013 _('[-fC] [NAME]'))
1014 def branch(ui, repo, label=None, **opts):
1014 def branch(ui, repo, label=None, **opts):
1015 """set or show the current branch name
1015 """set or show the current branch name
1016
1016
1017 .. note::
1017 .. note::
1018
1018
1019 Branch names are permanent and global. Use :hg:`bookmark` to create a
1019 Branch names are permanent and global. Use :hg:`bookmark` to create a
1020 light-weight bookmark instead. See :hg:`help glossary` for more
1020 light-weight bookmark instead. See :hg:`help glossary` for more
1021 information about named branches and bookmarks.
1021 information about named branches and bookmarks.
1022
1022
1023 With no argument, show the current branch name. With one argument,
1023 With no argument, show the current branch name. With one argument,
1024 set the working directory branch name (the branch will not exist
1024 set the working directory branch name (the branch will not exist
1025 in the repository until the next commit). Standard practice
1025 in the repository until the next commit). Standard practice
1026 recommends that primary development take place on the 'default'
1026 recommends that primary development take place on the 'default'
1027 branch.
1027 branch.
1028
1028
1029 Unless -f/--force is specified, branch will not let you set a
1029 Unless -f/--force is specified, branch will not let you set a
1030 branch name that already exists.
1030 branch name that already exists.
1031
1031
1032 Use -C/--clean to reset the working directory branch to that of
1032 Use -C/--clean to reset the working directory branch to that of
1033 the parent of the working directory, negating a previous branch
1033 the parent of the working directory, negating a previous branch
1034 change.
1034 change.
1035
1035
1036 Use the command :hg:`update` to switch to an existing branch. Use
1036 Use the command :hg:`update` to switch to an existing branch. Use
1037 :hg:`commit --close-branch` to mark this branch head as closed.
1037 :hg:`commit --close-branch` to mark this branch head as closed.
1038 When all heads of a branch are closed, the branch will be
1038 When all heads of a branch are closed, the branch will be
1039 considered closed.
1039 considered closed.
1040
1040
1041 Returns 0 on success.
1041 Returns 0 on success.
1042 """
1042 """
1043 opts = pycompat.byteskwargs(opts)
1043 opts = pycompat.byteskwargs(opts)
1044 revs = opts.get('rev')
1044 revs = opts.get('rev')
1045 if label:
1045 if label:
1046 label = label.strip()
1046 label = label.strip()
1047
1047
1048 if not opts.get('clean') and not label:
1048 if not opts.get('clean') and not label:
1049 if revs:
1049 if revs:
1050 raise error.Abort(_("no branch name specified for the revisions"))
1050 raise error.Abort(_("no branch name specified for the revisions"))
1051 ui.write("%s\n" % repo.dirstate.branch())
1051 ui.write("%s\n" % repo.dirstate.branch())
1052 return
1052 return
1053
1053
1054 with repo.wlock():
1054 with repo.wlock():
1055 if opts.get('clean'):
1055 if opts.get('clean'):
1056 label = repo[None].p1().branch()
1056 label = repo[None].p1().branch()
1057 repo.dirstate.setbranch(label)
1057 repo.dirstate.setbranch(label)
1058 ui.status(_('reset working directory to branch %s\n') % label)
1058 ui.status(_('reset working directory to branch %s\n') % label)
1059 elif label:
1059 elif label:
1060
1060
1061 scmutil.checknewlabel(repo, label, 'branch')
1061 scmutil.checknewlabel(repo, label, 'branch')
1062 if revs:
1062 if revs:
1063 return cmdutil.changebranch(ui, repo, revs, label)
1063 return cmdutil.changebranch(ui, repo, revs, label)
1064
1064
1065 if not opts.get('force') and label in repo.branchmap():
1065 if not opts.get('force') and label in repo.branchmap():
1066 if label not in [p.branch() for p in repo[None].parents()]:
1066 if label not in [p.branch() for p in repo[None].parents()]:
1067 raise error.Abort(_('a branch of the same name already'
1067 raise error.Abort(_('a branch of the same name already'
1068 ' exists'),
1068 ' exists'),
1069 # i18n: "it" refers to an existing branch
1069 # i18n: "it" refers to an existing branch
1070 hint=_("use 'hg update' to switch to it"))
1070 hint=_("use 'hg update' to switch to it"))
1071
1071
1072 repo.dirstate.setbranch(label)
1072 repo.dirstate.setbranch(label)
1073 ui.status(_('marked working directory as branch %s\n') % label)
1073 ui.status(_('marked working directory as branch %s\n') % label)
1074
1074
1075 # find any open named branches aside from default
1075 # find any open named branches aside from default
1076 others = [n for n, h, t, c in repo.branchmap().iterbranches()
1076 others = [n for n, h, t, c in repo.branchmap().iterbranches()
1077 if n != "default" and not c]
1077 if n != "default" and not c]
1078 if not others:
1078 if not others:
1079 ui.status(_('(branches are permanent and global, '
1079 ui.status(_('(branches are permanent and global, '
1080 'did you want a bookmark?)\n'))
1080 'did you want a bookmark?)\n'))
1081
1081
1082 @command('branches',
1082 @command('branches',
1083 [('a', 'active', False,
1083 [('a', 'active', False,
1084 _('show only branches that have unmerged heads (DEPRECATED)')),
1084 _('show only branches that have unmerged heads (DEPRECATED)')),
1085 ('c', 'closed', False, _('show normal and closed branches')),
1085 ('c', 'closed', False, _('show normal and closed branches')),
1086 ] + formatteropts,
1086 ] + formatteropts,
1087 _('[-c]'),
1087 _('[-c]'),
1088 intents={INTENT_READONLY})
1088 intents={INTENT_READONLY})
1089 def branches(ui, repo, active=False, closed=False, **opts):
1089 def branches(ui, repo, active=False, closed=False, **opts):
1090 """list repository named branches
1090 """list repository named branches
1091
1091
1092 List the repository's named branches, indicating which ones are
1092 List the repository's named branches, indicating which ones are
1093 inactive. If -c/--closed is specified, also list branches which have
1093 inactive. If -c/--closed is specified, also list branches which have
1094 been marked closed (see :hg:`commit --close-branch`).
1094 been marked closed (see :hg:`commit --close-branch`).
1095
1095
1096 Use the command :hg:`update` to switch to an existing branch.
1096 Use the command :hg:`update` to switch to an existing branch.
1097
1097
1098 Returns 0.
1098 Returns 0.
1099 """
1099 """
1100
1100
1101 opts = pycompat.byteskwargs(opts)
1101 opts = pycompat.byteskwargs(opts)
1102 ui.pager('branches')
1102 ui.pager('branches')
1103 fm = ui.formatter('branches', opts)
1103 fm = ui.formatter('branches', opts)
1104 hexfunc = fm.hexfunc
1104 hexfunc = fm.hexfunc
1105
1105
1106 allheads = set(repo.heads())
1106 allheads = set(repo.heads())
1107 branches = []
1107 branches = []
1108 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1108 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1109 isactive = False
1109 isactive = False
1110 if not isclosed:
1110 if not isclosed:
1111 openheads = set(repo.branchmap().iteropen(heads))
1111 openheads = set(repo.branchmap().iteropen(heads))
1112 isactive = bool(openheads & allheads)
1112 isactive = bool(openheads & allheads)
1113 branches.append((tag, repo[tip], isactive, not isclosed))
1113 branches.append((tag, repo[tip], isactive, not isclosed))
1114 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1114 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1115 reverse=True)
1115 reverse=True)
1116
1116
1117 for tag, ctx, isactive, isopen in branches:
1117 for tag, ctx, isactive, isopen in branches:
1118 if active and not isactive:
1118 if active and not isactive:
1119 continue
1119 continue
1120 if isactive:
1120 if isactive:
1121 label = 'branches.active'
1121 label = 'branches.active'
1122 notice = ''
1122 notice = ''
1123 elif not isopen:
1123 elif not isopen:
1124 if not closed:
1124 if not closed:
1125 continue
1125 continue
1126 label = 'branches.closed'
1126 label = 'branches.closed'
1127 notice = _(' (closed)')
1127 notice = _(' (closed)')
1128 else:
1128 else:
1129 label = 'branches.inactive'
1129 label = 'branches.inactive'
1130 notice = _(' (inactive)')
1130 notice = _(' (inactive)')
1131 current = (tag == repo.dirstate.branch())
1131 current = (tag == repo.dirstate.branch())
1132 if current:
1132 if current:
1133 label = 'branches.current'
1133 label = 'branches.current'
1134
1134
1135 fm.startitem()
1135 fm.startitem()
1136 fm.write('branch', '%s', tag, label=label)
1136 fm.write('branch', '%s', tag, label=label)
1137 rev = ctx.rev()
1137 rev = ctx.rev()
1138 padsize = max(31 - len("%d" % rev) - encoding.colwidth(tag), 0)
1138 padsize = max(31 - len("%d" % rev) - encoding.colwidth(tag), 0)
1139 fmt = ' ' * padsize + ' %d:%s'
1139 fmt = ' ' * padsize + ' %d:%s'
1140 fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
1140 fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
1141 label='log.changeset changeset.%s' % ctx.phasestr())
1141 label='log.changeset changeset.%s' % ctx.phasestr())
1142 fm.context(ctx=ctx)
1142 fm.context(ctx=ctx)
1143 fm.data(active=isactive, closed=not isopen, current=current)
1143 fm.data(active=isactive, closed=not isopen, current=current)
1144 if not ui.quiet:
1144 if not ui.quiet:
1145 fm.plain(notice)
1145 fm.plain(notice)
1146 fm.plain('\n')
1146 fm.plain('\n')
1147 fm.end()
1147 fm.end()
1148
1148
1149 @command('bundle',
1149 @command('bundle',
1150 [('f', 'force', None, _('run even when the destination is unrelated')),
1150 [('f', 'force', None, _('run even when the destination is unrelated')),
1151 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1151 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1152 _('REV')),
1152 _('REV')),
1153 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1153 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1154 _('BRANCH')),
1154 _('BRANCH')),
1155 ('', 'base', [],
1155 ('', 'base', [],
1156 _('a base changeset assumed to be available at the destination'),
1156 _('a base changeset assumed to be available at the destination'),
1157 _('REV')),
1157 _('REV')),
1158 ('a', 'all', None, _('bundle all changesets in the repository')),
1158 ('a', 'all', None, _('bundle all changesets in the repository')),
1159 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1159 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1160 ] + remoteopts,
1160 ] + remoteopts,
1161 _('[-f] [-t BUNDLESPEC] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1161 _('[-f] [-t BUNDLESPEC] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1162 def bundle(ui, repo, fname, dest=None, **opts):
1162 def bundle(ui, repo, fname, dest=None, **opts):
1163 """create a bundle file
1163 """create a bundle file
1164
1164
1165 Generate a bundle file containing data to be transferred to another
1165 Generate a bundle file containing data to be transferred to another
1166 repository.
1166 repository.
1167
1167
1168 To create a bundle containing all changesets, use -a/--all
1168 To create a bundle containing all changesets, use -a/--all
1169 (or --base null). Otherwise, hg assumes the destination will have
1169 (or --base null). Otherwise, hg assumes the destination will have
1170 all the nodes you specify with --base parameters. Otherwise, hg
1170 all the nodes you specify with --base parameters. Otherwise, hg
1171 will assume the repository has all the nodes in destination, or
1171 will assume the repository has all the nodes in destination, or
1172 default-push/default if no destination is specified, where destination
1172 default-push/default if no destination is specified, where destination
1173 is the repository you provide through DEST option.
1173 is the repository you provide through DEST option.
1174
1174
1175 You can change bundle format with the -t/--type option. See
1175 You can change bundle format with the -t/--type option. See
1176 :hg:`help bundlespec` for documentation on this format. By default,
1176 :hg:`help bundlespec` for documentation on this format. By default,
1177 the most appropriate format is used and compression defaults to
1177 the most appropriate format is used and compression defaults to
1178 bzip2.
1178 bzip2.
1179
1179
1180 The bundle file can then be transferred using conventional means
1180 The bundle file can then be transferred using conventional means
1181 and applied to another repository with the unbundle or pull
1181 and applied to another repository with the unbundle or pull
1182 command. This is useful when direct push and pull are not
1182 command. This is useful when direct push and pull are not
1183 available or when exporting an entire repository is undesirable.
1183 available or when exporting an entire repository is undesirable.
1184
1184
1185 Applying bundles preserves all changeset contents including
1185 Applying bundles preserves all changeset contents including
1186 permissions, copy/rename information, and revision history.
1186 permissions, copy/rename information, and revision history.
1187
1187
1188 Returns 0 on success, 1 if no changes found.
1188 Returns 0 on success, 1 if no changes found.
1189 """
1189 """
1190 opts = pycompat.byteskwargs(opts)
1190 opts = pycompat.byteskwargs(opts)
1191 revs = None
1191 revs = None
1192 if 'rev' in opts:
1192 if 'rev' in opts:
1193 revstrings = opts['rev']
1193 revstrings = opts['rev']
1194 revs = scmutil.revrange(repo, revstrings)
1194 revs = scmutil.revrange(repo, revstrings)
1195 if revstrings and not revs:
1195 if revstrings and not revs:
1196 raise error.Abort(_('no commits to bundle'))
1196 raise error.Abort(_('no commits to bundle'))
1197
1197
1198 bundletype = opts.get('type', 'bzip2').lower()
1198 bundletype = opts.get('type', 'bzip2').lower()
1199 try:
1199 try:
1200 bundlespec = exchange.parsebundlespec(repo, bundletype, strict=False)
1200 bundlespec = exchange.parsebundlespec(repo, bundletype, strict=False)
1201 except error.UnsupportedBundleSpecification as e:
1201 except error.UnsupportedBundleSpecification as e:
1202 raise error.Abort(pycompat.bytestr(e),
1202 raise error.Abort(pycompat.bytestr(e),
1203 hint=_("see 'hg help bundlespec' for supported "
1203 hint=_("see 'hg help bundlespec' for supported "
1204 "values for --type"))
1204 "values for --type"))
1205 cgversion = bundlespec.contentopts["cg.version"]
1205 cgversion = bundlespec.contentopts["cg.version"]
1206
1206
1207 # Packed bundles are a pseudo bundle format for now.
1207 # Packed bundles are a pseudo bundle format for now.
1208 if cgversion == 's1':
1208 if cgversion == 's1':
1209 raise error.Abort(_('packed bundles cannot be produced by "hg bundle"'),
1209 raise error.Abort(_('packed bundles cannot be produced by "hg bundle"'),
1210 hint=_("use 'hg debugcreatestreamclonebundle'"))
1210 hint=_("use 'hg debugcreatestreamclonebundle'"))
1211
1211
1212 if opts.get('all'):
1212 if opts.get('all'):
1213 if dest:
1213 if dest:
1214 raise error.Abort(_("--all is incompatible with specifying "
1214 raise error.Abort(_("--all is incompatible with specifying "
1215 "a destination"))
1215 "a destination"))
1216 if opts.get('base'):
1216 if opts.get('base'):
1217 ui.warn(_("ignoring --base because --all was specified\n"))
1217 ui.warn(_("ignoring --base because --all was specified\n"))
1218 base = ['null']
1218 base = ['null']
1219 else:
1219 else:
1220 base = scmutil.revrange(repo, opts.get('base'))
1220 base = scmutil.revrange(repo, opts.get('base'))
1221 if cgversion not in changegroup.supportedoutgoingversions(repo):
1221 if cgversion not in changegroup.supportedoutgoingversions(repo):
1222 raise error.Abort(_("repository does not support bundle version %s") %
1222 raise error.Abort(_("repository does not support bundle version %s") %
1223 cgversion)
1223 cgversion)
1224
1224
1225 if base:
1225 if base:
1226 if dest:
1226 if dest:
1227 raise error.Abort(_("--base is incompatible with specifying "
1227 raise error.Abort(_("--base is incompatible with specifying "
1228 "a destination"))
1228 "a destination"))
1229 common = [repo[rev].node() for rev in base]
1229 common = [repo[rev].node() for rev in base]
1230 heads = [repo[r].node() for r in revs] if revs else None
1230 heads = [repo[r].node() for r in revs] if revs else None
1231 outgoing = discovery.outgoing(repo, common, heads)
1231 outgoing = discovery.outgoing(repo, common, heads)
1232 else:
1232 else:
1233 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1233 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1234 dest, branches = hg.parseurl(dest, opts.get('branch'))
1234 dest, branches = hg.parseurl(dest, opts.get('branch'))
1235 other = hg.peer(repo, opts, dest)
1235 other = hg.peer(repo, opts, dest)
1236 revs = [repo[r].hex() for r in revs]
1236 revs = [repo[r].hex() for r in revs]
1237 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1237 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1238 heads = revs and map(repo.lookup, revs) or revs
1238 heads = revs and map(repo.lookup, revs) or revs
1239 outgoing = discovery.findcommonoutgoing(repo, other,
1239 outgoing = discovery.findcommonoutgoing(repo, other,
1240 onlyheads=heads,
1240 onlyheads=heads,
1241 force=opts.get('force'),
1241 force=opts.get('force'),
1242 portable=True)
1242 portable=True)
1243
1243
1244 if not outgoing.missing:
1244 if not outgoing.missing:
1245 scmutil.nochangesfound(ui, repo, not base and outgoing.excluded)
1245 scmutil.nochangesfound(ui, repo, not base and outgoing.excluded)
1246 return 1
1246 return 1
1247
1247
1248 if cgversion == '01': #bundle1
1248 if cgversion == '01': #bundle1
1249 bversion = 'HG10' + bundlespec.wirecompression
1249 bversion = 'HG10' + bundlespec.wirecompression
1250 bcompression = None
1250 bcompression = None
1251 elif cgversion in ('02', '03'):
1251 elif cgversion in ('02', '03'):
1252 bversion = 'HG20'
1252 bversion = 'HG20'
1253 bcompression = bundlespec.wirecompression
1253 bcompression = bundlespec.wirecompression
1254 else:
1254 else:
1255 raise error.ProgrammingError(
1255 raise error.ProgrammingError(
1256 'bundle: unexpected changegroup version %s' % cgversion)
1256 'bundle: unexpected changegroup version %s' % cgversion)
1257
1257
1258 # TODO compression options should be derived from bundlespec parsing.
1258 # TODO compression options should be derived from bundlespec parsing.
1259 # This is a temporary hack to allow adjusting bundle compression
1259 # This is a temporary hack to allow adjusting bundle compression
1260 # level without a) formalizing the bundlespec changes to declare it
1260 # level without a) formalizing the bundlespec changes to declare it
1261 # b) introducing a command flag.
1261 # b) introducing a command flag.
1262 compopts = {}
1262 compopts = {}
1263 complevel = ui.configint('experimental',
1263 complevel = ui.configint('experimental',
1264 'bundlecomplevel.' + bundlespec.compression)
1264 'bundlecomplevel.' + bundlespec.compression)
1265 if complevel is None:
1265 if complevel is None:
1266 complevel = ui.configint('experimental', 'bundlecomplevel')
1266 complevel = ui.configint('experimental', 'bundlecomplevel')
1267 if complevel is not None:
1267 if complevel is not None:
1268 compopts['level'] = complevel
1268 compopts['level'] = complevel
1269
1269
1270 # Allow overriding the bundling of obsmarker in phases through
1270 # Allow overriding the bundling of obsmarker in phases through
1271 # configuration while we don't have a bundle version that include them
1271 # configuration while we don't have a bundle version that include them
1272 if repo.ui.configbool('experimental', 'evolution.bundle-obsmarker'):
1272 if repo.ui.configbool('experimental', 'evolution.bundle-obsmarker'):
1273 bundlespec.contentopts['obsolescence'] = True
1273 bundlespec.contentopts['obsolescence'] = True
1274 if repo.ui.configbool('experimental', 'bundle-phases'):
1274 if repo.ui.configbool('experimental', 'bundle-phases'):
1275 bundlespec.contentopts['phases'] = True
1275 bundlespec.contentopts['phases'] = True
1276
1276
1277 bundle2.writenewbundle(ui, repo, 'bundle', fname, bversion, outgoing,
1277 bundle2.writenewbundle(ui, repo, 'bundle', fname, bversion, outgoing,
1278 bundlespec.contentopts, compression=bcompression,
1278 bundlespec.contentopts, compression=bcompression,
1279 compopts=compopts)
1279 compopts=compopts)
1280
1280
1281 @command('cat',
1281 @command('cat',
1282 [('o', 'output', '',
1282 [('o', 'output', '',
1283 _('print output to file with formatted name'), _('FORMAT')),
1283 _('print output to file with formatted name'), _('FORMAT')),
1284 ('r', 'rev', '', _('print the given revision'), _('REV')),
1284 ('r', 'rev', '', _('print the given revision'), _('REV')),
1285 ('', 'decode', None, _('apply any matching decode filter')),
1285 ('', 'decode', None, _('apply any matching decode filter')),
1286 ] + walkopts + formatteropts,
1286 ] + walkopts + formatteropts,
1287 _('[OPTION]... FILE...'),
1287 _('[OPTION]... FILE...'),
1288 inferrepo=True,
1288 inferrepo=True,
1289 intents={INTENT_READONLY})
1289 intents={INTENT_READONLY})
1290 def cat(ui, repo, file1, *pats, **opts):
1290 def cat(ui, repo, file1, *pats, **opts):
1291 """output the current or given revision of files
1291 """output the current or given revision of files
1292
1292
1293 Print the specified files as they were at the given revision. If
1293 Print the specified files as they were at the given revision. If
1294 no revision is given, the parent of the working directory is used.
1294 no revision is given, the parent of the working directory is used.
1295
1295
1296 Output may be to a file, in which case the name of the file is
1296 Output may be to a file, in which case the name of the file is
1297 given using a template string. See :hg:`help templates`. In addition
1297 given using a template string. See :hg:`help templates`. In addition
1298 to the common template keywords, the following formatting rules are
1298 to the common template keywords, the following formatting rules are
1299 supported:
1299 supported:
1300
1300
1301 :``%%``: literal "%" character
1301 :``%%``: literal "%" character
1302 :``%s``: basename of file being printed
1302 :``%s``: basename of file being printed
1303 :``%d``: dirname of file being printed, or '.' if in repository root
1303 :``%d``: dirname of file being printed, or '.' if in repository root
1304 :``%p``: root-relative path name of file being printed
1304 :``%p``: root-relative path name of file being printed
1305 :``%H``: changeset hash (40 hexadecimal digits)
1305 :``%H``: changeset hash (40 hexadecimal digits)
1306 :``%R``: changeset revision number
1306 :``%R``: changeset revision number
1307 :``%h``: short-form changeset hash (12 hexadecimal digits)
1307 :``%h``: short-form changeset hash (12 hexadecimal digits)
1308 :``%r``: zero-padded changeset revision number
1308 :``%r``: zero-padded changeset revision number
1309 :``%b``: basename of the exporting repository
1309 :``%b``: basename of the exporting repository
1310 :``\\``: literal "\\" character
1310 :``\\``: literal "\\" character
1311
1311
1312 Returns 0 on success.
1312 Returns 0 on success.
1313 """
1313 """
1314 opts = pycompat.byteskwargs(opts)
1314 opts = pycompat.byteskwargs(opts)
1315 rev = opts.get('rev')
1315 rev = opts.get('rev')
1316 if rev:
1316 if rev:
1317 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
1317 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
1318 ctx = scmutil.revsingle(repo, rev)
1318 ctx = scmutil.revsingle(repo, rev)
1319 m = scmutil.match(ctx, (file1,) + pats, opts)
1319 m = scmutil.match(ctx, (file1,) + pats, opts)
1320 fntemplate = opts.pop('output', '')
1320 fntemplate = opts.pop('output', '')
1321 if cmdutil.isstdiofilename(fntemplate):
1321 if cmdutil.isstdiofilename(fntemplate):
1322 fntemplate = ''
1322 fntemplate = ''
1323
1323
1324 if fntemplate:
1324 if fntemplate:
1325 fm = formatter.nullformatter(ui, 'cat', opts)
1325 fm = formatter.nullformatter(ui, 'cat', opts)
1326 else:
1326 else:
1327 ui.pager('cat')
1327 ui.pager('cat')
1328 fm = ui.formatter('cat', opts)
1328 fm = ui.formatter('cat', opts)
1329 with fm:
1329 with fm:
1330 return cmdutil.cat(ui, repo, ctx, m, fm, fntemplate, '',
1330 return cmdutil.cat(ui, repo, ctx, m, fm, fntemplate, '',
1331 **pycompat.strkwargs(opts))
1331 **pycompat.strkwargs(opts))
1332
1332
1333 @command('^clone',
1333 @command('^clone',
1334 [('U', 'noupdate', None, _('the clone will include an empty working '
1334 [('U', 'noupdate', None, _('the clone will include an empty working '
1335 'directory (only a repository)')),
1335 'directory (only a repository)')),
1336 ('u', 'updaterev', '', _('revision, tag, or branch to check out'),
1336 ('u', 'updaterev', '', _('revision, tag, or branch to check out'),
1337 _('REV')),
1337 _('REV')),
1338 ('r', 'rev', [], _('do not clone everything, but include this changeset'
1338 ('r', 'rev', [], _('do not clone everything, but include this changeset'
1339 ' and its ancestors'), _('REV')),
1339 ' and its ancestors'), _('REV')),
1340 ('b', 'branch', [], _('do not clone everything, but include this branch\'s'
1340 ('b', 'branch', [], _('do not clone everything, but include this branch\'s'
1341 ' changesets and their ancestors'), _('BRANCH')),
1341 ' changesets and their ancestors'), _('BRANCH')),
1342 ('', 'pull', None, _('use pull protocol to copy metadata')),
1342 ('', 'pull', None, _('use pull protocol to copy metadata')),
1343 ('', 'uncompressed', None,
1343 ('', 'uncompressed', None,
1344 _('an alias to --stream (DEPRECATED)')),
1344 _('an alias to --stream (DEPRECATED)')),
1345 ('', 'stream', None,
1345 ('', 'stream', None,
1346 _('clone with minimal data processing')),
1346 _('clone with minimal data processing')),
1347 ] + remoteopts,
1347 ] + remoteopts,
1348 _('[OPTION]... SOURCE [DEST]'),
1348 _('[OPTION]... SOURCE [DEST]'),
1349 norepo=True)
1349 norepo=True)
1350 def clone(ui, source, dest=None, **opts):
1350 def clone(ui, source, dest=None, **opts):
1351 """make a copy of an existing repository
1351 """make a copy of an existing repository
1352
1352
1353 Create a copy of an existing repository in a new directory.
1353 Create a copy of an existing repository in a new directory.
1354
1354
1355 If no destination directory name is specified, it defaults to the
1355 If no destination directory name is specified, it defaults to the
1356 basename of the source.
1356 basename of the source.
1357
1357
1358 The location of the source is added to the new repository's
1358 The location of the source is added to the new repository's
1359 ``.hg/hgrc`` file, as the default to be used for future pulls.
1359 ``.hg/hgrc`` file, as the default to be used for future pulls.
1360
1360
1361 Only local paths and ``ssh://`` URLs are supported as
1361 Only local paths and ``ssh://`` URLs are supported as
1362 destinations. For ``ssh://`` destinations, no working directory or
1362 destinations. For ``ssh://`` destinations, no working directory or
1363 ``.hg/hgrc`` will be created on the remote side.
1363 ``.hg/hgrc`` will be created on the remote side.
1364
1364
1365 If the source repository has a bookmark called '@' set, that
1365 If the source repository has a bookmark called '@' set, that
1366 revision will be checked out in the new repository by default.
1366 revision will be checked out in the new repository by default.
1367
1367
1368 To check out a particular version, use -u/--update, or
1368 To check out a particular version, use -u/--update, or
1369 -U/--noupdate to create a clone with no working directory.
1369 -U/--noupdate to create a clone with no working directory.
1370
1370
1371 To pull only a subset of changesets, specify one or more revisions
1371 To pull only a subset of changesets, specify one or more revisions
1372 identifiers with -r/--rev or branches with -b/--branch. The
1372 identifiers with -r/--rev or branches with -b/--branch. The
1373 resulting clone will contain only the specified changesets and
1373 resulting clone will contain only the specified changesets and
1374 their ancestors. These options (or 'clone src#rev dest') imply
1374 their ancestors. These options (or 'clone src#rev dest') imply
1375 --pull, even for local source repositories.
1375 --pull, even for local source repositories.
1376
1376
1377 In normal clone mode, the remote normalizes repository data into a common
1377 In normal clone mode, the remote normalizes repository data into a common
1378 exchange format and the receiving end translates this data into its local
1378 exchange format and the receiving end translates this data into its local
1379 storage format. --stream activates a different clone mode that essentially
1379 storage format. --stream activates a different clone mode that essentially
1380 copies repository files from the remote with minimal data processing. This
1380 copies repository files from the remote with minimal data processing. This
1381 significantly reduces the CPU cost of a clone both remotely and locally.
1381 significantly reduces the CPU cost of a clone both remotely and locally.
1382 However, it often increases the transferred data size by 30-40%. This can
1382 However, it often increases the transferred data size by 30-40%. This can
1383 result in substantially faster clones where I/O throughput is plentiful,
1383 result in substantially faster clones where I/O throughput is plentiful,
1384 especially for larger repositories. A side-effect of --stream clones is
1384 especially for larger repositories. A side-effect of --stream clones is
1385 that storage settings and requirements on the remote are applied locally:
1385 that storage settings and requirements on the remote are applied locally:
1386 a modern client may inherit legacy or inefficient storage used by the
1386 a modern client may inherit legacy or inefficient storage used by the
1387 remote or a legacy Mercurial client may not be able to clone from a
1387 remote or a legacy Mercurial client may not be able to clone from a
1388 modern Mercurial remote.
1388 modern Mercurial remote.
1389
1389
1390 .. note::
1390 .. note::
1391
1391
1392 Specifying a tag will include the tagged changeset but not the
1392 Specifying a tag will include the tagged changeset but not the
1393 changeset containing the tag.
1393 changeset containing the tag.
1394
1394
1395 .. container:: verbose
1395 .. container:: verbose
1396
1396
1397 For efficiency, hardlinks are used for cloning whenever the
1397 For efficiency, hardlinks are used for cloning whenever the
1398 source and destination are on the same filesystem (note this
1398 source and destination are on the same filesystem (note this
1399 applies only to the repository data, not to the working
1399 applies only to the repository data, not to the working
1400 directory). Some filesystems, such as AFS, implement hardlinking
1400 directory). Some filesystems, such as AFS, implement hardlinking
1401 incorrectly, but do not report errors. In these cases, use the
1401 incorrectly, but do not report errors. In these cases, use the
1402 --pull option to avoid hardlinking.
1402 --pull option to avoid hardlinking.
1403
1403
1404 Mercurial will update the working directory to the first applicable
1404 Mercurial will update the working directory to the first applicable
1405 revision from this list:
1405 revision from this list:
1406
1406
1407 a) null if -U or the source repository has no changesets
1407 a) null if -U or the source repository has no changesets
1408 b) if -u . and the source repository is local, the first parent of
1408 b) if -u . and the source repository is local, the first parent of
1409 the source repository's working directory
1409 the source repository's working directory
1410 c) the changeset specified with -u (if a branch name, this means the
1410 c) the changeset specified with -u (if a branch name, this means the
1411 latest head of that branch)
1411 latest head of that branch)
1412 d) the changeset specified with -r
1412 d) the changeset specified with -r
1413 e) the tipmost head specified with -b
1413 e) the tipmost head specified with -b
1414 f) the tipmost head specified with the url#branch source syntax
1414 f) the tipmost head specified with the url#branch source syntax
1415 g) the revision marked with the '@' bookmark, if present
1415 g) the revision marked with the '@' bookmark, if present
1416 h) the tipmost head of the default branch
1416 h) the tipmost head of the default branch
1417 i) tip
1417 i) tip
1418
1418
1419 When cloning from servers that support it, Mercurial may fetch
1419 When cloning from servers that support it, Mercurial may fetch
1420 pre-generated data from a server-advertised URL or inline from the
1420 pre-generated data from a server-advertised URL or inline from the
1421 same stream. When this is done, hooks operating on incoming changesets
1421 same stream. When this is done, hooks operating on incoming changesets
1422 and changegroups may fire more than once, once for each pre-generated
1422 and changegroups may fire more than once, once for each pre-generated
1423 bundle and as well as for any additional remaining data. In addition,
1423 bundle and as well as for any additional remaining data. In addition,
1424 if an error occurs, the repository may be rolled back to a partial
1424 if an error occurs, the repository may be rolled back to a partial
1425 clone. This behavior may change in future releases.
1425 clone. This behavior may change in future releases.
1426 See :hg:`help -e clonebundles` for more.
1426 See :hg:`help -e clonebundles` for more.
1427
1427
1428 Examples:
1428 Examples:
1429
1429
1430 - clone a remote repository to a new directory named hg/::
1430 - clone a remote repository to a new directory named hg/::
1431
1431
1432 hg clone https://www.mercurial-scm.org/repo/hg/
1432 hg clone https://www.mercurial-scm.org/repo/hg/
1433
1433
1434 - create a lightweight local clone::
1434 - create a lightweight local clone::
1435
1435
1436 hg clone project/ project-feature/
1436 hg clone project/ project-feature/
1437
1437
1438 - clone from an absolute path on an ssh server (note double-slash)::
1438 - clone from an absolute path on an ssh server (note double-slash)::
1439
1439
1440 hg clone ssh://user@server//home/projects/alpha/
1440 hg clone ssh://user@server//home/projects/alpha/
1441
1441
1442 - do a streaming clone while checking out a specified version::
1442 - do a streaming clone while checking out a specified version::
1443
1443
1444 hg clone --stream http://server/repo -u 1.5
1444 hg clone --stream http://server/repo -u 1.5
1445
1445
1446 - create a repository without changesets after a particular revision::
1446 - create a repository without changesets after a particular revision::
1447
1447
1448 hg clone -r 04e544 experimental/ good/
1448 hg clone -r 04e544 experimental/ good/
1449
1449
1450 - clone (and track) a particular named branch::
1450 - clone (and track) a particular named branch::
1451
1451
1452 hg clone https://www.mercurial-scm.org/repo/hg/#stable
1452 hg clone https://www.mercurial-scm.org/repo/hg/#stable
1453
1453
1454 See :hg:`help urls` for details on specifying URLs.
1454 See :hg:`help urls` for details on specifying URLs.
1455
1455
1456 Returns 0 on success.
1456 Returns 0 on success.
1457 """
1457 """
1458 opts = pycompat.byteskwargs(opts)
1458 opts = pycompat.byteskwargs(opts)
1459 if opts.get('noupdate') and opts.get('updaterev'):
1459 if opts.get('noupdate') and opts.get('updaterev'):
1460 raise error.Abort(_("cannot specify both --noupdate and --updaterev"))
1460 raise error.Abort(_("cannot specify both --noupdate and --updaterev"))
1461
1461
1462 r = hg.clone(ui, opts, source, dest,
1462 r = hg.clone(ui, opts, source, dest,
1463 pull=opts.get('pull'),
1463 pull=opts.get('pull'),
1464 stream=opts.get('stream') or opts.get('uncompressed'),
1464 stream=opts.get('stream') or opts.get('uncompressed'),
1465 revs=opts.get('rev'),
1465 revs=opts.get('rev'),
1466 update=opts.get('updaterev') or not opts.get('noupdate'),
1466 update=opts.get('updaterev') or not opts.get('noupdate'),
1467 branch=opts.get('branch'),
1467 branch=opts.get('branch'),
1468 shareopts=opts.get('shareopts'))
1468 shareopts=opts.get('shareopts'))
1469
1469
1470 return r is None
1470 return r is None
1471
1471
1472 @command('^commit|ci',
1472 @command('^commit|ci',
1473 [('A', 'addremove', None,
1473 [('A', 'addremove', None,
1474 _('mark new/missing files as added/removed before committing')),
1474 _('mark new/missing files as added/removed before committing')),
1475 ('', 'close-branch', None,
1475 ('', 'close-branch', None,
1476 _('mark a branch head as closed')),
1476 _('mark a branch head as closed')),
1477 ('', 'amend', None, _('amend the parent of the working directory')),
1477 ('', 'amend', None, _('amend the parent of the working directory')),
1478 ('s', 'secret', None, _('use the secret phase for committing')),
1478 ('s', 'secret', None, _('use the secret phase for committing')),
1479 ('e', 'edit', None, _('invoke editor on commit messages')),
1479 ('e', 'edit', None, _('invoke editor on commit messages')),
1480 ('i', 'interactive', None, _('use interactive mode')),
1480 ('i', 'interactive', None, _('use interactive mode')),
1481 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1481 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1482 _('[OPTION]... [FILE]...'),
1482 _('[OPTION]... [FILE]...'),
1483 inferrepo=True)
1483 inferrepo=True)
1484 def commit(ui, repo, *pats, **opts):
1484 def commit(ui, repo, *pats, **opts):
1485 """commit the specified files or all outstanding changes
1485 """commit the specified files or all outstanding changes
1486
1486
1487 Commit changes to the given files into the repository. Unlike a
1487 Commit changes to the given files into the repository. Unlike a
1488 centralized SCM, this operation is a local operation. See
1488 centralized SCM, this operation is a local operation. See
1489 :hg:`push` for a way to actively distribute your changes.
1489 :hg:`push` for a way to actively distribute your changes.
1490
1490
1491 If a list of files is omitted, all changes reported by :hg:`status`
1491 If a list of files is omitted, all changes reported by :hg:`status`
1492 will be committed.
1492 will be committed.
1493
1493
1494 If you are committing the result of a merge, do not provide any
1494 If you are committing the result of a merge, do not provide any
1495 filenames or -I/-X filters.
1495 filenames or -I/-X filters.
1496
1496
1497 If no commit message is specified, Mercurial starts your
1497 If no commit message is specified, Mercurial starts your
1498 configured editor where you can enter a message. In case your
1498 configured editor where you can enter a message. In case your
1499 commit fails, you will find a backup of your message in
1499 commit fails, you will find a backup of your message in
1500 ``.hg/last-message.txt``.
1500 ``.hg/last-message.txt``.
1501
1501
1502 The --close-branch flag can be used to mark the current branch
1502 The --close-branch flag can be used to mark the current branch
1503 head closed. When all heads of a branch are closed, the branch
1503 head closed. When all heads of a branch are closed, the branch
1504 will be considered closed and no longer listed.
1504 will be considered closed and no longer listed.
1505
1505
1506 The --amend flag can be used to amend the parent of the
1506 The --amend flag can be used to amend the parent of the
1507 working directory with a new commit that contains the changes
1507 working directory with a new commit that contains the changes
1508 in the parent in addition to those currently reported by :hg:`status`,
1508 in the parent in addition to those currently reported by :hg:`status`,
1509 if there are any. The old commit is stored in a backup bundle in
1509 if there are any. The old commit is stored in a backup bundle in
1510 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1510 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1511 on how to restore it).
1511 on how to restore it).
1512
1512
1513 Message, user and date are taken from the amended commit unless
1513 Message, user and date are taken from the amended commit unless
1514 specified. When a message isn't specified on the command line,
1514 specified. When a message isn't specified on the command line,
1515 the editor will open with the message of the amended commit.
1515 the editor will open with the message of the amended commit.
1516
1516
1517 It is not possible to amend public changesets (see :hg:`help phases`)
1517 It is not possible to amend public changesets (see :hg:`help phases`)
1518 or changesets that have children.
1518 or changesets that have children.
1519
1519
1520 See :hg:`help dates` for a list of formats valid for -d/--date.
1520 See :hg:`help dates` for a list of formats valid for -d/--date.
1521
1521
1522 Returns 0 on success, 1 if nothing changed.
1522 Returns 0 on success, 1 if nothing changed.
1523
1523
1524 .. container:: verbose
1524 .. container:: verbose
1525
1525
1526 Examples:
1526 Examples:
1527
1527
1528 - commit all files ending in .py::
1528 - commit all files ending in .py::
1529
1529
1530 hg commit --include "set:**.py"
1530 hg commit --include "set:**.py"
1531
1531
1532 - commit all non-binary files::
1532 - commit all non-binary files::
1533
1533
1534 hg commit --exclude "set:binary()"
1534 hg commit --exclude "set:binary()"
1535
1535
1536 - amend the current commit and set the date to now::
1536 - amend the current commit and set the date to now::
1537
1537
1538 hg commit --amend --date now
1538 hg commit --amend --date now
1539 """
1539 """
1540 wlock = lock = None
1540 wlock = lock = None
1541 try:
1541 try:
1542 wlock = repo.wlock()
1542 wlock = repo.wlock()
1543 lock = repo.lock()
1543 lock = repo.lock()
1544 return _docommit(ui, repo, *pats, **opts)
1544 return _docommit(ui, repo, *pats, **opts)
1545 finally:
1545 finally:
1546 release(lock, wlock)
1546 release(lock, wlock)
1547
1547
1548 def _docommit(ui, repo, *pats, **opts):
1548 def _docommit(ui, repo, *pats, **opts):
1549 if opts.get(r'interactive'):
1549 if opts.get(r'interactive'):
1550 opts.pop(r'interactive')
1550 opts.pop(r'interactive')
1551 ret = cmdutil.dorecord(ui, repo, commit, None, False,
1551 ret = cmdutil.dorecord(ui, repo, commit, None, False,
1552 cmdutil.recordfilter, *pats,
1552 cmdutil.recordfilter, *pats,
1553 **opts)
1553 **opts)
1554 # ret can be 0 (no changes to record) or the value returned by
1554 # ret can be 0 (no changes to record) or the value returned by
1555 # commit(), 1 if nothing changed or None on success.
1555 # commit(), 1 if nothing changed or None on success.
1556 return 1 if ret == 0 else ret
1556 return 1 if ret == 0 else ret
1557
1557
1558 opts = pycompat.byteskwargs(opts)
1558 opts = pycompat.byteskwargs(opts)
1559 if opts.get('subrepos'):
1559 if opts.get('subrepos'):
1560 if opts.get('amend'):
1560 if opts.get('amend'):
1561 raise error.Abort(_('cannot amend with --subrepos'))
1561 raise error.Abort(_('cannot amend with --subrepos'))
1562 # Let --subrepos on the command line override config setting.
1562 # Let --subrepos on the command line override config setting.
1563 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1563 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1564
1564
1565 cmdutil.checkunfinished(repo, commit=True)
1565 cmdutil.checkunfinished(repo, commit=True)
1566
1566
1567 branch = repo[None].branch()
1567 branch = repo[None].branch()
1568 bheads = repo.branchheads(branch)
1568 bheads = repo.branchheads(branch)
1569
1569
1570 extra = {}
1570 extra = {}
1571 if opts.get('close_branch'):
1571 if opts.get('close_branch'):
1572 extra['close'] = '1'
1572 extra['close'] = '1'
1573
1573
1574 if not bheads:
1574 if not bheads:
1575 raise error.Abort(_('can only close branch heads'))
1575 raise error.Abort(_('can only close branch heads'))
1576 elif opts.get('amend'):
1576 elif opts.get('amend'):
1577 if repo[None].parents()[0].p1().branch() != branch and \
1577 if repo[None].parents()[0].p1().branch() != branch and \
1578 repo[None].parents()[0].p2().branch() != branch:
1578 repo[None].parents()[0].p2().branch() != branch:
1579 raise error.Abort(_('can only close branch heads'))
1579 raise error.Abort(_('can only close branch heads'))
1580
1580
1581 if opts.get('amend'):
1581 if opts.get('amend'):
1582 if ui.configbool('ui', 'commitsubrepos'):
1582 if ui.configbool('ui', 'commitsubrepos'):
1583 raise error.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1583 raise error.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1584
1584
1585 old = repo['.']
1585 old = repo['.']
1586 rewriteutil.precheck(repo, [old.rev()], 'amend')
1586 rewriteutil.precheck(repo, [old.rev()], 'amend')
1587
1587
1588 # Currently histedit gets confused if an amend happens while histedit
1588 # Currently histedit gets confused if an amend happens while histedit
1589 # is in progress. Since we have a checkunfinished command, we are
1589 # is in progress. Since we have a checkunfinished command, we are
1590 # temporarily honoring it.
1590 # temporarily honoring it.
1591 #
1591 #
1592 # Note: eventually this guard will be removed. Please do not expect
1592 # Note: eventually this guard will be removed. Please do not expect
1593 # this behavior to remain.
1593 # this behavior to remain.
1594 if not obsolete.isenabled(repo, obsolete.createmarkersopt):
1594 if not obsolete.isenabled(repo, obsolete.createmarkersopt):
1595 cmdutil.checkunfinished(repo)
1595 cmdutil.checkunfinished(repo)
1596
1596
1597 node = cmdutil.amend(ui, repo, old, extra, pats, opts)
1597 node = cmdutil.amend(ui, repo, old, extra, pats, opts)
1598 if node == old.node():
1598 if node == old.node():
1599 ui.status(_("nothing changed\n"))
1599 ui.status(_("nothing changed\n"))
1600 return 1
1600 return 1
1601 else:
1601 else:
1602 def commitfunc(ui, repo, message, match, opts):
1602 def commitfunc(ui, repo, message, match, opts):
1603 overrides = {}
1603 overrides = {}
1604 if opts.get('secret'):
1604 if opts.get('secret'):
1605 overrides[('phases', 'new-commit')] = 'secret'
1605 overrides[('phases', 'new-commit')] = 'secret'
1606
1606
1607 baseui = repo.baseui
1607 baseui = repo.baseui
1608 with baseui.configoverride(overrides, 'commit'):
1608 with baseui.configoverride(overrides, 'commit'):
1609 with ui.configoverride(overrides, 'commit'):
1609 with ui.configoverride(overrides, 'commit'):
1610 editform = cmdutil.mergeeditform(repo[None],
1610 editform = cmdutil.mergeeditform(repo[None],
1611 'commit.normal')
1611 'commit.normal')
1612 editor = cmdutil.getcommiteditor(
1612 editor = cmdutil.getcommiteditor(
1613 editform=editform, **pycompat.strkwargs(opts))
1613 editform=editform, **pycompat.strkwargs(opts))
1614 return repo.commit(message,
1614 return repo.commit(message,
1615 opts.get('user'),
1615 opts.get('user'),
1616 opts.get('date'),
1616 opts.get('date'),
1617 match,
1617 match,
1618 editor=editor,
1618 editor=editor,
1619 extra=extra)
1619 extra=extra)
1620
1620
1621 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1621 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1622
1622
1623 if not node:
1623 if not node:
1624 stat = cmdutil.postcommitstatus(repo, pats, opts)
1624 stat = cmdutil.postcommitstatus(repo, pats, opts)
1625 if stat[3]:
1625 if stat[3]:
1626 ui.status(_("nothing changed (%d missing files, see "
1626 ui.status(_("nothing changed (%d missing files, see "
1627 "'hg status')\n") % len(stat[3]))
1627 "'hg status')\n") % len(stat[3]))
1628 else:
1628 else:
1629 ui.status(_("nothing changed\n"))
1629 ui.status(_("nothing changed\n"))
1630 return 1
1630 return 1
1631
1631
1632 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1632 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1633
1633
1634 @command('config|showconfig|debugconfig',
1634 @command('config|showconfig|debugconfig',
1635 [('u', 'untrusted', None, _('show untrusted configuration options')),
1635 [('u', 'untrusted', None, _('show untrusted configuration options')),
1636 ('e', 'edit', None, _('edit user config')),
1636 ('e', 'edit', None, _('edit user config')),
1637 ('l', 'local', None, _('edit repository config')),
1637 ('l', 'local', None, _('edit repository config')),
1638 ('g', 'global', None, _('edit global config'))] + formatteropts,
1638 ('g', 'global', None, _('edit global config'))] + formatteropts,
1639 _('[-u] [NAME]...'),
1639 _('[-u] [NAME]...'),
1640 optionalrepo=True,
1640 optionalrepo=True,
1641 intents={INTENT_READONLY})
1641 intents={INTENT_READONLY})
1642 def config(ui, repo, *values, **opts):
1642 def config(ui, repo, *values, **opts):
1643 """show combined config settings from all hgrc files
1643 """show combined config settings from all hgrc files
1644
1644
1645 With no arguments, print names and values of all config items.
1645 With no arguments, print names and values of all config items.
1646
1646
1647 With one argument of the form section.name, print just the value
1647 With one argument of the form section.name, print just the value
1648 of that config item.
1648 of that config item.
1649
1649
1650 With multiple arguments, print names and values of all config
1650 With multiple arguments, print names and values of all config
1651 items with matching section names or section.names.
1651 items with matching section names or section.names.
1652
1652
1653 With --edit, start an editor on the user-level config file. With
1653 With --edit, start an editor on the user-level config file. With
1654 --global, edit the system-wide config file. With --local, edit the
1654 --global, edit the system-wide config file. With --local, edit the
1655 repository-level config file.
1655 repository-level config file.
1656
1656
1657 With --debug, the source (filename and line number) is printed
1657 With --debug, the source (filename and line number) is printed
1658 for each config item.
1658 for each config item.
1659
1659
1660 See :hg:`help config` for more information about config files.
1660 See :hg:`help config` for more information about config files.
1661
1661
1662 Returns 0 on success, 1 if NAME does not exist.
1662 Returns 0 on success, 1 if NAME does not exist.
1663
1663
1664 """
1664 """
1665
1665
1666 opts = pycompat.byteskwargs(opts)
1666 opts = pycompat.byteskwargs(opts)
1667 if opts.get('edit') or opts.get('local') or opts.get('global'):
1667 if opts.get('edit') or opts.get('local') or opts.get('global'):
1668 if opts.get('local') and opts.get('global'):
1668 if opts.get('local') and opts.get('global'):
1669 raise error.Abort(_("can't use --local and --global together"))
1669 raise error.Abort(_("can't use --local and --global together"))
1670
1670
1671 if opts.get('local'):
1671 if opts.get('local'):
1672 if not repo:
1672 if not repo:
1673 raise error.Abort(_("can't use --local outside a repository"))
1673 raise error.Abort(_("can't use --local outside a repository"))
1674 paths = [repo.vfs.join('hgrc')]
1674 paths = [repo.vfs.join('hgrc')]
1675 elif opts.get('global'):
1675 elif opts.get('global'):
1676 paths = rcutil.systemrcpath()
1676 paths = rcutil.systemrcpath()
1677 else:
1677 else:
1678 paths = rcutil.userrcpath()
1678 paths = rcutil.userrcpath()
1679
1679
1680 for f in paths:
1680 for f in paths:
1681 if os.path.exists(f):
1681 if os.path.exists(f):
1682 break
1682 break
1683 else:
1683 else:
1684 if opts.get('global'):
1684 if opts.get('global'):
1685 samplehgrc = uimod.samplehgrcs['global']
1685 samplehgrc = uimod.samplehgrcs['global']
1686 elif opts.get('local'):
1686 elif opts.get('local'):
1687 samplehgrc = uimod.samplehgrcs['local']
1687 samplehgrc = uimod.samplehgrcs['local']
1688 else:
1688 else:
1689 samplehgrc = uimod.samplehgrcs['user']
1689 samplehgrc = uimod.samplehgrcs['user']
1690
1690
1691 f = paths[0]
1691 f = paths[0]
1692 fp = open(f, "wb")
1692 fp = open(f, "wb")
1693 fp.write(util.tonativeeol(samplehgrc))
1693 fp.write(util.tonativeeol(samplehgrc))
1694 fp.close()
1694 fp.close()
1695
1695
1696 editor = ui.geteditor()
1696 editor = ui.geteditor()
1697 ui.system("%s \"%s\"" % (editor, f),
1697 ui.system("%s \"%s\"" % (editor, f),
1698 onerr=error.Abort, errprefix=_("edit failed"),
1698 onerr=error.Abort, errprefix=_("edit failed"),
1699 blockedtag='config_edit')
1699 blockedtag='config_edit')
1700 return
1700 return
1701 ui.pager('config')
1701 ui.pager('config')
1702 fm = ui.formatter('config', opts)
1702 fm = ui.formatter('config', opts)
1703 for t, f in rcutil.rccomponents():
1703 for t, f in rcutil.rccomponents():
1704 if t == 'path':
1704 if t == 'path':
1705 ui.debug('read config from: %s\n' % f)
1705 ui.debug('read config from: %s\n' % f)
1706 elif t == 'items':
1706 elif t == 'items':
1707 for section, name, value, source in f:
1707 for section, name, value, source in f:
1708 ui.debug('set config by: %s\n' % source)
1708 ui.debug('set config by: %s\n' % source)
1709 else:
1709 else:
1710 raise error.ProgrammingError('unknown rctype: %s' % t)
1710 raise error.ProgrammingError('unknown rctype: %s' % t)
1711 untrusted = bool(opts.get('untrusted'))
1711 untrusted = bool(opts.get('untrusted'))
1712
1712
1713 selsections = selentries = []
1713 selsections = selentries = []
1714 if values:
1714 if values:
1715 selsections = [v for v in values if '.' not in v]
1715 selsections = [v for v in values if '.' not in v]
1716 selentries = [v for v in values if '.' in v]
1716 selentries = [v for v in values if '.' in v]
1717 uniquesel = (len(selentries) == 1 and not selsections)
1717 uniquesel = (len(selentries) == 1 and not selsections)
1718 selsections = set(selsections)
1718 selsections = set(selsections)
1719 selentries = set(selentries)
1719 selentries = set(selentries)
1720
1720
1721 matched = False
1721 matched = False
1722 for section, name, value in ui.walkconfig(untrusted=untrusted):
1722 for section, name, value in ui.walkconfig(untrusted=untrusted):
1723 source = ui.configsource(section, name, untrusted)
1723 source = ui.configsource(section, name, untrusted)
1724 value = pycompat.bytestr(value)
1724 value = pycompat.bytestr(value)
1725 if fm.isplain():
1725 if fm.isplain():
1726 source = source or 'none'
1726 source = source or 'none'
1727 value = value.replace('\n', '\\n')
1727 value = value.replace('\n', '\\n')
1728 entryname = section + '.' + name
1728 entryname = section + '.' + name
1729 if values and not (section in selsections or entryname in selentries):
1729 if values and not (section in selsections or entryname in selentries):
1730 continue
1730 continue
1731 fm.startitem()
1731 fm.startitem()
1732 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1732 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1733 if uniquesel:
1733 if uniquesel:
1734 fm.data(name=entryname)
1734 fm.data(name=entryname)
1735 fm.write('value', '%s\n', value)
1735 fm.write('value', '%s\n', value)
1736 else:
1736 else:
1737 fm.write('name value', '%s=%s\n', entryname, value)
1737 fm.write('name value', '%s=%s\n', entryname, value)
1738 matched = True
1738 matched = True
1739 fm.end()
1739 fm.end()
1740 if matched:
1740 if matched:
1741 return 0
1741 return 0
1742 return 1
1742 return 1
1743
1743
1744 @command('copy|cp',
1744 @command('copy|cp',
1745 [('A', 'after', None, _('record a copy that has already occurred')),
1745 [('A', 'after', None, _('record a copy that has already occurred')),
1746 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1746 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1747 ] + walkopts + dryrunopts,
1747 ] + walkopts + dryrunopts,
1748 _('[OPTION]... [SOURCE]... DEST'))
1748 _('[OPTION]... [SOURCE]... DEST'))
1749 def copy(ui, repo, *pats, **opts):
1749 def copy(ui, repo, *pats, **opts):
1750 """mark files as copied for the next commit
1750 """mark files as copied for the next commit
1751
1751
1752 Mark dest as having copies of source files. If dest is a
1752 Mark dest as having copies of source files. If dest is a
1753 directory, copies are put in that directory. If dest is a file,
1753 directory, copies are put in that directory. If dest is a file,
1754 the source must be a single file.
1754 the source must be a single file.
1755
1755
1756 By default, this command copies the contents of files as they
1756 By default, this command copies the contents of files as they
1757 exist in the working directory. If invoked with -A/--after, the
1757 exist in the working directory. If invoked with -A/--after, the
1758 operation is recorded, but no copying is performed.
1758 operation is recorded, but no copying is performed.
1759
1759
1760 This command takes effect with the next commit. To undo a copy
1760 This command takes effect with the next commit. To undo a copy
1761 before that, see :hg:`revert`.
1761 before that, see :hg:`revert`.
1762
1762
1763 Returns 0 on success, 1 if errors are encountered.
1763 Returns 0 on success, 1 if errors are encountered.
1764 """
1764 """
1765 opts = pycompat.byteskwargs(opts)
1765 opts = pycompat.byteskwargs(opts)
1766 with repo.wlock(False):
1766 with repo.wlock(False):
1767 return cmdutil.copy(ui, repo, pats, opts)
1767 return cmdutil.copy(ui, repo, pats, opts)
1768
1768
1769 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
1769 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
1770 def debugcommands(ui, cmd='', *args):
1770 def debugcommands(ui, cmd='', *args):
1771 """list all available commands and options"""
1771 """list all available commands and options"""
1772 for cmd, vals in sorted(table.iteritems()):
1772 for cmd, vals in sorted(table.iteritems()):
1773 cmd = cmd.split('|')[0].strip('^')
1773 cmd = cmd.split('|')[0].strip('^')
1774 opts = ', '.join([i[1] for i in vals[1]])
1774 opts = ', '.join([i[1] for i in vals[1]])
1775 ui.write('%s: %s\n' % (cmd, opts))
1775 ui.write('%s: %s\n' % (cmd, opts))
1776
1776
1777 @command('debugcomplete',
1777 @command('debugcomplete',
1778 [('o', 'options', None, _('show the command options'))],
1778 [('o', 'options', None, _('show the command options'))],
1779 _('[-o] CMD'),
1779 _('[-o] CMD'),
1780 norepo=True)
1780 norepo=True)
1781 def debugcomplete(ui, cmd='', **opts):
1781 def debugcomplete(ui, cmd='', **opts):
1782 """returns the completion list associated with the given command"""
1782 """returns the completion list associated with the given command"""
1783
1783
1784 if opts.get(r'options'):
1784 if opts.get(r'options'):
1785 options = []
1785 options = []
1786 otables = [globalopts]
1786 otables = [globalopts]
1787 if cmd:
1787 if cmd:
1788 aliases, entry = cmdutil.findcmd(cmd, table, False)
1788 aliases, entry = cmdutil.findcmd(cmd, table, False)
1789 otables.append(entry[1])
1789 otables.append(entry[1])
1790 for t in otables:
1790 for t in otables:
1791 for o in t:
1791 for o in t:
1792 if "(DEPRECATED)" in o[3]:
1792 if "(DEPRECATED)" in o[3]:
1793 continue
1793 continue
1794 if o[0]:
1794 if o[0]:
1795 options.append('-%s' % o[0])
1795 options.append('-%s' % o[0])
1796 options.append('--%s' % o[1])
1796 options.append('--%s' % o[1])
1797 ui.write("%s\n" % "\n".join(options))
1797 ui.write("%s\n" % "\n".join(options))
1798 return
1798 return
1799
1799
1800 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
1800 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
1801 if ui.verbose:
1801 if ui.verbose:
1802 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
1802 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
1803 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
1803 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
1804
1804
1805 @command('^diff',
1805 @command('^diff',
1806 [('r', 'rev', [], _('revision'), _('REV')),
1806 [('r', 'rev', [], _('revision'), _('REV')),
1807 ('c', 'change', '', _('change made by revision'), _('REV'))
1807 ('c', 'change', '', _('change made by revision'), _('REV'))
1808 ] + diffopts + diffopts2 + walkopts + subrepoopts,
1808 ] + diffopts + diffopts2 + walkopts + subrepoopts,
1809 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
1809 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
1810 inferrepo=True,
1810 inferrepo=True,
1811 intents={INTENT_READONLY})
1811 intents={INTENT_READONLY})
1812 def diff(ui, repo, *pats, **opts):
1812 def diff(ui, repo, *pats, **opts):
1813 """diff repository (or selected files)
1813 """diff repository (or selected files)
1814
1814
1815 Show differences between revisions for the specified files.
1815 Show differences between revisions for the specified files.
1816
1816
1817 Differences between files are shown using the unified diff format.
1817 Differences between files are shown using the unified diff format.
1818
1818
1819 .. note::
1819 .. note::
1820
1820
1821 :hg:`diff` may generate unexpected results for merges, as it will
1821 :hg:`diff` may generate unexpected results for merges, as it will
1822 default to comparing against the working directory's first
1822 default to comparing against the working directory's first
1823 parent changeset if no revisions are specified.
1823 parent changeset if no revisions are specified.
1824
1824
1825 When two revision arguments are given, then changes are shown
1825 When two revision arguments are given, then changes are shown
1826 between those revisions. If only one revision is specified then
1826 between those revisions. If only one revision is specified then
1827 that revision is compared to the working directory, and, when no
1827 that revision is compared to the working directory, and, when no
1828 revisions are specified, the working directory files are compared
1828 revisions are specified, the working directory files are compared
1829 to its first parent.
1829 to its first parent.
1830
1830
1831 Alternatively you can specify -c/--change with a revision to see
1831 Alternatively you can specify -c/--change with a revision to see
1832 the changes in that changeset relative to its first parent.
1832 the changes in that changeset relative to its first parent.
1833
1833
1834 Without the -a/--text option, diff will avoid generating diffs of
1834 Without the -a/--text option, diff will avoid generating diffs of
1835 files it detects as binary. With -a, diff will generate a diff
1835 files it detects as binary. With -a, diff will generate a diff
1836 anyway, probably with undesirable results.
1836 anyway, probably with undesirable results.
1837
1837
1838 Use the -g/--git option to generate diffs in the git extended diff
1838 Use the -g/--git option to generate diffs in the git extended diff
1839 format. For more information, read :hg:`help diffs`.
1839 format. For more information, read :hg:`help diffs`.
1840
1840
1841 .. container:: verbose
1841 .. container:: verbose
1842
1842
1843 Examples:
1843 Examples:
1844
1844
1845 - compare a file in the current working directory to its parent::
1845 - compare a file in the current working directory to its parent::
1846
1846
1847 hg diff foo.c
1847 hg diff foo.c
1848
1848
1849 - compare two historical versions of a directory, with rename info::
1849 - compare two historical versions of a directory, with rename info::
1850
1850
1851 hg diff --git -r 1.0:1.2 lib/
1851 hg diff --git -r 1.0:1.2 lib/
1852
1852
1853 - get change stats relative to the last change on some date::
1853 - get change stats relative to the last change on some date::
1854
1854
1855 hg diff --stat -r "date('may 2')"
1855 hg diff --stat -r "date('may 2')"
1856
1856
1857 - diff all newly-added files that contain a keyword::
1857 - diff all newly-added files that contain a keyword::
1858
1858
1859 hg diff "set:added() and grep(GNU)"
1859 hg diff "set:added() and grep(GNU)"
1860
1860
1861 - compare a revision and its parents::
1861 - compare a revision and its parents::
1862
1862
1863 hg diff -c 9353 # compare against first parent
1863 hg diff -c 9353 # compare against first parent
1864 hg diff -r 9353^:9353 # same using revset syntax
1864 hg diff -r 9353^:9353 # same using revset syntax
1865 hg diff -r 9353^2:9353 # compare against the second parent
1865 hg diff -r 9353^2:9353 # compare against the second parent
1866
1866
1867 Returns 0 on success.
1867 Returns 0 on success.
1868 """
1868 """
1869
1869
1870 opts = pycompat.byteskwargs(opts)
1870 opts = pycompat.byteskwargs(opts)
1871 revs = opts.get('rev')
1871 revs = opts.get('rev')
1872 change = opts.get('change')
1872 change = opts.get('change')
1873 stat = opts.get('stat')
1873 stat = opts.get('stat')
1874 reverse = opts.get('reverse')
1874 reverse = opts.get('reverse')
1875
1875
1876 if revs and change:
1876 if revs and change:
1877 msg = _('cannot specify --rev and --change at the same time')
1877 msg = _('cannot specify --rev and --change at the same time')
1878 raise error.Abort(msg)
1878 raise error.Abort(msg)
1879 elif change:
1879 elif change:
1880 repo = scmutil.unhidehashlikerevs(repo, [change], 'nowarn')
1880 repo = scmutil.unhidehashlikerevs(repo, [change], 'nowarn')
1881 ctx2 = scmutil.revsingle(repo, change, None)
1881 ctx2 = scmutil.revsingle(repo, change, None)
1882 ctx1 = ctx2.p1()
1882 ctx1 = ctx2.p1()
1883 else:
1883 else:
1884 repo = scmutil.unhidehashlikerevs(repo, revs, 'nowarn')
1884 repo = scmutil.unhidehashlikerevs(repo, revs, 'nowarn')
1885 ctx1, ctx2 = scmutil.revpair(repo, revs)
1885 ctx1, ctx2 = scmutil.revpair(repo, revs)
1886 node1, node2 = ctx1.node(), ctx2.node()
1886 node1, node2 = ctx1.node(), ctx2.node()
1887
1887
1888 if reverse:
1888 if reverse:
1889 node1, node2 = node2, node1
1889 node1, node2 = node2, node1
1890
1890
1891 diffopts = patch.diffallopts(ui, opts)
1891 diffopts = patch.diffallopts(ui, opts)
1892 m = scmutil.match(ctx2, pats, opts)
1892 m = scmutil.match(ctx2, pats, opts)
1893 ui.pager('diff')
1893 ui.pager('diff')
1894 logcmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
1894 logcmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
1895 listsubrepos=opts.get('subrepos'),
1895 listsubrepos=opts.get('subrepos'),
1896 root=opts.get('root'))
1896 root=opts.get('root'))
1897
1897
1898 @command('^export',
1898 @command('^export',
1899 [('B', 'bookmark', '',
1899 [('B', 'bookmark', '',
1900 _('export changes only reachable by given bookmark')),
1900 _('export changes only reachable by given bookmark')),
1901 ('o', 'output', '',
1901 ('o', 'output', '',
1902 _('print output to file with formatted name'), _('FORMAT')),
1902 _('print output to file with formatted name'), _('FORMAT')),
1903 ('', 'switch-parent', None, _('diff against the second parent')),
1903 ('', 'switch-parent', None, _('diff against the second parent')),
1904 ('r', 'rev', [], _('revisions to export'), _('REV')),
1904 ('r', 'rev', [], _('revisions to export'), _('REV')),
1905 ] + diffopts + formatteropts,
1905 ] + diffopts + formatteropts,
1906 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'),
1906 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'),
1907 intents={INTENT_READONLY})
1907 intents={INTENT_READONLY})
1908 def export(ui, repo, *changesets, **opts):
1908 def export(ui, repo, *changesets, **opts):
1909 """dump the header and diffs for one or more changesets
1909 """dump the header and diffs for one or more changesets
1910
1910
1911 Print the changeset header and diffs for one or more revisions.
1911 Print the changeset header and diffs for one or more revisions.
1912 If no revision is given, the parent of the working directory is used.
1912 If no revision is given, the parent of the working directory is used.
1913
1913
1914 The information shown in the changeset header is: author, date,
1914 The information shown in the changeset header is: author, date,
1915 branch name (if non-default), changeset hash, parent(s) and commit
1915 branch name (if non-default), changeset hash, parent(s) and commit
1916 comment.
1916 comment.
1917
1917
1918 .. note::
1918 .. note::
1919
1919
1920 :hg:`export` may generate unexpected diff output for merge
1920 :hg:`export` may generate unexpected diff output for merge
1921 changesets, as it will compare the merge changeset against its
1921 changesets, as it will compare the merge changeset against its
1922 first parent only.
1922 first parent only.
1923
1923
1924 Output may be to a file, in which case the name of the file is
1924 Output may be to a file, in which case the name of the file is
1925 given using a template string. See :hg:`help templates`. In addition
1925 given using a template string. See :hg:`help templates`. In addition
1926 to the common template keywords, the following formatting rules are
1926 to the common template keywords, the following formatting rules are
1927 supported:
1927 supported:
1928
1928
1929 :``%%``: literal "%" character
1929 :``%%``: literal "%" character
1930 :``%H``: changeset hash (40 hexadecimal digits)
1930 :``%H``: changeset hash (40 hexadecimal digits)
1931 :``%N``: number of patches being generated
1931 :``%N``: number of patches being generated
1932 :``%R``: changeset revision number
1932 :``%R``: changeset revision number
1933 :``%b``: basename of the exporting repository
1933 :``%b``: basename of the exporting repository
1934 :``%h``: short-form changeset hash (12 hexadecimal digits)
1934 :``%h``: short-form changeset hash (12 hexadecimal digits)
1935 :``%m``: first line of the commit message (only alphanumeric characters)
1935 :``%m``: first line of the commit message (only alphanumeric characters)
1936 :``%n``: zero-padded sequence number, starting at 1
1936 :``%n``: zero-padded sequence number, starting at 1
1937 :``%r``: zero-padded changeset revision number
1937 :``%r``: zero-padded changeset revision number
1938 :``\\``: literal "\\" character
1938 :``\\``: literal "\\" character
1939
1939
1940 Without the -a/--text option, export will avoid generating diffs
1940 Without the -a/--text option, export will avoid generating diffs
1941 of files it detects as binary. With -a, export will generate a
1941 of files it detects as binary. With -a, export will generate a
1942 diff anyway, probably with undesirable results.
1942 diff anyway, probably with undesirable results.
1943
1943
1944 With -B/--bookmark changesets reachable by the given bookmark are
1944 With -B/--bookmark changesets reachable by the given bookmark are
1945 selected.
1945 selected.
1946
1946
1947 Use the -g/--git option to generate diffs in the git extended diff
1947 Use the -g/--git option to generate diffs in the git extended diff
1948 format. See :hg:`help diffs` for more information.
1948 format. See :hg:`help diffs` for more information.
1949
1949
1950 With the --switch-parent option, the diff will be against the
1950 With the --switch-parent option, the diff will be against the
1951 second parent. It can be useful to review a merge.
1951 second parent. It can be useful to review a merge.
1952
1952
1953 .. container:: verbose
1953 .. container:: verbose
1954
1954
1955 Examples:
1955 Examples:
1956
1956
1957 - use export and import to transplant a bugfix to the current
1957 - use export and import to transplant a bugfix to the current
1958 branch::
1958 branch::
1959
1959
1960 hg export -r 9353 | hg import -
1960 hg export -r 9353 | hg import -
1961
1961
1962 - export all the changesets between two revisions to a file with
1962 - export all the changesets between two revisions to a file with
1963 rename information::
1963 rename information::
1964
1964
1965 hg export --git -r 123:150 > changes.txt
1965 hg export --git -r 123:150 > changes.txt
1966
1966
1967 - split outgoing changes into a series of patches with
1967 - split outgoing changes into a series of patches with
1968 descriptive names::
1968 descriptive names::
1969
1969
1970 hg export -r "outgoing()" -o "%n-%m.patch"
1970 hg export -r "outgoing()" -o "%n-%m.patch"
1971
1971
1972 Returns 0 on success.
1972 Returns 0 on success.
1973 """
1973 """
1974 opts = pycompat.byteskwargs(opts)
1974 opts = pycompat.byteskwargs(opts)
1975 bookmark = opts.get('bookmark')
1975 bookmark = opts.get('bookmark')
1976 changesets += tuple(opts.get('rev', []))
1976 changesets += tuple(opts.get('rev', []))
1977
1977
1978 if bookmark and changesets:
1978 if bookmark and changesets:
1979 raise error.Abort(_("-r and -B are mutually exclusive"))
1979 raise error.Abort(_("-r and -B are mutually exclusive"))
1980
1980
1981 if bookmark:
1981 if bookmark:
1982 if bookmark not in repo._bookmarks:
1982 if bookmark not in repo._bookmarks:
1983 raise error.Abort(_("bookmark '%s' not found") % bookmark)
1983 raise error.Abort(_("bookmark '%s' not found") % bookmark)
1984
1984
1985 revs = repair.stripbmrevset(repo, bookmark)
1985 revs = repair.stripbmrevset(repo, bookmark)
1986 else:
1986 else:
1987 if not changesets:
1987 if not changesets:
1988 changesets = ['.']
1988 changesets = ['.']
1989
1989
1990 repo = scmutil.unhidehashlikerevs(repo, changesets, 'nowarn')
1990 repo = scmutil.unhidehashlikerevs(repo, changesets, 'nowarn')
1991 revs = scmutil.revrange(repo, changesets)
1991 revs = scmutil.revrange(repo, changesets)
1992
1992
1993 if not revs:
1993 if not revs:
1994 raise error.Abort(_("export requires at least one changeset"))
1994 raise error.Abort(_("export requires at least one changeset"))
1995 if len(revs) > 1:
1995 if len(revs) > 1:
1996 ui.note(_('exporting patches:\n'))
1996 ui.note(_('exporting patches:\n'))
1997 else:
1997 else:
1998 ui.note(_('exporting patch:\n'))
1998 ui.note(_('exporting patch:\n'))
1999
1999
2000 fntemplate = opts.get('output')
2000 fntemplate = opts.get('output')
2001 if cmdutil.isstdiofilename(fntemplate):
2001 if cmdutil.isstdiofilename(fntemplate):
2002 fntemplate = ''
2002 fntemplate = ''
2003
2003
2004 if fntemplate:
2004 if fntemplate:
2005 fm = formatter.nullformatter(ui, 'export', opts)
2005 fm = formatter.nullformatter(ui, 'export', opts)
2006 else:
2006 else:
2007 ui.pager('export')
2007 ui.pager('export')
2008 fm = ui.formatter('export', opts)
2008 fm = ui.formatter('export', opts)
2009 with fm:
2009 with fm:
2010 cmdutil.export(repo, revs, fm, fntemplate=fntemplate,
2010 cmdutil.export(repo, revs, fm, fntemplate=fntemplate,
2011 switch_parent=opts.get('switch_parent'),
2011 switch_parent=opts.get('switch_parent'),
2012 opts=patch.diffallopts(ui, opts))
2012 opts=patch.diffallopts(ui, opts))
2013
2013
2014 @command('files',
2014 @command('files',
2015 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
2015 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
2016 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
2016 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
2017 ] + walkopts + formatteropts + subrepoopts,
2017 ] + walkopts + formatteropts + subrepoopts,
2018 _('[OPTION]... [FILE]...'),
2018 _('[OPTION]... [FILE]...'),
2019 intents={INTENT_READONLY})
2019 intents={INTENT_READONLY})
2020 def files(ui, repo, *pats, **opts):
2020 def files(ui, repo, *pats, **opts):
2021 """list tracked files
2021 """list tracked files
2022
2022
2023 Print files under Mercurial control in the working directory or
2023 Print files under Mercurial control in the working directory or
2024 specified revision for given files (excluding removed files).
2024 specified revision for given files (excluding removed files).
2025 Files can be specified as filenames or filesets.
2025 Files can be specified as filenames or filesets.
2026
2026
2027 If no files are given to match, this command prints the names
2027 If no files are given to match, this command prints the names
2028 of all files under Mercurial control.
2028 of all files under Mercurial control.
2029
2029
2030 .. container:: verbose
2030 .. container:: verbose
2031
2031
2032 Examples:
2032 Examples:
2033
2033
2034 - list all files under the current directory::
2034 - list all files under the current directory::
2035
2035
2036 hg files .
2036 hg files .
2037
2037
2038 - shows sizes and flags for current revision::
2038 - shows sizes and flags for current revision::
2039
2039
2040 hg files -vr .
2040 hg files -vr .
2041
2041
2042 - list all files named README::
2042 - list all files named README::
2043
2043
2044 hg files -I "**/README"
2044 hg files -I "**/README"
2045
2045
2046 - list all binary files::
2046 - list all binary files::
2047
2047
2048 hg files "set:binary()"
2048 hg files "set:binary()"
2049
2049
2050 - find files containing a regular expression::
2050 - find files containing a regular expression::
2051
2051
2052 hg files "set:grep('bob')"
2052 hg files "set:grep('bob')"
2053
2053
2054 - search tracked file contents with xargs and grep::
2054 - search tracked file contents with xargs and grep::
2055
2055
2056 hg files -0 | xargs -0 grep foo
2056 hg files -0 | xargs -0 grep foo
2057
2057
2058 See :hg:`help patterns` and :hg:`help filesets` for more information
2058 See :hg:`help patterns` and :hg:`help filesets` for more information
2059 on specifying file patterns.
2059 on specifying file patterns.
2060
2060
2061 Returns 0 if a match is found, 1 otherwise.
2061 Returns 0 if a match is found, 1 otherwise.
2062
2062
2063 """
2063 """
2064
2064
2065 opts = pycompat.byteskwargs(opts)
2065 opts = pycompat.byteskwargs(opts)
2066 rev = opts.get('rev')
2066 rev = opts.get('rev')
2067 if rev:
2067 if rev:
2068 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
2068 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
2069 ctx = scmutil.revsingle(repo, rev, None)
2069 ctx = scmutil.revsingle(repo, rev, None)
2070
2070
2071 end = '\n'
2071 end = '\n'
2072 if opts.get('print0'):
2072 if opts.get('print0'):
2073 end = '\0'
2073 end = '\0'
2074 fmt = '%s' + end
2074 fmt = '%s' + end
2075
2075
2076 m = scmutil.match(ctx, pats, opts)
2076 m = scmutil.match(ctx, pats, opts)
2077 ui.pager('files')
2077 ui.pager('files')
2078 with ui.formatter('files', opts) as fm:
2078 with ui.formatter('files', opts) as fm:
2079 return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
2079 return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
2080
2080
2081 @command(
2081 @command(
2082 '^forget',
2082 '^forget',
2083 [('i', 'interactive', None, _('use interactive mode')),
2083 [('i', 'interactive', None, _('use interactive mode')),
2084 ] + walkopts + dryrunopts,
2084 ] + walkopts + dryrunopts,
2085 _('[OPTION]... FILE...'), inferrepo=True)
2085 _('[OPTION]... FILE...'), inferrepo=True)
2086 def forget(ui, repo, *pats, **opts):
2086 def forget(ui, repo, *pats, **opts):
2087 """forget the specified files on the next commit
2087 """forget the specified files on the next commit
2088
2088
2089 Mark the specified files so they will no longer be tracked
2089 Mark the specified files so they will no longer be tracked
2090 after the next commit.
2090 after the next commit.
2091
2091
2092 This only removes files from the current branch, not from the
2092 This only removes files from the current branch, not from the
2093 entire project history, and it does not delete them from the
2093 entire project history, and it does not delete them from the
2094 working directory.
2094 working directory.
2095
2095
2096 To delete the file from the working directory, see :hg:`remove`.
2096 To delete the file from the working directory, see :hg:`remove`.
2097
2097
2098 To undo a forget before the next commit, see :hg:`add`.
2098 To undo a forget before the next commit, see :hg:`add`.
2099
2099
2100 .. container:: verbose
2100 .. container:: verbose
2101
2101
2102 Examples:
2102 Examples:
2103
2103
2104 - forget newly-added binary files::
2104 - forget newly-added binary files::
2105
2105
2106 hg forget "set:added() and binary()"
2106 hg forget "set:added() and binary()"
2107
2107
2108 - forget files that would be excluded by .hgignore::
2108 - forget files that would be excluded by .hgignore::
2109
2109
2110 hg forget "set:hgignore()"
2110 hg forget "set:hgignore()"
2111
2111
2112 Returns 0 on success.
2112 Returns 0 on success.
2113 """
2113 """
2114
2114
2115 opts = pycompat.byteskwargs(opts)
2115 opts = pycompat.byteskwargs(opts)
2116 if not pats:
2116 if not pats:
2117 raise error.Abort(_('no files specified'))
2117 raise error.Abort(_('no files specified'))
2118
2118
2119 m = scmutil.match(repo[None], pats, opts)
2119 m = scmutil.match(repo[None], pats, opts)
2120 dryrun, interactive = opts.get('dry_run'), opts.get('interactive')
2120 dryrun, interactive = opts.get('dry_run'), opts.get('interactive')
2121 rejected = cmdutil.forget(ui, repo, m, prefix="",
2121 rejected = cmdutil.forget(ui, repo, m, prefix="",
2122 explicitonly=False, dryrun=dryrun,
2122 explicitonly=False, dryrun=dryrun,
2123 interactive=interactive)[0]
2123 interactive=interactive)[0]
2124 return rejected and 1 or 0
2124 return rejected and 1 or 0
2125
2125
2126 @command(
2126 @command(
2127 'graft',
2127 'graft',
2128 [('r', 'rev', [], _('revisions to graft'), _('REV')),
2128 [('r', 'rev', [], _('revisions to graft'), _('REV')),
2129 ('c', 'continue', False, _('resume interrupted graft')),
2129 ('c', 'continue', False, _('resume interrupted graft')),
2130 ('e', 'edit', False, _('invoke editor on commit messages')),
2130 ('e', 'edit', False, _('invoke editor on commit messages')),
2131 ('', 'log', None, _('append graft info to log message')),
2131 ('', 'log', None, _('append graft info to log message')),
2132 ('f', 'force', False, _('force graft')),
2132 ('f', 'force', False, _('force graft')),
2133 ('D', 'currentdate', False,
2133 ('D', 'currentdate', False,
2134 _('record the current date as commit date')),
2134 _('record the current date as commit date')),
2135 ('U', 'currentuser', False,
2135 ('U', 'currentuser', False,
2136 _('record the current user as committer'), _('DATE'))]
2136 _('record the current user as committer'), _('DATE'))]
2137 + commitopts2 + mergetoolopts + dryrunopts,
2137 + commitopts2 + mergetoolopts + dryrunopts,
2138 _('[OPTION]... [-r REV]... REV...'))
2138 _('[OPTION]... [-r REV]... REV...'))
2139 def graft(ui, repo, *revs, **opts):
2139 def graft(ui, repo, *revs, **opts):
2140 '''copy changes from other branches onto the current branch
2140 '''copy changes from other branches onto the current branch
2141
2141
2142 This command uses Mercurial's merge logic to copy individual
2142 This command uses Mercurial's merge logic to copy individual
2143 changes from other branches without merging branches in the
2143 changes from other branches without merging branches in the
2144 history graph. This is sometimes known as 'backporting' or
2144 history graph. This is sometimes known as 'backporting' or
2145 'cherry-picking'. By default, graft will copy user, date, and
2145 'cherry-picking'. By default, graft will copy user, date, and
2146 description from the source changesets.
2146 description from the source changesets.
2147
2147
2148 Changesets that are ancestors of the current revision, that have
2148 Changesets that are ancestors of the current revision, that have
2149 already been grafted, or that are merges will be skipped.
2149 already been grafted, or that are merges will be skipped.
2150
2150
2151 If --log is specified, log messages will have a comment appended
2151 If --log is specified, log messages will have a comment appended
2152 of the form::
2152 of the form::
2153
2153
2154 (grafted from CHANGESETHASH)
2154 (grafted from CHANGESETHASH)
2155
2155
2156 If --force is specified, revisions will be grafted even if they
2156 If --force is specified, revisions will be grafted even if they
2157 are already ancestors of, or have been grafted to, the destination.
2157 are already ancestors of, or have been grafted to, the destination.
2158 This is useful when the revisions have since been backed out.
2158 This is useful when the revisions have since been backed out.
2159
2159
2160 If a graft merge results in conflicts, the graft process is
2160 If a graft merge results in conflicts, the graft process is
2161 interrupted so that the current merge can be manually resolved.
2161 interrupted so that the current merge can be manually resolved.
2162 Once all conflicts are addressed, the graft process can be
2162 Once all conflicts are addressed, the graft process can be
2163 continued with the -c/--continue option.
2163 continued with the -c/--continue option.
2164
2164
2165 .. note::
2165 .. note::
2166
2166
2167 The -c/--continue option does not reapply earlier options, except
2167 The -c/--continue option does not reapply earlier options, except
2168 for --force.
2168 for --force.
2169
2169
2170 .. container:: verbose
2170 .. container:: verbose
2171
2171
2172 Examples:
2172 Examples:
2173
2173
2174 - copy a single change to the stable branch and edit its description::
2174 - copy a single change to the stable branch and edit its description::
2175
2175
2176 hg update stable
2176 hg update stable
2177 hg graft --edit 9393
2177 hg graft --edit 9393
2178
2178
2179 - graft a range of changesets with one exception, updating dates::
2179 - graft a range of changesets with one exception, updating dates::
2180
2180
2181 hg graft -D "2085::2093 and not 2091"
2181 hg graft -D "2085::2093 and not 2091"
2182
2182
2183 - continue a graft after resolving conflicts::
2183 - continue a graft after resolving conflicts::
2184
2184
2185 hg graft -c
2185 hg graft -c
2186
2186
2187 - show the source of a grafted changeset::
2187 - show the source of a grafted changeset::
2188
2188
2189 hg log --debug -r .
2189 hg log --debug -r .
2190
2190
2191 - show revisions sorted by date::
2191 - show revisions sorted by date::
2192
2192
2193 hg log -r "sort(all(), date)"
2193 hg log -r "sort(all(), date)"
2194
2194
2195 See :hg:`help revisions` for more about specifying revisions.
2195 See :hg:`help revisions` for more about specifying revisions.
2196
2196
2197 Returns 0 on successful completion.
2197 Returns 0 on successful completion.
2198 '''
2198 '''
2199 with repo.wlock():
2199 with repo.wlock():
2200 return _dograft(ui, repo, *revs, **opts)
2200 return _dograft(ui, repo, *revs, **opts)
2201
2201
2202 def _dograft(ui, repo, *revs, **opts):
2202 def _dograft(ui, repo, *revs, **opts):
2203 opts = pycompat.byteskwargs(opts)
2203 opts = pycompat.byteskwargs(opts)
2204 if revs and opts.get('rev'):
2204 if revs and opts.get('rev'):
2205 ui.warn(_('warning: inconsistent use of --rev might give unexpected '
2205 ui.warn(_('warning: inconsistent use of --rev might give unexpected '
2206 'revision ordering!\n'))
2206 'revision ordering!\n'))
2207
2207
2208 revs = list(revs)
2208 revs = list(revs)
2209 revs.extend(opts.get('rev'))
2209 revs.extend(opts.get('rev'))
2210
2210
2211 if not opts.get('user') and opts.get('currentuser'):
2211 if not opts.get('user') and opts.get('currentuser'):
2212 opts['user'] = ui.username()
2212 opts['user'] = ui.username()
2213 if not opts.get('date') and opts.get('currentdate'):
2213 if not opts.get('date') and opts.get('currentdate'):
2214 opts['date'] = "%d %d" % dateutil.makedate()
2214 opts['date'] = "%d %d" % dateutil.makedate()
2215
2215
2216 editor = cmdutil.getcommiteditor(editform='graft',
2216 editor = cmdutil.getcommiteditor(editform='graft',
2217 **pycompat.strkwargs(opts))
2217 **pycompat.strkwargs(opts))
2218
2218
2219 cont = False
2219 cont = False
2220 if opts.get('continue'):
2220 if opts.get('continue'):
2221 cont = True
2221 cont = True
2222 if revs:
2222 if revs:
2223 raise error.Abort(_("can't specify --continue and revisions"))
2223 raise error.Abort(_("can't specify --continue and revisions"))
2224 # read in unfinished revisions
2224 # read in unfinished revisions
2225 try:
2225 try:
2226 nodes = repo.vfs.read('graftstate').splitlines()
2226 nodes = repo.vfs.read('graftstate').splitlines()
2227 revs = [repo[node].rev() for node in nodes]
2227 revs = [repo[node].rev() for node in nodes]
2228 except IOError as inst:
2228 except IOError as inst:
2229 if inst.errno != errno.ENOENT:
2229 if inst.errno != errno.ENOENT:
2230 raise
2230 raise
2231 cmdutil.wrongtooltocontinue(repo, _('graft'))
2231 cmdutil.wrongtooltocontinue(repo, _('graft'))
2232 else:
2232 else:
2233 if not revs:
2233 if not revs:
2234 raise error.Abort(_('no revisions specified'))
2234 raise error.Abort(_('no revisions specified'))
2235 cmdutil.checkunfinished(repo)
2235 cmdutil.checkunfinished(repo)
2236 cmdutil.bailifchanged(repo)
2236 cmdutil.bailifchanged(repo)
2237 revs = scmutil.revrange(repo, revs)
2237 revs = scmutil.revrange(repo, revs)
2238
2238
2239 skipped = set()
2239 skipped = set()
2240 # check for merges
2240 # check for merges
2241 for rev in repo.revs('%ld and merge()', revs):
2241 for rev in repo.revs('%ld and merge()', revs):
2242 ui.warn(_('skipping ungraftable merge revision %d\n') % rev)
2242 ui.warn(_('skipping ungraftable merge revision %d\n') % rev)
2243 skipped.add(rev)
2243 skipped.add(rev)
2244 revs = [r for r in revs if r not in skipped]
2244 revs = [r for r in revs if r not in skipped]
2245 if not revs:
2245 if not revs:
2246 return -1
2246 return -1
2247
2247
2248 # Don't check in the --continue case, in effect retaining --force across
2248 # Don't check in the --continue case, in effect retaining --force across
2249 # --continues. That's because without --force, any revisions we decided to
2249 # --continues. That's because without --force, any revisions we decided to
2250 # skip would have been filtered out here, so they wouldn't have made their
2250 # skip would have been filtered out here, so they wouldn't have made their
2251 # way to the graftstate. With --force, any revisions we would have otherwise
2251 # way to the graftstate. With --force, any revisions we would have otherwise
2252 # skipped would not have been filtered out, and if they hadn't been applied
2252 # skipped would not have been filtered out, and if they hadn't been applied
2253 # already, they'd have been in the graftstate.
2253 # already, they'd have been in the graftstate.
2254 if not (cont or opts.get('force')):
2254 if not (cont or opts.get('force')):
2255 # check for ancestors of dest branch
2255 # check for ancestors of dest branch
2256 crev = repo['.'].rev()
2256 crev = repo['.'].rev()
2257 ancestors = repo.changelog.ancestors([crev], inclusive=True)
2257 ancestors = repo.changelog.ancestors([crev], inclusive=True)
2258 # XXX make this lazy in the future
2258 # XXX make this lazy in the future
2259 # don't mutate while iterating, create a copy
2259 # don't mutate while iterating, create a copy
2260 for rev in list(revs):
2260 for rev in list(revs):
2261 if rev in ancestors:
2261 if rev in ancestors:
2262 ui.warn(_('skipping ancestor revision %d:%s\n') %
2262 ui.warn(_('skipping ancestor revision %d:%s\n') %
2263 (rev, repo[rev]))
2263 (rev, repo[rev]))
2264 # XXX remove on list is slow
2264 # XXX remove on list is slow
2265 revs.remove(rev)
2265 revs.remove(rev)
2266 if not revs:
2266 if not revs:
2267 return -1
2267 return -1
2268
2268
2269 # analyze revs for earlier grafts
2269 # analyze revs for earlier grafts
2270 ids = {}
2270 ids = {}
2271 for ctx in repo.set("%ld", revs):
2271 for ctx in repo.set("%ld", revs):
2272 ids[ctx.hex()] = ctx.rev()
2272 ids[ctx.hex()] = ctx.rev()
2273 n = ctx.extra().get('source')
2273 n = ctx.extra().get('source')
2274 if n:
2274 if n:
2275 ids[n] = ctx.rev()
2275 ids[n] = ctx.rev()
2276
2276
2277 # check ancestors for earlier grafts
2277 # check ancestors for earlier grafts
2278 ui.debug('scanning for duplicate grafts\n')
2278 ui.debug('scanning for duplicate grafts\n')
2279
2279
2280 # The only changesets we can be sure doesn't contain grafts of any
2280 # The only changesets we can be sure doesn't contain grafts of any
2281 # revs, are the ones that are common ancestors of *all* revs:
2281 # revs, are the ones that are common ancestors of *all* revs:
2282 for rev in repo.revs('only(%d,ancestor(%ld))', crev, revs):
2282 for rev in repo.revs('only(%d,ancestor(%ld))', crev, revs):
2283 ctx = repo[rev]
2283 ctx = repo[rev]
2284 n = ctx.extra().get('source')
2284 n = ctx.extra().get('source')
2285 if n in ids:
2285 if n in ids:
2286 try:
2286 try:
2287 r = repo[n].rev()
2287 r = repo[n].rev()
2288 except error.RepoLookupError:
2288 except error.RepoLookupError:
2289 r = None
2289 r = None
2290 if r in revs:
2290 if r in revs:
2291 ui.warn(_('skipping revision %d:%s '
2291 ui.warn(_('skipping revision %d:%s '
2292 '(already grafted to %d:%s)\n')
2292 '(already grafted to %d:%s)\n')
2293 % (r, repo[r], rev, ctx))
2293 % (r, repo[r], rev, ctx))
2294 revs.remove(r)
2294 revs.remove(r)
2295 elif ids[n] in revs:
2295 elif ids[n] in revs:
2296 if r is None:
2296 if r is None:
2297 ui.warn(_('skipping already grafted revision %d:%s '
2297 ui.warn(_('skipping already grafted revision %d:%s '
2298 '(%d:%s also has unknown origin %s)\n')
2298 '(%d:%s also has unknown origin %s)\n')
2299 % (ids[n], repo[ids[n]], rev, ctx, n[:12]))
2299 % (ids[n], repo[ids[n]], rev, ctx, n[:12]))
2300 else:
2300 else:
2301 ui.warn(_('skipping already grafted revision %d:%s '
2301 ui.warn(_('skipping already grafted revision %d:%s '
2302 '(%d:%s also has origin %d:%s)\n')
2302 '(%d:%s also has origin %d:%s)\n')
2303 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12]))
2303 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12]))
2304 revs.remove(ids[n])
2304 revs.remove(ids[n])
2305 elif ctx.hex() in ids:
2305 elif ctx.hex() in ids:
2306 r = ids[ctx.hex()]
2306 r = ids[ctx.hex()]
2307 ui.warn(_('skipping already grafted revision %d:%s '
2307 ui.warn(_('skipping already grafted revision %d:%s '
2308 '(was grafted from %d:%s)\n') %
2308 '(was grafted from %d:%s)\n') %
2309 (r, repo[r], rev, ctx))
2309 (r, repo[r], rev, ctx))
2310 revs.remove(r)
2310 revs.remove(r)
2311 if not revs:
2311 if not revs:
2312 return -1
2312 return -1
2313
2313
2314 for pos, ctx in enumerate(repo.set("%ld", revs)):
2314 for pos, ctx in enumerate(repo.set("%ld", revs)):
2315 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
2315 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
2316 ctx.description().split('\n', 1)[0])
2316 ctx.description().split('\n', 1)[0])
2317 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
2317 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
2318 if names:
2318 if names:
2319 desc += ' (%s)' % ' '.join(names)
2319 desc += ' (%s)' % ' '.join(names)
2320 ui.status(_('grafting %s\n') % desc)
2320 ui.status(_('grafting %s\n') % desc)
2321 if opts.get('dry_run'):
2321 if opts.get('dry_run'):
2322 continue
2322 continue
2323
2323
2324 source = ctx.extra().get('source')
2324 source = ctx.extra().get('source')
2325 extra = {}
2325 extra = {}
2326 if source:
2326 if source:
2327 extra['source'] = source
2327 extra['source'] = source
2328 extra['intermediate-source'] = ctx.hex()
2328 extra['intermediate-source'] = ctx.hex()
2329 else:
2329 else:
2330 extra['source'] = ctx.hex()
2330 extra['source'] = ctx.hex()
2331 user = ctx.user()
2331 user = ctx.user()
2332 if opts.get('user'):
2332 if opts.get('user'):
2333 user = opts['user']
2333 user = opts['user']
2334 date = ctx.date()
2334 date = ctx.date()
2335 if opts.get('date'):
2335 if opts.get('date'):
2336 date = opts['date']
2336 date = opts['date']
2337 message = ctx.description()
2337 message = ctx.description()
2338 if opts.get('log'):
2338 if opts.get('log'):
2339 message += '\n(grafted from %s)' % ctx.hex()
2339 message += '\n(grafted from %s)' % ctx.hex()
2340
2340
2341 # we don't merge the first commit when continuing
2341 # we don't merge the first commit when continuing
2342 if not cont:
2342 if not cont:
2343 # perform the graft merge with p1(rev) as 'ancestor'
2343 # perform the graft merge with p1(rev) as 'ancestor'
2344 try:
2344 try:
2345 # ui.forcemerge is an internal variable, do not document
2345 # ui.forcemerge is an internal variable, do not document
2346 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
2346 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
2347 'graft')
2347 'graft')
2348 stats = mergemod.graft(repo, ctx, ctx.p1(),
2348 stats = mergemod.graft(repo, ctx, ctx.p1(),
2349 ['local', 'graft'])
2349 ['local', 'graft'])
2350 finally:
2350 finally:
2351 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
2351 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
2352 # report any conflicts
2352 # report any conflicts
2353 if stats.unresolvedcount > 0:
2353 if stats.unresolvedcount > 0:
2354 # write out state for --continue
2354 # write out state for --continue
2355 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
2355 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
2356 repo.vfs.write('graftstate', ''.join(nodelines))
2356 repo.vfs.write('graftstate', ''.join(nodelines))
2357 extra = ''
2357 extra = ''
2358 if opts.get('user'):
2358 if opts.get('user'):
2359 extra += ' --user %s' % procutil.shellquote(opts['user'])
2359 extra += ' --user %s' % procutil.shellquote(opts['user'])
2360 if opts.get('date'):
2360 if opts.get('date'):
2361 extra += ' --date %s' % procutil.shellquote(opts['date'])
2361 extra += ' --date %s' % procutil.shellquote(opts['date'])
2362 if opts.get('log'):
2362 if opts.get('log'):
2363 extra += ' --log'
2363 extra += ' --log'
2364 hint=_("use 'hg resolve' and 'hg graft --continue%s'") % extra
2364 hint=_("use 'hg resolve' and 'hg graft --continue%s'") % extra
2365 raise error.Abort(
2365 raise error.Abort(
2366 _("unresolved conflicts, can't continue"),
2366 _("unresolved conflicts, can't continue"),
2367 hint=hint)
2367 hint=hint)
2368 else:
2368 else:
2369 cont = False
2369 cont = False
2370
2370
2371 # commit
2371 # commit
2372 node = repo.commit(text=message, user=user,
2372 node = repo.commit(text=message, user=user,
2373 date=date, extra=extra, editor=editor)
2373 date=date, extra=extra, editor=editor)
2374 if node is None:
2374 if node is None:
2375 ui.warn(
2375 ui.warn(
2376 _('note: graft of %d:%s created no changes to commit\n') %
2376 _('note: graft of %d:%s created no changes to commit\n') %
2377 (ctx.rev(), ctx))
2377 (ctx.rev(), ctx))
2378
2378
2379 # remove state when we complete successfully
2379 # remove state when we complete successfully
2380 if not opts.get('dry_run'):
2380 if not opts.get('dry_run'):
2381 repo.vfs.unlinkpath('graftstate', ignoremissing=True)
2381 repo.vfs.unlinkpath('graftstate', ignoremissing=True)
2382
2382
2383 return 0
2383 return 0
2384
2384
2385 @command('grep',
2385 @command('grep',
2386 [('0', 'print0', None, _('end fields with NUL')),
2386 [('0', 'print0', None, _('end fields with NUL')),
2387 ('', 'all', None, _('print all revisions that match')),
2387 ('', 'all', None, _('print all revisions that match')),
2388 ('a', 'text', None, _('treat all files as text')),
2388 ('a', 'text', None, _('treat all files as text')),
2389 ('f', 'follow', None,
2389 ('f', 'follow', None,
2390 _('follow changeset history,'
2390 _('follow changeset history,'
2391 ' or file history across copies and renames')),
2391 ' or file history across copies and renames')),
2392 ('i', 'ignore-case', None, _('ignore case when matching')),
2392 ('i', 'ignore-case', None, _('ignore case when matching')),
2393 ('l', 'files-with-matches', None,
2393 ('l', 'files-with-matches', None,
2394 _('print only filenames and revisions that match')),
2394 _('print only filenames and revisions that match')),
2395 ('n', 'line-number', None, _('print matching line numbers')),
2395 ('n', 'line-number', None, _('print matching line numbers')),
2396 ('r', 'rev', [],
2396 ('r', 'rev', [],
2397 _('only search files changed within revision range'), _('REV')),
2397 _('only search files changed within revision range'), _('REV')),
2398 ('u', 'user', None, _('list the author (long with -v)')),
2398 ('u', 'user', None, _('list the author (long with -v)')),
2399 ('d', 'date', None, _('list the date (short with -q)')),
2399 ('d', 'date', None, _('list the date (short with -q)')),
2400 ] + formatteropts + walkopts,
2400 ] + formatteropts + walkopts,
2401 _('[OPTION]... PATTERN [FILE]...'),
2401 _('[OPTION]... PATTERN [FILE]...'),
2402 inferrepo=True,
2402 inferrepo=True,
2403 intents={INTENT_READONLY})
2403 intents={INTENT_READONLY})
2404 def grep(ui, repo, pattern, *pats, **opts):
2404 def grep(ui, repo, pattern, *pats, **opts):
2405 """search revision history for a pattern in specified files
2405 """search revision history for a pattern in specified files
2406
2406
2407 Search revision history for a regular expression in the specified
2407 Search revision history for a regular expression in the specified
2408 files or the entire project.
2408 files or the entire project.
2409
2409
2410 By default, grep prints the most recent revision number for each
2410 By default, grep prints the most recent revision number for each
2411 file in which it finds a match. To get it to print every revision
2411 file in which it finds a match. To get it to print every revision
2412 that contains a change in match status ("-" for a match that becomes
2412 that contains a change in match status ("-" for a match that becomes
2413 a non-match, or "+" for a non-match that becomes a match), use the
2413 a non-match, or "+" for a non-match that becomes a match), use the
2414 --all flag.
2414 --all flag.
2415
2415
2416 PATTERN can be any Python (roughly Perl-compatible) regular
2416 PATTERN can be any Python (roughly Perl-compatible) regular
2417 expression.
2417 expression.
2418
2418
2419 If no FILEs are specified (and -f/--follow isn't set), all files in
2419 If no FILEs are specified (and -f/--follow isn't set), all files in
2420 the repository are searched, including those that don't exist in the
2420 the repository are searched, including those that don't exist in the
2421 current branch or have been deleted in a prior changeset.
2421 current branch or have been deleted in a prior changeset.
2422
2422
2423 Returns 0 if a match is found, 1 otherwise.
2423 Returns 0 if a match is found, 1 otherwise.
2424 """
2424 """
2425 opts = pycompat.byteskwargs(opts)
2425 opts = pycompat.byteskwargs(opts)
2426 reflags = re.M
2426 reflags = re.M
2427 if opts.get('ignore_case'):
2427 if opts.get('ignore_case'):
2428 reflags |= re.I
2428 reflags |= re.I
2429 try:
2429 try:
2430 regexp = util.re.compile(pattern, reflags)
2430 regexp = util.re.compile(pattern, reflags)
2431 except re.error as inst:
2431 except re.error as inst:
2432 ui.warn(_("grep: invalid match pattern: %s\n") % pycompat.bytestr(inst))
2432 ui.warn(_("grep: invalid match pattern: %s\n") % pycompat.bytestr(inst))
2433 return 1
2433 return 1
2434 sep, eol = ':', '\n'
2434 sep, eol = ':', '\n'
2435 if opts.get('print0'):
2435 if opts.get('print0'):
2436 sep = eol = '\0'
2436 sep = eol = '\0'
2437
2437
2438 getfile = util.lrucachefunc(repo.file)
2438 getfile = util.lrucachefunc(repo.file)
2439
2439
2440 def matchlines(body):
2440 def matchlines(body):
2441 begin = 0
2441 begin = 0
2442 linenum = 0
2442 linenum = 0
2443 while begin < len(body):
2443 while begin < len(body):
2444 match = regexp.search(body, begin)
2444 match = regexp.search(body, begin)
2445 if not match:
2445 if not match:
2446 break
2446 break
2447 mstart, mend = match.span()
2447 mstart, mend = match.span()
2448 linenum += body.count('\n', begin, mstart) + 1
2448 linenum += body.count('\n', begin, mstart) + 1
2449 lstart = body.rfind('\n', begin, mstart) + 1 or begin
2449 lstart = body.rfind('\n', begin, mstart) + 1 or begin
2450 begin = body.find('\n', mend) + 1 or len(body) + 1
2450 begin = body.find('\n', mend) + 1 or len(body) + 1
2451 lend = begin - 1
2451 lend = begin - 1
2452 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
2452 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
2453
2453
2454 class linestate(object):
2454 class linestate(object):
2455 def __init__(self, line, linenum, colstart, colend):
2455 def __init__(self, line, linenum, colstart, colend):
2456 self.line = line
2456 self.line = line
2457 self.linenum = linenum
2457 self.linenum = linenum
2458 self.colstart = colstart
2458 self.colstart = colstart
2459 self.colend = colend
2459 self.colend = colend
2460
2460
2461 def __hash__(self):
2461 def __hash__(self):
2462 return hash((self.linenum, self.line))
2462 return hash((self.linenum, self.line))
2463
2463
2464 def __eq__(self, other):
2464 def __eq__(self, other):
2465 return self.line == other.line
2465 return self.line == other.line
2466
2466
2467 def findpos(self):
2467 def findpos(self):
2468 """Iterate all (start, end) indices of matches"""
2468 """Iterate all (start, end) indices of matches"""
2469 yield self.colstart, self.colend
2469 yield self.colstart, self.colend
2470 p = self.colend
2470 p = self.colend
2471 while p < len(self.line):
2471 while p < len(self.line):
2472 m = regexp.search(self.line, p)
2472 m = regexp.search(self.line, p)
2473 if not m:
2473 if not m:
2474 break
2474 break
2475 yield m.span()
2475 yield m.span()
2476 p = m.end()
2476 p = m.end()
2477
2477
2478 matches = {}
2478 matches = {}
2479 copies = {}
2479 copies = {}
2480 def grepbody(fn, rev, body):
2480 def grepbody(fn, rev, body):
2481 matches[rev].setdefault(fn, [])
2481 matches[rev].setdefault(fn, [])
2482 m = matches[rev][fn]
2482 m = matches[rev][fn]
2483 for lnum, cstart, cend, line in matchlines(body):
2483 for lnum, cstart, cend, line in matchlines(body):
2484 s = linestate(line, lnum, cstart, cend)
2484 s = linestate(line, lnum, cstart, cend)
2485 m.append(s)
2485 m.append(s)
2486
2486
2487 def difflinestates(a, b):
2487 def difflinestates(a, b):
2488 sm = difflib.SequenceMatcher(None, a, b)
2488 sm = difflib.SequenceMatcher(None, a, b)
2489 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
2489 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
2490 if tag == 'insert':
2490 if tag == 'insert':
2491 for i in xrange(blo, bhi):
2491 for i in xrange(blo, bhi):
2492 yield ('+', b[i])
2492 yield ('+', b[i])
2493 elif tag == 'delete':
2493 elif tag == 'delete':
2494 for i in xrange(alo, ahi):
2494 for i in xrange(alo, ahi):
2495 yield ('-', a[i])
2495 yield ('-', a[i])
2496 elif tag == 'replace':
2496 elif tag == 'replace':
2497 for i in xrange(alo, ahi):
2497 for i in xrange(alo, ahi):
2498 yield ('-', a[i])
2498 yield ('-', a[i])
2499 for i in xrange(blo, bhi):
2499 for i in xrange(blo, bhi):
2500 yield ('+', b[i])
2500 yield ('+', b[i])
2501
2501
2502 def display(fm, fn, ctx, pstates, states):
2502 def display(fm, fn, ctx, pstates, states):
2503 rev = ctx.rev()
2503 rev = ctx.rev()
2504 if fm.isplain():
2504 if fm.isplain():
2505 formatuser = ui.shortuser
2505 formatuser = ui.shortuser
2506 else:
2506 else:
2507 formatuser = str
2507 formatuser = str
2508 if ui.quiet:
2508 if ui.quiet:
2509 datefmt = '%Y-%m-%d'
2509 datefmt = '%Y-%m-%d'
2510 else:
2510 else:
2511 datefmt = '%a %b %d %H:%M:%S %Y %1%2'
2511 datefmt = '%a %b %d %H:%M:%S %Y %1%2'
2512 found = False
2512 found = False
2513 @util.cachefunc
2513 @util.cachefunc
2514 def binary():
2514 def binary():
2515 flog = getfile(fn)
2515 flog = getfile(fn)
2516 return stringutil.binary(flog.read(ctx.filenode(fn)))
2516 return stringutil.binary(flog.read(ctx.filenode(fn)))
2517
2517
2518 fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'}
2518 fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'}
2519 if opts.get('all'):
2519 if opts.get('all'):
2520 iter = difflinestates(pstates, states)
2520 iter = difflinestates(pstates, states)
2521 else:
2521 else:
2522 iter = [('', l) for l in states]
2522 iter = [('', l) for l in states]
2523 for change, l in iter:
2523 for change, l in iter:
2524 fm.startitem()
2524 fm.startitem()
2525 fm.data(node=fm.hexfunc(ctx.node()))
2525 fm.data(node=fm.hexfunc(ctx.node()))
2526 cols = [
2526 cols = [
2527 ('filename', fn, True),
2527 ('filename', fn, True),
2528 ('rev', rev, True),
2528 ('rev', rev, True),
2529 ('linenumber', l.linenum, opts.get('line_number')),
2529 ('linenumber', l.linenum, opts.get('line_number')),
2530 ]
2530 ]
2531 if opts.get('all'):
2531 if opts.get('all'):
2532 cols.append(('change', change, True))
2532 cols.append(('change', change, True))
2533 cols.extend([
2533 cols.extend([
2534 ('user', formatuser(ctx.user()), opts.get('user')),
2534 ('user', formatuser(ctx.user()), opts.get('user')),
2535 ('date', fm.formatdate(ctx.date(), datefmt), opts.get('date')),
2535 ('date', fm.formatdate(ctx.date(), datefmt), opts.get('date')),
2536 ])
2536 ])
2537 lastcol = next(name for name, data, cond in reversed(cols) if cond)
2537 lastcol = next(name for name, data, cond in reversed(cols) if cond)
2538 for name, data, cond in cols:
2538 for name, data, cond in cols:
2539 field = fieldnamemap.get(name, name)
2539 field = fieldnamemap.get(name, name)
2540 fm.condwrite(cond, field, '%s', data, label='grep.%s' % name)
2540 fm.condwrite(cond, field, '%s', data, label='grep.%s' % name)
2541 if cond and name != lastcol:
2541 if cond and name != lastcol:
2542 fm.plain(sep, label='grep.sep')
2542 fm.plain(sep, label='grep.sep')
2543 if not opts.get('files_with_matches'):
2543 if not opts.get('files_with_matches'):
2544 fm.plain(sep, label='grep.sep')
2544 fm.plain(sep, label='grep.sep')
2545 if not opts.get('text') and binary():
2545 if not opts.get('text') and binary():
2546 fm.plain(_(" Binary file matches"))
2546 fm.plain(_(" Binary file matches"))
2547 else:
2547 else:
2548 displaymatches(fm.nested('texts', tmpl='{text}'), l)
2548 displaymatches(fm.nested('texts', tmpl='{text}'), l)
2549 fm.plain(eol)
2549 fm.plain(eol)
2550 found = True
2550 found = True
2551 if opts.get('files_with_matches'):
2551 if opts.get('files_with_matches'):
2552 break
2552 break
2553 return found
2553 return found
2554
2554
2555 def displaymatches(fm, l):
2555 def displaymatches(fm, l):
2556 p = 0
2556 p = 0
2557 for s, e in l.findpos():
2557 for s, e in l.findpos():
2558 if p < s:
2558 if p < s:
2559 fm.startitem()
2559 fm.startitem()
2560 fm.write('text', '%s', l.line[p:s])
2560 fm.write('text', '%s', l.line[p:s])
2561 fm.data(matched=False)
2561 fm.data(matched=False)
2562 fm.startitem()
2562 fm.startitem()
2563 fm.write('text', '%s', l.line[s:e], label='grep.match')
2563 fm.write('text', '%s', l.line[s:e], label='grep.match')
2564 fm.data(matched=True)
2564 fm.data(matched=True)
2565 p = e
2565 p = e
2566 if p < len(l.line):
2566 if p < len(l.line):
2567 fm.startitem()
2567 fm.startitem()
2568 fm.write('text', '%s', l.line[p:])
2568 fm.write('text', '%s', l.line[p:])
2569 fm.data(matched=False)
2569 fm.data(matched=False)
2570 fm.end()
2570 fm.end()
2571
2571
2572 skip = {}
2572 skip = {}
2573 revfiles = {}
2573 revfiles = {}
2574 match = scmutil.match(repo[None], pats, opts)
2574 match = scmutil.match(repo[None], pats, opts)
2575 found = False
2575 found = False
2576 follow = opts.get('follow')
2576 follow = opts.get('follow')
2577
2577
2578 def prep(ctx, fns):
2578 def prep(ctx, fns):
2579 rev = ctx.rev()
2579 rev = ctx.rev()
2580 pctx = ctx.p1()
2580 pctx = ctx.p1()
2581 parent = pctx.rev()
2581 parent = pctx.rev()
2582 matches.setdefault(rev, {})
2582 matches.setdefault(rev, {})
2583 matches.setdefault(parent, {})
2583 matches.setdefault(parent, {})
2584 files = revfiles.setdefault(rev, [])
2584 files = revfiles.setdefault(rev, [])
2585 for fn in fns:
2585 for fn in fns:
2586 flog = getfile(fn)
2586 flog = getfile(fn)
2587 try:
2587 try:
2588 fnode = ctx.filenode(fn)
2588 fnode = ctx.filenode(fn)
2589 except error.LookupError:
2589 except error.LookupError:
2590 continue
2590 continue
2591
2591
2592 copied = flog.renamed(fnode)
2592 copied = flog.renamed(fnode)
2593 copy = follow and copied and copied[0]
2593 copy = follow and copied and copied[0]
2594 if copy:
2594 if copy:
2595 copies.setdefault(rev, {})[fn] = copy
2595 copies.setdefault(rev, {})[fn] = copy
2596 if fn in skip:
2596 if fn in skip:
2597 if copy:
2597 if copy:
2598 skip[copy] = True
2598 skip[copy] = True
2599 continue
2599 continue
2600 files.append(fn)
2600 files.append(fn)
2601
2601
2602 if fn not in matches[rev]:
2602 if fn not in matches[rev]:
2603 grepbody(fn, rev, flog.read(fnode))
2603 grepbody(fn, rev, flog.read(fnode))
2604
2604
2605 pfn = copy or fn
2605 pfn = copy or fn
2606 if pfn not in matches[parent]:
2606 if pfn not in matches[parent]:
2607 try:
2607 try:
2608 fnode = pctx.filenode(pfn)
2608 fnode = pctx.filenode(pfn)
2609 grepbody(pfn, parent, flog.read(fnode))
2609 grepbody(pfn, parent, flog.read(fnode))
2610 except error.LookupError:
2610 except error.LookupError:
2611 pass
2611 pass
2612
2612
2613 ui.pager('grep')
2613 ui.pager('grep')
2614 fm = ui.formatter('grep', opts)
2614 fm = ui.formatter('grep', opts)
2615 for ctx in cmdutil.walkchangerevs(repo, match, opts, prep):
2615 for ctx in cmdutil.walkchangerevs(repo, match, opts, prep):
2616 rev = ctx.rev()
2616 rev = ctx.rev()
2617 parent = ctx.p1().rev()
2617 parent = ctx.p1().rev()
2618 for fn in sorted(revfiles.get(rev, [])):
2618 for fn in sorted(revfiles.get(rev, [])):
2619 states = matches[rev][fn]
2619 states = matches[rev][fn]
2620 copy = copies.get(rev, {}).get(fn)
2620 copy = copies.get(rev, {}).get(fn)
2621 if fn in skip:
2621 if fn in skip:
2622 if copy:
2622 if copy:
2623 skip[copy] = True
2623 skip[copy] = True
2624 continue
2624 continue
2625 pstates = matches.get(parent, {}).get(copy or fn, [])
2625 pstates = matches.get(parent, {}).get(copy or fn, [])
2626 if pstates or states:
2626 if pstates or states:
2627 r = display(fm, fn, ctx, pstates, states)
2627 r = display(fm, fn, ctx, pstates, states)
2628 found = found or r
2628 found = found or r
2629 if r and not opts.get('all'):
2629 if r and not opts.get('all'):
2630 skip[fn] = True
2630 skip[fn] = True
2631 if copy:
2631 if copy:
2632 skip[copy] = True
2632 skip[copy] = True
2633 del revfiles[rev]
2633 del revfiles[rev]
2634 # We will keep the matches dict for the duration of the window
2634 # We will keep the matches dict for the duration of the window
2635 # clear the matches dict once the window is over
2635 # clear the matches dict once the window is over
2636 if not revfiles:
2636 if not revfiles:
2637 matches.clear()
2637 matches.clear()
2638 fm.end()
2638 fm.end()
2639
2639
2640 return not found
2640 return not found
2641
2641
2642 @command('heads',
2642 @command('heads',
2643 [('r', 'rev', '',
2643 [('r', 'rev', '',
2644 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
2644 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
2645 ('t', 'topo', False, _('show topological heads only')),
2645 ('t', 'topo', False, _('show topological heads only')),
2646 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
2646 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
2647 ('c', 'closed', False, _('show normal and closed branch heads')),
2647 ('c', 'closed', False, _('show normal and closed branch heads')),
2648 ] + templateopts,
2648 ] + templateopts,
2649 _('[-ct] [-r STARTREV] [REV]...'),
2649 _('[-ct] [-r STARTREV] [REV]...'),
2650 intents={INTENT_READONLY})
2650 intents={INTENT_READONLY})
2651 def heads(ui, repo, *branchrevs, **opts):
2651 def heads(ui, repo, *branchrevs, **opts):
2652 """show branch heads
2652 """show branch heads
2653
2653
2654 With no arguments, show all open branch heads in the repository.
2654 With no arguments, show all open branch heads in the repository.
2655 Branch heads are changesets that have no descendants on the
2655 Branch heads are changesets that have no descendants on the
2656 same branch. They are where development generally takes place and
2656 same branch. They are where development generally takes place and
2657 are the usual targets for update and merge operations.
2657 are the usual targets for update and merge operations.
2658
2658
2659 If one or more REVs are given, only open branch heads on the
2659 If one or more REVs are given, only open branch heads on the
2660 branches associated with the specified changesets are shown. This
2660 branches associated with the specified changesets are shown. This
2661 means that you can use :hg:`heads .` to see the heads on the
2661 means that you can use :hg:`heads .` to see the heads on the
2662 currently checked-out branch.
2662 currently checked-out branch.
2663
2663
2664 If -c/--closed is specified, also show branch heads marked closed
2664 If -c/--closed is specified, also show branch heads marked closed
2665 (see :hg:`commit --close-branch`).
2665 (see :hg:`commit --close-branch`).
2666
2666
2667 If STARTREV is specified, only those heads that are descendants of
2667 If STARTREV is specified, only those heads that are descendants of
2668 STARTREV will be displayed.
2668 STARTREV will be displayed.
2669
2669
2670 If -t/--topo is specified, named branch mechanics will be ignored and only
2670 If -t/--topo is specified, named branch mechanics will be ignored and only
2671 topological heads (changesets with no children) will be shown.
2671 topological heads (changesets with no children) will be shown.
2672
2672
2673 Returns 0 if matching heads are found, 1 if not.
2673 Returns 0 if matching heads are found, 1 if not.
2674 """
2674 """
2675
2675
2676 opts = pycompat.byteskwargs(opts)
2676 opts = pycompat.byteskwargs(opts)
2677 start = None
2677 start = None
2678 rev = opts.get('rev')
2678 rev = opts.get('rev')
2679 if rev:
2679 if rev:
2680 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
2680 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
2681 start = scmutil.revsingle(repo, rev, None).node()
2681 start = scmutil.revsingle(repo, rev, None).node()
2682
2682
2683 if opts.get('topo'):
2683 if opts.get('topo'):
2684 heads = [repo[h] for h in repo.heads(start)]
2684 heads = [repo[h] for h in repo.heads(start)]
2685 else:
2685 else:
2686 heads = []
2686 heads = []
2687 for branch in repo.branchmap():
2687 for branch in repo.branchmap():
2688 heads += repo.branchheads(branch, start, opts.get('closed'))
2688 heads += repo.branchheads(branch, start, opts.get('closed'))
2689 heads = [repo[h] for h in heads]
2689 heads = [repo[h] for h in heads]
2690
2690
2691 if branchrevs:
2691 if branchrevs:
2692 branches = set(repo[r].branch()
2692 branches = set(repo[r].branch()
2693 for r in scmutil.revrange(repo, branchrevs))
2693 for r in scmutil.revrange(repo, branchrevs))
2694 heads = [h for h in heads if h.branch() in branches]
2694 heads = [h for h in heads if h.branch() in branches]
2695
2695
2696 if opts.get('active') and branchrevs:
2696 if opts.get('active') and branchrevs:
2697 dagheads = repo.heads(start)
2697 dagheads = repo.heads(start)
2698 heads = [h for h in heads if h.node() in dagheads]
2698 heads = [h for h in heads if h.node() in dagheads]
2699
2699
2700 if branchrevs:
2700 if branchrevs:
2701 haveheads = set(h.branch() for h in heads)
2701 haveheads = set(h.branch() for h in heads)
2702 if branches - haveheads:
2702 if branches - haveheads:
2703 headless = ', '.join(b for b in branches - haveheads)
2703 headless = ', '.join(b for b in branches - haveheads)
2704 msg = _('no open branch heads found on branches %s')
2704 msg = _('no open branch heads found on branches %s')
2705 if opts.get('rev'):
2705 if opts.get('rev'):
2706 msg += _(' (started at %s)') % opts['rev']
2706 msg += _(' (started at %s)') % opts['rev']
2707 ui.warn((msg + '\n') % headless)
2707 ui.warn((msg + '\n') % headless)
2708
2708
2709 if not heads:
2709 if not heads:
2710 return 1
2710 return 1
2711
2711
2712 ui.pager('heads')
2712 ui.pager('heads')
2713 heads = sorted(heads, key=lambda x: -x.rev())
2713 heads = sorted(heads, key=lambda x: -x.rev())
2714 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
2714 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
2715 for ctx in heads:
2715 for ctx in heads:
2716 displayer.show(ctx)
2716 displayer.show(ctx)
2717 displayer.close()
2717 displayer.close()
2718
2718
2719 @command('help',
2719 @command('help',
2720 [('e', 'extension', None, _('show only help for extensions')),
2720 [('e', 'extension', None, _('show only help for extensions')),
2721 ('c', 'command', None, _('show only help for commands')),
2721 ('c', 'command', None, _('show only help for commands')),
2722 ('k', 'keyword', None, _('show topics matching keyword')),
2722 ('k', 'keyword', None, _('show topics matching keyword')),
2723 ('s', 'system', [], _('show help for specific platform(s)')),
2723 ('s', 'system', [], _('show help for specific platform(s)')),
2724 ],
2724 ],
2725 _('[-ecks] [TOPIC]'),
2725 _('[-ecks] [TOPIC]'),
2726 norepo=True,
2726 norepo=True,
2727 intents={INTENT_READONLY})
2727 intents={INTENT_READONLY})
2728 def help_(ui, name=None, **opts):
2728 def help_(ui, name=None, **opts):
2729 """show help for a given topic or a help overview
2729 """show help for a given topic or a help overview
2730
2730
2731 With no arguments, print a list of commands with short help messages.
2731 With no arguments, print a list of commands with short help messages.
2732
2732
2733 Given a topic, extension, or command name, print help for that
2733 Given a topic, extension, or command name, print help for that
2734 topic.
2734 topic.
2735
2735
2736 Returns 0 if successful.
2736 Returns 0 if successful.
2737 """
2737 """
2738
2738
2739 keep = opts.get(r'system') or []
2739 keep = opts.get(r'system') or []
2740 if len(keep) == 0:
2740 if len(keep) == 0:
2741 if pycompat.sysplatform.startswith('win'):
2741 if pycompat.sysplatform.startswith('win'):
2742 keep.append('windows')
2742 keep.append('windows')
2743 elif pycompat.sysplatform == 'OpenVMS':
2743 elif pycompat.sysplatform == 'OpenVMS':
2744 keep.append('vms')
2744 keep.append('vms')
2745 elif pycompat.sysplatform == 'plan9':
2745 elif pycompat.sysplatform == 'plan9':
2746 keep.append('plan9')
2746 keep.append('plan9')
2747 else:
2747 else:
2748 keep.append('unix')
2748 keep.append('unix')
2749 keep.append(pycompat.sysplatform.lower())
2749 keep.append(pycompat.sysplatform.lower())
2750 if ui.verbose:
2750 if ui.verbose:
2751 keep.append('verbose')
2751 keep.append('verbose')
2752
2752
2753 commands = sys.modules[__name__]
2753 commands = sys.modules[__name__]
2754 formatted = help.formattedhelp(ui, commands, name, keep=keep, **opts)
2754 formatted = help.formattedhelp(ui, commands, name, keep=keep, **opts)
2755 ui.pager('help')
2755 ui.pager('help')
2756 ui.write(formatted)
2756 ui.write(formatted)
2757
2757
2758
2758
2759 @command('identify|id',
2759 @command('identify|id',
2760 [('r', 'rev', '',
2760 [('r', 'rev', '',
2761 _('identify the specified revision'), _('REV')),
2761 _('identify the specified revision'), _('REV')),
2762 ('n', 'num', None, _('show local revision number')),
2762 ('n', 'num', None, _('show local revision number')),
2763 ('i', 'id', None, _('show global revision id')),
2763 ('i', 'id', None, _('show global revision id')),
2764 ('b', 'branch', None, _('show branch')),
2764 ('b', 'branch', None, _('show branch')),
2765 ('t', 'tags', None, _('show tags')),
2765 ('t', 'tags', None, _('show tags')),
2766 ('B', 'bookmarks', None, _('show bookmarks')),
2766 ('B', 'bookmarks', None, _('show bookmarks')),
2767 ] + remoteopts + formatteropts,
2767 ] + remoteopts + formatteropts,
2768 _('[-nibtB] [-r REV] [SOURCE]'),
2768 _('[-nibtB] [-r REV] [SOURCE]'),
2769 optionalrepo=True,
2769 optionalrepo=True,
2770 intents={INTENT_READONLY})
2770 intents={INTENT_READONLY})
2771 def identify(ui, repo, source=None, rev=None,
2771 def identify(ui, repo, source=None, rev=None,
2772 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
2772 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
2773 """identify the working directory or specified revision
2773 """identify the working directory or specified revision
2774
2774
2775 Print a summary identifying the repository state at REV using one or
2775 Print a summary identifying the repository state at REV using one or
2776 two parent hash identifiers, followed by a "+" if the working
2776 two parent hash identifiers, followed by a "+" if the working
2777 directory has uncommitted changes, the branch name (if not default),
2777 directory has uncommitted changes, the branch name (if not default),
2778 a list of tags, and a list of bookmarks.
2778 a list of tags, and a list of bookmarks.
2779
2779
2780 When REV is not given, print a summary of the current state of the
2780 When REV is not given, print a summary of the current state of the
2781 repository including the working directory. Specify -r. to get information
2781 repository including the working directory. Specify -r. to get information
2782 of the working directory parent without scanning uncommitted changes.
2782 of the working directory parent without scanning uncommitted changes.
2783
2783
2784 Specifying a path to a repository root or Mercurial bundle will
2784 Specifying a path to a repository root or Mercurial bundle will
2785 cause lookup to operate on that repository/bundle.
2785 cause lookup to operate on that repository/bundle.
2786
2786
2787 .. container:: verbose
2787 .. container:: verbose
2788
2788
2789 Examples:
2789 Examples:
2790
2790
2791 - generate a build identifier for the working directory::
2791 - generate a build identifier for the working directory::
2792
2792
2793 hg id --id > build-id.dat
2793 hg id --id > build-id.dat
2794
2794
2795 - find the revision corresponding to a tag::
2795 - find the revision corresponding to a tag::
2796
2796
2797 hg id -n -r 1.3
2797 hg id -n -r 1.3
2798
2798
2799 - check the most recent revision of a remote repository::
2799 - check the most recent revision of a remote repository::
2800
2800
2801 hg id -r tip https://www.mercurial-scm.org/repo/hg/
2801 hg id -r tip https://www.mercurial-scm.org/repo/hg/
2802
2802
2803 See :hg:`log` for generating more information about specific revisions,
2803 See :hg:`log` for generating more information about specific revisions,
2804 including full hash identifiers.
2804 including full hash identifiers.
2805
2805
2806 Returns 0 if successful.
2806 Returns 0 if successful.
2807 """
2807 """
2808
2808
2809 opts = pycompat.byteskwargs(opts)
2809 opts = pycompat.byteskwargs(opts)
2810 if not repo and not source:
2810 if not repo and not source:
2811 raise error.Abort(_("there is no Mercurial repository here "
2811 raise error.Abort(_("there is no Mercurial repository here "
2812 "(.hg not found)"))
2812 "(.hg not found)"))
2813
2813
2814 if ui.debugflag:
2814 if ui.debugflag:
2815 hexfunc = hex
2815 hexfunc = hex
2816 else:
2816 else:
2817 hexfunc = short
2817 hexfunc = short
2818 default = not (num or id or branch or tags or bookmarks)
2818 default = not (num or id or branch or tags or bookmarks)
2819 output = []
2819 output = []
2820 revs = []
2820 revs = []
2821
2821
2822 if source:
2822 if source:
2823 source, branches = hg.parseurl(ui.expandpath(source))
2823 source, branches = hg.parseurl(ui.expandpath(source))
2824 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
2824 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
2825 repo = peer.local()
2825 repo = peer.local()
2826 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
2826 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
2827
2827
2828 fm = ui.formatter('identify', opts)
2828 fm = ui.formatter('identify', opts)
2829 fm.startitem()
2829 fm.startitem()
2830
2830
2831 if not repo:
2831 if not repo:
2832 if num or branch or tags:
2832 if num or branch or tags:
2833 raise error.Abort(
2833 raise error.Abort(
2834 _("can't query remote revision number, branch, or tags"))
2834 _("can't query remote revision number, branch, or tags"))
2835 if not rev and revs:
2835 if not rev and revs:
2836 rev = revs[0]
2836 rev = revs[0]
2837 if not rev:
2837 if not rev:
2838 rev = "tip"
2838 rev = "tip"
2839
2839
2840 remoterev = peer.lookup(rev)
2840 remoterev = peer.lookup(rev)
2841 hexrev = hexfunc(remoterev)
2841 hexrev = hexfunc(remoterev)
2842 if default or id:
2842 if default or id:
2843 output = [hexrev]
2843 output = [hexrev]
2844 fm.data(id=hexrev)
2844 fm.data(id=hexrev)
2845
2845
2846 def getbms():
2846 def getbms():
2847 bms = []
2847 bms = []
2848
2848
2849 if 'bookmarks' in peer.listkeys('namespaces'):
2849 if 'bookmarks' in peer.listkeys('namespaces'):
2850 hexremoterev = hex(remoterev)
2850 hexremoterev = hex(remoterev)
2851 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
2851 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
2852 if bmr == hexremoterev]
2852 if bmr == hexremoterev]
2853
2853
2854 return sorted(bms)
2854 return sorted(bms)
2855
2855
2856 bms = getbms()
2856 bms = getbms()
2857 if bookmarks:
2857 if bookmarks:
2858 output.extend(bms)
2858 output.extend(bms)
2859 elif default and not ui.quiet:
2859 elif default and not ui.quiet:
2860 # multiple bookmarks for a single parent separated by '/'
2860 # multiple bookmarks for a single parent separated by '/'
2861 bm = '/'.join(bms)
2861 bm = '/'.join(bms)
2862 if bm:
2862 if bm:
2863 output.append(bm)
2863 output.append(bm)
2864
2864
2865 fm.data(node=hex(remoterev))
2865 fm.data(node=hex(remoterev))
2866 fm.data(bookmarks=fm.formatlist(bms, name='bookmark'))
2866 fm.data(bookmarks=fm.formatlist(bms, name='bookmark'))
2867 else:
2867 else:
2868 if rev:
2868 if rev:
2869 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
2869 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
2870 ctx = scmutil.revsingle(repo, rev, None)
2870 ctx = scmutil.revsingle(repo, rev, None)
2871
2871
2872 if ctx.rev() is None:
2872 if ctx.rev() is None:
2873 ctx = repo[None]
2873 ctx = repo[None]
2874 parents = ctx.parents()
2874 parents = ctx.parents()
2875 taglist = []
2875 taglist = []
2876 for p in parents:
2876 for p in parents:
2877 taglist.extend(p.tags())
2877 taglist.extend(p.tags())
2878
2878
2879 dirty = ""
2879 dirty = ""
2880 if ctx.dirty(missing=True, merge=False, branch=False):
2880 if ctx.dirty(missing=True, merge=False, branch=False):
2881 dirty = '+'
2881 dirty = '+'
2882 fm.data(dirty=dirty)
2882 fm.data(dirty=dirty)
2883
2883
2884 hexoutput = [hexfunc(p.node()) for p in parents]
2884 hexoutput = [hexfunc(p.node()) for p in parents]
2885 if default or id:
2885 if default or id:
2886 output = ["%s%s" % ('+'.join(hexoutput), dirty)]
2886 output = ["%s%s" % ('+'.join(hexoutput), dirty)]
2887 fm.data(id="%s%s" % ('+'.join(hexoutput), dirty))
2887 fm.data(id="%s%s" % ('+'.join(hexoutput), dirty))
2888
2888
2889 if num:
2889 if num:
2890 numoutput = ["%d" % p.rev() for p in parents]
2890 numoutput = ["%d" % p.rev() for p in parents]
2891 output.append("%s%s" % ('+'.join(numoutput), dirty))
2891 output.append("%s%s" % ('+'.join(numoutput), dirty))
2892
2892
2893 fn = fm.nested('parents', tmpl='{rev}:{node|formatnode}', sep=' ')
2893 fn = fm.nested('parents', tmpl='{rev}:{node|formatnode}', sep=' ')
2894 for p in parents:
2894 for p in parents:
2895 fn.startitem()
2895 fn.startitem()
2896 fn.data(rev=p.rev())
2896 fn.data(rev=p.rev())
2897 fn.data(node=p.hex())
2897 fn.data(node=p.hex())
2898 fn.context(ctx=p)
2898 fn.context(ctx=p)
2899 fn.end()
2899 fn.end()
2900 else:
2900 else:
2901 hexoutput = hexfunc(ctx.node())
2901 hexoutput = hexfunc(ctx.node())
2902 if default or id:
2902 if default or id:
2903 output = [hexoutput]
2903 output = [hexoutput]
2904 fm.data(id=hexoutput)
2904 fm.data(id=hexoutput)
2905
2905
2906 if num:
2906 if num:
2907 output.append(pycompat.bytestr(ctx.rev()))
2907 output.append(pycompat.bytestr(ctx.rev()))
2908 taglist = ctx.tags()
2908 taglist = ctx.tags()
2909
2909
2910 if default and not ui.quiet:
2910 if default and not ui.quiet:
2911 b = ctx.branch()
2911 b = ctx.branch()
2912 if b != 'default':
2912 if b != 'default':
2913 output.append("(%s)" % b)
2913 output.append("(%s)" % b)
2914
2914
2915 # multiple tags for a single parent separated by '/'
2915 # multiple tags for a single parent separated by '/'
2916 t = '/'.join(taglist)
2916 t = '/'.join(taglist)
2917 if t:
2917 if t:
2918 output.append(t)
2918 output.append(t)
2919
2919
2920 # multiple bookmarks for a single parent separated by '/'
2920 # multiple bookmarks for a single parent separated by '/'
2921 bm = '/'.join(ctx.bookmarks())
2921 bm = '/'.join(ctx.bookmarks())
2922 if bm:
2922 if bm:
2923 output.append(bm)
2923 output.append(bm)
2924 else:
2924 else:
2925 if branch:
2925 if branch:
2926 output.append(ctx.branch())
2926 output.append(ctx.branch())
2927
2927
2928 if tags:
2928 if tags:
2929 output.extend(taglist)
2929 output.extend(taglist)
2930
2930
2931 if bookmarks:
2931 if bookmarks:
2932 output.extend(ctx.bookmarks())
2932 output.extend(ctx.bookmarks())
2933
2933
2934 fm.data(node=ctx.hex())
2934 fm.data(node=ctx.hex())
2935 fm.data(branch=ctx.branch())
2935 fm.data(branch=ctx.branch())
2936 fm.data(tags=fm.formatlist(taglist, name='tag', sep=':'))
2936 fm.data(tags=fm.formatlist(taglist, name='tag', sep=':'))
2937 fm.data(bookmarks=fm.formatlist(ctx.bookmarks(), name='bookmark'))
2937 fm.data(bookmarks=fm.formatlist(ctx.bookmarks(), name='bookmark'))
2938 fm.context(ctx=ctx)
2938 fm.context(ctx=ctx)
2939
2939
2940 fm.plain("%s\n" % ' '.join(output))
2940 fm.plain("%s\n" % ' '.join(output))
2941 fm.end()
2941 fm.end()
2942
2942
2943 @command('import|patch',
2943 @command('import|patch',
2944 [('p', 'strip', 1,
2944 [('p', 'strip', 1,
2945 _('directory strip option for patch. This has the same '
2945 _('directory strip option for patch. This has the same '
2946 'meaning as the corresponding patch option'), _('NUM')),
2946 'meaning as the corresponding patch option'), _('NUM')),
2947 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
2947 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
2948 ('e', 'edit', False, _('invoke editor on commit messages')),
2948 ('e', 'edit', False, _('invoke editor on commit messages')),
2949 ('f', 'force', None,
2949 ('f', 'force', None,
2950 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
2950 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
2951 ('', 'no-commit', None,
2951 ('', 'no-commit', None,
2952 _("don't commit, just update the working directory")),
2952 _("don't commit, just update the working directory")),
2953 ('', 'bypass', None,
2953 ('', 'bypass', None,
2954 _("apply patch without touching the working directory")),
2954 _("apply patch without touching the working directory")),
2955 ('', 'partial', None,
2955 ('', 'partial', None,
2956 _('commit even if some hunks fail')),
2956 _('commit even if some hunks fail')),
2957 ('', 'exact', None,
2957 ('', 'exact', None,
2958 _('abort if patch would apply lossily')),
2958 _('abort if patch would apply lossily')),
2959 ('', 'prefix', '',
2959 ('', 'prefix', '',
2960 _('apply patch to subdirectory'), _('DIR')),
2960 _('apply patch to subdirectory'), _('DIR')),
2961 ('', 'import-branch', None,
2961 ('', 'import-branch', None,
2962 _('use any branch information in patch (implied by --exact)'))] +
2962 _('use any branch information in patch (implied by --exact)'))] +
2963 commitopts + commitopts2 + similarityopts,
2963 commitopts + commitopts2 + similarityopts,
2964 _('[OPTION]... PATCH...'))
2964 _('[OPTION]... PATCH...'))
2965 def import_(ui, repo, patch1=None, *patches, **opts):
2965 def import_(ui, repo, patch1=None, *patches, **opts):
2966 """import an ordered set of patches
2966 """import an ordered set of patches
2967
2967
2968 Import a list of patches and commit them individually (unless
2968 Import a list of patches and commit them individually (unless
2969 --no-commit is specified).
2969 --no-commit is specified).
2970
2970
2971 To read a patch from standard input (stdin), use "-" as the patch
2971 To read a patch from standard input (stdin), use "-" as the patch
2972 name. If a URL is specified, the patch will be downloaded from
2972 name. If a URL is specified, the patch will be downloaded from
2973 there.
2973 there.
2974
2974
2975 Import first applies changes to the working directory (unless
2975 Import first applies changes to the working directory (unless
2976 --bypass is specified), import will abort if there are outstanding
2976 --bypass is specified), import will abort if there are outstanding
2977 changes.
2977 changes.
2978
2978
2979 Use --bypass to apply and commit patches directly to the
2979 Use --bypass to apply and commit patches directly to the
2980 repository, without affecting the working directory. Without
2980 repository, without affecting the working directory. Without
2981 --exact, patches will be applied on top of the working directory
2981 --exact, patches will be applied on top of the working directory
2982 parent revision.
2982 parent revision.
2983
2983
2984 You can import a patch straight from a mail message. Even patches
2984 You can import a patch straight from a mail message. Even patches
2985 as attachments work (to use the body part, it must have type
2985 as attachments work (to use the body part, it must have type
2986 text/plain or text/x-patch). From and Subject headers of email
2986 text/plain or text/x-patch). From and Subject headers of email
2987 message are used as default committer and commit message. All
2987 message are used as default committer and commit message. All
2988 text/plain body parts before first diff are added to the commit
2988 text/plain body parts before first diff are added to the commit
2989 message.
2989 message.
2990
2990
2991 If the imported patch was generated by :hg:`export`, user and
2991 If the imported patch was generated by :hg:`export`, user and
2992 description from patch override values from message headers and
2992 description from patch override values from message headers and
2993 body. Values given on command line with -m/--message and -u/--user
2993 body. Values given on command line with -m/--message and -u/--user
2994 override these.
2994 override these.
2995
2995
2996 If --exact is specified, import will set the working directory to
2996 If --exact is specified, import will set the working directory to
2997 the parent of each patch before applying it, and will abort if the
2997 the parent of each patch before applying it, and will abort if the
2998 resulting changeset has a different ID than the one recorded in
2998 resulting changeset has a different ID than the one recorded in
2999 the patch. This will guard against various ways that portable
2999 the patch. This will guard against various ways that portable
3000 patch formats and mail systems might fail to transfer Mercurial
3000 patch formats and mail systems might fail to transfer Mercurial
3001 data or metadata. See :hg:`bundle` for lossless transmission.
3001 data or metadata. See :hg:`bundle` for lossless transmission.
3002
3002
3003 Use --partial to ensure a changeset will be created from the patch
3003 Use --partial to ensure a changeset will be created from the patch
3004 even if some hunks fail to apply. Hunks that fail to apply will be
3004 even if some hunks fail to apply. Hunks that fail to apply will be
3005 written to a <target-file>.rej file. Conflicts can then be resolved
3005 written to a <target-file>.rej file. Conflicts can then be resolved
3006 by hand before :hg:`commit --amend` is run to update the created
3006 by hand before :hg:`commit --amend` is run to update the created
3007 changeset. This flag exists to let people import patches that
3007 changeset. This flag exists to let people import patches that
3008 partially apply without losing the associated metadata (author,
3008 partially apply without losing the associated metadata (author,
3009 date, description, ...).
3009 date, description, ...).
3010
3010
3011 .. note::
3011 .. note::
3012
3012
3013 When no hunks apply cleanly, :hg:`import --partial` will create
3013 When no hunks apply cleanly, :hg:`import --partial` will create
3014 an empty changeset, importing only the patch metadata.
3014 an empty changeset, importing only the patch metadata.
3015
3015
3016 With -s/--similarity, hg will attempt to discover renames and
3016 With -s/--similarity, hg will attempt to discover renames and
3017 copies in the patch in the same way as :hg:`addremove`.
3017 copies in the patch in the same way as :hg:`addremove`.
3018
3018
3019 It is possible to use external patch programs to perform the patch
3019 It is possible to use external patch programs to perform the patch
3020 by setting the ``ui.patch`` configuration option. For the default
3020 by setting the ``ui.patch`` configuration option. For the default
3021 internal tool, the fuzz can also be configured via ``patch.fuzz``.
3021 internal tool, the fuzz can also be configured via ``patch.fuzz``.
3022 See :hg:`help config` for more information about configuration
3022 See :hg:`help config` for more information about configuration
3023 files and how to use these options.
3023 files and how to use these options.
3024
3024
3025 See :hg:`help dates` for a list of formats valid for -d/--date.
3025 See :hg:`help dates` for a list of formats valid for -d/--date.
3026
3026
3027 .. container:: verbose
3027 .. container:: verbose
3028
3028
3029 Examples:
3029 Examples:
3030
3030
3031 - import a traditional patch from a website and detect renames::
3031 - import a traditional patch from a website and detect renames::
3032
3032
3033 hg import -s 80 http://example.com/bugfix.patch
3033 hg import -s 80 http://example.com/bugfix.patch
3034
3034
3035 - import a changeset from an hgweb server::
3035 - import a changeset from an hgweb server::
3036
3036
3037 hg import https://www.mercurial-scm.org/repo/hg/rev/5ca8c111e9aa
3037 hg import https://www.mercurial-scm.org/repo/hg/rev/5ca8c111e9aa
3038
3038
3039 - import all the patches in an Unix-style mbox::
3039 - import all the patches in an Unix-style mbox::
3040
3040
3041 hg import incoming-patches.mbox
3041 hg import incoming-patches.mbox
3042
3042
3043 - import patches from stdin::
3043 - import patches from stdin::
3044
3044
3045 hg import -
3045 hg import -
3046
3046
3047 - attempt to exactly restore an exported changeset (not always
3047 - attempt to exactly restore an exported changeset (not always
3048 possible)::
3048 possible)::
3049
3049
3050 hg import --exact proposed-fix.patch
3050 hg import --exact proposed-fix.patch
3051
3051
3052 - use an external tool to apply a patch which is too fuzzy for
3052 - use an external tool to apply a patch which is too fuzzy for
3053 the default internal tool.
3053 the default internal tool.
3054
3054
3055 hg import --config ui.patch="patch --merge" fuzzy.patch
3055 hg import --config ui.patch="patch --merge" fuzzy.patch
3056
3056
3057 - change the default fuzzing from 2 to a less strict 7
3057 - change the default fuzzing from 2 to a less strict 7
3058
3058
3059 hg import --config ui.fuzz=7 fuzz.patch
3059 hg import --config ui.fuzz=7 fuzz.patch
3060
3060
3061 Returns 0 on success, 1 on partial success (see --partial).
3061 Returns 0 on success, 1 on partial success (see --partial).
3062 """
3062 """
3063
3063
3064 opts = pycompat.byteskwargs(opts)
3064 opts = pycompat.byteskwargs(opts)
3065 if not patch1:
3065 if not patch1:
3066 raise error.Abort(_('need at least one patch to import'))
3066 raise error.Abort(_('need at least one patch to import'))
3067
3067
3068 patches = (patch1,) + patches
3068 patches = (patch1,) + patches
3069
3069
3070 date = opts.get('date')
3070 date = opts.get('date')
3071 if date:
3071 if date:
3072 opts['date'] = dateutil.parsedate(date)
3072 opts['date'] = dateutil.parsedate(date)
3073
3073
3074 exact = opts.get('exact')
3074 exact = opts.get('exact')
3075 update = not opts.get('bypass')
3075 update = not opts.get('bypass')
3076 if not update and opts.get('no_commit'):
3076 if not update and opts.get('no_commit'):
3077 raise error.Abort(_('cannot use --no-commit with --bypass'))
3077 raise error.Abort(_('cannot use --no-commit with --bypass'))
3078 try:
3078 try:
3079 sim = float(opts.get('similarity') or 0)
3079 sim = float(opts.get('similarity') or 0)
3080 except ValueError:
3080 except ValueError:
3081 raise error.Abort(_('similarity must be a number'))
3081 raise error.Abort(_('similarity must be a number'))
3082 if sim < 0 or sim > 100:
3082 if sim < 0 or sim > 100:
3083 raise error.Abort(_('similarity must be between 0 and 100'))
3083 raise error.Abort(_('similarity must be between 0 and 100'))
3084 if sim and not update:
3084 if sim and not update:
3085 raise error.Abort(_('cannot use --similarity with --bypass'))
3085 raise error.Abort(_('cannot use --similarity with --bypass'))
3086 if exact:
3086 if exact:
3087 if opts.get('edit'):
3087 if opts.get('edit'):
3088 raise error.Abort(_('cannot use --exact with --edit'))
3088 raise error.Abort(_('cannot use --exact with --edit'))
3089 if opts.get('prefix'):
3089 if opts.get('prefix'):
3090 raise error.Abort(_('cannot use --exact with --prefix'))
3090 raise error.Abort(_('cannot use --exact with --prefix'))
3091
3091
3092 base = opts["base"]
3092 base = opts["base"]
3093 wlock = dsguard = lock = tr = None
3093 wlock = dsguard = lock = tr = None
3094 msgs = []
3094 msgs = []
3095 ret = 0
3095 ret = 0
3096
3096
3097
3097
3098 try:
3098 try:
3099 wlock = repo.wlock()
3099 wlock = repo.wlock()
3100
3100
3101 if update:
3101 if update:
3102 cmdutil.checkunfinished(repo)
3102 cmdutil.checkunfinished(repo)
3103 if (exact or not opts.get('force')):
3103 if (exact or not opts.get('force')):
3104 cmdutil.bailifchanged(repo)
3104 cmdutil.bailifchanged(repo)
3105
3105
3106 if not opts.get('no_commit'):
3106 if not opts.get('no_commit'):
3107 lock = repo.lock()
3107 lock = repo.lock()
3108 tr = repo.transaction('import')
3108 tr = repo.transaction('import')
3109 else:
3109 else:
3110 dsguard = dirstateguard.dirstateguard(repo, 'import')
3110 dsguard = dirstateguard.dirstateguard(repo, 'import')
3111 parents = repo[None].parents()
3111 parents = repo[None].parents()
3112 for patchurl in patches:
3112 for patchurl in patches:
3113 if patchurl == '-':
3113 if patchurl == '-':
3114 ui.status(_('applying patch from stdin\n'))
3114 ui.status(_('applying patch from stdin\n'))
3115 patchfile = ui.fin
3115 patchfile = ui.fin
3116 patchurl = 'stdin' # for error message
3116 patchurl = 'stdin' # for error message
3117 else:
3117 else:
3118 patchurl = os.path.join(base, patchurl)
3118 patchurl = os.path.join(base, patchurl)
3119 ui.status(_('applying %s\n') % patchurl)
3119 ui.status(_('applying %s\n') % patchurl)
3120 patchfile = hg.openpath(ui, patchurl)
3120 patchfile = hg.openpath(ui, patchurl)
3121
3121
3122 haspatch = False
3122 haspatch = False
3123 for hunk in patch.split(patchfile):
3123 for hunk in patch.split(patchfile):
3124 with patch.extract(ui, hunk) as patchdata:
3124 with patch.extract(ui, hunk) as patchdata:
3125 msg, node, rej = cmdutil.tryimportone(ui, repo, patchdata,
3125 msg, node, rej = cmdutil.tryimportone(ui, repo, patchdata,
3126 parents, opts,
3126 parents, opts,
3127 msgs, hg.clean)
3127 msgs, hg.clean)
3128 if msg:
3128 if msg:
3129 haspatch = True
3129 haspatch = True
3130 ui.note(msg + '\n')
3130 ui.note(msg + '\n')
3131 if update or exact:
3131 if update or exact:
3132 parents = repo[None].parents()
3132 parents = repo[None].parents()
3133 else:
3133 else:
3134 parents = [repo[node]]
3134 parents = [repo[node]]
3135 if rej:
3135 if rej:
3136 ui.write_err(_("patch applied partially\n"))
3136 ui.write_err(_("patch applied partially\n"))
3137 ui.write_err(_("(fix the .rej files and run "
3137 ui.write_err(_("(fix the .rej files and run "
3138 "`hg commit --amend`)\n"))
3138 "`hg commit --amend`)\n"))
3139 ret = 1
3139 ret = 1
3140 break
3140 break
3141
3141
3142 if not haspatch:
3142 if not haspatch:
3143 raise error.Abort(_('%s: no diffs found') % patchurl)
3143 raise error.Abort(_('%s: no diffs found') % patchurl)
3144
3144
3145 if tr:
3145 if tr:
3146 tr.close()
3146 tr.close()
3147 if msgs:
3147 if msgs:
3148 repo.savecommitmessage('\n* * *\n'.join(msgs))
3148 repo.savecommitmessage('\n* * *\n'.join(msgs))
3149 if dsguard:
3149 if dsguard:
3150 dsguard.close()
3150 dsguard.close()
3151 return ret
3151 return ret
3152 finally:
3152 finally:
3153 if tr:
3153 if tr:
3154 tr.release()
3154 tr.release()
3155 release(lock, dsguard, wlock)
3155 release(lock, dsguard, wlock)
3156
3156
3157 @command('incoming|in',
3157 @command('incoming|in',
3158 [('f', 'force', None,
3158 [('f', 'force', None,
3159 _('run even if remote repository is unrelated')),
3159 _('run even if remote repository is unrelated')),
3160 ('n', 'newest-first', None, _('show newest record first')),
3160 ('n', 'newest-first', None, _('show newest record first')),
3161 ('', 'bundle', '',
3161 ('', 'bundle', '',
3162 _('file to store the bundles into'), _('FILE')),
3162 _('file to store the bundles into'), _('FILE')),
3163 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
3163 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
3164 ('B', 'bookmarks', False, _("compare bookmarks")),
3164 ('B', 'bookmarks', False, _("compare bookmarks")),
3165 ('b', 'branch', [],
3165 ('b', 'branch', [],
3166 _('a specific branch you would like to pull'), _('BRANCH')),
3166 _('a specific branch you would like to pull'), _('BRANCH')),
3167 ] + logopts + remoteopts + subrepoopts,
3167 ] + logopts + remoteopts + subrepoopts,
3168 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
3168 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
3169 def incoming(ui, repo, source="default", **opts):
3169 def incoming(ui, repo, source="default", **opts):
3170 """show new changesets found in source
3170 """show new changesets found in source
3171
3171
3172 Show new changesets found in the specified path/URL or the default
3172 Show new changesets found in the specified path/URL or the default
3173 pull location. These are the changesets that would have been pulled
3173 pull location. These are the changesets that would have been pulled
3174 by :hg:`pull` at the time you issued this command.
3174 by :hg:`pull` at the time you issued this command.
3175
3175
3176 See pull for valid source format details.
3176 See pull for valid source format details.
3177
3177
3178 .. container:: verbose
3178 .. container:: verbose
3179
3179
3180 With -B/--bookmarks, the result of bookmark comparison between
3180 With -B/--bookmarks, the result of bookmark comparison between
3181 local and remote repositories is displayed. With -v/--verbose,
3181 local and remote repositories is displayed. With -v/--verbose,
3182 status is also displayed for each bookmark like below::
3182 status is also displayed for each bookmark like below::
3183
3183
3184 BM1 01234567890a added
3184 BM1 01234567890a added
3185 BM2 1234567890ab advanced
3185 BM2 1234567890ab advanced
3186 BM3 234567890abc diverged
3186 BM3 234567890abc diverged
3187 BM4 34567890abcd changed
3187 BM4 34567890abcd changed
3188
3188
3189 The action taken locally when pulling depends on the
3189 The action taken locally when pulling depends on the
3190 status of each bookmark:
3190 status of each bookmark:
3191
3191
3192 :``added``: pull will create it
3192 :``added``: pull will create it
3193 :``advanced``: pull will update it
3193 :``advanced``: pull will update it
3194 :``diverged``: pull will create a divergent bookmark
3194 :``diverged``: pull will create a divergent bookmark
3195 :``changed``: result depends on remote changesets
3195 :``changed``: result depends on remote changesets
3196
3196
3197 From the point of view of pulling behavior, bookmark
3197 From the point of view of pulling behavior, bookmark
3198 existing only in the remote repository are treated as ``added``,
3198 existing only in the remote repository are treated as ``added``,
3199 even if it is in fact locally deleted.
3199 even if it is in fact locally deleted.
3200
3200
3201 .. container:: verbose
3201 .. container:: verbose
3202
3202
3203 For remote repository, using --bundle avoids downloading the
3203 For remote repository, using --bundle avoids downloading the
3204 changesets twice if the incoming is followed by a pull.
3204 changesets twice if the incoming is followed by a pull.
3205
3205
3206 Examples:
3206 Examples:
3207
3207
3208 - show incoming changes with patches and full description::
3208 - show incoming changes with patches and full description::
3209
3209
3210 hg incoming -vp
3210 hg incoming -vp
3211
3211
3212 - show incoming changes excluding merges, store a bundle::
3212 - show incoming changes excluding merges, store a bundle::
3213
3213
3214 hg in -vpM --bundle incoming.hg
3214 hg in -vpM --bundle incoming.hg
3215 hg pull incoming.hg
3215 hg pull incoming.hg
3216
3216
3217 - briefly list changes inside a bundle::
3217 - briefly list changes inside a bundle::
3218
3218
3219 hg in changes.hg -T "{desc|firstline}\\n"
3219 hg in changes.hg -T "{desc|firstline}\\n"
3220
3220
3221 Returns 0 if there are incoming changes, 1 otherwise.
3221 Returns 0 if there are incoming changes, 1 otherwise.
3222 """
3222 """
3223 opts = pycompat.byteskwargs(opts)
3223 opts = pycompat.byteskwargs(opts)
3224 if opts.get('graph'):
3224 if opts.get('graph'):
3225 logcmdutil.checkunsupportedgraphflags([], opts)
3225 logcmdutil.checkunsupportedgraphflags([], opts)
3226 def display(other, chlist, displayer):
3226 def display(other, chlist, displayer):
3227 revdag = logcmdutil.graphrevs(other, chlist, opts)
3227 revdag = logcmdutil.graphrevs(other, chlist, opts)
3228 logcmdutil.displaygraph(ui, repo, revdag, displayer,
3228 logcmdutil.displaygraph(ui, repo, revdag, displayer,
3229 graphmod.asciiedges)
3229 graphmod.asciiedges)
3230
3230
3231 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
3231 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
3232 return 0
3232 return 0
3233
3233
3234 if opts.get('bundle') and opts.get('subrepos'):
3234 if opts.get('bundle') and opts.get('subrepos'):
3235 raise error.Abort(_('cannot combine --bundle and --subrepos'))
3235 raise error.Abort(_('cannot combine --bundle and --subrepos'))
3236
3236
3237 if opts.get('bookmarks'):
3237 if opts.get('bookmarks'):
3238 source, branches = hg.parseurl(ui.expandpath(source),
3238 source, branches = hg.parseurl(ui.expandpath(source),
3239 opts.get('branch'))
3239 opts.get('branch'))
3240 other = hg.peer(repo, opts, source)
3240 other = hg.peer(repo, opts, source)
3241 if 'bookmarks' not in other.listkeys('namespaces'):
3241 if 'bookmarks' not in other.listkeys('namespaces'):
3242 ui.warn(_("remote doesn't support bookmarks\n"))
3242 ui.warn(_("remote doesn't support bookmarks\n"))
3243 return 0
3243 return 0
3244 ui.pager('incoming')
3244 ui.pager('incoming')
3245 ui.status(_('comparing with %s\n') % util.hidepassword(source))
3245 ui.status(_('comparing with %s\n') % util.hidepassword(source))
3246 return bookmarks.incoming(ui, repo, other)
3246 return bookmarks.incoming(ui, repo, other)
3247
3247
3248 repo._subtoppath = ui.expandpath(source)
3248 repo._subtoppath = ui.expandpath(source)
3249 try:
3249 try:
3250 return hg.incoming(ui, repo, source, opts)
3250 return hg.incoming(ui, repo, source, opts)
3251 finally:
3251 finally:
3252 del repo._subtoppath
3252 del repo._subtoppath
3253
3253
3254
3254
3255 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
3255 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
3256 norepo=True)
3256 norepo=True)
3257 def init(ui, dest=".", **opts):
3257 def init(ui, dest=".", **opts):
3258 """create a new repository in the given directory
3258 """create a new repository in the given directory
3259
3259
3260 Initialize a new repository in the given directory. If the given
3260 Initialize a new repository in the given directory. If the given
3261 directory does not exist, it will be created.
3261 directory does not exist, it will be created.
3262
3262
3263 If no directory is given, the current directory is used.
3263 If no directory is given, the current directory is used.
3264
3264
3265 It is possible to specify an ``ssh://`` URL as the destination.
3265 It is possible to specify an ``ssh://`` URL as the destination.
3266 See :hg:`help urls` for more information.
3266 See :hg:`help urls` for more information.
3267
3267
3268 Returns 0 on success.
3268 Returns 0 on success.
3269 """
3269 """
3270 opts = pycompat.byteskwargs(opts)
3270 opts = pycompat.byteskwargs(opts)
3271 hg.peer(ui, opts, ui.expandpath(dest), create=True)
3271 hg.peer(ui, opts, ui.expandpath(dest), create=True)
3272
3272
3273 @command('locate',
3273 @command('locate',
3274 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3274 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3275 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3275 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3276 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
3276 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
3277 ] + walkopts,
3277 ] + walkopts,
3278 _('[OPTION]... [PATTERN]...'))
3278 _('[OPTION]... [PATTERN]...'))
3279 def locate(ui, repo, *pats, **opts):
3279 def locate(ui, repo, *pats, **opts):
3280 """locate files matching specific patterns (DEPRECATED)
3280 """locate files matching specific patterns (DEPRECATED)
3281
3281
3282 Print files under Mercurial control in the working directory whose
3282 Print files under Mercurial control in the working directory whose
3283 names match the given patterns.
3283 names match the given patterns.
3284
3284
3285 By default, this command searches all directories in the working
3285 By default, this command searches all directories in the working
3286 directory. To search just the current directory and its
3286 directory. To search just the current directory and its
3287 subdirectories, use "--include .".
3287 subdirectories, use "--include .".
3288
3288
3289 If no patterns are given to match, this command prints the names
3289 If no patterns are given to match, this command prints the names
3290 of all files under Mercurial control in the working directory.
3290 of all files under Mercurial control in the working directory.
3291
3291
3292 If you want to feed the output of this command into the "xargs"
3292 If you want to feed the output of this command into the "xargs"
3293 command, use the -0 option to both this command and "xargs". This
3293 command, use the -0 option to both this command and "xargs". This
3294 will avoid the problem of "xargs" treating single filenames that
3294 will avoid the problem of "xargs" treating single filenames that
3295 contain whitespace as multiple filenames.
3295 contain whitespace as multiple filenames.
3296
3296
3297 See :hg:`help files` for a more versatile command.
3297 See :hg:`help files` for a more versatile command.
3298
3298
3299 Returns 0 if a match is found, 1 otherwise.
3299 Returns 0 if a match is found, 1 otherwise.
3300 """
3300 """
3301 opts = pycompat.byteskwargs(opts)
3301 opts = pycompat.byteskwargs(opts)
3302 if opts.get('print0'):
3302 if opts.get('print0'):
3303 end = '\0'
3303 end = '\0'
3304 else:
3304 else:
3305 end = '\n'
3305 end = '\n'
3306 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3306 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3307
3307
3308 ret = 1
3308 ret = 1
3309 m = scmutil.match(ctx, pats, opts, default='relglob',
3309 m = scmutil.match(ctx, pats, opts, default='relglob',
3310 badfn=lambda x, y: False)
3310 badfn=lambda x, y: False)
3311
3311
3312 ui.pager('locate')
3312 ui.pager('locate')
3313 for abs in ctx.matches(m):
3313 for abs in ctx.matches(m):
3314 if opts.get('fullpath'):
3314 if opts.get('fullpath'):
3315 ui.write(repo.wjoin(abs), end)
3315 ui.write(repo.wjoin(abs), end)
3316 else:
3316 else:
3317 ui.write(((pats and m.rel(abs)) or abs), end)
3317 ui.write(((pats and m.rel(abs)) or abs), end)
3318 ret = 0
3318 ret = 0
3319
3319
3320 return ret
3320 return ret
3321
3321
3322 @command('^log|history',
3322 @command('^log|history',
3323 [('f', 'follow', None,
3323 [('f', 'follow', None,
3324 _('follow changeset history, or file history across copies and renames')),
3324 _('follow changeset history, or file history across copies and renames')),
3325 ('', 'follow-first', None,
3325 ('', 'follow-first', None,
3326 _('only follow the first parent of merge changesets (DEPRECATED)')),
3326 _('only follow the first parent of merge changesets (DEPRECATED)')),
3327 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
3327 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
3328 ('C', 'copies', None, _('show copied files')),
3328 ('C', 'copies', None, _('show copied files')),
3329 ('k', 'keyword', [],
3329 ('k', 'keyword', [],
3330 _('do case-insensitive search for a given text'), _('TEXT')),
3330 _('do case-insensitive search for a given text'), _('TEXT')),
3331 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
3331 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
3332 ('L', 'line-range', [],
3332 ('L', 'line-range', [],
3333 _('follow line range of specified file (EXPERIMENTAL)'),
3333 _('follow line range of specified file (EXPERIMENTAL)'),
3334 _('FILE,RANGE')),
3334 _('FILE,RANGE')),
3335 ('', 'removed', None, _('include revisions where files were removed')),
3335 ('', 'removed', None, _('include revisions where files were removed')),
3336 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
3336 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
3337 ('u', 'user', [], _('revisions committed by user'), _('USER')),
3337 ('u', 'user', [], _('revisions committed by user'), _('USER')),
3338 ('', 'only-branch', [],
3338 ('', 'only-branch', [],
3339 _('show only changesets within the given named branch (DEPRECATED)'),
3339 _('show only changesets within the given named branch (DEPRECATED)'),
3340 _('BRANCH')),
3340 _('BRANCH')),
3341 ('b', 'branch', [],
3341 ('b', 'branch', [],
3342 _('show changesets within the given named branch'), _('BRANCH')),
3342 _('show changesets within the given named branch'), _('BRANCH')),
3343 ('P', 'prune', [],
3343 ('P', 'prune', [],
3344 _('do not display revision or any of its ancestors'), _('REV')),
3344 _('do not display revision or any of its ancestors'), _('REV')),
3345 ] + logopts + walkopts,
3345 ] + logopts + walkopts,
3346 _('[OPTION]... [FILE]'),
3346 _('[OPTION]... [FILE]'),
3347 inferrepo=True,
3347 inferrepo=True,
3348 intents={INTENT_READONLY})
3348 intents={INTENT_READONLY})
3349 def log(ui, repo, *pats, **opts):
3349 def log(ui, repo, *pats, **opts):
3350 """show revision history of entire repository or files
3350 """show revision history of entire repository or files
3351
3351
3352 Print the revision history of the specified files or the entire
3352 Print the revision history of the specified files or the entire
3353 project.
3353 project.
3354
3354
3355 If no revision range is specified, the default is ``tip:0`` unless
3355 If no revision range is specified, the default is ``tip:0`` unless
3356 --follow is set, in which case the working directory parent is
3356 --follow is set, in which case the working directory parent is
3357 used as the starting revision.
3357 used as the starting revision.
3358
3358
3359 File history is shown without following rename or copy history of
3359 File history is shown without following rename or copy history of
3360 files. Use -f/--follow with a filename to follow history across
3360 files. Use -f/--follow with a filename to follow history across
3361 renames and copies. --follow without a filename will only show
3361 renames and copies. --follow without a filename will only show
3362 ancestors of the starting revision.
3362 ancestors of the starting revision.
3363
3363
3364 By default this command prints revision number and changeset id,
3364 By default this command prints revision number and changeset id,
3365 tags, non-trivial parents, user, date and time, and a summary for
3365 tags, non-trivial parents, user, date and time, and a summary for
3366 each commit. When the -v/--verbose switch is used, the list of
3366 each commit. When the -v/--verbose switch is used, the list of
3367 changed files and full commit message are shown.
3367 changed files and full commit message are shown.
3368
3368
3369 With --graph the revisions are shown as an ASCII art DAG with the most
3369 With --graph the revisions are shown as an ASCII art DAG with the most
3370 recent changeset at the top.
3370 recent changeset at the top.
3371 'o' is a changeset, '@' is a working directory parent, '_' closes a branch,
3371 'o' is a changeset, '@' is a working directory parent, '_' closes a branch,
3372 'x' is obsolete, '*' is unstable, and '+' represents a fork where the
3372 'x' is obsolete, '*' is unstable, and '+' represents a fork where the
3373 changeset from the lines below is a parent of the 'o' merge on the same
3373 changeset from the lines below is a parent of the 'o' merge on the same
3374 line.
3374 line.
3375 Paths in the DAG are represented with '|', '/' and so forth. ':' in place
3375 Paths in the DAG are represented with '|', '/' and so forth. ':' in place
3376 of a '|' indicates one or more revisions in a path are omitted.
3376 of a '|' indicates one or more revisions in a path are omitted.
3377
3377
3378 .. container:: verbose
3378 .. container:: verbose
3379
3379
3380 Use -L/--line-range FILE,M:N options to follow the history of lines
3380 Use -L/--line-range FILE,M:N options to follow the history of lines
3381 from M to N in FILE. With -p/--patch only diff hunks affecting
3381 from M to N in FILE. With -p/--patch only diff hunks affecting
3382 specified line range will be shown. This option requires --follow;
3382 specified line range will be shown. This option requires --follow;
3383 it can be specified multiple times. Currently, this option is not
3383 it can be specified multiple times. Currently, this option is not
3384 compatible with --graph. This option is experimental.
3384 compatible with --graph. This option is experimental.
3385
3385
3386 .. note::
3386 .. note::
3387
3387
3388 :hg:`log --patch` may generate unexpected diff output for merge
3388 :hg:`log --patch` may generate unexpected diff output for merge
3389 changesets, as it will only compare the merge changeset against
3389 changesets, as it will only compare the merge changeset against
3390 its first parent. Also, only files different from BOTH parents
3390 its first parent. Also, only files different from BOTH parents
3391 will appear in files:.
3391 will appear in files:.
3392
3392
3393 .. note::
3393 .. note::
3394
3394
3395 For performance reasons, :hg:`log FILE` may omit duplicate changes
3395 For performance reasons, :hg:`log FILE` may omit duplicate changes
3396 made on branches and will not show removals or mode changes. To
3396 made on branches and will not show removals or mode changes. To
3397 see all such changes, use the --removed switch.
3397 see all such changes, use the --removed switch.
3398
3398
3399 .. container:: verbose
3399 .. container:: verbose
3400
3400
3401 .. note::
3401 .. note::
3402
3402
3403 The history resulting from -L/--line-range options depends on diff
3403 The history resulting from -L/--line-range options depends on diff
3404 options; for instance if white-spaces are ignored, respective changes
3404 options; for instance if white-spaces are ignored, respective changes
3405 with only white-spaces in specified line range will not be listed.
3405 with only white-spaces in specified line range will not be listed.
3406
3406
3407 .. container:: verbose
3407 .. container:: verbose
3408
3408
3409 Some examples:
3409 Some examples:
3410
3410
3411 - changesets with full descriptions and file lists::
3411 - changesets with full descriptions and file lists::
3412
3412
3413 hg log -v
3413 hg log -v
3414
3414
3415 - changesets ancestral to the working directory::
3415 - changesets ancestral to the working directory::
3416
3416
3417 hg log -f
3417 hg log -f
3418
3418
3419 - last 10 commits on the current branch::
3419 - last 10 commits on the current branch::
3420
3420
3421 hg log -l 10 -b .
3421 hg log -l 10 -b .
3422
3422
3423 - changesets showing all modifications of a file, including removals::
3423 - changesets showing all modifications of a file, including removals::
3424
3424
3425 hg log --removed file.c
3425 hg log --removed file.c
3426
3426
3427 - all changesets that touch a directory, with diffs, excluding merges::
3427 - all changesets that touch a directory, with diffs, excluding merges::
3428
3428
3429 hg log -Mp lib/
3429 hg log -Mp lib/
3430
3430
3431 - all revision numbers that match a keyword::
3431 - all revision numbers that match a keyword::
3432
3432
3433 hg log -k bug --template "{rev}\\n"
3433 hg log -k bug --template "{rev}\\n"
3434
3434
3435 - the full hash identifier of the working directory parent::
3435 - the full hash identifier of the working directory parent::
3436
3436
3437 hg log -r . --template "{node}\\n"
3437 hg log -r . --template "{node}\\n"
3438
3438
3439 - list available log templates::
3439 - list available log templates::
3440
3440
3441 hg log -T list
3441 hg log -T list
3442
3442
3443 - check if a given changeset is included in a tagged release::
3443 - check if a given changeset is included in a tagged release::
3444
3444
3445 hg log -r "a21ccf and ancestor(1.9)"
3445 hg log -r "a21ccf and ancestor(1.9)"
3446
3446
3447 - find all changesets by some user in a date range::
3447 - find all changesets by some user in a date range::
3448
3448
3449 hg log -k alice -d "may 2008 to jul 2008"
3449 hg log -k alice -d "may 2008 to jul 2008"
3450
3450
3451 - summary of all changesets after the last tag::
3451 - summary of all changesets after the last tag::
3452
3452
3453 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
3453 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
3454
3454
3455 - changesets touching lines 13 to 23 for file.c::
3455 - changesets touching lines 13 to 23 for file.c::
3456
3456
3457 hg log -L file.c,13:23
3457 hg log -L file.c,13:23
3458
3458
3459 - changesets touching lines 13 to 23 for file.c and lines 2 to 6 of
3459 - changesets touching lines 13 to 23 for file.c and lines 2 to 6 of
3460 main.c with patch::
3460 main.c with patch::
3461
3461
3462 hg log -L file.c,13:23 -L main.c,2:6 -p
3462 hg log -L file.c,13:23 -L main.c,2:6 -p
3463
3463
3464 See :hg:`help dates` for a list of formats valid for -d/--date.
3464 See :hg:`help dates` for a list of formats valid for -d/--date.
3465
3465
3466 See :hg:`help revisions` for more about specifying and ordering
3466 See :hg:`help revisions` for more about specifying and ordering
3467 revisions.
3467 revisions.
3468
3468
3469 See :hg:`help templates` for more about pre-packaged styles and
3469 See :hg:`help templates` for more about pre-packaged styles and
3470 specifying custom templates. The default template used by the log
3470 specifying custom templates. The default template used by the log
3471 command can be customized via the ``ui.logtemplate`` configuration
3471 command can be customized via the ``ui.logtemplate`` configuration
3472 setting.
3472 setting.
3473
3473
3474 Returns 0 on success.
3474 Returns 0 on success.
3475
3475
3476 """
3476 """
3477 opts = pycompat.byteskwargs(opts)
3477 opts = pycompat.byteskwargs(opts)
3478 linerange = opts.get('line_range')
3478 linerange = opts.get('line_range')
3479
3479
3480 if linerange and not opts.get('follow'):
3480 if linerange and not opts.get('follow'):
3481 raise error.Abort(_('--line-range requires --follow'))
3481 raise error.Abort(_('--line-range requires --follow'))
3482
3482
3483 if linerange and pats:
3483 if linerange and pats:
3484 # TODO: take pats as patterns with no line-range filter
3484 # TODO: take pats as patterns with no line-range filter
3485 raise error.Abort(
3485 raise error.Abort(
3486 _('FILE arguments are not compatible with --line-range option')
3486 _('FILE arguments are not compatible with --line-range option')
3487 )
3487 )
3488
3488
3489 repo = scmutil.unhidehashlikerevs(repo, opts.get('rev'), 'nowarn')
3489 repo = scmutil.unhidehashlikerevs(repo, opts.get('rev'), 'nowarn')
3490 revs, differ = logcmdutil.getrevs(repo, pats, opts)
3490 revs, differ = logcmdutil.getrevs(repo, pats, opts)
3491 if linerange:
3491 if linerange:
3492 # TODO: should follow file history from logcmdutil._initialrevs(),
3492 # TODO: should follow file history from logcmdutil._initialrevs(),
3493 # then filter the result by logcmdutil._makerevset() and --limit
3493 # then filter the result by logcmdutil._makerevset() and --limit
3494 revs, differ = logcmdutil.getlinerangerevs(repo, revs, opts)
3494 revs, differ = logcmdutil.getlinerangerevs(repo, revs, opts)
3495
3495
3496 getrenamed = None
3496 getrenamed = None
3497 if opts.get('copies'):
3497 if opts.get('copies'):
3498 endrev = None
3498 endrev = None
3499 if revs:
3499 if revs:
3500 endrev = revs.max() + 1
3500 endrev = revs.max() + 1
3501 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
3501 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
3502
3502
3503 ui.pager('log')
3503 ui.pager('log')
3504 displayer = logcmdutil.changesetdisplayer(ui, repo, opts, differ,
3504 displayer = logcmdutil.changesetdisplayer(ui, repo, opts, differ,
3505 buffered=True)
3505 buffered=True)
3506 if opts.get('graph'):
3506 if opts.get('graph'):
3507 displayfn = logcmdutil.displaygraphrevs
3507 displayfn = logcmdutil.displaygraphrevs
3508 else:
3508 else:
3509 displayfn = logcmdutil.displayrevs
3509 displayfn = logcmdutil.displayrevs
3510 displayfn(ui, repo, revs, displayer, getrenamed)
3510 displayfn(ui, repo, revs, displayer, getrenamed)
3511
3511
3512 @command('manifest',
3512 @command('manifest',
3513 [('r', 'rev', '', _('revision to display'), _('REV')),
3513 [('r', 'rev', '', _('revision to display'), _('REV')),
3514 ('', 'all', False, _("list files from all revisions"))]
3514 ('', 'all', False, _("list files from all revisions"))]
3515 + formatteropts,
3515 + formatteropts,
3516 _('[-r REV]'),
3516 _('[-r REV]'),
3517 intents={INTENT_READONLY})
3517 intents={INTENT_READONLY})
3518 def manifest(ui, repo, node=None, rev=None, **opts):
3518 def manifest(ui, repo, node=None, rev=None, **opts):
3519 """output the current or given revision of the project manifest
3519 """output the current or given revision of the project manifest
3520
3520
3521 Print a list of version controlled files for the given revision.
3521 Print a list of version controlled files for the given revision.
3522 If no revision is given, the first parent of the working directory
3522 If no revision is given, the first parent of the working directory
3523 is used, or the null revision if no revision is checked out.
3523 is used, or the null revision if no revision is checked out.
3524
3524
3525 With -v, print file permissions, symlink and executable bits.
3525 With -v, print file permissions, symlink and executable bits.
3526 With --debug, print file revision hashes.
3526 With --debug, print file revision hashes.
3527
3527
3528 If option --all is specified, the list of all files from all revisions
3528 If option --all is specified, the list of all files from all revisions
3529 is printed. This includes deleted and renamed files.
3529 is printed. This includes deleted and renamed files.
3530
3530
3531 Returns 0 on success.
3531 Returns 0 on success.
3532 """
3532 """
3533 opts = pycompat.byteskwargs(opts)
3533 opts = pycompat.byteskwargs(opts)
3534 fm = ui.formatter('manifest', opts)
3534 fm = ui.formatter('manifest', opts)
3535
3535
3536 if opts.get('all'):
3536 if opts.get('all'):
3537 if rev or node:
3537 if rev or node:
3538 raise error.Abort(_("can't specify a revision with --all"))
3538 raise error.Abort(_("can't specify a revision with --all"))
3539
3539
3540 res = set()
3540 res = set()
3541 for rev in repo:
3541 for rev in repo:
3542 ctx = repo[rev]
3542 ctx = repo[rev]
3543 res |= set(ctx.files())
3543 res |= set(ctx.files())
3544
3544
3545 ui.pager('manifest')
3545 ui.pager('manifest')
3546 for f in sorted(res):
3546 for f in sorted(res):
3547 fm.startitem()
3547 fm.startitem()
3548 fm.write("path", '%s\n', f)
3548 fm.write("path", '%s\n', f)
3549 fm.end()
3549 fm.end()
3550 return
3550 return
3551
3551
3552 if rev and node:
3552 if rev and node:
3553 raise error.Abort(_("please specify just one revision"))
3553 raise error.Abort(_("please specify just one revision"))
3554
3554
3555 if not node:
3555 if not node:
3556 node = rev
3556 node = rev
3557
3557
3558 char = {'l': '@', 'x': '*', '': '', 't': 'd'}
3558 char = {'l': '@', 'x': '*', '': '', 't': 'd'}
3559 mode = {'l': '644', 'x': '755', '': '644', 't': '755'}
3559 mode = {'l': '644', 'x': '755', '': '644', 't': '755'}
3560 if node:
3560 if node:
3561 repo = scmutil.unhidehashlikerevs(repo, [node], 'nowarn')
3561 repo = scmutil.unhidehashlikerevs(repo, [node], 'nowarn')
3562 ctx = scmutil.revsingle(repo, node)
3562 ctx = scmutil.revsingle(repo, node)
3563 mf = ctx.manifest()
3563 mf = ctx.manifest()
3564 ui.pager('manifest')
3564 ui.pager('manifest')
3565 for f in ctx:
3565 for f in ctx:
3566 fm.startitem()
3566 fm.startitem()
3567 fl = ctx[f].flags()
3567 fl = ctx[f].flags()
3568 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
3568 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
3569 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
3569 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
3570 fm.write('path', '%s\n', f)
3570 fm.write('path', '%s\n', f)
3571 fm.end()
3571 fm.end()
3572
3572
3573 @command('^merge',
3573 @command('^merge',
3574 [('f', 'force', None,
3574 [('f', 'force', None,
3575 _('force a merge including outstanding changes (DEPRECATED)')),
3575 _('force a merge including outstanding changes (DEPRECATED)')),
3576 ('r', 'rev', '', _('revision to merge'), _('REV')),
3576 ('r', 'rev', '', _('revision to merge'), _('REV')),
3577 ('P', 'preview', None,
3577 ('P', 'preview', None,
3578 _('review revisions to merge (no merge is performed)')),
3578 _('review revisions to merge (no merge is performed)')),
3579 ('', 'abort', None, _('abort the ongoing merge')),
3579 ('', 'abort', None, _('abort the ongoing merge')),
3580 ] + mergetoolopts,
3580 ] + mergetoolopts,
3581 _('[-P] [[-r] REV]'))
3581 _('[-P] [[-r] REV]'))
3582 def merge(ui, repo, node=None, **opts):
3582 def merge(ui, repo, node=None, **opts):
3583 """merge another revision into working directory
3583 """merge another revision into working directory
3584
3584
3585 The current working directory is updated with all changes made in
3585 The current working directory is updated with all changes made in
3586 the requested revision since the last common predecessor revision.
3586 the requested revision since the last common predecessor revision.
3587
3587
3588 Files that changed between either parent are marked as changed for
3588 Files that changed between either parent are marked as changed for
3589 the next commit and a commit must be performed before any further
3589 the next commit and a commit must be performed before any further
3590 updates to the repository are allowed. The next commit will have
3590 updates to the repository are allowed. The next commit will have
3591 two parents.
3591 two parents.
3592
3592
3593 ``--tool`` can be used to specify the merge tool used for file
3593 ``--tool`` can be used to specify the merge tool used for file
3594 merges. It overrides the HGMERGE environment variable and your
3594 merges. It overrides the HGMERGE environment variable and your
3595 configuration files. See :hg:`help merge-tools` for options.
3595 configuration files. See :hg:`help merge-tools` for options.
3596
3596
3597 If no revision is specified, the working directory's parent is a
3597 If no revision is specified, the working directory's parent is a
3598 head revision, and the current branch contains exactly one other
3598 head revision, and the current branch contains exactly one other
3599 head, the other head is merged with by default. Otherwise, an
3599 head, the other head is merged with by default. Otherwise, an
3600 explicit revision with which to merge with must be provided.
3600 explicit revision with which to merge with must be provided.
3601
3601
3602 See :hg:`help resolve` for information on handling file conflicts.
3602 See :hg:`help resolve` for information on handling file conflicts.
3603
3603
3604 To undo an uncommitted merge, use :hg:`merge --abort` which
3604 To undo an uncommitted merge, use :hg:`merge --abort` which
3605 will check out a clean copy of the original merge parent, losing
3605 will check out a clean copy of the original merge parent, losing
3606 all changes.
3606 all changes.
3607
3607
3608 Returns 0 on success, 1 if there are unresolved files.
3608 Returns 0 on success, 1 if there are unresolved files.
3609 """
3609 """
3610
3610
3611 opts = pycompat.byteskwargs(opts)
3611 opts = pycompat.byteskwargs(opts)
3612 abort = opts.get('abort')
3612 abort = opts.get('abort')
3613 if abort and repo.dirstate.p2() == nullid:
3613 if abort and repo.dirstate.p2() == nullid:
3614 cmdutil.wrongtooltocontinue(repo, _('merge'))
3614 cmdutil.wrongtooltocontinue(repo, _('merge'))
3615 if abort:
3615 if abort:
3616 if node:
3616 if node:
3617 raise error.Abort(_("cannot specify a node with --abort"))
3617 raise error.Abort(_("cannot specify a node with --abort"))
3618 if opts.get('rev'):
3618 if opts.get('rev'):
3619 raise error.Abort(_("cannot specify both --rev and --abort"))
3619 raise error.Abort(_("cannot specify both --rev and --abort"))
3620 if opts.get('preview'):
3620 if opts.get('preview'):
3621 raise error.Abort(_("cannot specify --preview with --abort"))
3621 raise error.Abort(_("cannot specify --preview with --abort"))
3622 if opts.get('rev') and node:
3622 if opts.get('rev') and node:
3623 raise error.Abort(_("please specify just one revision"))
3623 raise error.Abort(_("please specify just one revision"))
3624 if not node:
3624 if not node:
3625 node = opts.get('rev')
3625 node = opts.get('rev')
3626
3626
3627 if node:
3627 if node:
3628 node = scmutil.revsingle(repo, node).node()
3628 node = scmutil.revsingle(repo, node).node()
3629
3629
3630 if not node and not abort:
3630 if not node and not abort:
3631 node = repo[destutil.destmerge(repo)].node()
3631 node = repo[destutil.destmerge(repo)].node()
3632
3632
3633 if opts.get('preview'):
3633 if opts.get('preview'):
3634 # find nodes that are ancestors of p2 but not of p1
3634 # find nodes that are ancestors of p2 but not of p1
3635 p1 = repo.lookup('.')
3635 p1 = repo.lookup('.')
3636 p2 = node
3636 p2 = node
3637 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
3637 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
3638
3638
3639 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
3639 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
3640 for node in nodes:
3640 for node in nodes:
3641 displayer.show(repo[node])
3641 displayer.show(repo[node])
3642 displayer.close()
3642 displayer.close()
3643 return 0
3643 return 0
3644
3644
3645 try:
3645 try:
3646 # ui.forcemerge is an internal variable, do not document
3646 # ui.forcemerge is an internal variable, do not document
3647 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
3647 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
3648 force = opts.get('force')
3648 force = opts.get('force')
3649 labels = ['working copy', 'merge rev']
3649 labels = ['working copy', 'merge rev']
3650 return hg.merge(repo, node, force=force, mergeforce=force,
3650 return hg.merge(repo, node, force=force, mergeforce=force,
3651 labels=labels, abort=abort)
3651 labels=labels, abort=abort)
3652 finally:
3652 finally:
3653 ui.setconfig('ui', 'forcemerge', '', 'merge')
3653 ui.setconfig('ui', 'forcemerge', '', 'merge')
3654
3654
3655 @command('outgoing|out',
3655 @command('outgoing|out',
3656 [('f', 'force', None, _('run even when the destination is unrelated')),
3656 [('f', 'force', None, _('run even when the destination is unrelated')),
3657 ('r', 'rev', [],
3657 ('r', 'rev', [],
3658 _('a changeset intended to be included in the destination'), _('REV')),
3658 _('a changeset intended to be included in the destination'), _('REV')),
3659 ('n', 'newest-first', None, _('show newest record first')),
3659 ('n', 'newest-first', None, _('show newest record first')),
3660 ('B', 'bookmarks', False, _('compare bookmarks')),
3660 ('B', 'bookmarks', False, _('compare bookmarks')),
3661 ('b', 'branch', [], _('a specific branch you would like to push'),
3661 ('b', 'branch', [], _('a specific branch you would like to push'),
3662 _('BRANCH')),
3662 _('BRANCH')),
3663 ] + logopts + remoteopts + subrepoopts,
3663 ] + logopts + remoteopts + subrepoopts,
3664 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
3664 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
3665 def outgoing(ui, repo, dest=None, **opts):
3665 def outgoing(ui, repo, dest=None, **opts):
3666 """show changesets not found in the destination
3666 """show changesets not found in the destination
3667
3667
3668 Show changesets not found in the specified destination repository
3668 Show changesets not found in the specified destination repository
3669 or the default push location. These are the changesets that would
3669 or the default push location. These are the changesets that would
3670 be pushed if a push was requested.
3670 be pushed if a push was requested.
3671
3671
3672 See pull for details of valid destination formats.
3672 See pull for details of valid destination formats.
3673
3673
3674 .. container:: verbose
3674 .. container:: verbose
3675
3675
3676 With -B/--bookmarks, the result of bookmark comparison between
3676 With -B/--bookmarks, the result of bookmark comparison between
3677 local and remote repositories is displayed. With -v/--verbose,
3677 local and remote repositories is displayed. With -v/--verbose,
3678 status is also displayed for each bookmark like below::
3678 status is also displayed for each bookmark like below::
3679
3679
3680 BM1 01234567890a added
3680 BM1 01234567890a added
3681 BM2 deleted
3681 BM2 deleted
3682 BM3 234567890abc advanced
3682 BM3 234567890abc advanced
3683 BM4 34567890abcd diverged
3683 BM4 34567890abcd diverged
3684 BM5 4567890abcde changed
3684 BM5 4567890abcde changed
3685
3685
3686 The action taken when pushing depends on the
3686 The action taken when pushing depends on the
3687 status of each bookmark:
3687 status of each bookmark:
3688
3688
3689 :``added``: push with ``-B`` will create it
3689 :``added``: push with ``-B`` will create it
3690 :``deleted``: push with ``-B`` will delete it
3690 :``deleted``: push with ``-B`` will delete it
3691 :``advanced``: push will update it
3691 :``advanced``: push will update it
3692 :``diverged``: push with ``-B`` will update it
3692 :``diverged``: push with ``-B`` will update it
3693 :``changed``: push with ``-B`` will update it
3693 :``changed``: push with ``-B`` will update it
3694
3694
3695 From the point of view of pushing behavior, bookmarks
3695 From the point of view of pushing behavior, bookmarks
3696 existing only in the remote repository are treated as
3696 existing only in the remote repository are treated as
3697 ``deleted``, even if it is in fact added remotely.
3697 ``deleted``, even if it is in fact added remotely.
3698
3698
3699 Returns 0 if there are outgoing changes, 1 otherwise.
3699 Returns 0 if there are outgoing changes, 1 otherwise.
3700 """
3700 """
3701 opts = pycompat.byteskwargs(opts)
3701 opts = pycompat.byteskwargs(opts)
3702 if opts.get('graph'):
3702 if opts.get('graph'):
3703 logcmdutil.checkunsupportedgraphflags([], opts)
3703 logcmdutil.checkunsupportedgraphflags([], opts)
3704 o, other = hg._outgoing(ui, repo, dest, opts)
3704 o, other = hg._outgoing(ui, repo, dest, opts)
3705 if not o:
3705 if not o:
3706 cmdutil.outgoinghooks(ui, repo, other, opts, o)
3706 cmdutil.outgoinghooks(ui, repo, other, opts, o)
3707 return
3707 return
3708
3708
3709 revdag = logcmdutil.graphrevs(repo, o, opts)
3709 revdag = logcmdutil.graphrevs(repo, o, opts)
3710 ui.pager('outgoing')
3710 ui.pager('outgoing')
3711 displayer = logcmdutil.changesetdisplayer(ui, repo, opts, buffered=True)
3711 displayer = logcmdutil.changesetdisplayer(ui, repo, opts, buffered=True)
3712 logcmdutil.displaygraph(ui, repo, revdag, displayer,
3712 logcmdutil.displaygraph(ui, repo, revdag, displayer,
3713 graphmod.asciiedges)
3713 graphmod.asciiedges)
3714 cmdutil.outgoinghooks(ui, repo, other, opts, o)
3714 cmdutil.outgoinghooks(ui, repo, other, opts, o)
3715 return 0
3715 return 0
3716
3716
3717 if opts.get('bookmarks'):
3717 if opts.get('bookmarks'):
3718 dest = ui.expandpath(dest or 'default-push', dest or 'default')
3718 dest = ui.expandpath(dest or 'default-push', dest or 'default')
3719 dest, branches = hg.parseurl(dest, opts.get('branch'))
3719 dest, branches = hg.parseurl(dest, opts.get('branch'))
3720 other = hg.peer(repo, opts, dest)
3720 other = hg.peer(repo, opts, dest)
3721 if 'bookmarks' not in other.listkeys('namespaces'):
3721 if 'bookmarks' not in other.listkeys('namespaces'):
3722 ui.warn(_("remote doesn't support bookmarks\n"))
3722 ui.warn(_("remote doesn't support bookmarks\n"))
3723 return 0
3723 return 0
3724 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
3724 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
3725 ui.pager('outgoing')
3725 ui.pager('outgoing')
3726 return bookmarks.outgoing(ui, repo, other)
3726 return bookmarks.outgoing(ui, repo, other)
3727
3727
3728 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
3728 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
3729 try:
3729 try:
3730 return hg.outgoing(ui, repo, dest, opts)
3730 return hg.outgoing(ui, repo, dest, opts)
3731 finally:
3731 finally:
3732 del repo._subtoppath
3732 del repo._subtoppath
3733
3733
3734 @command('parents',
3734 @command('parents',
3735 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
3735 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
3736 ] + templateopts,
3736 ] + templateopts,
3737 _('[-r REV] [FILE]'),
3737 _('[-r REV] [FILE]'),
3738 inferrepo=True)
3738 inferrepo=True)
3739 def parents(ui, repo, file_=None, **opts):
3739 def parents(ui, repo, file_=None, **opts):
3740 """show the parents of the working directory or revision (DEPRECATED)
3740 """show the parents of the working directory or revision (DEPRECATED)
3741
3741
3742 Print the working directory's parent revisions. If a revision is
3742 Print the working directory's parent revisions. If a revision is
3743 given via -r/--rev, the parent of that revision will be printed.
3743 given via -r/--rev, the parent of that revision will be printed.
3744 If a file argument is given, the revision in which the file was
3744 If a file argument is given, the revision in which the file was
3745 last changed (before the working directory revision or the
3745 last changed (before the working directory revision or the
3746 argument to --rev if given) is printed.
3746 argument to --rev if given) is printed.
3747
3747
3748 This command is equivalent to::
3748 This command is equivalent to::
3749
3749
3750 hg log -r "p1()+p2()" or
3750 hg log -r "p1()+p2()" or
3751 hg log -r "p1(REV)+p2(REV)" or
3751 hg log -r "p1(REV)+p2(REV)" or
3752 hg log -r "max(::p1() and file(FILE))+max(::p2() and file(FILE))" or
3752 hg log -r "max(::p1() and file(FILE))+max(::p2() and file(FILE))" or
3753 hg log -r "max(::p1(REV) and file(FILE))+max(::p2(REV) and file(FILE))"
3753 hg log -r "max(::p1(REV) and file(FILE))+max(::p2(REV) and file(FILE))"
3754
3754
3755 See :hg:`summary` and :hg:`help revsets` for related information.
3755 See :hg:`summary` and :hg:`help revsets` for related information.
3756
3756
3757 Returns 0 on success.
3757 Returns 0 on success.
3758 """
3758 """
3759
3759
3760 opts = pycompat.byteskwargs(opts)
3760 opts = pycompat.byteskwargs(opts)
3761 rev = opts.get('rev')
3761 rev = opts.get('rev')
3762 if rev:
3762 if rev:
3763 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
3763 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
3764 ctx = scmutil.revsingle(repo, rev, None)
3764 ctx = scmutil.revsingle(repo, rev, None)
3765
3765
3766 if file_:
3766 if file_:
3767 m = scmutil.match(ctx, (file_,), opts)
3767 m = scmutil.match(ctx, (file_,), opts)
3768 if m.anypats() or len(m.files()) != 1:
3768 if m.anypats() or len(m.files()) != 1:
3769 raise error.Abort(_('can only specify an explicit filename'))
3769 raise error.Abort(_('can only specify an explicit filename'))
3770 file_ = m.files()[0]
3770 file_ = m.files()[0]
3771 filenodes = []
3771 filenodes = []
3772 for cp in ctx.parents():
3772 for cp in ctx.parents():
3773 if not cp:
3773 if not cp:
3774 continue
3774 continue
3775 try:
3775 try:
3776 filenodes.append(cp.filenode(file_))
3776 filenodes.append(cp.filenode(file_))
3777 except error.LookupError:
3777 except error.LookupError:
3778 pass
3778 pass
3779 if not filenodes:
3779 if not filenodes:
3780 raise error.Abort(_("'%s' not found in manifest!") % file_)
3780 raise error.Abort(_("'%s' not found in manifest!") % file_)
3781 p = []
3781 p = []
3782 for fn in filenodes:
3782 for fn in filenodes:
3783 fctx = repo.filectx(file_, fileid=fn)
3783 fctx = repo.filectx(file_, fileid=fn)
3784 p.append(fctx.node())
3784 p.append(fctx.node())
3785 else:
3785 else:
3786 p = [cp.node() for cp in ctx.parents()]
3786 p = [cp.node() for cp in ctx.parents()]
3787
3787
3788 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
3788 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
3789 for n in p:
3789 for n in p:
3790 if n != nullid:
3790 if n != nullid:
3791 displayer.show(repo[n])
3791 displayer.show(repo[n])
3792 displayer.close()
3792 displayer.close()
3793
3793
3794 @command('paths', formatteropts, _('[NAME]'), optionalrepo=True,
3794 @command('paths', formatteropts, _('[NAME]'), optionalrepo=True,
3795 intents={INTENT_READONLY})
3795 intents={INTENT_READONLY})
3796 def paths(ui, repo, search=None, **opts):
3796 def paths(ui, repo, search=None, **opts):
3797 """show aliases for remote repositories
3797 """show aliases for remote repositories
3798
3798
3799 Show definition of symbolic path name NAME. If no name is given,
3799 Show definition of symbolic path name NAME. If no name is given,
3800 show definition of all available names.
3800 show definition of all available names.
3801
3801
3802 Option -q/--quiet suppresses all output when searching for NAME
3802 Option -q/--quiet suppresses all output when searching for NAME
3803 and shows only the path names when listing all definitions.
3803 and shows only the path names when listing all definitions.
3804
3804
3805 Path names are defined in the [paths] section of your
3805 Path names are defined in the [paths] section of your
3806 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
3806 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
3807 repository, ``.hg/hgrc`` is used, too.
3807 repository, ``.hg/hgrc`` is used, too.
3808
3808
3809 The path names ``default`` and ``default-push`` have a special
3809 The path names ``default`` and ``default-push`` have a special
3810 meaning. When performing a push or pull operation, they are used
3810 meaning. When performing a push or pull operation, they are used
3811 as fallbacks if no location is specified on the command-line.
3811 as fallbacks if no location is specified on the command-line.
3812 When ``default-push`` is set, it will be used for push and
3812 When ``default-push`` is set, it will be used for push and
3813 ``default`` will be used for pull; otherwise ``default`` is used
3813 ``default`` will be used for pull; otherwise ``default`` is used
3814 as the fallback for both. When cloning a repository, the clone
3814 as the fallback for both. When cloning a repository, the clone
3815 source is written as ``default`` in ``.hg/hgrc``.
3815 source is written as ``default`` in ``.hg/hgrc``.
3816
3816
3817 .. note::
3817 .. note::
3818
3818
3819 ``default`` and ``default-push`` apply to all inbound (e.g.
3819 ``default`` and ``default-push`` apply to all inbound (e.g.
3820 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email`
3820 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email`
3821 and :hg:`bundle`) operations.
3821 and :hg:`bundle`) operations.
3822
3822
3823 See :hg:`help urls` for more information.
3823 See :hg:`help urls` for more information.
3824
3824
3825 Returns 0 on success.
3825 Returns 0 on success.
3826 """
3826 """
3827
3827
3828 opts = pycompat.byteskwargs(opts)
3828 opts = pycompat.byteskwargs(opts)
3829 ui.pager('paths')
3829 ui.pager('paths')
3830 if search:
3830 if search:
3831 pathitems = [(name, path) for name, path in ui.paths.iteritems()
3831 pathitems = [(name, path) for name, path in ui.paths.iteritems()
3832 if name == search]
3832 if name == search]
3833 else:
3833 else:
3834 pathitems = sorted(ui.paths.iteritems())
3834 pathitems = sorted(ui.paths.iteritems())
3835
3835
3836 fm = ui.formatter('paths', opts)
3836 fm = ui.formatter('paths', opts)
3837 if fm.isplain():
3837 if fm.isplain():
3838 hidepassword = util.hidepassword
3838 hidepassword = util.hidepassword
3839 else:
3839 else:
3840 hidepassword = bytes
3840 hidepassword = bytes
3841 if ui.quiet:
3841 if ui.quiet:
3842 namefmt = '%s\n'
3842 namefmt = '%s\n'
3843 else:
3843 else:
3844 namefmt = '%s = '
3844 namefmt = '%s = '
3845 showsubopts = not search and not ui.quiet
3845 showsubopts = not search and not ui.quiet
3846
3846
3847 for name, path in pathitems:
3847 for name, path in pathitems:
3848 fm.startitem()
3848 fm.startitem()
3849 fm.condwrite(not search, 'name', namefmt, name)
3849 fm.condwrite(not search, 'name', namefmt, name)
3850 fm.condwrite(not ui.quiet, 'url', '%s\n', hidepassword(path.rawloc))
3850 fm.condwrite(not ui.quiet, 'url', '%s\n', hidepassword(path.rawloc))
3851 for subopt, value in sorted(path.suboptions.items()):
3851 for subopt, value in sorted(path.suboptions.items()):
3852 assert subopt not in ('name', 'url')
3852 assert subopt not in ('name', 'url')
3853 if showsubopts:
3853 if showsubopts:
3854 fm.plain('%s:%s = ' % (name, subopt))
3854 fm.plain('%s:%s = ' % (name, subopt))
3855 fm.condwrite(showsubopts, subopt, '%s\n', value)
3855 fm.condwrite(showsubopts, subopt, '%s\n', value)
3856
3856
3857 fm.end()
3857 fm.end()
3858
3858
3859 if search and not pathitems:
3859 if search and not pathitems:
3860 if not ui.quiet:
3860 if not ui.quiet:
3861 ui.warn(_("not found!\n"))
3861 ui.warn(_("not found!\n"))
3862 return 1
3862 return 1
3863 else:
3863 else:
3864 return 0
3864 return 0
3865
3865
3866 @command('phase',
3866 @command('phase',
3867 [('p', 'public', False, _('set changeset phase to public')),
3867 [('p', 'public', False, _('set changeset phase to public')),
3868 ('d', 'draft', False, _('set changeset phase to draft')),
3868 ('d', 'draft', False, _('set changeset phase to draft')),
3869 ('s', 'secret', False, _('set changeset phase to secret')),
3869 ('s', 'secret', False, _('set changeset phase to secret')),
3870 ('f', 'force', False, _('allow to move boundary backward')),
3870 ('f', 'force', False, _('allow to move boundary backward')),
3871 ('r', 'rev', [], _('target revision'), _('REV')),
3871 ('r', 'rev', [], _('target revision'), _('REV')),
3872 ],
3872 ],
3873 _('[-p|-d|-s] [-f] [-r] [REV...]'))
3873 _('[-p|-d|-s] [-f] [-r] [REV...]'))
3874 def phase(ui, repo, *revs, **opts):
3874 def phase(ui, repo, *revs, **opts):
3875 """set or show the current phase name
3875 """set or show the current phase name
3876
3876
3877 With no argument, show the phase name of the current revision(s).
3877 With no argument, show the phase name of the current revision(s).
3878
3878
3879 With one of -p/--public, -d/--draft or -s/--secret, change the
3879 With one of -p/--public, -d/--draft or -s/--secret, change the
3880 phase value of the specified revisions.
3880 phase value of the specified revisions.
3881
3881
3882 Unless -f/--force is specified, :hg:`phase` won't move changesets from a
3882 Unless -f/--force is specified, :hg:`phase` won't move changesets from a
3883 lower phase to a higher phase. Phases are ordered as follows::
3883 lower phase to a higher phase. Phases are ordered as follows::
3884
3884
3885 public < draft < secret
3885 public < draft < secret
3886
3886
3887 Returns 0 on success, 1 if some phases could not be changed.
3887 Returns 0 on success, 1 if some phases could not be changed.
3888
3888
3889 (For more information about the phases concept, see :hg:`help phases`.)
3889 (For more information about the phases concept, see :hg:`help phases`.)
3890 """
3890 """
3891 opts = pycompat.byteskwargs(opts)
3891 opts = pycompat.byteskwargs(opts)
3892 # search for a unique phase argument
3892 # search for a unique phase argument
3893 targetphase = None
3893 targetphase = None
3894 for idx, name in enumerate(phases.phasenames):
3894 for idx, name in enumerate(phases.phasenames):
3895 if opts[name]:
3895 if opts[name]:
3896 if targetphase is not None:
3896 if targetphase is not None:
3897 raise error.Abort(_('only one phase can be specified'))
3897 raise error.Abort(_('only one phase can be specified'))
3898 targetphase = idx
3898 targetphase = idx
3899
3899
3900 # look for specified revision
3900 # look for specified revision
3901 revs = list(revs)
3901 revs = list(revs)
3902 revs.extend(opts['rev'])
3902 revs.extend(opts['rev'])
3903 if not revs:
3903 if not revs:
3904 # display both parents as the second parent phase can influence
3904 # display both parents as the second parent phase can influence
3905 # the phase of a merge commit
3905 # the phase of a merge commit
3906 revs = [c.rev() for c in repo[None].parents()]
3906 revs = [c.rev() for c in repo[None].parents()]
3907
3907
3908 revs = scmutil.revrange(repo, revs)
3908 revs = scmutil.revrange(repo, revs)
3909
3909
3910 ret = 0
3910 ret = 0
3911 if targetphase is None:
3911 if targetphase is None:
3912 # display
3912 # display
3913 for r in revs:
3913 for r in revs:
3914 ctx = repo[r]
3914 ctx = repo[r]
3915 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
3915 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
3916 else:
3916 else:
3917 with repo.lock(), repo.transaction("phase") as tr:
3917 with repo.lock(), repo.transaction("phase") as tr:
3918 # set phase
3918 # set phase
3919 if not revs:
3919 if not revs:
3920 raise error.Abort(_('empty revision set'))
3920 raise error.Abort(_('empty revision set'))
3921 nodes = [repo[r].node() for r in revs]
3921 nodes = [repo[r].node() for r in revs]
3922 # moving revision from public to draft may hide them
3922 # moving revision from public to draft may hide them
3923 # We have to check result on an unfiltered repository
3923 # We have to check result on an unfiltered repository
3924 unfi = repo.unfiltered()
3924 unfi = repo.unfiltered()
3925 getphase = unfi._phasecache.phase
3925 getphase = unfi._phasecache.phase
3926 olddata = [getphase(unfi, r) for r in unfi]
3926 olddata = [getphase(unfi, r) for r in unfi]
3927 phases.advanceboundary(repo, tr, targetphase, nodes)
3927 phases.advanceboundary(repo, tr, targetphase, nodes)
3928 if opts['force']:
3928 if opts['force']:
3929 phases.retractboundary(repo, tr, targetphase, nodes)
3929 phases.retractboundary(repo, tr, targetphase, nodes)
3930 getphase = unfi._phasecache.phase
3930 getphase = unfi._phasecache.phase
3931 newdata = [getphase(unfi, r) for r in unfi]
3931 newdata = [getphase(unfi, r) for r in unfi]
3932 changes = sum(newdata[r] != olddata[r] for r in unfi)
3932 changes = sum(newdata[r] != olddata[r] for r in unfi)
3933 cl = unfi.changelog
3933 cl = unfi.changelog
3934 rejected = [n for n in nodes
3934 rejected = [n for n in nodes
3935 if newdata[cl.rev(n)] < targetphase]
3935 if newdata[cl.rev(n)] < targetphase]
3936 if rejected:
3936 if rejected:
3937 ui.warn(_('cannot move %i changesets to a higher '
3937 ui.warn(_('cannot move %i changesets to a higher '
3938 'phase, use --force\n') % len(rejected))
3938 'phase, use --force\n') % len(rejected))
3939 ret = 1
3939 ret = 1
3940 if changes:
3940 if changes:
3941 msg = _('phase changed for %i changesets\n') % changes
3941 msg = _('phase changed for %i changesets\n') % changes
3942 if ret:
3942 if ret:
3943 ui.status(msg)
3943 ui.status(msg)
3944 else:
3944 else:
3945 ui.note(msg)
3945 ui.note(msg)
3946 else:
3946 else:
3947 ui.warn(_('no phases changed\n'))
3947 ui.warn(_('no phases changed\n'))
3948 return ret
3948 return ret
3949
3949
3950 def postincoming(ui, repo, modheads, optupdate, checkout, brev):
3950 def postincoming(ui, repo, modheads, optupdate, checkout, brev):
3951 """Run after a changegroup has been added via pull/unbundle
3951 """Run after a changegroup has been added via pull/unbundle
3952
3952
3953 This takes arguments below:
3953 This takes arguments below:
3954
3954
3955 :modheads: change of heads by pull/unbundle
3955 :modheads: change of heads by pull/unbundle
3956 :optupdate: updating working directory is needed or not
3956 :optupdate: updating working directory is needed or not
3957 :checkout: update destination revision (or None to default destination)
3957 :checkout: update destination revision (or None to default destination)
3958 :brev: a name, which might be a bookmark to be activated after updating
3958 :brev: a name, which might be a bookmark to be activated after updating
3959 """
3959 """
3960 if modheads == 0:
3960 if modheads == 0:
3961 return
3961 return
3962 if optupdate:
3962 if optupdate:
3963 try:
3963 try:
3964 return hg.updatetotally(ui, repo, checkout, brev)
3964 return hg.updatetotally(ui, repo, checkout, brev)
3965 except error.UpdateAbort as inst:
3965 except error.UpdateAbort as inst:
3966 msg = _("not updating: %s") % stringutil.forcebytestr(inst)
3966 msg = _("not updating: %s") % stringutil.forcebytestr(inst)
3967 hint = inst.hint
3967 hint = inst.hint
3968 raise error.UpdateAbort(msg, hint=hint)
3968 raise error.UpdateAbort(msg, hint=hint)
3969 if modheads > 1:
3969 if modheads > 1:
3970 currentbranchheads = len(repo.branchheads())
3970 currentbranchheads = len(repo.branchheads())
3971 if currentbranchheads == modheads:
3971 if currentbranchheads == modheads:
3972 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
3972 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
3973 elif currentbranchheads > 1:
3973 elif currentbranchheads > 1:
3974 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
3974 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
3975 "merge)\n"))
3975 "merge)\n"))
3976 else:
3976 else:
3977 ui.status(_("(run 'hg heads' to see heads)\n"))
3977 ui.status(_("(run 'hg heads' to see heads)\n"))
3978 elif not ui.configbool('commands', 'update.requiredest'):
3978 elif not ui.configbool('commands', 'update.requiredest'):
3979 ui.status(_("(run 'hg update' to get a working copy)\n"))
3979 ui.status(_("(run 'hg update' to get a working copy)\n"))
3980
3980
3981 @command('^pull',
3981 @command('^pull',
3982 [('u', 'update', None,
3982 [('u', 'update', None,
3983 _('update to new branch head if new descendants were pulled')),
3983 _('update to new branch head if new descendants were pulled')),
3984 ('f', 'force', None, _('run even when remote repository is unrelated')),
3984 ('f', 'force', None, _('run even when remote repository is unrelated')),
3985 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
3985 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
3986 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
3986 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
3987 ('b', 'branch', [], _('a specific branch you would like to pull'),
3987 ('b', 'branch', [], _('a specific branch you would like to pull'),
3988 _('BRANCH')),
3988 _('BRANCH')),
3989 ] + remoteopts,
3989 ] + remoteopts,
3990 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
3990 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
3991 def pull(ui, repo, source="default", **opts):
3991 def pull(ui, repo, source="default", **opts):
3992 """pull changes from the specified source
3992 """pull changes from the specified source
3993
3993
3994 Pull changes from a remote repository to a local one.
3994 Pull changes from a remote repository to a local one.
3995
3995
3996 This finds all changes from the repository at the specified path
3996 This finds all changes from the repository at the specified path
3997 or URL and adds them to a local repository (the current one unless
3997 or URL and adds them to a local repository (the current one unless
3998 -R is specified). By default, this does not update the copy of the
3998 -R is specified). By default, this does not update the copy of the
3999 project in the working directory.
3999 project in the working directory.
4000
4000
4001 When cloning from servers that support it, Mercurial may fetch
4001 When cloning from servers that support it, Mercurial may fetch
4002 pre-generated data. When this is done, hooks operating on incoming
4002 pre-generated data. When this is done, hooks operating on incoming
4003 changesets and changegroups may fire more than once, once for each
4003 changesets and changegroups may fire more than once, once for each
4004 pre-generated bundle and as well as for any additional remaining
4004 pre-generated bundle and as well as for any additional remaining
4005 data. See :hg:`help -e clonebundles` for more.
4005 data. See :hg:`help -e clonebundles` for more.
4006
4006
4007 Use :hg:`incoming` if you want to see what would have been added
4007 Use :hg:`incoming` if you want to see what would have been added
4008 by a pull at the time you issued this command. If you then decide
4008 by a pull at the time you issued this command. If you then decide
4009 to add those changes to the repository, you should use :hg:`pull
4009 to add those changes to the repository, you should use :hg:`pull
4010 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
4010 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
4011
4011
4012 If SOURCE is omitted, the 'default' path will be used.
4012 If SOURCE is omitted, the 'default' path will be used.
4013 See :hg:`help urls` for more information.
4013 See :hg:`help urls` for more information.
4014
4014
4015 Specifying bookmark as ``.`` is equivalent to specifying the active
4015 Specifying bookmark as ``.`` is equivalent to specifying the active
4016 bookmark's name.
4016 bookmark's name.
4017
4017
4018 Returns 0 on success, 1 if an update had unresolved files.
4018 Returns 0 on success, 1 if an update had unresolved files.
4019 """
4019 """
4020
4020
4021 opts = pycompat.byteskwargs(opts)
4021 opts = pycompat.byteskwargs(opts)
4022 if ui.configbool('commands', 'update.requiredest') and opts.get('update'):
4022 if ui.configbool('commands', 'update.requiredest') and opts.get('update'):
4023 msg = _('update destination required by configuration')
4023 msg = _('update destination required by configuration')
4024 hint = _('use hg pull followed by hg update DEST')
4024 hint = _('use hg pull followed by hg update DEST')
4025 raise error.Abort(msg, hint=hint)
4025 raise error.Abort(msg, hint=hint)
4026
4026
4027 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
4027 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
4028 ui.status(_('pulling from %s\n') % util.hidepassword(source))
4028 ui.status(_('pulling from %s\n') % util.hidepassword(source))
4029 other = hg.peer(repo, opts, source)
4029 other = hg.peer(repo, opts, source)
4030 try:
4030 try:
4031 revs, checkout = hg.addbranchrevs(repo, other, branches,
4031 revs, checkout = hg.addbranchrevs(repo, other, branches,
4032 opts.get('rev'))
4032 opts.get('rev'))
4033
4033
4034
4034
4035 pullopargs = {}
4035 pullopargs = {}
4036 if opts.get('bookmark'):
4036 if opts.get('bookmark'):
4037 if not revs:
4037 if not revs:
4038 revs = []
4038 revs = []
4039 # The list of bookmark used here is not the one used to actually
4039 # The list of bookmark used here is not the one used to actually
4040 # update the bookmark name. This can result in the revision pulled
4040 # update the bookmark name. This can result in the revision pulled
4041 # not ending up with the name of the bookmark because of a race
4041 # not ending up with the name of the bookmark because of a race
4042 # condition on the server. (See issue 4689 for details)
4042 # condition on the server. (See issue 4689 for details)
4043 remotebookmarks = other.listkeys('bookmarks')
4043 remotebookmarks = other.listkeys('bookmarks')
4044 remotebookmarks = bookmarks.unhexlifybookmarks(remotebookmarks)
4044 remotebookmarks = bookmarks.unhexlifybookmarks(remotebookmarks)
4045 pullopargs['remotebookmarks'] = remotebookmarks
4045 pullopargs['remotebookmarks'] = remotebookmarks
4046 for b in opts['bookmark']:
4046 for b in opts['bookmark']:
4047 b = repo._bookmarks.expandname(b)
4047 b = repo._bookmarks.expandname(b)
4048 if b not in remotebookmarks:
4048 if b not in remotebookmarks:
4049 raise error.Abort(_('remote bookmark %s not found!') % b)
4049 raise error.Abort(_('remote bookmark %s not found!') % b)
4050 revs.append(hex(remotebookmarks[b]))
4050 revs.append(hex(remotebookmarks[b]))
4051
4051
4052 if revs:
4052 if revs:
4053 try:
4053 try:
4054 # When 'rev' is a bookmark name, we cannot guarantee that it
4054 # When 'rev' is a bookmark name, we cannot guarantee that it
4055 # will be updated with that name because of a race condition
4055 # will be updated with that name because of a race condition
4056 # server side. (See issue 4689 for details)
4056 # server side. (See issue 4689 for details)
4057 oldrevs = revs
4057 oldrevs = revs
4058 revs = [] # actually, nodes
4058 revs = [] # actually, nodes
4059 for r in oldrevs:
4059 for r in oldrevs:
4060 with other.commandexecutor() as e:
4060 with other.commandexecutor() as e:
4061 node = e.callcommand('lookup', {'key': r}).result()
4061 node = e.callcommand('lookup', {'key': r}).result()
4062
4062
4063 revs.append(node)
4063 revs.append(node)
4064 if r == checkout:
4064 if r == checkout:
4065 checkout = node
4065 checkout = node
4066 except error.CapabilityError:
4066 except error.CapabilityError:
4067 err = _("other repository doesn't support revision lookup, "
4067 err = _("other repository doesn't support revision lookup, "
4068 "so a rev cannot be specified.")
4068 "so a rev cannot be specified.")
4069 raise error.Abort(err)
4069 raise error.Abort(err)
4070
4070
4071 wlock = util.nullcontextmanager()
4071 wlock = util.nullcontextmanager()
4072 if opts.get('update'):
4072 if opts.get('update'):
4073 wlock = repo.wlock()
4073 wlock = repo.wlock()
4074 with wlock:
4074 with wlock:
4075 pullopargs.update(opts.get('opargs', {}))
4075 pullopargs.update(opts.get('opargs', {}))
4076 modheads = exchange.pull(repo, other, heads=revs,
4076 modheads = exchange.pull(repo, other, heads=revs,
4077 force=opts.get('force'),
4077 force=opts.get('force'),
4078 bookmarks=opts.get('bookmark', ()),
4078 bookmarks=opts.get('bookmark', ()),
4079 opargs=pullopargs).cgresult
4079 opargs=pullopargs).cgresult
4080
4080
4081 # brev is a name, which might be a bookmark to be activated at
4081 # brev is a name, which might be a bookmark to be activated at
4082 # the end of the update. In other words, it is an explicit
4082 # the end of the update. In other words, it is an explicit
4083 # destination of the update
4083 # destination of the update
4084 brev = None
4084 brev = None
4085
4085
4086 if checkout:
4086 if checkout:
4087 checkout = repo.changelog.rev(checkout)
4087 checkout = repo.changelog.rev(checkout)
4088
4088
4089 # order below depends on implementation of
4089 # order below depends on implementation of
4090 # hg.addbranchrevs(). opts['bookmark'] is ignored,
4090 # hg.addbranchrevs(). opts['bookmark'] is ignored,
4091 # because 'checkout' is determined without it.
4091 # because 'checkout' is determined without it.
4092 if opts.get('rev'):
4092 if opts.get('rev'):
4093 brev = opts['rev'][0]
4093 brev = opts['rev'][0]
4094 elif opts.get('branch'):
4094 elif opts.get('branch'):
4095 brev = opts['branch'][0]
4095 brev = opts['branch'][0]
4096 else:
4096 else:
4097 brev = branches[0]
4097 brev = branches[0]
4098 repo._subtoppath = source
4098 repo._subtoppath = source
4099 try:
4099 try:
4100 ret = postincoming(ui, repo, modheads, opts.get('update'),
4100 ret = postincoming(ui, repo, modheads, opts.get('update'),
4101 checkout, brev)
4101 checkout, brev)
4102
4102
4103 finally:
4103 finally:
4104 del repo._subtoppath
4104 del repo._subtoppath
4105
4105
4106 finally:
4106 finally:
4107 other.close()
4107 other.close()
4108 return ret
4108 return ret
4109
4109
4110 @command('^push',
4110 @command('^push',
4111 [('f', 'force', None, _('force push')),
4111 [('f', 'force', None, _('force push')),
4112 ('r', 'rev', [],
4112 ('r', 'rev', [],
4113 _('a changeset intended to be included in the destination'),
4113 _('a changeset intended to be included in the destination'),
4114 _('REV')),
4114 _('REV')),
4115 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
4115 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
4116 ('b', 'branch', [],
4116 ('b', 'branch', [],
4117 _('a specific branch you would like to push'), _('BRANCH')),
4117 _('a specific branch you would like to push'), _('BRANCH')),
4118 ('', 'new-branch', False, _('allow pushing a new branch')),
4118 ('', 'new-branch', False, _('allow pushing a new branch')),
4119 ('', 'pushvars', [], _('variables that can be sent to server (ADVANCED)')),
4119 ('', 'pushvars', [], _('variables that can be sent to server (ADVANCED)')),
4120 ] + remoteopts,
4120 ] + remoteopts,
4121 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
4121 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
4122 def push(ui, repo, dest=None, **opts):
4122 def push(ui, repo, dest=None, **opts):
4123 """push changes to the specified destination
4123 """push changes to the specified destination
4124
4124
4125 Push changesets from the local repository to the specified
4125 Push changesets from the local repository to the specified
4126 destination.
4126 destination.
4127
4127
4128 This operation is symmetrical to pull: it is identical to a pull
4128 This operation is symmetrical to pull: it is identical to a pull
4129 in the destination repository from the current one.
4129 in the destination repository from the current one.
4130
4130
4131 By default, push will not allow creation of new heads at the
4131 By default, push will not allow creation of new heads at the
4132 destination, since multiple heads would make it unclear which head
4132 destination, since multiple heads would make it unclear which head
4133 to use. In this situation, it is recommended to pull and merge
4133 to use. In this situation, it is recommended to pull and merge
4134 before pushing.
4134 before pushing.
4135
4135
4136 Use --new-branch if you want to allow push to create a new named
4136 Use --new-branch if you want to allow push to create a new named
4137 branch that is not present at the destination. This allows you to
4137 branch that is not present at the destination. This allows you to
4138 only create a new branch without forcing other changes.
4138 only create a new branch without forcing other changes.
4139
4139
4140 .. note::
4140 .. note::
4141
4141
4142 Extra care should be taken with the -f/--force option,
4142 Extra care should be taken with the -f/--force option,
4143 which will push all new heads on all branches, an action which will
4143 which will push all new heads on all branches, an action which will
4144 almost always cause confusion for collaborators.
4144 almost always cause confusion for collaborators.
4145
4145
4146 If -r/--rev is used, the specified revision and all its ancestors
4146 If -r/--rev is used, the specified revision and all its ancestors
4147 will be pushed to the remote repository.
4147 will be pushed to the remote repository.
4148
4148
4149 If -B/--bookmark is used, the specified bookmarked revision, its
4149 If -B/--bookmark is used, the specified bookmarked revision, its
4150 ancestors, and the bookmark will be pushed to the remote
4150 ancestors, and the bookmark will be pushed to the remote
4151 repository. Specifying ``.`` is equivalent to specifying the active
4151 repository. Specifying ``.`` is equivalent to specifying the active
4152 bookmark's name.
4152 bookmark's name.
4153
4153
4154 Please see :hg:`help urls` for important details about ``ssh://``
4154 Please see :hg:`help urls` for important details about ``ssh://``
4155 URLs. If DESTINATION is omitted, a default path will be used.
4155 URLs. If DESTINATION is omitted, a default path will be used.
4156
4156
4157 .. container:: verbose
4157 .. container:: verbose
4158
4158
4159 The --pushvars option sends strings to the server that become
4159 The --pushvars option sends strings to the server that become
4160 environment variables prepended with ``HG_USERVAR_``. For example,
4160 environment variables prepended with ``HG_USERVAR_``. For example,
4161 ``--pushvars ENABLE_FEATURE=true``, provides the server side hooks with
4161 ``--pushvars ENABLE_FEATURE=true``, provides the server side hooks with
4162 ``HG_USERVAR_ENABLE_FEATURE=true`` as part of their environment.
4162 ``HG_USERVAR_ENABLE_FEATURE=true`` as part of their environment.
4163
4163
4164 pushvars can provide for user-overridable hooks as well as set debug
4164 pushvars can provide for user-overridable hooks as well as set debug
4165 levels. One example is having a hook that blocks commits containing
4165 levels. One example is having a hook that blocks commits containing
4166 conflict markers, but enables the user to override the hook if the file
4166 conflict markers, but enables the user to override the hook if the file
4167 is using conflict markers for testing purposes or the file format has
4167 is using conflict markers for testing purposes or the file format has
4168 strings that look like conflict markers.
4168 strings that look like conflict markers.
4169
4169
4170 By default, servers will ignore `--pushvars`. To enable it add the
4170 By default, servers will ignore `--pushvars`. To enable it add the
4171 following to your configuration file::
4171 following to your configuration file::
4172
4172
4173 [push]
4173 [push]
4174 pushvars.server = true
4174 pushvars.server = true
4175
4175
4176 Returns 0 if push was successful, 1 if nothing to push.
4176 Returns 0 if push was successful, 1 if nothing to push.
4177 """
4177 """
4178
4178
4179 opts = pycompat.byteskwargs(opts)
4179 opts = pycompat.byteskwargs(opts)
4180 if opts.get('bookmark'):
4180 if opts.get('bookmark'):
4181 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
4181 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
4182 for b in opts['bookmark']:
4182 for b in opts['bookmark']:
4183 # translate -B options to -r so changesets get pushed
4183 # translate -B options to -r so changesets get pushed
4184 b = repo._bookmarks.expandname(b)
4184 b = repo._bookmarks.expandname(b)
4185 if b in repo._bookmarks:
4185 if b in repo._bookmarks:
4186 opts.setdefault('rev', []).append(b)
4186 opts.setdefault('rev', []).append(b)
4187 else:
4187 else:
4188 # if we try to push a deleted bookmark, translate it to null
4188 # if we try to push a deleted bookmark, translate it to null
4189 # this lets simultaneous -r, -b options continue working
4189 # this lets simultaneous -r, -b options continue working
4190 opts.setdefault('rev', []).append("null")
4190 opts.setdefault('rev', []).append("null")
4191
4191
4192 path = ui.paths.getpath(dest, default=('default-push', 'default'))
4192 path = ui.paths.getpath(dest, default=('default-push', 'default'))
4193 if not path:
4193 if not path:
4194 raise error.Abort(_('default repository not configured!'),
4194 raise error.Abort(_('default repository not configured!'),
4195 hint=_("see 'hg help config.paths'"))
4195 hint=_("see 'hg help config.paths'"))
4196 dest = path.pushloc or path.loc
4196 dest = path.pushloc or path.loc
4197 branches = (path.branch, opts.get('branch') or [])
4197 branches = (path.branch, opts.get('branch') or [])
4198 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
4198 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
4199 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
4199 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
4200 other = hg.peer(repo, opts, dest)
4200 other = hg.peer(repo, opts, dest)
4201
4201
4202 if revs:
4202 if revs:
4203 revs = [repo[r].node() for r in scmutil.revrange(repo, revs)]
4203 revs = [repo[r].node() for r in scmutil.revrange(repo, revs)]
4204 if not revs:
4204 if not revs:
4205 raise error.Abort(_("specified revisions evaluate to an empty set"),
4205 raise error.Abort(_("specified revisions evaluate to an empty set"),
4206 hint=_("use different revision arguments"))
4206 hint=_("use different revision arguments"))
4207 elif path.pushrev:
4207 elif path.pushrev:
4208 # It doesn't make any sense to specify ancestor revisions. So limit
4208 # It doesn't make any sense to specify ancestor revisions. So limit
4209 # to DAG heads to make discovery simpler.
4209 # to DAG heads to make discovery simpler.
4210 expr = revsetlang.formatspec('heads(%r)', path.pushrev)
4210 expr = revsetlang.formatspec('heads(%r)', path.pushrev)
4211 revs = scmutil.revrange(repo, [expr])
4211 revs = scmutil.revrange(repo, [expr])
4212 revs = [repo[rev].node() for rev in revs]
4212 revs = [repo[rev].node() for rev in revs]
4213 if not revs:
4213 if not revs:
4214 raise error.Abort(_('default push revset for path evaluates to an '
4214 raise error.Abort(_('default push revset for path evaluates to an '
4215 'empty set'))
4215 'empty set'))
4216
4216
4217 repo._subtoppath = dest
4217 repo._subtoppath = dest
4218 try:
4218 try:
4219 # push subrepos depth-first for coherent ordering
4219 # push subrepos depth-first for coherent ordering
4220 c = repo['.']
4220 c = repo['.']
4221 subs = c.substate # only repos that are committed
4221 subs = c.substate # only repos that are committed
4222 for s in sorted(subs):
4222 for s in sorted(subs):
4223 result = c.sub(s).push(opts)
4223 result = c.sub(s).push(opts)
4224 if result == 0:
4224 if result == 0:
4225 return not result
4225 return not result
4226 finally:
4226 finally:
4227 del repo._subtoppath
4227 del repo._subtoppath
4228
4228
4229 opargs = dict(opts.get('opargs', {})) # copy opargs since we may mutate it
4229 opargs = dict(opts.get('opargs', {})) # copy opargs since we may mutate it
4230 opargs.setdefault('pushvars', []).extend(opts.get('pushvars', []))
4230 opargs.setdefault('pushvars', []).extend(opts.get('pushvars', []))
4231
4231
4232 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
4232 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
4233 newbranch=opts.get('new_branch'),
4233 newbranch=opts.get('new_branch'),
4234 bookmarks=opts.get('bookmark', ()),
4234 bookmarks=opts.get('bookmark', ()),
4235 opargs=opargs)
4235 opargs=opargs)
4236
4236
4237 result = not pushop.cgresult
4237 result = not pushop.cgresult
4238
4238
4239 if pushop.bkresult is not None:
4239 if pushop.bkresult is not None:
4240 if pushop.bkresult == 2:
4240 if pushop.bkresult == 2:
4241 result = 2
4241 result = 2
4242 elif not result and pushop.bkresult:
4242 elif not result and pushop.bkresult:
4243 result = 2
4243 result = 2
4244
4244
4245 return result
4245 return result
4246
4246
4247 @command('recover', [])
4247 @command('recover', [])
4248 def recover(ui, repo):
4248 def recover(ui, repo):
4249 """roll back an interrupted transaction
4249 """roll back an interrupted transaction
4250
4250
4251 Recover from an interrupted commit or pull.
4251 Recover from an interrupted commit or pull.
4252
4252
4253 This command tries to fix the repository status after an
4253 This command tries to fix the repository status after an
4254 interrupted operation. It should only be necessary when Mercurial
4254 interrupted operation. It should only be necessary when Mercurial
4255 suggests it.
4255 suggests it.
4256
4256
4257 Returns 0 if successful, 1 if nothing to recover or verify fails.
4257 Returns 0 if successful, 1 if nothing to recover or verify fails.
4258 """
4258 """
4259 if repo.recover():
4259 if repo.recover():
4260 return hg.verify(repo)
4260 return hg.verify(repo)
4261 return 1
4261 return 1
4262
4262
4263 @command('^remove|rm',
4263 @command('^remove|rm',
4264 [('A', 'after', None, _('record delete for missing files')),
4264 [('A', 'after', None, _('record delete for missing files')),
4265 ('f', 'force', None,
4265 ('f', 'force', None,
4266 _('forget added files, delete modified files')),
4266 _('forget added files, delete modified files')),
4267 ] + subrepoopts + walkopts + dryrunopts,
4267 ] + subrepoopts + walkopts + dryrunopts,
4268 _('[OPTION]... FILE...'),
4268 _('[OPTION]... FILE...'),
4269 inferrepo=True)
4269 inferrepo=True)
4270 def remove(ui, repo, *pats, **opts):
4270 def remove(ui, repo, *pats, **opts):
4271 """remove the specified files on the next commit
4271 """remove the specified files on the next commit
4272
4272
4273 Schedule the indicated files for removal from the current branch.
4273 Schedule the indicated files for removal from the current branch.
4274
4274
4275 This command schedules the files to be removed at the next commit.
4275 This command schedules the files to be removed at the next commit.
4276 To undo a remove before that, see :hg:`revert`. To undo added
4276 To undo a remove before that, see :hg:`revert`. To undo added
4277 files, see :hg:`forget`.
4277 files, see :hg:`forget`.
4278
4278
4279 .. container:: verbose
4279 .. container:: verbose
4280
4280
4281 -A/--after can be used to remove only files that have already
4281 -A/--after can be used to remove only files that have already
4282 been deleted, -f/--force can be used to force deletion, and -Af
4282 been deleted, -f/--force can be used to force deletion, and -Af
4283 can be used to remove files from the next revision without
4283 can be used to remove files from the next revision without
4284 deleting them from the working directory.
4284 deleting them from the working directory.
4285
4285
4286 The following table details the behavior of remove for different
4286 The following table details the behavior of remove for different
4287 file states (columns) and option combinations (rows). The file
4287 file states (columns) and option combinations (rows). The file
4288 states are Added [A], Clean [C], Modified [M] and Missing [!]
4288 states are Added [A], Clean [C], Modified [M] and Missing [!]
4289 (as reported by :hg:`status`). The actions are Warn, Remove
4289 (as reported by :hg:`status`). The actions are Warn, Remove
4290 (from branch) and Delete (from disk):
4290 (from branch) and Delete (from disk):
4291
4291
4292 ========= == == == ==
4292 ========= == == == ==
4293 opt/state A C M !
4293 opt/state A C M !
4294 ========= == == == ==
4294 ========= == == == ==
4295 none W RD W R
4295 none W RD W R
4296 -f R RD RD R
4296 -f R RD RD R
4297 -A W W W R
4297 -A W W W R
4298 -Af R R R R
4298 -Af R R R R
4299 ========= == == == ==
4299 ========= == == == ==
4300
4300
4301 .. note::
4301 .. note::
4302
4302
4303 :hg:`remove` never deletes files in Added [A] state from the
4303 :hg:`remove` never deletes files in Added [A] state from the
4304 working directory, not even if ``--force`` is specified.
4304 working directory, not even if ``--force`` is specified.
4305
4305
4306 Returns 0 on success, 1 if any warnings encountered.
4306 Returns 0 on success, 1 if any warnings encountered.
4307 """
4307 """
4308
4308
4309 opts = pycompat.byteskwargs(opts)
4309 opts = pycompat.byteskwargs(opts)
4310 after, force = opts.get('after'), opts.get('force')
4310 after, force = opts.get('after'), opts.get('force')
4311 dryrun = opts.get('dry_run')
4311 dryrun = opts.get('dry_run')
4312 if not pats and not after:
4312 if not pats and not after:
4313 raise error.Abort(_('no files specified'))
4313 raise error.Abort(_('no files specified'))
4314
4314
4315 m = scmutil.match(repo[None], pats, opts)
4315 m = scmutil.match(repo[None], pats, opts)
4316 subrepos = opts.get('subrepos')
4316 subrepos = opts.get('subrepos')
4317 return cmdutil.remove(ui, repo, m, "", after, force, subrepos,
4317 return cmdutil.remove(ui, repo, m, "", after, force, subrepos,
4318 dryrun=dryrun)
4318 dryrun=dryrun)
4319
4319
4320 @command('rename|move|mv',
4320 @command('rename|move|mv',
4321 [('A', 'after', None, _('record a rename that has already occurred')),
4321 [('A', 'after', None, _('record a rename that has already occurred')),
4322 ('f', 'force', None, _('forcibly copy over an existing managed file')),
4322 ('f', 'force', None, _('forcibly copy over an existing managed file')),
4323 ] + walkopts + dryrunopts,
4323 ] + walkopts + dryrunopts,
4324 _('[OPTION]... SOURCE... DEST'))
4324 _('[OPTION]... SOURCE... DEST'))
4325 def rename(ui, repo, *pats, **opts):
4325 def rename(ui, repo, *pats, **opts):
4326 """rename files; equivalent of copy + remove
4326 """rename files; equivalent of copy + remove
4327
4327
4328 Mark dest as copies of sources; mark sources for deletion. If dest
4328 Mark dest as copies of sources; mark sources for deletion. If dest
4329 is a directory, copies are put in that directory. If dest is a
4329 is a directory, copies are put in that directory. If dest is a
4330 file, there can only be one source.
4330 file, there can only be one source.
4331
4331
4332 By default, this command copies the contents of files as they
4332 By default, this command copies the contents of files as they
4333 exist in the working directory. If invoked with -A/--after, the
4333 exist in the working directory. If invoked with -A/--after, the
4334 operation is recorded, but no copying is performed.
4334 operation is recorded, but no copying is performed.
4335
4335
4336 This command takes effect at the next commit. To undo a rename
4336 This command takes effect at the next commit. To undo a rename
4337 before that, see :hg:`revert`.
4337 before that, see :hg:`revert`.
4338
4338
4339 Returns 0 on success, 1 if errors are encountered.
4339 Returns 0 on success, 1 if errors are encountered.
4340 """
4340 """
4341 opts = pycompat.byteskwargs(opts)
4341 opts = pycompat.byteskwargs(opts)
4342 with repo.wlock(False):
4342 with repo.wlock(False):
4343 return cmdutil.copy(ui, repo, pats, opts, rename=True)
4343 return cmdutil.copy(ui, repo, pats, opts, rename=True)
4344
4344
4345 @command('resolve',
4345 @command('resolve',
4346 [('a', 'all', None, _('select all unresolved files')),
4346 [('a', 'all', None, _('select all unresolved files')),
4347 ('l', 'list', None, _('list state of files needing merge')),
4347 ('l', 'list', None, _('list state of files needing merge')),
4348 ('m', 'mark', None, _('mark files as resolved')),
4348 ('m', 'mark', None, _('mark files as resolved')),
4349 ('u', 'unmark', None, _('mark files as unresolved')),
4349 ('u', 'unmark', None, _('mark files as unresolved')),
4350 ('n', 'no-status', None, _('hide status prefix'))]
4350 ('n', 'no-status', None, _('hide status prefix'))]
4351 + mergetoolopts + walkopts + formatteropts,
4351 + mergetoolopts + walkopts + formatteropts,
4352 _('[OPTION]... [FILE]...'),
4352 _('[OPTION]... [FILE]...'),
4353 inferrepo=True)
4353 inferrepo=True)
4354 def resolve(ui, repo, *pats, **opts):
4354 def resolve(ui, repo, *pats, **opts):
4355 """redo merges or set/view the merge status of files
4355 """redo merges or set/view the merge status of files
4356
4356
4357 Merges with unresolved conflicts are often the result of
4357 Merges with unresolved conflicts are often the result of
4358 non-interactive merging using the ``internal:merge`` configuration
4358 non-interactive merging using the ``internal:merge`` configuration
4359 setting, or a command-line merge tool like ``diff3``. The resolve
4359 setting, or a command-line merge tool like ``diff3``. The resolve
4360 command is used to manage the files involved in a merge, after
4360 command is used to manage the files involved in a merge, after
4361 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
4361 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
4362 working directory must have two parents). See :hg:`help
4362 working directory must have two parents). See :hg:`help
4363 merge-tools` for information on configuring merge tools.
4363 merge-tools` for information on configuring merge tools.
4364
4364
4365 The resolve command can be used in the following ways:
4365 The resolve command can be used in the following ways:
4366
4366
4367 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
4367 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
4368 files, discarding any previous merge attempts. Re-merging is not
4368 files, discarding any previous merge attempts. Re-merging is not
4369 performed for files already marked as resolved. Use ``--all/-a``
4369 performed for files already marked as resolved. Use ``--all/-a``
4370 to select all unresolved files. ``--tool`` can be used to specify
4370 to select all unresolved files. ``--tool`` can be used to specify
4371 the merge tool used for the given files. It overrides the HGMERGE
4371 the merge tool used for the given files. It overrides the HGMERGE
4372 environment variable and your configuration files. Previous file
4372 environment variable and your configuration files. Previous file
4373 contents are saved with a ``.orig`` suffix.
4373 contents are saved with a ``.orig`` suffix.
4374
4374
4375 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
4375 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
4376 (e.g. after having manually fixed-up the files). The default is
4376 (e.g. after having manually fixed-up the files). The default is
4377 to mark all unresolved files.
4377 to mark all unresolved files.
4378
4378
4379 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
4379 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
4380 default is to mark all resolved files.
4380 default is to mark all resolved files.
4381
4381
4382 - :hg:`resolve -l`: list files which had or still have conflicts.
4382 - :hg:`resolve -l`: list files which had or still have conflicts.
4383 In the printed list, ``U`` = unresolved and ``R`` = resolved.
4383 In the printed list, ``U`` = unresolved and ``R`` = resolved.
4384 You can use ``set:unresolved()`` or ``set:resolved()`` to filter
4384 You can use ``set:unresolved()`` or ``set:resolved()`` to filter
4385 the list. See :hg:`help filesets` for details.
4385 the list. See :hg:`help filesets` for details.
4386
4386
4387 .. note::
4387 .. note::
4388
4388
4389 Mercurial will not let you commit files with unresolved merge
4389 Mercurial will not let you commit files with unresolved merge
4390 conflicts. You must use :hg:`resolve -m ...` before you can
4390 conflicts. You must use :hg:`resolve -m ...` before you can
4391 commit after a conflicting merge.
4391 commit after a conflicting merge.
4392
4392
4393 Returns 0 on success, 1 if any files fail a resolve attempt.
4393 Returns 0 on success, 1 if any files fail a resolve attempt.
4394 """
4394 """
4395
4395
4396 opts = pycompat.byteskwargs(opts)
4396 opts = pycompat.byteskwargs(opts)
4397 flaglist = 'all mark unmark list no_status'.split()
4397 flaglist = 'all mark unmark list no_status'.split()
4398 all, mark, unmark, show, nostatus = \
4398 all, mark, unmark, show, nostatus = \
4399 [opts.get(o) for o in flaglist]
4399 [opts.get(o) for o in flaglist]
4400
4400
4401 if (show and (mark or unmark)) or (mark and unmark):
4401 if (show and (mark or unmark)) or (mark and unmark):
4402 raise error.Abort(_("too many options specified"))
4402 raise error.Abort(_("too many options specified"))
4403 if pats and all:
4403 if pats and all:
4404 raise error.Abort(_("can't specify --all and patterns"))
4404 raise error.Abort(_("can't specify --all and patterns"))
4405 if not (all or pats or show or mark or unmark):
4405 if not (all or pats or show or mark or unmark):
4406 raise error.Abort(_('no files or directories specified'),
4406 raise error.Abort(_('no files or directories specified'),
4407 hint=('use --all to re-merge all unresolved files'))
4407 hint=('use --all to re-merge all unresolved files'))
4408
4408
4409 if show:
4409 if show:
4410 ui.pager('resolve')
4410 ui.pager('resolve')
4411 fm = ui.formatter('resolve', opts)
4411 fm = ui.formatter('resolve', opts)
4412 ms = mergemod.mergestate.read(repo)
4412 ms = mergemod.mergestate.read(repo)
4413 m = scmutil.match(repo[None], pats, opts)
4413 m = scmutil.match(repo[None], pats, opts)
4414
4414
4415 # Labels and keys based on merge state. Unresolved path conflicts show
4415 # Labels and keys based on merge state. Unresolved path conflicts show
4416 # as 'P'. Resolved path conflicts show as 'R', the same as normal
4416 # as 'P'. Resolved path conflicts show as 'R', the same as normal
4417 # resolved conflicts.
4417 # resolved conflicts.
4418 mergestateinfo = {
4418 mergestateinfo = {
4419 mergemod.MERGE_RECORD_UNRESOLVED: ('resolve.unresolved', 'U'),
4419 mergemod.MERGE_RECORD_UNRESOLVED: ('resolve.unresolved', 'U'),
4420 mergemod.MERGE_RECORD_RESOLVED: ('resolve.resolved', 'R'),
4420 mergemod.MERGE_RECORD_RESOLVED: ('resolve.resolved', 'R'),
4421 mergemod.MERGE_RECORD_UNRESOLVED_PATH: ('resolve.unresolved', 'P'),
4421 mergemod.MERGE_RECORD_UNRESOLVED_PATH: ('resolve.unresolved', 'P'),
4422 mergemod.MERGE_RECORD_RESOLVED_PATH: ('resolve.resolved', 'R'),
4422 mergemod.MERGE_RECORD_RESOLVED_PATH: ('resolve.resolved', 'R'),
4423 mergemod.MERGE_RECORD_DRIVER_RESOLVED: ('resolve.driverresolved',
4423 mergemod.MERGE_RECORD_DRIVER_RESOLVED: ('resolve.driverresolved',
4424 'D'),
4424 'D'),
4425 }
4425 }
4426
4426
4427 for f in ms:
4427 for f in ms:
4428 if not m(f):
4428 if not m(f):
4429 continue
4429 continue
4430
4430
4431 label, key = mergestateinfo[ms[f]]
4431 label, key = mergestateinfo[ms[f]]
4432 fm.startitem()
4432 fm.startitem()
4433 fm.condwrite(not nostatus, 'status', '%s ', key, label=label)
4433 fm.condwrite(not nostatus, 'status', '%s ', key, label=label)
4434 fm.write('path', '%s\n', f, label=label)
4434 fm.write('path', '%s\n', f, label=label)
4435 fm.end()
4435 fm.end()
4436 return 0
4436 return 0
4437
4437
4438 with repo.wlock():
4438 with repo.wlock():
4439 ms = mergemod.mergestate.read(repo)
4439 ms = mergemod.mergestate.read(repo)
4440
4440
4441 if not (ms.active() or repo.dirstate.p2() != nullid):
4441 if not (ms.active() or repo.dirstate.p2() != nullid):
4442 raise error.Abort(
4442 raise error.Abort(
4443 _('resolve command not applicable when not merging'))
4443 _('resolve command not applicable when not merging'))
4444
4444
4445 wctx = repo[None]
4445 wctx = repo[None]
4446
4446
4447 if (ms.mergedriver
4447 if (ms.mergedriver
4448 and ms.mdstate() == mergemod.MERGE_DRIVER_STATE_UNMARKED):
4448 and ms.mdstate() == mergemod.MERGE_DRIVER_STATE_UNMARKED):
4449 proceed = mergemod.driverpreprocess(repo, ms, wctx)
4449 proceed = mergemod.driverpreprocess(repo, ms, wctx)
4450 ms.commit()
4450 ms.commit()
4451 # allow mark and unmark to go through
4451 # allow mark and unmark to go through
4452 if not mark and not unmark and not proceed:
4452 if not mark and not unmark and not proceed:
4453 return 1
4453 return 1
4454
4454
4455 m = scmutil.match(wctx, pats, opts)
4455 m = scmutil.match(wctx, pats, opts)
4456 ret = 0
4456 ret = 0
4457 didwork = False
4457 didwork = False
4458 runconclude = False
4458 runconclude = False
4459
4459
4460 tocomplete = []
4460 tocomplete = []
4461 for f in ms:
4461 for f in ms:
4462 if not m(f):
4462 if not m(f):
4463 continue
4463 continue
4464
4464
4465 didwork = True
4465 didwork = True
4466
4466
4467 # don't let driver-resolved files be marked, and run the conclude
4467 # don't let driver-resolved files be marked, and run the conclude
4468 # step if asked to resolve
4468 # step if asked to resolve
4469 if ms[f] == mergemod.MERGE_RECORD_DRIVER_RESOLVED:
4469 if ms[f] == mergemod.MERGE_RECORD_DRIVER_RESOLVED:
4470 exact = m.exact(f)
4470 exact = m.exact(f)
4471 if mark:
4471 if mark:
4472 if exact:
4472 if exact:
4473 ui.warn(_('not marking %s as it is driver-resolved\n')
4473 ui.warn(_('not marking %s as it is driver-resolved\n')
4474 % f)
4474 % f)
4475 elif unmark:
4475 elif unmark:
4476 if exact:
4476 if exact:
4477 ui.warn(_('not unmarking %s as it is driver-resolved\n')
4477 ui.warn(_('not unmarking %s as it is driver-resolved\n')
4478 % f)
4478 % f)
4479 else:
4479 else:
4480 runconclude = True
4480 runconclude = True
4481 continue
4481 continue
4482
4482
4483 # path conflicts must be resolved manually
4483 # path conflicts must be resolved manually
4484 if ms[f] in (mergemod.MERGE_RECORD_UNRESOLVED_PATH,
4484 if ms[f] in (mergemod.MERGE_RECORD_UNRESOLVED_PATH,
4485 mergemod.MERGE_RECORD_RESOLVED_PATH):
4485 mergemod.MERGE_RECORD_RESOLVED_PATH):
4486 if mark:
4486 if mark:
4487 ms.mark(f, mergemod.MERGE_RECORD_RESOLVED_PATH)
4487 ms.mark(f, mergemod.MERGE_RECORD_RESOLVED_PATH)
4488 elif unmark:
4488 elif unmark:
4489 ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED_PATH)
4489 ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED_PATH)
4490 elif ms[f] == mergemod.MERGE_RECORD_UNRESOLVED_PATH:
4490 elif ms[f] == mergemod.MERGE_RECORD_UNRESOLVED_PATH:
4491 ui.warn(_('%s: path conflict must be resolved manually\n')
4491 ui.warn(_('%s: path conflict must be resolved manually\n')
4492 % f)
4492 % f)
4493 continue
4493 continue
4494
4494
4495 if mark:
4495 if mark:
4496 ms.mark(f, mergemod.MERGE_RECORD_RESOLVED)
4496 ms.mark(f, mergemod.MERGE_RECORD_RESOLVED)
4497 elif unmark:
4497 elif unmark:
4498 ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED)
4498 ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED)
4499 else:
4499 else:
4500 # backup pre-resolve (merge uses .orig for its own purposes)
4500 # backup pre-resolve (merge uses .orig for its own purposes)
4501 a = repo.wjoin(f)
4501 a = repo.wjoin(f)
4502 try:
4502 try:
4503 util.copyfile(a, a + ".resolve")
4503 util.copyfile(a, a + ".resolve")
4504 except (IOError, OSError) as inst:
4504 except (IOError, OSError) as inst:
4505 if inst.errno != errno.ENOENT:
4505 if inst.errno != errno.ENOENT:
4506 raise
4506 raise
4507
4507
4508 try:
4508 try:
4509 # preresolve file
4509 # preresolve file
4510 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
4510 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
4511 'resolve')
4511 'resolve')
4512 complete, r = ms.preresolve(f, wctx)
4512 complete, r = ms.preresolve(f, wctx)
4513 if not complete:
4513 if not complete:
4514 tocomplete.append(f)
4514 tocomplete.append(f)
4515 elif r:
4515 elif r:
4516 ret = 1
4516 ret = 1
4517 finally:
4517 finally:
4518 ui.setconfig('ui', 'forcemerge', '', 'resolve')
4518 ui.setconfig('ui', 'forcemerge', '', 'resolve')
4519 ms.commit()
4519 ms.commit()
4520
4520
4521 # replace filemerge's .orig file with our resolve file, but only
4521 # replace filemerge's .orig file with our resolve file, but only
4522 # for merges that are complete
4522 # for merges that are complete
4523 if complete:
4523 if complete:
4524 try:
4524 try:
4525 util.rename(a + ".resolve",
4525 util.rename(a + ".resolve",
4526 scmutil.origpath(ui, repo, a))
4526 scmutil.origpath(ui, repo, a))
4527 except OSError as inst:
4527 except OSError as inst:
4528 if inst.errno != errno.ENOENT:
4528 if inst.errno != errno.ENOENT:
4529 raise
4529 raise
4530
4530
4531 for f in tocomplete:
4531 for f in tocomplete:
4532 try:
4532 try:
4533 # resolve file
4533 # resolve file
4534 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
4534 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
4535 'resolve')
4535 'resolve')
4536 r = ms.resolve(f, wctx)
4536 r = ms.resolve(f, wctx)
4537 if r:
4537 if r:
4538 ret = 1
4538 ret = 1
4539 finally:
4539 finally:
4540 ui.setconfig('ui', 'forcemerge', '', 'resolve')
4540 ui.setconfig('ui', 'forcemerge', '', 'resolve')
4541 ms.commit()
4541 ms.commit()
4542
4542
4543 # replace filemerge's .orig file with our resolve file
4543 # replace filemerge's .orig file with our resolve file
4544 a = repo.wjoin(f)
4544 a = repo.wjoin(f)
4545 try:
4545 try:
4546 util.rename(a + ".resolve", scmutil.origpath(ui, repo, a))
4546 util.rename(a + ".resolve", scmutil.origpath(ui, repo, a))
4547 except OSError as inst:
4547 except OSError as inst:
4548 if inst.errno != errno.ENOENT:
4548 if inst.errno != errno.ENOENT:
4549 raise
4549 raise
4550
4550
4551 ms.commit()
4551 ms.commit()
4552 ms.recordactions()
4552 ms.recordactions()
4553
4553
4554 if not didwork and pats:
4554 if not didwork and pats:
4555 hint = None
4555 hint = None
4556 if not any([p for p in pats if p.find(':') >= 0]):
4556 if not any([p for p in pats if p.find(':') >= 0]):
4557 pats = ['path:%s' % p for p in pats]
4557 pats = ['path:%s' % p for p in pats]
4558 m = scmutil.match(wctx, pats, opts)
4558 m = scmutil.match(wctx, pats, opts)
4559 for f in ms:
4559 for f in ms:
4560 if not m(f):
4560 if not m(f):
4561 continue
4561 continue
4562 flags = ''.join(['-%s ' % o[0:1] for o in flaglist
4562 flags = ''.join(['-%s ' % o[0:1] for o in flaglist
4563 if opts.get(o)])
4563 if opts.get(o)])
4564 hint = _("(try: hg resolve %s%s)\n") % (
4564 hint = _("(try: hg resolve %s%s)\n") % (
4565 flags,
4565 flags,
4566 ' '.join(pats))
4566 ' '.join(pats))
4567 break
4567 break
4568 ui.warn(_("arguments do not match paths that need resolving\n"))
4568 ui.warn(_("arguments do not match paths that need resolving\n"))
4569 if hint:
4569 if hint:
4570 ui.warn(hint)
4570 ui.warn(hint)
4571 elif ms.mergedriver and ms.mdstate() != 's':
4571 elif ms.mergedriver and ms.mdstate() != 's':
4572 # run conclude step when either a driver-resolved file is requested
4572 # run conclude step when either a driver-resolved file is requested
4573 # or there are no driver-resolved files
4573 # or there are no driver-resolved files
4574 # we can't use 'ret' to determine whether any files are unresolved
4574 # we can't use 'ret' to determine whether any files are unresolved
4575 # because we might not have tried to resolve some
4575 # because we might not have tried to resolve some
4576 if ((runconclude or not list(ms.driverresolved()))
4576 if ((runconclude or not list(ms.driverresolved()))
4577 and not list(ms.unresolved())):
4577 and not list(ms.unresolved())):
4578 proceed = mergemod.driverconclude(repo, ms, wctx)
4578 proceed = mergemod.driverconclude(repo, ms, wctx)
4579 ms.commit()
4579 ms.commit()
4580 if not proceed:
4580 if not proceed:
4581 return 1
4581 return 1
4582
4582
4583 # Nudge users into finishing an unfinished operation
4583 # Nudge users into finishing an unfinished operation
4584 unresolvedf = list(ms.unresolved())
4584 unresolvedf = list(ms.unresolved())
4585 driverresolvedf = list(ms.driverresolved())
4585 driverresolvedf = list(ms.driverresolved())
4586 if not unresolvedf and not driverresolvedf:
4586 if not unresolvedf and not driverresolvedf:
4587 ui.status(_('(no more unresolved files)\n'))
4587 ui.status(_('(no more unresolved files)\n'))
4588 cmdutil.checkafterresolved(repo)
4588 cmdutil.checkafterresolved(repo)
4589 elif not unresolvedf:
4589 elif not unresolvedf:
4590 ui.status(_('(no more unresolved files -- '
4590 ui.status(_('(no more unresolved files -- '
4591 'run "hg resolve --all" to conclude)\n'))
4591 'run "hg resolve --all" to conclude)\n'))
4592
4592
4593 return ret
4593 return ret
4594
4594
4595 @command('revert',
4595 @command('revert',
4596 [('a', 'all', None, _('revert all changes when no arguments given')),
4596 [('a', 'all', None, _('revert all changes when no arguments given')),
4597 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
4597 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
4598 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
4598 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
4599 ('C', 'no-backup', None, _('do not save backup copies of files')),
4599 ('C', 'no-backup', None, _('do not save backup copies of files')),
4600 ('i', 'interactive', None, _('interactively select the changes')),
4600 ('i', 'interactive', None, _('interactively select the changes')),
4601 ] + walkopts + dryrunopts,
4601 ] + walkopts + dryrunopts,
4602 _('[OPTION]... [-r REV] [NAME]...'))
4602 _('[OPTION]... [-r REV] [NAME]...'))
4603 def revert(ui, repo, *pats, **opts):
4603 def revert(ui, repo, *pats, **opts):
4604 """restore files to their checkout state
4604 """restore files to their checkout state
4605
4605
4606 .. note::
4606 .. note::
4607
4607
4608 To check out earlier revisions, you should use :hg:`update REV`.
4608 To check out earlier revisions, you should use :hg:`update REV`.
4609 To cancel an uncommitted merge (and lose your changes),
4609 To cancel an uncommitted merge (and lose your changes),
4610 use :hg:`merge --abort`.
4610 use :hg:`merge --abort`.
4611
4611
4612 With no revision specified, revert the specified files or directories
4612 With no revision specified, revert the specified files or directories
4613 to the contents they had in the parent of the working directory.
4613 to the contents they had in the parent of the working directory.
4614 This restores the contents of files to an unmodified
4614 This restores the contents of files to an unmodified
4615 state and unschedules adds, removes, copies, and renames. If the
4615 state and unschedules adds, removes, copies, and renames. If the
4616 working directory has two parents, you must explicitly specify a
4616 working directory has two parents, you must explicitly specify a
4617 revision.
4617 revision.
4618
4618
4619 Using the -r/--rev or -d/--date options, revert the given files or
4619 Using the -r/--rev or -d/--date options, revert the given files or
4620 directories to their states as of a specific revision. Because
4620 directories to their states as of a specific revision. Because
4621 revert does not change the working directory parents, this will
4621 revert does not change the working directory parents, this will
4622 cause these files to appear modified. This can be helpful to "back
4622 cause these files to appear modified. This can be helpful to "back
4623 out" some or all of an earlier change. See :hg:`backout` for a
4623 out" some or all of an earlier change. See :hg:`backout` for a
4624 related method.
4624 related method.
4625
4625
4626 Modified files are saved with a .orig suffix before reverting.
4626 Modified files are saved with a .orig suffix before reverting.
4627 To disable these backups, use --no-backup. It is possible to store
4627 To disable these backups, use --no-backup. It is possible to store
4628 the backup files in a custom directory relative to the root of the
4628 the backup files in a custom directory relative to the root of the
4629 repository by setting the ``ui.origbackuppath`` configuration
4629 repository by setting the ``ui.origbackuppath`` configuration
4630 option.
4630 option.
4631
4631
4632 See :hg:`help dates` for a list of formats valid for -d/--date.
4632 See :hg:`help dates` for a list of formats valid for -d/--date.
4633
4633
4634 See :hg:`help backout` for a way to reverse the effect of an
4634 See :hg:`help backout` for a way to reverse the effect of an
4635 earlier changeset.
4635 earlier changeset.
4636
4636
4637 Returns 0 on success.
4637 Returns 0 on success.
4638 """
4638 """
4639
4639
4640 opts = pycompat.byteskwargs(opts)
4640 opts = pycompat.byteskwargs(opts)
4641 if opts.get("date"):
4641 if opts.get("date"):
4642 if opts.get("rev"):
4642 if opts.get("rev"):
4643 raise error.Abort(_("you can't specify a revision and a date"))
4643 raise error.Abort(_("you can't specify a revision and a date"))
4644 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
4644 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
4645
4645
4646 parent, p2 = repo.dirstate.parents()
4646 parent, p2 = repo.dirstate.parents()
4647 if not opts.get('rev') and p2 != nullid:
4647 if not opts.get('rev') and p2 != nullid:
4648 # revert after merge is a trap for new users (issue2915)
4648 # revert after merge is a trap for new users (issue2915)
4649 raise error.Abort(_('uncommitted merge with no revision specified'),
4649 raise error.Abort(_('uncommitted merge with no revision specified'),
4650 hint=_("use 'hg update' or see 'hg help revert'"))
4650 hint=_("use 'hg update' or see 'hg help revert'"))
4651
4651
4652 rev = opts.get('rev')
4652 rev = opts.get('rev')
4653 if rev:
4653 if rev:
4654 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
4654 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
4655 ctx = scmutil.revsingle(repo, rev)
4655 ctx = scmutil.revsingle(repo, rev)
4656
4656
4657 if (not (pats or opts.get('include') or opts.get('exclude') or
4657 if (not (pats or opts.get('include') or opts.get('exclude') or
4658 opts.get('all') or opts.get('interactive'))):
4658 opts.get('all') or opts.get('interactive'))):
4659 msg = _("no files or directories specified")
4659 msg = _("no files or directories specified")
4660 if p2 != nullid:
4660 if p2 != nullid:
4661 hint = _("uncommitted merge, use --all to discard all changes,"
4661 hint = _("uncommitted merge, use --all to discard all changes,"
4662 " or 'hg update -C .' to abort the merge")
4662 " or 'hg update -C .' to abort the merge")
4663 raise error.Abort(msg, hint=hint)
4663 raise error.Abort(msg, hint=hint)
4664 dirty = any(repo.status())
4664 dirty = any(repo.status())
4665 node = ctx.node()
4665 node = ctx.node()
4666 if node != parent:
4666 if node != parent:
4667 if dirty:
4667 if dirty:
4668 hint = _("uncommitted changes, use --all to discard all"
4668 hint = _("uncommitted changes, use --all to discard all"
4669 " changes, or 'hg update %s' to update") % ctx.rev()
4669 " changes, or 'hg update %s' to update") % ctx.rev()
4670 else:
4670 else:
4671 hint = _("use --all to revert all files,"
4671 hint = _("use --all to revert all files,"
4672 " or 'hg update %s' to update") % ctx.rev()
4672 " or 'hg update %s' to update") % ctx.rev()
4673 elif dirty:
4673 elif dirty:
4674 hint = _("uncommitted changes, use --all to discard all changes")
4674 hint = _("uncommitted changes, use --all to discard all changes")
4675 else:
4675 else:
4676 hint = _("use --all to revert all files")
4676 hint = _("use --all to revert all files")
4677 raise error.Abort(msg, hint=hint)
4677 raise error.Abort(msg, hint=hint)
4678
4678
4679 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats,
4679 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats,
4680 **pycompat.strkwargs(opts))
4680 **pycompat.strkwargs(opts))
4681
4681
4682 @command('rollback', dryrunopts +
4682 @command('rollback', dryrunopts +
4683 [('f', 'force', False, _('ignore safety measures'))])
4683 [('f', 'force', False, _('ignore safety measures'))])
4684 def rollback(ui, repo, **opts):
4684 def rollback(ui, repo, **opts):
4685 """roll back the last transaction (DANGEROUS) (DEPRECATED)
4685 """roll back the last transaction (DANGEROUS) (DEPRECATED)
4686
4686
4687 Please use :hg:`commit --amend` instead of rollback to correct
4687 Please use :hg:`commit --amend` instead of rollback to correct
4688 mistakes in the last commit.
4688 mistakes in the last commit.
4689
4689
4690 This command should be used with care. There is only one level of
4690 This command should be used with care. There is only one level of
4691 rollback, and there is no way to undo a rollback. It will also
4691 rollback, and there is no way to undo a rollback. It will also
4692 restore the dirstate at the time of the last transaction, losing
4692 restore the dirstate at the time of the last transaction, losing
4693 any dirstate changes since that time. This command does not alter
4693 any dirstate changes since that time. This command does not alter
4694 the working directory.
4694 the working directory.
4695
4695
4696 Transactions are used to encapsulate the effects of all commands
4696 Transactions are used to encapsulate the effects of all commands
4697 that create new changesets or propagate existing changesets into a
4697 that create new changesets or propagate existing changesets into a
4698 repository.
4698 repository.
4699
4699
4700 .. container:: verbose
4700 .. container:: verbose
4701
4701
4702 For example, the following commands are transactional, and their
4702 For example, the following commands are transactional, and their
4703 effects can be rolled back:
4703 effects can be rolled back:
4704
4704
4705 - commit
4705 - commit
4706 - import
4706 - import
4707 - pull
4707 - pull
4708 - push (with this repository as the destination)
4708 - push (with this repository as the destination)
4709 - unbundle
4709 - unbundle
4710
4710
4711 To avoid permanent data loss, rollback will refuse to rollback a
4711 To avoid permanent data loss, rollback will refuse to rollback a
4712 commit transaction if it isn't checked out. Use --force to
4712 commit transaction if it isn't checked out. Use --force to
4713 override this protection.
4713 override this protection.
4714
4714
4715 The rollback command can be entirely disabled by setting the
4715 The rollback command can be entirely disabled by setting the
4716 ``ui.rollback`` configuration setting to false. If you're here
4716 ``ui.rollback`` configuration setting to false. If you're here
4717 because you want to use rollback and it's disabled, you can
4717 because you want to use rollback and it's disabled, you can
4718 re-enable the command by setting ``ui.rollback`` to true.
4718 re-enable the command by setting ``ui.rollback`` to true.
4719
4719
4720 This command is not intended for use on public repositories. Once
4720 This command is not intended for use on public repositories. Once
4721 changes are visible for pull by other users, rolling a transaction
4721 changes are visible for pull by other users, rolling a transaction
4722 back locally is ineffective (someone else may already have pulled
4722 back locally is ineffective (someone else may already have pulled
4723 the changes). Furthermore, a race is possible with readers of the
4723 the changes). Furthermore, a race is possible with readers of the
4724 repository; for example an in-progress pull from the repository
4724 repository; for example an in-progress pull from the repository
4725 may fail if a rollback is performed.
4725 may fail if a rollback is performed.
4726
4726
4727 Returns 0 on success, 1 if no rollback data is available.
4727 Returns 0 on success, 1 if no rollback data is available.
4728 """
4728 """
4729 if not ui.configbool('ui', 'rollback'):
4729 if not ui.configbool('ui', 'rollback'):
4730 raise error.Abort(_('rollback is disabled because it is unsafe'),
4730 raise error.Abort(_('rollback is disabled because it is unsafe'),
4731 hint=('see `hg help -v rollback` for information'))
4731 hint=('see `hg help -v rollback` for information'))
4732 return repo.rollback(dryrun=opts.get(r'dry_run'),
4732 return repo.rollback(dryrun=opts.get(r'dry_run'),
4733 force=opts.get(r'force'))
4733 force=opts.get(r'force'))
4734
4734
4735 @command('root', [], intents={INTENT_READONLY})
4735 @command('root', [], intents={INTENT_READONLY})
4736 def root(ui, repo):
4736 def root(ui, repo):
4737 """print the root (top) of the current working directory
4737 """print the root (top) of the current working directory
4738
4738
4739 Print the root directory of the current repository.
4739 Print the root directory of the current repository.
4740
4740
4741 Returns 0 on success.
4741 Returns 0 on success.
4742 """
4742 """
4743 ui.write(repo.root + "\n")
4743 ui.write(repo.root + "\n")
4744
4744
4745 @command('^serve',
4745 @command('^serve',
4746 [('A', 'accesslog', '', _('name of access log file to write to'),
4746 [('A', 'accesslog', '', _('name of access log file to write to'),
4747 _('FILE')),
4747 _('FILE')),
4748 ('d', 'daemon', None, _('run server in background')),
4748 ('d', 'daemon', None, _('run server in background')),
4749 ('', 'daemon-postexec', [], _('used internally by daemon mode')),
4749 ('', 'daemon-postexec', [], _('used internally by daemon mode')),
4750 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
4750 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
4751 # use string type, then we can check if something was passed
4751 # use string type, then we can check if something was passed
4752 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
4752 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
4753 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
4753 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
4754 _('ADDR')),
4754 _('ADDR')),
4755 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
4755 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
4756 _('PREFIX')),
4756 _('PREFIX')),
4757 ('n', 'name', '',
4757 ('n', 'name', '',
4758 _('name to show in web pages (default: working directory)'), _('NAME')),
4758 _('name to show in web pages (default: working directory)'), _('NAME')),
4759 ('', 'web-conf', '',
4759 ('', 'web-conf', '',
4760 _("name of the hgweb config file (see 'hg help hgweb')"), _('FILE')),
4760 _("name of the hgweb config file (see 'hg help hgweb')"), _('FILE')),
4761 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
4761 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
4762 _('FILE')),
4762 _('FILE')),
4763 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
4763 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
4764 ('', 'stdio', None, _('for remote clients (ADVANCED)')),
4764 ('', 'stdio', None, _('for remote clients (ADVANCED)')),
4765 ('', 'cmdserver', '', _('for remote clients (ADVANCED)'), _('MODE')),
4765 ('', 'cmdserver', '', _('for remote clients (ADVANCED)'), _('MODE')),
4766 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
4766 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
4767 ('', 'style', '', _('template style to use'), _('STYLE')),
4767 ('', 'style', '', _('template style to use'), _('STYLE')),
4768 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
4768 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
4769 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))]
4769 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))]
4770 + subrepoopts,
4770 + subrepoopts,
4771 _('[OPTION]...'),
4771 _('[OPTION]...'),
4772 optionalrepo=True)
4772 optionalrepo=True)
4773 def serve(ui, repo, **opts):
4773 def serve(ui, repo, **opts):
4774 """start stand-alone webserver
4774 """start stand-alone webserver
4775
4775
4776 Start a local HTTP repository browser and pull server. You can use
4776 Start a local HTTP repository browser and pull server. You can use
4777 this for ad-hoc sharing and browsing of repositories. It is
4777 this for ad-hoc sharing and browsing of repositories. It is
4778 recommended to use a real web server to serve a repository for
4778 recommended to use a real web server to serve a repository for
4779 longer periods of time.
4779 longer periods of time.
4780
4780
4781 Please note that the server does not implement access control.
4781 Please note that the server does not implement access control.
4782 This means that, by default, anybody can read from the server and
4782 This means that, by default, anybody can read from the server and
4783 nobody can write to it by default. Set the ``web.allow-push``
4783 nobody can write to it by default. Set the ``web.allow-push``
4784 option to ``*`` to allow everybody to push to the server. You
4784 option to ``*`` to allow everybody to push to the server. You
4785 should use a real web server if you need to authenticate users.
4785 should use a real web server if you need to authenticate users.
4786
4786
4787 By default, the server logs accesses to stdout and errors to
4787 By default, the server logs accesses to stdout and errors to
4788 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
4788 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
4789 files.
4789 files.
4790
4790
4791 To have the server choose a free port number to listen on, specify
4791 To have the server choose a free port number to listen on, specify
4792 a port number of 0; in this case, the server will print the port
4792 a port number of 0; in this case, the server will print the port
4793 number it uses.
4793 number it uses.
4794
4794
4795 Returns 0 on success.
4795 Returns 0 on success.
4796 """
4796 """
4797
4797
4798 opts = pycompat.byteskwargs(opts)
4798 opts = pycompat.byteskwargs(opts)
4799 if opts["stdio"] and opts["cmdserver"]:
4799 if opts["stdio"] and opts["cmdserver"]:
4800 raise error.Abort(_("cannot use --stdio with --cmdserver"))
4800 raise error.Abort(_("cannot use --stdio with --cmdserver"))
4801
4801
4802 if opts["stdio"]:
4802 if opts["stdio"]:
4803 if repo is None:
4803 if repo is None:
4804 raise error.RepoError(_("there is no Mercurial repository here"
4804 raise error.RepoError(_("there is no Mercurial repository here"
4805 " (.hg not found)"))
4805 " (.hg not found)"))
4806 s = wireprotoserver.sshserver(ui, repo)
4806 s = wireprotoserver.sshserver(ui, repo)
4807 s.serve_forever()
4807 s.serve_forever()
4808
4808
4809 service = server.createservice(ui, repo, opts)
4809 service = server.createservice(ui, repo, opts)
4810 return server.runservice(opts, initfn=service.init, runfn=service.run)
4810 return server.runservice(opts, initfn=service.init, runfn=service.run)
4811
4811
4812 _NOTTERSE = 'nothing'
4813
4812 @command('^status|st',
4814 @command('^status|st',
4813 [('A', 'all', None, _('show status of all files')),
4815 [('A', 'all', None, _('show status of all files')),
4814 ('m', 'modified', None, _('show only modified files')),
4816 ('m', 'modified', None, _('show only modified files')),
4815 ('a', 'added', None, _('show only added files')),
4817 ('a', 'added', None, _('show only added files')),
4816 ('r', 'removed', None, _('show only removed files')),
4818 ('r', 'removed', None, _('show only removed files')),
4817 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
4819 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
4818 ('c', 'clean', None, _('show only files without changes')),
4820 ('c', 'clean', None, _('show only files without changes')),
4819 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
4821 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
4820 ('i', 'ignored', None, _('show only ignored files')),
4822 ('i', 'ignored', None, _('show only ignored files')),
4821 ('n', 'no-status', None, _('hide status prefix')),
4823 ('n', 'no-status', None, _('hide status prefix')),
4822 ('t', 'terse', '', _('show the terse output (EXPERIMENTAL)')),
4824 ('t', 'terse', _NOTTERSE, _('show the terse output (EXPERIMENTAL)')),
4823 ('C', 'copies', None, _('show source of copied files')),
4825 ('C', 'copies', None, _('show source of copied files')),
4824 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
4826 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
4825 ('', 'rev', [], _('show difference from revision'), _('REV')),
4827 ('', 'rev', [], _('show difference from revision'), _('REV')),
4826 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
4828 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
4827 ] + walkopts + subrepoopts + formatteropts,
4829 ] + walkopts + subrepoopts + formatteropts,
4828 _('[OPTION]... [FILE]...'),
4830 _('[OPTION]... [FILE]...'),
4829 inferrepo=True,
4831 inferrepo=True,
4830 intents={INTENT_READONLY})
4832 intents={INTENT_READONLY})
4831 def status(ui, repo, *pats, **opts):
4833 def status(ui, repo, *pats, **opts):
4832 """show changed files in the working directory
4834 """show changed files in the working directory
4833
4835
4834 Show status of files in the repository. If names are given, only
4836 Show status of files in the repository. If names are given, only
4835 files that match are shown. Files that are clean or ignored or
4837 files that match are shown. Files that are clean or ignored or
4836 the source of a copy/move operation, are not listed unless
4838 the source of a copy/move operation, are not listed unless
4837 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
4839 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
4838 Unless options described with "show only ..." are given, the
4840 Unless options described with "show only ..." are given, the
4839 options -mardu are used.
4841 options -mardu are used.
4840
4842
4841 Option -q/--quiet hides untracked (unknown and ignored) files
4843 Option -q/--quiet hides untracked (unknown and ignored) files
4842 unless explicitly requested with -u/--unknown or -i/--ignored.
4844 unless explicitly requested with -u/--unknown or -i/--ignored.
4843
4845
4844 .. note::
4846 .. note::
4845
4847
4846 :hg:`status` may appear to disagree with diff if permissions have
4848 :hg:`status` may appear to disagree with diff if permissions have
4847 changed or a merge has occurred. The standard diff format does
4849 changed or a merge has occurred. The standard diff format does
4848 not report permission changes and diff only reports changes
4850 not report permission changes and diff only reports changes
4849 relative to one merge parent.
4851 relative to one merge parent.
4850
4852
4851 If one revision is given, it is used as the base revision.
4853 If one revision is given, it is used as the base revision.
4852 If two revisions are given, the differences between them are
4854 If two revisions are given, the differences between them are
4853 shown. The --change option can also be used as a shortcut to list
4855 shown. The --change option can also be used as a shortcut to list
4854 the changed files of a revision from its first parent.
4856 the changed files of a revision from its first parent.
4855
4857
4856 The codes used to show the status of files are::
4858 The codes used to show the status of files are::
4857
4859
4858 M = modified
4860 M = modified
4859 A = added
4861 A = added
4860 R = removed
4862 R = removed
4861 C = clean
4863 C = clean
4862 ! = missing (deleted by non-hg command, but still tracked)
4864 ! = missing (deleted by non-hg command, but still tracked)
4863 ? = not tracked
4865 ? = not tracked
4864 I = ignored
4866 I = ignored
4865 = origin of the previous file (with --copies)
4867 = origin of the previous file (with --copies)
4866
4868
4867 .. container:: verbose
4869 .. container:: verbose
4868
4870
4869 The -t/--terse option abbreviates the output by showing only the directory
4871 The -t/--terse option abbreviates the output by showing only the directory
4870 name if all the files in it share the same status. The option takes an
4872 name if all the files in it share the same status. The option takes an
4871 argument indicating the statuses to abbreviate: 'm' for 'modified', 'a'
4873 argument indicating the statuses to abbreviate: 'm' for 'modified', 'a'
4872 for 'added', 'r' for 'removed', 'd' for 'deleted', 'u' for 'unknown', 'i'
4874 for 'added', 'r' for 'removed', 'd' for 'deleted', 'u' for 'unknown', 'i'
4873 for 'ignored' and 'c' for clean.
4875 for 'ignored' and 'c' for clean.
4874
4876
4875 It abbreviates only those statuses which are passed. Note that clean and
4877 It abbreviates only those statuses which are passed. Note that clean and
4876 ignored files are not displayed with '--terse ic' unless the -c/--clean
4878 ignored files are not displayed with '--terse ic' unless the -c/--clean
4877 and -i/--ignored options are also used.
4879 and -i/--ignored options are also used.
4878
4880
4879 The -v/--verbose option shows information when the repository is in an
4881 The -v/--verbose option shows information when the repository is in an
4880 unfinished merge, shelve, rebase state etc. You can have this behavior
4882 unfinished merge, shelve, rebase state etc. You can have this behavior
4881 turned on by default by enabling the ``commands.status.verbose`` option.
4883 turned on by default by enabling the ``commands.status.verbose`` option.
4882
4884
4883 You can skip displaying some of these states by setting
4885 You can skip displaying some of these states by setting
4884 ``commands.status.skipstates`` to one or more of: 'bisect', 'graft',
4886 ``commands.status.skipstates`` to one or more of: 'bisect', 'graft',
4885 'histedit', 'merge', 'rebase', or 'unshelve'.
4887 'histedit', 'merge', 'rebase', or 'unshelve'.
4886
4888
4887 Examples:
4889 Examples:
4888
4890
4889 - show changes in the working directory relative to a
4891 - show changes in the working directory relative to a
4890 changeset::
4892 changeset::
4891
4893
4892 hg status --rev 9353
4894 hg status --rev 9353
4893
4895
4894 - show changes in the working directory relative to the
4896 - show changes in the working directory relative to the
4895 current directory (see :hg:`help patterns` for more information)::
4897 current directory (see :hg:`help patterns` for more information)::
4896
4898
4897 hg status re:
4899 hg status re:
4898
4900
4899 - show all changes including copies in an existing changeset::
4901 - show all changes including copies in an existing changeset::
4900
4902
4901 hg status --copies --change 9353
4903 hg status --copies --change 9353
4902
4904
4903 - get a NUL separated list of added files, suitable for xargs::
4905 - get a NUL separated list of added files, suitable for xargs::
4904
4906
4905 hg status -an0
4907 hg status -an0
4906
4908
4907 - show more information about the repository status, abbreviating
4909 - show more information about the repository status, abbreviating
4908 added, removed, modified, deleted, and untracked paths::
4910 added, removed, modified, deleted, and untracked paths::
4909
4911
4910 hg status -v -t mardu
4912 hg status -v -t mardu
4911
4913
4912 Returns 0 on success.
4914 Returns 0 on success.
4913
4915
4914 """
4916 """
4915
4917
4916 opts = pycompat.byteskwargs(opts)
4918 opts = pycompat.byteskwargs(opts)
4917 revs = opts.get('rev')
4919 revs = opts.get('rev')
4918 change = opts.get('change')
4920 change = opts.get('change')
4919 terse = opts.get('terse')
4921 terse = opts.get('terse')
4922 if terse is _NOTTERSE:
4923 if revs:
4924 terse = ''
4925 else:
4926 terse = ui.config('commands', 'status.terse')
4920
4927
4921 if revs and change:
4928 if revs and change:
4922 msg = _('cannot specify --rev and --change at the same time')
4929 msg = _('cannot specify --rev and --change at the same time')
4923 raise error.Abort(msg)
4930 raise error.Abort(msg)
4924 elif revs and terse:
4931 elif revs and terse:
4925 msg = _('cannot use --terse with --rev')
4932 msg = _('cannot use --terse with --rev')
4926 raise error.Abort(msg)
4933 raise error.Abort(msg)
4927 elif change:
4934 elif change:
4928 repo = scmutil.unhidehashlikerevs(repo, [change], 'nowarn')
4935 repo = scmutil.unhidehashlikerevs(repo, [change], 'nowarn')
4929 ctx2 = scmutil.revsingle(repo, change, None)
4936 ctx2 = scmutil.revsingle(repo, change, None)
4930 ctx1 = ctx2.p1()
4937 ctx1 = ctx2.p1()
4931 else:
4938 else:
4932 repo = scmutil.unhidehashlikerevs(repo, revs, 'nowarn')
4939 repo = scmutil.unhidehashlikerevs(repo, revs, 'nowarn')
4933 ctx1, ctx2 = scmutil.revpair(repo, revs)
4940 ctx1, ctx2 = scmutil.revpair(repo, revs)
4934
4941
4935 if pats or ui.configbool('commands', 'status.relative'):
4942 if pats or ui.configbool('commands', 'status.relative'):
4936 cwd = repo.getcwd()
4943 cwd = repo.getcwd()
4937 else:
4944 else:
4938 cwd = ''
4945 cwd = ''
4939
4946
4940 if opts.get('print0'):
4947 if opts.get('print0'):
4941 end = '\0'
4948 end = '\0'
4942 else:
4949 else:
4943 end = '\n'
4950 end = '\n'
4944 copy = {}
4951 copy = {}
4945 states = 'modified added removed deleted unknown ignored clean'.split()
4952 states = 'modified added removed deleted unknown ignored clean'.split()
4946 show = [k for k in states if opts.get(k)]
4953 show = [k for k in states if opts.get(k)]
4947 if opts.get('all'):
4954 if opts.get('all'):
4948 show += ui.quiet and (states[:4] + ['clean']) or states
4955 show += ui.quiet and (states[:4] + ['clean']) or states
4949
4956
4950 if not show:
4957 if not show:
4951 if ui.quiet:
4958 if ui.quiet:
4952 show = states[:4]
4959 show = states[:4]
4953 else:
4960 else:
4954 show = states[:5]
4961 show = states[:5]
4955
4962
4956 m = scmutil.match(ctx2, pats, opts)
4963 m = scmutil.match(ctx2, pats, opts)
4957 if terse:
4964 if terse:
4958 # we need to compute clean and unknown to terse
4965 # we need to compute clean and unknown to terse
4959 stat = repo.status(ctx1.node(), ctx2.node(), m,
4966 stat = repo.status(ctx1.node(), ctx2.node(), m,
4960 'ignored' in show or 'i' in terse,
4967 'ignored' in show or 'i' in terse,
4961 True, True, opts.get('subrepos'))
4968 True, True, opts.get('subrepos'))
4962
4969
4963 stat = cmdutil.tersedir(stat, terse)
4970 stat = cmdutil.tersedir(stat, terse)
4964 else:
4971 else:
4965 stat = repo.status(ctx1.node(), ctx2.node(), m,
4972 stat = repo.status(ctx1.node(), ctx2.node(), m,
4966 'ignored' in show, 'clean' in show,
4973 'ignored' in show, 'clean' in show,
4967 'unknown' in show, opts.get('subrepos'))
4974 'unknown' in show, opts.get('subrepos'))
4968
4975
4969 changestates = zip(states, pycompat.iterbytestr('MAR!?IC'), stat)
4976 changestates = zip(states, pycompat.iterbytestr('MAR!?IC'), stat)
4970
4977
4971 if (opts.get('all') or opts.get('copies')
4978 if (opts.get('all') or opts.get('copies')
4972 or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'):
4979 or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'):
4973 copy = copies.pathcopies(ctx1, ctx2, m)
4980 copy = copies.pathcopies(ctx1, ctx2, m)
4974
4981
4975 ui.pager('status')
4982 ui.pager('status')
4976 fm = ui.formatter('status', opts)
4983 fm = ui.formatter('status', opts)
4977 fmt = '%s' + end
4984 fmt = '%s' + end
4978 showchar = not opts.get('no_status')
4985 showchar = not opts.get('no_status')
4979
4986
4980 for state, char, files in changestates:
4987 for state, char, files in changestates:
4981 if state in show:
4988 if state in show:
4982 label = 'status.' + state
4989 label = 'status.' + state
4983 for f in files:
4990 for f in files:
4984 fm.startitem()
4991 fm.startitem()
4985 fm.condwrite(showchar, 'status', '%s ', char, label=label)
4992 fm.condwrite(showchar, 'status', '%s ', char, label=label)
4986 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
4993 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
4987 if f in copy:
4994 if f in copy:
4988 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
4995 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
4989 label='status.copied')
4996 label='status.copied')
4990
4997
4991 if ((ui.verbose or ui.configbool('commands', 'status.verbose'))
4998 if ((ui.verbose or ui.configbool('commands', 'status.verbose'))
4992 and not ui.plain()):
4999 and not ui.plain()):
4993 cmdutil.morestatus(repo, fm)
5000 cmdutil.morestatus(repo, fm)
4994 fm.end()
5001 fm.end()
4995
5002
4996 @command('^summary|sum',
5003 @command('^summary|sum',
4997 [('', 'remote', None, _('check for push and pull'))],
5004 [('', 'remote', None, _('check for push and pull'))],
4998 '[--remote]',
5005 '[--remote]',
4999 intents={INTENT_READONLY})
5006 intents={INTENT_READONLY})
5000 def summary(ui, repo, **opts):
5007 def summary(ui, repo, **opts):
5001 """summarize working directory state
5008 """summarize working directory state
5002
5009
5003 This generates a brief summary of the working directory state,
5010 This generates a brief summary of the working directory state,
5004 including parents, branch, commit status, phase and available updates.
5011 including parents, branch, commit status, phase and available updates.
5005
5012
5006 With the --remote option, this will check the default paths for
5013 With the --remote option, this will check the default paths for
5007 incoming and outgoing changes. This can be time-consuming.
5014 incoming and outgoing changes. This can be time-consuming.
5008
5015
5009 Returns 0 on success.
5016 Returns 0 on success.
5010 """
5017 """
5011
5018
5012 opts = pycompat.byteskwargs(opts)
5019 opts = pycompat.byteskwargs(opts)
5013 ui.pager('summary')
5020 ui.pager('summary')
5014 ctx = repo[None]
5021 ctx = repo[None]
5015 parents = ctx.parents()
5022 parents = ctx.parents()
5016 pnode = parents[0].node()
5023 pnode = parents[0].node()
5017 marks = []
5024 marks = []
5018
5025
5019 ms = None
5026 ms = None
5020 try:
5027 try:
5021 ms = mergemod.mergestate.read(repo)
5028 ms = mergemod.mergestate.read(repo)
5022 except error.UnsupportedMergeRecords as e:
5029 except error.UnsupportedMergeRecords as e:
5023 s = ' '.join(e.recordtypes)
5030 s = ' '.join(e.recordtypes)
5024 ui.warn(
5031 ui.warn(
5025 _('warning: merge state has unsupported record types: %s\n') % s)
5032 _('warning: merge state has unsupported record types: %s\n') % s)
5026 unresolved = []
5033 unresolved = []
5027 else:
5034 else:
5028 unresolved = list(ms.unresolved())
5035 unresolved = list(ms.unresolved())
5029
5036
5030 for p in parents:
5037 for p in parents:
5031 # label with log.changeset (instead of log.parent) since this
5038 # label with log.changeset (instead of log.parent) since this
5032 # shows a working directory parent *changeset*:
5039 # shows a working directory parent *changeset*:
5033 # i18n: column positioning for "hg summary"
5040 # i18n: column positioning for "hg summary"
5034 ui.write(_('parent: %d:%s ') % (p.rev(), p),
5041 ui.write(_('parent: %d:%s ') % (p.rev(), p),
5035 label=logcmdutil.changesetlabels(p))
5042 label=logcmdutil.changesetlabels(p))
5036 ui.write(' '.join(p.tags()), label='log.tag')
5043 ui.write(' '.join(p.tags()), label='log.tag')
5037 if p.bookmarks():
5044 if p.bookmarks():
5038 marks.extend(p.bookmarks())
5045 marks.extend(p.bookmarks())
5039 if p.rev() == -1:
5046 if p.rev() == -1:
5040 if not len(repo):
5047 if not len(repo):
5041 ui.write(_(' (empty repository)'))
5048 ui.write(_(' (empty repository)'))
5042 else:
5049 else:
5043 ui.write(_(' (no revision checked out)'))
5050 ui.write(_(' (no revision checked out)'))
5044 if p.obsolete():
5051 if p.obsolete():
5045 ui.write(_(' (obsolete)'))
5052 ui.write(_(' (obsolete)'))
5046 if p.isunstable():
5053 if p.isunstable():
5047 instabilities = (ui.label(instability, 'trouble.%s' % instability)
5054 instabilities = (ui.label(instability, 'trouble.%s' % instability)
5048 for instability in p.instabilities())
5055 for instability in p.instabilities())
5049 ui.write(' ('
5056 ui.write(' ('
5050 + ', '.join(instabilities)
5057 + ', '.join(instabilities)
5051 + ')')
5058 + ')')
5052 ui.write('\n')
5059 ui.write('\n')
5053 if p.description():
5060 if p.description():
5054 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
5061 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
5055 label='log.summary')
5062 label='log.summary')
5056
5063
5057 branch = ctx.branch()
5064 branch = ctx.branch()
5058 bheads = repo.branchheads(branch)
5065 bheads = repo.branchheads(branch)
5059 # i18n: column positioning for "hg summary"
5066 # i18n: column positioning for "hg summary"
5060 m = _('branch: %s\n') % branch
5067 m = _('branch: %s\n') % branch
5061 if branch != 'default':
5068 if branch != 'default':
5062 ui.write(m, label='log.branch')
5069 ui.write(m, label='log.branch')
5063 else:
5070 else:
5064 ui.status(m, label='log.branch')
5071 ui.status(m, label='log.branch')
5065
5072
5066 if marks:
5073 if marks:
5067 active = repo._activebookmark
5074 active = repo._activebookmark
5068 # i18n: column positioning for "hg summary"
5075 # i18n: column positioning for "hg summary"
5069 ui.write(_('bookmarks:'), label='log.bookmark')
5076 ui.write(_('bookmarks:'), label='log.bookmark')
5070 if active is not None:
5077 if active is not None:
5071 if active in marks:
5078 if active in marks:
5072 ui.write(' *' + active, label=bookmarks.activebookmarklabel)
5079 ui.write(' *' + active, label=bookmarks.activebookmarklabel)
5073 marks.remove(active)
5080 marks.remove(active)
5074 else:
5081 else:
5075 ui.write(' [%s]' % active, label=bookmarks.activebookmarklabel)
5082 ui.write(' [%s]' % active, label=bookmarks.activebookmarklabel)
5076 for m in marks:
5083 for m in marks:
5077 ui.write(' ' + m, label='log.bookmark')
5084 ui.write(' ' + m, label='log.bookmark')
5078 ui.write('\n', label='log.bookmark')
5085 ui.write('\n', label='log.bookmark')
5079
5086
5080 status = repo.status(unknown=True)
5087 status = repo.status(unknown=True)
5081
5088
5082 c = repo.dirstate.copies()
5089 c = repo.dirstate.copies()
5083 copied, renamed = [], []
5090 copied, renamed = [], []
5084 for d, s in c.iteritems():
5091 for d, s in c.iteritems():
5085 if s in status.removed:
5092 if s in status.removed:
5086 status.removed.remove(s)
5093 status.removed.remove(s)
5087 renamed.append(d)
5094 renamed.append(d)
5088 else:
5095 else:
5089 copied.append(d)
5096 copied.append(d)
5090 if d in status.added:
5097 if d in status.added:
5091 status.added.remove(d)
5098 status.added.remove(d)
5092
5099
5093 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
5100 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
5094
5101
5095 labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified),
5102 labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified),
5096 (ui.label(_('%d added'), 'status.added'), status.added),
5103 (ui.label(_('%d added'), 'status.added'), status.added),
5097 (ui.label(_('%d removed'), 'status.removed'), status.removed),
5104 (ui.label(_('%d removed'), 'status.removed'), status.removed),
5098 (ui.label(_('%d renamed'), 'status.copied'), renamed),
5105 (ui.label(_('%d renamed'), 'status.copied'), renamed),
5099 (ui.label(_('%d copied'), 'status.copied'), copied),
5106 (ui.label(_('%d copied'), 'status.copied'), copied),
5100 (ui.label(_('%d deleted'), 'status.deleted'), status.deleted),
5107 (ui.label(_('%d deleted'), 'status.deleted'), status.deleted),
5101 (ui.label(_('%d unknown'), 'status.unknown'), status.unknown),
5108 (ui.label(_('%d unknown'), 'status.unknown'), status.unknown),
5102 (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved),
5109 (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved),
5103 (ui.label(_('%d subrepos'), 'status.modified'), subs)]
5110 (ui.label(_('%d subrepos'), 'status.modified'), subs)]
5104 t = []
5111 t = []
5105 for l, s in labels:
5112 for l, s in labels:
5106 if s:
5113 if s:
5107 t.append(l % len(s))
5114 t.append(l % len(s))
5108
5115
5109 t = ', '.join(t)
5116 t = ', '.join(t)
5110 cleanworkdir = False
5117 cleanworkdir = False
5111
5118
5112 if repo.vfs.exists('graftstate'):
5119 if repo.vfs.exists('graftstate'):
5113 t += _(' (graft in progress)')
5120 t += _(' (graft in progress)')
5114 if repo.vfs.exists('updatestate'):
5121 if repo.vfs.exists('updatestate'):
5115 t += _(' (interrupted update)')
5122 t += _(' (interrupted update)')
5116 elif len(parents) > 1:
5123 elif len(parents) > 1:
5117 t += _(' (merge)')
5124 t += _(' (merge)')
5118 elif branch != parents[0].branch():
5125 elif branch != parents[0].branch():
5119 t += _(' (new branch)')
5126 t += _(' (new branch)')
5120 elif (parents[0].closesbranch() and
5127 elif (parents[0].closesbranch() and
5121 pnode in repo.branchheads(branch, closed=True)):
5128 pnode in repo.branchheads(branch, closed=True)):
5122 t += _(' (head closed)')
5129 t += _(' (head closed)')
5123 elif not (status.modified or status.added or status.removed or renamed or
5130 elif not (status.modified or status.added or status.removed or renamed or
5124 copied or subs):
5131 copied or subs):
5125 t += _(' (clean)')
5132 t += _(' (clean)')
5126 cleanworkdir = True
5133 cleanworkdir = True
5127 elif pnode not in bheads:
5134 elif pnode not in bheads:
5128 t += _(' (new branch head)')
5135 t += _(' (new branch head)')
5129
5136
5130 if parents:
5137 if parents:
5131 pendingphase = max(p.phase() for p in parents)
5138 pendingphase = max(p.phase() for p in parents)
5132 else:
5139 else:
5133 pendingphase = phases.public
5140 pendingphase = phases.public
5134
5141
5135 if pendingphase > phases.newcommitphase(ui):
5142 if pendingphase > phases.newcommitphase(ui):
5136 t += ' (%s)' % phases.phasenames[pendingphase]
5143 t += ' (%s)' % phases.phasenames[pendingphase]
5137
5144
5138 if cleanworkdir:
5145 if cleanworkdir:
5139 # i18n: column positioning for "hg summary"
5146 # i18n: column positioning for "hg summary"
5140 ui.status(_('commit: %s\n') % t.strip())
5147 ui.status(_('commit: %s\n') % t.strip())
5141 else:
5148 else:
5142 # i18n: column positioning for "hg summary"
5149 # i18n: column positioning for "hg summary"
5143 ui.write(_('commit: %s\n') % t.strip())
5150 ui.write(_('commit: %s\n') % t.strip())
5144
5151
5145 # all ancestors of branch heads - all ancestors of parent = new csets
5152 # all ancestors of branch heads - all ancestors of parent = new csets
5146 new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
5153 new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
5147 bheads))
5154 bheads))
5148
5155
5149 if new == 0:
5156 if new == 0:
5150 # i18n: column positioning for "hg summary"
5157 # i18n: column positioning for "hg summary"
5151 ui.status(_('update: (current)\n'))
5158 ui.status(_('update: (current)\n'))
5152 elif pnode not in bheads:
5159 elif pnode not in bheads:
5153 # i18n: column positioning for "hg summary"
5160 # i18n: column positioning for "hg summary"
5154 ui.write(_('update: %d new changesets (update)\n') % new)
5161 ui.write(_('update: %d new changesets (update)\n') % new)
5155 else:
5162 else:
5156 # i18n: column positioning for "hg summary"
5163 # i18n: column positioning for "hg summary"
5157 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
5164 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
5158 (new, len(bheads)))
5165 (new, len(bheads)))
5159
5166
5160 t = []
5167 t = []
5161 draft = len(repo.revs('draft()'))
5168 draft = len(repo.revs('draft()'))
5162 if draft:
5169 if draft:
5163 t.append(_('%d draft') % draft)
5170 t.append(_('%d draft') % draft)
5164 secret = len(repo.revs('secret()'))
5171 secret = len(repo.revs('secret()'))
5165 if secret:
5172 if secret:
5166 t.append(_('%d secret') % secret)
5173 t.append(_('%d secret') % secret)
5167
5174
5168 if draft or secret:
5175 if draft or secret:
5169 ui.status(_('phases: %s\n') % ', '.join(t))
5176 ui.status(_('phases: %s\n') % ', '.join(t))
5170
5177
5171 if obsolete.isenabled(repo, obsolete.createmarkersopt):
5178 if obsolete.isenabled(repo, obsolete.createmarkersopt):
5172 for trouble in ("orphan", "contentdivergent", "phasedivergent"):
5179 for trouble in ("orphan", "contentdivergent", "phasedivergent"):
5173 numtrouble = len(repo.revs(trouble + "()"))
5180 numtrouble = len(repo.revs(trouble + "()"))
5174 # We write all the possibilities to ease translation
5181 # We write all the possibilities to ease translation
5175 troublemsg = {
5182 troublemsg = {
5176 "orphan": _("orphan: %d changesets"),
5183 "orphan": _("orphan: %d changesets"),
5177 "contentdivergent": _("content-divergent: %d changesets"),
5184 "contentdivergent": _("content-divergent: %d changesets"),
5178 "phasedivergent": _("phase-divergent: %d changesets"),
5185 "phasedivergent": _("phase-divergent: %d changesets"),
5179 }
5186 }
5180 if numtrouble > 0:
5187 if numtrouble > 0:
5181 ui.status(troublemsg[trouble] % numtrouble + "\n")
5188 ui.status(troublemsg[trouble] % numtrouble + "\n")
5182
5189
5183 cmdutil.summaryhooks(ui, repo)
5190 cmdutil.summaryhooks(ui, repo)
5184
5191
5185 if opts.get('remote'):
5192 if opts.get('remote'):
5186 needsincoming, needsoutgoing = True, True
5193 needsincoming, needsoutgoing = True, True
5187 else:
5194 else:
5188 needsincoming, needsoutgoing = False, False
5195 needsincoming, needsoutgoing = False, False
5189 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
5196 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
5190 if i:
5197 if i:
5191 needsincoming = True
5198 needsincoming = True
5192 if o:
5199 if o:
5193 needsoutgoing = True
5200 needsoutgoing = True
5194 if not needsincoming and not needsoutgoing:
5201 if not needsincoming and not needsoutgoing:
5195 return
5202 return
5196
5203
5197 def getincoming():
5204 def getincoming():
5198 source, branches = hg.parseurl(ui.expandpath('default'))
5205 source, branches = hg.parseurl(ui.expandpath('default'))
5199 sbranch = branches[0]
5206 sbranch = branches[0]
5200 try:
5207 try:
5201 other = hg.peer(repo, {}, source)
5208 other = hg.peer(repo, {}, source)
5202 except error.RepoError:
5209 except error.RepoError:
5203 if opts.get('remote'):
5210 if opts.get('remote'):
5204 raise
5211 raise
5205 return source, sbranch, None, None, None
5212 return source, sbranch, None, None, None
5206 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
5213 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
5207 if revs:
5214 if revs:
5208 revs = [other.lookup(rev) for rev in revs]
5215 revs = [other.lookup(rev) for rev in revs]
5209 ui.debug('comparing with %s\n' % util.hidepassword(source))
5216 ui.debug('comparing with %s\n' % util.hidepassword(source))
5210 repo.ui.pushbuffer()
5217 repo.ui.pushbuffer()
5211 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
5218 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
5212 repo.ui.popbuffer()
5219 repo.ui.popbuffer()
5213 return source, sbranch, other, commoninc, commoninc[1]
5220 return source, sbranch, other, commoninc, commoninc[1]
5214
5221
5215 if needsincoming:
5222 if needsincoming:
5216 source, sbranch, sother, commoninc, incoming = getincoming()
5223 source, sbranch, sother, commoninc, incoming = getincoming()
5217 else:
5224 else:
5218 source = sbranch = sother = commoninc = incoming = None
5225 source = sbranch = sother = commoninc = incoming = None
5219
5226
5220 def getoutgoing():
5227 def getoutgoing():
5221 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
5228 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
5222 dbranch = branches[0]
5229 dbranch = branches[0]
5223 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
5230 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
5224 if source != dest:
5231 if source != dest:
5225 try:
5232 try:
5226 dother = hg.peer(repo, {}, dest)
5233 dother = hg.peer(repo, {}, dest)
5227 except error.RepoError:
5234 except error.RepoError:
5228 if opts.get('remote'):
5235 if opts.get('remote'):
5229 raise
5236 raise
5230 return dest, dbranch, None, None
5237 return dest, dbranch, None, None
5231 ui.debug('comparing with %s\n' % util.hidepassword(dest))
5238 ui.debug('comparing with %s\n' % util.hidepassword(dest))
5232 elif sother is None:
5239 elif sother is None:
5233 # there is no explicit destination peer, but source one is invalid
5240 # there is no explicit destination peer, but source one is invalid
5234 return dest, dbranch, None, None
5241 return dest, dbranch, None, None
5235 else:
5242 else:
5236 dother = sother
5243 dother = sother
5237 if (source != dest or (sbranch is not None and sbranch != dbranch)):
5244 if (source != dest or (sbranch is not None and sbranch != dbranch)):
5238 common = None
5245 common = None
5239 else:
5246 else:
5240 common = commoninc
5247 common = commoninc
5241 if revs:
5248 if revs:
5242 revs = [repo.lookup(rev) for rev in revs]
5249 revs = [repo.lookup(rev) for rev in revs]
5243 repo.ui.pushbuffer()
5250 repo.ui.pushbuffer()
5244 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
5251 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
5245 commoninc=common)
5252 commoninc=common)
5246 repo.ui.popbuffer()
5253 repo.ui.popbuffer()
5247 return dest, dbranch, dother, outgoing
5254 return dest, dbranch, dother, outgoing
5248
5255
5249 if needsoutgoing:
5256 if needsoutgoing:
5250 dest, dbranch, dother, outgoing = getoutgoing()
5257 dest, dbranch, dother, outgoing = getoutgoing()
5251 else:
5258 else:
5252 dest = dbranch = dother = outgoing = None
5259 dest = dbranch = dother = outgoing = None
5253
5260
5254 if opts.get('remote'):
5261 if opts.get('remote'):
5255 t = []
5262 t = []
5256 if incoming:
5263 if incoming:
5257 t.append(_('1 or more incoming'))
5264 t.append(_('1 or more incoming'))
5258 o = outgoing.missing
5265 o = outgoing.missing
5259 if o:
5266 if o:
5260 t.append(_('%d outgoing') % len(o))
5267 t.append(_('%d outgoing') % len(o))
5261 other = dother or sother
5268 other = dother or sother
5262 if 'bookmarks' in other.listkeys('namespaces'):
5269 if 'bookmarks' in other.listkeys('namespaces'):
5263 counts = bookmarks.summary(repo, other)
5270 counts = bookmarks.summary(repo, other)
5264 if counts[0] > 0:
5271 if counts[0] > 0:
5265 t.append(_('%d incoming bookmarks') % counts[0])
5272 t.append(_('%d incoming bookmarks') % counts[0])
5266 if counts[1] > 0:
5273 if counts[1] > 0:
5267 t.append(_('%d outgoing bookmarks') % counts[1])
5274 t.append(_('%d outgoing bookmarks') % counts[1])
5268
5275
5269 if t:
5276 if t:
5270 # i18n: column positioning for "hg summary"
5277 # i18n: column positioning for "hg summary"
5271 ui.write(_('remote: %s\n') % (', '.join(t)))
5278 ui.write(_('remote: %s\n') % (', '.join(t)))
5272 else:
5279 else:
5273 # i18n: column positioning for "hg summary"
5280 # i18n: column positioning for "hg summary"
5274 ui.status(_('remote: (synced)\n'))
5281 ui.status(_('remote: (synced)\n'))
5275
5282
5276 cmdutil.summaryremotehooks(ui, repo, opts,
5283 cmdutil.summaryremotehooks(ui, repo, opts,
5277 ((source, sbranch, sother, commoninc),
5284 ((source, sbranch, sother, commoninc),
5278 (dest, dbranch, dother, outgoing)))
5285 (dest, dbranch, dother, outgoing)))
5279
5286
5280 @command('tag',
5287 @command('tag',
5281 [('f', 'force', None, _('force tag')),
5288 [('f', 'force', None, _('force tag')),
5282 ('l', 'local', None, _('make the tag local')),
5289 ('l', 'local', None, _('make the tag local')),
5283 ('r', 'rev', '', _('revision to tag'), _('REV')),
5290 ('r', 'rev', '', _('revision to tag'), _('REV')),
5284 ('', 'remove', None, _('remove a tag')),
5291 ('', 'remove', None, _('remove a tag')),
5285 # -l/--local is already there, commitopts cannot be used
5292 # -l/--local is already there, commitopts cannot be used
5286 ('e', 'edit', None, _('invoke editor on commit messages')),
5293 ('e', 'edit', None, _('invoke editor on commit messages')),
5287 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
5294 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
5288 ] + commitopts2,
5295 ] + commitopts2,
5289 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
5296 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
5290 def tag(ui, repo, name1, *names, **opts):
5297 def tag(ui, repo, name1, *names, **opts):
5291 """add one or more tags for the current or given revision
5298 """add one or more tags for the current or given revision
5292
5299
5293 Name a particular revision using <name>.
5300 Name a particular revision using <name>.
5294
5301
5295 Tags are used to name particular revisions of the repository and are
5302 Tags are used to name particular revisions of the repository and are
5296 very useful to compare different revisions, to go back to significant
5303 very useful to compare different revisions, to go back to significant
5297 earlier versions or to mark branch points as releases, etc. Changing
5304 earlier versions or to mark branch points as releases, etc. Changing
5298 an existing tag is normally disallowed; use -f/--force to override.
5305 an existing tag is normally disallowed; use -f/--force to override.
5299
5306
5300 If no revision is given, the parent of the working directory is
5307 If no revision is given, the parent of the working directory is
5301 used.
5308 used.
5302
5309
5303 To facilitate version control, distribution, and merging of tags,
5310 To facilitate version control, distribution, and merging of tags,
5304 they are stored as a file named ".hgtags" which is managed similarly
5311 they are stored as a file named ".hgtags" which is managed similarly
5305 to other project files and can be hand-edited if necessary. This
5312 to other project files and can be hand-edited if necessary. This
5306 also means that tagging creates a new commit. The file
5313 also means that tagging creates a new commit. The file
5307 ".hg/localtags" is used for local tags (not shared among
5314 ".hg/localtags" is used for local tags (not shared among
5308 repositories).
5315 repositories).
5309
5316
5310 Tag commits are usually made at the head of a branch. If the parent
5317 Tag commits are usually made at the head of a branch. If the parent
5311 of the working directory is not a branch head, :hg:`tag` aborts; use
5318 of the working directory is not a branch head, :hg:`tag` aborts; use
5312 -f/--force to force the tag commit to be based on a non-head
5319 -f/--force to force the tag commit to be based on a non-head
5313 changeset.
5320 changeset.
5314
5321
5315 See :hg:`help dates` for a list of formats valid for -d/--date.
5322 See :hg:`help dates` for a list of formats valid for -d/--date.
5316
5323
5317 Since tag names have priority over branch names during revision
5324 Since tag names have priority over branch names during revision
5318 lookup, using an existing branch name as a tag name is discouraged.
5325 lookup, using an existing branch name as a tag name is discouraged.
5319
5326
5320 Returns 0 on success.
5327 Returns 0 on success.
5321 """
5328 """
5322 opts = pycompat.byteskwargs(opts)
5329 opts = pycompat.byteskwargs(opts)
5323 wlock = lock = None
5330 wlock = lock = None
5324 try:
5331 try:
5325 wlock = repo.wlock()
5332 wlock = repo.wlock()
5326 lock = repo.lock()
5333 lock = repo.lock()
5327 rev_ = "."
5334 rev_ = "."
5328 names = [t.strip() for t in (name1,) + names]
5335 names = [t.strip() for t in (name1,) + names]
5329 if len(names) != len(set(names)):
5336 if len(names) != len(set(names)):
5330 raise error.Abort(_('tag names must be unique'))
5337 raise error.Abort(_('tag names must be unique'))
5331 for n in names:
5338 for n in names:
5332 scmutil.checknewlabel(repo, n, 'tag')
5339 scmutil.checknewlabel(repo, n, 'tag')
5333 if not n:
5340 if not n:
5334 raise error.Abort(_('tag names cannot consist entirely of '
5341 raise error.Abort(_('tag names cannot consist entirely of '
5335 'whitespace'))
5342 'whitespace'))
5336 if opts.get('rev') and opts.get('remove'):
5343 if opts.get('rev') and opts.get('remove'):
5337 raise error.Abort(_("--rev and --remove are incompatible"))
5344 raise error.Abort(_("--rev and --remove are incompatible"))
5338 if opts.get('rev'):
5345 if opts.get('rev'):
5339 rev_ = opts['rev']
5346 rev_ = opts['rev']
5340 message = opts.get('message')
5347 message = opts.get('message')
5341 if opts.get('remove'):
5348 if opts.get('remove'):
5342 if opts.get('local'):
5349 if opts.get('local'):
5343 expectedtype = 'local'
5350 expectedtype = 'local'
5344 else:
5351 else:
5345 expectedtype = 'global'
5352 expectedtype = 'global'
5346
5353
5347 for n in names:
5354 for n in names:
5348 if not repo.tagtype(n):
5355 if not repo.tagtype(n):
5349 raise error.Abort(_("tag '%s' does not exist") % n)
5356 raise error.Abort(_("tag '%s' does not exist") % n)
5350 if repo.tagtype(n) != expectedtype:
5357 if repo.tagtype(n) != expectedtype:
5351 if expectedtype == 'global':
5358 if expectedtype == 'global':
5352 raise error.Abort(_("tag '%s' is not a global tag") % n)
5359 raise error.Abort(_("tag '%s' is not a global tag") % n)
5353 else:
5360 else:
5354 raise error.Abort(_("tag '%s' is not a local tag") % n)
5361 raise error.Abort(_("tag '%s' is not a local tag") % n)
5355 rev_ = 'null'
5362 rev_ = 'null'
5356 if not message:
5363 if not message:
5357 # we don't translate commit messages
5364 # we don't translate commit messages
5358 message = 'Removed tag %s' % ', '.join(names)
5365 message = 'Removed tag %s' % ', '.join(names)
5359 elif not opts.get('force'):
5366 elif not opts.get('force'):
5360 for n in names:
5367 for n in names:
5361 if n in repo.tags():
5368 if n in repo.tags():
5362 raise error.Abort(_("tag '%s' already exists "
5369 raise error.Abort(_("tag '%s' already exists "
5363 "(use -f to force)") % n)
5370 "(use -f to force)") % n)
5364 if not opts.get('local'):
5371 if not opts.get('local'):
5365 p1, p2 = repo.dirstate.parents()
5372 p1, p2 = repo.dirstate.parents()
5366 if p2 != nullid:
5373 if p2 != nullid:
5367 raise error.Abort(_('uncommitted merge'))
5374 raise error.Abort(_('uncommitted merge'))
5368 bheads = repo.branchheads()
5375 bheads = repo.branchheads()
5369 if not opts.get('force') and bheads and p1 not in bheads:
5376 if not opts.get('force') and bheads and p1 not in bheads:
5370 raise error.Abort(_('working directory is not at a branch head '
5377 raise error.Abort(_('working directory is not at a branch head '
5371 '(use -f to force)'))
5378 '(use -f to force)'))
5372 node = scmutil.revsingle(repo, rev_).node()
5379 node = scmutil.revsingle(repo, rev_).node()
5373
5380
5374 if not message:
5381 if not message:
5375 # we don't translate commit messages
5382 # we don't translate commit messages
5376 message = ('Added tag %s for changeset %s' %
5383 message = ('Added tag %s for changeset %s' %
5377 (', '.join(names), short(node)))
5384 (', '.join(names), short(node)))
5378
5385
5379 date = opts.get('date')
5386 date = opts.get('date')
5380 if date:
5387 if date:
5381 date = dateutil.parsedate(date)
5388 date = dateutil.parsedate(date)
5382
5389
5383 if opts.get('remove'):
5390 if opts.get('remove'):
5384 editform = 'tag.remove'
5391 editform = 'tag.remove'
5385 else:
5392 else:
5386 editform = 'tag.add'
5393 editform = 'tag.add'
5387 editor = cmdutil.getcommiteditor(editform=editform,
5394 editor = cmdutil.getcommiteditor(editform=editform,
5388 **pycompat.strkwargs(opts))
5395 **pycompat.strkwargs(opts))
5389
5396
5390 # don't allow tagging the null rev
5397 # don't allow tagging the null rev
5391 if (not opts.get('remove') and
5398 if (not opts.get('remove') and
5392 scmutil.revsingle(repo, rev_).rev() == nullrev):
5399 scmutil.revsingle(repo, rev_).rev() == nullrev):
5393 raise error.Abort(_("cannot tag null revision"))
5400 raise error.Abort(_("cannot tag null revision"))
5394
5401
5395 tagsmod.tag(repo, names, node, message, opts.get('local'),
5402 tagsmod.tag(repo, names, node, message, opts.get('local'),
5396 opts.get('user'), date, editor=editor)
5403 opts.get('user'), date, editor=editor)
5397 finally:
5404 finally:
5398 release(lock, wlock)
5405 release(lock, wlock)
5399
5406
5400 @command('tags', formatteropts, '', intents={INTENT_READONLY})
5407 @command('tags', formatteropts, '', intents={INTENT_READONLY})
5401 def tags(ui, repo, **opts):
5408 def tags(ui, repo, **opts):
5402 """list repository tags
5409 """list repository tags
5403
5410
5404 This lists both regular and local tags. When the -v/--verbose
5411 This lists both regular and local tags. When the -v/--verbose
5405 switch is used, a third column "local" is printed for local tags.
5412 switch is used, a third column "local" is printed for local tags.
5406 When the -q/--quiet switch is used, only the tag name is printed.
5413 When the -q/--quiet switch is used, only the tag name is printed.
5407
5414
5408 Returns 0 on success.
5415 Returns 0 on success.
5409 """
5416 """
5410
5417
5411 opts = pycompat.byteskwargs(opts)
5418 opts = pycompat.byteskwargs(opts)
5412 ui.pager('tags')
5419 ui.pager('tags')
5413 fm = ui.formatter('tags', opts)
5420 fm = ui.formatter('tags', opts)
5414 hexfunc = fm.hexfunc
5421 hexfunc = fm.hexfunc
5415 tagtype = ""
5422 tagtype = ""
5416
5423
5417 for t, n in reversed(repo.tagslist()):
5424 for t, n in reversed(repo.tagslist()):
5418 hn = hexfunc(n)
5425 hn = hexfunc(n)
5419 label = 'tags.normal'
5426 label = 'tags.normal'
5420 tagtype = ''
5427 tagtype = ''
5421 if repo.tagtype(t) == 'local':
5428 if repo.tagtype(t) == 'local':
5422 label = 'tags.local'
5429 label = 'tags.local'
5423 tagtype = 'local'
5430 tagtype = 'local'
5424
5431
5425 fm.startitem()
5432 fm.startitem()
5426 fm.write('tag', '%s', t, label=label)
5433 fm.write('tag', '%s', t, label=label)
5427 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
5434 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
5428 fm.condwrite(not ui.quiet, 'rev node', fmt,
5435 fm.condwrite(not ui.quiet, 'rev node', fmt,
5429 repo.changelog.rev(n), hn, label=label)
5436 repo.changelog.rev(n), hn, label=label)
5430 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
5437 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
5431 tagtype, label=label)
5438 tagtype, label=label)
5432 fm.plain('\n')
5439 fm.plain('\n')
5433 fm.end()
5440 fm.end()
5434
5441
5435 @command('tip',
5442 @command('tip',
5436 [('p', 'patch', None, _('show patch')),
5443 [('p', 'patch', None, _('show patch')),
5437 ('g', 'git', None, _('use git extended diff format')),
5444 ('g', 'git', None, _('use git extended diff format')),
5438 ] + templateopts,
5445 ] + templateopts,
5439 _('[-p] [-g]'))
5446 _('[-p] [-g]'))
5440 def tip(ui, repo, **opts):
5447 def tip(ui, repo, **opts):
5441 """show the tip revision (DEPRECATED)
5448 """show the tip revision (DEPRECATED)
5442
5449
5443 The tip revision (usually just called the tip) is the changeset
5450 The tip revision (usually just called the tip) is the changeset
5444 most recently added to the repository (and therefore the most
5451 most recently added to the repository (and therefore the most
5445 recently changed head).
5452 recently changed head).
5446
5453
5447 If you have just made a commit, that commit will be the tip. If
5454 If you have just made a commit, that commit will be the tip. If
5448 you have just pulled changes from another repository, the tip of
5455 you have just pulled changes from another repository, the tip of
5449 that repository becomes the current tip. The "tip" tag is special
5456 that repository becomes the current tip. The "tip" tag is special
5450 and cannot be renamed or assigned to a different changeset.
5457 and cannot be renamed or assigned to a different changeset.
5451
5458
5452 This command is deprecated, please use :hg:`heads` instead.
5459 This command is deprecated, please use :hg:`heads` instead.
5453
5460
5454 Returns 0 on success.
5461 Returns 0 on success.
5455 """
5462 """
5456 opts = pycompat.byteskwargs(opts)
5463 opts = pycompat.byteskwargs(opts)
5457 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
5464 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
5458 displayer.show(repo['tip'])
5465 displayer.show(repo['tip'])
5459 displayer.close()
5466 displayer.close()
5460
5467
5461 @command('unbundle',
5468 @command('unbundle',
5462 [('u', 'update', None,
5469 [('u', 'update', None,
5463 _('update to new branch head if changesets were unbundled'))],
5470 _('update to new branch head if changesets were unbundled'))],
5464 _('[-u] FILE...'))
5471 _('[-u] FILE...'))
5465 def unbundle(ui, repo, fname1, *fnames, **opts):
5472 def unbundle(ui, repo, fname1, *fnames, **opts):
5466 """apply one or more bundle files
5473 """apply one or more bundle files
5467
5474
5468 Apply one or more bundle files generated by :hg:`bundle`.
5475 Apply one or more bundle files generated by :hg:`bundle`.
5469
5476
5470 Returns 0 on success, 1 if an update has unresolved files.
5477 Returns 0 on success, 1 if an update has unresolved files.
5471 """
5478 """
5472 fnames = (fname1,) + fnames
5479 fnames = (fname1,) + fnames
5473
5480
5474 with repo.lock():
5481 with repo.lock():
5475 for fname in fnames:
5482 for fname in fnames:
5476 f = hg.openpath(ui, fname)
5483 f = hg.openpath(ui, fname)
5477 gen = exchange.readbundle(ui, f, fname)
5484 gen = exchange.readbundle(ui, f, fname)
5478 if isinstance(gen, streamclone.streamcloneapplier):
5485 if isinstance(gen, streamclone.streamcloneapplier):
5479 raise error.Abort(
5486 raise error.Abort(
5480 _('packed bundles cannot be applied with '
5487 _('packed bundles cannot be applied with '
5481 '"hg unbundle"'),
5488 '"hg unbundle"'),
5482 hint=_('use "hg debugapplystreamclonebundle"'))
5489 hint=_('use "hg debugapplystreamclonebundle"'))
5483 url = 'bundle:' + fname
5490 url = 'bundle:' + fname
5484 try:
5491 try:
5485 txnname = 'unbundle'
5492 txnname = 'unbundle'
5486 if not isinstance(gen, bundle2.unbundle20):
5493 if not isinstance(gen, bundle2.unbundle20):
5487 txnname = 'unbundle\n%s' % util.hidepassword(url)
5494 txnname = 'unbundle\n%s' % util.hidepassword(url)
5488 with repo.transaction(txnname) as tr:
5495 with repo.transaction(txnname) as tr:
5489 op = bundle2.applybundle(repo, gen, tr, source='unbundle',
5496 op = bundle2.applybundle(repo, gen, tr, source='unbundle',
5490 url=url)
5497 url=url)
5491 except error.BundleUnknownFeatureError as exc:
5498 except error.BundleUnknownFeatureError as exc:
5492 raise error.Abort(
5499 raise error.Abort(
5493 _('%s: unknown bundle feature, %s') % (fname, exc),
5500 _('%s: unknown bundle feature, %s') % (fname, exc),
5494 hint=_("see https://mercurial-scm.org/"
5501 hint=_("see https://mercurial-scm.org/"
5495 "wiki/BundleFeature for more "
5502 "wiki/BundleFeature for more "
5496 "information"))
5503 "information"))
5497 modheads = bundle2.combinechangegroupresults(op)
5504 modheads = bundle2.combinechangegroupresults(op)
5498
5505
5499 return postincoming(ui, repo, modheads, opts.get(r'update'), None, None)
5506 return postincoming(ui, repo, modheads, opts.get(r'update'), None, None)
5500
5507
5501 @command('^update|up|checkout|co',
5508 @command('^update|up|checkout|co',
5502 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
5509 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
5503 ('c', 'check', None, _('require clean working directory')),
5510 ('c', 'check', None, _('require clean working directory')),
5504 ('m', 'merge', None, _('merge uncommitted changes')),
5511 ('m', 'merge', None, _('merge uncommitted changes')),
5505 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5512 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5506 ('r', 'rev', '', _('revision'), _('REV'))
5513 ('r', 'rev', '', _('revision'), _('REV'))
5507 ] + mergetoolopts,
5514 ] + mergetoolopts,
5508 _('[-C|-c|-m] [-d DATE] [[-r] REV]'))
5515 _('[-C|-c|-m] [-d DATE] [[-r] REV]'))
5509 def update(ui, repo, node=None, **opts):
5516 def update(ui, repo, node=None, **opts):
5510 """update working directory (or switch revisions)
5517 """update working directory (or switch revisions)
5511
5518
5512 Update the repository's working directory to the specified
5519 Update the repository's working directory to the specified
5513 changeset. If no changeset is specified, update to the tip of the
5520 changeset. If no changeset is specified, update to the tip of the
5514 current named branch and move the active bookmark (see :hg:`help
5521 current named branch and move the active bookmark (see :hg:`help
5515 bookmarks`).
5522 bookmarks`).
5516
5523
5517 Update sets the working directory's parent revision to the specified
5524 Update sets the working directory's parent revision to the specified
5518 changeset (see :hg:`help parents`).
5525 changeset (see :hg:`help parents`).
5519
5526
5520 If the changeset is not a descendant or ancestor of the working
5527 If the changeset is not a descendant or ancestor of the working
5521 directory's parent and there are uncommitted changes, the update is
5528 directory's parent and there are uncommitted changes, the update is
5522 aborted. With the -c/--check option, the working directory is checked
5529 aborted. With the -c/--check option, the working directory is checked
5523 for uncommitted changes; if none are found, the working directory is
5530 for uncommitted changes; if none are found, the working directory is
5524 updated to the specified changeset.
5531 updated to the specified changeset.
5525
5532
5526 .. container:: verbose
5533 .. container:: verbose
5527
5534
5528 The -C/--clean, -c/--check, and -m/--merge options control what
5535 The -C/--clean, -c/--check, and -m/--merge options control what
5529 happens if the working directory contains uncommitted changes.
5536 happens if the working directory contains uncommitted changes.
5530 At most of one of them can be specified.
5537 At most of one of them can be specified.
5531
5538
5532 1. If no option is specified, and if
5539 1. If no option is specified, and if
5533 the requested changeset is an ancestor or descendant of
5540 the requested changeset is an ancestor or descendant of
5534 the working directory's parent, the uncommitted changes
5541 the working directory's parent, the uncommitted changes
5535 are merged into the requested changeset and the merged
5542 are merged into the requested changeset and the merged
5536 result is left uncommitted. If the requested changeset is
5543 result is left uncommitted. If the requested changeset is
5537 not an ancestor or descendant (that is, it is on another
5544 not an ancestor or descendant (that is, it is on another
5538 branch), the update is aborted and the uncommitted changes
5545 branch), the update is aborted and the uncommitted changes
5539 are preserved.
5546 are preserved.
5540
5547
5541 2. With the -m/--merge option, the update is allowed even if the
5548 2. With the -m/--merge option, the update is allowed even if the
5542 requested changeset is not an ancestor or descendant of
5549 requested changeset is not an ancestor or descendant of
5543 the working directory's parent.
5550 the working directory's parent.
5544
5551
5545 3. With the -c/--check option, the update is aborted and the
5552 3. With the -c/--check option, the update is aborted and the
5546 uncommitted changes are preserved.
5553 uncommitted changes are preserved.
5547
5554
5548 4. With the -C/--clean option, uncommitted changes are discarded and
5555 4. With the -C/--clean option, uncommitted changes are discarded and
5549 the working directory is updated to the requested changeset.
5556 the working directory is updated to the requested changeset.
5550
5557
5551 To cancel an uncommitted merge (and lose your changes), use
5558 To cancel an uncommitted merge (and lose your changes), use
5552 :hg:`merge --abort`.
5559 :hg:`merge --abort`.
5553
5560
5554 Use null as the changeset to remove the working directory (like
5561 Use null as the changeset to remove the working directory (like
5555 :hg:`clone -U`).
5562 :hg:`clone -U`).
5556
5563
5557 If you want to revert just one file to an older revision, use
5564 If you want to revert just one file to an older revision, use
5558 :hg:`revert [-r REV] NAME`.
5565 :hg:`revert [-r REV] NAME`.
5559
5566
5560 See :hg:`help dates` for a list of formats valid for -d/--date.
5567 See :hg:`help dates` for a list of formats valid for -d/--date.
5561
5568
5562 Returns 0 on success, 1 if there are unresolved files.
5569 Returns 0 on success, 1 if there are unresolved files.
5563 """
5570 """
5564 rev = opts.get(r'rev')
5571 rev = opts.get(r'rev')
5565 date = opts.get(r'date')
5572 date = opts.get(r'date')
5566 clean = opts.get(r'clean')
5573 clean = opts.get(r'clean')
5567 check = opts.get(r'check')
5574 check = opts.get(r'check')
5568 merge = opts.get(r'merge')
5575 merge = opts.get(r'merge')
5569 if rev and node:
5576 if rev and node:
5570 raise error.Abort(_("please specify just one revision"))
5577 raise error.Abort(_("please specify just one revision"))
5571
5578
5572 if ui.configbool('commands', 'update.requiredest'):
5579 if ui.configbool('commands', 'update.requiredest'):
5573 if not node and not rev and not date:
5580 if not node and not rev and not date:
5574 raise error.Abort(_('you must specify a destination'),
5581 raise error.Abort(_('you must specify a destination'),
5575 hint=_('for example: hg update ".::"'))
5582 hint=_('for example: hg update ".::"'))
5576
5583
5577 if rev is None or rev == '':
5584 if rev is None or rev == '':
5578 rev = node
5585 rev = node
5579
5586
5580 if date and rev is not None:
5587 if date and rev is not None:
5581 raise error.Abort(_("you can't specify a revision and a date"))
5588 raise error.Abort(_("you can't specify a revision and a date"))
5582
5589
5583 if len([x for x in (clean, check, merge) if x]) > 1:
5590 if len([x for x in (clean, check, merge) if x]) > 1:
5584 raise error.Abort(_("can only specify one of -C/--clean, -c/--check, "
5591 raise error.Abort(_("can only specify one of -C/--clean, -c/--check, "
5585 "or -m/--merge"))
5592 "or -m/--merge"))
5586
5593
5587 updatecheck = None
5594 updatecheck = None
5588 if check:
5595 if check:
5589 updatecheck = 'abort'
5596 updatecheck = 'abort'
5590 elif merge:
5597 elif merge:
5591 updatecheck = 'none'
5598 updatecheck = 'none'
5592
5599
5593 with repo.wlock():
5600 with repo.wlock():
5594 cmdutil.clearunfinished(repo)
5601 cmdutil.clearunfinished(repo)
5595
5602
5596 if date:
5603 if date:
5597 rev = cmdutil.finddate(ui, repo, date)
5604 rev = cmdutil.finddate(ui, repo, date)
5598
5605
5599 # if we defined a bookmark, we have to remember the original name
5606 # if we defined a bookmark, we have to remember the original name
5600 brev = rev
5607 brev = rev
5601 if rev:
5608 if rev:
5602 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
5609 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
5603 ctx = scmutil.revsingle(repo, rev, rev)
5610 ctx = scmutil.revsingle(repo, rev, rev)
5604 rev = ctx.rev()
5611 rev = ctx.rev()
5605 hidden = ctx.hidden()
5612 hidden = ctx.hidden()
5606 repo.ui.setconfig('ui', 'forcemerge', opts.get(r'tool'), 'update')
5613 repo.ui.setconfig('ui', 'forcemerge', opts.get(r'tool'), 'update')
5607
5614
5608 ret = hg.updatetotally(ui, repo, rev, brev, clean=clean,
5615 ret = hg.updatetotally(ui, repo, rev, brev, clean=clean,
5609 updatecheck=updatecheck)
5616 updatecheck=updatecheck)
5610 if hidden:
5617 if hidden:
5611 ctxstr = ctx.hex()[:12]
5618 ctxstr = ctx.hex()[:12]
5612 ui.warn(_("updated to hidden changeset %s\n") % ctxstr)
5619 ui.warn(_("updated to hidden changeset %s\n") % ctxstr)
5613
5620
5614 if ctx.obsolete():
5621 if ctx.obsolete():
5615 obsfatemsg = obsutil._getfilteredreason(repo, ctxstr, ctx)
5622 obsfatemsg = obsutil._getfilteredreason(repo, ctxstr, ctx)
5616 ui.warn("(%s)\n" % obsfatemsg)
5623 ui.warn("(%s)\n" % obsfatemsg)
5617 return ret
5624 return ret
5618
5625
5619 @command('verify', [])
5626 @command('verify', [])
5620 def verify(ui, repo):
5627 def verify(ui, repo):
5621 """verify the integrity of the repository
5628 """verify the integrity of the repository
5622
5629
5623 Verify the integrity of the current repository.
5630 Verify the integrity of the current repository.
5624
5631
5625 This will perform an extensive check of the repository's
5632 This will perform an extensive check of the repository's
5626 integrity, validating the hashes and checksums of each entry in
5633 integrity, validating the hashes and checksums of each entry in
5627 the changelog, manifest, and tracked files, as well as the
5634 the changelog, manifest, and tracked files, as well as the
5628 integrity of their crosslinks and indices.
5635 integrity of their crosslinks and indices.
5629
5636
5630 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
5637 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
5631 for more information about recovery from corruption of the
5638 for more information about recovery from corruption of the
5632 repository.
5639 repository.
5633
5640
5634 Returns 0 on success, 1 if errors are encountered.
5641 Returns 0 on success, 1 if errors are encountered.
5635 """
5642 """
5636 return hg.verify(repo)
5643 return hg.verify(repo)
5637
5644
5638 @command('version', [] + formatteropts, norepo=True,
5645 @command('version', [] + formatteropts, norepo=True,
5639 intents={INTENT_READONLY})
5646 intents={INTENT_READONLY})
5640 def version_(ui, **opts):
5647 def version_(ui, **opts):
5641 """output version and copyright information"""
5648 """output version and copyright information"""
5642 opts = pycompat.byteskwargs(opts)
5649 opts = pycompat.byteskwargs(opts)
5643 if ui.verbose:
5650 if ui.verbose:
5644 ui.pager('version')
5651 ui.pager('version')
5645 fm = ui.formatter("version", opts)
5652 fm = ui.formatter("version", opts)
5646 fm.startitem()
5653 fm.startitem()
5647 fm.write("ver", _("Mercurial Distributed SCM (version %s)\n"),
5654 fm.write("ver", _("Mercurial Distributed SCM (version %s)\n"),
5648 util.version())
5655 util.version())
5649 license = _(
5656 license = _(
5650 "(see https://mercurial-scm.org for more information)\n"
5657 "(see https://mercurial-scm.org for more information)\n"
5651 "\nCopyright (C) 2005-2018 Matt Mackall and others\n"
5658 "\nCopyright (C) 2005-2018 Matt Mackall and others\n"
5652 "This is free software; see the source for copying conditions. "
5659 "This is free software; see the source for copying conditions. "
5653 "There is NO\nwarranty; "
5660 "There is NO\nwarranty; "
5654 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
5661 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
5655 )
5662 )
5656 if not ui.quiet:
5663 if not ui.quiet:
5657 fm.plain(license)
5664 fm.plain(license)
5658
5665
5659 if ui.verbose:
5666 if ui.verbose:
5660 fm.plain(_("\nEnabled extensions:\n\n"))
5667 fm.plain(_("\nEnabled extensions:\n\n"))
5661 # format names and versions into columns
5668 # format names and versions into columns
5662 names = []
5669 names = []
5663 vers = []
5670 vers = []
5664 isinternals = []
5671 isinternals = []
5665 for name, module in extensions.extensions():
5672 for name, module in extensions.extensions():
5666 names.append(name)
5673 names.append(name)
5667 vers.append(extensions.moduleversion(module) or None)
5674 vers.append(extensions.moduleversion(module) or None)
5668 isinternals.append(extensions.ismoduleinternal(module))
5675 isinternals.append(extensions.ismoduleinternal(module))
5669 fn = fm.nested("extensions", tmpl='{name}\n')
5676 fn = fm.nested("extensions", tmpl='{name}\n')
5670 if names:
5677 if names:
5671 namefmt = " %%-%ds " % max(len(n) for n in names)
5678 namefmt = " %%-%ds " % max(len(n) for n in names)
5672 places = [_("external"), _("internal")]
5679 places = [_("external"), _("internal")]
5673 for n, v, p in zip(names, vers, isinternals):
5680 for n, v, p in zip(names, vers, isinternals):
5674 fn.startitem()
5681 fn.startitem()
5675 fn.condwrite(ui.verbose, "name", namefmt, n)
5682 fn.condwrite(ui.verbose, "name", namefmt, n)
5676 if ui.verbose:
5683 if ui.verbose:
5677 fn.plain("%s " % places[p])
5684 fn.plain("%s " % places[p])
5678 fn.data(bundled=p)
5685 fn.data(bundled=p)
5679 fn.condwrite(ui.verbose and v, "ver", "%s", v)
5686 fn.condwrite(ui.verbose and v, "ver", "%s", v)
5680 if ui.verbose:
5687 if ui.verbose:
5681 fn.plain("\n")
5688 fn.plain("\n")
5682 fn.end()
5689 fn.end()
5683 fm.end()
5690 fm.end()
5684
5691
5685 def loadcmdtable(ui, name, cmdtable):
5692 def loadcmdtable(ui, name, cmdtable):
5686 """Load command functions from specified cmdtable
5693 """Load command functions from specified cmdtable
5687 """
5694 """
5688 overrides = [cmd for cmd in cmdtable if cmd in table]
5695 overrides = [cmd for cmd in cmdtable if cmd in table]
5689 if overrides:
5696 if overrides:
5690 ui.warn(_("extension '%s' overrides commands: %s\n")
5697 ui.warn(_("extension '%s' overrides commands: %s\n")
5691 % (name, " ".join(overrides)))
5698 % (name, " ".join(overrides)))
5692 table.update(cmdtable)
5699 table.update(cmdtable)
@@ -1,1344 +1,1347 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 def loadconfigtable(ui, extname, configtable):
18 def loadconfigtable(ui, extname, configtable):
19 """update config item known to the ui with the extension ones"""
19 """update config item known to the ui with the extension ones"""
20 for section, items in sorted(configtable.items()):
20 for section, items in sorted(configtable.items()):
21 knownitems = ui._knownconfig.setdefault(section, itemregister())
21 knownitems = ui._knownconfig.setdefault(section, itemregister())
22 knownkeys = set(knownitems)
22 knownkeys = set(knownitems)
23 newkeys = set(items)
23 newkeys = set(items)
24 for key in sorted(knownkeys & newkeys):
24 for key in sorted(knownkeys & newkeys):
25 msg = "extension '%s' overwrite config item '%s.%s'"
25 msg = "extension '%s' overwrite config item '%s.%s'"
26 msg %= (extname, section, key)
26 msg %= (extname, section, key)
27 ui.develwarn(msg, config='warn-config')
27 ui.develwarn(msg, config='warn-config')
28
28
29 knownitems.update(items)
29 knownitems.update(items)
30
30
31 class configitem(object):
31 class configitem(object):
32 """represent a known config item
32 """represent a known config item
33
33
34 :section: the official config section where to find this item,
34 :section: the official config section where to find this item,
35 :name: the official name within the section,
35 :name: the official name within the section,
36 :default: default value for this item,
36 :default: default value for this item,
37 :alias: optional list of tuples as alternatives,
37 :alias: optional list of tuples as alternatives,
38 :generic: this is a generic definition, match name using regular expression.
38 :generic: this is a generic definition, match name using regular expression.
39 """
39 """
40
40
41 def __init__(self, section, name, default=None, alias=(),
41 def __init__(self, section, name, default=None, alias=(),
42 generic=False, priority=0):
42 generic=False, priority=0):
43 self.section = section
43 self.section = section
44 self.name = name
44 self.name = name
45 self.default = default
45 self.default = default
46 self.alias = list(alias)
46 self.alias = list(alias)
47 self.generic = generic
47 self.generic = generic
48 self.priority = priority
48 self.priority = priority
49 self._re = None
49 self._re = None
50 if generic:
50 if generic:
51 self._re = re.compile(self.name)
51 self._re = re.compile(self.name)
52
52
53 class itemregister(dict):
53 class itemregister(dict):
54 """A specialized dictionary that can handle wild-card selection"""
54 """A specialized dictionary that can handle wild-card selection"""
55
55
56 def __init__(self):
56 def __init__(self):
57 super(itemregister, self).__init__()
57 super(itemregister, self).__init__()
58 self._generics = set()
58 self._generics = set()
59
59
60 def update(self, other):
60 def update(self, other):
61 super(itemregister, self).update(other)
61 super(itemregister, self).update(other)
62 self._generics.update(other._generics)
62 self._generics.update(other._generics)
63
63
64 def __setitem__(self, key, item):
64 def __setitem__(self, key, item):
65 super(itemregister, self).__setitem__(key, item)
65 super(itemregister, self).__setitem__(key, item)
66 if item.generic:
66 if item.generic:
67 self._generics.add(item)
67 self._generics.add(item)
68
68
69 def get(self, key):
69 def get(self, key):
70 baseitem = super(itemregister, self).get(key)
70 baseitem = super(itemregister, self).get(key)
71 if baseitem is not None and not baseitem.generic:
71 if baseitem is not None and not baseitem.generic:
72 return baseitem
72 return baseitem
73
73
74 # search for a matching generic item
74 # search for a matching generic item
75 generics = sorted(self._generics, key=(lambda x: (x.priority, x.name)))
75 generics = sorted(self._generics, key=(lambda x: (x.priority, x.name)))
76 for item in generics:
76 for item in generics:
77 # we use 'match' instead of 'search' to make the matching simpler
77 # we use 'match' instead of 'search' to make the matching simpler
78 # for people unfamiliar with regular expression. Having the match
78 # for people unfamiliar with regular expression. Having the match
79 # rooted to the start of the string will produce less surprising
79 # rooted to the start of the string will produce less surprising
80 # result for user writing simple regex for sub-attribute.
80 # result for user writing simple regex for sub-attribute.
81 #
81 #
82 # For example using "color\..*" match produces an unsurprising
82 # For example using "color\..*" match produces an unsurprising
83 # result, while using search could suddenly match apparently
83 # result, while using search could suddenly match apparently
84 # unrelated configuration that happens to contains "color."
84 # unrelated configuration that happens to contains "color."
85 # anywhere. This is a tradeoff where we favor requiring ".*" on
85 # anywhere. This is a tradeoff where we favor requiring ".*" on
86 # some match to avoid the need to prefix most pattern with "^".
86 # some match to avoid the need to prefix most pattern with "^".
87 # The "^" seems more error prone.
87 # The "^" seems more error prone.
88 if item._re.match(key):
88 if item._re.match(key):
89 return item
89 return item
90
90
91 return None
91 return None
92
92
93 coreitems = {}
93 coreitems = {}
94
94
95 def _register(configtable, *args, **kwargs):
95 def _register(configtable, *args, **kwargs):
96 item = configitem(*args, **kwargs)
96 item = configitem(*args, **kwargs)
97 section = configtable.setdefault(item.section, itemregister())
97 section = configtable.setdefault(item.section, itemregister())
98 if item.name in section:
98 if item.name in section:
99 msg = "duplicated config item registration for '%s.%s'"
99 msg = "duplicated config item registration for '%s.%s'"
100 raise error.ProgrammingError(msg % (item.section, item.name))
100 raise error.ProgrammingError(msg % (item.section, item.name))
101 section[item.name] = item
101 section[item.name] = item
102
102
103 # special value for case where the default is derived from other values
103 # special value for case where the default is derived from other values
104 dynamicdefault = object()
104 dynamicdefault = object()
105
105
106 # Registering actual config items
106 # Registering actual config items
107
107
108 def getitemregister(configtable):
108 def getitemregister(configtable):
109 f = functools.partial(_register, configtable)
109 f = functools.partial(_register, configtable)
110 # export pseudo enum as configitem.*
110 # export pseudo enum as configitem.*
111 f.dynamicdefault = dynamicdefault
111 f.dynamicdefault = dynamicdefault
112 return f
112 return f
113
113
114 coreconfigitem = getitemregister(coreitems)
114 coreconfigitem = getitemregister(coreitems)
115
115
116 coreconfigitem('alias', '.*',
116 coreconfigitem('alias', '.*',
117 default=dynamicdefault,
117 default=dynamicdefault,
118 generic=True,
118 generic=True,
119 )
119 )
120 coreconfigitem('annotate', 'nodates',
120 coreconfigitem('annotate', 'nodates',
121 default=False,
121 default=False,
122 )
122 )
123 coreconfigitem('annotate', 'showfunc',
123 coreconfigitem('annotate', 'showfunc',
124 default=False,
124 default=False,
125 )
125 )
126 coreconfigitem('annotate', 'unified',
126 coreconfigitem('annotate', 'unified',
127 default=None,
127 default=None,
128 )
128 )
129 coreconfigitem('annotate', 'git',
129 coreconfigitem('annotate', 'git',
130 default=False,
130 default=False,
131 )
131 )
132 coreconfigitem('annotate', 'ignorews',
132 coreconfigitem('annotate', 'ignorews',
133 default=False,
133 default=False,
134 )
134 )
135 coreconfigitem('annotate', 'ignorewsamount',
135 coreconfigitem('annotate', 'ignorewsamount',
136 default=False,
136 default=False,
137 )
137 )
138 coreconfigitem('annotate', 'ignoreblanklines',
138 coreconfigitem('annotate', 'ignoreblanklines',
139 default=False,
139 default=False,
140 )
140 )
141 coreconfigitem('annotate', 'ignorewseol',
141 coreconfigitem('annotate', 'ignorewseol',
142 default=False,
142 default=False,
143 )
143 )
144 coreconfigitem('annotate', 'nobinary',
144 coreconfigitem('annotate', 'nobinary',
145 default=False,
145 default=False,
146 )
146 )
147 coreconfigitem('annotate', 'noprefix',
147 coreconfigitem('annotate', 'noprefix',
148 default=False,
148 default=False,
149 )
149 )
150 coreconfigitem('auth', 'cookiefile',
150 coreconfigitem('auth', 'cookiefile',
151 default=None,
151 default=None,
152 )
152 )
153 # bookmarks.pushing: internal hack for discovery
153 # bookmarks.pushing: internal hack for discovery
154 coreconfigitem('bookmarks', 'pushing',
154 coreconfigitem('bookmarks', 'pushing',
155 default=list,
155 default=list,
156 )
156 )
157 # bundle.mainreporoot: internal hack for bundlerepo
157 # bundle.mainreporoot: internal hack for bundlerepo
158 coreconfigitem('bundle', 'mainreporoot',
158 coreconfigitem('bundle', 'mainreporoot',
159 default='',
159 default='',
160 )
160 )
161 # bundle.reorder: experimental config
161 # bundle.reorder: experimental config
162 coreconfigitem('bundle', 'reorder',
162 coreconfigitem('bundle', 'reorder',
163 default='auto',
163 default='auto',
164 )
164 )
165 coreconfigitem('censor', 'policy',
165 coreconfigitem('censor', 'policy',
166 default='abort',
166 default='abort',
167 )
167 )
168 coreconfigitem('chgserver', 'idletimeout',
168 coreconfigitem('chgserver', 'idletimeout',
169 default=3600,
169 default=3600,
170 )
170 )
171 coreconfigitem('chgserver', 'skiphash',
171 coreconfigitem('chgserver', 'skiphash',
172 default=False,
172 default=False,
173 )
173 )
174 coreconfigitem('cmdserver', 'log',
174 coreconfigitem('cmdserver', 'log',
175 default=None,
175 default=None,
176 )
176 )
177 coreconfigitem('color', '.*',
177 coreconfigitem('color', '.*',
178 default=None,
178 default=None,
179 generic=True,
179 generic=True,
180 )
180 )
181 coreconfigitem('color', 'mode',
181 coreconfigitem('color', 'mode',
182 default='auto',
182 default='auto',
183 )
183 )
184 coreconfigitem('color', 'pagermode',
184 coreconfigitem('color', 'pagermode',
185 default=dynamicdefault,
185 default=dynamicdefault,
186 )
186 )
187 coreconfigitem('commands', 'show.aliasprefix',
187 coreconfigitem('commands', 'show.aliasprefix',
188 default=list,
188 default=list,
189 )
189 )
190 coreconfigitem('commands', 'status.relative',
190 coreconfigitem('commands', 'status.relative',
191 default=False,
191 default=False,
192 )
192 )
193 coreconfigitem('commands', 'status.skipstates',
193 coreconfigitem('commands', 'status.skipstates',
194 default=[],
194 default=[],
195 )
195 )
196 coreconfigitem('commands', 'status.terse',
197 default='',
198 )
196 coreconfigitem('commands', 'status.verbose',
199 coreconfigitem('commands', 'status.verbose',
197 default=False,
200 default=False,
198 )
201 )
199 coreconfigitem('commands', 'update.check',
202 coreconfigitem('commands', 'update.check',
200 default=None,
203 default=None,
201 # Deprecated, remove after 4.4 release
204 # Deprecated, remove after 4.4 release
202 alias=[('experimental', 'updatecheck')]
205 alias=[('experimental', 'updatecheck')]
203 )
206 )
204 coreconfigitem('commands', 'update.requiredest',
207 coreconfigitem('commands', 'update.requiredest',
205 default=False,
208 default=False,
206 )
209 )
207 coreconfigitem('committemplate', '.*',
210 coreconfigitem('committemplate', '.*',
208 default=None,
211 default=None,
209 generic=True,
212 generic=True,
210 )
213 )
211 coreconfigitem('convert', 'cvsps.cache',
214 coreconfigitem('convert', 'cvsps.cache',
212 default=True,
215 default=True,
213 )
216 )
214 coreconfigitem('convert', 'cvsps.fuzz',
217 coreconfigitem('convert', 'cvsps.fuzz',
215 default=60,
218 default=60,
216 )
219 )
217 coreconfigitem('convert', 'cvsps.logencoding',
220 coreconfigitem('convert', 'cvsps.logencoding',
218 default=None,
221 default=None,
219 )
222 )
220 coreconfigitem('convert', 'cvsps.mergefrom',
223 coreconfigitem('convert', 'cvsps.mergefrom',
221 default=None,
224 default=None,
222 )
225 )
223 coreconfigitem('convert', 'cvsps.mergeto',
226 coreconfigitem('convert', 'cvsps.mergeto',
224 default=None,
227 default=None,
225 )
228 )
226 coreconfigitem('convert', 'git.committeractions',
229 coreconfigitem('convert', 'git.committeractions',
227 default=lambda: ['messagedifferent'],
230 default=lambda: ['messagedifferent'],
228 )
231 )
229 coreconfigitem('convert', 'git.extrakeys',
232 coreconfigitem('convert', 'git.extrakeys',
230 default=list,
233 default=list,
231 )
234 )
232 coreconfigitem('convert', 'git.findcopiesharder',
235 coreconfigitem('convert', 'git.findcopiesharder',
233 default=False,
236 default=False,
234 )
237 )
235 coreconfigitem('convert', 'git.remoteprefix',
238 coreconfigitem('convert', 'git.remoteprefix',
236 default='remote',
239 default='remote',
237 )
240 )
238 coreconfigitem('convert', 'git.renamelimit',
241 coreconfigitem('convert', 'git.renamelimit',
239 default=400,
242 default=400,
240 )
243 )
241 coreconfigitem('convert', 'git.saverev',
244 coreconfigitem('convert', 'git.saverev',
242 default=True,
245 default=True,
243 )
246 )
244 coreconfigitem('convert', 'git.similarity',
247 coreconfigitem('convert', 'git.similarity',
245 default=50,
248 default=50,
246 )
249 )
247 coreconfigitem('convert', 'git.skipsubmodules',
250 coreconfigitem('convert', 'git.skipsubmodules',
248 default=False,
251 default=False,
249 )
252 )
250 coreconfigitem('convert', 'hg.clonebranches',
253 coreconfigitem('convert', 'hg.clonebranches',
251 default=False,
254 default=False,
252 )
255 )
253 coreconfigitem('convert', 'hg.ignoreerrors',
256 coreconfigitem('convert', 'hg.ignoreerrors',
254 default=False,
257 default=False,
255 )
258 )
256 coreconfigitem('convert', 'hg.revs',
259 coreconfigitem('convert', 'hg.revs',
257 default=None,
260 default=None,
258 )
261 )
259 coreconfigitem('convert', 'hg.saverev',
262 coreconfigitem('convert', 'hg.saverev',
260 default=False,
263 default=False,
261 )
264 )
262 coreconfigitem('convert', 'hg.sourcename',
265 coreconfigitem('convert', 'hg.sourcename',
263 default=None,
266 default=None,
264 )
267 )
265 coreconfigitem('convert', 'hg.startrev',
268 coreconfigitem('convert', 'hg.startrev',
266 default=None,
269 default=None,
267 )
270 )
268 coreconfigitem('convert', 'hg.tagsbranch',
271 coreconfigitem('convert', 'hg.tagsbranch',
269 default='default',
272 default='default',
270 )
273 )
271 coreconfigitem('convert', 'hg.usebranchnames',
274 coreconfigitem('convert', 'hg.usebranchnames',
272 default=True,
275 default=True,
273 )
276 )
274 coreconfigitem('convert', 'ignoreancestorcheck',
277 coreconfigitem('convert', 'ignoreancestorcheck',
275 default=False,
278 default=False,
276 )
279 )
277 coreconfigitem('convert', 'localtimezone',
280 coreconfigitem('convert', 'localtimezone',
278 default=False,
281 default=False,
279 )
282 )
280 coreconfigitem('convert', 'p4.encoding',
283 coreconfigitem('convert', 'p4.encoding',
281 default=dynamicdefault,
284 default=dynamicdefault,
282 )
285 )
283 coreconfigitem('convert', 'p4.startrev',
286 coreconfigitem('convert', 'p4.startrev',
284 default=0,
287 default=0,
285 )
288 )
286 coreconfigitem('convert', 'skiptags',
289 coreconfigitem('convert', 'skiptags',
287 default=False,
290 default=False,
288 )
291 )
289 coreconfigitem('convert', 'svn.debugsvnlog',
292 coreconfigitem('convert', 'svn.debugsvnlog',
290 default=True,
293 default=True,
291 )
294 )
292 coreconfigitem('convert', 'svn.trunk',
295 coreconfigitem('convert', 'svn.trunk',
293 default=None,
296 default=None,
294 )
297 )
295 coreconfigitem('convert', 'svn.tags',
298 coreconfigitem('convert', 'svn.tags',
296 default=None,
299 default=None,
297 )
300 )
298 coreconfigitem('convert', 'svn.branches',
301 coreconfigitem('convert', 'svn.branches',
299 default=None,
302 default=None,
300 )
303 )
301 coreconfigitem('convert', 'svn.startrev',
304 coreconfigitem('convert', 'svn.startrev',
302 default=0,
305 default=0,
303 )
306 )
304 coreconfigitem('debug', 'dirstate.delaywrite',
307 coreconfigitem('debug', 'dirstate.delaywrite',
305 default=0,
308 default=0,
306 )
309 )
307 coreconfigitem('defaults', '.*',
310 coreconfigitem('defaults', '.*',
308 default=None,
311 default=None,
309 generic=True,
312 generic=True,
310 )
313 )
311 coreconfigitem('devel', 'all-warnings',
314 coreconfigitem('devel', 'all-warnings',
312 default=False,
315 default=False,
313 )
316 )
314 coreconfigitem('devel', 'bundle2.debug',
317 coreconfigitem('devel', 'bundle2.debug',
315 default=False,
318 default=False,
316 )
319 )
317 coreconfigitem('devel', 'cache-vfs',
320 coreconfigitem('devel', 'cache-vfs',
318 default=None,
321 default=None,
319 )
322 )
320 coreconfigitem('devel', 'check-locks',
323 coreconfigitem('devel', 'check-locks',
321 default=False,
324 default=False,
322 )
325 )
323 coreconfigitem('devel', 'check-relroot',
326 coreconfigitem('devel', 'check-relroot',
324 default=False,
327 default=False,
325 )
328 )
326 coreconfigitem('devel', 'default-date',
329 coreconfigitem('devel', 'default-date',
327 default=None,
330 default=None,
328 )
331 )
329 coreconfigitem('devel', 'deprec-warn',
332 coreconfigitem('devel', 'deprec-warn',
330 default=False,
333 default=False,
331 )
334 )
332 coreconfigitem('devel', 'disableloaddefaultcerts',
335 coreconfigitem('devel', 'disableloaddefaultcerts',
333 default=False,
336 default=False,
334 )
337 )
335 coreconfigitem('devel', 'warn-empty-changegroup',
338 coreconfigitem('devel', 'warn-empty-changegroup',
336 default=False,
339 default=False,
337 )
340 )
338 coreconfigitem('devel', 'legacy.exchange',
341 coreconfigitem('devel', 'legacy.exchange',
339 default=list,
342 default=list,
340 )
343 )
341 coreconfigitem('devel', 'servercafile',
344 coreconfigitem('devel', 'servercafile',
342 default='',
345 default='',
343 )
346 )
344 coreconfigitem('devel', 'serverexactprotocol',
347 coreconfigitem('devel', 'serverexactprotocol',
345 default='',
348 default='',
346 )
349 )
347 coreconfigitem('devel', 'serverrequirecert',
350 coreconfigitem('devel', 'serverrequirecert',
348 default=False,
351 default=False,
349 )
352 )
350 coreconfigitem('devel', 'strip-obsmarkers',
353 coreconfigitem('devel', 'strip-obsmarkers',
351 default=True,
354 default=True,
352 )
355 )
353 coreconfigitem('devel', 'warn-config',
356 coreconfigitem('devel', 'warn-config',
354 default=None,
357 default=None,
355 )
358 )
356 coreconfigitem('devel', 'warn-config-default',
359 coreconfigitem('devel', 'warn-config-default',
357 default=None,
360 default=None,
358 )
361 )
359 coreconfigitem('devel', 'user.obsmarker',
362 coreconfigitem('devel', 'user.obsmarker',
360 default=None,
363 default=None,
361 )
364 )
362 coreconfigitem('devel', 'warn-config-unknown',
365 coreconfigitem('devel', 'warn-config-unknown',
363 default=None,
366 default=None,
364 )
367 )
365 coreconfigitem('devel', 'debug.peer-request',
368 coreconfigitem('devel', 'debug.peer-request',
366 default=False,
369 default=False,
367 )
370 )
368 coreconfigitem('diff', 'nodates',
371 coreconfigitem('diff', 'nodates',
369 default=False,
372 default=False,
370 )
373 )
371 coreconfigitem('diff', 'showfunc',
374 coreconfigitem('diff', 'showfunc',
372 default=False,
375 default=False,
373 )
376 )
374 coreconfigitem('diff', 'unified',
377 coreconfigitem('diff', 'unified',
375 default=None,
378 default=None,
376 )
379 )
377 coreconfigitem('diff', 'git',
380 coreconfigitem('diff', 'git',
378 default=False,
381 default=False,
379 )
382 )
380 coreconfigitem('diff', 'ignorews',
383 coreconfigitem('diff', 'ignorews',
381 default=False,
384 default=False,
382 )
385 )
383 coreconfigitem('diff', 'ignorewsamount',
386 coreconfigitem('diff', 'ignorewsamount',
384 default=False,
387 default=False,
385 )
388 )
386 coreconfigitem('diff', 'ignoreblanklines',
389 coreconfigitem('diff', 'ignoreblanklines',
387 default=False,
390 default=False,
388 )
391 )
389 coreconfigitem('diff', 'ignorewseol',
392 coreconfigitem('diff', 'ignorewseol',
390 default=False,
393 default=False,
391 )
394 )
392 coreconfigitem('diff', 'nobinary',
395 coreconfigitem('diff', 'nobinary',
393 default=False,
396 default=False,
394 )
397 )
395 coreconfigitem('diff', 'noprefix',
398 coreconfigitem('diff', 'noprefix',
396 default=False,
399 default=False,
397 )
400 )
398 coreconfigitem('email', 'bcc',
401 coreconfigitem('email', 'bcc',
399 default=None,
402 default=None,
400 )
403 )
401 coreconfigitem('email', 'cc',
404 coreconfigitem('email', 'cc',
402 default=None,
405 default=None,
403 )
406 )
404 coreconfigitem('email', 'charsets',
407 coreconfigitem('email', 'charsets',
405 default=list,
408 default=list,
406 )
409 )
407 coreconfigitem('email', 'from',
410 coreconfigitem('email', 'from',
408 default=None,
411 default=None,
409 )
412 )
410 coreconfigitem('email', 'method',
413 coreconfigitem('email', 'method',
411 default='smtp',
414 default='smtp',
412 )
415 )
413 coreconfigitem('email', 'reply-to',
416 coreconfigitem('email', 'reply-to',
414 default=None,
417 default=None,
415 )
418 )
416 coreconfigitem('email', 'to',
419 coreconfigitem('email', 'to',
417 default=None,
420 default=None,
418 )
421 )
419 coreconfigitem('experimental', 'archivemetatemplate',
422 coreconfigitem('experimental', 'archivemetatemplate',
420 default=dynamicdefault,
423 default=dynamicdefault,
421 )
424 )
422 coreconfigitem('experimental', 'bundle-phases',
425 coreconfigitem('experimental', 'bundle-phases',
423 default=False,
426 default=False,
424 )
427 )
425 coreconfigitem('experimental', 'bundle2-advertise',
428 coreconfigitem('experimental', 'bundle2-advertise',
426 default=True,
429 default=True,
427 )
430 )
428 coreconfigitem('experimental', 'bundle2-output-capture',
431 coreconfigitem('experimental', 'bundle2-output-capture',
429 default=False,
432 default=False,
430 )
433 )
431 coreconfigitem('experimental', 'bundle2.pushback',
434 coreconfigitem('experimental', 'bundle2.pushback',
432 default=False,
435 default=False,
433 )
436 )
434 coreconfigitem('experimental', 'bundle2.stream',
437 coreconfigitem('experimental', 'bundle2.stream',
435 default=False,
438 default=False,
436 )
439 )
437 coreconfigitem('experimental', 'bundle2lazylocking',
440 coreconfigitem('experimental', 'bundle2lazylocking',
438 default=False,
441 default=False,
439 )
442 )
440 coreconfigitem('experimental', 'bundlecomplevel',
443 coreconfigitem('experimental', 'bundlecomplevel',
441 default=None,
444 default=None,
442 )
445 )
443 coreconfigitem('experimental', 'bundlecomplevel.bzip2',
446 coreconfigitem('experimental', 'bundlecomplevel.bzip2',
444 default=None,
447 default=None,
445 )
448 )
446 coreconfigitem('experimental', 'bundlecomplevel.gzip',
449 coreconfigitem('experimental', 'bundlecomplevel.gzip',
447 default=None,
450 default=None,
448 )
451 )
449 coreconfigitem('experimental', 'bundlecomplevel.none',
452 coreconfigitem('experimental', 'bundlecomplevel.none',
450 default=None,
453 default=None,
451 )
454 )
452 coreconfigitem('experimental', 'bundlecomplevel.zstd',
455 coreconfigitem('experimental', 'bundlecomplevel.zstd',
453 default=None,
456 default=None,
454 )
457 )
455 coreconfigitem('experimental', 'changegroup3',
458 coreconfigitem('experimental', 'changegroup3',
456 default=False,
459 default=False,
457 )
460 )
458 coreconfigitem('experimental', 'clientcompressionengines',
461 coreconfigitem('experimental', 'clientcompressionengines',
459 default=list,
462 default=list,
460 )
463 )
461 coreconfigitem('experimental', 'copytrace',
464 coreconfigitem('experimental', 'copytrace',
462 default='on',
465 default='on',
463 )
466 )
464 coreconfigitem('experimental', 'copytrace.movecandidateslimit',
467 coreconfigitem('experimental', 'copytrace.movecandidateslimit',
465 default=100,
468 default=100,
466 )
469 )
467 coreconfigitem('experimental', 'copytrace.sourcecommitlimit',
470 coreconfigitem('experimental', 'copytrace.sourcecommitlimit',
468 default=100,
471 default=100,
469 )
472 )
470 coreconfigitem('experimental', 'crecordtest',
473 coreconfigitem('experimental', 'crecordtest',
471 default=None,
474 default=None,
472 )
475 )
473 coreconfigitem('experimental', 'directaccess',
476 coreconfigitem('experimental', 'directaccess',
474 default=False,
477 default=False,
475 )
478 )
476 coreconfigitem('experimental', 'directaccess.revnums',
479 coreconfigitem('experimental', 'directaccess.revnums',
477 default=False,
480 default=False,
478 )
481 )
479 coreconfigitem('experimental', 'editortmpinhg',
482 coreconfigitem('experimental', 'editortmpinhg',
480 default=False,
483 default=False,
481 )
484 )
482 coreconfigitem('experimental', 'evolution',
485 coreconfigitem('experimental', 'evolution',
483 default=list,
486 default=list,
484 )
487 )
485 coreconfigitem('experimental', 'evolution.allowdivergence',
488 coreconfigitem('experimental', 'evolution.allowdivergence',
486 default=False,
489 default=False,
487 alias=[('experimental', 'allowdivergence')]
490 alias=[('experimental', 'allowdivergence')]
488 )
491 )
489 coreconfigitem('experimental', 'evolution.allowunstable',
492 coreconfigitem('experimental', 'evolution.allowunstable',
490 default=None,
493 default=None,
491 )
494 )
492 coreconfigitem('experimental', 'evolution.createmarkers',
495 coreconfigitem('experimental', 'evolution.createmarkers',
493 default=None,
496 default=None,
494 )
497 )
495 coreconfigitem('experimental', 'evolution.effect-flags',
498 coreconfigitem('experimental', 'evolution.effect-flags',
496 default=True,
499 default=True,
497 alias=[('experimental', 'effect-flags')]
500 alias=[('experimental', 'effect-flags')]
498 )
501 )
499 coreconfigitem('experimental', 'evolution.exchange',
502 coreconfigitem('experimental', 'evolution.exchange',
500 default=None,
503 default=None,
501 )
504 )
502 coreconfigitem('experimental', 'evolution.bundle-obsmarker',
505 coreconfigitem('experimental', 'evolution.bundle-obsmarker',
503 default=False,
506 default=False,
504 )
507 )
505 coreconfigitem('experimental', 'evolution.report-instabilities',
508 coreconfigitem('experimental', 'evolution.report-instabilities',
506 default=True,
509 default=True,
507 )
510 )
508 coreconfigitem('experimental', 'evolution.track-operation',
511 coreconfigitem('experimental', 'evolution.track-operation',
509 default=True,
512 default=True,
510 )
513 )
511 coreconfigitem('experimental', 'worddiff',
514 coreconfigitem('experimental', 'worddiff',
512 default=False,
515 default=False,
513 )
516 )
514 coreconfigitem('experimental', 'maxdeltachainspan',
517 coreconfigitem('experimental', 'maxdeltachainspan',
515 default=-1,
518 default=-1,
516 )
519 )
517 coreconfigitem('experimental', 'mergetempdirprefix',
520 coreconfigitem('experimental', 'mergetempdirprefix',
518 default=None,
521 default=None,
519 )
522 )
520 coreconfigitem('experimental', 'mmapindexthreshold',
523 coreconfigitem('experimental', 'mmapindexthreshold',
521 default=None,
524 default=None,
522 )
525 )
523 coreconfigitem('experimental', 'nonnormalparanoidcheck',
526 coreconfigitem('experimental', 'nonnormalparanoidcheck',
524 default=False,
527 default=False,
525 )
528 )
526 coreconfigitem('experimental', 'exportableenviron',
529 coreconfigitem('experimental', 'exportableenviron',
527 default=list,
530 default=list,
528 )
531 )
529 coreconfigitem('experimental', 'extendedheader.index',
532 coreconfigitem('experimental', 'extendedheader.index',
530 default=None,
533 default=None,
531 )
534 )
532 coreconfigitem('experimental', 'extendedheader.similarity',
535 coreconfigitem('experimental', 'extendedheader.similarity',
533 default=False,
536 default=False,
534 )
537 )
535 coreconfigitem('experimental', 'format.compression',
538 coreconfigitem('experimental', 'format.compression',
536 default='zlib',
539 default='zlib',
537 )
540 )
538 coreconfigitem('experimental', 'graphshorten',
541 coreconfigitem('experimental', 'graphshorten',
539 default=False,
542 default=False,
540 )
543 )
541 coreconfigitem('experimental', 'graphstyle.parent',
544 coreconfigitem('experimental', 'graphstyle.parent',
542 default=dynamicdefault,
545 default=dynamicdefault,
543 )
546 )
544 coreconfigitem('experimental', 'graphstyle.missing',
547 coreconfigitem('experimental', 'graphstyle.missing',
545 default=dynamicdefault,
548 default=dynamicdefault,
546 )
549 )
547 coreconfigitem('experimental', 'graphstyle.grandparent',
550 coreconfigitem('experimental', 'graphstyle.grandparent',
548 default=dynamicdefault,
551 default=dynamicdefault,
549 )
552 )
550 coreconfigitem('experimental', 'hook-track-tags',
553 coreconfigitem('experimental', 'hook-track-tags',
551 default=False,
554 default=False,
552 )
555 )
553 coreconfigitem('experimental', 'httppeer.advertise-v2',
556 coreconfigitem('experimental', 'httppeer.advertise-v2',
554 default=False,
557 default=False,
555 )
558 )
556 coreconfigitem('experimental', 'httppostargs',
559 coreconfigitem('experimental', 'httppostargs',
557 default=False,
560 default=False,
558 )
561 )
559 coreconfigitem('experimental', 'mergedriver',
562 coreconfigitem('experimental', 'mergedriver',
560 default=None,
563 default=None,
561 )
564 )
562 coreconfigitem('experimental', 'obsmarkers-exchange-debug',
565 coreconfigitem('experimental', 'obsmarkers-exchange-debug',
563 default=False,
566 default=False,
564 )
567 )
565 coreconfigitem('experimental', 'remotenames',
568 coreconfigitem('experimental', 'remotenames',
566 default=False,
569 default=False,
567 )
570 )
568 coreconfigitem('experimental', 'revlogv2',
571 coreconfigitem('experimental', 'revlogv2',
569 default=None,
572 default=None,
570 )
573 )
571 coreconfigitem('experimental', 'single-head-per-branch',
574 coreconfigitem('experimental', 'single-head-per-branch',
572 default=False,
575 default=False,
573 )
576 )
574 coreconfigitem('experimental', 'sshserver.support-v2',
577 coreconfigitem('experimental', 'sshserver.support-v2',
575 default=False,
578 default=False,
576 )
579 )
577 coreconfigitem('experimental', 'spacemovesdown',
580 coreconfigitem('experimental', 'spacemovesdown',
578 default=False,
581 default=False,
579 )
582 )
580 coreconfigitem('experimental', 'sparse-read',
583 coreconfigitem('experimental', 'sparse-read',
581 default=False,
584 default=False,
582 )
585 )
583 coreconfigitem('experimental', 'sparse-read.density-threshold',
586 coreconfigitem('experimental', 'sparse-read.density-threshold',
584 default=0.25,
587 default=0.25,
585 )
588 )
586 coreconfigitem('experimental', 'sparse-read.min-gap-size',
589 coreconfigitem('experimental', 'sparse-read.min-gap-size',
587 default='256K',
590 default='256K',
588 )
591 )
589 coreconfigitem('experimental', 'treemanifest',
592 coreconfigitem('experimental', 'treemanifest',
590 default=False,
593 default=False,
591 )
594 )
592 coreconfigitem('experimental', 'update.atomic-file',
595 coreconfigitem('experimental', 'update.atomic-file',
593 default=False,
596 default=False,
594 )
597 )
595 coreconfigitem('experimental', 'sshpeer.advertise-v2',
598 coreconfigitem('experimental', 'sshpeer.advertise-v2',
596 default=False,
599 default=False,
597 )
600 )
598 coreconfigitem('experimental', 'web.apiserver',
601 coreconfigitem('experimental', 'web.apiserver',
599 default=False,
602 default=False,
600 )
603 )
601 coreconfigitem('experimental', 'web.api.http-v2',
604 coreconfigitem('experimental', 'web.api.http-v2',
602 default=False,
605 default=False,
603 )
606 )
604 coreconfigitem('experimental', 'web.api.debugreflect',
607 coreconfigitem('experimental', 'web.api.debugreflect',
605 default=False,
608 default=False,
606 )
609 )
607 coreconfigitem('experimental', 'xdiff',
610 coreconfigitem('experimental', 'xdiff',
608 default=False,
611 default=False,
609 )
612 )
610 coreconfigitem('extensions', '.*',
613 coreconfigitem('extensions', '.*',
611 default=None,
614 default=None,
612 generic=True,
615 generic=True,
613 )
616 )
614 coreconfigitem('extdata', '.*',
617 coreconfigitem('extdata', '.*',
615 default=None,
618 default=None,
616 generic=True,
619 generic=True,
617 )
620 )
618 coreconfigitem('format', 'aggressivemergedeltas',
621 coreconfigitem('format', 'aggressivemergedeltas',
619 default=False,
622 default=False,
620 )
623 )
621 coreconfigitem('format', 'chunkcachesize',
624 coreconfigitem('format', 'chunkcachesize',
622 default=None,
625 default=None,
623 )
626 )
624 coreconfigitem('format', 'dotencode',
627 coreconfigitem('format', 'dotencode',
625 default=True,
628 default=True,
626 )
629 )
627 coreconfigitem('format', 'generaldelta',
630 coreconfigitem('format', 'generaldelta',
628 default=False,
631 default=False,
629 )
632 )
630 coreconfigitem('format', 'manifestcachesize',
633 coreconfigitem('format', 'manifestcachesize',
631 default=None,
634 default=None,
632 )
635 )
633 coreconfigitem('format', 'maxchainlen',
636 coreconfigitem('format', 'maxchainlen',
634 default=None,
637 default=None,
635 )
638 )
636 coreconfigitem('format', 'obsstore-version',
639 coreconfigitem('format', 'obsstore-version',
637 default=None,
640 default=None,
638 )
641 )
639 coreconfigitem('format', 'usefncache',
642 coreconfigitem('format', 'usefncache',
640 default=True,
643 default=True,
641 )
644 )
642 coreconfigitem('format', 'usegeneraldelta',
645 coreconfigitem('format', 'usegeneraldelta',
643 default=True,
646 default=True,
644 )
647 )
645 coreconfigitem('format', 'usestore',
648 coreconfigitem('format', 'usestore',
646 default=True,
649 default=True,
647 )
650 )
648 coreconfigitem('fsmonitor', 'warn_when_unused',
651 coreconfigitem('fsmonitor', 'warn_when_unused',
649 default=True,
652 default=True,
650 )
653 )
651 coreconfigitem('fsmonitor', 'warn_update_file_count',
654 coreconfigitem('fsmonitor', 'warn_update_file_count',
652 default=50000,
655 default=50000,
653 )
656 )
654 coreconfigitem('hooks', '.*',
657 coreconfigitem('hooks', '.*',
655 default=dynamicdefault,
658 default=dynamicdefault,
656 generic=True,
659 generic=True,
657 )
660 )
658 coreconfigitem('hgweb-paths', '.*',
661 coreconfigitem('hgweb-paths', '.*',
659 default=list,
662 default=list,
660 generic=True,
663 generic=True,
661 )
664 )
662 coreconfigitem('hostfingerprints', '.*',
665 coreconfigitem('hostfingerprints', '.*',
663 default=list,
666 default=list,
664 generic=True,
667 generic=True,
665 )
668 )
666 coreconfigitem('hostsecurity', 'ciphers',
669 coreconfigitem('hostsecurity', 'ciphers',
667 default=None,
670 default=None,
668 )
671 )
669 coreconfigitem('hostsecurity', 'disabletls10warning',
672 coreconfigitem('hostsecurity', 'disabletls10warning',
670 default=False,
673 default=False,
671 )
674 )
672 coreconfigitem('hostsecurity', 'minimumprotocol',
675 coreconfigitem('hostsecurity', 'minimumprotocol',
673 default=dynamicdefault,
676 default=dynamicdefault,
674 )
677 )
675 coreconfigitem('hostsecurity', '.*:minimumprotocol$',
678 coreconfigitem('hostsecurity', '.*:minimumprotocol$',
676 default=dynamicdefault,
679 default=dynamicdefault,
677 generic=True,
680 generic=True,
678 )
681 )
679 coreconfigitem('hostsecurity', '.*:ciphers$',
682 coreconfigitem('hostsecurity', '.*:ciphers$',
680 default=dynamicdefault,
683 default=dynamicdefault,
681 generic=True,
684 generic=True,
682 )
685 )
683 coreconfigitem('hostsecurity', '.*:fingerprints$',
686 coreconfigitem('hostsecurity', '.*:fingerprints$',
684 default=list,
687 default=list,
685 generic=True,
688 generic=True,
686 )
689 )
687 coreconfigitem('hostsecurity', '.*:verifycertsfile$',
690 coreconfigitem('hostsecurity', '.*:verifycertsfile$',
688 default=None,
691 default=None,
689 generic=True,
692 generic=True,
690 )
693 )
691
694
692 coreconfigitem('http_proxy', 'always',
695 coreconfigitem('http_proxy', 'always',
693 default=False,
696 default=False,
694 )
697 )
695 coreconfigitem('http_proxy', 'host',
698 coreconfigitem('http_proxy', 'host',
696 default=None,
699 default=None,
697 )
700 )
698 coreconfigitem('http_proxy', 'no',
701 coreconfigitem('http_proxy', 'no',
699 default=list,
702 default=list,
700 )
703 )
701 coreconfigitem('http_proxy', 'passwd',
704 coreconfigitem('http_proxy', 'passwd',
702 default=None,
705 default=None,
703 )
706 )
704 coreconfigitem('http_proxy', 'user',
707 coreconfigitem('http_proxy', 'user',
705 default=None,
708 default=None,
706 )
709 )
707 coreconfigitem('logtoprocess', 'commandexception',
710 coreconfigitem('logtoprocess', 'commandexception',
708 default=None,
711 default=None,
709 )
712 )
710 coreconfigitem('logtoprocess', 'commandfinish',
713 coreconfigitem('logtoprocess', 'commandfinish',
711 default=None,
714 default=None,
712 )
715 )
713 coreconfigitem('logtoprocess', 'command',
716 coreconfigitem('logtoprocess', 'command',
714 default=None,
717 default=None,
715 )
718 )
716 coreconfigitem('logtoprocess', 'develwarn',
719 coreconfigitem('logtoprocess', 'develwarn',
717 default=None,
720 default=None,
718 )
721 )
719 coreconfigitem('logtoprocess', 'uiblocked',
722 coreconfigitem('logtoprocess', 'uiblocked',
720 default=None,
723 default=None,
721 )
724 )
722 coreconfigitem('merge', 'checkunknown',
725 coreconfigitem('merge', 'checkunknown',
723 default='abort',
726 default='abort',
724 )
727 )
725 coreconfigitem('merge', 'checkignored',
728 coreconfigitem('merge', 'checkignored',
726 default='abort',
729 default='abort',
727 )
730 )
728 coreconfigitem('experimental', 'merge.checkpathconflicts',
731 coreconfigitem('experimental', 'merge.checkpathconflicts',
729 default=False,
732 default=False,
730 )
733 )
731 coreconfigitem('merge', 'followcopies',
734 coreconfigitem('merge', 'followcopies',
732 default=True,
735 default=True,
733 )
736 )
734 coreconfigitem('merge', 'on-failure',
737 coreconfigitem('merge', 'on-failure',
735 default='continue',
738 default='continue',
736 )
739 )
737 coreconfigitem('merge', 'preferancestor',
740 coreconfigitem('merge', 'preferancestor',
738 default=lambda: ['*'],
741 default=lambda: ['*'],
739 )
742 )
740 coreconfigitem('merge-tools', '.*',
743 coreconfigitem('merge-tools', '.*',
741 default=None,
744 default=None,
742 generic=True,
745 generic=True,
743 )
746 )
744 coreconfigitem('merge-tools', br'.*\.args$',
747 coreconfigitem('merge-tools', br'.*\.args$',
745 default="$local $base $other",
748 default="$local $base $other",
746 generic=True,
749 generic=True,
747 priority=-1,
750 priority=-1,
748 )
751 )
749 coreconfigitem('merge-tools', br'.*\.binary$',
752 coreconfigitem('merge-tools', br'.*\.binary$',
750 default=False,
753 default=False,
751 generic=True,
754 generic=True,
752 priority=-1,
755 priority=-1,
753 )
756 )
754 coreconfigitem('merge-tools', br'.*\.check$',
757 coreconfigitem('merge-tools', br'.*\.check$',
755 default=list,
758 default=list,
756 generic=True,
759 generic=True,
757 priority=-1,
760 priority=-1,
758 )
761 )
759 coreconfigitem('merge-tools', br'.*\.checkchanged$',
762 coreconfigitem('merge-tools', br'.*\.checkchanged$',
760 default=False,
763 default=False,
761 generic=True,
764 generic=True,
762 priority=-1,
765 priority=-1,
763 )
766 )
764 coreconfigitem('merge-tools', br'.*\.executable$',
767 coreconfigitem('merge-tools', br'.*\.executable$',
765 default=dynamicdefault,
768 default=dynamicdefault,
766 generic=True,
769 generic=True,
767 priority=-1,
770 priority=-1,
768 )
771 )
769 coreconfigitem('merge-tools', br'.*\.fixeol$',
772 coreconfigitem('merge-tools', br'.*\.fixeol$',
770 default=False,
773 default=False,
771 generic=True,
774 generic=True,
772 priority=-1,
775 priority=-1,
773 )
776 )
774 coreconfigitem('merge-tools', br'.*\.gui$',
777 coreconfigitem('merge-tools', br'.*\.gui$',
775 default=False,
778 default=False,
776 generic=True,
779 generic=True,
777 priority=-1,
780 priority=-1,
778 )
781 )
779 coreconfigitem('merge-tools', br'.*\.mergemarkers$',
782 coreconfigitem('merge-tools', br'.*\.mergemarkers$',
780 default='basic',
783 default='basic',
781 generic=True,
784 generic=True,
782 priority=-1,
785 priority=-1,
783 )
786 )
784 coreconfigitem('merge-tools', br'.*\.mergemarkertemplate$',
787 coreconfigitem('merge-tools', br'.*\.mergemarkertemplate$',
785 default=dynamicdefault, # take from ui.mergemarkertemplate
788 default=dynamicdefault, # take from ui.mergemarkertemplate
786 generic=True,
789 generic=True,
787 priority=-1,
790 priority=-1,
788 )
791 )
789 coreconfigitem('merge-tools', br'.*\.priority$',
792 coreconfigitem('merge-tools', br'.*\.priority$',
790 default=0,
793 default=0,
791 generic=True,
794 generic=True,
792 priority=-1,
795 priority=-1,
793 )
796 )
794 coreconfigitem('merge-tools', br'.*\.premerge$',
797 coreconfigitem('merge-tools', br'.*\.premerge$',
795 default=dynamicdefault,
798 default=dynamicdefault,
796 generic=True,
799 generic=True,
797 priority=-1,
800 priority=-1,
798 )
801 )
799 coreconfigitem('merge-tools', br'.*\.symlink$',
802 coreconfigitem('merge-tools', br'.*\.symlink$',
800 default=False,
803 default=False,
801 generic=True,
804 generic=True,
802 priority=-1,
805 priority=-1,
803 )
806 )
804 coreconfigitem('pager', 'attend-.*',
807 coreconfigitem('pager', 'attend-.*',
805 default=dynamicdefault,
808 default=dynamicdefault,
806 generic=True,
809 generic=True,
807 )
810 )
808 coreconfigitem('pager', 'ignore',
811 coreconfigitem('pager', 'ignore',
809 default=list,
812 default=list,
810 )
813 )
811 coreconfigitem('pager', 'pager',
814 coreconfigitem('pager', 'pager',
812 default=dynamicdefault,
815 default=dynamicdefault,
813 )
816 )
814 coreconfigitem('patch', 'eol',
817 coreconfigitem('patch', 'eol',
815 default='strict',
818 default='strict',
816 )
819 )
817 coreconfigitem('patch', 'fuzz',
820 coreconfigitem('patch', 'fuzz',
818 default=2,
821 default=2,
819 )
822 )
820 coreconfigitem('paths', 'default',
823 coreconfigitem('paths', 'default',
821 default=None,
824 default=None,
822 )
825 )
823 coreconfigitem('paths', 'default-push',
826 coreconfigitem('paths', 'default-push',
824 default=None,
827 default=None,
825 )
828 )
826 coreconfigitem('paths', '.*',
829 coreconfigitem('paths', '.*',
827 default=None,
830 default=None,
828 generic=True,
831 generic=True,
829 )
832 )
830 coreconfigitem('phases', 'checksubrepos',
833 coreconfigitem('phases', 'checksubrepos',
831 default='follow',
834 default='follow',
832 )
835 )
833 coreconfigitem('phases', 'new-commit',
836 coreconfigitem('phases', 'new-commit',
834 default='draft',
837 default='draft',
835 )
838 )
836 coreconfigitem('phases', 'publish',
839 coreconfigitem('phases', 'publish',
837 default=True,
840 default=True,
838 )
841 )
839 coreconfigitem('profiling', 'enabled',
842 coreconfigitem('profiling', 'enabled',
840 default=False,
843 default=False,
841 )
844 )
842 coreconfigitem('profiling', 'format',
845 coreconfigitem('profiling', 'format',
843 default='text',
846 default='text',
844 )
847 )
845 coreconfigitem('profiling', 'freq',
848 coreconfigitem('profiling', 'freq',
846 default=1000,
849 default=1000,
847 )
850 )
848 coreconfigitem('profiling', 'limit',
851 coreconfigitem('profiling', 'limit',
849 default=30,
852 default=30,
850 )
853 )
851 coreconfigitem('profiling', 'nested',
854 coreconfigitem('profiling', 'nested',
852 default=0,
855 default=0,
853 )
856 )
854 coreconfigitem('profiling', 'output',
857 coreconfigitem('profiling', 'output',
855 default=None,
858 default=None,
856 )
859 )
857 coreconfigitem('profiling', 'showmax',
860 coreconfigitem('profiling', 'showmax',
858 default=0.999,
861 default=0.999,
859 )
862 )
860 coreconfigitem('profiling', 'showmin',
863 coreconfigitem('profiling', 'showmin',
861 default=dynamicdefault,
864 default=dynamicdefault,
862 )
865 )
863 coreconfigitem('profiling', 'sort',
866 coreconfigitem('profiling', 'sort',
864 default='inlinetime',
867 default='inlinetime',
865 )
868 )
866 coreconfigitem('profiling', 'statformat',
869 coreconfigitem('profiling', 'statformat',
867 default='hotpath',
870 default='hotpath',
868 )
871 )
869 coreconfigitem('profiling', 'type',
872 coreconfigitem('profiling', 'type',
870 default='stat',
873 default='stat',
871 )
874 )
872 coreconfigitem('progress', 'assume-tty',
875 coreconfigitem('progress', 'assume-tty',
873 default=False,
876 default=False,
874 )
877 )
875 coreconfigitem('progress', 'changedelay',
878 coreconfigitem('progress', 'changedelay',
876 default=1,
879 default=1,
877 )
880 )
878 coreconfigitem('progress', 'clear-complete',
881 coreconfigitem('progress', 'clear-complete',
879 default=True,
882 default=True,
880 )
883 )
881 coreconfigitem('progress', 'debug',
884 coreconfigitem('progress', 'debug',
882 default=False,
885 default=False,
883 )
886 )
884 coreconfigitem('progress', 'delay',
887 coreconfigitem('progress', 'delay',
885 default=3,
888 default=3,
886 )
889 )
887 coreconfigitem('progress', 'disable',
890 coreconfigitem('progress', 'disable',
888 default=False,
891 default=False,
889 )
892 )
890 coreconfigitem('progress', 'estimateinterval',
893 coreconfigitem('progress', 'estimateinterval',
891 default=60.0,
894 default=60.0,
892 )
895 )
893 coreconfigitem('progress', 'format',
896 coreconfigitem('progress', 'format',
894 default=lambda: ['topic', 'bar', 'number', 'estimate'],
897 default=lambda: ['topic', 'bar', 'number', 'estimate'],
895 )
898 )
896 coreconfigitem('progress', 'refresh',
899 coreconfigitem('progress', 'refresh',
897 default=0.1,
900 default=0.1,
898 )
901 )
899 coreconfigitem('progress', 'width',
902 coreconfigitem('progress', 'width',
900 default=dynamicdefault,
903 default=dynamicdefault,
901 )
904 )
902 coreconfigitem('push', 'pushvars.server',
905 coreconfigitem('push', 'pushvars.server',
903 default=False,
906 default=False,
904 )
907 )
905 coreconfigitem('server', 'bookmarks-pushkey-compat',
908 coreconfigitem('server', 'bookmarks-pushkey-compat',
906 default=True,
909 default=True,
907 )
910 )
908 coreconfigitem('server', 'bundle1',
911 coreconfigitem('server', 'bundle1',
909 default=True,
912 default=True,
910 )
913 )
911 coreconfigitem('server', 'bundle1gd',
914 coreconfigitem('server', 'bundle1gd',
912 default=None,
915 default=None,
913 )
916 )
914 coreconfigitem('server', 'bundle1.pull',
917 coreconfigitem('server', 'bundle1.pull',
915 default=None,
918 default=None,
916 )
919 )
917 coreconfigitem('server', 'bundle1gd.pull',
920 coreconfigitem('server', 'bundle1gd.pull',
918 default=None,
921 default=None,
919 )
922 )
920 coreconfigitem('server', 'bundle1.push',
923 coreconfigitem('server', 'bundle1.push',
921 default=None,
924 default=None,
922 )
925 )
923 coreconfigitem('server', 'bundle1gd.push',
926 coreconfigitem('server', 'bundle1gd.push',
924 default=None,
927 default=None,
925 )
928 )
926 coreconfigitem('server', 'compressionengines',
929 coreconfigitem('server', 'compressionengines',
927 default=list,
930 default=list,
928 )
931 )
929 coreconfigitem('server', 'concurrent-push-mode',
932 coreconfigitem('server', 'concurrent-push-mode',
930 default='strict',
933 default='strict',
931 )
934 )
932 coreconfigitem('server', 'disablefullbundle',
935 coreconfigitem('server', 'disablefullbundle',
933 default=False,
936 default=False,
934 )
937 )
935 coreconfigitem('server', 'streamunbundle',
938 coreconfigitem('server', 'streamunbundle',
936 default=False,
939 default=False,
937 )
940 )
938 coreconfigitem('server', 'pullbundle',
941 coreconfigitem('server', 'pullbundle',
939 default=False,
942 default=False,
940 )
943 )
941 coreconfigitem('server', 'maxhttpheaderlen',
944 coreconfigitem('server', 'maxhttpheaderlen',
942 default=1024,
945 default=1024,
943 )
946 )
944 coreconfigitem('server', 'preferuncompressed',
947 coreconfigitem('server', 'preferuncompressed',
945 default=False,
948 default=False,
946 )
949 )
947 coreconfigitem('server', 'uncompressed',
950 coreconfigitem('server', 'uncompressed',
948 default=True,
951 default=True,
949 )
952 )
950 coreconfigitem('server', 'uncompressedallowsecret',
953 coreconfigitem('server', 'uncompressedallowsecret',
951 default=False,
954 default=False,
952 )
955 )
953 coreconfigitem('server', 'validate',
956 coreconfigitem('server', 'validate',
954 default=False,
957 default=False,
955 )
958 )
956 coreconfigitem('server', 'zliblevel',
959 coreconfigitem('server', 'zliblevel',
957 default=-1,
960 default=-1,
958 )
961 )
959 coreconfigitem('server', 'zstdlevel',
962 coreconfigitem('server', 'zstdlevel',
960 default=3,
963 default=3,
961 )
964 )
962 coreconfigitem('share', 'pool',
965 coreconfigitem('share', 'pool',
963 default=None,
966 default=None,
964 )
967 )
965 coreconfigitem('share', 'poolnaming',
968 coreconfigitem('share', 'poolnaming',
966 default='identity',
969 default='identity',
967 )
970 )
968 coreconfigitem('smtp', 'host',
971 coreconfigitem('smtp', 'host',
969 default=None,
972 default=None,
970 )
973 )
971 coreconfigitem('smtp', 'local_hostname',
974 coreconfigitem('smtp', 'local_hostname',
972 default=None,
975 default=None,
973 )
976 )
974 coreconfigitem('smtp', 'password',
977 coreconfigitem('smtp', 'password',
975 default=None,
978 default=None,
976 )
979 )
977 coreconfigitem('smtp', 'port',
980 coreconfigitem('smtp', 'port',
978 default=dynamicdefault,
981 default=dynamicdefault,
979 )
982 )
980 coreconfigitem('smtp', 'tls',
983 coreconfigitem('smtp', 'tls',
981 default='none',
984 default='none',
982 )
985 )
983 coreconfigitem('smtp', 'username',
986 coreconfigitem('smtp', 'username',
984 default=None,
987 default=None,
985 )
988 )
986 coreconfigitem('sparse', 'missingwarning',
989 coreconfigitem('sparse', 'missingwarning',
987 default=True,
990 default=True,
988 )
991 )
989 coreconfigitem('subrepos', 'allowed',
992 coreconfigitem('subrepos', 'allowed',
990 default=dynamicdefault, # to make backporting simpler
993 default=dynamicdefault, # to make backporting simpler
991 )
994 )
992 coreconfigitem('subrepos', 'hg:allowed',
995 coreconfigitem('subrepos', 'hg:allowed',
993 default=dynamicdefault,
996 default=dynamicdefault,
994 )
997 )
995 coreconfigitem('subrepos', 'git:allowed',
998 coreconfigitem('subrepos', 'git:allowed',
996 default=dynamicdefault,
999 default=dynamicdefault,
997 )
1000 )
998 coreconfigitem('subrepos', 'svn:allowed',
1001 coreconfigitem('subrepos', 'svn:allowed',
999 default=dynamicdefault,
1002 default=dynamicdefault,
1000 )
1003 )
1001 coreconfigitem('templates', '.*',
1004 coreconfigitem('templates', '.*',
1002 default=None,
1005 default=None,
1003 generic=True,
1006 generic=True,
1004 )
1007 )
1005 coreconfigitem('trusted', 'groups',
1008 coreconfigitem('trusted', 'groups',
1006 default=list,
1009 default=list,
1007 )
1010 )
1008 coreconfigitem('trusted', 'users',
1011 coreconfigitem('trusted', 'users',
1009 default=list,
1012 default=list,
1010 )
1013 )
1011 coreconfigitem('ui', '_usedassubrepo',
1014 coreconfigitem('ui', '_usedassubrepo',
1012 default=False,
1015 default=False,
1013 )
1016 )
1014 coreconfigitem('ui', 'allowemptycommit',
1017 coreconfigitem('ui', 'allowemptycommit',
1015 default=False,
1018 default=False,
1016 )
1019 )
1017 coreconfigitem('ui', 'archivemeta',
1020 coreconfigitem('ui', 'archivemeta',
1018 default=True,
1021 default=True,
1019 )
1022 )
1020 coreconfigitem('ui', 'askusername',
1023 coreconfigitem('ui', 'askusername',
1021 default=False,
1024 default=False,
1022 )
1025 )
1023 coreconfigitem('ui', 'clonebundlefallback',
1026 coreconfigitem('ui', 'clonebundlefallback',
1024 default=False,
1027 default=False,
1025 )
1028 )
1026 coreconfigitem('ui', 'clonebundleprefers',
1029 coreconfigitem('ui', 'clonebundleprefers',
1027 default=list,
1030 default=list,
1028 )
1031 )
1029 coreconfigitem('ui', 'clonebundles',
1032 coreconfigitem('ui', 'clonebundles',
1030 default=True,
1033 default=True,
1031 )
1034 )
1032 coreconfigitem('ui', 'color',
1035 coreconfigitem('ui', 'color',
1033 default='auto',
1036 default='auto',
1034 )
1037 )
1035 coreconfigitem('ui', 'commitsubrepos',
1038 coreconfigitem('ui', 'commitsubrepos',
1036 default=False,
1039 default=False,
1037 )
1040 )
1038 coreconfigitem('ui', 'debug',
1041 coreconfigitem('ui', 'debug',
1039 default=False,
1042 default=False,
1040 )
1043 )
1041 coreconfigitem('ui', 'debugger',
1044 coreconfigitem('ui', 'debugger',
1042 default=None,
1045 default=None,
1043 )
1046 )
1044 coreconfigitem('ui', 'editor',
1047 coreconfigitem('ui', 'editor',
1045 default=dynamicdefault,
1048 default=dynamicdefault,
1046 )
1049 )
1047 coreconfigitem('ui', 'fallbackencoding',
1050 coreconfigitem('ui', 'fallbackencoding',
1048 default=None,
1051 default=None,
1049 )
1052 )
1050 coreconfigitem('ui', 'forcecwd',
1053 coreconfigitem('ui', 'forcecwd',
1051 default=None,
1054 default=None,
1052 )
1055 )
1053 coreconfigitem('ui', 'forcemerge',
1056 coreconfigitem('ui', 'forcemerge',
1054 default=None,
1057 default=None,
1055 )
1058 )
1056 coreconfigitem('ui', 'formatdebug',
1059 coreconfigitem('ui', 'formatdebug',
1057 default=False,
1060 default=False,
1058 )
1061 )
1059 coreconfigitem('ui', 'formatjson',
1062 coreconfigitem('ui', 'formatjson',
1060 default=False,
1063 default=False,
1061 )
1064 )
1062 coreconfigitem('ui', 'formatted',
1065 coreconfigitem('ui', 'formatted',
1063 default=None,
1066 default=None,
1064 )
1067 )
1065 coreconfigitem('ui', 'graphnodetemplate',
1068 coreconfigitem('ui', 'graphnodetemplate',
1066 default=None,
1069 default=None,
1067 )
1070 )
1068 coreconfigitem('ui', 'interactive',
1071 coreconfigitem('ui', 'interactive',
1069 default=None,
1072 default=None,
1070 )
1073 )
1071 coreconfigitem('ui', 'interface',
1074 coreconfigitem('ui', 'interface',
1072 default=None,
1075 default=None,
1073 )
1076 )
1074 coreconfigitem('ui', 'interface.chunkselector',
1077 coreconfigitem('ui', 'interface.chunkselector',
1075 default=None,
1078 default=None,
1076 )
1079 )
1077 coreconfigitem('ui', 'logblockedtimes',
1080 coreconfigitem('ui', 'logblockedtimes',
1078 default=False,
1081 default=False,
1079 )
1082 )
1080 coreconfigitem('ui', 'logtemplate',
1083 coreconfigitem('ui', 'logtemplate',
1081 default=None,
1084 default=None,
1082 )
1085 )
1083 coreconfigitem('ui', 'merge',
1086 coreconfigitem('ui', 'merge',
1084 default=None,
1087 default=None,
1085 )
1088 )
1086 coreconfigitem('ui', 'mergemarkers',
1089 coreconfigitem('ui', 'mergemarkers',
1087 default='basic',
1090 default='basic',
1088 )
1091 )
1089 coreconfigitem('ui', 'mergemarkertemplate',
1092 coreconfigitem('ui', 'mergemarkertemplate',
1090 default=('{node|short} '
1093 default=('{node|short} '
1091 '{ifeq(tags, "tip", "", '
1094 '{ifeq(tags, "tip", "", '
1092 'ifeq(tags, "", "", "{tags} "))}'
1095 'ifeq(tags, "", "", "{tags} "))}'
1093 '{if(bookmarks, "{bookmarks} ")}'
1096 '{if(bookmarks, "{bookmarks} ")}'
1094 '{ifeq(branch, "default", "", "{branch} ")}'
1097 '{ifeq(branch, "default", "", "{branch} ")}'
1095 '- {author|user}: {desc|firstline}')
1098 '- {author|user}: {desc|firstline}')
1096 )
1099 )
1097 coreconfigitem('ui', 'nontty',
1100 coreconfigitem('ui', 'nontty',
1098 default=False,
1101 default=False,
1099 )
1102 )
1100 coreconfigitem('ui', 'origbackuppath',
1103 coreconfigitem('ui', 'origbackuppath',
1101 default=None,
1104 default=None,
1102 )
1105 )
1103 coreconfigitem('ui', 'paginate',
1106 coreconfigitem('ui', 'paginate',
1104 default=True,
1107 default=True,
1105 )
1108 )
1106 coreconfigitem('ui', 'patch',
1109 coreconfigitem('ui', 'patch',
1107 default=None,
1110 default=None,
1108 )
1111 )
1109 coreconfigitem('ui', 'portablefilenames',
1112 coreconfigitem('ui', 'portablefilenames',
1110 default='warn',
1113 default='warn',
1111 )
1114 )
1112 coreconfigitem('ui', 'promptecho',
1115 coreconfigitem('ui', 'promptecho',
1113 default=False,
1116 default=False,
1114 )
1117 )
1115 coreconfigitem('ui', 'quiet',
1118 coreconfigitem('ui', 'quiet',
1116 default=False,
1119 default=False,
1117 )
1120 )
1118 coreconfigitem('ui', 'quietbookmarkmove',
1121 coreconfigitem('ui', 'quietbookmarkmove',
1119 default=False,
1122 default=False,
1120 )
1123 )
1121 coreconfigitem('ui', 'remotecmd',
1124 coreconfigitem('ui', 'remotecmd',
1122 default='hg',
1125 default='hg',
1123 )
1126 )
1124 coreconfigitem('ui', 'report_untrusted',
1127 coreconfigitem('ui', 'report_untrusted',
1125 default=True,
1128 default=True,
1126 )
1129 )
1127 coreconfigitem('ui', 'rollback',
1130 coreconfigitem('ui', 'rollback',
1128 default=True,
1131 default=True,
1129 )
1132 )
1130 coreconfigitem('ui', 'slash',
1133 coreconfigitem('ui', 'slash',
1131 default=False,
1134 default=False,
1132 )
1135 )
1133 coreconfigitem('ui', 'ssh',
1136 coreconfigitem('ui', 'ssh',
1134 default='ssh',
1137 default='ssh',
1135 )
1138 )
1136 coreconfigitem('ui', 'ssherrorhint',
1139 coreconfigitem('ui', 'ssherrorhint',
1137 default=None,
1140 default=None,
1138 )
1141 )
1139 coreconfigitem('ui', 'statuscopies',
1142 coreconfigitem('ui', 'statuscopies',
1140 default=False,
1143 default=False,
1141 )
1144 )
1142 coreconfigitem('ui', 'strict',
1145 coreconfigitem('ui', 'strict',
1143 default=False,
1146 default=False,
1144 )
1147 )
1145 coreconfigitem('ui', 'style',
1148 coreconfigitem('ui', 'style',
1146 default='',
1149 default='',
1147 )
1150 )
1148 coreconfigitem('ui', 'supportcontact',
1151 coreconfigitem('ui', 'supportcontact',
1149 default=None,
1152 default=None,
1150 )
1153 )
1151 coreconfigitem('ui', 'textwidth',
1154 coreconfigitem('ui', 'textwidth',
1152 default=78,
1155 default=78,
1153 )
1156 )
1154 coreconfigitem('ui', 'timeout',
1157 coreconfigitem('ui', 'timeout',
1155 default='600',
1158 default='600',
1156 )
1159 )
1157 coreconfigitem('ui', 'timeout.warn',
1160 coreconfigitem('ui', 'timeout.warn',
1158 default=0,
1161 default=0,
1159 )
1162 )
1160 coreconfigitem('ui', 'traceback',
1163 coreconfigitem('ui', 'traceback',
1161 default=False,
1164 default=False,
1162 )
1165 )
1163 coreconfigitem('ui', 'tweakdefaults',
1166 coreconfigitem('ui', 'tweakdefaults',
1164 default=False,
1167 default=False,
1165 )
1168 )
1166 coreconfigitem('ui', 'username',
1169 coreconfigitem('ui', 'username',
1167 alias=[('ui', 'user')]
1170 alias=[('ui', 'user')]
1168 )
1171 )
1169 coreconfigitem('ui', 'verbose',
1172 coreconfigitem('ui', 'verbose',
1170 default=False,
1173 default=False,
1171 )
1174 )
1172 coreconfigitem('verify', 'skipflags',
1175 coreconfigitem('verify', 'skipflags',
1173 default=None,
1176 default=None,
1174 )
1177 )
1175 coreconfigitem('web', 'allowbz2',
1178 coreconfigitem('web', 'allowbz2',
1176 default=False,
1179 default=False,
1177 )
1180 )
1178 coreconfigitem('web', 'allowgz',
1181 coreconfigitem('web', 'allowgz',
1179 default=False,
1182 default=False,
1180 )
1183 )
1181 coreconfigitem('web', 'allow-pull',
1184 coreconfigitem('web', 'allow-pull',
1182 alias=[('web', 'allowpull')],
1185 alias=[('web', 'allowpull')],
1183 default=True,
1186 default=True,
1184 )
1187 )
1185 coreconfigitem('web', 'allow-push',
1188 coreconfigitem('web', 'allow-push',
1186 alias=[('web', 'allow_push')],
1189 alias=[('web', 'allow_push')],
1187 default=list,
1190 default=list,
1188 )
1191 )
1189 coreconfigitem('web', 'allowzip',
1192 coreconfigitem('web', 'allowzip',
1190 default=False,
1193 default=False,
1191 )
1194 )
1192 coreconfigitem('web', 'archivesubrepos',
1195 coreconfigitem('web', 'archivesubrepos',
1193 default=False,
1196 default=False,
1194 )
1197 )
1195 coreconfigitem('web', 'cache',
1198 coreconfigitem('web', 'cache',
1196 default=True,
1199 default=True,
1197 )
1200 )
1198 coreconfigitem('web', 'contact',
1201 coreconfigitem('web', 'contact',
1199 default=None,
1202 default=None,
1200 )
1203 )
1201 coreconfigitem('web', 'deny_push',
1204 coreconfigitem('web', 'deny_push',
1202 default=list,
1205 default=list,
1203 )
1206 )
1204 coreconfigitem('web', 'guessmime',
1207 coreconfigitem('web', 'guessmime',
1205 default=False,
1208 default=False,
1206 )
1209 )
1207 coreconfigitem('web', 'hidden',
1210 coreconfigitem('web', 'hidden',
1208 default=False,
1211 default=False,
1209 )
1212 )
1210 coreconfigitem('web', 'labels',
1213 coreconfigitem('web', 'labels',
1211 default=list,
1214 default=list,
1212 )
1215 )
1213 coreconfigitem('web', 'logoimg',
1216 coreconfigitem('web', 'logoimg',
1214 default='hglogo.png',
1217 default='hglogo.png',
1215 )
1218 )
1216 coreconfigitem('web', 'logourl',
1219 coreconfigitem('web', 'logourl',
1217 default='https://mercurial-scm.org/',
1220 default='https://mercurial-scm.org/',
1218 )
1221 )
1219 coreconfigitem('web', 'accesslog',
1222 coreconfigitem('web', 'accesslog',
1220 default='-',
1223 default='-',
1221 )
1224 )
1222 coreconfigitem('web', 'address',
1225 coreconfigitem('web', 'address',
1223 default='',
1226 default='',
1224 )
1227 )
1225 coreconfigitem('web', 'allow_archive',
1228 coreconfigitem('web', 'allow_archive',
1226 default=list,
1229 default=list,
1227 )
1230 )
1228 coreconfigitem('web', 'allow_read',
1231 coreconfigitem('web', 'allow_read',
1229 default=list,
1232 default=list,
1230 )
1233 )
1231 coreconfigitem('web', 'baseurl',
1234 coreconfigitem('web', 'baseurl',
1232 default=None,
1235 default=None,
1233 )
1236 )
1234 coreconfigitem('web', 'cacerts',
1237 coreconfigitem('web', 'cacerts',
1235 default=None,
1238 default=None,
1236 )
1239 )
1237 coreconfigitem('web', 'certificate',
1240 coreconfigitem('web', 'certificate',
1238 default=None,
1241 default=None,
1239 )
1242 )
1240 coreconfigitem('web', 'collapse',
1243 coreconfigitem('web', 'collapse',
1241 default=False,
1244 default=False,
1242 )
1245 )
1243 coreconfigitem('web', 'csp',
1246 coreconfigitem('web', 'csp',
1244 default=None,
1247 default=None,
1245 )
1248 )
1246 coreconfigitem('web', 'deny_read',
1249 coreconfigitem('web', 'deny_read',
1247 default=list,
1250 default=list,
1248 )
1251 )
1249 coreconfigitem('web', 'descend',
1252 coreconfigitem('web', 'descend',
1250 default=True,
1253 default=True,
1251 )
1254 )
1252 coreconfigitem('web', 'description',
1255 coreconfigitem('web', 'description',
1253 default="",
1256 default="",
1254 )
1257 )
1255 coreconfigitem('web', 'encoding',
1258 coreconfigitem('web', 'encoding',
1256 default=lambda: encoding.encoding,
1259 default=lambda: encoding.encoding,
1257 )
1260 )
1258 coreconfigitem('web', 'errorlog',
1261 coreconfigitem('web', 'errorlog',
1259 default='-',
1262 default='-',
1260 )
1263 )
1261 coreconfigitem('web', 'ipv6',
1264 coreconfigitem('web', 'ipv6',
1262 default=False,
1265 default=False,
1263 )
1266 )
1264 coreconfigitem('web', 'maxchanges',
1267 coreconfigitem('web', 'maxchanges',
1265 default=10,
1268 default=10,
1266 )
1269 )
1267 coreconfigitem('web', 'maxfiles',
1270 coreconfigitem('web', 'maxfiles',
1268 default=10,
1271 default=10,
1269 )
1272 )
1270 coreconfigitem('web', 'maxshortchanges',
1273 coreconfigitem('web', 'maxshortchanges',
1271 default=60,
1274 default=60,
1272 )
1275 )
1273 coreconfigitem('web', 'motd',
1276 coreconfigitem('web', 'motd',
1274 default='',
1277 default='',
1275 )
1278 )
1276 coreconfigitem('web', 'name',
1279 coreconfigitem('web', 'name',
1277 default=dynamicdefault,
1280 default=dynamicdefault,
1278 )
1281 )
1279 coreconfigitem('web', 'port',
1282 coreconfigitem('web', 'port',
1280 default=8000,
1283 default=8000,
1281 )
1284 )
1282 coreconfigitem('web', 'prefix',
1285 coreconfigitem('web', 'prefix',
1283 default='',
1286 default='',
1284 )
1287 )
1285 coreconfigitem('web', 'push_ssl',
1288 coreconfigitem('web', 'push_ssl',
1286 default=True,
1289 default=True,
1287 )
1290 )
1288 coreconfigitem('web', 'refreshinterval',
1291 coreconfigitem('web', 'refreshinterval',
1289 default=20,
1292 default=20,
1290 )
1293 )
1291 coreconfigitem('web', 'server-header',
1294 coreconfigitem('web', 'server-header',
1292 default=None,
1295 default=None,
1293 )
1296 )
1294 coreconfigitem('web', 'staticurl',
1297 coreconfigitem('web', 'staticurl',
1295 default=None,
1298 default=None,
1296 )
1299 )
1297 coreconfigitem('web', 'stripes',
1300 coreconfigitem('web', 'stripes',
1298 default=1,
1301 default=1,
1299 )
1302 )
1300 coreconfigitem('web', 'style',
1303 coreconfigitem('web', 'style',
1301 default='paper',
1304 default='paper',
1302 )
1305 )
1303 coreconfigitem('web', 'templates',
1306 coreconfigitem('web', 'templates',
1304 default=None,
1307 default=None,
1305 )
1308 )
1306 coreconfigitem('web', 'view',
1309 coreconfigitem('web', 'view',
1307 default='served',
1310 default='served',
1308 )
1311 )
1309 coreconfigitem('worker', 'backgroundclose',
1312 coreconfigitem('worker', 'backgroundclose',
1310 default=dynamicdefault,
1313 default=dynamicdefault,
1311 )
1314 )
1312 # Windows defaults to a limit of 512 open files. A buffer of 128
1315 # Windows defaults to a limit of 512 open files. A buffer of 128
1313 # should give us enough headway.
1316 # should give us enough headway.
1314 coreconfigitem('worker', 'backgroundclosemaxqueue',
1317 coreconfigitem('worker', 'backgroundclosemaxqueue',
1315 default=384,
1318 default=384,
1316 )
1319 )
1317 coreconfigitem('worker', 'backgroundcloseminfilecount',
1320 coreconfigitem('worker', 'backgroundcloseminfilecount',
1318 default=2048,
1321 default=2048,
1319 )
1322 )
1320 coreconfigitem('worker', 'backgroundclosethreadcount',
1323 coreconfigitem('worker', 'backgroundclosethreadcount',
1321 default=4,
1324 default=4,
1322 )
1325 )
1323 coreconfigitem('worker', 'enabled',
1326 coreconfigitem('worker', 'enabled',
1324 default=True,
1327 default=True,
1325 )
1328 )
1326 coreconfigitem('worker', 'numcpus',
1329 coreconfigitem('worker', 'numcpus',
1327 default=None,
1330 default=None,
1328 )
1331 )
1329
1332
1330 # Rebase related configuration moved to core because other extension are doing
1333 # Rebase related configuration moved to core because other extension are doing
1331 # strange things. For example, shelve import the extensions to reuse some bit
1334 # strange things. For example, shelve import the extensions to reuse some bit
1332 # without formally loading it.
1335 # without formally loading it.
1333 coreconfigitem('commands', 'rebase.requiredest',
1336 coreconfigitem('commands', 'rebase.requiredest',
1334 default=False,
1337 default=False,
1335 )
1338 )
1336 coreconfigitem('experimental', 'rebaseskipobsolete',
1339 coreconfigitem('experimental', 'rebaseskipobsolete',
1337 default=True,
1340 default=True,
1338 )
1341 )
1339 coreconfigitem('rebase', 'singletransaction',
1342 coreconfigitem('rebase', 'singletransaction',
1340 default=False,
1343 default=False,
1341 )
1344 )
1342 coreconfigitem('rebase', 'experimental.inmemory',
1345 coreconfigitem('rebase', 'experimental.inmemory',
1343 default=False,
1346 default=False,
1344 )
1347 )
@@ -1,2636 +1,2640 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 ``status.relative``
441 ``status.relative``
442 Make paths in :hg:`status` output relative to the current directory.
442 Make paths in :hg:`status` output relative to the current directory.
443 (default: False)
443 (default: False)
444
444
445 ``status.terse``
446 Default value for the --terse flag, which condenes status output.
447 (default: empty)
448
445 ``update.check``
449 ``update.check``
446 Determines what level of checking :hg:`update` will perform before moving
450 Determines what level of checking :hg:`update` will perform before moving
447 to a destination revision. Valid values are ``abort``, ``none``,
451 to a destination revision. Valid values are ``abort``, ``none``,
448 ``linear``, and ``noconflict``. ``abort`` always fails if the working
452 ``linear``, and ``noconflict``. ``abort`` always fails if the working
449 directory has uncommitted changes. ``none`` performs no checking, and may
453 directory has uncommitted changes. ``none`` performs no checking, and may
450 result in a merge with uncommitted changes. ``linear`` allows any update
454 result in a merge with uncommitted changes. ``linear`` allows any update
451 as long as it follows a straight line in the revision history, and may
455 as long as it follows a straight line in the revision history, and may
452 trigger a merge with uncommitted changes. ``noconflict`` will allow any
456 trigger a merge with uncommitted changes. ``noconflict`` will allow any
453 update which would not trigger a merge with uncommitted changes, if any
457 update which would not trigger a merge with uncommitted changes, if any
454 are present.
458 are present.
455 (default: ``linear``)
459 (default: ``linear``)
456
460
457 ``update.requiredest``
461 ``update.requiredest``
458 Require that the user pass a destination when running :hg:`update`.
462 Require that the user pass a destination when running :hg:`update`.
459 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
463 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
460 will be disallowed.
464 will be disallowed.
461 (default: False)
465 (default: False)
462
466
463 ``committemplate``
467 ``committemplate``
464 ------------------
468 ------------------
465
469
466 ``changeset``
470 ``changeset``
467 String: configuration in this section is used as the template to
471 String: configuration in this section is used as the template to
468 customize the text shown in the editor when committing.
472 customize the text shown in the editor when committing.
469
473
470 In addition to pre-defined template keywords, commit log specific one
474 In addition to pre-defined template keywords, commit log specific one
471 below can be used for customization:
475 below can be used for customization:
472
476
473 ``extramsg``
477 ``extramsg``
474 String: Extra message (typically 'Leave message empty to abort
478 String: Extra message (typically 'Leave message empty to abort
475 commit.'). This may be changed by some commands or extensions.
479 commit.'). This may be changed by some commands or extensions.
476
480
477 For example, the template configuration below shows as same text as
481 For example, the template configuration below shows as same text as
478 one shown by default::
482 one shown by default::
479
483
480 [committemplate]
484 [committemplate]
481 changeset = {desc}\n\n
485 changeset = {desc}\n\n
482 HG: Enter commit message. Lines beginning with 'HG:' are removed.
486 HG: Enter commit message. Lines beginning with 'HG:' are removed.
483 HG: {extramsg}
487 HG: {extramsg}
484 HG: --
488 HG: --
485 HG: user: {author}\n{ifeq(p2rev, "-1", "",
489 HG: user: {author}\n{ifeq(p2rev, "-1", "",
486 "HG: branch merge\n")
490 "HG: branch merge\n")
487 }HG: branch '{branch}'\n{if(activebookmark,
491 }HG: branch '{branch}'\n{if(activebookmark,
488 "HG: bookmark '{activebookmark}'\n") }{subrepos %
492 "HG: bookmark '{activebookmark}'\n") }{subrepos %
489 "HG: subrepo {subrepo}\n" }{file_adds %
493 "HG: subrepo {subrepo}\n" }{file_adds %
490 "HG: added {file}\n" }{file_mods %
494 "HG: added {file}\n" }{file_mods %
491 "HG: changed {file}\n" }{file_dels %
495 "HG: changed {file}\n" }{file_dels %
492 "HG: removed {file}\n" }{if(files, "",
496 "HG: removed {file}\n" }{if(files, "",
493 "HG: no files changed\n")}
497 "HG: no files changed\n")}
494
498
495 ``diff()``
499 ``diff()``
496 String: show the diff (see :hg:`help templates` for detail)
500 String: show the diff (see :hg:`help templates` for detail)
497
501
498 Sometimes it is helpful to show the diff of the changeset in the editor without
502 Sometimes it is helpful to show the diff of the changeset in the editor without
499 having to prefix 'HG: ' to each line so that highlighting works correctly. For
503 having to prefix 'HG: ' to each line so that highlighting works correctly. For
500 this, Mercurial provides a special string which will ignore everything below
504 this, Mercurial provides a special string which will ignore everything below
501 it::
505 it::
502
506
503 HG: ------------------------ >8 ------------------------
507 HG: ------------------------ >8 ------------------------
504
508
505 For example, the template configuration below will show the diff below the
509 For example, the template configuration below will show the diff below the
506 extra message::
510 extra message::
507
511
508 [committemplate]
512 [committemplate]
509 changeset = {desc}\n\n
513 changeset = {desc}\n\n
510 HG: Enter commit message. Lines beginning with 'HG:' are removed.
514 HG: Enter commit message. Lines beginning with 'HG:' are removed.
511 HG: {extramsg}
515 HG: {extramsg}
512 HG: ------------------------ >8 ------------------------
516 HG: ------------------------ >8 ------------------------
513 HG: Do not touch the line above.
517 HG: Do not touch the line above.
514 HG: Everything below will be removed.
518 HG: Everything below will be removed.
515 {diff()}
519 {diff()}
516
520
517 .. note::
521 .. note::
518
522
519 For some problematic encodings (see :hg:`help win32mbcs` for
523 For some problematic encodings (see :hg:`help win32mbcs` for
520 detail), this customization should be configured carefully, to
524 detail), this customization should be configured carefully, to
521 avoid showing broken characters.
525 avoid showing broken characters.
522
526
523 For example, if a multibyte character ending with backslash (0x5c) is
527 For example, if a multibyte character ending with backslash (0x5c) is
524 followed by the ASCII character 'n' in the customized template,
528 followed by the ASCII character 'n' in the customized template,
525 the sequence of backslash and 'n' is treated as line-feed unexpectedly
529 the sequence of backslash and 'n' is treated as line-feed unexpectedly
526 (and the multibyte character is broken, too).
530 (and the multibyte character is broken, too).
527
531
528 Customized template is used for commands below (``--edit`` may be
532 Customized template is used for commands below (``--edit`` may be
529 required):
533 required):
530
534
531 - :hg:`backout`
535 - :hg:`backout`
532 - :hg:`commit`
536 - :hg:`commit`
533 - :hg:`fetch` (for merge commit only)
537 - :hg:`fetch` (for merge commit only)
534 - :hg:`graft`
538 - :hg:`graft`
535 - :hg:`histedit`
539 - :hg:`histedit`
536 - :hg:`import`
540 - :hg:`import`
537 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
541 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
538 - :hg:`rebase`
542 - :hg:`rebase`
539 - :hg:`shelve`
543 - :hg:`shelve`
540 - :hg:`sign`
544 - :hg:`sign`
541 - :hg:`tag`
545 - :hg:`tag`
542 - :hg:`transplant`
546 - :hg:`transplant`
543
547
544 Configuring items below instead of ``changeset`` allows showing
548 Configuring items below instead of ``changeset`` allows showing
545 customized message only for specific actions, or showing different
549 customized message only for specific actions, or showing different
546 messages for each action.
550 messages for each action.
547
551
548 - ``changeset.backout`` for :hg:`backout`
552 - ``changeset.backout`` for :hg:`backout`
549 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
553 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
550 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
554 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
551 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
555 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
552 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
556 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
553 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
557 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
554 - ``changeset.gpg.sign`` for :hg:`sign`
558 - ``changeset.gpg.sign`` for :hg:`sign`
555 - ``changeset.graft`` for :hg:`graft`
559 - ``changeset.graft`` for :hg:`graft`
556 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
560 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
557 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
561 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
558 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
562 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
559 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
563 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
560 - ``changeset.import.bypass`` for :hg:`import --bypass`
564 - ``changeset.import.bypass`` for :hg:`import --bypass`
561 - ``changeset.import.normal.merge`` for :hg:`import` on merges
565 - ``changeset.import.normal.merge`` for :hg:`import` on merges
562 - ``changeset.import.normal.normal`` for :hg:`import` on other
566 - ``changeset.import.normal.normal`` for :hg:`import` on other
563 - ``changeset.mq.qnew`` for :hg:`qnew`
567 - ``changeset.mq.qnew`` for :hg:`qnew`
564 - ``changeset.mq.qfold`` for :hg:`qfold`
568 - ``changeset.mq.qfold`` for :hg:`qfold`
565 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
569 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
566 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
570 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
567 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
571 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
568 - ``changeset.rebase.normal`` for :hg:`rebase` on other
572 - ``changeset.rebase.normal`` for :hg:`rebase` on other
569 - ``changeset.shelve.shelve`` for :hg:`shelve`
573 - ``changeset.shelve.shelve`` for :hg:`shelve`
570 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
574 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
571 - ``changeset.tag.remove`` for :hg:`tag --remove`
575 - ``changeset.tag.remove`` for :hg:`tag --remove`
572 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
576 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
573 - ``changeset.transplant.normal`` for :hg:`transplant` on other
577 - ``changeset.transplant.normal`` for :hg:`transplant` on other
574
578
575 These dot-separated lists of names are treated as hierarchical ones.
579 These dot-separated lists of names are treated as hierarchical ones.
576 For example, ``changeset.tag.remove`` customizes the commit message
580 For example, ``changeset.tag.remove`` customizes the commit message
577 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
581 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
578 commit message for :hg:`tag` regardless of ``--remove`` option.
582 commit message for :hg:`tag` regardless of ``--remove`` option.
579
583
580 When the external editor is invoked for a commit, the corresponding
584 When the external editor is invoked for a commit, the corresponding
581 dot-separated list of names without the ``changeset.`` prefix
585 dot-separated list of names without the ``changeset.`` prefix
582 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
586 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
583 variable.
587 variable.
584
588
585 In this section, items other than ``changeset`` can be referred from
589 In this section, items other than ``changeset`` can be referred from
586 others. For example, the configuration to list committed files up
590 others. For example, the configuration to list committed files up
587 below can be referred as ``{listupfiles}``::
591 below can be referred as ``{listupfiles}``::
588
592
589 [committemplate]
593 [committemplate]
590 listupfiles = {file_adds %
594 listupfiles = {file_adds %
591 "HG: added {file}\n" }{file_mods %
595 "HG: added {file}\n" }{file_mods %
592 "HG: changed {file}\n" }{file_dels %
596 "HG: changed {file}\n" }{file_dels %
593 "HG: removed {file}\n" }{if(files, "",
597 "HG: removed {file}\n" }{if(files, "",
594 "HG: no files changed\n")}
598 "HG: no files changed\n")}
595
599
596 ``decode/encode``
600 ``decode/encode``
597 -----------------
601 -----------------
598
602
599 Filters for transforming files on checkout/checkin. This would
603 Filters for transforming files on checkout/checkin. This would
600 typically be used for newline processing or other
604 typically be used for newline processing or other
601 localization/canonicalization of files.
605 localization/canonicalization of files.
602
606
603 Filters consist of a filter pattern followed by a filter command.
607 Filters consist of a filter pattern followed by a filter command.
604 Filter patterns are globs by default, rooted at the repository root.
608 Filter patterns are globs by default, rooted at the repository root.
605 For example, to match any file ending in ``.txt`` in the root
609 For example, to match any file ending in ``.txt`` in the root
606 directory only, use the pattern ``*.txt``. To match any file ending
610 directory only, use the pattern ``*.txt``. To match any file ending
607 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
611 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
608 For each file only the first matching filter applies.
612 For each file only the first matching filter applies.
609
613
610 The filter command can start with a specifier, either ``pipe:`` or
614 The filter command can start with a specifier, either ``pipe:`` or
611 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
615 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
612
616
613 A ``pipe:`` command must accept data on stdin and return the transformed
617 A ``pipe:`` command must accept data on stdin and return the transformed
614 data on stdout.
618 data on stdout.
615
619
616 Pipe example::
620 Pipe example::
617
621
618 [encode]
622 [encode]
619 # uncompress gzip files on checkin to improve delta compression
623 # uncompress gzip files on checkin to improve delta compression
620 # note: not necessarily a good idea, just an example
624 # note: not necessarily a good idea, just an example
621 *.gz = pipe: gunzip
625 *.gz = pipe: gunzip
622
626
623 [decode]
627 [decode]
624 # recompress gzip files when writing them to the working dir (we
628 # recompress gzip files when writing them to the working dir (we
625 # can safely omit "pipe:", because it's the default)
629 # can safely omit "pipe:", because it's the default)
626 *.gz = gzip
630 *.gz = gzip
627
631
628 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
632 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
629 with the name of a temporary file that contains the data to be
633 with the name of a temporary file that contains the data to be
630 filtered by the command. The string ``OUTFILE`` is replaced with the name
634 filtered by the command. The string ``OUTFILE`` is replaced with the name
631 of an empty temporary file, where the filtered data must be written by
635 of an empty temporary file, where the filtered data must be written by
632 the command.
636 the command.
633
637
634 .. container:: windows
638 .. container:: windows
635
639
636 .. note::
640 .. note::
637
641
638 The tempfile mechanism is recommended for Windows systems,
642 The tempfile mechanism is recommended for Windows systems,
639 where the standard shell I/O redirection operators often have
643 where the standard shell I/O redirection operators often have
640 strange effects and may corrupt the contents of your files.
644 strange effects and may corrupt the contents of your files.
641
645
642 This filter mechanism is used internally by the ``eol`` extension to
646 This filter mechanism is used internally by the ``eol`` extension to
643 translate line ending characters between Windows (CRLF) and Unix (LF)
647 translate line ending characters between Windows (CRLF) and Unix (LF)
644 format. We suggest you use the ``eol`` extension for convenience.
648 format. We suggest you use the ``eol`` extension for convenience.
645
649
646
650
647 ``defaults``
651 ``defaults``
648 ------------
652 ------------
649
653
650 (defaults are deprecated. Don't use them. Use aliases instead.)
654 (defaults are deprecated. Don't use them. Use aliases instead.)
651
655
652 Use the ``[defaults]`` section to define command defaults, i.e. the
656 Use the ``[defaults]`` section to define command defaults, i.e. the
653 default options/arguments to pass to the specified commands.
657 default options/arguments to pass to the specified commands.
654
658
655 The following example makes :hg:`log` run in verbose mode, and
659 The following example makes :hg:`log` run in verbose mode, and
656 :hg:`status` show only the modified files, by default::
660 :hg:`status` show only the modified files, by default::
657
661
658 [defaults]
662 [defaults]
659 log = -v
663 log = -v
660 status = -m
664 status = -m
661
665
662 The actual commands, instead of their aliases, must be used when
666 The actual commands, instead of their aliases, must be used when
663 defining command defaults. The command defaults will also be applied
667 defining command defaults. The command defaults will also be applied
664 to the aliases of the commands defined.
668 to the aliases of the commands defined.
665
669
666
670
667 ``diff``
671 ``diff``
668 --------
672 --------
669
673
670 Settings used when displaying diffs. Everything except for ``unified``
674 Settings used when displaying diffs. Everything except for ``unified``
671 is a Boolean and defaults to False. See :hg:`help config.annotate`
675 is a Boolean and defaults to False. See :hg:`help config.annotate`
672 for related options for the annotate command.
676 for related options for the annotate command.
673
677
674 ``git``
678 ``git``
675 Use git extended diff format.
679 Use git extended diff format.
676
680
677 ``nobinary``
681 ``nobinary``
678 Omit git binary patches.
682 Omit git binary patches.
679
683
680 ``nodates``
684 ``nodates``
681 Don't include dates in diff headers.
685 Don't include dates in diff headers.
682
686
683 ``noprefix``
687 ``noprefix``
684 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
688 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
685
689
686 ``showfunc``
690 ``showfunc``
687 Show which function each change is in.
691 Show which function each change is in.
688
692
689 ``ignorews``
693 ``ignorews``
690 Ignore white space when comparing lines.
694 Ignore white space when comparing lines.
691
695
692 ``ignorewsamount``
696 ``ignorewsamount``
693 Ignore changes in the amount of white space.
697 Ignore changes in the amount of white space.
694
698
695 ``ignoreblanklines``
699 ``ignoreblanklines``
696 Ignore changes whose lines are all blank.
700 Ignore changes whose lines are all blank.
697
701
698 ``unified``
702 ``unified``
699 Number of lines of context to show.
703 Number of lines of context to show.
700
704
701 ``email``
705 ``email``
702 ---------
706 ---------
703
707
704 Settings for extensions that send email messages.
708 Settings for extensions that send email messages.
705
709
706 ``from``
710 ``from``
707 Optional. Email address to use in "From" header and SMTP envelope
711 Optional. Email address to use in "From" header and SMTP envelope
708 of outgoing messages.
712 of outgoing messages.
709
713
710 ``to``
714 ``to``
711 Optional. Comma-separated list of recipients' email addresses.
715 Optional. Comma-separated list of recipients' email addresses.
712
716
713 ``cc``
717 ``cc``
714 Optional. Comma-separated list of carbon copy recipients'
718 Optional. Comma-separated list of carbon copy recipients'
715 email addresses.
719 email addresses.
716
720
717 ``bcc``
721 ``bcc``
718 Optional. Comma-separated list of blind carbon copy recipients'
722 Optional. Comma-separated list of blind carbon copy recipients'
719 email addresses.
723 email addresses.
720
724
721 ``method``
725 ``method``
722 Optional. Method to use to send email messages. If value is ``smtp``
726 Optional. Method to use to send email messages. If value is ``smtp``
723 (default), use SMTP (see the ``[smtp]`` section for configuration).
727 (default), use SMTP (see the ``[smtp]`` section for configuration).
724 Otherwise, use as name of program to run that acts like sendmail
728 Otherwise, use as name of program to run that acts like sendmail
725 (takes ``-f`` option for sender, list of recipients on command line,
729 (takes ``-f`` option for sender, list of recipients on command line,
726 message on stdin). Normally, setting this to ``sendmail`` or
730 message on stdin). Normally, setting this to ``sendmail`` or
727 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
731 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
728
732
729 ``charsets``
733 ``charsets``
730 Optional. Comma-separated list of character sets considered
734 Optional. Comma-separated list of character sets considered
731 convenient for recipients. Addresses, headers, and parts not
735 convenient for recipients. Addresses, headers, and parts not
732 containing patches of outgoing messages will be encoded in the
736 containing patches of outgoing messages will be encoded in the
733 first character set to which conversion from local encoding
737 first character set to which conversion from local encoding
734 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
738 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
735 conversion fails, the text in question is sent as is.
739 conversion fails, the text in question is sent as is.
736 (default: '')
740 (default: '')
737
741
738 Order of outgoing email character sets:
742 Order of outgoing email character sets:
739
743
740 1. ``us-ascii``: always first, regardless of settings
744 1. ``us-ascii``: always first, regardless of settings
741 2. ``email.charsets``: in order given by user
745 2. ``email.charsets``: in order given by user
742 3. ``ui.fallbackencoding``: if not in email.charsets
746 3. ``ui.fallbackencoding``: if not in email.charsets
743 4. ``$HGENCODING``: if not in email.charsets
747 4. ``$HGENCODING``: if not in email.charsets
744 5. ``utf-8``: always last, regardless of settings
748 5. ``utf-8``: always last, regardless of settings
745
749
746 Email example::
750 Email example::
747
751
748 [email]
752 [email]
749 from = Joseph User <joe.user@example.com>
753 from = Joseph User <joe.user@example.com>
750 method = /usr/sbin/sendmail
754 method = /usr/sbin/sendmail
751 # charsets for western Europeans
755 # charsets for western Europeans
752 # us-ascii, utf-8 omitted, as they are tried first and last
756 # us-ascii, utf-8 omitted, as they are tried first and last
753 charsets = iso-8859-1, iso-8859-15, windows-1252
757 charsets = iso-8859-1, iso-8859-15, windows-1252
754
758
755
759
756 ``extensions``
760 ``extensions``
757 --------------
761 --------------
758
762
759 Mercurial has an extension mechanism for adding new features. To
763 Mercurial has an extension mechanism for adding new features. To
760 enable an extension, create an entry for it in this section.
764 enable an extension, create an entry for it in this section.
761
765
762 If you know that the extension is already in Python's search path,
766 If you know that the extension is already in Python's search path,
763 you can give the name of the module, followed by ``=``, with nothing
767 you can give the name of the module, followed by ``=``, with nothing
764 after the ``=``.
768 after the ``=``.
765
769
766 Otherwise, give a name that you choose, followed by ``=``, followed by
770 Otherwise, give a name that you choose, followed by ``=``, followed by
767 the path to the ``.py`` file (including the file name extension) that
771 the path to the ``.py`` file (including the file name extension) that
768 defines the extension.
772 defines the extension.
769
773
770 To explicitly disable an extension that is enabled in an hgrc of
774 To explicitly disable an extension that is enabled in an hgrc of
771 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
775 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
772 or ``foo = !`` when path is not supplied.
776 or ``foo = !`` when path is not supplied.
773
777
774 Example for ``~/.hgrc``::
778 Example for ``~/.hgrc``::
775
779
776 [extensions]
780 [extensions]
777 # (the churn extension will get loaded from Mercurial's path)
781 # (the churn extension will get loaded from Mercurial's path)
778 churn =
782 churn =
779 # (this extension will get loaded from the file specified)
783 # (this extension will get loaded from the file specified)
780 myfeature = ~/.hgext/myfeature.py
784 myfeature = ~/.hgext/myfeature.py
781
785
782
786
783 ``format``
787 ``format``
784 ----------
788 ----------
785
789
786 ``usegeneraldelta``
790 ``usegeneraldelta``
787 Enable or disable the "generaldelta" repository format which improves
791 Enable or disable the "generaldelta" repository format which improves
788 repository compression by allowing "revlog" to store delta against arbitrary
792 repository compression by allowing "revlog" to store delta against arbitrary
789 revision instead of the previous stored one. This provides significant
793 revision instead of the previous stored one. This provides significant
790 improvement for repositories with branches.
794 improvement for repositories with branches.
791
795
792 Repositories with this on-disk format require Mercurial version 1.9.
796 Repositories with this on-disk format require Mercurial version 1.9.
793
797
794 Enabled by default.
798 Enabled by default.
795
799
796 ``dotencode``
800 ``dotencode``
797 Enable or disable the "dotencode" repository format which enhances
801 Enable or disable the "dotencode" repository format which enhances
798 the "fncache" repository format (which has to be enabled to use
802 the "fncache" repository format (which has to be enabled to use
799 dotencode) to avoid issues with filenames starting with ._ on
803 dotencode) to avoid issues with filenames starting with ._ on
800 Mac OS X and spaces on Windows.
804 Mac OS X and spaces on Windows.
801
805
802 Repositories with this on-disk format require Mercurial version 1.7.
806 Repositories with this on-disk format require Mercurial version 1.7.
803
807
804 Enabled by default.
808 Enabled by default.
805
809
806 ``usefncache``
810 ``usefncache``
807 Enable or disable the "fncache" repository format which enhances
811 Enable or disable the "fncache" repository format which enhances
808 the "store" repository format (which has to be enabled to use
812 the "store" repository format (which has to be enabled to use
809 fncache) to allow longer filenames and avoids using Windows
813 fncache) to allow longer filenames and avoids using Windows
810 reserved names, e.g. "nul".
814 reserved names, e.g. "nul".
811
815
812 Repositories with this on-disk format require Mercurial version 1.1.
816 Repositories with this on-disk format require Mercurial version 1.1.
813
817
814 Enabled by default.
818 Enabled by default.
815
819
816 ``usestore``
820 ``usestore``
817 Enable or disable the "store" repository format which improves
821 Enable or disable the "store" repository format which improves
818 compatibility with systems that fold case or otherwise mangle
822 compatibility with systems that fold case or otherwise mangle
819 filenames. Disabling this option will allow you to store longer filenames
823 filenames. Disabling this option will allow you to store longer filenames
820 in some situations at the expense of compatibility.
824 in some situations at the expense of compatibility.
821
825
822 Repositories with this on-disk format require Mercurial version 0.9.4.
826 Repositories with this on-disk format require Mercurial version 0.9.4.
823
827
824 Enabled by default.
828 Enabled by default.
825
829
826 ``graph``
830 ``graph``
827 ---------
831 ---------
828
832
829 Web graph view configuration. This section let you change graph
833 Web graph view configuration. This section let you change graph
830 elements display properties by branches, for instance to make the
834 elements display properties by branches, for instance to make the
831 ``default`` branch stand out.
835 ``default`` branch stand out.
832
836
833 Each line has the following format::
837 Each line has the following format::
834
838
835 <branch>.<argument> = <value>
839 <branch>.<argument> = <value>
836
840
837 where ``<branch>`` is the name of the branch being
841 where ``<branch>`` is the name of the branch being
838 customized. Example::
842 customized. Example::
839
843
840 [graph]
844 [graph]
841 # 2px width
845 # 2px width
842 default.width = 2
846 default.width = 2
843 # red color
847 # red color
844 default.color = FF0000
848 default.color = FF0000
845
849
846 Supported arguments:
850 Supported arguments:
847
851
848 ``width``
852 ``width``
849 Set branch edges width in pixels.
853 Set branch edges width in pixels.
850
854
851 ``color``
855 ``color``
852 Set branch edges color in hexadecimal RGB notation.
856 Set branch edges color in hexadecimal RGB notation.
853
857
854 ``hooks``
858 ``hooks``
855 ---------
859 ---------
856
860
857 Commands or Python functions that get automatically executed by
861 Commands or Python functions that get automatically executed by
858 various actions such as starting or finishing a commit. Multiple
862 various actions such as starting or finishing a commit. Multiple
859 hooks can be run for the same action by appending a suffix to the
863 hooks can be run for the same action by appending a suffix to the
860 action. Overriding a site-wide hook can be done by changing its
864 action. Overriding a site-wide hook can be done by changing its
861 value or setting it to an empty string. Hooks can be prioritized
865 value or setting it to an empty string. Hooks can be prioritized
862 by adding a prefix of ``priority.`` to the hook name on a new line
866 by adding a prefix of ``priority.`` to the hook name on a new line
863 and setting the priority. The default priority is 0.
867 and setting the priority. The default priority is 0.
864
868
865 Example ``.hg/hgrc``::
869 Example ``.hg/hgrc``::
866
870
867 [hooks]
871 [hooks]
868 # update working directory after adding changesets
872 # update working directory after adding changesets
869 changegroup.update = hg update
873 changegroup.update = hg update
870 # do not use the site-wide hook
874 # do not use the site-wide hook
871 incoming =
875 incoming =
872 incoming.email = /my/email/hook
876 incoming.email = /my/email/hook
873 incoming.autobuild = /my/build/hook
877 incoming.autobuild = /my/build/hook
874 # force autobuild hook to run before other incoming hooks
878 # force autobuild hook to run before other incoming hooks
875 priority.incoming.autobuild = 1
879 priority.incoming.autobuild = 1
876
880
877 Most hooks are run with environment variables set that give useful
881 Most hooks are run with environment variables set that give useful
878 additional information. For each hook below, the environment variables
882 additional information. For each hook below, the environment variables
879 it is passed are listed with names in the form ``$HG_foo``. The
883 it is passed are listed with names in the form ``$HG_foo``. The
880 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
884 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
881 They contain the type of hook which triggered the run and the full name
885 They contain the type of hook which triggered the run and the full name
882 of the hook in the config, respectively. In the example above, this will
886 of the hook in the config, respectively. In the example above, this will
883 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
887 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
884
888
885 ``changegroup``
889 ``changegroup``
886 Run after a changegroup has been added via push, pull or unbundle. The ID of
890 Run after a changegroup has been added via push, pull or unbundle. The ID of
887 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
891 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
888 The URL from which changes came is in ``$HG_URL``.
892 The URL from which changes came is in ``$HG_URL``.
889
893
890 ``commit``
894 ``commit``
891 Run after a changeset has been created in the local repository. The ID
895 Run after a changeset has been created in the local repository. The ID
892 of the newly created changeset is in ``$HG_NODE``. Parent changeset
896 of the newly created changeset is in ``$HG_NODE``. Parent changeset
893 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
897 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
894
898
895 ``incoming``
899 ``incoming``
896 Run after a changeset has been pulled, pushed, or unbundled into
900 Run after a changeset has been pulled, pushed, or unbundled into
897 the local repository. The ID of the newly arrived changeset is in
901 the local repository. The ID of the newly arrived changeset is in
898 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
902 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
899
903
900 ``outgoing``
904 ``outgoing``
901 Run after sending changes from the local repository to another. The ID of
905 Run after sending changes from the local repository to another. The ID of
902 first changeset sent is in ``$HG_NODE``. The source of operation is in
906 first changeset sent is in ``$HG_NODE``. The source of operation is in
903 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
907 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
904
908
905 ``post-<command>``
909 ``post-<command>``
906 Run after successful invocations of the associated command. The
910 Run after successful invocations of the associated command. The
907 contents of the command line are passed as ``$HG_ARGS`` and the result
911 contents of the command line are passed as ``$HG_ARGS`` and the result
908 code in ``$HG_RESULT``. Parsed command line arguments are passed as
912 code in ``$HG_RESULT``. Parsed command line arguments are passed as
909 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
913 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
910 the python data internally passed to <command>. ``$HG_OPTS`` is a
914 the python data internally passed to <command>. ``$HG_OPTS`` is a
911 dictionary of options (with unspecified options set to their defaults).
915 dictionary of options (with unspecified options set to their defaults).
912 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
916 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
913
917
914 ``fail-<command>``
918 ``fail-<command>``
915 Run after a failed invocation of an associated command. The contents
919 Run after a failed invocation of an associated command. The contents
916 of the command line are passed as ``$HG_ARGS``. Parsed command line
920 of the command line are passed as ``$HG_ARGS``. Parsed command line
917 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
921 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
918 string representations of the python data internally passed to
922 string representations of the python data internally passed to
919 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
923 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
920 options set to their defaults). ``$HG_PATS`` is a list of arguments.
924 options set to their defaults). ``$HG_PATS`` is a list of arguments.
921 Hook failure is ignored.
925 Hook failure is ignored.
922
926
923 ``pre-<command>``
927 ``pre-<command>``
924 Run before executing the associated command. The contents of the
928 Run before executing the associated command. The contents of the
925 command line are passed as ``$HG_ARGS``. Parsed command line arguments
929 command line are passed as ``$HG_ARGS``. Parsed command line arguments
926 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
930 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
927 representations of the data internally passed to <command>. ``$HG_OPTS``
931 representations of the data internally passed to <command>. ``$HG_OPTS``
928 is a dictionary of options (with unspecified options set to their
932 is a dictionary of options (with unspecified options set to their
929 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
933 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
930 failure, the command doesn't execute and Mercurial returns the failure
934 failure, the command doesn't execute and Mercurial returns the failure
931 code.
935 code.
932
936
933 ``prechangegroup``
937 ``prechangegroup``
934 Run before a changegroup is added via push, pull or unbundle. Exit
938 Run before a changegroup is added via push, pull or unbundle. Exit
935 status 0 allows the changegroup to proceed. A non-zero status will
939 status 0 allows the changegroup to proceed. A non-zero status will
936 cause the push, pull or unbundle to fail. The URL from which changes
940 cause the push, pull or unbundle to fail. The URL from which changes
937 will come is in ``$HG_URL``.
941 will come is in ``$HG_URL``.
938
942
939 ``precommit``
943 ``precommit``
940 Run before starting a local commit. Exit status 0 allows the
944 Run before starting a local commit. Exit status 0 allows the
941 commit to proceed. A non-zero status will cause the commit to fail.
945 commit to proceed. A non-zero status will cause the commit to fail.
942 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
946 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
943
947
944 ``prelistkeys``
948 ``prelistkeys``
945 Run before listing pushkeys (like bookmarks) in the
949 Run before listing pushkeys (like bookmarks) in the
946 repository. A non-zero status will cause failure. The key namespace is
950 repository. A non-zero status will cause failure. The key namespace is
947 in ``$HG_NAMESPACE``.
951 in ``$HG_NAMESPACE``.
948
952
949 ``preoutgoing``
953 ``preoutgoing``
950 Run before collecting changes to send from the local repository to
954 Run before collecting changes to send from the local repository to
951 another. A non-zero status will cause failure. This lets you prevent
955 another. A non-zero status will cause failure. This lets you prevent
952 pull over HTTP or SSH. It can also prevent propagating commits (via
956 pull over HTTP or SSH. It can also prevent propagating commits (via
953 local pull, push (outbound) or bundle commands), but not completely,
957 local pull, push (outbound) or bundle commands), but not completely,
954 since you can just copy files instead. The source of operation is in
958 since you can just copy files instead. The source of operation is in
955 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
959 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
956 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
960 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
957 is happening on behalf of a repository on same system.
961 is happening on behalf of a repository on same system.
958
962
959 ``prepushkey``
963 ``prepushkey``
960 Run before a pushkey (like a bookmark) is added to the
964 Run before a pushkey (like a bookmark) is added to the
961 repository. A non-zero status will cause the key to be rejected. The
965 repository. A non-zero status will cause the key to be rejected. The
962 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
966 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
963 the old value (if any) is in ``$HG_OLD``, and the new value is in
967 the old value (if any) is in ``$HG_OLD``, and the new value is in
964 ``$HG_NEW``.
968 ``$HG_NEW``.
965
969
966 ``pretag``
970 ``pretag``
967 Run before creating a tag. Exit status 0 allows the tag to be
971 Run before creating a tag. Exit status 0 allows the tag to be
968 created. A non-zero status will cause the tag to fail. The ID of the
972 created. A non-zero status will cause the tag to fail. The ID of the
969 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
973 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
970 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
974 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
971
975
972 ``pretxnopen``
976 ``pretxnopen``
973 Run before any new repository transaction is open. The reason for the
977 Run before any new repository transaction is open. The reason for the
974 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
978 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
975 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
979 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
976 transaction from being opened.
980 transaction from being opened.
977
981
978 ``pretxnclose``
982 ``pretxnclose``
979 Run right before the transaction is actually finalized. Any repository change
983 Run right before the transaction is actually finalized. Any repository change
980 will be visible to the hook program. This lets you validate the transaction
984 will be visible to the hook program. This lets you validate the transaction
981 content or change it. Exit status 0 allows the commit to proceed. A non-zero
985 content or change it. Exit status 0 allows the commit to proceed. A non-zero
982 status will cause the transaction to be rolled back. The reason for the
986 status will cause the transaction to be rolled back. The reason for the
983 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
987 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
984 the transaction will be in ``HG_TXNID``. The rest of the available data will
988 the transaction will be in ``HG_TXNID``. The rest of the available data will
985 vary according the transaction type. New changesets will add ``$HG_NODE``
989 vary according the transaction type. New changesets will add ``$HG_NODE``
986 (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
990 (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
987 added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables. Bookmark and
991 added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables. Bookmark and
988 phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
992 phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
989 respectively, etc.
993 respectively, etc.
990
994
991 ``pretxnclose-bookmark``
995 ``pretxnclose-bookmark``
992 Run right before a bookmark change is actually finalized. Any repository
996 Run right before a bookmark change is actually finalized. Any repository
993 change will be visible to the hook program. This lets you validate the
997 change will be visible to the hook program. This lets you validate the
994 transaction content or change it. Exit status 0 allows the commit to
998 transaction content or change it. Exit status 0 allows the commit to
995 proceed. A non-zero status will cause the transaction to be rolled back.
999 proceed. A non-zero status will cause the transaction to be rolled back.
996 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
1000 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
997 bookmark location will be available in ``$HG_NODE`` while the previous
1001 bookmark location will be available in ``$HG_NODE`` while the previous
998 location will be available in ``$HG_OLDNODE``. In case of a bookmark
1002 location will be available in ``$HG_OLDNODE``. In case of a bookmark
999 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1003 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1000 will be empty.
1004 will be empty.
1001 In addition, the reason for the transaction opening will be in
1005 In addition, the reason for the transaction opening will be in
1002 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1006 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1003 ``HG_TXNID``.
1007 ``HG_TXNID``.
1004
1008
1005 ``pretxnclose-phase``
1009 ``pretxnclose-phase``
1006 Run right before a phase change is actually finalized. Any repository change
1010 Run right before a phase change is actually finalized. Any repository change
1007 will be visible to the hook program. This lets you validate the transaction
1011 will be visible to the hook program. This lets you validate the transaction
1008 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1012 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1009 status will cause the transaction to be rolled back. The hook is called
1013 status will cause the transaction to be rolled back. The hook is called
1010 multiple times, once for each revision affected by a phase change.
1014 multiple times, once for each revision affected by a phase change.
1011 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1015 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1012 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1016 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1013 will be empty. In addition, the reason for the transaction opening will be in
1017 will be empty. In addition, the reason for the transaction opening will be in
1014 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1018 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1015 ``HG_TXNID``. The hook is also run for newly added revisions. In this case
1019 ``HG_TXNID``. The hook is also run for newly added revisions. In this case
1016 the ``$HG_OLDPHASE`` entry will be empty.
1020 the ``$HG_OLDPHASE`` entry will be empty.
1017
1021
1018 ``txnclose``
1022 ``txnclose``
1019 Run after any repository transaction has been committed. At this
1023 Run after any repository transaction has been committed. At this
1020 point, the transaction can no longer be rolled back. The hook will run
1024 point, the transaction can no longer be rolled back. The hook will run
1021 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1025 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1022 details about available variables.
1026 details about available variables.
1023
1027
1024 ``txnclose-bookmark``
1028 ``txnclose-bookmark``
1025 Run after any bookmark change has been committed. At this point, the
1029 Run after any bookmark change has been committed. At this point, the
1026 transaction can no longer be rolled back. The hook will run after the lock
1030 transaction can no longer be rolled back. The hook will run after the lock
1027 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1031 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1028 about available variables.
1032 about available variables.
1029
1033
1030 ``txnclose-phase``
1034 ``txnclose-phase``
1031 Run after any phase change has been committed. At this point, the
1035 Run after any phase change has been committed. At this point, the
1032 transaction can no longer be rolled back. The hook will run after the lock
1036 transaction can no longer be rolled back. The hook will run after the lock
1033 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1037 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1034 available variables.
1038 available variables.
1035
1039
1036 ``txnabort``
1040 ``txnabort``
1037 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1041 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1038 for details about available variables.
1042 for details about available variables.
1039
1043
1040 ``pretxnchangegroup``
1044 ``pretxnchangegroup``
1041 Run after a changegroup has been added via push, pull or unbundle, but before
1045 Run after a changegroup has been added via push, pull or unbundle, but before
1042 the transaction has been committed. The changegroup is visible to the hook
1046 the transaction has been committed. The changegroup is visible to the hook
1043 program. This allows validation of incoming changes before accepting them.
1047 program. This allows validation of incoming changes before accepting them.
1044 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1048 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1045 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1049 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1046 status will cause the transaction to be rolled back, and the push, pull or
1050 status will cause the transaction to be rolled back, and the push, pull or
1047 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1051 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1048
1052
1049 ``pretxncommit``
1053 ``pretxncommit``
1050 Run after a changeset has been created, but before the transaction is
1054 Run after a changeset has been created, but before the transaction is
1051 committed. The changeset is visible to the hook program. This allows
1055 committed. The changeset is visible to the hook program. This allows
1052 validation of the commit message and changes. Exit status 0 allows the
1056 validation of the commit message and changes. Exit status 0 allows the
1053 commit to proceed. A non-zero status will cause the transaction to
1057 commit to proceed. A non-zero status will cause the transaction to
1054 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1058 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1055 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1059 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1056
1060
1057 ``preupdate``
1061 ``preupdate``
1058 Run before updating the working directory. Exit status 0 allows
1062 Run before updating the working directory. Exit status 0 allows
1059 the update to proceed. A non-zero status will prevent the update.
1063 the update to proceed. A non-zero status will prevent the update.
1060 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1064 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1061 merge, the ID of second new parent is in ``$HG_PARENT2``.
1065 merge, the ID of second new parent is in ``$HG_PARENT2``.
1062
1066
1063 ``listkeys``
1067 ``listkeys``
1064 Run after listing pushkeys (like bookmarks) in the repository. The
1068 Run after listing pushkeys (like bookmarks) in the repository. The
1065 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1069 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1066 dictionary containing the keys and values.
1070 dictionary containing the keys and values.
1067
1071
1068 ``pushkey``
1072 ``pushkey``
1069 Run after a pushkey (like a bookmark) is added to the
1073 Run after a pushkey (like a bookmark) is added to the
1070 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1074 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1071 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1075 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1072 value is in ``$HG_NEW``.
1076 value is in ``$HG_NEW``.
1073
1077
1074 ``tag``
1078 ``tag``
1075 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1079 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1076 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1080 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1077 the repository if ``$HG_LOCAL=0``.
1081 the repository if ``$HG_LOCAL=0``.
1078
1082
1079 ``update``
1083 ``update``
1080 Run after updating the working directory. The changeset ID of first
1084 Run after updating the working directory. The changeset ID of first
1081 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1085 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1082 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1086 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1083 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1087 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1084
1088
1085 .. note::
1089 .. note::
1086
1090
1087 It is generally better to use standard hooks rather than the
1091 It is generally better to use standard hooks rather than the
1088 generic pre- and post- command hooks, as they are guaranteed to be
1092 generic pre- and post- command hooks, as they are guaranteed to be
1089 called in the appropriate contexts for influencing transactions.
1093 called in the appropriate contexts for influencing transactions.
1090 Also, hooks like "commit" will be called in all contexts that
1094 Also, hooks like "commit" will be called in all contexts that
1091 generate a commit (e.g. tag) and not just the commit command.
1095 generate a commit (e.g. tag) and not just the commit command.
1092
1096
1093 .. note::
1097 .. note::
1094
1098
1095 Environment variables with empty values may not be passed to
1099 Environment variables with empty values may not be passed to
1096 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1100 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1097 will have an empty value under Unix-like platforms for non-merge
1101 will have an empty value under Unix-like platforms for non-merge
1098 changesets, while it will not be available at all under Windows.
1102 changesets, while it will not be available at all under Windows.
1099
1103
1100 The syntax for Python hooks is as follows::
1104 The syntax for Python hooks is as follows::
1101
1105
1102 hookname = python:modulename.submodule.callable
1106 hookname = python:modulename.submodule.callable
1103 hookname = python:/path/to/python/module.py:callable
1107 hookname = python:/path/to/python/module.py:callable
1104
1108
1105 Python hooks are run within the Mercurial process. Each hook is
1109 Python hooks are run within the Mercurial process. Each hook is
1106 called with at least three keyword arguments: a ui object (keyword
1110 called with at least three keyword arguments: a ui object (keyword
1107 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1111 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1108 keyword that tells what kind of hook is used. Arguments listed as
1112 keyword that tells what kind of hook is used. Arguments listed as
1109 environment variables above are passed as keyword arguments, with no
1113 environment variables above are passed as keyword arguments, with no
1110 ``HG_`` prefix, and names in lower case.
1114 ``HG_`` prefix, and names in lower case.
1111
1115
1112 If a Python hook returns a "true" value or raises an exception, this
1116 If a Python hook returns a "true" value or raises an exception, this
1113 is treated as a failure.
1117 is treated as a failure.
1114
1118
1115
1119
1116 ``hostfingerprints``
1120 ``hostfingerprints``
1117 --------------------
1121 --------------------
1118
1122
1119 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1123 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1120
1124
1121 Fingerprints of the certificates of known HTTPS servers.
1125 Fingerprints of the certificates of known HTTPS servers.
1122
1126
1123 A HTTPS connection to a server with a fingerprint configured here will
1127 A HTTPS connection to a server with a fingerprint configured here will
1124 only succeed if the servers certificate matches the fingerprint.
1128 only succeed if the servers certificate matches the fingerprint.
1125 This is very similar to how ssh known hosts works.
1129 This is very similar to how ssh known hosts works.
1126
1130
1127 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1131 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1128 Multiple values can be specified (separated by spaces or commas). This can
1132 Multiple values can be specified (separated by spaces or commas). This can
1129 be used to define both old and new fingerprints while a host transitions
1133 be used to define both old and new fingerprints while a host transitions
1130 to a new certificate.
1134 to a new certificate.
1131
1135
1132 The CA chain and web.cacerts is not used for servers with a fingerprint.
1136 The CA chain and web.cacerts is not used for servers with a fingerprint.
1133
1137
1134 For example::
1138 For example::
1135
1139
1136 [hostfingerprints]
1140 [hostfingerprints]
1137 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1141 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1138 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1142 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1139
1143
1140 ``hostsecurity``
1144 ``hostsecurity``
1141 ----------------
1145 ----------------
1142
1146
1143 Used to specify global and per-host security settings for connecting to
1147 Used to specify global and per-host security settings for connecting to
1144 other machines.
1148 other machines.
1145
1149
1146 The following options control default behavior for all hosts.
1150 The following options control default behavior for all hosts.
1147
1151
1148 ``ciphers``
1152 ``ciphers``
1149 Defines the cryptographic ciphers to use for connections.
1153 Defines the cryptographic ciphers to use for connections.
1150
1154
1151 Value must be a valid OpenSSL Cipher List Format as documented at
1155 Value must be a valid OpenSSL Cipher List Format as documented at
1152 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1156 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1153
1157
1154 This setting is for advanced users only. Setting to incorrect values
1158 This setting is for advanced users only. Setting to incorrect values
1155 can significantly lower connection security or decrease performance.
1159 can significantly lower connection security or decrease performance.
1156 You have been warned.
1160 You have been warned.
1157
1161
1158 This option requires Python 2.7.
1162 This option requires Python 2.7.
1159
1163
1160 ``minimumprotocol``
1164 ``minimumprotocol``
1161 Defines the minimum channel encryption protocol to use.
1165 Defines the minimum channel encryption protocol to use.
1162
1166
1163 By default, the highest version of TLS supported by both client and server
1167 By default, the highest version of TLS supported by both client and server
1164 is used.
1168 is used.
1165
1169
1166 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1170 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1167
1171
1168 When running on an old Python version, only ``tls1.0`` is allowed since
1172 When running on an old Python version, only ``tls1.0`` is allowed since
1169 old versions of Python only support up to TLS 1.0.
1173 old versions of Python only support up to TLS 1.0.
1170
1174
1171 When running a Python that supports modern TLS versions, the default is
1175 When running a Python that supports modern TLS versions, the default is
1172 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1176 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1173 weakens security and should only be used as a feature of last resort if
1177 weakens security and should only be used as a feature of last resort if
1174 a server does not support TLS 1.1+.
1178 a server does not support TLS 1.1+.
1175
1179
1176 Options in the ``[hostsecurity]`` section can have the form
1180 Options in the ``[hostsecurity]`` section can have the form
1177 ``hostname``:``setting``. This allows multiple settings to be defined on a
1181 ``hostname``:``setting``. This allows multiple settings to be defined on a
1178 per-host basis.
1182 per-host basis.
1179
1183
1180 The following per-host settings can be defined.
1184 The following per-host settings can be defined.
1181
1185
1182 ``ciphers``
1186 ``ciphers``
1183 This behaves like ``ciphers`` as described above except it only applies
1187 This behaves like ``ciphers`` as described above except it only applies
1184 to the host on which it is defined.
1188 to the host on which it is defined.
1185
1189
1186 ``fingerprints``
1190 ``fingerprints``
1187 A list of hashes of the DER encoded peer/remote certificate. Values have
1191 A list of hashes of the DER encoded peer/remote certificate. Values have
1188 the form ``algorithm``:``fingerprint``. e.g.
1192 the form ``algorithm``:``fingerprint``. e.g.
1189 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1193 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1190 In addition, colons (``:``) can appear in the fingerprint part.
1194 In addition, colons (``:``) can appear in the fingerprint part.
1191
1195
1192 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1196 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1193 ``sha512``.
1197 ``sha512``.
1194
1198
1195 Use of ``sha256`` or ``sha512`` is preferred.
1199 Use of ``sha256`` or ``sha512`` is preferred.
1196
1200
1197 If a fingerprint is specified, the CA chain is not validated for this
1201 If a fingerprint is specified, the CA chain is not validated for this
1198 host and Mercurial will require the remote certificate to match one
1202 host and Mercurial will require the remote certificate to match one
1199 of the fingerprints specified. This means if the server updates its
1203 of the fingerprints specified. This means if the server updates its
1200 certificate, Mercurial will abort until a new fingerprint is defined.
1204 certificate, Mercurial will abort until a new fingerprint is defined.
1201 This can provide stronger security than traditional CA-based validation
1205 This can provide stronger security than traditional CA-based validation
1202 at the expense of convenience.
1206 at the expense of convenience.
1203
1207
1204 This option takes precedence over ``verifycertsfile``.
1208 This option takes precedence over ``verifycertsfile``.
1205
1209
1206 ``minimumprotocol``
1210 ``minimumprotocol``
1207 This behaves like ``minimumprotocol`` as described above except it
1211 This behaves like ``minimumprotocol`` as described above except it
1208 only applies to the host on which it is defined.
1212 only applies to the host on which it is defined.
1209
1213
1210 ``verifycertsfile``
1214 ``verifycertsfile``
1211 Path to file a containing a list of PEM encoded certificates used to
1215 Path to file a containing a list of PEM encoded certificates used to
1212 verify the server certificate. Environment variables and ``~user``
1216 verify the server certificate. Environment variables and ``~user``
1213 constructs are expanded in the filename.
1217 constructs are expanded in the filename.
1214
1218
1215 The server certificate or the certificate's certificate authority (CA)
1219 The server certificate or the certificate's certificate authority (CA)
1216 must match a certificate from this file or certificate verification
1220 must match a certificate from this file or certificate verification
1217 will fail and connections to the server will be refused.
1221 will fail and connections to the server will be refused.
1218
1222
1219 If defined, only certificates provided by this file will be used:
1223 If defined, only certificates provided by this file will be used:
1220 ``web.cacerts`` and any system/default certificates will not be
1224 ``web.cacerts`` and any system/default certificates will not be
1221 used.
1225 used.
1222
1226
1223 This option has no effect if the per-host ``fingerprints`` option
1227 This option has no effect if the per-host ``fingerprints`` option
1224 is set.
1228 is set.
1225
1229
1226 The format of the file is as follows::
1230 The format of the file is as follows::
1227
1231
1228 -----BEGIN CERTIFICATE-----
1232 -----BEGIN CERTIFICATE-----
1229 ... (certificate in base64 PEM encoding) ...
1233 ... (certificate in base64 PEM encoding) ...
1230 -----END CERTIFICATE-----
1234 -----END CERTIFICATE-----
1231 -----BEGIN CERTIFICATE-----
1235 -----BEGIN CERTIFICATE-----
1232 ... (certificate in base64 PEM encoding) ...
1236 ... (certificate in base64 PEM encoding) ...
1233 -----END CERTIFICATE-----
1237 -----END CERTIFICATE-----
1234
1238
1235 For example::
1239 For example::
1236
1240
1237 [hostsecurity]
1241 [hostsecurity]
1238 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1242 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1239 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
1243 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
1240 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
1244 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
1241 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1245 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1242
1246
1243 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1247 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1244 when connecting to ``hg.example.com``::
1248 when connecting to ``hg.example.com``::
1245
1249
1246 [hostsecurity]
1250 [hostsecurity]
1247 minimumprotocol = tls1.2
1251 minimumprotocol = tls1.2
1248 hg.example.com:minimumprotocol = tls1.1
1252 hg.example.com:minimumprotocol = tls1.1
1249
1253
1250 ``http_proxy``
1254 ``http_proxy``
1251 --------------
1255 --------------
1252
1256
1253 Used to access web-based Mercurial repositories through a HTTP
1257 Used to access web-based Mercurial repositories through a HTTP
1254 proxy.
1258 proxy.
1255
1259
1256 ``host``
1260 ``host``
1257 Host name and (optional) port of the proxy server, for example
1261 Host name and (optional) port of the proxy server, for example
1258 "myproxy:8000".
1262 "myproxy:8000".
1259
1263
1260 ``no``
1264 ``no``
1261 Optional. Comma-separated list of host names that should bypass
1265 Optional. Comma-separated list of host names that should bypass
1262 the proxy.
1266 the proxy.
1263
1267
1264 ``passwd``
1268 ``passwd``
1265 Optional. Password to authenticate with at the proxy server.
1269 Optional. Password to authenticate with at the proxy server.
1266
1270
1267 ``user``
1271 ``user``
1268 Optional. User name to authenticate with at the proxy server.
1272 Optional. User name to authenticate with at the proxy server.
1269
1273
1270 ``always``
1274 ``always``
1271 Optional. Always use the proxy, even for localhost and any entries
1275 Optional. Always use the proxy, even for localhost and any entries
1272 in ``http_proxy.no``. (default: False)
1276 in ``http_proxy.no``. (default: False)
1273
1277
1274 ``merge``
1278 ``merge``
1275 ---------
1279 ---------
1276
1280
1277 This section specifies behavior during merges and updates.
1281 This section specifies behavior during merges and updates.
1278
1282
1279 ``checkignored``
1283 ``checkignored``
1280 Controls behavior when an ignored file on disk has the same name as a tracked
1284 Controls behavior when an ignored file on disk has the same name as a tracked
1281 file in the changeset being merged or updated to, and has different
1285 file in the changeset being merged or updated to, and has different
1282 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1286 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1283 abort on such files. With ``warn``, warn on such files and back them up as
1287 abort on such files. With ``warn``, warn on such files and back them up as
1284 ``.orig``. With ``ignore``, don't print a warning and back them up as
1288 ``.orig``. With ``ignore``, don't print a warning and back them up as
1285 ``.orig``. (default: ``abort``)
1289 ``.orig``. (default: ``abort``)
1286
1290
1287 ``checkunknown``
1291 ``checkunknown``
1288 Controls behavior when an unknown file that isn't ignored has the same name
1292 Controls behavior when an unknown file that isn't ignored has the same name
1289 as a tracked file in the changeset being merged or updated to, and has
1293 as a tracked file in the changeset being merged or updated to, and has
1290 different contents. Similar to ``merge.checkignored``, except for files that
1294 different contents. Similar to ``merge.checkignored``, except for files that
1291 are not ignored. (default: ``abort``)
1295 are not ignored. (default: ``abort``)
1292
1296
1293 ``on-failure``
1297 ``on-failure``
1294 When set to ``continue`` (the default), the merge process attempts to
1298 When set to ``continue`` (the default), the merge process attempts to
1295 merge all unresolved files using the merge chosen tool, regardless of
1299 merge all unresolved files using the merge chosen tool, regardless of
1296 whether previous file merge attempts during the process succeeded or not.
1300 whether previous file merge attempts during the process succeeded or not.
1297 Setting this to ``prompt`` will prompt after any merge failure continue
1301 Setting this to ``prompt`` will prompt after any merge failure continue
1298 or halt the merge process. Setting this to ``halt`` will automatically
1302 or halt the merge process. Setting this to ``halt`` will automatically
1299 halt the merge process on any merge tool failure. The merge process
1303 halt the merge process on any merge tool failure. The merge process
1300 can be restarted by using the ``resolve`` command. When a merge is
1304 can be restarted by using the ``resolve`` command. When a merge is
1301 halted, the repository is left in a normal ``unresolved`` merge state.
1305 halted, the repository is left in a normal ``unresolved`` merge state.
1302 (default: ``continue``)
1306 (default: ``continue``)
1303
1307
1304 ``merge-patterns``
1308 ``merge-patterns``
1305 ------------------
1309 ------------------
1306
1310
1307 This section specifies merge tools to associate with particular file
1311 This section specifies merge tools to associate with particular file
1308 patterns. Tools matched here will take precedence over the default
1312 patterns. Tools matched here will take precedence over the default
1309 merge tool. Patterns are globs by default, rooted at the repository
1313 merge tool. Patterns are globs by default, rooted at the repository
1310 root.
1314 root.
1311
1315
1312 Example::
1316 Example::
1313
1317
1314 [merge-patterns]
1318 [merge-patterns]
1315 **.c = kdiff3
1319 **.c = kdiff3
1316 **.jpg = myimgmerge
1320 **.jpg = myimgmerge
1317
1321
1318 ``merge-tools``
1322 ``merge-tools``
1319 ---------------
1323 ---------------
1320
1324
1321 This section configures external merge tools to use for file-level
1325 This section configures external merge tools to use for file-level
1322 merges. This section has likely been preconfigured at install time.
1326 merges. This section has likely been preconfigured at install time.
1323 Use :hg:`config merge-tools` to check the existing configuration.
1327 Use :hg:`config merge-tools` to check the existing configuration.
1324 Also see :hg:`help merge-tools` for more details.
1328 Also see :hg:`help merge-tools` for more details.
1325
1329
1326 Example ``~/.hgrc``::
1330 Example ``~/.hgrc``::
1327
1331
1328 [merge-tools]
1332 [merge-tools]
1329 # Override stock tool location
1333 # Override stock tool location
1330 kdiff3.executable = ~/bin/kdiff3
1334 kdiff3.executable = ~/bin/kdiff3
1331 # Specify command line
1335 # Specify command line
1332 kdiff3.args = $base $local $other -o $output
1336 kdiff3.args = $base $local $other -o $output
1333 # Give higher priority
1337 # Give higher priority
1334 kdiff3.priority = 1
1338 kdiff3.priority = 1
1335
1339
1336 # Changing the priority of preconfigured tool
1340 # Changing the priority of preconfigured tool
1337 meld.priority = 0
1341 meld.priority = 0
1338
1342
1339 # Disable a preconfigured tool
1343 # Disable a preconfigured tool
1340 vimdiff.disabled = yes
1344 vimdiff.disabled = yes
1341
1345
1342 # Define new tool
1346 # Define new tool
1343 myHtmlTool.args = -m $local $other $base $output
1347 myHtmlTool.args = -m $local $other $base $output
1344 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1348 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1345 myHtmlTool.priority = 1
1349 myHtmlTool.priority = 1
1346
1350
1347 Supported arguments:
1351 Supported arguments:
1348
1352
1349 ``priority``
1353 ``priority``
1350 The priority in which to evaluate this tool.
1354 The priority in which to evaluate this tool.
1351 (default: 0)
1355 (default: 0)
1352
1356
1353 ``executable``
1357 ``executable``
1354 Either just the name of the executable or its pathname.
1358 Either just the name of the executable or its pathname.
1355
1359
1356 .. container:: windows
1360 .. container:: windows
1357
1361
1358 On Windows, the path can use environment variables with ${ProgramFiles}
1362 On Windows, the path can use environment variables with ${ProgramFiles}
1359 syntax.
1363 syntax.
1360
1364
1361 (default: the tool name)
1365 (default: the tool name)
1362
1366
1363 ``args``
1367 ``args``
1364 The arguments to pass to the tool executable. You can refer to the
1368 The arguments to pass to the tool executable. You can refer to the
1365 files being merged as well as the output file through these
1369 files being merged as well as the output file through these
1366 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1370 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1367
1371
1368 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1372 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1369 being performed. During an update or merge, ``$local`` represents the original
1373 being performed. During an update or merge, ``$local`` represents the original
1370 state of the file, while ``$other`` represents the commit you are updating to or
1374 state of the file, while ``$other`` represents the commit you are updating to or
1371 the commit you are merging with. During a rebase, ``$local`` represents the
1375 the commit you are merging with. During a rebase, ``$local`` represents the
1372 destination of the rebase, and ``$other`` represents the commit being rebased.
1376 destination of the rebase, and ``$other`` represents the commit being rebased.
1373
1377
1374 Some operations define custom labels to assist with identifying the revisions,
1378 Some operations define custom labels to assist with identifying the revisions,
1375 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1379 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1376 labels are not available, these will be ``local``, ``other``, and ``base``,
1380 labels are not available, these will be ``local``, ``other``, and ``base``,
1377 respectively.
1381 respectively.
1378 (default: ``$local $base $other``)
1382 (default: ``$local $base $other``)
1379
1383
1380 ``premerge``
1384 ``premerge``
1381 Attempt to run internal non-interactive 3-way merge tool before
1385 Attempt to run internal non-interactive 3-way merge tool before
1382 launching external tool. Options are ``true``, ``false``, ``keep`` or
1386 launching external tool. Options are ``true``, ``false``, ``keep`` or
1383 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1387 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1384 premerge fails. The ``keep-merge3`` will do the same but include information
1388 premerge fails. The ``keep-merge3`` will do the same but include information
1385 about the base of the merge in the marker (see internal :merge3 in
1389 about the base of the merge in the marker (see internal :merge3 in
1386 :hg:`help merge-tools`).
1390 :hg:`help merge-tools`).
1387 (default: True)
1391 (default: True)
1388
1392
1389 ``binary``
1393 ``binary``
1390 This tool can merge binary files. (default: False, unless tool
1394 This tool can merge binary files. (default: False, unless tool
1391 was selected by file pattern match)
1395 was selected by file pattern match)
1392
1396
1393 ``symlink``
1397 ``symlink``
1394 This tool can merge symlinks. (default: False)
1398 This tool can merge symlinks. (default: False)
1395
1399
1396 ``check``
1400 ``check``
1397 A list of merge success-checking options:
1401 A list of merge success-checking options:
1398
1402
1399 ``changed``
1403 ``changed``
1400 Ask whether merge was successful when the merged file shows no changes.
1404 Ask whether merge was successful when the merged file shows no changes.
1401 ``conflicts``
1405 ``conflicts``
1402 Check whether there are conflicts even though the tool reported success.
1406 Check whether there are conflicts even though the tool reported success.
1403 ``prompt``
1407 ``prompt``
1404 Always prompt for merge success, regardless of success reported by tool.
1408 Always prompt for merge success, regardless of success reported by tool.
1405
1409
1406 ``fixeol``
1410 ``fixeol``
1407 Attempt to fix up EOL changes caused by the merge tool.
1411 Attempt to fix up EOL changes caused by the merge tool.
1408 (default: False)
1412 (default: False)
1409
1413
1410 ``gui``
1414 ``gui``
1411 This tool requires a graphical interface to run. (default: False)
1415 This tool requires a graphical interface to run. (default: False)
1412
1416
1413 ``mergemarkers``
1417 ``mergemarkers``
1414 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1418 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1415 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1419 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1416 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1420 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1417 markers generated during premerge will be ``detailed`` if either this option or
1421 markers generated during premerge will be ``detailed`` if either this option or
1418 the corresponding option in the ``[ui]`` section is ``detailed``.
1422 the corresponding option in the ``[ui]`` section is ``detailed``.
1419 (default: ``basic``)
1423 (default: ``basic``)
1420
1424
1421 ``mergemarkertemplate``
1425 ``mergemarkertemplate``
1422 This setting can be used to override ``mergemarkertemplate`` from the ``[ui]``
1426 This setting can be used to override ``mergemarkertemplate`` from the ``[ui]``
1423 section on a per-tool basis; this applies to the ``$label``-prefixed variables
1427 section on a per-tool basis; this applies to the ``$label``-prefixed variables
1424 and to the conflict markers that are generated if ``premerge`` is ``keep` or
1428 and to the conflict markers that are generated if ``premerge`` is ``keep` or
1425 ``keep-merge3``. See the corresponding variable in ``[ui]`` for more
1429 ``keep-merge3``. See the corresponding variable in ``[ui]`` for more
1426 information.
1430 information.
1427
1431
1428 .. container:: windows
1432 .. container:: windows
1429
1433
1430 ``regkey``
1434 ``regkey``
1431 Windows registry key which describes install location of this
1435 Windows registry key which describes install location of this
1432 tool. Mercurial will search for this key first under
1436 tool. Mercurial will search for this key first under
1433 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1437 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1434 (default: None)
1438 (default: None)
1435
1439
1436 ``regkeyalt``
1440 ``regkeyalt``
1437 An alternate Windows registry key to try if the first key is not
1441 An alternate Windows registry key to try if the first key is not
1438 found. The alternate key uses the same ``regname`` and ``regappend``
1442 found. The alternate key uses the same ``regname`` and ``regappend``
1439 semantics of the primary key. The most common use for this key
1443 semantics of the primary key. The most common use for this key
1440 is to search for 32bit applications on 64bit operating systems.
1444 is to search for 32bit applications on 64bit operating systems.
1441 (default: None)
1445 (default: None)
1442
1446
1443 ``regname``
1447 ``regname``
1444 Name of value to read from specified registry key.
1448 Name of value to read from specified registry key.
1445 (default: the unnamed (default) value)
1449 (default: the unnamed (default) value)
1446
1450
1447 ``regappend``
1451 ``regappend``
1448 String to append to the value read from the registry, typically
1452 String to append to the value read from the registry, typically
1449 the executable name of the tool.
1453 the executable name of the tool.
1450 (default: None)
1454 (default: None)
1451
1455
1452 ``pager``
1456 ``pager``
1453 ---------
1457 ---------
1454
1458
1455 Setting used to control when to paginate and with what external tool. See
1459 Setting used to control when to paginate and with what external tool. See
1456 :hg:`help pager` for details.
1460 :hg:`help pager` for details.
1457
1461
1458 ``pager``
1462 ``pager``
1459 Define the external tool used as pager.
1463 Define the external tool used as pager.
1460
1464
1461 If no pager is set, Mercurial uses the environment variable $PAGER.
1465 If no pager is set, Mercurial uses the environment variable $PAGER.
1462 If neither pager.pager, nor $PAGER is set, a default pager will be
1466 If neither pager.pager, nor $PAGER is set, a default pager will be
1463 used, typically `less` on Unix and `more` on Windows. Example::
1467 used, typically `less` on Unix and `more` on Windows. Example::
1464
1468
1465 [pager]
1469 [pager]
1466 pager = less -FRX
1470 pager = less -FRX
1467
1471
1468 ``ignore``
1472 ``ignore``
1469 List of commands to disable the pager for. Example::
1473 List of commands to disable the pager for. Example::
1470
1474
1471 [pager]
1475 [pager]
1472 ignore = version, help, update
1476 ignore = version, help, update
1473
1477
1474 ``patch``
1478 ``patch``
1475 ---------
1479 ---------
1476
1480
1477 Settings used when applying patches, for instance through the 'import'
1481 Settings used when applying patches, for instance through the 'import'
1478 command or with Mercurial Queues extension.
1482 command or with Mercurial Queues extension.
1479
1483
1480 ``eol``
1484 ``eol``
1481 When set to 'strict' patch content and patched files end of lines
1485 When set to 'strict' patch content and patched files end of lines
1482 are preserved. When set to ``lf`` or ``crlf``, both files end of
1486 are preserved. When set to ``lf`` or ``crlf``, both files end of
1483 lines are ignored when patching and the result line endings are
1487 lines are ignored when patching and the result line endings are
1484 normalized to either LF (Unix) or CRLF (Windows). When set to
1488 normalized to either LF (Unix) or CRLF (Windows). When set to
1485 ``auto``, end of lines are again ignored while patching but line
1489 ``auto``, end of lines are again ignored while patching but line
1486 endings in patched files are normalized to their original setting
1490 endings in patched files are normalized to their original setting
1487 on a per-file basis. If target file does not exist or has no end
1491 on a per-file basis. If target file does not exist or has no end
1488 of line, patch line endings are preserved.
1492 of line, patch line endings are preserved.
1489 (default: strict)
1493 (default: strict)
1490
1494
1491 ``fuzz``
1495 ``fuzz``
1492 The number of lines of 'fuzz' to allow when applying patches. This
1496 The number of lines of 'fuzz' to allow when applying patches. This
1493 controls how much context the patcher is allowed to ignore when
1497 controls how much context the patcher is allowed to ignore when
1494 trying to apply a patch.
1498 trying to apply a patch.
1495 (default: 2)
1499 (default: 2)
1496
1500
1497 ``paths``
1501 ``paths``
1498 ---------
1502 ---------
1499
1503
1500 Assigns symbolic names and behavior to repositories.
1504 Assigns symbolic names and behavior to repositories.
1501
1505
1502 Options are symbolic names defining the URL or directory that is the
1506 Options are symbolic names defining the URL or directory that is the
1503 location of the repository. Example::
1507 location of the repository. Example::
1504
1508
1505 [paths]
1509 [paths]
1506 my_server = https://example.com/my_repo
1510 my_server = https://example.com/my_repo
1507 local_path = /home/me/repo
1511 local_path = /home/me/repo
1508
1512
1509 These symbolic names can be used from the command line. To pull
1513 These symbolic names can be used from the command line. To pull
1510 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1514 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1511 :hg:`push local_path`.
1515 :hg:`push local_path`.
1512
1516
1513 Options containing colons (``:``) denote sub-options that can influence
1517 Options containing colons (``:``) denote sub-options that can influence
1514 behavior for that specific path. Example::
1518 behavior for that specific path. Example::
1515
1519
1516 [paths]
1520 [paths]
1517 my_server = https://example.com/my_path
1521 my_server = https://example.com/my_path
1518 my_server:pushurl = ssh://example.com/my_path
1522 my_server:pushurl = ssh://example.com/my_path
1519
1523
1520 The following sub-options can be defined:
1524 The following sub-options can be defined:
1521
1525
1522 ``pushurl``
1526 ``pushurl``
1523 The URL to use for push operations. If not defined, the location
1527 The URL to use for push operations. If not defined, the location
1524 defined by the path's main entry is used.
1528 defined by the path's main entry is used.
1525
1529
1526 ``pushrev``
1530 ``pushrev``
1527 A revset defining which revisions to push by default.
1531 A revset defining which revisions to push by default.
1528
1532
1529 When :hg:`push` is executed without a ``-r`` argument, the revset
1533 When :hg:`push` is executed without a ``-r`` argument, the revset
1530 defined by this sub-option is evaluated to determine what to push.
1534 defined by this sub-option is evaluated to determine what to push.
1531
1535
1532 For example, a value of ``.`` will push the working directory's
1536 For example, a value of ``.`` will push the working directory's
1533 revision by default.
1537 revision by default.
1534
1538
1535 Revsets specifying bookmarks will not result in the bookmark being
1539 Revsets specifying bookmarks will not result in the bookmark being
1536 pushed.
1540 pushed.
1537
1541
1538 The following special named paths exist:
1542 The following special named paths exist:
1539
1543
1540 ``default``
1544 ``default``
1541 The URL or directory to use when no source or remote is specified.
1545 The URL or directory to use when no source or remote is specified.
1542
1546
1543 :hg:`clone` will automatically define this path to the location the
1547 :hg:`clone` will automatically define this path to the location the
1544 repository was cloned from.
1548 repository was cloned from.
1545
1549
1546 ``default-push``
1550 ``default-push``
1547 (deprecated) The URL or directory for the default :hg:`push` location.
1551 (deprecated) The URL or directory for the default :hg:`push` location.
1548 ``default:pushurl`` should be used instead.
1552 ``default:pushurl`` should be used instead.
1549
1553
1550 ``phases``
1554 ``phases``
1551 ----------
1555 ----------
1552
1556
1553 Specifies default handling of phases. See :hg:`help phases` for more
1557 Specifies default handling of phases. See :hg:`help phases` for more
1554 information about working with phases.
1558 information about working with phases.
1555
1559
1556 ``publish``
1560 ``publish``
1557 Controls draft phase behavior when working as a server. When true,
1561 Controls draft phase behavior when working as a server. When true,
1558 pushed changesets are set to public in both client and server and
1562 pushed changesets are set to public in both client and server and
1559 pulled or cloned changesets are set to public in the client.
1563 pulled or cloned changesets are set to public in the client.
1560 (default: True)
1564 (default: True)
1561
1565
1562 ``new-commit``
1566 ``new-commit``
1563 Phase of newly-created commits.
1567 Phase of newly-created commits.
1564 (default: draft)
1568 (default: draft)
1565
1569
1566 ``checksubrepos``
1570 ``checksubrepos``
1567 Check the phase of the current revision of each subrepository. Allowed
1571 Check the phase of the current revision of each subrepository. Allowed
1568 values are "ignore", "follow" and "abort". For settings other than
1572 values are "ignore", "follow" and "abort". For settings other than
1569 "ignore", the phase of the current revision of each subrepository is
1573 "ignore", the phase of the current revision of each subrepository is
1570 checked before committing the parent repository. If any of those phases is
1574 checked before committing the parent repository. If any of those phases is
1571 greater than the phase of the parent repository (e.g. if a subrepo is in a
1575 greater than the phase of the parent repository (e.g. if a subrepo is in a
1572 "secret" phase while the parent repo is in "draft" phase), the commit is
1576 "secret" phase while the parent repo is in "draft" phase), the commit is
1573 either aborted (if checksubrepos is set to "abort") or the higher phase is
1577 either aborted (if checksubrepos is set to "abort") or the higher phase is
1574 used for the parent repository commit (if set to "follow").
1578 used for the parent repository commit (if set to "follow").
1575 (default: follow)
1579 (default: follow)
1576
1580
1577
1581
1578 ``profiling``
1582 ``profiling``
1579 -------------
1583 -------------
1580
1584
1581 Specifies profiling type, format, and file output. Two profilers are
1585 Specifies profiling type, format, and file output. Two profilers are
1582 supported: an instrumenting profiler (named ``ls``), and a sampling
1586 supported: an instrumenting profiler (named ``ls``), and a sampling
1583 profiler (named ``stat``).
1587 profiler (named ``stat``).
1584
1588
1585 In this section description, 'profiling data' stands for the raw data
1589 In this section description, 'profiling data' stands for the raw data
1586 collected during profiling, while 'profiling report' stands for a
1590 collected during profiling, while 'profiling report' stands for a
1587 statistical text report generated from the profiling data.
1591 statistical text report generated from the profiling data.
1588
1592
1589 ``enabled``
1593 ``enabled``
1590 Enable the profiler.
1594 Enable the profiler.
1591 (default: false)
1595 (default: false)
1592
1596
1593 This is equivalent to passing ``--profile`` on the command line.
1597 This is equivalent to passing ``--profile`` on the command line.
1594
1598
1595 ``type``
1599 ``type``
1596 The type of profiler to use.
1600 The type of profiler to use.
1597 (default: stat)
1601 (default: stat)
1598
1602
1599 ``ls``
1603 ``ls``
1600 Use Python's built-in instrumenting profiler. This profiler
1604 Use Python's built-in instrumenting profiler. This profiler
1601 works on all platforms, but each line number it reports is the
1605 works on all platforms, but each line number it reports is the
1602 first line of a function. This restriction makes it difficult to
1606 first line of a function. This restriction makes it difficult to
1603 identify the expensive parts of a non-trivial function.
1607 identify the expensive parts of a non-trivial function.
1604 ``stat``
1608 ``stat``
1605 Use a statistical profiler, statprof. This profiler is most
1609 Use a statistical profiler, statprof. This profiler is most
1606 useful for profiling commands that run for longer than about 0.1
1610 useful for profiling commands that run for longer than about 0.1
1607 seconds.
1611 seconds.
1608
1612
1609 ``format``
1613 ``format``
1610 Profiling format. Specific to the ``ls`` instrumenting profiler.
1614 Profiling format. Specific to the ``ls`` instrumenting profiler.
1611 (default: text)
1615 (default: text)
1612
1616
1613 ``text``
1617 ``text``
1614 Generate a profiling report. When saving to a file, it should be
1618 Generate a profiling report. When saving to a file, it should be
1615 noted that only the report is saved, and the profiling data is
1619 noted that only the report is saved, and the profiling data is
1616 not kept.
1620 not kept.
1617 ``kcachegrind``
1621 ``kcachegrind``
1618 Format profiling data for kcachegrind use: when saving to a
1622 Format profiling data for kcachegrind use: when saving to a
1619 file, the generated file can directly be loaded into
1623 file, the generated file can directly be loaded into
1620 kcachegrind.
1624 kcachegrind.
1621
1625
1622 ``statformat``
1626 ``statformat``
1623 Profiling format for the ``stat`` profiler.
1627 Profiling format for the ``stat`` profiler.
1624 (default: hotpath)
1628 (default: hotpath)
1625
1629
1626 ``hotpath``
1630 ``hotpath``
1627 Show a tree-based display containing the hot path of execution (where
1631 Show a tree-based display containing the hot path of execution (where
1628 most time was spent).
1632 most time was spent).
1629 ``bymethod``
1633 ``bymethod``
1630 Show a table of methods ordered by how frequently they are active.
1634 Show a table of methods ordered by how frequently they are active.
1631 ``byline``
1635 ``byline``
1632 Show a table of lines in files ordered by how frequently they are active.
1636 Show a table of lines in files ordered by how frequently they are active.
1633 ``json``
1637 ``json``
1634 Render profiling data as JSON.
1638 Render profiling data as JSON.
1635
1639
1636 ``frequency``
1640 ``frequency``
1637 Sampling frequency. Specific to the ``stat`` sampling profiler.
1641 Sampling frequency. Specific to the ``stat`` sampling profiler.
1638 (default: 1000)
1642 (default: 1000)
1639
1643
1640 ``output``
1644 ``output``
1641 File path where profiling data or report should be saved. If the
1645 File path where profiling data or report should be saved. If the
1642 file exists, it is replaced. (default: None, data is printed on
1646 file exists, it is replaced. (default: None, data is printed on
1643 stderr)
1647 stderr)
1644
1648
1645 ``sort``
1649 ``sort``
1646 Sort field. Specific to the ``ls`` instrumenting profiler.
1650 Sort field. Specific to the ``ls`` instrumenting profiler.
1647 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1651 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1648 ``inlinetime``.
1652 ``inlinetime``.
1649 (default: inlinetime)
1653 (default: inlinetime)
1650
1654
1651 ``limit``
1655 ``limit``
1652 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1656 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1653 (default: 30)
1657 (default: 30)
1654
1658
1655 ``nested``
1659 ``nested``
1656 Show at most this number of lines of drill-down info after each main entry.
1660 Show at most this number of lines of drill-down info after each main entry.
1657 This can help explain the difference between Total and Inline.
1661 This can help explain the difference between Total and Inline.
1658 Specific to the ``ls`` instrumenting profiler.
1662 Specific to the ``ls`` instrumenting profiler.
1659 (default: 0)
1663 (default: 0)
1660
1664
1661 ``showmin``
1665 ``showmin``
1662 Minimum fraction of samples an entry must have for it to be displayed.
1666 Minimum fraction of samples an entry must have for it to be displayed.
1663 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1667 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1664 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1668 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1665
1669
1666 Only used by the ``stat`` profiler.
1670 Only used by the ``stat`` profiler.
1667
1671
1668 For the ``hotpath`` format, default is ``0.05``.
1672 For the ``hotpath`` format, default is ``0.05``.
1669 For the ``chrome`` format, default is ``0.005``.
1673 For the ``chrome`` format, default is ``0.005``.
1670
1674
1671 The option is unused on other formats.
1675 The option is unused on other formats.
1672
1676
1673 ``showmax``
1677 ``showmax``
1674 Maximum fraction of samples an entry can have before it is ignored in
1678 Maximum fraction of samples an entry can have before it is ignored in
1675 display. Values format is the same as ``showmin``.
1679 display. Values format is the same as ``showmin``.
1676
1680
1677 Only used by the ``stat`` profiler.
1681 Only used by the ``stat`` profiler.
1678
1682
1679 For the ``chrome`` format, default is ``0.999``.
1683 For the ``chrome`` format, default is ``0.999``.
1680
1684
1681 The option is unused on other formats.
1685 The option is unused on other formats.
1682
1686
1683 ``progress``
1687 ``progress``
1684 ------------
1688 ------------
1685
1689
1686 Mercurial commands can draw progress bars that are as informative as
1690 Mercurial commands can draw progress bars that are as informative as
1687 possible. Some progress bars only offer indeterminate information, while others
1691 possible. Some progress bars only offer indeterminate information, while others
1688 have a definite end point.
1692 have a definite end point.
1689
1693
1690 ``delay``
1694 ``delay``
1691 Number of seconds (float) before showing the progress bar. (default: 3)
1695 Number of seconds (float) before showing the progress bar. (default: 3)
1692
1696
1693 ``changedelay``
1697 ``changedelay``
1694 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1698 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1695 that value will be used instead. (default: 1)
1699 that value will be used instead. (default: 1)
1696
1700
1697 ``estimateinterval``
1701 ``estimateinterval``
1698 Maximum sampling interval in seconds for speed and estimated time
1702 Maximum sampling interval in seconds for speed and estimated time
1699 calculation. (default: 60)
1703 calculation. (default: 60)
1700
1704
1701 ``refresh``
1705 ``refresh``
1702 Time in seconds between refreshes of the progress bar. (default: 0.1)
1706 Time in seconds between refreshes of the progress bar. (default: 0.1)
1703
1707
1704 ``format``
1708 ``format``
1705 Format of the progress bar.
1709 Format of the progress bar.
1706
1710
1707 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1711 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1708 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1712 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1709 last 20 characters of the item, but this can be changed by adding either
1713 last 20 characters of the item, but this can be changed by adding either
1710 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1714 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1711 first num characters.
1715 first num characters.
1712
1716
1713 (default: topic bar number estimate)
1717 (default: topic bar number estimate)
1714
1718
1715 ``width``
1719 ``width``
1716 If set, the maximum width of the progress information (that is, min(width,
1720 If set, the maximum width of the progress information (that is, min(width,
1717 term width) will be used).
1721 term width) will be used).
1718
1722
1719 ``clear-complete``
1723 ``clear-complete``
1720 Clear the progress bar after it's done. (default: True)
1724 Clear the progress bar after it's done. (default: True)
1721
1725
1722 ``disable``
1726 ``disable``
1723 If true, don't show a progress bar.
1727 If true, don't show a progress bar.
1724
1728
1725 ``assume-tty``
1729 ``assume-tty``
1726 If true, ALWAYS show a progress bar, unless disable is given.
1730 If true, ALWAYS show a progress bar, unless disable is given.
1727
1731
1728 ``rebase``
1732 ``rebase``
1729 ----------
1733 ----------
1730
1734
1731 ``evolution.allowdivergence``
1735 ``evolution.allowdivergence``
1732 Default to False, when True allow creating divergence when performing
1736 Default to False, when True allow creating divergence when performing
1733 rebase of obsolete changesets.
1737 rebase of obsolete changesets.
1734
1738
1735 ``revsetalias``
1739 ``revsetalias``
1736 ---------------
1740 ---------------
1737
1741
1738 Alias definitions for revsets. See :hg:`help revsets` for details.
1742 Alias definitions for revsets. See :hg:`help revsets` for details.
1739
1743
1740 ``server``
1744 ``server``
1741 ----------
1745 ----------
1742
1746
1743 Controls generic server settings.
1747 Controls generic server settings.
1744
1748
1745 ``bookmarks-pushkey-compat``
1749 ``bookmarks-pushkey-compat``
1746 Trigger pushkey hook when being pushed bookmark updates. This config exist
1750 Trigger pushkey hook when being pushed bookmark updates. This config exist
1747 for compatibility purpose (default to True)
1751 for compatibility purpose (default to True)
1748
1752
1749 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
1753 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
1750 movement we recommend you migrate them to ``txnclose-bookmark`` and
1754 movement we recommend you migrate them to ``txnclose-bookmark`` and
1751 ``pretxnclose-bookmark``.
1755 ``pretxnclose-bookmark``.
1752
1756
1753 ``compressionengines``
1757 ``compressionengines``
1754 List of compression engines and their relative priority to advertise
1758 List of compression engines and their relative priority to advertise
1755 to clients.
1759 to clients.
1756
1760
1757 The order of compression engines determines their priority, the first
1761 The order of compression engines determines their priority, the first
1758 having the highest priority. If a compression engine is not listed
1762 having the highest priority. If a compression engine is not listed
1759 here, it won't be advertised to clients.
1763 here, it won't be advertised to clients.
1760
1764
1761 If not set (the default), built-in defaults are used. Run
1765 If not set (the default), built-in defaults are used. Run
1762 :hg:`debuginstall` to list available compression engines and their
1766 :hg:`debuginstall` to list available compression engines and their
1763 default wire protocol priority.
1767 default wire protocol priority.
1764
1768
1765 Older Mercurial clients only support zlib compression and this setting
1769 Older Mercurial clients only support zlib compression and this setting
1766 has no effect for legacy clients.
1770 has no effect for legacy clients.
1767
1771
1768 ``uncompressed``
1772 ``uncompressed``
1769 Whether to allow clients to clone a repository using the
1773 Whether to allow clients to clone a repository using the
1770 uncompressed streaming protocol. This transfers about 40% more
1774 uncompressed streaming protocol. This transfers about 40% more
1771 data than a regular clone, but uses less memory and CPU on both
1775 data than a regular clone, but uses less memory and CPU on both
1772 server and client. Over a LAN (100 Mbps or better) or a very fast
1776 server and client. Over a LAN (100 Mbps or better) or a very fast
1773 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1777 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1774 regular clone. Over most WAN connections (anything slower than
1778 regular clone. Over most WAN connections (anything slower than
1775 about 6 Mbps), uncompressed streaming is slower, because of the
1779 about 6 Mbps), uncompressed streaming is slower, because of the
1776 extra data transfer overhead. This mode will also temporarily hold
1780 extra data transfer overhead. This mode will also temporarily hold
1777 the write lock while determining what data to transfer.
1781 the write lock while determining what data to transfer.
1778 (default: True)
1782 (default: True)
1779
1783
1780 ``uncompressedallowsecret``
1784 ``uncompressedallowsecret``
1781 Whether to allow stream clones when the repository contains secret
1785 Whether to allow stream clones when the repository contains secret
1782 changesets. (default: False)
1786 changesets. (default: False)
1783
1787
1784 ``preferuncompressed``
1788 ``preferuncompressed``
1785 When set, clients will try to use the uncompressed streaming
1789 When set, clients will try to use the uncompressed streaming
1786 protocol. (default: False)
1790 protocol. (default: False)
1787
1791
1788 ``disablefullbundle``
1792 ``disablefullbundle``
1789 When set, servers will refuse attempts to do pull-based clones.
1793 When set, servers will refuse attempts to do pull-based clones.
1790 If this option is set, ``preferuncompressed`` and/or clone bundles
1794 If this option is set, ``preferuncompressed`` and/or clone bundles
1791 are highly recommended. Partial clones will still be allowed.
1795 are highly recommended. Partial clones will still be allowed.
1792 (default: False)
1796 (default: False)
1793
1797
1794 ``streamunbundle``
1798 ``streamunbundle``
1795 When set, servers will apply data sent from the client directly,
1799 When set, servers will apply data sent from the client directly,
1796 otherwise it will be written to a temporary file first. This option
1800 otherwise it will be written to a temporary file first. This option
1797 effectively prevents concurrent pushes.
1801 effectively prevents concurrent pushes.
1798
1802
1799 ``pullbundle``
1803 ``pullbundle``
1800 When set, the server will check pullbundle.manifest for bundles
1804 When set, the server will check pullbundle.manifest for bundles
1801 covering the requested heads and common nodes. The first matching
1805 covering the requested heads and common nodes. The first matching
1802 entry will be streamed to the client.
1806 entry will be streamed to the client.
1803
1807
1804 For HTTP transport, the stream will still use zlib compression
1808 For HTTP transport, the stream will still use zlib compression
1805 for older clients.
1809 for older clients.
1806
1810
1807 ``concurrent-push-mode``
1811 ``concurrent-push-mode``
1808 Level of allowed race condition between two pushing clients.
1812 Level of allowed race condition between two pushing clients.
1809
1813
1810 - 'strict': push is abort if another client touched the repository
1814 - 'strict': push is abort if another client touched the repository
1811 while the push was preparing. (default)
1815 while the push was preparing. (default)
1812 - 'check-related': push is only aborted if it affects head that got also
1816 - 'check-related': push is only aborted if it affects head that got also
1813 affected while the push was preparing.
1817 affected while the push was preparing.
1814
1818
1815 This requires compatible client (version 4.3 and later). Old client will
1819 This requires compatible client (version 4.3 and later). Old client will
1816 use 'strict'.
1820 use 'strict'.
1817
1821
1818 ``validate``
1822 ``validate``
1819 Whether to validate the completeness of pushed changesets by
1823 Whether to validate the completeness of pushed changesets by
1820 checking that all new file revisions specified in manifests are
1824 checking that all new file revisions specified in manifests are
1821 present. (default: False)
1825 present. (default: False)
1822
1826
1823 ``maxhttpheaderlen``
1827 ``maxhttpheaderlen``
1824 Instruct HTTP clients not to send request headers longer than this
1828 Instruct HTTP clients not to send request headers longer than this
1825 many bytes. (default: 1024)
1829 many bytes. (default: 1024)
1826
1830
1827 ``bundle1``
1831 ``bundle1``
1828 Whether to allow clients to push and pull using the legacy bundle1
1832 Whether to allow clients to push and pull using the legacy bundle1
1829 exchange format. (default: True)
1833 exchange format. (default: True)
1830
1834
1831 ``bundle1gd``
1835 ``bundle1gd``
1832 Like ``bundle1`` but only used if the repository is using the
1836 Like ``bundle1`` but only used if the repository is using the
1833 *generaldelta* storage format. (default: True)
1837 *generaldelta* storage format. (default: True)
1834
1838
1835 ``bundle1.push``
1839 ``bundle1.push``
1836 Whether to allow clients to push using the legacy bundle1 exchange
1840 Whether to allow clients to push using the legacy bundle1 exchange
1837 format. (default: True)
1841 format. (default: True)
1838
1842
1839 ``bundle1gd.push``
1843 ``bundle1gd.push``
1840 Like ``bundle1.push`` but only used if the repository is using the
1844 Like ``bundle1.push`` but only used if the repository is using the
1841 *generaldelta* storage format. (default: True)
1845 *generaldelta* storage format. (default: True)
1842
1846
1843 ``bundle1.pull``
1847 ``bundle1.pull``
1844 Whether to allow clients to pull using the legacy bundle1 exchange
1848 Whether to allow clients to pull using the legacy bundle1 exchange
1845 format. (default: True)
1849 format. (default: True)
1846
1850
1847 ``bundle1gd.pull``
1851 ``bundle1gd.pull``
1848 Like ``bundle1.pull`` but only used if the repository is using the
1852 Like ``bundle1.pull`` but only used if the repository is using the
1849 *generaldelta* storage format. (default: True)
1853 *generaldelta* storage format. (default: True)
1850
1854
1851 Large repositories using the *generaldelta* storage format should
1855 Large repositories using the *generaldelta* storage format should
1852 consider setting this option because converting *generaldelta*
1856 consider setting this option because converting *generaldelta*
1853 repositories to the exchange format required by the bundle1 data
1857 repositories to the exchange format required by the bundle1 data
1854 format can consume a lot of CPU.
1858 format can consume a lot of CPU.
1855
1859
1856 ``zliblevel``
1860 ``zliblevel``
1857 Integer between ``-1`` and ``9`` that controls the zlib compression level
1861 Integer between ``-1`` and ``9`` that controls the zlib compression level
1858 for wire protocol commands that send zlib compressed output (notably the
1862 for wire protocol commands that send zlib compressed output (notably the
1859 commands that send repository history data).
1863 commands that send repository history data).
1860
1864
1861 The default (``-1``) uses the default zlib compression level, which is
1865 The default (``-1``) uses the default zlib compression level, which is
1862 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
1866 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
1863 maximum compression.
1867 maximum compression.
1864
1868
1865 Setting this option allows server operators to make trade-offs between
1869 Setting this option allows server operators to make trade-offs between
1866 bandwidth and CPU used. Lowering the compression lowers CPU utilization
1870 bandwidth and CPU used. Lowering the compression lowers CPU utilization
1867 but sends more bytes to clients.
1871 but sends more bytes to clients.
1868
1872
1869 This option only impacts the HTTP server.
1873 This option only impacts the HTTP server.
1870
1874
1871 ``zstdlevel``
1875 ``zstdlevel``
1872 Integer between ``1`` and ``22`` that controls the zstd compression level
1876 Integer between ``1`` and ``22`` that controls the zstd compression level
1873 for wire protocol commands. ``1`` is the minimal amount of compression and
1877 for wire protocol commands. ``1`` is the minimal amount of compression and
1874 ``22`` is the highest amount of compression.
1878 ``22`` is the highest amount of compression.
1875
1879
1876 The default (``3``) should be significantly faster than zlib while likely
1880 The default (``3``) should be significantly faster than zlib while likely
1877 delivering better compression ratios.
1881 delivering better compression ratios.
1878
1882
1879 This option only impacts the HTTP server.
1883 This option only impacts the HTTP server.
1880
1884
1881 See also ``server.zliblevel``.
1885 See also ``server.zliblevel``.
1882
1886
1883 ``smtp``
1887 ``smtp``
1884 --------
1888 --------
1885
1889
1886 Configuration for extensions that need to send email messages.
1890 Configuration for extensions that need to send email messages.
1887
1891
1888 ``host``
1892 ``host``
1889 Host name of mail server, e.g. "mail.example.com".
1893 Host name of mail server, e.g. "mail.example.com".
1890
1894
1891 ``port``
1895 ``port``
1892 Optional. Port to connect to on mail server. (default: 465 if
1896 Optional. Port to connect to on mail server. (default: 465 if
1893 ``tls`` is smtps; 25 otherwise)
1897 ``tls`` is smtps; 25 otherwise)
1894
1898
1895 ``tls``
1899 ``tls``
1896 Optional. Method to enable TLS when connecting to mail server: starttls,
1900 Optional. Method to enable TLS when connecting to mail server: starttls,
1897 smtps or none. (default: none)
1901 smtps or none. (default: none)
1898
1902
1899 ``username``
1903 ``username``
1900 Optional. User name for authenticating with the SMTP server.
1904 Optional. User name for authenticating with the SMTP server.
1901 (default: None)
1905 (default: None)
1902
1906
1903 ``password``
1907 ``password``
1904 Optional. Password for authenticating with the SMTP server. If not
1908 Optional. Password for authenticating with the SMTP server. If not
1905 specified, interactive sessions will prompt the user for a
1909 specified, interactive sessions will prompt the user for a
1906 password; non-interactive sessions will fail. (default: None)
1910 password; non-interactive sessions will fail. (default: None)
1907
1911
1908 ``local_hostname``
1912 ``local_hostname``
1909 Optional. The hostname that the sender can use to identify
1913 Optional. The hostname that the sender can use to identify
1910 itself to the MTA.
1914 itself to the MTA.
1911
1915
1912
1916
1913 ``subpaths``
1917 ``subpaths``
1914 ------------
1918 ------------
1915
1919
1916 Subrepository source URLs can go stale if a remote server changes name
1920 Subrepository source URLs can go stale if a remote server changes name
1917 or becomes temporarily unavailable. This section lets you define
1921 or becomes temporarily unavailable. This section lets you define
1918 rewrite rules of the form::
1922 rewrite rules of the form::
1919
1923
1920 <pattern> = <replacement>
1924 <pattern> = <replacement>
1921
1925
1922 where ``pattern`` is a regular expression matching a subrepository
1926 where ``pattern`` is a regular expression matching a subrepository
1923 source URL and ``replacement`` is the replacement string used to
1927 source URL and ``replacement`` is the replacement string used to
1924 rewrite it. Groups can be matched in ``pattern`` and referenced in
1928 rewrite it. Groups can be matched in ``pattern`` and referenced in
1925 ``replacements``. For instance::
1929 ``replacements``. For instance::
1926
1930
1927 http://server/(.*)-hg/ = http://hg.server/\1/
1931 http://server/(.*)-hg/ = http://hg.server/\1/
1928
1932
1929 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1933 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1930
1934
1931 Relative subrepository paths are first made absolute, and the
1935 Relative subrepository paths are first made absolute, and the
1932 rewrite rules are then applied on the full (absolute) path. If ``pattern``
1936 rewrite rules are then applied on the full (absolute) path. If ``pattern``
1933 doesn't match the full path, an attempt is made to apply it on the
1937 doesn't match the full path, an attempt is made to apply it on the
1934 relative path alone. The rules are applied in definition order.
1938 relative path alone. The rules are applied in definition order.
1935
1939
1936 ``subrepos``
1940 ``subrepos``
1937 ------------
1941 ------------
1938
1942
1939 This section contains options that control the behavior of the
1943 This section contains options that control the behavior of the
1940 subrepositories feature. See also :hg:`help subrepos`.
1944 subrepositories feature. See also :hg:`help subrepos`.
1941
1945
1942 Security note: auditing in Mercurial is known to be insufficient to
1946 Security note: auditing in Mercurial is known to be insufficient to
1943 prevent clone-time code execution with carefully constructed Git
1947 prevent clone-time code execution with carefully constructed Git
1944 subrepos. It is unknown if a similar detect is present in Subversion
1948 subrepos. It is unknown if a similar detect is present in Subversion
1945 subrepos. Both Git and Subversion subrepos are disabled by default
1949 subrepos. Both Git and Subversion subrepos are disabled by default
1946 out of security concerns. These subrepo types can be enabled using
1950 out of security concerns. These subrepo types can be enabled using
1947 the respective options below.
1951 the respective options below.
1948
1952
1949 ``allowed``
1953 ``allowed``
1950 Whether subrepositories are allowed in the working directory.
1954 Whether subrepositories are allowed in the working directory.
1951
1955
1952 When false, commands involving subrepositories (like :hg:`update`)
1956 When false, commands involving subrepositories (like :hg:`update`)
1953 will fail for all subrepository types.
1957 will fail for all subrepository types.
1954 (default: true)
1958 (default: true)
1955
1959
1956 ``hg:allowed``
1960 ``hg:allowed``
1957 Whether Mercurial subrepositories are allowed in the working
1961 Whether Mercurial subrepositories are allowed in the working
1958 directory. This option only has an effect if ``subrepos.allowed``
1962 directory. This option only has an effect if ``subrepos.allowed``
1959 is true.
1963 is true.
1960 (default: true)
1964 (default: true)
1961
1965
1962 ``git:allowed``
1966 ``git:allowed``
1963 Whether Git subrepositories are allowed in the working directory.
1967 Whether Git subrepositories are allowed in the working directory.
1964 This option only has an effect if ``subrepos.allowed`` is true.
1968 This option only has an effect if ``subrepos.allowed`` is true.
1965
1969
1966 See the security note above before enabling Git subrepos.
1970 See the security note above before enabling Git subrepos.
1967 (default: false)
1971 (default: false)
1968
1972
1969 ``svn:allowed``
1973 ``svn:allowed``
1970 Whether Subversion subrepositories are allowed in the working
1974 Whether Subversion subrepositories are allowed in the working
1971 directory. This option only has an effect if ``subrepos.allowed``
1975 directory. This option only has an effect if ``subrepos.allowed``
1972 is true.
1976 is true.
1973
1977
1974 See the security note above before enabling Subversion subrepos.
1978 See the security note above before enabling Subversion subrepos.
1975 (default: false)
1979 (default: false)
1976
1980
1977 ``templatealias``
1981 ``templatealias``
1978 -----------------
1982 -----------------
1979
1983
1980 Alias definitions for templates. See :hg:`help templates` for details.
1984 Alias definitions for templates. See :hg:`help templates` for details.
1981
1985
1982 ``templates``
1986 ``templates``
1983 -------------
1987 -------------
1984
1988
1985 Use the ``[templates]`` section to define template strings.
1989 Use the ``[templates]`` section to define template strings.
1986 See :hg:`help templates` for details.
1990 See :hg:`help templates` for details.
1987
1991
1988 ``trusted``
1992 ``trusted``
1989 -----------
1993 -----------
1990
1994
1991 Mercurial will not use the settings in the
1995 Mercurial will not use the settings in the
1992 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
1996 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
1993 user or to a trusted group, as various hgrc features allow arbitrary
1997 user or to a trusted group, as various hgrc features allow arbitrary
1994 commands to be run. This issue is often encountered when configuring
1998 commands to be run. This issue is often encountered when configuring
1995 hooks or extensions for shared repositories or servers. However,
1999 hooks or extensions for shared repositories or servers. However,
1996 the web interface will use some safe settings from the ``[web]``
2000 the web interface will use some safe settings from the ``[web]``
1997 section.
2001 section.
1998
2002
1999 This section specifies what users and groups are trusted. The
2003 This section specifies what users and groups are trusted. The
2000 current user is always trusted. To trust everybody, list a user or a
2004 current user is always trusted. To trust everybody, list a user or a
2001 group with name ``*``. These settings must be placed in an
2005 group with name ``*``. These settings must be placed in an
2002 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2006 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2003 user or service running Mercurial.
2007 user or service running Mercurial.
2004
2008
2005 ``users``
2009 ``users``
2006 Comma-separated list of trusted users.
2010 Comma-separated list of trusted users.
2007
2011
2008 ``groups``
2012 ``groups``
2009 Comma-separated list of trusted groups.
2013 Comma-separated list of trusted groups.
2010
2014
2011
2015
2012 ``ui``
2016 ``ui``
2013 ------
2017 ------
2014
2018
2015 User interface controls.
2019 User interface controls.
2016
2020
2017 ``archivemeta``
2021 ``archivemeta``
2018 Whether to include the .hg_archival.txt file containing meta data
2022 Whether to include the .hg_archival.txt file containing meta data
2019 (hashes for the repository base and for tip) in archives created
2023 (hashes for the repository base and for tip) in archives created
2020 by the :hg:`archive` command or downloaded via hgweb.
2024 by the :hg:`archive` command or downloaded via hgweb.
2021 (default: True)
2025 (default: True)
2022
2026
2023 ``askusername``
2027 ``askusername``
2024 Whether to prompt for a username when committing. If True, and
2028 Whether to prompt for a username when committing. If True, and
2025 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2029 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2026 be prompted to enter a username. If no username is entered, the
2030 be prompted to enter a username. If no username is entered, the
2027 default ``USER@HOST`` is used instead.
2031 default ``USER@HOST`` is used instead.
2028 (default: False)
2032 (default: False)
2029
2033
2030 ``clonebundles``
2034 ``clonebundles``
2031 Whether the "clone bundles" feature is enabled.
2035 Whether the "clone bundles" feature is enabled.
2032
2036
2033 When enabled, :hg:`clone` may download and apply a server-advertised
2037 When enabled, :hg:`clone` may download and apply a server-advertised
2034 bundle file from a URL instead of using the normal exchange mechanism.
2038 bundle file from a URL instead of using the normal exchange mechanism.
2035
2039
2036 This can likely result in faster and more reliable clones.
2040 This can likely result in faster and more reliable clones.
2037
2041
2038 (default: True)
2042 (default: True)
2039
2043
2040 ``clonebundlefallback``
2044 ``clonebundlefallback``
2041 Whether failure to apply an advertised "clone bundle" from a server
2045 Whether failure to apply an advertised "clone bundle" from a server
2042 should result in fallback to a regular clone.
2046 should result in fallback to a regular clone.
2043
2047
2044 This is disabled by default because servers advertising "clone
2048 This is disabled by default because servers advertising "clone
2045 bundles" often do so to reduce server load. If advertised bundles
2049 bundles" often do so to reduce server load. If advertised bundles
2046 start mass failing and clients automatically fall back to a regular
2050 start mass failing and clients automatically fall back to a regular
2047 clone, this would add significant and unexpected load to the server
2051 clone, this would add significant and unexpected load to the server
2048 since the server is expecting clone operations to be offloaded to
2052 since the server is expecting clone operations to be offloaded to
2049 pre-generated bundles. Failing fast (the default behavior) ensures
2053 pre-generated bundles. Failing fast (the default behavior) ensures
2050 clients don't overwhelm the server when "clone bundle" application
2054 clients don't overwhelm the server when "clone bundle" application
2051 fails.
2055 fails.
2052
2056
2053 (default: False)
2057 (default: False)
2054
2058
2055 ``clonebundleprefers``
2059 ``clonebundleprefers``
2056 Defines preferences for which "clone bundles" to use.
2060 Defines preferences for which "clone bundles" to use.
2057
2061
2058 Servers advertising "clone bundles" may advertise multiple available
2062 Servers advertising "clone bundles" may advertise multiple available
2059 bundles. Each bundle may have different attributes, such as the bundle
2063 bundles. Each bundle may have different attributes, such as the bundle
2060 type and compression format. This option is used to prefer a particular
2064 type and compression format. This option is used to prefer a particular
2061 bundle over another.
2065 bundle over another.
2062
2066
2063 The following keys are defined by Mercurial:
2067 The following keys are defined by Mercurial:
2064
2068
2065 BUNDLESPEC
2069 BUNDLESPEC
2066 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2070 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2067 e.g. ``gzip-v2`` or ``bzip2-v1``.
2071 e.g. ``gzip-v2`` or ``bzip2-v1``.
2068
2072
2069 COMPRESSION
2073 COMPRESSION
2070 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2074 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2071
2075
2072 Server operators may define custom keys.
2076 Server operators may define custom keys.
2073
2077
2074 Example values: ``COMPRESSION=bzip2``,
2078 Example values: ``COMPRESSION=bzip2``,
2075 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2079 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2076
2080
2077 By default, the first bundle advertised by the server is used.
2081 By default, the first bundle advertised by the server is used.
2078
2082
2079 ``color``
2083 ``color``
2080 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2084 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2081 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2085 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2082 seems possible. See :hg:`help color` for details.
2086 seems possible. See :hg:`help color` for details.
2083
2087
2084 ``commitsubrepos``
2088 ``commitsubrepos``
2085 Whether to commit modified subrepositories when committing the
2089 Whether to commit modified subrepositories when committing the
2086 parent repository. If False and one subrepository has uncommitted
2090 parent repository. If False and one subrepository has uncommitted
2087 changes, abort the commit.
2091 changes, abort the commit.
2088 (default: False)
2092 (default: False)
2089
2093
2090 ``debug``
2094 ``debug``
2091 Print debugging information. (default: False)
2095 Print debugging information. (default: False)
2092
2096
2093 ``editor``
2097 ``editor``
2094 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2098 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2095
2099
2096 ``fallbackencoding``
2100 ``fallbackencoding``
2097 Encoding to try if it's not possible to decode the changelog using
2101 Encoding to try if it's not possible to decode the changelog using
2098 UTF-8. (default: ISO-8859-1)
2102 UTF-8. (default: ISO-8859-1)
2099
2103
2100 ``graphnodetemplate``
2104 ``graphnodetemplate``
2101 The template used to print changeset nodes in an ASCII revision graph.
2105 The template used to print changeset nodes in an ASCII revision graph.
2102 (default: ``{graphnode}``)
2106 (default: ``{graphnode}``)
2103
2107
2104 ``ignore``
2108 ``ignore``
2105 A file to read per-user ignore patterns from. This file should be
2109 A file to read per-user ignore patterns from. This file should be
2106 in the same format as a repository-wide .hgignore file. Filenames
2110 in the same format as a repository-wide .hgignore file. Filenames
2107 are relative to the repository root. This option supports hook syntax,
2111 are relative to the repository root. This option supports hook syntax,
2108 so if you want to specify multiple ignore files, you can do so by
2112 so if you want to specify multiple ignore files, you can do so by
2109 setting something like ``ignore.other = ~/.hgignore2``. For details
2113 setting something like ``ignore.other = ~/.hgignore2``. For details
2110 of the ignore file format, see the ``hgignore(5)`` man page.
2114 of the ignore file format, see the ``hgignore(5)`` man page.
2111
2115
2112 ``interactive``
2116 ``interactive``
2113 Allow to prompt the user. (default: True)
2117 Allow to prompt the user. (default: True)
2114
2118
2115 ``interface``
2119 ``interface``
2116 Select the default interface for interactive features (default: text).
2120 Select the default interface for interactive features (default: text).
2117 Possible values are 'text' and 'curses'.
2121 Possible values are 'text' and 'curses'.
2118
2122
2119 ``interface.chunkselector``
2123 ``interface.chunkselector``
2120 Select the interface for change recording (e.g. :hg:`commit -i`).
2124 Select the interface for change recording (e.g. :hg:`commit -i`).
2121 Possible values are 'text' and 'curses'.
2125 Possible values are 'text' and 'curses'.
2122 This config overrides the interface specified by ui.interface.
2126 This config overrides the interface specified by ui.interface.
2123
2127
2124 ``logtemplate``
2128 ``logtemplate``
2125 Template string for commands that print changesets.
2129 Template string for commands that print changesets.
2126
2130
2127 ``merge``
2131 ``merge``
2128 The conflict resolution program to use during a manual merge.
2132 The conflict resolution program to use during a manual merge.
2129 For more information on merge tools see :hg:`help merge-tools`.
2133 For more information on merge tools see :hg:`help merge-tools`.
2130 For configuring merge tools see the ``[merge-tools]`` section.
2134 For configuring merge tools see the ``[merge-tools]`` section.
2131
2135
2132 ``mergemarkers``
2136 ``mergemarkers``
2133 Sets the merge conflict marker label styling. The ``detailed``
2137 Sets the merge conflict marker label styling. The ``detailed``
2134 style uses the ``mergemarkertemplate`` setting to style the labels.
2138 style uses the ``mergemarkertemplate`` setting to style the labels.
2135 The ``basic`` style just uses 'local' and 'other' as the marker label.
2139 The ``basic`` style just uses 'local' and 'other' as the marker label.
2136 One of ``basic`` or ``detailed``.
2140 One of ``basic`` or ``detailed``.
2137 (default: ``basic``)
2141 (default: ``basic``)
2138
2142
2139 ``mergemarkertemplate``
2143 ``mergemarkertemplate``
2140 The template used to print the commit description next to each conflict
2144 The template used to print the commit description next to each conflict
2141 marker during merge conflicts. See :hg:`help templates` for the template
2145 marker during merge conflicts. See :hg:`help templates` for the template
2142 format.
2146 format.
2143
2147
2144 Defaults to showing the hash, tags, branches, bookmarks, author, and
2148 Defaults to showing the hash, tags, branches, bookmarks, author, and
2145 the first line of the commit description.
2149 the first line of the commit description.
2146
2150
2147 If you use non-ASCII characters in names for tags, branches, bookmarks,
2151 If you use non-ASCII characters in names for tags, branches, bookmarks,
2148 authors, and/or commit descriptions, you must pay attention to encodings of
2152 authors, and/or commit descriptions, you must pay attention to encodings of
2149 managed files. At template expansion, non-ASCII characters use the encoding
2153 managed files. At template expansion, non-ASCII characters use the encoding
2150 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2154 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2151 environment variables that govern your locale. If the encoding of the merge
2155 environment variables that govern your locale. If the encoding of the merge
2152 markers is different from the encoding of the merged files,
2156 markers is different from the encoding of the merged files,
2153 serious problems may occur.
2157 serious problems may occur.
2154
2158
2155 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2159 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2156
2160
2157 ``origbackuppath``
2161 ``origbackuppath``
2158 The path to a directory used to store generated .orig files. If the path is
2162 The path to a directory used to store generated .orig files. If the path is
2159 not a directory, one will be created. If set, files stored in this
2163 not a directory, one will be created. If set, files stored in this
2160 directory have the same name as the original file and do not have a .orig
2164 directory have the same name as the original file and do not have a .orig
2161 suffix.
2165 suffix.
2162
2166
2163 ``paginate``
2167 ``paginate``
2164 Control the pagination of command output (default: True). See :hg:`help pager`
2168 Control the pagination of command output (default: True). See :hg:`help pager`
2165 for details.
2169 for details.
2166
2170
2167 ``patch``
2171 ``patch``
2168 An optional external tool that ``hg import`` and some extensions
2172 An optional external tool that ``hg import`` and some extensions
2169 will use for applying patches. By default Mercurial uses an
2173 will use for applying patches. By default Mercurial uses an
2170 internal patch utility. The external tool must work as the common
2174 internal patch utility. The external tool must work as the common
2171 Unix ``patch`` program. In particular, it must accept a ``-p``
2175 Unix ``patch`` program. In particular, it must accept a ``-p``
2172 argument to strip patch headers, a ``-d`` argument to specify the
2176 argument to strip patch headers, a ``-d`` argument to specify the
2173 current directory, a file name to patch, and a patch file to take
2177 current directory, a file name to patch, and a patch file to take
2174 from stdin.
2178 from stdin.
2175
2179
2176 It is possible to specify a patch tool together with extra
2180 It is possible to specify a patch tool together with extra
2177 arguments. For example, setting this option to ``patch --merge``
2181 arguments. For example, setting this option to ``patch --merge``
2178 will use the ``patch`` program with its 2-way merge option.
2182 will use the ``patch`` program with its 2-way merge option.
2179
2183
2180 ``portablefilenames``
2184 ``portablefilenames``
2181 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2185 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2182 (default: ``warn``)
2186 (default: ``warn``)
2183
2187
2184 ``warn``
2188 ``warn``
2185 Print a warning message on POSIX platforms, if a file with a non-portable
2189 Print a warning message on POSIX platforms, if a file with a non-portable
2186 filename is added (e.g. a file with a name that can't be created on
2190 filename is added (e.g. a file with a name that can't be created on
2187 Windows because it contains reserved parts like ``AUX``, reserved
2191 Windows because it contains reserved parts like ``AUX``, reserved
2188 characters like ``:``, or would cause a case collision with an existing
2192 characters like ``:``, or would cause a case collision with an existing
2189 file).
2193 file).
2190
2194
2191 ``ignore``
2195 ``ignore``
2192 Don't print a warning.
2196 Don't print a warning.
2193
2197
2194 ``abort``
2198 ``abort``
2195 The command is aborted.
2199 The command is aborted.
2196
2200
2197 ``true``
2201 ``true``
2198 Alias for ``warn``.
2202 Alias for ``warn``.
2199
2203
2200 ``false``
2204 ``false``
2201 Alias for ``ignore``.
2205 Alias for ``ignore``.
2202
2206
2203 .. container:: windows
2207 .. container:: windows
2204
2208
2205 On Windows, this configuration option is ignored and the command aborted.
2209 On Windows, this configuration option is ignored and the command aborted.
2206
2210
2207 ``quiet``
2211 ``quiet``
2208 Reduce the amount of output printed.
2212 Reduce the amount of output printed.
2209 (default: False)
2213 (default: False)
2210
2214
2211 ``remotecmd``
2215 ``remotecmd``
2212 Remote command to use for clone/push/pull operations.
2216 Remote command to use for clone/push/pull operations.
2213 (default: ``hg``)
2217 (default: ``hg``)
2214
2218
2215 ``report_untrusted``
2219 ``report_untrusted``
2216 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2220 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2217 trusted user or group.
2221 trusted user or group.
2218 (default: True)
2222 (default: True)
2219
2223
2220 ``slash``
2224 ``slash``
2221 (Deprecated. Use ``slashpath`` template filter instead.)
2225 (Deprecated. Use ``slashpath`` template filter instead.)
2222
2226
2223 Display paths using a slash (``/``) as the path separator. This
2227 Display paths using a slash (``/``) as the path separator. This
2224 only makes a difference on systems where the default path
2228 only makes a difference on systems where the default path
2225 separator is not the slash character (e.g. Windows uses the
2229 separator is not the slash character (e.g. Windows uses the
2226 backslash character (``\``)).
2230 backslash character (``\``)).
2227 (default: False)
2231 (default: False)
2228
2232
2229 ``statuscopies``
2233 ``statuscopies``
2230 Display copies in the status command.
2234 Display copies in the status command.
2231
2235
2232 ``ssh``
2236 ``ssh``
2233 Command to use for SSH connections. (default: ``ssh``)
2237 Command to use for SSH connections. (default: ``ssh``)
2234
2238
2235 ``ssherrorhint``
2239 ``ssherrorhint``
2236 A hint shown to the user in the case of SSH error (e.g.
2240 A hint shown to the user in the case of SSH error (e.g.
2237 ``Please see http://company/internalwiki/ssh.html``)
2241 ``Please see http://company/internalwiki/ssh.html``)
2238
2242
2239 ``strict``
2243 ``strict``
2240 Require exact command names, instead of allowing unambiguous
2244 Require exact command names, instead of allowing unambiguous
2241 abbreviations. (default: False)
2245 abbreviations. (default: False)
2242
2246
2243 ``style``
2247 ``style``
2244 Name of style to use for command output.
2248 Name of style to use for command output.
2245
2249
2246 ``supportcontact``
2250 ``supportcontact``
2247 A URL where users should report a Mercurial traceback. Use this if you are a
2251 A URL where users should report a Mercurial traceback. Use this if you are a
2248 large organisation with its own Mercurial deployment process and crash
2252 large organisation with its own Mercurial deployment process and crash
2249 reports should be addressed to your internal support.
2253 reports should be addressed to your internal support.
2250
2254
2251 ``textwidth``
2255 ``textwidth``
2252 Maximum width of help text. A longer line generated by ``hg help`` or
2256 Maximum width of help text. A longer line generated by ``hg help`` or
2253 ``hg subcommand --help`` will be broken after white space to get this
2257 ``hg subcommand --help`` will be broken after white space to get this
2254 width or the terminal width, whichever comes first.
2258 width or the terminal width, whichever comes first.
2255 A non-positive value will disable this and the terminal width will be
2259 A non-positive value will disable this and the terminal width will be
2256 used. (default: 78)
2260 used. (default: 78)
2257
2261
2258 ``timeout``
2262 ``timeout``
2259 The timeout used when a lock is held (in seconds), a negative value
2263 The timeout used when a lock is held (in seconds), a negative value
2260 means no timeout. (default: 600)
2264 means no timeout. (default: 600)
2261
2265
2262 ``timeout.warn``
2266 ``timeout.warn``
2263 Time (in seconds) before a warning is printed about held lock. A negative
2267 Time (in seconds) before a warning is printed about held lock. A negative
2264 value means no warning. (default: 0)
2268 value means no warning. (default: 0)
2265
2269
2266 ``traceback``
2270 ``traceback``
2267 Mercurial always prints a traceback when an unknown exception
2271 Mercurial always prints a traceback when an unknown exception
2268 occurs. Setting this to True will make Mercurial print a traceback
2272 occurs. Setting this to True will make Mercurial print a traceback
2269 on all exceptions, even those recognized by Mercurial (such as
2273 on all exceptions, even those recognized by Mercurial (such as
2270 IOError or MemoryError). (default: False)
2274 IOError or MemoryError). (default: False)
2271
2275
2272 ``tweakdefaults``
2276 ``tweakdefaults``
2273
2277
2274 By default Mercurial's behavior changes very little from release
2278 By default Mercurial's behavior changes very little from release
2275 to release, but over time the recommended config settings
2279 to release, but over time the recommended config settings
2276 shift. Enable this config to opt in to get automatic tweaks to
2280 shift. Enable this config to opt in to get automatic tweaks to
2277 Mercurial's behavior over time. This config setting will have no
2281 Mercurial's behavior over time. This config setting will have no
2278 effet if ``HGPLAIN` is set or ``HGPLAINEXCEPT`` is set and does
2282 effet if ``HGPLAIN` is set or ``HGPLAINEXCEPT`` is set and does
2279 not include ``tweakdefaults``. (default: False)
2283 not include ``tweakdefaults``. (default: False)
2280
2284
2281 ``username``
2285 ``username``
2282 The committer of a changeset created when running "commit".
2286 The committer of a changeset created when running "commit".
2283 Typically a person's name and email address, e.g. ``Fred Widget
2287 Typically a person's name and email address, e.g. ``Fred Widget
2284 <fred@example.com>``. Environment variables in the
2288 <fred@example.com>``. Environment variables in the
2285 username are expanded.
2289 username are expanded.
2286
2290
2287 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2291 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2288 hgrc is empty, e.g. if the system admin set ``username =`` in the
2292 hgrc is empty, e.g. if the system admin set ``username =`` in the
2289 system hgrc, it has to be specified manually or in a different
2293 system hgrc, it has to be specified manually or in a different
2290 hgrc file)
2294 hgrc file)
2291
2295
2292 ``verbose``
2296 ``verbose``
2293 Increase the amount of output printed. (default: False)
2297 Increase the amount of output printed. (default: False)
2294
2298
2295
2299
2296 ``web``
2300 ``web``
2297 -------
2301 -------
2298
2302
2299 Web interface configuration. The settings in this section apply to
2303 Web interface configuration. The settings in this section apply to
2300 both the builtin webserver (started by :hg:`serve`) and the script you
2304 both the builtin webserver (started by :hg:`serve`) and the script you
2301 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2305 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2302 and WSGI).
2306 and WSGI).
2303
2307
2304 The Mercurial webserver does no authentication (it does not prompt for
2308 The Mercurial webserver does no authentication (it does not prompt for
2305 usernames and passwords to validate *who* users are), but it does do
2309 usernames and passwords to validate *who* users are), but it does do
2306 authorization (it grants or denies access for *authenticated users*
2310 authorization (it grants or denies access for *authenticated users*
2307 based on settings in this section). You must either configure your
2311 based on settings in this section). You must either configure your
2308 webserver to do authentication for you, or disable the authorization
2312 webserver to do authentication for you, or disable the authorization
2309 checks.
2313 checks.
2310
2314
2311 For a quick setup in a trusted environment, e.g., a private LAN, where
2315 For a quick setup in a trusted environment, e.g., a private LAN, where
2312 you want it to accept pushes from anybody, you can use the following
2316 you want it to accept pushes from anybody, you can use the following
2313 command line::
2317 command line::
2314
2318
2315 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2319 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2316
2320
2317 Note that this will allow anybody to push anything to the server and
2321 Note that this will allow anybody to push anything to the server and
2318 that this should not be used for public servers.
2322 that this should not be used for public servers.
2319
2323
2320 The full set of options is:
2324 The full set of options is:
2321
2325
2322 ``accesslog``
2326 ``accesslog``
2323 Where to output the access log. (default: stdout)
2327 Where to output the access log. (default: stdout)
2324
2328
2325 ``address``
2329 ``address``
2326 Interface address to bind to. (default: all)
2330 Interface address to bind to. (default: all)
2327
2331
2328 ``allow_archive``
2332 ``allow_archive``
2329 List of archive format (bz2, gz, zip) allowed for downloading.
2333 List of archive format (bz2, gz, zip) allowed for downloading.
2330 (default: empty)
2334 (default: empty)
2331
2335
2332 ``allowbz2``
2336 ``allowbz2``
2333 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2337 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2334 revisions.
2338 revisions.
2335 (default: False)
2339 (default: False)
2336
2340
2337 ``allowgz``
2341 ``allowgz``
2338 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2342 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2339 revisions.
2343 revisions.
2340 (default: False)
2344 (default: False)
2341
2345
2342 ``allow-pull``
2346 ``allow-pull``
2343 Whether to allow pulling from the repository. (default: True)
2347 Whether to allow pulling from the repository. (default: True)
2344
2348
2345 ``allow-push``
2349 ``allow-push``
2346 Whether to allow pushing to the repository. If empty or not set,
2350 Whether to allow pushing to the repository. If empty or not set,
2347 pushing is not allowed. If the special value ``*``, any remote
2351 pushing is not allowed. If the special value ``*``, any remote
2348 user can push, including unauthenticated users. Otherwise, the
2352 user can push, including unauthenticated users. Otherwise, the
2349 remote user must have been authenticated, and the authenticated
2353 remote user must have been authenticated, and the authenticated
2350 user name must be present in this list. The contents of the
2354 user name must be present in this list. The contents of the
2351 allow-push list are examined after the deny_push list.
2355 allow-push list are examined after the deny_push list.
2352
2356
2353 ``allow_read``
2357 ``allow_read``
2354 If the user has not already been denied repository access due to
2358 If the user has not already been denied repository access due to
2355 the contents of deny_read, this list determines whether to grant
2359 the contents of deny_read, this list determines whether to grant
2356 repository access to the user. If this list is not empty, and the
2360 repository access to the user. If this list is not empty, and the
2357 user is unauthenticated or not present in the list, then access is
2361 user is unauthenticated or not present in the list, then access is
2358 denied for the user. If the list is empty or not set, then access
2362 denied for the user. If the list is empty or not set, then access
2359 is permitted to all users by default. Setting allow_read to the
2363 is permitted to all users by default. Setting allow_read to the
2360 special value ``*`` is equivalent to it not being set (i.e. access
2364 special value ``*`` is equivalent to it not being set (i.e. access
2361 is permitted to all users). The contents of the allow_read list are
2365 is permitted to all users). The contents of the allow_read list are
2362 examined after the deny_read list.
2366 examined after the deny_read list.
2363
2367
2364 ``allowzip``
2368 ``allowzip``
2365 (DEPRECATED) Whether to allow .zip downloading of repository
2369 (DEPRECATED) Whether to allow .zip downloading of repository
2366 revisions. This feature creates temporary files.
2370 revisions. This feature creates temporary files.
2367 (default: False)
2371 (default: False)
2368
2372
2369 ``archivesubrepos``
2373 ``archivesubrepos``
2370 Whether to recurse into subrepositories when archiving.
2374 Whether to recurse into subrepositories when archiving.
2371 (default: False)
2375 (default: False)
2372
2376
2373 ``baseurl``
2377 ``baseurl``
2374 Base URL to use when publishing URLs in other locations, so
2378 Base URL to use when publishing URLs in other locations, so
2375 third-party tools like email notification hooks can construct
2379 third-party tools like email notification hooks can construct
2376 URLs. Example: ``http://hgserver/repos/``.
2380 URLs. Example: ``http://hgserver/repos/``.
2377
2381
2378 ``cacerts``
2382 ``cacerts``
2379 Path to file containing a list of PEM encoded certificate
2383 Path to file containing a list of PEM encoded certificate
2380 authority certificates. Environment variables and ``~user``
2384 authority certificates. Environment variables and ``~user``
2381 constructs are expanded in the filename. If specified on the
2385 constructs are expanded in the filename. If specified on the
2382 client, then it will verify the identity of remote HTTPS servers
2386 client, then it will verify the identity of remote HTTPS servers
2383 with these certificates.
2387 with these certificates.
2384
2388
2385 To disable SSL verification temporarily, specify ``--insecure`` from
2389 To disable SSL verification temporarily, specify ``--insecure`` from
2386 command line.
2390 command line.
2387
2391
2388 You can use OpenSSL's CA certificate file if your platform has
2392 You can use OpenSSL's CA certificate file if your platform has
2389 one. On most Linux systems this will be
2393 one. On most Linux systems this will be
2390 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2394 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2391 generate this file manually. The form must be as follows::
2395 generate this file manually. The form must be as follows::
2392
2396
2393 -----BEGIN CERTIFICATE-----
2397 -----BEGIN CERTIFICATE-----
2394 ... (certificate in base64 PEM encoding) ...
2398 ... (certificate in base64 PEM encoding) ...
2395 -----END CERTIFICATE-----
2399 -----END CERTIFICATE-----
2396 -----BEGIN CERTIFICATE-----
2400 -----BEGIN CERTIFICATE-----
2397 ... (certificate in base64 PEM encoding) ...
2401 ... (certificate in base64 PEM encoding) ...
2398 -----END CERTIFICATE-----
2402 -----END CERTIFICATE-----
2399
2403
2400 ``cache``
2404 ``cache``
2401 Whether to support caching in hgweb. (default: True)
2405 Whether to support caching in hgweb. (default: True)
2402
2406
2403 ``certificate``
2407 ``certificate``
2404 Certificate to use when running :hg:`serve`.
2408 Certificate to use when running :hg:`serve`.
2405
2409
2406 ``collapse``
2410 ``collapse``
2407 With ``descend`` enabled, repositories in subdirectories are shown at
2411 With ``descend`` enabled, repositories in subdirectories are shown at
2408 a single level alongside repositories in the current path. With
2412 a single level alongside repositories in the current path. With
2409 ``collapse`` also enabled, repositories residing at a deeper level than
2413 ``collapse`` also enabled, repositories residing at a deeper level than
2410 the current path are grouped behind navigable directory entries that
2414 the current path are grouped behind navigable directory entries that
2411 lead to the locations of these repositories. In effect, this setting
2415 lead to the locations of these repositories. In effect, this setting
2412 collapses each collection of repositories found within a subdirectory
2416 collapses each collection of repositories found within a subdirectory
2413 into a single entry for that subdirectory. (default: False)
2417 into a single entry for that subdirectory. (default: False)
2414
2418
2415 ``comparisoncontext``
2419 ``comparisoncontext``
2416 Number of lines of context to show in side-by-side file comparison. If
2420 Number of lines of context to show in side-by-side file comparison. If
2417 negative or the value ``full``, whole files are shown. (default: 5)
2421 negative or the value ``full``, whole files are shown. (default: 5)
2418
2422
2419 This setting can be overridden by a ``context`` request parameter to the
2423 This setting can be overridden by a ``context`` request parameter to the
2420 ``comparison`` command, taking the same values.
2424 ``comparison`` command, taking the same values.
2421
2425
2422 ``contact``
2426 ``contact``
2423 Name or email address of the person in charge of the repository.
2427 Name or email address of the person in charge of the repository.
2424 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2428 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2425
2429
2426 ``csp``
2430 ``csp``
2427 Send a ``Content-Security-Policy`` HTTP header with this value.
2431 Send a ``Content-Security-Policy`` HTTP header with this value.
2428
2432
2429 The value may contain a special string ``%nonce%``, which will be replaced
2433 The value may contain a special string ``%nonce%``, which will be replaced
2430 by a randomly-generated one-time use value. If the value contains
2434 by a randomly-generated one-time use value. If the value contains
2431 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2435 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2432 one-time property of the nonce. This nonce will also be inserted into
2436 one-time property of the nonce. This nonce will also be inserted into
2433 ``<script>`` elements containing inline JavaScript.
2437 ``<script>`` elements containing inline JavaScript.
2434
2438
2435 Note: lots of HTML content sent by the server is derived from repository
2439 Note: lots of HTML content sent by the server is derived from repository
2436 data. Please consider the potential for malicious repository data to
2440 data. Please consider the potential for malicious repository data to
2437 "inject" itself into generated HTML content as part of your security
2441 "inject" itself into generated HTML content as part of your security
2438 threat model.
2442 threat model.
2439
2443
2440 ``deny_push``
2444 ``deny_push``
2441 Whether to deny pushing to the repository. If empty or not set,
2445 Whether to deny pushing to the repository. If empty or not set,
2442 push is not denied. If the special value ``*``, all remote users are
2446 push is not denied. If the special value ``*``, all remote users are
2443 denied push. Otherwise, unauthenticated users are all denied, and
2447 denied push. Otherwise, unauthenticated users are all denied, and
2444 any authenticated user name present in this list is also denied. The
2448 any authenticated user name present in this list is also denied. The
2445 contents of the deny_push list are examined before the allow-push list.
2449 contents of the deny_push list are examined before the allow-push list.
2446
2450
2447 ``deny_read``
2451 ``deny_read``
2448 Whether to deny reading/viewing of the repository. If this list is
2452 Whether to deny reading/viewing of the repository. If this list is
2449 not empty, unauthenticated users are all denied, and any
2453 not empty, unauthenticated users are all denied, and any
2450 authenticated user name present in this list is also denied access to
2454 authenticated user name present in this list is also denied access to
2451 the repository. If set to the special value ``*``, all remote users
2455 the repository. If set to the special value ``*``, all remote users
2452 are denied access (rarely needed ;). If deny_read is empty or not set,
2456 are denied access (rarely needed ;). If deny_read is empty or not set,
2453 the determination of repository access depends on the presence and
2457 the determination of repository access depends on the presence and
2454 content of the allow_read list (see description). If both
2458 content of the allow_read list (see description). If both
2455 deny_read and allow_read are empty or not set, then access is
2459 deny_read and allow_read are empty or not set, then access is
2456 permitted to all users by default. If the repository is being
2460 permitted to all users by default. If the repository is being
2457 served via hgwebdir, denied users will not be able to see it in
2461 served via hgwebdir, denied users will not be able to see it in
2458 the list of repositories. The contents of the deny_read list have
2462 the list of repositories. The contents of the deny_read list have
2459 priority over (are examined before) the contents of the allow_read
2463 priority over (are examined before) the contents of the allow_read
2460 list.
2464 list.
2461
2465
2462 ``descend``
2466 ``descend``
2463 hgwebdir indexes will not descend into subdirectories. Only repositories
2467 hgwebdir indexes will not descend into subdirectories. Only repositories
2464 directly in the current path will be shown (other repositories are still
2468 directly in the current path will be shown (other repositories are still
2465 available from the index corresponding to their containing path).
2469 available from the index corresponding to their containing path).
2466
2470
2467 ``description``
2471 ``description``
2468 Textual description of the repository's purpose or contents.
2472 Textual description of the repository's purpose or contents.
2469 (default: "unknown")
2473 (default: "unknown")
2470
2474
2471 ``encoding``
2475 ``encoding``
2472 Character encoding name. (default: the current locale charset)
2476 Character encoding name. (default: the current locale charset)
2473 Example: "UTF-8".
2477 Example: "UTF-8".
2474
2478
2475 ``errorlog``
2479 ``errorlog``
2476 Where to output the error log. (default: stderr)
2480 Where to output the error log. (default: stderr)
2477
2481
2478 ``guessmime``
2482 ``guessmime``
2479 Control MIME types for raw download of file content.
2483 Control MIME types for raw download of file content.
2480 Set to True to let hgweb guess the content type from the file
2484 Set to True to let hgweb guess the content type from the file
2481 extension. This will serve HTML files as ``text/html`` and might
2485 extension. This will serve HTML files as ``text/html`` and might
2482 allow cross-site scripting attacks when serving untrusted
2486 allow cross-site scripting attacks when serving untrusted
2483 repositories. (default: False)
2487 repositories. (default: False)
2484
2488
2485 ``hidden``
2489 ``hidden``
2486 Whether to hide the repository in the hgwebdir index.
2490 Whether to hide the repository in the hgwebdir index.
2487 (default: False)
2491 (default: False)
2488
2492
2489 ``ipv6``
2493 ``ipv6``
2490 Whether to use IPv6. (default: False)
2494 Whether to use IPv6. (default: False)
2491
2495
2492 ``labels``
2496 ``labels``
2493 List of string *labels* associated with the repository.
2497 List of string *labels* associated with the repository.
2494
2498
2495 Labels are exposed as a template keyword and can be used to customize
2499 Labels are exposed as a template keyword and can be used to customize
2496 output. e.g. the ``index`` template can group or filter repositories
2500 output. e.g. the ``index`` template can group or filter repositories
2497 by labels and the ``summary`` template can display additional content
2501 by labels and the ``summary`` template can display additional content
2498 if a specific label is present.
2502 if a specific label is present.
2499
2503
2500 ``logoimg``
2504 ``logoimg``
2501 File name of the logo image that some templates display on each page.
2505 File name of the logo image that some templates display on each page.
2502 The file name is relative to ``staticurl``. That is, the full path to
2506 The file name is relative to ``staticurl``. That is, the full path to
2503 the logo image is "staticurl/logoimg".
2507 the logo image is "staticurl/logoimg".
2504 If unset, ``hglogo.png`` will be used.
2508 If unset, ``hglogo.png`` will be used.
2505
2509
2506 ``logourl``
2510 ``logourl``
2507 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2511 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2508 will be used.
2512 will be used.
2509
2513
2510 ``maxchanges``
2514 ``maxchanges``
2511 Maximum number of changes to list on the changelog. (default: 10)
2515 Maximum number of changes to list on the changelog. (default: 10)
2512
2516
2513 ``maxfiles``
2517 ``maxfiles``
2514 Maximum number of files to list per changeset. (default: 10)
2518 Maximum number of files to list per changeset. (default: 10)
2515
2519
2516 ``maxshortchanges``
2520 ``maxshortchanges``
2517 Maximum number of changes to list on the shortlog, graph or filelog
2521 Maximum number of changes to list on the shortlog, graph or filelog
2518 pages. (default: 60)
2522 pages. (default: 60)
2519
2523
2520 ``name``
2524 ``name``
2521 Repository name to use in the web interface.
2525 Repository name to use in the web interface.
2522 (default: current working directory)
2526 (default: current working directory)
2523
2527
2524 ``port``
2528 ``port``
2525 Port to listen on. (default: 8000)
2529 Port to listen on. (default: 8000)
2526
2530
2527 ``prefix``
2531 ``prefix``
2528 Prefix path to serve from. (default: '' (server root))
2532 Prefix path to serve from. (default: '' (server root))
2529
2533
2530 ``push_ssl``
2534 ``push_ssl``
2531 Whether to require that inbound pushes be transported over SSL to
2535 Whether to require that inbound pushes be transported over SSL to
2532 prevent password sniffing. (default: True)
2536 prevent password sniffing. (default: True)
2533
2537
2534 ``refreshinterval``
2538 ``refreshinterval``
2535 How frequently directory listings re-scan the filesystem for new
2539 How frequently directory listings re-scan the filesystem for new
2536 repositories, in seconds. This is relevant when wildcards are used
2540 repositories, in seconds. This is relevant when wildcards are used
2537 to define paths. Depending on how much filesystem traversal is
2541 to define paths. Depending on how much filesystem traversal is
2538 required, refreshing may negatively impact performance.
2542 required, refreshing may negatively impact performance.
2539
2543
2540 Values less than or equal to 0 always refresh.
2544 Values less than or equal to 0 always refresh.
2541 (default: 20)
2545 (default: 20)
2542
2546
2543 ``server-header``
2547 ``server-header``
2544 Value for HTTP ``Server`` response header.
2548 Value for HTTP ``Server`` response header.
2545
2549
2546 ``staticurl``
2550 ``staticurl``
2547 Base URL to use for static files. If unset, static files (e.g. the
2551 Base URL to use for static files. If unset, static files (e.g. the
2548 hgicon.png favicon) will be served by the CGI script itself. Use
2552 hgicon.png favicon) will be served by the CGI script itself. Use
2549 this setting to serve them directly with the HTTP server.
2553 this setting to serve them directly with the HTTP server.
2550 Example: ``http://hgserver/static/``.
2554 Example: ``http://hgserver/static/``.
2551
2555
2552 ``stripes``
2556 ``stripes``
2553 How many lines a "zebra stripe" should span in multi-line output.
2557 How many lines a "zebra stripe" should span in multi-line output.
2554 Set to 0 to disable. (default: 1)
2558 Set to 0 to disable. (default: 1)
2555
2559
2556 ``style``
2560 ``style``
2557 Which template map style to use. The available options are the names of
2561 Which template map style to use. The available options are the names of
2558 subdirectories in the HTML templates path. (default: ``paper``)
2562 subdirectories in the HTML templates path. (default: ``paper``)
2559 Example: ``monoblue``.
2563 Example: ``monoblue``.
2560
2564
2561 ``templates``
2565 ``templates``
2562 Where to find the HTML templates. The default path to the HTML templates
2566 Where to find the HTML templates. The default path to the HTML templates
2563 can be obtained from ``hg debuginstall``.
2567 can be obtained from ``hg debuginstall``.
2564
2568
2565 ``websub``
2569 ``websub``
2566 ----------
2570 ----------
2567
2571
2568 Web substitution filter definition. You can use this section to
2572 Web substitution filter definition. You can use this section to
2569 define a set of regular expression substitution patterns which
2573 define a set of regular expression substitution patterns which
2570 let you automatically modify the hgweb server output.
2574 let you automatically modify the hgweb server output.
2571
2575
2572 The default hgweb templates only apply these substitution patterns
2576 The default hgweb templates only apply these substitution patterns
2573 on the revision description fields. You can apply them anywhere
2577 on the revision description fields. You can apply them anywhere
2574 you want when you create your own templates by adding calls to the
2578 you want when you create your own templates by adding calls to the
2575 "websub" filter (usually after calling the "escape" filter).
2579 "websub" filter (usually after calling the "escape" filter).
2576
2580
2577 This can be used, for example, to convert issue references to links
2581 This can be used, for example, to convert issue references to links
2578 to your issue tracker, or to convert "markdown-like" syntax into
2582 to your issue tracker, or to convert "markdown-like" syntax into
2579 HTML (see the examples below).
2583 HTML (see the examples below).
2580
2584
2581 Each entry in this section names a substitution filter.
2585 Each entry in this section names a substitution filter.
2582 The value of each entry defines the substitution expression itself.
2586 The value of each entry defines the substitution expression itself.
2583 The websub expressions follow the old interhg extension syntax,
2587 The websub expressions follow the old interhg extension syntax,
2584 which in turn imitates the Unix sed replacement syntax::
2588 which in turn imitates the Unix sed replacement syntax::
2585
2589
2586 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2590 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2587
2591
2588 You can use any separator other than "/". The final "i" is optional
2592 You can use any separator other than "/". The final "i" is optional
2589 and indicates that the search must be case insensitive.
2593 and indicates that the search must be case insensitive.
2590
2594
2591 Examples::
2595 Examples::
2592
2596
2593 [websub]
2597 [websub]
2594 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2598 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2595 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2599 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2596 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2600 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2597
2601
2598 ``worker``
2602 ``worker``
2599 ----------
2603 ----------
2600
2604
2601 Parallel master/worker configuration. We currently perform working
2605 Parallel master/worker configuration. We currently perform working
2602 directory updates in parallel on Unix-like systems, which greatly
2606 directory updates in parallel on Unix-like systems, which greatly
2603 helps performance.
2607 helps performance.
2604
2608
2605 ``enabled``
2609 ``enabled``
2606 Whether to enable workers code to be used.
2610 Whether to enable workers code to be used.
2607 (default: true)
2611 (default: true)
2608
2612
2609 ``numcpus``
2613 ``numcpus``
2610 Number of CPUs to use for parallel operations. A zero or
2614 Number of CPUs to use for parallel operations. A zero or
2611 negative value is treated as ``use the default``.
2615 negative value is treated as ``use the default``.
2612 (default: 4 or the number of CPUs on the system, whichever is larger)
2616 (default: 4 or the number of CPUs on the system, whichever is larger)
2613
2617
2614 ``backgroundclose``
2618 ``backgroundclose``
2615 Whether to enable closing file handles on background threads during certain
2619 Whether to enable closing file handles on background threads during certain
2616 operations. Some platforms aren't very efficient at closing file
2620 operations. Some platforms aren't very efficient at closing file
2617 handles that have been written or appended to. By performing file closing
2621 handles that have been written or appended to. By performing file closing
2618 on background threads, file write rate can increase substantially.
2622 on background threads, file write rate can increase substantially.
2619 (default: true on Windows, false elsewhere)
2623 (default: true on Windows, false elsewhere)
2620
2624
2621 ``backgroundcloseminfilecount``
2625 ``backgroundcloseminfilecount``
2622 Minimum number of files required to trigger background file closing.
2626 Minimum number of files required to trigger background file closing.
2623 Operations not writing this many files won't start background close
2627 Operations not writing this many files won't start background close
2624 threads.
2628 threads.
2625 (default: 2048)
2629 (default: 2048)
2626
2630
2627 ``backgroundclosemaxqueue``
2631 ``backgroundclosemaxqueue``
2628 The maximum number of opened file handles waiting to be closed in the
2632 The maximum number of opened file handles waiting to be closed in the
2629 background. This option only has an effect if ``backgroundclose`` is
2633 background. This option only has an effect if ``backgroundclose`` is
2630 enabled.
2634 enabled.
2631 (default: 384)
2635 (default: 384)
2632
2636
2633 ``backgroundclosethreadcount``
2637 ``backgroundclosethreadcount``
2634 Number of threads to process background file closes. Only relevant if
2638 Number of threads to process background file closes. Only relevant if
2635 ``backgroundclose`` is enabled.
2639 ``backgroundclose`` is enabled.
2636 (default: 4)
2640 (default: 4)
@@ -1,185 +1,237 b''
1 $ mkdir folder
1 $ mkdir folder
2 $ cd folder
2 $ cd folder
3 $ hg init
3 $ hg init
4 $ mkdir x x/l x/m x/n x/l/u x/l/u/a
4 $ mkdir x x/l x/m x/n x/l/u x/l/u/a
5 $ touch a b x/aa.o x/bb.o
5 $ touch a b x/aa.o x/bb.o
6 $ hg status
6 $ hg status
7 ? a
7 ? a
8 ? b
8 ? b
9 ? x/aa.o
9 ? x/aa.o
10 ? x/bb.o
10 ? x/bb.o
11
11
12 $ hg status --terse u
12 $ hg status --terse u
13 ? a
13 ? a
14 ? b
14 ? b
15 ? x/
15 ? x/
16 $ hg status --terse maudric
16 $ hg status --terse maudric
17 ? a
17 ? a
18 ? b
18 ? b
19 ? x/
19 ? x/
20 $ hg status --terse madric
20 $ hg status --terse madric
21 ? a
21 ? a
22 ? b
22 ? b
23 ? x/aa.o
23 ? x/aa.o
24 ? x/bb.o
24 ? x/bb.o
25 $ hg status --terse f
25 $ hg status --terse f
26 abort: 'f' not recognized
26 abort: 'f' not recognized
27 [255]
27 [255]
28
28
29 Add a .hgignore so that we can also have ignored files
29 Add a .hgignore so that we can also have ignored files
30
30
31 $ echo ".*\.o" > .hgignore
31 $ echo ".*\.o" > .hgignore
32 $ hg status
32 $ hg status
33 ? .hgignore
33 ? .hgignore
34 ? a
34 ? a
35 ? b
35 ? b
36 $ hg status -i
36 $ hg status -i
37 I x/aa.o
37 I x/aa.o
38 I x/bb.o
38 I x/bb.o
39
39
40 Tersing ignored files
40 Tersing ignored files
41 $ hg status -t i --ignored
41 $ hg status -t i --ignored
42 I x/
42 I x/
43
43
44 Adding more files
44 Adding more files
45 $ mkdir y
45 $ mkdir y
46 $ touch x/aa x/bb y/l y/m y/l.o y/m.o
46 $ touch x/aa x/bb y/l y/m y/l.o y/m.o
47 $ touch x/l/aa x/m/aa x/n/aa x/l/u/bb x/l/u/a/bb
47 $ touch x/l/aa x/m/aa x/n/aa x/l/u/bb x/l/u/a/bb
48
48
49 $ hg status
49 $ hg status
50 ? .hgignore
50 ? .hgignore
51 ? a
51 ? a
52 ? b
52 ? b
53 ? x/aa
53 ? x/aa
54 ? x/bb
54 ? x/bb
55 ? x/l/aa
55 ? x/l/aa
56 ? x/l/u/a/bb
56 ? x/l/u/a/bb
57 ? x/l/u/bb
57 ? x/l/u/bb
58 ? x/m/aa
58 ? x/m/aa
59 ? x/n/aa
59 ? x/n/aa
60 ? y/l
60 ? y/l
61 ? y/m
61 ? y/m
62
62
63 $ hg status --terse u
63 $ hg status --terse u
64 ? .hgignore
64 ? .hgignore
65 ? a
65 ? a
66 ? b
66 ? b
67 ? x/
67 ? x/
68 ? y/
68 ? y/
69
69
70 $ hg add x/aa x/bb .hgignore
70 $ hg add x/aa x/bb .hgignore
71 $ hg status --terse au
71 $ hg status --terse au
72 A .hgignore
72 A .hgignore
73 A x/aa
73 A x/aa
74 A x/bb
74 A x/bb
75 ? a
75 ? a
76 ? b
76 ? b
77 ? x/l/
77 ? x/l/
78 ? x/m/
78 ? x/m/
79 ? x/n/
79 ? x/n/
80 ? y/
80 ? y/
81
81
82 Including ignored files
82 Including ignored files
83
83
84 $ hg status --terse aui
84 $ hg status --terse aui
85 A .hgignore
85 A .hgignore
86 A x/aa
86 A x/aa
87 A x/bb
87 A x/bb
88 ? a
88 ? a
89 ? b
89 ? b
90 ? x/l/
90 ? x/l/
91 ? x/m/
91 ? x/m/
92 ? x/n/
92 ? x/n/
93 ? y/l
93 ? y/l
94 ? y/m
94 ? y/m
95 $ hg status --terse au -i
95 $ hg status --terse au -i
96 I x/aa.o
96 I x/aa.o
97 I x/bb.o
97 I x/bb.o
98 I y/l.o
98 I y/l.o
99 I y/m.o
99 I y/m.o
100
100
101 Committing some of the files
101 Committing some of the files
102
102
103 $ hg commit x/aa x/bb .hgignore -m "First commit"
103 $ hg commit x/aa x/bb .hgignore -m "First commit"
104 $ hg status
104 $ hg status
105 ? a
105 ? a
106 ? b
106 ? b
107 ? x/l/aa
107 ? x/l/aa
108 ? x/l/u/a/bb
108 ? x/l/u/a/bb
109 ? x/l/u/bb
109 ? x/l/u/bb
110 ? x/m/aa
110 ? x/m/aa
111 ? x/n/aa
111 ? x/n/aa
112 ? y/l
112 ? y/l
113 ? y/m
113 ? y/m
114 $ hg status --terse mardu
114 $ hg status --terse mardu
115 ? a
115 ? a
116 ? b
116 ? b
117 ? x/l/
117 ? x/l/
118 ? x/m/
118 ? x/m/
119 ? x/n/
119 ? x/n/
120 ? y/
120 ? y/
121
121
122 Modifying already committed files
122 Modifying already committed files
123
123
124 $ echo "Hello" >> x/aa
124 $ echo "Hello" >> x/aa
125 $ echo "World" >> x/bb
125 $ echo "World" >> x/bb
126 $ hg status --terse maurdc
126 $ hg status --terse maurdc
127 M x/aa
127 M x/aa
128 M x/bb
128 M x/bb
129 ? a
129 ? a
130 ? b
130 ? b
131 ? x/l/
131 ? x/l/
132 ? x/m/
132 ? x/m/
133 ? x/n/
133 ? x/n/
134 ? y/
134 ? y/
135
135
136 Respecting other flags
136 Respecting other flags
137
137
138 $ hg status --terse marduic --all
138 $ hg status --terse marduic --all
139 M x/aa
139 M x/aa
140 M x/bb
140 M x/bb
141 ? a
141 ? a
142 ? b
142 ? b
143 ? x/l/
143 ? x/l/
144 ? x/m/
144 ? x/m/
145 ? x/n/
145 ? x/n/
146 ? y/l
146 ? y/l
147 ? y/m
147 ? y/m
148 I x/aa.o
148 I x/aa.o
149 I x/bb.o
149 I x/bb.o
150 I y/l.o
150 I y/l.o
151 I y/m.o
151 I y/m.o
152 C .hgignore
152 C .hgignore
153 $ hg status --terse marduic -a
153 $ hg status --terse marduic -a
154 $ hg status --terse marduic -c
154 $ hg status --terse marduic -c
155 C .hgignore
155 C .hgignore
156 $ hg status --terse marduic -m
156 $ hg status --terse marduic -m
157 M x/aa
157 M x/aa
158 M x/bb
158 M x/bb
159
159
160 Passing 'i' in terse value will consider the ignored files while tersing
160 Passing 'i' in terse value will consider the ignored files while tersing
161
161
162 $ hg status --terse marduic -u
162 $ hg status --terse marduic -u
163 ? a
163 ? a
164 ? b
164 ? b
165 ? x/l/
165 ? x/l/
166 ? x/m/
166 ? x/m/
167 ? x/n/
167 ? x/n/
168 ? y/l
168 ? y/l
169 ? y/m
169 ? y/m
170
170
171 Omitting 'i' in terse value does not consider ignored files while tersing
171 Omitting 'i' in terse value does not consider ignored files while tersing
172
172
173 $ hg status --terse marduc -u
173 $ hg status --terse marduc -u
174 ? a
174 ? a
175 ? b
175 ? b
176 ? x/l/
176 ? x/l/
177 ? x/m/
177 ? x/m/
178 ? x/n/
178 ? x/n/
179 ? y/
179 ? y/
180
180
181 Trying with --rev
181 Trying with --rev
182
182
183 $ hg status --terse marduic --rev 0 --rev 1
183 $ hg status --terse marduic --rev 0 --rev 1
184 abort: cannot use --terse with --rev
184 abort: cannot use --terse with --rev
185 [255]
185 [255]
186
187 Config item to set the default terseness
188 $ cat <<EOF >> $HGRCPATH
189 > [commands]
190 > status.terse = u
191 > EOF
192 $ hg status -mu
193 M x/aa
194 M x/bb
195 ? a
196 ? b
197 ? x/l/
198 ? x/m/
199 ? x/n/
200 ? y/
201
202 Command line flag overrides the default
203 $ hg status --terse=
204 M x/aa
205 M x/bb
206 ? a
207 ? b
208 ? x/l/aa
209 ? x/l/u/a/bb
210 ? x/l/u/bb
211 ? x/m/aa
212 ? x/n/aa
213 ? y/l
214 ? y/m
215 $ hg status --terse=mardu
216 M x/aa
217 M x/bb
218 ? a
219 ? b
220 ? x/l/
221 ? x/m/
222 ? x/n/
223 ? y/
224
225 Specifying --rev should still work, with the terseness disabled.
226 $ hg status --rev 0
227 M x/aa
228 M x/bb
229 ? a
230 ? b
231 ? x/l/aa
232 ? x/l/u/a/bb
233 ? x/l/u/bb
234 ? x/m/aa
235 ? x/n/aa
236 ? y/l
237 ? y/m
General Comments 0
You need to be logged in to leave comments. Login now