##// 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 1 # commands.py - command processing for mercurial
2 2 #
3 3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9 9
10 10 import difflib
11 11 import errno
12 12 import os
13 13 import re
14 14 import sys
15 15
16 16 from .i18n import _
17 17 from .node import (
18 18 hex,
19 19 nullid,
20 20 nullrev,
21 21 short,
22 22 )
23 23 from . import (
24 24 archival,
25 25 bookmarks,
26 26 bundle2,
27 27 changegroup,
28 28 cmdutil,
29 29 copies,
30 30 debugcommands as debugcommandsmod,
31 31 destutil,
32 32 dirstateguard,
33 33 discovery,
34 34 encoding,
35 35 error,
36 36 exchange,
37 37 extensions,
38 38 formatter,
39 39 graphmod,
40 40 hbisect,
41 41 help,
42 42 hg,
43 43 lock as lockmod,
44 44 logcmdutil,
45 45 merge as mergemod,
46 46 obsolete,
47 47 obsutil,
48 48 patch,
49 49 phases,
50 50 pycompat,
51 51 rcutil,
52 52 registrar,
53 53 repair,
54 54 revsetlang,
55 55 rewriteutil,
56 56 scmutil,
57 57 server,
58 58 streamclone,
59 59 tags as tagsmod,
60 60 templatekw,
61 61 ui as uimod,
62 62 util,
63 63 wireprotoserver,
64 64 )
65 65 from .utils import (
66 66 dateutil,
67 67 procutil,
68 68 stringutil,
69 69 )
70 70
71 71 release = lockmod.release
72 72
73 73 table = {}
74 74 table.update(debugcommandsmod.command._table)
75 75
76 76 command = registrar.command(table)
77 77 INTENT_READONLY = registrar.INTENT_READONLY
78 78
79 79 # common command options
80 80
81 81 globalopts = [
82 82 ('R', 'repository', '',
83 83 _('repository root directory or name of overlay bundle file'),
84 84 _('REPO')),
85 85 ('', 'cwd', '',
86 86 _('change working directory'), _('DIR')),
87 87 ('y', 'noninteractive', None,
88 88 _('do not prompt, automatically pick the first choice for all prompts')),
89 89 ('q', 'quiet', None, _('suppress output')),
90 90 ('v', 'verbose', None, _('enable additional output')),
91 91 ('', 'color', '',
92 92 # i18n: 'always', 'auto', 'never', and 'debug' are keywords
93 93 # and should not be translated
94 94 _("when to colorize (boolean, always, auto, never, or debug)"),
95 95 _('TYPE')),
96 96 ('', 'config', [],
97 97 _('set/override config option (use \'section.name=value\')'),
98 98 _('CONFIG')),
99 99 ('', 'debug', None, _('enable debugging output')),
100 100 ('', 'debugger', None, _('start debugger')),
101 101 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
102 102 _('ENCODE')),
103 103 ('', 'encodingmode', encoding.encodingmode,
104 104 _('set the charset encoding mode'), _('MODE')),
105 105 ('', 'traceback', None, _('always print a traceback on exception')),
106 106 ('', 'time', None, _('time how long the command takes')),
107 107 ('', 'profile', None, _('print command execution profile')),
108 108 ('', 'version', None, _('output version information and exit')),
109 109 ('h', 'help', None, _('display help and exit')),
110 110 ('', 'hidden', False, _('consider hidden changesets')),
111 111 ('', 'pager', 'auto',
112 112 _("when to paginate (boolean, always, auto, or never)"), _('TYPE')),
113 113 ]
114 114
115 115 dryrunopts = cmdutil.dryrunopts
116 116 remoteopts = cmdutil.remoteopts
117 117 walkopts = cmdutil.walkopts
118 118 commitopts = cmdutil.commitopts
119 119 commitopts2 = cmdutil.commitopts2
120 120 formatteropts = cmdutil.formatteropts
121 121 templateopts = cmdutil.templateopts
122 122 logopts = cmdutil.logopts
123 123 diffopts = cmdutil.diffopts
124 124 diffwsopts = cmdutil.diffwsopts
125 125 diffopts2 = cmdutil.diffopts2
126 126 mergetoolopts = cmdutil.mergetoolopts
127 127 similarityopts = cmdutil.similarityopts
128 128 subrepoopts = cmdutil.subrepoopts
129 129 debugrevlogopts = cmdutil.debugrevlogopts
130 130
131 131 # Commands start here, listed alphabetically
132 132
133 133 @command('^add',
134 134 walkopts + subrepoopts + dryrunopts,
135 135 _('[OPTION]... [FILE]...'),
136 136 inferrepo=True)
137 137 def add(ui, repo, *pats, **opts):
138 138 """add the specified files on the next commit
139 139
140 140 Schedule files to be version controlled and added to the
141 141 repository.
142 142
143 143 The files will be added to the repository at the next commit. To
144 144 undo an add before that, see :hg:`forget`.
145 145
146 146 If no names are given, add all files to the repository (except
147 147 files matching ``.hgignore``).
148 148
149 149 .. container:: verbose
150 150
151 151 Examples:
152 152
153 153 - New (unknown) files are added
154 154 automatically by :hg:`add`::
155 155
156 156 $ ls
157 157 foo.c
158 158 $ hg status
159 159 ? foo.c
160 160 $ hg add
161 161 adding foo.c
162 162 $ hg status
163 163 A foo.c
164 164
165 165 - Specific files to be added can be specified::
166 166
167 167 $ ls
168 168 bar.c foo.c
169 169 $ hg status
170 170 ? bar.c
171 171 ? foo.c
172 172 $ hg add bar.c
173 173 $ hg status
174 174 A bar.c
175 175 ? foo.c
176 176
177 177 Returns 0 if all files are successfully added.
178 178 """
179 179
180 180 m = scmutil.match(repo[None], pats, pycompat.byteskwargs(opts))
181 181 rejected = cmdutil.add(ui, repo, m, "", False, **opts)
182 182 return rejected and 1 or 0
183 183
184 184 @command('addremove',
185 185 similarityopts + subrepoopts + walkopts + dryrunopts,
186 186 _('[OPTION]... [FILE]...'),
187 187 inferrepo=True)
188 188 def addremove(ui, repo, *pats, **opts):
189 189 """add all new files, delete all missing files
190 190
191 191 Add all new files and remove all missing files from the
192 192 repository.
193 193
194 194 Unless names are given, new files are ignored if they match any of
195 195 the patterns in ``.hgignore``. As with add, these changes take
196 196 effect at the next commit.
197 197
198 198 Use the -s/--similarity option to detect renamed files. This
199 199 option takes a percentage between 0 (disabled) and 100 (files must
200 200 be identical) as its parameter. With a parameter greater than 0,
201 201 this compares every removed file with every added file and records
202 202 those similar enough as renames. Detecting renamed files this way
203 203 can be expensive. After using this option, :hg:`status -C` can be
204 204 used to check which files were identified as moved or renamed. If
205 205 not specified, -s/--similarity defaults to 100 and only renames of
206 206 identical files are detected.
207 207
208 208 .. container:: verbose
209 209
210 210 Examples:
211 211
212 212 - A number of files (bar.c and foo.c) are new,
213 213 while foobar.c has been removed (without using :hg:`remove`)
214 214 from the repository::
215 215
216 216 $ ls
217 217 bar.c foo.c
218 218 $ hg status
219 219 ! foobar.c
220 220 ? bar.c
221 221 ? foo.c
222 222 $ hg addremove
223 223 adding bar.c
224 224 adding foo.c
225 225 removing foobar.c
226 226 $ hg status
227 227 A bar.c
228 228 A foo.c
229 229 R foobar.c
230 230
231 231 - A file foobar.c was moved to foo.c without using :hg:`rename`.
232 232 Afterwards, it was edited slightly::
233 233
234 234 $ ls
235 235 foo.c
236 236 $ hg status
237 237 ! foobar.c
238 238 ? foo.c
239 239 $ hg addremove --similarity 90
240 240 removing foobar.c
241 241 adding foo.c
242 242 recording removal of foobar.c as rename to foo.c (94% similar)
243 243 $ hg status -C
244 244 A foo.c
245 245 foobar.c
246 246 R foobar.c
247 247
248 248 Returns 0 if all files are successfully added.
249 249 """
250 250 opts = pycompat.byteskwargs(opts)
251 251 if not opts.get('similarity'):
252 252 opts['similarity'] = '100'
253 253 matcher = scmutil.match(repo[None], pats, opts)
254 254 return scmutil.addremove(repo, matcher, "", opts)
255 255
256 256 @command('^annotate|blame',
257 257 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
258 258 ('', 'follow', None,
259 259 _('follow copies/renames and list the filename (DEPRECATED)')),
260 260 ('', 'no-follow', None, _("don't follow copies and renames")),
261 261 ('a', 'text', None, _('treat all files as text')),
262 262 ('u', 'user', None, _('list the author (long with -v)')),
263 263 ('f', 'file', None, _('list the filename')),
264 264 ('d', 'date', None, _('list the date (short with -q)')),
265 265 ('n', 'number', None, _('list the revision number (default)')),
266 266 ('c', 'changeset', None, _('list the changeset')),
267 267 ('l', 'line-number', None, _('show line number at the first appearance')),
268 268 ('', 'skip', [], _('revision to not display (EXPERIMENTAL)'), _('REV')),
269 269 ] + diffwsopts + walkopts + formatteropts,
270 270 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
271 271 inferrepo=True)
272 272 def annotate(ui, repo, *pats, **opts):
273 273 """show changeset information by line for each file
274 274
275 275 List changes in files, showing the revision id responsible for
276 276 each line.
277 277
278 278 This command is useful for discovering when a change was made and
279 279 by whom.
280 280
281 281 If you include --file, --user, or --date, the revision number is
282 282 suppressed unless you also include --number.
283 283
284 284 Without the -a/--text option, annotate will avoid processing files
285 285 it detects as binary. With -a, annotate will annotate the file
286 286 anyway, although the results will probably be neither useful
287 287 nor desirable.
288 288
289 289 Returns 0 on success.
290 290 """
291 291 opts = pycompat.byteskwargs(opts)
292 292 if not pats:
293 293 raise error.Abort(_('at least one filename or pattern is required'))
294 294
295 295 if opts.get('follow'):
296 296 # --follow is deprecated and now just an alias for -f/--file
297 297 # to mimic the behavior of Mercurial before version 1.5
298 298 opts['file'] = True
299 299
300 300 rev = opts.get('rev')
301 301 if rev:
302 302 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
303 303 ctx = scmutil.revsingle(repo, rev)
304 304
305 305 rootfm = ui.formatter('annotate', opts)
306 306 if ui.quiet:
307 307 datefunc = dateutil.shortdate
308 308 else:
309 309 datefunc = dateutil.datestr
310 310 if ctx.rev() is None:
311 311 def hexfn(node):
312 312 if node is None:
313 313 return None
314 314 else:
315 315 return rootfm.hexfunc(node)
316 316 if opts.get('changeset'):
317 317 # omit "+" suffix which is appended to node hex
318 318 def formatrev(rev):
319 319 if rev is None:
320 320 return '%d' % ctx.p1().rev()
321 321 else:
322 322 return '%d' % rev
323 323 else:
324 324 def formatrev(rev):
325 325 if rev is None:
326 326 return '%d+' % ctx.p1().rev()
327 327 else:
328 328 return '%d ' % rev
329 329 def formathex(hex):
330 330 if hex is None:
331 331 return '%s+' % rootfm.hexfunc(ctx.p1().node())
332 332 else:
333 333 return '%s ' % hex
334 334 else:
335 335 hexfn = rootfm.hexfunc
336 336 formatrev = formathex = pycompat.bytestr
337 337
338 338 opmap = [('user', ' ', lambda x: x.fctx.user(), ui.shortuser),
339 339 ('number', ' ', lambda x: x.fctx.rev(), formatrev),
340 340 ('changeset', ' ', lambda x: hexfn(x.fctx.node()), formathex),
341 341 ('date', ' ', lambda x: x.fctx.date(), util.cachefunc(datefunc)),
342 342 ('file', ' ', lambda x: x.fctx.path(), pycompat.bytestr),
343 343 ('line_number', ':', lambda x: x.lineno, pycompat.bytestr),
344 344 ]
345 345 fieldnamemap = {'number': 'rev', 'changeset': 'node'}
346 346
347 347 if (not opts.get('user') and not opts.get('changeset')
348 348 and not opts.get('date') and not opts.get('file')):
349 349 opts['number'] = True
350 350
351 351 linenumber = opts.get('line_number') is not None
352 352 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
353 353 raise error.Abort(_('at least one of -n/-c is required for -l'))
354 354
355 355 ui.pager('annotate')
356 356
357 357 if rootfm.isplain():
358 358 def makefunc(get, fmt):
359 359 return lambda x: fmt(get(x))
360 360 else:
361 361 def makefunc(get, fmt):
362 362 return get
363 363 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap
364 364 if opts.get(op)]
365 365 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
366 366 fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap
367 367 if opts.get(op))
368 368
369 369 def bad(x, y):
370 370 raise error.Abort("%s: %s" % (x, y))
371 371
372 372 m = scmutil.match(ctx, pats, opts, badfn=bad)
373 373
374 374 follow = not opts.get('no_follow')
375 375 diffopts = patch.difffeatureopts(ui, opts, section='annotate',
376 376 whitespace=True)
377 377 skiprevs = opts.get('skip')
378 378 if skiprevs:
379 379 skiprevs = scmutil.revrange(repo, skiprevs)
380 380
381 381 for abs in ctx.walk(m):
382 382 fctx = ctx[abs]
383 383 rootfm.startitem()
384 384 rootfm.data(abspath=abs, path=m.rel(abs))
385 385 if not opts.get('text') and fctx.isbinary():
386 386 rootfm.plain(_("%s: binary file\n")
387 387 % ((pats and m.rel(abs)) or abs))
388 388 continue
389 389
390 390 fm = rootfm.nested('lines', tmpl='{rev}: {line}')
391 391 lines = fctx.annotate(follow=follow, skiprevs=skiprevs,
392 392 diffopts=diffopts)
393 393 if not lines:
394 394 fm.end()
395 395 continue
396 396 formats = []
397 397 pieces = []
398 398
399 399 for f, sep in funcmap:
400 400 l = [f(n) for n in lines]
401 401 if fm.isplain():
402 402 sizes = [encoding.colwidth(x) for x in l]
403 403 ml = max(sizes)
404 404 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes])
405 405 else:
406 406 formats.append(['%s' for x in l])
407 407 pieces.append(l)
408 408
409 409 for f, p, n in zip(zip(*formats), zip(*pieces), lines):
410 410 fm.startitem()
411 411 fm.context(fctx=n.fctx)
412 412 fm.write(fields, "".join(f), *p)
413 413 if n.skip:
414 414 fmt = "* %s"
415 415 else:
416 416 fmt = ": %s"
417 417 fm.write('line', fmt, n.text)
418 418
419 419 if not lines[-1].text.endswith('\n'):
420 420 fm.plain('\n')
421 421 fm.end()
422 422
423 423 rootfm.end()
424 424
425 425 @command('archive',
426 426 [('', 'no-decode', None, _('do not pass files through decoders')),
427 427 ('p', 'prefix', '', _('directory prefix for files in archive'),
428 428 _('PREFIX')),
429 429 ('r', 'rev', '', _('revision to distribute'), _('REV')),
430 430 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
431 431 ] + subrepoopts + walkopts,
432 432 _('[OPTION]... DEST'))
433 433 def archive(ui, repo, dest, **opts):
434 434 '''create an unversioned archive of a repository revision
435 435
436 436 By default, the revision used is the parent of the working
437 437 directory; use -r/--rev to specify a different revision.
438 438
439 439 The archive type is automatically detected based on file
440 440 extension (to override, use -t/--type).
441 441
442 442 .. container:: verbose
443 443
444 444 Examples:
445 445
446 446 - create a zip file containing the 1.0 release::
447 447
448 448 hg archive -r 1.0 project-1.0.zip
449 449
450 450 - create a tarball excluding .hg files::
451 451
452 452 hg archive project.tar.gz -X ".hg*"
453 453
454 454 Valid types are:
455 455
456 456 :``files``: a directory full of files (default)
457 457 :``tar``: tar archive, uncompressed
458 458 :``tbz2``: tar archive, compressed using bzip2
459 459 :``tgz``: tar archive, compressed using gzip
460 460 :``uzip``: zip archive, uncompressed
461 461 :``zip``: zip archive, compressed using deflate
462 462
463 463 The exact name of the destination archive or directory is given
464 464 using a format string; see :hg:`help export` for details.
465 465
466 466 Each member added to an archive file has a directory prefix
467 467 prepended. Use -p/--prefix to specify a format string for the
468 468 prefix. The default is the basename of the archive, with suffixes
469 469 removed.
470 470
471 471 Returns 0 on success.
472 472 '''
473 473
474 474 opts = pycompat.byteskwargs(opts)
475 475 rev = opts.get('rev')
476 476 if rev:
477 477 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
478 478 ctx = scmutil.revsingle(repo, rev)
479 479 if not ctx:
480 480 raise error.Abort(_('no working directory: please specify a revision'))
481 481 node = ctx.node()
482 482 dest = cmdutil.makefilename(ctx, dest)
483 483 if os.path.realpath(dest) == repo.root:
484 484 raise error.Abort(_('repository root cannot be destination'))
485 485
486 486 kind = opts.get('type') or archival.guesskind(dest) or 'files'
487 487 prefix = opts.get('prefix')
488 488
489 489 if dest == '-':
490 490 if kind == 'files':
491 491 raise error.Abort(_('cannot archive plain files to stdout'))
492 492 dest = cmdutil.makefileobj(ctx, dest)
493 493 if not prefix:
494 494 prefix = os.path.basename(repo.root) + '-%h'
495 495
496 496 prefix = cmdutil.makefilename(ctx, prefix)
497 497 match = scmutil.match(ctx, [], opts)
498 498 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
499 499 match, prefix, subrepos=opts.get('subrepos'))
500 500
501 501 @command('backout',
502 502 [('', 'merge', None, _('merge with old dirstate parent after backout')),
503 503 ('', 'commit', None,
504 504 _('commit if no conflicts were encountered (DEPRECATED)')),
505 505 ('', 'no-commit', None, _('do not commit')),
506 506 ('', 'parent', '',
507 507 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
508 508 ('r', 'rev', '', _('revision to backout'), _('REV')),
509 509 ('e', 'edit', False, _('invoke editor on commit messages')),
510 510 ] + mergetoolopts + walkopts + commitopts + commitopts2,
511 511 _('[OPTION]... [-r] REV'))
512 512 def backout(ui, repo, node=None, rev=None, **opts):
513 513 '''reverse effect of earlier changeset
514 514
515 515 Prepare a new changeset with the effect of REV undone in the
516 516 current working directory. If no conflicts were encountered,
517 517 it will be committed immediately.
518 518
519 519 If REV is the parent of the working directory, then this new changeset
520 520 is committed automatically (unless --no-commit is specified).
521 521
522 522 .. note::
523 523
524 524 :hg:`backout` cannot be used to fix either an unwanted or
525 525 incorrect merge.
526 526
527 527 .. container:: verbose
528 528
529 529 Examples:
530 530
531 531 - Reverse the effect of the parent of the working directory.
532 532 This backout will be committed immediately::
533 533
534 534 hg backout -r .
535 535
536 536 - Reverse the effect of previous bad revision 23::
537 537
538 538 hg backout -r 23
539 539
540 540 - Reverse the effect of previous bad revision 23 and
541 541 leave changes uncommitted::
542 542
543 543 hg backout -r 23 --no-commit
544 544 hg commit -m "Backout revision 23"
545 545
546 546 By default, the pending changeset will have one parent,
547 547 maintaining a linear history. With --merge, the pending
548 548 changeset will instead have two parents: the old parent of the
549 549 working directory and a new child of REV that simply undoes REV.
550 550
551 551 Before version 1.7, the behavior without --merge was equivalent
552 552 to specifying --merge followed by :hg:`update --clean .` to
553 553 cancel the merge and leave the child of REV as a head to be
554 554 merged separately.
555 555
556 556 See :hg:`help dates` for a list of formats valid for -d/--date.
557 557
558 558 See :hg:`help revert` for a way to restore files to the state
559 559 of another revision.
560 560
561 561 Returns 0 on success, 1 if nothing to backout or there are unresolved
562 562 files.
563 563 '''
564 564 wlock = lock = None
565 565 try:
566 566 wlock = repo.wlock()
567 567 lock = repo.lock()
568 568 return _dobackout(ui, repo, node, rev, **opts)
569 569 finally:
570 570 release(lock, wlock)
571 571
572 572 def _dobackout(ui, repo, node=None, rev=None, **opts):
573 573 opts = pycompat.byteskwargs(opts)
574 574 if opts.get('commit') and opts.get('no_commit'):
575 575 raise error.Abort(_("cannot use --commit with --no-commit"))
576 576 if opts.get('merge') and opts.get('no_commit'):
577 577 raise error.Abort(_("cannot use --merge with --no-commit"))
578 578
579 579 if rev and node:
580 580 raise error.Abort(_("please specify just one revision"))
581 581
582 582 if not rev:
583 583 rev = node
584 584
585 585 if not rev:
586 586 raise error.Abort(_("please specify a revision to backout"))
587 587
588 588 date = opts.get('date')
589 589 if date:
590 590 opts['date'] = dateutil.parsedate(date)
591 591
592 592 cmdutil.checkunfinished(repo)
593 593 cmdutil.bailifchanged(repo)
594 594 node = scmutil.revsingle(repo, rev).node()
595 595
596 596 op1, op2 = repo.dirstate.parents()
597 597 if not repo.changelog.isancestor(node, op1):
598 598 raise error.Abort(_('cannot backout change that is not an ancestor'))
599 599
600 600 p1, p2 = repo.changelog.parents(node)
601 601 if p1 == nullid:
602 602 raise error.Abort(_('cannot backout a change with no parents'))
603 603 if p2 != nullid:
604 604 if not opts.get('parent'):
605 605 raise error.Abort(_('cannot backout a merge changeset'))
606 606 p = repo.lookup(opts['parent'])
607 607 if p not in (p1, p2):
608 608 raise error.Abort(_('%s is not a parent of %s') %
609 609 (short(p), short(node)))
610 610 parent = p
611 611 else:
612 612 if opts.get('parent'):
613 613 raise error.Abort(_('cannot use --parent on non-merge changeset'))
614 614 parent = p1
615 615
616 616 # the backout should appear on the same branch
617 617 branch = repo.dirstate.branch()
618 618 bheads = repo.branchheads(branch)
619 619 rctx = scmutil.revsingle(repo, hex(parent))
620 620 if not opts.get('merge') and op1 != node:
621 621 dsguard = dirstateguard.dirstateguard(repo, 'backout')
622 622 try:
623 623 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
624 624 'backout')
625 625 stats = mergemod.update(repo, parent, True, True, node, False)
626 626 repo.setparents(op1, op2)
627 627 dsguard.close()
628 628 hg._showstats(repo, stats)
629 629 if stats.unresolvedcount:
630 630 repo.ui.status(_("use 'hg resolve' to retry unresolved "
631 631 "file merges\n"))
632 632 return 1
633 633 finally:
634 634 ui.setconfig('ui', 'forcemerge', '', '')
635 635 lockmod.release(dsguard)
636 636 else:
637 637 hg.clean(repo, node, show_stats=False)
638 638 repo.dirstate.setbranch(branch)
639 639 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
640 640
641 641 if opts.get('no_commit'):
642 642 msg = _("changeset %s backed out, "
643 643 "don't forget to commit.\n")
644 644 ui.status(msg % short(node))
645 645 return 0
646 646
647 647 def commitfunc(ui, repo, message, match, opts):
648 648 editform = 'backout'
649 649 e = cmdutil.getcommiteditor(editform=editform,
650 650 **pycompat.strkwargs(opts))
651 651 if not message:
652 652 # we don't translate commit messages
653 653 message = "Backed out changeset %s" % short(node)
654 654 e = cmdutil.getcommiteditor(edit=True, editform=editform)
655 655 return repo.commit(message, opts.get('user'), opts.get('date'),
656 656 match, editor=e)
657 657 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
658 658 if not newnode:
659 659 ui.status(_("nothing changed\n"))
660 660 return 1
661 661 cmdutil.commitstatus(repo, newnode, branch, bheads)
662 662
663 663 def nice(node):
664 664 return '%d:%s' % (repo.changelog.rev(node), short(node))
665 665 ui.status(_('changeset %s backs out changeset %s\n') %
666 666 (nice(repo.changelog.tip()), nice(node)))
667 667 if opts.get('merge') and op1 != node:
668 668 hg.clean(repo, op1, show_stats=False)
669 669 ui.status(_('merging with changeset %s\n')
670 670 % nice(repo.changelog.tip()))
671 671 try:
672 672 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
673 673 'backout')
674 674 return hg.merge(repo, hex(repo.changelog.tip()))
675 675 finally:
676 676 ui.setconfig('ui', 'forcemerge', '', '')
677 677 return 0
678 678
679 679 @command('bisect',
680 680 [('r', 'reset', False, _('reset bisect state')),
681 681 ('g', 'good', False, _('mark changeset good')),
682 682 ('b', 'bad', False, _('mark changeset bad')),
683 683 ('s', 'skip', False, _('skip testing changeset')),
684 684 ('e', 'extend', False, _('extend the bisect range')),
685 685 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
686 686 ('U', 'noupdate', False, _('do not update to target'))],
687 687 _("[-gbsr] [-U] [-c CMD] [REV]"))
688 688 def bisect(ui, repo, rev=None, extra=None, command=None,
689 689 reset=None, good=None, bad=None, skip=None, extend=None,
690 690 noupdate=None):
691 691 """subdivision search of changesets
692 692
693 693 This command helps to find changesets which introduce problems. To
694 694 use, mark the earliest changeset you know exhibits the problem as
695 695 bad, then mark the latest changeset which is free from the problem
696 696 as good. Bisect will update your working directory to a revision
697 697 for testing (unless the -U/--noupdate option is specified). Once
698 698 you have performed tests, mark the working directory as good or
699 699 bad, and bisect will either update to another candidate changeset
700 700 or announce that it has found the bad revision.
701 701
702 702 As a shortcut, you can also use the revision argument to mark a
703 703 revision as good or bad without checking it out first.
704 704
705 705 If you supply a command, it will be used for automatic bisection.
706 706 The environment variable HG_NODE will contain the ID of the
707 707 changeset being tested. The exit status of the command will be
708 708 used to mark revisions as good or bad: status 0 means good, 125
709 709 means to skip the revision, 127 (command not found) will abort the
710 710 bisection, and any other non-zero exit status means the revision
711 711 is bad.
712 712
713 713 .. container:: verbose
714 714
715 715 Some examples:
716 716
717 717 - start a bisection with known bad revision 34, and good revision 12::
718 718
719 719 hg bisect --bad 34
720 720 hg bisect --good 12
721 721
722 722 - advance the current bisection by marking current revision as good or
723 723 bad::
724 724
725 725 hg bisect --good
726 726 hg bisect --bad
727 727
728 728 - mark the current revision, or a known revision, to be skipped (e.g. if
729 729 that revision is not usable because of another issue)::
730 730
731 731 hg bisect --skip
732 732 hg bisect --skip 23
733 733
734 734 - skip all revisions that do not touch directories ``foo`` or ``bar``::
735 735
736 736 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
737 737
738 738 - forget the current bisection::
739 739
740 740 hg bisect --reset
741 741
742 742 - use 'make && make tests' to automatically find the first broken
743 743 revision::
744 744
745 745 hg bisect --reset
746 746 hg bisect --bad 34
747 747 hg bisect --good 12
748 748 hg bisect --command "make && make tests"
749 749
750 750 - see all changesets whose states are already known in the current
751 751 bisection::
752 752
753 753 hg log -r "bisect(pruned)"
754 754
755 755 - see the changeset currently being bisected (especially useful
756 756 if running with -U/--noupdate)::
757 757
758 758 hg log -r "bisect(current)"
759 759
760 760 - see all changesets that took part in the current bisection::
761 761
762 762 hg log -r "bisect(range)"
763 763
764 764 - you can even get a nice graph::
765 765
766 766 hg log --graph -r "bisect(range)"
767 767
768 768 See :hg:`help revisions.bisect` for more about the `bisect()` predicate.
769 769
770 770 Returns 0 on success.
771 771 """
772 772 # backward compatibility
773 773 if rev in "good bad reset init".split():
774 774 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
775 775 cmd, rev, extra = rev, extra, None
776 776 if cmd == "good":
777 777 good = True
778 778 elif cmd == "bad":
779 779 bad = True
780 780 else:
781 781 reset = True
782 782 elif extra:
783 783 raise error.Abort(_('incompatible arguments'))
784 784
785 785 incompatibles = {
786 786 '--bad': bad,
787 787 '--command': bool(command),
788 788 '--extend': extend,
789 789 '--good': good,
790 790 '--reset': reset,
791 791 '--skip': skip,
792 792 }
793 793
794 794 enabled = [x for x in incompatibles if incompatibles[x]]
795 795
796 796 if len(enabled) > 1:
797 797 raise error.Abort(_('%s and %s are incompatible') %
798 798 tuple(sorted(enabled)[0:2]))
799 799
800 800 if reset:
801 801 hbisect.resetstate(repo)
802 802 return
803 803
804 804 state = hbisect.load_state(repo)
805 805
806 806 # update state
807 807 if good or bad or skip:
808 808 if rev:
809 809 nodes = [repo[i].node() for i in scmutil.revrange(repo, [rev])]
810 810 else:
811 811 nodes = [repo.lookup('.')]
812 812 if good:
813 813 state['good'] += nodes
814 814 elif bad:
815 815 state['bad'] += nodes
816 816 elif skip:
817 817 state['skip'] += nodes
818 818 hbisect.save_state(repo, state)
819 819 if not (state['good'] and state['bad']):
820 820 return
821 821
822 822 def mayupdate(repo, node, show_stats=True):
823 823 """common used update sequence"""
824 824 if noupdate:
825 825 return
826 826 cmdutil.checkunfinished(repo)
827 827 cmdutil.bailifchanged(repo)
828 828 return hg.clean(repo, node, show_stats=show_stats)
829 829
830 830 displayer = logcmdutil.changesetdisplayer(ui, repo, {})
831 831
832 832 if command:
833 833 changesets = 1
834 834 if noupdate:
835 835 try:
836 836 node = state['current'][0]
837 837 except LookupError:
838 838 raise error.Abort(_('current bisect revision is unknown - '
839 839 'start a new bisect to fix'))
840 840 else:
841 841 node, p2 = repo.dirstate.parents()
842 842 if p2 != nullid:
843 843 raise error.Abort(_('current bisect revision is a merge'))
844 844 if rev:
845 845 node = repo[scmutil.revsingle(repo, rev, node)].node()
846 846 try:
847 847 while changesets:
848 848 # update state
849 849 state['current'] = [node]
850 850 hbisect.save_state(repo, state)
851 851 status = ui.system(command, environ={'HG_NODE': hex(node)},
852 852 blockedtag='bisect_check')
853 853 if status == 125:
854 854 transition = "skip"
855 855 elif status == 0:
856 856 transition = "good"
857 857 # status < 0 means process was killed
858 858 elif status == 127:
859 859 raise error.Abort(_("failed to execute %s") % command)
860 860 elif status < 0:
861 861 raise error.Abort(_("%s killed") % command)
862 862 else:
863 863 transition = "bad"
864 864 state[transition].append(node)
865 865 ctx = repo[node]
866 866 ui.status(_('changeset %d:%s: %s\n') % (ctx.rev(), ctx,
867 867 transition))
868 868 hbisect.checkstate(state)
869 869 # bisect
870 870 nodes, changesets, bgood = hbisect.bisect(repo, state)
871 871 # update to next check
872 872 node = nodes[0]
873 873 mayupdate(repo, node, show_stats=False)
874 874 finally:
875 875 state['current'] = [node]
876 876 hbisect.save_state(repo, state)
877 877 hbisect.printresult(ui, repo, state, displayer, nodes, bgood)
878 878 return
879 879
880 880 hbisect.checkstate(state)
881 881
882 882 # actually bisect
883 883 nodes, changesets, good = hbisect.bisect(repo, state)
884 884 if extend:
885 885 if not changesets:
886 886 extendnode = hbisect.extendrange(repo, state, nodes, good)
887 887 if extendnode is not None:
888 888 ui.write(_("Extending search to changeset %d:%s\n")
889 889 % (extendnode.rev(), extendnode))
890 890 state['current'] = [extendnode.node()]
891 891 hbisect.save_state(repo, state)
892 892 return mayupdate(repo, extendnode.node())
893 893 raise error.Abort(_("nothing to extend"))
894 894
895 895 if changesets == 0:
896 896 hbisect.printresult(ui, repo, state, displayer, nodes, good)
897 897 else:
898 898 assert len(nodes) == 1 # only a single node can be tested next
899 899 node = nodes[0]
900 900 # compute the approximate number of remaining tests
901 901 tests, size = 0, 2
902 902 while size <= changesets:
903 903 tests, size = tests + 1, size * 2
904 904 rev = repo.changelog.rev(node)
905 905 ui.write(_("Testing changeset %d:%s "
906 906 "(%d changesets remaining, ~%d tests)\n")
907 907 % (rev, short(node), changesets, tests))
908 908 state['current'] = [node]
909 909 hbisect.save_state(repo, state)
910 910 return mayupdate(repo, node)
911 911
912 912 @command('bookmarks|bookmark',
913 913 [('f', 'force', False, _('force')),
914 914 ('r', 'rev', '', _('revision for bookmark action'), _('REV')),
915 915 ('d', 'delete', False, _('delete a given bookmark')),
916 916 ('m', 'rename', '', _('rename a given bookmark'), _('OLD')),
917 917 ('i', 'inactive', False, _('mark a bookmark inactive')),
918 918 ] + formatteropts,
919 919 _('hg bookmarks [OPTIONS]... [NAME]...'))
920 920 def bookmark(ui, repo, *names, **opts):
921 921 '''create a new bookmark or list existing bookmarks
922 922
923 923 Bookmarks are labels on changesets to help track lines of development.
924 924 Bookmarks are unversioned and can be moved, renamed and deleted.
925 925 Deleting or moving a bookmark has no effect on the associated changesets.
926 926
927 927 Creating or updating to a bookmark causes it to be marked as 'active'.
928 928 The active bookmark is indicated with a '*'.
929 929 When a commit is made, the active bookmark will advance to the new commit.
930 930 A plain :hg:`update` will also advance an active bookmark, if possible.
931 931 Updating away from a bookmark will cause it to be deactivated.
932 932
933 933 Bookmarks can be pushed and pulled between repositories (see
934 934 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
935 935 diverged, a new 'divergent bookmark' of the form 'name@path' will
936 936 be created. Using :hg:`merge` will resolve the divergence.
937 937
938 938 Specifying bookmark as '.' to -m or -d options is equivalent to specifying
939 939 the active bookmark's name.
940 940
941 941 A bookmark named '@' has the special property that :hg:`clone` will
942 942 check it out by default if it exists.
943 943
944 944 .. container:: verbose
945 945
946 946 Examples:
947 947
948 948 - create an active bookmark for a new line of development::
949 949
950 950 hg book new-feature
951 951
952 952 - create an inactive bookmark as a place marker::
953 953
954 954 hg book -i reviewed
955 955
956 956 - create an inactive bookmark on another changeset::
957 957
958 958 hg book -r .^ tested
959 959
960 960 - rename bookmark turkey to dinner::
961 961
962 962 hg book -m turkey dinner
963 963
964 964 - move the '@' bookmark from another branch::
965 965
966 966 hg book -f @
967 967 '''
968 968 force = opts.get(r'force')
969 969 rev = opts.get(r'rev')
970 970 delete = opts.get(r'delete')
971 971 rename = opts.get(r'rename')
972 972 inactive = opts.get(r'inactive')
973 973
974 974 if delete and rename:
975 975 raise error.Abort(_("--delete and --rename are incompatible"))
976 976 if delete and rev:
977 977 raise error.Abort(_("--rev is incompatible with --delete"))
978 978 if rename and rev:
979 979 raise error.Abort(_("--rev is incompatible with --rename"))
980 980 if not names and (delete or rev):
981 981 raise error.Abort(_("bookmark name required"))
982 982
983 983 if delete or rename or names or inactive:
984 984 with repo.wlock(), repo.lock(), repo.transaction('bookmark') as tr:
985 985 if delete:
986 986 names = pycompat.maplist(repo._bookmarks.expandname, names)
987 987 bookmarks.delete(repo, tr, names)
988 988 elif rename:
989 989 if not names:
990 990 raise error.Abort(_("new bookmark name required"))
991 991 elif len(names) > 1:
992 992 raise error.Abort(_("only one new bookmark name allowed"))
993 993 rename = repo._bookmarks.expandname(rename)
994 994 bookmarks.rename(repo, tr, rename, names[0], force, inactive)
995 995 elif names:
996 996 bookmarks.addbookmarks(repo, tr, names, rev, force, inactive)
997 997 elif inactive:
998 998 if len(repo._bookmarks) == 0:
999 999 ui.status(_("no bookmarks set\n"))
1000 1000 elif not repo._activebookmark:
1001 1001 ui.status(_("no active bookmark\n"))
1002 1002 else:
1003 1003 bookmarks.deactivate(repo)
1004 1004 else: # show bookmarks
1005 1005 bookmarks.printbookmarks(ui, repo, **opts)
1006 1006
1007 1007 @command('branch',
1008 1008 [('f', 'force', None,
1009 1009 _('set branch name even if it shadows an existing branch')),
1010 1010 ('C', 'clean', None, _('reset branch name to parent branch name')),
1011 1011 ('r', 'rev', [], _('change branches of the given revs (EXPERIMENTAL)')),
1012 1012 ],
1013 1013 _('[-fC] [NAME]'))
1014 1014 def branch(ui, repo, label=None, **opts):
1015 1015 """set or show the current branch name
1016 1016
1017 1017 .. note::
1018 1018
1019 1019 Branch names are permanent and global. Use :hg:`bookmark` to create a
1020 1020 light-weight bookmark instead. See :hg:`help glossary` for more
1021 1021 information about named branches and bookmarks.
1022 1022
1023 1023 With no argument, show the current branch name. With one argument,
1024 1024 set the working directory branch name (the branch will not exist
1025 1025 in the repository until the next commit). Standard practice
1026 1026 recommends that primary development take place on the 'default'
1027 1027 branch.
1028 1028
1029 1029 Unless -f/--force is specified, branch will not let you set a
1030 1030 branch name that already exists.
1031 1031
1032 1032 Use -C/--clean to reset the working directory branch to that of
1033 1033 the parent of the working directory, negating a previous branch
1034 1034 change.
1035 1035
1036 1036 Use the command :hg:`update` to switch to an existing branch. Use
1037 1037 :hg:`commit --close-branch` to mark this branch head as closed.
1038 1038 When all heads of a branch are closed, the branch will be
1039 1039 considered closed.
1040 1040
1041 1041 Returns 0 on success.
1042 1042 """
1043 1043 opts = pycompat.byteskwargs(opts)
1044 1044 revs = opts.get('rev')
1045 1045 if label:
1046 1046 label = label.strip()
1047 1047
1048 1048 if not opts.get('clean') and not label:
1049 1049 if revs:
1050 1050 raise error.Abort(_("no branch name specified for the revisions"))
1051 1051 ui.write("%s\n" % repo.dirstate.branch())
1052 1052 return
1053 1053
1054 1054 with repo.wlock():
1055 1055 if opts.get('clean'):
1056 1056 label = repo[None].p1().branch()
1057 1057 repo.dirstate.setbranch(label)
1058 1058 ui.status(_('reset working directory to branch %s\n') % label)
1059 1059 elif label:
1060 1060
1061 1061 scmutil.checknewlabel(repo, label, 'branch')
1062 1062 if revs:
1063 1063 return cmdutil.changebranch(ui, repo, revs, label)
1064 1064
1065 1065 if not opts.get('force') and label in repo.branchmap():
1066 1066 if label not in [p.branch() for p in repo[None].parents()]:
1067 1067 raise error.Abort(_('a branch of the same name already'
1068 1068 ' exists'),
1069 1069 # i18n: "it" refers to an existing branch
1070 1070 hint=_("use 'hg update' to switch to it"))
1071 1071
1072 1072 repo.dirstate.setbranch(label)
1073 1073 ui.status(_('marked working directory as branch %s\n') % label)
1074 1074
1075 1075 # find any open named branches aside from default
1076 1076 others = [n for n, h, t, c in repo.branchmap().iterbranches()
1077 1077 if n != "default" and not c]
1078 1078 if not others:
1079 1079 ui.status(_('(branches are permanent and global, '
1080 1080 'did you want a bookmark?)\n'))
1081 1081
1082 1082 @command('branches',
1083 1083 [('a', 'active', False,
1084 1084 _('show only branches that have unmerged heads (DEPRECATED)')),
1085 1085 ('c', 'closed', False, _('show normal and closed branches')),
1086 1086 ] + formatteropts,
1087 1087 _('[-c]'),
1088 1088 intents={INTENT_READONLY})
1089 1089 def branches(ui, repo, active=False, closed=False, **opts):
1090 1090 """list repository named branches
1091 1091
1092 1092 List the repository's named branches, indicating which ones are
1093 1093 inactive. If -c/--closed is specified, also list branches which have
1094 1094 been marked closed (see :hg:`commit --close-branch`).
1095 1095
1096 1096 Use the command :hg:`update` to switch to an existing branch.
1097 1097
1098 1098 Returns 0.
1099 1099 """
1100 1100
1101 1101 opts = pycompat.byteskwargs(opts)
1102 1102 ui.pager('branches')
1103 1103 fm = ui.formatter('branches', opts)
1104 1104 hexfunc = fm.hexfunc
1105 1105
1106 1106 allheads = set(repo.heads())
1107 1107 branches = []
1108 1108 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1109 1109 isactive = False
1110 1110 if not isclosed:
1111 1111 openheads = set(repo.branchmap().iteropen(heads))
1112 1112 isactive = bool(openheads & allheads)
1113 1113 branches.append((tag, repo[tip], isactive, not isclosed))
1114 1114 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1115 1115 reverse=True)
1116 1116
1117 1117 for tag, ctx, isactive, isopen in branches:
1118 1118 if active and not isactive:
1119 1119 continue
1120 1120 if isactive:
1121 1121 label = 'branches.active'
1122 1122 notice = ''
1123 1123 elif not isopen:
1124 1124 if not closed:
1125 1125 continue
1126 1126 label = 'branches.closed'
1127 1127 notice = _(' (closed)')
1128 1128 else:
1129 1129 label = 'branches.inactive'
1130 1130 notice = _(' (inactive)')
1131 1131 current = (tag == repo.dirstate.branch())
1132 1132 if current:
1133 1133 label = 'branches.current'
1134 1134
1135 1135 fm.startitem()
1136 1136 fm.write('branch', '%s', tag, label=label)
1137 1137 rev = ctx.rev()
1138 1138 padsize = max(31 - len("%d" % rev) - encoding.colwidth(tag), 0)
1139 1139 fmt = ' ' * padsize + ' %d:%s'
1140 1140 fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
1141 1141 label='log.changeset changeset.%s' % ctx.phasestr())
1142 1142 fm.context(ctx=ctx)
1143 1143 fm.data(active=isactive, closed=not isopen, current=current)
1144 1144 if not ui.quiet:
1145 1145 fm.plain(notice)
1146 1146 fm.plain('\n')
1147 1147 fm.end()
1148 1148
1149 1149 @command('bundle',
1150 1150 [('f', 'force', None, _('run even when the destination is unrelated')),
1151 1151 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1152 1152 _('REV')),
1153 1153 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1154 1154 _('BRANCH')),
1155 1155 ('', 'base', [],
1156 1156 _('a base changeset assumed to be available at the destination'),
1157 1157 _('REV')),
1158 1158 ('a', 'all', None, _('bundle all changesets in the repository')),
1159 1159 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1160 1160 ] + remoteopts,
1161 1161 _('[-f] [-t BUNDLESPEC] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1162 1162 def bundle(ui, repo, fname, dest=None, **opts):
1163 1163 """create a bundle file
1164 1164
1165 1165 Generate a bundle file containing data to be transferred to another
1166 1166 repository.
1167 1167
1168 1168 To create a bundle containing all changesets, use -a/--all
1169 1169 (or --base null). Otherwise, hg assumes the destination will have
1170 1170 all the nodes you specify with --base parameters. Otherwise, hg
1171 1171 will assume the repository has all the nodes in destination, or
1172 1172 default-push/default if no destination is specified, where destination
1173 1173 is the repository you provide through DEST option.
1174 1174
1175 1175 You can change bundle format with the -t/--type option. See
1176 1176 :hg:`help bundlespec` for documentation on this format. By default,
1177 1177 the most appropriate format is used and compression defaults to
1178 1178 bzip2.
1179 1179
1180 1180 The bundle file can then be transferred using conventional means
1181 1181 and applied to another repository with the unbundle or pull
1182 1182 command. This is useful when direct push and pull are not
1183 1183 available or when exporting an entire repository is undesirable.
1184 1184
1185 1185 Applying bundles preserves all changeset contents including
1186 1186 permissions, copy/rename information, and revision history.
1187 1187
1188 1188 Returns 0 on success, 1 if no changes found.
1189 1189 """
1190 1190 opts = pycompat.byteskwargs(opts)
1191 1191 revs = None
1192 1192 if 'rev' in opts:
1193 1193 revstrings = opts['rev']
1194 1194 revs = scmutil.revrange(repo, revstrings)
1195 1195 if revstrings and not revs:
1196 1196 raise error.Abort(_('no commits to bundle'))
1197 1197
1198 1198 bundletype = opts.get('type', 'bzip2').lower()
1199 1199 try:
1200 1200 bundlespec = exchange.parsebundlespec(repo, bundletype, strict=False)
1201 1201 except error.UnsupportedBundleSpecification as e:
1202 1202 raise error.Abort(pycompat.bytestr(e),
1203 1203 hint=_("see 'hg help bundlespec' for supported "
1204 1204 "values for --type"))
1205 1205 cgversion = bundlespec.contentopts["cg.version"]
1206 1206
1207 1207 # Packed bundles are a pseudo bundle format for now.
1208 1208 if cgversion == 's1':
1209 1209 raise error.Abort(_('packed bundles cannot be produced by "hg bundle"'),
1210 1210 hint=_("use 'hg debugcreatestreamclonebundle'"))
1211 1211
1212 1212 if opts.get('all'):
1213 1213 if dest:
1214 1214 raise error.Abort(_("--all is incompatible with specifying "
1215 1215 "a destination"))
1216 1216 if opts.get('base'):
1217 1217 ui.warn(_("ignoring --base because --all was specified\n"))
1218 1218 base = ['null']
1219 1219 else:
1220 1220 base = scmutil.revrange(repo, opts.get('base'))
1221 1221 if cgversion not in changegroup.supportedoutgoingversions(repo):
1222 1222 raise error.Abort(_("repository does not support bundle version %s") %
1223 1223 cgversion)
1224 1224
1225 1225 if base:
1226 1226 if dest:
1227 1227 raise error.Abort(_("--base is incompatible with specifying "
1228 1228 "a destination"))
1229 1229 common = [repo[rev].node() for rev in base]
1230 1230 heads = [repo[r].node() for r in revs] if revs else None
1231 1231 outgoing = discovery.outgoing(repo, common, heads)
1232 1232 else:
1233 1233 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1234 1234 dest, branches = hg.parseurl(dest, opts.get('branch'))
1235 1235 other = hg.peer(repo, opts, dest)
1236 1236 revs = [repo[r].hex() for r in revs]
1237 1237 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1238 1238 heads = revs and map(repo.lookup, revs) or revs
1239 1239 outgoing = discovery.findcommonoutgoing(repo, other,
1240 1240 onlyheads=heads,
1241 1241 force=opts.get('force'),
1242 1242 portable=True)
1243 1243
1244 1244 if not outgoing.missing:
1245 1245 scmutil.nochangesfound(ui, repo, not base and outgoing.excluded)
1246 1246 return 1
1247 1247
1248 1248 if cgversion == '01': #bundle1
1249 1249 bversion = 'HG10' + bundlespec.wirecompression
1250 1250 bcompression = None
1251 1251 elif cgversion in ('02', '03'):
1252 1252 bversion = 'HG20'
1253 1253 bcompression = bundlespec.wirecompression
1254 1254 else:
1255 1255 raise error.ProgrammingError(
1256 1256 'bundle: unexpected changegroup version %s' % cgversion)
1257 1257
1258 1258 # TODO compression options should be derived from bundlespec parsing.
1259 1259 # This is a temporary hack to allow adjusting bundle compression
1260 1260 # level without a) formalizing the bundlespec changes to declare it
1261 1261 # b) introducing a command flag.
1262 1262 compopts = {}
1263 1263 complevel = ui.configint('experimental',
1264 1264 'bundlecomplevel.' + bundlespec.compression)
1265 1265 if complevel is None:
1266 1266 complevel = ui.configint('experimental', 'bundlecomplevel')
1267 1267 if complevel is not None:
1268 1268 compopts['level'] = complevel
1269 1269
1270 1270 # Allow overriding the bundling of obsmarker in phases through
1271 1271 # configuration while we don't have a bundle version that include them
1272 1272 if repo.ui.configbool('experimental', 'evolution.bundle-obsmarker'):
1273 1273 bundlespec.contentopts['obsolescence'] = True
1274 1274 if repo.ui.configbool('experimental', 'bundle-phases'):
1275 1275 bundlespec.contentopts['phases'] = True
1276 1276
1277 1277 bundle2.writenewbundle(ui, repo, 'bundle', fname, bversion, outgoing,
1278 1278 bundlespec.contentopts, compression=bcompression,
1279 1279 compopts=compopts)
1280 1280
1281 1281 @command('cat',
1282 1282 [('o', 'output', '',
1283 1283 _('print output to file with formatted name'), _('FORMAT')),
1284 1284 ('r', 'rev', '', _('print the given revision'), _('REV')),
1285 1285 ('', 'decode', None, _('apply any matching decode filter')),
1286 1286 ] + walkopts + formatteropts,
1287 1287 _('[OPTION]... FILE...'),
1288 1288 inferrepo=True,
1289 1289 intents={INTENT_READONLY})
1290 1290 def cat(ui, repo, file1, *pats, **opts):
1291 1291 """output the current or given revision of files
1292 1292
1293 1293 Print the specified files as they were at the given revision. If
1294 1294 no revision is given, the parent of the working directory is used.
1295 1295
1296 1296 Output may be to a file, in which case the name of the file is
1297 1297 given using a template string. See :hg:`help templates`. In addition
1298 1298 to the common template keywords, the following formatting rules are
1299 1299 supported:
1300 1300
1301 1301 :``%%``: literal "%" character
1302 1302 :``%s``: basename of file being printed
1303 1303 :``%d``: dirname of file being printed, or '.' if in repository root
1304 1304 :``%p``: root-relative path name of file being printed
1305 1305 :``%H``: changeset hash (40 hexadecimal digits)
1306 1306 :``%R``: changeset revision number
1307 1307 :``%h``: short-form changeset hash (12 hexadecimal digits)
1308 1308 :``%r``: zero-padded changeset revision number
1309 1309 :``%b``: basename of the exporting repository
1310 1310 :``\\``: literal "\\" character
1311 1311
1312 1312 Returns 0 on success.
1313 1313 """
1314 1314 opts = pycompat.byteskwargs(opts)
1315 1315 rev = opts.get('rev')
1316 1316 if rev:
1317 1317 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
1318 1318 ctx = scmutil.revsingle(repo, rev)
1319 1319 m = scmutil.match(ctx, (file1,) + pats, opts)
1320 1320 fntemplate = opts.pop('output', '')
1321 1321 if cmdutil.isstdiofilename(fntemplate):
1322 1322 fntemplate = ''
1323 1323
1324 1324 if fntemplate:
1325 1325 fm = formatter.nullformatter(ui, 'cat', opts)
1326 1326 else:
1327 1327 ui.pager('cat')
1328 1328 fm = ui.formatter('cat', opts)
1329 1329 with fm:
1330 1330 return cmdutil.cat(ui, repo, ctx, m, fm, fntemplate, '',
1331 1331 **pycompat.strkwargs(opts))
1332 1332
1333 1333 @command('^clone',
1334 1334 [('U', 'noupdate', None, _('the clone will include an empty working '
1335 1335 'directory (only a repository)')),
1336 1336 ('u', 'updaterev', '', _('revision, tag, or branch to check out'),
1337 1337 _('REV')),
1338 1338 ('r', 'rev', [], _('do not clone everything, but include this changeset'
1339 1339 ' and its ancestors'), _('REV')),
1340 1340 ('b', 'branch', [], _('do not clone everything, but include this branch\'s'
1341 1341 ' changesets and their ancestors'), _('BRANCH')),
1342 1342 ('', 'pull', None, _('use pull protocol to copy metadata')),
1343 1343 ('', 'uncompressed', None,
1344 1344 _('an alias to --stream (DEPRECATED)')),
1345 1345 ('', 'stream', None,
1346 1346 _('clone with minimal data processing')),
1347 1347 ] + remoteopts,
1348 1348 _('[OPTION]... SOURCE [DEST]'),
1349 1349 norepo=True)
1350 1350 def clone(ui, source, dest=None, **opts):
1351 1351 """make a copy of an existing repository
1352 1352
1353 1353 Create a copy of an existing repository in a new directory.
1354 1354
1355 1355 If no destination directory name is specified, it defaults to the
1356 1356 basename of the source.
1357 1357
1358 1358 The location of the source is added to the new repository's
1359 1359 ``.hg/hgrc`` file, as the default to be used for future pulls.
1360 1360
1361 1361 Only local paths and ``ssh://`` URLs are supported as
1362 1362 destinations. For ``ssh://`` destinations, no working directory or
1363 1363 ``.hg/hgrc`` will be created on the remote side.
1364 1364
1365 1365 If the source repository has a bookmark called '@' set, that
1366 1366 revision will be checked out in the new repository by default.
1367 1367
1368 1368 To check out a particular version, use -u/--update, or
1369 1369 -U/--noupdate to create a clone with no working directory.
1370 1370
1371 1371 To pull only a subset of changesets, specify one or more revisions
1372 1372 identifiers with -r/--rev or branches with -b/--branch. The
1373 1373 resulting clone will contain only the specified changesets and
1374 1374 their ancestors. These options (or 'clone src#rev dest') imply
1375 1375 --pull, even for local source repositories.
1376 1376
1377 1377 In normal clone mode, the remote normalizes repository data into a common
1378 1378 exchange format and the receiving end translates this data into its local
1379 1379 storage format. --stream activates a different clone mode that essentially
1380 1380 copies repository files from the remote with minimal data processing. This
1381 1381 significantly reduces the CPU cost of a clone both remotely and locally.
1382 1382 However, it often increases the transferred data size by 30-40%. This can
1383 1383 result in substantially faster clones where I/O throughput is plentiful,
1384 1384 especially for larger repositories. A side-effect of --stream clones is
1385 1385 that storage settings and requirements on the remote are applied locally:
1386 1386 a modern client may inherit legacy or inefficient storage used by the
1387 1387 remote or a legacy Mercurial client may not be able to clone from a
1388 1388 modern Mercurial remote.
1389 1389
1390 1390 .. note::
1391 1391
1392 1392 Specifying a tag will include the tagged changeset but not the
1393 1393 changeset containing the tag.
1394 1394
1395 1395 .. container:: verbose
1396 1396
1397 1397 For efficiency, hardlinks are used for cloning whenever the
1398 1398 source and destination are on the same filesystem (note this
1399 1399 applies only to the repository data, not to the working
1400 1400 directory). Some filesystems, such as AFS, implement hardlinking
1401 1401 incorrectly, but do not report errors. In these cases, use the
1402 1402 --pull option to avoid hardlinking.
1403 1403
1404 1404 Mercurial will update the working directory to the first applicable
1405 1405 revision from this list:
1406 1406
1407 1407 a) null if -U or the source repository has no changesets
1408 1408 b) if -u . and the source repository is local, the first parent of
1409 1409 the source repository's working directory
1410 1410 c) the changeset specified with -u (if a branch name, this means the
1411 1411 latest head of that branch)
1412 1412 d) the changeset specified with -r
1413 1413 e) the tipmost head specified with -b
1414 1414 f) the tipmost head specified with the url#branch source syntax
1415 1415 g) the revision marked with the '@' bookmark, if present
1416 1416 h) the tipmost head of the default branch
1417 1417 i) tip
1418 1418
1419 1419 When cloning from servers that support it, Mercurial may fetch
1420 1420 pre-generated data from a server-advertised URL or inline from the
1421 1421 same stream. When this is done, hooks operating on incoming changesets
1422 1422 and changegroups may fire more than once, once for each pre-generated
1423 1423 bundle and as well as for any additional remaining data. In addition,
1424 1424 if an error occurs, the repository may be rolled back to a partial
1425 1425 clone. This behavior may change in future releases.
1426 1426 See :hg:`help -e clonebundles` for more.
1427 1427
1428 1428 Examples:
1429 1429
1430 1430 - clone a remote repository to a new directory named hg/::
1431 1431
1432 1432 hg clone https://www.mercurial-scm.org/repo/hg/
1433 1433
1434 1434 - create a lightweight local clone::
1435 1435
1436 1436 hg clone project/ project-feature/
1437 1437
1438 1438 - clone from an absolute path on an ssh server (note double-slash)::
1439 1439
1440 1440 hg clone ssh://user@server//home/projects/alpha/
1441 1441
1442 1442 - do a streaming clone while checking out a specified version::
1443 1443
1444 1444 hg clone --stream http://server/repo -u 1.5
1445 1445
1446 1446 - create a repository without changesets after a particular revision::
1447 1447
1448 1448 hg clone -r 04e544 experimental/ good/
1449 1449
1450 1450 - clone (and track) a particular named branch::
1451 1451
1452 1452 hg clone https://www.mercurial-scm.org/repo/hg/#stable
1453 1453
1454 1454 See :hg:`help urls` for details on specifying URLs.
1455 1455
1456 1456 Returns 0 on success.
1457 1457 """
1458 1458 opts = pycompat.byteskwargs(opts)
1459 1459 if opts.get('noupdate') and opts.get('updaterev'):
1460 1460 raise error.Abort(_("cannot specify both --noupdate and --updaterev"))
1461 1461
1462 1462 r = hg.clone(ui, opts, source, dest,
1463 1463 pull=opts.get('pull'),
1464 1464 stream=opts.get('stream') or opts.get('uncompressed'),
1465 1465 revs=opts.get('rev'),
1466 1466 update=opts.get('updaterev') or not opts.get('noupdate'),
1467 1467 branch=opts.get('branch'),
1468 1468 shareopts=opts.get('shareopts'))
1469 1469
1470 1470 return r is None
1471 1471
1472 1472 @command('^commit|ci',
1473 1473 [('A', 'addremove', None,
1474 1474 _('mark new/missing files as added/removed before committing')),
1475 1475 ('', 'close-branch', None,
1476 1476 _('mark a branch head as closed')),
1477 1477 ('', 'amend', None, _('amend the parent of the working directory')),
1478 1478 ('s', 'secret', None, _('use the secret phase for committing')),
1479 1479 ('e', 'edit', None, _('invoke editor on commit messages')),
1480 1480 ('i', 'interactive', None, _('use interactive mode')),
1481 1481 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1482 1482 _('[OPTION]... [FILE]...'),
1483 1483 inferrepo=True)
1484 1484 def commit(ui, repo, *pats, **opts):
1485 1485 """commit the specified files or all outstanding changes
1486 1486
1487 1487 Commit changes to the given files into the repository. Unlike a
1488 1488 centralized SCM, this operation is a local operation. See
1489 1489 :hg:`push` for a way to actively distribute your changes.
1490 1490
1491 1491 If a list of files is omitted, all changes reported by :hg:`status`
1492 1492 will be committed.
1493 1493
1494 1494 If you are committing the result of a merge, do not provide any
1495 1495 filenames or -I/-X filters.
1496 1496
1497 1497 If no commit message is specified, Mercurial starts your
1498 1498 configured editor where you can enter a message. In case your
1499 1499 commit fails, you will find a backup of your message in
1500 1500 ``.hg/last-message.txt``.
1501 1501
1502 1502 The --close-branch flag can be used to mark the current branch
1503 1503 head closed. When all heads of a branch are closed, the branch
1504 1504 will be considered closed and no longer listed.
1505 1505
1506 1506 The --amend flag can be used to amend the parent of the
1507 1507 working directory with a new commit that contains the changes
1508 1508 in the parent in addition to those currently reported by :hg:`status`,
1509 1509 if there are any. The old commit is stored in a backup bundle in
1510 1510 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1511 1511 on how to restore it).
1512 1512
1513 1513 Message, user and date are taken from the amended commit unless
1514 1514 specified. When a message isn't specified on the command line,
1515 1515 the editor will open with the message of the amended commit.
1516 1516
1517 1517 It is not possible to amend public changesets (see :hg:`help phases`)
1518 1518 or changesets that have children.
1519 1519
1520 1520 See :hg:`help dates` for a list of formats valid for -d/--date.
1521 1521
1522 1522 Returns 0 on success, 1 if nothing changed.
1523 1523
1524 1524 .. container:: verbose
1525 1525
1526 1526 Examples:
1527 1527
1528 1528 - commit all files ending in .py::
1529 1529
1530 1530 hg commit --include "set:**.py"
1531 1531
1532 1532 - commit all non-binary files::
1533 1533
1534 1534 hg commit --exclude "set:binary()"
1535 1535
1536 1536 - amend the current commit and set the date to now::
1537 1537
1538 1538 hg commit --amend --date now
1539 1539 """
1540 1540 wlock = lock = None
1541 1541 try:
1542 1542 wlock = repo.wlock()
1543 1543 lock = repo.lock()
1544 1544 return _docommit(ui, repo, *pats, **opts)
1545 1545 finally:
1546 1546 release(lock, wlock)
1547 1547
1548 1548 def _docommit(ui, repo, *pats, **opts):
1549 1549 if opts.get(r'interactive'):
1550 1550 opts.pop(r'interactive')
1551 1551 ret = cmdutil.dorecord(ui, repo, commit, None, False,
1552 1552 cmdutil.recordfilter, *pats,
1553 1553 **opts)
1554 1554 # ret can be 0 (no changes to record) or the value returned by
1555 1555 # commit(), 1 if nothing changed or None on success.
1556 1556 return 1 if ret == 0 else ret
1557 1557
1558 1558 opts = pycompat.byteskwargs(opts)
1559 1559 if opts.get('subrepos'):
1560 1560 if opts.get('amend'):
1561 1561 raise error.Abort(_('cannot amend with --subrepos'))
1562 1562 # Let --subrepos on the command line override config setting.
1563 1563 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1564 1564
1565 1565 cmdutil.checkunfinished(repo, commit=True)
1566 1566
1567 1567 branch = repo[None].branch()
1568 1568 bheads = repo.branchheads(branch)
1569 1569
1570 1570 extra = {}
1571 1571 if opts.get('close_branch'):
1572 1572 extra['close'] = '1'
1573 1573
1574 1574 if not bheads:
1575 1575 raise error.Abort(_('can only close branch heads'))
1576 1576 elif opts.get('amend'):
1577 1577 if repo[None].parents()[0].p1().branch() != branch and \
1578 1578 repo[None].parents()[0].p2().branch() != branch:
1579 1579 raise error.Abort(_('can only close branch heads'))
1580 1580
1581 1581 if opts.get('amend'):
1582 1582 if ui.configbool('ui', 'commitsubrepos'):
1583 1583 raise error.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1584 1584
1585 1585 old = repo['.']
1586 1586 rewriteutil.precheck(repo, [old.rev()], 'amend')
1587 1587
1588 1588 # Currently histedit gets confused if an amend happens while histedit
1589 1589 # is in progress. Since we have a checkunfinished command, we are
1590 1590 # temporarily honoring it.
1591 1591 #
1592 1592 # Note: eventually this guard will be removed. Please do not expect
1593 1593 # this behavior to remain.
1594 1594 if not obsolete.isenabled(repo, obsolete.createmarkersopt):
1595 1595 cmdutil.checkunfinished(repo)
1596 1596
1597 1597 node = cmdutil.amend(ui, repo, old, extra, pats, opts)
1598 1598 if node == old.node():
1599 1599 ui.status(_("nothing changed\n"))
1600 1600 return 1
1601 1601 else:
1602 1602 def commitfunc(ui, repo, message, match, opts):
1603 1603 overrides = {}
1604 1604 if opts.get('secret'):
1605 1605 overrides[('phases', 'new-commit')] = 'secret'
1606 1606
1607 1607 baseui = repo.baseui
1608 1608 with baseui.configoverride(overrides, 'commit'):
1609 1609 with ui.configoverride(overrides, 'commit'):
1610 1610 editform = cmdutil.mergeeditform(repo[None],
1611 1611 'commit.normal')
1612 1612 editor = cmdutil.getcommiteditor(
1613 1613 editform=editform, **pycompat.strkwargs(opts))
1614 1614 return repo.commit(message,
1615 1615 opts.get('user'),
1616 1616 opts.get('date'),
1617 1617 match,
1618 1618 editor=editor,
1619 1619 extra=extra)
1620 1620
1621 1621 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1622 1622
1623 1623 if not node:
1624 1624 stat = cmdutil.postcommitstatus(repo, pats, opts)
1625 1625 if stat[3]:
1626 1626 ui.status(_("nothing changed (%d missing files, see "
1627 1627 "'hg status')\n") % len(stat[3]))
1628 1628 else:
1629 1629 ui.status(_("nothing changed\n"))
1630 1630 return 1
1631 1631
1632 1632 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1633 1633
1634 1634 @command('config|showconfig|debugconfig',
1635 1635 [('u', 'untrusted', None, _('show untrusted configuration options')),
1636 1636 ('e', 'edit', None, _('edit user config')),
1637 1637 ('l', 'local', None, _('edit repository config')),
1638 1638 ('g', 'global', None, _('edit global config'))] + formatteropts,
1639 1639 _('[-u] [NAME]...'),
1640 1640 optionalrepo=True,
1641 1641 intents={INTENT_READONLY})
1642 1642 def config(ui, repo, *values, **opts):
1643 1643 """show combined config settings from all hgrc files
1644 1644
1645 1645 With no arguments, print names and values of all config items.
1646 1646
1647 1647 With one argument of the form section.name, print just the value
1648 1648 of that config item.
1649 1649
1650 1650 With multiple arguments, print names and values of all config
1651 1651 items with matching section names or section.names.
1652 1652
1653 1653 With --edit, start an editor on the user-level config file. With
1654 1654 --global, edit the system-wide config file. With --local, edit the
1655 1655 repository-level config file.
1656 1656
1657 1657 With --debug, the source (filename and line number) is printed
1658 1658 for each config item.
1659 1659
1660 1660 See :hg:`help config` for more information about config files.
1661 1661
1662 1662 Returns 0 on success, 1 if NAME does not exist.
1663 1663
1664 1664 """
1665 1665
1666 1666 opts = pycompat.byteskwargs(opts)
1667 1667 if opts.get('edit') or opts.get('local') or opts.get('global'):
1668 1668 if opts.get('local') and opts.get('global'):
1669 1669 raise error.Abort(_("can't use --local and --global together"))
1670 1670
1671 1671 if opts.get('local'):
1672 1672 if not repo:
1673 1673 raise error.Abort(_("can't use --local outside a repository"))
1674 1674 paths = [repo.vfs.join('hgrc')]
1675 1675 elif opts.get('global'):
1676 1676 paths = rcutil.systemrcpath()
1677 1677 else:
1678 1678 paths = rcutil.userrcpath()
1679 1679
1680 1680 for f in paths:
1681 1681 if os.path.exists(f):
1682 1682 break
1683 1683 else:
1684 1684 if opts.get('global'):
1685 1685 samplehgrc = uimod.samplehgrcs['global']
1686 1686 elif opts.get('local'):
1687 1687 samplehgrc = uimod.samplehgrcs['local']
1688 1688 else:
1689 1689 samplehgrc = uimod.samplehgrcs['user']
1690 1690
1691 1691 f = paths[0]
1692 1692 fp = open(f, "wb")
1693 1693 fp.write(util.tonativeeol(samplehgrc))
1694 1694 fp.close()
1695 1695
1696 1696 editor = ui.geteditor()
1697 1697 ui.system("%s \"%s\"" % (editor, f),
1698 1698 onerr=error.Abort, errprefix=_("edit failed"),
1699 1699 blockedtag='config_edit')
1700 1700 return
1701 1701 ui.pager('config')
1702 1702 fm = ui.formatter('config', opts)
1703 1703 for t, f in rcutil.rccomponents():
1704 1704 if t == 'path':
1705 1705 ui.debug('read config from: %s\n' % f)
1706 1706 elif t == 'items':
1707 1707 for section, name, value, source in f:
1708 1708 ui.debug('set config by: %s\n' % source)
1709 1709 else:
1710 1710 raise error.ProgrammingError('unknown rctype: %s' % t)
1711 1711 untrusted = bool(opts.get('untrusted'))
1712 1712
1713 1713 selsections = selentries = []
1714 1714 if values:
1715 1715 selsections = [v for v in values if '.' not in v]
1716 1716 selentries = [v for v in values if '.' in v]
1717 1717 uniquesel = (len(selentries) == 1 and not selsections)
1718 1718 selsections = set(selsections)
1719 1719 selentries = set(selentries)
1720 1720
1721 1721 matched = False
1722 1722 for section, name, value in ui.walkconfig(untrusted=untrusted):
1723 1723 source = ui.configsource(section, name, untrusted)
1724 1724 value = pycompat.bytestr(value)
1725 1725 if fm.isplain():
1726 1726 source = source or 'none'
1727 1727 value = value.replace('\n', '\\n')
1728 1728 entryname = section + '.' + name
1729 1729 if values and not (section in selsections or entryname in selentries):
1730 1730 continue
1731 1731 fm.startitem()
1732 1732 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1733 1733 if uniquesel:
1734 1734 fm.data(name=entryname)
1735 1735 fm.write('value', '%s\n', value)
1736 1736 else:
1737 1737 fm.write('name value', '%s=%s\n', entryname, value)
1738 1738 matched = True
1739 1739 fm.end()
1740 1740 if matched:
1741 1741 return 0
1742 1742 return 1
1743 1743
1744 1744 @command('copy|cp',
1745 1745 [('A', 'after', None, _('record a copy that has already occurred')),
1746 1746 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1747 1747 ] + walkopts + dryrunopts,
1748 1748 _('[OPTION]... [SOURCE]... DEST'))
1749 1749 def copy(ui, repo, *pats, **opts):
1750 1750 """mark files as copied for the next commit
1751 1751
1752 1752 Mark dest as having copies of source files. If dest is a
1753 1753 directory, copies are put in that directory. If dest is a file,
1754 1754 the source must be a single file.
1755 1755
1756 1756 By default, this command copies the contents of files as they
1757 1757 exist in the working directory. If invoked with -A/--after, the
1758 1758 operation is recorded, but no copying is performed.
1759 1759
1760 1760 This command takes effect with the next commit. To undo a copy
1761 1761 before that, see :hg:`revert`.
1762 1762
1763 1763 Returns 0 on success, 1 if errors are encountered.
1764 1764 """
1765 1765 opts = pycompat.byteskwargs(opts)
1766 1766 with repo.wlock(False):
1767 1767 return cmdutil.copy(ui, repo, pats, opts)
1768 1768
1769 1769 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
1770 1770 def debugcommands(ui, cmd='', *args):
1771 1771 """list all available commands and options"""
1772 1772 for cmd, vals in sorted(table.iteritems()):
1773 1773 cmd = cmd.split('|')[0].strip('^')
1774 1774 opts = ', '.join([i[1] for i in vals[1]])
1775 1775 ui.write('%s: %s\n' % (cmd, opts))
1776 1776
1777 1777 @command('debugcomplete',
1778 1778 [('o', 'options', None, _('show the command options'))],
1779 1779 _('[-o] CMD'),
1780 1780 norepo=True)
1781 1781 def debugcomplete(ui, cmd='', **opts):
1782 1782 """returns the completion list associated with the given command"""
1783 1783
1784 1784 if opts.get(r'options'):
1785 1785 options = []
1786 1786 otables = [globalopts]
1787 1787 if cmd:
1788 1788 aliases, entry = cmdutil.findcmd(cmd, table, False)
1789 1789 otables.append(entry[1])
1790 1790 for t in otables:
1791 1791 for o in t:
1792 1792 if "(DEPRECATED)" in o[3]:
1793 1793 continue
1794 1794 if o[0]:
1795 1795 options.append('-%s' % o[0])
1796 1796 options.append('--%s' % o[1])
1797 1797 ui.write("%s\n" % "\n".join(options))
1798 1798 return
1799 1799
1800 1800 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
1801 1801 if ui.verbose:
1802 1802 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
1803 1803 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
1804 1804
1805 1805 @command('^diff',
1806 1806 [('r', 'rev', [], _('revision'), _('REV')),
1807 1807 ('c', 'change', '', _('change made by revision'), _('REV'))
1808 1808 ] + diffopts + diffopts2 + walkopts + subrepoopts,
1809 1809 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
1810 1810 inferrepo=True,
1811 1811 intents={INTENT_READONLY})
1812 1812 def diff(ui, repo, *pats, **opts):
1813 1813 """diff repository (or selected files)
1814 1814
1815 1815 Show differences between revisions for the specified files.
1816 1816
1817 1817 Differences between files are shown using the unified diff format.
1818 1818
1819 1819 .. note::
1820 1820
1821 1821 :hg:`diff` may generate unexpected results for merges, as it will
1822 1822 default to comparing against the working directory's first
1823 1823 parent changeset if no revisions are specified.
1824 1824
1825 1825 When two revision arguments are given, then changes are shown
1826 1826 between those revisions. If only one revision is specified then
1827 1827 that revision is compared to the working directory, and, when no
1828 1828 revisions are specified, the working directory files are compared
1829 1829 to its first parent.
1830 1830
1831 1831 Alternatively you can specify -c/--change with a revision to see
1832 1832 the changes in that changeset relative to its first parent.
1833 1833
1834 1834 Without the -a/--text option, diff will avoid generating diffs of
1835 1835 files it detects as binary. With -a, diff will generate a diff
1836 1836 anyway, probably with undesirable results.
1837 1837
1838 1838 Use the -g/--git option to generate diffs in the git extended diff
1839 1839 format. For more information, read :hg:`help diffs`.
1840 1840
1841 1841 .. container:: verbose
1842 1842
1843 1843 Examples:
1844 1844
1845 1845 - compare a file in the current working directory to its parent::
1846 1846
1847 1847 hg diff foo.c
1848 1848
1849 1849 - compare two historical versions of a directory, with rename info::
1850 1850
1851 1851 hg diff --git -r 1.0:1.2 lib/
1852 1852
1853 1853 - get change stats relative to the last change on some date::
1854 1854
1855 1855 hg diff --stat -r "date('may 2')"
1856 1856
1857 1857 - diff all newly-added files that contain a keyword::
1858 1858
1859 1859 hg diff "set:added() and grep(GNU)"
1860 1860
1861 1861 - compare a revision and its parents::
1862 1862
1863 1863 hg diff -c 9353 # compare against first parent
1864 1864 hg diff -r 9353^:9353 # same using revset syntax
1865 1865 hg diff -r 9353^2:9353 # compare against the second parent
1866 1866
1867 1867 Returns 0 on success.
1868 1868 """
1869 1869
1870 1870 opts = pycompat.byteskwargs(opts)
1871 1871 revs = opts.get('rev')
1872 1872 change = opts.get('change')
1873 1873 stat = opts.get('stat')
1874 1874 reverse = opts.get('reverse')
1875 1875
1876 1876 if revs and change:
1877 1877 msg = _('cannot specify --rev and --change at the same time')
1878 1878 raise error.Abort(msg)
1879 1879 elif change:
1880 1880 repo = scmutil.unhidehashlikerevs(repo, [change], 'nowarn')
1881 1881 ctx2 = scmutil.revsingle(repo, change, None)
1882 1882 ctx1 = ctx2.p1()
1883 1883 else:
1884 1884 repo = scmutil.unhidehashlikerevs(repo, revs, 'nowarn')
1885 1885 ctx1, ctx2 = scmutil.revpair(repo, revs)
1886 1886 node1, node2 = ctx1.node(), ctx2.node()
1887 1887
1888 1888 if reverse:
1889 1889 node1, node2 = node2, node1
1890 1890
1891 1891 diffopts = patch.diffallopts(ui, opts)
1892 1892 m = scmutil.match(ctx2, pats, opts)
1893 1893 ui.pager('diff')
1894 1894 logcmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
1895 1895 listsubrepos=opts.get('subrepos'),
1896 1896 root=opts.get('root'))
1897 1897
1898 1898 @command('^export',
1899 1899 [('B', 'bookmark', '',
1900 1900 _('export changes only reachable by given bookmark')),
1901 1901 ('o', 'output', '',
1902 1902 _('print output to file with formatted name'), _('FORMAT')),
1903 1903 ('', 'switch-parent', None, _('diff against the second parent')),
1904 1904 ('r', 'rev', [], _('revisions to export'), _('REV')),
1905 1905 ] + diffopts + formatteropts,
1906 1906 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'),
1907 1907 intents={INTENT_READONLY})
1908 1908 def export(ui, repo, *changesets, **opts):
1909 1909 """dump the header and diffs for one or more changesets
1910 1910
1911 1911 Print the changeset header and diffs for one or more revisions.
1912 1912 If no revision is given, the parent of the working directory is used.
1913 1913
1914 1914 The information shown in the changeset header is: author, date,
1915 1915 branch name (if non-default), changeset hash, parent(s) and commit
1916 1916 comment.
1917 1917
1918 1918 .. note::
1919 1919
1920 1920 :hg:`export` may generate unexpected diff output for merge
1921 1921 changesets, as it will compare the merge changeset against its
1922 1922 first parent only.
1923 1923
1924 1924 Output may be to a file, in which case the name of the file is
1925 1925 given using a template string. See :hg:`help templates`. In addition
1926 1926 to the common template keywords, the following formatting rules are
1927 1927 supported:
1928 1928
1929 1929 :``%%``: literal "%" character
1930 1930 :``%H``: changeset hash (40 hexadecimal digits)
1931 1931 :``%N``: number of patches being generated
1932 1932 :``%R``: changeset revision number
1933 1933 :``%b``: basename of the exporting repository
1934 1934 :``%h``: short-form changeset hash (12 hexadecimal digits)
1935 1935 :``%m``: first line of the commit message (only alphanumeric characters)
1936 1936 :``%n``: zero-padded sequence number, starting at 1
1937 1937 :``%r``: zero-padded changeset revision number
1938 1938 :``\\``: literal "\\" character
1939 1939
1940 1940 Without the -a/--text option, export will avoid generating diffs
1941 1941 of files it detects as binary. With -a, export will generate a
1942 1942 diff anyway, probably with undesirable results.
1943 1943
1944 1944 With -B/--bookmark changesets reachable by the given bookmark are
1945 1945 selected.
1946 1946
1947 1947 Use the -g/--git option to generate diffs in the git extended diff
1948 1948 format. See :hg:`help diffs` for more information.
1949 1949
1950 1950 With the --switch-parent option, the diff will be against the
1951 1951 second parent. It can be useful to review a merge.
1952 1952
1953 1953 .. container:: verbose
1954 1954
1955 1955 Examples:
1956 1956
1957 1957 - use export and import to transplant a bugfix to the current
1958 1958 branch::
1959 1959
1960 1960 hg export -r 9353 | hg import -
1961 1961
1962 1962 - export all the changesets between two revisions to a file with
1963 1963 rename information::
1964 1964
1965 1965 hg export --git -r 123:150 > changes.txt
1966 1966
1967 1967 - split outgoing changes into a series of patches with
1968 1968 descriptive names::
1969 1969
1970 1970 hg export -r "outgoing()" -o "%n-%m.patch"
1971 1971
1972 1972 Returns 0 on success.
1973 1973 """
1974 1974 opts = pycompat.byteskwargs(opts)
1975 1975 bookmark = opts.get('bookmark')
1976 1976 changesets += tuple(opts.get('rev', []))
1977 1977
1978 1978 if bookmark and changesets:
1979 1979 raise error.Abort(_("-r and -B are mutually exclusive"))
1980 1980
1981 1981 if bookmark:
1982 1982 if bookmark not in repo._bookmarks:
1983 1983 raise error.Abort(_("bookmark '%s' not found") % bookmark)
1984 1984
1985 1985 revs = repair.stripbmrevset(repo, bookmark)
1986 1986 else:
1987 1987 if not changesets:
1988 1988 changesets = ['.']
1989 1989
1990 1990 repo = scmutil.unhidehashlikerevs(repo, changesets, 'nowarn')
1991 1991 revs = scmutil.revrange(repo, changesets)
1992 1992
1993 1993 if not revs:
1994 1994 raise error.Abort(_("export requires at least one changeset"))
1995 1995 if len(revs) > 1:
1996 1996 ui.note(_('exporting patches:\n'))
1997 1997 else:
1998 1998 ui.note(_('exporting patch:\n'))
1999 1999
2000 2000 fntemplate = opts.get('output')
2001 2001 if cmdutil.isstdiofilename(fntemplate):
2002 2002 fntemplate = ''
2003 2003
2004 2004 if fntemplate:
2005 2005 fm = formatter.nullformatter(ui, 'export', opts)
2006 2006 else:
2007 2007 ui.pager('export')
2008 2008 fm = ui.formatter('export', opts)
2009 2009 with fm:
2010 2010 cmdutil.export(repo, revs, fm, fntemplate=fntemplate,
2011 2011 switch_parent=opts.get('switch_parent'),
2012 2012 opts=patch.diffallopts(ui, opts))
2013 2013
2014 2014 @command('files',
2015 2015 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
2016 2016 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
2017 2017 ] + walkopts + formatteropts + subrepoopts,
2018 2018 _('[OPTION]... [FILE]...'),
2019 2019 intents={INTENT_READONLY})
2020 2020 def files(ui, repo, *pats, **opts):
2021 2021 """list tracked files
2022 2022
2023 2023 Print files under Mercurial control in the working directory or
2024 2024 specified revision for given files (excluding removed files).
2025 2025 Files can be specified as filenames or filesets.
2026 2026
2027 2027 If no files are given to match, this command prints the names
2028 2028 of all files under Mercurial control.
2029 2029
2030 2030 .. container:: verbose
2031 2031
2032 2032 Examples:
2033 2033
2034 2034 - list all files under the current directory::
2035 2035
2036 2036 hg files .
2037 2037
2038 2038 - shows sizes and flags for current revision::
2039 2039
2040 2040 hg files -vr .
2041 2041
2042 2042 - list all files named README::
2043 2043
2044 2044 hg files -I "**/README"
2045 2045
2046 2046 - list all binary files::
2047 2047
2048 2048 hg files "set:binary()"
2049 2049
2050 2050 - find files containing a regular expression::
2051 2051
2052 2052 hg files "set:grep('bob')"
2053 2053
2054 2054 - search tracked file contents with xargs and grep::
2055 2055
2056 2056 hg files -0 | xargs -0 grep foo
2057 2057
2058 2058 See :hg:`help patterns` and :hg:`help filesets` for more information
2059 2059 on specifying file patterns.
2060 2060
2061 2061 Returns 0 if a match is found, 1 otherwise.
2062 2062
2063 2063 """
2064 2064
2065 2065 opts = pycompat.byteskwargs(opts)
2066 2066 rev = opts.get('rev')
2067 2067 if rev:
2068 2068 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
2069 2069 ctx = scmutil.revsingle(repo, rev, None)
2070 2070
2071 2071 end = '\n'
2072 2072 if opts.get('print0'):
2073 2073 end = '\0'
2074 2074 fmt = '%s' + end
2075 2075
2076 2076 m = scmutil.match(ctx, pats, opts)
2077 2077 ui.pager('files')
2078 2078 with ui.formatter('files', opts) as fm:
2079 2079 return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
2080 2080
2081 2081 @command(
2082 2082 '^forget',
2083 2083 [('i', 'interactive', None, _('use interactive mode')),
2084 2084 ] + walkopts + dryrunopts,
2085 2085 _('[OPTION]... FILE...'), inferrepo=True)
2086 2086 def forget(ui, repo, *pats, **opts):
2087 2087 """forget the specified files on the next commit
2088 2088
2089 2089 Mark the specified files so they will no longer be tracked
2090 2090 after the next commit.
2091 2091
2092 2092 This only removes files from the current branch, not from the
2093 2093 entire project history, and it does not delete them from the
2094 2094 working directory.
2095 2095
2096 2096 To delete the file from the working directory, see :hg:`remove`.
2097 2097
2098 2098 To undo a forget before the next commit, see :hg:`add`.
2099 2099
2100 2100 .. container:: verbose
2101 2101
2102 2102 Examples:
2103 2103
2104 2104 - forget newly-added binary files::
2105 2105
2106 2106 hg forget "set:added() and binary()"
2107 2107
2108 2108 - forget files that would be excluded by .hgignore::
2109 2109
2110 2110 hg forget "set:hgignore()"
2111 2111
2112 2112 Returns 0 on success.
2113 2113 """
2114 2114
2115 2115 opts = pycompat.byteskwargs(opts)
2116 2116 if not pats:
2117 2117 raise error.Abort(_('no files specified'))
2118 2118
2119 2119 m = scmutil.match(repo[None], pats, opts)
2120 2120 dryrun, interactive = opts.get('dry_run'), opts.get('interactive')
2121 2121 rejected = cmdutil.forget(ui, repo, m, prefix="",
2122 2122 explicitonly=False, dryrun=dryrun,
2123 2123 interactive=interactive)[0]
2124 2124 return rejected and 1 or 0
2125 2125
2126 2126 @command(
2127 2127 'graft',
2128 2128 [('r', 'rev', [], _('revisions to graft'), _('REV')),
2129 2129 ('c', 'continue', False, _('resume interrupted graft')),
2130 2130 ('e', 'edit', False, _('invoke editor on commit messages')),
2131 2131 ('', 'log', None, _('append graft info to log message')),
2132 2132 ('f', 'force', False, _('force graft')),
2133 2133 ('D', 'currentdate', False,
2134 2134 _('record the current date as commit date')),
2135 2135 ('U', 'currentuser', False,
2136 2136 _('record the current user as committer'), _('DATE'))]
2137 2137 + commitopts2 + mergetoolopts + dryrunopts,
2138 2138 _('[OPTION]... [-r REV]... REV...'))
2139 2139 def graft(ui, repo, *revs, **opts):
2140 2140 '''copy changes from other branches onto the current branch
2141 2141
2142 2142 This command uses Mercurial's merge logic to copy individual
2143 2143 changes from other branches without merging branches in the
2144 2144 history graph. This is sometimes known as 'backporting' or
2145 2145 'cherry-picking'. By default, graft will copy user, date, and
2146 2146 description from the source changesets.
2147 2147
2148 2148 Changesets that are ancestors of the current revision, that have
2149 2149 already been grafted, or that are merges will be skipped.
2150 2150
2151 2151 If --log is specified, log messages will have a comment appended
2152 2152 of the form::
2153 2153
2154 2154 (grafted from CHANGESETHASH)
2155 2155
2156 2156 If --force is specified, revisions will be grafted even if they
2157 2157 are already ancestors of, or have been grafted to, the destination.
2158 2158 This is useful when the revisions have since been backed out.
2159 2159
2160 2160 If a graft merge results in conflicts, the graft process is
2161 2161 interrupted so that the current merge can be manually resolved.
2162 2162 Once all conflicts are addressed, the graft process can be
2163 2163 continued with the -c/--continue option.
2164 2164
2165 2165 .. note::
2166 2166
2167 2167 The -c/--continue option does not reapply earlier options, except
2168 2168 for --force.
2169 2169
2170 2170 .. container:: verbose
2171 2171
2172 2172 Examples:
2173 2173
2174 2174 - copy a single change to the stable branch and edit its description::
2175 2175
2176 2176 hg update stable
2177 2177 hg graft --edit 9393
2178 2178
2179 2179 - graft a range of changesets with one exception, updating dates::
2180 2180
2181 2181 hg graft -D "2085::2093 and not 2091"
2182 2182
2183 2183 - continue a graft after resolving conflicts::
2184 2184
2185 2185 hg graft -c
2186 2186
2187 2187 - show the source of a grafted changeset::
2188 2188
2189 2189 hg log --debug -r .
2190 2190
2191 2191 - show revisions sorted by date::
2192 2192
2193 2193 hg log -r "sort(all(), date)"
2194 2194
2195 2195 See :hg:`help revisions` for more about specifying revisions.
2196 2196
2197 2197 Returns 0 on successful completion.
2198 2198 '''
2199 2199 with repo.wlock():
2200 2200 return _dograft(ui, repo, *revs, **opts)
2201 2201
2202 2202 def _dograft(ui, repo, *revs, **opts):
2203 2203 opts = pycompat.byteskwargs(opts)
2204 2204 if revs and opts.get('rev'):
2205 2205 ui.warn(_('warning: inconsistent use of --rev might give unexpected '
2206 2206 'revision ordering!\n'))
2207 2207
2208 2208 revs = list(revs)
2209 2209 revs.extend(opts.get('rev'))
2210 2210
2211 2211 if not opts.get('user') and opts.get('currentuser'):
2212 2212 opts['user'] = ui.username()
2213 2213 if not opts.get('date') and opts.get('currentdate'):
2214 2214 opts['date'] = "%d %d" % dateutil.makedate()
2215 2215
2216 2216 editor = cmdutil.getcommiteditor(editform='graft',
2217 2217 **pycompat.strkwargs(opts))
2218 2218
2219 2219 cont = False
2220 2220 if opts.get('continue'):
2221 2221 cont = True
2222 2222 if revs:
2223 2223 raise error.Abort(_("can't specify --continue and revisions"))
2224 2224 # read in unfinished revisions
2225 2225 try:
2226 2226 nodes = repo.vfs.read('graftstate').splitlines()
2227 2227 revs = [repo[node].rev() for node in nodes]
2228 2228 except IOError as inst:
2229 2229 if inst.errno != errno.ENOENT:
2230 2230 raise
2231 2231 cmdutil.wrongtooltocontinue(repo, _('graft'))
2232 2232 else:
2233 2233 if not revs:
2234 2234 raise error.Abort(_('no revisions specified'))
2235 2235 cmdutil.checkunfinished(repo)
2236 2236 cmdutil.bailifchanged(repo)
2237 2237 revs = scmutil.revrange(repo, revs)
2238 2238
2239 2239 skipped = set()
2240 2240 # check for merges
2241 2241 for rev in repo.revs('%ld and merge()', revs):
2242 2242 ui.warn(_('skipping ungraftable merge revision %d\n') % rev)
2243 2243 skipped.add(rev)
2244 2244 revs = [r for r in revs if r not in skipped]
2245 2245 if not revs:
2246 2246 return -1
2247 2247
2248 2248 # Don't check in the --continue case, in effect retaining --force across
2249 2249 # --continues. That's because without --force, any revisions we decided to
2250 2250 # skip would have been filtered out here, so they wouldn't have made their
2251 2251 # way to the graftstate. With --force, any revisions we would have otherwise
2252 2252 # skipped would not have been filtered out, and if they hadn't been applied
2253 2253 # already, they'd have been in the graftstate.
2254 2254 if not (cont or opts.get('force')):
2255 2255 # check for ancestors of dest branch
2256 2256 crev = repo['.'].rev()
2257 2257 ancestors = repo.changelog.ancestors([crev], inclusive=True)
2258 2258 # XXX make this lazy in the future
2259 2259 # don't mutate while iterating, create a copy
2260 2260 for rev in list(revs):
2261 2261 if rev in ancestors:
2262 2262 ui.warn(_('skipping ancestor revision %d:%s\n') %
2263 2263 (rev, repo[rev]))
2264 2264 # XXX remove on list is slow
2265 2265 revs.remove(rev)
2266 2266 if not revs:
2267 2267 return -1
2268 2268
2269 2269 # analyze revs for earlier grafts
2270 2270 ids = {}
2271 2271 for ctx in repo.set("%ld", revs):
2272 2272 ids[ctx.hex()] = ctx.rev()
2273 2273 n = ctx.extra().get('source')
2274 2274 if n:
2275 2275 ids[n] = ctx.rev()
2276 2276
2277 2277 # check ancestors for earlier grafts
2278 2278 ui.debug('scanning for duplicate grafts\n')
2279 2279
2280 2280 # The only changesets we can be sure doesn't contain grafts of any
2281 2281 # revs, are the ones that are common ancestors of *all* revs:
2282 2282 for rev in repo.revs('only(%d,ancestor(%ld))', crev, revs):
2283 2283 ctx = repo[rev]
2284 2284 n = ctx.extra().get('source')
2285 2285 if n in ids:
2286 2286 try:
2287 2287 r = repo[n].rev()
2288 2288 except error.RepoLookupError:
2289 2289 r = None
2290 2290 if r in revs:
2291 2291 ui.warn(_('skipping revision %d:%s '
2292 2292 '(already grafted to %d:%s)\n')
2293 2293 % (r, repo[r], rev, ctx))
2294 2294 revs.remove(r)
2295 2295 elif ids[n] in revs:
2296 2296 if r is None:
2297 2297 ui.warn(_('skipping already grafted revision %d:%s '
2298 2298 '(%d:%s also has unknown origin %s)\n')
2299 2299 % (ids[n], repo[ids[n]], rev, ctx, n[:12]))
2300 2300 else:
2301 2301 ui.warn(_('skipping already grafted revision %d:%s '
2302 2302 '(%d:%s also has origin %d:%s)\n')
2303 2303 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12]))
2304 2304 revs.remove(ids[n])
2305 2305 elif ctx.hex() in ids:
2306 2306 r = ids[ctx.hex()]
2307 2307 ui.warn(_('skipping already grafted revision %d:%s '
2308 2308 '(was grafted from %d:%s)\n') %
2309 2309 (r, repo[r], rev, ctx))
2310 2310 revs.remove(r)
2311 2311 if not revs:
2312 2312 return -1
2313 2313
2314 2314 for pos, ctx in enumerate(repo.set("%ld", revs)):
2315 2315 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
2316 2316 ctx.description().split('\n', 1)[0])
2317 2317 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
2318 2318 if names:
2319 2319 desc += ' (%s)' % ' '.join(names)
2320 2320 ui.status(_('grafting %s\n') % desc)
2321 2321 if opts.get('dry_run'):
2322 2322 continue
2323 2323
2324 2324 source = ctx.extra().get('source')
2325 2325 extra = {}
2326 2326 if source:
2327 2327 extra['source'] = source
2328 2328 extra['intermediate-source'] = ctx.hex()
2329 2329 else:
2330 2330 extra['source'] = ctx.hex()
2331 2331 user = ctx.user()
2332 2332 if opts.get('user'):
2333 2333 user = opts['user']
2334 2334 date = ctx.date()
2335 2335 if opts.get('date'):
2336 2336 date = opts['date']
2337 2337 message = ctx.description()
2338 2338 if opts.get('log'):
2339 2339 message += '\n(grafted from %s)' % ctx.hex()
2340 2340
2341 2341 # we don't merge the first commit when continuing
2342 2342 if not cont:
2343 2343 # perform the graft merge with p1(rev) as 'ancestor'
2344 2344 try:
2345 2345 # ui.forcemerge is an internal variable, do not document
2346 2346 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
2347 2347 'graft')
2348 2348 stats = mergemod.graft(repo, ctx, ctx.p1(),
2349 2349 ['local', 'graft'])
2350 2350 finally:
2351 2351 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
2352 2352 # report any conflicts
2353 2353 if stats.unresolvedcount > 0:
2354 2354 # write out state for --continue
2355 2355 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
2356 2356 repo.vfs.write('graftstate', ''.join(nodelines))
2357 2357 extra = ''
2358 2358 if opts.get('user'):
2359 2359 extra += ' --user %s' % procutil.shellquote(opts['user'])
2360 2360 if opts.get('date'):
2361 2361 extra += ' --date %s' % procutil.shellquote(opts['date'])
2362 2362 if opts.get('log'):
2363 2363 extra += ' --log'
2364 2364 hint=_("use 'hg resolve' and 'hg graft --continue%s'") % extra
2365 2365 raise error.Abort(
2366 2366 _("unresolved conflicts, can't continue"),
2367 2367 hint=hint)
2368 2368 else:
2369 2369 cont = False
2370 2370
2371 2371 # commit
2372 2372 node = repo.commit(text=message, user=user,
2373 2373 date=date, extra=extra, editor=editor)
2374 2374 if node is None:
2375 2375 ui.warn(
2376 2376 _('note: graft of %d:%s created no changes to commit\n') %
2377 2377 (ctx.rev(), ctx))
2378 2378
2379 2379 # remove state when we complete successfully
2380 2380 if not opts.get('dry_run'):
2381 2381 repo.vfs.unlinkpath('graftstate', ignoremissing=True)
2382 2382
2383 2383 return 0
2384 2384
2385 2385 @command('grep',
2386 2386 [('0', 'print0', None, _('end fields with NUL')),
2387 2387 ('', 'all', None, _('print all revisions that match')),
2388 2388 ('a', 'text', None, _('treat all files as text')),
2389 2389 ('f', 'follow', None,
2390 2390 _('follow changeset history,'
2391 2391 ' or file history across copies and renames')),
2392 2392 ('i', 'ignore-case', None, _('ignore case when matching')),
2393 2393 ('l', 'files-with-matches', None,
2394 2394 _('print only filenames and revisions that match')),
2395 2395 ('n', 'line-number', None, _('print matching line numbers')),
2396 2396 ('r', 'rev', [],
2397 2397 _('only search files changed within revision range'), _('REV')),
2398 2398 ('u', 'user', None, _('list the author (long with -v)')),
2399 2399 ('d', 'date', None, _('list the date (short with -q)')),
2400 2400 ] + formatteropts + walkopts,
2401 2401 _('[OPTION]... PATTERN [FILE]...'),
2402 2402 inferrepo=True,
2403 2403 intents={INTENT_READONLY})
2404 2404 def grep(ui, repo, pattern, *pats, **opts):
2405 2405 """search revision history for a pattern in specified files
2406 2406
2407 2407 Search revision history for a regular expression in the specified
2408 2408 files or the entire project.
2409 2409
2410 2410 By default, grep prints the most recent revision number for each
2411 2411 file in which it finds a match. To get it to print every revision
2412 2412 that contains a change in match status ("-" for a match that becomes
2413 2413 a non-match, or "+" for a non-match that becomes a match), use the
2414 2414 --all flag.
2415 2415
2416 2416 PATTERN can be any Python (roughly Perl-compatible) regular
2417 2417 expression.
2418 2418
2419 2419 If no FILEs are specified (and -f/--follow isn't set), all files in
2420 2420 the repository are searched, including those that don't exist in the
2421 2421 current branch or have been deleted in a prior changeset.
2422 2422
2423 2423 Returns 0 if a match is found, 1 otherwise.
2424 2424 """
2425 2425 opts = pycompat.byteskwargs(opts)
2426 2426 reflags = re.M
2427 2427 if opts.get('ignore_case'):
2428 2428 reflags |= re.I
2429 2429 try:
2430 2430 regexp = util.re.compile(pattern, reflags)
2431 2431 except re.error as inst:
2432 2432 ui.warn(_("grep: invalid match pattern: %s\n") % pycompat.bytestr(inst))
2433 2433 return 1
2434 2434 sep, eol = ':', '\n'
2435 2435 if opts.get('print0'):
2436 2436 sep = eol = '\0'
2437 2437
2438 2438 getfile = util.lrucachefunc(repo.file)
2439 2439
2440 2440 def matchlines(body):
2441 2441 begin = 0
2442 2442 linenum = 0
2443 2443 while begin < len(body):
2444 2444 match = regexp.search(body, begin)
2445 2445 if not match:
2446 2446 break
2447 2447 mstart, mend = match.span()
2448 2448 linenum += body.count('\n', begin, mstart) + 1
2449 2449 lstart = body.rfind('\n', begin, mstart) + 1 or begin
2450 2450 begin = body.find('\n', mend) + 1 or len(body) + 1
2451 2451 lend = begin - 1
2452 2452 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
2453 2453
2454 2454 class linestate(object):
2455 2455 def __init__(self, line, linenum, colstart, colend):
2456 2456 self.line = line
2457 2457 self.linenum = linenum
2458 2458 self.colstart = colstart
2459 2459 self.colend = colend
2460 2460
2461 2461 def __hash__(self):
2462 2462 return hash((self.linenum, self.line))
2463 2463
2464 2464 def __eq__(self, other):
2465 2465 return self.line == other.line
2466 2466
2467 2467 def findpos(self):
2468 2468 """Iterate all (start, end) indices of matches"""
2469 2469 yield self.colstart, self.colend
2470 2470 p = self.colend
2471 2471 while p < len(self.line):
2472 2472 m = regexp.search(self.line, p)
2473 2473 if not m:
2474 2474 break
2475 2475 yield m.span()
2476 2476 p = m.end()
2477 2477
2478 2478 matches = {}
2479 2479 copies = {}
2480 2480 def grepbody(fn, rev, body):
2481 2481 matches[rev].setdefault(fn, [])
2482 2482 m = matches[rev][fn]
2483 2483 for lnum, cstart, cend, line in matchlines(body):
2484 2484 s = linestate(line, lnum, cstart, cend)
2485 2485 m.append(s)
2486 2486
2487 2487 def difflinestates(a, b):
2488 2488 sm = difflib.SequenceMatcher(None, a, b)
2489 2489 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
2490 2490 if tag == 'insert':
2491 2491 for i in xrange(blo, bhi):
2492 2492 yield ('+', b[i])
2493 2493 elif tag == 'delete':
2494 2494 for i in xrange(alo, ahi):
2495 2495 yield ('-', a[i])
2496 2496 elif tag == 'replace':
2497 2497 for i in xrange(alo, ahi):
2498 2498 yield ('-', a[i])
2499 2499 for i in xrange(blo, bhi):
2500 2500 yield ('+', b[i])
2501 2501
2502 2502 def display(fm, fn, ctx, pstates, states):
2503 2503 rev = ctx.rev()
2504 2504 if fm.isplain():
2505 2505 formatuser = ui.shortuser
2506 2506 else:
2507 2507 formatuser = str
2508 2508 if ui.quiet:
2509 2509 datefmt = '%Y-%m-%d'
2510 2510 else:
2511 2511 datefmt = '%a %b %d %H:%M:%S %Y %1%2'
2512 2512 found = False
2513 2513 @util.cachefunc
2514 2514 def binary():
2515 2515 flog = getfile(fn)
2516 2516 return stringutil.binary(flog.read(ctx.filenode(fn)))
2517 2517
2518 2518 fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'}
2519 2519 if opts.get('all'):
2520 2520 iter = difflinestates(pstates, states)
2521 2521 else:
2522 2522 iter = [('', l) for l in states]
2523 2523 for change, l in iter:
2524 2524 fm.startitem()
2525 2525 fm.data(node=fm.hexfunc(ctx.node()))
2526 2526 cols = [
2527 2527 ('filename', fn, True),
2528 2528 ('rev', rev, True),
2529 2529 ('linenumber', l.linenum, opts.get('line_number')),
2530 2530 ]
2531 2531 if opts.get('all'):
2532 2532 cols.append(('change', change, True))
2533 2533 cols.extend([
2534 2534 ('user', formatuser(ctx.user()), opts.get('user')),
2535 2535 ('date', fm.formatdate(ctx.date(), datefmt), opts.get('date')),
2536 2536 ])
2537 2537 lastcol = next(name for name, data, cond in reversed(cols) if cond)
2538 2538 for name, data, cond in cols:
2539 2539 field = fieldnamemap.get(name, name)
2540 2540 fm.condwrite(cond, field, '%s', data, label='grep.%s' % name)
2541 2541 if cond and name != lastcol:
2542 2542 fm.plain(sep, label='grep.sep')
2543 2543 if not opts.get('files_with_matches'):
2544 2544 fm.plain(sep, label='grep.sep')
2545 2545 if not opts.get('text') and binary():
2546 2546 fm.plain(_(" Binary file matches"))
2547 2547 else:
2548 2548 displaymatches(fm.nested('texts', tmpl='{text}'), l)
2549 2549 fm.plain(eol)
2550 2550 found = True
2551 2551 if opts.get('files_with_matches'):
2552 2552 break
2553 2553 return found
2554 2554
2555 2555 def displaymatches(fm, l):
2556 2556 p = 0
2557 2557 for s, e in l.findpos():
2558 2558 if p < s:
2559 2559 fm.startitem()
2560 2560 fm.write('text', '%s', l.line[p:s])
2561 2561 fm.data(matched=False)
2562 2562 fm.startitem()
2563 2563 fm.write('text', '%s', l.line[s:e], label='grep.match')
2564 2564 fm.data(matched=True)
2565 2565 p = e
2566 2566 if p < len(l.line):
2567 2567 fm.startitem()
2568 2568 fm.write('text', '%s', l.line[p:])
2569 2569 fm.data(matched=False)
2570 2570 fm.end()
2571 2571
2572 2572 skip = {}
2573 2573 revfiles = {}
2574 2574 match = scmutil.match(repo[None], pats, opts)
2575 2575 found = False
2576 2576 follow = opts.get('follow')
2577 2577
2578 2578 def prep(ctx, fns):
2579 2579 rev = ctx.rev()
2580 2580 pctx = ctx.p1()
2581 2581 parent = pctx.rev()
2582 2582 matches.setdefault(rev, {})
2583 2583 matches.setdefault(parent, {})
2584 2584 files = revfiles.setdefault(rev, [])
2585 2585 for fn in fns:
2586 2586 flog = getfile(fn)
2587 2587 try:
2588 2588 fnode = ctx.filenode(fn)
2589 2589 except error.LookupError:
2590 2590 continue
2591 2591
2592 2592 copied = flog.renamed(fnode)
2593 2593 copy = follow and copied and copied[0]
2594 2594 if copy:
2595 2595 copies.setdefault(rev, {})[fn] = copy
2596 2596 if fn in skip:
2597 2597 if copy:
2598 2598 skip[copy] = True
2599 2599 continue
2600 2600 files.append(fn)
2601 2601
2602 2602 if fn not in matches[rev]:
2603 2603 grepbody(fn, rev, flog.read(fnode))
2604 2604
2605 2605 pfn = copy or fn
2606 2606 if pfn not in matches[parent]:
2607 2607 try:
2608 2608 fnode = pctx.filenode(pfn)
2609 2609 grepbody(pfn, parent, flog.read(fnode))
2610 2610 except error.LookupError:
2611 2611 pass
2612 2612
2613 2613 ui.pager('grep')
2614 2614 fm = ui.formatter('grep', opts)
2615 2615 for ctx in cmdutil.walkchangerevs(repo, match, opts, prep):
2616 2616 rev = ctx.rev()
2617 2617 parent = ctx.p1().rev()
2618 2618 for fn in sorted(revfiles.get(rev, [])):
2619 2619 states = matches[rev][fn]
2620 2620 copy = copies.get(rev, {}).get(fn)
2621 2621 if fn in skip:
2622 2622 if copy:
2623 2623 skip[copy] = True
2624 2624 continue
2625 2625 pstates = matches.get(parent, {}).get(copy or fn, [])
2626 2626 if pstates or states:
2627 2627 r = display(fm, fn, ctx, pstates, states)
2628 2628 found = found or r
2629 2629 if r and not opts.get('all'):
2630 2630 skip[fn] = True
2631 2631 if copy:
2632 2632 skip[copy] = True
2633 2633 del revfiles[rev]
2634 2634 # We will keep the matches dict for the duration of the window
2635 2635 # clear the matches dict once the window is over
2636 2636 if not revfiles:
2637 2637 matches.clear()
2638 2638 fm.end()
2639 2639
2640 2640 return not found
2641 2641
2642 2642 @command('heads',
2643 2643 [('r', 'rev', '',
2644 2644 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
2645 2645 ('t', 'topo', False, _('show topological heads only')),
2646 2646 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
2647 2647 ('c', 'closed', False, _('show normal and closed branch heads')),
2648 2648 ] + templateopts,
2649 2649 _('[-ct] [-r STARTREV] [REV]...'),
2650 2650 intents={INTENT_READONLY})
2651 2651 def heads(ui, repo, *branchrevs, **opts):
2652 2652 """show branch heads
2653 2653
2654 2654 With no arguments, show all open branch heads in the repository.
2655 2655 Branch heads are changesets that have no descendants on the
2656 2656 same branch. They are where development generally takes place and
2657 2657 are the usual targets for update and merge operations.
2658 2658
2659 2659 If one or more REVs are given, only open branch heads on the
2660 2660 branches associated with the specified changesets are shown. This
2661 2661 means that you can use :hg:`heads .` to see the heads on the
2662 2662 currently checked-out branch.
2663 2663
2664 2664 If -c/--closed is specified, also show branch heads marked closed
2665 2665 (see :hg:`commit --close-branch`).
2666 2666
2667 2667 If STARTREV is specified, only those heads that are descendants of
2668 2668 STARTREV will be displayed.
2669 2669
2670 2670 If -t/--topo is specified, named branch mechanics will be ignored and only
2671 2671 topological heads (changesets with no children) will be shown.
2672 2672
2673 2673 Returns 0 if matching heads are found, 1 if not.
2674 2674 """
2675 2675
2676 2676 opts = pycompat.byteskwargs(opts)
2677 2677 start = None
2678 2678 rev = opts.get('rev')
2679 2679 if rev:
2680 2680 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
2681 2681 start = scmutil.revsingle(repo, rev, None).node()
2682 2682
2683 2683 if opts.get('topo'):
2684 2684 heads = [repo[h] for h in repo.heads(start)]
2685 2685 else:
2686 2686 heads = []
2687 2687 for branch in repo.branchmap():
2688 2688 heads += repo.branchheads(branch, start, opts.get('closed'))
2689 2689 heads = [repo[h] for h in heads]
2690 2690
2691 2691 if branchrevs:
2692 2692 branches = set(repo[r].branch()
2693 2693 for r in scmutil.revrange(repo, branchrevs))
2694 2694 heads = [h for h in heads if h.branch() in branches]
2695 2695
2696 2696 if opts.get('active') and branchrevs:
2697 2697 dagheads = repo.heads(start)
2698 2698 heads = [h for h in heads if h.node() in dagheads]
2699 2699
2700 2700 if branchrevs:
2701 2701 haveheads = set(h.branch() for h in heads)
2702 2702 if branches - haveheads:
2703 2703 headless = ', '.join(b for b in branches - haveheads)
2704 2704 msg = _('no open branch heads found on branches %s')
2705 2705 if opts.get('rev'):
2706 2706 msg += _(' (started at %s)') % opts['rev']
2707 2707 ui.warn((msg + '\n') % headless)
2708 2708
2709 2709 if not heads:
2710 2710 return 1
2711 2711
2712 2712 ui.pager('heads')
2713 2713 heads = sorted(heads, key=lambda x: -x.rev())
2714 2714 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
2715 2715 for ctx in heads:
2716 2716 displayer.show(ctx)
2717 2717 displayer.close()
2718 2718
2719 2719 @command('help',
2720 2720 [('e', 'extension', None, _('show only help for extensions')),
2721 2721 ('c', 'command', None, _('show only help for commands')),
2722 2722 ('k', 'keyword', None, _('show topics matching keyword')),
2723 2723 ('s', 'system', [], _('show help for specific platform(s)')),
2724 2724 ],
2725 2725 _('[-ecks] [TOPIC]'),
2726 2726 norepo=True,
2727 2727 intents={INTENT_READONLY})
2728 2728 def help_(ui, name=None, **opts):
2729 2729 """show help for a given topic or a help overview
2730 2730
2731 2731 With no arguments, print a list of commands with short help messages.
2732 2732
2733 2733 Given a topic, extension, or command name, print help for that
2734 2734 topic.
2735 2735
2736 2736 Returns 0 if successful.
2737 2737 """
2738 2738
2739 2739 keep = opts.get(r'system') or []
2740 2740 if len(keep) == 0:
2741 2741 if pycompat.sysplatform.startswith('win'):
2742 2742 keep.append('windows')
2743 2743 elif pycompat.sysplatform == 'OpenVMS':
2744 2744 keep.append('vms')
2745 2745 elif pycompat.sysplatform == 'plan9':
2746 2746 keep.append('plan9')
2747 2747 else:
2748 2748 keep.append('unix')
2749 2749 keep.append(pycompat.sysplatform.lower())
2750 2750 if ui.verbose:
2751 2751 keep.append('verbose')
2752 2752
2753 2753 commands = sys.modules[__name__]
2754 2754 formatted = help.formattedhelp(ui, commands, name, keep=keep, **opts)
2755 2755 ui.pager('help')
2756 2756 ui.write(formatted)
2757 2757
2758 2758
2759 2759 @command('identify|id',
2760 2760 [('r', 'rev', '',
2761 2761 _('identify the specified revision'), _('REV')),
2762 2762 ('n', 'num', None, _('show local revision number')),
2763 2763 ('i', 'id', None, _('show global revision id')),
2764 2764 ('b', 'branch', None, _('show branch')),
2765 2765 ('t', 'tags', None, _('show tags')),
2766 2766 ('B', 'bookmarks', None, _('show bookmarks')),
2767 2767 ] + remoteopts + formatteropts,
2768 2768 _('[-nibtB] [-r REV] [SOURCE]'),
2769 2769 optionalrepo=True,
2770 2770 intents={INTENT_READONLY})
2771 2771 def identify(ui, repo, source=None, rev=None,
2772 2772 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
2773 2773 """identify the working directory or specified revision
2774 2774
2775 2775 Print a summary identifying the repository state at REV using one or
2776 2776 two parent hash identifiers, followed by a "+" if the working
2777 2777 directory has uncommitted changes, the branch name (if not default),
2778 2778 a list of tags, and a list of bookmarks.
2779 2779
2780 2780 When REV is not given, print a summary of the current state of the
2781 2781 repository including the working directory. Specify -r. to get information
2782 2782 of the working directory parent without scanning uncommitted changes.
2783 2783
2784 2784 Specifying a path to a repository root or Mercurial bundle will
2785 2785 cause lookup to operate on that repository/bundle.
2786 2786
2787 2787 .. container:: verbose
2788 2788
2789 2789 Examples:
2790 2790
2791 2791 - generate a build identifier for the working directory::
2792 2792
2793 2793 hg id --id > build-id.dat
2794 2794
2795 2795 - find the revision corresponding to a tag::
2796 2796
2797 2797 hg id -n -r 1.3
2798 2798
2799 2799 - check the most recent revision of a remote repository::
2800 2800
2801 2801 hg id -r tip https://www.mercurial-scm.org/repo/hg/
2802 2802
2803 2803 See :hg:`log` for generating more information about specific revisions,
2804 2804 including full hash identifiers.
2805 2805
2806 2806 Returns 0 if successful.
2807 2807 """
2808 2808
2809 2809 opts = pycompat.byteskwargs(opts)
2810 2810 if not repo and not source:
2811 2811 raise error.Abort(_("there is no Mercurial repository here "
2812 2812 "(.hg not found)"))
2813 2813
2814 2814 if ui.debugflag:
2815 2815 hexfunc = hex
2816 2816 else:
2817 2817 hexfunc = short
2818 2818 default = not (num or id or branch or tags or bookmarks)
2819 2819 output = []
2820 2820 revs = []
2821 2821
2822 2822 if source:
2823 2823 source, branches = hg.parseurl(ui.expandpath(source))
2824 2824 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
2825 2825 repo = peer.local()
2826 2826 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
2827 2827
2828 2828 fm = ui.formatter('identify', opts)
2829 2829 fm.startitem()
2830 2830
2831 2831 if not repo:
2832 2832 if num or branch or tags:
2833 2833 raise error.Abort(
2834 2834 _("can't query remote revision number, branch, or tags"))
2835 2835 if not rev and revs:
2836 2836 rev = revs[0]
2837 2837 if not rev:
2838 2838 rev = "tip"
2839 2839
2840 2840 remoterev = peer.lookup(rev)
2841 2841 hexrev = hexfunc(remoterev)
2842 2842 if default or id:
2843 2843 output = [hexrev]
2844 2844 fm.data(id=hexrev)
2845 2845
2846 2846 def getbms():
2847 2847 bms = []
2848 2848
2849 2849 if 'bookmarks' in peer.listkeys('namespaces'):
2850 2850 hexremoterev = hex(remoterev)
2851 2851 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
2852 2852 if bmr == hexremoterev]
2853 2853
2854 2854 return sorted(bms)
2855 2855
2856 2856 bms = getbms()
2857 2857 if bookmarks:
2858 2858 output.extend(bms)
2859 2859 elif default and not ui.quiet:
2860 2860 # multiple bookmarks for a single parent separated by '/'
2861 2861 bm = '/'.join(bms)
2862 2862 if bm:
2863 2863 output.append(bm)
2864 2864
2865 2865 fm.data(node=hex(remoterev))
2866 2866 fm.data(bookmarks=fm.formatlist(bms, name='bookmark'))
2867 2867 else:
2868 2868 if rev:
2869 2869 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
2870 2870 ctx = scmutil.revsingle(repo, rev, None)
2871 2871
2872 2872 if ctx.rev() is None:
2873 2873 ctx = repo[None]
2874 2874 parents = ctx.parents()
2875 2875 taglist = []
2876 2876 for p in parents:
2877 2877 taglist.extend(p.tags())
2878 2878
2879 2879 dirty = ""
2880 2880 if ctx.dirty(missing=True, merge=False, branch=False):
2881 2881 dirty = '+'
2882 2882 fm.data(dirty=dirty)
2883 2883
2884 2884 hexoutput = [hexfunc(p.node()) for p in parents]
2885 2885 if default or id:
2886 2886 output = ["%s%s" % ('+'.join(hexoutput), dirty)]
2887 2887 fm.data(id="%s%s" % ('+'.join(hexoutput), dirty))
2888 2888
2889 2889 if num:
2890 2890 numoutput = ["%d" % p.rev() for p in parents]
2891 2891 output.append("%s%s" % ('+'.join(numoutput), dirty))
2892 2892
2893 2893 fn = fm.nested('parents', tmpl='{rev}:{node|formatnode}', sep=' ')
2894 2894 for p in parents:
2895 2895 fn.startitem()
2896 2896 fn.data(rev=p.rev())
2897 2897 fn.data(node=p.hex())
2898 2898 fn.context(ctx=p)
2899 2899 fn.end()
2900 2900 else:
2901 2901 hexoutput = hexfunc(ctx.node())
2902 2902 if default or id:
2903 2903 output = [hexoutput]
2904 2904 fm.data(id=hexoutput)
2905 2905
2906 2906 if num:
2907 2907 output.append(pycompat.bytestr(ctx.rev()))
2908 2908 taglist = ctx.tags()
2909 2909
2910 2910 if default and not ui.quiet:
2911 2911 b = ctx.branch()
2912 2912 if b != 'default':
2913 2913 output.append("(%s)" % b)
2914 2914
2915 2915 # multiple tags for a single parent separated by '/'
2916 2916 t = '/'.join(taglist)
2917 2917 if t:
2918 2918 output.append(t)
2919 2919
2920 2920 # multiple bookmarks for a single parent separated by '/'
2921 2921 bm = '/'.join(ctx.bookmarks())
2922 2922 if bm:
2923 2923 output.append(bm)
2924 2924 else:
2925 2925 if branch:
2926 2926 output.append(ctx.branch())
2927 2927
2928 2928 if tags:
2929 2929 output.extend(taglist)
2930 2930
2931 2931 if bookmarks:
2932 2932 output.extend(ctx.bookmarks())
2933 2933
2934 2934 fm.data(node=ctx.hex())
2935 2935 fm.data(branch=ctx.branch())
2936 2936 fm.data(tags=fm.formatlist(taglist, name='tag', sep=':'))
2937 2937 fm.data(bookmarks=fm.formatlist(ctx.bookmarks(), name='bookmark'))
2938 2938 fm.context(ctx=ctx)
2939 2939
2940 2940 fm.plain("%s\n" % ' '.join(output))
2941 2941 fm.end()
2942 2942
2943 2943 @command('import|patch',
2944 2944 [('p', 'strip', 1,
2945 2945 _('directory strip option for patch. This has the same '
2946 2946 'meaning as the corresponding patch option'), _('NUM')),
2947 2947 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
2948 2948 ('e', 'edit', False, _('invoke editor on commit messages')),
2949 2949 ('f', 'force', None,
2950 2950 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
2951 2951 ('', 'no-commit', None,
2952 2952 _("don't commit, just update the working directory")),
2953 2953 ('', 'bypass', None,
2954 2954 _("apply patch without touching the working directory")),
2955 2955 ('', 'partial', None,
2956 2956 _('commit even if some hunks fail')),
2957 2957 ('', 'exact', None,
2958 2958 _('abort if patch would apply lossily')),
2959 2959 ('', 'prefix', '',
2960 2960 _('apply patch to subdirectory'), _('DIR')),
2961 2961 ('', 'import-branch', None,
2962 2962 _('use any branch information in patch (implied by --exact)'))] +
2963 2963 commitopts + commitopts2 + similarityopts,
2964 2964 _('[OPTION]... PATCH...'))
2965 2965 def import_(ui, repo, patch1=None, *patches, **opts):
2966 2966 """import an ordered set of patches
2967 2967
2968 2968 Import a list of patches and commit them individually (unless
2969 2969 --no-commit is specified).
2970 2970
2971 2971 To read a patch from standard input (stdin), use "-" as the patch
2972 2972 name. If a URL is specified, the patch will be downloaded from
2973 2973 there.
2974 2974
2975 2975 Import first applies changes to the working directory (unless
2976 2976 --bypass is specified), import will abort if there are outstanding
2977 2977 changes.
2978 2978
2979 2979 Use --bypass to apply and commit patches directly to the
2980 2980 repository, without affecting the working directory. Without
2981 2981 --exact, patches will be applied on top of the working directory
2982 2982 parent revision.
2983 2983
2984 2984 You can import a patch straight from a mail message. Even patches
2985 2985 as attachments work (to use the body part, it must have type
2986 2986 text/plain or text/x-patch). From and Subject headers of email
2987 2987 message are used as default committer and commit message. All
2988 2988 text/plain body parts before first diff are added to the commit
2989 2989 message.
2990 2990
2991 2991 If the imported patch was generated by :hg:`export`, user and
2992 2992 description from patch override values from message headers and
2993 2993 body. Values given on command line with -m/--message and -u/--user
2994 2994 override these.
2995 2995
2996 2996 If --exact is specified, import will set the working directory to
2997 2997 the parent of each patch before applying it, and will abort if the
2998 2998 resulting changeset has a different ID than the one recorded in
2999 2999 the patch. This will guard against various ways that portable
3000 3000 patch formats and mail systems might fail to transfer Mercurial
3001 3001 data or metadata. See :hg:`bundle` for lossless transmission.
3002 3002
3003 3003 Use --partial to ensure a changeset will be created from the patch
3004 3004 even if some hunks fail to apply. Hunks that fail to apply will be
3005 3005 written to a <target-file>.rej file. Conflicts can then be resolved
3006 3006 by hand before :hg:`commit --amend` is run to update the created
3007 3007 changeset. This flag exists to let people import patches that
3008 3008 partially apply without losing the associated metadata (author,
3009 3009 date, description, ...).
3010 3010
3011 3011 .. note::
3012 3012
3013 3013 When no hunks apply cleanly, :hg:`import --partial` will create
3014 3014 an empty changeset, importing only the patch metadata.
3015 3015
3016 3016 With -s/--similarity, hg will attempt to discover renames and
3017 3017 copies in the patch in the same way as :hg:`addremove`.
3018 3018
3019 3019 It is possible to use external patch programs to perform the patch
3020 3020 by setting the ``ui.patch`` configuration option. For the default
3021 3021 internal tool, the fuzz can also be configured via ``patch.fuzz``.
3022 3022 See :hg:`help config` for more information about configuration
3023 3023 files and how to use these options.
3024 3024
3025 3025 See :hg:`help dates` for a list of formats valid for -d/--date.
3026 3026
3027 3027 .. container:: verbose
3028 3028
3029 3029 Examples:
3030 3030
3031 3031 - import a traditional patch from a website and detect renames::
3032 3032
3033 3033 hg import -s 80 http://example.com/bugfix.patch
3034 3034
3035 3035 - import a changeset from an hgweb server::
3036 3036
3037 3037 hg import https://www.mercurial-scm.org/repo/hg/rev/5ca8c111e9aa
3038 3038
3039 3039 - import all the patches in an Unix-style mbox::
3040 3040
3041 3041 hg import incoming-patches.mbox
3042 3042
3043 3043 - import patches from stdin::
3044 3044
3045 3045 hg import -
3046 3046
3047 3047 - attempt to exactly restore an exported changeset (not always
3048 3048 possible)::
3049 3049
3050 3050 hg import --exact proposed-fix.patch
3051 3051
3052 3052 - use an external tool to apply a patch which is too fuzzy for
3053 3053 the default internal tool.
3054 3054
3055 3055 hg import --config ui.patch="patch --merge" fuzzy.patch
3056 3056
3057 3057 - change the default fuzzing from 2 to a less strict 7
3058 3058
3059 3059 hg import --config ui.fuzz=7 fuzz.patch
3060 3060
3061 3061 Returns 0 on success, 1 on partial success (see --partial).
3062 3062 """
3063 3063
3064 3064 opts = pycompat.byteskwargs(opts)
3065 3065 if not patch1:
3066 3066 raise error.Abort(_('need at least one patch to import'))
3067 3067
3068 3068 patches = (patch1,) + patches
3069 3069
3070 3070 date = opts.get('date')
3071 3071 if date:
3072 3072 opts['date'] = dateutil.parsedate(date)
3073 3073
3074 3074 exact = opts.get('exact')
3075 3075 update = not opts.get('bypass')
3076 3076 if not update and opts.get('no_commit'):
3077 3077 raise error.Abort(_('cannot use --no-commit with --bypass'))
3078 3078 try:
3079 3079 sim = float(opts.get('similarity') or 0)
3080 3080 except ValueError:
3081 3081 raise error.Abort(_('similarity must be a number'))
3082 3082 if sim < 0 or sim > 100:
3083 3083 raise error.Abort(_('similarity must be between 0 and 100'))
3084 3084 if sim and not update:
3085 3085 raise error.Abort(_('cannot use --similarity with --bypass'))
3086 3086 if exact:
3087 3087 if opts.get('edit'):
3088 3088 raise error.Abort(_('cannot use --exact with --edit'))
3089 3089 if opts.get('prefix'):
3090 3090 raise error.Abort(_('cannot use --exact with --prefix'))
3091 3091
3092 3092 base = opts["base"]
3093 3093 wlock = dsguard = lock = tr = None
3094 3094 msgs = []
3095 3095 ret = 0
3096 3096
3097 3097
3098 3098 try:
3099 3099 wlock = repo.wlock()
3100 3100
3101 3101 if update:
3102 3102 cmdutil.checkunfinished(repo)
3103 3103 if (exact or not opts.get('force')):
3104 3104 cmdutil.bailifchanged(repo)
3105 3105
3106 3106 if not opts.get('no_commit'):
3107 3107 lock = repo.lock()
3108 3108 tr = repo.transaction('import')
3109 3109 else:
3110 3110 dsguard = dirstateguard.dirstateguard(repo, 'import')
3111 3111 parents = repo[None].parents()
3112 3112 for patchurl in patches:
3113 3113 if patchurl == '-':
3114 3114 ui.status(_('applying patch from stdin\n'))
3115 3115 patchfile = ui.fin
3116 3116 patchurl = 'stdin' # for error message
3117 3117 else:
3118 3118 patchurl = os.path.join(base, patchurl)
3119 3119 ui.status(_('applying %s\n') % patchurl)
3120 3120 patchfile = hg.openpath(ui, patchurl)
3121 3121
3122 3122 haspatch = False
3123 3123 for hunk in patch.split(patchfile):
3124 3124 with patch.extract(ui, hunk) as patchdata:
3125 3125 msg, node, rej = cmdutil.tryimportone(ui, repo, patchdata,
3126 3126 parents, opts,
3127 3127 msgs, hg.clean)
3128 3128 if msg:
3129 3129 haspatch = True
3130 3130 ui.note(msg + '\n')
3131 3131 if update or exact:
3132 3132 parents = repo[None].parents()
3133 3133 else:
3134 3134 parents = [repo[node]]
3135 3135 if rej:
3136 3136 ui.write_err(_("patch applied partially\n"))
3137 3137 ui.write_err(_("(fix the .rej files and run "
3138 3138 "`hg commit --amend`)\n"))
3139 3139 ret = 1
3140 3140 break
3141 3141
3142 3142 if not haspatch:
3143 3143 raise error.Abort(_('%s: no diffs found') % patchurl)
3144 3144
3145 3145 if tr:
3146 3146 tr.close()
3147 3147 if msgs:
3148 3148 repo.savecommitmessage('\n* * *\n'.join(msgs))
3149 3149 if dsguard:
3150 3150 dsguard.close()
3151 3151 return ret
3152 3152 finally:
3153 3153 if tr:
3154 3154 tr.release()
3155 3155 release(lock, dsguard, wlock)
3156 3156
3157 3157 @command('incoming|in',
3158 3158 [('f', 'force', None,
3159 3159 _('run even if remote repository is unrelated')),
3160 3160 ('n', 'newest-first', None, _('show newest record first')),
3161 3161 ('', 'bundle', '',
3162 3162 _('file to store the bundles into'), _('FILE')),
3163 3163 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
3164 3164 ('B', 'bookmarks', False, _("compare bookmarks")),
3165 3165 ('b', 'branch', [],
3166 3166 _('a specific branch you would like to pull'), _('BRANCH')),
3167 3167 ] + logopts + remoteopts + subrepoopts,
3168 3168 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
3169 3169 def incoming(ui, repo, source="default", **opts):
3170 3170 """show new changesets found in source
3171 3171
3172 3172 Show new changesets found in the specified path/URL or the default
3173 3173 pull location. These are the changesets that would have been pulled
3174 3174 by :hg:`pull` at the time you issued this command.
3175 3175
3176 3176 See pull for valid source format details.
3177 3177
3178 3178 .. container:: verbose
3179 3179
3180 3180 With -B/--bookmarks, the result of bookmark comparison between
3181 3181 local and remote repositories is displayed. With -v/--verbose,
3182 3182 status is also displayed for each bookmark like below::
3183 3183
3184 3184 BM1 01234567890a added
3185 3185 BM2 1234567890ab advanced
3186 3186 BM3 234567890abc diverged
3187 3187 BM4 34567890abcd changed
3188 3188
3189 3189 The action taken locally when pulling depends on the
3190 3190 status of each bookmark:
3191 3191
3192 3192 :``added``: pull will create it
3193 3193 :``advanced``: pull will update it
3194 3194 :``diverged``: pull will create a divergent bookmark
3195 3195 :``changed``: result depends on remote changesets
3196 3196
3197 3197 From the point of view of pulling behavior, bookmark
3198 3198 existing only in the remote repository are treated as ``added``,
3199 3199 even if it is in fact locally deleted.
3200 3200
3201 3201 .. container:: verbose
3202 3202
3203 3203 For remote repository, using --bundle avoids downloading the
3204 3204 changesets twice if the incoming is followed by a pull.
3205 3205
3206 3206 Examples:
3207 3207
3208 3208 - show incoming changes with patches and full description::
3209 3209
3210 3210 hg incoming -vp
3211 3211
3212 3212 - show incoming changes excluding merges, store a bundle::
3213 3213
3214 3214 hg in -vpM --bundle incoming.hg
3215 3215 hg pull incoming.hg
3216 3216
3217 3217 - briefly list changes inside a bundle::
3218 3218
3219 3219 hg in changes.hg -T "{desc|firstline}\\n"
3220 3220
3221 3221 Returns 0 if there are incoming changes, 1 otherwise.
3222 3222 """
3223 3223 opts = pycompat.byteskwargs(opts)
3224 3224 if opts.get('graph'):
3225 3225 logcmdutil.checkunsupportedgraphflags([], opts)
3226 3226 def display(other, chlist, displayer):
3227 3227 revdag = logcmdutil.graphrevs(other, chlist, opts)
3228 3228 logcmdutil.displaygraph(ui, repo, revdag, displayer,
3229 3229 graphmod.asciiedges)
3230 3230
3231 3231 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
3232 3232 return 0
3233 3233
3234 3234 if opts.get('bundle') and opts.get('subrepos'):
3235 3235 raise error.Abort(_('cannot combine --bundle and --subrepos'))
3236 3236
3237 3237 if opts.get('bookmarks'):
3238 3238 source, branches = hg.parseurl(ui.expandpath(source),
3239 3239 opts.get('branch'))
3240 3240 other = hg.peer(repo, opts, source)
3241 3241 if 'bookmarks' not in other.listkeys('namespaces'):
3242 3242 ui.warn(_("remote doesn't support bookmarks\n"))
3243 3243 return 0
3244 3244 ui.pager('incoming')
3245 3245 ui.status(_('comparing with %s\n') % util.hidepassword(source))
3246 3246 return bookmarks.incoming(ui, repo, other)
3247 3247
3248 3248 repo._subtoppath = ui.expandpath(source)
3249 3249 try:
3250 3250 return hg.incoming(ui, repo, source, opts)
3251 3251 finally:
3252 3252 del repo._subtoppath
3253 3253
3254 3254
3255 3255 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
3256 3256 norepo=True)
3257 3257 def init(ui, dest=".", **opts):
3258 3258 """create a new repository in the given directory
3259 3259
3260 3260 Initialize a new repository in the given directory. If the given
3261 3261 directory does not exist, it will be created.
3262 3262
3263 3263 If no directory is given, the current directory is used.
3264 3264
3265 3265 It is possible to specify an ``ssh://`` URL as the destination.
3266 3266 See :hg:`help urls` for more information.
3267 3267
3268 3268 Returns 0 on success.
3269 3269 """
3270 3270 opts = pycompat.byteskwargs(opts)
3271 3271 hg.peer(ui, opts, ui.expandpath(dest), create=True)
3272 3272
3273 3273 @command('locate',
3274 3274 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3275 3275 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3276 3276 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
3277 3277 ] + walkopts,
3278 3278 _('[OPTION]... [PATTERN]...'))
3279 3279 def locate(ui, repo, *pats, **opts):
3280 3280 """locate files matching specific patterns (DEPRECATED)
3281 3281
3282 3282 Print files under Mercurial control in the working directory whose
3283 3283 names match the given patterns.
3284 3284
3285 3285 By default, this command searches all directories in the working
3286 3286 directory. To search just the current directory and its
3287 3287 subdirectories, use "--include .".
3288 3288
3289 3289 If no patterns are given to match, this command prints the names
3290 3290 of all files under Mercurial control in the working directory.
3291 3291
3292 3292 If you want to feed the output of this command into the "xargs"
3293 3293 command, use the -0 option to both this command and "xargs". This
3294 3294 will avoid the problem of "xargs" treating single filenames that
3295 3295 contain whitespace as multiple filenames.
3296 3296
3297 3297 See :hg:`help files` for a more versatile command.
3298 3298
3299 3299 Returns 0 if a match is found, 1 otherwise.
3300 3300 """
3301 3301 opts = pycompat.byteskwargs(opts)
3302 3302 if opts.get('print0'):
3303 3303 end = '\0'
3304 3304 else:
3305 3305 end = '\n'
3306 3306 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3307 3307
3308 3308 ret = 1
3309 3309 m = scmutil.match(ctx, pats, opts, default='relglob',
3310 3310 badfn=lambda x, y: False)
3311 3311
3312 3312 ui.pager('locate')
3313 3313 for abs in ctx.matches(m):
3314 3314 if opts.get('fullpath'):
3315 3315 ui.write(repo.wjoin(abs), end)
3316 3316 else:
3317 3317 ui.write(((pats and m.rel(abs)) or abs), end)
3318 3318 ret = 0
3319 3319
3320 3320 return ret
3321 3321
3322 3322 @command('^log|history',
3323 3323 [('f', 'follow', None,
3324 3324 _('follow changeset history, or file history across copies and renames')),
3325 3325 ('', 'follow-first', None,
3326 3326 _('only follow the first parent of merge changesets (DEPRECATED)')),
3327 3327 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
3328 3328 ('C', 'copies', None, _('show copied files')),
3329 3329 ('k', 'keyword', [],
3330 3330 _('do case-insensitive search for a given text'), _('TEXT')),
3331 3331 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
3332 3332 ('L', 'line-range', [],
3333 3333 _('follow line range of specified file (EXPERIMENTAL)'),
3334 3334 _('FILE,RANGE')),
3335 3335 ('', 'removed', None, _('include revisions where files were removed')),
3336 3336 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
3337 3337 ('u', 'user', [], _('revisions committed by user'), _('USER')),
3338 3338 ('', 'only-branch', [],
3339 3339 _('show only changesets within the given named branch (DEPRECATED)'),
3340 3340 _('BRANCH')),
3341 3341 ('b', 'branch', [],
3342 3342 _('show changesets within the given named branch'), _('BRANCH')),
3343 3343 ('P', 'prune', [],
3344 3344 _('do not display revision or any of its ancestors'), _('REV')),
3345 3345 ] + logopts + walkopts,
3346 3346 _('[OPTION]... [FILE]'),
3347 3347 inferrepo=True,
3348 3348 intents={INTENT_READONLY})
3349 3349 def log(ui, repo, *pats, **opts):
3350 3350 """show revision history of entire repository or files
3351 3351
3352 3352 Print the revision history of the specified files or the entire
3353 3353 project.
3354 3354
3355 3355 If no revision range is specified, the default is ``tip:0`` unless
3356 3356 --follow is set, in which case the working directory parent is
3357 3357 used as the starting revision.
3358 3358
3359 3359 File history is shown without following rename or copy history of
3360 3360 files. Use -f/--follow with a filename to follow history across
3361 3361 renames and copies. --follow without a filename will only show
3362 3362 ancestors of the starting revision.
3363 3363
3364 3364 By default this command prints revision number and changeset id,
3365 3365 tags, non-trivial parents, user, date and time, and a summary for
3366 3366 each commit. When the -v/--verbose switch is used, the list of
3367 3367 changed files and full commit message are shown.
3368 3368
3369 3369 With --graph the revisions are shown as an ASCII art DAG with the most
3370 3370 recent changeset at the top.
3371 3371 'o' is a changeset, '@' is a working directory parent, '_' closes a branch,
3372 3372 'x' is obsolete, '*' is unstable, and '+' represents a fork where the
3373 3373 changeset from the lines below is a parent of the 'o' merge on the same
3374 3374 line.
3375 3375 Paths in the DAG are represented with '|', '/' and so forth. ':' in place
3376 3376 of a '|' indicates one or more revisions in a path are omitted.
3377 3377
3378 3378 .. container:: verbose
3379 3379
3380 3380 Use -L/--line-range FILE,M:N options to follow the history of lines
3381 3381 from M to N in FILE. With -p/--patch only diff hunks affecting
3382 3382 specified line range will be shown. This option requires --follow;
3383 3383 it can be specified multiple times. Currently, this option is not
3384 3384 compatible with --graph. This option is experimental.
3385 3385
3386 3386 .. note::
3387 3387
3388 3388 :hg:`log --patch` may generate unexpected diff output for merge
3389 3389 changesets, as it will only compare the merge changeset against
3390 3390 its first parent. Also, only files different from BOTH parents
3391 3391 will appear in files:.
3392 3392
3393 3393 .. note::
3394 3394
3395 3395 For performance reasons, :hg:`log FILE` may omit duplicate changes
3396 3396 made on branches and will not show removals or mode changes. To
3397 3397 see all such changes, use the --removed switch.
3398 3398
3399 3399 .. container:: verbose
3400 3400
3401 3401 .. note::
3402 3402
3403 3403 The history resulting from -L/--line-range options depends on diff
3404 3404 options; for instance if white-spaces are ignored, respective changes
3405 3405 with only white-spaces in specified line range will not be listed.
3406 3406
3407 3407 .. container:: verbose
3408 3408
3409 3409 Some examples:
3410 3410
3411 3411 - changesets with full descriptions and file lists::
3412 3412
3413 3413 hg log -v
3414 3414
3415 3415 - changesets ancestral to the working directory::
3416 3416
3417 3417 hg log -f
3418 3418
3419 3419 - last 10 commits on the current branch::
3420 3420
3421 3421 hg log -l 10 -b .
3422 3422
3423 3423 - changesets showing all modifications of a file, including removals::
3424 3424
3425 3425 hg log --removed file.c
3426 3426
3427 3427 - all changesets that touch a directory, with diffs, excluding merges::
3428 3428
3429 3429 hg log -Mp lib/
3430 3430
3431 3431 - all revision numbers that match a keyword::
3432 3432
3433 3433 hg log -k bug --template "{rev}\\n"
3434 3434
3435 3435 - the full hash identifier of the working directory parent::
3436 3436
3437 3437 hg log -r . --template "{node}\\n"
3438 3438
3439 3439 - list available log templates::
3440 3440
3441 3441 hg log -T list
3442 3442
3443 3443 - check if a given changeset is included in a tagged release::
3444 3444
3445 3445 hg log -r "a21ccf and ancestor(1.9)"
3446 3446
3447 3447 - find all changesets by some user in a date range::
3448 3448
3449 3449 hg log -k alice -d "may 2008 to jul 2008"
3450 3450
3451 3451 - summary of all changesets after the last tag::
3452 3452
3453 3453 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
3454 3454
3455 3455 - changesets touching lines 13 to 23 for file.c::
3456 3456
3457 3457 hg log -L file.c,13:23
3458 3458
3459 3459 - changesets touching lines 13 to 23 for file.c and lines 2 to 6 of
3460 3460 main.c with patch::
3461 3461
3462 3462 hg log -L file.c,13:23 -L main.c,2:6 -p
3463 3463
3464 3464 See :hg:`help dates` for a list of formats valid for -d/--date.
3465 3465
3466 3466 See :hg:`help revisions` for more about specifying and ordering
3467 3467 revisions.
3468 3468
3469 3469 See :hg:`help templates` for more about pre-packaged styles and
3470 3470 specifying custom templates. The default template used by the log
3471 3471 command can be customized via the ``ui.logtemplate`` configuration
3472 3472 setting.
3473 3473
3474 3474 Returns 0 on success.
3475 3475
3476 3476 """
3477 3477 opts = pycompat.byteskwargs(opts)
3478 3478 linerange = opts.get('line_range')
3479 3479
3480 3480 if linerange and not opts.get('follow'):
3481 3481 raise error.Abort(_('--line-range requires --follow'))
3482 3482
3483 3483 if linerange and pats:
3484 3484 # TODO: take pats as patterns with no line-range filter
3485 3485 raise error.Abort(
3486 3486 _('FILE arguments are not compatible with --line-range option')
3487 3487 )
3488 3488
3489 3489 repo = scmutil.unhidehashlikerevs(repo, opts.get('rev'), 'nowarn')
3490 3490 revs, differ = logcmdutil.getrevs(repo, pats, opts)
3491 3491 if linerange:
3492 3492 # TODO: should follow file history from logcmdutil._initialrevs(),
3493 3493 # then filter the result by logcmdutil._makerevset() and --limit
3494 3494 revs, differ = logcmdutil.getlinerangerevs(repo, revs, opts)
3495 3495
3496 3496 getrenamed = None
3497 3497 if opts.get('copies'):
3498 3498 endrev = None
3499 3499 if revs:
3500 3500 endrev = revs.max() + 1
3501 3501 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
3502 3502
3503 3503 ui.pager('log')
3504 3504 displayer = logcmdutil.changesetdisplayer(ui, repo, opts, differ,
3505 3505 buffered=True)
3506 3506 if opts.get('graph'):
3507 3507 displayfn = logcmdutil.displaygraphrevs
3508 3508 else:
3509 3509 displayfn = logcmdutil.displayrevs
3510 3510 displayfn(ui, repo, revs, displayer, getrenamed)
3511 3511
3512 3512 @command('manifest',
3513 3513 [('r', 'rev', '', _('revision to display'), _('REV')),
3514 3514 ('', 'all', False, _("list files from all revisions"))]
3515 3515 + formatteropts,
3516 3516 _('[-r REV]'),
3517 3517 intents={INTENT_READONLY})
3518 3518 def manifest(ui, repo, node=None, rev=None, **opts):
3519 3519 """output the current or given revision of the project manifest
3520 3520
3521 3521 Print a list of version controlled files for the given revision.
3522 3522 If no revision is given, the first parent of the working directory
3523 3523 is used, or the null revision if no revision is checked out.
3524 3524
3525 3525 With -v, print file permissions, symlink and executable bits.
3526 3526 With --debug, print file revision hashes.
3527 3527
3528 3528 If option --all is specified, the list of all files from all revisions
3529 3529 is printed. This includes deleted and renamed files.
3530 3530
3531 3531 Returns 0 on success.
3532 3532 """
3533 3533 opts = pycompat.byteskwargs(opts)
3534 3534 fm = ui.formatter('manifest', opts)
3535 3535
3536 3536 if opts.get('all'):
3537 3537 if rev or node:
3538 3538 raise error.Abort(_("can't specify a revision with --all"))
3539 3539
3540 3540 res = set()
3541 3541 for rev in repo:
3542 3542 ctx = repo[rev]
3543 3543 res |= set(ctx.files())
3544 3544
3545 3545 ui.pager('manifest')
3546 3546 for f in sorted(res):
3547 3547 fm.startitem()
3548 3548 fm.write("path", '%s\n', f)
3549 3549 fm.end()
3550 3550 return
3551 3551
3552 3552 if rev and node:
3553 3553 raise error.Abort(_("please specify just one revision"))
3554 3554
3555 3555 if not node:
3556 3556 node = rev
3557 3557
3558 3558 char = {'l': '@', 'x': '*', '': '', 't': 'd'}
3559 3559 mode = {'l': '644', 'x': '755', '': '644', 't': '755'}
3560 3560 if node:
3561 3561 repo = scmutil.unhidehashlikerevs(repo, [node], 'nowarn')
3562 3562 ctx = scmutil.revsingle(repo, node)
3563 3563 mf = ctx.manifest()
3564 3564 ui.pager('manifest')
3565 3565 for f in ctx:
3566 3566 fm.startitem()
3567 3567 fl = ctx[f].flags()
3568 3568 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
3569 3569 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
3570 3570 fm.write('path', '%s\n', f)
3571 3571 fm.end()
3572 3572
3573 3573 @command('^merge',
3574 3574 [('f', 'force', None,
3575 3575 _('force a merge including outstanding changes (DEPRECATED)')),
3576 3576 ('r', 'rev', '', _('revision to merge'), _('REV')),
3577 3577 ('P', 'preview', None,
3578 3578 _('review revisions to merge (no merge is performed)')),
3579 3579 ('', 'abort', None, _('abort the ongoing merge')),
3580 3580 ] + mergetoolopts,
3581 3581 _('[-P] [[-r] REV]'))
3582 3582 def merge(ui, repo, node=None, **opts):
3583 3583 """merge another revision into working directory
3584 3584
3585 3585 The current working directory is updated with all changes made in
3586 3586 the requested revision since the last common predecessor revision.
3587 3587
3588 3588 Files that changed between either parent are marked as changed for
3589 3589 the next commit and a commit must be performed before any further
3590 3590 updates to the repository are allowed. The next commit will have
3591 3591 two parents.
3592 3592
3593 3593 ``--tool`` can be used to specify the merge tool used for file
3594 3594 merges. It overrides the HGMERGE environment variable and your
3595 3595 configuration files. See :hg:`help merge-tools` for options.
3596 3596
3597 3597 If no revision is specified, the working directory's parent is a
3598 3598 head revision, and the current branch contains exactly one other
3599 3599 head, the other head is merged with by default. Otherwise, an
3600 3600 explicit revision with which to merge with must be provided.
3601 3601
3602 3602 See :hg:`help resolve` for information on handling file conflicts.
3603 3603
3604 3604 To undo an uncommitted merge, use :hg:`merge --abort` which
3605 3605 will check out a clean copy of the original merge parent, losing
3606 3606 all changes.
3607 3607
3608 3608 Returns 0 on success, 1 if there are unresolved files.
3609 3609 """
3610 3610
3611 3611 opts = pycompat.byteskwargs(opts)
3612 3612 abort = opts.get('abort')
3613 3613 if abort and repo.dirstate.p2() == nullid:
3614 3614 cmdutil.wrongtooltocontinue(repo, _('merge'))
3615 3615 if abort:
3616 3616 if node:
3617 3617 raise error.Abort(_("cannot specify a node with --abort"))
3618 3618 if opts.get('rev'):
3619 3619 raise error.Abort(_("cannot specify both --rev and --abort"))
3620 3620 if opts.get('preview'):
3621 3621 raise error.Abort(_("cannot specify --preview with --abort"))
3622 3622 if opts.get('rev') and node:
3623 3623 raise error.Abort(_("please specify just one revision"))
3624 3624 if not node:
3625 3625 node = opts.get('rev')
3626 3626
3627 3627 if node:
3628 3628 node = scmutil.revsingle(repo, node).node()
3629 3629
3630 3630 if not node and not abort:
3631 3631 node = repo[destutil.destmerge(repo)].node()
3632 3632
3633 3633 if opts.get('preview'):
3634 3634 # find nodes that are ancestors of p2 but not of p1
3635 3635 p1 = repo.lookup('.')
3636 3636 p2 = node
3637 3637 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
3638 3638
3639 3639 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
3640 3640 for node in nodes:
3641 3641 displayer.show(repo[node])
3642 3642 displayer.close()
3643 3643 return 0
3644 3644
3645 3645 try:
3646 3646 # ui.forcemerge is an internal variable, do not document
3647 3647 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
3648 3648 force = opts.get('force')
3649 3649 labels = ['working copy', 'merge rev']
3650 3650 return hg.merge(repo, node, force=force, mergeforce=force,
3651 3651 labels=labels, abort=abort)
3652 3652 finally:
3653 3653 ui.setconfig('ui', 'forcemerge', '', 'merge')
3654 3654
3655 3655 @command('outgoing|out',
3656 3656 [('f', 'force', None, _('run even when the destination is unrelated')),
3657 3657 ('r', 'rev', [],
3658 3658 _('a changeset intended to be included in the destination'), _('REV')),
3659 3659 ('n', 'newest-first', None, _('show newest record first')),
3660 3660 ('B', 'bookmarks', False, _('compare bookmarks')),
3661 3661 ('b', 'branch', [], _('a specific branch you would like to push'),
3662 3662 _('BRANCH')),
3663 3663 ] + logopts + remoteopts + subrepoopts,
3664 3664 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
3665 3665 def outgoing(ui, repo, dest=None, **opts):
3666 3666 """show changesets not found in the destination
3667 3667
3668 3668 Show changesets not found in the specified destination repository
3669 3669 or the default push location. These are the changesets that would
3670 3670 be pushed if a push was requested.
3671 3671
3672 3672 See pull for details of valid destination formats.
3673 3673
3674 3674 .. container:: verbose
3675 3675
3676 3676 With -B/--bookmarks, the result of bookmark comparison between
3677 3677 local and remote repositories is displayed. With -v/--verbose,
3678 3678 status is also displayed for each bookmark like below::
3679 3679
3680 3680 BM1 01234567890a added
3681 3681 BM2 deleted
3682 3682 BM3 234567890abc advanced
3683 3683 BM4 34567890abcd diverged
3684 3684 BM5 4567890abcde changed
3685 3685
3686 3686 The action taken when pushing depends on the
3687 3687 status of each bookmark:
3688 3688
3689 3689 :``added``: push with ``-B`` will create it
3690 3690 :``deleted``: push with ``-B`` will delete it
3691 3691 :``advanced``: push will update it
3692 3692 :``diverged``: push with ``-B`` will update it
3693 3693 :``changed``: push with ``-B`` will update it
3694 3694
3695 3695 From the point of view of pushing behavior, bookmarks
3696 3696 existing only in the remote repository are treated as
3697 3697 ``deleted``, even if it is in fact added remotely.
3698 3698
3699 3699 Returns 0 if there are outgoing changes, 1 otherwise.
3700 3700 """
3701 3701 opts = pycompat.byteskwargs(opts)
3702 3702 if opts.get('graph'):
3703 3703 logcmdutil.checkunsupportedgraphflags([], opts)
3704 3704 o, other = hg._outgoing(ui, repo, dest, opts)
3705 3705 if not o:
3706 3706 cmdutil.outgoinghooks(ui, repo, other, opts, o)
3707 3707 return
3708 3708
3709 3709 revdag = logcmdutil.graphrevs(repo, o, opts)
3710 3710 ui.pager('outgoing')
3711 3711 displayer = logcmdutil.changesetdisplayer(ui, repo, opts, buffered=True)
3712 3712 logcmdutil.displaygraph(ui, repo, revdag, displayer,
3713 3713 graphmod.asciiedges)
3714 3714 cmdutil.outgoinghooks(ui, repo, other, opts, o)
3715 3715 return 0
3716 3716
3717 3717 if opts.get('bookmarks'):
3718 3718 dest = ui.expandpath(dest or 'default-push', dest or 'default')
3719 3719 dest, branches = hg.parseurl(dest, opts.get('branch'))
3720 3720 other = hg.peer(repo, opts, dest)
3721 3721 if 'bookmarks' not in other.listkeys('namespaces'):
3722 3722 ui.warn(_("remote doesn't support bookmarks\n"))
3723 3723 return 0
3724 3724 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
3725 3725 ui.pager('outgoing')
3726 3726 return bookmarks.outgoing(ui, repo, other)
3727 3727
3728 3728 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
3729 3729 try:
3730 3730 return hg.outgoing(ui, repo, dest, opts)
3731 3731 finally:
3732 3732 del repo._subtoppath
3733 3733
3734 3734 @command('parents',
3735 3735 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
3736 3736 ] + templateopts,
3737 3737 _('[-r REV] [FILE]'),
3738 3738 inferrepo=True)
3739 3739 def parents(ui, repo, file_=None, **opts):
3740 3740 """show the parents of the working directory or revision (DEPRECATED)
3741 3741
3742 3742 Print the working directory's parent revisions. If a revision is
3743 3743 given via -r/--rev, the parent of that revision will be printed.
3744 3744 If a file argument is given, the revision in which the file was
3745 3745 last changed (before the working directory revision or the
3746 3746 argument to --rev if given) is printed.
3747 3747
3748 3748 This command is equivalent to::
3749 3749
3750 3750 hg log -r "p1()+p2()" or
3751 3751 hg log -r "p1(REV)+p2(REV)" or
3752 3752 hg log -r "max(::p1() and file(FILE))+max(::p2() and file(FILE))" or
3753 3753 hg log -r "max(::p1(REV) and file(FILE))+max(::p2(REV) and file(FILE))"
3754 3754
3755 3755 See :hg:`summary` and :hg:`help revsets` for related information.
3756 3756
3757 3757 Returns 0 on success.
3758 3758 """
3759 3759
3760 3760 opts = pycompat.byteskwargs(opts)
3761 3761 rev = opts.get('rev')
3762 3762 if rev:
3763 3763 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
3764 3764 ctx = scmutil.revsingle(repo, rev, None)
3765 3765
3766 3766 if file_:
3767 3767 m = scmutil.match(ctx, (file_,), opts)
3768 3768 if m.anypats() or len(m.files()) != 1:
3769 3769 raise error.Abort(_('can only specify an explicit filename'))
3770 3770 file_ = m.files()[0]
3771 3771 filenodes = []
3772 3772 for cp in ctx.parents():
3773 3773 if not cp:
3774 3774 continue
3775 3775 try:
3776 3776 filenodes.append(cp.filenode(file_))
3777 3777 except error.LookupError:
3778 3778 pass
3779 3779 if not filenodes:
3780 3780 raise error.Abort(_("'%s' not found in manifest!") % file_)
3781 3781 p = []
3782 3782 for fn in filenodes:
3783 3783 fctx = repo.filectx(file_, fileid=fn)
3784 3784 p.append(fctx.node())
3785 3785 else:
3786 3786 p = [cp.node() for cp in ctx.parents()]
3787 3787
3788 3788 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
3789 3789 for n in p:
3790 3790 if n != nullid:
3791 3791 displayer.show(repo[n])
3792 3792 displayer.close()
3793 3793
3794 3794 @command('paths', formatteropts, _('[NAME]'), optionalrepo=True,
3795 3795 intents={INTENT_READONLY})
3796 3796 def paths(ui, repo, search=None, **opts):
3797 3797 """show aliases for remote repositories
3798 3798
3799 3799 Show definition of symbolic path name NAME. If no name is given,
3800 3800 show definition of all available names.
3801 3801
3802 3802 Option -q/--quiet suppresses all output when searching for NAME
3803 3803 and shows only the path names when listing all definitions.
3804 3804
3805 3805 Path names are defined in the [paths] section of your
3806 3806 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
3807 3807 repository, ``.hg/hgrc`` is used, too.
3808 3808
3809 3809 The path names ``default`` and ``default-push`` have a special
3810 3810 meaning. When performing a push or pull operation, they are used
3811 3811 as fallbacks if no location is specified on the command-line.
3812 3812 When ``default-push`` is set, it will be used for push and
3813 3813 ``default`` will be used for pull; otherwise ``default`` is used
3814 3814 as the fallback for both. When cloning a repository, the clone
3815 3815 source is written as ``default`` in ``.hg/hgrc``.
3816 3816
3817 3817 .. note::
3818 3818
3819 3819 ``default`` and ``default-push`` apply to all inbound (e.g.
3820 3820 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email`
3821 3821 and :hg:`bundle`) operations.
3822 3822
3823 3823 See :hg:`help urls` for more information.
3824 3824
3825 3825 Returns 0 on success.
3826 3826 """
3827 3827
3828 3828 opts = pycompat.byteskwargs(opts)
3829 3829 ui.pager('paths')
3830 3830 if search:
3831 3831 pathitems = [(name, path) for name, path in ui.paths.iteritems()
3832 3832 if name == search]
3833 3833 else:
3834 3834 pathitems = sorted(ui.paths.iteritems())
3835 3835
3836 3836 fm = ui.formatter('paths', opts)
3837 3837 if fm.isplain():
3838 3838 hidepassword = util.hidepassword
3839 3839 else:
3840 3840 hidepassword = bytes
3841 3841 if ui.quiet:
3842 3842 namefmt = '%s\n'
3843 3843 else:
3844 3844 namefmt = '%s = '
3845 3845 showsubopts = not search and not ui.quiet
3846 3846
3847 3847 for name, path in pathitems:
3848 3848 fm.startitem()
3849 3849 fm.condwrite(not search, 'name', namefmt, name)
3850 3850 fm.condwrite(not ui.quiet, 'url', '%s\n', hidepassword(path.rawloc))
3851 3851 for subopt, value in sorted(path.suboptions.items()):
3852 3852 assert subopt not in ('name', 'url')
3853 3853 if showsubopts:
3854 3854 fm.plain('%s:%s = ' % (name, subopt))
3855 3855 fm.condwrite(showsubopts, subopt, '%s\n', value)
3856 3856
3857 3857 fm.end()
3858 3858
3859 3859 if search and not pathitems:
3860 3860 if not ui.quiet:
3861 3861 ui.warn(_("not found!\n"))
3862 3862 return 1
3863 3863 else:
3864 3864 return 0
3865 3865
3866 3866 @command('phase',
3867 3867 [('p', 'public', False, _('set changeset phase to public')),
3868 3868 ('d', 'draft', False, _('set changeset phase to draft')),
3869 3869 ('s', 'secret', False, _('set changeset phase to secret')),
3870 3870 ('f', 'force', False, _('allow to move boundary backward')),
3871 3871 ('r', 'rev', [], _('target revision'), _('REV')),
3872 3872 ],
3873 3873 _('[-p|-d|-s] [-f] [-r] [REV...]'))
3874 3874 def phase(ui, repo, *revs, **opts):
3875 3875 """set or show the current phase name
3876 3876
3877 3877 With no argument, show the phase name of the current revision(s).
3878 3878
3879 3879 With one of -p/--public, -d/--draft or -s/--secret, change the
3880 3880 phase value of the specified revisions.
3881 3881
3882 3882 Unless -f/--force is specified, :hg:`phase` won't move changesets from a
3883 3883 lower phase to a higher phase. Phases are ordered as follows::
3884 3884
3885 3885 public < draft < secret
3886 3886
3887 3887 Returns 0 on success, 1 if some phases could not be changed.
3888 3888
3889 3889 (For more information about the phases concept, see :hg:`help phases`.)
3890 3890 """
3891 3891 opts = pycompat.byteskwargs(opts)
3892 3892 # search for a unique phase argument
3893 3893 targetphase = None
3894 3894 for idx, name in enumerate(phases.phasenames):
3895 3895 if opts[name]:
3896 3896 if targetphase is not None:
3897 3897 raise error.Abort(_('only one phase can be specified'))
3898 3898 targetphase = idx
3899 3899
3900 3900 # look for specified revision
3901 3901 revs = list(revs)
3902 3902 revs.extend(opts['rev'])
3903 3903 if not revs:
3904 3904 # display both parents as the second parent phase can influence
3905 3905 # the phase of a merge commit
3906 3906 revs = [c.rev() for c in repo[None].parents()]
3907 3907
3908 3908 revs = scmutil.revrange(repo, revs)
3909 3909
3910 3910 ret = 0
3911 3911 if targetphase is None:
3912 3912 # display
3913 3913 for r in revs:
3914 3914 ctx = repo[r]
3915 3915 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
3916 3916 else:
3917 3917 with repo.lock(), repo.transaction("phase") as tr:
3918 3918 # set phase
3919 3919 if not revs:
3920 3920 raise error.Abort(_('empty revision set'))
3921 3921 nodes = [repo[r].node() for r in revs]
3922 3922 # moving revision from public to draft may hide them
3923 3923 # We have to check result on an unfiltered repository
3924 3924 unfi = repo.unfiltered()
3925 3925 getphase = unfi._phasecache.phase
3926 3926 olddata = [getphase(unfi, r) for r in unfi]
3927 3927 phases.advanceboundary(repo, tr, targetphase, nodes)
3928 3928 if opts['force']:
3929 3929 phases.retractboundary(repo, tr, targetphase, nodes)
3930 3930 getphase = unfi._phasecache.phase
3931 3931 newdata = [getphase(unfi, r) for r in unfi]
3932 3932 changes = sum(newdata[r] != olddata[r] for r in unfi)
3933 3933 cl = unfi.changelog
3934 3934 rejected = [n for n in nodes
3935 3935 if newdata[cl.rev(n)] < targetphase]
3936 3936 if rejected:
3937 3937 ui.warn(_('cannot move %i changesets to a higher '
3938 3938 'phase, use --force\n') % len(rejected))
3939 3939 ret = 1
3940 3940 if changes:
3941 3941 msg = _('phase changed for %i changesets\n') % changes
3942 3942 if ret:
3943 3943 ui.status(msg)
3944 3944 else:
3945 3945 ui.note(msg)
3946 3946 else:
3947 3947 ui.warn(_('no phases changed\n'))
3948 3948 return ret
3949 3949
3950 3950 def postincoming(ui, repo, modheads, optupdate, checkout, brev):
3951 3951 """Run after a changegroup has been added via pull/unbundle
3952 3952
3953 3953 This takes arguments below:
3954 3954
3955 3955 :modheads: change of heads by pull/unbundle
3956 3956 :optupdate: updating working directory is needed or not
3957 3957 :checkout: update destination revision (or None to default destination)
3958 3958 :brev: a name, which might be a bookmark to be activated after updating
3959 3959 """
3960 3960 if modheads == 0:
3961 3961 return
3962 3962 if optupdate:
3963 3963 try:
3964 3964 return hg.updatetotally(ui, repo, checkout, brev)
3965 3965 except error.UpdateAbort as inst:
3966 3966 msg = _("not updating: %s") % stringutil.forcebytestr(inst)
3967 3967 hint = inst.hint
3968 3968 raise error.UpdateAbort(msg, hint=hint)
3969 3969 if modheads > 1:
3970 3970 currentbranchheads = len(repo.branchheads())
3971 3971 if currentbranchheads == modheads:
3972 3972 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
3973 3973 elif currentbranchheads > 1:
3974 3974 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
3975 3975 "merge)\n"))
3976 3976 else:
3977 3977 ui.status(_("(run 'hg heads' to see heads)\n"))
3978 3978 elif not ui.configbool('commands', 'update.requiredest'):
3979 3979 ui.status(_("(run 'hg update' to get a working copy)\n"))
3980 3980
3981 3981 @command('^pull',
3982 3982 [('u', 'update', None,
3983 3983 _('update to new branch head if new descendants were pulled')),
3984 3984 ('f', 'force', None, _('run even when remote repository is unrelated')),
3985 3985 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
3986 3986 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
3987 3987 ('b', 'branch', [], _('a specific branch you would like to pull'),
3988 3988 _('BRANCH')),
3989 3989 ] + remoteopts,
3990 3990 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
3991 3991 def pull(ui, repo, source="default", **opts):
3992 3992 """pull changes from the specified source
3993 3993
3994 3994 Pull changes from a remote repository to a local one.
3995 3995
3996 3996 This finds all changes from the repository at the specified path
3997 3997 or URL and adds them to a local repository (the current one unless
3998 3998 -R is specified). By default, this does not update the copy of the
3999 3999 project in the working directory.
4000 4000
4001 4001 When cloning from servers that support it, Mercurial may fetch
4002 4002 pre-generated data. When this is done, hooks operating on incoming
4003 4003 changesets and changegroups may fire more than once, once for each
4004 4004 pre-generated bundle and as well as for any additional remaining
4005 4005 data. See :hg:`help -e clonebundles` for more.
4006 4006
4007 4007 Use :hg:`incoming` if you want to see what would have been added
4008 4008 by a pull at the time you issued this command. If you then decide
4009 4009 to add those changes to the repository, you should use :hg:`pull
4010 4010 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
4011 4011
4012 4012 If SOURCE is omitted, the 'default' path will be used.
4013 4013 See :hg:`help urls` for more information.
4014 4014
4015 4015 Specifying bookmark as ``.`` is equivalent to specifying the active
4016 4016 bookmark's name.
4017 4017
4018 4018 Returns 0 on success, 1 if an update had unresolved files.
4019 4019 """
4020 4020
4021 4021 opts = pycompat.byteskwargs(opts)
4022 4022 if ui.configbool('commands', 'update.requiredest') and opts.get('update'):
4023 4023 msg = _('update destination required by configuration')
4024 4024 hint = _('use hg pull followed by hg update DEST')
4025 4025 raise error.Abort(msg, hint=hint)
4026 4026
4027 4027 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
4028 4028 ui.status(_('pulling from %s\n') % util.hidepassword(source))
4029 4029 other = hg.peer(repo, opts, source)
4030 4030 try:
4031 4031 revs, checkout = hg.addbranchrevs(repo, other, branches,
4032 4032 opts.get('rev'))
4033 4033
4034 4034
4035 4035 pullopargs = {}
4036 4036 if opts.get('bookmark'):
4037 4037 if not revs:
4038 4038 revs = []
4039 4039 # The list of bookmark used here is not the one used to actually
4040 4040 # update the bookmark name. This can result in the revision pulled
4041 4041 # not ending up with the name of the bookmark because of a race
4042 4042 # condition on the server. (See issue 4689 for details)
4043 4043 remotebookmarks = other.listkeys('bookmarks')
4044 4044 remotebookmarks = bookmarks.unhexlifybookmarks(remotebookmarks)
4045 4045 pullopargs['remotebookmarks'] = remotebookmarks
4046 4046 for b in opts['bookmark']:
4047 4047 b = repo._bookmarks.expandname(b)
4048 4048 if b not in remotebookmarks:
4049 4049 raise error.Abort(_('remote bookmark %s not found!') % b)
4050 4050 revs.append(hex(remotebookmarks[b]))
4051 4051
4052 4052 if revs:
4053 4053 try:
4054 4054 # When 'rev' is a bookmark name, we cannot guarantee that it
4055 4055 # will be updated with that name because of a race condition
4056 4056 # server side. (See issue 4689 for details)
4057 4057 oldrevs = revs
4058 4058 revs = [] # actually, nodes
4059 4059 for r in oldrevs:
4060 4060 with other.commandexecutor() as e:
4061 4061 node = e.callcommand('lookup', {'key': r}).result()
4062 4062
4063 4063 revs.append(node)
4064 4064 if r == checkout:
4065 4065 checkout = node
4066 4066 except error.CapabilityError:
4067 4067 err = _("other repository doesn't support revision lookup, "
4068 4068 "so a rev cannot be specified.")
4069 4069 raise error.Abort(err)
4070 4070
4071 4071 wlock = util.nullcontextmanager()
4072 4072 if opts.get('update'):
4073 4073 wlock = repo.wlock()
4074 4074 with wlock:
4075 4075 pullopargs.update(opts.get('opargs', {}))
4076 4076 modheads = exchange.pull(repo, other, heads=revs,
4077 4077 force=opts.get('force'),
4078 4078 bookmarks=opts.get('bookmark', ()),
4079 4079 opargs=pullopargs).cgresult
4080 4080
4081 4081 # brev is a name, which might be a bookmark to be activated at
4082 4082 # the end of the update. In other words, it is an explicit
4083 4083 # destination of the update
4084 4084 brev = None
4085 4085
4086 4086 if checkout:
4087 4087 checkout = repo.changelog.rev(checkout)
4088 4088
4089 4089 # order below depends on implementation of
4090 4090 # hg.addbranchrevs(). opts['bookmark'] is ignored,
4091 4091 # because 'checkout' is determined without it.
4092 4092 if opts.get('rev'):
4093 4093 brev = opts['rev'][0]
4094 4094 elif opts.get('branch'):
4095 4095 brev = opts['branch'][0]
4096 4096 else:
4097 4097 brev = branches[0]
4098 4098 repo._subtoppath = source
4099 4099 try:
4100 4100 ret = postincoming(ui, repo, modheads, opts.get('update'),
4101 4101 checkout, brev)
4102 4102
4103 4103 finally:
4104 4104 del repo._subtoppath
4105 4105
4106 4106 finally:
4107 4107 other.close()
4108 4108 return ret
4109 4109
4110 4110 @command('^push',
4111 4111 [('f', 'force', None, _('force push')),
4112 4112 ('r', 'rev', [],
4113 4113 _('a changeset intended to be included in the destination'),
4114 4114 _('REV')),
4115 4115 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
4116 4116 ('b', 'branch', [],
4117 4117 _('a specific branch you would like to push'), _('BRANCH')),
4118 4118 ('', 'new-branch', False, _('allow pushing a new branch')),
4119 4119 ('', 'pushvars', [], _('variables that can be sent to server (ADVANCED)')),
4120 4120 ] + remoteopts,
4121 4121 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
4122 4122 def push(ui, repo, dest=None, **opts):
4123 4123 """push changes to the specified destination
4124 4124
4125 4125 Push changesets from the local repository to the specified
4126 4126 destination.
4127 4127
4128 4128 This operation is symmetrical to pull: it is identical to a pull
4129 4129 in the destination repository from the current one.
4130 4130
4131 4131 By default, push will not allow creation of new heads at the
4132 4132 destination, since multiple heads would make it unclear which head
4133 4133 to use. In this situation, it is recommended to pull and merge
4134 4134 before pushing.
4135 4135
4136 4136 Use --new-branch if you want to allow push to create a new named
4137 4137 branch that is not present at the destination. This allows you to
4138 4138 only create a new branch without forcing other changes.
4139 4139
4140 4140 .. note::
4141 4141
4142 4142 Extra care should be taken with the -f/--force option,
4143 4143 which will push all new heads on all branches, an action which will
4144 4144 almost always cause confusion for collaborators.
4145 4145
4146 4146 If -r/--rev is used, the specified revision and all its ancestors
4147 4147 will be pushed to the remote repository.
4148 4148
4149 4149 If -B/--bookmark is used, the specified bookmarked revision, its
4150 4150 ancestors, and the bookmark will be pushed to the remote
4151 4151 repository. Specifying ``.`` is equivalent to specifying the active
4152 4152 bookmark's name.
4153 4153
4154 4154 Please see :hg:`help urls` for important details about ``ssh://``
4155 4155 URLs. If DESTINATION is omitted, a default path will be used.
4156 4156
4157 4157 .. container:: verbose
4158 4158
4159 4159 The --pushvars option sends strings to the server that become
4160 4160 environment variables prepended with ``HG_USERVAR_``. For example,
4161 4161 ``--pushvars ENABLE_FEATURE=true``, provides the server side hooks with
4162 4162 ``HG_USERVAR_ENABLE_FEATURE=true`` as part of their environment.
4163 4163
4164 4164 pushvars can provide for user-overridable hooks as well as set debug
4165 4165 levels. One example is having a hook that blocks commits containing
4166 4166 conflict markers, but enables the user to override the hook if the file
4167 4167 is using conflict markers for testing purposes or the file format has
4168 4168 strings that look like conflict markers.
4169 4169
4170 4170 By default, servers will ignore `--pushvars`. To enable it add the
4171 4171 following to your configuration file::
4172 4172
4173 4173 [push]
4174 4174 pushvars.server = true
4175 4175
4176 4176 Returns 0 if push was successful, 1 if nothing to push.
4177 4177 """
4178 4178
4179 4179 opts = pycompat.byteskwargs(opts)
4180 4180 if opts.get('bookmark'):
4181 4181 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
4182 4182 for b in opts['bookmark']:
4183 4183 # translate -B options to -r so changesets get pushed
4184 4184 b = repo._bookmarks.expandname(b)
4185 4185 if b in repo._bookmarks:
4186 4186 opts.setdefault('rev', []).append(b)
4187 4187 else:
4188 4188 # if we try to push a deleted bookmark, translate it to null
4189 4189 # this lets simultaneous -r, -b options continue working
4190 4190 opts.setdefault('rev', []).append("null")
4191 4191
4192 4192 path = ui.paths.getpath(dest, default=('default-push', 'default'))
4193 4193 if not path:
4194 4194 raise error.Abort(_('default repository not configured!'),
4195 4195 hint=_("see 'hg help config.paths'"))
4196 4196 dest = path.pushloc or path.loc
4197 4197 branches = (path.branch, opts.get('branch') or [])
4198 4198 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
4199 4199 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
4200 4200 other = hg.peer(repo, opts, dest)
4201 4201
4202 4202 if revs:
4203 4203 revs = [repo[r].node() for r in scmutil.revrange(repo, revs)]
4204 4204 if not revs:
4205 4205 raise error.Abort(_("specified revisions evaluate to an empty set"),
4206 4206 hint=_("use different revision arguments"))
4207 4207 elif path.pushrev:
4208 4208 # It doesn't make any sense to specify ancestor revisions. So limit
4209 4209 # to DAG heads to make discovery simpler.
4210 4210 expr = revsetlang.formatspec('heads(%r)', path.pushrev)
4211 4211 revs = scmutil.revrange(repo, [expr])
4212 4212 revs = [repo[rev].node() for rev in revs]
4213 4213 if not revs:
4214 4214 raise error.Abort(_('default push revset for path evaluates to an '
4215 4215 'empty set'))
4216 4216
4217 4217 repo._subtoppath = dest
4218 4218 try:
4219 4219 # push subrepos depth-first for coherent ordering
4220 4220 c = repo['.']
4221 4221 subs = c.substate # only repos that are committed
4222 4222 for s in sorted(subs):
4223 4223 result = c.sub(s).push(opts)
4224 4224 if result == 0:
4225 4225 return not result
4226 4226 finally:
4227 4227 del repo._subtoppath
4228 4228
4229 4229 opargs = dict(opts.get('opargs', {})) # copy opargs since we may mutate it
4230 4230 opargs.setdefault('pushvars', []).extend(opts.get('pushvars', []))
4231 4231
4232 4232 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
4233 4233 newbranch=opts.get('new_branch'),
4234 4234 bookmarks=opts.get('bookmark', ()),
4235 4235 opargs=opargs)
4236 4236
4237 4237 result = not pushop.cgresult
4238 4238
4239 4239 if pushop.bkresult is not None:
4240 4240 if pushop.bkresult == 2:
4241 4241 result = 2
4242 4242 elif not result and pushop.bkresult:
4243 4243 result = 2
4244 4244
4245 4245 return result
4246 4246
4247 4247 @command('recover', [])
4248 4248 def recover(ui, repo):
4249 4249 """roll back an interrupted transaction
4250 4250
4251 4251 Recover from an interrupted commit or pull.
4252 4252
4253 4253 This command tries to fix the repository status after an
4254 4254 interrupted operation. It should only be necessary when Mercurial
4255 4255 suggests it.
4256 4256
4257 4257 Returns 0 if successful, 1 if nothing to recover or verify fails.
4258 4258 """
4259 4259 if repo.recover():
4260 4260 return hg.verify(repo)
4261 4261 return 1
4262 4262
4263 4263 @command('^remove|rm',
4264 4264 [('A', 'after', None, _('record delete for missing files')),
4265 4265 ('f', 'force', None,
4266 4266 _('forget added files, delete modified files')),
4267 4267 ] + subrepoopts + walkopts + dryrunopts,
4268 4268 _('[OPTION]... FILE...'),
4269 4269 inferrepo=True)
4270 4270 def remove(ui, repo, *pats, **opts):
4271 4271 """remove the specified files on the next commit
4272 4272
4273 4273 Schedule the indicated files for removal from the current branch.
4274 4274
4275 4275 This command schedules the files to be removed at the next commit.
4276 4276 To undo a remove before that, see :hg:`revert`. To undo added
4277 4277 files, see :hg:`forget`.
4278 4278
4279 4279 .. container:: verbose
4280 4280
4281 4281 -A/--after can be used to remove only files that have already
4282 4282 been deleted, -f/--force can be used to force deletion, and -Af
4283 4283 can be used to remove files from the next revision without
4284 4284 deleting them from the working directory.
4285 4285
4286 4286 The following table details the behavior of remove for different
4287 4287 file states (columns) and option combinations (rows). The file
4288 4288 states are Added [A], Clean [C], Modified [M] and Missing [!]
4289 4289 (as reported by :hg:`status`). The actions are Warn, Remove
4290 4290 (from branch) and Delete (from disk):
4291 4291
4292 4292 ========= == == == ==
4293 4293 opt/state A C M !
4294 4294 ========= == == == ==
4295 4295 none W RD W R
4296 4296 -f R RD RD R
4297 4297 -A W W W R
4298 4298 -Af R R R R
4299 4299 ========= == == == ==
4300 4300
4301 4301 .. note::
4302 4302
4303 4303 :hg:`remove` never deletes files in Added [A] state from the
4304 4304 working directory, not even if ``--force`` is specified.
4305 4305
4306 4306 Returns 0 on success, 1 if any warnings encountered.
4307 4307 """
4308 4308
4309 4309 opts = pycompat.byteskwargs(opts)
4310 4310 after, force = opts.get('after'), opts.get('force')
4311 4311 dryrun = opts.get('dry_run')
4312 4312 if not pats and not after:
4313 4313 raise error.Abort(_('no files specified'))
4314 4314
4315 4315 m = scmutil.match(repo[None], pats, opts)
4316 4316 subrepos = opts.get('subrepos')
4317 4317 return cmdutil.remove(ui, repo, m, "", after, force, subrepos,
4318 4318 dryrun=dryrun)
4319 4319
4320 4320 @command('rename|move|mv',
4321 4321 [('A', 'after', None, _('record a rename that has already occurred')),
4322 4322 ('f', 'force', None, _('forcibly copy over an existing managed file')),
4323 4323 ] + walkopts + dryrunopts,
4324 4324 _('[OPTION]... SOURCE... DEST'))
4325 4325 def rename(ui, repo, *pats, **opts):
4326 4326 """rename files; equivalent of copy + remove
4327 4327
4328 4328 Mark dest as copies of sources; mark sources for deletion. If dest
4329 4329 is a directory, copies are put in that directory. If dest is a
4330 4330 file, there can only be one source.
4331 4331
4332 4332 By default, this command copies the contents of files as they
4333 4333 exist in the working directory. If invoked with -A/--after, the
4334 4334 operation is recorded, but no copying is performed.
4335 4335
4336 4336 This command takes effect at the next commit. To undo a rename
4337 4337 before that, see :hg:`revert`.
4338 4338
4339 4339 Returns 0 on success, 1 if errors are encountered.
4340 4340 """
4341 4341 opts = pycompat.byteskwargs(opts)
4342 4342 with repo.wlock(False):
4343 4343 return cmdutil.copy(ui, repo, pats, opts, rename=True)
4344 4344
4345 4345 @command('resolve',
4346 4346 [('a', 'all', None, _('select all unresolved files')),
4347 4347 ('l', 'list', None, _('list state of files needing merge')),
4348 4348 ('m', 'mark', None, _('mark files as resolved')),
4349 4349 ('u', 'unmark', None, _('mark files as unresolved')),
4350 4350 ('n', 'no-status', None, _('hide status prefix'))]
4351 4351 + mergetoolopts + walkopts + formatteropts,
4352 4352 _('[OPTION]... [FILE]...'),
4353 4353 inferrepo=True)
4354 4354 def resolve(ui, repo, *pats, **opts):
4355 4355 """redo merges or set/view the merge status of files
4356 4356
4357 4357 Merges with unresolved conflicts are often the result of
4358 4358 non-interactive merging using the ``internal:merge`` configuration
4359 4359 setting, or a command-line merge tool like ``diff3``. The resolve
4360 4360 command is used to manage the files involved in a merge, after
4361 4361 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
4362 4362 working directory must have two parents). See :hg:`help
4363 4363 merge-tools` for information on configuring merge tools.
4364 4364
4365 4365 The resolve command can be used in the following ways:
4366 4366
4367 4367 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
4368 4368 files, discarding any previous merge attempts. Re-merging is not
4369 4369 performed for files already marked as resolved. Use ``--all/-a``
4370 4370 to select all unresolved files. ``--tool`` can be used to specify
4371 4371 the merge tool used for the given files. It overrides the HGMERGE
4372 4372 environment variable and your configuration files. Previous file
4373 4373 contents are saved with a ``.orig`` suffix.
4374 4374
4375 4375 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
4376 4376 (e.g. after having manually fixed-up the files). The default is
4377 4377 to mark all unresolved files.
4378 4378
4379 4379 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
4380 4380 default is to mark all resolved files.
4381 4381
4382 4382 - :hg:`resolve -l`: list files which had or still have conflicts.
4383 4383 In the printed list, ``U`` = unresolved and ``R`` = resolved.
4384 4384 You can use ``set:unresolved()`` or ``set:resolved()`` to filter
4385 4385 the list. See :hg:`help filesets` for details.
4386 4386
4387 4387 .. note::
4388 4388
4389 4389 Mercurial will not let you commit files with unresolved merge
4390 4390 conflicts. You must use :hg:`resolve -m ...` before you can
4391 4391 commit after a conflicting merge.
4392 4392
4393 4393 Returns 0 on success, 1 if any files fail a resolve attempt.
4394 4394 """
4395 4395
4396 4396 opts = pycompat.byteskwargs(opts)
4397 4397 flaglist = 'all mark unmark list no_status'.split()
4398 4398 all, mark, unmark, show, nostatus = \
4399 4399 [opts.get(o) for o in flaglist]
4400 4400
4401 4401 if (show and (mark or unmark)) or (mark and unmark):
4402 4402 raise error.Abort(_("too many options specified"))
4403 4403 if pats and all:
4404 4404 raise error.Abort(_("can't specify --all and patterns"))
4405 4405 if not (all or pats or show or mark or unmark):
4406 4406 raise error.Abort(_('no files or directories specified'),
4407 4407 hint=('use --all to re-merge all unresolved files'))
4408 4408
4409 4409 if show:
4410 4410 ui.pager('resolve')
4411 4411 fm = ui.formatter('resolve', opts)
4412 4412 ms = mergemod.mergestate.read(repo)
4413 4413 m = scmutil.match(repo[None], pats, opts)
4414 4414
4415 4415 # Labels and keys based on merge state. Unresolved path conflicts show
4416 4416 # as 'P'. Resolved path conflicts show as 'R', the same as normal
4417 4417 # resolved conflicts.
4418 4418 mergestateinfo = {
4419 4419 mergemod.MERGE_RECORD_UNRESOLVED: ('resolve.unresolved', 'U'),
4420 4420 mergemod.MERGE_RECORD_RESOLVED: ('resolve.resolved', 'R'),
4421 4421 mergemod.MERGE_RECORD_UNRESOLVED_PATH: ('resolve.unresolved', 'P'),
4422 4422 mergemod.MERGE_RECORD_RESOLVED_PATH: ('resolve.resolved', 'R'),
4423 4423 mergemod.MERGE_RECORD_DRIVER_RESOLVED: ('resolve.driverresolved',
4424 4424 'D'),
4425 4425 }
4426 4426
4427 4427 for f in ms:
4428 4428 if not m(f):
4429 4429 continue
4430 4430
4431 4431 label, key = mergestateinfo[ms[f]]
4432 4432 fm.startitem()
4433 4433 fm.condwrite(not nostatus, 'status', '%s ', key, label=label)
4434 4434 fm.write('path', '%s\n', f, label=label)
4435 4435 fm.end()
4436 4436 return 0
4437 4437
4438 4438 with repo.wlock():
4439 4439 ms = mergemod.mergestate.read(repo)
4440 4440
4441 4441 if not (ms.active() or repo.dirstate.p2() != nullid):
4442 4442 raise error.Abort(
4443 4443 _('resolve command not applicable when not merging'))
4444 4444
4445 4445 wctx = repo[None]
4446 4446
4447 4447 if (ms.mergedriver
4448 4448 and ms.mdstate() == mergemod.MERGE_DRIVER_STATE_UNMARKED):
4449 4449 proceed = mergemod.driverpreprocess(repo, ms, wctx)
4450 4450 ms.commit()
4451 4451 # allow mark and unmark to go through
4452 4452 if not mark and not unmark and not proceed:
4453 4453 return 1
4454 4454
4455 4455 m = scmutil.match(wctx, pats, opts)
4456 4456 ret = 0
4457 4457 didwork = False
4458 4458 runconclude = False
4459 4459
4460 4460 tocomplete = []
4461 4461 for f in ms:
4462 4462 if not m(f):
4463 4463 continue
4464 4464
4465 4465 didwork = True
4466 4466
4467 4467 # don't let driver-resolved files be marked, and run the conclude
4468 4468 # step if asked to resolve
4469 4469 if ms[f] == mergemod.MERGE_RECORD_DRIVER_RESOLVED:
4470 4470 exact = m.exact(f)
4471 4471 if mark:
4472 4472 if exact:
4473 4473 ui.warn(_('not marking %s as it is driver-resolved\n')
4474 4474 % f)
4475 4475 elif unmark:
4476 4476 if exact:
4477 4477 ui.warn(_('not unmarking %s as it is driver-resolved\n')
4478 4478 % f)
4479 4479 else:
4480 4480 runconclude = True
4481 4481 continue
4482 4482
4483 4483 # path conflicts must be resolved manually
4484 4484 if ms[f] in (mergemod.MERGE_RECORD_UNRESOLVED_PATH,
4485 4485 mergemod.MERGE_RECORD_RESOLVED_PATH):
4486 4486 if mark:
4487 4487 ms.mark(f, mergemod.MERGE_RECORD_RESOLVED_PATH)
4488 4488 elif unmark:
4489 4489 ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED_PATH)
4490 4490 elif ms[f] == mergemod.MERGE_RECORD_UNRESOLVED_PATH:
4491 4491 ui.warn(_('%s: path conflict must be resolved manually\n')
4492 4492 % f)
4493 4493 continue
4494 4494
4495 4495 if mark:
4496 4496 ms.mark(f, mergemod.MERGE_RECORD_RESOLVED)
4497 4497 elif unmark:
4498 4498 ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED)
4499 4499 else:
4500 4500 # backup pre-resolve (merge uses .orig for its own purposes)
4501 4501 a = repo.wjoin(f)
4502 4502 try:
4503 4503 util.copyfile(a, a + ".resolve")
4504 4504 except (IOError, OSError) as inst:
4505 4505 if inst.errno != errno.ENOENT:
4506 4506 raise
4507 4507
4508 4508 try:
4509 4509 # preresolve file
4510 4510 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
4511 4511 'resolve')
4512 4512 complete, r = ms.preresolve(f, wctx)
4513 4513 if not complete:
4514 4514 tocomplete.append(f)
4515 4515 elif r:
4516 4516 ret = 1
4517 4517 finally:
4518 4518 ui.setconfig('ui', 'forcemerge', '', 'resolve')
4519 4519 ms.commit()
4520 4520
4521 4521 # replace filemerge's .orig file with our resolve file, but only
4522 4522 # for merges that are complete
4523 4523 if complete:
4524 4524 try:
4525 4525 util.rename(a + ".resolve",
4526 4526 scmutil.origpath(ui, repo, a))
4527 4527 except OSError as inst:
4528 4528 if inst.errno != errno.ENOENT:
4529 4529 raise
4530 4530
4531 4531 for f in tocomplete:
4532 4532 try:
4533 4533 # resolve file
4534 4534 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
4535 4535 'resolve')
4536 4536 r = ms.resolve(f, wctx)
4537 4537 if r:
4538 4538 ret = 1
4539 4539 finally:
4540 4540 ui.setconfig('ui', 'forcemerge', '', 'resolve')
4541 4541 ms.commit()
4542 4542
4543 4543 # replace filemerge's .orig file with our resolve file
4544 4544 a = repo.wjoin(f)
4545 4545 try:
4546 4546 util.rename(a + ".resolve", scmutil.origpath(ui, repo, a))
4547 4547 except OSError as inst:
4548 4548 if inst.errno != errno.ENOENT:
4549 4549 raise
4550 4550
4551 4551 ms.commit()
4552 4552 ms.recordactions()
4553 4553
4554 4554 if not didwork and pats:
4555 4555 hint = None
4556 4556 if not any([p for p in pats if p.find(':') >= 0]):
4557 4557 pats = ['path:%s' % p for p in pats]
4558 4558 m = scmutil.match(wctx, pats, opts)
4559 4559 for f in ms:
4560 4560 if not m(f):
4561 4561 continue
4562 4562 flags = ''.join(['-%s ' % o[0:1] for o in flaglist
4563 4563 if opts.get(o)])
4564 4564 hint = _("(try: hg resolve %s%s)\n") % (
4565 4565 flags,
4566 4566 ' '.join(pats))
4567 4567 break
4568 4568 ui.warn(_("arguments do not match paths that need resolving\n"))
4569 4569 if hint:
4570 4570 ui.warn(hint)
4571 4571 elif ms.mergedriver and ms.mdstate() != 's':
4572 4572 # run conclude step when either a driver-resolved file is requested
4573 4573 # or there are no driver-resolved files
4574 4574 # we can't use 'ret' to determine whether any files are unresolved
4575 4575 # because we might not have tried to resolve some
4576 4576 if ((runconclude or not list(ms.driverresolved()))
4577 4577 and not list(ms.unresolved())):
4578 4578 proceed = mergemod.driverconclude(repo, ms, wctx)
4579 4579 ms.commit()
4580 4580 if not proceed:
4581 4581 return 1
4582 4582
4583 4583 # Nudge users into finishing an unfinished operation
4584 4584 unresolvedf = list(ms.unresolved())
4585 4585 driverresolvedf = list(ms.driverresolved())
4586 4586 if not unresolvedf and not driverresolvedf:
4587 4587 ui.status(_('(no more unresolved files)\n'))
4588 4588 cmdutil.checkafterresolved(repo)
4589 4589 elif not unresolvedf:
4590 4590 ui.status(_('(no more unresolved files -- '
4591 4591 'run "hg resolve --all" to conclude)\n'))
4592 4592
4593 4593 return ret
4594 4594
4595 4595 @command('revert',
4596 4596 [('a', 'all', None, _('revert all changes when no arguments given')),
4597 4597 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
4598 4598 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
4599 4599 ('C', 'no-backup', None, _('do not save backup copies of files')),
4600 4600 ('i', 'interactive', None, _('interactively select the changes')),
4601 4601 ] + walkopts + dryrunopts,
4602 4602 _('[OPTION]... [-r REV] [NAME]...'))
4603 4603 def revert(ui, repo, *pats, **opts):
4604 4604 """restore files to their checkout state
4605 4605
4606 4606 .. note::
4607 4607
4608 4608 To check out earlier revisions, you should use :hg:`update REV`.
4609 4609 To cancel an uncommitted merge (and lose your changes),
4610 4610 use :hg:`merge --abort`.
4611 4611
4612 4612 With no revision specified, revert the specified files or directories
4613 4613 to the contents they had in the parent of the working directory.
4614 4614 This restores the contents of files to an unmodified
4615 4615 state and unschedules adds, removes, copies, and renames. If the
4616 4616 working directory has two parents, you must explicitly specify a
4617 4617 revision.
4618 4618
4619 4619 Using the -r/--rev or -d/--date options, revert the given files or
4620 4620 directories to their states as of a specific revision. Because
4621 4621 revert does not change the working directory parents, this will
4622 4622 cause these files to appear modified. This can be helpful to "back
4623 4623 out" some or all of an earlier change. See :hg:`backout` for a
4624 4624 related method.
4625 4625
4626 4626 Modified files are saved with a .orig suffix before reverting.
4627 4627 To disable these backups, use --no-backup. It is possible to store
4628 4628 the backup files in a custom directory relative to the root of the
4629 4629 repository by setting the ``ui.origbackuppath`` configuration
4630 4630 option.
4631 4631
4632 4632 See :hg:`help dates` for a list of formats valid for -d/--date.
4633 4633
4634 4634 See :hg:`help backout` for a way to reverse the effect of an
4635 4635 earlier changeset.
4636 4636
4637 4637 Returns 0 on success.
4638 4638 """
4639 4639
4640 4640 opts = pycompat.byteskwargs(opts)
4641 4641 if opts.get("date"):
4642 4642 if opts.get("rev"):
4643 4643 raise error.Abort(_("you can't specify a revision and a date"))
4644 4644 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
4645 4645
4646 4646 parent, p2 = repo.dirstate.parents()
4647 4647 if not opts.get('rev') and p2 != nullid:
4648 4648 # revert after merge is a trap for new users (issue2915)
4649 4649 raise error.Abort(_('uncommitted merge with no revision specified'),
4650 4650 hint=_("use 'hg update' or see 'hg help revert'"))
4651 4651
4652 4652 rev = opts.get('rev')
4653 4653 if rev:
4654 4654 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
4655 4655 ctx = scmutil.revsingle(repo, rev)
4656 4656
4657 4657 if (not (pats or opts.get('include') or opts.get('exclude') or
4658 4658 opts.get('all') or opts.get('interactive'))):
4659 4659 msg = _("no files or directories specified")
4660 4660 if p2 != nullid:
4661 4661 hint = _("uncommitted merge, use --all to discard all changes,"
4662 4662 " or 'hg update -C .' to abort the merge")
4663 4663 raise error.Abort(msg, hint=hint)
4664 4664 dirty = any(repo.status())
4665 4665 node = ctx.node()
4666 4666 if node != parent:
4667 4667 if dirty:
4668 4668 hint = _("uncommitted changes, use --all to discard all"
4669 4669 " changes, or 'hg update %s' to update") % ctx.rev()
4670 4670 else:
4671 4671 hint = _("use --all to revert all files,"
4672 4672 " or 'hg update %s' to update") % ctx.rev()
4673 4673 elif dirty:
4674 4674 hint = _("uncommitted changes, use --all to discard all changes")
4675 4675 else:
4676 4676 hint = _("use --all to revert all files")
4677 4677 raise error.Abort(msg, hint=hint)
4678 4678
4679 4679 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats,
4680 4680 **pycompat.strkwargs(opts))
4681 4681
4682 4682 @command('rollback', dryrunopts +
4683 4683 [('f', 'force', False, _('ignore safety measures'))])
4684 4684 def rollback(ui, repo, **opts):
4685 4685 """roll back the last transaction (DANGEROUS) (DEPRECATED)
4686 4686
4687 4687 Please use :hg:`commit --amend` instead of rollback to correct
4688 4688 mistakes in the last commit.
4689 4689
4690 4690 This command should be used with care. There is only one level of
4691 4691 rollback, and there is no way to undo a rollback. It will also
4692 4692 restore the dirstate at the time of the last transaction, losing
4693 4693 any dirstate changes since that time. This command does not alter
4694 4694 the working directory.
4695 4695
4696 4696 Transactions are used to encapsulate the effects of all commands
4697 4697 that create new changesets or propagate existing changesets into a
4698 4698 repository.
4699 4699
4700 4700 .. container:: verbose
4701 4701
4702 4702 For example, the following commands are transactional, and their
4703 4703 effects can be rolled back:
4704 4704
4705 4705 - commit
4706 4706 - import
4707 4707 - pull
4708 4708 - push (with this repository as the destination)
4709 4709 - unbundle
4710 4710
4711 4711 To avoid permanent data loss, rollback will refuse to rollback a
4712 4712 commit transaction if it isn't checked out. Use --force to
4713 4713 override this protection.
4714 4714
4715 4715 The rollback command can be entirely disabled by setting the
4716 4716 ``ui.rollback`` configuration setting to false. If you're here
4717 4717 because you want to use rollback and it's disabled, you can
4718 4718 re-enable the command by setting ``ui.rollback`` to true.
4719 4719
4720 4720 This command is not intended for use on public repositories. Once
4721 4721 changes are visible for pull by other users, rolling a transaction
4722 4722 back locally is ineffective (someone else may already have pulled
4723 4723 the changes). Furthermore, a race is possible with readers of the
4724 4724 repository; for example an in-progress pull from the repository
4725 4725 may fail if a rollback is performed.
4726 4726
4727 4727 Returns 0 on success, 1 if no rollback data is available.
4728 4728 """
4729 4729 if not ui.configbool('ui', 'rollback'):
4730 4730 raise error.Abort(_('rollback is disabled because it is unsafe'),
4731 4731 hint=('see `hg help -v rollback` for information'))
4732 4732 return repo.rollback(dryrun=opts.get(r'dry_run'),
4733 4733 force=opts.get(r'force'))
4734 4734
4735 4735 @command('root', [], intents={INTENT_READONLY})
4736 4736 def root(ui, repo):
4737 4737 """print the root (top) of the current working directory
4738 4738
4739 4739 Print the root directory of the current repository.
4740 4740
4741 4741 Returns 0 on success.
4742 4742 """
4743 4743 ui.write(repo.root + "\n")
4744 4744
4745 4745 @command('^serve',
4746 4746 [('A', 'accesslog', '', _('name of access log file to write to'),
4747 4747 _('FILE')),
4748 4748 ('d', 'daemon', None, _('run server in background')),
4749 4749 ('', 'daemon-postexec', [], _('used internally by daemon mode')),
4750 4750 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
4751 4751 # use string type, then we can check if something was passed
4752 4752 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
4753 4753 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
4754 4754 _('ADDR')),
4755 4755 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
4756 4756 _('PREFIX')),
4757 4757 ('n', 'name', '',
4758 4758 _('name to show in web pages (default: working directory)'), _('NAME')),
4759 4759 ('', 'web-conf', '',
4760 4760 _("name of the hgweb config file (see 'hg help hgweb')"), _('FILE')),
4761 4761 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
4762 4762 _('FILE')),
4763 4763 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
4764 4764 ('', 'stdio', None, _('for remote clients (ADVANCED)')),
4765 4765 ('', 'cmdserver', '', _('for remote clients (ADVANCED)'), _('MODE')),
4766 4766 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
4767 4767 ('', 'style', '', _('template style to use'), _('STYLE')),
4768 4768 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
4769 4769 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))]
4770 4770 + subrepoopts,
4771 4771 _('[OPTION]...'),
4772 4772 optionalrepo=True)
4773 4773 def serve(ui, repo, **opts):
4774 4774 """start stand-alone webserver
4775 4775
4776 4776 Start a local HTTP repository browser and pull server. You can use
4777 4777 this for ad-hoc sharing and browsing of repositories. It is
4778 4778 recommended to use a real web server to serve a repository for
4779 4779 longer periods of time.
4780 4780
4781 4781 Please note that the server does not implement access control.
4782 4782 This means that, by default, anybody can read from the server and
4783 4783 nobody can write to it by default. Set the ``web.allow-push``
4784 4784 option to ``*`` to allow everybody to push to the server. You
4785 4785 should use a real web server if you need to authenticate users.
4786 4786
4787 4787 By default, the server logs accesses to stdout and errors to
4788 4788 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
4789 4789 files.
4790 4790
4791 4791 To have the server choose a free port number to listen on, specify
4792 4792 a port number of 0; in this case, the server will print the port
4793 4793 number it uses.
4794 4794
4795 4795 Returns 0 on success.
4796 4796 """
4797 4797
4798 4798 opts = pycompat.byteskwargs(opts)
4799 4799 if opts["stdio"] and opts["cmdserver"]:
4800 4800 raise error.Abort(_("cannot use --stdio with --cmdserver"))
4801 4801
4802 4802 if opts["stdio"]:
4803 4803 if repo is None:
4804 4804 raise error.RepoError(_("there is no Mercurial repository here"
4805 4805 " (.hg not found)"))
4806 4806 s = wireprotoserver.sshserver(ui, repo)
4807 4807 s.serve_forever()
4808 4808
4809 4809 service = server.createservice(ui, repo, opts)
4810 4810 return server.runservice(opts, initfn=service.init, runfn=service.run)
4811 4811
4812 _NOTTERSE = 'nothing'
4813
4812 4814 @command('^status|st',
4813 4815 [('A', 'all', None, _('show status of all files')),
4814 4816 ('m', 'modified', None, _('show only modified files')),
4815 4817 ('a', 'added', None, _('show only added files')),
4816 4818 ('r', 'removed', None, _('show only removed files')),
4817 4819 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
4818 4820 ('c', 'clean', None, _('show only files without changes')),
4819 4821 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
4820 4822 ('i', 'ignored', None, _('show only ignored files')),
4821 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 4825 ('C', 'copies', None, _('show source of copied files')),
4824 4826 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
4825 4827 ('', 'rev', [], _('show difference from revision'), _('REV')),
4826 4828 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
4827 4829 ] + walkopts + subrepoopts + formatteropts,
4828 4830 _('[OPTION]... [FILE]...'),
4829 4831 inferrepo=True,
4830 4832 intents={INTENT_READONLY})
4831 4833 def status(ui, repo, *pats, **opts):
4832 4834 """show changed files in the working directory
4833 4835
4834 4836 Show status of files in the repository. If names are given, only
4835 4837 files that match are shown. Files that are clean or ignored or
4836 4838 the source of a copy/move operation, are not listed unless
4837 4839 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
4838 4840 Unless options described with "show only ..." are given, the
4839 4841 options -mardu are used.
4840 4842
4841 4843 Option -q/--quiet hides untracked (unknown and ignored) files
4842 4844 unless explicitly requested with -u/--unknown or -i/--ignored.
4843 4845
4844 4846 .. note::
4845 4847
4846 4848 :hg:`status` may appear to disagree with diff if permissions have
4847 4849 changed or a merge has occurred. The standard diff format does
4848 4850 not report permission changes and diff only reports changes
4849 4851 relative to one merge parent.
4850 4852
4851 4853 If one revision is given, it is used as the base revision.
4852 4854 If two revisions are given, the differences between them are
4853 4855 shown. The --change option can also be used as a shortcut to list
4854 4856 the changed files of a revision from its first parent.
4855 4857
4856 4858 The codes used to show the status of files are::
4857 4859
4858 4860 M = modified
4859 4861 A = added
4860 4862 R = removed
4861 4863 C = clean
4862 4864 ! = missing (deleted by non-hg command, but still tracked)
4863 4865 ? = not tracked
4864 4866 I = ignored
4865 4867 = origin of the previous file (with --copies)
4866 4868
4867 4869 .. container:: verbose
4868 4870
4869 4871 The -t/--terse option abbreviates the output by showing only the directory
4870 4872 name if all the files in it share the same status. The option takes an
4871 4873 argument indicating the statuses to abbreviate: 'm' for 'modified', 'a'
4872 4874 for 'added', 'r' for 'removed', 'd' for 'deleted', 'u' for 'unknown', 'i'
4873 4875 for 'ignored' and 'c' for clean.
4874 4876
4875 4877 It abbreviates only those statuses which are passed. Note that clean and
4876 4878 ignored files are not displayed with '--terse ic' unless the -c/--clean
4877 4879 and -i/--ignored options are also used.
4878 4880
4879 4881 The -v/--verbose option shows information when the repository is in an
4880 4882 unfinished merge, shelve, rebase state etc. You can have this behavior
4881 4883 turned on by default by enabling the ``commands.status.verbose`` option.
4882 4884
4883 4885 You can skip displaying some of these states by setting
4884 4886 ``commands.status.skipstates`` to one or more of: 'bisect', 'graft',
4885 4887 'histedit', 'merge', 'rebase', or 'unshelve'.
4886 4888
4887 4889 Examples:
4888 4890
4889 4891 - show changes in the working directory relative to a
4890 4892 changeset::
4891 4893
4892 4894 hg status --rev 9353
4893 4895
4894 4896 - show changes in the working directory relative to the
4895 4897 current directory (see :hg:`help patterns` for more information)::
4896 4898
4897 4899 hg status re:
4898 4900
4899 4901 - show all changes including copies in an existing changeset::
4900 4902
4901 4903 hg status --copies --change 9353
4902 4904
4903 4905 - get a NUL separated list of added files, suitable for xargs::
4904 4906
4905 4907 hg status -an0
4906 4908
4907 4909 - show more information about the repository status, abbreviating
4908 4910 added, removed, modified, deleted, and untracked paths::
4909 4911
4910 4912 hg status -v -t mardu
4911 4913
4912 4914 Returns 0 on success.
4913 4915
4914 4916 """
4915 4917
4916 4918 opts = pycompat.byteskwargs(opts)
4917 4919 revs = opts.get('rev')
4918 4920 change = opts.get('change')
4919 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 4928 if revs and change:
4922 4929 msg = _('cannot specify --rev and --change at the same time')
4923 4930 raise error.Abort(msg)
4924 4931 elif revs and terse:
4925 4932 msg = _('cannot use --terse with --rev')
4926 4933 raise error.Abort(msg)
4927 4934 elif change:
4928 4935 repo = scmutil.unhidehashlikerevs(repo, [change], 'nowarn')
4929 4936 ctx2 = scmutil.revsingle(repo, change, None)
4930 4937 ctx1 = ctx2.p1()
4931 4938 else:
4932 4939 repo = scmutil.unhidehashlikerevs(repo, revs, 'nowarn')
4933 4940 ctx1, ctx2 = scmutil.revpair(repo, revs)
4934 4941
4935 4942 if pats or ui.configbool('commands', 'status.relative'):
4936 4943 cwd = repo.getcwd()
4937 4944 else:
4938 4945 cwd = ''
4939 4946
4940 4947 if opts.get('print0'):
4941 4948 end = '\0'
4942 4949 else:
4943 4950 end = '\n'
4944 4951 copy = {}
4945 4952 states = 'modified added removed deleted unknown ignored clean'.split()
4946 4953 show = [k for k in states if opts.get(k)]
4947 4954 if opts.get('all'):
4948 4955 show += ui.quiet and (states[:4] + ['clean']) or states
4949 4956
4950 4957 if not show:
4951 4958 if ui.quiet:
4952 4959 show = states[:4]
4953 4960 else:
4954 4961 show = states[:5]
4955 4962
4956 4963 m = scmutil.match(ctx2, pats, opts)
4957 4964 if terse:
4958 4965 # we need to compute clean and unknown to terse
4959 4966 stat = repo.status(ctx1.node(), ctx2.node(), m,
4960 4967 'ignored' in show or 'i' in terse,
4961 4968 True, True, opts.get('subrepos'))
4962 4969
4963 4970 stat = cmdutil.tersedir(stat, terse)
4964 4971 else:
4965 4972 stat = repo.status(ctx1.node(), ctx2.node(), m,
4966 4973 'ignored' in show, 'clean' in show,
4967 4974 'unknown' in show, opts.get('subrepos'))
4968 4975
4969 4976 changestates = zip(states, pycompat.iterbytestr('MAR!?IC'), stat)
4970 4977
4971 4978 if (opts.get('all') or opts.get('copies')
4972 4979 or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'):
4973 4980 copy = copies.pathcopies(ctx1, ctx2, m)
4974 4981
4975 4982 ui.pager('status')
4976 4983 fm = ui.formatter('status', opts)
4977 4984 fmt = '%s' + end
4978 4985 showchar = not opts.get('no_status')
4979 4986
4980 4987 for state, char, files in changestates:
4981 4988 if state in show:
4982 4989 label = 'status.' + state
4983 4990 for f in files:
4984 4991 fm.startitem()
4985 4992 fm.condwrite(showchar, 'status', '%s ', char, label=label)
4986 4993 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
4987 4994 if f in copy:
4988 4995 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
4989 4996 label='status.copied')
4990 4997
4991 4998 if ((ui.verbose or ui.configbool('commands', 'status.verbose'))
4992 4999 and not ui.plain()):
4993 5000 cmdutil.morestatus(repo, fm)
4994 5001 fm.end()
4995 5002
4996 5003 @command('^summary|sum',
4997 5004 [('', 'remote', None, _('check for push and pull'))],
4998 5005 '[--remote]',
4999 5006 intents={INTENT_READONLY})
5000 5007 def summary(ui, repo, **opts):
5001 5008 """summarize working directory state
5002 5009
5003 5010 This generates a brief summary of the working directory state,
5004 5011 including parents, branch, commit status, phase and available updates.
5005 5012
5006 5013 With the --remote option, this will check the default paths for
5007 5014 incoming and outgoing changes. This can be time-consuming.
5008 5015
5009 5016 Returns 0 on success.
5010 5017 """
5011 5018
5012 5019 opts = pycompat.byteskwargs(opts)
5013 5020 ui.pager('summary')
5014 5021 ctx = repo[None]
5015 5022 parents = ctx.parents()
5016 5023 pnode = parents[0].node()
5017 5024 marks = []
5018 5025
5019 5026 ms = None
5020 5027 try:
5021 5028 ms = mergemod.mergestate.read(repo)
5022 5029 except error.UnsupportedMergeRecords as e:
5023 5030 s = ' '.join(e.recordtypes)
5024 5031 ui.warn(
5025 5032 _('warning: merge state has unsupported record types: %s\n') % s)
5026 5033 unresolved = []
5027 5034 else:
5028 5035 unresolved = list(ms.unresolved())
5029 5036
5030 5037 for p in parents:
5031 5038 # label with log.changeset (instead of log.parent) since this
5032 5039 # shows a working directory parent *changeset*:
5033 5040 # i18n: column positioning for "hg summary"
5034 5041 ui.write(_('parent: %d:%s ') % (p.rev(), p),
5035 5042 label=logcmdutil.changesetlabels(p))
5036 5043 ui.write(' '.join(p.tags()), label='log.tag')
5037 5044 if p.bookmarks():
5038 5045 marks.extend(p.bookmarks())
5039 5046 if p.rev() == -1:
5040 5047 if not len(repo):
5041 5048 ui.write(_(' (empty repository)'))
5042 5049 else:
5043 5050 ui.write(_(' (no revision checked out)'))
5044 5051 if p.obsolete():
5045 5052 ui.write(_(' (obsolete)'))
5046 5053 if p.isunstable():
5047 5054 instabilities = (ui.label(instability, 'trouble.%s' % instability)
5048 5055 for instability in p.instabilities())
5049 5056 ui.write(' ('
5050 5057 + ', '.join(instabilities)
5051 5058 + ')')
5052 5059 ui.write('\n')
5053 5060 if p.description():
5054 5061 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
5055 5062 label='log.summary')
5056 5063
5057 5064 branch = ctx.branch()
5058 5065 bheads = repo.branchheads(branch)
5059 5066 # i18n: column positioning for "hg summary"
5060 5067 m = _('branch: %s\n') % branch
5061 5068 if branch != 'default':
5062 5069 ui.write(m, label='log.branch')
5063 5070 else:
5064 5071 ui.status(m, label='log.branch')
5065 5072
5066 5073 if marks:
5067 5074 active = repo._activebookmark
5068 5075 # i18n: column positioning for "hg summary"
5069 5076 ui.write(_('bookmarks:'), label='log.bookmark')
5070 5077 if active is not None:
5071 5078 if active in marks:
5072 5079 ui.write(' *' + active, label=bookmarks.activebookmarklabel)
5073 5080 marks.remove(active)
5074 5081 else:
5075 5082 ui.write(' [%s]' % active, label=bookmarks.activebookmarklabel)
5076 5083 for m in marks:
5077 5084 ui.write(' ' + m, label='log.bookmark')
5078 5085 ui.write('\n', label='log.bookmark')
5079 5086
5080 5087 status = repo.status(unknown=True)
5081 5088
5082 5089 c = repo.dirstate.copies()
5083 5090 copied, renamed = [], []
5084 5091 for d, s in c.iteritems():
5085 5092 if s in status.removed:
5086 5093 status.removed.remove(s)
5087 5094 renamed.append(d)
5088 5095 else:
5089 5096 copied.append(d)
5090 5097 if d in status.added:
5091 5098 status.added.remove(d)
5092 5099
5093 5100 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
5094 5101
5095 5102 labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified),
5096 5103 (ui.label(_('%d added'), 'status.added'), status.added),
5097 5104 (ui.label(_('%d removed'), 'status.removed'), status.removed),
5098 5105 (ui.label(_('%d renamed'), 'status.copied'), renamed),
5099 5106 (ui.label(_('%d copied'), 'status.copied'), copied),
5100 5107 (ui.label(_('%d deleted'), 'status.deleted'), status.deleted),
5101 5108 (ui.label(_('%d unknown'), 'status.unknown'), status.unknown),
5102 5109 (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved),
5103 5110 (ui.label(_('%d subrepos'), 'status.modified'), subs)]
5104 5111 t = []
5105 5112 for l, s in labels:
5106 5113 if s:
5107 5114 t.append(l % len(s))
5108 5115
5109 5116 t = ', '.join(t)
5110 5117 cleanworkdir = False
5111 5118
5112 5119 if repo.vfs.exists('graftstate'):
5113 5120 t += _(' (graft in progress)')
5114 5121 if repo.vfs.exists('updatestate'):
5115 5122 t += _(' (interrupted update)')
5116 5123 elif len(parents) > 1:
5117 5124 t += _(' (merge)')
5118 5125 elif branch != parents[0].branch():
5119 5126 t += _(' (new branch)')
5120 5127 elif (parents[0].closesbranch() and
5121 5128 pnode in repo.branchheads(branch, closed=True)):
5122 5129 t += _(' (head closed)')
5123 5130 elif not (status.modified or status.added or status.removed or renamed or
5124 5131 copied or subs):
5125 5132 t += _(' (clean)')
5126 5133 cleanworkdir = True
5127 5134 elif pnode not in bheads:
5128 5135 t += _(' (new branch head)')
5129 5136
5130 5137 if parents:
5131 5138 pendingphase = max(p.phase() for p in parents)
5132 5139 else:
5133 5140 pendingphase = phases.public
5134 5141
5135 5142 if pendingphase > phases.newcommitphase(ui):
5136 5143 t += ' (%s)' % phases.phasenames[pendingphase]
5137 5144
5138 5145 if cleanworkdir:
5139 5146 # i18n: column positioning for "hg summary"
5140 5147 ui.status(_('commit: %s\n') % t.strip())
5141 5148 else:
5142 5149 # i18n: column positioning for "hg summary"
5143 5150 ui.write(_('commit: %s\n') % t.strip())
5144 5151
5145 5152 # all ancestors of branch heads - all ancestors of parent = new csets
5146 5153 new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
5147 5154 bheads))
5148 5155
5149 5156 if new == 0:
5150 5157 # i18n: column positioning for "hg summary"
5151 5158 ui.status(_('update: (current)\n'))
5152 5159 elif pnode not in bheads:
5153 5160 # i18n: column positioning for "hg summary"
5154 5161 ui.write(_('update: %d new changesets (update)\n') % new)
5155 5162 else:
5156 5163 # i18n: column positioning for "hg summary"
5157 5164 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
5158 5165 (new, len(bheads)))
5159 5166
5160 5167 t = []
5161 5168 draft = len(repo.revs('draft()'))
5162 5169 if draft:
5163 5170 t.append(_('%d draft') % draft)
5164 5171 secret = len(repo.revs('secret()'))
5165 5172 if secret:
5166 5173 t.append(_('%d secret') % secret)
5167 5174
5168 5175 if draft or secret:
5169 5176 ui.status(_('phases: %s\n') % ', '.join(t))
5170 5177
5171 5178 if obsolete.isenabled(repo, obsolete.createmarkersopt):
5172 5179 for trouble in ("orphan", "contentdivergent", "phasedivergent"):
5173 5180 numtrouble = len(repo.revs(trouble + "()"))
5174 5181 # We write all the possibilities to ease translation
5175 5182 troublemsg = {
5176 5183 "orphan": _("orphan: %d changesets"),
5177 5184 "contentdivergent": _("content-divergent: %d changesets"),
5178 5185 "phasedivergent": _("phase-divergent: %d changesets"),
5179 5186 }
5180 5187 if numtrouble > 0:
5181 5188 ui.status(troublemsg[trouble] % numtrouble + "\n")
5182 5189
5183 5190 cmdutil.summaryhooks(ui, repo)
5184 5191
5185 5192 if opts.get('remote'):
5186 5193 needsincoming, needsoutgoing = True, True
5187 5194 else:
5188 5195 needsincoming, needsoutgoing = False, False
5189 5196 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
5190 5197 if i:
5191 5198 needsincoming = True
5192 5199 if o:
5193 5200 needsoutgoing = True
5194 5201 if not needsincoming and not needsoutgoing:
5195 5202 return
5196 5203
5197 5204 def getincoming():
5198 5205 source, branches = hg.parseurl(ui.expandpath('default'))
5199 5206 sbranch = branches[0]
5200 5207 try:
5201 5208 other = hg.peer(repo, {}, source)
5202 5209 except error.RepoError:
5203 5210 if opts.get('remote'):
5204 5211 raise
5205 5212 return source, sbranch, None, None, None
5206 5213 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
5207 5214 if revs:
5208 5215 revs = [other.lookup(rev) for rev in revs]
5209 5216 ui.debug('comparing with %s\n' % util.hidepassword(source))
5210 5217 repo.ui.pushbuffer()
5211 5218 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
5212 5219 repo.ui.popbuffer()
5213 5220 return source, sbranch, other, commoninc, commoninc[1]
5214 5221
5215 5222 if needsincoming:
5216 5223 source, sbranch, sother, commoninc, incoming = getincoming()
5217 5224 else:
5218 5225 source = sbranch = sother = commoninc = incoming = None
5219 5226
5220 5227 def getoutgoing():
5221 5228 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
5222 5229 dbranch = branches[0]
5223 5230 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
5224 5231 if source != dest:
5225 5232 try:
5226 5233 dother = hg.peer(repo, {}, dest)
5227 5234 except error.RepoError:
5228 5235 if opts.get('remote'):
5229 5236 raise
5230 5237 return dest, dbranch, None, None
5231 5238 ui.debug('comparing with %s\n' % util.hidepassword(dest))
5232 5239 elif sother is None:
5233 5240 # there is no explicit destination peer, but source one is invalid
5234 5241 return dest, dbranch, None, None
5235 5242 else:
5236 5243 dother = sother
5237 5244 if (source != dest or (sbranch is not None and sbranch != dbranch)):
5238 5245 common = None
5239 5246 else:
5240 5247 common = commoninc
5241 5248 if revs:
5242 5249 revs = [repo.lookup(rev) for rev in revs]
5243 5250 repo.ui.pushbuffer()
5244 5251 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
5245 5252 commoninc=common)
5246 5253 repo.ui.popbuffer()
5247 5254 return dest, dbranch, dother, outgoing
5248 5255
5249 5256 if needsoutgoing:
5250 5257 dest, dbranch, dother, outgoing = getoutgoing()
5251 5258 else:
5252 5259 dest = dbranch = dother = outgoing = None
5253 5260
5254 5261 if opts.get('remote'):
5255 5262 t = []
5256 5263 if incoming:
5257 5264 t.append(_('1 or more incoming'))
5258 5265 o = outgoing.missing
5259 5266 if o:
5260 5267 t.append(_('%d outgoing') % len(o))
5261 5268 other = dother or sother
5262 5269 if 'bookmarks' in other.listkeys('namespaces'):
5263 5270 counts = bookmarks.summary(repo, other)
5264 5271 if counts[0] > 0:
5265 5272 t.append(_('%d incoming bookmarks') % counts[0])
5266 5273 if counts[1] > 0:
5267 5274 t.append(_('%d outgoing bookmarks') % counts[1])
5268 5275
5269 5276 if t:
5270 5277 # i18n: column positioning for "hg summary"
5271 5278 ui.write(_('remote: %s\n') % (', '.join(t)))
5272 5279 else:
5273 5280 # i18n: column positioning for "hg summary"
5274 5281 ui.status(_('remote: (synced)\n'))
5275 5282
5276 5283 cmdutil.summaryremotehooks(ui, repo, opts,
5277 5284 ((source, sbranch, sother, commoninc),
5278 5285 (dest, dbranch, dother, outgoing)))
5279 5286
5280 5287 @command('tag',
5281 5288 [('f', 'force', None, _('force tag')),
5282 5289 ('l', 'local', None, _('make the tag local')),
5283 5290 ('r', 'rev', '', _('revision to tag'), _('REV')),
5284 5291 ('', 'remove', None, _('remove a tag')),
5285 5292 # -l/--local is already there, commitopts cannot be used
5286 5293 ('e', 'edit', None, _('invoke editor on commit messages')),
5287 5294 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
5288 5295 ] + commitopts2,
5289 5296 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
5290 5297 def tag(ui, repo, name1, *names, **opts):
5291 5298 """add one or more tags for the current or given revision
5292 5299
5293 5300 Name a particular revision using <name>.
5294 5301
5295 5302 Tags are used to name particular revisions of the repository and are
5296 5303 very useful to compare different revisions, to go back to significant
5297 5304 earlier versions or to mark branch points as releases, etc. Changing
5298 5305 an existing tag is normally disallowed; use -f/--force to override.
5299 5306
5300 5307 If no revision is given, the parent of the working directory is
5301 5308 used.
5302 5309
5303 5310 To facilitate version control, distribution, and merging of tags,
5304 5311 they are stored as a file named ".hgtags" which is managed similarly
5305 5312 to other project files and can be hand-edited if necessary. This
5306 5313 also means that tagging creates a new commit. The file
5307 5314 ".hg/localtags" is used for local tags (not shared among
5308 5315 repositories).
5309 5316
5310 5317 Tag commits are usually made at the head of a branch. If the parent
5311 5318 of the working directory is not a branch head, :hg:`tag` aborts; use
5312 5319 -f/--force to force the tag commit to be based on a non-head
5313 5320 changeset.
5314 5321
5315 5322 See :hg:`help dates` for a list of formats valid for -d/--date.
5316 5323
5317 5324 Since tag names have priority over branch names during revision
5318 5325 lookup, using an existing branch name as a tag name is discouraged.
5319 5326
5320 5327 Returns 0 on success.
5321 5328 """
5322 5329 opts = pycompat.byteskwargs(opts)
5323 5330 wlock = lock = None
5324 5331 try:
5325 5332 wlock = repo.wlock()
5326 5333 lock = repo.lock()
5327 5334 rev_ = "."
5328 5335 names = [t.strip() for t in (name1,) + names]
5329 5336 if len(names) != len(set(names)):
5330 5337 raise error.Abort(_('tag names must be unique'))
5331 5338 for n in names:
5332 5339 scmutil.checknewlabel(repo, n, 'tag')
5333 5340 if not n:
5334 5341 raise error.Abort(_('tag names cannot consist entirely of '
5335 5342 'whitespace'))
5336 5343 if opts.get('rev') and opts.get('remove'):
5337 5344 raise error.Abort(_("--rev and --remove are incompatible"))
5338 5345 if opts.get('rev'):
5339 5346 rev_ = opts['rev']
5340 5347 message = opts.get('message')
5341 5348 if opts.get('remove'):
5342 5349 if opts.get('local'):
5343 5350 expectedtype = 'local'
5344 5351 else:
5345 5352 expectedtype = 'global'
5346 5353
5347 5354 for n in names:
5348 5355 if not repo.tagtype(n):
5349 5356 raise error.Abort(_("tag '%s' does not exist") % n)
5350 5357 if repo.tagtype(n) != expectedtype:
5351 5358 if expectedtype == 'global':
5352 5359 raise error.Abort(_("tag '%s' is not a global tag") % n)
5353 5360 else:
5354 5361 raise error.Abort(_("tag '%s' is not a local tag") % n)
5355 5362 rev_ = 'null'
5356 5363 if not message:
5357 5364 # we don't translate commit messages
5358 5365 message = 'Removed tag %s' % ', '.join(names)
5359 5366 elif not opts.get('force'):
5360 5367 for n in names:
5361 5368 if n in repo.tags():
5362 5369 raise error.Abort(_("tag '%s' already exists "
5363 5370 "(use -f to force)") % n)
5364 5371 if not opts.get('local'):
5365 5372 p1, p2 = repo.dirstate.parents()
5366 5373 if p2 != nullid:
5367 5374 raise error.Abort(_('uncommitted merge'))
5368 5375 bheads = repo.branchheads()
5369 5376 if not opts.get('force') and bheads and p1 not in bheads:
5370 5377 raise error.Abort(_('working directory is not at a branch head '
5371 5378 '(use -f to force)'))
5372 5379 node = scmutil.revsingle(repo, rev_).node()
5373 5380
5374 5381 if not message:
5375 5382 # we don't translate commit messages
5376 5383 message = ('Added tag %s for changeset %s' %
5377 5384 (', '.join(names), short(node)))
5378 5385
5379 5386 date = opts.get('date')
5380 5387 if date:
5381 5388 date = dateutil.parsedate(date)
5382 5389
5383 5390 if opts.get('remove'):
5384 5391 editform = 'tag.remove'
5385 5392 else:
5386 5393 editform = 'tag.add'
5387 5394 editor = cmdutil.getcommiteditor(editform=editform,
5388 5395 **pycompat.strkwargs(opts))
5389 5396
5390 5397 # don't allow tagging the null rev
5391 5398 if (not opts.get('remove') and
5392 5399 scmutil.revsingle(repo, rev_).rev() == nullrev):
5393 5400 raise error.Abort(_("cannot tag null revision"))
5394 5401
5395 5402 tagsmod.tag(repo, names, node, message, opts.get('local'),
5396 5403 opts.get('user'), date, editor=editor)
5397 5404 finally:
5398 5405 release(lock, wlock)
5399 5406
5400 5407 @command('tags', formatteropts, '', intents={INTENT_READONLY})
5401 5408 def tags(ui, repo, **opts):
5402 5409 """list repository tags
5403 5410
5404 5411 This lists both regular and local tags. When the -v/--verbose
5405 5412 switch is used, a third column "local" is printed for local tags.
5406 5413 When the -q/--quiet switch is used, only the tag name is printed.
5407 5414
5408 5415 Returns 0 on success.
5409 5416 """
5410 5417
5411 5418 opts = pycompat.byteskwargs(opts)
5412 5419 ui.pager('tags')
5413 5420 fm = ui.formatter('tags', opts)
5414 5421 hexfunc = fm.hexfunc
5415 5422 tagtype = ""
5416 5423
5417 5424 for t, n in reversed(repo.tagslist()):
5418 5425 hn = hexfunc(n)
5419 5426 label = 'tags.normal'
5420 5427 tagtype = ''
5421 5428 if repo.tagtype(t) == 'local':
5422 5429 label = 'tags.local'
5423 5430 tagtype = 'local'
5424 5431
5425 5432 fm.startitem()
5426 5433 fm.write('tag', '%s', t, label=label)
5427 5434 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
5428 5435 fm.condwrite(not ui.quiet, 'rev node', fmt,
5429 5436 repo.changelog.rev(n), hn, label=label)
5430 5437 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
5431 5438 tagtype, label=label)
5432 5439 fm.plain('\n')
5433 5440 fm.end()
5434 5441
5435 5442 @command('tip',
5436 5443 [('p', 'patch', None, _('show patch')),
5437 5444 ('g', 'git', None, _('use git extended diff format')),
5438 5445 ] + templateopts,
5439 5446 _('[-p] [-g]'))
5440 5447 def tip(ui, repo, **opts):
5441 5448 """show the tip revision (DEPRECATED)
5442 5449
5443 5450 The tip revision (usually just called the tip) is the changeset
5444 5451 most recently added to the repository (and therefore the most
5445 5452 recently changed head).
5446 5453
5447 5454 If you have just made a commit, that commit will be the tip. If
5448 5455 you have just pulled changes from another repository, the tip of
5449 5456 that repository becomes the current tip. The "tip" tag is special
5450 5457 and cannot be renamed or assigned to a different changeset.
5451 5458
5452 5459 This command is deprecated, please use :hg:`heads` instead.
5453 5460
5454 5461 Returns 0 on success.
5455 5462 """
5456 5463 opts = pycompat.byteskwargs(opts)
5457 5464 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
5458 5465 displayer.show(repo['tip'])
5459 5466 displayer.close()
5460 5467
5461 5468 @command('unbundle',
5462 5469 [('u', 'update', None,
5463 5470 _('update to new branch head if changesets were unbundled'))],
5464 5471 _('[-u] FILE...'))
5465 5472 def unbundle(ui, repo, fname1, *fnames, **opts):
5466 5473 """apply one or more bundle files
5467 5474
5468 5475 Apply one or more bundle files generated by :hg:`bundle`.
5469 5476
5470 5477 Returns 0 on success, 1 if an update has unresolved files.
5471 5478 """
5472 5479 fnames = (fname1,) + fnames
5473 5480
5474 5481 with repo.lock():
5475 5482 for fname in fnames:
5476 5483 f = hg.openpath(ui, fname)
5477 5484 gen = exchange.readbundle(ui, f, fname)
5478 5485 if isinstance(gen, streamclone.streamcloneapplier):
5479 5486 raise error.Abort(
5480 5487 _('packed bundles cannot be applied with '
5481 5488 '"hg unbundle"'),
5482 5489 hint=_('use "hg debugapplystreamclonebundle"'))
5483 5490 url = 'bundle:' + fname
5484 5491 try:
5485 5492 txnname = 'unbundle'
5486 5493 if not isinstance(gen, bundle2.unbundle20):
5487 5494 txnname = 'unbundle\n%s' % util.hidepassword(url)
5488 5495 with repo.transaction(txnname) as tr:
5489 5496 op = bundle2.applybundle(repo, gen, tr, source='unbundle',
5490 5497 url=url)
5491 5498 except error.BundleUnknownFeatureError as exc:
5492 5499 raise error.Abort(
5493 5500 _('%s: unknown bundle feature, %s') % (fname, exc),
5494 5501 hint=_("see https://mercurial-scm.org/"
5495 5502 "wiki/BundleFeature for more "
5496 5503 "information"))
5497 5504 modheads = bundle2.combinechangegroupresults(op)
5498 5505
5499 5506 return postincoming(ui, repo, modheads, opts.get(r'update'), None, None)
5500 5507
5501 5508 @command('^update|up|checkout|co',
5502 5509 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
5503 5510 ('c', 'check', None, _('require clean working directory')),
5504 5511 ('m', 'merge', None, _('merge uncommitted changes')),
5505 5512 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5506 5513 ('r', 'rev', '', _('revision'), _('REV'))
5507 5514 ] + mergetoolopts,
5508 5515 _('[-C|-c|-m] [-d DATE] [[-r] REV]'))
5509 5516 def update(ui, repo, node=None, **opts):
5510 5517 """update working directory (or switch revisions)
5511 5518
5512 5519 Update the repository's working directory to the specified
5513 5520 changeset. If no changeset is specified, update to the tip of the
5514 5521 current named branch and move the active bookmark (see :hg:`help
5515 5522 bookmarks`).
5516 5523
5517 5524 Update sets the working directory's parent revision to the specified
5518 5525 changeset (see :hg:`help parents`).
5519 5526
5520 5527 If the changeset is not a descendant or ancestor of the working
5521 5528 directory's parent and there are uncommitted changes, the update is
5522 5529 aborted. With the -c/--check option, the working directory is checked
5523 5530 for uncommitted changes; if none are found, the working directory is
5524 5531 updated to the specified changeset.
5525 5532
5526 5533 .. container:: verbose
5527 5534
5528 5535 The -C/--clean, -c/--check, and -m/--merge options control what
5529 5536 happens if the working directory contains uncommitted changes.
5530 5537 At most of one of them can be specified.
5531 5538
5532 5539 1. If no option is specified, and if
5533 5540 the requested changeset is an ancestor or descendant of
5534 5541 the working directory's parent, the uncommitted changes
5535 5542 are merged into the requested changeset and the merged
5536 5543 result is left uncommitted. If the requested changeset is
5537 5544 not an ancestor or descendant (that is, it is on another
5538 5545 branch), the update is aborted and the uncommitted changes
5539 5546 are preserved.
5540 5547
5541 5548 2. With the -m/--merge option, the update is allowed even if the
5542 5549 requested changeset is not an ancestor or descendant of
5543 5550 the working directory's parent.
5544 5551
5545 5552 3. With the -c/--check option, the update is aborted and the
5546 5553 uncommitted changes are preserved.
5547 5554
5548 5555 4. With the -C/--clean option, uncommitted changes are discarded and
5549 5556 the working directory is updated to the requested changeset.
5550 5557
5551 5558 To cancel an uncommitted merge (and lose your changes), use
5552 5559 :hg:`merge --abort`.
5553 5560
5554 5561 Use null as the changeset to remove the working directory (like
5555 5562 :hg:`clone -U`).
5556 5563
5557 5564 If you want to revert just one file to an older revision, use
5558 5565 :hg:`revert [-r REV] NAME`.
5559 5566
5560 5567 See :hg:`help dates` for a list of formats valid for -d/--date.
5561 5568
5562 5569 Returns 0 on success, 1 if there are unresolved files.
5563 5570 """
5564 5571 rev = opts.get(r'rev')
5565 5572 date = opts.get(r'date')
5566 5573 clean = opts.get(r'clean')
5567 5574 check = opts.get(r'check')
5568 5575 merge = opts.get(r'merge')
5569 5576 if rev and node:
5570 5577 raise error.Abort(_("please specify just one revision"))
5571 5578
5572 5579 if ui.configbool('commands', 'update.requiredest'):
5573 5580 if not node and not rev and not date:
5574 5581 raise error.Abort(_('you must specify a destination'),
5575 5582 hint=_('for example: hg update ".::"'))
5576 5583
5577 5584 if rev is None or rev == '':
5578 5585 rev = node
5579 5586
5580 5587 if date and rev is not None:
5581 5588 raise error.Abort(_("you can't specify a revision and a date"))
5582 5589
5583 5590 if len([x for x in (clean, check, merge) if x]) > 1:
5584 5591 raise error.Abort(_("can only specify one of -C/--clean, -c/--check, "
5585 5592 "or -m/--merge"))
5586 5593
5587 5594 updatecheck = None
5588 5595 if check:
5589 5596 updatecheck = 'abort'
5590 5597 elif merge:
5591 5598 updatecheck = 'none'
5592 5599
5593 5600 with repo.wlock():
5594 5601 cmdutil.clearunfinished(repo)
5595 5602
5596 5603 if date:
5597 5604 rev = cmdutil.finddate(ui, repo, date)
5598 5605
5599 5606 # if we defined a bookmark, we have to remember the original name
5600 5607 brev = rev
5601 5608 if rev:
5602 5609 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
5603 5610 ctx = scmutil.revsingle(repo, rev, rev)
5604 5611 rev = ctx.rev()
5605 5612 hidden = ctx.hidden()
5606 5613 repo.ui.setconfig('ui', 'forcemerge', opts.get(r'tool'), 'update')
5607 5614
5608 5615 ret = hg.updatetotally(ui, repo, rev, brev, clean=clean,
5609 5616 updatecheck=updatecheck)
5610 5617 if hidden:
5611 5618 ctxstr = ctx.hex()[:12]
5612 5619 ui.warn(_("updated to hidden changeset %s\n") % ctxstr)
5613 5620
5614 5621 if ctx.obsolete():
5615 5622 obsfatemsg = obsutil._getfilteredreason(repo, ctxstr, ctx)
5616 5623 ui.warn("(%s)\n" % obsfatemsg)
5617 5624 return ret
5618 5625
5619 5626 @command('verify', [])
5620 5627 def verify(ui, repo):
5621 5628 """verify the integrity of the repository
5622 5629
5623 5630 Verify the integrity of the current repository.
5624 5631
5625 5632 This will perform an extensive check of the repository's
5626 5633 integrity, validating the hashes and checksums of each entry in
5627 5634 the changelog, manifest, and tracked files, as well as the
5628 5635 integrity of their crosslinks and indices.
5629 5636
5630 5637 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
5631 5638 for more information about recovery from corruption of the
5632 5639 repository.
5633 5640
5634 5641 Returns 0 on success, 1 if errors are encountered.
5635 5642 """
5636 5643 return hg.verify(repo)
5637 5644
5638 5645 @command('version', [] + formatteropts, norepo=True,
5639 5646 intents={INTENT_READONLY})
5640 5647 def version_(ui, **opts):
5641 5648 """output version and copyright information"""
5642 5649 opts = pycompat.byteskwargs(opts)
5643 5650 if ui.verbose:
5644 5651 ui.pager('version')
5645 5652 fm = ui.formatter("version", opts)
5646 5653 fm.startitem()
5647 5654 fm.write("ver", _("Mercurial Distributed SCM (version %s)\n"),
5648 5655 util.version())
5649 5656 license = _(
5650 5657 "(see https://mercurial-scm.org for more information)\n"
5651 5658 "\nCopyright (C) 2005-2018 Matt Mackall and others\n"
5652 5659 "This is free software; see the source for copying conditions. "
5653 5660 "There is NO\nwarranty; "
5654 5661 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
5655 5662 )
5656 5663 if not ui.quiet:
5657 5664 fm.plain(license)
5658 5665
5659 5666 if ui.verbose:
5660 5667 fm.plain(_("\nEnabled extensions:\n\n"))
5661 5668 # format names and versions into columns
5662 5669 names = []
5663 5670 vers = []
5664 5671 isinternals = []
5665 5672 for name, module in extensions.extensions():
5666 5673 names.append(name)
5667 5674 vers.append(extensions.moduleversion(module) or None)
5668 5675 isinternals.append(extensions.ismoduleinternal(module))
5669 5676 fn = fm.nested("extensions", tmpl='{name}\n')
5670 5677 if names:
5671 5678 namefmt = " %%-%ds " % max(len(n) for n in names)
5672 5679 places = [_("external"), _("internal")]
5673 5680 for n, v, p in zip(names, vers, isinternals):
5674 5681 fn.startitem()
5675 5682 fn.condwrite(ui.verbose, "name", namefmt, n)
5676 5683 if ui.verbose:
5677 5684 fn.plain("%s " % places[p])
5678 5685 fn.data(bundled=p)
5679 5686 fn.condwrite(ui.verbose and v, "ver", "%s", v)
5680 5687 if ui.verbose:
5681 5688 fn.plain("\n")
5682 5689 fn.end()
5683 5690 fm.end()
5684 5691
5685 5692 def loadcmdtable(ui, name, cmdtable):
5686 5693 """Load command functions from specified cmdtable
5687 5694 """
5688 5695 overrides = [cmd for cmd in cmdtable if cmd in table]
5689 5696 if overrides:
5690 5697 ui.warn(_("extension '%s' overrides commands: %s\n")
5691 5698 % (name, " ".join(overrides)))
5692 5699 table.update(cmdtable)
@@ -1,1344 +1,1347 b''
1 1 # configitems.py - centralized declaration of configuration option
2 2 #
3 3 # Copyright 2017 Pierre-Yves David <pierre-yves.david@octobus.net>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9 9
10 10 import functools
11 11 import re
12 12
13 13 from . import (
14 14 encoding,
15 15 error,
16 16 )
17 17
18 18 def loadconfigtable(ui, extname, configtable):
19 19 """update config item known to the ui with the extension ones"""
20 20 for section, items in sorted(configtable.items()):
21 21 knownitems = ui._knownconfig.setdefault(section, itemregister())
22 22 knownkeys = set(knownitems)
23 23 newkeys = set(items)
24 24 for key in sorted(knownkeys & newkeys):
25 25 msg = "extension '%s' overwrite config item '%s.%s'"
26 26 msg %= (extname, section, key)
27 27 ui.develwarn(msg, config='warn-config')
28 28
29 29 knownitems.update(items)
30 30
31 31 class configitem(object):
32 32 """represent a known config item
33 33
34 34 :section: the official config section where to find this item,
35 35 :name: the official name within the section,
36 36 :default: default value for this item,
37 37 :alias: optional list of tuples as alternatives,
38 38 :generic: this is a generic definition, match name using regular expression.
39 39 """
40 40
41 41 def __init__(self, section, name, default=None, alias=(),
42 42 generic=False, priority=0):
43 43 self.section = section
44 44 self.name = name
45 45 self.default = default
46 46 self.alias = list(alias)
47 47 self.generic = generic
48 48 self.priority = priority
49 49 self._re = None
50 50 if generic:
51 51 self._re = re.compile(self.name)
52 52
53 53 class itemregister(dict):
54 54 """A specialized dictionary that can handle wild-card selection"""
55 55
56 56 def __init__(self):
57 57 super(itemregister, self).__init__()
58 58 self._generics = set()
59 59
60 60 def update(self, other):
61 61 super(itemregister, self).update(other)
62 62 self._generics.update(other._generics)
63 63
64 64 def __setitem__(self, key, item):
65 65 super(itemregister, self).__setitem__(key, item)
66 66 if item.generic:
67 67 self._generics.add(item)
68 68
69 69 def get(self, key):
70 70 baseitem = super(itemregister, self).get(key)
71 71 if baseitem is not None and not baseitem.generic:
72 72 return baseitem
73 73
74 74 # search for a matching generic item
75 75 generics = sorted(self._generics, key=(lambda x: (x.priority, x.name)))
76 76 for item in generics:
77 77 # we use 'match' instead of 'search' to make the matching simpler
78 78 # for people unfamiliar with regular expression. Having the match
79 79 # rooted to the start of the string will produce less surprising
80 80 # result for user writing simple regex for sub-attribute.
81 81 #
82 82 # For example using "color\..*" match produces an unsurprising
83 83 # result, while using search could suddenly match apparently
84 84 # unrelated configuration that happens to contains "color."
85 85 # anywhere. This is a tradeoff where we favor requiring ".*" on
86 86 # some match to avoid the need to prefix most pattern with "^".
87 87 # The "^" seems more error prone.
88 88 if item._re.match(key):
89 89 return item
90 90
91 91 return None
92 92
93 93 coreitems = {}
94 94
95 95 def _register(configtable, *args, **kwargs):
96 96 item = configitem(*args, **kwargs)
97 97 section = configtable.setdefault(item.section, itemregister())
98 98 if item.name in section:
99 99 msg = "duplicated config item registration for '%s.%s'"
100 100 raise error.ProgrammingError(msg % (item.section, item.name))
101 101 section[item.name] = item
102 102
103 103 # special value for case where the default is derived from other values
104 104 dynamicdefault = object()
105 105
106 106 # Registering actual config items
107 107
108 108 def getitemregister(configtable):
109 109 f = functools.partial(_register, configtable)
110 110 # export pseudo enum as configitem.*
111 111 f.dynamicdefault = dynamicdefault
112 112 return f
113 113
114 114 coreconfigitem = getitemregister(coreitems)
115 115
116 116 coreconfigitem('alias', '.*',
117 117 default=dynamicdefault,
118 118 generic=True,
119 119 )
120 120 coreconfigitem('annotate', 'nodates',
121 121 default=False,
122 122 )
123 123 coreconfigitem('annotate', 'showfunc',
124 124 default=False,
125 125 )
126 126 coreconfigitem('annotate', 'unified',
127 127 default=None,
128 128 )
129 129 coreconfigitem('annotate', 'git',
130 130 default=False,
131 131 )
132 132 coreconfigitem('annotate', 'ignorews',
133 133 default=False,
134 134 )
135 135 coreconfigitem('annotate', 'ignorewsamount',
136 136 default=False,
137 137 )
138 138 coreconfigitem('annotate', 'ignoreblanklines',
139 139 default=False,
140 140 )
141 141 coreconfigitem('annotate', 'ignorewseol',
142 142 default=False,
143 143 )
144 144 coreconfigitem('annotate', 'nobinary',
145 145 default=False,
146 146 )
147 147 coreconfigitem('annotate', 'noprefix',
148 148 default=False,
149 149 )
150 150 coreconfigitem('auth', 'cookiefile',
151 151 default=None,
152 152 )
153 153 # bookmarks.pushing: internal hack for discovery
154 154 coreconfigitem('bookmarks', 'pushing',
155 155 default=list,
156 156 )
157 157 # bundle.mainreporoot: internal hack for bundlerepo
158 158 coreconfigitem('bundle', 'mainreporoot',
159 159 default='',
160 160 )
161 161 # bundle.reorder: experimental config
162 162 coreconfigitem('bundle', 'reorder',
163 163 default='auto',
164 164 )
165 165 coreconfigitem('censor', 'policy',
166 166 default='abort',
167 167 )
168 168 coreconfigitem('chgserver', 'idletimeout',
169 169 default=3600,
170 170 )
171 171 coreconfigitem('chgserver', 'skiphash',
172 172 default=False,
173 173 )
174 174 coreconfigitem('cmdserver', 'log',
175 175 default=None,
176 176 )
177 177 coreconfigitem('color', '.*',
178 178 default=None,
179 179 generic=True,
180 180 )
181 181 coreconfigitem('color', 'mode',
182 182 default='auto',
183 183 )
184 184 coreconfigitem('color', 'pagermode',
185 185 default=dynamicdefault,
186 186 )
187 187 coreconfigitem('commands', 'show.aliasprefix',
188 188 default=list,
189 189 )
190 190 coreconfigitem('commands', 'status.relative',
191 191 default=False,
192 192 )
193 193 coreconfigitem('commands', 'status.skipstates',
194 194 default=[],
195 195 )
196 coreconfigitem('commands', 'status.terse',
197 default='',
198 )
196 199 coreconfigitem('commands', 'status.verbose',
197 200 default=False,
198 201 )
199 202 coreconfigitem('commands', 'update.check',
200 203 default=None,
201 204 # Deprecated, remove after 4.4 release
202 205 alias=[('experimental', 'updatecheck')]
203 206 )
204 207 coreconfigitem('commands', 'update.requiredest',
205 208 default=False,
206 209 )
207 210 coreconfigitem('committemplate', '.*',
208 211 default=None,
209 212 generic=True,
210 213 )
211 214 coreconfigitem('convert', 'cvsps.cache',
212 215 default=True,
213 216 )
214 217 coreconfigitem('convert', 'cvsps.fuzz',
215 218 default=60,
216 219 )
217 220 coreconfigitem('convert', 'cvsps.logencoding',
218 221 default=None,
219 222 )
220 223 coreconfigitem('convert', 'cvsps.mergefrom',
221 224 default=None,
222 225 )
223 226 coreconfigitem('convert', 'cvsps.mergeto',
224 227 default=None,
225 228 )
226 229 coreconfigitem('convert', 'git.committeractions',
227 230 default=lambda: ['messagedifferent'],
228 231 )
229 232 coreconfigitem('convert', 'git.extrakeys',
230 233 default=list,
231 234 )
232 235 coreconfigitem('convert', 'git.findcopiesharder',
233 236 default=False,
234 237 )
235 238 coreconfigitem('convert', 'git.remoteprefix',
236 239 default='remote',
237 240 )
238 241 coreconfigitem('convert', 'git.renamelimit',
239 242 default=400,
240 243 )
241 244 coreconfigitem('convert', 'git.saverev',
242 245 default=True,
243 246 )
244 247 coreconfigitem('convert', 'git.similarity',
245 248 default=50,
246 249 )
247 250 coreconfigitem('convert', 'git.skipsubmodules',
248 251 default=False,
249 252 )
250 253 coreconfigitem('convert', 'hg.clonebranches',
251 254 default=False,
252 255 )
253 256 coreconfigitem('convert', 'hg.ignoreerrors',
254 257 default=False,
255 258 )
256 259 coreconfigitem('convert', 'hg.revs',
257 260 default=None,
258 261 )
259 262 coreconfigitem('convert', 'hg.saverev',
260 263 default=False,
261 264 )
262 265 coreconfigitem('convert', 'hg.sourcename',
263 266 default=None,
264 267 )
265 268 coreconfigitem('convert', 'hg.startrev',
266 269 default=None,
267 270 )
268 271 coreconfigitem('convert', 'hg.tagsbranch',
269 272 default='default',
270 273 )
271 274 coreconfigitem('convert', 'hg.usebranchnames',
272 275 default=True,
273 276 )
274 277 coreconfigitem('convert', 'ignoreancestorcheck',
275 278 default=False,
276 279 )
277 280 coreconfigitem('convert', 'localtimezone',
278 281 default=False,
279 282 )
280 283 coreconfigitem('convert', 'p4.encoding',
281 284 default=dynamicdefault,
282 285 )
283 286 coreconfigitem('convert', 'p4.startrev',
284 287 default=0,
285 288 )
286 289 coreconfigitem('convert', 'skiptags',
287 290 default=False,
288 291 )
289 292 coreconfigitem('convert', 'svn.debugsvnlog',
290 293 default=True,
291 294 )
292 295 coreconfigitem('convert', 'svn.trunk',
293 296 default=None,
294 297 )
295 298 coreconfigitem('convert', 'svn.tags',
296 299 default=None,
297 300 )
298 301 coreconfigitem('convert', 'svn.branches',
299 302 default=None,
300 303 )
301 304 coreconfigitem('convert', 'svn.startrev',
302 305 default=0,
303 306 )
304 307 coreconfigitem('debug', 'dirstate.delaywrite',
305 308 default=0,
306 309 )
307 310 coreconfigitem('defaults', '.*',
308 311 default=None,
309 312 generic=True,
310 313 )
311 314 coreconfigitem('devel', 'all-warnings',
312 315 default=False,
313 316 )
314 317 coreconfigitem('devel', 'bundle2.debug',
315 318 default=False,
316 319 )
317 320 coreconfigitem('devel', 'cache-vfs',
318 321 default=None,
319 322 )
320 323 coreconfigitem('devel', 'check-locks',
321 324 default=False,
322 325 )
323 326 coreconfigitem('devel', 'check-relroot',
324 327 default=False,
325 328 )
326 329 coreconfigitem('devel', 'default-date',
327 330 default=None,
328 331 )
329 332 coreconfigitem('devel', 'deprec-warn',
330 333 default=False,
331 334 )
332 335 coreconfigitem('devel', 'disableloaddefaultcerts',
333 336 default=False,
334 337 )
335 338 coreconfigitem('devel', 'warn-empty-changegroup',
336 339 default=False,
337 340 )
338 341 coreconfigitem('devel', 'legacy.exchange',
339 342 default=list,
340 343 )
341 344 coreconfigitem('devel', 'servercafile',
342 345 default='',
343 346 )
344 347 coreconfigitem('devel', 'serverexactprotocol',
345 348 default='',
346 349 )
347 350 coreconfigitem('devel', 'serverrequirecert',
348 351 default=False,
349 352 )
350 353 coreconfigitem('devel', 'strip-obsmarkers',
351 354 default=True,
352 355 )
353 356 coreconfigitem('devel', 'warn-config',
354 357 default=None,
355 358 )
356 359 coreconfigitem('devel', 'warn-config-default',
357 360 default=None,
358 361 )
359 362 coreconfigitem('devel', 'user.obsmarker',
360 363 default=None,
361 364 )
362 365 coreconfigitem('devel', 'warn-config-unknown',
363 366 default=None,
364 367 )
365 368 coreconfigitem('devel', 'debug.peer-request',
366 369 default=False,
367 370 )
368 371 coreconfigitem('diff', 'nodates',
369 372 default=False,
370 373 )
371 374 coreconfigitem('diff', 'showfunc',
372 375 default=False,
373 376 )
374 377 coreconfigitem('diff', 'unified',
375 378 default=None,
376 379 )
377 380 coreconfigitem('diff', 'git',
378 381 default=False,
379 382 )
380 383 coreconfigitem('diff', 'ignorews',
381 384 default=False,
382 385 )
383 386 coreconfigitem('diff', 'ignorewsamount',
384 387 default=False,
385 388 )
386 389 coreconfigitem('diff', 'ignoreblanklines',
387 390 default=False,
388 391 )
389 392 coreconfigitem('diff', 'ignorewseol',
390 393 default=False,
391 394 )
392 395 coreconfigitem('diff', 'nobinary',
393 396 default=False,
394 397 )
395 398 coreconfigitem('diff', 'noprefix',
396 399 default=False,
397 400 )
398 401 coreconfigitem('email', 'bcc',
399 402 default=None,
400 403 )
401 404 coreconfigitem('email', 'cc',
402 405 default=None,
403 406 )
404 407 coreconfigitem('email', 'charsets',
405 408 default=list,
406 409 )
407 410 coreconfigitem('email', 'from',
408 411 default=None,
409 412 )
410 413 coreconfigitem('email', 'method',
411 414 default='smtp',
412 415 )
413 416 coreconfigitem('email', 'reply-to',
414 417 default=None,
415 418 )
416 419 coreconfigitem('email', 'to',
417 420 default=None,
418 421 )
419 422 coreconfigitem('experimental', 'archivemetatemplate',
420 423 default=dynamicdefault,
421 424 )
422 425 coreconfigitem('experimental', 'bundle-phases',
423 426 default=False,
424 427 )
425 428 coreconfigitem('experimental', 'bundle2-advertise',
426 429 default=True,
427 430 )
428 431 coreconfigitem('experimental', 'bundle2-output-capture',
429 432 default=False,
430 433 )
431 434 coreconfigitem('experimental', 'bundle2.pushback',
432 435 default=False,
433 436 )
434 437 coreconfigitem('experimental', 'bundle2.stream',
435 438 default=False,
436 439 )
437 440 coreconfigitem('experimental', 'bundle2lazylocking',
438 441 default=False,
439 442 )
440 443 coreconfigitem('experimental', 'bundlecomplevel',
441 444 default=None,
442 445 )
443 446 coreconfigitem('experimental', 'bundlecomplevel.bzip2',
444 447 default=None,
445 448 )
446 449 coreconfigitem('experimental', 'bundlecomplevel.gzip',
447 450 default=None,
448 451 )
449 452 coreconfigitem('experimental', 'bundlecomplevel.none',
450 453 default=None,
451 454 )
452 455 coreconfigitem('experimental', 'bundlecomplevel.zstd',
453 456 default=None,
454 457 )
455 458 coreconfigitem('experimental', 'changegroup3',
456 459 default=False,
457 460 )
458 461 coreconfigitem('experimental', 'clientcompressionengines',
459 462 default=list,
460 463 )
461 464 coreconfigitem('experimental', 'copytrace',
462 465 default='on',
463 466 )
464 467 coreconfigitem('experimental', 'copytrace.movecandidateslimit',
465 468 default=100,
466 469 )
467 470 coreconfigitem('experimental', 'copytrace.sourcecommitlimit',
468 471 default=100,
469 472 )
470 473 coreconfigitem('experimental', 'crecordtest',
471 474 default=None,
472 475 )
473 476 coreconfigitem('experimental', 'directaccess',
474 477 default=False,
475 478 )
476 479 coreconfigitem('experimental', 'directaccess.revnums',
477 480 default=False,
478 481 )
479 482 coreconfigitem('experimental', 'editortmpinhg',
480 483 default=False,
481 484 )
482 485 coreconfigitem('experimental', 'evolution',
483 486 default=list,
484 487 )
485 488 coreconfigitem('experimental', 'evolution.allowdivergence',
486 489 default=False,
487 490 alias=[('experimental', 'allowdivergence')]
488 491 )
489 492 coreconfigitem('experimental', 'evolution.allowunstable',
490 493 default=None,
491 494 )
492 495 coreconfigitem('experimental', 'evolution.createmarkers',
493 496 default=None,
494 497 )
495 498 coreconfigitem('experimental', 'evolution.effect-flags',
496 499 default=True,
497 500 alias=[('experimental', 'effect-flags')]
498 501 )
499 502 coreconfigitem('experimental', 'evolution.exchange',
500 503 default=None,
501 504 )
502 505 coreconfigitem('experimental', 'evolution.bundle-obsmarker',
503 506 default=False,
504 507 )
505 508 coreconfigitem('experimental', 'evolution.report-instabilities',
506 509 default=True,
507 510 )
508 511 coreconfigitem('experimental', 'evolution.track-operation',
509 512 default=True,
510 513 )
511 514 coreconfigitem('experimental', 'worddiff',
512 515 default=False,
513 516 )
514 517 coreconfigitem('experimental', 'maxdeltachainspan',
515 518 default=-1,
516 519 )
517 520 coreconfigitem('experimental', 'mergetempdirprefix',
518 521 default=None,
519 522 )
520 523 coreconfigitem('experimental', 'mmapindexthreshold',
521 524 default=None,
522 525 )
523 526 coreconfigitem('experimental', 'nonnormalparanoidcheck',
524 527 default=False,
525 528 )
526 529 coreconfigitem('experimental', 'exportableenviron',
527 530 default=list,
528 531 )
529 532 coreconfigitem('experimental', 'extendedheader.index',
530 533 default=None,
531 534 )
532 535 coreconfigitem('experimental', 'extendedheader.similarity',
533 536 default=False,
534 537 )
535 538 coreconfigitem('experimental', 'format.compression',
536 539 default='zlib',
537 540 )
538 541 coreconfigitem('experimental', 'graphshorten',
539 542 default=False,
540 543 )
541 544 coreconfigitem('experimental', 'graphstyle.parent',
542 545 default=dynamicdefault,
543 546 )
544 547 coreconfigitem('experimental', 'graphstyle.missing',
545 548 default=dynamicdefault,
546 549 )
547 550 coreconfigitem('experimental', 'graphstyle.grandparent',
548 551 default=dynamicdefault,
549 552 )
550 553 coreconfigitem('experimental', 'hook-track-tags',
551 554 default=False,
552 555 )
553 556 coreconfigitem('experimental', 'httppeer.advertise-v2',
554 557 default=False,
555 558 )
556 559 coreconfigitem('experimental', 'httppostargs',
557 560 default=False,
558 561 )
559 562 coreconfigitem('experimental', 'mergedriver',
560 563 default=None,
561 564 )
562 565 coreconfigitem('experimental', 'obsmarkers-exchange-debug',
563 566 default=False,
564 567 )
565 568 coreconfigitem('experimental', 'remotenames',
566 569 default=False,
567 570 )
568 571 coreconfigitem('experimental', 'revlogv2',
569 572 default=None,
570 573 )
571 574 coreconfigitem('experimental', 'single-head-per-branch',
572 575 default=False,
573 576 )
574 577 coreconfigitem('experimental', 'sshserver.support-v2',
575 578 default=False,
576 579 )
577 580 coreconfigitem('experimental', 'spacemovesdown',
578 581 default=False,
579 582 )
580 583 coreconfigitem('experimental', 'sparse-read',
581 584 default=False,
582 585 )
583 586 coreconfigitem('experimental', 'sparse-read.density-threshold',
584 587 default=0.25,
585 588 )
586 589 coreconfigitem('experimental', 'sparse-read.min-gap-size',
587 590 default='256K',
588 591 )
589 592 coreconfigitem('experimental', 'treemanifest',
590 593 default=False,
591 594 )
592 595 coreconfigitem('experimental', 'update.atomic-file',
593 596 default=False,
594 597 )
595 598 coreconfigitem('experimental', 'sshpeer.advertise-v2',
596 599 default=False,
597 600 )
598 601 coreconfigitem('experimental', 'web.apiserver',
599 602 default=False,
600 603 )
601 604 coreconfigitem('experimental', 'web.api.http-v2',
602 605 default=False,
603 606 )
604 607 coreconfigitem('experimental', 'web.api.debugreflect',
605 608 default=False,
606 609 )
607 610 coreconfigitem('experimental', 'xdiff',
608 611 default=False,
609 612 )
610 613 coreconfigitem('extensions', '.*',
611 614 default=None,
612 615 generic=True,
613 616 )
614 617 coreconfigitem('extdata', '.*',
615 618 default=None,
616 619 generic=True,
617 620 )
618 621 coreconfigitem('format', 'aggressivemergedeltas',
619 622 default=False,
620 623 )
621 624 coreconfigitem('format', 'chunkcachesize',
622 625 default=None,
623 626 )
624 627 coreconfigitem('format', 'dotencode',
625 628 default=True,
626 629 )
627 630 coreconfigitem('format', 'generaldelta',
628 631 default=False,
629 632 )
630 633 coreconfigitem('format', 'manifestcachesize',
631 634 default=None,
632 635 )
633 636 coreconfigitem('format', 'maxchainlen',
634 637 default=None,
635 638 )
636 639 coreconfigitem('format', 'obsstore-version',
637 640 default=None,
638 641 )
639 642 coreconfigitem('format', 'usefncache',
640 643 default=True,
641 644 )
642 645 coreconfigitem('format', 'usegeneraldelta',
643 646 default=True,
644 647 )
645 648 coreconfigitem('format', 'usestore',
646 649 default=True,
647 650 )
648 651 coreconfigitem('fsmonitor', 'warn_when_unused',
649 652 default=True,
650 653 )
651 654 coreconfigitem('fsmonitor', 'warn_update_file_count',
652 655 default=50000,
653 656 )
654 657 coreconfigitem('hooks', '.*',
655 658 default=dynamicdefault,
656 659 generic=True,
657 660 )
658 661 coreconfigitem('hgweb-paths', '.*',
659 662 default=list,
660 663 generic=True,
661 664 )
662 665 coreconfigitem('hostfingerprints', '.*',
663 666 default=list,
664 667 generic=True,
665 668 )
666 669 coreconfigitem('hostsecurity', 'ciphers',
667 670 default=None,
668 671 )
669 672 coreconfigitem('hostsecurity', 'disabletls10warning',
670 673 default=False,
671 674 )
672 675 coreconfigitem('hostsecurity', 'minimumprotocol',
673 676 default=dynamicdefault,
674 677 )
675 678 coreconfigitem('hostsecurity', '.*:minimumprotocol$',
676 679 default=dynamicdefault,
677 680 generic=True,
678 681 )
679 682 coreconfigitem('hostsecurity', '.*:ciphers$',
680 683 default=dynamicdefault,
681 684 generic=True,
682 685 )
683 686 coreconfigitem('hostsecurity', '.*:fingerprints$',
684 687 default=list,
685 688 generic=True,
686 689 )
687 690 coreconfigitem('hostsecurity', '.*:verifycertsfile$',
688 691 default=None,
689 692 generic=True,
690 693 )
691 694
692 695 coreconfigitem('http_proxy', 'always',
693 696 default=False,
694 697 )
695 698 coreconfigitem('http_proxy', 'host',
696 699 default=None,
697 700 )
698 701 coreconfigitem('http_proxy', 'no',
699 702 default=list,
700 703 )
701 704 coreconfigitem('http_proxy', 'passwd',
702 705 default=None,
703 706 )
704 707 coreconfigitem('http_proxy', 'user',
705 708 default=None,
706 709 )
707 710 coreconfigitem('logtoprocess', 'commandexception',
708 711 default=None,
709 712 )
710 713 coreconfigitem('logtoprocess', 'commandfinish',
711 714 default=None,
712 715 )
713 716 coreconfigitem('logtoprocess', 'command',
714 717 default=None,
715 718 )
716 719 coreconfigitem('logtoprocess', 'develwarn',
717 720 default=None,
718 721 )
719 722 coreconfigitem('logtoprocess', 'uiblocked',
720 723 default=None,
721 724 )
722 725 coreconfigitem('merge', 'checkunknown',
723 726 default='abort',
724 727 )
725 728 coreconfigitem('merge', 'checkignored',
726 729 default='abort',
727 730 )
728 731 coreconfigitem('experimental', 'merge.checkpathconflicts',
729 732 default=False,
730 733 )
731 734 coreconfigitem('merge', 'followcopies',
732 735 default=True,
733 736 )
734 737 coreconfigitem('merge', 'on-failure',
735 738 default='continue',
736 739 )
737 740 coreconfigitem('merge', 'preferancestor',
738 741 default=lambda: ['*'],
739 742 )
740 743 coreconfigitem('merge-tools', '.*',
741 744 default=None,
742 745 generic=True,
743 746 )
744 747 coreconfigitem('merge-tools', br'.*\.args$',
745 748 default="$local $base $other",
746 749 generic=True,
747 750 priority=-1,
748 751 )
749 752 coreconfigitem('merge-tools', br'.*\.binary$',
750 753 default=False,
751 754 generic=True,
752 755 priority=-1,
753 756 )
754 757 coreconfigitem('merge-tools', br'.*\.check$',
755 758 default=list,
756 759 generic=True,
757 760 priority=-1,
758 761 )
759 762 coreconfigitem('merge-tools', br'.*\.checkchanged$',
760 763 default=False,
761 764 generic=True,
762 765 priority=-1,
763 766 )
764 767 coreconfigitem('merge-tools', br'.*\.executable$',
765 768 default=dynamicdefault,
766 769 generic=True,
767 770 priority=-1,
768 771 )
769 772 coreconfigitem('merge-tools', br'.*\.fixeol$',
770 773 default=False,
771 774 generic=True,
772 775 priority=-1,
773 776 )
774 777 coreconfigitem('merge-tools', br'.*\.gui$',
775 778 default=False,
776 779 generic=True,
777 780 priority=-1,
778 781 )
779 782 coreconfigitem('merge-tools', br'.*\.mergemarkers$',
780 783 default='basic',
781 784 generic=True,
782 785 priority=-1,
783 786 )
784 787 coreconfigitem('merge-tools', br'.*\.mergemarkertemplate$',
785 788 default=dynamicdefault, # take from ui.mergemarkertemplate
786 789 generic=True,
787 790 priority=-1,
788 791 )
789 792 coreconfigitem('merge-tools', br'.*\.priority$',
790 793 default=0,
791 794 generic=True,
792 795 priority=-1,
793 796 )
794 797 coreconfigitem('merge-tools', br'.*\.premerge$',
795 798 default=dynamicdefault,
796 799 generic=True,
797 800 priority=-1,
798 801 )
799 802 coreconfigitem('merge-tools', br'.*\.symlink$',
800 803 default=False,
801 804 generic=True,
802 805 priority=-1,
803 806 )
804 807 coreconfigitem('pager', 'attend-.*',
805 808 default=dynamicdefault,
806 809 generic=True,
807 810 )
808 811 coreconfigitem('pager', 'ignore',
809 812 default=list,
810 813 )
811 814 coreconfigitem('pager', 'pager',
812 815 default=dynamicdefault,
813 816 )
814 817 coreconfigitem('patch', 'eol',
815 818 default='strict',
816 819 )
817 820 coreconfigitem('patch', 'fuzz',
818 821 default=2,
819 822 )
820 823 coreconfigitem('paths', 'default',
821 824 default=None,
822 825 )
823 826 coreconfigitem('paths', 'default-push',
824 827 default=None,
825 828 )
826 829 coreconfigitem('paths', '.*',
827 830 default=None,
828 831 generic=True,
829 832 )
830 833 coreconfigitem('phases', 'checksubrepos',
831 834 default='follow',
832 835 )
833 836 coreconfigitem('phases', 'new-commit',
834 837 default='draft',
835 838 )
836 839 coreconfigitem('phases', 'publish',
837 840 default=True,
838 841 )
839 842 coreconfigitem('profiling', 'enabled',
840 843 default=False,
841 844 )
842 845 coreconfigitem('profiling', 'format',
843 846 default='text',
844 847 )
845 848 coreconfigitem('profiling', 'freq',
846 849 default=1000,
847 850 )
848 851 coreconfigitem('profiling', 'limit',
849 852 default=30,
850 853 )
851 854 coreconfigitem('profiling', 'nested',
852 855 default=0,
853 856 )
854 857 coreconfigitem('profiling', 'output',
855 858 default=None,
856 859 )
857 860 coreconfigitem('profiling', 'showmax',
858 861 default=0.999,
859 862 )
860 863 coreconfigitem('profiling', 'showmin',
861 864 default=dynamicdefault,
862 865 )
863 866 coreconfigitem('profiling', 'sort',
864 867 default='inlinetime',
865 868 )
866 869 coreconfigitem('profiling', 'statformat',
867 870 default='hotpath',
868 871 )
869 872 coreconfigitem('profiling', 'type',
870 873 default='stat',
871 874 )
872 875 coreconfigitem('progress', 'assume-tty',
873 876 default=False,
874 877 )
875 878 coreconfigitem('progress', 'changedelay',
876 879 default=1,
877 880 )
878 881 coreconfigitem('progress', 'clear-complete',
879 882 default=True,
880 883 )
881 884 coreconfigitem('progress', 'debug',
882 885 default=False,
883 886 )
884 887 coreconfigitem('progress', 'delay',
885 888 default=3,
886 889 )
887 890 coreconfigitem('progress', 'disable',
888 891 default=False,
889 892 )
890 893 coreconfigitem('progress', 'estimateinterval',
891 894 default=60.0,
892 895 )
893 896 coreconfigitem('progress', 'format',
894 897 default=lambda: ['topic', 'bar', 'number', 'estimate'],
895 898 )
896 899 coreconfigitem('progress', 'refresh',
897 900 default=0.1,
898 901 )
899 902 coreconfigitem('progress', 'width',
900 903 default=dynamicdefault,
901 904 )
902 905 coreconfigitem('push', 'pushvars.server',
903 906 default=False,
904 907 )
905 908 coreconfigitem('server', 'bookmarks-pushkey-compat',
906 909 default=True,
907 910 )
908 911 coreconfigitem('server', 'bundle1',
909 912 default=True,
910 913 )
911 914 coreconfigitem('server', 'bundle1gd',
912 915 default=None,
913 916 )
914 917 coreconfigitem('server', 'bundle1.pull',
915 918 default=None,
916 919 )
917 920 coreconfigitem('server', 'bundle1gd.pull',
918 921 default=None,
919 922 )
920 923 coreconfigitem('server', 'bundle1.push',
921 924 default=None,
922 925 )
923 926 coreconfigitem('server', 'bundle1gd.push',
924 927 default=None,
925 928 )
926 929 coreconfigitem('server', 'compressionengines',
927 930 default=list,
928 931 )
929 932 coreconfigitem('server', 'concurrent-push-mode',
930 933 default='strict',
931 934 )
932 935 coreconfigitem('server', 'disablefullbundle',
933 936 default=False,
934 937 )
935 938 coreconfigitem('server', 'streamunbundle',
936 939 default=False,
937 940 )
938 941 coreconfigitem('server', 'pullbundle',
939 942 default=False,
940 943 )
941 944 coreconfigitem('server', 'maxhttpheaderlen',
942 945 default=1024,
943 946 )
944 947 coreconfigitem('server', 'preferuncompressed',
945 948 default=False,
946 949 )
947 950 coreconfigitem('server', 'uncompressed',
948 951 default=True,
949 952 )
950 953 coreconfigitem('server', 'uncompressedallowsecret',
951 954 default=False,
952 955 )
953 956 coreconfigitem('server', 'validate',
954 957 default=False,
955 958 )
956 959 coreconfigitem('server', 'zliblevel',
957 960 default=-1,
958 961 )
959 962 coreconfigitem('server', 'zstdlevel',
960 963 default=3,
961 964 )
962 965 coreconfigitem('share', 'pool',
963 966 default=None,
964 967 )
965 968 coreconfigitem('share', 'poolnaming',
966 969 default='identity',
967 970 )
968 971 coreconfigitem('smtp', 'host',
969 972 default=None,
970 973 )
971 974 coreconfigitem('smtp', 'local_hostname',
972 975 default=None,
973 976 )
974 977 coreconfigitem('smtp', 'password',
975 978 default=None,
976 979 )
977 980 coreconfigitem('smtp', 'port',
978 981 default=dynamicdefault,
979 982 )
980 983 coreconfigitem('smtp', 'tls',
981 984 default='none',
982 985 )
983 986 coreconfigitem('smtp', 'username',
984 987 default=None,
985 988 )
986 989 coreconfigitem('sparse', 'missingwarning',
987 990 default=True,
988 991 )
989 992 coreconfigitem('subrepos', 'allowed',
990 993 default=dynamicdefault, # to make backporting simpler
991 994 )
992 995 coreconfigitem('subrepos', 'hg:allowed',
993 996 default=dynamicdefault,
994 997 )
995 998 coreconfigitem('subrepos', 'git:allowed',
996 999 default=dynamicdefault,
997 1000 )
998 1001 coreconfigitem('subrepos', 'svn:allowed',
999 1002 default=dynamicdefault,
1000 1003 )
1001 1004 coreconfigitem('templates', '.*',
1002 1005 default=None,
1003 1006 generic=True,
1004 1007 )
1005 1008 coreconfigitem('trusted', 'groups',
1006 1009 default=list,
1007 1010 )
1008 1011 coreconfigitem('trusted', 'users',
1009 1012 default=list,
1010 1013 )
1011 1014 coreconfigitem('ui', '_usedassubrepo',
1012 1015 default=False,
1013 1016 )
1014 1017 coreconfigitem('ui', 'allowemptycommit',
1015 1018 default=False,
1016 1019 )
1017 1020 coreconfigitem('ui', 'archivemeta',
1018 1021 default=True,
1019 1022 )
1020 1023 coreconfigitem('ui', 'askusername',
1021 1024 default=False,
1022 1025 )
1023 1026 coreconfigitem('ui', 'clonebundlefallback',
1024 1027 default=False,
1025 1028 )
1026 1029 coreconfigitem('ui', 'clonebundleprefers',
1027 1030 default=list,
1028 1031 )
1029 1032 coreconfigitem('ui', 'clonebundles',
1030 1033 default=True,
1031 1034 )
1032 1035 coreconfigitem('ui', 'color',
1033 1036 default='auto',
1034 1037 )
1035 1038 coreconfigitem('ui', 'commitsubrepos',
1036 1039 default=False,
1037 1040 )
1038 1041 coreconfigitem('ui', 'debug',
1039 1042 default=False,
1040 1043 )
1041 1044 coreconfigitem('ui', 'debugger',
1042 1045 default=None,
1043 1046 )
1044 1047 coreconfigitem('ui', 'editor',
1045 1048 default=dynamicdefault,
1046 1049 )
1047 1050 coreconfigitem('ui', 'fallbackencoding',
1048 1051 default=None,
1049 1052 )
1050 1053 coreconfigitem('ui', 'forcecwd',
1051 1054 default=None,
1052 1055 )
1053 1056 coreconfigitem('ui', 'forcemerge',
1054 1057 default=None,
1055 1058 )
1056 1059 coreconfigitem('ui', 'formatdebug',
1057 1060 default=False,
1058 1061 )
1059 1062 coreconfigitem('ui', 'formatjson',
1060 1063 default=False,
1061 1064 )
1062 1065 coreconfigitem('ui', 'formatted',
1063 1066 default=None,
1064 1067 )
1065 1068 coreconfigitem('ui', 'graphnodetemplate',
1066 1069 default=None,
1067 1070 )
1068 1071 coreconfigitem('ui', 'interactive',
1069 1072 default=None,
1070 1073 )
1071 1074 coreconfigitem('ui', 'interface',
1072 1075 default=None,
1073 1076 )
1074 1077 coreconfigitem('ui', 'interface.chunkselector',
1075 1078 default=None,
1076 1079 )
1077 1080 coreconfigitem('ui', 'logblockedtimes',
1078 1081 default=False,
1079 1082 )
1080 1083 coreconfigitem('ui', 'logtemplate',
1081 1084 default=None,
1082 1085 )
1083 1086 coreconfigitem('ui', 'merge',
1084 1087 default=None,
1085 1088 )
1086 1089 coreconfigitem('ui', 'mergemarkers',
1087 1090 default='basic',
1088 1091 )
1089 1092 coreconfigitem('ui', 'mergemarkertemplate',
1090 1093 default=('{node|short} '
1091 1094 '{ifeq(tags, "tip", "", '
1092 1095 'ifeq(tags, "", "", "{tags} "))}'
1093 1096 '{if(bookmarks, "{bookmarks} ")}'
1094 1097 '{ifeq(branch, "default", "", "{branch} ")}'
1095 1098 '- {author|user}: {desc|firstline}')
1096 1099 )
1097 1100 coreconfigitem('ui', 'nontty',
1098 1101 default=False,
1099 1102 )
1100 1103 coreconfigitem('ui', 'origbackuppath',
1101 1104 default=None,
1102 1105 )
1103 1106 coreconfigitem('ui', 'paginate',
1104 1107 default=True,
1105 1108 )
1106 1109 coreconfigitem('ui', 'patch',
1107 1110 default=None,
1108 1111 )
1109 1112 coreconfigitem('ui', 'portablefilenames',
1110 1113 default='warn',
1111 1114 )
1112 1115 coreconfigitem('ui', 'promptecho',
1113 1116 default=False,
1114 1117 )
1115 1118 coreconfigitem('ui', 'quiet',
1116 1119 default=False,
1117 1120 )
1118 1121 coreconfigitem('ui', 'quietbookmarkmove',
1119 1122 default=False,
1120 1123 )
1121 1124 coreconfigitem('ui', 'remotecmd',
1122 1125 default='hg',
1123 1126 )
1124 1127 coreconfigitem('ui', 'report_untrusted',
1125 1128 default=True,
1126 1129 )
1127 1130 coreconfigitem('ui', 'rollback',
1128 1131 default=True,
1129 1132 )
1130 1133 coreconfigitem('ui', 'slash',
1131 1134 default=False,
1132 1135 )
1133 1136 coreconfigitem('ui', 'ssh',
1134 1137 default='ssh',
1135 1138 )
1136 1139 coreconfigitem('ui', 'ssherrorhint',
1137 1140 default=None,
1138 1141 )
1139 1142 coreconfigitem('ui', 'statuscopies',
1140 1143 default=False,
1141 1144 )
1142 1145 coreconfigitem('ui', 'strict',
1143 1146 default=False,
1144 1147 )
1145 1148 coreconfigitem('ui', 'style',
1146 1149 default='',
1147 1150 )
1148 1151 coreconfigitem('ui', 'supportcontact',
1149 1152 default=None,
1150 1153 )
1151 1154 coreconfigitem('ui', 'textwidth',
1152 1155 default=78,
1153 1156 )
1154 1157 coreconfigitem('ui', 'timeout',
1155 1158 default='600',
1156 1159 )
1157 1160 coreconfigitem('ui', 'timeout.warn',
1158 1161 default=0,
1159 1162 )
1160 1163 coreconfigitem('ui', 'traceback',
1161 1164 default=False,
1162 1165 )
1163 1166 coreconfigitem('ui', 'tweakdefaults',
1164 1167 default=False,
1165 1168 )
1166 1169 coreconfigitem('ui', 'username',
1167 1170 alias=[('ui', 'user')]
1168 1171 )
1169 1172 coreconfigitem('ui', 'verbose',
1170 1173 default=False,
1171 1174 )
1172 1175 coreconfigitem('verify', 'skipflags',
1173 1176 default=None,
1174 1177 )
1175 1178 coreconfigitem('web', 'allowbz2',
1176 1179 default=False,
1177 1180 )
1178 1181 coreconfigitem('web', 'allowgz',
1179 1182 default=False,
1180 1183 )
1181 1184 coreconfigitem('web', 'allow-pull',
1182 1185 alias=[('web', 'allowpull')],
1183 1186 default=True,
1184 1187 )
1185 1188 coreconfigitem('web', 'allow-push',
1186 1189 alias=[('web', 'allow_push')],
1187 1190 default=list,
1188 1191 )
1189 1192 coreconfigitem('web', 'allowzip',
1190 1193 default=False,
1191 1194 )
1192 1195 coreconfigitem('web', 'archivesubrepos',
1193 1196 default=False,
1194 1197 )
1195 1198 coreconfigitem('web', 'cache',
1196 1199 default=True,
1197 1200 )
1198 1201 coreconfigitem('web', 'contact',
1199 1202 default=None,
1200 1203 )
1201 1204 coreconfigitem('web', 'deny_push',
1202 1205 default=list,
1203 1206 )
1204 1207 coreconfigitem('web', 'guessmime',
1205 1208 default=False,
1206 1209 )
1207 1210 coreconfigitem('web', 'hidden',
1208 1211 default=False,
1209 1212 )
1210 1213 coreconfigitem('web', 'labels',
1211 1214 default=list,
1212 1215 )
1213 1216 coreconfigitem('web', 'logoimg',
1214 1217 default='hglogo.png',
1215 1218 )
1216 1219 coreconfigitem('web', 'logourl',
1217 1220 default='https://mercurial-scm.org/',
1218 1221 )
1219 1222 coreconfigitem('web', 'accesslog',
1220 1223 default='-',
1221 1224 )
1222 1225 coreconfigitem('web', 'address',
1223 1226 default='',
1224 1227 )
1225 1228 coreconfigitem('web', 'allow_archive',
1226 1229 default=list,
1227 1230 )
1228 1231 coreconfigitem('web', 'allow_read',
1229 1232 default=list,
1230 1233 )
1231 1234 coreconfigitem('web', 'baseurl',
1232 1235 default=None,
1233 1236 )
1234 1237 coreconfigitem('web', 'cacerts',
1235 1238 default=None,
1236 1239 )
1237 1240 coreconfigitem('web', 'certificate',
1238 1241 default=None,
1239 1242 )
1240 1243 coreconfigitem('web', 'collapse',
1241 1244 default=False,
1242 1245 )
1243 1246 coreconfigitem('web', 'csp',
1244 1247 default=None,
1245 1248 )
1246 1249 coreconfigitem('web', 'deny_read',
1247 1250 default=list,
1248 1251 )
1249 1252 coreconfigitem('web', 'descend',
1250 1253 default=True,
1251 1254 )
1252 1255 coreconfigitem('web', 'description',
1253 1256 default="",
1254 1257 )
1255 1258 coreconfigitem('web', 'encoding',
1256 1259 default=lambda: encoding.encoding,
1257 1260 )
1258 1261 coreconfigitem('web', 'errorlog',
1259 1262 default='-',
1260 1263 )
1261 1264 coreconfigitem('web', 'ipv6',
1262 1265 default=False,
1263 1266 )
1264 1267 coreconfigitem('web', 'maxchanges',
1265 1268 default=10,
1266 1269 )
1267 1270 coreconfigitem('web', 'maxfiles',
1268 1271 default=10,
1269 1272 )
1270 1273 coreconfigitem('web', 'maxshortchanges',
1271 1274 default=60,
1272 1275 )
1273 1276 coreconfigitem('web', 'motd',
1274 1277 default='',
1275 1278 )
1276 1279 coreconfigitem('web', 'name',
1277 1280 default=dynamicdefault,
1278 1281 )
1279 1282 coreconfigitem('web', 'port',
1280 1283 default=8000,
1281 1284 )
1282 1285 coreconfigitem('web', 'prefix',
1283 1286 default='',
1284 1287 )
1285 1288 coreconfigitem('web', 'push_ssl',
1286 1289 default=True,
1287 1290 )
1288 1291 coreconfigitem('web', 'refreshinterval',
1289 1292 default=20,
1290 1293 )
1291 1294 coreconfigitem('web', 'server-header',
1292 1295 default=None,
1293 1296 )
1294 1297 coreconfigitem('web', 'staticurl',
1295 1298 default=None,
1296 1299 )
1297 1300 coreconfigitem('web', 'stripes',
1298 1301 default=1,
1299 1302 )
1300 1303 coreconfigitem('web', 'style',
1301 1304 default='paper',
1302 1305 )
1303 1306 coreconfigitem('web', 'templates',
1304 1307 default=None,
1305 1308 )
1306 1309 coreconfigitem('web', 'view',
1307 1310 default='served',
1308 1311 )
1309 1312 coreconfigitem('worker', 'backgroundclose',
1310 1313 default=dynamicdefault,
1311 1314 )
1312 1315 # Windows defaults to a limit of 512 open files. A buffer of 128
1313 1316 # should give us enough headway.
1314 1317 coreconfigitem('worker', 'backgroundclosemaxqueue',
1315 1318 default=384,
1316 1319 )
1317 1320 coreconfigitem('worker', 'backgroundcloseminfilecount',
1318 1321 default=2048,
1319 1322 )
1320 1323 coreconfigitem('worker', 'backgroundclosethreadcount',
1321 1324 default=4,
1322 1325 )
1323 1326 coreconfigitem('worker', 'enabled',
1324 1327 default=True,
1325 1328 )
1326 1329 coreconfigitem('worker', 'numcpus',
1327 1330 default=None,
1328 1331 )
1329 1332
1330 1333 # Rebase related configuration moved to core because other extension are doing
1331 1334 # strange things. For example, shelve import the extensions to reuse some bit
1332 1335 # without formally loading it.
1333 1336 coreconfigitem('commands', 'rebase.requiredest',
1334 1337 default=False,
1335 1338 )
1336 1339 coreconfigitem('experimental', 'rebaseskipobsolete',
1337 1340 default=True,
1338 1341 )
1339 1342 coreconfigitem('rebase', 'singletransaction',
1340 1343 default=False,
1341 1344 )
1342 1345 coreconfigitem('rebase', 'experimental.inmemory',
1343 1346 default=False,
1344 1347 )
@@ -1,2636 +1,2640 b''
1 1 The Mercurial system uses a set of configuration files to control
2 2 aspects of its behavior.
3 3
4 4 Troubleshooting
5 5 ===============
6 6
7 7 If you're having problems with your configuration,
8 8 :hg:`config --debug` can help you understand what is introducing
9 9 a setting into your environment.
10 10
11 11 See :hg:`help config.syntax` and :hg:`help config.files`
12 12 for information about how and where to override things.
13 13
14 14 Structure
15 15 =========
16 16
17 17 The configuration files use a simple ini-file format. A configuration
18 18 file consists of sections, led by a ``[section]`` header and followed
19 19 by ``name = value`` entries::
20 20
21 21 [ui]
22 22 username = Firstname Lastname <firstname.lastname@example.net>
23 23 verbose = True
24 24
25 25 The above entries will be referred to as ``ui.username`` and
26 26 ``ui.verbose``, respectively. See :hg:`help config.syntax`.
27 27
28 28 Files
29 29 =====
30 30
31 31 Mercurial reads configuration data from several files, if they exist.
32 32 These files do not exist by default and you will have to create the
33 33 appropriate configuration files yourself:
34 34
35 35 Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
36 36
37 37 Global configuration like the username setting is typically put into:
38 38
39 39 .. container:: windows
40 40
41 41 - ``%USERPROFILE%\mercurial.ini`` (on Windows)
42 42
43 43 .. container:: unix.plan9
44 44
45 45 - ``$HOME/.hgrc`` (on Unix, Plan9)
46 46
47 47 The names of these files depend on the system on which Mercurial is
48 48 installed. ``*.rc`` files from a single directory are read in
49 49 alphabetical order, later ones overriding earlier ones. Where multiple
50 50 paths are given below, settings from earlier paths override later
51 51 ones.
52 52
53 53 .. container:: verbose.unix
54 54
55 55 On Unix, the following files are consulted:
56 56
57 57 - ``<repo>/.hg/hgrc`` (per-repository)
58 58 - ``$HOME/.hgrc`` (per-user)
59 59 - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
60 60 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
61 61 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
62 62 - ``/etc/mercurial/hgrc`` (per-system)
63 63 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
64 64 - ``<internal>/default.d/*.rc`` (defaults)
65 65
66 66 .. container:: verbose.windows
67 67
68 68 On Windows, the following files are consulted:
69 69
70 70 - ``<repo>/.hg/hgrc`` (per-repository)
71 71 - ``%USERPROFILE%\.hgrc`` (per-user)
72 72 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
73 73 - ``%HOME%\.hgrc`` (per-user)
74 74 - ``%HOME%\Mercurial.ini`` (per-user)
75 75 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
76 76 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
77 77 - ``<install-dir>\Mercurial.ini`` (per-installation)
78 78 - ``<internal>/default.d/*.rc`` (defaults)
79 79
80 80 .. note::
81 81
82 82 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
83 83 is used when running 32-bit Python on 64-bit Windows.
84 84
85 85 .. container:: windows
86 86
87 87 On Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``.
88 88
89 89 .. container:: verbose.plan9
90 90
91 91 On Plan9, the following files are consulted:
92 92
93 93 - ``<repo>/.hg/hgrc`` (per-repository)
94 94 - ``$home/lib/hgrc`` (per-user)
95 95 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
96 96 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
97 97 - ``/lib/mercurial/hgrc`` (per-system)
98 98 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
99 99 - ``<internal>/default.d/*.rc`` (defaults)
100 100
101 101 Per-repository configuration options only apply in a
102 102 particular repository. This file is not version-controlled, and
103 103 will not get transferred during a "clone" operation. Options in
104 104 this file override options in all other configuration files.
105 105
106 106 .. container:: unix.plan9
107 107
108 108 On Plan 9 and Unix, most of this file will be ignored if it doesn't
109 109 belong to a trusted user or to a trusted group. See
110 110 :hg:`help config.trusted` for more details.
111 111
112 112 Per-user configuration file(s) are for the user running Mercurial. Options
113 113 in these files apply to all Mercurial commands executed by this user in any
114 114 directory. Options in these files override per-system and per-installation
115 115 options.
116 116
117 117 Per-installation configuration files are searched for in the
118 118 directory where Mercurial is installed. ``<install-root>`` is the
119 119 parent directory of the **hg** executable (or symlink) being run.
120 120
121 121 .. container:: unix.plan9
122 122
123 123 For example, if installed in ``/shared/tools/bin/hg``, Mercurial
124 124 will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
125 125 files apply to all Mercurial commands executed by any user in any
126 126 directory.
127 127
128 128 Per-installation configuration files are for the system on
129 129 which Mercurial is running. Options in these files apply to all
130 130 Mercurial commands executed by any user in any directory. Registry
131 131 keys contain PATH-like strings, every part of which must reference
132 132 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
133 133 be read. Mercurial checks each of these locations in the specified
134 134 order until one or more configuration files are detected.
135 135
136 136 Per-system configuration files are for the system on which Mercurial
137 137 is running. Options in these files apply to all Mercurial commands
138 138 executed by any user in any directory. Options in these files
139 139 override per-installation options.
140 140
141 141 Mercurial comes with some default configuration. The default configuration
142 142 files are installed with Mercurial and will be overwritten on upgrades. Default
143 143 configuration files should never be edited by users or administrators but can
144 144 be overridden in other configuration files. So far the directory only contains
145 145 merge tool configuration but packagers can also put other default configuration
146 146 there.
147 147
148 148 Syntax
149 149 ======
150 150
151 151 A configuration file consists of sections, led by a ``[section]`` header
152 152 and followed by ``name = value`` entries (sometimes called
153 153 ``configuration keys``)::
154 154
155 155 [spam]
156 156 eggs=ham
157 157 green=
158 158 eggs
159 159
160 160 Each line contains one entry. If the lines that follow are indented,
161 161 they are treated as continuations of that entry. Leading whitespace is
162 162 removed from values. Empty lines are skipped. Lines beginning with
163 163 ``#`` or ``;`` are ignored and may be used to provide comments.
164 164
165 165 Configuration keys can be set multiple times, in which case Mercurial
166 166 will use the value that was configured last. As an example::
167 167
168 168 [spam]
169 169 eggs=large
170 170 ham=serrano
171 171 eggs=small
172 172
173 173 This would set the configuration key named ``eggs`` to ``small``.
174 174
175 175 It is also possible to define a section multiple times. A section can
176 176 be redefined on the same and/or on different configuration files. For
177 177 example::
178 178
179 179 [foo]
180 180 eggs=large
181 181 ham=serrano
182 182 eggs=small
183 183
184 184 [bar]
185 185 eggs=ham
186 186 green=
187 187 eggs
188 188
189 189 [foo]
190 190 ham=prosciutto
191 191 eggs=medium
192 192 bread=toasted
193 193
194 194 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
195 195 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
196 196 respectively. As you can see there only thing that matters is the last
197 197 value that was set for each of the configuration keys.
198 198
199 199 If a configuration key is set multiple times in different
200 200 configuration files the final value will depend on the order in which
201 201 the different configuration files are read, with settings from earlier
202 202 paths overriding later ones as described on the ``Files`` section
203 203 above.
204 204
205 205 A line of the form ``%include file`` will include ``file`` into the
206 206 current configuration file. The inclusion is recursive, which means
207 207 that included files can include other files. Filenames are relative to
208 208 the configuration file in which the ``%include`` directive is found.
209 209 Environment variables and ``~user`` constructs are expanded in
210 210 ``file``. This lets you do something like::
211 211
212 212 %include ~/.hgrc.d/$HOST.rc
213 213
214 214 to include a different configuration file on each computer you use.
215 215
216 216 A line with ``%unset name`` will remove ``name`` from the current
217 217 section, if it has been set previously.
218 218
219 219 The values are either free-form text strings, lists of text strings,
220 220 or Boolean values. Boolean values can be set to true using any of "1",
221 221 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
222 222 (all case insensitive).
223 223
224 224 List values are separated by whitespace or comma, except when values are
225 225 placed in double quotation marks::
226 226
227 227 allow_read = "John Doe, PhD", brian, betty
228 228
229 229 Quotation marks can be escaped by prefixing them with a backslash. Only
230 230 quotation marks at the beginning of a word is counted as a quotation
231 231 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
232 232
233 233 Sections
234 234 ========
235 235
236 236 This section describes the different sections that may appear in a
237 237 Mercurial configuration file, the purpose of each section, its possible
238 238 keys, and their possible values.
239 239
240 240 ``alias``
241 241 ---------
242 242
243 243 Defines command aliases.
244 244
245 245 Aliases allow you to define your own commands in terms of other
246 246 commands (or aliases), optionally including arguments. Positional
247 247 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
248 248 are expanded by Mercurial before execution. Positional arguments not
249 249 already used by ``$N`` in the definition are put at the end of the
250 250 command to be executed.
251 251
252 252 Alias definitions consist of lines of the form::
253 253
254 254 <alias> = <command> [<argument>]...
255 255
256 256 For example, this definition::
257 257
258 258 latest = log --limit 5
259 259
260 260 creates a new command ``latest`` that shows only the five most recent
261 261 changesets. You can define subsequent aliases using earlier ones::
262 262
263 263 stable5 = latest -b stable
264 264
265 265 .. note::
266 266
267 267 It is possible to create aliases with the same names as
268 268 existing commands, which will then override the original
269 269 definitions. This is almost always a bad idea!
270 270
271 271 An alias can start with an exclamation point (``!``) to make it a
272 272 shell alias. A shell alias is executed with the shell and will let you
273 273 run arbitrary commands. As an example, ::
274 274
275 275 echo = !echo $@
276 276
277 277 will let you do ``hg echo foo`` to have ``foo`` printed in your
278 278 terminal. A better example might be::
279 279
280 280 purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
281 281
282 282 which will make ``hg purge`` delete all unknown files in the
283 283 repository in the same manner as the purge extension.
284 284
285 285 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
286 286 expand to the command arguments. Unmatched arguments are
287 287 removed. ``$0`` expands to the alias name and ``$@`` expands to all
288 288 arguments separated by a space. ``"$@"`` (with quotes) expands to all
289 289 arguments quoted individually and separated by a space. These expansions
290 290 happen before the command is passed to the shell.
291 291
292 292 Shell aliases are executed in an environment where ``$HG`` expands to
293 293 the path of the Mercurial that was used to execute the alias. This is
294 294 useful when you want to call further Mercurial commands in a shell
295 295 alias, as was done above for the purge alias. In addition,
296 296 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
297 297 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
298 298
299 299 .. note::
300 300
301 301 Some global configuration options such as ``-R`` are
302 302 processed before shell aliases and will thus not be passed to
303 303 aliases.
304 304
305 305
306 306 ``annotate``
307 307 ------------
308 308
309 309 Settings used when displaying file annotations. All values are
310 310 Booleans and default to False. See :hg:`help config.diff` for
311 311 related options for the diff command.
312 312
313 313 ``ignorews``
314 314 Ignore white space when comparing lines.
315 315
316 316 ``ignorewseol``
317 317 Ignore white space at the end of a line when comparing lines.
318 318
319 319 ``ignorewsamount``
320 320 Ignore changes in the amount of white space.
321 321
322 322 ``ignoreblanklines``
323 323 Ignore changes whose lines are all blank.
324 324
325 325
326 326 ``auth``
327 327 --------
328 328
329 329 Authentication credentials and other authentication-like configuration
330 330 for HTTP connections. This section allows you to store usernames and
331 331 passwords for use when logging *into* HTTP servers. See
332 332 :hg:`help config.web` if you want to configure *who* can login to
333 333 your HTTP server.
334 334
335 335 The following options apply to all hosts.
336 336
337 337 ``cookiefile``
338 338 Path to a file containing HTTP cookie lines. Cookies matching a
339 339 host will be sent automatically.
340 340
341 341 The file format uses the Mozilla cookies.txt format, which defines cookies
342 342 on their own lines. Each line contains 7 fields delimited by the tab
343 343 character (domain, is_domain_cookie, path, is_secure, expires, name,
344 344 value). For more info, do an Internet search for "Netscape cookies.txt
345 345 format."
346 346
347 347 Note: the cookies parser does not handle port numbers on domains. You
348 348 will need to remove ports from the domain for the cookie to be recognized.
349 349 This could result in a cookie being disclosed to an unwanted server.
350 350
351 351 The cookies file is read-only.
352 352
353 353 Other options in this section are grouped by name and have the following
354 354 format::
355 355
356 356 <name>.<argument> = <value>
357 357
358 358 where ``<name>`` is used to group arguments into authentication
359 359 entries. Example::
360 360
361 361 foo.prefix = hg.intevation.de/mercurial
362 362 foo.username = foo
363 363 foo.password = bar
364 364 foo.schemes = http https
365 365
366 366 bar.prefix = secure.example.org
367 367 bar.key = path/to/file.key
368 368 bar.cert = path/to/file.cert
369 369 bar.schemes = https
370 370
371 371 Supported arguments:
372 372
373 373 ``prefix``
374 374 Either ``*`` or a URI prefix with or without the scheme part.
375 375 The authentication entry with the longest matching prefix is used
376 376 (where ``*`` matches everything and counts as a match of length
377 377 1). If the prefix doesn't include a scheme, the match is performed
378 378 against the URI with its scheme stripped as well, and the schemes
379 379 argument, q.v., is then subsequently consulted.
380 380
381 381 ``username``
382 382 Optional. Username to authenticate with. If not given, and the
383 383 remote site requires basic or digest authentication, the user will
384 384 be prompted for it. Environment variables are expanded in the
385 385 username letting you do ``foo.username = $USER``. If the URI
386 386 includes a username, only ``[auth]`` entries with a matching
387 387 username or without a username will be considered.
388 388
389 389 ``password``
390 390 Optional. Password to authenticate with. If not given, and the
391 391 remote site requires basic or digest authentication, the user
392 392 will be prompted for it.
393 393
394 394 ``key``
395 395 Optional. PEM encoded client certificate key file. Environment
396 396 variables are expanded in the filename.
397 397
398 398 ``cert``
399 399 Optional. PEM encoded client certificate chain file. Environment
400 400 variables are expanded in the filename.
401 401
402 402 ``schemes``
403 403 Optional. Space separated list of URI schemes to use this
404 404 authentication entry with. Only used if the prefix doesn't include
405 405 a scheme. Supported schemes are http and https. They will match
406 406 static-http and static-https respectively, as well.
407 407 (default: https)
408 408
409 409 If no suitable authentication entry is found, the user is prompted
410 410 for credentials as usual if required by the remote.
411 411
412 412 ``color``
413 413 ---------
414 414
415 415 Configure the Mercurial color mode. For details about how to define your custom
416 416 effect and style see :hg:`help color`.
417 417
418 418 ``mode``
419 419 String: control the method used to output color. One of ``auto``, ``ansi``,
420 420 ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will
421 421 use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a
422 422 terminal. Any invalid value will disable color.
423 423
424 424 ``pagermode``
425 425 String: optional override of ``color.mode`` used with pager.
426 426
427 427 On some systems, terminfo mode may cause problems when using
428 428 color with ``less -R`` as a pager program. less with the -R option
429 429 will only display ECMA-48 color codes, and terminfo mode may sometimes
430 430 emit codes that less doesn't understand. You can work around this by
431 431 either using ansi mode (or auto mode), or by using less -r (which will
432 432 pass through all terminal control codes, not just color control
433 433 codes).
434 434
435 435 On some systems (such as MSYS in Windows), the terminal may support
436 436 a different color mode than the pager program.
437 437
438 438 ``commands``
439 439 ------------
440 440
441 441 ``status.relative``
442 442 Make paths in :hg:`status` output relative to the current directory.
443 443 (default: False)
444 444
445 ``status.terse``
446 Default value for the --terse flag, which condenes status output.
447 (default: empty)
448
445 449 ``update.check``
446 450 Determines what level of checking :hg:`update` will perform before moving
447 451 to a destination revision. Valid values are ``abort``, ``none``,
448 452 ``linear``, and ``noconflict``. ``abort`` always fails if the working
449 453 directory has uncommitted changes. ``none`` performs no checking, and may
450 454 result in a merge with uncommitted changes. ``linear`` allows any update
451 455 as long as it follows a straight line in the revision history, and may
452 456 trigger a merge with uncommitted changes. ``noconflict`` will allow any
453 457 update which would not trigger a merge with uncommitted changes, if any
454 458 are present.
455 459 (default: ``linear``)
456 460
457 461 ``update.requiredest``
458 462 Require that the user pass a destination when running :hg:`update`.
459 463 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
460 464 will be disallowed.
461 465 (default: False)
462 466
463 467 ``committemplate``
464 468 ------------------
465 469
466 470 ``changeset``
467 471 String: configuration in this section is used as the template to
468 472 customize the text shown in the editor when committing.
469 473
470 474 In addition to pre-defined template keywords, commit log specific one
471 475 below can be used for customization:
472 476
473 477 ``extramsg``
474 478 String: Extra message (typically 'Leave message empty to abort
475 479 commit.'). This may be changed by some commands or extensions.
476 480
477 481 For example, the template configuration below shows as same text as
478 482 one shown by default::
479 483
480 484 [committemplate]
481 485 changeset = {desc}\n\n
482 486 HG: Enter commit message. Lines beginning with 'HG:' are removed.
483 487 HG: {extramsg}
484 488 HG: --
485 489 HG: user: {author}\n{ifeq(p2rev, "-1", "",
486 490 "HG: branch merge\n")
487 491 }HG: branch '{branch}'\n{if(activebookmark,
488 492 "HG: bookmark '{activebookmark}'\n") }{subrepos %
489 493 "HG: subrepo {subrepo}\n" }{file_adds %
490 494 "HG: added {file}\n" }{file_mods %
491 495 "HG: changed {file}\n" }{file_dels %
492 496 "HG: removed {file}\n" }{if(files, "",
493 497 "HG: no files changed\n")}
494 498
495 499 ``diff()``
496 500 String: show the diff (see :hg:`help templates` for detail)
497 501
498 502 Sometimes it is helpful to show the diff of the changeset in the editor without
499 503 having to prefix 'HG: ' to each line so that highlighting works correctly. For
500 504 this, Mercurial provides a special string which will ignore everything below
501 505 it::
502 506
503 507 HG: ------------------------ >8 ------------------------
504 508
505 509 For example, the template configuration below will show the diff below the
506 510 extra message::
507 511
508 512 [committemplate]
509 513 changeset = {desc}\n\n
510 514 HG: Enter commit message. Lines beginning with 'HG:' are removed.
511 515 HG: {extramsg}
512 516 HG: ------------------------ >8 ------------------------
513 517 HG: Do not touch the line above.
514 518 HG: Everything below will be removed.
515 519 {diff()}
516 520
517 521 .. note::
518 522
519 523 For some problematic encodings (see :hg:`help win32mbcs` for
520 524 detail), this customization should be configured carefully, to
521 525 avoid showing broken characters.
522 526
523 527 For example, if a multibyte character ending with backslash (0x5c) is
524 528 followed by the ASCII character 'n' in the customized template,
525 529 the sequence of backslash and 'n' is treated as line-feed unexpectedly
526 530 (and the multibyte character is broken, too).
527 531
528 532 Customized template is used for commands below (``--edit`` may be
529 533 required):
530 534
531 535 - :hg:`backout`
532 536 - :hg:`commit`
533 537 - :hg:`fetch` (for merge commit only)
534 538 - :hg:`graft`
535 539 - :hg:`histedit`
536 540 - :hg:`import`
537 541 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
538 542 - :hg:`rebase`
539 543 - :hg:`shelve`
540 544 - :hg:`sign`
541 545 - :hg:`tag`
542 546 - :hg:`transplant`
543 547
544 548 Configuring items below instead of ``changeset`` allows showing
545 549 customized message only for specific actions, or showing different
546 550 messages for each action.
547 551
548 552 - ``changeset.backout`` for :hg:`backout`
549 553 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
550 554 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
551 555 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
552 556 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
553 557 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
554 558 - ``changeset.gpg.sign`` for :hg:`sign`
555 559 - ``changeset.graft`` for :hg:`graft`
556 560 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
557 561 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
558 562 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
559 563 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
560 564 - ``changeset.import.bypass`` for :hg:`import --bypass`
561 565 - ``changeset.import.normal.merge`` for :hg:`import` on merges
562 566 - ``changeset.import.normal.normal`` for :hg:`import` on other
563 567 - ``changeset.mq.qnew`` for :hg:`qnew`
564 568 - ``changeset.mq.qfold`` for :hg:`qfold`
565 569 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
566 570 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
567 571 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
568 572 - ``changeset.rebase.normal`` for :hg:`rebase` on other
569 573 - ``changeset.shelve.shelve`` for :hg:`shelve`
570 574 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
571 575 - ``changeset.tag.remove`` for :hg:`tag --remove`
572 576 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
573 577 - ``changeset.transplant.normal`` for :hg:`transplant` on other
574 578
575 579 These dot-separated lists of names are treated as hierarchical ones.
576 580 For example, ``changeset.tag.remove`` customizes the commit message
577 581 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
578 582 commit message for :hg:`tag` regardless of ``--remove`` option.
579 583
580 584 When the external editor is invoked for a commit, the corresponding
581 585 dot-separated list of names without the ``changeset.`` prefix
582 586 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
583 587 variable.
584 588
585 589 In this section, items other than ``changeset`` can be referred from
586 590 others. For example, the configuration to list committed files up
587 591 below can be referred as ``{listupfiles}``::
588 592
589 593 [committemplate]
590 594 listupfiles = {file_adds %
591 595 "HG: added {file}\n" }{file_mods %
592 596 "HG: changed {file}\n" }{file_dels %
593 597 "HG: removed {file}\n" }{if(files, "",
594 598 "HG: no files changed\n")}
595 599
596 600 ``decode/encode``
597 601 -----------------
598 602
599 603 Filters for transforming files on checkout/checkin. This would
600 604 typically be used for newline processing or other
601 605 localization/canonicalization of files.
602 606
603 607 Filters consist of a filter pattern followed by a filter command.
604 608 Filter patterns are globs by default, rooted at the repository root.
605 609 For example, to match any file ending in ``.txt`` in the root
606 610 directory only, use the pattern ``*.txt``. To match any file ending
607 611 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
608 612 For each file only the first matching filter applies.
609 613
610 614 The filter command can start with a specifier, either ``pipe:`` or
611 615 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
612 616
613 617 A ``pipe:`` command must accept data on stdin and return the transformed
614 618 data on stdout.
615 619
616 620 Pipe example::
617 621
618 622 [encode]
619 623 # uncompress gzip files on checkin to improve delta compression
620 624 # note: not necessarily a good idea, just an example
621 625 *.gz = pipe: gunzip
622 626
623 627 [decode]
624 628 # recompress gzip files when writing them to the working dir (we
625 629 # can safely omit "pipe:", because it's the default)
626 630 *.gz = gzip
627 631
628 632 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
629 633 with the name of a temporary file that contains the data to be
630 634 filtered by the command. The string ``OUTFILE`` is replaced with the name
631 635 of an empty temporary file, where the filtered data must be written by
632 636 the command.
633 637
634 638 .. container:: windows
635 639
636 640 .. note::
637 641
638 642 The tempfile mechanism is recommended for Windows systems,
639 643 where the standard shell I/O redirection operators often have
640 644 strange effects and may corrupt the contents of your files.
641 645
642 646 This filter mechanism is used internally by the ``eol`` extension to
643 647 translate line ending characters between Windows (CRLF) and Unix (LF)
644 648 format. We suggest you use the ``eol`` extension for convenience.
645 649
646 650
647 651 ``defaults``
648 652 ------------
649 653
650 654 (defaults are deprecated. Don't use them. Use aliases instead.)
651 655
652 656 Use the ``[defaults]`` section to define command defaults, i.e. the
653 657 default options/arguments to pass to the specified commands.
654 658
655 659 The following example makes :hg:`log` run in verbose mode, and
656 660 :hg:`status` show only the modified files, by default::
657 661
658 662 [defaults]
659 663 log = -v
660 664 status = -m
661 665
662 666 The actual commands, instead of their aliases, must be used when
663 667 defining command defaults. The command defaults will also be applied
664 668 to the aliases of the commands defined.
665 669
666 670
667 671 ``diff``
668 672 --------
669 673
670 674 Settings used when displaying diffs. Everything except for ``unified``
671 675 is a Boolean and defaults to False. See :hg:`help config.annotate`
672 676 for related options for the annotate command.
673 677
674 678 ``git``
675 679 Use git extended diff format.
676 680
677 681 ``nobinary``
678 682 Omit git binary patches.
679 683
680 684 ``nodates``
681 685 Don't include dates in diff headers.
682 686
683 687 ``noprefix``
684 688 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
685 689
686 690 ``showfunc``
687 691 Show which function each change is in.
688 692
689 693 ``ignorews``
690 694 Ignore white space when comparing lines.
691 695
692 696 ``ignorewsamount``
693 697 Ignore changes in the amount of white space.
694 698
695 699 ``ignoreblanklines``
696 700 Ignore changes whose lines are all blank.
697 701
698 702 ``unified``
699 703 Number of lines of context to show.
700 704
701 705 ``email``
702 706 ---------
703 707
704 708 Settings for extensions that send email messages.
705 709
706 710 ``from``
707 711 Optional. Email address to use in "From" header and SMTP envelope
708 712 of outgoing messages.
709 713
710 714 ``to``
711 715 Optional. Comma-separated list of recipients' email addresses.
712 716
713 717 ``cc``
714 718 Optional. Comma-separated list of carbon copy recipients'
715 719 email addresses.
716 720
717 721 ``bcc``
718 722 Optional. Comma-separated list of blind carbon copy recipients'
719 723 email addresses.
720 724
721 725 ``method``
722 726 Optional. Method to use to send email messages. If value is ``smtp``
723 727 (default), use SMTP (see the ``[smtp]`` section for configuration).
724 728 Otherwise, use as name of program to run that acts like sendmail
725 729 (takes ``-f`` option for sender, list of recipients on command line,
726 730 message on stdin). Normally, setting this to ``sendmail`` or
727 731 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
728 732
729 733 ``charsets``
730 734 Optional. Comma-separated list of character sets considered
731 735 convenient for recipients. Addresses, headers, and parts not
732 736 containing patches of outgoing messages will be encoded in the
733 737 first character set to which conversion from local encoding
734 738 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
735 739 conversion fails, the text in question is sent as is.
736 740 (default: '')
737 741
738 742 Order of outgoing email character sets:
739 743
740 744 1. ``us-ascii``: always first, regardless of settings
741 745 2. ``email.charsets``: in order given by user
742 746 3. ``ui.fallbackencoding``: if not in email.charsets
743 747 4. ``$HGENCODING``: if not in email.charsets
744 748 5. ``utf-8``: always last, regardless of settings
745 749
746 750 Email example::
747 751
748 752 [email]
749 753 from = Joseph User <joe.user@example.com>
750 754 method = /usr/sbin/sendmail
751 755 # charsets for western Europeans
752 756 # us-ascii, utf-8 omitted, as they are tried first and last
753 757 charsets = iso-8859-1, iso-8859-15, windows-1252
754 758
755 759
756 760 ``extensions``
757 761 --------------
758 762
759 763 Mercurial has an extension mechanism for adding new features. To
760 764 enable an extension, create an entry for it in this section.
761 765
762 766 If you know that the extension is already in Python's search path,
763 767 you can give the name of the module, followed by ``=``, with nothing
764 768 after the ``=``.
765 769
766 770 Otherwise, give a name that you choose, followed by ``=``, followed by
767 771 the path to the ``.py`` file (including the file name extension) that
768 772 defines the extension.
769 773
770 774 To explicitly disable an extension that is enabled in an hgrc of
771 775 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
772 776 or ``foo = !`` when path is not supplied.
773 777
774 778 Example for ``~/.hgrc``::
775 779
776 780 [extensions]
777 781 # (the churn extension will get loaded from Mercurial's path)
778 782 churn =
779 783 # (this extension will get loaded from the file specified)
780 784 myfeature = ~/.hgext/myfeature.py
781 785
782 786
783 787 ``format``
784 788 ----------
785 789
786 790 ``usegeneraldelta``
787 791 Enable or disable the "generaldelta" repository format which improves
788 792 repository compression by allowing "revlog" to store delta against arbitrary
789 793 revision instead of the previous stored one. This provides significant
790 794 improvement for repositories with branches.
791 795
792 796 Repositories with this on-disk format require Mercurial version 1.9.
793 797
794 798 Enabled by default.
795 799
796 800 ``dotencode``
797 801 Enable or disable the "dotencode" repository format which enhances
798 802 the "fncache" repository format (which has to be enabled to use
799 803 dotencode) to avoid issues with filenames starting with ._ on
800 804 Mac OS X and spaces on Windows.
801 805
802 806 Repositories with this on-disk format require Mercurial version 1.7.
803 807
804 808 Enabled by default.
805 809
806 810 ``usefncache``
807 811 Enable or disable the "fncache" repository format which enhances
808 812 the "store" repository format (which has to be enabled to use
809 813 fncache) to allow longer filenames and avoids using Windows
810 814 reserved names, e.g. "nul".
811 815
812 816 Repositories with this on-disk format require Mercurial version 1.1.
813 817
814 818 Enabled by default.
815 819
816 820 ``usestore``
817 821 Enable or disable the "store" repository format which improves
818 822 compatibility with systems that fold case or otherwise mangle
819 823 filenames. Disabling this option will allow you to store longer filenames
820 824 in some situations at the expense of compatibility.
821 825
822 826 Repositories with this on-disk format require Mercurial version 0.9.4.
823 827
824 828 Enabled by default.
825 829
826 830 ``graph``
827 831 ---------
828 832
829 833 Web graph view configuration. This section let you change graph
830 834 elements display properties by branches, for instance to make the
831 835 ``default`` branch stand out.
832 836
833 837 Each line has the following format::
834 838
835 839 <branch>.<argument> = <value>
836 840
837 841 where ``<branch>`` is the name of the branch being
838 842 customized. Example::
839 843
840 844 [graph]
841 845 # 2px width
842 846 default.width = 2
843 847 # red color
844 848 default.color = FF0000
845 849
846 850 Supported arguments:
847 851
848 852 ``width``
849 853 Set branch edges width in pixels.
850 854
851 855 ``color``
852 856 Set branch edges color in hexadecimal RGB notation.
853 857
854 858 ``hooks``
855 859 ---------
856 860
857 861 Commands or Python functions that get automatically executed by
858 862 various actions such as starting or finishing a commit. Multiple
859 863 hooks can be run for the same action by appending a suffix to the
860 864 action. Overriding a site-wide hook can be done by changing its
861 865 value or setting it to an empty string. Hooks can be prioritized
862 866 by adding a prefix of ``priority.`` to the hook name on a new line
863 867 and setting the priority. The default priority is 0.
864 868
865 869 Example ``.hg/hgrc``::
866 870
867 871 [hooks]
868 872 # update working directory after adding changesets
869 873 changegroup.update = hg update
870 874 # do not use the site-wide hook
871 875 incoming =
872 876 incoming.email = /my/email/hook
873 877 incoming.autobuild = /my/build/hook
874 878 # force autobuild hook to run before other incoming hooks
875 879 priority.incoming.autobuild = 1
876 880
877 881 Most hooks are run with environment variables set that give useful
878 882 additional information. For each hook below, the environment variables
879 883 it is passed are listed with names in the form ``$HG_foo``. The
880 884 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
881 885 They contain the type of hook which triggered the run and the full name
882 886 of the hook in the config, respectively. In the example above, this will
883 887 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
884 888
885 889 ``changegroup``
886 890 Run after a changegroup has been added via push, pull or unbundle. The ID of
887 891 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
888 892 The URL from which changes came is in ``$HG_URL``.
889 893
890 894 ``commit``
891 895 Run after a changeset has been created in the local repository. The ID
892 896 of the newly created changeset is in ``$HG_NODE``. Parent changeset
893 897 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
894 898
895 899 ``incoming``
896 900 Run after a changeset has been pulled, pushed, or unbundled into
897 901 the local repository. The ID of the newly arrived changeset is in
898 902 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
899 903
900 904 ``outgoing``
901 905 Run after sending changes from the local repository to another. The ID of
902 906 first changeset sent is in ``$HG_NODE``. The source of operation is in
903 907 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
904 908
905 909 ``post-<command>``
906 910 Run after successful invocations of the associated command. The
907 911 contents of the command line are passed as ``$HG_ARGS`` and the result
908 912 code in ``$HG_RESULT``. Parsed command line arguments are passed as
909 913 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
910 914 the python data internally passed to <command>. ``$HG_OPTS`` is a
911 915 dictionary of options (with unspecified options set to their defaults).
912 916 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
913 917
914 918 ``fail-<command>``
915 919 Run after a failed invocation of an associated command. The contents
916 920 of the command line are passed as ``$HG_ARGS``. Parsed command line
917 921 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
918 922 string representations of the python data internally passed to
919 923 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
920 924 options set to their defaults). ``$HG_PATS`` is a list of arguments.
921 925 Hook failure is ignored.
922 926
923 927 ``pre-<command>``
924 928 Run before executing the associated command. The contents of the
925 929 command line are passed as ``$HG_ARGS``. Parsed command line arguments
926 930 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
927 931 representations of the data internally passed to <command>. ``$HG_OPTS``
928 932 is a dictionary of options (with unspecified options set to their
929 933 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
930 934 failure, the command doesn't execute and Mercurial returns the failure
931 935 code.
932 936
933 937 ``prechangegroup``
934 938 Run before a changegroup is added via push, pull or unbundle. Exit
935 939 status 0 allows the changegroup to proceed. A non-zero status will
936 940 cause the push, pull or unbundle to fail. The URL from which changes
937 941 will come is in ``$HG_URL``.
938 942
939 943 ``precommit``
940 944 Run before starting a local commit. Exit status 0 allows the
941 945 commit to proceed. A non-zero status will cause the commit to fail.
942 946 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
943 947
944 948 ``prelistkeys``
945 949 Run before listing pushkeys (like bookmarks) in the
946 950 repository. A non-zero status will cause failure. The key namespace is
947 951 in ``$HG_NAMESPACE``.
948 952
949 953 ``preoutgoing``
950 954 Run before collecting changes to send from the local repository to
951 955 another. A non-zero status will cause failure. This lets you prevent
952 956 pull over HTTP or SSH. It can also prevent propagating commits (via
953 957 local pull, push (outbound) or bundle commands), but not completely,
954 958 since you can just copy files instead. The source of operation is in
955 959 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
956 960 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
957 961 is happening on behalf of a repository on same system.
958 962
959 963 ``prepushkey``
960 964 Run before a pushkey (like a bookmark) is added to the
961 965 repository. A non-zero status will cause the key to be rejected. The
962 966 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
963 967 the old value (if any) is in ``$HG_OLD``, and the new value is in
964 968 ``$HG_NEW``.
965 969
966 970 ``pretag``
967 971 Run before creating a tag. Exit status 0 allows the tag to be
968 972 created. A non-zero status will cause the tag to fail. The ID of the
969 973 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
970 974 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
971 975
972 976 ``pretxnopen``
973 977 Run before any new repository transaction is open. The reason for the
974 978 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
975 979 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
976 980 transaction from being opened.
977 981
978 982 ``pretxnclose``
979 983 Run right before the transaction is actually finalized. Any repository change
980 984 will be visible to the hook program. This lets you validate the transaction
981 985 content or change it. Exit status 0 allows the commit to proceed. A non-zero
982 986 status will cause the transaction to be rolled back. The reason for the
983 987 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
984 988 the transaction will be in ``HG_TXNID``. The rest of the available data will
985 989 vary according the transaction type. New changesets will add ``$HG_NODE``
986 990 (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
987 991 added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables. Bookmark and
988 992 phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
989 993 respectively, etc.
990 994
991 995 ``pretxnclose-bookmark``
992 996 Run right before a bookmark change is actually finalized. Any repository
993 997 change will be visible to the hook program. This lets you validate the
994 998 transaction content or change it. Exit status 0 allows the commit to
995 999 proceed. A non-zero status will cause the transaction to be rolled back.
996 1000 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
997 1001 bookmark location will be available in ``$HG_NODE`` while the previous
998 1002 location will be available in ``$HG_OLDNODE``. In case of a bookmark
999 1003 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1000 1004 will be empty.
1001 1005 In addition, the reason for the transaction opening will be in
1002 1006 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1003 1007 ``HG_TXNID``.
1004 1008
1005 1009 ``pretxnclose-phase``
1006 1010 Run right before a phase change is actually finalized. Any repository change
1007 1011 will be visible to the hook program. This lets you validate the transaction
1008 1012 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1009 1013 status will cause the transaction to be rolled back. The hook is called
1010 1014 multiple times, once for each revision affected by a phase change.
1011 1015 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1012 1016 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1013 1017 will be empty. In addition, the reason for the transaction opening will be in
1014 1018 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1015 1019 ``HG_TXNID``. The hook is also run for newly added revisions. In this case
1016 1020 the ``$HG_OLDPHASE`` entry will be empty.
1017 1021
1018 1022 ``txnclose``
1019 1023 Run after any repository transaction has been committed. At this
1020 1024 point, the transaction can no longer be rolled back. The hook will run
1021 1025 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1022 1026 details about available variables.
1023 1027
1024 1028 ``txnclose-bookmark``
1025 1029 Run after any bookmark change has been committed. At this point, the
1026 1030 transaction can no longer be rolled back. The hook will run after the lock
1027 1031 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1028 1032 about available variables.
1029 1033
1030 1034 ``txnclose-phase``
1031 1035 Run after any phase change has been committed. At this point, the
1032 1036 transaction can no longer be rolled back. The hook will run after the lock
1033 1037 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1034 1038 available variables.
1035 1039
1036 1040 ``txnabort``
1037 1041 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1038 1042 for details about available variables.
1039 1043
1040 1044 ``pretxnchangegroup``
1041 1045 Run after a changegroup has been added via push, pull or unbundle, but before
1042 1046 the transaction has been committed. The changegroup is visible to the hook
1043 1047 program. This allows validation of incoming changes before accepting them.
1044 1048 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1045 1049 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1046 1050 status will cause the transaction to be rolled back, and the push, pull or
1047 1051 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1048 1052
1049 1053 ``pretxncommit``
1050 1054 Run after a changeset has been created, but before the transaction is
1051 1055 committed. The changeset is visible to the hook program. This allows
1052 1056 validation of the commit message and changes. Exit status 0 allows the
1053 1057 commit to proceed. A non-zero status will cause the transaction to
1054 1058 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1055 1059 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1056 1060
1057 1061 ``preupdate``
1058 1062 Run before updating the working directory. Exit status 0 allows
1059 1063 the update to proceed. A non-zero status will prevent the update.
1060 1064 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1061 1065 merge, the ID of second new parent is in ``$HG_PARENT2``.
1062 1066
1063 1067 ``listkeys``
1064 1068 Run after listing pushkeys (like bookmarks) in the repository. The
1065 1069 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1066 1070 dictionary containing the keys and values.
1067 1071
1068 1072 ``pushkey``
1069 1073 Run after a pushkey (like a bookmark) is added to the
1070 1074 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1071 1075 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1072 1076 value is in ``$HG_NEW``.
1073 1077
1074 1078 ``tag``
1075 1079 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1076 1080 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1077 1081 the repository if ``$HG_LOCAL=0``.
1078 1082
1079 1083 ``update``
1080 1084 Run after updating the working directory. The changeset ID of first
1081 1085 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1082 1086 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1083 1087 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1084 1088
1085 1089 .. note::
1086 1090
1087 1091 It is generally better to use standard hooks rather than the
1088 1092 generic pre- and post- command hooks, as they are guaranteed to be
1089 1093 called in the appropriate contexts for influencing transactions.
1090 1094 Also, hooks like "commit" will be called in all contexts that
1091 1095 generate a commit (e.g. tag) and not just the commit command.
1092 1096
1093 1097 .. note::
1094 1098
1095 1099 Environment variables with empty values may not be passed to
1096 1100 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1097 1101 will have an empty value under Unix-like platforms for non-merge
1098 1102 changesets, while it will not be available at all under Windows.
1099 1103
1100 1104 The syntax for Python hooks is as follows::
1101 1105
1102 1106 hookname = python:modulename.submodule.callable
1103 1107 hookname = python:/path/to/python/module.py:callable
1104 1108
1105 1109 Python hooks are run within the Mercurial process. Each hook is
1106 1110 called with at least three keyword arguments: a ui object (keyword
1107 1111 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1108 1112 keyword that tells what kind of hook is used. Arguments listed as
1109 1113 environment variables above are passed as keyword arguments, with no
1110 1114 ``HG_`` prefix, and names in lower case.
1111 1115
1112 1116 If a Python hook returns a "true" value or raises an exception, this
1113 1117 is treated as a failure.
1114 1118
1115 1119
1116 1120 ``hostfingerprints``
1117 1121 --------------------
1118 1122
1119 1123 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1120 1124
1121 1125 Fingerprints of the certificates of known HTTPS servers.
1122 1126
1123 1127 A HTTPS connection to a server with a fingerprint configured here will
1124 1128 only succeed if the servers certificate matches the fingerprint.
1125 1129 This is very similar to how ssh known hosts works.
1126 1130
1127 1131 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1128 1132 Multiple values can be specified (separated by spaces or commas). This can
1129 1133 be used to define both old and new fingerprints while a host transitions
1130 1134 to a new certificate.
1131 1135
1132 1136 The CA chain and web.cacerts is not used for servers with a fingerprint.
1133 1137
1134 1138 For example::
1135 1139
1136 1140 [hostfingerprints]
1137 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 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 1144 ``hostsecurity``
1141 1145 ----------------
1142 1146
1143 1147 Used to specify global and per-host security settings for connecting to
1144 1148 other machines.
1145 1149
1146 1150 The following options control default behavior for all hosts.
1147 1151
1148 1152 ``ciphers``
1149 1153 Defines the cryptographic ciphers to use for connections.
1150 1154
1151 1155 Value must be a valid OpenSSL Cipher List Format as documented at
1152 1156 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1153 1157
1154 1158 This setting is for advanced users only. Setting to incorrect values
1155 1159 can significantly lower connection security or decrease performance.
1156 1160 You have been warned.
1157 1161
1158 1162 This option requires Python 2.7.
1159 1163
1160 1164 ``minimumprotocol``
1161 1165 Defines the minimum channel encryption protocol to use.
1162 1166
1163 1167 By default, the highest version of TLS supported by both client and server
1164 1168 is used.
1165 1169
1166 1170 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1167 1171
1168 1172 When running on an old Python version, only ``tls1.0`` is allowed since
1169 1173 old versions of Python only support up to TLS 1.0.
1170 1174
1171 1175 When running a Python that supports modern TLS versions, the default is
1172 1176 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1173 1177 weakens security and should only be used as a feature of last resort if
1174 1178 a server does not support TLS 1.1+.
1175 1179
1176 1180 Options in the ``[hostsecurity]`` section can have the form
1177 1181 ``hostname``:``setting``. This allows multiple settings to be defined on a
1178 1182 per-host basis.
1179 1183
1180 1184 The following per-host settings can be defined.
1181 1185
1182 1186 ``ciphers``
1183 1187 This behaves like ``ciphers`` as described above except it only applies
1184 1188 to the host on which it is defined.
1185 1189
1186 1190 ``fingerprints``
1187 1191 A list of hashes of the DER encoded peer/remote certificate. Values have
1188 1192 the form ``algorithm``:``fingerprint``. e.g.
1189 1193 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1190 1194 In addition, colons (``:``) can appear in the fingerprint part.
1191 1195
1192 1196 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1193 1197 ``sha512``.
1194 1198
1195 1199 Use of ``sha256`` or ``sha512`` is preferred.
1196 1200
1197 1201 If a fingerprint is specified, the CA chain is not validated for this
1198 1202 host and Mercurial will require the remote certificate to match one
1199 1203 of the fingerprints specified. This means if the server updates its
1200 1204 certificate, Mercurial will abort until a new fingerprint is defined.
1201 1205 This can provide stronger security than traditional CA-based validation
1202 1206 at the expense of convenience.
1203 1207
1204 1208 This option takes precedence over ``verifycertsfile``.
1205 1209
1206 1210 ``minimumprotocol``
1207 1211 This behaves like ``minimumprotocol`` as described above except it
1208 1212 only applies to the host on which it is defined.
1209 1213
1210 1214 ``verifycertsfile``
1211 1215 Path to file a containing a list of PEM encoded certificates used to
1212 1216 verify the server certificate. Environment variables and ``~user``
1213 1217 constructs are expanded in the filename.
1214 1218
1215 1219 The server certificate or the certificate's certificate authority (CA)
1216 1220 must match a certificate from this file or certificate verification
1217 1221 will fail and connections to the server will be refused.
1218 1222
1219 1223 If defined, only certificates provided by this file will be used:
1220 1224 ``web.cacerts`` and any system/default certificates will not be
1221 1225 used.
1222 1226
1223 1227 This option has no effect if the per-host ``fingerprints`` option
1224 1228 is set.
1225 1229
1226 1230 The format of the file is as follows::
1227 1231
1228 1232 -----BEGIN CERTIFICATE-----
1229 1233 ... (certificate in base64 PEM encoding) ...
1230 1234 -----END CERTIFICATE-----
1231 1235 -----BEGIN CERTIFICATE-----
1232 1236 ... (certificate in base64 PEM encoding) ...
1233 1237 -----END CERTIFICATE-----
1234 1238
1235 1239 For example::
1236 1240
1237 1241 [hostsecurity]
1238 1242 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1239 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 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 1245 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1242 1246
1243 1247 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1244 1248 when connecting to ``hg.example.com``::
1245 1249
1246 1250 [hostsecurity]
1247 1251 minimumprotocol = tls1.2
1248 1252 hg.example.com:minimumprotocol = tls1.1
1249 1253
1250 1254 ``http_proxy``
1251 1255 --------------
1252 1256
1253 1257 Used to access web-based Mercurial repositories through a HTTP
1254 1258 proxy.
1255 1259
1256 1260 ``host``
1257 1261 Host name and (optional) port of the proxy server, for example
1258 1262 "myproxy:8000".
1259 1263
1260 1264 ``no``
1261 1265 Optional. Comma-separated list of host names that should bypass
1262 1266 the proxy.
1263 1267
1264 1268 ``passwd``
1265 1269 Optional. Password to authenticate with at the proxy server.
1266 1270
1267 1271 ``user``
1268 1272 Optional. User name to authenticate with at the proxy server.
1269 1273
1270 1274 ``always``
1271 1275 Optional. Always use the proxy, even for localhost and any entries
1272 1276 in ``http_proxy.no``. (default: False)
1273 1277
1274 1278 ``merge``
1275 1279 ---------
1276 1280
1277 1281 This section specifies behavior during merges and updates.
1278 1282
1279 1283 ``checkignored``
1280 1284 Controls behavior when an ignored file on disk has the same name as a tracked
1281 1285 file in the changeset being merged or updated to, and has different
1282 1286 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1283 1287 abort on such files. With ``warn``, warn on such files and back them up as
1284 1288 ``.orig``. With ``ignore``, don't print a warning and back them up as
1285 1289 ``.orig``. (default: ``abort``)
1286 1290
1287 1291 ``checkunknown``
1288 1292 Controls behavior when an unknown file that isn't ignored has the same name
1289 1293 as a tracked file in the changeset being merged or updated to, and has
1290 1294 different contents. Similar to ``merge.checkignored``, except for files that
1291 1295 are not ignored. (default: ``abort``)
1292 1296
1293 1297 ``on-failure``
1294 1298 When set to ``continue`` (the default), the merge process attempts to
1295 1299 merge all unresolved files using the merge chosen tool, regardless of
1296 1300 whether previous file merge attempts during the process succeeded or not.
1297 1301 Setting this to ``prompt`` will prompt after any merge failure continue
1298 1302 or halt the merge process. Setting this to ``halt`` will automatically
1299 1303 halt the merge process on any merge tool failure. The merge process
1300 1304 can be restarted by using the ``resolve`` command. When a merge is
1301 1305 halted, the repository is left in a normal ``unresolved`` merge state.
1302 1306 (default: ``continue``)
1303 1307
1304 1308 ``merge-patterns``
1305 1309 ------------------
1306 1310
1307 1311 This section specifies merge tools to associate with particular file
1308 1312 patterns. Tools matched here will take precedence over the default
1309 1313 merge tool. Patterns are globs by default, rooted at the repository
1310 1314 root.
1311 1315
1312 1316 Example::
1313 1317
1314 1318 [merge-patterns]
1315 1319 **.c = kdiff3
1316 1320 **.jpg = myimgmerge
1317 1321
1318 1322 ``merge-tools``
1319 1323 ---------------
1320 1324
1321 1325 This section configures external merge tools to use for file-level
1322 1326 merges. This section has likely been preconfigured at install time.
1323 1327 Use :hg:`config merge-tools` to check the existing configuration.
1324 1328 Also see :hg:`help merge-tools` for more details.
1325 1329
1326 1330 Example ``~/.hgrc``::
1327 1331
1328 1332 [merge-tools]
1329 1333 # Override stock tool location
1330 1334 kdiff3.executable = ~/bin/kdiff3
1331 1335 # Specify command line
1332 1336 kdiff3.args = $base $local $other -o $output
1333 1337 # Give higher priority
1334 1338 kdiff3.priority = 1
1335 1339
1336 1340 # Changing the priority of preconfigured tool
1337 1341 meld.priority = 0
1338 1342
1339 1343 # Disable a preconfigured tool
1340 1344 vimdiff.disabled = yes
1341 1345
1342 1346 # Define new tool
1343 1347 myHtmlTool.args = -m $local $other $base $output
1344 1348 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1345 1349 myHtmlTool.priority = 1
1346 1350
1347 1351 Supported arguments:
1348 1352
1349 1353 ``priority``
1350 1354 The priority in which to evaluate this tool.
1351 1355 (default: 0)
1352 1356
1353 1357 ``executable``
1354 1358 Either just the name of the executable or its pathname.
1355 1359
1356 1360 .. container:: windows
1357 1361
1358 1362 On Windows, the path can use environment variables with ${ProgramFiles}
1359 1363 syntax.
1360 1364
1361 1365 (default: the tool name)
1362 1366
1363 1367 ``args``
1364 1368 The arguments to pass to the tool executable. You can refer to the
1365 1369 files being merged as well as the output file through these
1366 1370 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1367 1371
1368 1372 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1369 1373 being performed. During an update or merge, ``$local`` represents the original
1370 1374 state of the file, while ``$other`` represents the commit you are updating to or
1371 1375 the commit you are merging with. During a rebase, ``$local`` represents the
1372 1376 destination of the rebase, and ``$other`` represents the commit being rebased.
1373 1377
1374 1378 Some operations define custom labels to assist with identifying the revisions,
1375 1379 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1376 1380 labels are not available, these will be ``local``, ``other``, and ``base``,
1377 1381 respectively.
1378 1382 (default: ``$local $base $other``)
1379 1383
1380 1384 ``premerge``
1381 1385 Attempt to run internal non-interactive 3-way merge tool before
1382 1386 launching external tool. Options are ``true``, ``false``, ``keep`` or
1383 1387 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1384 1388 premerge fails. The ``keep-merge3`` will do the same but include information
1385 1389 about the base of the merge in the marker (see internal :merge3 in
1386 1390 :hg:`help merge-tools`).
1387 1391 (default: True)
1388 1392
1389 1393 ``binary``
1390 1394 This tool can merge binary files. (default: False, unless tool
1391 1395 was selected by file pattern match)
1392 1396
1393 1397 ``symlink``
1394 1398 This tool can merge symlinks. (default: False)
1395 1399
1396 1400 ``check``
1397 1401 A list of merge success-checking options:
1398 1402
1399 1403 ``changed``
1400 1404 Ask whether merge was successful when the merged file shows no changes.
1401 1405 ``conflicts``
1402 1406 Check whether there are conflicts even though the tool reported success.
1403 1407 ``prompt``
1404 1408 Always prompt for merge success, regardless of success reported by tool.
1405 1409
1406 1410 ``fixeol``
1407 1411 Attempt to fix up EOL changes caused by the merge tool.
1408 1412 (default: False)
1409 1413
1410 1414 ``gui``
1411 1415 This tool requires a graphical interface to run. (default: False)
1412 1416
1413 1417 ``mergemarkers``
1414 1418 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1415 1419 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1416 1420 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1417 1421 markers generated during premerge will be ``detailed`` if either this option or
1418 1422 the corresponding option in the ``[ui]`` section is ``detailed``.
1419 1423 (default: ``basic``)
1420 1424
1421 1425 ``mergemarkertemplate``
1422 1426 This setting can be used to override ``mergemarkertemplate`` from the ``[ui]``
1423 1427 section on a per-tool basis; this applies to the ``$label``-prefixed variables
1424 1428 and to the conflict markers that are generated if ``premerge`` is ``keep` or
1425 1429 ``keep-merge3``. See the corresponding variable in ``[ui]`` for more
1426 1430 information.
1427 1431
1428 1432 .. container:: windows
1429 1433
1430 1434 ``regkey``
1431 1435 Windows registry key which describes install location of this
1432 1436 tool. Mercurial will search for this key first under
1433 1437 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1434 1438 (default: None)
1435 1439
1436 1440 ``regkeyalt``
1437 1441 An alternate Windows registry key to try if the first key is not
1438 1442 found. The alternate key uses the same ``regname`` and ``regappend``
1439 1443 semantics of the primary key. The most common use for this key
1440 1444 is to search for 32bit applications on 64bit operating systems.
1441 1445 (default: None)
1442 1446
1443 1447 ``regname``
1444 1448 Name of value to read from specified registry key.
1445 1449 (default: the unnamed (default) value)
1446 1450
1447 1451 ``regappend``
1448 1452 String to append to the value read from the registry, typically
1449 1453 the executable name of the tool.
1450 1454 (default: None)
1451 1455
1452 1456 ``pager``
1453 1457 ---------
1454 1458
1455 1459 Setting used to control when to paginate and with what external tool. See
1456 1460 :hg:`help pager` for details.
1457 1461
1458 1462 ``pager``
1459 1463 Define the external tool used as pager.
1460 1464
1461 1465 If no pager is set, Mercurial uses the environment variable $PAGER.
1462 1466 If neither pager.pager, nor $PAGER is set, a default pager will be
1463 1467 used, typically `less` on Unix and `more` on Windows. Example::
1464 1468
1465 1469 [pager]
1466 1470 pager = less -FRX
1467 1471
1468 1472 ``ignore``
1469 1473 List of commands to disable the pager for. Example::
1470 1474
1471 1475 [pager]
1472 1476 ignore = version, help, update
1473 1477
1474 1478 ``patch``
1475 1479 ---------
1476 1480
1477 1481 Settings used when applying patches, for instance through the 'import'
1478 1482 command or with Mercurial Queues extension.
1479 1483
1480 1484 ``eol``
1481 1485 When set to 'strict' patch content and patched files end of lines
1482 1486 are preserved. When set to ``lf`` or ``crlf``, both files end of
1483 1487 lines are ignored when patching and the result line endings are
1484 1488 normalized to either LF (Unix) or CRLF (Windows). When set to
1485 1489 ``auto``, end of lines are again ignored while patching but line
1486 1490 endings in patched files are normalized to their original setting
1487 1491 on a per-file basis. If target file does not exist or has no end
1488 1492 of line, patch line endings are preserved.
1489 1493 (default: strict)
1490 1494
1491 1495 ``fuzz``
1492 1496 The number of lines of 'fuzz' to allow when applying patches. This
1493 1497 controls how much context the patcher is allowed to ignore when
1494 1498 trying to apply a patch.
1495 1499 (default: 2)
1496 1500
1497 1501 ``paths``
1498 1502 ---------
1499 1503
1500 1504 Assigns symbolic names and behavior to repositories.
1501 1505
1502 1506 Options are symbolic names defining the URL or directory that is the
1503 1507 location of the repository. Example::
1504 1508
1505 1509 [paths]
1506 1510 my_server = https://example.com/my_repo
1507 1511 local_path = /home/me/repo
1508 1512
1509 1513 These symbolic names can be used from the command line. To pull
1510 1514 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1511 1515 :hg:`push local_path`.
1512 1516
1513 1517 Options containing colons (``:``) denote sub-options that can influence
1514 1518 behavior for that specific path. Example::
1515 1519
1516 1520 [paths]
1517 1521 my_server = https://example.com/my_path
1518 1522 my_server:pushurl = ssh://example.com/my_path
1519 1523
1520 1524 The following sub-options can be defined:
1521 1525
1522 1526 ``pushurl``
1523 1527 The URL to use for push operations. If not defined, the location
1524 1528 defined by the path's main entry is used.
1525 1529
1526 1530 ``pushrev``
1527 1531 A revset defining which revisions to push by default.
1528 1532
1529 1533 When :hg:`push` is executed without a ``-r`` argument, the revset
1530 1534 defined by this sub-option is evaluated to determine what to push.
1531 1535
1532 1536 For example, a value of ``.`` will push the working directory's
1533 1537 revision by default.
1534 1538
1535 1539 Revsets specifying bookmarks will not result in the bookmark being
1536 1540 pushed.
1537 1541
1538 1542 The following special named paths exist:
1539 1543
1540 1544 ``default``
1541 1545 The URL or directory to use when no source or remote is specified.
1542 1546
1543 1547 :hg:`clone` will automatically define this path to the location the
1544 1548 repository was cloned from.
1545 1549
1546 1550 ``default-push``
1547 1551 (deprecated) The URL or directory for the default :hg:`push` location.
1548 1552 ``default:pushurl`` should be used instead.
1549 1553
1550 1554 ``phases``
1551 1555 ----------
1552 1556
1553 1557 Specifies default handling of phases. See :hg:`help phases` for more
1554 1558 information about working with phases.
1555 1559
1556 1560 ``publish``
1557 1561 Controls draft phase behavior when working as a server. When true,
1558 1562 pushed changesets are set to public in both client and server and
1559 1563 pulled or cloned changesets are set to public in the client.
1560 1564 (default: True)
1561 1565
1562 1566 ``new-commit``
1563 1567 Phase of newly-created commits.
1564 1568 (default: draft)
1565 1569
1566 1570 ``checksubrepos``
1567 1571 Check the phase of the current revision of each subrepository. Allowed
1568 1572 values are "ignore", "follow" and "abort". For settings other than
1569 1573 "ignore", the phase of the current revision of each subrepository is
1570 1574 checked before committing the parent repository. If any of those phases is
1571 1575 greater than the phase of the parent repository (e.g. if a subrepo is in a
1572 1576 "secret" phase while the parent repo is in "draft" phase), the commit is
1573 1577 either aborted (if checksubrepos is set to "abort") or the higher phase is
1574 1578 used for the parent repository commit (if set to "follow").
1575 1579 (default: follow)
1576 1580
1577 1581
1578 1582 ``profiling``
1579 1583 -------------
1580 1584
1581 1585 Specifies profiling type, format, and file output. Two profilers are
1582 1586 supported: an instrumenting profiler (named ``ls``), and a sampling
1583 1587 profiler (named ``stat``).
1584 1588
1585 1589 In this section description, 'profiling data' stands for the raw data
1586 1590 collected during profiling, while 'profiling report' stands for a
1587 1591 statistical text report generated from the profiling data.
1588 1592
1589 1593 ``enabled``
1590 1594 Enable the profiler.
1591 1595 (default: false)
1592 1596
1593 1597 This is equivalent to passing ``--profile`` on the command line.
1594 1598
1595 1599 ``type``
1596 1600 The type of profiler to use.
1597 1601 (default: stat)
1598 1602
1599 1603 ``ls``
1600 1604 Use Python's built-in instrumenting profiler. This profiler
1601 1605 works on all platforms, but each line number it reports is the
1602 1606 first line of a function. This restriction makes it difficult to
1603 1607 identify the expensive parts of a non-trivial function.
1604 1608 ``stat``
1605 1609 Use a statistical profiler, statprof. This profiler is most
1606 1610 useful for profiling commands that run for longer than about 0.1
1607 1611 seconds.
1608 1612
1609 1613 ``format``
1610 1614 Profiling format. Specific to the ``ls`` instrumenting profiler.
1611 1615 (default: text)
1612 1616
1613 1617 ``text``
1614 1618 Generate a profiling report. When saving to a file, it should be
1615 1619 noted that only the report is saved, and the profiling data is
1616 1620 not kept.
1617 1621 ``kcachegrind``
1618 1622 Format profiling data for kcachegrind use: when saving to a
1619 1623 file, the generated file can directly be loaded into
1620 1624 kcachegrind.
1621 1625
1622 1626 ``statformat``
1623 1627 Profiling format for the ``stat`` profiler.
1624 1628 (default: hotpath)
1625 1629
1626 1630 ``hotpath``
1627 1631 Show a tree-based display containing the hot path of execution (where
1628 1632 most time was spent).
1629 1633 ``bymethod``
1630 1634 Show a table of methods ordered by how frequently they are active.
1631 1635 ``byline``
1632 1636 Show a table of lines in files ordered by how frequently they are active.
1633 1637 ``json``
1634 1638 Render profiling data as JSON.
1635 1639
1636 1640 ``frequency``
1637 1641 Sampling frequency. Specific to the ``stat`` sampling profiler.
1638 1642 (default: 1000)
1639 1643
1640 1644 ``output``
1641 1645 File path where profiling data or report should be saved. If the
1642 1646 file exists, it is replaced. (default: None, data is printed on
1643 1647 stderr)
1644 1648
1645 1649 ``sort``
1646 1650 Sort field. Specific to the ``ls`` instrumenting profiler.
1647 1651 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1648 1652 ``inlinetime``.
1649 1653 (default: inlinetime)
1650 1654
1651 1655 ``limit``
1652 1656 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1653 1657 (default: 30)
1654 1658
1655 1659 ``nested``
1656 1660 Show at most this number of lines of drill-down info after each main entry.
1657 1661 This can help explain the difference between Total and Inline.
1658 1662 Specific to the ``ls`` instrumenting profiler.
1659 1663 (default: 0)
1660 1664
1661 1665 ``showmin``
1662 1666 Minimum fraction of samples an entry must have for it to be displayed.
1663 1667 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1664 1668 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1665 1669
1666 1670 Only used by the ``stat`` profiler.
1667 1671
1668 1672 For the ``hotpath`` format, default is ``0.05``.
1669 1673 For the ``chrome`` format, default is ``0.005``.
1670 1674
1671 1675 The option is unused on other formats.
1672 1676
1673 1677 ``showmax``
1674 1678 Maximum fraction of samples an entry can have before it is ignored in
1675 1679 display. Values format is the same as ``showmin``.
1676 1680
1677 1681 Only used by the ``stat`` profiler.
1678 1682
1679 1683 For the ``chrome`` format, default is ``0.999``.
1680 1684
1681 1685 The option is unused on other formats.
1682 1686
1683 1687 ``progress``
1684 1688 ------------
1685 1689
1686 1690 Mercurial commands can draw progress bars that are as informative as
1687 1691 possible. Some progress bars only offer indeterminate information, while others
1688 1692 have a definite end point.
1689 1693
1690 1694 ``delay``
1691 1695 Number of seconds (float) before showing the progress bar. (default: 3)
1692 1696
1693 1697 ``changedelay``
1694 1698 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1695 1699 that value will be used instead. (default: 1)
1696 1700
1697 1701 ``estimateinterval``
1698 1702 Maximum sampling interval in seconds for speed and estimated time
1699 1703 calculation. (default: 60)
1700 1704
1701 1705 ``refresh``
1702 1706 Time in seconds between refreshes of the progress bar. (default: 0.1)
1703 1707
1704 1708 ``format``
1705 1709 Format of the progress bar.
1706 1710
1707 1711 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1708 1712 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1709 1713 last 20 characters of the item, but this can be changed by adding either
1710 1714 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1711 1715 first num characters.
1712 1716
1713 1717 (default: topic bar number estimate)
1714 1718
1715 1719 ``width``
1716 1720 If set, the maximum width of the progress information (that is, min(width,
1717 1721 term width) will be used).
1718 1722
1719 1723 ``clear-complete``
1720 1724 Clear the progress bar after it's done. (default: True)
1721 1725
1722 1726 ``disable``
1723 1727 If true, don't show a progress bar.
1724 1728
1725 1729 ``assume-tty``
1726 1730 If true, ALWAYS show a progress bar, unless disable is given.
1727 1731
1728 1732 ``rebase``
1729 1733 ----------
1730 1734
1731 1735 ``evolution.allowdivergence``
1732 1736 Default to False, when True allow creating divergence when performing
1733 1737 rebase of obsolete changesets.
1734 1738
1735 1739 ``revsetalias``
1736 1740 ---------------
1737 1741
1738 1742 Alias definitions for revsets. See :hg:`help revsets` for details.
1739 1743
1740 1744 ``server``
1741 1745 ----------
1742 1746
1743 1747 Controls generic server settings.
1744 1748
1745 1749 ``bookmarks-pushkey-compat``
1746 1750 Trigger pushkey hook when being pushed bookmark updates. This config exist
1747 1751 for compatibility purpose (default to True)
1748 1752
1749 1753 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
1750 1754 movement we recommend you migrate them to ``txnclose-bookmark`` and
1751 1755 ``pretxnclose-bookmark``.
1752 1756
1753 1757 ``compressionengines``
1754 1758 List of compression engines and their relative priority to advertise
1755 1759 to clients.
1756 1760
1757 1761 The order of compression engines determines their priority, the first
1758 1762 having the highest priority. If a compression engine is not listed
1759 1763 here, it won't be advertised to clients.
1760 1764
1761 1765 If not set (the default), built-in defaults are used. Run
1762 1766 :hg:`debuginstall` to list available compression engines and their
1763 1767 default wire protocol priority.
1764 1768
1765 1769 Older Mercurial clients only support zlib compression and this setting
1766 1770 has no effect for legacy clients.
1767 1771
1768 1772 ``uncompressed``
1769 1773 Whether to allow clients to clone a repository using the
1770 1774 uncompressed streaming protocol. This transfers about 40% more
1771 1775 data than a regular clone, but uses less memory and CPU on both
1772 1776 server and client. Over a LAN (100 Mbps or better) or a very fast
1773 1777 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1774 1778 regular clone. Over most WAN connections (anything slower than
1775 1779 about 6 Mbps), uncompressed streaming is slower, because of the
1776 1780 extra data transfer overhead. This mode will also temporarily hold
1777 1781 the write lock while determining what data to transfer.
1778 1782 (default: True)
1779 1783
1780 1784 ``uncompressedallowsecret``
1781 1785 Whether to allow stream clones when the repository contains secret
1782 1786 changesets. (default: False)
1783 1787
1784 1788 ``preferuncompressed``
1785 1789 When set, clients will try to use the uncompressed streaming
1786 1790 protocol. (default: False)
1787 1791
1788 1792 ``disablefullbundle``
1789 1793 When set, servers will refuse attempts to do pull-based clones.
1790 1794 If this option is set, ``preferuncompressed`` and/or clone bundles
1791 1795 are highly recommended. Partial clones will still be allowed.
1792 1796 (default: False)
1793 1797
1794 1798 ``streamunbundle``
1795 1799 When set, servers will apply data sent from the client directly,
1796 1800 otherwise it will be written to a temporary file first. This option
1797 1801 effectively prevents concurrent pushes.
1798 1802
1799 1803 ``pullbundle``
1800 1804 When set, the server will check pullbundle.manifest for bundles
1801 1805 covering the requested heads and common nodes. The first matching
1802 1806 entry will be streamed to the client.
1803 1807
1804 1808 For HTTP transport, the stream will still use zlib compression
1805 1809 for older clients.
1806 1810
1807 1811 ``concurrent-push-mode``
1808 1812 Level of allowed race condition between two pushing clients.
1809 1813
1810 1814 - 'strict': push is abort if another client touched the repository
1811 1815 while the push was preparing. (default)
1812 1816 - 'check-related': push is only aborted if it affects head that got also
1813 1817 affected while the push was preparing.
1814 1818
1815 1819 This requires compatible client (version 4.3 and later). Old client will
1816 1820 use 'strict'.
1817 1821
1818 1822 ``validate``
1819 1823 Whether to validate the completeness of pushed changesets by
1820 1824 checking that all new file revisions specified in manifests are
1821 1825 present. (default: False)
1822 1826
1823 1827 ``maxhttpheaderlen``
1824 1828 Instruct HTTP clients not to send request headers longer than this
1825 1829 many bytes. (default: 1024)
1826 1830
1827 1831 ``bundle1``
1828 1832 Whether to allow clients to push and pull using the legacy bundle1
1829 1833 exchange format. (default: True)
1830 1834
1831 1835 ``bundle1gd``
1832 1836 Like ``bundle1`` but only used if the repository is using the
1833 1837 *generaldelta* storage format. (default: True)
1834 1838
1835 1839 ``bundle1.push``
1836 1840 Whether to allow clients to push using the legacy bundle1 exchange
1837 1841 format. (default: True)
1838 1842
1839 1843 ``bundle1gd.push``
1840 1844 Like ``bundle1.push`` but only used if the repository is using the
1841 1845 *generaldelta* storage format. (default: True)
1842 1846
1843 1847 ``bundle1.pull``
1844 1848 Whether to allow clients to pull using the legacy bundle1 exchange
1845 1849 format. (default: True)
1846 1850
1847 1851 ``bundle1gd.pull``
1848 1852 Like ``bundle1.pull`` but only used if the repository is using the
1849 1853 *generaldelta* storage format. (default: True)
1850 1854
1851 1855 Large repositories using the *generaldelta* storage format should
1852 1856 consider setting this option because converting *generaldelta*
1853 1857 repositories to the exchange format required by the bundle1 data
1854 1858 format can consume a lot of CPU.
1855 1859
1856 1860 ``zliblevel``
1857 1861 Integer between ``-1`` and ``9`` that controls the zlib compression level
1858 1862 for wire protocol commands that send zlib compressed output (notably the
1859 1863 commands that send repository history data).
1860 1864
1861 1865 The default (``-1``) uses the default zlib compression level, which is
1862 1866 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
1863 1867 maximum compression.
1864 1868
1865 1869 Setting this option allows server operators to make trade-offs between
1866 1870 bandwidth and CPU used. Lowering the compression lowers CPU utilization
1867 1871 but sends more bytes to clients.
1868 1872
1869 1873 This option only impacts the HTTP server.
1870 1874
1871 1875 ``zstdlevel``
1872 1876 Integer between ``1`` and ``22`` that controls the zstd compression level
1873 1877 for wire protocol commands. ``1`` is the minimal amount of compression and
1874 1878 ``22`` is the highest amount of compression.
1875 1879
1876 1880 The default (``3``) should be significantly faster than zlib while likely
1877 1881 delivering better compression ratios.
1878 1882
1879 1883 This option only impacts the HTTP server.
1880 1884
1881 1885 See also ``server.zliblevel``.
1882 1886
1883 1887 ``smtp``
1884 1888 --------
1885 1889
1886 1890 Configuration for extensions that need to send email messages.
1887 1891
1888 1892 ``host``
1889 1893 Host name of mail server, e.g. "mail.example.com".
1890 1894
1891 1895 ``port``
1892 1896 Optional. Port to connect to on mail server. (default: 465 if
1893 1897 ``tls`` is smtps; 25 otherwise)
1894 1898
1895 1899 ``tls``
1896 1900 Optional. Method to enable TLS when connecting to mail server: starttls,
1897 1901 smtps or none. (default: none)
1898 1902
1899 1903 ``username``
1900 1904 Optional. User name for authenticating with the SMTP server.
1901 1905 (default: None)
1902 1906
1903 1907 ``password``
1904 1908 Optional. Password for authenticating with the SMTP server. If not
1905 1909 specified, interactive sessions will prompt the user for a
1906 1910 password; non-interactive sessions will fail. (default: None)
1907 1911
1908 1912 ``local_hostname``
1909 1913 Optional. The hostname that the sender can use to identify
1910 1914 itself to the MTA.
1911 1915
1912 1916
1913 1917 ``subpaths``
1914 1918 ------------
1915 1919
1916 1920 Subrepository source URLs can go stale if a remote server changes name
1917 1921 or becomes temporarily unavailable. This section lets you define
1918 1922 rewrite rules of the form::
1919 1923
1920 1924 <pattern> = <replacement>
1921 1925
1922 1926 where ``pattern`` is a regular expression matching a subrepository
1923 1927 source URL and ``replacement`` is the replacement string used to
1924 1928 rewrite it. Groups can be matched in ``pattern`` and referenced in
1925 1929 ``replacements``. For instance::
1926 1930
1927 1931 http://server/(.*)-hg/ = http://hg.server/\1/
1928 1932
1929 1933 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1930 1934
1931 1935 Relative subrepository paths are first made absolute, and the
1932 1936 rewrite rules are then applied on the full (absolute) path. If ``pattern``
1933 1937 doesn't match the full path, an attempt is made to apply it on the
1934 1938 relative path alone. The rules are applied in definition order.
1935 1939
1936 1940 ``subrepos``
1937 1941 ------------
1938 1942
1939 1943 This section contains options that control the behavior of the
1940 1944 subrepositories feature. See also :hg:`help subrepos`.
1941 1945
1942 1946 Security note: auditing in Mercurial is known to be insufficient to
1943 1947 prevent clone-time code execution with carefully constructed Git
1944 1948 subrepos. It is unknown if a similar detect is present in Subversion
1945 1949 subrepos. Both Git and Subversion subrepos are disabled by default
1946 1950 out of security concerns. These subrepo types can be enabled using
1947 1951 the respective options below.
1948 1952
1949 1953 ``allowed``
1950 1954 Whether subrepositories are allowed in the working directory.
1951 1955
1952 1956 When false, commands involving subrepositories (like :hg:`update`)
1953 1957 will fail for all subrepository types.
1954 1958 (default: true)
1955 1959
1956 1960 ``hg:allowed``
1957 1961 Whether Mercurial subrepositories are allowed in the working
1958 1962 directory. This option only has an effect if ``subrepos.allowed``
1959 1963 is true.
1960 1964 (default: true)
1961 1965
1962 1966 ``git:allowed``
1963 1967 Whether Git subrepositories are allowed in the working directory.
1964 1968 This option only has an effect if ``subrepos.allowed`` is true.
1965 1969
1966 1970 See the security note above before enabling Git subrepos.
1967 1971 (default: false)
1968 1972
1969 1973 ``svn:allowed``
1970 1974 Whether Subversion subrepositories are allowed in the working
1971 1975 directory. This option only has an effect if ``subrepos.allowed``
1972 1976 is true.
1973 1977
1974 1978 See the security note above before enabling Subversion subrepos.
1975 1979 (default: false)
1976 1980
1977 1981 ``templatealias``
1978 1982 -----------------
1979 1983
1980 1984 Alias definitions for templates. See :hg:`help templates` for details.
1981 1985
1982 1986 ``templates``
1983 1987 -------------
1984 1988
1985 1989 Use the ``[templates]`` section to define template strings.
1986 1990 See :hg:`help templates` for details.
1987 1991
1988 1992 ``trusted``
1989 1993 -----------
1990 1994
1991 1995 Mercurial will not use the settings in the
1992 1996 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
1993 1997 user or to a trusted group, as various hgrc features allow arbitrary
1994 1998 commands to be run. This issue is often encountered when configuring
1995 1999 hooks or extensions for shared repositories or servers. However,
1996 2000 the web interface will use some safe settings from the ``[web]``
1997 2001 section.
1998 2002
1999 2003 This section specifies what users and groups are trusted. The
2000 2004 current user is always trusted. To trust everybody, list a user or a
2001 2005 group with name ``*``. These settings must be placed in an
2002 2006 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2003 2007 user or service running Mercurial.
2004 2008
2005 2009 ``users``
2006 2010 Comma-separated list of trusted users.
2007 2011
2008 2012 ``groups``
2009 2013 Comma-separated list of trusted groups.
2010 2014
2011 2015
2012 2016 ``ui``
2013 2017 ------
2014 2018
2015 2019 User interface controls.
2016 2020
2017 2021 ``archivemeta``
2018 2022 Whether to include the .hg_archival.txt file containing meta data
2019 2023 (hashes for the repository base and for tip) in archives created
2020 2024 by the :hg:`archive` command or downloaded via hgweb.
2021 2025 (default: True)
2022 2026
2023 2027 ``askusername``
2024 2028 Whether to prompt for a username when committing. If True, and
2025 2029 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2026 2030 be prompted to enter a username. If no username is entered, the
2027 2031 default ``USER@HOST`` is used instead.
2028 2032 (default: False)
2029 2033
2030 2034 ``clonebundles``
2031 2035 Whether the "clone bundles" feature is enabled.
2032 2036
2033 2037 When enabled, :hg:`clone` may download and apply a server-advertised
2034 2038 bundle file from a URL instead of using the normal exchange mechanism.
2035 2039
2036 2040 This can likely result in faster and more reliable clones.
2037 2041
2038 2042 (default: True)
2039 2043
2040 2044 ``clonebundlefallback``
2041 2045 Whether failure to apply an advertised "clone bundle" from a server
2042 2046 should result in fallback to a regular clone.
2043 2047
2044 2048 This is disabled by default because servers advertising "clone
2045 2049 bundles" often do so to reduce server load. If advertised bundles
2046 2050 start mass failing and clients automatically fall back to a regular
2047 2051 clone, this would add significant and unexpected load to the server
2048 2052 since the server is expecting clone operations to be offloaded to
2049 2053 pre-generated bundles. Failing fast (the default behavior) ensures
2050 2054 clients don't overwhelm the server when "clone bundle" application
2051 2055 fails.
2052 2056
2053 2057 (default: False)
2054 2058
2055 2059 ``clonebundleprefers``
2056 2060 Defines preferences for which "clone bundles" to use.
2057 2061
2058 2062 Servers advertising "clone bundles" may advertise multiple available
2059 2063 bundles. Each bundle may have different attributes, such as the bundle
2060 2064 type and compression format. This option is used to prefer a particular
2061 2065 bundle over another.
2062 2066
2063 2067 The following keys are defined by Mercurial:
2064 2068
2065 2069 BUNDLESPEC
2066 2070 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2067 2071 e.g. ``gzip-v2`` or ``bzip2-v1``.
2068 2072
2069 2073 COMPRESSION
2070 2074 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2071 2075
2072 2076 Server operators may define custom keys.
2073 2077
2074 2078 Example values: ``COMPRESSION=bzip2``,
2075 2079 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2076 2080
2077 2081 By default, the first bundle advertised by the server is used.
2078 2082
2079 2083 ``color``
2080 2084 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2081 2085 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2082 2086 seems possible. See :hg:`help color` for details.
2083 2087
2084 2088 ``commitsubrepos``
2085 2089 Whether to commit modified subrepositories when committing the
2086 2090 parent repository. If False and one subrepository has uncommitted
2087 2091 changes, abort the commit.
2088 2092 (default: False)
2089 2093
2090 2094 ``debug``
2091 2095 Print debugging information. (default: False)
2092 2096
2093 2097 ``editor``
2094 2098 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2095 2099
2096 2100 ``fallbackencoding``
2097 2101 Encoding to try if it's not possible to decode the changelog using
2098 2102 UTF-8. (default: ISO-8859-1)
2099 2103
2100 2104 ``graphnodetemplate``
2101 2105 The template used to print changeset nodes in an ASCII revision graph.
2102 2106 (default: ``{graphnode}``)
2103 2107
2104 2108 ``ignore``
2105 2109 A file to read per-user ignore patterns from. This file should be
2106 2110 in the same format as a repository-wide .hgignore file. Filenames
2107 2111 are relative to the repository root. This option supports hook syntax,
2108 2112 so if you want to specify multiple ignore files, you can do so by
2109 2113 setting something like ``ignore.other = ~/.hgignore2``. For details
2110 2114 of the ignore file format, see the ``hgignore(5)`` man page.
2111 2115
2112 2116 ``interactive``
2113 2117 Allow to prompt the user. (default: True)
2114 2118
2115 2119 ``interface``
2116 2120 Select the default interface for interactive features (default: text).
2117 2121 Possible values are 'text' and 'curses'.
2118 2122
2119 2123 ``interface.chunkselector``
2120 2124 Select the interface for change recording (e.g. :hg:`commit -i`).
2121 2125 Possible values are 'text' and 'curses'.
2122 2126 This config overrides the interface specified by ui.interface.
2123 2127
2124 2128 ``logtemplate``
2125 2129 Template string for commands that print changesets.
2126 2130
2127 2131 ``merge``
2128 2132 The conflict resolution program to use during a manual merge.
2129 2133 For more information on merge tools see :hg:`help merge-tools`.
2130 2134 For configuring merge tools see the ``[merge-tools]`` section.
2131 2135
2132 2136 ``mergemarkers``
2133 2137 Sets the merge conflict marker label styling. The ``detailed``
2134 2138 style uses the ``mergemarkertemplate`` setting to style the labels.
2135 2139 The ``basic`` style just uses 'local' and 'other' as the marker label.
2136 2140 One of ``basic`` or ``detailed``.
2137 2141 (default: ``basic``)
2138 2142
2139 2143 ``mergemarkertemplate``
2140 2144 The template used to print the commit description next to each conflict
2141 2145 marker during merge conflicts. See :hg:`help templates` for the template
2142 2146 format.
2143 2147
2144 2148 Defaults to showing the hash, tags, branches, bookmarks, author, and
2145 2149 the first line of the commit description.
2146 2150
2147 2151 If you use non-ASCII characters in names for tags, branches, bookmarks,
2148 2152 authors, and/or commit descriptions, you must pay attention to encodings of
2149 2153 managed files. At template expansion, non-ASCII characters use the encoding
2150 2154 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2151 2155 environment variables that govern your locale. If the encoding of the merge
2152 2156 markers is different from the encoding of the merged files,
2153 2157 serious problems may occur.
2154 2158
2155 2159 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2156 2160
2157 2161 ``origbackuppath``
2158 2162 The path to a directory used to store generated .orig files. If the path is
2159 2163 not a directory, one will be created. If set, files stored in this
2160 2164 directory have the same name as the original file and do not have a .orig
2161 2165 suffix.
2162 2166
2163 2167 ``paginate``
2164 2168 Control the pagination of command output (default: True). See :hg:`help pager`
2165 2169 for details.
2166 2170
2167 2171 ``patch``
2168 2172 An optional external tool that ``hg import`` and some extensions
2169 2173 will use for applying patches. By default Mercurial uses an
2170 2174 internal patch utility. The external tool must work as the common
2171 2175 Unix ``patch`` program. In particular, it must accept a ``-p``
2172 2176 argument to strip patch headers, a ``-d`` argument to specify the
2173 2177 current directory, a file name to patch, and a patch file to take
2174 2178 from stdin.
2175 2179
2176 2180 It is possible to specify a patch tool together with extra
2177 2181 arguments. For example, setting this option to ``patch --merge``
2178 2182 will use the ``patch`` program with its 2-way merge option.
2179 2183
2180 2184 ``portablefilenames``
2181 2185 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2182 2186 (default: ``warn``)
2183 2187
2184 2188 ``warn``
2185 2189 Print a warning message on POSIX platforms, if a file with a non-portable
2186 2190 filename is added (e.g. a file with a name that can't be created on
2187 2191 Windows because it contains reserved parts like ``AUX``, reserved
2188 2192 characters like ``:``, or would cause a case collision with an existing
2189 2193 file).
2190 2194
2191 2195 ``ignore``
2192 2196 Don't print a warning.
2193 2197
2194 2198 ``abort``
2195 2199 The command is aborted.
2196 2200
2197 2201 ``true``
2198 2202 Alias for ``warn``.
2199 2203
2200 2204 ``false``
2201 2205 Alias for ``ignore``.
2202 2206
2203 2207 .. container:: windows
2204 2208
2205 2209 On Windows, this configuration option is ignored and the command aborted.
2206 2210
2207 2211 ``quiet``
2208 2212 Reduce the amount of output printed.
2209 2213 (default: False)
2210 2214
2211 2215 ``remotecmd``
2212 2216 Remote command to use for clone/push/pull operations.
2213 2217 (default: ``hg``)
2214 2218
2215 2219 ``report_untrusted``
2216 2220 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2217 2221 trusted user or group.
2218 2222 (default: True)
2219 2223
2220 2224 ``slash``
2221 2225 (Deprecated. Use ``slashpath`` template filter instead.)
2222 2226
2223 2227 Display paths using a slash (``/``) as the path separator. This
2224 2228 only makes a difference on systems where the default path
2225 2229 separator is not the slash character (e.g. Windows uses the
2226 2230 backslash character (``\``)).
2227 2231 (default: False)
2228 2232
2229 2233 ``statuscopies``
2230 2234 Display copies in the status command.
2231 2235
2232 2236 ``ssh``
2233 2237 Command to use for SSH connections. (default: ``ssh``)
2234 2238
2235 2239 ``ssherrorhint``
2236 2240 A hint shown to the user in the case of SSH error (e.g.
2237 2241 ``Please see http://company/internalwiki/ssh.html``)
2238 2242
2239 2243 ``strict``
2240 2244 Require exact command names, instead of allowing unambiguous
2241 2245 abbreviations. (default: False)
2242 2246
2243 2247 ``style``
2244 2248 Name of style to use for command output.
2245 2249
2246 2250 ``supportcontact``
2247 2251 A URL where users should report a Mercurial traceback. Use this if you are a
2248 2252 large organisation with its own Mercurial deployment process and crash
2249 2253 reports should be addressed to your internal support.
2250 2254
2251 2255 ``textwidth``
2252 2256 Maximum width of help text. A longer line generated by ``hg help`` or
2253 2257 ``hg subcommand --help`` will be broken after white space to get this
2254 2258 width or the terminal width, whichever comes first.
2255 2259 A non-positive value will disable this and the terminal width will be
2256 2260 used. (default: 78)
2257 2261
2258 2262 ``timeout``
2259 2263 The timeout used when a lock is held (in seconds), a negative value
2260 2264 means no timeout. (default: 600)
2261 2265
2262 2266 ``timeout.warn``
2263 2267 Time (in seconds) before a warning is printed about held lock. A negative
2264 2268 value means no warning. (default: 0)
2265 2269
2266 2270 ``traceback``
2267 2271 Mercurial always prints a traceback when an unknown exception
2268 2272 occurs. Setting this to True will make Mercurial print a traceback
2269 2273 on all exceptions, even those recognized by Mercurial (such as
2270 2274 IOError or MemoryError). (default: False)
2271 2275
2272 2276 ``tweakdefaults``
2273 2277
2274 2278 By default Mercurial's behavior changes very little from release
2275 2279 to release, but over time the recommended config settings
2276 2280 shift. Enable this config to opt in to get automatic tweaks to
2277 2281 Mercurial's behavior over time. This config setting will have no
2278 2282 effet if ``HGPLAIN` is set or ``HGPLAINEXCEPT`` is set and does
2279 2283 not include ``tweakdefaults``. (default: False)
2280 2284
2281 2285 ``username``
2282 2286 The committer of a changeset created when running "commit".
2283 2287 Typically a person's name and email address, e.g. ``Fred Widget
2284 2288 <fred@example.com>``. Environment variables in the
2285 2289 username are expanded.
2286 2290
2287 2291 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2288 2292 hgrc is empty, e.g. if the system admin set ``username =`` in the
2289 2293 system hgrc, it has to be specified manually or in a different
2290 2294 hgrc file)
2291 2295
2292 2296 ``verbose``
2293 2297 Increase the amount of output printed. (default: False)
2294 2298
2295 2299
2296 2300 ``web``
2297 2301 -------
2298 2302
2299 2303 Web interface configuration. The settings in this section apply to
2300 2304 both the builtin webserver (started by :hg:`serve`) and the script you
2301 2305 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2302 2306 and WSGI).
2303 2307
2304 2308 The Mercurial webserver does no authentication (it does not prompt for
2305 2309 usernames and passwords to validate *who* users are), but it does do
2306 2310 authorization (it grants or denies access for *authenticated users*
2307 2311 based on settings in this section). You must either configure your
2308 2312 webserver to do authentication for you, or disable the authorization
2309 2313 checks.
2310 2314
2311 2315 For a quick setup in a trusted environment, e.g., a private LAN, where
2312 2316 you want it to accept pushes from anybody, you can use the following
2313 2317 command line::
2314 2318
2315 2319 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2316 2320
2317 2321 Note that this will allow anybody to push anything to the server and
2318 2322 that this should not be used for public servers.
2319 2323
2320 2324 The full set of options is:
2321 2325
2322 2326 ``accesslog``
2323 2327 Where to output the access log. (default: stdout)
2324 2328
2325 2329 ``address``
2326 2330 Interface address to bind to. (default: all)
2327 2331
2328 2332 ``allow_archive``
2329 2333 List of archive format (bz2, gz, zip) allowed for downloading.
2330 2334 (default: empty)
2331 2335
2332 2336 ``allowbz2``
2333 2337 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2334 2338 revisions.
2335 2339 (default: False)
2336 2340
2337 2341 ``allowgz``
2338 2342 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2339 2343 revisions.
2340 2344 (default: False)
2341 2345
2342 2346 ``allow-pull``
2343 2347 Whether to allow pulling from the repository. (default: True)
2344 2348
2345 2349 ``allow-push``
2346 2350 Whether to allow pushing to the repository. If empty or not set,
2347 2351 pushing is not allowed. If the special value ``*``, any remote
2348 2352 user can push, including unauthenticated users. Otherwise, the
2349 2353 remote user must have been authenticated, and the authenticated
2350 2354 user name must be present in this list. The contents of the
2351 2355 allow-push list are examined after the deny_push list.
2352 2356
2353 2357 ``allow_read``
2354 2358 If the user has not already been denied repository access due to
2355 2359 the contents of deny_read, this list determines whether to grant
2356 2360 repository access to the user. If this list is not empty, and the
2357 2361 user is unauthenticated or not present in the list, then access is
2358 2362 denied for the user. If the list is empty or not set, then access
2359 2363 is permitted to all users by default. Setting allow_read to the
2360 2364 special value ``*`` is equivalent to it not being set (i.e. access
2361 2365 is permitted to all users). The contents of the allow_read list are
2362 2366 examined after the deny_read list.
2363 2367
2364 2368 ``allowzip``
2365 2369 (DEPRECATED) Whether to allow .zip downloading of repository
2366 2370 revisions. This feature creates temporary files.
2367 2371 (default: False)
2368 2372
2369 2373 ``archivesubrepos``
2370 2374 Whether to recurse into subrepositories when archiving.
2371 2375 (default: False)
2372 2376
2373 2377 ``baseurl``
2374 2378 Base URL to use when publishing URLs in other locations, so
2375 2379 third-party tools like email notification hooks can construct
2376 2380 URLs. Example: ``http://hgserver/repos/``.
2377 2381
2378 2382 ``cacerts``
2379 2383 Path to file containing a list of PEM encoded certificate
2380 2384 authority certificates. Environment variables and ``~user``
2381 2385 constructs are expanded in the filename. If specified on the
2382 2386 client, then it will verify the identity of remote HTTPS servers
2383 2387 with these certificates.
2384 2388
2385 2389 To disable SSL verification temporarily, specify ``--insecure`` from
2386 2390 command line.
2387 2391
2388 2392 You can use OpenSSL's CA certificate file if your platform has
2389 2393 one. On most Linux systems this will be
2390 2394 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2391 2395 generate this file manually. The form must be as follows::
2392 2396
2393 2397 -----BEGIN CERTIFICATE-----
2394 2398 ... (certificate in base64 PEM encoding) ...
2395 2399 -----END CERTIFICATE-----
2396 2400 -----BEGIN CERTIFICATE-----
2397 2401 ... (certificate in base64 PEM encoding) ...
2398 2402 -----END CERTIFICATE-----
2399 2403
2400 2404 ``cache``
2401 2405 Whether to support caching in hgweb. (default: True)
2402 2406
2403 2407 ``certificate``
2404 2408 Certificate to use when running :hg:`serve`.
2405 2409
2406 2410 ``collapse``
2407 2411 With ``descend`` enabled, repositories in subdirectories are shown at
2408 2412 a single level alongside repositories in the current path. With
2409 2413 ``collapse`` also enabled, repositories residing at a deeper level than
2410 2414 the current path are grouped behind navigable directory entries that
2411 2415 lead to the locations of these repositories. In effect, this setting
2412 2416 collapses each collection of repositories found within a subdirectory
2413 2417 into a single entry for that subdirectory. (default: False)
2414 2418
2415 2419 ``comparisoncontext``
2416 2420 Number of lines of context to show in side-by-side file comparison. If
2417 2421 negative or the value ``full``, whole files are shown. (default: 5)
2418 2422
2419 2423 This setting can be overridden by a ``context`` request parameter to the
2420 2424 ``comparison`` command, taking the same values.
2421 2425
2422 2426 ``contact``
2423 2427 Name or email address of the person in charge of the repository.
2424 2428 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2425 2429
2426 2430 ``csp``
2427 2431 Send a ``Content-Security-Policy`` HTTP header with this value.
2428 2432
2429 2433 The value may contain a special string ``%nonce%``, which will be replaced
2430 2434 by a randomly-generated one-time use value. If the value contains
2431 2435 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2432 2436 one-time property of the nonce. This nonce will also be inserted into
2433 2437 ``<script>`` elements containing inline JavaScript.
2434 2438
2435 2439 Note: lots of HTML content sent by the server is derived from repository
2436 2440 data. Please consider the potential for malicious repository data to
2437 2441 "inject" itself into generated HTML content as part of your security
2438 2442 threat model.
2439 2443
2440 2444 ``deny_push``
2441 2445 Whether to deny pushing to the repository. If empty or not set,
2442 2446 push is not denied. If the special value ``*``, all remote users are
2443 2447 denied push. Otherwise, unauthenticated users are all denied, and
2444 2448 any authenticated user name present in this list is also denied. The
2445 2449 contents of the deny_push list are examined before the allow-push list.
2446 2450
2447 2451 ``deny_read``
2448 2452 Whether to deny reading/viewing of the repository. If this list is
2449 2453 not empty, unauthenticated users are all denied, and any
2450 2454 authenticated user name present in this list is also denied access to
2451 2455 the repository. If set to the special value ``*``, all remote users
2452 2456 are denied access (rarely needed ;). If deny_read is empty or not set,
2453 2457 the determination of repository access depends on the presence and
2454 2458 content of the allow_read list (see description). If both
2455 2459 deny_read and allow_read are empty or not set, then access is
2456 2460 permitted to all users by default. If the repository is being
2457 2461 served via hgwebdir, denied users will not be able to see it in
2458 2462 the list of repositories. The contents of the deny_read list have
2459 2463 priority over (are examined before) the contents of the allow_read
2460 2464 list.
2461 2465
2462 2466 ``descend``
2463 2467 hgwebdir indexes will not descend into subdirectories. Only repositories
2464 2468 directly in the current path will be shown (other repositories are still
2465 2469 available from the index corresponding to their containing path).
2466 2470
2467 2471 ``description``
2468 2472 Textual description of the repository's purpose or contents.
2469 2473 (default: "unknown")
2470 2474
2471 2475 ``encoding``
2472 2476 Character encoding name. (default: the current locale charset)
2473 2477 Example: "UTF-8".
2474 2478
2475 2479 ``errorlog``
2476 2480 Where to output the error log. (default: stderr)
2477 2481
2478 2482 ``guessmime``
2479 2483 Control MIME types for raw download of file content.
2480 2484 Set to True to let hgweb guess the content type from the file
2481 2485 extension. This will serve HTML files as ``text/html`` and might
2482 2486 allow cross-site scripting attacks when serving untrusted
2483 2487 repositories. (default: False)
2484 2488
2485 2489 ``hidden``
2486 2490 Whether to hide the repository in the hgwebdir index.
2487 2491 (default: False)
2488 2492
2489 2493 ``ipv6``
2490 2494 Whether to use IPv6. (default: False)
2491 2495
2492 2496 ``labels``
2493 2497 List of string *labels* associated with the repository.
2494 2498
2495 2499 Labels are exposed as a template keyword and can be used to customize
2496 2500 output. e.g. the ``index`` template can group or filter repositories
2497 2501 by labels and the ``summary`` template can display additional content
2498 2502 if a specific label is present.
2499 2503
2500 2504 ``logoimg``
2501 2505 File name of the logo image that some templates display on each page.
2502 2506 The file name is relative to ``staticurl``. That is, the full path to
2503 2507 the logo image is "staticurl/logoimg".
2504 2508 If unset, ``hglogo.png`` will be used.
2505 2509
2506 2510 ``logourl``
2507 2511 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2508 2512 will be used.
2509 2513
2510 2514 ``maxchanges``
2511 2515 Maximum number of changes to list on the changelog. (default: 10)
2512 2516
2513 2517 ``maxfiles``
2514 2518 Maximum number of files to list per changeset. (default: 10)
2515 2519
2516 2520 ``maxshortchanges``
2517 2521 Maximum number of changes to list on the shortlog, graph or filelog
2518 2522 pages. (default: 60)
2519 2523
2520 2524 ``name``
2521 2525 Repository name to use in the web interface.
2522 2526 (default: current working directory)
2523 2527
2524 2528 ``port``
2525 2529 Port to listen on. (default: 8000)
2526 2530
2527 2531 ``prefix``
2528 2532 Prefix path to serve from. (default: '' (server root))
2529 2533
2530 2534 ``push_ssl``
2531 2535 Whether to require that inbound pushes be transported over SSL to
2532 2536 prevent password sniffing. (default: True)
2533 2537
2534 2538 ``refreshinterval``
2535 2539 How frequently directory listings re-scan the filesystem for new
2536 2540 repositories, in seconds. This is relevant when wildcards are used
2537 2541 to define paths. Depending on how much filesystem traversal is
2538 2542 required, refreshing may negatively impact performance.
2539 2543
2540 2544 Values less than or equal to 0 always refresh.
2541 2545 (default: 20)
2542 2546
2543 2547 ``server-header``
2544 2548 Value for HTTP ``Server`` response header.
2545 2549
2546 2550 ``staticurl``
2547 2551 Base URL to use for static files. If unset, static files (e.g. the
2548 2552 hgicon.png favicon) will be served by the CGI script itself. Use
2549 2553 this setting to serve them directly with the HTTP server.
2550 2554 Example: ``http://hgserver/static/``.
2551 2555
2552 2556 ``stripes``
2553 2557 How many lines a "zebra stripe" should span in multi-line output.
2554 2558 Set to 0 to disable. (default: 1)
2555 2559
2556 2560 ``style``
2557 2561 Which template map style to use. The available options are the names of
2558 2562 subdirectories in the HTML templates path. (default: ``paper``)
2559 2563 Example: ``monoblue``.
2560 2564
2561 2565 ``templates``
2562 2566 Where to find the HTML templates. The default path to the HTML templates
2563 2567 can be obtained from ``hg debuginstall``.
2564 2568
2565 2569 ``websub``
2566 2570 ----------
2567 2571
2568 2572 Web substitution filter definition. You can use this section to
2569 2573 define a set of regular expression substitution patterns which
2570 2574 let you automatically modify the hgweb server output.
2571 2575
2572 2576 The default hgweb templates only apply these substitution patterns
2573 2577 on the revision description fields. You can apply them anywhere
2574 2578 you want when you create your own templates by adding calls to the
2575 2579 "websub" filter (usually after calling the "escape" filter).
2576 2580
2577 2581 This can be used, for example, to convert issue references to links
2578 2582 to your issue tracker, or to convert "markdown-like" syntax into
2579 2583 HTML (see the examples below).
2580 2584
2581 2585 Each entry in this section names a substitution filter.
2582 2586 The value of each entry defines the substitution expression itself.
2583 2587 The websub expressions follow the old interhg extension syntax,
2584 2588 which in turn imitates the Unix sed replacement syntax::
2585 2589
2586 2590 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2587 2591
2588 2592 You can use any separator other than "/". The final "i" is optional
2589 2593 and indicates that the search must be case insensitive.
2590 2594
2591 2595 Examples::
2592 2596
2593 2597 [websub]
2594 2598 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2595 2599 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2596 2600 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2597 2601
2598 2602 ``worker``
2599 2603 ----------
2600 2604
2601 2605 Parallel master/worker configuration. We currently perform working
2602 2606 directory updates in parallel on Unix-like systems, which greatly
2603 2607 helps performance.
2604 2608
2605 2609 ``enabled``
2606 2610 Whether to enable workers code to be used.
2607 2611 (default: true)
2608 2612
2609 2613 ``numcpus``
2610 2614 Number of CPUs to use for parallel operations. A zero or
2611 2615 negative value is treated as ``use the default``.
2612 2616 (default: 4 or the number of CPUs on the system, whichever is larger)
2613 2617
2614 2618 ``backgroundclose``
2615 2619 Whether to enable closing file handles on background threads during certain
2616 2620 operations. Some platforms aren't very efficient at closing file
2617 2621 handles that have been written or appended to. By performing file closing
2618 2622 on background threads, file write rate can increase substantially.
2619 2623 (default: true on Windows, false elsewhere)
2620 2624
2621 2625 ``backgroundcloseminfilecount``
2622 2626 Minimum number of files required to trigger background file closing.
2623 2627 Operations not writing this many files won't start background close
2624 2628 threads.
2625 2629 (default: 2048)
2626 2630
2627 2631 ``backgroundclosemaxqueue``
2628 2632 The maximum number of opened file handles waiting to be closed in the
2629 2633 background. This option only has an effect if ``backgroundclose`` is
2630 2634 enabled.
2631 2635 (default: 384)
2632 2636
2633 2637 ``backgroundclosethreadcount``
2634 2638 Number of threads to process background file closes. Only relevant if
2635 2639 ``backgroundclose`` is enabled.
2636 2640 (default: 4)
@@ -1,185 +1,237 b''
1 1 $ mkdir folder
2 2 $ cd folder
3 3 $ hg init
4 4 $ mkdir x x/l x/m x/n x/l/u x/l/u/a
5 5 $ touch a b x/aa.o x/bb.o
6 6 $ hg status
7 7 ? a
8 8 ? b
9 9 ? x/aa.o
10 10 ? x/bb.o
11 11
12 12 $ hg status --terse u
13 13 ? a
14 14 ? b
15 15 ? x/
16 16 $ hg status --terse maudric
17 17 ? a
18 18 ? b
19 19 ? x/
20 20 $ hg status --terse madric
21 21 ? a
22 22 ? b
23 23 ? x/aa.o
24 24 ? x/bb.o
25 25 $ hg status --terse f
26 26 abort: 'f' not recognized
27 27 [255]
28 28
29 29 Add a .hgignore so that we can also have ignored files
30 30
31 31 $ echo ".*\.o" > .hgignore
32 32 $ hg status
33 33 ? .hgignore
34 34 ? a
35 35 ? b
36 36 $ hg status -i
37 37 I x/aa.o
38 38 I x/bb.o
39 39
40 40 Tersing ignored files
41 41 $ hg status -t i --ignored
42 42 I x/
43 43
44 44 Adding more files
45 45 $ mkdir y
46 46 $ touch x/aa x/bb y/l y/m y/l.o y/m.o
47 47 $ touch x/l/aa x/m/aa x/n/aa x/l/u/bb x/l/u/a/bb
48 48
49 49 $ hg status
50 50 ? .hgignore
51 51 ? a
52 52 ? b
53 53 ? x/aa
54 54 ? x/bb
55 55 ? x/l/aa
56 56 ? x/l/u/a/bb
57 57 ? x/l/u/bb
58 58 ? x/m/aa
59 59 ? x/n/aa
60 60 ? y/l
61 61 ? y/m
62 62
63 63 $ hg status --terse u
64 64 ? .hgignore
65 65 ? a
66 66 ? b
67 67 ? x/
68 68 ? y/
69 69
70 70 $ hg add x/aa x/bb .hgignore
71 71 $ hg status --terse au
72 72 A .hgignore
73 73 A x/aa
74 74 A x/bb
75 75 ? a
76 76 ? b
77 77 ? x/l/
78 78 ? x/m/
79 79 ? x/n/
80 80 ? y/
81 81
82 82 Including ignored files
83 83
84 84 $ hg status --terse aui
85 85 A .hgignore
86 86 A x/aa
87 87 A x/bb
88 88 ? a
89 89 ? b
90 90 ? x/l/
91 91 ? x/m/
92 92 ? x/n/
93 93 ? y/l
94 94 ? y/m
95 95 $ hg status --terse au -i
96 96 I x/aa.o
97 97 I x/bb.o
98 98 I y/l.o
99 99 I y/m.o
100 100
101 101 Committing some of the files
102 102
103 103 $ hg commit x/aa x/bb .hgignore -m "First commit"
104 104 $ hg status
105 105 ? a
106 106 ? b
107 107 ? x/l/aa
108 108 ? x/l/u/a/bb
109 109 ? x/l/u/bb
110 110 ? x/m/aa
111 111 ? x/n/aa
112 112 ? y/l
113 113 ? y/m
114 114 $ hg status --terse mardu
115 115 ? a
116 116 ? b
117 117 ? x/l/
118 118 ? x/m/
119 119 ? x/n/
120 120 ? y/
121 121
122 122 Modifying already committed files
123 123
124 124 $ echo "Hello" >> x/aa
125 125 $ echo "World" >> x/bb
126 126 $ hg status --terse maurdc
127 127 M x/aa
128 128 M x/bb
129 129 ? a
130 130 ? b
131 131 ? x/l/
132 132 ? x/m/
133 133 ? x/n/
134 134 ? y/
135 135
136 136 Respecting other flags
137 137
138 138 $ hg status --terse marduic --all
139 139 M x/aa
140 140 M x/bb
141 141 ? a
142 142 ? b
143 143 ? x/l/
144 144 ? x/m/
145 145 ? x/n/
146 146 ? y/l
147 147 ? y/m
148 148 I x/aa.o
149 149 I x/bb.o
150 150 I y/l.o
151 151 I y/m.o
152 152 C .hgignore
153 153 $ hg status --terse marduic -a
154 154 $ hg status --terse marduic -c
155 155 C .hgignore
156 156 $ hg status --terse marduic -m
157 157 M x/aa
158 158 M x/bb
159 159
160 160 Passing 'i' in terse value will consider the ignored files while tersing
161 161
162 162 $ hg status --terse marduic -u
163 163 ? a
164 164 ? b
165 165 ? x/l/
166 166 ? x/m/
167 167 ? x/n/
168 168 ? y/l
169 169 ? y/m
170 170
171 171 Omitting 'i' in terse value does not consider ignored files while tersing
172 172
173 173 $ hg status --terse marduc -u
174 174 ? a
175 175 ? b
176 176 ? x/l/
177 177 ? x/m/
178 178 ? x/n/
179 179 ? y/
180 180
181 181 Trying with --rev
182 182
183 183 $ hg status --terse marduic --rev 0 --rev 1
184 184 abort: cannot use --terse with --rev
185 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