##// END OF EJS Templates
merge: add commands.merge.require-rev to require an argument to hg merge...
Kyle Lippincott -
r44325:8caec25f default
parent child Browse files
Show More
@@ -1,7838 +1,7845 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 wdirhex,
23 23 wdirrev,
24 24 )
25 25 from .pycompat import open
26 26 from . import (
27 27 archival,
28 28 bookmarks,
29 29 bundle2,
30 30 changegroup,
31 31 cmdutil,
32 32 copies,
33 33 debugcommands as debugcommandsmod,
34 34 destutil,
35 35 dirstateguard,
36 36 discovery,
37 37 encoding,
38 38 error,
39 39 exchange,
40 40 extensions,
41 41 filemerge,
42 42 formatter,
43 43 graphmod,
44 44 hbisect,
45 45 help,
46 46 hg,
47 47 logcmdutil,
48 48 merge as mergemod,
49 49 narrowspec,
50 50 obsolete,
51 51 obsutil,
52 52 patch,
53 53 phases,
54 54 pycompat,
55 55 rcutil,
56 56 registrar,
57 57 revsetlang,
58 58 rewriteutil,
59 59 scmutil,
60 60 server,
61 61 shelve as shelvemod,
62 62 state as statemod,
63 63 streamclone,
64 64 tags as tagsmod,
65 65 ui as uimod,
66 66 util,
67 67 verify as verifymod,
68 68 wireprotoserver,
69 69 )
70 70 from .utils import (
71 71 dateutil,
72 72 stringutil,
73 73 )
74 74
75 75 table = {}
76 76 table.update(debugcommandsmod.command._table)
77 77
78 78 command = registrar.command(table)
79 79 INTENT_READONLY = registrar.INTENT_READONLY
80 80
81 81 # common command options
82 82
83 83 globalopts = [
84 84 (
85 85 b'R',
86 86 b'repository',
87 87 b'',
88 88 _(b'repository root directory or name of overlay bundle file'),
89 89 _(b'REPO'),
90 90 ),
91 91 (b'', b'cwd', b'', _(b'change working directory'), _(b'DIR')),
92 92 (
93 93 b'y',
94 94 b'noninteractive',
95 95 None,
96 96 _(
97 97 b'do not prompt, automatically pick the first choice for all prompts'
98 98 ),
99 99 ),
100 100 (b'q', b'quiet', None, _(b'suppress output')),
101 101 (b'v', b'verbose', None, _(b'enable additional output')),
102 102 (
103 103 b'',
104 104 b'color',
105 105 b'',
106 106 # i18n: 'always', 'auto', 'never', and 'debug' are keywords
107 107 # and should not be translated
108 108 _(b"when to colorize (boolean, always, auto, never, or debug)"),
109 109 _(b'TYPE'),
110 110 ),
111 111 (
112 112 b'',
113 113 b'config',
114 114 [],
115 115 _(b'set/override config option (use \'section.name=value\')'),
116 116 _(b'CONFIG'),
117 117 ),
118 118 (b'', b'debug', None, _(b'enable debugging output')),
119 119 (b'', b'debugger', None, _(b'start debugger')),
120 120 (
121 121 b'',
122 122 b'encoding',
123 123 encoding.encoding,
124 124 _(b'set the charset encoding'),
125 125 _(b'ENCODE'),
126 126 ),
127 127 (
128 128 b'',
129 129 b'encodingmode',
130 130 encoding.encodingmode,
131 131 _(b'set the charset encoding mode'),
132 132 _(b'MODE'),
133 133 ),
134 134 (b'', b'traceback', None, _(b'always print a traceback on exception')),
135 135 (b'', b'time', None, _(b'time how long the command takes')),
136 136 (b'', b'profile', None, _(b'print command execution profile')),
137 137 (b'', b'version', None, _(b'output version information and exit')),
138 138 (b'h', b'help', None, _(b'display help and exit')),
139 139 (b'', b'hidden', False, _(b'consider hidden changesets')),
140 140 (
141 141 b'',
142 142 b'pager',
143 143 b'auto',
144 144 _(b"when to paginate (boolean, always, auto, or never)"),
145 145 _(b'TYPE'),
146 146 ),
147 147 ]
148 148
149 149 dryrunopts = cmdutil.dryrunopts
150 150 remoteopts = cmdutil.remoteopts
151 151 walkopts = cmdutil.walkopts
152 152 commitopts = cmdutil.commitopts
153 153 commitopts2 = cmdutil.commitopts2
154 154 commitopts3 = cmdutil.commitopts3
155 155 formatteropts = cmdutil.formatteropts
156 156 templateopts = cmdutil.templateopts
157 157 logopts = cmdutil.logopts
158 158 diffopts = cmdutil.diffopts
159 159 diffwsopts = cmdutil.diffwsopts
160 160 diffopts2 = cmdutil.diffopts2
161 161 mergetoolopts = cmdutil.mergetoolopts
162 162 similarityopts = cmdutil.similarityopts
163 163 subrepoopts = cmdutil.subrepoopts
164 164 debugrevlogopts = cmdutil.debugrevlogopts
165 165
166 166 # Commands start here, listed alphabetically
167 167
168 168
169 169 @command(
170 170 b'abort',
171 171 dryrunopts,
172 172 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
173 173 helpbasic=True,
174 174 )
175 175 def abort(ui, repo, **opts):
176 176 """abort an unfinished operation (EXPERIMENTAL)
177 177
178 178 Aborts a multistep operation like graft, histedit, rebase, merge,
179 179 and unshelve if they are in an unfinished state.
180 180
181 181 use --dry-run/-n to dry run the command.
182 182 """
183 183 dryrun = opts.get('dry_run')
184 184 abortstate = cmdutil.getunfinishedstate(repo)
185 185 if not abortstate:
186 186 raise error.Abort(_(b'no operation in progress'))
187 187 if not abortstate.abortfunc:
188 188 raise error.Abort(
189 189 (
190 190 _(b"%s in progress but does not support 'hg abort'")
191 191 % (abortstate._opname)
192 192 ),
193 193 hint=abortstate.hint(),
194 194 )
195 195 if dryrun:
196 196 ui.status(
197 197 _(b'%s in progress, will be aborted\n') % (abortstate._opname)
198 198 )
199 199 return
200 200 return abortstate.abortfunc(ui, repo)
201 201
202 202
203 203 @command(
204 204 b'add',
205 205 walkopts + subrepoopts + dryrunopts,
206 206 _(b'[OPTION]... [FILE]...'),
207 207 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
208 208 helpbasic=True,
209 209 inferrepo=True,
210 210 )
211 211 def add(ui, repo, *pats, **opts):
212 212 """add the specified files on the next commit
213 213
214 214 Schedule files to be version controlled and added to the
215 215 repository.
216 216
217 217 The files will be added to the repository at the next commit. To
218 218 undo an add before that, see :hg:`forget`.
219 219
220 220 If no names are given, add all files to the repository (except
221 221 files matching ``.hgignore``).
222 222
223 223 .. container:: verbose
224 224
225 225 Examples:
226 226
227 227 - New (unknown) files are added
228 228 automatically by :hg:`add`::
229 229
230 230 $ ls
231 231 foo.c
232 232 $ hg status
233 233 ? foo.c
234 234 $ hg add
235 235 adding foo.c
236 236 $ hg status
237 237 A foo.c
238 238
239 239 - Specific files to be added can be specified::
240 240
241 241 $ ls
242 242 bar.c foo.c
243 243 $ hg status
244 244 ? bar.c
245 245 ? foo.c
246 246 $ hg add bar.c
247 247 $ hg status
248 248 A bar.c
249 249 ? foo.c
250 250
251 251 Returns 0 if all files are successfully added.
252 252 """
253 253
254 254 m = scmutil.match(repo[None], pats, pycompat.byteskwargs(opts))
255 255 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
256 256 rejected = cmdutil.add(ui, repo, m, b"", uipathfn, False, **opts)
257 257 return rejected and 1 or 0
258 258
259 259
260 260 @command(
261 261 b'addremove',
262 262 similarityopts + subrepoopts + walkopts + dryrunopts,
263 263 _(b'[OPTION]... [FILE]...'),
264 264 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
265 265 inferrepo=True,
266 266 )
267 267 def addremove(ui, repo, *pats, **opts):
268 268 """add all new files, delete all missing files
269 269
270 270 Add all new files and remove all missing files from the
271 271 repository.
272 272
273 273 Unless names are given, new files are ignored if they match any of
274 274 the patterns in ``.hgignore``. As with add, these changes take
275 275 effect at the next commit.
276 276
277 277 Use the -s/--similarity option to detect renamed files. This
278 278 option takes a percentage between 0 (disabled) and 100 (files must
279 279 be identical) as its parameter. With a parameter greater than 0,
280 280 this compares every removed file with every added file and records
281 281 those similar enough as renames. Detecting renamed files this way
282 282 can be expensive. After using this option, :hg:`status -C` can be
283 283 used to check which files were identified as moved or renamed. If
284 284 not specified, -s/--similarity defaults to 100 and only renames of
285 285 identical files are detected.
286 286
287 287 .. container:: verbose
288 288
289 289 Examples:
290 290
291 291 - A number of files (bar.c and foo.c) are new,
292 292 while foobar.c has been removed (without using :hg:`remove`)
293 293 from the repository::
294 294
295 295 $ ls
296 296 bar.c foo.c
297 297 $ hg status
298 298 ! foobar.c
299 299 ? bar.c
300 300 ? foo.c
301 301 $ hg addremove
302 302 adding bar.c
303 303 adding foo.c
304 304 removing foobar.c
305 305 $ hg status
306 306 A bar.c
307 307 A foo.c
308 308 R foobar.c
309 309
310 310 - A file foobar.c was moved to foo.c without using :hg:`rename`.
311 311 Afterwards, it was edited slightly::
312 312
313 313 $ ls
314 314 foo.c
315 315 $ hg status
316 316 ! foobar.c
317 317 ? foo.c
318 318 $ hg addremove --similarity 90
319 319 removing foobar.c
320 320 adding foo.c
321 321 recording removal of foobar.c as rename to foo.c (94% similar)
322 322 $ hg status -C
323 323 A foo.c
324 324 foobar.c
325 325 R foobar.c
326 326
327 327 Returns 0 if all files are successfully added.
328 328 """
329 329 opts = pycompat.byteskwargs(opts)
330 330 if not opts.get(b'similarity'):
331 331 opts[b'similarity'] = b'100'
332 332 matcher = scmutil.match(repo[None], pats, opts)
333 333 relative = scmutil.anypats(pats, opts)
334 334 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=relative)
335 335 return scmutil.addremove(repo, matcher, b"", uipathfn, opts)
336 336
337 337
338 338 @command(
339 339 b'annotate|blame',
340 340 [
341 341 (b'r', b'rev', b'', _(b'annotate the specified revision'), _(b'REV')),
342 342 (
343 343 b'',
344 344 b'follow',
345 345 None,
346 346 _(b'follow copies/renames and list the filename (DEPRECATED)'),
347 347 ),
348 348 (b'', b'no-follow', None, _(b"don't follow copies and renames")),
349 349 (b'a', b'text', None, _(b'treat all files as text')),
350 350 (b'u', b'user', None, _(b'list the author (long with -v)')),
351 351 (b'f', b'file', None, _(b'list the filename')),
352 352 (b'd', b'date', None, _(b'list the date (short with -q)')),
353 353 (b'n', b'number', None, _(b'list the revision number (default)')),
354 354 (b'c', b'changeset', None, _(b'list the changeset')),
355 355 (
356 356 b'l',
357 357 b'line-number',
358 358 None,
359 359 _(b'show line number at the first appearance'),
360 360 ),
361 361 (
362 362 b'',
363 363 b'skip',
364 364 [],
365 365 _(b'revset to not display (EXPERIMENTAL)'),
366 366 _(b'REV'),
367 367 ),
368 368 ]
369 369 + diffwsopts
370 370 + walkopts
371 371 + formatteropts,
372 372 _(b'[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
373 373 helpcategory=command.CATEGORY_FILE_CONTENTS,
374 374 helpbasic=True,
375 375 inferrepo=True,
376 376 )
377 377 def annotate(ui, repo, *pats, **opts):
378 378 """show changeset information by line for each file
379 379
380 380 List changes in files, showing the revision id responsible for
381 381 each line.
382 382
383 383 This command is useful for discovering when a change was made and
384 384 by whom.
385 385
386 386 If you include --file, --user, or --date, the revision number is
387 387 suppressed unless you also include --number.
388 388
389 389 Without the -a/--text option, annotate will avoid processing files
390 390 it detects as binary. With -a, annotate will annotate the file
391 391 anyway, although the results will probably be neither useful
392 392 nor desirable.
393 393
394 394 .. container:: verbose
395 395
396 396 Template:
397 397
398 398 The following keywords are supported in addition to the common template
399 399 keywords and functions. See also :hg:`help templates`.
400 400
401 401 :lines: List of lines with annotation data.
402 402 :path: String. Repository-absolute path of the specified file.
403 403
404 404 And each entry of ``{lines}`` provides the following sub-keywords in
405 405 addition to ``{date}``, ``{node}``, ``{rev}``, ``{user}``, etc.
406 406
407 407 :line: String. Line content.
408 408 :lineno: Integer. Line number at that revision.
409 409 :path: String. Repository-absolute path of the file at that revision.
410 410
411 411 See :hg:`help templates.operators` for the list expansion syntax.
412 412
413 413 Returns 0 on success.
414 414 """
415 415 opts = pycompat.byteskwargs(opts)
416 416 if not pats:
417 417 raise error.Abort(_(b'at least one filename or pattern is required'))
418 418
419 419 if opts.get(b'follow'):
420 420 # --follow is deprecated and now just an alias for -f/--file
421 421 # to mimic the behavior of Mercurial before version 1.5
422 422 opts[b'file'] = True
423 423
424 424 if (
425 425 not opts.get(b'user')
426 426 and not opts.get(b'changeset')
427 427 and not opts.get(b'date')
428 428 and not opts.get(b'file')
429 429 ):
430 430 opts[b'number'] = True
431 431
432 432 linenumber = opts.get(b'line_number') is not None
433 433 if (
434 434 linenumber
435 435 and (not opts.get(b'changeset'))
436 436 and (not opts.get(b'number'))
437 437 ):
438 438 raise error.Abort(_(b'at least one of -n/-c is required for -l'))
439 439
440 440 rev = opts.get(b'rev')
441 441 if rev:
442 442 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
443 443 ctx = scmutil.revsingle(repo, rev)
444 444
445 445 ui.pager(b'annotate')
446 446 rootfm = ui.formatter(b'annotate', opts)
447 447 if ui.debugflag:
448 448 shorthex = pycompat.identity
449 449 else:
450 450
451 451 def shorthex(h):
452 452 return h[:12]
453 453
454 454 if ui.quiet:
455 455 datefunc = dateutil.shortdate
456 456 else:
457 457 datefunc = dateutil.datestr
458 458 if ctx.rev() is None:
459 459 if opts.get(b'changeset'):
460 460 # omit "+" suffix which is appended to node hex
461 461 def formatrev(rev):
462 462 if rev == wdirrev:
463 463 return b'%d' % ctx.p1().rev()
464 464 else:
465 465 return b'%d' % rev
466 466
467 467 else:
468 468
469 469 def formatrev(rev):
470 470 if rev == wdirrev:
471 471 return b'%d+' % ctx.p1().rev()
472 472 else:
473 473 return b'%d ' % rev
474 474
475 475 def formathex(h):
476 476 if h == wdirhex:
477 477 return b'%s+' % shorthex(hex(ctx.p1().node()))
478 478 else:
479 479 return b'%s ' % shorthex(h)
480 480
481 481 else:
482 482 formatrev = b'%d'.__mod__
483 483 formathex = shorthex
484 484
485 485 opmap = [
486 486 (b'user', b' ', lambda x: x.fctx.user(), ui.shortuser),
487 487 (b'rev', b' ', lambda x: scmutil.intrev(x.fctx), formatrev),
488 488 (b'node', b' ', lambda x: hex(scmutil.binnode(x.fctx)), formathex),
489 489 (b'date', b' ', lambda x: x.fctx.date(), util.cachefunc(datefunc)),
490 490 (b'path', b' ', lambda x: x.fctx.path(), pycompat.bytestr),
491 491 (b'lineno', b':', lambda x: x.lineno, pycompat.bytestr),
492 492 ]
493 493 opnamemap = {
494 494 b'rev': b'number',
495 495 b'node': b'changeset',
496 496 b'path': b'file',
497 497 b'lineno': b'line_number',
498 498 }
499 499
500 500 if rootfm.isplain():
501 501
502 502 def makefunc(get, fmt):
503 503 return lambda x: fmt(get(x))
504 504
505 505 else:
506 506
507 507 def makefunc(get, fmt):
508 508 return get
509 509
510 510 datahint = rootfm.datahint()
511 511 funcmap = [
512 512 (makefunc(get, fmt), sep)
513 513 for fn, sep, get, fmt in opmap
514 514 if opts.get(opnamemap.get(fn, fn)) or fn in datahint
515 515 ]
516 516 funcmap[0] = (funcmap[0][0], b'') # no separator in front of first column
517 517 fields = b' '.join(
518 518 fn
519 519 for fn, sep, get, fmt in opmap
520 520 if opts.get(opnamemap.get(fn, fn)) or fn in datahint
521 521 )
522 522
523 523 def bad(x, y):
524 524 raise error.Abort(b"%s: %s" % (x, y))
525 525
526 526 m = scmutil.match(ctx, pats, opts, badfn=bad)
527 527
528 528 follow = not opts.get(b'no_follow')
529 529 diffopts = patch.difffeatureopts(
530 530 ui, opts, section=b'annotate', whitespace=True
531 531 )
532 532 skiprevs = opts.get(b'skip')
533 533 if skiprevs:
534 534 skiprevs = scmutil.revrange(repo, skiprevs)
535 535
536 536 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
537 537 for abs in ctx.walk(m):
538 538 fctx = ctx[abs]
539 539 rootfm.startitem()
540 540 rootfm.data(path=abs)
541 541 if not opts.get(b'text') and fctx.isbinary():
542 542 rootfm.plain(_(b"%s: binary file\n") % uipathfn(abs))
543 543 continue
544 544
545 545 fm = rootfm.nested(b'lines', tmpl=b'{rev}: {line}')
546 546 lines = fctx.annotate(
547 547 follow=follow, skiprevs=skiprevs, diffopts=diffopts
548 548 )
549 549 if not lines:
550 550 fm.end()
551 551 continue
552 552 formats = []
553 553 pieces = []
554 554
555 555 for f, sep in funcmap:
556 556 l = [f(n) for n in lines]
557 557 if fm.isplain():
558 558 sizes = [encoding.colwidth(x) for x in l]
559 559 ml = max(sizes)
560 560 formats.append([sep + b' ' * (ml - w) + b'%s' for w in sizes])
561 561 else:
562 562 formats.append([b'%s' for x in l])
563 563 pieces.append(l)
564 564
565 565 for f, p, n in zip(zip(*formats), zip(*pieces), lines):
566 566 fm.startitem()
567 567 fm.context(fctx=n.fctx)
568 568 fm.write(fields, b"".join(f), *p)
569 569 if n.skip:
570 570 fmt = b"* %s"
571 571 else:
572 572 fmt = b": %s"
573 573 fm.write(b'line', fmt, n.text)
574 574
575 575 if not lines[-1].text.endswith(b'\n'):
576 576 fm.plain(b'\n')
577 577 fm.end()
578 578
579 579 rootfm.end()
580 580
581 581
582 582 @command(
583 583 b'archive',
584 584 [
585 585 (b'', b'no-decode', None, _(b'do not pass files through decoders')),
586 586 (
587 587 b'p',
588 588 b'prefix',
589 589 b'',
590 590 _(b'directory prefix for files in archive'),
591 591 _(b'PREFIX'),
592 592 ),
593 593 (b'r', b'rev', b'', _(b'revision to distribute'), _(b'REV')),
594 594 (b't', b'type', b'', _(b'type of distribution to create'), _(b'TYPE')),
595 595 ]
596 596 + subrepoopts
597 597 + walkopts,
598 598 _(b'[OPTION]... DEST'),
599 599 helpcategory=command.CATEGORY_IMPORT_EXPORT,
600 600 )
601 601 def archive(ui, repo, dest, **opts):
602 602 '''create an unversioned archive of a repository revision
603 603
604 604 By default, the revision used is the parent of the working
605 605 directory; use -r/--rev to specify a different revision.
606 606
607 607 The archive type is automatically detected based on file
608 608 extension (to override, use -t/--type).
609 609
610 610 .. container:: verbose
611 611
612 612 Examples:
613 613
614 614 - create a zip file containing the 1.0 release::
615 615
616 616 hg archive -r 1.0 project-1.0.zip
617 617
618 618 - create a tarball excluding .hg files::
619 619
620 620 hg archive project.tar.gz -X ".hg*"
621 621
622 622 Valid types are:
623 623
624 624 :``files``: a directory full of files (default)
625 625 :``tar``: tar archive, uncompressed
626 626 :``tbz2``: tar archive, compressed using bzip2
627 627 :``tgz``: tar archive, compressed using gzip
628 628 :``txz``: tar archive, compressed using lzma (only in Python 3)
629 629 :``uzip``: zip archive, uncompressed
630 630 :``zip``: zip archive, compressed using deflate
631 631
632 632 The exact name of the destination archive or directory is given
633 633 using a format string; see :hg:`help export` for details.
634 634
635 635 Each member added to an archive file has a directory prefix
636 636 prepended. Use -p/--prefix to specify a format string for the
637 637 prefix. The default is the basename of the archive, with suffixes
638 638 removed.
639 639
640 640 Returns 0 on success.
641 641 '''
642 642
643 643 opts = pycompat.byteskwargs(opts)
644 644 rev = opts.get(b'rev')
645 645 if rev:
646 646 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
647 647 ctx = scmutil.revsingle(repo, rev)
648 648 if not ctx:
649 649 raise error.Abort(_(b'no working directory: please specify a revision'))
650 650 node = ctx.node()
651 651 dest = cmdutil.makefilename(ctx, dest)
652 652 if os.path.realpath(dest) == repo.root:
653 653 raise error.Abort(_(b'repository root cannot be destination'))
654 654
655 655 kind = opts.get(b'type') or archival.guesskind(dest) or b'files'
656 656 prefix = opts.get(b'prefix')
657 657
658 658 if dest == b'-':
659 659 if kind == b'files':
660 660 raise error.Abort(_(b'cannot archive plain files to stdout'))
661 661 dest = cmdutil.makefileobj(ctx, dest)
662 662 if not prefix:
663 663 prefix = os.path.basename(repo.root) + b'-%h'
664 664
665 665 prefix = cmdutil.makefilename(ctx, prefix)
666 666 match = scmutil.match(ctx, [], opts)
667 667 archival.archive(
668 668 repo,
669 669 dest,
670 670 node,
671 671 kind,
672 672 not opts.get(b'no_decode'),
673 673 match,
674 674 prefix,
675 675 subrepos=opts.get(b'subrepos'),
676 676 )
677 677
678 678
679 679 @command(
680 680 b'backout',
681 681 [
682 682 (
683 683 b'',
684 684 b'merge',
685 685 None,
686 686 _(b'merge with old dirstate parent after backout'),
687 687 ),
688 688 (
689 689 b'',
690 690 b'commit',
691 691 None,
692 692 _(b'commit if no conflicts were encountered (DEPRECATED)'),
693 693 ),
694 694 (b'', b'no-commit', None, _(b'do not commit')),
695 695 (
696 696 b'',
697 697 b'parent',
698 698 b'',
699 699 _(b'parent to choose when backing out merge (DEPRECATED)'),
700 700 _(b'REV'),
701 701 ),
702 702 (b'r', b'rev', b'', _(b'revision to backout'), _(b'REV')),
703 703 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
704 704 ]
705 705 + mergetoolopts
706 706 + walkopts
707 707 + commitopts
708 708 + commitopts2,
709 709 _(b'[OPTION]... [-r] REV'),
710 710 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
711 711 )
712 712 def backout(ui, repo, node=None, rev=None, **opts):
713 713 '''reverse effect of earlier changeset
714 714
715 715 Prepare a new changeset with the effect of REV undone in the
716 716 current working directory. If no conflicts were encountered,
717 717 it will be committed immediately.
718 718
719 719 If REV is the parent of the working directory, then this new changeset
720 720 is committed automatically (unless --no-commit is specified).
721 721
722 722 .. note::
723 723
724 724 :hg:`backout` cannot be used to fix either an unwanted or
725 725 incorrect merge.
726 726
727 727 .. container:: verbose
728 728
729 729 Examples:
730 730
731 731 - Reverse the effect of the parent of the working directory.
732 732 This backout will be committed immediately::
733 733
734 734 hg backout -r .
735 735
736 736 - Reverse the effect of previous bad revision 23::
737 737
738 738 hg backout -r 23
739 739
740 740 - Reverse the effect of previous bad revision 23 and
741 741 leave changes uncommitted::
742 742
743 743 hg backout -r 23 --no-commit
744 744 hg commit -m "Backout revision 23"
745 745
746 746 By default, the pending changeset will have one parent,
747 747 maintaining a linear history. With --merge, the pending
748 748 changeset will instead have two parents: the old parent of the
749 749 working directory and a new child of REV that simply undoes REV.
750 750
751 751 Before version 1.7, the behavior without --merge was equivalent
752 752 to specifying --merge followed by :hg:`update --clean .` to
753 753 cancel the merge and leave the child of REV as a head to be
754 754 merged separately.
755 755
756 756 See :hg:`help dates` for a list of formats valid for -d/--date.
757 757
758 758 See :hg:`help revert` for a way to restore files to the state
759 759 of another revision.
760 760
761 761 Returns 0 on success, 1 if nothing to backout or there are unresolved
762 762 files.
763 763 '''
764 764 with repo.wlock(), repo.lock():
765 765 return _dobackout(ui, repo, node, rev, **opts)
766 766
767 767
768 768 def _dobackout(ui, repo, node=None, rev=None, **opts):
769 769 opts = pycompat.byteskwargs(opts)
770 770 if opts.get(b'commit') and opts.get(b'no_commit'):
771 771 raise error.Abort(_(b"cannot use --commit with --no-commit"))
772 772 if opts.get(b'merge') and opts.get(b'no_commit'):
773 773 raise error.Abort(_(b"cannot use --merge with --no-commit"))
774 774
775 775 if rev and node:
776 776 raise error.Abort(_(b"please specify just one revision"))
777 777
778 778 if not rev:
779 779 rev = node
780 780
781 781 if not rev:
782 782 raise error.Abort(_(b"please specify a revision to backout"))
783 783
784 784 date = opts.get(b'date')
785 785 if date:
786 786 opts[b'date'] = dateutil.parsedate(date)
787 787
788 788 cmdutil.checkunfinished(repo)
789 789 cmdutil.bailifchanged(repo)
790 790 node = scmutil.revsingle(repo, rev).node()
791 791
792 792 op1, op2 = repo.dirstate.parents()
793 793 if not repo.changelog.isancestor(node, op1):
794 794 raise error.Abort(_(b'cannot backout change that is not an ancestor'))
795 795
796 796 p1, p2 = repo.changelog.parents(node)
797 797 if p1 == nullid:
798 798 raise error.Abort(_(b'cannot backout a change with no parents'))
799 799 if p2 != nullid:
800 800 if not opts.get(b'parent'):
801 801 raise error.Abort(_(b'cannot backout a merge changeset'))
802 802 p = repo.lookup(opts[b'parent'])
803 803 if p not in (p1, p2):
804 804 raise error.Abort(
805 805 _(b'%s is not a parent of %s') % (short(p), short(node))
806 806 )
807 807 parent = p
808 808 else:
809 809 if opts.get(b'parent'):
810 810 raise error.Abort(_(b'cannot use --parent on non-merge changeset'))
811 811 parent = p1
812 812
813 813 # the backout should appear on the same branch
814 814 branch = repo.dirstate.branch()
815 815 bheads = repo.branchheads(branch)
816 816 rctx = scmutil.revsingle(repo, hex(parent))
817 817 if not opts.get(b'merge') and op1 != node:
818 818 with dirstateguard.dirstateguard(repo, b'backout'):
819 819 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
820 820 with ui.configoverride(overrides, b'backout'):
821 821 stats = mergemod.update(
822 822 repo,
823 823 parent,
824 824 branchmerge=True,
825 825 force=True,
826 826 ancestor=node,
827 827 mergeancestor=False,
828 828 )
829 829 repo.setparents(op1, op2)
830 830 hg._showstats(repo, stats)
831 831 if stats.unresolvedcount:
832 832 repo.ui.status(
833 833 _(b"use 'hg resolve' to retry unresolved file merges\n")
834 834 )
835 835 return 1
836 836 else:
837 837 hg.clean(repo, node, show_stats=False)
838 838 repo.dirstate.setbranch(branch)
839 839 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
840 840
841 841 if opts.get(b'no_commit'):
842 842 msg = _(b"changeset %s backed out, don't forget to commit.\n")
843 843 ui.status(msg % short(node))
844 844 return 0
845 845
846 846 def commitfunc(ui, repo, message, match, opts):
847 847 editform = b'backout'
848 848 e = cmdutil.getcommiteditor(
849 849 editform=editform, **pycompat.strkwargs(opts)
850 850 )
851 851 if not message:
852 852 # we don't translate commit messages
853 853 message = b"Backed out changeset %s" % short(node)
854 854 e = cmdutil.getcommiteditor(edit=True, editform=editform)
855 855 return repo.commit(
856 856 message, opts.get(b'user'), opts.get(b'date'), match, editor=e
857 857 )
858 858
859 859 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
860 860 if not newnode:
861 861 ui.status(_(b"nothing changed\n"))
862 862 return 1
863 863 cmdutil.commitstatus(repo, newnode, branch, bheads)
864 864
865 865 def nice(node):
866 866 return b'%d:%s' % (repo.changelog.rev(node), short(node))
867 867
868 868 ui.status(
869 869 _(b'changeset %s backs out changeset %s\n')
870 870 % (nice(repo.changelog.tip()), nice(node))
871 871 )
872 872 if opts.get(b'merge') and op1 != node:
873 873 hg.clean(repo, op1, show_stats=False)
874 874 ui.status(
875 875 _(b'merging with changeset %s\n') % nice(repo.changelog.tip())
876 876 )
877 877 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
878 878 with ui.configoverride(overrides, b'backout'):
879 879 return hg.merge(repo, hex(repo.changelog.tip()))
880 880 return 0
881 881
882 882
883 883 @command(
884 884 b'bisect',
885 885 [
886 886 (b'r', b'reset', False, _(b'reset bisect state')),
887 887 (b'g', b'good', False, _(b'mark changeset good')),
888 888 (b'b', b'bad', False, _(b'mark changeset bad')),
889 889 (b's', b'skip', False, _(b'skip testing changeset')),
890 890 (b'e', b'extend', False, _(b'extend the bisect range')),
891 891 (
892 892 b'c',
893 893 b'command',
894 894 b'',
895 895 _(b'use command to check changeset state'),
896 896 _(b'CMD'),
897 897 ),
898 898 (b'U', b'noupdate', False, _(b'do not update to target')),
899 899 ],
900 900 _(b"[-gbsr] [-U] [-c CMD] [REV]"),
901 901 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
902 902 )
903 903 def bisect(
904 904 ui,
905 905 repo,
906 906 rev=None,
907 907 extra=None,
908 908 command=None,
909 909 reset=None,
910 910 good=None,
911 911 bad=None,
912 912 skip=None,
913 913 extend=None,
914 914 noupdate=None,
915 915 ):
916 916 """subdivision search of changesets
917 917
918 918 This command helps to find changesets which introduce problems. To
919 919 use, mark the earliest changeset you know exhibits the problem as
920 920 bad, then mark the latest changeset which is free from the problem
921 921 as good. Bisect will update your working directory to a revision
922 922 for testing (unless the -U/--noupdate option is specified). Once
923 923 you have performed tests, mark the working directory as good or
924 924 bad, and bisect will either update to another candidate changeset
925 925 or announce that it has found the bad revision.
926 926
927 927 As a shortcut, you can also use the revision argument to mark a
928 928 revision as good or bad without checking it out first.
929 929
930 930 If you supply a command, it will be used for automatic bisection.
931 931 The environment variable HG_NODE will contain the ID of the
932 932 changeset being tested. The exit status of the command will be
933 933 used to mark revisions as good or bad: status 0 means good, 125
934 934 means to skip the revision, 127 (command not found) will abort the
935 935 bisection, and any other non-zero exit status means the revision
936 936 is bad.
937 937
938 938 .. container:: verbose
939 939
940 940 Some examples:
941 941
942 942 - start a bisection with known bad revision 34, and good revision 12::
943 943
944 944 hg bisect --bad 34
945 945 hg bisect --good 12
946 946
947 947 - advance the current bisection by marking current revision as good or
948 948 bad::
949 949
950 950 hg bisect --good
951 951 hg bisect --bad
952 952
953 953 - mark the current revision, or a known revision, to be skipped (e.g. if
954 954 that revision is not usable because of another issue)::
955 955
956 956 hg bisect --skip
957 957 hg bisect --skip 23
958 958
959 959 - skip all revisions that do not touch directories ``foo`` or ``bar``::
960 960
961 961 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
962 962
963 963 - forget the current bisection::
964 964
965 965 hg bisect --reset
966 966
967 967 - use 'make && make tests' to automatically find the first broken
968 968 revision::
969 969
970 970 hg bisect --reset
971 971 hg bisect --bad 34
972 972 hg bisect --good 12
973 973 hg bisect --command "make && make tests"
974 974
975 975 - see all changesets whose states are already known in the current
976 976 bisection::
977 977
978 978 hg log -r "bisect(pruned)"
979 979
980 980 - see the changeset currently being bisected (especially useful
981 981 if running with -U/--noupdate)::
982 982
983 983 hg log -r "bisect(current)"
984 984
985 985 - see all changesets that took part in the current bisection::
986 986
987 987 hg log -r "bisect(range)"
988 988
989 989 - you can even get a nice graph::
990 990
991 991 hg log --graph -r "bisect(range)"
992 992
993 993 See :hg:`help revisions.bisect` for more about the `bisect()` predicate.
994 994
995 995 Returns 0 on success.
996 996 """
997 997 # backward compatibility
998 998 if rev in b"good bad reset init".split():
999 999 ui.warn(_(b"(use of 'hg bisect <cmd>' is deprecated)\n"))
1000 1000 cmd, rev, extra = rev, extra, None
1001 1001 if cmd == b"good":
1002 1002 good = True
1003 1003 elif cmd == b"bad":
1004 1004 bad = True
1005 1005 else:
1006 1006 reset = True
1007 1007 elif extra:
1008 1008 raise error.Abort(_(b'incompatible arguments'))
1009 1009
1010 1010 incompatibles = {
1011 1011 b'--bad': bad,
1012 1012 b'--command': bool(command),
1013 1013 b'--extend': extend,
1014 1014 b'--good': good,
1015 1015 b'--reset': reset,
1016 1016 b'--skip': skip,
1017 1017 }
1018 1018
1019 1019 enabled = [x for x in incompatibles if incompatibles[x]]
1020 1020
1021 1021 if len(enabled) > 1:
1022 1022 raise error.Abort(
1023 1023 _(b'%s and %s are incompatible') % tuple(sorted(enabled)[0:2])
1024 1024 )
1025 1025
1026 1026 if reset:
1027 1027 hbisect.resetstate(repo)
1028 1028 return
1029 1029
1030 1030 state = hbisect.load_state(repo)
1031 1031
1032 1032 # update state
1033 1033 if good or bad or skip:
1034 1034 if rev:
1035 1035 nodes = [repo[i].node() for i in scmutil.revrange(repo, [rev])]
1036 1036 else:
1037 1037 nodes = [repo.lookup(b'.')]
1038 1038 if good:
1039 1039 state[b'good'] += nodes
1040 1040 elif bad:
1041 1041 state[b'bad'] += nodes
1042 1042 elif skip:
1043 1043 state[b'skip'] += nodes
1044 1044 hbisect.save_state(repo, state)
1045 1045 if not (state[b'good'] and state[b'bad']):
1046 1046 return
1047 1047
1048 1048 def mayupdate(repo, node, show_stats=True):
1049 1049 """common used update sequence"""
1050 1050 if noupdate:
1051 1051 return
1052 1052 cmdutil.checkunfinished(repo)
1053 1053 cmdutil.bailifchanged(repo)
1054 1054 return hg.clean(repo, node, show_stats=show_stats)
1055 1055
1056 1056 displayer = logcmdutil.changesetdisplayer(ui, repo, {})
1057 1057
1058 1058 if command:
1059 1059 changesets = 1
1060 1060 if noupdate:
1061 1061 try:
1062 1062 node = state[b'current'][0]
1063 1063 except LookupError:
1064 1064 raise error.Abort(
1065 1065 _(
1066 1066 b'current bisect revision is unknown - '
1067 1067 b'start a new bisect to fix'
1068 1068 )
1069 1069 )
1070 1070 else:
1071 1071 node, p2 = repo.dirstate.parents()
1072 1072 if p2 != nullid:
1073 1073 raise error.Abort(_(b'current bisect revision is a merge'))
1074 1074 if rev:
1075 1075 node = repo[scmutil.revsingle(repo, rev, node)].node()
1076 1076 with hbisect.restore_state(repo, state, node):
1077 1077 while changesets:
1078 1078 # update state
1079 1079 state[b'current'] = [node]
1080 1080 hbisect.save_state(repo, state)
1081 1081 status = ui.system(
1082 1082 command,
1083 1083 environ={b'HG_NODE': hex(node)},
1084 1084 blockedtag=b'bisect_check',
1085 1085 )
1086 1086 if status == 125:
1087 1087 transition = b"skip"
1088 1088 elif status == 0:
1089 1089 transition = b"good"
1090 1090 # status < 0 means process was killed
1091 1091 elif status == 127:
1092 1092 raise error.Abort(_(b"failed to execute %s") % command)
1093 1093 elif status < 0:
1094 1094 raise error.Abort(_(b"%s killed") % command)
1095 1095 else:
1096 1096 transition = b"bad"
1097 1097 state[transition].append(node)
1098 1098 ctx = repo[node]
1099 1099 ui.status(
1100 1100 _(b'changeset %d:%s: %s\n') % (ctx.rev(), ctx, transition)
1101 1101 )
1102 1102 hbisect.checkstate(state)
1103 1103 # bisect
1104 1104 nodes, changesets, bgood = hbisect.bisect(repo, state)
1105 1105 # update to next check
1106 1106 node = nodes[0]
1107 1107 mayupdate(repo, node, show_stats=False)
1108 1108 hbisect.printresult(ui, repo, state, displayer, nodes, bgood)
1109 1109 return
1110 1110
1111 1111 hbisect.checkstate(state)
1112 1112
1113 1113 # actually bisect
1114 1114 nodes, changesets, good = hbisect.bisect(repo, state)
1115 1115 if extend:
1116 1116 if not changesets:
1117 1117 extendnode = hbisect.extendrange(repo, state, nodes, good)
1118 1118 if extendnode is not None:
1119 1119 ui.write(
1120 1120 _(b"Extending search to changeset %d:%s\n")
1121 1121 % (extendnode.rev(), extendnode)
1122 1122 )
1123 1123 state[b'current'] = [extendnode.node()]
1124 1124 hbisect.save_state(repo, state)
1125 1125 return mayupdate(repo, extendnode.node())
1126 1126 raise error.Abort(_(b"nothing to extend"))
1127 1127
1128 1128 if changesets == 0:
1129 1129 hbisect.printresult(ui, repo, state, displayer, nodes, good)
1130 1130 else:
1131 1131 assert len(nodes) == 1 # only a single node can be tested next
1132 1132 node = nodes[0]
1133 1133 # compute the approximate number of remaining tests
1134 1134 tests, size = 0, 2
1135 1135 while size <= changesets:
1136 1136 tests, size = tests + 1, size * 2
1137 1137 rev = repo.changelog.rev(node)
1138 1138 ui.write(
1139 1139 _(
1140 1140 b"Testing changeset %d:%s "
1141 1141 b"(%d changesets remaining, ~%d tests)\n"
1142 1142 )
1143 1143 % (rev, short(node), changesets, tests)
1144 1144 )
1145 1145 state[b'current'] = [node]
1146 1146 hbisect.save_state(repo, state)
1147 1147 return mayupdate(repo, node)
1148 1148
1149 1149
1150 1150 @command(
1151 1151 b'bookmarks|bookmark',
1152 1152 [
1153 1153 (b'f', b'force', False, _(b'force')),
1154 1154 (b'r', b'rev', b'', _(b'revision for bookmark action'), _(b'REV')),
1155 1155 (b'd', b'delete', False, _(b'delete a given bookmark')),
1156 1156 (b'm', b'rename', b'', _(b'rename a given bookmark'), _(b'OLD')),
1157 1157 (b'i', b'inactive', False, _(b'mark a bookmark inactive')),
1158 1158 (b'l', b'list', False, _(b'list existing bookmarks')),
1159 1159 ]
1160 1160 + formatteropts,
1161 1161 _(b'hg bookmarks [OPTIONS]... [NAME]...'),
1162 1162 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
1163 1163 )
1164 1164 def bookmark(ui, repo, *names, **opts):
1165 1165 '''create a new bookmark or list existing bookmarks
1166 1166
1167 1167 Bookmarks are labels on changesets to help track lines of development.
1168 1168 Bookmarks are unversioned and can be moved, renamed and deleted.
1169 1169 Deleting or moving a bookmark has no effect on the associated changesets.
1170 1170
1171 1171 Creating or updating to a bookmark causes it to be marked as 'active'.
1172 1172 The active bookmark is indicated with a '*'.
1173 1173 When a commit is made, the active bookmark will advance to the new commit.
1174 1174 A plain :hg:`update` will also advance an active bookmark, if possible.
1175 1175 Updating away from a bookmark will cause it to be deactivated.
1176 1176
1177 1177 Bookmarks can be pushed and pulled between repositories (see
1178 1178 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
1179 1179 diverged, a new 'divergent bookmark' of the form 'name@path' will
1180 1180 be created. Using :hg:`merge` will resolve the divergence.
1181 1181
1182 1182 Specifying bookmark as '.' to -m/-d/-l options is equivalent to specifying
1183 1183 the active bookmark's name.
1184 1184
1185 1185 A bookmark named '@' has the special property that :hg:`clone` will
1186 1186 check it out by default if it exists.
1187 1187
1188 1188 .. container:: verbose
1189 1189
1190 1190 Template:
1191 1191
1192 1192 The following keywords are supported in addition to the common template
1193 1193 keywords and functions such as ``{bookmark}``. See also
1194 1194 :hg:`help templates`.
1195 1195
1196 1196 :active: Boolean. True if the bookmark is active.
1197 1197
1198 1198 Examples:
1199 1199
1200 1200 - create an active bookmark for a new line of development::
1201 1201
1202 1202 hg book new-feature
1203 1203
1204 1204 - create an inactive bookmark as a place marker::
1205 1205
1206 1206 hg book -i reviewed
1207 1207
1208 1208 - create an inactive bookmark on another changeset::
1209 1209
1210 1210 hg book -r .^ tested
1211 1211
1212 1212 - rename bookmark turkey to dinner::
1213 1213
1214 1214 hg book -m turkey dinner
1215 1215
1216 1216 - move the '@' bookmark from another branch::
1217 1217
1218 1218 hg book -f @
1219 1219
1220 1220 - print only the active bookmark name::
1221 1221
1222 1222 hg book -ql .
1223 1223 '''
1224 1224 opts = pycompat.byteskwargs(opts)
1225 1225 force = opts.get(b'force')
1226 1226 rev = opts.get(b'rev')
1227 1227 inactive = opts.get(b'inactive') # meaning add/rename to inactive bookmark
1228 1228
1229 1229 selactions = [k for k in [b'delete', b'rename', b'list'] if opts.get(k)]
1230 1230 if len(selactions) > 1:
1231 1231 raise error.Abort(
1232 1232 _(b'--%s and --%s are incompatible') % tuple(selactions[:2])
1233 1233 )
1234 1234 if selactions:
1235 1235 action = selactions[0]
1236 1236 elif names or rev:
1237 1237 action = b'add'
1238 1238 elif inactive:
1239 1239 action = b'inactive' # meaning deactivate
1240 1240 else:
1241 1241 action = b'list'
1242 1242
1243 1243 if rev and action in {b'delete', b'rename', b'list'}:
1244 1244 raise error.Abort(_(b"--rev is incompatible with --%s") % action)
1245 1245 if inactive and action in {b'delete', b'list'}:
1246 1246 raise error.Abort(_(b"--inactive is incompatible with --%s") % action)
1247 1247 if not names and action in {b'add', b'delete'}:
1248 1248 raise error.Abort(_(b"bookmark name required"))
1249 1249
1250 1250 if action in {b'add', b'delete', b'rename', b'inactive'}:
1251 1251 with repo.wlock(), repo.lock(), repo.transaction(b'bookmark') as tr:
1252 1252 if action == b'delete':
1253 1253 names = pycompat.maplist(repo._bookmarks.expandname, names)
1254 1254 bookmarks.delete(repo, tr, names)
1255 1255 elif action == b'rename':
1256 1256 if not names:
1257 1257 raise error.Abort(_(b"new bookmark name required"))
1258 1258 elif len(names) > 1:
1259 1259 raise error.Abort(_(b"only one new bookmark name allowed"))
1260 1260 oldname = repo._bookmarks.expandname(opts[b'rename'])
1261 1261 bookmarks.rename(repo, tr, oldname, names[0], force, inactive)
1262 1262 elif action == b'add':
1263 1263 bookmarks.addbookmarks(repo, tr, names, rev, force, inactive)
1264 1264 elif action == b'inactive':
1265 1265 if len(repo._bookmarks) == 0:
1266 1266 ui.status(_(b"no bookmarks set\n"))
1267 1267 elif not repo._activebookmark:
1268 1268 ui.status(_(b"no active bookmark\n"))
1269 1269 else:
1270 1270 bookmarks.deactivate(repo)
1271 1271 elif action == b'list':
1272 1272 names = pycompat.maplist(repo._bookmarks.expandname, names)
1273 1273 with ui.formatter(b'bookmarks', opts) as fm:
1274 1274 bookmarks.printbookmarks(ui, repo, fm, names)
1275 1275 else:
1276 1276 raise error.ProgrammingError(b'invalid action: %s' % action)
1277 1277
1278 1278
1279 1279 @command(
1280 1280 b'branch',
1281 1281 [
1282 1282 (
1283 1283 b'f',
1284 1284 b'force',
1285 1285 None,
1286 1286 _(b'set branch name even if it shadows an existing branch'),
1287 1287 ),
1288 1288 (b'C', b'clean', None, _(b'reset branch name to parent branch name')),
1289 1289 (
1290 1290 b'r',
1291 1291 b'rev',
1292 1292 [],
1293 1293 _(b'change branches of the given revs (EXPERIMENTAL)'),
1294 1294 ),
1295 1295 ],
1296 1296 _(b'[-fC] [NAME]'),
1297 1297 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
1298 1298 )
1299 1299 def branch(ui, repo, label=None, **opts):
1300 1300 """set or show the current branch name
1301 1301
1302 1302 .. note::
1303 1303
1304 1304 Branch names are permanent and global. Use :hg:`bookmark` to create a
1305 1305 light-weight bookmark instead. See :hg:`help glossary` for more
1306 1306 information about named branches and bookmarks.
1307 1307
1308 1308 With no argument, show the current branch name. With one argument,
1309 1309 set the working directory branch name (the branch will not exist
1310 1310 in the repository until the next commit). Standard practice
1311 1311 recommends that primary development take place on the 'default'
1312 1312 branch.
1313 1313
1314 1314 Unless -f/--force is specified, branch will not let you set a
1315 1315 branch name that already exists.
1316 1316
1317 1317 Use -C/--clean to reset the working directory branch to that of
1318 1318 the parent of the working directory, negating a previous branch
1319 1319 change.
1320 1320
1321 1321 Use the command :hg:`update` to switch to an existing branch. Use
1322 1322 :hg:`commit --close-branch` to mark this branch head as closed.
1323 1323 When all heads of a branch are closed, the branch will be
1324 1324 considered closed.
1325 1325
1326 1326 Returns 0 on success.
1327 1327 """
1328 1328 opts = pycompat.byteskwargs(opts)
1329 1329 revs = opts.get(b'rev')
1330 1330 if label:
1331 1331 label = label.strip()
1332 1332
1333 1333 if not opts.get(b'clean') and not label:
1334 1334 if revs:
1335 1335 raise error.Abort(_(b"no branch name specified for the revisions"))
1336 1336 ui.write(b"%s\n" % repo.dirstate.branch())
1337 1337 return
1338 1338
1339 1339 with repo.wlock():
1340 1340 if opts.get(b'clean'):
1341 1341 label = repo[b'.'].branch()
1342 1342 repo.dirstate.setbranch(label)
1343 1343 ui.status(_(b'reset working directory to branch %s\n') % label)
1344 1344 elif label:
1345 1345
1346 1346 scmutil.checknewlabel(repo, label, b'branch')
1347 1347 if revs:
1348 1348 return cmdutil.changebranch(ui, repo, revs, label)
1349 1349
1350 1350 if not opts.get(b'force') and label in repo.branchmap():
1351 1351 if label not in [p.branch() for p in repo[None].parents()]:
1352 1352 raise error.Abort(
1353 1353 _(b'a branch of the same name already exists'),
1354 1354 # i18n: "it" refers to an existing branch
1355 1355 hint=_(b"use 'hg update' to switch to it"),
1356 1356 )
1357 1357
1358 1358 repo.dirstate.setbranch(label)
1359 1359 ui.status(_(b'marked working directory as branch %s\n') % label)
1360 1360
1361 1361 # find any open named branches aside from default
1362 1362 for n, h, t, c in repo.branchmap().iterbranches():
1363 1363 if n != b"default" and not c:
1364 1364 return 0
1365 1365 ui.status(
1366 1366 _(
1367 1367 b'(branches are permanent and global, '
1368 1368 b'did you want a bookmark?)\n'
1369 1369 )
1370 1370 )
1371 1371
1372 1372
1373 1373 @command(
1374 1374 b'branches',
1375 1375 [
1376 1376 (
1377 1377 b'a',
1378 1378 b'active',
1379 1379 False,
1380 1380 _(b'show only branches that have unmerged heads (DEPRECATED)'),
1381 1381 ),
1382 1382 (b'c', b'closed', False, _(b'show normal and closed branches')),
1383 1383 (b'r', b'rev', [], _(b'show branch name(s) of the given rev')),
1384 1384 ]
1385 1385 + formatteropts,
1386 1386 _(b'[-c]'),
1387 1387 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
1388 1388 intents={INTENT_READONLY},
1389 1389 )
1390 1390 def branches(ui, repo, active=False, closed=False, **opts):
1391 1391 """list repository named branches
1392 1392
1393 1393 List the repository's named branches, indicating which ones are
1394 1394 inactive. If -c/--closed is specified, also list branches which have
1395 1395 been marked closed (see :hg:`commit --close-branch`).
1396 1396
1397 1397 Use the command :hg:`update` to switch to an existing branch.
1398 1398
1399 1399 .. container:: verbose
1400 1400
1401 1401 Template:
1402 1402
1403 1403 The following keywords are supported in addition to the common template
1404 1404 keywords and functions such as ``{branch}``. See also
1405 1405 :hg:`help templates`.
1406 1406
1407 1407 :active: Boolean. True if the branch is active.
1408 1408 :closed: Boolean. True if the branch is closed.
1409 1409 :current: Boolean. True if it is the current branch.
1410 1410
1411 1411 Returns 0.
1412 1412 """
1413 1413
1414 1414 opts = pycompat.byteskwargs(opts)
1415 1415 revs = opts.get(b'rev')
1416 1416 selectedbranches = None
1417 1417 if revs:
1418 1418 revs = scmutil.revrange(repo, revs)
1419 1419 getbi = repo.revbranchcache().branchinfo
1420 1420 selectedbranches = {getbi(r)[0] for r in revs}
1421 1421
1422 1422 ui.pager(b'branches')
1423 1423 fm = ui.formatter(b'branches', opts)
1424 1424 hexfunc = fm.hexfunc
1425 1425
1426 1426 allheads = set(repo.heads())
1427 1427 branches = []
1428 1428 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1429 1429 if selectedbranches is not None and tag not in selectedbranches:
1430 1430 continue
1431 1431 isactive = False
1432 1432 if not isclosed:
1433 1433 openheads = set(repo.branchmap().iteropen(heads))
1434 1434 isactive = bool(openheads & allheads)
1435 1435 branches.append((tag, repo[tip], isactive, not isclosed))
1436 1436 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]), reverse=True)
1437 1437
1438 1438 for tag, ctx, isactive, isopen in branches:
1439 1439 if active and not isactive:
1440 1440 continue
1441 1441 if isactive:
1442 1442 label = b'branches.active'
1443 1443 notice = b''
1444 1444 elif not isopen:
1445 1445 if not closed:
1446 1446 continue
1447 1447 label = b'branches.closed'
1448 1448 notice = _(b' (closed)')
1449 1449 else:
1450 1450 label = b'branches.inactive'
1451 1451 notice = _(b' (inactive)')
1452 1452 current = tag == repo.dirstate.branch()
1453 1453 if current:
1454 1454 label = b'branches.current'
1455 1455
1456 1456 fm.startitem()
1457 1457 fm.write(b'branch', b'%s', tag, label=label)
1458 1458 rev = ctx.rev()
1459 1459 padsize = max(31 - len(b"%d" % rev) - encoding.colwidth(tag), 0)
1460 1460 fmt = b' ' * padsize + b' %d:%s'
1461 1461 fm.condwrite(
1462 1462 not ui.quiet,
1463 1463 b'rev node',
1464 1464 fmt,
1465 1465 rev,
1466 1466 hexfunc(ctx.node()),
1467 1467 label=b'log.changeset changeset.%s' % ctx.phasestr(),
1468 1468 )
1469 1469 fm.context(ctx=ctx)
1470 1470 fm.data(active=isactive, closed=not isopen, current=current)
1471 1471 if not ui.quiet:
1472 1472 fm.plain(notice)
1473 1473 fm.plain(b'\n')
1474 1474 fm.end()
1475 1475
1476 1476
1477 1477 @command(
1478 1478 b'bundle',
1479 1479 [
1480 1480 (
1481 1481 b'f',
1482 1482 b'force',
1483 1483 None,
1484 1484 _(b'run even when the destination is unrelated'),
1485 1485 ),
1486 1486 (
1487 1487 b'r',
1488 1488 b'rev',
1489 1489 [],
1490 1490 _(b'a changeset intended to be added to the destination'),
1491 1491 _(b'REV'),
1492 1492 ),
1493 1493 (
1494 1494 b'b',
1495 1495 b'branch',
1496 1496 [],
1497 1497 _(b'a specific branch you would like to bundle'),
1498 1498 _(b'BRANCH'),
1499 1499 ),
1500 1500 (
1501 1501 b'',
1502 1502 b'base',
1503 1503 [],
1504 1504 _(b'a base changeset assumed to be available at the destination'),
1505 1505 _(b'REV'),
1506 1506 ),
1507 1507 (b'a', b'all', None, _(b'bundle all changesets in the repository')),
1508 1508 (
1509 1509 b't',
1510 1510 b'type',
1511 1511 b'bzip2',
1512 1512 _(b'bundle compression type to use'),
1513 1513 _(b'TYPE'),
1514 1514 ),
1515 1515 ]
1516 1516 + remoteopts,
1517 1517 _(b'[-f] [-t BUNDLESPEC] [-a] [-r REV]... [--base REV]... FILE [DEST]'),
1518 1518 helpcategory=command.CATEGORY_IMPORT_EXPORT,
1519 1519 )
1520 1520 def bundle(ui, repo, fname, dest=None, **opts):
1521 1521 """create a bundle file
1522 1522
1523 1523 Generate a bundle file containing data to be transferred to another
1524 1524 repository.
1525 1525
1526 1526 To create a bundle containing all changesets, use -a/--all
1527 1527 (or --base null). Otherwise, hg assumes the destination will have
1528 1528 all the nodes you specify with --base parameters. Otherwise, hg
1529 1529 will assume the repository has all the nodes in destination, or
1530 1530 default-push/default if no destination is specified, where destination
1531 1531 is the repository you provide through DEST option.
1532 1532
1533 1533 You can change bundle format with the -t/--type option. See
1534 1534 :hg:`help bundlespec` for documentation on this format. By default,
1535 1535 the most appropriate format is used and compression defaults to
1536 1536 bzip2.
1537 1537
1538 1538 The bundle file can then be transferred using conventional means
1539 1539 and applied to another repository with the unbundle or pull
1540 1540 command. This is useful when direct push and pull are not
1541 1541 available or when exporting an entire repository is undesirable.
1542 1542
1543 1543 Applying bundles preserves all changeset contents including
1544 1544 permissions, copy/rename information, and revision history.
1545 1545
1546 1546 Returns 0 on success, 1 if no changes found.
1547 1547 """
1548 1548 opts = pycompat.byteskwargs(opts)
1549 1549 revs = None
1550 1550 if b'rev' in opts:
1551 1551 revstrings = opts[b'rev']
1552 1552 revs = scmutil.revrange(repo, revstrings)
1553 1553 if revstrings and not revs:
1554 1554 raise error.Abort(_(b'no commits to bundle'))
1555 1555
1556 1556 bundletype = opts.get(b'type', b'bzip2').lower()
1557 1557 try:
1558 1558 bundlespec = exchange.parsebundlespec(repo, bundletype, strict=False)
1559 1559 except error.UnsupportedBundleSpecification as e:
1560 1560 raise error.Abort(
1561 1561 pycompat.bytestr(e),
1562 1562 hint=_(b"see 'hg help bundlespec' for supported values for --type"),
1563 1563 )
1564 1564 cgversion = bundlespec.contentopts[b"cg.version"]
1565 1565
1566 1566 # Packed bundles are a pseudo bundle format for now.
1567 1567 if cgversion == b's1':
1568 1568 raise error.Abort(
1569 1569 _(b'packed bundles cannot be produced by "hg bundle"'),
1570 1570 hint=_(b"use 'hg debugcreatestreamclonebundle'"),
1571 1571 )
1572 1572
1573 1573 if opts.get(b'all'):
1574 1574 if dest:
1575 1575 raise error.Abort(
1576 1576 _(b"--all is incompatible with specifying a destination")
1577 1577 )
1578 1578 if opts.get(b'base'):
1579 1579 ui.warn(_(b"ignoring --base because --all was specified\n"))
1580 1580 base = [nullrev]
1581 1581 else:
1582 1582 base = scmutil.revrange(repo, opts.get(b'base'))
1583 1583 if cgversion not in changegroup.supportedoutgoingversions(repo):
1584 1584 raise error.Abort(
1585 1585 _(b"repository does not support bundle version %s") % cgversion
1586 1586 )
1587 1587
1588 1588 if base:
1589 1589 if dest:
1590 1590 raise error.Abort(
1591 1591 _(b"--base is incompatible with specifying a destination")
1592 1592 )
1593 1593 common = [repo[rev].node() for rev in base]
1594 1594 heads = [repo[r].node() for r in revs] if revs else None
1595 1595 outgoing = discovery.outgoing(repo, common, heads)
1596 1596 else:
1597 1597 dest = ui.expandpath(dest or b'default-push', dest or b'default')
1598 1598 dest, branches = hg.parseurl(dest, opts.get(b'branch'))
1599 1599 other = hg.peer(repo, opts, dest)
1600 1600 revs = [repo[r].hex() for r in revs]
1601 1601 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1602 1602 heads = revs and pycompat.maplist(repo.lookup, revs) or revs
1603 1603 outgoing = discovery.findcommonoutgoing(
1604 1604 repo,
1605 1605 other,
1606 1606 onlyheads=heads,
1607 1607 force=opts.get(b'force'),
1608 1608 portable=True,
1609 1609 )
1610 1610
1611 1611 if not outgoing.missing:
1612 1612 scmutil.nochangesfound(ui, repo, not base and outgoing.excluded)
1613 1613 return 1
1614 1614
1615 1615 if cgversion == b'01': # bundle1
1616 1616 bversion = b'HG10' + bundlespec.wirecompression
1617 1617 bcompression = None
1618 1618 elif cgversion in (b'02', b'03'):
1619 1619 bversion = b'HG20'
1620 1620 bcompression = bundlespec.wirecompression
1621 1621 else:
1622 1622 raise error.ProgrammingError(
1623 1623 b'bundle: unexpected changegroup version %s' % cgversion
1624 1624 )
1625 1625
1626 1626 # TODO compression options should be derived from bundlespec parsing.
1627 1627 # This is a temporary hack to allow adjusting bundle compression
1628 1628 # level without a) formalizing the bundlespec changes to declare it
1629 1629 # b) introducing a command flag.
1630 1630 compopts = {}
1631 1631 complevel = ui.configint(
1632 1632 b'experimental', b'bundlecomplevel.' + bundlespec.compression
1633 1633 )
1634 1634 if complevel is None:
1635 1635 complevel = ui.configint(b'experimental', b'bundlecomplevel')
1636 1636 if complevel is not None:
1637 1637 compopts[b'level'] = complevel
1638 1638
1639 1639 # Allow overriding the bundling of obsmarker in phases through
1640 1640 # configuration while we don't have a bundle version that include them
1641 1641 if repo.ui.configbool(b'experimental', b'evolution.bundle-obsmarker'):
1642 1642 bundlespec.contentopts[b'obsolescence'] = True
1643 1643 if repo.ui.configbool(b'experimental', b'bundle-phases'):
1644 1644 bundlespec.contentopts[b'phases'] = True
1645 1645
1646 1646 bundle2.writenewbundle(
1647 1647 ui,
1648 1648 repo,
1649 1649 b'bundle',
1650 1650 fname,
1651 1651 bversion,
1652 1652 outgoing,
1653 1653 bundlespec.contentopts,
1654 1654 compression=bcompression,
1655 1655 compopts=compopts,
1656 1656 )
1657 1657
1658 1658
1659 1659 @command(
1660 1660 b'cat',
1661 1661 [
1662 1662 (
1663 1663 b'o',
1664 1664 b'output',
1665 1665 b'',
1666 1666 _(b'print output to file with formatted name'),
1667 1667 _(b'FORMAT'),
1668 1668 ),
1669 1669 (b'r', b'rev', b'', _(b'print the given revision'), _(b'REV')),
1670 1670 (b'', b'decode', None, _(b'apply any matching decode filter')),
1671 1671 ]
1672 1672 + walkopts
1673 1673 + formatteropts,
1674 1674 _(b'[OPTION]... FILE...'),
1675 1675 helpcategory=command.CATEGORY_FILE_CONTENTS,
1676 1676 inferrepo=True,
1677 1677 intents={INTENT_READONLY},
1678 1678 )
1679 1679 def cat(ui, repo, file1, *pats, **opts):
1680 1680 """output the current or given revision of files
1681 1681
1682 1682 Print the specified files as they were at the given revision. If
1683 1683 no revision is given, the parent of the working directory is used.
1684 1684
1685 1685 Output may be to a file, in which case the name of the file is
1686 1686 given using a template string. See :hg:`help templates`. In addition
1687 1687 to the common template keywords, the following formatting rules are
1688 1688 supported:
1689 1689
1690 1690 :``%%``: literal "%" character
1691 1691 :``%s``: basename of file being printed
1692 1692 :``%d``: dirname of file being printed, or '.' if in repository root
1693 1693 :``%p``: root-relative path name of file being printed
1694 1694 :``%H``: changeset hash (40 hexadecimal digits)
1695 1695 :``%R``: changeset revision number
1696 1696 :``%h``: short-form changeset hash (12 hexadecimal digits)
1697 1697 :``%r``: zero-padded changeset revision number
1698 1698 :``%b``: basename of the exporting repository
1699 1699 :``\\``: literal "\\" character
1700 1700
1701 1701 .. container:: verbose
1702 1702
1703 1703 Template:
1704 1704
1705 1705 The following keywords are supported in addition to the common template
1706 1706 keywords and functions. See also :hg:`help templates`.
1707 1707
1708 1708 :data: String. File content.
1709 1709 :path: String. Repository-absolute path of the file.
1710 1710
1711 1711 Returns 0 on success.
1712 1712 """
1713 1713 opts = pycompat.byteskwargs(opts)
1714 1714 rev = opts.get(b'rev')
1715 1715 if rev:
1716 1716 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
1717 1717 ctx = scmutil.revsingle(repo, rev)
1718 1718 m = scmutil.match(ctx, (file1,) + pats, opts)
1719 1719 fntemplate = opts.pop(b'output', b'')
1720 1720 if cmdutil.isstdiofilename(fntemplate):
1721 1721 fntemplate = b''
1722 1722
1723 1723 if fntemplate:
1724 1724 fm = formatter.nullformatter(ui, b'cat', opts)
1725 1725 else:
1726 1726 ui.pager(b'cat')
1727 1727 fm = ui.formatter(b'cat', opts)
1728 1728 with fm:
1729 1729 return cmdutil.cat(
1730 1730 ui, repo, ctx, m, fm, fntemplate, b'', **pycompat.strkwargs(opts)
1731 1731 )
1732 1732
1733 1733
1734 1734 @command(
1735 1735 b'clone',
1736 1736 [
1737 1737 (
1738 1738 b'U',
1739 1739 b'noupdate',
1740 1740 None,
1741 1741 _(
1742 1742 b'the clone will include an empty working '
1743 1743 b'directory (only a repository)'
1744 1744 ),
1745 1745 ),
1746 1746 (
1747 1747 b'u',
1748 1748 b'updaterev',
1749 1749 b'',
1750 1750 _(b'revision, tag, or branch to check out'),
1751 1751 _(b'REV'),
1752 1752 ),
1753 1753 (
1754 1754 b'r',
1755 1755 b'rev',
1756 1756 [],
1757 1757 _(
1758 1758 b'do not clone everything, but include this changeset'
1759 1759 b' and its ancestors'
1760 1760 ),
1761 1761 _(b'REV'),
1762 1762 ),
1763 1763 (
1764 1764 b'b',
1765 1765 b'branch',
1766 1766 [],
1767 1767 _(
1768 1768 b'do not clone everything, but include this branch\'s'
1769 1769 b' changesets and their ancestors'
1770 1770 ),
1771 1771 _(b'BRANCH'),
1772 1772 ),
1773 1773 (b'', b'pull', None, _(b'use pull protocol to copy metadata')),
1774 1774 (b'', b'uncompressed', None, _(b'an alias to --stream (DEPRECATED)')),
1775 1775 (b'', b'stream', None, _(b'clone with minimal data processing')),
1776 1776 ]
1777 1777 + remoteopts,
1778 1778 _(b'[OPTION]... SOURCE [DEST]'),
1779 1779 helpcategory=command.CATEGORY_REPO_CREATION,
1780 1780 helpbasic=True,
1781 1781 norepo=True,
1782 1782 )
1783 1783 def clone(ui, source, dest=None, **opts):
1784 1784 """make a copy of an existing repository
1785 1785
1786 1786 Create a copy of an existing repository in a new directory.
1787 1787
1788 1788 If no destination directory name is specified, it defaults to the
1789 1789 basename of the source.
1790 1790
1791 1791 The location of the source is added to the new repository's
1792 1792 ``.hg/hgrc`` file, as the default to be used for future pulls.
1793 1793
1794 1794 Only local paths and ``ssh://`` URLs are supported as
1795 1795 destinations. For ``ssh://`` destinations, no working directory or
1796 1796 ``.hg/hgrc`` will be created on the remote side.
1797 1797
1798 1798 If the source repository has a bookmark called '@' set, that
1799 1799 revision will be checked out in the new repository by default.
1800 1800
1801 1801 To check out a particular version, use -u/--update, or
1802 1802 -U/--noupdate to create a clone with no working directory.
1803 1803
1804 1804 To pull only a subset of changesets, specify one or more revisions
1805 1805 identifiers with -r/--rev or branches with -b/--branch. The
1806 1806 resulting clone will contain only the specified changesets and
1807 1807 their ancestors. These options (or 'clone src#rev dest') imply
1808 1808 --pull, even for local source repositories.
1809 1809
1810 1810 In normal clone mode, the remote normalizes repository data into a common
1811 1811 exchange format and the receiving end translates this data into its local
1812 1812 storage format. --stream activates a different clone mode that essentially
1813 1813 copies repository files from the remote with minimal data processing. This
1814 1814 significantly reduces the CPU cost of a clone both remotely and locally.
1815 1815 However, it often increases the transferred data size by 30-40%. This can
1816 1816 result in substantially faster clones where I/O throughput is plentiful,
1817 1817 especially for larger repositories. A side-effect of --stream clones is
1818 1818 that storage settings and requirements on the remote are applied locally:
1819 1819 a modern client may inherit legacy or inefficient storage used by the
1820 1820 remote or a legacy Mercurial client may not be able to clone from a
1821 1821 modern Mercurial remote.
1822 1822
1823 1823 .. note::
1824 1824
1825 1825 Specifying a tag will include the tagged changeset but not the
1826 1826 changeset containing the tag.
1827 1827
1828 1828 .. container:: verbose
1829 1829
1830 1830 For efficiency, hardlinks are used for cloning whenever the
1831 1831 source and destination are on the same filesystem (note this
1832 1832 applies only to the repository data, not to the working
1833 1833 directory). Some filesystems, such as AFS, implement hardlinking
1834 1834 incorrectly, but do not report errors. In these cases, use the
1835 1835 --pull option to avoid hardlinking.
1836 1836
1837 1837 Mercurial will update the working directory to the first applicable
1838 1838 revision from this list:
1839 1839
1840 1840 a) null if -U or the source repository has no changesets
1841 1841 b) if -u . and the source repository is local, the first parent of
1842 1842 the source repository's working directory
1843 1843 c) the changeset specified with -u (if a branch name, this means the
1844 1844 latest head of that branch)
1845 1845 d) the changeset specified with -r
1846 1846 e) the tipmost head specified with -b
1847 1847 f) the tipmost head specified with the url#branch source syntax
1848 1848 g) the revision marked with the '@' bookmark, if present
1849 1849 h) the tipmost head of the default branch
1850 1850 i) tip
1851 1851
1852 1852 When cloning from servers that support it, Mercurial may fetch
1853 1853 pre-generated data from a server-advertised URL or inline from the
1854 1854 same stream. When this is done, hooks operating on incoming changesets
1855 1855 and changegroups may fire more than once, once for each pre-generated
1856 1856 bundle and as well as for any additional remaining data. In addition,
1857 1857 if an error occurs, the repository may be rolled back to a partial
1858 1858 clone. This behavior may change in future releases.
1859 1859 See :hg:`help -e clonebundles` for more.
1860 1860
1861 1861 Examples:
1862 1862
1863 1863 - clone a remote repository to a new directory named hg/::
1864 1864
1865 1865 hg clone https://www.mercurial-scm.org/repo/hg/
1866 1866
1867 1867 - create a lightweight local clone::
1868 1868
1869 1869 hg clone project/ project-feature/
1870 1870
1871 1871 - clone from an absolute path on an ssh server (note double-slash)::
1872 1872
1873 1873 hg clone ssh://user@server//home/projects/alpha/
1874 1874
1875 1875 - do a streaming clone while checking out a specified version::
1876 1876
1877 1877 hg clone --stream http://server/repo -u 1.5
1878 1878
1879 1879 - create a repository without changesets after a particular revision::
1880 1880
1881 1881 hg clone -r 04e544 experimental/ good/
1882 1882
1883 1883 - clone (and track) a particular named branch::
1884 1884
1885 1885 hg clone https://www.mercurial-scm.org/repo/hg/#stable
1886 1886
1887 1887 See :hg:`help urls` for details on specifying URLs.
1888 1888
1889 1889 Returns 0 on success.
1890 1890 """
1891 1891 opts = pycompat.byteskwargs(opts)
1892 1892 if opts.get(b'noupdate') and opts.get(b'updaterev'):
1893 1893 raise error.Abort(_(b"cannot specify both --noupdate and --updaterev"))
1894 1894
1895 1895 # --include/--exclude can come from narrow or sparse.
1896 1896 includepats, excludepats = None, None
1897 1897
1898 1898 # hg.clone() differentiates between None and an empty set. So make sure
1899 1899 # patterns are sets if narrow is requested without patterns.
1900 1900 if opts.get(b'narrow'):
1901 1901 includepats = set()
1902 1902 excludepats = set()
1903 1903
1904 1904 if opts.get(b'include'):
1905 1905 includepats = narrowspec.parsepatterns(opts.get(b'include'))
1906 1906 if opts.get(b'exclude'):
1907 1907 excludepats = narrowspec.parsepatterns(opts.get(b'exclude'))
1908 1908
1909 1909 r = hg.clone(
1910 1910 ui,
1911 1911 opts,
1912 1912 source,
1913 1913 dest,
1914 1914 pull=opts.get(b'pull'),
1915 1915 stream=opts.get(b'stream') or opts.get(b'uncompressed'),
1916 1916 revs=opts.get(b'rev'),
1917 1917 update=opts.get(b'updaterev') or not opts.get(b'noupdate'),
1918 1918 branch=opts.get(b'branch'),
1919 1919 shareopts=opts.get(b'shareopts'),
1920 1920 storeincludepats=includepats,
1921 1921 storeexcludepats=excludepats,
1922 1922 depth=opts.get(b'depth') or None,
1923 1923 )
1924 1924
1925 1925 return r is None
1926 1926
1927 1927
1928 1928 @command(
1929 1929 b'commit|ci',
1930 1930 [
1931 1931 (
1932 1932 b'A',
1933 1933 b'addremove',
1934 1934 None,
1935 1935 _(b'mark new/missing files as added/removed before committing'),
1936 1936 ),
1937 1937 (b'', b'close-branch', None, _(b'mark a branch head as closed')),
1938 1938 (b'', b'amend', None, _(b'amend the parent of the working directory')),
1939 1939 (b's', b'secret', None, _(b'use the secret phase for committing')),
1940 1940 (b'e', b'edit', None, _(b'invoke editor on commit messages')),
1941 1941 (
1942 1942 b'',
1943 1943 b'force-close-branch',
1944 1944 None,
1945 1945 _(b'forcibly close branch from a non-head changeset (ADVANCED)'),
1946 1946 ),
1947 1947 (b'i', b'interactive', None, _(b'use interactive mode')),
1948 1948 ]
1949 1949 + walkopts
1950 1950 + commitopts
1951 1951 + commitopts2
1952 1952 + subrepoopts,
1953 1953 _(b'[OPTION]... [FILE]...'),
1954 1954 helpcategory=command.CATEGORY_COMMITTING,
1955 1955 helpbasic=True,
1956 1956 inferrepo=True,
1957 1957 )
1958 1958 def commit(ui, repo, *pats, **opts):
1959 1959 """commit the specified files or all outstanding changes
1960 1960
1961 1961 Commit changes to the given files into the repository. Unlike a
1962 1962 centralized SCM, this operation is a local operation. See
1963 1963 :hg:`push` for a way to actively distribute your changes.
1964 1964
1965 1965 If a list of files is omitted, all changes reported by :hg:`status`
1966 1966 will be committed.
1967 1967
1968 1968 If you are committing the result of a merge, do not provide any
1969 1969 filenames or -I/-X filters.
1970 1970
1971 1971 If no commit message is specified, Mercurial starts your
1972 1972 configured editor where you can enter a message. In case your
1973 1973 commit fails, you will find a backup of your message in
1974 1974 ``.hg/last-message.txt``.
1975 1975
1976 1976 The --close-branch flag can be used to mark the current branch
1977 1977 head closed. When all heads of a branch are closed, the branch
1978 1978 will be considered closed and no longer listed.
1979 1979
1980 1980 The --amend flag can be used to amend the parent of the
1981 1981 working directory with a new commit that contains the changes
1982 1982 in the parent in addition to those currently reported by :hg:`status`,
1983 1983 if there are any. The old commit is stored in a backup bundle in
1984 1984 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1985 1985 on how to restore it).
1986 1986
1987 1987 Message, user and date are taken from the amended commit unless
1988 1988 specified. When a message isn't specified on the command line,
1989 1989 the editor will open with the message of the amended commit.
1990 1990
1991 1991 It is not possible to amend public changesets (see :hg:`help phases`)
1992 1992 or changesets that have children.
1993 1993
1994 1994 See :hg:`help dates` for a list of formats valid for -d/--date.
1995 1995
1996 1996 Returns 0 on success, 1 if nothing changed.
1997 1997
1998 1998 .. container:: verbose
1999 1999
2000 2000 Examples:
2001 2001
2002 2002 - commit all files ending in .py::
2003 2003
2004 2004 hg commit --include "set:**.py"
2005 2005
2006 2006 - commit all non-binary files::
2007 2007
2008 2008 hg commit --exclude "set:binary()"
2009 2009
2010 2010 - amend the current commit and set the date to now::
2011 2011
2012 2012 hg commit --amend --date now
2013 2013 """
2014 2014 with repo.wlock(), repo.lock():
2015 2015 return _docommit(ui, repo, *pats, **opts)
2016 2016
2017 2017
2018 2018 def _docommit(ui, repo, *pats, **opts):
2019 2019 if opts.get('interactive'):
2020 2020 opts.pop('interactive')
2021 2021 ret = cmdutil.dorecord(
2022 2022 ui, repo, commit, None, False, cmdutil.recordfilter, *pats, **opts
2023 2023 )
2024 2024 # ret can be 0 (no changes to record) or the value returned by
2025 2025 # commit(), 1 if nothing changed or None on success.
2026 2026 return 1 if ret == 0 else ret
2027 2027
2028 2028 opts = pycompat.byteskwargs(opts)
2029 2029 if opts.get(b'subrepos'):
2030 2030 if opts.get(b'amend'):
2031 2031 raise error.Abort(_(b'cannot amend with --subrepos'))
2032 2032 # Let --subrepos on the command line override config setting.
2033 2033 ui.setconfig(b'ui', b'commitsubrepos', True, b'commit')
2034 2034
2035 2035 cmdutil.checkunfinished(repo, commit=True)
2036 2036
2037 2037 branch = repo[None].branch()
2038 2038 bheads = repo.branchheads(branch)
2039 2039
2040 2040 extra = {}
2041 2041 if opts.get(b'close_branch') or opts.get(b'force_close_branch'):
2042 2042 extra[b'close'] = b'1'
2043 2043
2044 2044 if repo[b'.'].closesbranch():
2045 2045 raise error.Abort(
2046 2046 _(b'current revision is already a branch closing head')
2047 2047 )
2048 2048 elif not bheads:
2049 2049 raise error.Abort(_(b'branch "%s" has no heads to close') % branch)
2050 2050 elif (
2051 2051 branch == repo[b'.'].branch()
2052 2052 and repo[b'.'].node() not in bheads
2053 2053 and not opts.get(b'force_close_branch')
2054 2054 ):
2055 2055 hint = _(
2056 2056 b'use --force-close-branch to close branch from a non-head'
2057 2057 b' changeset'
2058 2058 )
2059 2059 raise error.Abort(_(b'can only close branch heads'), hint=hint)
2060 2060 elif opts.get(b'amend'):
2061 2061 if (
2062 2062 repo[b'.'].p1().branch() != branch
2063 2063 and repo[b'.'].p2().branch() != branch
2064 2064 ):
2065 2065 raise error.Abort(_(b'can only close branch heads'))
2066 2066
2067 2067 if opts.get(b'amend'):
2068 2068 if ui.configbool(b'ui', b'commitsubrepos'):
2069 2069 raise error.Abort(_(b'cannot amend with ui.commitsubrepos enabled'))
2070 2070
2071 2071 old = repo[b'.']
2072 2072 rewriteutil.precheck(repo, [old.rev()], b'amend')
2073 2073
2074 2074 # Currently histedit gets confused if an amend happens while histedit
2075 2075 # is in progress. Since we have a checkunfinished command, we are
2076 2076 # temporarily honoring it.
2077 2077 #
2078 2078 # Note: eventually this guard will be removed. Please do not expect
2079 2079 # this behavior to remain.
2080 2080 if not obsolete.isenabled(repo, obsolete.createmarkersopt):
2081 2081 cmdutil.checkunfinished(repo)
2082 2082
2083 2083 node = cmdutil.amend(ui, repo, old, extra, pats, opts)
2084 2084 if node == old.node():
2085 2085 ui.status(_(b"nothing changed\n"))
2086 2086 return 1
2087 2087 else:
2088 2088
2089 2089 def commitfunc(ui, repo, message, match, opts):
2090 2090 overrides = {}
2091 2091 if opts.get(b'secret'):
2092 2092 overrides[(b'phases', b'new-commit')] = b'secret'
2093 2093
2094 2094 baseui = repo.baseui
2095 2095 with baseui.configoverride(overrides, b'commit'):
2096 2096 with ui.configoverride(overrides, b'commit'):
2097 2097 editform = cmdutil.mergeeditform(
2098 2098 repo[None], b'commit.normal'
2099 2099 )
2100 2100 editor = cmdutil.getcommiteditor(
2101 2101 editform=editform, **pycompat.strkwargs(opts)
2102 2102 )
2103 2103 return repo.commit(
2104 2104 message,
2105 2105 opts.get(b'user'),
2106 2106 opts.get(b'date'),
2107 2107 match,
2108 2108 editor=editor,
2109 2109 extra=extra,
2110 2110 )
2111 2111
2112 2112 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
2113 2113
2114 2114 if not node:
2115 2115 stat = cmdutil.postcommitstatus(repo, pats, opts)
2116 2116 if stat.deleted:
2117 2117 ui.status(
2118 2118 _(
2119 2119 b"nothing changed (%d missing files, see "
2120 2120 b"'hg status')\n"
2121 2121 )
2122 2122 % len(stat.deleted)
2123 2123 )
2124 2124 else:
2125 2125 ui.status(_(b"nothing changed\n"))
2126 2126 return 1
2127 2127
2128 2128 cmdutil.commitstatus(repo, node, branch, bheads, opts)
2129 2129
2130 2130 if not ui.quiet and ui.configbool(b'commands', b'commit.post-status'):
2131 2131 status(
2132 2132 ui,
2133 2133 repo,
2134 2134 modified=True,
2135 2135 added=True,
2136 2136 removed=True,
2137 2137 deleted=True,
2138 2138 unknown=True,
2139 2139 subrepos=opts.get(b'subrepos'),
2140 2140 )
2141 2141
2142 2142
2143 2143 @command(
2144 2144 b'config|showconfig|debugconfig',
2145 2145 [
2146 2146 (b'u', b'untrusted', None, _(b'show untrusted configuration options')),
2147 2147 (b'e', b'edit', None, _(b'edit user config')),
2148 2148 (b'l', b'local', None, _(b'edit repository config')),
2149 2149 (b'g', b'global', None, _(b'edit global config')),
2150 2150 ]
2151 2151 + formatteropts,
2152 2152 _(b'[-u] [NAME]...'),
2153 2153 helpcategory=command.CATEGORY_HELP,
2154 2154 optionalrepo=True,
2155 2155 intents={INTENT_READONLY},
2156 2156 )
2157 2157 def config(ui, repo, *values, **opts):
2158 2158 """show combined config settings from all hgrc files
2159 2159
2160 2160 With no arguments, print names and values of all config items.
2161 2161
2162 2162 With one argument of the form section.name, print just the value
2163 2163 of that config item.
2164 2164
2165 2165 With multiple arguments, print names and values of all config
2166 2166 items with matching section names or section.names.
2167 2167
2168 2168 With --edit, start an editor on the user-level config file. With
2169 2169 --global, edit the system-wide config file. With --local, edit the
2170 2170 repository-level config file.
2171 2171
2172 2172 With --debug, the source (filename and line number) is printed
2173 2173 for each config item.
2174 2174
2175 2175 See :hg:`help config` for more information about config files.
2176 2176
2177 2177 .. container:: verbose
2178 2178
2179 2179 Template:
2180 2180
2181 2181 The following keywords are supported. See also :hg:`help templates`.
2182 2182
2183 2183 :name: String. Config name.
2184 2184 :source: String. Filename and line number where the item is defined.
2185 2185 :value: String. Config value.
2186 2186
2187 2187 Returns 0 on success, 1 if NAME does not exist.
2188 2188
2189 2189 """
2190 2190
2191 2191 opts = pycompat.byteskwargs(opts)
2192 2192 if opts.get(b'edit') or opts.get(b'local') or opts.get(b'global'):
2193 2193 if opts.get(b'local') and opts.get(b'global'):
2194 2194 raise error.Abort(_(b"can't use --local and --global together"))
2195 2195
2196 2196 if opts.get(b'local'):
2197 2197 if not repo:
2198 2198 raise error.Abort(_(b"can't use --local outside a repository"))
2199 2199 paths = [repo.vfs.join(b'hgrc')]
2200 2200 elif opts.get(b'global'):
2201 2201 paths = rcutil.systemrcpath()
2202 2202 else:
2203 2203 paths = rcutil.userrcpath()
2204 2204
2205 2205 for f in paths:
2206 2206 if os.path.exists(f):
2207 2207 break
2208 2208 else:
2209 2209 if opts.get(b'global'):
2210 2210 samplehgrc = uimod.samplehgrcs[b'global']
2211 2211 elif opts.get(b'local'):
2212 2212 samplehgrc = uimod.samplehgrcs[b'local']
2213 2213 else:
2214 2214 samplehgrc = uimod.samplehgrcs[b'user']
2215 2215
2216 2216 f = paths[0]
2217 2217 fp = open(f, b"wb")
2218 2218 fp.write(util.tonativeeol(samplehgrc))
2219 2219 fp.close()
2220 2220
2221 2221 editor = ui.geteditor()
2222 2222 ui.system(
2223 2223 b"%s \"%s\"" % (editor, f),
2224 2224 onerr=error.Abort,
2225 2225 errprefix=_(b"edit failed"),
2226 2226 blockedtag=b'config_edit',
2227 2227 )
2228 2228 return
2229 2229 ui.pager(b'config')
2230 2230 fm = ui.formatter(b'config', opts)
2231 2231 for t, f in rcutil.rccomponents():
2232 2232 if t == b'path':
2233 2233 ui.debug(b'read config from: %s\n' % f)
2234 2234 elif t == b'items':
2235 2235 for section, name, value, source in f:
2236 2236 ui.debug(b'set config by: %s\n' % source)
2237 2237 else:
2238 2238 raise error.ProgrammingError(b'unknown rctype: %s' % t)
2239 2239 untrusted = bool(opts.get(b'untrusted'))
2240 2240
2241 2241 selsections = selentries = []
2242 2242 if values:
2243 2243 selsections = [v for v in values if b'.' not in v]
2244 2244 selentries = [v for v in values if b'.' in v]
2245 2245 uniquesel = len(selentries) == 1 and not selsections
2246 2246 selsections = set(selsections)
2247 2247 selentries = set(selentries)
2248 2248
2249 2249 matched = False
2250 2250 for section, name, value in ui.walkconfig(untrusted=untrusted):
2251 2251 source = ui.configsource(section, name, untrusted)
2252 2252 value = pycompat.bytestr(value)
2253 2253 defaultvalue = ui.configdefault(section, name)
2254 2254 if fm.isplain():
2255 2255 source = source or b'none'
2256 2256 value = value.replace(b'\n', b'\\n')
2257 2257 entryname = section + b'.' + name
2258 2258 if values and not (section in selsections or entryname in selentries):
2259 2259 continue
2260 2260 fm.startitem()
2261 2261 fm.condwrite(ui.debugflag, b'source', b'%s: ', source)
2262 2262 if uniquesel:
2263 2263 fm.data(name=entryname)
2264 2264 fm.write(b'value', b'%s\n', value)
2265 2265 else:
2266 2266 fm.write(b'name value', b'%s=%s\n', entryname, value)
2267 2267 if formatter.isprintable(defaultvalue):
2268 2268 fm.data(defaultvalue=defaultvalue)
2269 2269 elif isinstance(defaultvalue, list) and all(
2270 2270 formatter.isprintable(e) for e in defaultvalue
2271 2271 ):
2272 2272 fm.data(defaultvalue=fm.formatlist(defaultvalue, name=b'value'))
2273 2273 # TODO: no idea how to process unsupported defaultvalue types
2274 2274 matched = True
2275 2275 fm.end()
2276 2276 if matched:
2277 2277 return 0
2278 2278 return 1
2279 2279
2280 2280
2281 2281 @command(
2282 2282 b'continue',
2283 2283 dryrunopts,
2284 2284 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
2285 2285 helpbasic=True,
2286 2286 )
2287 2287 def continuecmd(ui, repo, **opts):
2288 2288 """resumes an interrupted operation (EXPERIMENTAL)
2289 2289
2290 2290 Finishes a multistep operation like graft, histedit, rebase, merge,
2291 2291 and unshelve if they are in an interrupted state.
2292 2292
2293 2293 use --dry-run/-n to dry run the command.
2294 2294 """
2295 2295 dryrun = opts.get('dry_run')
2296 2296 contstate = cmdutil.getunfinishedstate(repo)
2297 2297 if not contstate:
2298 2298 raise error.Abort(_(b'no operation in progress'))
2299 2299 if not contstate.continuefunc:
2300 2300 raise error.Abort(
2301 2301 (
2302 2302 _(b"%s in progress but does not support 'hg continue'")
2303 2303 % (contstate._opname)
2304 2304 ),
2305 2305 hint=contstate.continuemsg(),
2306 2306 )
2307 2307 if dryrun:
2308 2308 ui.status(_(b'%s in progress, will be resumed\n') % (contstate._opname))
2309 2309 return
2310 2310 return contstate.continuefunc(ui, repo)
2311 2311
2312 2312
2313 2313 @command(
2314 2314 b'copy|cp',
2315 2315 [
2316 2316 (b'A', b'after', None, _(b'record a copy that has already occurred')),
2317 2317 (
2318 2318 b'f',
2319 2319 b'force',
2320 2320 None,
2321 2321 _(b'forcibly copy over an existing managed file'),
2322 2322 ),
2323 2323 ]
2324 2324 + walkopts
2325 2325 + dryrunopts,
2326 2326 _(b'[OPTION]... SOURCE... DEST'),
2327 2327 helpcategory=command.CATEGORY_FILE_CONTENTS,
2328 2328 )
2329 2329 def copy(ui, repo, *pats, **opts):
2330 2330 """mark files as copied for the next commit
2331 2331
2332 2332 Mark dest as having copies of source files. If dest is a
2333 2333 directory, copies are put in that directory. If dest is a file,
2334 2334 the source must be a single file.
2335 2335
2336 2336 By default, this command copies the contents of files as they
2337 2337 exist in the working directory. If invoked with -A/--after, the
2338 2338 operation is recorded, but no copying is performed.
2339 2339
2340 2340 This command takes effect with the next commit. To undo a copy
2341 2341 before that, see :hg:`revert`.
2342 2342
2343 2343 Returns 0 on success, 1 if errors are encountered.
2344 2344 """
2345 2345 opts = pycompat.byteskwargs(opts)
2346 2346 with repo.wlock(False):
2347 2347 return cmdutil.copy(ui, repo, pats, opts)
2348 2348
2349 2349
2350 2350 @command(
2351 2351 b'debugcommands',
2352 2352 [],
2353 2353 _(b'[COMMAND]'),
2354 2354 helpcategory=command.CATEGORY_HELP,
2355 2355 norepo=True,
2356 2356 )
2357 2357 def debugcommands(ui, cmd=b'', *args):
2358 2358 """list all available commands and options"""
2359 2359 for cmd, vals in sorted(pycompat.iteritems(table)):
2360 2360 cmd = cmd.split(b'|')[0]
2361 2361 opts = b', '.join([i[1] for i in vals[1]])
2362 2362 ui.write(b'%s: %s\n' % (cmd, opts))
2363 2363
2364 2364
2365 2365 @command(
2366 2366 b'debugcomplete',
2367 2367 [(b'o', b'options', None, _(b'show the command options'))],
2368 2368 _(b'[-o] CMD'),
2369 2369 helpcategory=command.CATEGORY_HELP,
2370 2370 norepo=True,
2371 2371 )
2372 2372 def debugcomplete(ui, cmd=b'', **opts):
2373 2373 """returns the completion list associated with the given command"""
2374 2374
2375 2375 if opts.get('options'):
2376 2376 options = []
2377 2377 otables = [globalopts]
2378 2378 if cmd:
2379 2379 aliases, entry = cmdutil.findcmd(cmd, table, False)
2380 2380 otables.append(entry[1])
2381 2381 for t in otables:
2382 2382 for o in t:
2383 2383 if b"(DEPRECATED)" in o[3]:
2384 2384 continue
2385 2385 if o[0]:
2386 2386 options.append(b'-%s' % o[0])
2387 2387 options.append(b'--%s' % o[1])
2388 2388 ui.write(b"%s\n" % b"\n".join(options))
2389 2389 return
2390 2390
2391 2391 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
2392 2392 if ui.verbose:
2393 2393 cmdlist = [b' '.join(c[0]) for c in cmdlist.values()]
2394 2394 ui.write(b"%s\n" % b"\n".join(sorted(cmdlist)))
2395 2395
2396 2396
2397 2397 @command(
2398 2398 b'diff',
2399 2399 [
2400 2400 (b'r', b'rev', [], _(b'revision'), _(b'REV')),
2401 2401 (b'c', b'change', b'', _(b'change made by revision'), _(b'REV')),
2402 2402 ]
2403 2403 + diffopts
2404 2404 + diffopts2
2405 2405 + walkopts
2406 2406 + subrepoopts,
2407 2407 _(b'[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
2408 2408 helpcategory=command.CATEGORY_FILE_CONTENTS,
2409 2409 helpbasic=True,
2410 2410 inferrepo=True,
2411 2411 intents={INTENT_READONLY},
2412 2412 )
2413 2413 def diff(ui, repo, *pats, **opts):
2414 2414 """diff repository (or selected files)
2415 2415
2416 2416 Show differences between revisions for the specified files.
2417 2417
2418 2418 Differences between files are shown using the unified diff format.
2419 2419
2420 2420 .. note::
2421 2421
2422 2422 :hg:`diff` may generate unexpected results for merges, as it will
2423 2423 default to comparing against the working directory's first
2424 2424 parent changeset if no revisions are specified.
2425 2425
2426 2426 When two revision arguments are given, then changes are shown
2427 2427 between those revisions. If only one revision is specified then
2428 2428 that revision is compared to the working directory, and, when no
2429 2429 revisions are specified, the working directory files are compared
2430 2430 to its first parent.
2431 2431
2432 2432 Alternatively you can specify -c/--change with a revision to see
2433 2433 the changes in that changeset relative to its first parent.
2434 2434
2435 2435 Without the -a/--text option, diff will avoid generating diffs of
2436 2436 files it detects as binary. With -a, diff will generate a diff
2437 2437 anyway, probably with undesirable results.
2438 2438
2439 2439 Use the -g/--git option to generate diffs in the git extended diff
2440 2440 format. For more information, read :hg:`help diffs`.
2441 2441
2442 2442 .. container:: verbose
2443 2443
2444 2444 Examples:
2445 2445
2446 2446 - compare a file in the current working directory to its parent::
2447 2447
2448 2448 hg diff foo.c
2449 2449
2450 2450 - compare two historical versions of a directory, with rename info::
2451 2451
2452 2452 hg diff --git -r 1.0:1.2 lib/
2453 2453
2454 2454 - get change stats relative to the last change on some date::
2455 2455
2456 2456 hg diff --stat -r "date('may 2')"
2457 2457
2458 2458 - diff all newly-added files that contain a keyword::
2459 2459
2460 2460 hg diff "set:added() and grep(GNU)"
2461 2461
2462 2462 - compare a revision and its parents::
2463 2463
2464 2464 hg diff -c 9353 # compare against first parent
2465 2465 hg diff -r 9353^:9353 # same using revset syntax
2466 2466 hg diff -r 9353^2:9353 # compare against the second parent
2467 2467
2468 2468 Returns 0 on success.
2469 2469 """
2470 2470
2471 2471 opts = pycompat.byteskwargs(opts)
2472 2472 revs = opts.get(b'rev')
2473 2473 change = opts.get(b'change')
2474 2474 stat = opts.get(b'stat')
2475 2475 reverse = opts.get(b'reverse')
2476 2476
2477 2477 if revs and change:
2478 2478 msg = _(b'cannot specify --rev and --change at the same time')
2479 2479 raise error.Abort(msg)
2480 2480 elif change:
2481 2481 repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
2482 2482 ctx2 = scmutil.revsingle(repo, change, None)
2483 2483 ctx1 = ctx2.p1()
2484 2484 else:
2485 2485 repo = scmutil.unhidehashlikerevs(repo, revs, b'nowarn')
2486 2486 ctx1, ctx2 = scmutil.revpair(repo, revs)
2487 2487 node1, node2 = ctx1.node(), ctx2.node()
2488 2488
2489 2489 if reverse:
2490 2490 node1, node2 = node2, node1
2491 2491
2492 2492 diffopts = patch.diffallopts(ui, opts)
2493 2493 m = scmutil.match(ctx2, pats, opts)
2494 2494 m = repo.narrowmatch(m)
2495 2495 ui.pager(b'diff')
2496 2496 logcmdutil.diffordiffstat(
2497 2497 ui,
2498 2498 repo,
2499 2499 diffopts,
2500 2500 node1,
2501 2501 node2,
2502 2502 m,
2503 2503 stat=stat,
2504 2504 listsubrepos=opts.get(b'subrepos'),
2505 2505 root=opts.get(b'root'),
2506 2506 )
2507 2507
2508 2508
2509 2509 @command(
2510 2510 b'export',
2511 2511 [
2512 2512 (
2513 2513 b'B',
2514 2514 b'bookmark',
2515 2515 b'',
2516 2516 _(b'export changes only reachable by given bookmark'),
2517 2517 _(b'BOOKMARK'),
2518 2518 ),
2519 2519 (
2520 2520 b'o',
2521 2521 b'output',
2522 2522 b'',
2523 2523 _(b'print output to file with formatted name'),
2524 2524 _(b'FORMAT'),
2525 2525 ),
2526 2526 (b'', b'switch-parent', None, _(b'diff against the second parent')),
2527 2527 (b'r', b'rev', [], _(b'revisions to export'), _(b'REV')),
2528 2528 ]
2529 2529 + diffopts
2530 2530 + formatteropts,
2531 2531 _(b'[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'),
2532 2532 helpcategory=command.CATEGORY_IMPORT_EXPORT,
2533 2533 helpbasic=True,
2534 2534 intents={INTENT_READONLY},
2535 2535 )
2536 2536 def export(ui, repo, *changesets, **opts):
2537 2537 """dump the header and diffs for one or more changesets
2538 2538
2539 2539 Print the changeset header and diffs for one or more revisions.
2540 2540 If no revision is given, the parent of the working directory is used.
2541 2541
2542 2542 The information shown in the changeset header is: author, date,
2543 2543 branch name (if non-default), changeset hash, parent(s) and commit
2544 2544 comment.
2545 2545
2546 2546 .. note::
2547 2547
2548 2548 :hg:`export` may generate unexpected diff output for merge
2549 2549 changesets, as it will compare the merge changeset against its
2550 2550 first parent only.
2551 2551
2552 2552 Output may be to a file, in which case the name of the file is
2553 2553 given using a template string. See :hg:`help templates`. In addition
2554 2554 to the common template keywords, the following formatting rules are
2555 2555 supported:
2556 2556
2557 2557 :``%%``: literal "%" character
2558 2558 :``%H``: changeset hash (40 hexadecimal digits)
2559 2559 :``%N``: number of patches being generated
2560 2560 :``%R``: changeset revision number
2561 2561 :``%b``: basename of the exporting repository
2562 2562 :``%h``: short-form changeset hash (12 hexadecimal digits)
2563 2563 :``%m``: first line of the commit message (only alphanumeric characters)
2564 2564 :``%n``: zero-padded sequence number, starting at 1
2565 2565 :``%r``: zero-padded changeset revision number
2566 2566 :``\\``: literal "\\" character
2567 2567
2568 2568 Without the -a/--text option, export will avoid generating diffs
2569 2569 of files it detects as binary. With -a, export will generate a
2570 2570 diff anyway, probably with undesirable results.
2571 2571
2572 2572 With -B/--bookmark changesets reachable by the given bookmark are
2573 2573 selected.
2574 2574
2575 2575 Use the -g/--git option to generate diffs in the git extended diff
2576 2576 format. See :hg:`help diffs` for more information.
2577 2577
2578 2578 With the --switch-parent option, the diff will be against the
2579 2579 second parent. It can be useful to review a merge.
2580 2580
2581 2581 .. container:: verbose
2582 2582
2583 2583 Template:
2584 2584
2585 2585 The following keywords are supported in addition to the common template
2586 2586 keywords and functions. See also :hg:`help templates`.
2587 2587
2588 2588 :diff: String. Diff content.
2589 2589 :parents: List of strings. Parent nodes of the changeset.
2590 2590
2591 2591 Examples:
2592 2592
2593 2593 - use export and import to transplant a bugfix to the current
2594 2594 branch::
2595 2595
2596 2596 hg export -r 9353 | hg import -
2597 2597
2598 2598 - export all the changesets between two revisions to a file with
2599 2599 rename information::
2600 2600
2601 2601 hg export --git -r 123:150 > changes.txt
2602 2602
2603 2603 - split outgoing changes into a series of patches with
2604 2604 descriptive names::
2605 2605
2606 2606 hg export -r "outgoing()" -o "%n-%m.patch"
2607 2607
2608 2608 Returns 0 on success.
2609 2609 """
2610 2610 opts = pycompat.byteskwargs(opts)
2611 2611 bookmark = opts.get(b'bookmark')
2612 2612 changesets += tuple(opts.get(b'rev', []))
2613 2613
2614 2614 if bookmark and changesets:
2615 2615 raise error.Abort(_(b"-r and -B are mutually exclusive"))
2616 2616
2617 2617 if bookmark:
2618 2618 if bookmark not in repo._bookmarks:
2619 2619 raise error.Abort(_(b"bookmark '%s' not found") % bookmark)
2620 2620
2621 2621 revs = scmutil.bookmarkrevs(repo, bookmark)
2622 2622 else:
2623 2623 if not changesets:
2624 2624 changesets = [b'.']
2625 2625
2626 2626 repo = scmutil.unhidehashlikerevs(repo, changesets, b'nowarn')
2627 2627 revs = scmutil.revrange(repo, changesets)
2628 2628
2629 2629 if not revs:
2630 2630 raise error.Abort(_(b"export requires at least one changeset"))
2631 2631 if len(revs) > 1:
2632 2632 ui.note(_(b'exporting patches:\n'))
2633 2633 else:
2634 2634 ui.note(_(b'exporting patch:\n'))
2635 2635
2636 2636 fntemplate = opts.get(b'output')
2637 2637 if cmdutil.isstdiofilename(fntemplate):
2638 2638 fntemplate = b''
2639 2639
2640 2640 if fntemplate:
2641 2641 fm = formatter.nullformatter(ui, b'export', opts)
2642 2642 else:
2643 2643 ui.pager(b'export')
2644 2644 fm = ui.formatter(b'export', opts)
2645 2645 with fm:
2646 2646 cmdutil.export(
2647 2647 repo,
2648 2648 revs,
2649 2649 fm,
2650 2650 fntemplate=fntemplate,
2651 2651 switch_parent=opts.get(b'switch_parent'),
2652 2652 opts=patch.diffallopts(ui, opts),
2653 2653 )
2654 2654
2655 2655
2656 2656 @command(
2657 2657 b'files',
2658 2658 [
2659 2659 (
2660 2660 b'r',
2661 2661 b'rev',
2662 2662 b'',
2663 2663 _(b'search the repository as it is in REV'),
2664 2664 _(b'REV'),
2665 2665 ),
2666 2666 (
2667 2667 b'0',
2668 2668 b'print0',
2669 2669 None,
2670 2670 _(b'end filenames with NUL, for use with xargs'),
2671 2671 ),
2672 2672 ]
2673 2673 + walkopts
2674 2674 + formatteropts
2675 2675 + subrepoopts,
2676 2676 _(b'[OPTION]... [FILE]...'),
2677 2677 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
2678 2678 intents={INTENT_READONLY},
2679 2679 )
2680 2680 def files(ui, repo, *pats, **opts):
2681 2681 """list tracked files
2682 2682
2683 2683 Print files under Mercurial control in the working directory or
2684 2684 specified revision for given files (excluding removed files).
2685 2685 Files can be specified as filenames or filesets.
2686 2686
2687 2687 If no files are given to match, this command prints the names
2688 2688 of all files under Mercurial control.
2689 2689
2690 2690 .. container:: verbose
2691 2691
2692 2692 Template:
2693 2693
2694 2694 The following keywords are supported in addition to the common template
2695 2695 keywords and functions. See also :hg:`help templates`.
2696 2696
2697 2697 :flags: String. Character denoting file's symlink and executable bits.
2698 2698 :path: String. Repository-absolute path of the file.
2699 2699 :size: Integer. Size of the file in bytes.
2700 2700
2701 2701 Examples:
2702 2702
2703 2703 - list all files under the current directory::
2704 2704
2705 2705 hg files .
2706 2706
2707 2707 - shows sizes and flags for current revision::
2708 2708
2709 2709 hg files -vr .
2710 2710
2711 2711 - list all files named README::
2712 2712
2713 2713 hg files -I "**/README"
2714 2714
2715 2715 - list all binary files::
2716 2716
2717 2717 hg files "set:binary()"
2718 2718
2719 2719 - find files containing a regular expression::
2720 2720
2721 2721 hg files "set:grep('bob')"
2722 2722
2723 2723 - search tracked file contents with xargs and grep::
2724 2724
2725 2725 hg files -0 | xargs -0 grep foo
2726 2726
2727 2727 See :hg:`help patterns` and :hg:`help filesets` for more information
2728 2728 on specifying file patterns.
2729 2729
2730 2730 Returns 0 if a match is found, 1 otherwise.
2731 2731
2732 2732 """
2733 2733
2734 2734 opts = pycompat.byteskwargs(opts)
2735 2735 rev = opts.get(b'rev')
2736 2736 if rev:
2737 2737 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
2738 2738 ctx = scmutil.revsingle(repo, rev, None)
2739 2739
2740 2740 end = b'\n'
2741 2741 if opts.get(b'print0'):
2742 2742 end = b'\0'
2743 2743 fmt = b'%s' + end
2744 2744
2745 2745 m = scmutil.match(ctx, pats, opts)
2746 2746 ui.pager(b'files')
2747 2747 uipathfn = scmutil.getuipathfn(ctx.repo(), legacyrelativevalue=True)
2748 2748 with ui.formatter(b'files', opts) as fm:
2749 2749 return cmdutil.files(
2750 2750 ui, ctx, m, uipathfn, fm, fmt, opts.get(b'subrepos')
2751 2751 )
2752 2752
2753 2753
2754 2754 @command(
2755 2755 b'forget',
2756 2756 [(b'i', b'interactive', None, _(b'use interactive mode')),]
2757 2757 + walkopts
2758 2758 + dryrunopts,
2759 2759 _(b'[OPTION]... FILE...'),
2760 2760 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
2761 2761 helpbasic=True,
2762 2762 inferrepo=True,
2763 2763 )
2764 2764 def forget(ui, repo, *pats, **opts):
2765 2765 """forget the specified files on the next commit
2766 2766
2767 2767 Mark the specified files so they will no longer be tracked
2768 2768 after the next commit.
2769 2769
2770 2770 This only removes files from the current branch, not from the
2771 2771 entire project history, and it does not delete them from the
2772 2772 working directory.
2773 2773
2774 2774 To delete the file from the working directory, see :hg:`remove`.
2775 2775
2776 2776 To undo a forget before the next commit, see :hg:`add`.
2777 2777
2778 2778 .. container:: verbose
2779 2779
2780 2780 Examples:
2781 2781
2782 2782 - forget newly-added binary files::
2783 2783
2784 2784 hg forget "set:added() and binary()"
2785 2785
2786 2786 - forget files that would be excluded by .hgignore::
2787 2787
2788 2788 hg forget "set:hgignore()"
2789 2789
2790 2790 Returns 0 on success.
2791 2791 """
2792 2792
2793 2793 opts = pycompat.byteskwargs(opts)
2794 2794 if not pats:
2795 2795 raise error.Abort(_(b'no files specified'))
2796 2796
2797 2797 m = scmutil.match(repo[None], pats, opts)
2798 2798 dryrun, interactive = opts.get(b'dry_run'), opts.get(b'interactive')
2799 2799 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
2800 2800 rejected = cmdutil.forget(
2801 2801 ui,
2802 2802 repo,
2803 2803 m,
2804 2804 prefix=b"",
2805 2805 uipathfn=uipathfn,
2806 2806 explicitonly=False,
2807 2807 dryrun=dryrun,
2808 2808 interactive=interactive,
2809 2809 )[0]
2810 2810 return rejected and 1 or 0
2811 2811
2812 2812
2813 2813 @command(
2814 2814 b'graft',
2815 2815 [
2816 2816 (b'r', b'rev', [], _(b'revisions to graft'), _(b'REV')),
2817 2817 (
2818 2818 b'',
2819 2819 b'base',
2820 2820 b'',
2821 2821 _(b'base revision when doing the graft merge (ADVANCED)'),
2822 2822 _(b'REV'),
2823 2823 ),
2824 2824 (b'c', b'continue', False, _(b'resume interrupted graft')),
2825 2825 (b'', b'stop', False, _(b'stop interrupted graft')),
2826 2826 (b'', b'abort', False, _(b'abort interrupted graft')),
2827 2827 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
2828 2828 (b'', b'log', None, _(b'append graft info to log message')),
2829 2829 (
2830 2830 b'',
2831 2831 b'no-commit',
2832 2832 None,
2833 2833 _(b"don't commit, just apply the changes in working directory"),
2834 2834 ),
2835 2835 (b'f', b'force', False, _(b'force graft')),
2836 2836 (
2837 2837 b'D',
2838 2838 b'currentdate',
2839 2839 False,
2840 2840 _(b'record the current date as commit date'),
2841 2841 ),
2842 2842 (
2843 2843 b'U',
2844 2844 b'currentuser',
2845 2845 False,
2846 2846 _(b'record the current user as committer'),
2847 2847 ),
2848 2848 ]
2849 2849 + commitopts2
2850 2850 + mergetoolopts
2851 2851 + dryrunopts,
2852 2852 _(b'[OPTION]... [-r REV]... REV...'),
2853 2853 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
2854 2854 )
2855 2855 def graft(ui, repo, *revs, **opts):
2856 2856 '''copy changes from other branches onto the current branch
2857 2857
2858 2858 This command uses Mercurial's merge logic to copy individual
2859 2859 changes from other branches without merging branches in the
2860 2860 history graph. This is sometimes known as 'backporting' or
2861 2861 'cherry-picking'. By default, graft will copy user, date, and
2862 2862 description from the source changesets.
2863 2863
2864 2864 Changesets that are ancestors of the current revision, that have
2865 2865 already been grafted, or that are merges will be skipped.
2866 2866
2867 2867 If --log is specified, log messages will have a comment appended
2868 2868 of the form::
2869 2869
2870 2870 (grafted from CHANGESETHASH)
2871 2871
2872 2872 If --force is specified, revisions will be grafted even if they
2873 2873 are already ancestors of, or have been grafted to, the destination.
2874 2874 This is useful when the revisions have since been backed out.
2875 2875
2876 2876 If a graft merge results in conflicts, the graft process is
2877 2877 interrupted so that the current merge can be manually resolved.
2878 2878 Once all conflicts are addressed, the graft process can be
2879 2879 continued with the -c/--continue option.
2880 2880
2881 2881 The -c/--continue option reapplies all the earlier options.
2882 2882
2883 2883 .. container:: verbose
2884 2884
2885 2885 The --base option exposes more of how graft internally uses merge with a
2886 2886 custom base revision. --base can be used to specify another ancestor than
2887 2887 the first and only parent.
2888 2888
2889 2889 The command::
2890 2890
2891 2891 hg graft -r 345 --base 234
2892 2892
2893 2893 is thus pretty much the same as::
2894 2894
2895 2895 hg diff -r 234 -r 345 | hg import
2896 2896
2897 2897 but using merge to resolve conflicts and track moved files.
2898 2898
2899 2899 The result of a merge can thus be backported as a single commit by
2900 2900 specifying one of the merge parents as base, and thus effectively
2901 2901 grafting the changes from the other side.
2902 2902
2903 2903 It is also possible to collapse multiple changesets and clean up history
2904 2904 by specifying another ancestor as base, much like rebase --collapse
2905 2905 --keep.
2906 2906
2907 2907 The commit message can be tweaked after the fact using commit --amend .
2908 2908
2909 2909 For using non-ancestors as the base to backout changes, see the backout
2910 2910 command and the hidden --parent option.
2911 2911
2912 2912 .. container:: verbose
2913 2913
2914 2914 Examples:
2915 2915
2916 2916 - copy a single change to the stable branch and edit its description::
2917 2917
2918 2918 hg update stable
2919 2919 hg graft --edit 9393
2920 2920
2921 2921 - graft a range of changesets with one exception, updating dates::
2922 2922
2923 2923 hg graft -D "2085::2093 and not 2091"
2924 2924
2925 2925 - continue a graft after resolving conflicts::
2926 2926
2927 2927 hg graft -c
2928 2928
2929 2929 - show the source of a grafted changeset::
2930 2930
2931 2931 hg log --debug -r .
2932 2932
2933 2933 - show revisions sorted by date::
2934 2934
2935 2935 hg log -r "sort(all(), date)"
2936 2936
2937 2937 - backport the result of a merge as a single commit::
2938 2938
2939 2939 hg graft -r 123 --base 123^
2940 2940
2941 2941 - land a feature branch as one changeset::
2942 2942
2943 2943 hg up -cr default
2944 2944 hg graft -r featureX --base "ancestor('featureX', 'default')"
2945 2945
2946 2946 See :hg:`help revisions` for more about specifying revisions.
2947 2947
2948 2948 Returns 0 on successful completion.
2949 2949 '''
2950 2950 with repo.wlock():
2951 2951 return _dograft(ui, repo, *revs, **opts)
2952 2952
2953 2953
2954 2954 def _dograft(ui, repo, *revs, **opts):
2955 2955 opts = pycompat.byteskwargs(opts)
2956 2956 if revs and opts.get(b'rev'):
2957 2957 ui.warn(
2958 2958 _(
2959 2959 b'warning: inconsistent use of --rev might give unexpected '
2960 2960 b'revision ordering!\n'
2961 2961 )
2962 2962 )
2963 2963
2964 2964 revs = list(revs)
2965 2965 revs.extend(opts.get(b'rev'))
2966 2966 basectx = None
2967 2967 if opts.get(b'base'):
2968 2968 basectx = scmutil.revsingle(repo, opts[b'base'], None)
2969 2969 # a dict of data to be stored in state file
2970 2970 statedata = {}
2971 2971 # list of new nodes created by ongoing graft
2972 2972 statedata[b'newnodes'] = []
2973 2973
2974 2974 if opts.get(b'user') and opts.get(b'currentuser'):
2975 2975 raise error.Abort(_(b'--user and --currentuser are mutually exclusive'))
2976 2976 if opts.get(b'date') and opts.get(b'currentdate'):
2977 2977 raise error.Abort(_(b'--date and --currentdate are mutually exclusive'))
2978 2978 if not opts.get(b'user') and opts.get(b'currentuser'):
2979 2979 opts[b'user'] = ui.username()
2980 2980 if not opts.get(b'date') and opts.get(b'currentdate'):
2981 2981 opts[b'date'] = b"%d %d" % dateutil.makedate()
2982 2982
2983 2983 editor = cmdutil.getcommiteditor(
2984 2984 editform=b'graft', **pycompat.strkwargs(opts)
2985 2985 )
2986 2986
2987 2987 cont = False
2988 2988 if opts.get(b'no_commit'):
2989 2989 if opts.get(b'edit'):
2990 2990 raise error.Abort(
2991 2991 _(b"cannot specify --no-commit and --edit together")
2992 2992 )
2993 2993 if opts.get(b'currentuser'):
2994 2994 raise error.Abort(
2995 2995 _(b"cannot specify --no-commit and --currentuser together")
2996 2996 )
2997 2997 if opts.get(b'currentdate'):
2998 2998 raise error.Abort(
2999 2999 _(b"cannot specify --no-commit and --currentdate together")
3000 3000 )
3001 3001 if opts.get(b'log'):
3002 3002 raise error.Abort(
3003 3003 _(b"cannot specify --no-commit and --log together")
3004 3004 )
3005 3005
3006 3006 graftstate = statemod.cmdstate(repo, b'graftstate')
3007 3007
3008 3008 if opts.get(b'stop'):
3009 3009 if opts.get(b'continue'):
3010 3010 raise error.Abort(
3011 3011 _(b"cannot use '--continue' and '--stop' together")
3012 3012 )
3013 3013 if opts.get(b'abort'):
3014 3014 raise error.Abort(_(b"cannot use '--abort' and '--stop' together"))
3015 3015
3016 3016 if any(
3017 3017 (
3018 3018 opts.get(b'edit'),
3019 3019 opts.get(b'log'),
3020 3020 opts.get(b'user'),
3021 3021 opts.get(b'date'),
3022 3022 opts.get(b'currentdate'),
3023 3023 opts.get(b'currentuser'),
3024 3024 opts.get(b'rev'),
3025 3025 )
3026 3026 ):
3027 3027 raise error.Abort(_(b"cannot specify any other flag with '--stop'"))
3028 3028 return _stopgraft(ui, repo, graftstate)
3029 3029 elif opts.get(b'abort'):
3030 3030 if opts.get(b'continue'):
3031 3031 raise error.Abort(
3032 3032 _(b"cannot use '--continue' and '--abort' together")
3033 3033 )
3034 3034 if any(
3035 3035 (
3036 3036 opts.get(b'edit'),
3037 3037 opts.get(b'log'),
3038 3038 opts.get(b'user'),
3039 3039 opts.get(b'date'),
3040 3040 opts.get(b'currentdate'),
3041 3041 opts.get(b'currentuser'),
3042 3042 opts.get(b'rev'),
3043 3043 )
3044 3044 ):
3045 3045 raise error.Abort(
3046 3046 _(b"cannot specify any other flag with '--abort'")
3047 3047 )
3048 3048
3049 3049 return cmdutil.abortgraft(ui, repo, graftstate)
3050 3050 elif opts.get(b'continue'):
3051 3051 cont = True
3052 3052 if revs:
3053 3053 raise error.Abort(_(b"can't specify --continue and revisions"))
3054 3054 # read in unfinished revisions
3055 3055 if graftstate.exists():
3056 3056 statedata = cmdutil.readgraftstate(repo, graftstate)
3057 3057 if statedata.get(b'date'):
3058 3058 opts[b'date'] = statedata[b'date']
3059 3059 if statedata.get(b'user'):
3060 3060 opts[b'user'] = statedata[b'user']
3061 3061 if statedata.get(b'log'):
3062 3062 opts[b'log'] = True
3063 3063 if statedata.get(b'no_commit'):
3064 3064 opts[b'no_commit'] = statedata.get(b'no_commit')
3065 3065 nodes = statedata[b'nodes']
3066 3066 revs = [repo[node].rev() for node in nodes]
3067 3067 else:
3068 3068 cmdutil.wrongtooltocontinue(repo, _(b'graft'))
3069 3069 else:
3070 3070 if not revs:
3071 3071 raise error.Abort(_(b'no revisions specified'))
3072 3072 cmdutil.checkunfinished(repo)
3073 3073 cmdutil.bailifchanged(repo)
3074 3074 revs = scmutil.revrange(repo, revs)
3075 3075
3076 3076 skipped = set()
3077 3077 if basectx is None:
3078 3078 # check for merges
3079 3079 for rev in repo.revs(b'%ld and merge()', revs):
3080 3080 ui.warn(_(b'skipping ungraftable merge revision %d\n') % rev)
3081 3081 skipped.add(rev)
3082 3082 revs = [r for r in revs if r not in skipped]
3083 3083 if not revs:
3084 3084 return -1
3085 3085 if basectx is not None and len(revs) != 1:
3086 3086 raise error.Abort(_(b'only one revision allowed with --base '))
3087 3087
3088 3088 # Don't check in the --continue case, in effect retaining --force across
3089 3089 # --continues. That's because without --force, any revisions we decided to
3090 3090 # skip would have been filtered out here, so they wouldn't have made their
3091 3091 # way to the graftstate. With --force, any revisions we would have otherwise
3092 3092 # skipped would not have been filtered out, and if they hadn't been applied
3093 3093 # already, they'd have been in the graftstate.
3094 3094 if not (cont or opts.get(b'force')) and basectx is None:
3095 3095 # check for ancestors of dest branch
3096 3096 crev = repo[b'.'].rev()
3097 3097 ancestors = repo.changelog.ancestors([crev], inclusive=True)
3098 3098 # XXX make this lazy in the future
3099 3099 # don't mutate while iterating, create a copy
3100 3100 for rev in list(revs):
3101 3101 if rev in ancestors:
3102 3102 ui.warn(
3103 3103 _(b'skipping ancestor revision %d:%s\n') % (rev, repo[rev])
3104 3104 )
3105 3105 # XXX remove on list is slow
3106 3106 revs.remove(rev)
3107 3107 if not revs:
3108 3108 return -1
3109 3109
3110 3110 # analyze revs for earlier grafts
3111 3111 ids = {}
3112 3112 for ctx in repo.set(b"%ld", revs):
3113 3113 ids[ctx.hex()] = ctx.rev()
3114 3114 n = ctx.extra().get(b'source')
3115 3115 if n:
3116 3116 ids[n] = ctx.rev()
3117 3117
3118 3118 # check ancestors for earlier grafts
3119 3119 ui.debug(b'scanning for duplicate grafts\n')
3120 3120
3121 3121 # The only changesets we can be sure doesn't contain grafts of any
3122 3122 # revs, are the ones that are common ancestors of *all* revs:
3123 3123 for rev in repo.revs(b'only(%d,ancestor(%ld))', crev, revs):
3124 3124 ctx = repo[rev]
3125 3125 n = ctx.extra().get(b'source')
3126 3126 if n in ids:
3127 3127 try:
3128 3128 r = repo[n].rev()
3129 3129 except error.RepoLookupError:
3130 3130 r = None
3131 3131 if r in revs:
3132 3132 ui.warn(
3133 3133 _(
3134 3134 b'skipping revision %d:%s '
3135 3135 b'(already grafted to %d:%s)\n'
3136 3136 )
3137 3137 % (r, repo[r], rev, ctx)
3138 3138 )
3139 3139 revs.remove(r)
3140 3140 elif ids[n] in revs:
3141 3141 if r is None:
3142 3142 ui.warn(
3143 3143 _(
3144 3144 b'skipping already grafted revision %d:%s '
3145 3145 b'(%d:%s also has unknown origin %s)\n'
3146 3146 )
3147 3147 % (ids[n], repo[ids[n]], rev, ctx, n[:12])
3148 3148 )
3149 3149 else:
3150 3150 ui.warn(
3151 3151 _(
3152 3152 b'skipping already grafted revision %d:%s '
3153 3153 b'(%d:%s also has origin %d:%s)\n'
3154 3154 )
3155 3155 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12])
3156 3156 )
3157 3157 revs.remove(ids[n])
3158 3158 elif ctx.hex() in ids:
3159 3159 r = ids[ctx.hex()]
3160 3160 if r in revs:
3161 3161 ui.warn(
3162 3162 _(
3163 3163 b'skipping already grafted revision %d:%s '
3164 3164 b'(was grafted from %d:%s)\n'
3165 3165 )
3166 3166 % (r, repo[r], rev, ctx)
3167 3167 )
3168 3168 revs.remove(r)
3169 3169 if not revs:
3170 3170 return -1
3171 3171
3172 3172 if opts.get(b'no_commit'):
3173 3173 statedata[b'no_commit'] = True
3174 3174 for pos, ctx in enumerate(repo.set(b"%ld", revs)):
3175 3175 desc = b'%d:%s "%s"' % (
3176 3176 ctx.rev(),
3177 3177 ctx,
3178 3178 ctx.description().split(b'\n', 1)[0],
3179 3179 )
3180 3180 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
3181 3181 if names:
3182 3182 desc += b' (%s)' % b' '.join(names)
3183 3183 ui.status(_(b'grafting %s\n') % desc)
3184 3184 if opts.get(b'dry_run'):
3185 3185 continue
3186 3186
3187 3187 source = ctx.extra().get(b'source')
3188 3188 extra = {}
3189 3189 if source:
3190 3190 extra[b'source'] = source
3191 3191 extra[b'intermediate-source'] = ctx.hex()
3192 3192 else:
3193 3193 extra[b'source'] = ctx.hex()
3194 3194 user = ctx.user()
3195 3195 if opts.get(b'user'):
3196 3196 user = opts[b'user']
3197 3197 statedata[b'user'] = user
3198 3198 date = ctx.date()
3199 3199 if opts.get(b'date'):
3200 3200 date = opts[b'date']
3201 3201 statedata[b'date'] = date
3202 3202 message = ctx.description()
3203 3203 if opts.get(b'log'):
3204 3204 message += b'\n(grafted from %s)' % ctx.hex()
3205 3205 statedata[b'log'] = True
3206 3206
3207 3207 # we don't merge the first commit when continuing
3208 3208 if not cont:
3209 3209 # perform the graft merge with p1(rev) as 'ancestor'
3210 3210 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
3211 3211 base = ctx.p1() if basectx is None else basectx
3212 3212 with ui.configoverride(overrides, b'graft'):
3213 3213 stats = mergemod.graft(repo, ctx, base, [b'local', b'graft'])
3214 3214 # report any conflicts
3215 3215 if stats.unresolvedcount > 0:
3216 3216 # write out state for --continue
3217 3217 nodes = [repo[rev].hex() for rev in revs[pos:]]
3218 3218 statedata[b'nodes'] = nodes
3219 3219 stateversion = 1
3220 3220 graftstate.save(stateversion, statedata)
3221 3221 hint = _(b"use 'hg resolve' and 'hg graft --continue'")
3222 3222 raise error.Abort(
3223 3223 _(b"unresolved conflicts, can't continue"), hint=hint
3224 3224 )
3225 3225 else:
3226 3226 cont = False
3227 3227
3228 3228 # commit if --no-commit is false
3229 3229 if not opts.get(b'no_commit'):
3230 3230 node = repo.commit(
3231 3231 text=message, user=user, date=date, extra=extra, editor=editor
3232 3232 )
3233 3233 if node is None:
3234 3234 ui.warn(
3235 3235 _(b'note: graft of %d:%s created no changes to commit\n')
3236 3236 % (ctx.rev(), ctx)
3237 3237 )
3238 3238 # checking that newnodes exist because old state files won't have it
3239 3239 elif statedata.get(b'newnodes') is not None:
3240 3240 statedata[b'newnodes'].append(node)
3241 3241
3242 3242 # remove state when we complete successfully
3243 3243 if not opts.get(b'dry_run'):
3244 3244 graftstate.delete()
3245 3245
3246 3246 return 0
3247 3247
3248 3248
3249 3249 def _stopgraft(ui, repo, graftstate):
3250 3250 """stop the interrupted graft"""
3251 3251 if not graftstate.exists():
3252 3252 raise error.Abort(_(b"no interrupted graft found"))
3253 3253 pctx = repo[b'.']
3254 3254 hg.updaterepo(repo, pctx.node(), overwrite=True)
3255 3255 graftstate.delete()
3256 3256 ui.status(_(b"stopped the interrupted graft\n"))
3257 3257 ui.status(_(b"working directory is now at %s\n") % pctx.hex()[:12])
3258 3258 return 0
3259 3259
3260 3260
3261 3261 statemod.addunfinished(
3262 3262 b'graft',
3263 3263 fname=b'graftstate',
3264 3264 clearable=True,
3265 3265 stopflag=True,
3266 3266 continueflag=True,
3267 3267 abortfunc=cmdutil.hgabortgraft,
3268 3268 cmdhint=_(b"use 'hg graft --continue' or 'hg graft --stop' to stop"),
3269 3269 )
3270 3270
3271 3271
3272 3272 @command(
3273 3273 b'grep',
3274 3274 [
3275 3275 (b'0', b'print0', None, _(b'end fields with NUL')),
3276 3276 (b'', b'all', None, _(b'print all revisions that match (DEPRECATED) ')),
3277 3277 (
3278 3278 b'',
3279 3279 b'diff',
3280 3280 None,
3281 3281 _(
3282 3282 b'search revision differences for when the pattern was added '
3283 3283 b'or removed'
3284 3284 ),
3285 3285 ),
3286 3286 (b'a', b'text', None, _(b'treat all files as text')),
3287 3287 (
3288 3288 b'f',
3289 3289 b'follow',
3290 3290 None,
3291 3291 _(
3292 3292 b'follow changeset history,'
3293 3293 b' or file history across copies and renames'
3294 3294 ),
3295 3295 ),
3296 3296 (b'i', b'ignore-case', None, _(b'ignore case when matching')),
3297 3297 (
3298 3298 b'l',
3299 3299 b'files-with-matches',
3300 3300 None,
3301 3301 _(b'print only filenames and revisions that match'),
3302 3302 ),
3303 3303 (b'n', b'line-number', None, _(b'print matching line numbers')),
3304 3304 (
3305 3305 b'r',
3306 3306 b'rev',
3307 3307 [],
3308 3308 _(b'search files changed within revision range'),
3309 3309 _(b'REV'),
3310 3310 ),
3311 3311 (
3312 3312 b'',
3313 3313 b'all-files',
3314 3314 None,
3315 3315 _(
3316 3316 b'include all files in the changeset while grepping (DEPRECATED)'
3317 3317 ),
3318 3318 ),
3319 3319 (b'u', b'user', None, _(b'list the author (long with -v)')),
3320 3320 (b'd', b'date', None, _(b'list the date (short with -q)')),
3321 3321 ]
3322 3322 + formatteropts
3323 3323 + walkopts,
3324 3324 _(b'[--diff] [OPTION]... PATTERN [FILE]...'),
3325 3325 helpcategory=command.CATEGORY_FILE_CONTENTS,
3326 3326 inferrepo=True,
3327 3327 intents={INTENT_READONLY},
3328 3328 )
3329 3329 def grep(ui, repo, pattern, *pats, **opts):
3330 3330 """search for a pattern in specified files
3331 3331
3332 3332 Search the working directory or revision history for a regular
3333 3333 expression in the specified files for the entire repository.
3334 3334
3335 3335 By default, grep searches the repository files in the working
3336 3336 directory and prints the files where it finds a match. To specify
3337 3337 historical revisions instead of the working directory, use the
3338 3338 --rev flag.
3339 3339
3340 3340 To search instead historical revision differences that contains a
3341 3341 change in match status ("-" for a match that becomes a non-match,
3342 3342 or "+" for a non-match that becomes a match), use the --diff flag.
3343 3343
3344 3344 PATTERN can be any Python (roughly Perl-compatible) regular
3345 3345 expression.
3346 3346
3347 3347 If no FILEs are specified and the --rev flag isn't supplied, all
3348 3348 files in the working directory are searched. When using the --rev
3349 3349 flag and specifying FILEs, use the --follow argument to also
3350 3350 follow the specified FILEs across renames and copies.
3351 3351
3352 3352 .. container:: verbose
3353 3353
3354 3354 Template:
3355 3355
3356 3356 The following keywords are supported in addition to the common template
3357 3357 keywords and functions. See also :hg:`help templates`.
3358 3358
3359 3359 :change: String. Character denoting insertion ``+`` or removal ``-``.
3360 3360 Available if ``--diff`` is specified.
3361 3361 :lineno: Integer. Line number of the match.
3362 3362 :path: String. Repository-absolute path of the file.
3363 3363 :texts: List of text chunks.
3364 3364
3365 3365 And each entry of ``{texts}`` provides the following sub-keywords.
3366 3366
3367 3367 :matched: Boolean. True if the chunk matches the specified pattern.
3368 3368 :text: String. Chunk content.
3369 3369
3370 3370 See :hg:`help templates.operators` for the list expansion syntax.
3371 3371
3372 3372 Returns 0 if a match is found, 1 otherwise.
3373 3373
3374 3374 """
3375 3375 opts = pycompat.byteskwargs(opts)
3376 3376 diff = opts.get(b'all') or opts.get(b'diff')
3377 3377 if diff and opts.get(b'all_files'):
3378 3378 raise error.Abort(_(b'--diff and --all-files are mutually exclusive'))
3379 3379 if opts.get(b'all_files') is None and not diff:
3380 3380 opts[b'all_files'] = True
3381 3381 plaingrep = opts.get(b'all_files') and not opts.get(b'rev')
3382 3382 all_files = opts.get(b'all_files')
3383 3383 if plaingrep:
3384 3384 opts[b'rev'] = [b'wdir()']
3385 3385
3386 3386 reflags = re.M
3387 3387 if opts.get(b'ignore_case'):
3388 3388 reflags |= re.I
3389 3389 try:
3390 3390 regexp = util.re.compile(pattern, reflags)
3391 3391 except re.error as inst:
3392 3392 ui.warn(
3393 3393 _(b"grep: invalid match pattern: %s\n") % pycompat.bytestr(inst)
3394 3394 )
3395 3395 return 1
3396 3396 sep, eol = b':', b'\n'
3397 3397 if opts.get(b'print0'):
3398 3398 sep = eol = b'\0'
3399 3399
3400 3400 getfile = util.lrucachefunc(repo.file)
3401 3401
3402 3402 def matchlines(body):
3403 3403 begin = 0
3404 3404 linenum = 0
3405 3405 while begin < len(body):
3406 3406 match = regexp.search(body, begin)
3407 3407 if not match:
3408 3408 break
3409 3409 mstart, mend = match.span()
3410 3410 linenum += body.count(b'\n', begin, mstart) + 1
3411 3411 lstart = body.rfind(b'\n', begin, mstart) + 1 or begin
3412 3412 begin = body.find(b'\n', mend) + 1 or len(body) + 1
3413 3413 lend = begin - 1
3414 3414 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
3415 3415
3416 3416 class linestate(object):
3417 3417 def __init__(self, line, linenum, colstart, colend):
3418 3418 self.line = line
3419 3419 self.linenum = linenum
3420 3420 self.colstart = colstart
3421 3421 self.colend = colend
3422 3422
3423 3423 def __hash__(self):
3424 3424 return hash((self.linenum, self.line))
3425 3425
3426 3426 def __eq__(self, other):
3427 3427 return self.line == other.line
3428 3428
3429 3429 def findpos(self):
3430 3430 """Iterate all (start, end) indices of matches"""
3431 3431 yield self.colstart, self.colend
3432 3432 p = self.colend
3433 3433 while p < len(self.line):
3434 3434 m = regexp.search(self.line, p)
3435 3435 if not m:
3436 3436 break
3437 3437 yield m.span()
3438 3438 p = m.end()
3439 3439
3440 3440 matches = {}
3441 3441 copies = {}
3442 3442
3443 3443 def grepbody(fn, rev, body):
3444 3444 matches[rev].setdefault(fn, [])
3445 3445 m = matches[rev][fn]
3446 3446 if body is None:
3447 3447 return
3448 3448
3449 3449 for lnum, cstart, cend, line in matchlines(body):
3450 3450 s = linestate(line, lnum, cstart, cend)
3451 3451 m.append(s)
3452 3452
3453 3453 def difflinestates(a, b):
3454 3454 sm = difflib.SequenceMatcher(None, a, b)
3455 3455 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
3456 3456 if tag == 'insert':
3457 3457 for i in pycompat.xrange(blo, bhi):
3458 3458 yield (b'+', b[i])
3459 3459 elif tag == 'delete':
3460 3460 for i in pycompat.xrange(alo, ahi):
3461 3461 yield (b'-', a[i])
3462 3462 elif tag == 'replace':
3463 3463 for i in pycompat.xrange(alo, ahi):
3464 3464 yield (b'-', a[i])
3465 3465 for i in pycompat.xrange(blo, bhi):
3466 3466 yield (b'+', b[i])
3467 3467
3468 3468 uipathfn = scmutil.getuipathfn(repo)
3469 3469
3470 3470 def display(fm, fn, ctx, pstates, states):
3471 3471 rev = scmutil.intrev(ctx)
3472 3472 if fm.isplain():
3473 3473 formatuser = ui.shortuser
3474 3474 else:
3475 3475 formatuser = pycompat.bytestr
3476 3476 if ui.quiet:
3477 3477 datefmt = b'%Y-%m-%d'
3478 3478 else:
3479 3479 datefmt = b'%a %b %d %H:%M:%S %Y %1%2'
3480 3480 found = False
3481 3481
3482 3482 @util.cachefunc
3483 3483 def binary():
3484 3484 flog = getfile(fn)
3485 3485 try:
3486 3486 return stringutil.binary(flog.read(ctx.filenode(fn)))
3487 3487 except error.WdirUnsupported:
3488 3488 return ctx[fn].isbinary()
3489 3489
3490 3490 fieldnamemap = {b'linenumber': b'lineno'}
3491 3491 if diff:
3492 3492 iter = difflinestates(pstates, states)
3493 3493 else:
3494 3494 iter = [(b'', l) for l in states]
3495 3495 for change, l in iter:
3496 3496 fm.startitem()
3497 3497 fm.context(ctx=ctx)
3498 3498 fm.data(node=fm.hexfunc(scmutil.binnode(ctx)), path=fn)
3499 3499 fm.plain(uipathfn(fn), label=b'grep.filename')
3500 3500
3501 3501 cols = [
3502 3502 (b'rev', b'%d', rev, not plaingrep, b''),
3503 3503 (
3504 3504 b'linenumber',
3505 3505 b'%d',
3506 3506 l.linenum,
3507 3507 opts.get(b'line_number'),
3508 3508 b'',
3509 3509 ),
3510 3510 ]
3511 3511 if diff:
3512 3512 cols.append(
3513 3513 (
3514 3514 b'change',
3515 3515 b'%s',
3516 3516 change,
3517 3517 True,
3518 3518 b'grep.inserted '
3519 3519 if change == b'+'
3520 3520 else b'grep.deleted ',
3521 3521 )
3522 3522 )
3523 3523 cols.extend(
3524 3524 [
3525 3525 (
3526 3526 b'user',
3527 3527 b'%s',
3528 3528 formatuser(ctx.user()),
3529 3529 opts.get(b'user'),
3530 3530 b'',
3531 3531 ),
3532 3532 (
3533 3533 b'date',
3534 3534 b'%s',
3535 3535 fm.formatdate(ctx.date(), datefmt),
3536 3536 opts.get(b'date'),
3537 3537 b'',
3538 3538 ),
3539 3539 ]
3540 3540 )
3541 3541 for name, fmt, data, cond, extra_label in cols:
3542 3542 if cond:
3543 3543 fm.plain(sep, label=b'grep.sep')
3544 3544 field = fieldnamemap.get(name, name)
3545 3545 label = extra_label + (b'grep.%s' % name)
3546 3546 fm.condwrite(cond, field, fmt, data, label=label)
3547 3547 if not opts.get(b'files_with_matches'):
3548 3548 fm.plain(sep, label=b'grep.sep')
3549 3549 if not opts.get(b'text') and binary():
3550 3550 fm.plain(_(b" Binary file matches"))
3551 3551 else:
3552 3552 displaymatches(fm.nested(b'texts', tmpl=b'{text}'), l)
3553 3553 fm.plain(eol)
3554 3554 found = True
3555 3555 if opts.get(b'files_with_matches'):
3556 3556 break
3557 3557 return found
3558 3558
3559 3559 def displaymatches(fm, l):
3560 3560 p = 0
3561 3561 for s, e in l.findpos():
3562 3562 if p < s:
3563 3563 fm.startitem()
3564 3564 fm.write(b'text', b'%s', l.line[p:s])
3565 3565 fm.data(matched=False)
3566 3566 fm.startitem()
3567 3567 fm.write(b'text', b'%s', l.line[s:e], label=b'grep.match')
3568 3568 fm.data(matched=True)
3569 3569 p = e
3570 3570 if p < len(l.line):
3571 3571 fm.startitem()
3572 3572 fm.write(b'text', b'%s', l.line[p:])
3573 3573 fm.data(matched=False)
3574 3574 fm.end()
3575 3575
3576 3576 skip = set()
3577 3577 revfiles = {}
3578 3578 match = scmutil.match(repo[None], pats, opts)
3579 3579 found = False
3580 3580 follow = opts.get(b'follow')
3581 3581
3582 3582 getrenamed = scmutil.getrenamedfn(repo)
3583 3583
3584 3584 def get_file_content(filename, filelog, filenode, context, revision):
3585 3585 try:
3586 3586 content = filelog.read(filenode)
3587 3587 except error.WdirUnsupported:
3588 3588 content = context[filename].data()
3589 3589 except error.CensoredNodeError:
3590 3590 content = None
3591 3591 ui.warn(
3592 3592 _(b'cannot search in censored file: %(filename)s:%(revnum)s\n')
3593 3593 % {b'filename': filename, b'revnum': pycompat.bytestr(revision)}
3594 3594 )
3595 3595 return content
3596 3596
3597 3597 def prep(ctx, fns):
3598 3598 rev = ctx.rev()
3599 3599 pctx = ctx.p1()
3600 3600 parent = pctx.rev()
3601 3601 matches.setdefault(rev, {})
3602 3602 matches.setdefault(parent, {})
3603 3603 files = revfiles.setdefault(rev, [])
3604 3604 for fn in fns:
3605 3605 flog = getfile(fn)
3606 3606 try:
3607 3607 fnode = ctx.filenode(fn)
3608 3608 except error.LookupError:
3609 3609 continue
3610 3610
3611 3611 copy = None
3612 3612 if follow:
3613 3613 copy = getrenamed(fn, rev)
3614 3614 if copy:
3615 3615 copies.setdefault(rev, {})[fn] = copy
3616 3616 if fn in skip:
3617 3617 skip.add(copy)
3618 3618 if fn in skip:
3619 3619 continue
3620 3620 files.append(fn)
3621 3621
3622 3622 if fn not in matches[rev]:
3623 3623 content = get_file_content(fn, flog, fnode, ctx, rev)
3624 3624 grepbody(fn, rev, content)
3625 3625
3626 3626 pfn = copy or fn
3627 3627 if pfn not in matches[parent]:
3628 3628 try:
3629 3629 pfnode = pctx.filenode(pfn)
3630 3630 pcontent = get_file_content(pfn, flog, pfnode, pctx, parent)
3631 3631 grepbody(pfn, parent, pcontent)
3632 3632 except error.LookupError:
3633 3633 pass
3634 3634
3635 3635 ui.pager(b'grep')
3636 3636 fm = ui.formatter(b'grep', opts)
3637 3637 for ctx in cmdutil.walkchangerevs(repo, match, opts, prep):
3638 3638 rev = ctx.rev()
3639 3639 parent = ctx.p1().rev()
3640 3640 for fn in sorted(revfiles.get(rev, [])):
3641 3641 states = matches[rev][fn]
3642 3642 copy = copies.get(rev, {}).get(fn)
3643 3643 if fn in skip:
3644 3644 if copy:
3645 3645 skip.add(copy)
3646 3646 continue
3647 3647 pstates = matches.get(parent, {}).get(copy or fn, [])
3648 3648 if pstates or states:
3649 3649 r = display(fm, fn, ctx, pstates, states)
3650 3650 found = found or r
3651 3651 if r and not diff and not all_files:
3652 3652 skip.add(fn)
3653 3653 if copy:
3654 3654 skip.add(copy)
3655 3655 del revfiles[rev]
3656 3656 # We will keep the matches dict for the duration of the window
3657 3657 # clear the matches dict once the window is over
3658 3658 if not revfiles:
3659 3659 matches.clear()
3660 3660 fm.end()
3661 3661
3662 3662 return not found
3663 3663
3664 3664
3665 3665 @command(
3666 3666 b'heads',
3667 3667 [
3668 3668 (
3669 3669 b'r',
3670 3670 b'rev',
3671 3671 b'',
3672 3672 _(b'show only heads which are descendants of STARTREV'),
3673 3673 _(b'STARTREV'),
3674 3674 ),
3675 3675 (b't', b'topo', False, _(b'show topological heads only')),
3676 3676 (
3677 3677 b'a',
3678 3678 b'active',
3679 3679 False,
3680 3680 _(b'show active branchheads only (DEPRECATED)'),
3681 3681 ),
3682 3682 (b'c', b'closed', False, _(b'show normal and closed branch heads')),
3683 3683 ]
3684 3684 + templateopts,
3685 3685 _(b'[-ct] [-r STARTREV] [REV]...'),
3686 3686 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
3687 3687 intents={INTENT_READONLY},
3688 3688 )
3689 3689 def heads(ui, repo, *branchrevs, **opts):
3690 3690 """show branch heads
3691 3691
3692 3692 With no arguments, show all open branch heads in the repository.
3693 3693 Branch heads are changesets that have no descendants on the
3694 3694 same branch. They are where development generally takes place and
3695 3695 are the usual targets for update and merge operations.
3696 3696
3697 3697 If one or more REVs are given, only open branch heads on the
3698 3698 branches associated with the specified changesets are shown. This
3699 3699 means that you can use :hg:`heads .` to see the heads on the
3700 3700 currently checked-out branch.
3701 3701
3702 3702 If -c/--closed is specified, also show branch heads marked closed
3703 3703 (see :hg:`commit --close-branch`).
3704 3704
3705 3705 If STARTREV is specified, only those heads that are descendants of
3706 3706 STARTREV will be displayed.
3707 3707
3708 3708 If -t/--topo is specified, named branch mechanics will be ignored and only
3709 3709 topological heads (changesets with no children) will be shown.
3710 3710
3711 3711 Returns 0 if matching heads are found, 1 if not.
3712 3712 """
3713 3713
3714 3714 opts = pycompat.byteskwargs(opts)
3715 3715 start = None
3716 3716 rev = opts.get(b'rev')
3717 3717 if rev:
3718 3718 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
3719 3719 start = scmutil.revsingle(repo, rev, None).node()
3720 3720
3721 3721 if opts.get(b'topo'):
3722 3722 heads = [repo[h] for h in repo.heads(start)]
3723 3723 else:
3724 3724 heads = []
3725 3725 for branch in repo.branchmap():
3726 3726 heads += repo.branchheads(branch, start, opts.get(b'closed'))
3727 3727 heads = [repo[h] for h in heads]
3728 3728
3729 3729 if branchrevs:
3730 3730 branches = set(
3731 3731 repo[r].branch() for r in scmutil.revrange(repo, branchrevs)
3732 3732 )
3733 3733 heads = [h for h in heads if h.branch() in branches]
3734 3734
3735 3735 if opts.get(b'active') and branchrevs:
3736 3736 dagheads = repo.heads(start)
3737 3737 heads = [h for h in heads if h.node() in dagheads]
3738 3738
3739 3739 if branchrevs:
3740 3740 haveheads = set(h.branch() for h in heads)
3741 3741 if branches - haveheads:
3742 3742 headless = b', '.join(b for b in branches - haveheads)
3743 3743 msg = _(b'no open branch heads found on branches %s')
3744 3744 if opts.get(b'rev'):
3745 3745 msg += _(b' (started at %s)') % opts[b'rev']
3746 3746 ui.warn((msg + b'\n') % headless)
3747 3747
3748 3748 if not heads:
3749 3749 return 1
3750 3750
3751 3751 ui.pager(b'heads')
3752 3752 heads = sorted(heads, key=lambda x: -(x.rev()))
3753 3753 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
3754 3754 for ctx in heads:
3755 3755 displayer.show(ctx)
3756 3756 displayer.close()
3757 3757
3758 3758
3759 3759 @command(
3760 3760 b'help',
3761 3761 [
3762 3762 (b'e', b'extension', None, _(b'show only help for extensions')),
3763 3763 (b'c', b'command', None, _(b'show only help for commands')),
3764 3764 (b'k', b'keyword', None, _(b'show topics matching keyword')),
3765 3765 (
3766 3766 b's',
3767 3767 b'system',
3768 3768 [],
3769 3769 _(b'show help for specific platform(s)'),
3770 3770 _(b'PLATFORM'),
3771 3771 ),
3772 3772 ],
3773 3773 _(b'[-eck] [-s PLATFORM] [TOPIC]'),
3774 3774 helpcategory=command.CATEGORY_HELP,
3775 3775 norepo=True,
3776 3776 intents={INTENT_READONLY},
3777 3777 )
3778 3778 def help_(ui, name=None, **opts):
3779 3779 """show help for a given topic or a help overview
3780 3780
3781 3781 With no arguments, print a list of commands with short help messages.
3782 3782
3783 3783 Given a topic, extension, or command name, print help for that
3784 3784 topic.
3785 3785
3786 3786 Returns 0 if successful.
3787 3787 """
3788 3788
3789 3789 keep = opts.get('system') or []
3790 3790 if len(keep) == 0:
3791 3791 if pycompat.sysplatform.startswith(b'win'):
3792 3792 keep.append(b'windows')
3793 3793 elif pycompat.sysplatform == b'OpenVMS':
3794 3794 keep.append(b'vms')
3795 3795 elif pycompat.sysplatform == b'plan9':
3796 3796 keep.append(b'plan9')
3797 3797 else:
3798 3798 keep.append(b'unix')
3799 3799 keep.append(pycompat.sysplatform.lower())
3800 3800 if ui.verbose:
3801 3801 keep.append(b'verbose')
3802 3802
3803 3803 commands = sys.modules[__name__]
3804 3804 formatted = help.formattedhelp(ui, commands, name, keep=keep, **opts)
3805 3805 ui.pager(b'help')
3806 3806 ui.write(formatted)
3807 3807
3808 3808
3809 3809 @command(
3810 3810 b'identify|id',
3811 3811 [
3812 3812 (b'r', b'rev', b'', _(b'identify the specified revision'), _(b'REV')),
3813 3813 (b'n', b'num', None, _(b'show local revision number')),
3814 3814 (b'i', b'id', None, _(b'show global revision id')),
3815 3815 (b'b', b'branch', None, _(b'show branch')),
3816 3816 (b't', b'tags', None, _(b'show tags')),
3817 3817 (b'B', b'bookmarks', None, _(b'show bookmarks')),
3818 3818 ]
3819 3819 + remoteopts
3820 3820 + formatteropts,
3821 3821 _(b'[-nibtB] [-r REV] [SOURCE]'),
3822 3822 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
3823 3823 optionalrepo=True,
3824 3824 intents={INTENT_READONLY},
3825 3825 )
3826 3826 def identify(
3827 3827 ui,
3828 3828 repo,
3829 3829 source=None,
3830 3830 rev=None,
3831 3831 num=None,
3832 3832 id=None,
3833 3833 branch=None,
3834 3834 tags=None,
3835 3835 bookmarks=None,
3836 3836 **opts
3837 3837 ):
3838 3838 """identify the working directory or specified revision
3839 3839
3840 3840 Print a summary identifying the repository state at REV using one or
3841 3841 two parent hash identifiers, followed by a "+" if the working
3842 3842 directory has uncommitted changes, the branch name (if not default),
3843 3843 a list of tags, and a list of bookmarks.
3844 3844
3845 3845 When REV is not given, print a summary of the current state of the
3846 3846 repository including the working directory. Specify -r. to get information
3847 3847 of the working directory parent without scanning uncommitted changes.
3848 3848
3849 3849 Specifying a path to a repository root or Mercurial bundle will
3850 3850 cause lookup to operate on that repository/bundle.
3851 3851
3852 3852 .. container:: verbose
3853 3853
3854 3854 Template:
3855 3855
3856 3856 The following keywords are supported in addition to the common template
3857 3857 keywords and functions. See also :hg:`help templates`.
3858 3858
3859 3859 :dirty: String. Character ``+`` denoting if the working directory has
3860 3860 uncommitted changes.
3861 3861 :id: String. One or two nodes, optionally followed by ``+``.
3862 3862 :parents: List of strings. Parent nodes of the changeset.
3863 3863
3864 3864 Examples:
3865 3865
3866 3866 - generate a build identifier for the working directory::
3867 3867
3868 3868 hg id --id > build-id.dat
3869 3869
3870 3870 - find the revision corresponding to a tag::
3871 3871
3872 3872 hg id -n -r 1.3
3873 3873
3874 3874 - check the most recent revision of a remote repository::
3875 3875
3876 3876 hg id -r tip https://www.mercurial-scm.org/repo/hg/
3877 3877
3878 3878 See :hg:`log` for generating more information about specific revisions,
3879 3879 including full hash identifiers.
3880 3880
3881 3881 Returns 0 if successful.
3882 3882 """
3883 3883
3884 3884 opts = pycompat.byteskwargs(opts)
3885 3885 if not repo and not source:
3886 3886 raise error.Abort(
3887 3887 _(b"there is no Mercurial repository here (.hg not found)")
3888 3888 )
3889 3889
3890 3890 default = not (num or id or branch or tags or bookmarks)
3891 3891 output = []
3892 3892 revs = []
3893 3893
3894 3894 if source:
3895 3895 source, branches = hg.parseurl(ui.expandpath(source))
3896 3896 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
3897 3897 repo = peer.local()
3898 3898 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
3899 3899
3900 3900 fm = ui.formatter(b'identify', opts)
3901 3901 fm.startitem()
3902 3902
3903 3903 if not repo:
3904 3904 if num or branch or tags:
3905 3905 raise error.Abort(
3906 3906 _(b"can't query remote revision number, branch, or tags")
3907 3907 )
3908 3908 if not rev and revs:
3909 3909 rev = revs[0]
3910 3910 if not rev:
3911 3911 rev = b"tip"
3912 3912
3913 3913 remoterev = peer.lookup(rev)
3914 3914 hexrev = fm.hexfunc(remoterev)
3915 3915 if default or id:
3916 3916 output = [hexrev]
3917 3917 fm.data(id=hexrev)
3918 3918
3919 3919 @util.cachefunc
3920 3920 def getbms():
3921 3921 bms = []
3922 3922
3923 3923 if b'bookmarks' in peer.listkeys(b'namespaces'):
3924 3924 hexremoterev = hex(remoterev)
3925 3925 bms = [
3926 3926 bm
3927 3927 for bm, bmr in pycompat.iteritems(
3928 3928 peer.listkeys(b'bookmarks')
3929 3929 )
3930 3930 if bmr == hexremoterev
3931 3931 ]
3932 3932
3933 3933 return sorted(bms)
3934 3934
3935 3935 if fm.isplain():
3936 3936 if bookmarks:
3937 3937 output.extend(getbms())
3938 3938 elif default and not ui.quiet:
3939 3939 # multiple bookmarks for a single parent separated by '/'
3940 3940 bm = b'/'.join(getbms())
3941 3941 if bm:
3942 3942 output.append(bm)
3943 3943 else:
3944 3944 fm.data(node=hex(remoterev))
3945 3945 if bookmarks or b'bookmarks' in fm.datahint():
3946 3946 fm.data(bookmarks=fm.formatlist(getbms(), name=b'bookmark'))
3947 3947 else:
3948 3948 if rev:
3949 3949 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
3950 3950 ctx = scmutil.revsingle(repo, rev, None)
3951 3951
3952 3952 if ctx.rev() is None:
3953 3953 ctx = repo[None]
3954 3954 parents = ctx.parents()
3955 3955 taglist = []
3956 3956 for p in parents:
3957 3957 taglist.extend(p.tags())
3958 3958
3959 3959 dirty = b""
3960 3960 if ctx.dirty(missing=True, merge=False, branch=False):
3961 3961 dirty = b'+'
3962 3962 fm.data(dirty=dirty)
3963 3963
3964 3964 hexoutput = [fm.hexfunc(p.node()) for p in parents]
3965 3965 if default or id:
3966 3966 output = [b"%s%s" % (b'+'.join(hexoutput), dirty)]
3967 3967 fm.data(id=b"%s%s" % (b'+'.join(hexoutput), dirty))
3968 3968
3969 3969 if num:
3970 3970 numoutput = [b"%d" % p.rev() for p in parents]
3971 3971 output.append(b"%s%s" % (b'+'.join(numoutput), dirty))
3972 3972
3973 3973 fm.data(
3974 3974 parents=fm.formatlist(
3975 3975 [fm.hexfunc(p.node()) for p in parents], name=b'node'
3976 3976 )
3977 3977 )
3978 3978 else:
3979 3979 hexoutput = fm.hexfunc(ctx.node())
3980 3980 if default or id:
3981 3981 output = [hexoutput]
3982 3982 fm.data(id=hexoutput)
3983 3983
3984 3984 if num:
3985 3985 output.append(pycompat.bytestr(ctx.rev()))
3986 3986 taglist = ctx.tags()
3987 3987
3988 3988 if default and not ui.quiet:
3989 3989 b = ctx.branch()
3990 3990 if b != b'default':
3991 3991 output.append(b"(%s)" % b)
3992 3992
3993 3993 # multiple tags for a single parent separated by '/'
3994 3994 t = b'/'.join(taglist)
3995 3995 if t:
3996 3996 output.append(t)
3997 3997
3998 3998 # multiple bookmarks for a single parent separated by '/'
3999 3999 bm = b'/'.join(ctx.bookmarks())
4000 4000 if bm:
4001 4001 output.append(bm)
4002 4002 else:
4003 4003 if branch:
4004 4004 output.append(ctx.branch())
4005 4005
4006 4006 if tags:
4007 4007 output.extend(taglist)
4008 4008
4009 4009 if bookmarks:
4010 4010 output.extend(ctx.bookmarks())
4011 4011
4012 4012 fm.data(node=ctx.hex())
4013 4013 fm.data(branch=ctx.branch())
4014 4014 fm.data(tags=fm.formatlist(taglist, name=b'tag', sep=b':'))
4015 4015 fm.data(bookmarks=fm.formatlist(ctx.bookmarks(), name=b'bookmark'))
4016 4016 fm.context(ctx=ctx)
4017 4017
4018 4018 fm.plain(b"%s\n" % b' '.join(output))
4019 4019 fm.end()
4020 4020
4021 4021
4022 4022 @command(
4023 4023 b'import|patch',
4024 4024 [
4025 4025 (
4026 4026 b'p',
4027 4027 b'strip',
4028 4028 1,
4029 4029 _(
4030 4030 b'directory strip option for patch. This has the same '
4031 4031 b'meaning as the corresponding patch option'
4032 4032 ),
4033 4033 _(b'NUM'),
4034 4034 ),
4035 4035 (b'b', b'base', b'', _(b'base path (DEPRECATED)'), _(b'PATH')),
4036 4036 (b'', b'secret', None, _(b'use the secret phase for committing')),
4037 4037 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
4038 4038 (
4039 4039 b'f',
4040 4040 b'force',
4041 4041 None,
4042 4042 _(b'skip check for outstanding uncommitted changes (DEPRECATED)'),
4043 4043 ),
4044 4044 (
4045 4045 b'',
4046 4046 b'no-commit',
4047 4047 None,
4048 4048 _(b"don't commit, just update the working directory"),
4049 4049 ),
4050 4050 (
4051 4051 b'',
4052 4052 b'bypass',
4053 4053 None,
4054 4054 _(b"apply patch without touching the working directory"),
4055 4055 ),
4056 4056 (b'', b'partial', None, _(b'commit even if some hunks fail')),
4057 4057 (b'', b'exact', None, _(b'abort if patch would apply lossily')),
4058 4058 (b'', b'prefix', b'', _(b'apply patch to subdirectory'), _(b'DIR')),
4059 4059 (
4060 4060 b'',
4061 4061 b'import-branch',
4062 4062 None,
4063 4063 _(b'use any branch information in patch (implied by --exact)'),
4064 4064 ),
4065 4065 ]
4066 4066 + commitopts
4067 4067 + commitopts2
4068 4068 + similarityopts,
4069 4069 _(b'[OPTION]... PATCH...'),
4070 4070 helpcategory=command.CATEGORY_IMPORT_EXPORT,
4071 4071 )
4072 4072 def import_(ui, repo, patch1=None, *patches, **opts):
4073 4073 """import an ordered set of patches
4074 4074
4075 4075 Import a list of patches and commit them individually (unless
4076 4076 --no-commit is specified).
4077 4077
4078 4078 To read a patch from standard input (stdin), use "-" as the patch
4079 4079 name. If a URL is specified, the patch will be downloaded from
4080 4080 there.
4081 4081
4082 4082 Import first applies changes to the working directory (unless
4083 4083 --bypass is specified), import will abort if there are outstanding
4084 4084 changes.
4085 4085
4086 4086 Use --bypass to apply and commit patches directly to the
4087 4087 repository, without affecting the working directory. Without
4088 4088 --exact, patches will be applied on top of the working directory
4089 4089 parent revision.
4090 4090
4091 4091 You can import a patch straight from a mail message. Even patches
4092 4092 as attachments work (to use the body part, it must have type
4093 4093 text/plain or text/x-patch). From and Subject headers of email
4094 4094 message are used as default committer and commit message. All
4095 4095 text/plain body parts before first diff are added to the commit
4096 4096 message.
4097 4097
4098 4098 If the imported patch was generated by :hg:`export`, user and
4099 4099 description from patch override values from message headers and
4100 4100 body. Values given on command line with -m/--message and -u/--user
4101 4101 override these.
4102 4102
4103 4103 If --exact is specified, import will set the working directory to
4104 4104 the parent of each patch before applying it, and will abort if the
4105 4105 resulting changeset has a different ID than the one recorded in
4106 4106 the patch. This will guard against various ways that portable
4107 4107 patch formats and mail systems might fail to transfer Mercurial
4108 4108 data or metadata. See :hg:`bundle` for lossless transmission.
4109 4109
4110 4110 Use --partial to ensure a changeset will be created from the patch
4111 4111 even if some hunks fail to apply. Hunks that fail to apply will be
4112 4112 written to a <target-file>.rej file. Conflicts can then be resolved
4113 4113 by hand before :hg:`commit --amend` is run to update the created
4114 4114 changeset. This flag exists to let people import patches that
4115 4115 partially apply without losing the associated metadata (author,
4116 4116 date, description, ...).
4117 4117
4118 4118 .. note::
4119 4119
4120 4120 When no hunks apply cleanly, :hg:`import --partial` will create
4121 4121 an empty changeset, importing only the patch metadata.
4122 4122
4123 4123 With -s/--similarity, hg will attempt to discover renames and
4124 4124 copies in the patch in the same way as :hg:`addremove`.
4125 4125
4126 4126 It is possible to use external patch programs to perform the patch
4127 4127 by setting the ``ui.patch`` configuration option. For the default
4128 4128 internal tool, the fuzz can also be configured via ``patch.fuzz``.
4129 4129 See :hg:`help config` for more information about configuration
4130 4130 files and how to use these options.
4131 4131
4132 4132 See :hg:`help dates` for a list of formats valid for -d/--date.
4133 4133
4134 4134 .. container:: verbose
4135 4135
4136 4136 Examples:
4137 4137
4138 4138 - import a traditional patch from a website and detect renames::
4139 4139
4140 4140 hg import -s 80 http://example.com/bugfix.patch
4141 4141
4142 4142 - import a changeset from an hgweb server::
4143 4143
4144 4144 hg import https://www.mercurial-scm.org/repo/hg/rev/5ca8c111e9aa
4145 4145
4146 4146 - import all the patches in an Unix-style mbox::
4147 4147
4148 4148 hg import incoming-patches.mbox
4149 4149
4150 4150 - import patches from stdin::
4151 4151
4152 4152 hg import -
4153 4153
4154 4154 - attempt to exactly restore an exported changeset (not always
4155 4155 possible)::
4156 4156
4157 4157 hg import --exact proposed-fix.patch
4158 4158
4159 4159 - use an external tool to apply a patch which is too fuzzy for
4160 4160 the default internal tool.
4161 4161
4162 4162 hg import --config ui.patch="patch --merge" fuzzy.patch
4163 4163
4164 4164 - change the default fuzzing from 2 to a less strict 7
4165 4165
4166 4166 hg import --config ui.fuzz=7 fuzz.patch
4167 4167
4168 4168 Returns 0 on success, 1 on partial success (see --partial).
4169 4169 """
4170 4170
4171 4171 opts = pycompat.byteskwargs(opts)
4172 4172 if not patch1:
4173 4173 raise error.Abort(_(b'need at least one patch to import'))
4174 4174
4175 4175 patches = (patch1,) + patches
4176 4176
4177 4177 date = opts.get(b'date')
4178 4178 if date:
4179 4179 opts[b'date'] = dateutil.parsedate(date)
4180 4180
4181 4181 exact = opts.get(b'exact')
4182 4182 update = not opts.get(b'bypass')
4183 4183 if not update and opts.get(b'no_commit'):
4184 4184 raise error.Abort(_(b'cannot use --no-commit with --bypass'))
4185 4185 if opts.get(b'secret') and opts.get(b'no_commit'):
4186 4186 raise error.Abort(_(b'cannot use --no-commit with --secret'))
4187 4187 try:
4188 4188 sim = float(opts.get(b'similarity') or 0)
4189 4189 except ValueError:
4190 4190 raise error.Abort(_(b'similarity must be a number'))
4191 4191 if sim < 0 or sim > 100:
4192 4192 raise error.Abort(_(b'similarity must be between 0 and 100'))
4193 4193 if sim and not update:
4194 4194 raise error.Abort(_(b'cannot use --similarity with --bypass'))
4195 4195 if exact:
4196 4196 if opts.get(b'edit'):
4197 4197 raise error.Abort(_(b'cannot use --exact with --edit'))
4198 4198 if opts.get(b'prefix'):
4199 4199 raise error.Abort(_(b'cannot use --exact with --prefix'))
4200 4200
4201 4201 base = opts[b"base"]
4202 4202 msgs = []
4203 4203 ret = 0
4204 4204
4205 4205 with repo.wlock():
4206 4206 if update:
4207 4207 cmdutil.checkunfinished(repo)
4208 4208 if exact or not opts.get(b'force'):
4209 4209 cmdutil.bailifchanged(repo)
4210 4210
4211 4211 if not opts.get(b'no_commit'):
4212 4212 lock = repo.lock
4213 4213 tr = lambda: repo.transaction(b'import')
4214 4214 dsguard = util.nullcontextmanager
4215 4215 else:
4216 4216 lock = util.nullcontextmanager
4217 4217 tr = util.nullcontextmanager
4218 4218 dsguard = lambda: dirstateguard.dirstateguard(repo, b'import')
4219 4219 with lock(), tr(), dsguard():
4220 4220 parents = repo[None].parents()
4221 4221 for patchurl in patches:
4222 4222 if patchurl == b'-':
4223 4223 ui.status(_(b'applying patch from stdin\n'))
4224 4224 patchfile = ui.fin
4225 4225 patchurl = b'stdin' # for error message
4226 4226 else:
4227 4227 patchurl = os.path.join(base, patchurl)
4228 4228 ui.status(_(b'applying %s\n') % patchurl)
4229 4229 patchfile = hg.openpath(ui, patchurl, sendaccept=False)
4230 4230
4231 4231 haspatch = False
4232 4232 for hunk in patch.split(patchfile):
4233 4233 with patch.extract(ui, hunk) as patchdata:
4234 4234 msg, node, rej = cmdutil.tryimportone(
4235 4235 ui, repo, patchdata, parents, opts, msgs, hg.clean
4236 4236 )
4237 4237 if msg:
4238 4238 haspatch = True
4239 4239 ui.note(msg + b'\n')
4240 4240 if update or exact:
4241 4241 parents = repo[None].parents()
4242 4242 else:
4243 4243 parents = [repo[node]]
4244 4244 if rej:
4245 4245 ui.write_err(_(b"patch applied partially\n"))
4246 4246 ui.write_err(
4247 4247 _(
4248 4248 b"(fix the .rej files and run "
4249 4249 b"`hg commit --amend`)\n"
4250 4250 )
4251 4251 )
4252 4252 ret = 1
4253 4253 break
4254 4254
4255 4255 if not haspatch:
4256 4256 raise error.Abort(_(b'%s: no diffs found') % patchurl)
4257 4257
4258 4258 if msgs:
4259 4259 repo.savecommitmessage(b'\n* * *\n'.join(msgs))
4260 4260 return ret
4261 4261
4262 4262
4263 4263 @command(
4264 4264 b'incoming|in',
4265 4265 [
4266 4266 (
4267 4267 b'f',
4268 4268 b'force',
4269 4269 None,
4270 4270 _(b'run even if remote repository is unrelated'),
4271 4271 ),
4272 4272 (b'n', b'newest-first', None, _(b'show newest record first')),
4273 4273 (b'', b'bundle', b'', _(b'file to store the bundles into'), _(b'FILE')),
4274 4274 (
4275 4275 b'r',
4276 4276 b'rev',
4277 4277 [],
4278 4278 _(b'a remote changeset intended to be added'),
4279 4279 _(b'REV'),
4280 4280 ),
4281 4281 (b'B', b'bookmarks', False, _(b"compare bookmarks")),
4282 4282 (
4283 4283 b'b',
4284 4284 b'branch',
4285 4285 [],
4286 4286 _(b'a specific branch you would like to pull'),
4287 4287 _(b'BRANCH'),
4288 4288 ),
4289 4289 ]
4290 4290 + logopts
4291 4291 + remoteopts
4292 4292 + subrepoopts,
4293 4293 _(b'[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'),
4294 4294 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
4295 4295 )
4296 4296 def incoming(ui, repo, source=b"default", **opts):
4297 4297 """show new changesets found in source
4298 4298
4299 4299 Show new changesets found in the specified path/URL or the default
4300 4300 pull location. These are the changesets that would have been pulled
4301 4301 by :hg:`pull` at the time you issued this command.
4302 4302
4303 4303 See pull for valid source format details.
4304 4304
4305 4305 .. container:: verbose
4306 4306
4307 4307 With -B/--bookmarks, the result of bookmark comparison between
4308 4308 local and remote repositories is displayed. With -v/--verbose,
4309 4309 status is also displayed for each bookmark like below::
4310 4310
4311 4311 BM1 01234567890a added
4312 4312 BM2 1234567890ab advanced
4313 4313 BM3 234567890abc diverged
4314 4314 BM4 34567890abcd changed
4315 4315
4316 4316 The action taken locally when pulling depends on the
4317 4317 status of each bookmark:
4318 4318
4319 4319 :``added``: pull will create it
4320 4320 :``advanced``: pull will update it
4321 4321 :``diverged``: pull will create a divergent bookmark
4322 4322 :``changed``: result depends on remote changesets
4323 4323
4324 4324 From the point of view of pulling behavior, bookmark
4325 4325 existing only in the remote repository are treated as ``added``,
4326 4326 even if it is in fact locally deleted.
4327 4327
4328 4328 .. container:: verbose
4329 4329
4330 4330 For remote repository, using --bundle avoids downloading the
4331 4331 changesets twice if the incoming is followed by a pull.
4332 4332
4333 4333 Examples:
4334 4334
4335 4335 - show incoming changes with patches and full description::
4336 4336
4337 4337 hg incoming -vp
4338 4338
4339 4339 - show incoming changes excluding merges, store a bundle::
4340 4340
4341 4341 hg in -vpM --bundle incoming.hg
4342 4342 hg pull incoming.hg
4343 4343
4344 4344 - briefly list changes inside a bundle::
4345 4345
4346 4346 hg in changes.hg -T "{desc|firstline}\\n"
4347 4347
4348 4348 Returns 0 if there are incoming changes, 1 otherwise.
4349 4349 """
4350 4350 opts = pycompat.byteskwargs(opts)
4351 4351 if opts.get(b'graph'):
4352 4352 logcmdutil.checkunsupportedgraphflags([], opts)
4353 4353
4354 4354 def display(other, chlist, displayer):
4355 4355 revdag = logcmdutil.graphrevs(other, chlist, opts)
4356 4356 logcmdutil.displaygraph(
4357 4357 ui, repo, revdag, displayer, graphmod.asciiedges
4358 4358 )
4359 4359
4360 4360 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
4361 4361 return 0
4362 4362
4363 4363 if opts.get(b'bundle') and opts.get(b'subrepos'):
4364 4364 raise error.Abort(_(b'cannot combine --bundle and --subrepos'))
4365 4365
4366 4366 if opts.get(b'bookmarks'):
4367 4367 source, branches = hg.parseurl(
4368 4368 ui.expandpath(source), opts.get(b'branch')
4369 4369 )
4370 4370 other = hg.peer(repo, opts, source)
4371 4371 if b'bookmarks' not in other.listkeys(b'namespaces'):
4372 4372 ui.warn(_(b"remote doesn't support bookmarks\n"))
4373 4373 return 0
4374 4374 ui.pager(b'incoming')
4375 4375 ui.status(_(b'comparing with %s\n') % util.hidepassword(source))
4376 4376 return bookmarks.incoming(ui, repo, other)
4377 4377
4378 4378 repo._subtoppath = ui.expandpath(source)
4379 4379 try:
4380 4380 return hg.incoming(ui, repo, source, opts)
4381 4381 finally:
4382 4382 del repo._subtoppath
4383 4383
4384 4384
4385 4385 @command(
4386 4386 b'init',
4387 4387 remoteopts,
4388 4388 _(b'[-e CMD] [--remotecmd CMD] [DEST]'),
4389 4389 helpcategory=command.CATEGORY_REPO_CREATION,
4390 4390 helpbasic=True,
4391 4391 norepo=True,
4392 4392 )
4393 4393 def init(ui, dest=b".", **opts):
4394 4394 """create a new repository in the given directory
4395 4395
4396 4396 Initialize a new repository in the given directory. If the given
4397 4397 directory does not exist, it will be created.
4398 4398
4399 4399 If no directory is given, the current directory is used.
4400 4400
4401 4401 It is possible to specify an ``ssh://`` URL as the destination.
4402 4402 See :hg:`help urls` for more information.
4403 4403
4404 4404 Returns 0 on success.
4405 4405 """
4406 4406 opts = pycompat.byteskwargs(opts)
4407 4407 hg.peer(ui, opts, ui.expandpath(dest), create=True)
4408 4408
4409 4409
4410 4410 @command(
4411 4411 b'locate',
4412 4412 [
4413 4413 (
4414 4414 b'r',
4415 4415 b'rev',
4416 4416 b'',
4417 4417 _(b'search the repository as it is in REV'),
4418 4418 _(b'REV'),
4419 4419 ),
4420 4420 (
4421 4421 b'0',
4422 4422 b'print0',
4423 4423 None,
4424 4424 _(b'end filenames with NUL, for use with xargs'),
4425 4425 ),
4426 4426 (
4427 4427 b'f',
4428 4428 b'fullpath',
4429 4429 None,
4430 4430 _(b'print complete paths from the filesystem root'),
4431 4431 ),
4432 4432 ]
4433 4433 + walkopts,
4434 4434 _(b'[OPTION]... [PATTERN]...'),
4435 4435 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
4436 4436 )
4437 4437 def locate(ui, repo, *pats, **opts):
4438 4438 """locate files matching specific patterns (DEPRECATED)
4439 4439
4440 4440 Print files under Mercurial control in the working directory whose
4441 4441 names match the given patterns.
4442 4442
4443 4443 By default, this command searches all directories in the working
4444 4444 directory. To search just the current directory and its
4445 4445 subdirectories, use "--include .".
4446 4446
4447 4447 If no patterns are given to match, this command prints the names
4448 4448 of all files under Mercurial control in the working directory.
4449 4449
4450 4450 If you want to feed the output of this command into the "xargs"
4451 4451 command, use the -0 option to both this command and "xargs". This
4452 4452 will avoid the problem of "xargs" treating single filenames that
4453 4453 contain whitespace as multiple filenames.
4454 4454
4455 4455 See :hg:`help files` for a more versatile command.
4456 4456
4457 4457 Returns 0 if a match is found, 1 otherwise.
4458 4458 """
4459 4459 opts = pycompat.byteskwargs(opts)
4460 4460 if opts.get(b'print0'):
4461 4461 end = b'\0'
4462 4462 else:
4463 4463 end = b'\n'
4464 4464 ctx = scmutil.revsingle(repo, opts.get(b'rev'), None)
4465 4465
4466 4466 ret = 1
4467 4467 m = scmutil.match(
4468 4468 ctx, pats, opts, default=b'relglob', badfn=lambda x, y: False
4469 4469 )
4470 4470
4471 4471 ui.pager(b'locate')
4472 4472 if ctx.rev() is None:
4473 4473 # When run on the working copy, "locate" includes removed files, so
4474 4474 # we get the list of files from the dirstate.
4475 4475 filesgen = sorted(repo.dirstate.matches(m))
4476 4476 else:
4477 4477 filesgen = ctx.matches(m)
4478 4478 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=bool(pats))
4479 4479 for abs in filesgen:
4480 4480 if opts.get(b'fullpath'):
4481 4481 ui.write(repo.wjoin(abs), end)
4482 4482 else:
4483 4483 ui.write(uipathfn(abs), end)
4484 4484 ret = 0
4485 4485
4486 4486 return ret
4487 4487
4488 4488
4489 4489 @command(
4490 4490 b'log|history',
4491 4491 [
4492 4492 (
4493 4493 b'f',
4494 4494 b'follow',
4495 4495 None,
4496 4496 _(
4497 4497 b'follow changeset history, or file history across copies and renames'
4498 4498 ),
4499 4499 ),
4500 4500 (
4501 4501 b'',
4502 4502 b'follow-first',
4503 4503 None,
4504 4504 _(b'only follow the first parent of merge changesets (DEPRECATED)'),
4505 4505 ),
4506 4506 (
4507 4507 b'd',
4508 4508 b'date',
4509 4509 b'',
4510 4510 _(b'show revisions matching date spec'),
4511 4511 _(b'DATE'),
4512 4512 ),
4513 4513 (b'C', b'copies', None, _(b'show copied files')),
4514 4514 (
4515 4515 b'k',
4516 4516 b'keyword',
4517 4517 [],
4518 4518 _(b'do case-insensitive search for a given text'),
4519 4519 _(b'TEXT'),
4520 4520 ),
4521 4521 (
4522 4522 b'r',
4523 4523 b'rev',
4524 4524 [],
4525 4525 _(b'show the specified revision or revset'),
4526 4526 _(b'REV'),
4527 4527 ),
4528 4528 (
4529 4529 b'L',
4530 4530 b'line-range',
4531 4531 [],
4532 4532 _(b'follow line range of specified file (EXPERIMENTAL)'),
4533 4533 _(b'FILE,RANGE'),
4534 4534 ),
4535 4535 (
4536 4536 b'',
4537 4537 b'removed',
4538 4538 None,
4539 4539 _(b'include revisions where files were removed'),
4540 4540 ),
4541 4541 (
4542 4542 b'm',
4543 4543 b'only-merges',
4544 4544 None,
4545 4545 _(b'show only merges (DEPRECATED) (use -r "merge()" instead)'),
4546 4546 ),
4547 4547 (b'u', b'user', [], _(b'revisions committed by user'), _(b'USER')),
4548 4548 (
4549 4549 b'',
4550 4550 b'only-branch',
4551 4551 [],
4552 4552 _(
4553 4553 b'show only changesets within the given named branch (DEPRECATED)'
4554 4554 ),
4555 4555 _(b'BRANCH'),
4556 4556 ),
4557 4557 (
4558 4558 b'b',
4559 4559 b'branch',
4560 4560 [],
4561 4561 _(b'show changesets within the given named branch'),
4562 4562 _(b'BRANCH'),
4563 4563 ),
4564 4564 (
4565 4565 b'P',
4566 4566 b'prune',
4567 4567 [],
4568 4568 _(b'do not display revision or any of its ancestors'),
4569 4569 _(b'REV'),
4570 4570 ),
4571 4571 ]
4572 4572 + logopts
4573 4573 + walkopts,
4574 4574 _(b'[OPTION]... [FILE]'),
4575 4575 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
4576 4576 helpbasic=True,
4577 4577 inferrepo=True,
4578 4578 intents={INTENT_READONLY},
4579 4579 )
4580 4580 def log(ui, repo, *pats, **opts):
4581 4581 """show revision history of entire repository or files
4582 4582
4583 4583 Print the revision history of the specified files or the entire
4584 4584 project.
4585 4585
4586 4586 If no revision range is specified, the default is ``tip:0`` unless
4587 4587 --follow is set, in which case the working directory parent is
4588 4588 used as the starting revision.
4589 4589
4590 4590 File history is shown without following rename or copy history of
4591 4591 files. Use -f/--follow with a filename to follow history across
4592 4592 renames and copies. --follow without a filename will only show
4593 4593 ancestors of the starting revision.
4594 4594
4595 4595 By default this command prints revision number and changeset id,
4596 4596 tags, non-trivial parents, user, date and time, and a summary for
4597 4597 each commit. When the -v/--verbose switch is used, the list of
4598 4598 changed files and full commit message are shown.
4599 4599
4600 4600 With --graph the revisions are shown as an ASCII art DAG with the most
4601 4601 recent changeset at the top.
4602 4602 'o' is a changeset, '@' is a working directory parent, '_' closes a branch,
4603 4603 'x' is obsolete, '*' is unstable, and '+' represents a fork where the
4604 4604 changeset from the lines below is a parent of the 'o' merge on the same
4605 4605 line.
4606 4606 Paths in the DAG are represented with '|', '/' and so forth. ':' in place
4607 4607 of a '|' indicates one or more revisions in a path are omitted.
4608 4608
4609 4609 .. container:: verbose
4610 4610
4611 4611 Use -L/--line-range FILE,M:N options to follow the history of lines
4612 4612 from M to N in FILE. With -p/--patch only diff hunks affecting
4613 4613 specified line range will be shown. This option requires --follow;
4614 4614 it can be specified multiple times. Currently, this option is not
4615 4615 compatible with --graph. This option is experimental.
4616 4616
4617 4617 .. note::
4618 4618
4619 4619 :hg:`log --patch` may generate unexpected diff output for merge
4620 4620 changesets, as it will only compare the merge changeset against
4621 4621 its first parent. Also, only files different from BOTH parents
4622 4622 will appear in files:.
4623 4623
4624 4624 .. note::
4625 4625
4626 4626 For performance reasons, :hg:`log FILE` may omit duplicate changes
4627 4627 made on branches and will not show removals or mode changes. To
4628 4628 see all such changes, use the --removed switch.
4629 4629
4630 4630 .. container:: verbose
4631 4631
4632 4632 .. note::
4633 4633
4634 4634 The history resulting from -L/--line-range options depends on diff
4635 4635 options; for instance if white-spaces are ignored, respective changes
4636 4636 with only white-spaces in specified line range will not be listed.
4637 4637
4638 4638 .. container:: verbose
4639 4639
4640 4640 Some examples:
4641 4641
4642 4642 - changesets with full descriptions and file lists::
4643 4643
4644 4644 hg log -v
4645 4645
4646 4646 - changesets ancestral to the working directory::
4647 4647
4648 4648 hg log -f
4649 4649
4650 4650 - last 10 commits on the current branch::
4651 4651
4652 4652 hg log -l 10 -b .
4653 4653
4654 4654 - changesets showing all modifications of a file, including removals::
4655 4655
4656 4656 hg log --removed file.c
4657 4657
4658 4658 - all changesets that touch a directory, with diffs, excluding merges::
4659 4659
4660 4660 hg log -Mp lib/
4661 4661
4662 4662 - all revision numbers that match a keyword::
4663 4663
4664 4664 hg log -k bug --template "{rev}\\n"
4665 4665
4666 4666 - the full hash identifier of the working directory parent::
4667 4667
4668 4668 hg log -r . --template "{node}\\n"
4669 4669
4670 4670 - list available log templates::
4671 4671
4672 4672 hg log -T list
4673 4673
4674 4674 - check if a given changeset is included in a tagged release::
4675 4675
4676 4676 hg log -r "a21ccf and ancestor(1.9)"
4677 4677
4678 4678 - find all changesets by some user in a date range::
4679 4679
4680 4680 hg log -k alice -d "may 2008 to jul 2008"
4681 4681
4682 4682 - summary of all changesets after the last tag::
4683 4683
4684 4684 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4685 4685
4686 4686 - changesets touching lines 13 to 23 for file.c::
4687 4687
4688 4688 hg log -L file.c,13:23
4689 4689
4690 4690 - changesets touching lines 13 to 23 for file.c and lines 2 to 6 of
4691 4691 main.c with patch::
4692 4692
4693 4693 hg log -L file.c,13:23 -L main.c,2:6 -p
4694 4694
4695 4695 See :hg:`help dates` for a list of formats valid for -d/--date.
4696 4696
4697 4697 See :hg:`help revisions` for more about specifying and ordering
4698 4698 revisions.
4699 4699
4700 4700 See :hg:`help templates` for more about pre-packaged styles and
4701 4701 specifying custom templates. The default template used by the log
4702 4702 command can be customized via the ``ui.logtemplate`` configuration
4703 4703 setting.
4704 4704
4705 4705 Returns 0 on success.
4706 4706
4707 4707 """
4708 4708 opts = pycompat.byteskwargs(opts)
4709 4709 linerange = opts.get(b'line_range')
4710 4710
4711 4711 if linerange and not opts.get(b'follow'):
4712 4712 raise error.Abort(_(b'--line-range requires --follow'))
4713 4713
4714 4714 if linerange and pats:
4715 4715 # TODO: take pats as patterns with no line-range filter
4716 4716 raise error.Abort(
4717 4717 _(b'FILE arguments are not compatible with --line-range option')
4718 4718 )
4719 4719
4720 4720 repo = scmutil.unhidehashlikerevs(repo, opts.get(b'rev'), b'nowarn')
4721 4721 revs, differ = logcmdutil.getrevs(repo, pats, opts)
4722 4722 if linerange:
4723 4723 # TODO: should follow file history from logcmdutil._initialrevs(),
4724 4724 # then filter the result by logcmdutil._makerevset() and --limit
4725 4725 revs, differ = logcmdutil.getlinerangerevs(repo, revs, opts)
4726 4726
4727 4727 getcopies = None
4728 4728 if opts.get(b'copies'):
4729 4729 endrev = None
4730 4730 if revs:
4731 4731 endrev = revs.max() + 1
4732 4732 getcopies = scmutil.getcopiesfn(repo, endrev=endrev)
4733 4733
4734 4734 ui.pager(b'log')
4735 4735 displayer = logcmdutil.changesetdisplayer(
4736 4736 ui, repo, opts, differ, buffered=True
4737 4737 )
4738 4738 if opts.get(b'graph'):
4739 4739 displayfn = logcmdutil.displaygraphrevs
4740 4740 else:
4741 4741 displayfn = logcmdutil.displayrevs
4742 4742 displayfn(ui, repo, revs, displayer, getcopies)
4743 4743
4744 4744
4745 4745 @command(
4746 4746 b'manifest',
4747 4747 [
4748 4748 (b'r', b'rev', b'', _(b'revision to display'), _(b'REV')),
4749 4749 (b'', b'all', False, _(b"list files from all revisions")),
4750 4750 ]
4751 4751 + formatteropts,
4752 4752 _(b'[-r REV]'),
4753 4753 helpcategory=command.CATEGORY_MAINTENANCE,
4754 4754 intents={INTENT_READONLY},
4755 4755 )
4756 4756 def manifest(ui, repo, node=None, rev=None, **opts):
4757 4757 """output the current or given revision of the project manifest
4758 4758
4759 4759 Print a list of version controlled files for the given revision.
4760 4760 If no revision is given, the first parent of the working directory
4761 4761 is used, or the null revision if no revision is checked out.
4762 4762
4763 4763 With -v, print file permissions, symlink and executable bits.
4764 4764 With --debug, print file revision hashes.
4765 4765
4766 4766 If option --all is specified, the list of all files from all revisions
4767 4767 is printed. This includes deleted and renamed files.
4768 4768
4769 4769 Returns 0 on success.
4770 4770 """
4771 4771 opts = pycompat.byteskwargs(opts)
4772 4772 fm = ui.formatter(b'manifest', opts)
4773 4773
4774 4774 if opts.get(b'all'):
4775 4775 if rev or node:
4776 4776 raise error.Abort(_(b"can't specify a revision with --all"))
4777 4777
4778 4778 res = set()
4779 4779 for rev in repo:
4780 4780 ctx = repo[rev]
4781 4781 res |= set(ctx.files())
4782 4782
4783 4783 ui.pager(b'manifest')
4784 4784 for f in sorted(res):
4785 4785 fm.startitem()
4786 4786 fm.write(b"path", b'%s\n', f)
4787 4787 fm.end()
4788 4788 return
4789 4789
4790 4790 if rev and node:
4791 4791 raise error.Abort(_(b"please specify just one revision"))
4792 4792
4793 4793 if not node:
4794 4794 node = rev
4795 4795
4796 4796 char = {b'l': b'@', b'x': b'*', b'': b'', b't': b'd'}
4797 4797 mode = {b'l': b'644', b'x': b'755', b'': b'644', b't': b'755'}
4798 4798 if node:
4799 4799 repo = scmutil.unhidehashlikerevs(repo, [node], b'nowarn')
4800 4800 ctx = scmutil.revsingle(repo, node)
4801 4801 mf = ctx.manifest()
4802 4802 ui.pager(b'manifest')
4803 4803 for f in ctx:
4804 4804 fm.startitem()
4805 4805 fm.context(ctx=ctx)
4806 4806 fl = ctx[f].flags()
4807 4807 fm.condwrite(ui.debugflag, b'hash', b'%s ', hex(mf[f]))
4808 4808 fm.condwrite(ui.verbose, b'mode type', b'%s %1s ', mode[fl], char[fl])
4809 4809 fm.write(b'path', b'%s\n', f)
4810 4810 fm.end()
4811 4811
4812 4812
4813 4813 @command(
4814 4814 b'merge',
4815 4815 [
4816 4816 (
4817 4817 b'f',
4818 4818 b'force',
4819 4819 None,
4820 4820 _(b'force a merge including outstanding changes (DEPRECATED)'),
4821 4821 ),
4822 4822 (b'r', b'rev', b'', _(b'revision to merge'), _(b'REV')),
4823 4823 (
4824 4824 b'P',
4825 4825 b'preview',
4826 4826 None,
4827 4827 _(b'review revisions to merge (no merge is performed)'),
4828 4828 ),
4829 4829 (b'', b'abort', None, _(b'abort the ongoing merge')),
4830 4830 ]
4831 4831 + mergetoolopts,
4832 4832 _(b'[-P] [[-r] REV]'),
4833 4833 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
4834 4834 helpbasic=True,
4835 4835 )
4836 4836 def merge(ui, repo, node=None, **opts):
4837 4837 """merge another revision into working directory
4838 4838
4839 4839 The current working directory is updated with all changes made in
4840 4840 the requested revision since the last common predecessor revision.
4841 4841
4842 4842 Files that changed between either parent are marked as changed for
4843 4843 the next commit and a commit must be performed before any further
4844 4844 updates to the repository are allowed. The next commit will have
4845 4845 two parents.
4846 4846
4847 4847 ``--tool`` can be used to specify the merge tool used for file
4848 4848 merges. It overrides the HGMERGE environment variable and your
4849 4849 configuration files. See :hg:`help merge-tools` for options.
4850 4850
4851 4851 If no revision is specified, the working directory's parent is a
4852 4852 head revision, and the current branch contains exactly one other
4853 4853 head, the other head is merged with by default. Otherwise, an
4854 4854 explicit revision with which to merge must be provided.
4855 4855
4856 4856 See :hg:`help resolve` for information on handling file conflicts.
4857 4857
4858 4858 To undo an uncommitted merge, use :hg:`merge --abort` which
4859 4859 will check out a clean copy of the original merge parent, losing
4860 4860 all changes.
4861 4861
4862 4862 Returns 0 on success, 1 if there are unresolved files.
4863 4863 """
4864 4864
4865 4865 opts = pycompat.byteskwargs(opts)
4866 4866 abort = opts.get(b'abort')
4867 4867 if abort and repo.dirstate.p2() == nullid:
4868 4868 cmdutil.wrongtooltocontinue(repo, _(b'merge'))
4869 4869 if abort:
4870 4870 state = cmdutil.getunfinishedstate(repo)
4871 4871 if state and state._opname != b'merge':
4872 4872 raise error.Abort(
4873 4873 _(b'cannot abort merge with %s in progress') % (state._opname),
4874 4874 hint=state.hint(),
4875 4875 )
4876 4876 if node:
4877 4877 raise error.Abort(_(b"cannot specify a node with --abort"))
4878 4878 if opts.get(b'rev'):
4879 4879 raise error.Abort(_(b"cannot specify both --rev and --abort"))
4880 4880 if opts.get(b'preview'):
4881 4881 raise error.Abort(_(b"cannot specify --preview with --abort"))
4882 4882 if opts.get(b'rev') and node:
4883 4883 raise error.Abort(_(b"please specify just one revision"))
4884 4884 if not node:
4885 4885 node = opts.get(b'rev')
4886 4886
4887 4887 if node:
4888 4888 node = scmutil.revsingle(repo, node).node()
4889 4889
4890 4890 if not node and not abort:
4891 if ui.configbool(b'commands', b'merge.require-rev'):
4892 raise error.Abort(
4893 _(
4894 b'configuration requires specifying revision to merge '
4895 b'with'
4896 )
4897 )
4891 4898 node = repo[destutil.destmerge(repo)].node()
4892 4899
4893 4900 if opts.get(b'preview'):
4894 4901 # find nodes that are ancestors of p2 but not of p1
4895 4902 p1 = repo.lookup(b'.')
4896 4903 p2 = node
4897 4904 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4898 4905
4899 4906 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
4900 4907 for node in nodes:
4901 4908 displayer.show(repo[node])
4902 4909 displayer.close()
4903 4910 return 0
4904 4911
4905 4912 # ui.forcemerge is an internal variable, do not document
4906 4913 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
4907 4914 with ui.configoverride(overrides, b'merge'):
4908 4915 force = opts.get(b'force')
4909 4916 labels = [b'working copy', b'merge rev']
4910 4917 return hg.merge(
4911 4918 repo,
4912 4919 node,
4913 4920 force=force,
4914 4921 mergeforce=force,
4915 4922 labels=labels,
4916 4923 abort=abort,
4917 4924 )
4918 4925
4919 4926
4920 4927 statemod.addunfinished(
4921 4928 b'merge',
4922 4929 fname=None,
4923 4930 clearable=True,
4924 4931 allowcommit=True,
4925 4932 cmdmsg=_(b'outstanding uncommitted merge'),
4926 4933 abortfunc=hg.abortmerge,
4927 4934 statushint=_(
4928 4935 b'To continue: hg commit\nTo abort: hg merge --abort'
4929 4936 ),
4930 4937 cmdhint=_(b"use 'hg commit' or 'hg merge --abort'"),
4931 4938 )
4932 4939
4933 4940
4934 4941 @command(
4935 4942 b'outgoing|out',
4936 4943 [
4937 4944 (
4938 4945 b'f',
4939 4946 b'force',
4940 4947 None,
4941 4948 _(b'run even when the destination is unrelated'),
4942 4949 ),
4943 4950 (
4944 4951 b'r',
4945 4952 b'rev',
4946 4953 [],
4947 4954 _(b'a changeset intended to be included in the destination'),
4948 4955 _(b'REV'),
4949 4956 ),
4950 4957 (b'n', b'newest-first', None, _(b'show newest record first')),
4951 4958 (b'B', b'bookmarks', False, _(b'compare bookmarks')),
4952 4959 (
4953 4960 b'b',
4954 4961 b'branch',
4955 4962 [],
4956 4963 _(b'a specific branch you would like to push'),
4957 4964 _(b'BRANCH'),
4958 4965 ),
4959 4966 ]
4960 4967 + logopts
4961 4968 + remoteopts
4962 4969 + subrepoopts,
4963 4970 _(b'[-M] [-p] [-n] [-f] [-r REV]... [DEST]'),
4964 4971 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
4965 4972 )
4966 4973 def outgoing(ui, repo, dest=None, **opts):
4967 4974 """show changesets not found in the destination
4968 4975
4969 4976 Show changesets not found in the specified destination repository
4970 4977 or the default push location. These are the changesets that would
4971 4978 be pushed if a push was requested.
4972 4979
4973 4980 See pull for details of valid destination formats.
4974 4981
4975 4982 .. container:: verbose
4976 4983
4977 4984 With -B/--bookmarks, the result of bookmark comparison between
4978 4985 local and remote repositories is displayed. With -v/--verbose,
4979 4986 status is also displayed for each bookmark like below::
4980 4987
4981 4988 BM1 01234567890a added
4982 4989 BM2 deleted
4983 4990 BM3 234567890abc advanced
4984 4991 BM4 34567890abcd diverged
4985 4992 BM5 4567890abcde changed
4986 4993
4987 4994 The action taken when pushing depends on the
4988 4995 status of each bookmark:
4989 4996
4990 4997 :``added``: push with ``-B`` will create it
4991 4998 :``deleted``: push with ``-B`` will delete it
4992 4999 :``advanced``: push will update it
4993 5000 :``diverged``: push with ``-B`` will update it
4994 5001 :``changed``: push with ``-B`` will update it
4995 5002
4996 5003 From the point of view of pushing behavior, bookmarks
4997 5004 existing only in the remote repository are treated as
4998 5005 ``deleted``, even if it is in fact added remotely.
4999 5006
5000 5007 Returns 0 if there are outgoing changes, 1 otherwise.
5001 5008 """
5002 5009 # hg._outgoing() needs to re-resolve the path in order to handle #branch
5003 5010 # style URLs, so don't overwrite dest.
5004 5011 path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
5005 5012 if not path:
5006 5013 raise error.Abort(
5007 5014 _(b'default repository not configured!'),
5008 5015 hint=_(b"see 'hg help config.paths'"),
5009 5016 )
5010 5017
5011 5018 opts = pycompat.byteskwargs(opts)
5012 5019 if opts.get(b'graph'):
5013 5020 logcmdutil.checkunsupportedgraphflags([], opts)
5014 5021 o, other = hg._outgoing(ui, repo, dest, opts)
5015 5022 if not o:
5016 5023 cmdutil.outgoinghooks(ui, repo, other, opts, o)
5017 5024 return
5018 5025
5019 5026 revdag = logcmdutil.graphrevs(repo, o, opts)
5020 5027 ui.pager(b'outgoing')
5021 5028 displayer = logcmdutil.changesetdisplayer(ui, repo, opts, buffered=True)
5022 5029 logcmdutil.displaygraph(
5023 5030 ui, repo, revdag, displayer, graphmod.asciiedges
5024 5031 )
5025 5032 cmdutil.outgoinghooks(ui, repo, other, opts, o)
5026 5033 return 0
5027 5034
5028 5035 if opts.get(b'bookmarks'):
5029 5036 dest = path.pushloc or path.loc
5030 5037 other = hg.peer(repo, opts, dest)
5031 5038 if b'bookmarks' not in other.listkeys(b'namespaces'):
5032 5039 ui.warn(_(b"remote doesn't support bookmarks\n"))
5033 5040 return 0
5034 5041 ui.status(_(b'comparing with %s\n') % util.hidepassword(dest))
5035 5042 ui.pager(b'outgoing')
5036 5043 return bookmarks.outgoing(ui, repo, other)
5037 5044
5038 5045 repo._subtoppath = path.pushloc or path.loc
5039 5046 try:
5040 5047 return hg.outgoing(ui, repo, dest, opts)
5041 5048 finally:
5042 5049 del repo._subtoppath
5043 5050
5044 5051
5045 5052 @command(
5046 5053 b'parents',
5047 5054 [
5048 5055 (
5049 5056 b'r',
5050 5057 b'rev',
5051 5058 b'',
5052 5059 _(b'show parents of the specified revision'),
5053 5060 _(b'REV'),
5054 5061 ),
5055 5062 ]
5056 5063 + templateopts,
5057 5064 _(b'[-r REV] [FILE]'),
5058 5065 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
5059 5066 inferrepo=True,
5060 5067 )
5061 5068 def parents(ui, repo, file_=None, **opts):
5062 5069 """show the parents of the working directory or revision (DEPRECATED)
5063 5070
5064 5071 Print the working directory's parent revisions. If a revision is
5065 5072 given via -r/--rev, the parent of that revision will be printed.
5066 5073 If a file argument is given, the revision in which the file was
5067 5074 last changed (before the working directory revision or the
5068 5075 argument to --rev if given) is printed.
5069 5076
5070 5077 This command is equivalent to::
5071 5078
5072 5079 hg log -r "p1()+p2()" or
5073 5080 hg log -r "p1(REV)+p2(REV)" or
5074 5081 hg log -r "max(::p1() and file(FILE))+max(::p2() and file(FILE))" or
5075 5082 hg log -r "max(::p1(REV) and file(FILE))+max(::p2(REV) and file(FILE))"
5076 5083
5077 5084 See :hg:`summary` and :hg:`help revsets` for related information.
5078 5085
5079 5086 Returns 0 on success.
5080 5087 """
5081 5088
5082 5089 opts = pycompat.byteskwargs(opts)
5083 5090 rev = opts.get(b'rev')
5084 5091 if rev:
5085 5092 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
5086 5093 ctx = scmutil.revsingle(repo, rev, None)
5087 5094
5088 5095 if file_:
5089 5096 m = scmutil.match(ctx, (file_,), opts)
5090 5097 if m.anypats() or len(m.files()) != 1:
5091 5098 raise error.Abort(_(b'can only specify an explicit filename'))
5092 5099 file_ = m.files()[0]
5093 5100 filenodes = []
5094 5101 for cp in ctx.parents():
5095 5102 if not cp:
5096 5103 continue
5097 5104 try:
5098 5105 filenodes.append(cp.filenode(file_))
5099 5106 except error.LookupError:
5100 5107 pass
5101 5108 if not filenodes:
5102 5109 raise error.Abort(_(b"'%s' not found in manifest!") % file_)
5103 5110 p = []
5104 5111 for fn in filenodes:
5105 5112 fctx = repo.filectx(file_, fileid=fn)
5106 5113 p.append(fctx.node())
5107 5114 else:
5108 5115 p = [cp.node() for cp in ctx.parents()]
5109 5116
5110 5117 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
5111 5118 for n in p:
5112 5119 if n != nullid:
5113 5120 displayer.show(repo[n])
5114 5121 displayer.close()
5115 5122
5116 5123
5117 5124 @command(
5118 5125 b'paths',
5119 5126 formatteropts,
5120 5127 _(b'[NAME]'),
5121 5128 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
5122 5129 optionalrepo=True,
5123 5130 intents={INTENT_READONLY},
5124 5131 )
5125 5132 def paths(ui, repo, search=None, **opts):
5126 5133 """show aliases for remote repositories
5127 5134
5128 5135 Show definition of symbolic path name NAME. If no name is given,
5129 5136 show definition of all available names.
5130 5137
5131 5138 Option -q/--quiet suppresses all output when searching for NAME
5132 5139 and shows only the path names when listing all definitions.
5133 5140
5134 5141 Path names are defined in the [paths] section of your
5135 5142 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
5136 5143 repository, ``.hg/hgrc`` is used, too.
5137 5144
5138 5145 The path names ``default`` and ``default-push`` have a special
5139 5146 meaning. When performing a push or pull operation, they are used
5140 5147 as fallbacks if no location is specified on the command-line.
5141 5148 When ``default-push`` is set, it will be used for push and
5142 5149 ``default`` will be used for pull; otherwise ``default`` is used
5143 5150 as the fallback for both. When cloning a repository, the clone
5144 5151 source is written as ``default`` in ``.hg/hgrc``.
5145 5152
5146 5153 .. note::
5147 5154
5148 5155 ``default`` and ``default-push`` apply to all inbound (e.g.
5149 5156 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email`
5150 5157 and :hg:`bundle`) operations.
5151 5158
5152 5159 See :hg:`help urls` for more information.
5153 5160
5154 5161 .. container:: verbose
5155 5162
5156 5163 Template:
5157 5164
5158 5165 The following keywords are supported. See also :hg:`help templates`.
5159 5166
5160 5167 :name: String. Symbolic name of the path alias.
5161 5168 :pushurl: String. URL for push operations.
5162 5169 :url: String. URL or directory path for the other operations.
5163 5170
5164 5171 Returns 0 on success.
5165 5172 """
5166 5173
5167 5174 opts = pycompat.byteskwargs(opts)
5168 5175 ui.pager(b'paths')
5169 5176 if search:
5170 5177 pathitems = [
5171 5178 (name, path)
5172 5179 for name, path in pycompat.iteritems(ui.paths)
5173 5180 if name == search
5174 5181 ]
5175 5182 else:
5176 5183 pathitems = sorted(pycompat.iteritems(ui.paths))
5177 5184
5178 5185 fm = ui.formatter(b'paths', opts)
5179 5186 if fm.isplain():
5180 5187 hidepassword = util.hidepassword
5181 5188 else:
5182 5189 hidepassword = bytes
5183 5190 if ui.quiet:
5184 5191 namefmt = b'%s\n'
5185 5192 else:
5186 5193 namefmt = b'%s = '
5187 5194 showsubopts = not search and not ui.quiet
5188 5195
5189 5196 for name, path in pathitems:
5190 5197 fm.startitem()
5191 5198 fm.condwrite(not search, b'name', namefmt, name)
5192 5199 fm.condwrite(not ui.quiet, b'url', b'%s\n', hidepassword(path.rawloc))
5193 5200 for subopt, value in sorted(path.suboptions.items()):
5194 5201 assert subopt not in (b'name', b'url')
5195 5202 if showsubopts:
5196 5203 fm.plain(b'%s:%s = ' % (name, subopt))
5197 5204 fm.condwrite(showsubopts, subopt, b'%s\n', value)
5198 5205
5199 5206 fm.end()
5200 5207
5201 5208 if search and not pathitems:
5202 5209 if not ui.quiet:
5203 5210 ui.warn(_(b"not found!\n"))
5204 5211 return 1
5205 5212 else:
5206 5213 return 0
5207 5214
5208 5215
5209 5216 @command(
5210 5217 b'phase',
5211 5218 [
5212 5219 (b'p', b'public', False, _(b'set changeset phase to public')),
5213 5220 (b'd', b'draft', False, _(b'set changeset phase to draft')),
5214 5221 (b's', b'secret', False, _(b'set changeset phase to secret')),
5215 5222 (b'f', b'force', False, _(b'allow to move boundary backward')),
5216 5223 (b'r', b'rev', [], _(b'target revision'), _(b'REV')),
5217 5224 ],
5218 5225 _(b'[-p|-d|-s] [-f] [-r] [REV...]'),
5219 5226 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
5220 5227 )
5221 5228 def phase(ui, repo, *revs, **opts):
5222 5229 """set or show the current phase name
5223 5230
5224 5231 With no argument, show the phase name of the current revision(s).
5225 5232
5226 5233 With one of -p/--public, -d/--draft or -s/--secret, change the
5227 5234 phase value of the specified revisions.
5228 5235
5229 5236 Unless -f/--force is specified, :hg:`phase` won't move changesets from a
5230 5237 lower phase to a higher phase. Phases are ordered as follows::
5231 5238
5232 5239 public < draft < secret
5233 5240
5234 5241 Returns 0 on success, 1 if some phases could not be changed.
5235 5242
5236 5243 (For more information about the phases concept, see :hg:`help phases`.)
5237 5244 """
5238 5245 opts = pycompat.byteskwargs(opts)
5239 5246 # search for a unique phase argument
5240 5247 targetphase = None
5241 5248 for idx, name in enumerate(phases.cmdphasenames):
5242 5249 if opts[name]:
5243 5250 if targetphase is not None:
5244 5251 raise error.Abort(_(b'only one phase can be specified'))
5245 5252 targetphase = idx
5246 5253
5247 5254 # look for specified revision
5248 5255 revs = list(revs)
5249 5256 revs.extend(opts[b'rev'])
5250 5257 if not revs:
5251 5258 # display both parents as the second parent phase can influence
5252 5259 # the phase of a merge commit
5253 5260 revs = [c.rev() for c in repo[None].parents()]
5254 5261
5255 5262 revs = scmutil.revrange(repo, revs)
5256 5263
5257 5264 ret = 0
5258 5265 if targetphase is None:
5259 5266 # display
5260 5267 for r in revs:
5261 5268 ctx = repo[r]
5262 5269 ui.write(b'%i: %s\n' % (ctx.rev(), ctx.phasestr()))
5263 5270 else:
5264 5271 with repo.lock(), repo.transaction(b"phase") as tr:
5265 5272 # set phase
5266 5273 if not revs:
5267 5274 raise error.Abort(_(b'empty revision set'))
5268 5275 nodes = [repo[r].node() for r in revs]
5269 5276 # moving revision from public to draft may hide them
5270 5277 # We have to check result on an unfiltered repository
5271 5278 unfi = repo.unfiltered()
5272 5279 getphase = unfi._phasecache.phase
5273 5280 olddata = [getphase(unfi, r) for r in unfi]
5274 5281 phases.advanceboundary(repo, tr, targetphase, nodes)
5275 5282 if opts[b'force']:
5276 5283 phases.retractboundary(repo, tr, targetphase, nodes)
5277 5284 getphase = unfi._phasecache.phase
5278 5285 newdata = [getphase(unfi, r) for r in unfi]
5279 5286 changes = sum(newdata[r] != olddata[r] for r in unfi)
5280 5287 cl = unfi.changelog
5281 5288 rejected = [n for n in nodes if newdata[cl.rev(n)] < targetphase]
5282 5289 if rejected:
5283 5290 ui.warn(
5284 5291 _(
5285 5292 b'cannot move %i changesets to a higher '
5286 5293 b'phase, use --force\n'
5287 5294 )
5288 5295 % len(rejected)
5289 5296 )
5290 5297 ret = 1
5291 5298 if changes:
5292 5299 msg = _(b'phase changed for %i changesets\n') % changes
5293 5300 if ret:
5294 5301 ui.status(msg)
5295 5302 else:
5296 5303 ui.note(msg)
5297 5304 else:
5298 5305 ui.warn(_(b'no phases changed\n'))
5299 5306 return ret
5300 5307
5301 5308
5302 5309 def postincoming(ui, repo, modheads, optupdate, checkout, brev):
5303 5310 """Run after a changegroup has been added via pull/unbundle
5304 5311
5305 5312 This takes arguments below:
5306 5313
5307 5314 :modheads: change of heads by pull/unbundle
5308 5315 :optupdate: updating working directory is needed or not
5309 5316 :checkout: update destination revision (or None to default destination)
5310 5317 :brev: a name, which might be a bookmark to be activated after updating
5311 5318 """
5312 5319 if modheads == 0:
5313 5320 return
5314 5321 if optupdate:
5315 5322 try:
5316 5323 return hg.updatetotally(ui, repo, checkout, brev)
5317 5324 except error.UpdateAbort as inst:
5318 5325 msg = _(b"not updating: %s") % stringutil.forcebytestr(inst)
5319 5326 hint = inst.hint
5320 5327 raise error.UpdateAbort(msg, hint=hint)
5321 5328 if modheads is not None and modheads > 1:
5322 5329 currentbranchheads = len(repo.branchheads())
5323 5330 if currentbranchheads == modheads:
5324 5331 ui.status(
5325 5332 _(b"(run 'hg heads' to see heads, 'hg merge' to merge)\n")
5326 5333 )
5327 5334 elif currentbranchheads > 1:
5328 5335 ui.status(
5329 5336 _(b"(run 'hg heads .' to see heads, 'hg merge' to merge)\n")
5330 5337 )
5331 5338 else:
5332 5339 ui.status(_(b"(run 'hg heads' to see heads)\n"))
5333 5340 elif not ui.configbool(b'commands', b'update.requiredest'):
5334 5341 ui.status(_(b"(run 'hg update' to get a working copy)\n"))
5335 5342
5336 5343
5337 5344 @command(
5338 5345 b'pull',
5339 5346 [
5340 5347 (
5341 5348 b'u',
5342 5349 b'update',
5343 5350 None,
5344 5351 _(b'update to new branch head if new descendants were pulled'),
5345 5352 ),
5346 5353 (
5347 5354 b'f',
5348 5355 b'force',
5349 5356 None,
5350 5357 _(b'run even when remote repository is unrelated'),
5351 5358 ),
5352 5359 (
5353 5360 b'r',
5354 5361 b'rev',
5355 5362 [],
5356 5363 _(b'a remote changeset intended to be added'),
5357 5364 _(b'REV'),
5358 5365 ),
5359 5366 (b'B', b'bookmark', [], _(b"bookmark to pull"), _(b'BOOKMARK')),
5360 5367 (
5361 5368 b'b',
5362 5369 b'branch',
5363 5370 [],
5364 5371 _(b'a specific branch you would like to pull'),
5365 5372 _(b'BRANCH'),
5366 5373 ),
5367 5374 ]
5368 5375 + remoteopts,
5369 5376 _(b'[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'),
5370 5377 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
5371 5378 helpbasic=True,
5372 5379 )
5373 5380 def pull(ui, repo, source=b"default", **opts):
5374 5381 """pull changes from the specified source
5375 5382
5376 5383 Pull changes from a remote repository to a local one.
5377 5384
5378 5385 This finds all changes from the repository at the specified path
5379 5386 or URL and adds them to a local repository (the current one unless
5380 5387 -R is specified). By default, this does not update the copy of the
5381 5388 project in the working directory.
5382 5389
5383 5390 When cloning from servers that support it, Mercurial may fetch
5384 5391 pre-generated data. When this is done, hooks operating on incoming
5385 5392 changesets and changegroups may fire more than once, once for each
5386 5393 pre-generated bundle and as well as for any additional remaining
5387 5394 data. See :hg:`help -e clonebundles` for more.
5388 5395
5389 5396 Use :hg:`incoming` if you want to see what would have been added
5390 5397 by a pull at the time you issued this command. If you then decide
5391 5398 to add those changes to the repository, you should use :hg:`pull
5392 5399 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
5393 5400
5394 5401 If SOURCE is omitted, the 'default' path will be used.
5395 5402 See :hg:`help urls` for more information.
5396 5403
5397 5404 Specifying bookmark as ``.`` is equivalent to specifying the active
5398 5405 bookmark's name.
5399 5406
5400 5407 Returns 0 on success, 1 if an update had unresolved files.
5401 5408 """
5402 5409
5403 5410 opts = pycompat.byteskwargs(opts)
5404 5411 if ui.configbool(b'commands', b'update.requiredest') and opts.get(
5405 5412 b'update'
5406 5413 ):
5407 5414 msg = _(b'update destination required by configuration')
5408 5415 hint = _(b'use hg pull followed by hg update DEST')
5409 5416 raise error.Abort(msg, hint=hint)
5410 5417
5411 5418 source, branches = hg.parseurl(ui.expandpath(source), opts.get(b'branch'))
5412 5419 ui.status(_(b'pulling from %s\n') % util.hidepassword(source))
5413 5420 other = hg.peer(repo, opts, source)
5414 5421 try:
5415 5422 revs, checkout = hg.addbranchrevs(
5416 5423 repo, other, branches, opts.get(b'rev')
5417 5424 )
5418 5425
5419 5426 pullopargs = {}
5420 5427
5421 5428 nodes = None
5422 5429 if opts.get(b'bookmark') or revs:
5423 5430 # The list of bookmark used here is the same used to actually update
5424 5431 # the bookmark names, to avoid the race from issue 4689 and we do
5425 5432 # all lookup and bookmark queries in one go so they see the same
5426 5433 # version of the server state (issue 4700).
5427 5434 nodes = []
5428 5435 fnodes = []
5429 5436 revs = revs or []
5430 5437 if revs and not other.capable(b'lookup'):
5431 5438 err = _(
5432 5439 b"other repository doesn't support revision lookup, "
5433 5440 b"so a rev cannot be specified."
5434 5441 )
5435 5442 raise error.Abort(err)
5436 5443 with other.commandexecutor() as e:
5437 5444 fremotebookmarks = e.callcommand(
5438 5445 b'listkeys', {b'namespace': b'bookmarks'}
5439 5446 )
5440 5447 for r in revs:
5441 5448 fnodes.append(e.callcommand(b'lookup', {b'key': r}))
5442 5449 remotebookmarks = fremotebookmarks.result()
5443 5450 remotebookmarks = bookmarks.unhexlifybookmarks(remotebookmarks)
5444 5451 pullopargs[b'remotebookmarks'] = remotebookmarks
5445 5452 for b in opts.get(b'bookmark', []):
5446 5453 b = repo._bookmarks.expandname(b)
5447 5454 if b not in remotebookmarks:
5448 5455 raise error.Abort(_(b'remote bookmark %s not found!') % b)
5449 5456 nodes.append(remotebookmarks[b])
5450 5457 for i, rev in enumerate(revs):
5451 5458 node = fnodes[i].result()
5452 5459 nodes.append(node)
5453 5460 if rev == checkout:
5454 5461 checkout = node
5455 5462
5456 5463 wlock = util.nullcontextmanager()
5457 5464 if opts.get(b'update'):
5458 5465 wlock = repo.wlock()
5459 5466 with wlock:
5460 5467 pullopargs.update(opts.get(b'opargs', {}))
5461 5468 modheads = exchange.pull(
5462 5469 repo,
5463 5470 other,
5464 5471 heads=nodes,
5465 5472 force=opts.get(b'force'),
5466 5473 bookmarks=opts.get(b'bookmark', ()),
5467 5474 opargs=pullopargs,
5468 5475 ).cgresult
5469 5476
5470 5477 # brev is a name, which might be a bookmark to be activated at
5471 5478 # the end of the update. In other words, it is an explicit
5472 5479 # destination of the update
5473 5480 brev = None
5474 5481
5475 5482 if checkout:
5476 5483 checkout = repo.unfiltered().changelog.rev(checkout)
5477 5484
5478 5485 # order below depends on implementation of
5479 5486 # hg.addbranchrevs(). opts['bookmark'] is ignored,
5480 5487 # because 'checkout' is determined without it.
5481 5488 if opts.get(b'rev'):
5482 5489 brev = opts[b'rev'][0]
5483 5490 elif opts.get(b'branch'):
5484 5491 brev = opts[b'branch'][0]
5485 5492 else:
5486 5493 brev = branches[0]
5487 5494 repo._subtoppath = source
5488 5495 try:
5489 5496 ret = postincoming(
5490 5497 ui, repo, modheads, opts.get(b'update'), checkout, brev
5491 5498 )
5492 5499 except error.FilteredRepoLookupError as exc:
5493 5500 msg = _(b'cannot update to target: %s') % exc.args[0]
5494 5501 exc.args = (msg,) + exc.args[1:]
5495 5502 raise
5496 5503 finally:
5497 5504 del repo._subtoppath
5498 5505
5499 5506 finally:
5500 5507 other.close()
5501 5508 return ret
5502 5509
5503 5510
5504 5511 @command(
5505 5512 b'push',
5506 5513 [
5507 5514 (b'f', b'force', None, _(b'force push')),
5508 5515 (
5509 5516 b'r',
5510 5517 b'rev',
5511 5518 [],
5512 5519 _(b'a changeset intended to be included in the destination'),
5513 5520 _(b'REV'),
5514 5521 ),
5515 5522 (b'B', b'bookmark', [], _(b"bookmark to push"), _(b'BOOKMARK')),
5516 5523 (
5517 5524 b'b',
5518 5525 b'branch',
5519 5526 [],
5520 5527 _(b'a specific branch you would like to push'),
5521 5528 _(b'BRANCH'),
5522 5529 ),
5523 5530 (b'', b'new-branch', False, _(b'allow pushing a new branch')),
5524 5531 (
5525 5532 b'',
5526 5533 b'pushvars',
5527 5534 [],
5528 5535 _(b'variables that can be sent to server (ADVANCED)'),
5529 5536 ),
5530 5537 (
5531 5538 b'',
5532 5539 b'publish',
5533 5540 False,
5534 5541 _(b'push the changeset as public (EXPERIMENTAL)'),
5535 5542 ),
5536 5543 ]
5537 5544 + remoteopts,
5538 5545 _(b'[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'),
5539 5546 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
5540 5547 helpbasic=True,
5541 5548 )
5542 5549 def push(ui, repo, dest=None, **opts):
5543 5550 """push changes to the specified destination
5544 5551
5545 5552 Push changesets from the local repository to the specified
5546 5553 destination.
5547 5554
5548 5555 This operation is symmetrical to pull: it is identical to a pull
5549 5556 in the destination repository from the current one.
5550 5557
5551 5558 By default, push will not allow creation of new heads at the
5552 5559 destination, since multiple heads would make it unclear which head
5553 5560 to use. In this situation, it is recommended to pull and merge
5554 5561 before pushing.
5555 5562
5556 5563 Use --new-branch if you want to allow push to create a new named
5557 5564 branch that is not present at the destination. This allows you to
5558 5565 only create a new branch without forcing other changes.
5559 5566
5560 5567 .. note::
5561 5568
5562 5569 Extra care should be taken with the -f/--force option,
5563 5570 which will push all new heads on all branches, an action which will
5564 5571 almost always cause confusion for collaborators.
5565 5572
5566 5573 If -r/--rev is used, the specified revision and all its ancestors
5567 5574 will be pushed to the remote repository.
5568 5575
5569 5576 If -B/--bookmark is used, the specified bookmarked revision, its
5570 5577 ancestors, and the bookmark will be pushed to the remote
5571 5578 repository. Specifying ``.`` is equivalent to specifying the active
5572 5579 bookmark's name.
5573 5580
5574 5581 Please see :hg:`help urls` for important details about ``ssh://``
5575 5582 URLs. If DESTINATION is omitted, a default path will be used.
5576 5583
5577 5584 .. container:: verbose
5578 5585
5579 5586 The --pushvars option sends strings to the server that become
5580 5587 environment variables prepended with ``HG_USERVAR_``. For example,
5581 5588 ``--pushvars ENABLE_FEATURE=true``, provides the server side hooks with
5582 5589 ``HG_USERVAR_ENABLE_FEATURE=true`` as part of their environment.
5583 5590
5584 5591 pushvars can provide for user-overridable hooks as well as set debug
5585 5592 levels. One example is having a hook that blocks commits containing
5586 5593 conflict markers, but enables the user to override the hook if the file
5587 5594 is using conflict markers for testing purposes or the file format has
5588 5595 strings that look like conflict markers.
5589 5596
5590 5597 By default, servers will ignore `--pushvars`. To enable it add the
5591 5598 following to your configuration file::
5592 5599
5593 5600 [push]
5594 5601 pushvars.server = true
5595 5602
5596 5603 Returns 0 if push was successful, 1 if nothing to push.
5597 5604 """
5598 5605
5599 5606 opts = pycompat.byteskwargs(opts)
5600 5607 if opts.get(b'bookmark'):
5601 5608 ui.setconfig(b'bookmarks', b'pushing', opts[b'bookmark'], b'push')
5602 5609 for b in opts[b'bookmark']:
5603 5610 # translate -B options to -r so changesets get pushed
5604 5611 b = repo._bookmarks.expandname(b)
5605 5612 if b in repo._bookmarks:
5606 5613 opts.setdefault(b'rev', []).append(b)
5607 5614 else:
5608 5615 # if we try to push a deleted bookmark, translate it to null
5609 5616 # this lets simultaneous -r, -b options continue working
5610 5617 opts.setdefault(b'rev', []).append(b"null")
5611 5618
5612 5619 path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
5613 5620 if not path:
5614 5621 raise error.Abort(
5615 5622 _(b'default repository not configured!'),
5616 5623 hint=_(b"see 'hg help config.paths'"),
5617 5624 )
5618 5625 dest = path.pushloc or path.loc
5619 5626 branches = (path.branch, opts.get(b'branch') or [])
5620 5627 ui.status(_(b'pushing to %s\n') % util.hidepassword(dest))
5621 5628 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get(b'rev'))
5622 5629 other = hg.peer(repo, opts, dest)
5623 5630
5624 5631 if revs:
5625 5632 revs = [repo[r].node() for r in scmutil.revrange(repo, revs)]
5626 5633 if not revs:
5627 5634 raise error.Abort(
5628 5635 _(b"specified revisions evaluate to an empty set"),
5629 5636 hint=_(b"use different revision arguments"),
5630 5637 )
5631 5638 elif path.pushrev:
5632 5639 # It doesn't make any sense to specify ancestor revisions. So limit
5633 5640 # to DAG heads to make discovery simpler.
5634 5641 expr = revsetlang.formatspec(b'heads(%r)', path.pushrev)
5635 5642 revs = scmutil.revrange(repo, [expr])
5636 5643 revs = [repo[rev].node() for rev in revs]
5637 5644 if not revs:
5638 5645 raise error.Abort(
5639 5646 _(b'default push revset for path evaluates to an empty set')
5640 5647 )
5641 5648 elif ui.configbool(b'commands', b'push.require-revs'):
5642 5649 raise error.Abort(
5643 5650 _(b'no revisions specified to push'),
5644 5651 hint=_(b'did you mean "hg push -r ."?'),
5645 5652 )
5646 5653
5647 5654 repo._subtoppath = dest
5648 5655 try:
5649 5656 # push subrepos depth-first for coherent ordering
5650 5657 c = repo[b'.']
5651 5658 subs = c.substate # only repos that are committed
5652 5659 for s in sorted(subs):
5653 5660 result = c.sub(s).push(opts)
5654 5661 if result == 0:
5655 5662 return not result
5656 5663 finally:
5657 5664 del repo._subtoppath
5658 5665
5659 5666 opargs = dict(opts.get(b'opargs', {})) # copy opargs since we may mutate it
5660 5667 opargs.setdefault(b'pushvars', []).extend(opts.get(b'pushvars', []))
5661 5668
5662 5669 pushop = exchange.push(
5663 5670 repo,
5664 5671 other,
5665 5672 opts.get(b'force'),
5666 5673 revs=revs,
5667 5674 newbranch=opts.get(b'new_branch'),
5668 5675 bookmarks=opts.get(b'bookmark', ()),
5669 5676 publish=opts.get(b'publish'),
5670 5677 opargs=opargs,
5671 5678 )
5672 5679
5673 5680 result = not pushop.cgresult
5674 5681
5675 5682 if pushop.bkresult is not None:
5676 5683 if pushop.bkresult == 2:
5677 5684 result = 2
5678 5685 elif not result and pushop.bkresult:
5679 5686 result = 2
5680 5687
5681 5688 return result
5682 5689
5683 5690
5684 5691 @command(
5685 5692 b'recover',
5686 5693 [(b'', b'verify', True, b"run `hg verify` after succesful recover"),],
5687 5694 helpcategory=command.CATEGORY_MAINTENANCE,
5688 5695 )
5689 5696 def recover(ui, repo, **opts):
5690 5697 """roll back an interrupted transaction
5691 5698
5692 5699 Recover from an interrupted commit or pull.
5693 5700
5694 5701 This command tries to fix the repository status after an
5695 5702 interrupted operation. It should only be necessary when Mercurial
5696 5703 suggests it.
5697 5704
5698 5705 Returns 0 if successful, 1 if nothing to recover or verify fails.
5699 5706 """
5700 5707 ret = repo.recover()
5701 5708 if ret:
5702 5709 if opts['verify']:
5703 5710 return hg.verify(repo)
5704 5711 else:
5705 5712 msg = _(
5706 5713 b"(verify step skipped, run `hg verify` to check your "
5707 5714 b"repository content)\n"
5708 5715 )
5709 5716 ui.warn(msg)
5710 5717 return 0
5711 5718 return 1
5712 5719
5713 5720
5714 5721 @command(
5715 5722 b'remove|rm',
5716 5723 [
5717 5724 (b'A', b'after', None, _(b'record delete for missing files')),
5718 5725 (b'f', b'force', None, _(b'forget added files, delete modified files')),
5719 5726 ]
5720 5727 + subrepoopts
5721 5728 + walkopts
5722 5729 + dryrunopts,
5723 5730 _(b'[OPTION]... FILE...'),
5724 5731 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
5725 5732 helpbasic=True,
5726 5733 inferrepo=True,
5727 5734 )
5728 5735 def remove(ui, repo, *pats, **opts):
5729 5736 """remove the specified files on the next commit
5730 5737
5731 5738 Schedule the indicated files for removal from the current branch.
5732 5739
5733 5740 This command schedules the files to be removed at the next commit.
5734 5741 To undo a remove before that, see :hg:`revert`. To undo added
5735 5742 files, see :hg:`forget`.
5736 5743
5737 5744 .. container:: verbose
5738 5745
5739 5746 -A/--after can be used to remove only files that have already
5740 5747 been deleted, -f/--force can be used to force deletion, and -Af
5741 5748 can be used to remove files from the next revision without
5742 5749 deleting them from the working directory.
5743 5750
5744 5751 The following table details the behavior of remove for different
5745 5752 file states (columns) and option combinations (rows). The file
5746 5753 states are Added [A], Clean [C], Modified [M] and Missing [!]
5747 5754 (as reported by :hg:`status`). The actions are Warn, Remove
5748 5755 (from branch) and Delete (from disk):
5749 5756
5750 5757 ========= == == == ==
5751 5758 opt/state A C M !
5752 5759 ========= == == == ==
5753 5760 none W RD W R
5754 5761 -f R RD RD R
5755 5762 -A W W W R
5756 5763 -Af R R R R
5757 5764 ========= == == == ==
5758 5765
5759 5766 .. note::
5760 5767
5761 5768 :hg:`remove` never deletes files in Added [A] state from the
5762 5769 working directory, not even if ``--force`` is specified.
5763 5770
5764 5771 Returns 0 on success, 1 if any warnings encountered.
5765 5772 """
5766 5773
5767 5774 opts = pycompat.byteskwargs(opts)
5768 5775 after, force = opts.get(b'after'), opts.get(b'force')
5769 5776 dryrun = opts.get(b'dry_run')
5770 5777 if not pats and not after:
5771 5778 raise error.Abort(_(b'no files specified'))
5772 5779
5773 5780 m = scmutil.match(repo[None], pats, opts)
5774 5781 subrepos = opts.get(b'subrepos')
5775 5782 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
5776 5783 return cmdutil.remove(
5777 5784 ui, repo, m, b"", uipathfn, after, force, subrepos, dryrun=dryrun
5778 5785 )
5779 5786
5780 5787
5781 5788 @command(
5782 5789 b'rename|move|mv',
5783 5790 [
5784 5791 (b'A', b'after', None, _(b'record a rename that has already occurred')),
5785 5792 (
5786 5793 b'f',
5787 5794 b'force',
5788 5795 None,
5789 5796 _(b'forcibly move over an existing managed file'),
5790 5797 ),
5791 5798 ]
5792 5799 + walkopts
5793 5800 + dryrunopts,
5794 5801 _(b'[OPTION]... SOURCE... DEST'),
5795 5802 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
5796 5803 )
5797 5804 def rename(ui, repo, *pats, **opts):
5798 5805 """rename files; equivalent of copy + remove
5799 5806
5800 5807 Mark dest as copies of sources; mark sources for deletion. If dest
5801 5808 is a directory, copies are put in that directory. If dest is a
5802 5809 file, there can only be one source.
5803 5810
5804 5811 By default, this command copies the contents of files as they
5805 5812 exist in the working directory. If invoked with -A/--after, the
5806 5813 operation is recorded, but no copying is performed.
5807 5814
5808 5815 This command takes effect at the next commit. To undo a rename
5809 5816 before that, see :hg:`revert`.
5810 5817
5811 5818 Returns 0 on success, 1 if errors are encountered.
5812 5819 """
5813 5820 opts = pycompat.byteskwargs(opts)
5814 5821 with repo.wlock(False):
5815 5822 return cmdutil.copy(ui, repo, pats, opts, rename=True)
5816 5823
5817 5824
5818 5825 @command(
5819 5826 b'resolve',
5820 5827 [
5821 5828 (b'a', b'all', None, _(b'select all unresolved files')),
5822 5829 (b'l', b'list', None, _(b'list state of files needing merge')),
5823 5830 (b'm', b'mark', None, _(b'mark files as resolved')),
5824 5831 (b'u', b'unmark', None, _(b'mark files as unresolved')),
5825 5832 (b'n', b'no-status', None, _(b'hide status prefix')),
5826 5833 (b'', b're-merge', None, _(b're-merge files')),
5827 5834 ]
5828 5835 + mergetoolopts
5829 5836 + walkopts
5830 5837 + formatteropts,
5831 5838 _(b'[OPTION]... [FILE]...'),
5832 5839 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
5833 5840 inferrepo=True,
5834 5841 )
5835 5842 def resolve(ui, repo, *pats, **opts):
5836 5843 """redo merges or set/view the merge status of files
5837 5844
5838 5845 Merges with unresolved conflicts are often the result of
5839 5846 non-interactive merging using the ``internal:merge`` configuration
5840 5847 setting, or a command-line merge tool like ``diff3``. The resolve
5841 5848 command is used to manage the files involved in a merge, after
5842 5849 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
5843 5850 working directory must have two parents). See :hg:`help
5844 5851 merge-tools` for information on configuring merge tools.
5845 5852
5846 5853 The resolve command can be used in the following ways:
5847 5854
5848 5855 - :hg:`resolve [--re-merge] [--tool TOOL] FILE...`: attempt to re-merge
5849 5856 the specified files, discarding any previous merge attempts. Re-merging
5850 5857 is not performed for files already marked as resolved. Use ``--all/-a``
5851 5858 to select all unresolved files. ``--tool`` can be used to specify
5852 5859 the merge tool used for the given files. It overrides the HGMERGE
5853 5860 environment variable and your configuration files. Previous file
5854 5861 contents are saved with a ``.orig`` suffix.
5855 5862
5856 5863 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
5857 5864 (e.g. after having manually fixed-up the files). The default is
5858 5865 to mark all unresolved files.
5859 5866
5860 5867 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
5861 5868 default is to mark all resolved files.
5862 5869
5863 5870 - :hg:`resolve -l`: list files which had or still have conflicts.
5864 5871 In the printed list, ``U`` = unresolved and ``R`` = resolved.
5865 5872 You can use ``set:unresolved()`` or ``set:resolved()`` to filter
5866 5873 the list. See :hg:`help filesets` for details.
5867 5874
5868 5875 .. note::
5869 5876
5870 5877 Mercurial will not let you commit files with unresolved merge
5871 5878 conflicts. You must use :hg:`resolve -m ...` before you can
5872 5879 commit after a conflicting merge.
5873 5880
5874 5881 .. container:: verbose
5875 5882
5876 5883 Template:
5877 5884
5878 5885 The following keywords are supported in addition to the common template
5879 5886 keywords and functions. See also :hg:`help templates`.
5880 5887
5881 5888 :mergestatus: String. Character denoting merge conflicts, ``U`` or ``R``.
5882 5889 :path: String. Repository-absolute path of the file.
5883 5890
5884 5891 Returns 0 on success, 1 if any files fail a resolve attempt.
5885 5892 """
5886 5893
5887 5894 opts = pycompat.byteskwargs(opts)
5888 5895 confirm = ui.configbool(b'commands', b'resolve.confirm')
5889 5896 flaglist = b'all mark unmark list no_status re_merge'.split()
5890 5897 all, mark, unmark, show, nostatus, remerge = [opts.get(o) for o in flaglist]
5891 5898
5892 5899 actioncount = len(list(filter(None, [show, mark, unmark, remerge])))
5893 5900 if actioncount > 1:
5894 5901 raise error.Abort(_(b"too many actions specified"))
5895 5902 elif actioncount == 0 and ui.configbool(
5896 5903 b'commands', b'resolve.explicit-re-merge'
5897 5904 ):
5898 5905 hint = _(b'use --mark, --unmark, --list or --re-merge')
5899 5906 raise error.Abort(_(b'no action specified'), hint=hint)
5900 5907 if pats and all:
5901 5908 raise error.Abort(_(b"can't specify --all and patterns"))
5902 5909 if not (all or pats or show or mark or unmark):
5903 5910 raise error.Abort(
5904 5911 _(b'no files or directories specified'),
5905 5912 hint=b'use --all to re-merge all unresolved files',
5906 5913 )
5907 5914
5908 5915 if confirm:
5909 5916 if all:
5910 5917 if ui.promptchoice(
5911 5918 _(b're-merge all unresolved files (yn)?$$ &Yes $$ &No')
5912 5919 ):
5913 5920 raise error.Abort(_(b'user quit'))
5914 5921 if mark and not pats:
5915 5922 if ui.promptchoice(
5916 5923 _(
5917 5924 b'mark all unresolved files as resolved (yn)?'
5918 5925 b'$$ &Yes $$ &No'
5919 5926 )
5920 5927 ):
5921 5928 raise error.Abort(_(b'user quit'))
5922 5929 if unmark and not pats:
5923 5930 if ui.promptchoice(
5924 5931 _(
5925 5932 b'mark all resolved files as unresolved (yn)?'
5926 5933 b'$$ &Yes $$ &No'
5927 5934 )
5928 5935 ):
5929 5936 raise error.Abort(_(b'user quit'))
5930 5937
5931 5938 uipathfn = scmutil.getuipathfn(repo)
5932 5939
5933 5940 if show:
5934 5941 ui.pager(b'resolve')
5935 5942 fm = ui.formatter(b'resolve', opts)
5936 5943 ms = mergemod.mergestate.read(repo)
5937 5944 wctx = repo[None]
5938 5945 m = scmutil.match(wctx, pats, opts)
5939 5946
5940 5947 # Labels and keys based on merge state. Unresolved path conflicts show
5941 5948 # as 'P'. Resolved path conflicts show as 'R', the same as normal
5942 5949 # resolved conflicts.
5943 5950 mergestateinfo = {
5944 5951 mergemod.MERGE_RECORD_UNRESOLVED: (b'resolve.unresolved', b'U'),
5945 5952 mergemod.MERGE_RECORD_RESOLVED: (b'resolve.resolved', b'R'),
5946 5953 mergemod.MERGE_RECORD_UNRESOLVED_PATH: (
5947 5954 b'resolve.unresolved',
5948 5955 b'P',
5949 5956 ),
5950 5957 mergemod.MERGE_RECORD_RESOLVED_PATH: (b'resolve.resolved', b'R'),
5951 5958 mergemod.MERGE_RECORD_DRIVER_RESOLVED: (
5952 5959 b'resolve.driverresolved',
5953 5960 b'D',
5954 5961 ),
5955 5962 }
5956 5963
5957 5964 for f in ms:
5958 5965 if not m(f):
5959 5966 continue
5960 5967
5961 5968 label, key = mergestateinfo[ms[f]]
5962 5969 fm.startitem()
5963 5970 fm.context(ctx=wctx)
5964 5971 fm.condwrite(not nostatus, b'mergestatus', b'%s ', key, label=label)
5965 5972 fm.data(path=f)
5966 5973 fm.plain(b'%s\n' % uipathfn(f), label=label)
5967 5974 fm.end()
5968 5975 return 0
5969 5976
5970 5977 with repo.wlock():
5971 5978 ms = mergemod.mergestate.read(repo)
5972 5979
5973 5980 if not (ms.active() or repo.dirstate.p2() != nullid):
5974 5981 raise error.Abort(
5975 5982 _(b'resolve command not applicable when not merging')
5976 5983 )
5977 5984
5978 5985 wctx = repo[None]
5979 5986
5980 5987 if (
5981 5988 ms.mergedriver
5982 5989 and ms.mdstate() == mergemod.MERGE_DRIVER_STATE_UNMARKED
5983 5990 ):
5984 5991 proceed = mergemod.driverpreprocess(repo, ms, wctx)
5985 5992 ms.commit()
5986 5993 # allow mark and unmark to go through
5987 5994 if not mark and not unmark and not proceed:
5988 5995 return 1
5989 5996
5990 5997 m = scmutil.match(wctx, pats, opts)
5991 5998 ret = 0
5992 5999 didwork = False
5993 6000 runconclude = False
5994 6001
5995 6002 tocomplete = []
5996 6003 hasconflictmarkers = []
5997 6004 if mark:
5998 6005 markcheck = ui.config(b'commands', b'resolve.mark-check')
5999 6006 if markcheck not in [b'warn', b'abort']:
6000 6007 # Treat all invalid / unrecognized values as 'none'.
6001 6008 markcheck = False
6002 6009 for f in ms:
6003 6010 if not m(f):
6004 6011 continue
6005 6012
6006 6013 didwork = True
6007 6014
6008 6015 # don't let driver-resolved files be marked, and run the conclude
6009 6016 # step if asked to resolve
6010 6017 if ms[f] == mergemod.MERGE_RECORD_DRIVER_RESOLVED:
6011 6018 exact = m.exact(f)
6012 6019 if mark:
6013 6020 if exact:
6014 6021 ui.warn(
6015 6022 _(b'not marking %s as it is driver-resolved\n')
6016 6023 % uipathfn(f)
6017 6024 )
6018 6025 elif unmark:
6019 6026 if exact:
6020 6027 ui.warn(
6021 6028 _(b'not unmarking %s as it is driver-resolved\n')
6022 6029 % uipathfn(f)
6023 6030 )
6024 6031 else:
6025 6032 runconclude = True
6026 6033 continue
6027 6034
6028 6035 # path conflicts must be resolved manually
6029 6036 if ms[f] in (
6030 6037 mergemod.MERGE_RECORD_UNRESOLVED_PATH,
6031 6038 mergemod.MERGE_RECORD_RESOLVED_PATH,
6032 6039 ):
6033 6040 if mark:
6034 6041 ms.mark(f, mergemod.MERGE_RECORD_RESOLVED_PATH)
6035 6042 elif unmark:
6036 6043 ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED_PATH)
6037 6044 elif ms[f] == mergemod.MERGE_RECORD_UNRESOLVED_PATH:
6038 6045 ui.warn(
6039 6046 _(b'%s: path conflict must be resolved manually\n')
6040 6047 % uipathfn(f)
6041 6048 )
6042 6049 continue
6043 6050
6044 6051 if mark:
6045 6052 if markcheck:
6046 6053 fdata = repo.wvfs.tryread(f)
6047 6054 if (
6048 6055 filemerge.hasconflictmarkers(fdata)
6049 6056 and ms[f] != mergemod.MERGE_RECORD_RESOLVED
6050 6057 ):
6051 6058 hasconflictmarkers.append(f)
6052 6059 ms.mark(f, mergemod.MERGE_RECORD_RESOLVED)
6053 6060 elif unmark:
6054 6061 ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED)
6055 6062 else:
6056 6063 # backup pre-resolve (merge uses .orig for its own purposes)
6057 6064 a = repo.wjoin(f)
6058 6065 try:
6059 6066 util.copyfile(a, a + b".resolve")
6060 6067 except (IOError, OSError) as inst:
6061 6068 if inst.errno != errno.ENOENT:
6062 6069 raise
6063 6070
6064 6071 try:
6065 6072 # preresolve file
6066 6073 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
6067 6074 with ui.configoverride(overrides, b'resolve'):
6068 6075 complete, r = ms.preresolve(f, wctx)
6069 6076 if not complete:
6070 6077 tocomplete.append(f)
6071 6078 elif r:
6072 6079 ret = 1
6073 6080 finally:
6074 6081 ms.commit()
6075 6082
6076 6083 # replace filemerge's .orig file with our resolve file, but only
6077 6084 # for merges that are complete
6078 6085 if complete:
6079 6086 try:
6080 6087 util.rename(
6081 6088 a + b".resolve", scmutil.backuppath(ui, repo, f)
6082 6089 )
6083 6090 except OSError as inst:
6084 6091 if inst.errno != errno.ENOENT:
6085 6092 raise
6086 6093
6087 6094 if hasconflictmarkers:
6088 6095 ui.warn(
6089 6096 _(
6090 6097 b'warning: the following files still have conflict '
6091 6098 b'markers:\n'
6092 6099 )
6093 6100 + b''.join(
6094 6101 b' ' + uipathfn(f) + b'\n' for f in hasconflictmarkers
6095 6102 )
6096 6103 )
6097 6104 if markcheck == b'abort' and not all and not pats:
6098 6105 raise error.Abort(
6099 6106 _(b'conflict markers detected'),
6100 6107 hint=_(b'use --all to mark anyway'),
6101 6108 )
6102 6109
6103 6110 for f in tocomplete:
6104 6111 try:
6105 6112 # resolve file
6106 6113 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
6107 6114 with ui.configoverride(overrides, b'resolve'):
6108 6115 r = ms.resolve(f, wctx)
6109 6116 if r:
6110 6117 ret = 1
6111 6118 finally:
6112 6119 ms.commit()
6113 6120
6114 6121 # replace filemerge's .orig file with our resolve file
6115 6122 a = repo.wjoin(f)
6116 6123 try:
6117 6124 util.rename(a + b".resolve", scmutil.backuppath(ui, repo, f))
6118 6125 except OSError as inst:
6119 6126 if inst.errno != errno.ENOENT:
6120 6127 raise
6121 6128
6122 6129 ms.commit()
6123 6130 ms.recordactions()
6124 6131
6125 6132 if not didwork and pats:
6126 6133 hint = None
6127 6134 if not any([p for p in pats if p.find(b':') >= 0]):
6128 6135 pats = [b'path:%s' % p for p in pats]
6129 6136 m = scmutil.match(wctx, pats, opts)
6130 6137 for f in ms:
6131 6138 if not m(f):
6132 6139 continue
6133 6140
6134 6141 def flag(o):
6135 6142 if o == b're_merge':
6136 6143 return b'--re-merge '
6137 6144 return b'-%s ' % o[0:1]
6138 6145
6139 6146 flags = b''.join([flag(o) for o in flaglist if opts.get(o)])
6140 6147 hint = _(b"(try: hg resolve %s%s)\n") % (
6141 6148 flags,
6142 6149 b' '.join(pats),
6143 6150 )
6144 6151 break
6145 6152 ui.warn(_(b"arguments do not match paths that need resolving\n"))
6146 6153 if hint:
6147 6154 ui.warn(hint)
6148 6155 elif ms.mergedriver and ms.mdstate() != b's':
6149 6156 # run conclude step when either a driver-resolved file is requested
6150 6157 # or there are no driver-resolved files
6151 6158 # we can't use 'ret' to determine whether any files are unresolved
6152 6159 # because we might not have tried to resolve some
6153 6160 if (runconclude or not list(ms.driverresolved())) and not list(
6154 6161 ms.unresolved()
6155 6162 ):
6156 6163 proceed = mergemod.driverconclude(repo, ms, wctx)
6157 6164 ms.commit()
6158 6165 if not proceed:
6159 6166 return 1
6160 6167
6161 6168 # Nudge users into finishing an unfinished operation
6162 6169 unresolvedf = list(ms.unresolved())
6163 6170 driverresolvedf = list(ms.driverresolved())
6164 6171 if not unresolvedf and not driverresolvedf:
6165 6172 ui.status(_(b'(no more unresolved files)\n'))
6166 6173 cmdutil.checkafterresolved(repo)
6167 6174 elif not unresolvedf:
6168 6175 ui.status(
6169 6176 _(
6170 6177 b'(no more unresolved files -- '
6171 6178 b'run "hg resolve --all" to conclude)\n'
6172 6179 )
6173 6180 )
6174 6181
6175 6182 return ret
6176 6183
6177 6184
6178 6185 @command(
6179 6186 b'revert',
6180 6187 [
6181 6188 (b'a', b'all', None, _(b'revert all changes when no arguments given')),
6182 6189 (b'd', b'date', b'', _(b'tipmost revision matching date'), _(b'DATE')),
6183 6190 (b'r', b'rev', b'', _(b'revert to the specified revision'), _(b'REV')),
6184 6191 (b'C', b'no-backup', None, _(b'do not save backup copies of files')),
6185 6192 (b'i', b'interactive', None, _(b'interactively select the changes')),
6186 6193 ]
6187 6194 + walkopts
6188 6195 + dryrunopts,
6189 6196 _(b'[OPTION]... [-r REV] [NAME]...'),
6190 6197 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6191 6198 )
6192 6199 def revert(ui, repo, *pats, **opts):
6193 6200 """restore files to their checkout state
6194 6201
6195 6202 .. note::
6196 6203
6197 6204 To check out earlier revisions, you should use :hg:`update REV`.
6198 6205 To cancel an uncommitted merge (and lose your changes),
6199 6206 use :hg:`merge --abort`.
6200 6207
6201 6208 With no revision specified, revert the specified files or directories
6202 6209 to the contents they had in the parent of the working directory.
6203 6210 This restores the contents of files to an unmodified
6204 6211 state and unschedules adds, removes, copies, and renames. If the
6205 6212 working directory has two parents, you must explicitly specify a
6206 6213 revision.
6207 6214
6208 6215 Using the -r/--rev or -d/--date options, revert the given files or
6209 6216 directories to their states as of a specific revision. Because
6210 6217 revert does not change the working directory parents, this will
6211 6218 cause these files to appear modified. This can be helpful to "back
6212 6219 out" some or all of an earlier change. See :hg:`backout` for a
6213 6220 related method.
6214 6221
6215 6222 Modified files are saved with a .orig suffix before reverting.
6216 6223 To disable these backups, use --no-backup. It is possible to store
6217 6224 the backup files in a custom directory relative to the root of the
6218 6225 repository by setting the ``ui.origbackuppath`` configuration
6219 6226 option.
6220 6227
6221 6228 See :hg:`help dates` for a list of formats valid for -d/--date.
6222 6229
6223 6230 See :hg:`help backout` for a way to reverse the effect of an
6224 6231 earlier changeset.
6225 6232
6226 6233 Returns 0 on success.
6227 6234 """
6228 6235
6229 6236 opts = pycompat.byteskwargs(opts)
6230 6237 if opts.get(b"date"):
6231 6238 if opts.get(b"rev"):
6232 6239 raise error.Abort(_(b"you can't specify a revision and a date"))
6233 6240 opts[b"rev"] = cmdutil.finddate(ui, repo, opts[b"date"])
6234 6241
6235 6242 parent, p2 = repo.dirstate.parents()
6236 6243 if not opts.get(b'rev') and p2 != nullid:
6237 6244 # revert after merge is a trap for new users (issue2915)
6238 6245 raise error.Abort(
6239 6246 _(b'uncommitted merge with no revision specified'),
6240 6247 hint=_(b"use 'hg update' or see 'hg help revert'"),
6241 6248 )
6242 6249
6243 6250 rev = opts.get(b'rev')
6244 6251 if rev:
6245 6252 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
6246 6253 ctx = scmutil.revsingle(repo, rev)
6247 6254
6248 6255 if not (
6249 6256 pats
6250 6257 or opts.get(b'include')
6251 6258 or opts.get(b'exclude')
6252 6259 or opts.get(b'all')
6253 6260 or opts.get(b'interactive')
6254 6261 ):
6255 6262 msg = _(b"no files or directories specified")
6256 6263 if p2 != nullid:
6257 6264 hint = _(
6258 6265 b"uncommitted merge, use --all to discard all changes,"
6259 6266 b" or 'hg update -C .' to abort the merge"
6260 6267 )
6261 6268 raise error.Abort(msg, hint=hint)
6262 6269 dirty = any(repo.status())
6263 6270 node = ctx.node()
6264 6271 if node != parent:
6265 6272 if dirty:
6266 6273 hint = (
6267 6274 _(
6268 6275 b"uncommitted changes, use --all to discard all"
6269 6276 b" changes, or 'hg update %d' to update"
6270 6277 )
6271 6278 % ctx.rev()
6272 6279 )
6273 6280 else:
6274 6281 hint = (
6275 6282 _(
6276 6283 b"use --all to revert all files,"
6277 6284 b" or 'hg update %d' to update"
6278 6285 )
6279 6286 % ctx.rev()
6280 6287 )
6281 6288 elif dirty:
6282 6289 hint = _(b"uncommitted changes, use --all to discard all changes")
6283 6290 else:
6284 6291 hint = _(b"use --all to revert all files")
6285 6292 raise error.Abort(msg, hint=hint)
6286 6293
6287 6294 return cmdutil.revert(
6288 6295 ui, repo, ctx, (parent, p2), *pats, **pycompat.strkwargs(opts)
6289 6296 )
6290 6297
6291 6298
6292 6299 @command(
6293 6300 b'rollback',
6294 6301 dryrunopts + [(b'f', b'force', False, _(b'ignore safety measures'))],
6295 6302 helpcategory=command.CATEGORY_MAINTENANCE,
6296 6303 )
6297 6304 def rollback(ui, repo, **opts):
6298 6305 """roll back the last transaction (DANGEROUS) (DEPRECATED)
6299 6306
6300 6307 Please use :hg:`commit --amend` instead of rollback to correct
6301 6308 mistakes in the last commit.
6302 6309
6303 6310 This command should be used with care. There is only one level of
6304 6311 rollback, and there is no way to undo a rollback. It will also
6305 6312 restore the dirstate at the time of the last transaction, losing
6306 6313 any dirstate changes since that time. This command does not alter
6307 6314 the working directory.
6308 6315
6309 6316 Transactions are used to encapsulate the effects of all commands
6310 6317 that create new changesets or propagate existing changesets into a
6311 6318 repository.
6312 6319
6313 6320 .. container:: verbose
6314 6321
6315 6322 For example, the following commands are transactional, and their
6316 6323 effects can be rolled back:
6317 6324
6318 6325 - commit
6319 6326 - import
6320 6327 - pull
6321 6328 - push (with this repository as the destination)
6322 6329 - unbundle
6323 6330
6324 6331 To avoid permanent data loss, rollback will refuse to rollback a
6325 6332 commit transaction if it isn't checked out. Use --force to
6326 6333 override this protection.
6327 6334
6328 6335 The rollback command can be entirely disabled by setting the
6329 6336 ``ui.rollback`` configuration setting to false. If you're here
6330 6337 because you want to use rollback and it's disabled, you can
6331 6338 re-enable the command by setting ``ui.rollback`` to true.
6332 6339
6333 6340 This command is not intended for use on public repositories. Once
6334 6341 changes are visible for pull by other users, rolling a transaction
6335 6342 back locally is ineffective (someone else may already have pulled
6336 6343 the changes). Furthermore, a race is possible with readers of the
6337 6344 repository; for example an in-progress pull from the repository
6338 6345 may fail if a rollback is performed.
6339 6346
6340 6347 Returns 0 on success, 1 if no rollback data is available.
6341 6348 """
6342 6349 if not ui.configbool(b'ui', b'rollback'):
6343 6350 raise error.Abort(
6344 6351 _(b'rollback is disabled because it is unsafe'),
6345 6352 hint=b'see `hg help -v rollback` for information',
6346 6353 )
6347 6354 return repo.rollback(dryrun=opts.get('dry_run'), force=opts.get('force'))
6348 6355
6349 6356
6350 6357 @command(
6351 6358 b'root',
6352 6359 [] + formatteropts,
6353 6360 intents={INTENT_READONLY},
6354 6361 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6355 6362 )
6356 6363 def root(ui, repo, **opts):
6357 6364 """print the root (top) of the current working directory
6358 6365
6359 6366 Print the root directory of the current repository.
6360 6367
6361 6368 .. container:: verbose
6362 6369
6363 6370 Template:
6364 6371
6365 6372 The following keywords are supported in addition to the common template
6366 6373 keywords and functions. See also :hg:`help templates`.
6367 6374
6368 6375 :hgpath: String. Path to the .hg directory.
6369 6376 :storepath: String. Path to the directory holding versioned data.
6370 6377
6371 6378 Returns 0 on success.
6372 6379 """
6373 6380 opts = pycompat.byteskwargs(opts)
6374 6381 with ui.formatter(b'root', opts) as fm:
6375 6382 fm.startitem()
6376 6383 fm.write(b'reporoot', b'%s\n', repo.root)
6377 6384 fm.data(hgpath=repo.path, storepath=repo.spath)
6378 6385
6379 6386
6380 6387 @command(
6381 6388 b'serve',
6382 6389 [
6383 6390 (
6384 6391 b'A',
6385 6392 b'accesslog',
6386 6393 b'',
6387 6394 _(b'name of access log file to write to'),
6388 6395 _(b'FILE'),
6389 6396 ),
6390 6397 (b'd', b'daemon', None, _(b'run server in background')),
6391 6398 (b'', b'daemon-postexec', [], _(b'used internally by daemon mode')),
6392 6399 (
6393 6400 b'E',
6394 6401 b'errorlog',
6395 6402 b'',
6396 6403 _(b'name of error log file to write to'),
6397 6404 _(b'FILE'),
6398 6405 ),
6399 6406 # use string type, then we can check if something was passed
6400 6407 (
6401 6408 b'p',
6402 6409 b'port',
6403 6410 b'',
6404 6411 _(b'port to listen on (default: 8000)'),
6405 6412 _(b'PORT'),
6406 6413 ),
6407 6414 (
6408 6415 b'a',
6409 6416 b'address',
6410 6417 b'',
6411 6418 _(b'address to listen on (default: all interfaces)'),
6412 6419 _(b'ADDR'),
6413 6420 ),
6414 6421 (
6415 6422 b'',
6416 6423 b'prefix',
6417 6424 b'',
6418 6425 _(b'prefix path to serve from (default: server root)'),
6419 6426 _(b'PREFIX'),
6420 6427 ),
6421 6428 (
6422 6429 b'n',
6423 6430 b'name',
6424 6431 b'',
6425 6432 _(b'name to show in web pages (default: working directory)'),
6426 6433 _(b'NAME'),
6427 6434 ),
6428 6435 (
6429 6436 b'',
6430 6437 b'web-conf',
6431 6438 b'',
6432 6439 _(b"name of the hgweb config file (see 'hg help hgweb')"),
6433 6440 _(b'FILE'),
6434 6441 ),
6435 6442 (
6436 6443 b'',
6437 6444 b'webdir-conf',
6438 6445 b'',
6439 6446 _(b'name of the hgweb config file (DEPRECATED)'),
6440 6447 _(b'FILE'),
6441 6448 ),
6442 6449 (
6443 6450 b'',
6444 6451 b'pid-file',
6445 6452 b'',
6446 6453 _(b'name of file to write process ID to'),
6447 6454 _(b'FILE'),
6448 6455 ),
6449 6456 (b'', b'stdio', None, _(b'for remote clients (ADVANCED)')),
6450 6457 (
6451 6458 b'',
6452 6459 b'cmdserver',
6453 6460 b'',
6454 6461 _(b'for remote clients (ADVANCED)'),
6455 6462 _(b'MODE'),
6456 6463 ),
6457 6464 (b't', b'templates', b'', _(b'web templates to use'), _(b'TEMPLATE')),
6458 6465 (b'', b'style', b'', _(b'template style to use'), _(b'STYLE')),
6459 6466 (b'6', b'ipv6', None, _(b'use IPv6 in addition to IPv4')),
6460 6467 (b'', b'certificate', b'', _(b'SSL certificate file'), _(b'FILE')),
6461 6468 (b'', b'print-url', None, _(b'start and print only the URL')),
6462 6469 ]
6463 6470 + subrepoopts,
6464 6471 _(b'[OPTION]...'),
6465 6472 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
6466 6473 helpbasic=True,
6467 6474 optionalrepo=True,
6468 6475 )
6469 6476 def serve(ui, repo, **opts):
6470 6477 """start stand-alone webserver
6471 6478
6472 6479 Start a local HTTP repository browser and pull server. You can use
6473 6480 this for ad-hoc sharing and browsing of repositories. It is
6474 6481 recommended to use a real web server to serve a repository for
6475 6482 longer periods of time.
6476 6483
6477 6484 Please note that the server does not implement access control.
6478 6485 This means that, by default, anybody can read from the server and
6479 6486 nobody can write to it by default. Set the ``web.allow-push``
6480 6487 option to ``*`` to allow everybody to push to the server. You
6481 6488 should use a real web server if you need to authenticate users.
6482 6489
6483 6490 By default, the server logs accesses to stdout and errors to
6484 6491 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
6485 6492 files.
6486 6493
6487 6494 To have the server choose a free port number to listen on, specify
6488 6495 a port number of 0; in this case, the server will print the port
6489 6496 number it uses.
6490 6497
6491 6498 Returns 0 on success.
6492 6499 """
6493 6500
6494 6501 opts = pycompat.byteskwargs(opts)
6495 6502 if opts[b"stdio"] and opts[b"cmdserver"]:
6496 6503 raise error.Abort(_(b"cannot use --stdio with --cmdserver"))
6497 6504 if opts[b"print_url"] and ui.verbose:
6498 6505 raise error.Abort(_(b"cannot use --print-url with --verbose"))
6499 6506
6500 6507 if opts[b"stdio"]:
6501 6508 if repo is None:
6502 6509 raise error.RepoError(
6503 6510 _(b"there is no Mercurial repository here (.hg not found)")
6504 6511 )
6505 6512 s = wireprotoserver.sshserver(ui, repo)
6506 6513 s.serve_forever()
6507 6514
6508 6515 service = server.createservice(ui, repo, opts)
6509 6516 return server.runservice(opts, initfn=service.init, runfn=service.run)
6510 6517
6511 6518
6512 6519 @command(
6513 6520 b'shelve',
6514 6521 [
6515 6522 (
6516 6523 b'A',
6517 6524 b'addremove',
6518 6525 None,
6519 6526 _(b'mark new/missing files as added/removed before shelving'),
6520 6527 ),
6521 6528 (b'u', b'unknown', None, _(b'store unknown files in the shelve')),
6522 6529 (b'', b'cleanup', None, _(b'delete all shelved changes')),
6523 6530 (
6524 6531 b'',
6525 6532 b'date',
6526 6533 b'',
6527 6534 _(b'shelve with the specified commit date'),
6528 6535 _(b'DATE'),
6529 6536 ),
6530 6537 (b'd', b'delete', None, _(b'delete the named shelved change(s)')),
6531 6538 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
6532 6539 (
6533 6540 b'k',
6534 6541 b'keep',
6535 6542 False,
6536 6543 _(b'shelve, but keep changes in the working directory'),
6537 6544 ),
6538 6545 (b'l', b'list', None, _(b'list current shelves')),
6539 6546 (b'm', b'message', b'', _(b'use text as shelve message'), _(b'TEXT')),
6540 6547 (
6541 6548 b'n',
6542 6549 b'name',
6543 6550 b'',
6544 6551 _(b'use the given name for the shelved commit'),
6545 6552 _(b'NAME'),
6546 6553 ),
6547 6554 (
6548 6555 b'p',
6549 6556 b'patch',
6550 6557 None,
6551 6558 _(
6552 6559 b'output patches for changes (provide the names of the shelved '
6553 6560 b'changes as positional arguments)'
6554 6561 ),
6555 6562 ),
6556 6563 (b'i', b'interactive', None, _(b'interactive mode')),
6557 6564 (
6558 6565 b'',
6559 6566 b'stat',
6560 6567 None,
6561 6568 _(
6562 6569 b'output diffstat-style summary of changes (provide the names of '
6563 6570 b'the shelved changes as positional arguments)'
6564 6571 ),
6565 6572 ),
6566 6573 ]
6567 6574 + cmdutil.walkopts,
6568 6575 _(b'hg shelve [OPTION]... [FILE]...'),
6569 6576 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6570 6577 )
6571 6578 def shelve(ui, repo, *pats, **opts):
6572 6579 '''save and set aside changes from the working directory
6573 6580
6574 6581 Shelving takes files that "hg status" reports as not clean, saves
6575 6582 the modifications to a bundle (a shelved change), and reverts the
6576 6583 files so that their state in the working directory becomes clean.
6577 6584
6578 6585 To restore these changes to the working directory, using "hg
6579 6586 unshelve"; this will work even if you switch to a different
6580 6587 commit.
6581 6588
6582 6589 When no files are specified, "hg shelve" saves all not-clean
6583 6590 files. If specific files or directories are named, only changes to
6584 6591 those files are shelved.
6585 6592
6586 6593 In bare shelve (when no files are specified, without interactive,
6587 6594 include and exclude option), shelving remembers information if the
6588 6595 working directory was on newly created branch, in other words working
6589 6596 directory was on different branch than its first parent. In this
6590 6597 situation unshelving restores branch information to the working directory.
6591 6598
6592 6599 Each shelved change has a name that makes it easier to find later.
6593 6600 The name of a shelved change defaults to being based on the active
6594 6601 bookmark, or if there is no active bookmark, the current named
6595 6602 branch. To specify a different name, use ``--name``.
6596 6603
6597 6604 To see a list of existing shelved changes, use the ``--list``
6598 6605 option. For each shelved change, this will print its name, age,
6599 6606 and description; use ``--patch`` or ``--stat`` for more details.
6600 6607
6601 6608 To delete specific shelved changes, use ``--delete``. To delete
6602 6609 all shelved changes, use ``--cleanup``.
6603 6610 '''
6604 6611 opts = pycompat.byteskwargs(opts)
6605 6612 allowables = [
6606 6613 (b'addremove', {b'create'}), # 'create' is pseudo action
6607 6614 (b'unknown', {b'create'}),
6608 6615 (b'cleanup', {b'cleanup'}),
6609 6616 # ('date', {'create'}), # ignored for passing '--date "0 0"' in tests
6610 6617 (b'delete', {b'delete'}),
6611 6618 (b'edit', {b'create'}),
6612 6619 (b'keep', {b'create'}),
6613 6620 (b'list', {b'list'}),
6614 6621 (b'message', {b'create'}),
6615 6622 (b'name', {b'create'}),
6616 6623 (b'patch', {b'patch', b'list'}),
6617 6624 (b'stat', {b'stat', b'list'}),
6618 6625 ]
6619 6626
6620 6627 def checkopt(opt):
6621 6628 if opts.get(opt):
6622 6629 for i, allowable in allowables:
6623 6630 if opts[i] and opt not in allowable:
6624 6631 raise error.Abort(
6625 6632 _(
6626 6633 b"options '--%s' and '--%s' may not be "
6627 6634 b"used together"
6628 6635 )
6629 6636 % (opt, i)
6630 6637 )
6631 6638 return True
6632 6639
6633 6640 if checkopt(b'cleanup'):
6634 6641 if pats:
6635 6642 raise error.Abort(_(b"cannot specify names when using '--cleanup'"))
6636 6643 return shelvemod.cleanupcmd(ui, repo)
6637 6644 elif checkopt(b'delete'):
6638 6645 return shelvemod.deletecmd(ui, repo, pats)
6639 6646 elif checkopt(b'list'):
6640 6647 return shelvemod.listcmd(ui, repo, pats, opts)
6641 6648 elif checkopt(b'patch') or checkopt(b'stat'):
6642 6649 return shelvemod.patchcmds(ui, repo, pats, opts)
6643 6650 else:
6644 6651 return shelvemod.createcmd(ui, repo, pats, opts)
6645 6652
6646 6653
6647 6654 _NOTTERSE = b'nothing'
6648 6655
6649 6656
6650 6657 @command(
6651 6658 b'status|st',
6652 6659 [
6653 6660 (b'A', b'all', None, _(b'show status of all files')),
6654 6661 (b'm', b'modified', None, _(b'show only modified files')),
6655 6662 (b'a', b'added', None, _(b'show only added files')),
6656 6663 (b'r', b'removed', None, _(b'show only removed files')),
6657 6664 (b'd', b'deleted', None, _(b'show only deleted (but tracked) files')),
6658 6665 (b'c', b'clean', None, _(b'show only files without changes')),
6659 6666 (b'u', b'unknown', None, _(b'show only unknown (not tracked) files')),
6660 6667 (b'i', b'ignored', None, _(b'show only ignored files')),
6661 6668 (b'n', b'no-status', None, _(b'hide status prefix')),
6662 6669 (b't', b'terse', _NOTTERSE, _(b'show the terse output (EXPERIMENTAL)')),
6663 6670 (b'C', b'copies', None, _(b'show source of copied files')),
6664 6671 (
6665 6672 b'0',
6666 6673 b'print0',
6667 6674 None,
6668 6675 _(b'end filenames with NUL, for use with xargs'),
6669 6676 ),
6670 6677 (b'', b'rev', [], _(b'show difference from revision'), _(b'REV')),
6671 6678 (
6672 6679 b'',
6673 6680 b'change',
6674 6681 b'',
6675 6682 _(b'list the changed files of a revision'),
6676 6683 _(b'REV'),
6677 6684 ),
6678 6685 ]
6679 6686 + walkopts
6680 6687 + subrepoopts
6681 6688 + formatteropts,
6682 6689 _(b'[OPTION]... [FILE]...'),
6683 6690 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6684 6691 helpbasic=True,
6685 6692 inferrepo=True,
6686 6693 intents={INTENT_READONLY},
6687 6694 )
6688 6695 def status(ui, repo, *pats, **opts):
6689 6696 """show changed files in the working directory
6690 6697
6691 6698 Show status of files in the repository. If names are given, only
6692 6699 files that match are shown. Files that are clean or ignored or
6693 6700 the source of a copy/move operation, are not listed unless
6694 6701 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
6695 6702 Unless options described with "show only ..." are given, the
6696 6703 options -mardu are used.
6697 6704
6698 6705 Option -q/--quiet hides untracked (unknown and ignored) files
6699 6706 unless explicitly requested with -u/--unknown or -i/--ignored.
6700 6707
6701 6708 .. note::
6702 6709
6703 6710 :hg:`status` may appear to disagree with diff if permissions have
6704 6711 changed or a merge has occurred. The standard diff format does
6705 6712 not report permission changes and diff only reports changes
6706 6713 relative to one merge parent.
6707 6714
6708 6715 If one revision is given, it is used as the base revision.
6709 6716 If two revisions are given, the differences between them are
6710 6717 shown. The --change option can also be used as a shortcut to list
6711 6718 the changed files of a revision from its first parent.
6712 6719
6713 6720 The codes used to show the status of files are::
6714 6721
6715 6722 M = modified
6716 6723 A = added
6717 6724 R = removed
6718 6725 C = clean
6719 6726 ! = missing (deleted by non-hg command, but still tracked)
6720 6727 ? = not tracked
6721 6728 I = ignored
6722 6729 = origin of the previous file (with --copies)
6723 6730
6724 6731 .. container:: verbose
6725 6732
6726 6733 The -t/--terse option abbreviates the output by showing only the directory
6727 6734 name if all the files in it share the same status. The option takes an
6728 6735 argument indicating the statuses to abbreviate: 'm' for 'modified', 'a'
6729 6736 for 'added', 'r' for 'removed', 'd' for 'deleted', 'u' for 'unknown', 'i'
6730 6737 for 'ignored' and 'c' for clean.
6731 6738
6732 6739 It abbreviates only those statuses which are passed. Note that clean and
6733 6740 ignored files are not displayed with '--terse ic' unless the -c/--clean
6734 6741 and -i/--ignored options are also used.
6735 6742
6736 6743 The -v/--verbose option shows information when the repository is in an
6737 6744 unfinished merge, shelve, rebase state etc. You can have this behavior
6738 6745 turned on by default by enabling the ``commands.status.verbose`` option.
6739 6746
6740 6747 You can skip displaying some of these states by setting
6741 6748 ``commands.status.skipstates`` to one or more of: 'bisect', 'graft',
6742 6749 'histedit', 'merge', 'rebase', or 'unshelve'.
6743 6750
6744 6751 Template:
6745 6752
6746 6753 The following keywords are supported in addition to the common template
6747 6754 keywords and functions. See also :hg:`help templates`.
6748 6755
6749 6756 :path: String. Repository-absolute path of the file.
6750 6757 :source: String. Repository-absolute path of the file originated from.
6751 6758 Available if ``--copies`` is specified.
6752 6759 :status: String. Character denoting file's status.
6753 6760
6754 6761 Examples:
6755 6762
6756 6763 - show changes in the working directory relative to a
6757 6764 changeset::
6758 6765
6759 6766 hg status --rev 9353
6760 6767
6761 6768 - show changes in the working directory relative to the
6762 6769 current directory (see :hg:`help patterns` for more information)::
6763 6770
6764 6771 hg status re:
6765 6772
6766 6773 - show all changes including copies in an existing changeset::
6767 6774
6768 6775 hg status --copies --change 9353
6769 6776
6770 6777 - get a NUL separated list of added files, suitable for xargs::
6771 6778
6772 6779 hg status -an0
6773 6780
6774 6781 - show more information about the repository status, abbreviating
6775 6782 added, removed, modified, deleted, and untracked paths::
6776 6783
6777 6784 hg status -v -t mardu
6778 6785
6779 6786 Returns 0 on success.
6780 6787
6781 6788 """
6782 6789
6783 6790 opts = pycompat.byteskwargs(opts)
6784 6791 revs = opts.get(b'rev')
6785 6792 change = opts.get(b'change')
6786 6793 terse = opts.get(b'terse')
6787 6794 if terse is _NOTTERSE:
6788 6795 if revs:
6789 6796 terse = b''
6790 6797 else:
6791 6798 terse = ui.config(b'commands', b'status.terse')
6792 6799
6793 6800 if revs and change:
6794 6801 msg = _(b'cannot specify --rev and --change at the same time')
6795 6802 raise error.Abort(msg)
6796 6803 elif revs and terse:
6797 6804 msg = _(b'cannot use --terse with --rev')
6798 6805 raise error.Abort(msg)
6799 6806 elif change:
6800 6807 repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
6801 6808 ctx2 = scmutil.revsingle(repo, change, None)
6802 6809 ctx1 = ctx2.p1()
6803 6810 else:
6804 6811 repo = scmutil.unhidehashlikerevs(repo, revs, b'nowarn')
6805 6812 ctx1, ctx2 = scmutil.revpair(repo, revs)
6806 6813
6807 6814 forcerelativevalue = None
6808 6815 if ui.hasconfig(b'commands', b'status.relative'):
6809 6816 forcerelativevalue = ui.configbool(b'commands', b'status.relative')
6810 6817 uipathfn = scmutil.getuipathfn(
6811 6818 repo,
6812 6819 legacyrelativevalue=bool(pats),
6813 6820 forcerelativevalue=forcerelativevalue,
6814 6821 )
6815 6822
6816 6823 if opts.get(b'print0'):
6817 6824 end = b'\0'
6818 6825 else:
6819 6826 end = b'\n'
6820 6827 states = b'modified added removed deleted unknown ignored clean'.split()
6821 6828 show = [k for k in states if opts.get(k)]
6822 6829 if opts.get(b'all'):
6823 6830 show += ui.quiet and (states[:4] + [b'clean']) or states
6824 6831
6825 6832 if not show:
6826 6833 if ui.quiet:
6827 6834 show = states[:4]
6828 6835 else:
6829 6836 show = states[:5]
6830 6837
6831 6838 m = scmutil.match(ctx2, pats, opts)
6832 6839 if terse:
6833 6840 # we need to compute clean and unknown to terse
6834 6841 stat = repo.status(
6835 6842 ctx1.node(),
6836 6843 ctx2.node(),
6837 6844 m,
6838 6845 b'ignored' in show or b'i' in terse,
6839 6846 clean=True,
6840 6847 unknown=True,
6841 6848 listsubrepos=opts.get(b'subrepos'),
6842 6849 )
6843 6850
6844 6851 stat = cmdutil.tersedir(stat, terse)
6845 6852 else:
6846 6853 stat = repo.status(
6847 6854 ctx1.node(),
6848 6855 ctx2.node(),
6849 6856 m,
6850 6857 b'ignored' in show,
6851 6858 b'clean' in show,
6852 6859 b'unknown' in show,
6853 6860 opts.get(b'subrepos'),
6854 6861 )
6855 6862
6856 6863 changestates = zip(
6857 6864 states,
6858 6865 pycompat.iterbytestr(b'MAR!?IC'),
6859 6866 [getattr(stat, s.decode('utf8')) for s in states],
6860 6867 )
6861 6868
6862 6869 copy = {}
6863 6870 if (
6864 6871 opts.get(b'all')
6865 6872 or opts.get(b'copies')
6866 6873 or ui.configbool(b'ui', b'statuscopies')
6867 6874 ) and not opts.get(b'no_status'):
6868 6875 copy = copies.pathcopies(ctx1, ctx2, m)
6869 6876
6870 6877 morestatus = None
6871 6878 if (
6872 6879 ui.verbose or ui.configbool(b'commands', b'status.verbose')
6873 6880 ) and not ui.plain():
6874 6881 morestatus = cmdutil.readmorestatus(repo)
6875 6882
6876 6883 ui.pager(b'status')
6877 6884 fm = ui.formatter(b'status', opts)
6878 6885 fmt = b'%s' + end
6879 6886 showchar = not opts.get(b'no_status')
6880 6887
6881 6888 for state, char, files in changestates:
6882 6889 if state in show:
6883 6890 label = b'status.' + state
6884 6891 for f in files:
6885 6892 fm.startitem()
6886 6893 fm.context(ctx=ctx2)
6887 6894 fm.data(itemtype=b'file', path=f)
6888 6895 fm.condwrite(showchar, b'status', b'%s ', char, label=label)
6889 6896 fm.plain(fmt % uipathfn(f), label=label)
6890 6897 if f in copy:
6891 6898 fm.data(source=copy[f])
6892 6899 fm.plain(
6893 6900 (b' %s' + end) % uipathfn(copy[f]),
6894 6901 label=b'status.copied',
6895 6902 )
6896 6903 if morestatus:
6897 6904 morestatus.formatfile(f, fm)
6898 6905
6899 6906 if morestatus:
6900 6907 morestatus.formatfooter(fm)
6901 6908 fm.end()
6902 6909
6903 6910
6904 6911 @command(
6905 6912 b'summary|sum',
6906 6913 [(b'', b'remote', None, _(b'check for push and pull'))],
6907 6914 b'[--remote]',
6908 6915 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6909 6916 helpbasic=True,
6910 6917 intents={INTENT_READONLY},
6911 6918 )
6912 6919 def summary(ui, repo, **opts):
6913 6920 """summarize working directory state
6914 6921
6915 6922 This generates a brief summary of the working directory state,
6916 6923 including parents, branch, commit status, phase and available updates.
6917 6924
6918 6925 With the --remote option, this will check the default paths for
6919 6926 incoming and outgoing changes. This can be time-consuming.
6920 6927
6921 6928 Returns 0 on success.
6922 6929 """
6923 6930
6924 6931 opts = pycompat.byteskwargs(opts)
6925 6932 ui.pager(b'summary')
6926 6933 ctx = repo[None]
6927 6934 parents = ctx.parents()
6928 6935 pnode = parents[0].node()
6929 6936 marks = []
6930 6937
6931 6938 try:
6932 6939 ms = mergemod.mergestate.read(repo)
6933 6940 except error.UnsupportedMergeRecords as e:
6934 6941 s = b' '.join(e.recordtypes)
6935 6942 ui.warn(
6936 6943 _(b'warning: merge state has unsupported record types: %s\n') % s
6937 6944 )
6938 6945 unresolved = []
6939 6946 else:
6940 6947 unresolved = list(ms.unresolved())
6941 6948
6942 6949 for p in parents:
6943 6950 # label with log.changeset (instead of log.parent) since this
6944 6951 # shows a working directory parent *changeset*:
6945 6952 # i18n: column positioning for "hg summary"
6946 6953 ui.write(
6947 6954 _(b'parent: %d:%s ') % (p.rev(), p),
6948 6955 label=logcmdutil.changesetlabels(p),
6949 6956 )
6950 6957 ui.write(b' '.join(p.tags()), label=b'log.tag')
6951 6958 if p.bookmarks():
6952 6959 marks.extend(p.bookmarks())
6953 6960 if p.rev() == -1:
6954 6961 if not len(repo):
6955 6962 ui.write(_(b' (empty repository)'))
6956 6963 else:
6957 6964 ui.write(_(b' (no revision checked out)'))
6958 6965 if p.obsolete():
6959 6966 ui.write(_(b' (obsolete)'))
6960 6967 if p.isunstable():
6961 6968 instabilities = (
6962 6969 ui.label(instability, b'trouble.%s' % instability)
6963 6970 for instability in p.instabilities()
6964 6971 )
6965 6972 ui.write(b' (' + b', '.join(instabilities) + b')')
6966 6973 ui.write(b'\n')
6967 6974 if p.description():
6968 6975 ui.status(
6969 6976 b' ' + p.description().splitlines()[0].strip() + b'\n',
6970 6977 label=b'log.summary',
6971 6978 )
6972 6979
6973 6980 branch = ctx.branch()
6974 6981 bheads = repo.branchheads(branch)
6975 6982 # i18n: column positioning for "hg summary"
6976 6983 m = _(b'branch: %s\n') % branch
6977 6984 if branch != b'default':
6978 6985 ui.write(m, label=b'log.branch')
6979 6986 else:
6980 6987 ui.status(m, label=b'log.branch')
6981 6988
6982 6989 if marks:
6983 6990 active = repo._activebookmark
6984 6991 # i18n: column positioning for "hg summary"
6985 6992 ui.write(_(b'bookmarks:'), label=b'log.bookmark')
6986 6993 if active is not None:
6987 6994 if active in marks:
6988 6995 ui.write(b' *' + active, label=bookmarks.activebookmarklabel)
6989 6996 marks.remove(active)
6990 6997 else:
6991 6998 ui.write(b' [%s]' % active, label=bookmarks.activebookmarklabel)
6992 6999 for m in marks:
6993 7000 ui.write(b' ' + m, label=b'log.bookmark')
6994 7001 ui.write(b'\n', label=b'log.bookmark')
6995 7002
6996 7003 status = repo.status(unknown=True)
6997 7004
6998 7005 c = repo.dirstate.copies()
6999 7006 copied, renamed = [], []
7000 7007 for d, s in pycompat.iteritems(c):
7001 7008 if s in status.removed:
7002 7009 status.removed.remove(s)
7003 7010 renamed.append(d)
7004 7011 else:
7005 7012 copied.append(d)
7006 7013 if d in status.added:
7007 7014 status.added.remove(d)
7008 7015
7009 7016 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
7010 7017
7011 7018 labels = [
7012 7019 (ui.label(_(b'%d modified'), b'status.modified'), status.modified),
7013 7020 (ui.label(_(b'%d added'), b'status.added'), status.added),
7014 7021 (ui.label(_(b'%d removed'), b'status.removed'), status.removed),
7015 7022 (ui.label(_(b'%d renamed'), b'status.copied'), renamed),
7016 7023 (ui.label(_(b'%d copied'), b'status.copied'), copied),
7017 7024 (ui.label(_(b'%d deleted'), b'status.deleted'), status.deleted),
7018 7025 (ui.label(_(b'%d unknown'), b'status.unknown'), status.unknown),
7019 7026 (ui.label(_(b'%d unresolved'), b'resolve.unresolved'), unresolved),
7020 7027 (ui.label(_(b'%d subrepos'), b'status.modified'), subs),
7021 7028 ]
7022 7029 t = []
7023 7030 for l, s in labels:
7024 7031 if s:
7025 7032 t.append(l % len(s))
7026 7033
7027 7034 t = b', '.join(t)
7028 7035 cleanworkdir = False
7029 7036
7030 7037 if repo.vfs.exists(b'graftstate'):
7031 7038 t += _(b' (graft in progress)')
7032 7039 if repo.vfs.exists(b'updatestate'):
7033 7040 t += _(b' (interrupted update)')
7034 7041 elif len(parents) > 1:
7035 7042 t += _(b' (merge)')
7036 7043 elif branch != parents[0].branch():
7037 7044 t += _(b' (new branch)')
7038 7045 elif parents[0].closesbranch() and pnode in repo.branchheads(
7039 7046 branch, closed=True
7040 7047 ):
7041 7048 t += _(b' (head closed)')
7042 7049 elif not (
7043 7050 status.modified
7044 7051 or status.added
7045 7052 or status.removed
7046 7053 or renamed
7047 7054 or copied
7048 7055 or subs
7049 7056 ):
7050 7057 t += _(b' (clean)')
7051 7058 cleanworkdir = True
7052 7059 elif pnode not in bheads:
7053 7060 t += _(b' (new branch head)')
7054 7061
7055 7062 if parents:
7056 7063 pendingphase = max(p.phase() for p in parents)
7057 7064 else:
7058 7065 pendingphase = phases.public
7059 7066
7060 7067 if pendingphase > phases.newcommitphase(ui):
7061 7068 t += b' (%s)' % phases.phasenames[pendingphase]
7062 7069
7063 7070 if cleanworkdir:
7064 7071 # i18n: column positioning for "hg summary"
7065 7072 ui.status(_(b'commit: %s\n') % t.strip())
7066 7073 else:
7067 7074 # i18n: column positioning for "hg summary"
7068 7075 ui.write(_(b'commit: %s\n') % t.strip())
7069 7076
7070 7077 # all ancestors of branch heads - all ancestors of parent = new csets
7071 7078 new = len(
7072 7079 repo.changelog.findmissing([pctx.node() for pctx in parents], bheads)
7073 7080 )
7074 7081
7075 7082 if new == 0:
7076 7083 # i18n: column positioning for "hg summary"
7077 7084 ui.status(_(b'update: (current)\n'))
7078 7085 elif pnode not in bheads:
7079 7086 # i18n: column positioning for "hg summary"
7080 7087 ui.write(_(b'update: %d new changesets (update)\n') % new)
7081 7088 else:
7082 7089 # i18n: column positioning for "hg summary"
7083 7090 ui.write(
7084 7091 _(b'update: %d new changesets, %d branch heads (merge)\n')
7085 7092 % (new, len(bheads))
7086 7093 )
7087 7094
7088 7095 t = []
7089 7096 draft = len(repo.revs(b'draft()'))
7090 7097 if draft:
7091 7098 t.append(_(b'%d draft') % draft)
7092 7099 secret = len(repo.revs(b'secret()'))
7093 7100 if secret:
7094 7101 t.append(_(b'%d secret') % secret)
7095 7102
7096 7103 if draft or secret:
7097 7104 ui.status(_(b'phases: %s\n') % b', '.join(t))
7098 7105
7099 7106 if obsolete.isenabled(repo, obsolete.createmarkersopt):
7100 7107 for trouble in (b"orphan", b"contentdivergent", b"phasedivergent"):
7101 7108 numtrouble = len(repo.revs(trouble + b"()"))
7102 7109 # We write all the possibilities to ease translation
7103 7110 troublemsg = {
7104 7111 b"orphan": _(b"orphan: %d changesets"),
7105 7112 b"contentdivergent": _(b"content-divergent: %d changesets"),
7106 7113 b"phasedivergent": _(b"phase-divergent: %d changesets"),
7107 7114 }
7108 7115 if numtrouble > 0:
7109 7116 ui.status(troublemsg[trouble] % numtrouble + b"\n")
7110 7117
7111 7118 cmdutil.summaryhooks(ui, repo)
7112 7119
7113 7120 if opts.get(b'remote'):
7114 7121 needsincoming, needsoutgoing = True, True
7115 7122 else:
7116 7123 needsincoming, needsoutgoing = False, False
7117 7124 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
7118 7125 if i:
7119 7126 needsincoming = True
7120 7127 if o:
7121 7128 needsoutgoing = True
7122 7129 if not needsincoming and not needsoutgoing:
7123 7130 return
7124 7131
7125 7132 def getincoming():
7126 7133 source, branches = hg.parseurl(ui.expandpath(b'default'))
7127 7134 sbranch = branches[0]
7128 7135 try:
7129 7136 other = hg.peer(repo, {}, source)
7130 7137 except error.RepoError:
7131 7138 if opts.get(b'remote'):
7132 7139 raise
7133 7140 return source, sbranch, None, None, None
7134 7141 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
7135 7142 if revs:
7136 7143 revs = [other.lookup(rev) for rev in revs]
7137 7144 ui.debug(b'comparing with %s\n' % util.hidepassword(source))
7138 7145 repo.ui.pushbuffer()
7139 7146 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
7140 7147 repo.ui.popbuffer()
7141 7148 return source, sbranch, other, commoninc, commoninc[1]
7142 7149
7143 7150 if needsincoming:
7144 7151 source, sbranch, sother, commoninc, incoming = getincoming()
7145 7152 else:
7146 7153 source = sbranch = sother = commoninc = incoming = None
7147 7154
7148 7155 def getoutgoing():
7149 7156 dest, branches = hg.parseurl(ui.expandpath(b'default-push', b'default'))
7150 7157 dbranch = branches[0]
7151 7158 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
7152 7159 if source != dest:
7153 7160 try:
7154 7161 dother = hg.peer(repo, {}, dest)
7155 7162 except error.RepoError:
7156 7163 if opts.get(b'remote'):
7157 7164 raise
7158 7165 return dest, dbranch, None, None
7159 7166 ui.debug(b'comparing with %s\n' % util.hidepassword(dest))
7160 7167 elif sother is None:
7161 7168 # there is no explicit destination peer, but source one is invalid
7162 7169 return dest, dbranch, None, None
7163 7170 else:
7164 7171 dother = sother
7165 7172 if source != dest or (sbranch is not None and sbranch != dbranch):
7166 7173 common = None
7167 7174 else:
7168 7175 common = commoninc
7169 7176 if revs:
7170 7177 revs = [repo.lookup(rev) for rev in revs]
7171 7178 repo.ui.pushbuffer()
7172 7179 outgoing = discovery.findcommonoutgoing(
7173 7180 repo, dother, onlyheads=revs, commoninc=common
7174 7181 )
7175 7182 repo.ui.popbuffer()
7176 7183 return dest, dbranch, dother, outgoing
7177 7184
7178 7185 if needsoutgoing:
7179 7186 dest, dbranch, dother, outgoing = getoutgoing()
7180 7187 else:
7181 7188 dest = dbranch = dother = outgoing = None
7182 7189
7183 7190 if opts.get(b'remote'):
7184 7191 t = []
7185 7192 if incoming:
7186 7193 t.append(_(b'1 or more incoming'))
7187 7194 o = outgoing.missing
7188 7195 if o:
7189 7196 t.append(_(b'%d outgoing') % len(o))
7190 7197 other = dother or sother
7191 7198 if b'bookmarks' in other.listkeys(b'namespaces'):
7192 7199 counts = bookmarks.summary(repo, other)
7193 7200 if counts[0] > 0:
7194 7201 t.append(_(b'%d incoming bookmarks') % counts[0])
7195 7202 if counts[1] > 0:
7196 7203 t.append(_(b'%d outgoing bookmarks') % counts[1])
7197 7204
7198 7205 if t:
7199 7206 # i18n: column positioning for "hg summary"
7200 7207 ui.write(_(b'remote: %s\n') % (b', '.join(t)))
7201 7208 else:
7202 7209 # i18n: column positioning for "hg summary"
7203 7210 ui.status(_(b'remote: (synced)\n'))
7204 7211
7205 7212 cmdutil.summaryremotehooks(
7206 7213 ui,
7207 7214 repo,
7208 7215 opts,
7209 7216 (
7210 7217 (source, sbranch, sother, commoninc),
7211 7218 (dest, dbranch, dother, outgoing),
7212 7219 ),
7213 7220 )
7214 7221
7215 7222
7216 7223 @command(
7217 7224 b'tag',
7218 7225 [
7219 7226 (b'f', b'force', None, _(b'force tag')),
7220 7227 (b'l', b'local', None, _(b'make the tag local')),
7221 7228 (b'r', b'rev', b'', _(b'revision to tag'), _(b'REV')),
7222 7229 (b'', b'remove', None, _(b'remove a tag')),
7223 7230 # -l/--local is already there, commitopts cannot be used
7224 7231 (b'e', b'edit', None, _(b'invoke editor on commit messages')),
7225 7232 (b'm', b'message', b'', _(b'use text as commit message'), _(b'TEXT')),
7226 7233 ]
7227 7234 + commitopts2,
7228 7235 _(b'[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'),
7229 7236 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
7230 7237 )
7231 7238 def tag(ui, repo, name1, *names, **opts):
7232 7239 """add one or more tags for the current or given revision
7233 7240
7234 7241 Name a particular revision using <name>.
7235 7242
7236 7243 Tags are used to name particular revisions of the repository and are
7237 7244 very useful to compare different revisions, to go back to significant
7238 7245 earlier versions or to mark branch points as releases, etc. Changing
7239 7246 an existing tag is normally disallowed; use -f/--force to override.
7240 7247
7241 7248 If no revision is given, the parent of the working directory is
7242 7249 used.
7243 7250
7244 7251 To facilitate version control, distribution, and merging of tags,
7245 7252 they are stored as a file named ".hgtags" which is managed similarly
7246 7253 to other project files and can be hand-edited if necessary. This
7247 7254 also means that tagging creates a new commit. The file
7248 7255 ".hg/localtags" is used for local tags (not shared among
7249 7256 repositories).
7250 7257
7251 7258 Tag commits are usually made at the head of a branch. If the parent
7252 7259 of the working directory is not a branch head, :hg:`tag` aborts; use
7253 7260 -f/--force to force the tag commit to be based on a non-head
7254 7261 changeset.
7255 7262
7256 7263 See :hg:`help dates` for a list of formats valid for -d/--date.
7257 7264
7258 7265 Since tag names have priority over branch names during revision
7259 7266 lookup, using an existing branch name as a tag name is discouraged.
7260 7267
7261 7268 Returns 0 on success.
7262 7269 """
7263 7270 opts = pycompat.byteskwargs(opts)
7264 7271 with repo.wlock(), repo.lock():
7265 7272 rev_ = b"."
7266 7273 names = [t.strip() for t in (name1,) + names]
7267 7274 if len(names) != len(set(names)):
7268 7275 raise error.Abort(_(b'tag names must be unique'))
7269 7276 for n in names:
7270 7277 scmutil.checknewlabel(repo, n, b'tag')
7271 7278 if not n:
7272 7279 raise error.Abort(
7273 7280 _(b'tag names cannot consist entirely of whitespace')
7274 7281 )
7275 7282 if opts.get(b'rev') and opts.get(b'remove'):
7276 7283 raise error.Abort(_(b"--rev and --remove are incompatible"))
7277 7284 if opts.get(b'rev'):
7278 7285 rev_ = opts[b'rev']
7279 7286 message = opts.get(b'message')
7280 7287 if opts.get(b'remove'):
7281 7288 if opts.get(b'local'):
7282 7289 expectedtype = b'local'
7283 7290 else:
7284 7291 expectedtype = b'global'
7285 7292
7286 7293 for n in names:
7287 7294 if repo.tagtype(n) == b'global':
7288 7295 alltags = tagsmod.findglobaltags(ui, repo)
7289 7296 if alltags[n][0] == nullid:
7290 7297 raise error.Abort(_(b"tag '%s' is already removed") % n)
7291 7298 if not repo.tagtype(n):
7292 7299 raise error.Abort(_(b"tag '%s' does not exist") % n)
7293 7300 if repo.tagtype(n) != expectedtype:
7294 7301 if expectedtype == b'global':
7295 7302 raise error.Abort(
7296 7303 _(b"tag '%s' is not a global tag") % n
7297 7304 )
7298 7305 else:
7299 7306 raise error.Abort(_(b"tag '%s' is not a local tag") % n)
7300 7307 rev_ = b'null'
7301 7308 if not message:
7302 7309 # we don't translate commit messages
7303 7310 message = b'Removed tag %s' % b', '.join(names)
7304 7311 elif not opts.get(b'force'):
7305 7312 for n in names:
7306 7313 if n in repo.tags():
7307 7314 raise error.Abort(
7308 7315 _(b"tag '%s' already exists (use -f to force)") % n
7309 7316 )
7310 7317 if not opts.get(b'local'):
7311 7318 p1, p2 = repo.dirstate.parents()
7312 7319 if p2 != nullid:
7313 7320 raise error.Abort(_(b'uncommitted merge'))
7314 7321 bheads = repo.branchheads()
7315 7322 if not opts.get(b'force') and bheads and p1 not in bheads:
7316 7323 raise error.Abort(
7317 7324 _(
7318 7325 b'working directory is not at a branch head '
7319 7326 b'(use -f to force)'
7320 7327 )
7321 7328 )
7322 7329 node = scmutil.revsingle(repo, rev_).node()
7323 7330
7324 7331 if not message:
7325 7332 # we don't translate commit messages
7326 7333 message = b'Added tag %s for changeset %s' % (
7327 7334 b', '.join(names),
7328 7335 short(node),
7329 7336 )
7330 7337
7331 7338 date = opts.get(b'date')
7332 7339 if date:
7333 7340 date = dateutil.parsedate(date)
7334 7341
7335 7342 if opts.get(b'remove'):
7336 7343 editform = b'tag.remove'
7337 7344 else:
7338 7345 editform = b'tag.add'
7339 7346 editor = cmdutil.getcommiteditor(
7340 7347 editform=editform, **pycompat.strkwargs(opts)
7341 7348 )
7342 7349
7343 7350 # don't allow tagging the null rev
7344 7351 if (
7345 7352 not opts.get(b'remove')
7346 7353 and scmutil.revsingle(repo, rev_).rev() == nullrev
7347 7354 ):
7348 7355 raise error.Abort(_(b"cannot tag null revision"))
7349 7356
7350 7357 tagsmod.tag(
7351 7358 repo,
7352 7359 names,
7353 7360 node,
7354 7361 message,
7355 7362 opts.get(b'local'),
7356 7363 opts.get(b'user'),
7357 7364 date,
7358 7365 editor=editor,
7359 7366 )
7360 7367
7361 7368
7362 7369 @command(
7363 7370 b'tags',
7364 7371 formatteropts,
7365 7372 b'',
7366 7373 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
7367 7374 intents={INTENT_READONLY},
7368 7375 )
7369 7376 def tags(ui, repo, **opts):
7370 7377 """list repository tags
7371 7378
7372 7379 This lists both regular and local tags. When the -v/--verbose
7373 7380 switch is used, a third column "local" is printed for local tags.
7374 7381 When the -q/--quiet switch is used, only the tag name is printed.
7375 7382
7376 7383 .. container:: verbose
7377 7384
7378 7385 Template:
7379 7386
7380 7387 The following keywords are supported in addition to the common template
7381 7388 keywords and functions such as ``{tag}``. See also
7382 7389 :hg:`help templates`.
7383 7390
7384 7391 :type: String. ``local`` for local tags.
7385 7392
7386 7393 Returns 0 on success.
7387 7394 """
7388 7395
7389 7396 opts = pycompat.byteskwargs(opts)
7390 7397 ui.pager(b'tags')
7391 7398 fm = ui.formatter(b'tags', opts)
7392 7399 hexfunc = fm.hexfunc
7393 7400
7394 7401 for t, n in reversed(repo.tagslist()):
7395 7402 hn = hexfunc(n)
7396 7403 label = b'tags.normal'
7397 7404 tagtype = b''
7398 7405 if repo.tagtype(t) == b'local':
7399 7406 label = b'tags.local'
7400 7407 tagtype = b'local'
7401 7408
7402 7409 fm.startitem()
7403 7410 fm.context(repo=repo)
7404 7411 fm.write(b'tag', b'%s', t, label=label)
7405 7412 fmt = b" " * (30 - encoding.colwidth(t)) + b' %5d:%s'
7406 7413 fm.condwrite(
7407 7414 not ui.quiet,
7408 7415 b'rev node',
7409 7416 fmt,
7410 7417 repo.changelog.rev(n),
7411 7418 hn,
7412 7419 label=label,
7413 7420 )
7414 7421 fm.condwrite(
7415 7422 ui.verbose and tagtype, b'type', b' %s', tagtype, label=label
7416 7423 )
7417 7424 fm.plain(b'\n')
7418 7425 fm.end()
7419 7426
7420 7427
7421 7428 @command(
7422 7429 b'tip',
7423 7430 [
7424 7431 (b'p', b'patch', None, _(b'show patch')),
7425 7432 (b'g', b'git', None, _(b'use git extended diff format')),
7426 7433 ]
7427 7434 + templateopts,
7428 7435 _(b'[-p] [-g]'),
7429 7436 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
7430 7437 )
7431 7438 def tip(ui, repo, **opts):
7432 7439 """show the tip revision (DEPRECATED)
7433 7440
7434 7441 The tip revision (usually just called the tip) is the changeset
7435 7442 most recently added to the repository (and therefore the most
7436 7443 recently changed head).
7437 7444
7438 7445 If you have just made a commit, that commit will be the tip. If
7439 7446 you have just pulled changes from another repository, the tip of
7440 7447 that repository becomes the current tip. The "tip" tag is special
7441 7448 and cannot be renamed or assigned to a different changeset.
7442 7449
7443 7450 This command is deprecated, please use :hg:`heads` instead.
7444 7451
7445 7452 Returns 0 on success.
7446 7453 """
7447 7454 opts = pycompat.byteskwargs(opts)
7448 7455 displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
7449 7456 displayer.show(repo[b'tip'])
7450 7457 displayer.close()
7451 7458
7452 7459
7453 7460 @command(
7454 7461 b'unbundle',
7455 7462 [
7456 7463 (
7457 7464 b'u',
7458 7465 b'update',
7459 7466 None,
7460 7467 _(b'update to new branch head if changesets were unbundled'),
7461 7468 )
7462 7469 ],
7463 7470 _(b'[-u] FILE...'),
7464 7471 helpcategory=command.CATEGORY_IMPORT_EXPORT,
7465 7472 )
7466 7473 def unbundle(ui, repo, fname1, *fnames, **opts):
7467 7474 """apply one or more bundle files
7468 7475
7469 7476 Apply one or more bundle files generated by :hg:`bundle`.
7470 7477
7471 7478 Returns 0 on success, 1 if an update has unresolved files.
7472 7479 """
7473 7480 fnames = (fname1,) + fnames
7474 7481
7475 7482 with repo.lock():
7476 7483 for fname in fnames:
7477 7484 f = hg.openpath(ui, fname)
7478 7485 gen = exchange.readbundle(ui, f, fname)
7479 7486 if isinstance(gen, streamclone.streamcloneapplier):
7480 7487 raise error.Abort(
7481 7488 _(
7482 7489 b'packed bundles cannot be applied with '
7483 7490 b'"hg unbundle"'
7484 7491 ),
7485 7492 hint=_(b'use "hg debugapplystreamclonebundle"'),
7486 7493 )
7487 7494 url = b'bundle:' + fname
7488 7495 try:
7489 7496 txnname = b'unbundle'
7490 7497 if not isinstance(gen, bundle2.unbundle20):
7491 7498 txnname = b'unbundle\n%s' % util.hidepassword(url)
7492 7499 with repo.transaction(txnname) as tr:
7493 7500 op = bundle2.applybundle(
7494 7501 repo, gen, tr, source=b'unbundle', url=url
7495 7502 )
7496 7503 except error.BundleUnknownFeatureError as exc:
7497 7504 raise error.Abort(
7498 7505 _(b'%s: unknown bundle feature, %s') % (fname, exc),
7499 7506 hint=_(
7500 7507 b"see https://mercurial-scm.org/"
7501 7508 b"wiki/BundleFeature for more "
7502 7509 b"information"
7503 7510 ),
7504 7511 )
7505 7512 modheads = bundle2.combinechangegroupresults(op)
7506 7513
7507 7514 return postincoming(ui, repo, modheads, opts.get('update'), None, None)
7508 7515
7509 7516
7510 7517 @command(
7511 7518 b'unshelve',
7512 7519 [
7513 7520 (b'a', b'abort', None, _(b'abort an incomplete unshelve operation')),
7514 7521 (
7515 7522 b'c',
7516 7523 b'continue',
7517 7524 None,
7518 7525 _(b'continue an incomplete unshelve operation'),
7519 7526 ),
7520 7527 (b'i', b'interactive', None, _(b'use interactive mode (EXPERIMENTAL)')),
7521 7528 (b'k', b'keep', None, _(b'keep shelve after unshelving')),
7522 7529 (
7523 7530 b'n',
7524 7531 b'name',
7525 7532 b'',
7526 7533 _(b'restore shelved change with given name'),
7527 7534 _(b'NAME'),
7528 7535 ),
7529 7536 (b't', b'tool', b'', _(b'specify merge tool')),
7530 7537 (
7531 7538 b'',
7532 7539 b'date',
7533 7540 b'',
7534 7541 _(b'set date for temporary commits (DEPRECATED)'),
7535 7542 _(b'DATE'),
7536 7543 ),
7537 7544 ],
7538 7545 _(b'hg unshelve [OPTION]... [[-n] SHELVED]'),
7539 7546 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
7540 7547 )
7541 7548 def unshelve(ui, repo, *shelved, **opts):
7542 7549 """restore a shelved change to the working directory
7543 7550
7544 7551 This command accepts an optional name of a shelved change to
7545 7552 restore. If none is given, the most recent shelved change is used.
7546 7553
7547 7554 If a shelved change is applied successfully, the bundle that
7548 7555 contains the shelved changes is moved to a backup location
7549 7556 (.hg/shelve-backup).
7550 7557
7551 7558 Since you can restore a shelved change on top of an arbitrary
7552 7559 commit, it is possible that unshelving will result in a conflict
7553 7560 between your changes and the commits you are unshelving onto. If
7554 7561 this occurs, you must resolve the conflict, then use
7555 7562 ``--continue`` to complete the unshelve operation. (The bundle
7556 7563 will not be moved until you successfully complete the unshelve.)
7557 7564
7558 7565 (Alternatively, you can use ``--abort`` to abandon an unshelve
7559 7566 that causes a conflict. This reverts the unshelved changes, and
7560 7567 leaves the bundle in place.)
7561 7568
7562 7569 If bare shelved change (without interactive, include and exclude
7563 7570 option) was done on newly created branch it would restore branch
7564 7571 information to the working directory.
7565 7572
7566 7573 After a successful unshelve, the shelved changes are stored in a
7567 7574 backup directory. Only the N most recent backups are kept. N
7568 7575 defaults to 10 but can be overridden using the ``shelve.maxbackups``
7569 7576 configuration option.
7570 7577
7571 7578 .. container:: verbose
7572 7579
7573 7580 Timestamp in seconds is used to decide order of backups. More
7574 7581 than ``maxbackups`` backups are kept, if same timestamp
7575 7582 prevents from deciding exact order of them, for safety.
7576 7583
7577 7584 Selected changes can be unshelved with ``--interactive`` flag.
7578 7585 The working directory is updated with the selected changes, and
7579 7586 only the unselected changes remain shelved.
7580 7587 Note: The whole shelve is applied to working directory first before
7581 7588 running interactively. So, this will bring up all the conflicts between
7582 7589 working directory and the shelve, irrespective of which changes will be
7583 7590 unshelved.
7584 7591 """
7585 7592 with repo.wlock():
7586 7593 return shelvemod.dounshelve(ui, repo, *shelved, **opts)
7587 7594
7588 7595
7589 7596 statemod.addunfinished(
7590 7597 b'unshelve',
7591 7598 fname=b'shelvedstate',
7592 7599 continueflag=True,
7593 7600 abortfunc=shelvemod.hgabortunshelve,
7594 7601 continuefunc=shelvemod.hgcontinueunshelve,
7595 7602 cmdmsg=_(b'unshelve already in progress'),
7596 7603 )
7597 7604
7598 7605
7599 7606 @command(
7600 7607 b'update|up|checkout|co',
7601 7608 [
7602 7609 (b'C', b'clean', None, _(b'discard uncommitted changes (no backup)')),
7603 7610 (b'c', b'check', None, _(b'require clean working directory')),
7604 7611 (b'm', b'merge', None, _(b'merge uncommitted changes')),
7605 7612 (b'd', b'date', b'', _(b'tipmost revision matching date'), _(b'DATE')),
7606 7613 (b'r', b'rev', b'', _(b'revision'), _(b'REV')),
7607 7614 ]
7608 7615 + mergetoolopts,
7609 7616 _(b'[-C|-c|-m] [-d DATE] [[-r] REV]'),
7610 7617 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
7611 7618 helpbasic=True,
7612 7619 )
7613 7620 def update(ui, repo, node=None, **opts):
7614 7621 """update working directory (or switch revisions)
7615 7622
7616 7623 Update the repository's working directory to the specified
7617 7624 changeset. If no changeset is specified, update to the tip of the
7618 7625 current named branch and move the active bookmark (see :hg:`help
7619 7626 bookmarks`).
7620 7627
7621 7628 Update sets the working directory's parent revision to the specified
7622 7629 changeset (see :hg:`help parents`).
7623 7630
7624 7631 If the changeset is not a descendant or ancestor of the working
7625 7632 directory's parent and there are uncommitted changes, the update is
7626 7633 aborted. With the -c/--check option, the working directory is checked
7627 7634 for uncommitted changes; if none are found, the working directory is
7628 7635 updated to the specified changeset.
7629 7636
7630 7637 .. container:: verbose
7631 7638
7632 7639 The -C/--clean, -c/--check, and -m/--merge options control what
7633 7640 happens if the working directory contains uncommitted changes.
7634 7641 At most of one of them can be specified.
7635 7642
7636 7643 1. If no option is specified, and if
7637 7644 the requested changeset is an ancestor or descendant of
7638 7645 the working directory's parent, the uncommitted changes
7639 7646 are merged into the requested changeset and the merged
7640 7647 result is left uncommitted. If the requested changeset is
7641 7648 not an ancestor or descendant (that is, it is on another
7642 7649 branch), the update is aborted and the uncommitted changes
7643 7650 are preserved.
7644 7651
7645 7652 2. With the -m/--merge option, the update is allowed even if the
7646 7653 requested changeset is not an ancestor or descendant of
7647 7654 the working directory's parent.
7648 7655
7649 7656 3. With the -c/--check option, the update is aborted and the
7650 7657 uncommitted changes are preserved.
7651 7658
7652 7659 4. With the -C/--clean option, uncommitted changes are discarded and
7653 7660 the working directory is updated to the requested changeset.
7654 7661
7655 7662 To cancel an uncommitted merge (and lose your changes), use
7656 7663 :hg:`merge --abort`.
7657 7664
7658 7665 Use null as the changeset to remove the working directory (like
7659 7666 :hg:`clone -U`).
7660 7667
7661 7668 If you want to revert just one file to an older revision, use
7662 7669 :hg:`revert [-r REV] NAME`.
7663 7670
7664 7671 See :hg:`help dates` for a list of formats valid for -d/--date.
7665 7672
7666 7673 Returns 0 on success, 1 if there are unresolved files.
7667 7674 """
7668 7675 rev = opts.get('rev')
7669 7676 date = opts.get('date')
7670 7677 clean = opts.get('clean')
7671 7678 check = opts.get('check')
7672 7679 merge = opts.get('merge')
7673 7680 if rev and node:
7674 7681 raise error.Abort(_(b"please specify just one revision"))
7675 7682
7676 7683 if ui.configbool(b'commands', b'update.requiredest'):
7677 7684 if not node and not rev and not date:
7678 7685 raise error.Abort(
7679 7686 _(b'you must specify a destination'),
7680 7687 hint=_(b'for example: hg update ".::"'),
7681 7688 )
7682 7689
7683 7690 if rev is None or rev == b'':
7684 7691 rev = node
7685 7692
7686 7693 if date and rev is not None:
7687 7694 raise error.Abort(_(b"you can't specify a revision and a date"))
7688 7695
7689 7696 if len([x for x in (clean, check, merge) if x]) > 1:
7690 7697 raise error.Abort(
7691 7698 _(
7692 7699 b"can only specify one of -C/--clean, -c/--check, "
7693 7700 b"or -m/--merge"
7694 7701 )
7695 7702 )
7696 7703
7697 7704 updatecheck = None
7698 7705 if check:
7699 7706 updatecheck = b'abort'
7700 7707 elif merge:
7701 7708 updatecheck = b'none'
7702 7709
7703 7710 with repo.wlock():
7704 7711 cmdutil.clearunfinished(repo)
7705 7712 if date:
7706 7713 rev = cmdutil.finddate(ui, repo, date)
7707 7714
7708 7715 # if we defined a bookmark, we have to remember the original name
7709 7716 brev = rev
7710 7717 if rev:
7711 7718 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
7712 7719 ctx = scmutil.revsingle(repo, rev, default=None)
7713 7720 rev = ctx.rev()
7714 7721 hidden = ctx.hidden()
7715 7722 overrides = {(b'ui', b'forcemerge'): opts.get('tool', b'')}
7716 7723 with ui.configoverride(overrides, b'update'):
7717 7724 ret = hg.updatetotally(
7718 7725 ui, repo, rev, brev, clean=clean, updatecheck=updatecheck
7719 7726 )
7720 7727 if hidden:
7721 7728 ctxstr = ctx.hex()[:12]
7722 7729 ui.warn(_(b"updated to hidden changeset %s\n") % ctxstr)
7723 7730
7724 7731 if ctx.obsolete():
7725 7732 obsfatemsg = obsutil._getfilteredreason(repo, ctxstr, ctx)
7726 7733 ui.warn(b"(%s)\n" % obsfatemsg)
7727 7734 return ret
7728 7735
7729 7736
7730 7737 @command(
7731 7738 b'verify',
7732 7739 [(b'', b'full', False, b'perform more checks (EXPERIMENTAL)')],
7733 7740 helpcategory=command.CATEGORY_MAINTENANCE,
7734 7741 )
7735 7742 def verify(ui, repo, **opts):
7736 7743 """verify the integrity of the repository
7737 7744
7738 7745 Verify the integrity of the current repository.
7739 7746
7740 7747 This will perform an extensive check of the repository's
7741 7748 integrity, validating the hashes and checksums of each entry in
7742 7749 the changelog, manifest, and tracked files, as well as the
7743 7750 integrity of their crosslinks and indices.
7744 7751
7745 7752 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
7746 7753 for more information about recovery from corruption of the
7747 7754 repository.
7748 7755
7749 7756 Returns 0 on success, 1 if errors are encountered.
7750 7757 """
7751 7758 opts = pycompat.byteskwargs(opts)
7752 7759
7753 7760 level = None
7754 7761 if opts[b'full']:
7755 7762 level = verifymod.VERIFY_FULL
7756 7763 return hg.verify(repo, level)
7757 7764
7758 7765
7759 7766 @command(
7760 7767 b'version',
7761 7768 [] + formatteropts,
7762 7769 helpcategory=command.CATEGORY_HELP,
7763 7770 norepo=True,
7764 7771 intents={INTENT_READONLY},
7765 7772 )
7766 7773 def version_(ui, **opts):
7767 7774 """output version and copyright information
7768 7775
7769 7776 .. container:: verbose
7770 7777
7771 7778 Template:
7772 7779
7773 7780 The following keywords are supported. See also :hg:`help templates`.
7774 7781
7775 7782 :extensions: List of extensions.
7776 7783 :ver: String. Version number.
7777 7784
7778 7785 And each entry of ``{extensions}`` provides the following sub-keywords
7779 7786 in addition to ``{ver}``.
7780 7787
7781 7788 :bundled: Boolean. True if included in the release.
7782 7789 :name: String. Extension name.
7783 7790 """
7784 7791 opts = pycompat.byteskwargs(opts)
7785 7792 if ui.verbose:
7786 7793 ui.pager(b'version')
7787 7794 fm = ui.formatter(b"version", opts)
7788 7795 fm.startitem()
7789 7796 fm.write(
7790 7797 b"ver", _(b"Mercurial Distributed SCM (version %s)\n"), util.version()
7791 7798 )
7792 7799 license = _(
7793 7800 b"(see https://mercurial-scm.org for more information)\n"
7794 7801 b"\nCopyright (C) 2005-2019 Matt Mackall and others\n"
7795 7802 b"This is free software; see the source for copying conditions. "
7796 7803 b"There is NO\nwarranty; "
7797 7804 b"not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
7798 7805 )
7799 7806 if not ui.quiet:
7800 7807 fm.plain(license)
7801 7808
7802 7809 if ui.verbose:
7803 7810 fm.plain(_(b"\nEnabled extensions:\n\n"))
7804 7811 # format names and versions into columns
7805 7812 names = []
7806 7813 vers = []
7807 7814 isinternals = []
7808 7815 for name, module in extensions.extensions():
7809 7816 names.append(name)
7810 7817 vers.append(extensions.moduleversion(module) or None)
7811 7818 isinternals.append(extensions.ismoduleinternal(module))
7812 7819 fn = fm.nested(b"extensions", tmpl=b'{name}\n')
7813 7820 if names:
7814 7821 namefmt = b" %%-%ds " % max(len(n) for n in names)
7815 7822 places = [_(b"external"), _(b"internal")]
7816 7823 for n, v, p in zip(names, vers, isinternals):
7817 7824 fn.startitem()
7818 7825 fn.condwrite(ui.verbose, b"name", namefmt, n)
7819 7826 if ui.verbose:
7820 7827 fn.plain(b"%s " % places[p])
7821 7828 fn.data(bundled=p)
7822 7829 fn.condwrite(ui.verbose and v, b"ver", b"%s", v)
7823 7830 if ui.verbose:
7824 7831 fn.plain(b"\n")
7825 7832 fn.end()
7826 7833 fm.end()
7827 7834
7828 7835
7829 7836 def loadcmdtable(ui, name, cmdtable):
7830 7837 """Load command functions from specified cmdtable
7831 7838 """
7832 7839 overrides = [cmd for cmd in cmdtable if cmd in table]
7833 7840 if overrides:
7834 7841 ui.warn(
7835 7842 _(b"extension '%s' overrides commands: %s\n")
7836 7843 % (name, b" ".join(overrides))
7837 7844 )
7838 7845 table.update(cmdtable)
@@ -1,1549 +1,1552 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
19 19 def loadconfigtable(ui, extname, configtable):
20 20 """update config item known to the ui with the extension ones"""
21 21 for section, items in sorted(configtable.items()):
22 22 knownitems = ui._knownconfig.setdefault(section, itemregister())
23 23 knownkeys = set(knownitems)
24 24 newkeys = set(items)
25 25 for key in sorted(knownkeys & newkeys):
26 26 msg = b"extension '%s' overwrite config item '%s.%s'"
27 27 msg %= (extname, section, key)
28 28 ui.develwarn(msg, config=b'warn-config')
29 29
30 30 knownitems.update(items)
31 31
32 32
33 33 class configitem(object):
34 34 """represent a known config item
35 35
36 36 :section: the official config section where to find this item,
37 37 :name: the official name within the section,
38 38 :default: default value for this item,
39 39 :alias: optional list of tuples as alternatives,
40 40 :generic: this is a generic definition, match name using regular expression.
41 41 """
42 42
43 43 def __init__(
44 44 self,
45 45 section,
46 46 name,
47 47 default=None,
48 48 alias=(),
49 49 generic=False,
50 50 priority=0,
51 51 experimental=False,
52 52 ):
53 53 self.section = section
54 54 self.name = name
55 55 self.default = default
56 56 self.alias = list(alias)
57 57 self.generic = generic
58 58 self.priority = priority
59 59 self.experimental = experimental
60 60 self._re = None
61 61 if generic:
62 62 self._re = re.compile(self.name)
63 63
64 64
65 65 class itemregister(dict):
66 66 """A specialized dictionary that can handle wild-card selection"""
67 67
68 68 def __init__(self):
69 69 super(itemregister, self).__init__()
70 70 self._generics = set()
71 71
72 72 def update(self, other):
73 73 super(itemregister, self).update(other)
74 74 self._generics.update(other._generics)
75 75
76 76 def __setitem__(self, key, item):
77 77 super(itemregister, self).__setitem__(key, item)
78 78 if item.generic:
79 79 self._generics.add(item)
80 80
81 81 def get(self, key):
82 82 baseitem = super(itemregister, self).get(key)
83 83 if baseitem is not None and not baseitem.generic:
84 84 return baseitem
85 85
86 86 # search for a matching generic item
87 87 generics = sorted(self._generics, key=(lambda x: (x.priority, x.name)))
88 88 for item in generics:
89 89 # we use 'match' instead of 'search' to make the matching simpler
90 90 # for people unfamiliar with regular expression. Having the match
91 91 # rooted to the start of the string will produce less surprising
92 92 # result for user writing simple regex for sub-attribute.
93 93 #
94 94 # For example using "color\..*" match produces an unsurprising
95 95 # result, while using search could suddenly match apparently
96 96 # unrelated configuration that happens to contains "color."
97 97 # anywhere. This is a tradeoff where we favor requiring ".*" on
98 98 # some match to avoid the need to prefix most pattern with "^".
99 99 # The "^" seems more error prone.
100 100 if item._re.match(key):
101 101 return item
102 102
103 103 return None
104 104
105 105
106 106 coreitems = {}
107 107
108 108
109 109 def _register(configtable, *args, **kwargs):
110 110 item = configitem(*args, **kwargs)
111 111 section = configtable.setdefault(item.section, itemregister())
112 112 if item.name in section:
113 113 msg = b"duplicated config item registration for '%s.%s'"
114 114 raise error.ProgrammingError(msg % (item.section, item.name))
115 115 section[item.name] = item
116 116
117 117
118 118 # special value for case where the default is derived from other values
119 119 dynamicdefault = object()
120 120
121 121 # Registering actual config items
122 122
123 123
124 124 def getitemregister(configtable):
125 125 f = functools.partial(_register, configtable)
126 126 # export pseudo enum as configitem.*
127 127 f.dynamicdefault = dynamicdefault
128 128 return f
129 129
130 130
131 131 coreconfigitem = getitemregister(coreitems)
132 132
133 133
134 134 def _registerdiffopts(section, configprefix=b''):
135 135 coreconfigitem(
136 136 section, configprefix + b'nodates', default=False,
137 137 )
138 138 coreconfigitem(
139 139 section, configprefix + b'showfunc', default=False,
140 140 )
141 141 coreconfigitem(
142 142 section, configprefix + b'unified', default=None,
143 143 )
144 144 coreconfigitem(
145 145 section, configprefix + b'git', default=False,
146 146 )
147 147 coreconfigitem(
148 148 section, configprefix + b'ignorews', default=False,
149 149 )
150 150 coreconfigitem(
151 151 section, configprefix + b'ignorewsamount', default=False,
152 152 )
153 153 coreconfigitem(
154 154 section, configprefix + b'ignoreblanklines', default=False,
155 155 )
156 156 coreconfigitem(
157 157 section, configprefix + b'ignorewseol', default=False,
158 158 )
159 159 coreconfigitem(
160 160 section, configprefix + b'nobinary', default=False,
161 161 )
162 162 coreconfigitem(
163 163 section, configprefix + b'noprefix', default=False,
164 164 )
165 165 coreconfigitem(
166 166 section, configprefix + b'word-diff', default=False,
167 167 )
168 168
169 169
170 170 coreconfigitem(
171 171 b'alias', b'.*', default=dynamicdefault, generic=True,
172 172 )
173 173 coreconfigitem(
174 174 b'auth', b'cookiefile', default=None,
175 175 )
176 176 _registerdiffopts(section=b'annotate')
177 177 # bookmarks.pushing: internal hack for discovery
178 178 coreconfigitem(
179 179 b'bookmarks', b'pushing', default=list,
180 180 )
181 181 # bundle.mainreporoot: internal hack for bundlerepo
182 182 coreconfigitem(
183 183 b'bundle', b'mainreporoot', default=b'',
184 184 )
185 185 coreconfigitem(
186 186 b'censor', b'policy', default=b'abort', experimental=True,
187 187 )
188 188 coreconfigitem(
189 189 b'chgserver', b'idletimeout', default=3600,
190 190 )
191 191 coreconfigitem(
192 192 b'chgserver', b'skiphash', default=False,
193 193 )
194 194 coreconfigitem(
195 195 b'cmdserver', b'log', default=None,
196 196 )
197 197 coreconfigitem(
198 198 b'cmdserver', b'max-log-files', default=7,
199 199 )
200 200 coreconfigitem(
201 201 b'cmdserver', b'max-log-size', default=b'1 MB',
202 202 )
203 203 coreconfigitem(
204 204 b'cmdserver', b'max-repo-cache', default=0, experimental=True,
205 205 )
206 206 coreconfigitem(
207 207 b'cmdserver', b'message-encodings', default=list, experimental=True,
208 208 )
209 209 coreconfigitem(
210 210 b'cmdserver',
211 211 b'track-log',
212 212 default=lambda: [b'chgserver', b'cmdserver', b'repocache'],
213 213 )
214 214 coreconfigitem(
215 215 b'color', b'.*', default=None, generic=True,
216 216 )
217 217 coreconfigitem(
218 218 b'color', b'mode', default=b'auto',
219 219 )
220 220 coreconfigitem(
221 221 b'color', b'pagermode', default=dynamicdefault,
222 222 )
223 223 _registerdiffopts(section=b'commands', configprefix=b'commit.interactive.')
224 224 coreconfigitem(
225 225 b'commands', b'commit.post-status', default=False,
226 226 )
227 227 coreconfigitem(
228 228 b'commands', b'grep.all-files', default=False, experimental=True,
229 229 )
230 230 coreconfigitem(
231 b'commands', b'merge.require-rev', default=False,
232 )
233 coreconfigitem(
231 234 b'commands', b'push.require-revs', default=False,
232 235 )
233 236 coreconfigitem(
234 237 b'commands', b'resolve.confirm', default=False,
235 238 )
236 239 coreconfigitem(
237 240 b'commands', b'resolve.explicit-re-merge', default=False,
238 241 )
239 242 coreconfigitem(
240 243 b'commands', b'resolve.mark-check', default=b'none',
241 244 )
242 245 _registerdiffopts(section=b'commands', configprefix=b'revert.interactive.')
243 246 coreconfigitem(
244 247 b'commands', b'show.aliasprefix', default=list,
245 248 )
246 249 coreconfigitem(
247 250 b'commands', b'status.relative', default=False,
248 251 )
249 252 coreconfigitem(
250 253 b'commands', b'status.skipstates', default=[], experimental=True,
251 254 )
252 255 coreconfigitem(
253 256 b'commands', b'status.terse', default=b'',
254 257 )
255 258 coreconfigitem(
256 259 b'commands', b'status.verbose', default=False,
257 260 )
258 261 coreconfigitem(
259 262 b'commands', b'update.check', default=None,
260 263 )
261 264 coreconfigitem(
262 265 b'commands', b'update.requiredest', default=False,
263 266 )
264 267 coreconfigitem(
265 268 b'committemplate', b'.*', default=None, generic=True,
266 269 )
267 270 coreconfigitem(
268 271 b'convert', b'bzr.saverev', default=True,
269 272 )
270 273 coreconfigitem(
271 274 b'convert', b'cvsps.cache', default=True,
272 275 )
273 276 coreconfigitem(
274 277 b'convert', b'cvsps.fuzz', default=60,
275 278 )
276 279 coreconfigitem(
277 280 b'convert', b'cvsps.logencoding', default=None,
278 281 )
279 282 coreconfigitem(
280 283 b'convert', b'cvsps.mergefrom', default=None,
281 284 )
282 285 coreconfigitem(
283 286 b'convert', b'cvsps.mergeto', default=None,
284 287 )
285 288 coreconfigitem(
286 289 b'convert', b'git.committeractions', default=lambda: [b'messagedifferent'],
287 290 )
288 291 coreconfigitem(
289 292 b'convert', b'git.extrakeys', default=list,
290 293 )
291 294 coreconfigitem(
292 295 b'convert', b'git.findcopiesharder', default=False,
293 296 )
294 297 coreconfigitem(
295 298 b'convert', b'git.remoteprefix', default=b'remote',
296 299 )
297 300 coreconfigitem(
298 301 b'convert', b'git.renamelimit', default=400,
299 302 )
300 303 coreconfigitem(
301 304 b'convert', b'git.saverev', default=True,
302 305 )
303 306 coreconfigitem(
304 307 b'convert', b'git.similarity', default=50,
305 308 )
306 309 coreconfigitem(
307 310 b'convert', b'git.skipsubmodules', default=False,
308 311 )
309 312 coreconfigitem(
310 313 b'convert', b'hg.clonebranches', default=False,
311 314 )
312 315 coreconfigitem(
313 316 b'convert', b'hg.ignoreerrors', default=False,
314 317 )
315 318 coreconfigitem(
316 319 b'convert', b'hg.preserve-hash', default=False,
317 320 )
318 321 coreconfigitem(
319 322 b'convert', b'hg.revs', default=None,
320 323 )
321 324 coreconfigitem(
322 325 b'convert', b'hg.saverev', default=False,
323 326 )
324 327 coreconfigitem(
325 328 b'convert', b'hg.sourcename', default=None,
326 329 )
327 330 coreconfigitem(
328 331 b'convert', b'hg.startrev', default=None,
329 332 )
330 333 coreconfigitem(
331 334 b'convert', b'hg.tagsbranch', default=b'default',
332 335 )
333 336 coreconfigitem(
334 337 b'convert', b'hg.usebranchnames', default=True,
335 338 )
336 339 coreconfigitem(
337 340 b'convert', b'ignoreancestorcheck', default=False, experimental=True,
338 341 )
339 342 coreconfigitem(
340 343 b'convert', b'localtimezone', default=False,
341 344 )
342 345 coreconfigitem(
343 346 b'convert', b'p4.encoding', default=dynamicdefault,
344 347 )
345 348 coreconfigitem(
346 349 b'convert', b'p4.startrev', default=0,
347 350 )
348 351 coreconfigitem(
349 352 b'convert', b'skiptags', default=False,
350 353 )
351 354 coreconfigitem(
352 355 b'convert', b'svn.debugsvnlog', default=True,
353 356 )
354 357 coreconfigitem(
355 358 b'convert', b'svn.trunk', default=None,
356 359 )
357 360 coreconfigitem(
358 361 b'convert', b'svn.tags', default=None,
359 362 )
360 363 coreconfigitem(
361 364 b'convert', b'svn.branches', default=None,
362 365 )
363 366 coreconfigitem(
364 367 b'convert', b'svn.startrev', default=0,
365 368 )
366 369 coreconfigitem(
367 370 b'debug', b'dirstate.delaywrite', default=0,
368 371 )
369 372 coreconfigitem(
370 373 b'defaults', b'.*', default=None, generic=True,
371 374 )
372 375 coreconfigitem(
373 376 b'devel', b'all-warnings', default=False,
374 377 )
375 378 coreconfigitem(
376 379 b'devel', b'bundle2.debug', default=False,
377 380 )
378 381 coreconfigitem(
379 382 b'devel', b'bundle.delta', default=b'',
380 383 )
381 384 coreconfigitem(
382 385 b'devel', b'cache-vfs', default=None,
383 386 )
384 387 coreconfigitem(
385 388 b'devel', b'check-locks', default=False,
386 389 )
387 390 coreconfigitem(
388 391 b'devel', b'check-relroot', default=False,
389 392 )
390 393 coreconfigitem(
391 394 b'devel', b'default-date', default=None,
392 395 )
393 396 coreconfigitem(
394 397 b'devel', b'deprec-warn', default=False,
395 398 )
396 399 coreconfigitem(
397 400 b'devel', b'disableloaddefaultcerts', default=False,
398 401 )
399 402 coreconfigitem(
400 403 b'devel', b'warn-empty-changegroup', default=False,
401 404 )
402 405 coreconfigitem(
403 406 b'devel', b'legacy.exchange', default=list,
404 407 )
405 408 coreconfigitem(
406 409 b'devel', b'servercafile', default=b'',
407 410 )
408 411 coreconfigitem(
409 412 b'devel', b'serverexactprotocol', default=b'',
410 413 )
411 414 coreconfigitem(
412 415 b'devel', b'serverrequirecert', default=False,
413 416 )
414 417 coreconfigitem(
415 418 b'devel', b'strip-obsmarkers', default=True,
416 419 )
417 420 coreconfigitem(
418 421 b'devel', b'warn-config', default=None,
419 422 )
420 423 coreconfigitem(
421 424 b'devel', b'warn-config-default', default=None,
422 425 )
423 426 coreconfigitem(
424 427 b'devel', b'user.obsmarker', default=None,
425 428 )
426 429 coreconfigitem(
427 430 b'devel', b'warn-config-unknown', default=None,
428 431 )
429 432 coreconfigitem(
430 433 b'devel', b'debug.copies', default=False,
431 434 )
432 435 coreconfigitem(
433 436 b'devel', b'debug.extensions', default=False,
434 437 )
435 438 coreconfigitem(
436 439 b'devel', b'debug.repo-filters', default=False,
437 440 )
438 441 coreconfigitem(
439 442 b'devel', b'debug.peer-request', default=False,
440 443 )
441 444 coreconfigitem(
442 445 b'devel', b'discovery.randomize', default=True,
443 446 )
444 447 _registerdiffopts(section=b'diff')
445 448 coreconfigitem(
446 449 b'email', b'bcc', default=None,
447 450 )
448 451 coreconfigitem(
449 452 b'email', b'cc', default=None,
450 453 )
451 454 coreconfigitem(
452 455 b'email', b'charsets', default=list,
453 456 )
454 457 coreconfigitem(
455 458 b'email', b'from', default=None,
456 459 )
457 460 coreconfigitem(
458 461 b'email', b'method', default=b'smtp',
459 462 )
460 463 coreconfigitem(
461 464 b'email', b'reply-to', default=None,
462 465 )
463 466 coreconfigitem(
464 467 b'email', b'to', default=None,
465 468 )
466 469 coreconfigitem(
467 470 b'experimental', b'archivemetatemplate', default=dynamicdefault,
468 471 )
469 472 coreconfigitem(
470 473 b'experimental', b'auto-publish', default=b'publish',
471 474 )
472 475 coreconfigitem(
473 476 b'experimental', b'bundle-phases', default=False,
474 477 )
475 478 coreconfigitem(
476 479 b'experimental', b'bundle2-advertise', default=True,
477 480 )
478 481 coreconfigitem(
479 482 b'experimental', b'bundle2-output-capture', default=False,
480 483 )
481 484 coreconfigitem(
482 485 b'experimental', b'bundle2.pushback', default=False,
483 486 )
484 487 coreconfigitem(
485 488 b'experimental', b'bundle2lazylocking', default=False,
486 489 )
487 490 coreconfigitem(
488 491 b'experimental', b'bundlecomplevel', default=None,
489 492 )
490 493 coreconfigitem(
491 494 b'experimental', b'bundlecomplevel.bzip2', default=None,
492 495 )
493 496 coreconfigitem(
494 497 b'experimental', b'bundlecomplevel.gzip', default=None,
495 498 )
496 499 coreconfigitem(
497 500 b'experimental', b'bundlecomplevel.none', default=None,
498 501 )
499 502 coreconfigitem(
500 503 b'experimental', b'bundlecomplevel.zstd', default=None,
501 504 )
502 505 coreconfigitem(
503 506 b'experimental', b'changegroup3', default=False,
504 507 )
505 508 coreconfigitem(
506 509 b'experimental', b'cleanup-as-archived', default=False,
507 510 )
508 511 coreconfigitem(
509 512 b'experimental', b'clientcompressionengines', default=list,
510 513 )
511 514 coreconfigitem(
512 515 b'experimental', b'copytrace', default=b'on',
513 516 )
514 517 coreconfigitem(
515 518 b'experimental', b'copytrace.movecandidateslimit', default=100,
516 519 )
517 520 coreconfigitem(
518 521 b'experimental', b'copytrace.sourcecommitlimit', default=100,
519 522 )
520 523 coreconfigitem(
521 524 b'experimental', b'copies.read-from', default=b"filelog-only",
522 525 )
523 526 coreconfigitem(
524 527 b'experimental', b'copies.write-to', default=b'filelog-only',
525 528 )
526 529 coreconfigitem(
527 530 b'experimental', b'crecordtest', default=None,
528 531 )
529 532 coreconfigitem(
530 533 b'experimental', b'directaccess', default=False,
531 534 )
532 535 coreconfigitem(
533 536 b'experimental', b'directaccess.revnums', default=False,
534 537 )
535 538 coreconfigitem(
536 539 b'experimental', b'editortmpinhg', default=False,
537 540 )
538 541 coreconfigitem(
539 542 b'experimental', b'evolution', default=list,
540 543 )
541 544 coreconfigitem(
542 545 b'experimental',
543 546 b'evolution.allowdivergence',
544 547 default=False,
545 548 alias=[(b'experimental', b'allowdivergence')],
546 549 )
547 550 coreconfigitem(
548 551 b'experimental', b'evolution.allowunstable', default=None,
549 552 )
550 553 coreconfigitem(
551 554 b'experimental', b'evolution.createmarkers', default=None,
552 555 )
553 556 coreconfigitem(
554 557 b'experimental',
555 558 b'evolution.effect-flags',
556 559 default=True,
557 560 alias=[(b'experimental', b'effect-flags')],
558 561 )
559 562 coreconfigitem(
560 563 b'experimental', b'evolution.exchange', default=None,
561 564 )
562 565 coreconfigitem(
563 566 b'experimental', b'evolution.bundle-obsmarker', default=False,
564 567 )
565 568 coreconfigitem(
566 569 b'experimental', b'log.topo', default=False,
567 570 )
568 571 coreconfigitem(
569 572 b'experimental', b'evolution.report-instabilities', default=True,
570 573 )
571 574 coreconfigitem(
572 575 b'experimental', b'evolution.track-operation', default=True,
573 576 )
574 577 # repo-level config to exclude a revset visibility
575 578 #
576 579 # The target use case is to use `share` to expose different subset of the same
577 580 # repository, especially server side. See also `server.view`.
578 581 coreconfigitem(
579 582 b'experimental', b'extra-filter-revs', default=None,
580 583 )
581 584 coreconfigitem(
582 585 b'experimental', b'maxdeltachainspan', default=-1,
583 586 )
584 587 coreconfigitem(
585 588 b'experimental', b'mergetempdirprefix', default=None,
586 589 )
587 590 coreconfigitem(
588 591 b'experimental', b'mmapindexthreshold', default=None,
589 592 )
590 593 coreconfigitem(
591 594 b'experimental', b'narrow', default=False,
592 595 )
593 596 coreconfigitem(
594 597 b'experimental', b'nonnormalparanoidcheck', default=False,
595 598 )
596 599 coreconfigitem(
597 600 b'experimental', b'exportableenviron', default=list,
598 601 )
599 602 coreconfigitem(
600 603 b'experimental', b'extendedheader.index', default=None,
601 604 )
602 605 coreconfigitem(
603 606 b'experimental', b'extendedheader.similarity', default=False,
604 607 )
605 608 coreconfigitem(
606 609 b'experimental', b'graphshorten', default=False,
607 610 )
608 611 coreconfigitem(
609 612 b'experimental', b'graphstyle.parent', default=dynamicdefault,
610 613 )
611 614 coreconfigitem(
612 615 b'experimental', b'graphstyle.missing', default=dynamicdefault,
613 616 )
614 617 coreconfigitem(
615 618 b'experimental', b'graphstyle.grandparent', default=dynamicdefault,
616 619 )
617 620 coreconfigitem(
618 621 b'experimental', b'hook-track-tags', default=False,
619 622 )
620 623 coreconfigitem(
621 624 b'experimental', b'httppeer.advertise-v2', default=False,
622 625 )
623 626 coreconfigitem(
624 627 b'experimental', b'httppeer.v2-encoder-order', default=None,
625 628 )
626 629 coreconfigitem(
627 630 b'experimental', b'httppostargs', default=False,
628 631 )
629 632 coreconfigitem(
630 633 b'experimental', b'mergedriver', default=None,
631 634 )
632 635 coreconfigitem(b'experimental', b'nointerrupt', default=False)
633 636 coreconfigitem(b'experimental', b'nointerrupt-interactiveonly', default=True)
634 637
635 638 coreconfigitem(
636 639 b'experimental', b'obsmarkers-exchange-debug', default=False,
637 640 )
638 641 coreconfigitem(
639 642 b'experimental', b'remotenames', default=False,
640 643 )
641 644 coreconfigitem(
642 645 b'experimental', b'removeemptydirs', default=True,
643 646 )
644 647 coreconfigitem(
645 648 b'experimental', b'revert.interactive.select-to-keep', default=False,
646 649 )
647 650 coreconfigitem(
648 651 b'experimental', b'revisions.prefixhexnode', default=False,
649 652 )
650 653 coreconfigitem(
651 654 b'experimental', b'revlogv2', default=None,
652 655 )
653 656 coreconfigitem(
654 657 b'experimental', b'revisions.disambiguatewithin', default=None,
655 658 )
656 659 coreconfigitem(
657 660 b'experimental', b'server.filesdata.recommended-batch-size', default=50000,
658 661 )
659 662 coreconfigitem(
660 663 b'experimental',
661 664 b'server.manifestdata.recommended-batch-size',
662 665 default=100000,
663 666 )
664 667 coreconfigitem(
665 668 b'experimental', b'server.stream-narrow-clones', default=False,
666 669 )
667 670 coreconfigitem(
668 671 b'experimental', b'single-head-per-branch', default=False,
669 672 )
670 673 coreconfigitem(
671 674 b'experimental',
672 675 b'single-head-per-branch:account-closed-heads',
673 676 default=False,
674 677 )
675 678 coreconfigitem(
676 679 b'experimental', b'sshserver.support-v2', default=False,
677 680 )
678 681 coreconfigitem(
679 682 b'experimental', b'sparse-read', default=False,
680 683 )
681 684 coreconfigitem(
682 685 b'experimental', b'sparse-read.density-threshold', default=0.50,
683 686 )
684 687 coreconfigitem(
685 688 b'experimental', b'sparse-read.min-gap-size', default=b'65K',
686 689 )
687 690 coreconfigitem(
688 691 b'experimental', b'treemanifest', default=False,
689 692 )
690 693 coreconfigitem(
691 694 b'experimental', b'update.atomic-file', default=False,
692 695 )
693 696 coreconfigitem(
694 697 b'experimental', b'sshpeer.advertise-v2', default=False,
695 698 )
696 699 coreconfigitem(
697 700 b'experimental', b'web.apiserver', default=False,
698 701 )
699 702 coreconfigitem(
700 703 b'experimental', b'web.api.http-v2', default=False,
701 704 )
702 705 coreconfigitem(
703 706 b'experimental', b'web.api.debugreflect', default=False,
704 707 )
705 708 coreconfigitem(
706 709 b'experimental', b'worker.wdir-get-thread-safe', default=False,
707 710 )
708 711 coreconfigitem(
709 712 b'experimental', b'worker.repository-upgrade', default=False,
710 713 )
711 714 coreconfigitem(
712 715 b'experimental', b'xdiff', default=False,
713 716 )
714 717 coreconfigitem(
715 718 b'extensions', b'.*', default=None, generic=True,
716 719 )
717 720 coreconfigitem(
718 721 b'extdata', b'.*', default=None, generic=True,
719 722 )
720 723 coreconfigitem(
721 724 b'format', b'bookmarks-in-store', default=False,
722 725 )
723 726 coreconfigitem(
724 727 b'format', b'chunkcachesize', default=None, experimental=True,
725 728 )
726 729 coreconfigitem(
727 730 b'format', b'dotencode', default=True,
728 731 )
729 732 coreconfigitem(
730 733 b'format', b'generaldelta', default=False, experimental=True,
731 734 )
732 735 coreconfigitem(
733 736 b'format', b'manifestcachesize', default=None, experimental=True,
734 737 )
735 738 coreconfigitem(
736 739 b'format', b'maxchainlen', default=dynamicdefault, experimental=True,
737 740 )
738 741 coreconfigitem(
739 742 b'format', b'obsstore-version', default=None,
740 743 )
741 744 coreconfigitem(
742 745 b'format', b'sparse-revlog', default=True,
743 746 )
744 747 coreconfigitem(
745 748 b'format',
746 749 b'revlog-compression',
747 750 default=b'zlib',
748 751 alias=[(b'experimental', b'format.compression')],
749 752 )
750 753 coreconfigitem(
751 754 b'format', b'usefncache', default=True,
752 755 )
753 756 coreconfigitem(
754 757 b'format', b'usegeneraldelta', default=True,
755 758 )
756 759 coreconfigitem(
757 760 b'format', b'usestore', default=True,
758 761 )
759 762 coreconfigitem(
760 763 b'format',
761 764 b'exp-use-copies-side-data-changeset',
762 765 default=False,
763 766 experimental=True,
764 767 )
765 768 coreconfigitem(
766 769 b'format', b'exp-use-side-data', default=False, experimental=True,
767 770 )
768 771 coreconfigitem(
769 772 b'format', b'internal-phase', default=False, experimental=True,
770 773 )
771 774 coreconfigitem(
772 775 b'fsmonitor', b'warn_when_unused', default=True,
773 776 )
774 777 coreconfigitem(
775 778 b'fsmonitor', b'warn_update_file_count', default=50000,
776 779 )
777 780 coreconfigitem(
778 781 b'help', br'hidden-command\..*', default=False, generic=True,
779 782 )
780 783 coreconfigitem(
781 784 b'help', br'hidden-topic\..*', default=False, generic=True,
782 785 )
783 786 coreconfigitem(
784 787 b'hooks', b'.*', default=dynamicdefault, generic=True,
785 788 )
786 789 coreconfigitem(
787 790 b'hgweb-paths', b'.*', default=list, generic=True,
788 791 )
789 792 coreconfigitem(
790 793 b'hostfingerprints', b'.*', default=list, generic=True,
791 794 )
792 795 coreconfigitem(
793 796 b'hostsecurity', b'ciphers', default=None,
794 797 )
795 798 coreconfigitem(
796 799 b'hostsecurity', b'disabletls10warning', default=False,
797 800 )
798 801 coreconfigitem(
799 802 b'hostsecurity', b'minimumprotocol', default=dynamicdefault,
800 803 )
801 804 coreconfigitem(
802 805 b'hostsecurity',
803 806 b'.*:minimumprotocol$',
804 807 default=dynamicdefault,
805 808 generic=True,
806 809 )
807 810 coreconfigitem(
808 811 b'hostsecurity', b'.*:ciphers$', default=dynamicdefault, generic=True,
809 812 )
810 813 coreconfigitem(
811 814 b'hostsecurity', b'.*:fingerprints$', default=list, generic=True,
812 815 )
813 816 coreconfigitem(
814 817 b'hostsecurity', b'.*:verifycertsfile$', default=None, generic=True,
815 818 )
816 819
817 820 coreconfigitem(
818 821 b'http_proxy', b'always', default=False,
819 822 )
820 823 coreconfigitem(
821 824 b'http_proxy', b'host', default=None,
822 825 )
823 826 coreconfigitem(
824 827 b'http_proxy', b'no', default=list,
825 828 )
826 829 coreconfigitem(
827 830 b'http_proxy', b'passwd', default=None,
828 831 )
829 832 coreconfigitem(
830 833 b'http_proxy', b'user', default=None,
831 834 )
832 835
833 836 coreconfigitem(
834 837 b'http', b'timeout', default=None,
835 838 )
836 839
837 840 coreconfigitem(
838 841 b'logtoprocess', b'commandexception', default=None,
839 842 )
840 843 coreconfigitem(
841 844 b'logtoprocess', b'commandfinish', default=None,
842 845 )
843 846 coreconfigitem(
844 847 b'logtoprocess', b'command', default=None,
845 848 )
846 849 coreconfigitem(
847 850 b'logtoprocess', b'develwarn', default=None,
848 851 )
849 852 coreconfigitem(
850 853 b'logtoprocess', b'uiblocked', default=None,
851 854 )
852 855 coreconfigitem(
853 856 b'merge', b'checkunknown', default=b'abort',
854 857 )
855 858 coreconfigitem(
856 859 b'merge', b'checkignored', default=b'abort',
857 860 )
858 861 coreconfigitem(
859 862 b'experimental', b'merge.checkpathconflicts', default=False,
860 863 )
861 864 coreconfigitem(
862 865 b'merge', b'followcopies', default=True,
863 866 )
864 867 coreconfigitem(
865 868 b'merge', b'on-failure', default=b'continue',
866 869 )
867 870 coreconfigitem(
868 871 b'merge', b'preferancestor', default=lambda: [b'*'], experimental=True,
869 872 )
870 873 coreconfigitem(
871 874 b'merge', b'strict-capability-check', default=False,
872 875 )
873 876 coreconfigitem(
874 877 b'merge-tools', b'.*', default=None, generic=True,
875 878 )
876 879 coreconfigitem(
877 880 b'merge-tools',
878 881 br'.*\.args$',
879 882 default=b"$local $base $other",
880 883 generic=True,
881 884 priority=-1,
882 885 )
883 886 coreconfigitem(
884 887 b'merge-tools', br'.*\.binary$', default=False, generic=True, priority=-1,
885 888 )
886 889 coreconfigitem(
887 890 b'merge-tools', br'.*\.check$', default=list, generic=True, priority=-1,
888 891 )
889 892 coreconfigitem(
890 893 b'merge-tools',
891 894 br'.*\.checkchanged$',
892 895 default=False,
893 896 generic=True,
894 897 priority=-1,
895 898 )
896 899 coreconfigitem(
897 900 b'merge-tools',
898 901 br'.*\.executable$',
899 902 default=dynamicdefault,
900 903 generic=True,
901 904 priority=-1,
902 905 )
903 906 coreconfigitem(
904 907 b'merge-tools', br'.*\.fixeol$', default=False, generic=True, priority=-1,
905 908 )
906 909 coreconfigitem(
907 910 b'merge-tools', br'.*\.gui$', default=False, generic=True, priority=-1,
908 911 )
909 912 coreconfigitem(
910 913 b'merge-tools',
911 914 br'.*\.mergemarkers$',
912 915 default=b'basic',
913 916 generic=True,
914 917 priority=-1,
915 918 )
916 919 coreconfigitem(
917 920 b'merge-tools',
918 921 br'.*\.mergemarkertemplate$',
919 922 default=dynamicdefault, # take from ui.mergemarkertemplate
920 923 generic=True,
921 924 priority=-1,
922 925 )
923 926 coreconfigitem(
924 927 b'merge-tools', br'.*\.priority$', default=0, generic=True, priority=-1,
925 928 )
926 929 coreconfigitem(
927 930 b'merge-tools',
928 931 br'.*\.premerge$',
929 932 default=dynamicdefault,
930 933 generic=True,
931 934 priority=-1,
932 935 )
933 936 coreconfigitem(
934 937 b'merge-tools', br'.*\.symlink$', default=False, generic=True, priority=-1,
935 938 )
936 939 coreconfigitem(
937 940 b'pager', b'attend-.*', default=dynamicdefault, generic=True,
938 941 )
939 942 coreconfigitem(
940 943 b'pager', b'ignore', default=list,
941 944 )
942 945 coreconfigitem(
943 946 b'pager', b'pager', default=dynamicdefault,
944 947 )
945 948 coreconfigitem(
946 949 b'patch', b'eol', default=b'strict',
947 950 )
948 951 coreconfigitem(
949 952 b'patch', b'fuzz', default=2,
950 953 )
951 954 coreconfigitem(
952 955 b'paths', b'default', default=None,
953 956 )
954 957 coreconfigitem(
955 958 b'paths', b'default-push', default=None,
956 959 )
957 960 coreconfigitem(
958 961 b'paths', b'.*', default=None, generic=True,
959 962 )
960 963 coreconfigitem(
961 964 b'phases', b'checksubrepos', default=b'follow',
962 965 )
963 966 coreconfigitem(
964 967 b'phases', b'new-commit', default=b'draft',
965 968 )
966 969 coreconfigitem(
967 970 b'phases', b'publish', default=True,
968 971 )
969 972 coreconfigitem(
970 973 b'profiling', b'enabled', default=False,
971 974 )
972 975 coreconfigitem(
973 976 b'profiling', b'format', default=b'text',
974 977 )
975 978 coreconfigitem(
976 979 b'profiling', b'freq', default=1000,
977 980 )
978 981 coreconfigitem(
979 982 b'profiling', b'limit', default=30,
980 983 )
981 984 coreconfigitem(
982 985 b'profiling', b'nested', default=0,
983 986 )
984 987 coreconfigitem(
985 988 b'profiling', b'output', default=None,
986 989 )
987 990 coreconfigitem(
988 991 b'profiling', b'showmax', default=0.999,
989 992 )
990 993 coreconfigitem(
991 994 b'profiling', b'showmin', default=dynamicdefault,
992 995 )
993 996 coreconfigitem(
994 997 b'profiling', b'showtime', default=True,
995 998 )
996 999 coreconfigitem(
997 1000 b'profiling', b'sort', default=b'inlinetime',
998 1001 )
999 1002 coreconfigitem(
1000 1003 b'profiling', b'statformat', default=b'hotpath',
1001 1004 )
1002 1005 coreconfigitem(
1003 1006 b'profiling', b'time-track', default=dynamicdefault,
1004 1007 )
1005 1008 coreconfigitem(
1006 1009 b'profiling', b'type', default=b'stat',
1007 1010 )
1008 1011 coreconfigitem(
1009 1012 b'progress', b'assume-tty', default=False,
1010 1013 )
1011 1014 coreconfigitem(
1012 1015 b'progress', b'changedelay', default=1,
1013 1016 )
1014 1017 coreconfigitem(
1015 1018 b'progress', b'clear-complete', default=True,
1016 1019 )
1017 1020 coreconfigitem(
1018 1021 b'progress', b'debug', default=False,
1019 1022 )
1020 1023 coreconfigitem(
1021 1024 b'progress', b'delay', default=3,
1022 1025 )
1023 1026 coreconfigitem(
1024 1027 b'progress', b'disable', default=False,
1025 1028 )
1026 1029 coreconfigitem(
1027 1030 b'progress', b'estimateinterval', default=60.0,
1028 1031 )
1029 1032 coreconfigitem(
1030 1033 b'progress',
1031 1034 b'format',
1032 1035 default=lambda: [b'topic', b'bar', b'number', b'estimate'],
1033 1036 )
1034 1037 coreconfigitem(
1035 1038 b'progress', b'refresh', default=0.1,
1036 1039 )
1037 1040 coreconfigitem(
1038 1041 b'progress', b'width', default=dynamicdefault,
1039 1042 )
1040 1043 coreconfigitem(
1041 1044 b'push', b'pushvars.server', default=False,
1042 1045 )
1043 1046 coreconfigitem(
1044 1047 b'rewrite',
1045 1048 b'backup-bundle',
1046 1049 default=True,
1047 1050 alias=[(b'ui', b'history-editing-backup')],
1048 1051 )
1049 1052 coreconfigitem(
1050 1053 b'rewrite', b'update-timestamp', default=False,
1051 1054 )
1052 1055 coreconfigitem(
1053 1056 b'storage', b'new-repo-backend', default=b'revlogv1', experimental=True,
1054 1057 )
1055 1058 coreconfigitem(
1056 1059 b'storage',
1057 1060 b'revlog.optimize-delta-parent-choice',
1058 1061 default=True,
1059 1062 alias=[(b'format', b'aggressivemergedeltas')],
1060 1063 )
1061 1064 coreconfigitem(
1062 1065 b'storage', b'revlog.reuse-external-delta', default=True,
1063 1066 )
1064 1067 coreconfigitem(
1065 1068 b'storage', b'revlog.reuse-external-delta-parent', default=None,
1066 1069 )
1067 1070 coreconfigitem(
1068 1071 b'storage', b'revlog.zlib.level', default=None,
1069 1072 )
1070 1073 coreconfigitem(
1071 1074 b'storage', b'revlog.zstd.level', default=None,
1072 1075 )
1073 1076 coreconfigitem(
1074 1077 b'server', b'bookmarks-pushkey-compat', default=True,
1075 1078 )
1076 1079 coreconfigitem(
1077 1080 b'server', b'bundle1', default=True,
1078 1081 )
1079 1082 coreconfigitem(
1080 1083 b'server', b'bundle1gd', default=None,
1081 1084 )
1082 1085 coreconfigitem(
1083 1086 b'server', b'bundle1.pull', default=None,
1084 1087 )
1085 1088 coreconfigitem(
1086 1089 b'server', b'bundle1gd.pull', default=None,
1087 1090 )
1088 1091 coreconfigitem(
1089 1092 b'server', b'bundle1.push', default=None,
1090 1093 )
1091 1094 coreconfigitem(
1092 1095 b'server', b'bundle1gd.push', default=None,
1093 1096 )
1094 1097 coreconfigitem(
1095 1098 b'server',
1096 1099 b'bundle2.stream',
1097 1100 default=True,
1098 1101 alias=[(b'experimental', b'bundle2.stream')],
1099 1102 )
1100 1103 coreconfigitem(
1101 1104 b'server', b'compressionengines', default=list,
1102 1105 )
1103 1106 coreconfigitem(
1104 1107 b'server', b'concurrent-push-mode', default=b'strict',
1105 1108 )
1106 1109 coreconfigitem(
1107 1110 b'server', b'disablefullbundle', default=False,
1108 1111 )
1109 1112 coreconfigitem(
1110 1113 b'server', b'maxhttpheaderlen', default=1024,
1111 1114 )
1112 1115 coreconfigitem(
1113 1116 b'server', b'pullbundle', default=False,
1114 1117 )
1115 1118 coreconfigitem(
1116 1119 b'server', b'preferuncompressed', default=False,
1117 1120 )
1118 1121 coreconfigitem(
1119 1122 b'server', b'streamunbundle', default=False,
1120 1123 )
1121 1124 coreconfigitem(
1122 1125 b'server', b'uncompressed', default=True,
1123 1126 )
1124 1127 coreconfigitem(
1125 1128 b'server', b'uncompressedallowsecret', default=False,
1126 1129 )
1127 1130 coreconfigitem(
1128 1131 b'server', b'view', default=b'served',
1129 1132 )
1130 1133 coreconfigitem(
1131 1134 b'server', b'validate', default=False,
1132 1135 )
1133 1136 coreconfigitem(
1134 1137 b'server', b'zliblevel', default=-1,
1135 1138 )
1136 1139 coreconfigitem(
1137 1140 b'server', b'zstdlevel', default=3,
1138 1141 )
1139 1142 coreconfigitem(
1140 1143 b'share', b'pool', default=None,
1141 1144 )
1142 1145 coreconfigitem(
1143 1146 b'share', b'poolnaming', default=b'identity',
1144 1147 )
1145 1148 coreconfigitem(
1146 1149 b'shelve', b'maxbackups', default=10,
1147 1150 )
1148 1151 coreconfigitem(
1149 1152 b'smtp', b'host', default=None,
1150 1153 )
1151 1154 coreconfigitem(
1152 1155 b'smtp', b'local_hostname', default=None,
1153 1156 )
1154 1157 coreconfigitem(
1155 1158 b'smtp', b'password', default=None,
1156 1159 )
1157 1160 coreconfigitem(
1158 1161 b'smtp', b'port', default=dynamicdefault,
1159 1162 )
1160 1163 coreconfigitem(
1161 1164 b'smtp', b'tls', default=b'none',
1162 1165 )
1163 1166 coreconfigitem(
1164 1167 b'smtp', b'username', default=None,
1165 1168 )
1166 1169 coreconfigitem(
1167 1170 b'sparse', b'missingwarning', default=True, experimental=True,
1168 1171 )
1169 1172 coreconfigitem(
1170 1173 b'subrepos',
1171 1174 b'allowed',
1172 1175 default=dynamicdefault, # to make backporting simpler
1173 1176 )
1174 1177 coreconfigitem(
1175 1178 b'subrepos', b'hg:allowed', default=dynamicdefault,
1176 1179 )
1177 1180 coreconfigitem(
1178 1181 b'subrepos', b'git:allowed', default=dynamicdefault,
1179 1182 )
1180 1183 coreconfigitem(
1181 1184 b'subrepos', b'svn:allowed', default=dynamicdefault,
1182 1185 )
1183 1186 coreconfigitem(
1184 1187 b'templates', b'.*', default=None, generic=True,
1185 1188 )
1186 1189 coreconfigitem(
1187 1190 b'templateconfig', b'.*', default=dynamicdefault, generic=True,
1188 1191 )
1189 1192 coreconfigitem(
1190 1193 b'trusted', b'groups', default=list,
1191 1194 )
1192 1195 coreconfigitem(
1193 1196 b'trusted', b'users', default=list,
1194 1197 )
1195 1198 coreconfigitem(
1196 1199 b'ui', b'_usedassubrepo', default=False,
1197 1200 )
1198 1201 coreconfigitem(
1199 1202 b'ui', b'allowemptycommit', default=False,
1200 1203 )
1201 1204 coreconfigitem(
1202 1205 b'ui', b'archivemeta', default=True,
1203 1206 )
1204 1207 coreconfigitem(
1205 1208 b'ui', b'askusername', default=False,
1206 1209 )
1207 1210 coreconfigitem(
1208 1211 b'ui', b'clonebundlefallback', default=False,
1209 1212 )
1210 1213 coreconfigitem(
1211 1214 b'ui', b'clonebundleprefers', default=list,
1212 1215 )
1213 1216 coreconfigitem(
1214 1217 b'ui', b'clonebundles', default=True,
1215 1218 )
1216 1219 coreconfigitem(
1217 1220 b'ui', b'color', default=b'auto',
1218 1221 )
1219 1222 coreconfigitem(
1220 1223 b'ui', b'commitsubrepos', default=False,
1221 1224 )
1222 1225 coreconfigitem(
1223 1226 b'ui', b'debug', default=False,
1224 1227 )
1225 1228 coreconfigitem(
1226 1229 b'ui', b'debugger', default=None,
1227 1230 )
1228 1231 coreconfigitem(
1229 1232 b'ui', b'editor', default=dynamicdefault,
1230 1233 )
1231 1234 coreconfigitem(
1232 1235 b'ui', b'fallbackencoding', default=None,
1233 1236 )
1234 1237 coreconfigitem(
1235 1238 b'ui', b'forcecwd', default=None,
1236 1239 )
1237 1240 coreconfigitem(
1238 1241 b'ui', b'forcemerge', default=None,
1239 1242 )
1240 1243 coreconfigitem(
1241 1244 b'ui', b'formatdebug', default=False,
1242 1245 )
1243 1246 coreconfigitem(
1244 1247 b'ui', b'formatjson', default=False,
1245 1248 )
1246 1249 coreconfigitem(
1247 1250 b'ui', b'formatted', default=None,
1248 1251 )
1249 1252 coreconfigitem(
1250 1253 b'ui', b'graphnodetemplate', default=None,
1251 1254 )
1252 1255 coreconfigitem(
1253 1256 b'ui', b'interactive', default=None,
1254 1257 )
1255 1258 coreconfigitem(
1256 1259 b'ui', b'interface', default=None,
1257 1260 )
1258 1261 coreconfigitem(
1259 1262 b'ui', b'interface.chunkselector', default=None,
1260 1263 )
1261 1264 coreconfigitem(
1262 1265 b'ui', b'large-file-limit', default=10000000,
1263 1266 )
1264 1267 coreconfigitem(
1265 1268 b'ui', b'logblockedtimes', default=False,
1266 1269 )
1267 1270 coreconfigitem(
1268 1271 b'ui', b'logtemplate', default=None,
1269 1272 )
1270 1273 coreconfigitem(
1271 1274 b'ui', b'merge', default=None,
1272 1275 )
1273 1276 coreconfigitem(
1274 1277 b'ui', b'mergemarkers', default=b'basic',
1275 1278 )
1276 1279 coreconfigitem(
1277 1280 b'ui',
1278 1281 b'mergemarkertemplate',
1279 1282 default=(
1280 1283 b'{node|short} '
1281 1284 b'{ifeq(tags, "tip", "", '
1282 1285 b'ifeq(tags, "", "", "{tags} "))}'
1283 1286 b'{if(bookmarks, "{bookmarks} ")}'
1284 1287 b'{ifeq(branch, "default", "", "{branch} ")}'
1285 1288 b'- {author|user}: {desc|firstline}'
1286 1289 ),
1287 1290 )
1288 1291 coreconfigitem(
1289 1292 b'ui', b'message-output', default=b'stdio',
1290 1293 )
1291 1294 coreconfigitem(
1292 1295 b'ui', b'nontty', default=False,
1293 1296 )
1294 1297 coreconfigitem(
1295 1298 b'ui', b'origbackuppath', default=None,
1296 1299 )
1297 1300 coreconfigitem(
1298 1301 b'ui', b'paginate', default=True,
1299 1302 )
1300 1303 coreconfigitem(
1301 1304 b'ui', b'patch', default=None,
1302 1305 )
1303 1306 coreconfigitem(
1304 1307 b'ui', b'pre-merge-tool-output-template', default=None,
1305 1308 )
1306 1309 coreconfigitem(
1307 1310 b'ui', b'portablefilenames', default=b'warn',
1308 1311 )
1309 1312 coreconfigitem(
1310 1313 b'ui', b'promptecho', default=False,
1311 1314 )
1312 1315 coreconfigitem(
1313 1316 b'ui', b'quiet', default=False,
1314 1317 )
1315 1318 coreconfigitem(
1316 1319 b'ui', b'quietbookmarkmove', default=False,
1317 1320 )
1318 1321 coreconfigitem(
1319 1322 b'ui', b'relative-paths', default=b'legacy',
1320 1323 )
1321 1324 coreconfigitem(
1322 1325 b'ui', b'remotecmd', default=b'hg',
1323 1326 )
1324 1327 coreconfigitem(
1325 1328 b'ui', b'report_untrusted', default=True,
1326 1329 )
1327 1330 coreconfigitem(
1328 1331 b'ui', b'rollback', default=True,
1329 1332 )
1330 1333 coreconfigitem(
1331 1334 b'ui', b'signal-safe-lock', default=True,
1332 1335 )
1333 1336 coreconfigitem(
1334 1337 b'ui', b'slash', default=False,
1335 1338 )
1336 1339 coreconfigitem(
1337 1340 b'ui', b'ssh', default=b'ssh',
1338 1341 )
1339 1342 coreconfigitem(
1340 1343 b'ui', b'ssherrorhint', default=None,
1341 1344 )
1342 1345 coreconfigitem(
1343 1346 b'ui', b'statuscopies', default=False,
1344 1347 )
1345 1348 coreconfigitem(
1346 1349 b'ui', b'strict', default=False,
1347 1350 )
1348 1351 coreconfigitem(
1349 1352 b'ui', b'style', default=b'',
1350 1353 )
1351 1354 coreconfigitem(
1352 1355 b'ui', b'supportcontact', default=None,
1353 1356 )
1354 1357 coreconfigitem(
1355 1358 b'ui', b'textwidth', default=78,
1356 1359 )
1357 1360 coreconfigitem(
1358 1361 b'ui', b'timeout', default=b'600',
1359 1362 )
1360 1363 coreconfigitem(
1361 1364 b'ui', b'timeout.warn', default=0,
1362 1365 )
1363 1366 coreconfigitem(
1364 1367 b'ui', b'traceback', default=False,
1365 1368 )
1366 1369 coreconfigitem(
1367 1370 b'ui', b'tweakdefaults', default=False,
1368 1371 )
1369 1372 coreconfigitem(b'ui', b'username', alias=[(b'ui', b'user')])
1370 1373 coreconfigitem(
1371 1374 b'ui', b'verbose', default=False,
1372 1375 )
1373 1376 coreconfigitem(
1374 1377 b'verify', b'skipflags', default=None,
1375 1378 )
1376 1379 coreconfigitem(
1377 1380 b'web', b'allowbz2', default=False,
1378 1381 )
1379 1382 coreconfigitem(
1380 1383 b'web', b'allowgz', default=False,
1381 1384 )
1382 1385 coreconfigitem(
1383 1386 b'web', b'allow-pull', alias=[(b'web', b'allowpull')], default=True,
1384 1387 )
1385 1388 coreconfigitem(
1386 1389 b'web', b'allow-push', alias=[(b'web', b'allow_push')], default=list,
1387 1390 )
1388 1391 coreconfigitem(
1389 1392 b'web', b'allowzip', default=False,
1390 1393 )
1391 1394 coreconfigitem(
1392 1395 b'web', b'archivesubrepos', default=False,
1393 1396 )
1394 1397 coreconfigitem(
1395 1398 b'web', b'cache', default=True,
1396 1399 )
1397 1400 coreconfigitem(
1398 1401 b'web', b'comparisoncontext', default=5,
1399 1402 )
1400 1403 coreconfigitem(
1401 1404 b'web', b'contact', default=None,
1402 1405 )
1403 1406 coreconfigitem(
1404 1407 b'web', b'deny_push', default=list,
1405 1408 )
1406 1409 coreconfigitem(
1407 1410 b'web', b'guessmime', default=False,
1408 1411 )
1409 1412 coreconfigitem(
1410 1413 b'web', b'hidden', default=False,
1411 1414 )
1412 1415 coreconfigitem(
1413 1416 b'web', b'labels', default=list,
1414 1417 )
1415 1418 coreconfigitem(
1416 1419 b'web', b'logoimg', default=b'hglogo.png',
1417 1420 )
1418 1421 coreconfigitem(
1419 1422 b'web', b'logourl', default=b'https://mercurial-scm.org/',
1420 1423 )
1421 1424 coreconfigitem(
1422 1425 b'web', b'accesslog', default=b'-',
1423 1426 )
1424 1427 coreconfigitem(
1425 1428 b'web', b'address', default=b'',
1426 1429 )
1427 1430 coreconfigitem(
1428 1431 b'web', b'allow-archive', alias=[(b'web', b'allow_archive')], default=list,
1429 1432 )
1430 1433 coreconfigitem(
1431 1434 b'web', b'allow_read', default=list,
1432 1435 )
1433 1436 coreconfigitem(
1434 1437 b'web', b'baseurl', default=None,
1435 1438 )
1436 1439 coreconfigitem(
1437 1440 b'web', b'cacerts', default=None,
1438 1441 )
1439 1442 coreconfigitem(
1440 1443 b'web', b'certificate', default=None,
1441 1444 )
1442 1445 coreconfigitem(
1443 1446 b'web', b'collapse', default=False,
1444 1447 )
1445 1448 coreconfigitem(
1446 1449 b'web', b'csp', default=None,
1447 1450 )
1448 1451 coreconfigitem(
1449 1452 b'web', b'deny_read', default=list,
1450 1453 )
1451 1454 coreconfigitem(
1452 1455 b'web', b'descend', default=True,
1453 1456 )
1454 1457 coreconfigitem(
1455 1458 b'web', b'description', default=b"",
1456 1459 )
1457 1460 coreconfigitem(
1458 1461 b'web', b'encoding', default=lambda: encoding.encoding,
1459 1462 )
1460 1463 coreconfigitem(
1461 1464 b'web', b'errorlog', default=b'-',
1462 1465 )
1463 1466 coreconfigitem(
1464 1467 b'web', b'ipv6', default=False,
1465 1468 )
1466 1469 coreconfigitem(
1467 1470 b'web', b'maxchanges', default=10,
1468 1471 )
1469 1472 coreconfigitem(
1470 1473 b'web', b'maxfiles', default=10,
1471 1474 )
1472 1475 coreconfigitem(
1473 1476 b'web', b'maxshortchanges', default=60,
1474 1477 )
1475 1478 coreconfigitem(
1476 1479 b'web', b'motd', default=b'',
1477 1480 )
1478 1481 coreconfigitem(
1479 1482 b'web', b'name', default=dynamicdefault,
1480 1483 )
1481 1484 coreconfigitem(
1482 1485 b'web', b'port', default=8000,
1483 1486 )
1484 1487 coreconfigitem(
1485 1488 b'web', b'prefix', default=b'',
1486 1489 )
1487 1490 coreconfigitem(
1488 1491 b'web', b'push_ssl', default=True,
1489 1492 )
1490 1493 coreconfigitem(
1491 1494 b'web', b'refreshinterval', default=20,
1492 1495 )
1493 1496 coreconfigitem(
1494 1497 b'web', b'server-header', default=None,
1495 1498 )
1496 1499 coreconfigitem(
1497 1500 b'web', b'static', default=None,
1498 1501 )
1499 1502 coreconfigitem(
1500 1503 b'web', b'staticurl', default=None,
1501 1504 )
1502 1505 coreconfigitem(
1503 1506 b'web', b'stripes', default=1,
1504 1507 )
1505 1508 coreconfigitem(
1506 1509 b'web', b'style', default=b'paper',
1507 1510 )
1508 1511 coreconfigitem(
1509 1512 b'web', b'templates', default=None,
1510 1513 )
1511 1514 coreconfigitem(
1512 1515 b'web', b'view', default=b'served', experimental=True,
1513 1516 )
1514 1517 coreconfigitem(
1515 1518 b'worker', b'backgroundclose', default=dynamicdefault,
1516 1519 )
1517 1520 # Windows defaults to a limit of 512 open files. A buffer of 128
1518 1521 # should give us enough headway.
1519 1522 coreconfigitem(
1520 1523 b'worker', b'backgroundclosemaxqueue', default=384,
1521 1524 )
1522 1525 coreconfigitem(
1523 1526 b'worker', b'backgroundcloseminfilecount', default=2048,
1524 1527 )
1525 1528 coreconfigitem(
1526 1529 b'worker', b'backgroundclosethreadcount', default=4,
1527 1530 )
1528 1531 coreconfigitem(
1529 1532 b'worker', b'enabled', default=True,
1530 1533 )
1531 1534 coreconfigitem(
1532 1535 b'worker', b'numcpus', default=None,
1533 1536 )
1534 1537
1535 1538 # Rebase related configuration moved to core because other extension are doing
1536 1539 # strange things. For example, shelve import the extensions to reuse some bit
1537 1540 # without formally loading it.
1538 1541 coreconfigitem(
1539 1542 b'commands', b'rebase.requiredest', default=False,
1540 1543 )
1541 1544 coreconfigitem(
1542 1545 b'experimental', b'rebaseskipobsolete', default=True,
1543 1546 )
1544 1547 coreconfigitem(
1545 1548 b'rebase', b'singletransaction', default=False,
1546 1549 )
1547 1550 coreconfigitem(
1548 1551 b'rebase', b'experimental.inmemory', default=False,
1549 1552 )
@@ -1,2870 +1,2876 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>/*.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>/*.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>/*.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 ``commit.post-status``
442 442 Show status of files in the working directory after successful commit.
443 443 (default: False)
444 444
445 ``merge.require-rev``
446 Require that the revision to merge the current commit with be specified on
447 the command line. If this is enabled and a revision is not specified, the
448 command aborts.
449 (default: False)
450
445 451 ``push.require-revs``
446 452 Require revisions to push be specified using one or more mechanisms such as
447 453 specifying them positionally on the command line, using ``-r``, ``-b``,
448 454 and/or ``-B`` on the command line, or using ``paths.<path>:pushrev`` in the
449 455 configuration. If this is enabled and revisions are not specified, the
450 456 command aborts.
451 457 (default: False)
452 458
453 459 ``resolve.confirm``
454 460 Confirm before performing action if no filename is passed.
455 461 (default: False)
456 462
457 463 ``resolve.explicit-re-merge``
458 464 Require uses of ``hg resolve`` to specify which action it should perform,
459 465 instead of re-merging files by default.
460 466 (default: False)
461 467
462 468 ``resolve.mark-check``
463 469 Determines what level of checking :hg:`resolve --mark` will perform before
464 470 marking files as resolved. Valid values are ``none`, ``warn``, and
465 471 ``abort``. ``warn`` will output a warning listing the file(s) that still
466 472 have conflict markers in them, but will still mark everything resolved.
467 473 ``abort`` will output the same warning but will not mark things as resolved.
468 474 If --all is passed and this is set to ``abort``, only a warning will be
469 475 shown (an error will not be raised).
470 476 (default: ``none``)
471 477
472 478 ``status.relative``
473 479 Make paths in :hg:`status` output relative to the current directory.
474 480 (default: False)
475 481
476 482 ``status.terse``
477 483 Default value for the --terse flag, which condenses status output.
478 484 (default: empty)
479 485
480 486 ``update.check``
481 487 Determines what level of checking :hg:`update` will perform before moving
482 488 to a destination revision. Valid values are ``abort``, ``none``,
483 489 ``linear``, and ``noconflict``. ``abort`` always fails if the working
484 490 directory has uncommitted changes. ``none`` performs no checking, and may
485 491 result in a merge with uncommitted changes. ``linear`` allows any update
486 492 as long as it follows a straight line in the revision history, and may
487 493 trigger a merge with uncommitted changes. ``noconflict`` will allow any
488 494 update which would not trigger a merge with uncommitted changes, if any
489 495 are present.
490 496 (default: ``linear``)
491 497
492 498 ``update.requiredest``
493 499 Require that the user pass a destination when running :hg:`update`.
494 500 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
495 501 will be disallowed.
496 502 (default: False)
497 503
498 504 ``committemplate``
499 505 ------------------
500 506
501 507 ``changeset``
502 508 String: configuration in this section is used as the template to
503 509 customize the text shown in the editor when committing.
504 510
505 511 In addition to pre-defined template keywords, commit log specific one
506 512 below can be used for customization:
507 513
508 514 ``extramsg``
509 515 String: Extra message (typically 'Leave message empty to abort
510 516 commit.'). This may be changed by some commands or extensions.
511 517
512 518 For example, the template configuration below shows as same text as
513 519 one shown by default::
514 520
515 521 [committemplate]
516 522 changeset = {desc}\n\n
517 523 HG: Enter commit message. Lines beginning with 'HG:' are removed.
518 524 HG: {extramsg}
519 525 HG: --
520 526 HG: user: {author}\n{ifeq(p2rev, "-1", "",
521 527 "HG: branch merge\n")
522 528 }HG: branch '{branch}'\n{if(activebookmark,
523 529 "HG: bookmark '{activebookmark}'\n") }{subrepos %
524 530 "HG: subrepo {subrepo}\n" }{file_adds %
525 531 "HG: added {file}\n" }{file_mods %
526 532 "HG: changed {file}\n" }{file_dels %
527 533 "HG: removed {file}\n" }{if(files, "",
528 534 "HG: no files changed\n")}
529 535
530 536 ``diff()``
531 537 String: show the diff (see :hg:`help templates` for detail)
532 538
533 539 Sometimes it is helpful to show the diff of the changeset in the editor without
534 540 having to prefix 'HG: ' to each line so that highlighting works correctly. For
535 541 this, Mercurial provides a special string which will ignore everything below
536 542 it::
537 543
538 544 HG: ------------------------ >8 ------------------------
539 545
540 546 For example, the template configuration below will show the diff below the
541 547 extra message::
542 548
543 549 [committemplate]
544 550 changeset = {desc}\n\n
545 551 HG: Enter commit message. Lines beginning with 'HG:' are removed.
546 552 HG: {extramsg}
547 553 HG: ------------------------ >8 ------------------------
548 554 HG: Do not touch the line above.
549 555 HG: Everything below will be removed.
550 556 {diff()}
551 557
552 558 .. note::
553 559
554 560 For some problematic encodings (see :hg:`help win32mbcs` for
555 561 detail), this customization should be configured carefully, to
556 562 avoid showing broken characters.
557 563
558 564 For example, if a multibyte character ending with backslash (0x5c) is
559 565 followed by the ASCII character 'n' in the customized template,
560 566 the sequence of backslash and 'n' is treated as line-feed unexpectedly
561 567 (and the multibyte character is broken, too).
562 568
563 569 Customized template is used for commands below (``--edit`` may be
564 570 required):
565 571
566 572 - :hg:`backout`
567 573 - :hg:`commit`
568 574 - :hg:`fetch` (for merge commit only)
569 575 - :hg:`graft`
570 576 - :hg:`histedit`
571 577 - :hg:`import`
572 578 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
573 579 - :hg:`rebase`
574 580 - :hg:`shelve`
575 581 - :hg:`sign`
576 582 - :hg:`tag`
577 583 - :hg:`transplant`
578 584
579 585 Configuring items below instead of ``changeset`` allows showing
580 586 customized message only for specific actions, or showing different
581 587 messages for each action.
582 588
583 589 - ``changeset.backout`` for :hg:`backout`
584 590 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
585 591 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
586 592 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
587 593 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
588 594 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
589 595 - ``changeset.gpg.sign`` for :hg:`sign`
590 596 - ``changeset.graft`` for :hg:`graft`
591 597 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
592 598 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
593 599 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
594 600 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
595 601 - ``changeset.import.bypass`` for :hg:`import --bypass`
596 602 - ``changeset.import.normal.merge`` for :hg:`import` on merges
597 603 - ``changeset.import.normal.normal`` for :hg:`import` on other
598 604 - ``changeset.mq.qnew`` for :hg:`qnew`
599 605 - ``changeset.mq.qfold`` for :hg:`qfold`
600 606 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
601 607 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
602 608 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
603 609 - ``changeset.rebase.normal`` for :hg:`rebase` on other
604 610 - ``changeset.shelve.shelve`` for :hg:`shelve`
605 611 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
606 612 - ``changeset.tag.remove`` for :hg:`tag --remove`
607 613 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
608 614 - ``changeset.transplant.normal`` for :hg:`transplant` on other
609 615
610 616 These dot-separated lists of names are treated as hierarchical ones.
611 617 For example, ``changeset.tag.remove`` customizes the commit message
612 618 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
613 619 commit message for :hg:`tag` regardless of ``--remove`` option.
614 620
615 621 When the external editor is invoked for a commit, the corresponding
616 622 dot-separated list of names without the ``changeset.`` prefix
617 623 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
618 624 variable.
619 625
620 626 In this section, items other than ``changeset`` can be referred from
621 627 others. For example, the configuration to list committed files up
622 628 below can be referred as ``{listupfiles}``::
623 629
624 630 [committemplate]
625 631 listupfiles = {file_adds %
626 632 "HG: added {file}\n" }{file_mods %
627 633 "HG: changed {file}\n" }{file_dels %
628 634 "HG: removed {file}\n" }{if(files, "",
629 635 "HG: no files changed\n")}
630 636
631 637 ``decode/encode``
632 638 -----------------
633 639
634 640 Filters for transforming files on checkout/checkin. This would
635 641 typically be used for newline processing or other
636 642 localization/canonicalization of files.
637 643
638 644 Filters consist of a filter pattern followed by a filter command.
639 645 Filter patterns are globs by default, rooted at the repository root.
640 646 For example, to match any file ending in ``.txt`` in the root
641 647 directory only, use the pattern ``*.txt``. To match any file ending
642 648 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
643 649 For each file only the first matching filter applies.
644 650
645 651 The filter command can start with a specifier, either ``pipe:`` or
646 652 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
647 653
648 654 A ``pipe:`` command must accept data on stdin and return the transformed
649 655 data on stdout.
650 656
651 657 Pipe example::
652 658
653 659 [encode]
654 660 # uncompress gzip files on checkin to improve delta compression
655 661 # note: not necessarily a good idea, just an example
656 662 *.gz = pipe: gunzip
657 663
658 664 [decode]
659 665 # recompress gzip files when writing them to the working dir (we
660 666 # can safely omit "pipe:", because it's the default)
661 667 *.gz = gzip
662 668
663 669 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
664 670 with the name of a temporary file that contains the data to be
665 671 filtered by the command. The string ``OUTFILE`` is replaced with the name
666 672 of an empty temporary file, where the filtered data must be written by
667 673 the command.
668 674
669 675 .. container:: windows
670 676
671 677 .. note::
672 678
673 679 The tempfile mechanism is recommended for Windows systems,
674 680 where the standard shell I/O redirection operators often have
675 681 strange effects and may corrupt the contents of your files.
676 682
677 683 This filter mechanism is used internally by the ``eol`` extension to
678 684 translate line ending characters between Windows (CRLF) and Unix (LF)
679 685 format. We suggest you use the ``eol`` extension for convenience.
680 686
681 687
682 688 ``defaults``
683 689 ------------
684 690
685 691 (defaults are deprecated. Don't use them. Use aliases instead.)
686 692
687 693 Use the ``[defaults]`` section to define command defaults, i.e. the
688 694 default options/arguments to pass to the specified commands.
689 695
690 696 The following example makes :hg:`log` run in verbose mode, and
691 697 :hg:`status` show only the modified files, by default::
692 698
693 699 [defaults]
694 700 log = -v
695 701 status = -m
696 702
697 703 The actual commands, instead of their aliases, must be used when
698 704 defining command defaults. The command defaults will also be applied
699 705 to the aliases of the commands defined.
700 706
701 707
702 708 ``diff``
703 709 --------
704 710
705 711 Settings used when displaying diffs. Everything except for ``unified``
706 712 is a Boolean and defaults to False. See :hg:`help config.annotate`
707 713 for related options for the annotate command.
708 714
709 715 ``git``
710 716 Use git extended diff format.
711 717
712 718 ``nobinary``
713 719 Omit git binary patches.
714 720
715 721 ``nodates``
716 722 Don't include dates in diff headers.
717 723
718 724 ``noprefix``
719 725 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
720 726
721 727 ``showfunc``
722 728 Show which function each change is in.
723 729
724 730 ``ignorews``
725 731 Ignore white space when comparing lines.
726 732
727 733 ``ignorewsamount``
728 734 Ignore changes in the amount of white space.
729 735
730 736 ``ignoreblanklines``
731 737 Ignore changes whose lines are all blank.
732 738
733 739 ``unified``
734 740 Number of lines of context to show.
735 741
736 742 ``word-diff``
737 743 Highlight changed words.
738 744
739 745 ``email``
740 746 ---------
741 747
742 748 Settings for extensions that send email messages.
743 749
744 750 ``from``
745 751 Optional. Email address to use in "From" header and SMTP envelope
746 752 of outgoing messages.
747 753
748 754 ``to``
749 755 Optional. Comma-separated list of recipients' email addresses.
750 756
751 757 ``cc``
752 758 Optional. Comma-separated list of carbon copy recipients'
753 759 email addresses.
754 760
755 761 ``bcc``
756 762 Optional. Comma-separated list of blind carbon copy recipients'
757 763 email addresses.
758 764
759 765 ``method``
760 766 Optional. Method to use to send email messages. If value is ``smtp``
761 767 (default), use SMTP (see the ``[smtp]`` section for configuration).
762 768 Otherwise, use as name of program to run that acts like sendmail
763 769 (takes ``-f`` option for sender, list of recipients on command line,
764 770 message on stdin). Normally, setting this to ``sendmail`` or
765 771 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
766 772
767 773 ``charsets``
768 774 Optional. Comma-separated list of character sets considered
769 775 convenient for recipients. Addresses, headers, and parts not
770 776 containing patches of outgoing messages will be encoded in the
771 777 first character set to which conversion from local encoding
772 778 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
773 779 conversion fails, the text in question is sent as is.
774 780 (default: '')
775 781
776 782 Order of outgoing email character sets:
777 783
778 784 1. ``us-ascii``: always first, regardless of settings
779 785 2. ``email.charsets``: in order given by user
780 786 3. ``ui.fallbackencoding``: if not in email.charsets
781 787 4. ``$HGENCODING``: if not in email.charsets
782 788 5. ``utf-8``: always last, regardless of settings
783 789
784 790 Email example::
785 791
786 792 [email]
787 793 from = Joseph User <joe.user@example.com>
788 794 method = /usr/sbin/sendmail
789 795 # charsets for western Europeans
790 796 # us-ascii, utf-8 omitted, as they are tried first and last
791 797 charsets = iso-8859-1, iso-8859-15, windows-1252
792 798
793 799
794 800 ``extensions``
795 801 --------------
796 802
797 803 Mercurial has an extension mechanism for adding new features. To
798 804 enable an extension, create an entry for it in this section.
799 805
800 806 If you know that the extension is already in Python's search path,
801 807 you can give the name of the module, followed by ``=``, with nothing
802 808 after the ``=``.
803 809
804 810 Otherwise, give a name that you choose, followed by ``=``, followed by
805 811 the path to the ``.py`` file (including the file name extension) that
806 812 defines the extension.
807 813
808 814 To explicitly disable an extension that is enabled in an hgrc of
809 815 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
810 816 or ``foo = !`` when path is not supplied.
811 817
812 818 Example for ``~/.hgrc``::
813 819
814 820 [extensions]
815 821 # (the churn extension will get loaded from Mercurial's path)
816 822 churn =
817 823 # (this extension will get loaded from the file specified)
818 824 myfeature = ~/.hgext/myfeature.py
819 825
820 826
821 827 ``format``
822 828 ----------
823 829
824 830 Configuration that controls the repository format. Newer format options are more
825 831 powerful but incompatible with some older versions of Mercurial. Format options
826 832 are considered at repository initialization only. You need to make a new clone
827 833 for config change to be taken into account.
828 834
829 835 For more details about repository format and version compatibility, see
830 836 https://www.mercurial-scm.org/wiki/MissingRequirement
831 837
832 838 ``usegeneraldelta``
833 839 Enable or disable the "generaldelta" repository format which improves
834 840 repository compression by allowing "revlog" to store delta against arbitrary
835 841 revision instead of the previous stored one. This provides significant
836 842 improvement for repositories with branches.
837 843
838 844 Repositories with this on-disk format require Mercurial version 1.9.
839 845
840 846 Enabled by default.
841 847
842 848 ``dotencode``
843 849 Enable or disable the "dotencode" repository format which enhances
844 850 the "fncache" repository format (which has to be enabled to use
845 851 dotencode) to avoid issues with filenames starting with ._ on
846 852 Mac OS X and spaces on Windows.
847 853
848 854 Repositories with this on-disk format require Mercurial version 1.7.
849 855
850 856 Enabled by default.
851 857
852 858 ``usefncache``
853 859 Enable or disable the "fncache" repository format which enhances
854 860 the "store" repository format (which has to be enabled to use
855 861 fncache) to allow longer filenames and avoids using Windows
856 862 reserved names, e.g. "nul".
857 863
858 864 Repositories with this on-disk format require Mercurial version 1.1.
859 865
860 866 Enabled by default.
861 867
862 868 ``usestore``
863 869 Enable or disable the "store" repository format which improves
864 870 compatibility with systems that fold case or otherwise mangle
865 871 filenames. Disabling this option will allow you to store longer filenames
866 872 in some situations at the expense of compatibility.
867 873
868 874 Repositories with this on-disk format require Mercurial version 0.9.4.
869 875
870 876 Enabled by default.
871 877
872 878 ``sparse-revlog``
873 879 Enable or disable the ``sparse-revlog`` delta strategy. This format improves
874 880 delta re-use inside revlog. For very branchy repositories, it results in a
875 881 smaller store. For repositories with many revisions, it also helps
876 882 performance (by using shortened delta chains.)
877 883
878 884 Repositories with this on-disk format require Mercurial version 4.7
879 885
880 886 Enabled by default.
881 887
882 888 ``revlog-compression``
883 889 Compression algorithm used by revlog. Supported value are `zlib` and `zstd`.
884 890 The `zlib` engine is the historical default of Mercurial. `zstd` is a newer
885 891 format that is usually a net win over `zlib` operating faster at better
886 892 compression rate. Use `zstd` to reduce CPU usage.
887 893
888 894 On some system, Mercurial installation may lack `zstd` supports. Default is `zlib`.
889 895
890 896 ``bookmarks-in-store``
891 897 Store bookmarks in .hg/store/. This means that bookmarks are shared when
892 898 using `hg share` regardless of the `-B` option.
893 899
894 900 Repositories with this on-disk format require Mercurial version 5.1.
895 901
896 902 Disabled by default.
897 903
898 904
899 905 ``graph``
900 906 ---------
901 907
902 908 Web graph view configuration. This section let you change graph
903 909 elements display properties by branches, for instance to make the
904 910 ``default`` branch stand out.
905 911
906 912 Each line has the following format::
907 913
908 914 <branch>.<argument> = <value>
909 915
910 916 where ``<branch>`` is the name of the branch being
911 917 customized. Example::
912 918
913 919 [graph]
914 920 # 2px width
915 921 default.width = 2
916 922 # red color
917 923 default.color = FF0000
918 924
919 925 Supported arguments:
920 926
921 927 ``width``
922 928 Set branch edges width in pixels.
923 929
924 930 ``color``
925 931 Set branch edges color in hexadecimal RGB notation.
926 932
927 933 ``hooks``
928 934 ---------
929 935
930 936 Commands or Python functions that get automatically executed by
931 937 various actions such as starting or finishing a commit. Multiple
932 938 hooks can be run for the same action by appending a suffix to the
933 939 action. Overriding a site-wide hook can be done by changing its
934 940 value or setting it to an empty string. Hooks can be prioritized
935 941 by adding a prefix of ``priority.`` to the hook name on a new line
936 942 and setting the priority. The default priority is 0.
937 943
938 944 Example ``.hg/hgrc``::
939 945
940 946 [hooks]
941 947 # update working directory after adding changesets
942 948 changegroup.update = hg update
943 949 # do not use the site-wide hook
944 950 incoming =
945 951 incoming.email = /my/email/hook
946 952 incoming.autobuild = /my/build/hook
947 953 # force autobuild hook to run before other incoming hooks
948 954 priority.incoming.autobuild = 1
949 955
950 956 Most hooks are run with environment variables set that give useful
951 957 additional information. For each hook below, the environment variables
952 958 it is passed are listed with names in the form ``$HG_foo``. The
953 959 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
954 960 They contain the type of hook which triggered the run and the full name
955 961 of the hook in the config, respectively. In the example above, this will
956 962 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
957 963
958 964 .. container:: windows
959 965
960 966 Some basic Unix syntax can be enabled for portability, including ``$VAR``
961 967 and ``${VAR}`` style variables. A ``~`` followed by ``\`` or ``/`` will
962 968 be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion
963 969 on Unix. To use a literal ``$`` or ``~``, it must be escaped with a back
964 970 slash or inside of a strong quote. Strong quotes will be replaced by
965 971 double quotes after processing.
966 972
967 973 This feature is enabled by adding a prefix of ``tonative.`` to the hook
968 974 name on a new line, and setting it to ``True``. For example::
969 975
970 976 [hooks]
971 977 incoming.autobuild = /my/build/hook
972 978 # enable translation to cmd.exe syntax for autobuild hook
973 979 tonative.incoming.autobuild = True
974 980
975 981 ``changegroup``
976 982 Run after a changegroup has been added via push, pull or unbundle. The ID of
977 983 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
978 984 The URL from which changes came is in ``$HG_URL``.
979 985
980 986 ``commit``
981 987 Run after a changeset has been created in the local repository. The ID
982 988 of the newly created changeset is in ``$HG_NODE``. Parent changeset
983 989 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
984 990
985 991 ``incoming``
986 992 Run after a changeset has been pulled, pushed, or unbundled into
987 993 the local repository. The ID of the newly arrived changeset is in
988 994 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
989 995
990 996 ``outgoing``
991 997 Run after sending changes from the local repository to another. The ID of
992 998 first changeset sent is in ``$HG_NODE``. The source of operation is in
993 999 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
994 1000
995 1001 ``post-<command>``
996 1002 Run after successful invocations of the associated command. The
997 1003 contents of the command line are passed as ``$HG_ARGS`` and the result
998 1004 code in ``$HG_RESULT``. Parsed command line arguments are passed as
999 1005 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
1000 1006 the python data internally passed to <command>. ``$HG_OPTS`` is a
1001 1007 dictionary of options (with unspecified options set to their defaults).
1002 1008 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
1003 1009
1004 1010 ``fail-<command>``
1005 1011 Run after a failed invocation of an associated command. The contents
1006 1012 of the command line are passed as ``$HG_ARGS``. Parsed command line
1007 1013 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
1008 1014 string representations of the python data internally passed to
1009 1015 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
1010 1016 options set to their defaults). ``$HG_PATS`` is a list of arguments.
1011 1017 Hook failure is ignored.
1012 1018
1013 1019 ``pre-<command>``
1014 1020 Run before executing the associated command. The contents of the
1015 1021 command line are passed as ``$HG_ARGS``. Parsed command line arguments
1016 1022 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
1017 1023 representations of the data internally passed to <command>. ``$HG_OPTS``
1018 1024 is a dictionary of options (with unspecified options set to their
1019 1025 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
1020 1026 failure, the command doesn't execute and Mercurial returns the failure
1021 1027 code.
1022 1028
1023 1029 ``prechangegroup``
1024 1030 Run before a changegroup is added via push, pull or unbundle. Exit
1025 1031 status 0 allows the changegroup to proceed. A non-zero status will
1026 1032 cause the push, pull or unbundle to fail. The URL from which changes
1027 1033 will come is in ``$HG_URL``.
1028 1034
1029 1035 ``precommit``
1030 1036 Run before starting a local commit. Exit status 0 allows the
1031 1037 commit to proceed. A non-zero status will cause the commit to fail.
1032 1038 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1033 1039
1034 1040 ``prelistkeys``
1035 1041 Run before listing pushkeys (like bookmarks) in the
1036 1042 repository. A non-zero status will cause failure. The key namespace is
1037 1043 in ``$HG_NAMESPACE``.
1038 1044
1039 1045 ``preoutgoing``
1040 1046 Run before collecting changes to send from the local repository to
1041 1047 another. A non-zero status will cause failure. This lets you prevent
1042 1048 pull over HTTP or SSH. It can also prevent propagating commits (via
1043 1049 local pull, push (outbound) or bundle commands), but not completely,
1044 1050 since you can just copy files instead. The source of operation is in
1045 1051 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
1046 1052 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
1047 1053 is happening on behalf of a repository on same system.
1048 1054
1049 1055 ``prepushkey``
1050 1056 Run before a pushkey (like a bookmark) is added to the
1051 1057 repository. A non-zero status will cause the key to be rejected. The
1052 1058 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
1053 1059 the old value (if any) is in ``$HG_OLD``, and the new value is in
1054 1060 ``$HG_NEW``.
1055 1061
1056 1062 ``pretag``
1057 1063 Run before creating a tag. Exit status 0 allows the tag to be
1058 1064 created. A non-zero status will cause the tag to fail. The ID of the
1059 1065 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
1060 1066 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
1061 1067
1062 1068 ``pretxnopen``
1063 1069 Run before any new repository transaction is open. The reason for the
1064 1070 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
1065 1071 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
1066 1072 transaction from being opened.
1067 1073
1068 1074 ``pretxnclose``
1069 1075 Run right before the transaction is actually finalized. Any repository change
1070 1076 will be visible to the hook program. This lets you validate the transaction
1071 1077 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1072 1078 status will cause the transaction to be rolled back. The reason for the
1073 1079 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
1074 1080 the transaction will be in ``HG_TXNID``. The rest of the available data will
1075 1081 vary according the transaction type. New changesets will add ``$HG_NODE``
1076 1082 (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
1077 1083 added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables. Bookmark and
1078 1084 phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
1079 1085 respectively, etc.
1080 1086
1081 1087 ``pretxnclose-bookmark``
1082 1088 Run right before a bookmark change is actually finalized. Any repository
1083 1089 change will be visible to the hook program. This lets you validate the
1084 1090 transaction content or change it. Exit status 0 allows the commit to
1085 1091 proceed. A non-zero status will cause the transaction to be rolled back.
1086 1092 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
1087 1093 bookmark location will be available in ``$HG_NODE`` while the previous
1088 1094 location will be available in ``$HG_OLDNODE``. In case of a bookmark
1089 1095 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1090 1096 will be empty.
1091 1097 In addition, the reason for the transaction opening will be in
1092 1098 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1093 1099 ``HG_TXNID``.
1094 1100
1095 1101 ``pretxnclose-phase``
1096 1102 Run right before a phase change is actually finalized. Any repository change
1097 1103 will be visible to the hook program. This lets you validate the transaction
1098 1104 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1099 1105 status will cause the transaction to be rolled back. The hook is called
1100 1106 multiple times, once for each revision affected by a phase change.
1101 1107 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1102 1108 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1103 1109 will be empty. In addition, the reason for the transaction opening will be in
1104 1110 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1105 1111 ``HG_TXNID``. The hook is also run for newly added revisions. In this case
1106 1112 the ``$HG_OLDPHASE`` entry will be empty.
1107 1113
1108 1114 ``txnclose``
1109 1115 Run after any repository transaction has been committed. At this
1110 1116 point, the transaction can no longer be rolled back. The hook will run
1111 1117 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1112 1118 details about available variables.
1113 1119
1114 1120 ``txnclose-bookmark``
1115 1121 Run after any bookmark change has been committed. At this point, the
1116 1122 transaction can no longer be rolled back. The hook will run after the lock
1117 1123 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1118 1124 about available variables.
1119 1125
1120 1126 ``txnclose-phase``
1121 1127 Run after any phase change has been committed. At this point, the
1122 1128 transaction can no longer be rolled back. The hook will run after the lock
1123 1129 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1124 1130 available variables.
1125 1131
1126 1132 ``txnabort``
1127 1133 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1128 1134 for details about available variables.
1129 1135
1130 1136 ``pretxnchangegroup``
1131 1137 Run after a changegroup has been added via push, pull or unbundle, but before
1132 1138 the transaction has been committed. The changegroup is visible to the hook
1133 1139 program. This allows validation of incoming changes before accepting them.
1134 1140 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1135 1141 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1136 1142 status will cause the transaction to be rolled back, and the push, pull or
1137 1143 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1138 1144
1139 1145 ``pretxncommit``
1140 1146 Run after a changeset has been created, but before the transaction is
1141 1147 committed. The changeset is visible to the hook program. This allows
1142 1148 validation of the commit message and changes. Exit status 0 allows the
1143 1149 commit to proceed. A non-zero status will cause the transaction to
1144 1150 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1145 1151 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1146 1152
1147 1153 ``preupdate``
1148 1154 Run before updating the working directory. Exit status 0 allows
1149 1155 the update to proceed. A non-zero status will prevent the update.
1150 1156 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1151 1157 merge, the ID of second new parent is in ``$HG_PARENT2``.
1152 1158
1153 1159 ``listkeys``
1154 1160 Run after listing pushkeys (like bookmarks) in the repository. The
1155 1161 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1156 1162 dictionary containing the keys and values.
1157 1163
1158 1164 ``pushkey``
1159 1165 Run after a pushkey (like a bookmark) is added to the
1160 1166 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1161 1167 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1162 1168 value is in ``$HG_NEW``.
1163 1169
1164 1170 ``tag``
1165 1171 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1166 1172 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1167 1173 the repository if ``$HG_LOCAL=0``.
1168 1174
1169 1175 ``update``
1170 1176 Run after updating the working directory. The changeset ID of first
1171 1177 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1172 1178 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1173 1179 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1174 1180
1175 1181 .. note::
1176 1182
1177 1183 It is generally better to use standard hooks rather than the
1178 1184 generic pre- and post- command hooks, as they are guaranteed to be
1179 1185 called in the appropriate contexts for influencing transactions.
1180 1186 Also, hooks like "commit" will be called in all contexts that
1181 1187 generate a commit (e.g. tag) and not just the commit command.
1182 1188
1183 1189 .. note::
1184 1190
1185 1191 Environment variables with empty values may not be passed to
1186 1192 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1187 1193 will have an empty value under Unix-like platforms for non-merge
1188 1194 changesets, while it will not be available at all under Windows.
1189 1195
1190 1196 The syntax for Python hooks is as follows::
1191 1197
1192 1198 hookname = python:modulename.submodule.callable
1193 1199 hookname = python:/path/to/python/module.py:callable
1194 1200
1195 1201 Python hooks are run within the Mercurial process. Each hook is
1196 1202 called with at least three keyword arguments: a ui object (keyword
1197 1203 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1198 1204 keyword that tells what kind of hook is used. Arguments listed as
1199 1205 environment variables above are passed as keyword arguments, with no
1200 1206 ``HG_`` prefix, and names in lower case.
1201 1207
1202 1208 If a Python hook returns a "true" value or raises an exception, this
1203 1209 is treated as a failure.
1204 1210
1205 1211
1206 1212 ``hostfingerprints``
1207 1213 --------------------
1208 1214
1209 1215 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1210 1216
1211 1217 Fingerprints of the certificates of known HTTPS servers.
1212 1218
1213 1219 A HTTPS connection to a server with a fingerprint configured here will
1214 1220 only succeed if the servers certificate matches the fingerprint.
1215 1221 This is very similar to how ssh known hosts works.
1216 1222
1217 1223 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1218 1224 Multiple values can be specified (separated by spaces or commas). This can
1219 1225 be used to define both old and new fingerprints while a host transitions
1220 1226 to a new certificate.
1221 1227
1222 1228 The CA chain and web.cacerts is not used for servers with a fingerprint.
1223 1229
1224 1230 For example::
1225 1231
1226 1232 [hostfingerprints]
1227 1233 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1228 1234 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1229 1235
1230 1236 ``hostsecurity``
1231 1237 ----------------
1232 1238
1233 1239 Used to specify global and per-host security settings for connecting to
1234 1240 other machines.
1235 1241
1236 1242 The following options control default behavior for all hosts.
1237 1243
1238 1244 ``ciphers``
1239 1245 Defines the cryptographic ciphers to use for connections.
1240 1246
1241 1247 Value must be a valid OpenSSL Cipher List Format as documented at
1242 1248 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1243 1249
1244 1250 This setting is for advanced users only. Setting to incorrect values
1245 1251 can significantly lower connection security or decrease performance.
1246 1252 You have been warned.
1247 1253
1248 1254 This option requires Python 2.7.
1249 1255
1250 1256 ``minimumprotocol``
1251 1257 Defines the minimum channel encryption protocol to use.
1252 1258
1253 1259 By default, the highest version of TLS supported by both client and server
1254 1260 is used.
1255 1261
1256 1262 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1257 1263
1258 1264 When running on an old Python version, only ``tls1.0`` is allowed since
1259 1265 old versions of Python only support up to TLS 1.0.
1260 1266
1261 1267 When running a Python that supports modern TLS versions, the default is
1262 1268 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1263 1269 weakens security and should only be used as a feature of last resort if
1264 1270 a server does not support TLS 1.1+.
1265 1271
1266 1272 Options in the ``[hostsecurity]`` section can have the form
1267 1273 ``hostname``:``setting``. This allows multiple settings to be defined on a
1268 1274 per-host basis.
1269 1275
1270 1276 The following per-host settings can be defined.
1271 1277
1272 1278 ``ciphers``
1273 1279 This behaves like ``ciphers`` as described above except it only applies
1274 1280 to the host on which it is defined.
1275 1281
1276 1282 ``fingerprints``
1277 1283 A list of hashes of the DER encoded peer/remote certificate. Values have
1278 1284 the form ``algorithm``:``fingerprint``. e.g.
1279 1285 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1280 1286 In addition, colons (``:``) can appear in the fingerprint part.
1281 1287
1282 1288 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1283 1289 ``sha512``.
1284 1290
1285 1291 Use of ``sha256`` or ``sha512`` is preferred.
1286 1292
1287 1293 If a fingerprint is specified, the CA chain is not validated for this
1288 1294 host and Mercurial will require the remote certificate to match one
1289 1295 of the fingerprints specified. This means if the server updates its
1290 1296 certificate, Mercurial will abort until a new fingerprint is defined.
1291 1297 This can provide stronger security than traditional CA-based validation
1292 1298 at the expense of convenience.
1293 1299
1294 1300 This option takes precedence over ``verifycertsfile``.
1295 1301
1296 1302 ``minimumprotocol``
1297 1303 This behaves like ``minimumprotocol`` as described above except it
1298 1304 only applies to the host on which it is defined.
1299 1305
1300 1306 ``verifycertsfile``
1301 1307 Path to file a containing a list of PEM encoded certificates used to
1302 1308 verify the server certificate. Environment variables and ``~user``
1303 1309 constructs are expanded in the filename.
1304 1310
1305 1311 The server certificate or the certificate's certificate authority (CA)
1306 1312 must match a certificate from this file or certificate verification
1307 1313 will fail and connections to the server will be refused.
1308 1314
1309 1315 If defined, only certificates provided by this file will be used:
1310 1316 ``web.cacerts`` and any system/default certificates will not be
1311 1317 used.
1312 1318
1313 1319 This option has no effect if the per-host ``fingerprints`` option
1314 1320 is set.
1315 1321
1316 1322 The format of the file is as follows::
1317 1323
1318 1324 -----BEGIN CERTIFICATE-----
1319 1325 ... (certificate in base64 PEM encoding) ...
1320 1326 -----END CERTIFICATE-----
1321 1327 -----BEGIN CERTIFICATE-----
1322 1328 ... (certificate in base64 PEM encoding) ...
1323 1329 -----END CERTIFICATE-----
1324 1330
1325 1331 For example::
1326 1332
1327 1333 [hostsecurity]
1328 1334 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1329 1335 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
1330 1336 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
1331 1337 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1332 1338
1333 1339 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1334 1340 when connecting to ``hg.example.com``::
1335 1341
1336 1342 [hostsecurity]
1337 1343 minimumprotocol = tls1.2
1338 1344 hg.example.com:minimumprotocol = tls1.1
1339 1345
1340 1346 ``http_proxy``
1341 1347 --------------
1342 1348
1343 1349 Used to access web-based Mercurial repositories through a HTTP
1344 1350 proxy.
1345 1351
1346 1352 ``host``
1347 1353 Host name and (optional) port of the proxy server, for example
1348 1354 "myproxy:8000".
1349 1355
1350 1356 ``no``
1351 1357 Optional. Comma-separated list of host names that should bypass
1352 1358 the proxy.
1353 1359
1354 1360 ``passwd``
1355 1361 Optional. Password to authenticate with at the proxy server.
1356 1362
1357 1363 ``user``
1358 1364 Optional. User name to authenticate with at the proxy server.
1359 1365
1360 1366 ``always``
1361 1367 Optional. Always use the proxy, even for localhost and any entries
1362 1368 in ``http_proxy.no``. (default: False)
1363 1369
1364 1370 ``http``
1365 1371 ----------
1366 1372
1367 1373 Used to configure access to Mercurial repositories via HTTP.
1368 1374
1369 1375 ``timeout``
1370 1376 If set, blocking operations will timeout after that many seconds.
1371 1377 (default: None)
1372 1378
1373 1379 ``merge``
1374 1380 ---------
1375 1381
1376 1382 This section specifies behavior during merges and updates.
1377 1383
1378 1384 ``checkignored``
1379 1385 Controls behavior when an ignored file on disk has the same name as a tracked
1380 1386 file in the changeset being merged or updated to, and has different
1381 1387 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1382 1388 abort on such files. With ``warn``, warn on such files and back them up as
1383 1389 ``.orig``. With ``ignore``, don't print a warning and back them up as
1384 1390 ``.orig``. (default: ``abort``)
1385 1391
1386 1392 ``checkunknown``
1387 1393 Controls behavior when an unknown file that isn't ignored has the same name
1388 1394 as a tracked file in the changeset being merged or updated to, and has
1389 1395 different contents. Similar to ``merge.checkignored``, except for files that
1390 1396 are not ignored. (default: ``abort``)
1391 1397
1392 1398 ``on-failure``
1393 1399 When set to ``continue`` (the default), the merge process attempts to
1394 1400 merge all unresolved files using the merge chosen tool, regardless of
1395 1401 whether previous file merge attempts during the process succeeded or not.
1396 1402 Setting this to ``prompt`` will prompt after any merge failure continue
1397 1403 or halt the merge process. Setting this to ``halt`` will automatically
1398 1404 halt the merge process on any merge tool failure. The merge process
1399 1405 can be restarted by using the ``resolve`` command. When a merge is
1400 1406 halted, the repository is left in a normal ``unresolved`` merge state.
1401 1407 (default: ``continue``)
1402 1408
1403 1409 ``strict-capability-check``
1404 1410 Whether capabilities of internal merge tools are checked strictly
1405 1411 or not, while examining rules to decide merge tool to be used.
1406 1412 (default: False)
1407 1413
1408 1414 ``merge-patterns``
1409 1415 ------------------
1410 1416
1411 1417 This section specifies merge tools to associate with particular file
1412 1418 patterns. Tools matched here will take precedence over the default
1413 1419 merge tool. Patterns are globs by default, rooted at the repository
1414 1420 root.
1415 1421
1416 1422 Example::
1417 1423
1418 1424 [merge-patterns]
1419 1425 **.c = kdiff3
1420 1426 **.jpg = myimgmerge
1421 1427
1422 1428 ``merge-tools``
1423 1429 ---------------
1424 1430
1425 1431 This section configures external merge tools to use for file-level
1426 1432 merges. This section has likely been preconfigured at install time.
1427 1433 Use :hg:`config merge-tools` to check the existing configuration.
1428 1434 Also see :hg:`help merge-tools` for more details.
1429 1435
1430 1436 Example ``~/.hgrc``::
1431 1437
1432 1438 [merge-tools]
1433 1439 # Override stock tool location
1434 1440 kdiff3.executable = ~/bin/kdiff3
1435 1441 # Specify command line
1436 1442 kdiff3.args = $base $local $other -o $output
1437 1443 # Give higher priority
1438 1444 kdiff3.priority = 1
1439 1445
1440 1446 # Changing the priority of preconfigured tool
1441 1447 meld.priority = 0
1442 1448
1443 1449 # Disable a preconfigured tool
1444 1450 vimdiff.disabled = yes
1445 1451
1446 1452 # Define new tool
1447 1453 myHtmlTool.args = -m $local $other $base $output
1448 1454 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1449 1455 myHtmlTool.priority = 1
1450 1456
1451 1457 Supported arguments:
1452 1458
1453 1459 ``priority``
1454 1460 The priority in which to evaluate this tool.
1455 1461 (default: 0)
1456 1462
1457 1463 ``executable``
1458 1464 Either just the name of the executable or its pathname.
1459 1465
1460 1466 .. container:: windows
1461 1467
1462 1468 On Windows, the path can use environment variables with ${ProgramFiles}
1463 1469 syntax.
1464 1470
1465 1471 (default: the tool name)
1466 1472
1467 1473 ``args``
1468 1474 The arguments to pass to the tool executable. You can refer to the
1469 1475 files being merged as well as the output file through these
1470 1476 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1471 1477
1472 1478 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1473 1479 being performed. During an update or merge, ``$local`` represents the original
1474 1480 state of the file, while ``$other`` represents the commit you are updating to or
1475 1481 the commit you are merging with. During a rebase, ``$local`` represents the
1476 1482 destination of the rebase, and ``$other`` represents the commit being rebased.
1477 1483
1478 1484 Some operations define custom labels to assist with identifying the revisions,
1479 1485 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1480 1486 labels are not available, these will be ``local``, ``other``, and ``base``,
1481 1487 respectively.
1482 1488 (default: ``$local $base $other``)
1483 1489
1484 1490 ``premerge``
1485 1491 Attempt to run internal non-interactive 3-way merge tool before
1486 1492 launching external tool. Options are ``true``, ``false``, ``keep`` or
1487 1493 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1488 1494 premerge fails. The ``keep-merge3`` will do the same but include information
1489 1495 about the base of the merge in the marker (see internal :merge3 in
1490 1496 :hg:`help merge-tools`).
1491 1497 (default: True)
1492 1498
1493 1499 ``binary``
1494 1500 This tool can merge binary files. (default: False, unless tool
1495 1501 was selected by file pattern match)
1496 1502
1497 1503 ``symlink``
1498 1504 This tool can merge symlinks. (default: False)
1499 1505
1500 1506 ``check``
1501 1507 A list of merge success-checking options:
1502 1508
1503 1509 ``changed``
1504 1510 Ask whether merge was successful when the merged file shows no changes.
1505 1511 ``conflicts``
1506 1512 Check whether there are conflicts even though the tool reported success.
1507 1513 ``prompt``
1508 1514 Always prompt for merge success, regardless of success reported by tool.
1509 1515
1510 1516 ``fixeol``
1511 1517 Attempt to fix up EOL changes caused by the merge tool.
1512 1518 (default: False)
1513 1519
1514 1520 ``gui``
1515 1521 This tool requires a graphical interface to run. (default: False)
1516 1522
1517 1523 ``mergemarkers``
1518 1524 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1519 1525 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1520 1526 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1521 1527 markers generated during premerge will be ``detailed`` if either this option or
1522 1528 the corresponding option in the ``[ui]`` section is ``detailed``.
1523 1529 (default: ``basic``)
1524 1530
1525 1531 ``mergemarkertemplate``
1526 1532 This setting can be used to override ``mergemarkertemplate`` from the ``[ui]``
1527 1533 section on a per-tool basis; this applies to the ``$label``-prefixed variables
1528 1534 and to the conflict markers that are generated if ``premerge`` is ``keep` or
1529 1535 ``keep-merge3``. See the corresponding variable in ``[ui]`` for more
1530 1536 information.
1531 1537
1532 1538 .. container:: windows
1533 1539
1534 1540 ``regkey``
1535 1541 Windows registry key which describes install location of this
1536 1542 tool. Mercurial will search for this key first under
1537 1543 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1538 1544 (default: None)
1539 1545
1540 1546 ``regkeyalt``
1541 1547 An alternate Windows registry key to try if the first key is not
1542 1548 found. The alternate key uses the same ``regname`` and ``regappend``
1543 1549 semantics of the primary key. The most common use for this key
1544 1550 is to search for 32bit applications on 64bit operating systems.
1545 1551 (default: None)
1546 1552
1547 1553 ``regname``
1548 1554 Name of value to read from specified registry key.
1549 1555 (default: the unnamed (default) value)
1550 1556
1551 1557 ``regappend``
1552 1558 String to append to the value read from the registry, typically
1553 1559 the executable name of the tool.
1554 1560 (default: None)
1555 1561
1556 1562 ``pager``
1557 1563 ---------
1558 1564
1559 1565 Setting used to control when to paginate and with what external tool. See
1560 1566 :hg:`help pager` for details.
1561 1567
1562 1568 ``pager``
1563 1569 Define the external tool used as pager.
1564 1570
1565 1571 If no pager is set, Mercurial uses the environment variable $PAGER.
1566 1572 If neither pager.pager, nor $PAGER is set, a default pager will be
1567 1573 used, typically `less` on Unix and `more` on Windows. Example::
1568 1574
1569 1575 [pager]
1570 1576 pager = less -FRX
1571 1577
1572 1578 ``ignore``
1573 1579 List of commands to disable the pager for. Example::
1574 1580
1575 1581 [pager]
1576 1582 ignore = version, help, update
1577 1583
1578 1584 ``patch``
1579 1585 ---------
1580 1586
1581 1587 Settings used when applying patches, for instance through the 'import'
1582 1588 command or with Mercurial Queues extension.
1583 1589
1584 1590 ``eol``
1585 1591 When set to 'strict' patch content and patched files end of lines
1586 1592 are preserved. When set to ``lf`` or ``crlf``, both files end of
1587 1593 lines are ignored when patching and the result line endings are
1588 1594 normalized to either LF (Unix) or CRLF (Windows). When set to
1589 1595 ``auto``, end of lines are again ignored while patching but line
1590 1596 endings in patched files are normalized to their original setting
1591 1597 on a per-file basis. If target file does not exist or has no end
1592 1598 of line, patch line endings are preserved.
1593 1599 (default: strict)
1594 1600
1595 1601 ``fuzz``
1596 1602 The number of lines of 'fuzz' to allow when applying patches. This
1597 1603 controls how much context the patcher is allowed to ignore when
1598 1604 trying to apply a patch.
1599 1605 (default: 2)
1600 1606
1601 1607 ``paths``
1602 1608 ---------
1603 1609
1604 1610 Assigns symbolic names and behavior to repositories.
1605 1611
1606 1612 Options are symbolic names defining the URL or directory that is the
1607 1613 location of the repository. Example::
1608 1614
1609 1615 [paths]
1610 1616 my_server = https://example.com/my_repo
1611 1617 local_path = /home/me/repo
1612 1618
1613 1619 These symbolic names can be used from the command line. To pull
1614 1620 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1615 1621 :hg:`push local_path`.
1616 1622
1617 1623 Options containing colons (``:``) denote sub-options that can influence
1618 1624 behavior for that specific path. Example::
1619 1625
1620 1626 [paths]
1621 1627 my_server = https://example.com/my_path
1622 1628 my_server:pushurl = ssh://example.com/my_path
1623 1629
1624 1630 The following sub-options can be defined:
1625 1631
1626 1632 ``pushurl``
1627 1633 The URL to use for push operations. If not defined, the location
1628 1634 defined by the path's main entry is used.
1629 1635
1630 1636 ``pushrev``
1631 1637 A revset defining which revisions to push by default.
1632 1638
1633 1639 When :hg:`push` is executed without a ``-r`` argument, the revset
1634 1640 defined by this sub-option is evaluated to determine what to push.
1635 1641
1636 1642 For example, a value of ``.`` will push the working directory's
1637 1643 revision by default.
1638 1644
1639 1645 Revsets specifying bookmarks will not result in the bookmark being
1640 1646 pushed.
1641 1647
1642 1648 The following special named paths exist:
1643 1649
1644 1650 ``default``
1645 1651 The URL or directory to use when no source or remote is specified.
1646 1652
1647 1653 :hg:`clone` will automatically define this path to the location the
1648 1654 repository was cloned from.
1649 1655
1650 1656 ``default-push``
1651 1657 (deprecated) The URL or directory for the default :hg:`push` location.
1652 1658 ``default:pushurl`` should be used instead.
1653 1659
1654 1660 ``phases``
1655 1661 ----------
1656 1662
1657 1663 Specifies default handling of phases. See :hg:`help phases` for more
1658 1664 information about working with phases.
1659 1665
1660 1666 ``publish``
1661 1667 Controls draft phase behavior when working as a server. When true,
1662 1668 pushed changesets are set to public in both client and server and
1663 1669 pulled or cloned changesets are set to public in the client.
1664 1670 (default: True)
1665 1671
1666 1672 ``new-commit``
1667 1673 Phase of newly-created commits.
1668 1674 (default: draft)
1669 1675
1670 1676 ``checksubrepos``
1671 1677 Check the phase of the current revision of each subrepository. Allowed
1672 1678 values are "ignore", "follow" and "abort". For settings other than
1673 1679 "ignore", the phase of the current revision of each subrepository is
1674 1680 checked before committing the parent repository. If any of those phases is
1675 1681 greater than the phase of the parent repository (e.g. if a subrepo is in a
1676 1682 "secret" phase while the parent repo is in "draft" phase), the commit is
1677 1683 either aborted (if checksubrepos is set to "abort") or the higher phase is
1678 1684 used for the parent repository commit (if set to "follow").
1679 1685 (default: follow)
1680 1686
1681 1687
1682 1688 ``profiling``
1683 1689 -------------
1684 1690
1685 1691 Specifies profiling type, format, and file output. Two profilers are
1686 1692 supported: an instrumenting profiler (named ``ls``), and a sampling
1687 1693 profiler (named ``stat``).
1688 1694
1689 1695 In this section description, 'profiling data' stands for the raw data
1690 1696 collected during profiling, while 'profiling report' stands for a
1691 1697 statistical text report generated from the profiling data.
1692 1698
1693 1699 ``enabled``
1694 1700 Enable the profiler.
1695 1701 (default: false)
1696 1702
1697 1703 This is equivalent to passing ``--profile`` on the command line.
1698 1704
1699 1705 ``type``
1700 1706 The type of profiler to use.
1701 1707 (default: stat)
1702 1708
1703 1709 ``ls``
1704 1710 Use Python's built-in instrumenting profiler. This profiler
1705 1711 works on all platforms, but each line number it reports is the
1706 1712 first line of a function. This restriction makes it difficult to
1707 1713 identify the expensive parts of a non-trivial function.
1708 1714 ``stat``
1709 1715 Use a statistical profiler, statprof. This profiler is most
1710 1716 useful for profiling commands that run for longer than about 0.1
1711 1717 seconds.
1712 1718
1713 1719 ``format``
1714 1720 Profiling format. Specific to the ``ls`` instrumenting profiler.
1715 1721 (default: text)
1716 1722
1717 1723 ``text``
1718 1724 Generate a profiling report. When saving to a file, it should be
1719 1725 noted that only the report is saved, and the profiling data is
1720 1726 not kept.
1721 1727 ``kcachegrind``
1722 1728 Format profiling data for kcachegrind use: when saving to a
1723 1729 file, the generated file can directly be loaded into
1724 1730 kcachegrind.
1725 1731
1726 1732 ``statformat``
1727 1733 Profiling format for the ``stat`` profiler.
1728 1734 (default: hotpath)
1729 1735
1730 1736 ``hotpath``
1731 1737 Show a tree-based display containing the hot path of execution (where
1732 1738 most time was spent).
1733 1739 ``bymethod``
1734 1740 Show a table of methods ordered by how frequently they are active.
1735 1741 ``byline``
1736 1742 Show a table of lines in files ordered by how frequently they are active.
1737 1743 ``json``
1738 1744 Render profiling data as JSON.
1739 1745
1740 1746 ``frequency``
1741 1747 Sampling frequency. Specific to the ``stat`` sampling profiler.
1742 1748 (default: 1000)
1743 1749
1744 1750 ``output``
1745 1751 File path where profiling data or report should be saved. If the
1746 1752 file exists, it is replaced. (default: None, data is printed on
1747 1753 stderr)
1748 1754
1749 1755 ``sort``
1750 1756 Sort field. Specific to the ``ls`` instrumenting profiler.
1751 1757 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1752 1758 ``inlinetime``.
1753 1759 (default: inlinetime)
1754 1760
1755 1761 ``time-track``
1756 1762 Control if the stat profiler track ``cpu`` or ``real`` time.
1757 1763 (default: ``cpu`` on Windows, otherwise ``real``)
1758 1764
1759 1765 ``limit``
1760 1766 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1761 1767 (default: 30)
1762 1768
1763 1769 ``nested``
1764 1770 Show at most this number of lines of drill-down info after each main entry.
1765 1771 This can help explain the difference between Total and Inline.
1766 1772 Specific to the ``ls`` instrumenting profiler.
1767 1773 (default: 0)
1768 1774
1769 1775 ``showmin``
1770 1776 Minimum fraction of samples an entry must have for it to be displayed.
1771 1777 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1772 1778 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1773 1779
1774 1780 Only used by the ``stat`` profiler.
1775 1781
1776 1782 For the ``hotpath`` format, default is ``0.05``.
1777 1783 For the ``chrome`` format, default is ``0.005``.
1778 1784
1779 1785 The option is unused on other formats.
1780 1786
1781 1787 ``showmax``
1782 1788 Maximum fraction of samples an entry can have before it is ignored in
1783 1789 display. Values format is the same as ``showmin``.
1784 1790
1785 1791 Only used by the ``stat`` profiler.
1786 1792
1787 1793 For the ``chrome`` format, default is ``0.999``.
1788 1794
1789 1795 The option is unused on other formats.
1790 1796
1791 1797 ``showtime``
1792 1798 Show time taken as absolute durations, in addition to percentages.
1793 1799 Only used by the ``hotpath`` format.
1794 1800 (default: true)
1795 1801
1796 1802 ``progress``
1797 1803 ------------
1798 1804
1799 1805 Mercurial commands can draw progress bars that are as informative as
1800 1806 possible. Some progress bars only offer indeterminate information, while others
1801 1807 have a definite end point.
1802 1808
1803 1809 ``debug``
1804 1810 Whether to print debug info when updating the progress bar. (default: False)
1805 1811
1806 1812 ``delay``
1807 1813 Number of seconds (float) before showing the progress bar. (default: 3)
1808 1814
1809 1815 ``changedelay``
1810 1816 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1811 1817 that value will be used instead. (default: 1)
1812 1818
1813 1819 ``estimateinterval``
1814 1820 Maximum sampling interval in seconds for speed and estimated time
1815 1821 calculation. (default: 60)
1816 1822
1817 1823 ``refresh``
1818 1824 Time in seconds between refreshes of the progress bar. (default: 0.1)
1819 1825
1820 1826 ``format``
1821 1827 Format of the progress bar.
1822 1828
1823 1829 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1824 1830 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1825 1831 last 20 characters of the item, but this can be changed by adding either
1826 1832 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1827 1833 first num characters.
1828 1834
1829 1835 (default: topic bar number estimate)
1830 1836
1831 1837 ``width``
1832 1838 If set, the maximum width of the progress information (that is, min(width,
1833 1839 term width) will be used).
1834 1840
1835 1841 ``clear-complete``
1836 1842 Clear the progress bar after it's done. (default: True)
1837 1843
1838 1844 ``disable``
1839 1845 If true, don't show a progress bar.
1840 1846
1841 1847 ``assume-tty``
1842 1848 If true, ALWAYS show a progress bar, unless disable is given.
1843 1849
1844 1850 ``rebase``
1845 1851 ----------
1846 1852
1847 1853 ``evolution.allowdivergence``
1848 1854 Default to False, when True allow creating divergence when performing
1849 1855 rebase of obsolete changesets.
1850 1856
1851 1857 ``revsetalias``
1852 1858 ---------------
1853 1859
1854 1860 Alias definitions for revsets. See :hg:`help revsets` for details.
1855 1861
1856 1862 ``rewrite``
1857 1863 -----------
1858 1864
1859 1865 ``backup-bundle``
1860 1866 Whether to save stripped changesets to a bundle file. (default: True)
1861 1867
1862 1868 ``update-timestamp``
1863 1869 If true, updates the date and time of the changeset to current. It is only
1864 1870 applicable for `hg amend`, `hg commit --amend` and `hg uncommit` in the
1865 1871 current version.
1866 1872
1867 1873 ``storage``
1868 1874 -----------
1869 1875
1870 1876 Control the strategy Mercurial uses internally to store history. Options in this
1871 1877 category impact performance and repository size.
1872 1878
1873 1879 ``revlog.optimize-delta-parent-choice``
1874 1880 When storing a merge revision, both parents will be equally considered as
1875 1881 a possible delta base. This results in better delta selection and improved
1876 1882 revlog compression. This option is enabled by default.
1877 1883
1878 1884 Turning this option off can result in large increase of repository size for
1879 1885 repository with many merges.
1880 1886
1881 1887 ``revlog.reuse-external-delta-parent``
1882 1888 Control the order in which delta parents are considered when adding new
1883 1889 revisions from an external source.
1884 1890 (typically: apply bundle from `hg pull` or `hg push`).
1885 1891
1886 1892 New revisions are usually provided as a delta against other revisions. By
1887 1893 default, Mercurial will try to reuse this delta first, therefore using the
1888 1894 same "delta parent" as the source. Directly using delta's from the source
1889 1895 reduces CPU usage and usually speeds up operation. However, in some case,
1890 1896 the source might have sub-optimal delta bases and forcing their reevaluation
1891 1897 is useful. For example, pushes from an old client could have sub-optimal
1892 1898 delta's parent that the server want to optimize. (lack of general delta, bad
1893 1899 parents, choice, lack of sparse-revlog, etc).
1894 1900
1895 1901 This option is enabled by default. Turning it off will ensure bad delta
1896 1902 parent choices from older client do not propagate to this repository, at
1897 1903 the cost of a small increase in CPU consumption.
1898 1904
1899 1905 Note: this option only control the order in which delta parents are
1900 1906 considered. Even when disabled, the existing delta from the source will be
1901 1907 reused if the same delta parent is selected.
1902 1908
1903 1909 ``revlog.reuse-external-delta``
1904 1910 Control the reuse of delta from external source.
1905 1911 (typically: apply bundle from `hg pull` or `hg push`).
1906 1912
1907 1913 New revisions are usually provided as a delta against another revision. By
1908 1914 default, Mercurial will not recompute the same delta again, trusting
1909 1915 externally provided deltas. There have been rare cases of small adjustment
1910 1916 to the diffing algorithm in the past. So in some rare case, recomputing
1911 1917 delta provided by ancient clients can provides better results. Disabling
1912 1918 this option means going through a full delta recomputation for all incoming
1913 1919 revisions. It means a large increase in CPU usage and will slow operations
1914 1920 down.
1915 1921
1916 1922 This option is enabled by default. When disabled, it also disables the
1917 1923 related ``storage.revlog.reuse-external-delta-parent`` option.
1918 1924
1919 1925 ``revlog.zlib.level``
1920 1926 Zlib compression level used when storing data into the repository. Accepted
1921 1927 Value range from 1 (lowest compression) to 9 (highest compression). Zlib
1922 1928 default value is 6.
1923 1929
1924 1930
1925 1931 ``revlog.zstd.level``
1926 1932 zstd compression level used when storing data into the repository. Accepted
1927 1933 Value range from 1 (lowest compression) to 22 (highest compression).
1928 1934 (default 3)
1929 1935
1930 1936 ``server``
1931 1937 ----------
1932 1938
1933 1939 Controls generic server settings.
1934 1940
1935 1941 ``bookmarks-pushkey-compat``
1936 1942 Trigger pushkey hook when being pushed bookmark updates. This config exist
1937 1943 for compatibility purpose (default to True)
1938 1944
1939 1945 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
1940 1946 movement we recommend you migrate them to ``txnclose-bookmark`` and
1941 1947 ``pretxnclose-bookmark``.
1942 1948
1943 1949 ``compressionengines``
1944 1950 List of compression engines and their relative priority to advertise
1945 1951 to clients.
1946 1952
1947 1953 The order of compression engines determines their priority, the first
1948 1954 having the highest priority. If a compression engine is not listed
1949 1955 here, it won't be advertised to clients.
1950 1956
1951 1957 If not set (the default), built-in defaults are used. Run
1952 1958 :hg:`debuginstall` to list available compression engines and their
1953 1959 default wire protocol priority.
1954 1960
1955 1961 Older Mercurial clients only support zlib compression and this setting
1956 1962 has no effect for legacy clients.
1957 1963
1958 1964 ``uncompressed``
1959 1965 Whether to allow clients to clone a repository using the
1960 1966 uncompressed streaming protocol. This transfers about 40% more
1961 1967 data than a regular clone, but uses less memory and CPU on both
1962 1968 server and client. Over a LAN (100 Mbps or better) or a very fast
1963 1969 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1964 1970 regular clone. Over most WAN connections (anything slower than
1965 1971 about 6 Mbps), uncompressed streaming is slower, because of the
1966 1972 extra data transfer overhead. This mode will also temporarily hold
1967 1973 the write lock while determining what data to transfer.
1968 1974 (default: True)
1969 1975
1970 1976 ``uncompressedallowsecret``
1971 1977 Whether to allow stream clones when the repository contains secret
1972 1978 changesets. (default: False)
1973 1979
1974 1980 ``preferuncompressed``
1975 1981 When set, clients will try to use the uncompressed streaming
1976 1982 protocol. (default: False)
1977 1983
1978 1984 ``disablefullbundle``
1979 1985 When set, servers will refuse attempts to do pull-based clones.
1980 1986 If this option is set, ``preferuncompressed`` and/or clone bundles
1981 1987 are highly recommended. Partial clones will still be allowed.
1982 1988 (default: False)
1983 1989
1984 1990 ``streamunbundle``
1985 1991 When set, servers will apply data sent from the client directly,
1986 1992 otherwise it will be written to a temporary file first. This option
1987 1993 effectively prevents concurrent pushes.
1988 1994
1989 1995 ``pullbundle``
1990 1996 When set, the server will check pullbundle.manifest for bundles
1991 1997 covering the requested heads and common nodes. The first matching
1992 1998 entry will be streamed to the client.
1993 1999
1994 2000 For HTTP transport, the stream will still use zlib compression
1995 2001 for older clients.
1996 2002
1997 2003 ``concurrent-push-mode``
1998 2004 Level of allowed race condition between two pushing clients.
1999 2005
2000 2006 - 'strict': push is abort if another client touched the repository
2001 2007 while the push was preparing. (default)
2002 2008 - 'check-related': push is only aborted if it affects head that got also
2003 2009 affected while the push was preparing.
2004 2010
2005 2011 This requires compatible client (version 4.3 and later). Old client will
2006 2012 use 'strict'.
2007 2013
2008 2014 ``validate``
2009 2015 Whether to validate the completeness of pushed changesets by
2010 2016 checking that all new file revisions specified in manifests are
2011 2017 present. (default: False)
2012 2018
2013 2019 ``maxhttpheaderlen``
2014 2020 Instruct HTTP clients not to send request headers longer than this
2015 2021 many bytes. (default: 1024)
2016 2022
2017 2023 ``bundle1``
2018 2024 Whether to allow clients to push and pull using the legacy bundle1
2019 2025 exchange format. (default: True)
2020 2026
2021 2027 ``bundle1gd``
2022 2028 Like ``bundle1`` but only used if the repository is using the
2023 2029 *generaldelta* storage format. (default: True)
2024 2030
2025 2031 ``bundle1.push``
2026 2032 Whether to allow clients to push using the legacy bundle1 exchange
2027 2033 format. (default: True)
2028 2034
2029 2035 ``bundle1gd.push``
2030 2036 Like ``bundle1.push`` but only used if the repository is using the
2031 2037 *generaldelta* storage format. (default: True)
2032 2038
2033 2039 ``bundle1.pull``
2034 2040 Whether to allow clients to pull using the legacy bundle1 exchange
2035 2041 format. (default: True)
2036 2042
2037 2043 ``bundle1gd.pull``
2038 2044 Like ``bundle1.pull`` but only used if the repository is using the
2039 2045 *generaldelta* storage format. (default: True)
2040 2046
2041 2047 Large repositories using the *generaldelta* storage format should
2042 2048 consider setting this option because converting *generaldelta*
2043 2049 repositories to the exchange format required by the bundle1 data
2044 2050 format can consume a lot of CPU.
2045 2051
2046 2052 ``bundle2.stream``
2047 2053 Whether to allow clients to pull using the bundle2 streaming protocol.
2048 2054 (default: True)
2049 2055
2050 2056 ``zliblevel``
2051 2057 Integer between ``-1`` and ``9`` that controls the zlib compression level
2052 2058 for wire protocol commands that send zlib compressed output (notably the
2053 2059 commands that send repository history data).
2054 2060
2055 2061 The default (``-1``) uses the default zlib compression level, which is
2056 2062 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
2057 2063 maximum compression.
2058 2064
2059 2065 Setting this option allows server operators to make trade-offs between
2060 2066 bandwidth and CPU used. Lowering the compression lowers CPU utilization
2061 2067 but sends more bytes to clients.
2062 2068
2063 2069 This option only impacts the HTTP server.
2064 2070
2065 2071 ``zstdlevel``
2066 2072 Integer between ``1`` and ``22`` that controls the zstd compression level
2067 2073 for wire protocol commands. ``1`` is the minimal amount of compression and
2068 2074 ``22`` is the highest amount of compression.
2069 2075
2070 2076 The default (``3``) should be significantly faster than zlib while likely
2071 2077 delivering better compression ratios.
2072 2078
2073 2079 This option only impacts the HTTP server.
2074 2080
2075 2081 See also ``server.zliblevel``.
2076 2082
2077 2083 ``view``
2078 2084 Repository filter used when exchanging revisions with the peer.
2079 2085
2080 2086 The default view (``served``) excludes secret and hidden changesets.
2081 2087 Another useful value is ``immutable`` (no draft, secret or hidden
2082 2088 changesets). (EXPERIMENTAL)
2083 2089
2084 2090 ``smtp``
2085 2091 --------
2086 2092
2087 2093 Configuration for extensions that need to send email messages.
2088 2094
2089 2095 ``host``
2090 2096 Host name of mail server, e.g. "mail.example.com".
2091 2097
2092 2098 ``port``
2093 2099 Optional. Port to connect to on mail server. (default: 465 if
2094 2100 ``tls`` is smtps; 25 otherwise)
2095 2101
2096 2102 ``tls``
2097 2103 Optional. Method to enable TLS when connecting to mail server: starttls,
2098 2104 smtps or none. (default: none)
2099 2105
2100 2106 ``username``
2101 2107 Optional. User name for authenticating with the SMTP server.
2102 2108 (default: None)
2103 2109
2104 2110 ``password``
2105 2111 Optional. Password for authenticating with the SMTP server. If not
2106 2112 specified, interactive sessions will prompt the user for a
2107 2113 password; non-interactive sessions will fail. (default: None)
2108 2114
2109 2115 ``local_hostname``
2110 2116 Optional. The hostname that the sender can use to identify
2111 2117 itself to the MTA.
2112 2118
2113 2119
2114 2120 ``subpaths``
2115 2121 ------------
2116 2122
2117 2123 Subrepository source URLs can go stale if a remote server changes name
2118 2124 or becomes temporarily unavailable. This section lets you define
2119 2125 rewrite rules of the form::
2120 2126
2121 2127 <pattern> = <replacement>
2122 2128
2123 2129 where ``pattern`` is a regular expression matching a subrepository
2124 2130 source URL and ``replacement`` is the replacement string used to
2125 2131 rewrite it. Groups can be matched in ``pattern`` and referenced in
2126 2132 ``replacements``. For instance::
2127 2133
2128 2134 http://server/(.*)-hg/ = http://hg.server/\1/
2129 2135
2130 2136 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
2131 2137
2132 2138 Relative subrepository paths are first made absolute, and the
2133 2139 rewrite rules are then applied on the full (absolute) path. If ``pattern``
2134 2140 doesn't match the full path, an attempt is made to apply it on the
2135 2141 relative path alone. The rules are applied in definition order.
2136 2142
2137 2143 ``subrepos``
2138 2144 ------------
2139 2145
2140 2146 This section contains options that control the behavior of the
2141 2147 subrepositories feature. See also :hg:`help subrepos`.
2142 2148
2143 2149 Security note: auditing in Mercurial is known to be insufficient to
2144 2150 prevent clone-time code execution with carefully constructed Git
2145 2151 subrepos. It is unknown if a similar detect is present in Subversion
2146 2152 subrepos. Both Git and Subversion subrepos are disabled by default
2147 2153 out of security concerns. These subrepo types can be enabled using
2148 2154 the respective options below.
2149 2155
2150 2156 ``allowed``
2151 2157 Whether subrepositories are allowed in the working directory.
2152 2158
2153 2159 When false, commands involving subrepositories (like :hg:`update`)
2154 2160 will fail for all subrepository types.
2155 2161 (default: true)
2156 2162
2157 2163 ``hg:allowed``
2158 2164 Whether Mercurial subrepositories are allowed in the working
2159 2165 directory. This option only has an effect if ``subrepos.allowed``
2160 2166 is true.
2161 2167 (default: true)
2162 2168
2163 2169 ``git:allowed``
2164 2170 Whether Git subrepositories are allowed in the working directory.
2165 2171 This option only has an effect if ``subrepos.allowed`` is true.
2166 2172
2167 2173 See the security note above before enabling Git subrepos.
2168 2174 (default: false)
2169 2175
2170 2176 ``svn:allowed``
2171 2177 Whether Subversion subrepositories are allowed in the working
2172 2178 directory. This option only has an effect if ``subrepos.allowed``
2173 2179 is true.
2174 2180
2175 2181 See the security note above before enabling Subversion subrepos.
2176 2182 (default: false)
2177 2183
2178 2184 ``templatealias``
2179 2185 -----------------
2180 2186
2181 2187 Alias definitions for templates. See :hg:`help templates` for details.
2182 2188
2183 2189 ``templates``
2184 2190 -------------
2185 2191
2186 2192 Use the ``[templates]`` section to define template strings.
2187 2193 See :hg:`help templates` for details.
2188 2194
2189 2195 ``trusted``
2190 2196 -----------
2191 2197
2192 2198 Mercurial will not use the settings in the
2193 2199 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
2194 2200 user or to a trusted group, as various hgrc features allow arbitrary
2195 2201 commands to be run. This issue is often encountered when configuring
2196 2202 hooks or extensions for shared repositories or servers. However,
2197 2203 the web interface will use some safe settings from the ``[web]``
2198 2204 section.
2199 2205
2200 2206 This section specifies what users and groups are trusted. The
2201 2207 current user is always trusted. To trust everybody, list a user or a
2202 2208 group with name ``*``. These settings must be placed in an
2203 2209 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2204 2210 user or service running Mercurial.
2205 2211
2206 2212 ``users``
2207 2213 Comma-separated list of trusted users.
2208 2214
2209 2215 ``groups``
2210 2216 Comma-separated list of trusted groups.
2211 2217
2212 2218
2213 2219 ``ui``
2214 2220 ------
2215 2221
2216 2222 User interface controls.
2217 2223
2218 2224 ``archivemeta``
2219 2225 Whether to include the .hg_archival.txt file containing meta data
2220 2226 (hashes for the repository base and for tip) in archives created
2221 2227 by the :hg:`archive` command or downloaded via hgweb.
2222 2228 (default: True)
2223 2229
2224 2230 ``askusername``
2225 2231 Whether to prompt for a username when committing. If True, and
2226 2232 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2227 2233 be prompted to enter a username. If no username is entered, the
2228 2234 default ``USER@HOST`` is used instead.
2229 2235 (default: False)
2230 2236
2231 2237 ``clonebundles``
2232 2238 Whether the "clone bundles" feature is enabled.
2233 2239
2234 2240 When enabled, :hg:`clone` may download and apply a server-advertised
2235 2241 bundle file from a URL instead of using the normal exchange mechanism.
2236 2242
2237 2243 This can likely result in faster and more reliable clones.
2238 2244
2239 2245 (default: True)
2240 2246
2241 2247 ``clonebundlefallback``
2242 2248 Whether failure to apply an advertised "clone bundle" from a server
2243 2249 should result in fallback to a regular clone.
2244 2250
2245 2251 This is disabled by default because servers advertising "clone
2246 2252 bundles" often do so to reduce server load. If advertised bundles
2247 2253 start mass failing and clients automatically fall back to a regular
2248 2254 clone, this would add significant and unexpected load to the server
2249 2255 since the server is expecting clone operations to be offloaded to
2250 2256 pre-generated bundles. Failing fast (the default behavior) ensures
2251 2257 clients don't overwhelm the server when "clone bundle" application
2252 2258 fails.
2253 2259
2254 2260 (default: False)
2255 2261
2256 2262 ``clonebundleprefers``
2257 2263 Defines preferences for which "clone bundles" to use.
2258 2264
2259 2265 Servers advertising "clone bundles" may advertise multiple available
2260 2266 bundles. Each bundle may have different attributes, such as the bundle
2261 2267 type and compression format. This option is used to prefer a particular
2262 2268 bundle over another.
2263 2269
2264 2270 The following keys are defined by Mercurial:
2265 2271
2266 2272 BUNDLESPEC
2267 2273 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2268 2274 e.g. ``gzip-v2`` or ``bzip2-v1``.
2269 2275
2270 2276 COMPRESSION
2271 2277 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2272 2278
2273 2279 Server operators may define custom keys.
2274 2280
2275 2281 Example values: ``COMPRESSION=bzip2``,
2276 2282 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2277 2283
2278 2284 By default, the first bundle advertised by the server is used.
2279 2285
2280 2286 ``color``
2281 2287 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2282 2288 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2283 2289 seems possible. See :hg:`help color` for details.
2284 2290
2285 2291 ``commitsubrepos``
2286 2292 Whether to commit modified subrepositories when committing the
2287 2293 parent repository. If False and one subrepository has uncommitted
2288 2294 changes, abort the commit.
2289 2295 (default: False)
2290 2296
2291 2297 ``debug``
2292 2298 Print debugging information. (default: False)
2293 2299
2294 2300 ``editor``
2295 2301 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2296 2302
2297 2303 ``fallbackencoding``
2298 2304 Encoding to try if it's not possible to decode the changelog using
2299 2305 UTF-8. (default: ISO-8859-1)
2300 2306
2301 2307 ``graphnodetemplate``
2302 2308 The template used to print changeset nodes in an ASCII revision graph.
2303 2309 (default: ``{graphnode}``)
2304 2310
2305 2311 ``ignore``
2306 2312 A file to read per-user ignore patterns from. This file should be
2307 2313 in the same format as a repository-wide .hgignore file. Filenames
2308 2314 are relative to the repository root. This option supports hook syntax,
2309 2315 so if you want to specify multiple ignore files, you can do so by
2310 2316 setting something like ``ignore.other = ~/.hgignore2``. For details
2311 2317 of the ignore file format, see the ``hgignore(5)`` man page.
2312 2318
2313 2319 ``interactive``
2314 2320 Allow to prompt the user. (default: True)
2315 2321
2316 2322 ``interface``
2317 2323 Select the default interface for interactive features (default: text).
2318 2324 Possible values are 'text' and 'curses'.
2319 2325
2320 2326 ``interface.chunkselector``
2321 2327 Select the interface for change recording (e.g. :hg:`commit -i`).
2322 2328 Possible values are 'text' and 'curses'.
2323 2329 This config overrides the interface specified by ui.interface.
2324 2330
2325 2331 ``large-file-limit``
2326 2332 Largest file size that gives no memory use warning.
2327 2333 Possible values are integers or 0 to disable the check.
2328 2334 (default: 10000000)
2329 2335
2330 2336 ``logtemplate``
2331 2337 Template string for commands that print changesets.
2332 2338
2333 2339 ``merge``
2334 2340 The conflict resolution program to use during a manual merge.
2335 2341 For more information on merge tools see :hg:`help merge-tools`.
2336 2342 For configuring merge tools see the ``[merge-tools]`` section.
2337 2343
2338 2344 ``mergemarkers``
2339 2345 Sets the merge conflict marker label styling. The ``detailed``
2340 2346 style uses the ``mergemarkertemplate`` setting to style the labels.
2341 2347 The ``basic`` style just uses 'local' and 'other' as the marker label.
2342 2348 One of ``basic`` or ``detailed``.
2343 2349 (default: ``basic``)
2344 2350
2345 2351 ``mergemarkertemplate``
2346 2352 The template used to print the commit description next to each conflict
2347 2353 marker during merge conflicts. See :hg:`help templates` for the template
2348 2354 format.
2349 2355
2350 2356 Defaults to showing the hash, tags, branches, bookmarks, author, and
2351 2357 the first line of the commit description.
2352 2358
2353 2359 If you use non-ASCII characters in names for tags, branches, bookmarks,
2354 2360 authors, and/or commit descriptions, you must pay attention to encodings of
2355 2361 managed files. At template expansion, non-ASCII characters use the encoding
2356 2362 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2357 2363 environment variables that govern your locale. If the encoding of the merge
2358 2364 markers is different from the encoding of the merged files,
2359 2365 serious problems may occur.
2360 2366
2361 2367 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2362 2368
2363 2369 ``message-output``
2364 2370 Where to write status and error messages. (default: ``stdio``)
2365 2371
2366 2372 ``stderr``
2367 2373 Everything to stderr.
2368 2374 ``stdio``
2369 2375 Status to stdout, and error to stderr.
2370 2376
2371 2377 ``origbackuppath``
2372 2378 The path to a directory used to store generated .orig files. If the path is
2373 2379 not a directory, one will be created. If set, files stored in this
2374 2380 directory have the same name as the original file and do not have a .orig
2375 2381 suffix.
2376 2382
2377 2383 ``paginate``
2378 2384 Control the pagination of command output (default: True). See :hg:`help pager`
2379 2385 for details.
2380 2386
2381 2387 ``patch``
2382 2388 An optional external tool that ``hg import`` and some extensions
2383 2389 will use for applying patches. By default Mercurial uses an
2384 2390 internal patch utility. The external tool must work as the common
2385 2391 Unix ``patch`` program. In particular, it must accept a ``-p``
2386 2392 argument to strip patch headers, a ``-d`` argument to specify the
2387 2393 current directory, a file name to patch, and a patch file to take
2388 2394 from stdin.
2389 2395
2390 2396 It is possible to specify a patch tool together with extra
2391 2397 arguments. For example, setting this option to ``patch --merge``
2392 2398 will use the ``patch`` program with its 2-way merge option.
2393 2399
2394 2400 ``portablefilenames``
2395 2401 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2396 2402 (default: ``warn``)
2397 2403
2398 2404 ``warn``
2399 2405 Print a warning message on POSIX platforms, if a file with a non-portable
2400 2406 filename is added (e.g. a file with a name that can't be created on
2401 2407 Windows because it contains reserved parts like ``AUX``, reserved
2402 2408 characters like ``:``, or would cause a case collision with an existing
2403 2409 file).
2404 2410
2405 2411 ``ignore``
2406 2412 Don't print a warning.
2407 2413
2408 2414 ``abort``
2409 2415 The command is aborted.
2410 2416
2411 2417 ``true``
2412 2418 Alias for ``warn``.
2413 2419
2414 2420 ``false``
2415 2421 Alias for ``ignore``.
2416 2422
2417 2423 .. container:: windows
2418 2424
2419 2425 On Windows, this configuration option is ignored and the command aborted.
2420 2426
2421 2427 ``pre-merge-tool-output-template``
2422 2428 A template that is printed before executing an external merge tool. This can
2423 2429 be used to print out additional context that might be useful to have during
2424 2430 the conflict resolution, such as the description of the various commits
2425 2431 involved or bookmarks/tags.
2426 2432
2427 2433 Additional information is available in the ``local`, ``base``, and ``other``
2428 2434 dicts. For example: ``{local.label}``, ``{base.name}``, or
2429 2435 ``{other.islink}``.
2430 2436
2431 2437 ``quiet``
2432 2438 Reduce the amount of output printed.
2433 2439 (default: False)
2434 2440
2435 2441 ``relative-paths``
2436 2442 Prefer relative paths in the UI.
2437 2443
2438 2444 ``remotecmd``
2439 2445 Remote command to use for clone/push/pull operations.
2440 2446 (default: ``hg``)
2441 2447
2442 2448 ``report_untrusted``
2443 2449 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2444 2450 trusted user or group.
2445 2451 (default: True)
2446 2452
2447 2453 ``slash``
2448 2454 (Deprecated. Use ``slashpath`` template filter instead.)
2449 2455
2450 2456 Display paths using a slash (``/``) as the path separator. This
2451 2457 only makes a difference on systems where the default path
2452 2458 separator is not the slash character (e.g. Windows uses the
2453 2459 backslash character (``\``)).
2454 2460 (default: False)
2455 2461
2456 2462 ``statuscopies``
2457 2463 Display copies in the status command.
2458 2464
2459 2465 ``ssh``
2460 2466 Command to use for SSH connections. (default: ``ssh``)
2461 2467
2462 2468 ``ssherrorhint``
2463 2469 A hint shown to the user in the case of SSH error (e.g.
2464 2470 ``Please see http://company/internalwiki/ssh.html``)
2465 2471
2466 2472 ``strict``
2467 2473 Require exact command names, instead of allowing unambiguous
2468 2474 abbreviations. (default: False)
2469 2475
2470 2476 ``style``
2471 2477 Name of style to use for command output.
2472 2478
2473 2479 ``supportcontact``
2474 2480 A URL where users should report a Mercurial traceback. Use this if you are a
2475 2481 large organisation with its own Mercurial deployment process and crash
2476 2482 reports should be addressed to your internal support.
2477 2483
2478 2484 ``textwidth``
2479 2485 Maximum width of help text. A longer line generated by ``hg help`` or
2480 2486 ``hg subcommand --help`` will be broken after white space to get this
2481 2487 width or the terminal width, whichever comes first.
2482 2488 A non-positive value will disable this and the terminal width will be
2483 2489 used. (default: 78)
2484 2490
2485 2491 ``timeout``
2486 2492 The timeout used when a lock is held (in seconds), a negative value
2487 2493 means no timeout. (default: 600)
2488 2494
2489 2495 ``timeout.warn``
2490 2496 Time (in seconds) before a warning is printed about held lock. A negative
2491 2497 value means no warning. (default: 0)
2492 2498
2493 2499 ``traceback``
2494 2500 Mercurial always prints a traceback when an unknown exception
2495 2501 occurs. Setting this to True will make Mercurial print a traceback
2496 2502 on all exceptions, even those recognized by Mercurial (such as
2497 2503 IOError or MemoryError). (default: False)
2498 2504
2499 2505 ``tweakdefaults``
2500 2506
2501 2507 By default Mercurial's behavior changes very little from release
2502 2508 to release, but over time the recommended config settings
2503 2509 shift. Enable this config to opt in to get automatic tweaks to
2504 2510 Mercurial's behavior over time. This config setting will have no
2505 2511 effect if ``HGPLAIN`` is set or ``HGPLAINEXCEPT`` is set and does
2506 2512 not include ``tweakdefaults``. (default: False)
2507 2513
2508 2514 It currently means::
2509 2515
2510 2516 .. tweakdefaultsmarker
2511 2517
2512 2518 ``username``
2513 2519 The committer of a changeset created when running "commit".
2514 2520 Typically a person's name and email address, e.g. ``Fred Widget
2515 2521 <fred@example.com>``. Environment variables in the
2516 2522 username are expanded.
2517 2523
2518 2524 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2519 2525 hgrc is empty, e.g. if the system admin set ``username =`` in the
2520 2526 system hgrc, it has to be specified manually or in a different
2521 2527 hgrc file)
2522 2528
2523 2529 ``verbose``
2524 2530 Increase the amount of output printed. (default: False)
2525 2531
2526 2532
2527 2533 ``web``
2528 2534 -------
2529 2535
2530 2536 Web interface configuration. The settings in this section apply to
2531 2537 both the builtin webserver (started by :hg:`serve`) and the script you
2532 2538 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2533 2539 and WSGI).
2534 2540
2535 2541 The Mercurial webserver does no authentication (it does not prompt for
2536 2542 usernames and passwords to validate *who* users are), but it does do
2537 2543 authorization (it grants or denies access for *authenticated users*
2538 2544 based on settings in this section). You must either configure your
2539 2545 webserver to do authentication for you, or disable the authorization
2540 2546 checks.
2541 2547
2542 2548 For a quick setup in a trusted environment, e.g., a private LAN, where
2543 2549 you want it to accept pushes from anybody, you can use the following
2544 2550 command line::
2545 2551
2546 2552 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2547 2553
2548 2554 Note that this will allow anybody to push anything to the server and
2549 2555 that this should not be used for public servers.
2550 2556
2551 2557 The full set of options is:
2552 2558
2553 2559 ``accesslog``
2554 2560 Where to output the access log. (default: stdout)
2555 2561
2556 2562 ``address``
2557 2563 Interface address to bind to. (default: all)
2558 2564
2559 2565 ``allow-archive``
2560 2566 List of archive format (bz2, gz, zip) allowed for downloading.
2561 2567 (default: empty)
2562 2568
2563 2569 ``allowbz2``
2564 2570 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2565 2571 revisions.
2566 2572 (default: False)
2567 2573
2568 2574 ``allowgz``
2569 2575 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2570 2576 revisions.
2571 2577 (default: False)
2572 2578
2573 2579 ``allow-pull``
2574 2580 Whether to allow pulling from the repository. (default: True)
2575 2581
2576 2582 ``allow-push``
2577 2583 Whether to allow pushing to the repository. If empty or not set,
2578 2584 pushing is not allowed. If the special value ``*``, any remote
2579 2585 user can push, including unauthenticated users. Otherwise, the
2580 2586 remote user must have been authenticated, and the authenticated
2581 2587 user name must be present in this list. The contents of the
2582 2588 allow-push list are examined after the deny_push list.
2583 2589
2584 2590 ``allow_read``
2585 2591 If the user has not already been denied repository access due to
2586 2592 the contents of deny_read, this list determines whether to grant
2587 2593 repository access to the user. If this list is not empty, and the
2588 2594 user is unauthenticated or not present in the list, then access is
2589 2595 denied for the user. If the list is empty or not set, then access
2590 2596 is permitted to all users by default. Setting allow_read to the
2591 2597 special value ``*`` is equivalent to it not being set (i.e. access
2592 2598 is permitted to all users). The contents of the allow_read list are
2593 2599 examined after the deny_read list.
2594 2600
2595 2601 ``allowzip``
2596 2602 (DEPRECATED) Whether to allow .zip downloading of repository
2597 2603 revisions. This feature creates temporary files.
2598 2604 (default: False)
2599 2605
2600 2606 ``archivesubrepos``
2601 2607 Whether to recurse into subrepositories when archiving.
2602 2608 (default: False)
2603 2609
2604 2610 ``baseurl``
2605 2611 Base URL to use when publishing URLs in other locations, so
2606 2612 third-party tools like email notification hooks can construct
2607 2613 URLs. Example: ``http://hgserver/repos/``.
2608 2614
2609 2615 ``cacerts``
2610 2616 Path to file containing a list of PEM encoded certificate
2611 2617 authority certificates. Environment variables and ``~user``
2612 2618 constructs are expanded in the filename. If specified on the
2613 2619 client, then it will verify the identity of remote HTTPS servers
2614 2620 with these certificates.
2615 2621
2616 2622 To disable SSL verification temporarily, specify ``--insecure`` from
2617 2623 command line.
2618 2624
2619 2625 You can use OpenSSL's CA certificate file if your platform has
2620 2626 one. On most Linux systems this will be
2621 2627 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2622 2628 generate this file manually. The form must be as follows::
2623 2629
2624 2630 -----BEGIN CERTIFICATE-----
2625 2631 ... (certificate in base64 PEM encoding) ...
2626 2632 -----END CERTIFICATE-----
2627 2633 -----BEGIN CERTIFICATE-----
2628 2634 ... (certificate in base64 PEM encoding) ...
2629 2635 -----END CERTIFICATE-----
2630 2636
2631 2637 ``cache``
2632 2638 Whether to support caching in hgweb. (default: True)
2633 2639
2634 2640 ``certificate``
2635 2641 Certificate to use when running :hg:`serve`.
2636 2642
2637 2643 ``collapse``
2638 2644 With ``descend`` enabled, repositories in subdirectories are shown at
2639 2645 a single level alongside repositories in the current path. With
2640 2646 ``collapse`` also enabled, repositories residing at a deeper level than
2641 2647 the current path are grouped behind navigable directory entries that
2642 2648 lead to the locations of these repositories. In effect, this setting
2643 2649 collapses each collection of repositories found within a subdirectory
2644 2650 into a single entry for that subdirectory. (default: False)
2645 2651
2646 2652 ``comparisoncontext``
2647 2653 Number of lines of context to show in side-by-side file comparison. If
2648 2654 negative or the value ``full``, whole files are shown. (default: 5)
2649 2655
2650 2656 This setting can be overridden by a ``context`` request parameter to the
2651 2657 ``comparison`` command, taking the same values.
2652 2658
2653 2659 ``contact``
2654 2660 Name or email address of the person in charge of the repository.
2655 2661 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2656 2662
2657 2663 ``csp``
2658 2664 Send a ``Content-Security-Policy`` HTTP header with this value.
2659 2665
2660 2666 The value may contain a special string ``%nonce%``, which will be replaced
2661 2667 by a randomly-generated one-time use value. If the value contains
2662 2668 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2663 2669 one-time property of the nonce. This nonce will also be inserted into
2664 2670 ``<script>`` elements containing inline JavaScript.
2665 2671
2666 2672 Note: lots of HTML content sent by the server is derived from repository
2667 2673 data. Please consider the potential for malicious repository data to
2668 2674 "inject" itself into generated HTML content as part of your security
2669 2675 threat model.
2670 2676
2671 2677 ``deny_push``
2672 2678 Whether to deny pushing to the repository. If empty or not set,
2673 2679 push is not denied. If the special value ``*``, all remote users are
2674 2680 denied push. Otherwise, unauthenticated users are all denied, and
2675 2681 any authenticated user name present in this list is also denied. The
2676 2682 contents of the deny_push list are examined before the allow-push list.
2677 2683
2678 2684 ``deny_read``
2679 2685 Whether to deny reading/viewing of the repository. If this list is
2680 2686 not empty, unauthenticated users are all denied, and any
2681 2687 authenticated user name present in this list is also denied access to
2682 2688 the repository. If set to the special value ``*``, all remote users
2683 2689 are denied access (rarely needed ;). If deny_read is empty or not set,
2684 2690 the determination of repository access depends on the presence and
2685 2691 content of the allow_read list (see description). If both
2686 2692 deny_read and allow_read are empty or not set, then access is
2687 2693 permitted to all users by default. If the repository is being
2688 2694 served via hgwebdir, denied users will not be able to see it in
2689 2695 the list of repositories. The contents of the deny_read list have
2690 2696 priority over (are examined before) the contents of the allow_read
2691 2697 list.
2692 2698
2693 2699 ``descend``
2694 2700 hgwebdir indexes will not descend into subdirectories. Only repositories
2695 2701 directly in the current path will be shown (other repositories are still
2696 2702 available from the index corresponding to their containing path).
2697 2703
2698 2704 ``description``
2699 2705 Textual description of the repository's purpose or contents.
2700 2706 (default: "unknown")
2701 2707
2702 2708 ``encoding``
2703 2709 Character encoding name. (default: the current locale charset)
2704 2710 Example: "UTF-8".
2705 2711
2706 2712 ``errorlog``
2707 2713 Where to output the error log. (default: stderr)
2708 2714
2709 2715 ``guessmime``
2710 2716 Control MIME types for raw download of file content.
2711 2717 Set to True to let hgweb guess the content type from the file
2712 2718 extension. This will serve HTML files as ``text/html`` and might
2713 2719 allow cross-site scripting attacks when serving untrusted
2714 2720 repositories. (default: False)
2715 2721
2716 2722 ``hidden``
2717 2723 Whether to hide the repository in the hgwebdir index.
2718 2724 (default: False)
2719 2725
2720 2726 ``ipv6``
2721 2727 Whether to use IPv6. (default: False)
2722 2728
2723 2729 ``labels``
2724 2730 List of string *labels* associated with the repository.
2725 2731
2726 2732 Labels are exposed as a template keyword and can be used to customize
2727 2733 output. e.g. the ``index`` template can group or filter repositories
2728 2734 by labels and the ``summary`` template can display additional content
2729 2735 if a specific label is present.
2730 2736
2731 2737 ``logoimg``
2732 2738 File name of the logo image that some templates display on each page.
2733 2739 The file name is relative to ``staticurl``. That is, the full path to
2734 2740 the logo image is "staticurl/logoimg".
2735 2741 If unset, ``hglogo.png`` will be used.
2736 2742
2737 2743 ``logourl``
2738 2744 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2739 2745 will be used.
2740 2746
2741 2747 ``maxchanges``
2742 2748 Maximum number of changes to list on the changelog. (default: 10)
2743 2749
2744 2750 ``maxfiles``
2745 2751 Maximum number of files to list per changeset. (default: 10)
2746 2752
2747 2753 ``maxshortchanges``
2748 2754 Maximum number of changes to list on the shortlog, graph or filelog
2749 2755 pages. (default: 60)
2750 2756
2751 2757 ``name``
2752 2758 Repository name to use in the web interface.
2753 2759 (default: current working directory)
2754 2760
2755 2761 ``port``
2756 2762 Port to listen on. (default: 8000)
2757 2763
2758 2764 ``prefix``
2759 2765 Prefix path to serve from. (default: '' (server root))
2760 2766
2761 2767 ``push_ssl``
2762 2768 Whether to require that inbound pushes be transported over SSL to
2763 2769 prevent password sniffing. (default: True)
2764 2770
2765 2771 ``refreshinterval``
2766 2772 How frequently directory listings re-scan the filesystem for new
2767 2773 repositories, in seconds. This is relevant when wildcards are used
2768 2774 to define paths. Depending on how much filesystem traversal is
2769 2775 required, refreshing may negatively impact performance.
2770 2776
2771 2777 Values less than or equal to 0 always refresh.
2772 2778 (default: 20)
2773 2779
2774 2780 ``server-header``
2775 2781 Value for HTTP ``Server`` response header.
2776 2782
2777 2783 ``static``
2778 2784 Directory where static files are served from.
2779 2785
2780 2786 ``staticurl``
2781 2787 Base URL to use for static files. If unset, static files (e.g. the
2782 2788 hgicon.png favicon) will be served by the CGI script itself. Use
2783 2789 this setting to serve them directly with the HTTP server.
2784 2790 Example: ``http://hgserver/static/``.
2785 2791
2786 2792 ``stripes``
2787 2793 How many lines a "zebra stripe" should span in multi-line output.
2788 2794 Set to 0 to disable. (default: 1)
2789 2795
2790 2796 ``style``
2791 2797 Which template map style to use. The available options are the names of
2792 2798 subdirectories in the HTML templates path. (default: ``paper``)
2793 2799 Example: ``monoblue``.
2794 2800
2795 2801 ``templates``
2796 2802 Where to find the HTML templates. The default path to the HTML templates
2797 2803 can be obtained from ``hg debuginstall``.
2798 2804
2799 2805 ``websub``
2800 2806 ----------
2801 2807
2802 2808 Web substitution filter definition. You can use this section to
2803 2809 define a set of regular expression substitution patterns which
2804 2810 let you automatically modify the hgweb server output.
2805 2811
2806 2812 The default hgweb templates only apply these substitution patterns
2807 2813 on the revision description fields. You can apply them anywhere
2808 2814 you want when you create your own templates by adding calls to the
2809 2815 "websub" filter (usually after calling the "escape" filter).
2810 2816
2811 2817 This can be used, for example, to convert issue references to links
2812 2818 to your issue tracker, or to convert "markdown-like" syntax into
2813 2819 HTML (see the examples below).
2814 2820
2815 2821 Each entry in this section names a substitution filter.
2816 2822 The value of each entry defines the substitution expression itself.
2817 2823 The websub expressions follow the old interhg extension syntax,
2818 2824 which in turn imitates the Unix sed replacement syntax::
2819 2825
2820 2826 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2821 2827
2822 2828 You can use any separator other than "/". The final "i" is optional
2823 2829 and indicates that the search must be case insensitive.
2824 2830
2825 2831 Examples::
2826 2832
2827 2833 [websub]
2828 2834 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2829 2835 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2830 2836 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2831 2837
2832 2838 ``worker``
2833 2839 ----------
2834 2840
2835 2841 Parallel master/worker configuration. We currently perform working
2836 2842 directory updates in parallel on Unix-like systems, which greatly
2837 2843 helps performance.
2838 2844
2839 2845 ``enabled``
2840 2846 Whether to enable workers code to be used.
2841 2847 (default: true)
2842 2848
2843 2849 ``numcpus``
2844 2850 Number of CPUs to use for parallel operations. A zero or
2845 2851 negative value is treated as ``use the default``.
2846 2852 (default: 4 or the number of CPUs on the system, whichever is larger)
2847 2853
2848 2854 ``backgroundclose``
2849 2855 Whether to enable closing file handles on background threads during certain
2850 2856 operations. Some platforms aren't very efficient at closing file
2851 2857 handles that have been written or appended to. By performing file closing
2852 2858 on background threads, file write rate can increase substantially.
2853 2859 (default: true on Windows, false elsewhere)
2854 2860
2855 2861 ``backgroundcloseminfilecount``
2856 2862 Minimum number of files required to trigger background file closing.
2857 2863 Operations not writing this many files won't start background close
2858 2864 threads.
2859 2865 (default: 2048)
2860 2866
2861 2867 ``backgroundclosemaxqueue``
2862 2868 The maximum number of opened file handles waiting to be closed in the
2863 2869 background. This option only has an effect if ``backgroundclose`` is
2864 2870 enabled.
2865 2871 (default: 384)
2866 2872
2867 2873 ``backgroundclosethreadcount``
2868 2874 Number of threads to process background file closes. Only relevant if
2869 2875 ``backgroundclose`` is enabled.
2870 2876 (default: 4)
@@ -1,175 +1,190 b''
1 1 $ hg init
2 2 $ echo a > a
3 3 $ hg commit -A -ma
4 4 adding a
5 5
6 6 $ echo b >> a
7 7 $ hg commit -mb
8 8
9 9 $ echo c >> a
10 10 $ hg commit -mc
11 11
12 12 $ hg up 1
13 13 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
14 14 $ echo d >> a
15 15 $ hg commit -md
16 16 created new head
17 17
18 18 $ hg up 1
19 19 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
20 20 $ echo e >> a
21 21 $ hg commit -me
22 22 created new head
23 23
24 24 $ hg up 1
25 25 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
26 26
27 27 Should fail because not at a head:
28 28
29 29 $ hg merge
30 30 abort: working directory not at a head revision
31 31 (use 'hg update' or merge with an explicit revision)
32 32 [255]
33 33
34 34 $ hg up
35 35 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
36 36 updated to "f25cbe84d8b3: e"
37 37 2 other heads for branch "default"
38 38
39 39 Should fail because > 2 heads:
40 40
41 41 $ HGMERGE=internal:other; export HGMERGE
42 42 $ hg merge
43 43 abort: branch 'default' has 3 heads - please merge with an explicit rev
44 44 (run 'hg heads .' to see heads, specify rev with -r)
45 45 [255]
46 46
47 Should succeed:
47 Should succeed (we're specifying commands.merge.require-rev=True just to test
48 that it allows merge to succeed if we specify a revision):
48 49
49 $ hg merge 2
50 $ hg merge 2 --config commands.merge.require-rev=True
50 51 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
51 52 (branch merge, don't forget to commit)
52 53 $ hg id -Tjson
53 54 [
54 55 {
55 56 "bookmarks": [],
56 57 "branch": "default",
57 58 "dirty": "+",
58 59 "id": "f25cbe84d8b320e298e7703f18a25a3959518c23+2d95304fed5d89bc9d70b2a0d02f0d567469c3ab+",
59 60 "node": "ffffffffffffffffffffffffffffffffffffffff",
60 61 "parents": ["f25cbe84d8b320e298e7703f18a25a3959518c23", "2d95304fed5d89bc9d70b2a0d02f0d567469c3ab"],
61 62 "tags": ["tip"]
62 63 }
63 64 ]
64 65 $ hg commit -mm1
65 66
67 Should fail because we didn't specify a revision (even though it would have
68 succeeded without this):
69
70 $ hg merge --config commands.merge.require-rev=True
71 abort: configuration requires specifying revision to merge with
72 [255]
73
66 74 Should succeed - 2 heads:
67 75
68 76 $ hg merge -P
69 77 changeset: 3:ea9ff125ff88
70 78 parent: 1:1846eede8b68
71 79 user: test
72 80 date: Thu Jan 01 00:00:00 1970 +0000
73 81 summary: d
74 82
75 83 $ hg merge
76 84 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
77 85 (branch merge, don't forget to commit)
78 86 $ hg commit -mm2
79 87
80 88 $ hg id -r 1 -Tjson
81 89 [
82 90 {
83 91 "bookmarks": [],
84 92 "branch": "default",
85 93 "id": "1846eede8b6886d8cc8a88c96a687b7fe8f3b9d1",
86 94 "node": "1846eede8b6886d8cc8a88c96a687b7fe8f3b9d1",
87 95 "tags": []
88 96 }
89 97 ]
90 98
99 Should fail because we didn't specify a revision (even though it would have
100 failed without this due to being on tip, but this check comes first):
101
102 $ hg merge --config commands.merge.require-rev=True
103 abort: configuration requires specifying revision to merge with
104 [255]
105
91 106 Should fail because at tip:
92 107
93 108 $ hg merge
94 109 abort: nothing to merge
95 110 [255]
96 111
97 112 $ hg up 0
98 113 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
99 114
100 115 Should fail because there is only one head:
101 116
102 117 $ hg merge
103 118 abort: nothing to merge
104 119 (use 'hg update' instead)
105 120 [255]
106 121
107 122 $ hg up 3
108 123 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
109 124
110 125 $ echo f >> a
111 126 $ hg branch foobranch
112 127 marked working directory as branch foobranch
113 128 (branches are permanent and global, did you want a bookmark?)
114 129 $ hg commit -mf
115 130
116 131 Should fail because merge with other branch:
117 132
118 133 $ hg merge
119 134 abort: branch 'foobranch' has one head - please merge with an explicit rev
120 135 (run 'hg heads' to see all heads, specify rev with -r)
121 136 [255]
122 137
123 138
124 139 Test for issue2043: ensure that 'merge -P' shows ancestors of 6 that
125 140 are not ancestors of 7, regardless of where their common ancestors are.
126 141
127 142 Merge preview not affected by common ancestor:
128 143
129 144 $ hg up -q 7
130 145 $ hg merge -q -P 6
131 146 2:2d95304fed5d
132 147 4:f25cbe84d8b3
133 148 5:a431fabd6039
134 149 6:e88e33f3bf62
135 150
136 151 Test experimental destination revset
137 152
138 153 $ hg log -r '_destmerge()'
139 154 abort: branch 'foobranch' has one head - please merge with an explicit rev
140 155 (run 'hg heads' to see all heads, specify rev with -r)
141 156 [255]
142 157
143 158 (on a branch with a two heads)
144 159
145 160 $ hg up 5
146 161 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
147 162 $ echo f >> a
148 163 $ hg commit -mf
149 164 created new head
150 165 $ hg log -r '_destmerge()'
151 166 changeset: 6:e88e33f3bf62
152 167 parent: 5:a431fabd6039
153 168 parent: 3:ea9ff125ff88
154 169 user: test
155 170 date: Thu Jan 01 00:00:00 1970 +0000
156 171 summary: m2
157 172
158 173
159 174 (from the other head)
160 175
161 176 $ hg log -r '_destmerge(e88e33f3bf62)'
162 177 changeset: 8:b613918999e2
163 178 tag: tip
164 179 parent: 5:a431fabd6039
165 180 user: test
166 181 date: Thu Jan 01 00:00:00 1970 +0000
167 182 summary: f
168 183
169 184
170 185 (from unrelated branch)
171 186
172 187 $ hg log -r '_destmerge(foobranch)'
173 188 abort: branch 'foobranch' has one head - please merge with an explicit rev
174 189 (run 'hg heads' to see all heads, specify rev with -r)
175 190 [255]
@@ -1,2088 +1,2091 b''
1 1 test merge-tools configuration - mostly exercising filemerge.py
2 2
3 3 $ unset HGMERGE # make sure HGMERGE doesn't interfere with the test
4 4 $ cat >> $HGRCPATH << EOF
5 5 > [ui]
6 6 > merge=
7 > [commands]
8 > merge.require-rev=True
7 9 > EOF
8 10 $ hg init repo
9 11 $ cd repo
10 12
11 13 revision 0
12 14
13 15 $ echo "revision 0" > f
14 16 $ echo "space" >> f
15 17 $ hg commit -Am "revision 0"
16 18 adding f
17 19
18 20 revision 1
19 21
20 22 $ echo "revision 1" > f
21 23 $ echo "space" >> f
22 24 $ hg commit -Am "revision 1"
23 25 $ hg update 0 > /dev/null
24 26
25 27 revision 2
26 28
27 29 $ echo "revision 2" > f
28 30 $ echo "space" >> f
29 31 $ hg commit -Am "revision 2"
30 32 created new head
31 33 $ hg update 0 > /dev/null
32 34
33 35 revision 3 - simple to merge
34 36
35 37 $ echo "revision 3" >> f
36 38 $ hg commit -Am "revision 3"
37 39 created new head
38 40
39 41 revision 4 - hard to merge
40 42
41 43 $ hg update 0 > /dev/null
42 44 $ echo "revision 4" > f
43 45 $ hg commit -Am "revision 4"
44 46 created new head
45 47
46 48 $ echo "[merge-tools]" > .hg/hgrc
47 49
48 50 $ beforemerge() {
49 51 > cat .hg/hgrc
50 52 > echo "# hg update -C 1"
51 53 > hg update -C 1 > /dev/null
52 54 > }
53 55 $ aftermerge() {
54 56 > echo "# cat f"
55 57 > cat f
56 58 > echo "# hg stat"
57 59 > hg stat
58 60 > echo "# hg resolve --list"
59 61 > hg resolve --list
60 62 > rm -f f.orig
61 63 > }
62 64
63 65 Tool selection
64 66
65 67 default is internal merge:
66 68
67 69 $ beforemerge
68 70 [merge-tools]
69 71 # hg update -C 1
70 72
71 73 hg merge -r 2
72 74 override $PATH to ensure hgmerge not visible; use $PYTHON in case we're
73 75 running from a devel copy, not a temp installation
74 76
75 77 $ PATH="/usr/sbin" "$PYTHON" "$BINDIR"/hg merge -r 2
76 78 merging f
77 79 warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
78 80 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
79 81 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
80 82 [1]
81 83 $ aftermerge
82 84 # cat f
83 85 <<<<<<< working copy: ef83787e2614 - test: revision 1
84 86 revision 1
85 87 =======
86 88 revision 2
87 89 >>>>>>> merge rev: 0185f4e0cf02 - test: revision 2
88 90 space
89 91 # hg stat
90 92 M f
91 93 ? f.orig
92 94 # hg resolve --list
93 95 U f
94 96
95 97 simplest hgrc using false for merge:
96 98
97 99 $ echo "false.whatever=" >> .hg/hgrc
98 100 $ beforemerge
99 101 [merge-tools]
100 102 false.whatever=
101 103 # hg update -C 1
102 104 $ hg merge -r 2
103 105 merging f
104 106 merging f failed!
105 107 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
106 108 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
107 109 [1]
108 110 $ aftermerge
109 111 # cat f
110 112 revision 1
111 113 space
112 114 # hg stat
113 115 M f
114 116 ? f.orig
115 117 # hg resolve --list
116 118 U f
117 119
118 120 #if unix-permissions
119 121
120 122 unexecutable file in $PATH shouldn't be found:
121 123
122 124 $ echo "echo fail" > false
123 125 $ hg up -qC 1
124 126 $ PATH="`pwd`:/usr/sbin" "$PYTHON" "$BINDIR"/hg merge -r 2
125 127 merging f
126 128 warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
127 129 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
128 130 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
129 131 [1]
130 132 $ rm false
131 133
132 134 #endif
133 135
134 136 executable directory in $PATH shouldn't be found:
135 137
136 138 $ mkdir false
137 139 $ hg up -qC 1
138 140 $ PATH="`pwd`:/usr/sbin" "$PYTHON" "$BINDIR"/hg merge -r 2
139 141 merging f
140 142 warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
141 143 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
142 144 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
143 145 [1]
144 146 $ rmdir false
145 147
146 148 true with higher .priority gets precedence:
147 149
148 150 $ echo "true.priority=1" >> .hg/hgrc
149 151 $ beforemerge
150 152 [merge-tools]
151 153 false.whatever=
152 154 true.priority=1
153 155 # hg update -C 1
154 156 $ hg merge -r 2
155 157 merging f
156 158 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
157 159 (branch merge, don't forget to commit)
158 160 $ aftermerge
159 161 # cat f
160 162 revision 1
161 163 space
162 164 # hg stat
163 165 M f
164 166 # hg resolve --list
165 167 R f
166 168
167 169 unless lowered on command line:
168 170
169 171 $ beforemerge
170 172 [merge-tools]
171 173 false.whatever=
172 174 true.priority=1
173 175 # hg update -C 1
174 176 $ hg merge -r 2 --config merge-tools.true.priority=-7
175 177 merging f
176 178 merging f failed!
177 179 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
178 180 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
179 181 [1]
180 182 $ aftermerge
181 183 # cat f
182 184 revision 1
183 185 space
184 186 # hg stat
185 187 M f
186 188 ? f.orig
187 189 # hg resolve --list
188 190 U f
189 191
190 192 or false set higher on command line:
191 193
192 194 $ beforemerge
193 195 [merge-tools]
194 196 false.whatever=
195 197 true.priority=1
196 198 # hg update -C 1
197 199 $ hg merge -r 2 --config merge-tools.false.priority=117
198 200 merging f
199 201 merging f failed!
200 202 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
201 203 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
202 204 [1]
203 205 $ aftermerge
204 206 # cat f
205 207 revision 1
206 208 space
207 209 # hg stat
208 210 M f
209 211 ? f.orig
210 212 # hg resolve --list
211 213 U f
212 214
213 215 or true set to disabled:
214 216 $ beforemerge
215 217 [merge-tools]
216 218 false.whatever=
217 219 true.priority=1
218 220 # hg update -C 1
219 221 $ hg merge -r 2 --config merge-tools.true.disabled=yes
220 222 merging f
221 223 merging f failed!
222 224 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
223 225 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
224 226 [1]
225 227 $ aftermerge
226 228 # cat f
227 229 revision 1
228 230 space
229 231 # hg stat
230 232 M f
231 233 ? f.orig
232 234 # hg resolve --list
233 235 U f
234 236
235 237 or true.executable not found in PATH:
236 238
237 239 $ beforemerge
238 240 [merge-tools]
239 241 false.whatever=
240 242 true.priority=1
241 243 # hg update -C 1
242 244 $ hg merge -r 2 --config merge-tools.true.executable=nonexistentmergetool
243 245 merging f
244 246 merging f failed!
245 247 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
246 248 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
247 249 [1]
248 250 $ aftermerge
249 251 # cat f
250 252 revision 1
251 253 space
252 254 # hg stat
253 255 M f
254 256 ? f.orig
255 257 # hg resolve --list
256 258 U f
257 259
258 260 or true.executable with bogus path:
259 261
260 262 $ beforemerge
261 263 [merge-tools]
262 264 false.whatever=
263 265 true.priority=1
264 266 # hg update -C 1
265 267 $ hg merge -r 2 --config merge-tools.true.executable=/nonexistent/mergetool
266 268 merging f
267 269 merging f failed!
268 270 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
269 271 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
270 272 [1]
271 273 $ aftermerge
272 274 # cat f
273 275 revision 1
274 276 space
275 277 # hg stat
276 278 M f
277 279 ? f.orig
278 280 # hg resolve --list
279 281 U f
280 282
281 283 but true.executable set to cat found in PATH works:
282 284
283 285 $ echo "true.executable=cat" >> .hg/hgrc
284 286 $ beforemerge
285 287 [merge-tools]
286 288 false.whatever=
287 289 true.priority=1
288 290 true.executable=cat
289 291 # hg update -C 1
290 292 $ hg merge -r 2
291 293 merging f
292 294 revision 1
293 295 space
294 296 revision 0
295 297 space
296 298 revision 2
297 299 space
298 300 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
299 301 (branch merge, don't forget to commit)
300 302 $ aftermerge
301 303 # cat f
302 304 revision 1
303 305 space
304 306 # hg stat
305 307 M f
306 308 # hg resolve --list
307 309 R f
308 310
309 311 and true.executable set to cat with path works:
310 312
311 313 $ beforemerge
312 314 [merge-tools]
313 315 false.whatever=
314 316 true.priority=1
315 317 true.executable=cat
316 318 # hg update -C 1
317 319 $ hg merge -r 2 --config merge-tools.true.executable=cat
318 320 merging f
319 321 revision 1
320 322 space
321 323 revision 0
322 324 space
323 325 revision 2
324 326 space
325 327 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
326 328 (branch merge, don't forget to commit)
327 329 $ aftermerge
328 330 # cat f
329 331 revision 1
330 332 space
331 333 # hg stat
332 334 M f
333 335 # hg resolve --list
334 336 R f
335 337
336 338 executable set to python script that succeeds:
337 339
338 340 $ cat > "$TESTTMP/myworkingmerge.py" <<EOF
339 341 > def myworkingmergefn(ui, repo, args, **kwargs):
340 342 > return False
341 343 > EOF
342 344 $ beforemerge
343 345 [merge-tools]
344 346 false.whatever=
345 347 true.priority=1
346 348 true.executable=cat
347 349 # hg update -C 1
348 350 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/myworkingmerge.py:myworkingmergefn"
349 351 merging f
350 352 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
351 353 (branch merge, don't forget to commit)
352 354 $ aftermerge
353 355 # cat f
354 356 revision 1
355 357 space
356 358 # hg stat
357 359 M f
358 360 # hg resolve --list
359 361 R f
360 362
361 363 executable set to python script that fails:
362 364
363 365 $ cat > "$TESTTMP/mybrokenmerge.py" <<EOF
364 366 > def mybrokenmergefn(ui, repo, args, **kwargs):
365 367 > ui.write(b"some fail message\n")
366 368 > return True
367 369 > EOF
368 370 $ beforemerge
369 371 [merge-tools]
370 372 false.whatever=
371 373 true.priority=1
372 374 true.executable=cat
373 375 # hg update -C 1
374 376 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/mybrokenmerge.py:mybrokenmergefn"
375 377 merging f
376 378 some fail message
377 379 abort: $TESTTMP/mybrokenmerge.py hook failed
378 380 [255]
379 381 $ aftermerge
380 382 # cat f
381 383 revision 1
382 384 space
383 385 # hg stat
384 386 ? f.orig
385 387 # hg resolve --list
386 388 U f
387 389
388 390 executable set to python script that is missing function:
389 391
390 392 $ beforemerge
391 393 [merge-tools]
392 394 false.whatever=
393 395 true.priority=1
394 396 true.executable=cat
395 397 # hg update -C 1
396 398 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/myworkingmerge.py:missingFunction"
397 399 merging f
398 400 abort: $TESTTMP/myworkingmerge.py does not have function: missingFunction
399 401 [255]
400 402 $ aftermerge
401 403 # cat f
402 404 revision 1
403 405 space
404 406 # hg stat
405 407 ? f.orig
406 408 # hg resolve --list
407 409 U f
408 410
409 411 executable set to missing python script:
410 412
411 413 $ beforemerge
412 414 [merge-tools]
413 415 false.whatever=
414 416 true.priority=1
415 417 true.executable=cat
416 418 # hg update -C 1
417 419 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/missingpythonscript.py:mergefn"
418 420 merging f
419 421 abort: loading python merge script failed: $TESTTMP/missingpythonscript.py
420 422 [255]
421 423 $ aftermerge
422 424 # cat f
423 425 revision 1
424 426 space
425 427 # hg stat
426 428 ? f.orig
427 429 # hg resolve --list
428 430 U f
429 431
430 432 executable set to python script but callable function is missing:
431 433
432 434 $ beforemerge
433 435 [merge-tools]
434 436 false.whatever=
435 437 true.priority=1
436 438 true.executable=cat
437 439 # hg update -C 1
438 440 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/myworkingmerge.py"
439 441 abort: invalid 'python:' syntax: python:$TESTTMP/myworkingmerge.py
440 442 [255]
441 443 $ aftermerge
442 444 # cat f
443 445 revision 1
444 446 space
445 447 # hg stat
446 448 # hg resolve --list
447 449 U f
448 450
449 451 executable set to python script but callable function is empty string:
450 452
451 453 $ beforemerge
452 454 [merge-tools]
453 455 false.whatever=
454 456 true.priority=1
455 457 true.executable=cat
456 458 # hg update -C 1
457 459 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/myworkingmerge.py:"
458 460 abort: invalid 'python:' syntax: python:$TESTTMP/myworkingmerge.py:
459 461 [255]
460 462 $ aftermerge
461 463 # cat f
462 464 revision 1
463 465 space
464 466 # hg stat
465 467 # hg resolve --list
466 468 U f
467 469
468 470 executable set to python script but callable function is missing and path contains colon:
469 471
470 472 $ beforemerge
471 473 [merge-tools]
472 474 false.whatever=
473 475 true.priority=1
474 476 true.executable=cat
475 477 # hg update -C 1
476 478 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/some:dir/myworkingmerge.py"
477 479 abort: invalid 'python:' syntax: python:$TESTTMP/some:dir/myworkingmerge.py
478 480 [255]
479 481 $ aftermerge
480 482 # cat f
481 483 revision 1
482 484 space
483 485 # hg stat
484 486 # hg resolve --list
485 487 U f
486 488
487 489 executable set to python script filename that contains spaces:
488 490
489 491 $ mkdir -p "$TESTTMP/my path"
490 492 $ cat > "$TESTTMP/my path/my working merge with spaces in filename.py" <<EOF
491 493 > def myworkingmergefn(ui, repo, args, **kwargs):
492 494 > return False
493 495 > EOF
494 496 $ beforemerge
495 497 [merge-tools]
496 498 false.whatever=
497 499 true.priority=1
498 500 true.executable=cat
499 501 # hg update -C 1
500 502 $ hg merge -r 2 --config "merge-tools.true.executable=python:$TESTTMP/my path/my working merge with spaces in filename.py:myworkingmergefn"
501 503 merging f
502 504 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
503 505 (branch merge, don't forget to commit)
504 506 $ aftermerge
505 507 # cat f
506 508 revision 1
507 509 space
508 510 # hg stat
509 511 M f
510 512 # hg resolve --list
511 513 R f
512 514
513 515 #if unix-permissions
514 516
515 517 environment variables in true.executable are handled:
516 518
517 519 $ echo 'echo "custom merge tool"' > .hg/merge.sh
518 520 $ beforemerge
519 521 [merge-tools]
520 522 false.whatever=
521 523 true.priority=1
522 524 true.executable=cat
523 525 # hg update -C 1
524 526 $ hg --config merge-tools.true.executable='sh' \
525 527 > --config merge-tools.true.args=.hg/merge.sh \
526 528 > merge -r 2
527 529 merging f
528 530 custom merge tool
529 531 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
530 532 (branch merge, don't forget to commit)
531 533 $ aftermerge
532 534 # cat f
533 535 revision 1
534 536 space
535 537 # hg stat
536 538 M f
537 539 # hg resolve --list
538 540 R f
539 541
540 542 #endif
541 543
542 544 Tool selection and merge-patterns
543 545
544 546 merge-patterns specifies new tool false:
545 547
546 548 $ beforemerge
547 549 [merge-tools]
548 550 false.whatever=
549 551 true.priority=1
550 552 true.executable=cat
551 553 # hg update -C 1
552 554 $ hg merge -r 2 --config merge-patterns.f=false
553 555 merging f
554 556 merging f failed!
555 557 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
556 558 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
557 559 [1]
558 560 $ aftermerge
559 561 # cat f
560 562 revision 1
561 563 space
562 564 # hg stat
563 565 M f
564 566 ? f.orig
565 567 # hg resolve --list
566 568 U f
567 569
568 570 merge-patterns specifies executable not found in PATH and gets warning:
569 571
570 572 $ beforemerge
571 573 [merge-tools]
572 574 false.whatever=
573 575 true.priority=1
574 576 true.executable=cat
575 577 # hg update -C 1
576 578 $ hg merge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=nonexistentmergetool
577 579 couldn't find merge tool true (for pattern f)
578 580 merging f
579 581 couldn't find merge tool true (for pattern f)
580 582 merging f failed!
581 583 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
582 584 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
583 585 [1]
584 586 $ aftermerge
585 587 # cat f
586 588 revision 1
587 589 space
588 590 # hg stat
589 591 M f
590 592 ? f.orig
591 593 # hg resolve --list
592 594 U f
593 595
594 596 merge-patterns specifies executable with bogus path and gets warning:
595 597
596 598 $ beforemerge
597 599 [merge-tools]
598 600 false.whatever=
599 601 true.priority=1
600 602 true.executable=cat
601 603 # hg update -C 1
602 604 $ hg merge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=/nonexistent/mergetool
603 605 couldn't find merge tool true (for pattern f)
604 606 merging f
605 607 couldn't find merge tool true (for pattern f)
606 608 merging f failed!
607 609 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
608 610 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
609 611 [1]
610 612 $ aftermerge
611 613 # cat f
612 614 revision 1
613 615 space
614 616 # hg stat
615 617 M f
616 618 ? f.orig
617 619 # hg resolve --list
618 620 U f
619 621
620 622 ui.merge overrules priority
621 623
622 624 ui.merge specifies false:
623 625
624 626 $ beforemerge
625 627 [merge-tools]
626 628 false.whatever=
627 629 true.priority=1
628 630 true.executable=cat
629 631 # hg update -C 1
630 632 $ hg merge -r 2 --config ui.merge=false
631 633 merging f
632 634 merging f failed!
633 635 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
634 636 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
635 637 [1]
636 638 $ aftermerge
637 639 # cat f
638 640 revision 1
639 641 space
640 642 # hg stat
641 643 M f
642 644 ? f.orig
643 645 # hg resolve --list
644 646 U f
645 647
646 648 ui.merge specifies internal:fail:
647 649
648 650 $ beforemerge
649 651 [merge-tools]
650 652 false.whatever=
651 653 true.priority=1
652 654 true.executable=cat
653 655 # hg update -C 1
654 656 $ hg merge -r 2 --config ui.merge=internal:fail
655 657 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
656 658 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
657 659 [1]
658 660 $ aftermerge
659 661 # cat f
660 662 revision 1
661 663 space
662 664 # hg stat
663 665 M f
664 666 # hg resolve --list
665 667 U f
666 668
667 669 ui.merge specifies :local (without internal prefix):
668 670
669 671 $ beforemerge
670 672 [merge-tools]
671 673 false.whatever=
672 674 true.priority=1
673 675 true.executable=cat
674 676 # hg update -C 1
675 677 $ hg merge -r 2 --config ui.merge=:local
676 678 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
677 679 (branch merge, don't forget to commit)
678 680 $ aftermerge
679 681 # cat f
680 682 revision 1
681 683 space
682 684 # hg stat
683 685 M f
684 686 # hg resolve --list
685 687 R f
686 688
687 689 ui.merge specifies internal:other:
688 690
689 691 $ beforemerge
690 692 [merge-tools]
691 693 false.whatever=
692 694 true.priority=1
693 695 true.executable=cat
694 696 # hg update -C 1
695 697 $ hg merge -r 2 --config ui.merge=internal:other
696 698 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
697 699 (branch merge, don't forget to commit)
698 700 $ aftermerge
699 701 # cat f
700 702 revision 2
701 703 space
702 704 # hg stat
703 705 M f
704 706 # hg resolve --list
705 707 R f
706 708
707 709 ui.merge specifies internal:prompt:
708 710
709 711 $ beforemerge
710 712 [merge-tools]
711 713 false.whatever=
712 714 true.priority=1
713 715 true.executable=cat
714 716 # hg update -C 1
715 717 $ hg merge -r 2 --config ui.merge=internal:prompt
716 718 file 'f' needs to be resolved.
717 719 You can keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved.
718 720 What do you want to do? u
719 721 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
720 722 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
721 723 [1]
722 724 $ aftermerge
723 725 # cat f
724 726 revision 1
725 727 space
726 728 # hg stat
727 729 M f
728 730 # hg resolve --list
729 731 U f
730 732
731 733 ui.merge specifies :prompt, with 'leave unresolved' chosen
732 734
733 735 $ beforemerge
734 736 [merge-tools]
735 737 false.whatever=
736 738 true.priority=1
737 739 true.executable=cat
738 740 # hg update -C 1
739 741 $ hg merge -r 2 --config ui.merge=:prompt --config ui.interactive=True << EOF
740 742 > u
741 743 > EOF
742 744 file 'f' needs to be resolved.
743 745 You can keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved.
744 746 What do you want to do? u
745 747 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
746 748 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
747 749 [1]
748 750 $ aftermerge
749 751 # cat f
750 752 revision 1
751 753 space
752 754 # hg stat
753 755 M f
754 756 # hg resolve --list
755 757 U f
756 758
757 759 prompt with EOF
758 760
759 761 $ beforemerge
760 762 [merge-tools]
761 763 false.whatever=
762 764 true.priority=1
763 765 true.executable=cat
764 766 # hg update -C 1
765 767 $ hg merge -r 2 --config ui.merge=internal:prompt --config ui.interactive=true
766 768 file 'f' needs to be resolved.
767 769 You can keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved.
768 770 What do you want to do?
769 771 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
770 772 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
771 773 [1]
772 774 $ aftermerge
773 775 # cat f
774 776 revision 1
775 777 space
776 778 # hg stat
777 779 M f
778 780 # hg resolve --list
779 781 U f
780 782 $ hg resolve --all --config ui.merge=internal:prompt --config ui.interactive=true
781 783 file 'f' needs to be resolved.
782 784 You can keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved.
783 785 What do you want to do?
784 786 [1]
785 787 $ aftermerge
786 788 # cat f
787 789 revision 1
788 790 space
789 791 # hg stat
790 792 M f
791 793 ? f.orig
792 794 # hg resolve --list
793 795 U f
794 796 $ rm f
795 797 $ hg resolve --all --config ui.merge=internal:prompt --config ui.interactive=true
796 798 file 'f' needs to be resolved.
797 799 You can keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved.
798 800 What do you want to do?
799 801 [1]
800 802 $ aftermerge
801 803 # cat f
802 804 revision 1
803 805 space
804 806 # hg stat
805 807 M f
806 808 # hg resolve --list
807 809 U f
808 810 $ hg resolve --all --config ui.merge=internal:prompt
809 811 file 'f' needs to be resolved.
810 812 You can keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved.
811 813 What do you want to do? u
812 814 [1]
813 815 $ aftermerge
814 816 # cat f
815 817 revision 1
816 818 space
817 819 # hg stat
818 820 M f
819 821 ? f.orig
820 822 # hg resolve --list
821 823 U f
822 824
823 825 ui.merge specifies internal:dump:
824 826
825 827 $ beforemerge
826 828 [merge-tools]
827 829 false.whatever=
828 830 true.priority=1
829 831 true.executable=cat
830 832 # hg update -C 1
831 833 $ hg merge -r 2 --config ui.merge=internal:dump
832 834 merging f
833 835 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
834 836 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
835 837 [1]
836 838 $ aftermerge
837 839 # cat f
838 840 revision 1
839 841 space
840 842 # hg stat
841 843 M f
842 844 ? f.base
843 845 ? f.local
844 846 ? f.orig
845 847 ? f.other
846 848 # hg resolve --list
847 849 U f
848 850
849 851 f.base:
850 852
851 853 $ cat f.base
852 854 revision 0
853 855 space
854 856
855 857 f.local:
856 858
857 859 $ cat f.local
858 860 revision 1
859 861 space
860 862
861 863 f.other:
862 864
863 865 $ cat f.other
864 866 revision 2
865 867 space
866 868 $ rm f.base f.local f.other
867 869
868 870 check that internal:dump doesn't dump files if premerge runs
869 871 successfully
870 872
871 873 $ beforemerge
872 874 [merge-tools]
873 875 false.whatever=
874 876 true.priority=1
875 877 true.executable=cat
876 878 # hg update -C 1
877 879 $ hg merge -r 3 --config ui.merge=internal:dump
878 880 merging f
879 881 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
880 882 (branch merge, don't forget to commit)
881 883
882 884 $ aftermerge
883 885 # cat f
884 886 revision 1
885 887 space
886 888 revision 3
887 889 # hg stat
888 890 M f
889 891 # hg resolve --list
890 892 R f
891 893
892 894 check that internal:forcedump dumps files, even if local and other can
893 895 be merged easily
894 896
895 897 $ beforemerge
896 898 [merge-tools]
897 899 false.whatever=
898 900 true.priority=1
899 901 true.executable=cat
900 902 # hg update -C 1
901 903 $ hg merge -r 3 --config ui.merge=internal:forcedump
902 904 merging f
903 905 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
904 906 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
905 907 [1]
906 908 $ aftermerge
907 909 # cat f
908 910 revision 1
909 911 space
910 912 # hg stat
911 913 M f
912 914 ? f.base
913 915 ? f.local
914 916 ? f.orig
915 917 ? f.other
916 918 # hg resolve --list
917 919 U f
918 920
919 921 $ cat f.base
920 922 revision 0
921 923 space
922 924
923 925 $ cat f.local
924 926 revision 1
925 927 space
926 928
927 929 $ cat f.other
928 930 revision 0
929 931 space
930 932 revision 3
931 933
932 934 $ rm -f f.base f.local f.other
933 935
934 936 ui.merge specifies internal:other but is overruled by pattern for false:
935 937
936 938 $ beforemerge
937 939 [merge-tools]
938 940 false.whatever=
939 941 true.priority=1
940 942 true.executable=cat
941 943 # hg update -C 1
942 944 $ hg merge -r 2 --config ui.merge=internal:other --config merge-patterns.f=false
943 945 merging f
944 946 merging f failed!
945 947 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
946 948 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
947 949 [1]
948 950 $ aftermerge
949 951 # cat f
950 952 revision 1
951 953 space
952 954 # hg stat
953 955 M f
954 956 ? f.orig
955 957 # hg resolve --list
956 958 U f
957 959
958 960 Premerge
959 961
960 962 ui.merge specifies internal:other but is overruled by --tool=false
961 963
962 964 $ beforemerge
963 965 [merge-tools]
964 966 false.whatever=
965 967 true.priority=1
966 968 true.executable=cat
967 969 # hg update -C 1
968 970 $ hg merge -r 2 --config ui.merge=internal:other --tool=false
969 971 merging f
970 972 merging f failed!
971 973 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
972 974 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
973 975 [1]
974 976 $ aftermerge
975 977 # cat f
976 978 revision 1
977 979 space
978 980 # hg stat
979 981 M f
980 982 ? f.orig
981 983 # hg resolve --list
982 984 U f
983 985
984 986 HGMERGE specifies internal:other but is overruled by --tool=false
985 987
986 988 $ HGMERGE=internal:other ; export HGMERGE
987 989 $ beforemerge
988 990 [merge-tools]
989 991 false.whatever=
990 992 true.priority=1
991 993 true.executable=cat
992 994 # hg update -C 1
993 995 $ hg merge -r 2 --tool=false
994 996 merging f
995 997 merging f failed!
996 998 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
997 999 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
998 1000 [1]
999 1001 $ aftermerge
1000 1002 # cat f
1001 1003 revision 1
1002 1004 space
1003 1005 # hg stat
1004 1006 M f
1005 1007 ? f.orig
1006 1008 # hg resolve --list
1007 1009 U f
1008 1010
1009 1011 $ unset HGMERGE # make sure HGMERGE doesn't interfere with remaining tests
1010 1012
1011 1013 update is a merge ...
1012 1014
1013 1015 (this also tests that files reverted with '--rev REV' are treated as
1014 1016 "modified", even if none of mode, size and timestamp of them isn't
1015 1017 changed on the filesystem (see also issue4583))
1016 1018
1017 1019 $ cat >> $HGRCPATH <<EOF
1018 1020 > [fakedirstatewritetime]
1019 1021 > # emulate invoking dirstate.write() via repo.status()
1020 1022 > # at 2000-01-01 00:00
1021 1023 > fakenow = 200001010000
1022 1024 > EOF
1023 1025
1024 1026 $ beforemerge
1025 1027 [merge-tools]
1026 1028 false.whatever=
1027 1029 true.priority=1
1028 1030 true.executable=cat
1029 1031 # hg update -C 1
1030 1032 $ hg update -q 0
1031 1033 $ f -s f
1032 1034 f: size=17
1033 1035 $ touch -t 200001010000 f
1034 1036 $ hg debugrebuildstate
1035 1037 $ cat >> $HGRCPATH <<EOF
1036 1038 > [extensions]
1037 1039 > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py
1038 1040 > EOF
1039 1041 $ hg revert -q -r 1 .
1040 1042 $ cat >> $HGRCPATH <<EOF
1041 1043 > [extensions]
1042 1044 > fakedirstatewritetime = !
1043 1045 > EOF
1044 1046 $ f -s f
1045 1047 f: size=17
1046 1048 $ touch -t 200001010000 f
1047 1049 $ hg status f
1048 1050 M f
1049 1051 $ hg update -r 2
1050 1052 merging f
1051 1053 revision 1
1052 1054 space
1053 1055 revision 0
1054 1056 space
1055 1057 revision 2
1056 1058 space
1057 1059 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1058 1060 $ aftermerge
1059 1061 # cat f
1060 1062 revision 1
1061 1063 space
1062 1064 # hg stat
1063 1065 M f
1064 1066 # hg resolve --list
1065 1067 R f
1066 1068
1067 1069 update should also have --tool
1068 1070
1069 1071 $ beforemerge
1070 1072 [merge-tools]
1071 1073 false.whatever=
1072 1074 true.priority=1
1073 1075 true.executable=cat
1074 1076 # hg update -C 1
1075 1077 $ hg update -q 0
1076 1078 $ f -s f
1077 1079 f: size=17
1078 1080 $ touch -t 200001010000 f
1079 1081 $ hg debugrebuildstate
1080 1082 $ cat >> $HGRCPATH <<EOF
1081 1083 > [extensions]
1082 1084 > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py
1083 1085 > EOF
1084 1086 $ hg revert -q -r 1 .
1085 1087 $ cat >> $HGRCPATH <<EOF
1086 1088 > [extensions]
1087 1089 > fakedirstatewritetime = !
1088 1090 > EOF
1089 1091 $ f -s f
1090 1092 f: size=17
1091 1093 $ touch -t 200001010000 f
1092 1094 $ hg status f
1093 1095 M f
1094 1096 $ hg update -r 2 --tool false
1095 1097 merging f
1096 1098 merging f failed!
1097 1099 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1098 1100 use 'hg resolve' to retry unresolved file merges
1099 1101 [1]
1100 1102 $ aftermerge
1101 1103 # cat f
1102 1104 revision 1
1103 1105 space
1104 1106 # hg stat
1105 1107 M f
1106 1108 ? f.orig
1107 1109 # hg resolve --list
1108 1110 U f
1109 1111
1110 1112 Default is silent simplemerge:
1111 1113
1112 1114 $ beforemerge
1113 1115 [merge-tools]
1114 1116 false.whatever=
1115 1117 true.priority=1
1116 1118 true.executable=cat
1117 1119 # hg update -C 1
1118 1120 $ hg merge -r 3
1119 1121 merging f
1120 1122 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1121 1123 (branch merge, don't forget to commit)
1122 1124 $ aftermerge
1123 1125 # cat f
1124 1126 revision 1
1125 1127 space
1126 1128 revision 3
1127 1129 # hg stat
1128 1130 M f
1129 1131 # hg resolve --list
1130 1132 R f
1131 1133
1132 1134 .premerge=True is same:
1133 1135
1134 1136 $ beforemerge
1135 1137 [merge-tools]
1136 1138 false.whatever=
1137 1139 true.priority=1
1138 1140 true.executable=cat
1139 1141 # hg update -C 1
1140 1142 $ hg merge -r 3 --config merge-tools.true.premerge=True
1141 1143 merging f
1142 1144 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1143 1145 (branch merge, don't forget to commit)
1144 1146 $ aftermerge
1145 1147 # cat f
1146 1148 revision 1
1147 1149 space
1148 1150 revision 3
1149 1151 # hg stat
1150 1152 M f
1151 1153 # hg resolve --list
1152 1154 R f
1153 1155
1154 1156 .premerge=False executes merge-tool:
1155 1157
1156 1158 $ beforemerge
1157 1159 [merge-tools]
1158 1160 false.whatever=
1159 1161 true.priority=1
1160 1162 true.executable=cat
1161 1163 # hg update -C 1
1162 1164 $ hg merge -r 3 --config merge-tools.true.premerge=False
1163 1165 merging f
1164 1166 revision 1
1165 1167 space
1166 1168 revision 0
1167 1169 space
1168 1170 revision 0
1169 1171 space
1170 1172 revision 3
1171 1173 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1172 1174 (branch merge, don't forget to commit)
1173 1175 $ aftermerge
1174 1176 # cat f
1175 1177 revision 1
1176 1178 space
1177 1179 # hg stat
1178 1180 M f
1179 1181 # hg resolve --list
1180 1182 R f
1181 1183
1182 1184 premerge=keep keeps conflict markers in:
1183 1185
1184 1186 $ beforemerge
1185 1187 [merge-tools]
1186 1188 false.whatever=
1187 1189 true.priority=1
1188 1190 true.executable=cat
1189 1191 # hg update -C 1
1190 1192 $ hg merge -r 4 --config merge-tools.true.premerge=keep
1191 1193 merging f
1192 1194 <<<<<<< working copy: ef83787e2614 - test: revision 1
1193 1195 revision 1
1194 1196 space
1195 1197 =======
1196 1198 revision 4
1197 1199 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1198 1200 revision 0
1199 1201 space
1200 1202 revision 4
1201 1203 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1202 1204 (branch merge, don't forget to commit)
1203 1205 $ aftermerge
1204 1206 # cat f
1205 1207 <<<<<<< working copy: ef83787e2614 - test: revision 1
1206 1208 revision 1
1207 1209 space
1208 1210 =======
1209 1211 revision 4
1210 1212 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1211 1213 # hg stat
1212 1214 M f
1213 1215 # hg resolve --list
1214 1216 R f
1215 1217
1216 1218 premerge=keep-merge3 keeps conflict markers with base content:
1217 1219
1218 1220 $ beforemerge
1219 1221 [merge-tools]
1220 1222 false.whatever=
1221 1223 true.priority=1
1222 1224 true.executable=cat
1223 1225 # hg update -C 1
1224 1226 $ hg merge -r 4 --config merge-tools.true.premerge=keep-merge3
1225 1227 merging f
1226 1228 <<<<<<< working copy: ef83787e2614 - test: revision 1
1227 1229 revision 1
1228 1230 space
1229 1231 ||||||| base
1230 1232 revision 0
1231 1233 space
1232 1234 =======
1233 1235 revision 4
1234 1236 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1235 1237 revision 0
1236 1238 space
1237 1239 revision 4
1238 1240 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1239 1241 (branch merge, don't forget to commit)
1240 1242 $ aftermerge
1241 1243 # cat f
1242 1244 <<<<<<< working copy: ef83787e2614 - test: revision 1
1243 1245 revision 1
1244 1246 space
1245 1247 ||||||| base
1246 1248 revision 0
1247 1249 space
1248 1250 =======
1249 1251 revision 4
1250 1252 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1251 1253 # hg stat
1252 1254 M f
1253 1255 # hg resolve --list
1254 1256 R f
1255 1257
1256 1258 premerge=keep respects ui.mergemarkers=basic:
1257 1259
1258 1260 $ beforemerge
1259 1261 [merge-tools]
1260 1262 false.whatever=
1261 1263 true.priority=1
1262 1264 true.executable=cat
1263 1265 # hg update -C 1
1264 1266 $ hg merge -r 4 --config merge-tools.true.premerge=keep --config ui.mergemarkers=basic
1265 1267 merging f
1266 1268 <<<<<<< working copy
1267 1269 revision 1
1268 1270 space
1269 1271 =======
1270 1272 revision 4
1271 1273 >>>>>>> merge rev
1272 1274 revision 0
1273 1275 space
1274 1276 revision 4
1275 1277 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1276 1278 (branch merge, don't forget to commit)
1277 1279 $ aftermerge
1278 1280 # cat f
1279 1281 <<<<<<< working copy
1280 1282 revision 1
1281 1283 space
1282 1284 =======
1283 1285 revision 4
1284 1286 >>>>>>> merge rev
1285 1287 # hg stat
1286 1288 M f
1287 1289 # hg resolve --list
1288 1290 R f
1289 1291
1290 1292 premerge=keep ignores ui.mergemarkers=basic if true.mergemarkers=detailed:
1291 1293
1292 1294 $ beforemerge
1293 1295 [merge-tools]
1294 1296 false.whatever=
1295 1297 true.priority=1
1296 1298 true.executable=cat
1297 1299 # hg update -C 1
1298 1300 $ hg merge -r 4 --config merge-tools.true.premerge=keep \
1299 1301 > --config ui.mergemarkers=basic \
1300 1302 > --config merge-tools.true.mergemarkers=detailed
1301 1303 merging f
1302 1304 <<<<<<< working copy: ef83787e2614 - test: revision 1
1303 1305 revision 1
1304 1306 space
1305 1307 =======
1306 1308 revision 4
1307 1309 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1308 1310 revision 0
1309 1311 space
1310 1312 revision 4
1311 1313 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1312 1314 (branch merge, don't forget to commit)
1313 1315 $ aftermerge
1314 1316 # cat f
1315 1317 <<<<<<< working copy: ef83787e2614 - test: revision 1
1316 1318 revision 1
1317 1319 space
1318 1320 =======
1319 1321 revision 4
1320 1322 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1321 1323 # hg stat
1322 1324 M f
1323 1325 # hg resolve --list
1324 1326 R f
1325 1327
1326 1328 premerge=keep respects ui.mergemarkertemplate instead of
1327 1329 true.mergemarkertemplate if true.mergemarkers=basic:
1328 1330
1329 1331 $ beforemerge
1330 1332 [merge-tools]
1331 1333 false.whatever=
1332 1334 true.priority=1
1333 1335 true.executable=cat
1334 1336 # hg update -C 1
1335 1337 $ hg merge -r 4 --config merge-tools.true.premerge=keep \
1336 1338 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1337 1339 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}'
1338 1340 merging f
1339 1341 <<<<<<< working copy: uitmpl 1
1340 1342 revision 1
1341 1343 space
1342 1344 =======
1343 1345 revision 4
1344 1346 >>>>>>> merge rev: uitmpl 4
1345 1347 revision 0
1346 1348 space
1347 1349 revision 4
1348 1350 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1349 1351 (branch merge, don't forget to commit)
1350 1352 $ aftermerge
1351 1353 # cat f
1352 1354 <<<<<<< working copy: uitmpl 1
1353 1355 revision 1
1354 1356 space
1355 1357 =======
1356 1358 revision 4
1357 1359 >>>>>>> merge rev: uitmpl 4
1358 1360 # hg stat
1359 1361 M f
1360 1362 # hg resolve --list
1361 1363 R f
1362 1364
1363 1365 premerge=keep respects true.mergemarkertemplate instead of
1364 1366 true.mergemarkertemplate if true.mergemarkers=detailed:
1365 1367
1366 1368 $ beforemerge
1367 1369 [merge-tools]
1368 1370 false.whatever=
1369 1371 true.priority=1
1370 1372 true.executable=cat
1371 1373 # hg update -C 1
1372 1374 $ hg merge -r 4 --config merge-tools.true.premerge=keep \
1373 1375 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1374 1376 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1375 1377 > --config merge-tools.true.mergemarkers=detailed
1376 1378 merging f
1377 1379 <<<<<<< working copy: tooltmpl ef83787e2614
1378 1380 revision 1
1379 1381 space
1380 1382 =======
1381 1383 revision 4
1382 1384 >>>>>>> merge rev: tooltmpl 81448d39c9a0
1383 1385 revision 0
1384 1386 space
1385 1387 revision 4
1386 1388 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1387 1389 (branch merge, don't forget to commit)
1388 1390 $ aftermerge
1389 1391 # cat f
1390 1392 <<<<<<< working copy: tooltmpl ef83787e2614
1391 1393 revision 1
1392 1394 space
1393 1395 =======
1394 1396 revision 4
1395 1397 >>>>>>> merge rev: tooltmpl 81448d39c9a0
1396 1398 # hg stat
1397 1399 M f
1398 1400 # hg resolve --list
1399 1401 R f
1400 1402
1401 1403 Tool execution
1402 1404
1403 1405 set tools.args explicit to include $base $local $other $output:
1404 1406
1405 1407 $ beforemerge
1406 1408 [merge-tools]
1407 1409 false.whatever=
1408 1410 true.priority=1
1409 1411 true.executable=cat
1410 1412 # hg update -C 1
1411 1413 $ hg merge -r 2 --config merge-tools.true.executable=head --config merge-tools.true.args='$base $local $other $output' \
1412 1414 > | sed 's,==> .* <==,==> ... <==,g'
1413 1415 merging f
1414 1416 ==> ... <==
1415 1417 revision 0
1416 1418 space
1417 1419
1418 1420 ==> ... <==
1419 1421 revision 1
1420 1422 space
1421 1423
1422 1424 ==> ... <==
1423 1425 revision 2
1424 1426 space
1425 1427
1426 1428 ==> ... <==
1427 1429 revision 1
1428 1430 space
1429 1431 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1430 1432 (branch merge, don't forget to commit)
1431 1433 $ aftermerge
1432 1434 # cat f
1433 1435 revision 1
1434 1436 space
1435 1437 # hg stat
1436 1438 M f
1437 1439 # hg resolve --list
1438 1440 R f
1439 1441
1440 1442 Merge with "echo mergeresult > $local":
1441 1443
1442 1444 $ beforemerge
1443 1445 [merge-tools]
1444 1446 false.whatever=
1445 1447 true.priority=1
1446 1448 true.executable=cat
1447 1449 # hg update -C 1
1448 1450 $ hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > $local'
1449 1451 merging f
1450 1452 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1451 1453 (branch merge, don't forget to commit)
1452 1454 $ aftermerge
1453 1455 # cat f
1454 1456 mergeresult
1455 1457 # hg stat
1456 1458 M f
1457 1459 # hg resolve --list
1458 1460 R f
1459 1461
1460 1462 - and $local is the file f:
1461 1463
1462 1464 $ beforemerge
1463 1465 [merge-tools]
1464 1466 false.whatever=
1465 1467 true.priority=1
1466 1468 true.executable=cat
1467 1469 # hg update -C 1
1468 1470 $ hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > f'
1469 1471 merging f
1470 1472 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1471 1473 (branch merge, don't forget to commit)
1472 1474 $ aftermerge
1473 1475 # cat f
1474 1476 mergeresult
1475 1477 # hg stat
1476 1478 M f
1477 1479 # hg resolve --list
1478 1480 R f
1479 1481
1480 1482 Merge with "echo mergeresult > $output" - the variable is a bit magic:
1481 1483
1482 1484 $ beforemerge
1483 1485 [merge-tools]
1484 1486 false.whatever=
1485 1487 true.priority=1
1486 1488 true.executable=cat
1487 1489 # hg update -C 1
1488 1490 $ hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > $output'
1489 1491 merging f
1490 1492 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1491 1493 (branch merge, don't forget to commit)
1492 1494 $ aftermerge
1493 1495 # cat f
1494 1496 mergeresult
1495 1497 # hg stat
1496 1498 M f
1497 1499 # hg resolve --list
1498 1500 R f
1499 1501
1500 1502 Merge using tool with a path that must be quoted:
1501 1503
1502 1504 $ beforemerge
1503 1505 [merge-tools]
1504 1506 false.whatever=
1505 1507 true.priority=1
1506 1508 true.executable=cat
1507 1509 # hg update -C 1
1508 1510 $ cat <<EOF > 'my merge tool'
1509 1511 > cat "\$1" "\$2" "\$3" > "\$4"
1510 1512 > EOF
1511 1513 $ hg --config merge-tools.true.executable='sh' \
1512 1514 > --config merge-tools.true.args='"./my merge tool" $base $local $other $output' \
1513 1515 > merge -r 2
1514 1516 merging f
1515 1517 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1516 1518 (branch merge, don't forget to commit)
1517 1519 $ rm -f 'my merge tool'
1518 1520 $ aftermerge
1519 1521 # cat f
1520 1522 revision 0
1521 1523 space
1522 1524 revision 1
1523 1525 space
1524 1526 revision 2
1525 1527 space
1526 1528 # hg stat
1527 1529 M f
1528 1530 # hg resolve --list
1529 1531 R f
1530 1532
1531 1533 Merge using a tool that supports labellocal, labelother, and labelbase, checking
1532 1534 that they're quoted properly as well. This is using the default 'basic'
1533 1535 mergemarkers even though ui.mergemarkers is 'detailed', so it's ignoring both
1534 1536 mergemarkertemplate settings:
1535 1537
1536 1538 $ beforemerge
1537 1539 [merge-tools]
1538 1540 false.whatever=
1539 1541 true.priority=1
1540 1542 true.executable=cat
1541 1543 # hg update -C 1
1542 1544 $ cat <<EOF > printargs_merge_tool
1543 1545 > while test \$# -gt 0; do echo arg: \"\$1\"; shift; done
1544 1546 > EOF
1545 1547 $ hg --config merge-tools.true.executable='sh' \
1546 1548 > --config merge-tools.true.args='./printargs_merge_tool ll:$labellocal lo: $labelother lb:$labelbase": "$base' \
1547 1549 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1548 1550 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1549 1551 > --config ui.mergemarkers=detailed \
1550 1552 > merge -r 2
1551 1553 merging f
1552 1554 arg: "ll:working copy"
1553 1555 arg: "lo:"
1554 1556 arg: "merge rev"
1555 1557 arg: "lb:base: */f~base.*" (glob)
1556 1558 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1557 1559 (branch merge, don't forget to commit)
1558 1560 $ rm -f 'printargs_merge_tool'
1559 1561
1560 1562 Same test with experimental.mergetempdirprefix set:
1561 1563
1562 1564 $ beforemerge
1563 1565 [merge-tools]
1564 1566 false.whatever=
1565 1567 true.priority=1
1566 1568 true.executable=cat
1567 1569 # hg update -C 1
1568 1570 $ cat <<EOF > printargs_merge_tool
1569 1571 > while test \$# -gt 0; do echo arg: \"\$1\"; shift; done
1570 1572 > EOF
1571 1573 $ hg --config experimental.mergetempdirprefix=$TESTTMP/hgmerge. \
1572 1574 > --config merge-tools.true.executable='sh' \
1573 1575 > --config merge-tools.true.args='./printargs_merge_tool ll:$labellocal lo: $labelother lb:$labelbase": "$base' \
1574 1576 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1575 1577 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1576 1578 > --config ui.mergemarkers=detailed \
1577 1579 > merge -r 2
1578 1580 merging f
1579 1581 arg: "ll:working copy"
1580 1582 arg: "lo:"
1581 1583 arg: "merge rev"
1582 1584 arg: "lb:base: */hgmerge.*/f~base" (glob)
1583 1585 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1584 1586 (branch merge, don't forget to commit)
1585 1587 $ rm -f 'printargs_merge_tool'
1586 1588
1587 1589 Merge using a tool that supports labellocal, labelother, and labelbase, checking
1588 1590 that they're quoted properly as well. This is using 'detailed' mergemarkers,
1589 1591 even though ui.mergemarkers is 'basic', and using the tool's
1590 1592 mergemarkertemplate:
1591 1593
1592 1594 $ beforemerge
1593 1595 [merge-tools]
1594 1596 false.whatever=
1595 1597 true.priority=1
1596 1598 true.executable=cat
1597 1599 # hg update -C 1
1598 1600 $ cat <<EOF > printargs_merge_tool
1599 1601 > while test \$# -gt 0; do echo arg: \"\$1\"; shift; done
1600 1602 > EOF
1601 1603 $ hg --config merge-tools.true.executable='sh' \
1602 1604 > --config merge-tools.true.args='./printargs_merge_tool ll:$labellocal lo: $labelother lb:$labelbase": "$base' \
1603 1605 > --config merge-tools.true.mergemarkers=detailed \
1604 1606 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1605 1607 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1606 1608 > --config ui.mergemarkers=basic \
1607 1609 > merge -r 2
1608 1610 merging f
1609 1611 arg: "ll:working copy: tooltmpl ef83787e2614"
1610 1612 arg: "lo:"
1611 1613 arg: "merge rev: tooltmpl 0185f4e0cf02"
1612 1614 arg: "lb:base: */f~base.*" (glob)
1613 1615 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1614 1616 (branch merge, don't forget to commit)
1615 1617 $ rm -f 'printargs_merge_tool'
1616 1618
1617 1619 The merge tool still gets labellocal and labelother as 'basic' even when
1618 1620 premerge=keep is used and has 'detailed' markers:
1619 1621
1620 1622 $ beforemerge
1621 1623 [merge-tools]
1622 1624 false.whatever=
1623 1625 true.priority=1
1624 1626 true.executable=cat
1625 1627 # hg update -C 1
1626 1628 $ cat <<EOF > mytool
1627 1629 > echo labellocal: \"\$1\"
1628 1630 > echo labelother: \"\$2\"
1629 1631 > echo "output (arg)": \"\$3\"
1630 1632 > echo "output (contents)":
1631 1633 > cat "\$3"
1632 1634 > EOF
1633 1635 $ hg --config merge-tools.true.executable='sh' \
1634 1636 > --config merge-tools.true.args='mytool $labellocal $labelother $output' \
1635 1637 > --config merge-tools.true.premerge=keep \
1636 1638 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1637 1639 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1638 1640 > --config ui.mergemarkers=detailed \
1639 1641 > merge -r 2
1640 1642 merging f
1641 1643 labellocal: "working copy"
1642 1644 labelother: "merge rev"
1643 1645 output (arg): "$TESTTMP/repo/f"
1644 1646 output (contents):
1645 1647 <<<<<<< working copy: uitmpl 1
1646 1648 revision 1
1647 1649 =======
1648 1650 revision 2
1649 1651 >>>>>>> merge rev: uitmpl 2
1650 1652 space
1651 1653 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1652 1654 (branch merge, don't forget to commit)
1653 1655 $ rm -f 'mytool'
1654 1656
1655 1657 premerge=keep uses the *tool's* mergemarkertemplate if tool's
1656 1658 mergemarkers=detailed; labellocal and labelother also use the tool's template
1657 1659
1658 1660 $ beforemerge
1659 1661 [merge-tools]
1660 1662 false.whatever=
1661 1663 true.priority=1
1662 1664 true.executable=cat
1663 1665 # hg update -C 1
1664 1666 $ cat <<EOF > mytool
1665 1667 > echo labellocal: \"\$1\"
1666 1668 > echo labelother: \"\$2\"
1667 1669 > echo "output (arg)": \"\$3\"
1668 1670 > echo "output (contents)":
1669 1671 > cat "\$3"
1670 1672 > EOF
1671 1673 $ hg --config merge-tools.true.executable='sh' \
1672 1674 > --config merge-tools.true.args='mytool $labellocal $labelother $output' \
1673 1675 > --config merge-tools.true.premerge=keep \
1674 1676 > --config merge-tools.true.mergemarkers=detailed \
1675 1677 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1676 1678 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1677 1679 > --config ui.mergemarkers=detailed \
1678 1680 > merge -r 2
1679 1681 merging f
1680 1682 labellocal: "working copy: tooltmpl ef83787e2614"
1681 1683 labelother: "merge rev: tooltmpl 0185f4e0cf02"
1682 1684 output (arg): "$TESTTMP/repo/f"
1683 1685 output (contents):
1684 1686 <<<<<<< working copy: tooltmpl ef83787e2614
1685 1687 revision 1
1686 1688 =======
1687 1689 revision 2
1688 1690 >>>>>>> merge rev: tooltmpl 0185f4e0cf02
1689 1691 space
1690 1692 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1691 1693 (branch merge, don't forget to commit)
1692 1694 $ rm -f 'mytool'
1693 1695
1694 1696 Issue3581: Merging a filename that needs to be quoted
1695 1697 (This test doesn't work on Windows filesystems even on Linux, so check
1696 1698 for Unix-like permission)
1697 1699
1698 1700 #if unix-permissions
1699 1701 $ beforemerge
1700 1702 [merge-tools]
1701 1703 false.whatever=
1702 1704 true.priority=1
1703 1705 true.executable=cat
1704 1706 # hg update -C 1
1705 1707 $ echo "revision 5" > '"; exit 1; echo "'
1706 1708 $ hg commit -Am "revision 5"
1707 1709 adding "; exit 1; echo "
1708 1710 warning: filename contains '"', which is reserved on Windows: '"; exit 1; echo "'
1709 1711 $ hg update -C 1 > /dev/null
1710 1712 $ echo "revision 6" > '"; exit 1; echo "'
1711 1713 $ hg commit -Am "revision 6"
1712 1714 adding "; exit 1; echo "
1713 1715 warning: filename contains '"', which is reserved on Windows: '"; exit 1; echo "'
1714 1716 created new head
1715 1717 $ hg merge --config merge-tools.true.executable="true" -r 5
1716 1718 merging "; exit 1; echo "
1717 1719 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1718 1720 (branch merge, don't forget to commit)
1719 1721 $ hg update -C 1 > /dev/null
1720 1722
1721 1723 #else
1722 1724
1723 1725 Match the non-portable filename commits above for test stability
1724 1726
1725 1727 $ hg import --bypass -q - << EOF
1726 1728 > # HG changeset patch
1727 1729 > revision 5
1728 1730 >
1729 1731 > diff --git a/"; exit 1; echo " b/"; exit 1; echo "
1730 1732 > new file mode 100644
1731 1733 > --- /dev/null
1732 1734 > +++ b/"; exit 1; echo "
1733 1735 > @@ -0,0 +1,1 @@
1734 1736 > +revision 5
1735 1737 > EOF
1736 1738
1737 1739 $ hg import --bypass -q - << EOF
1738 1740 > # HG changeset patch
1739 1741 > revision 6
1740 1742 >
1741 1743 > diff --git a/"; exit 1; echo " b/"; exit 1; echo "
1742 1744 > new file mode 100644
1743 1745 > --- /dev/null
1744 1746 > +++ b/"; exit 1; echo "
1745 1747 > @@ -0,0 +1,1 @@
1746 1748 > +revision 6
1747 1749 > EOF
1748 1750
1749 1751 #endif
1750 1752
1751 1753 Merge post-processing
1752 1754
1753 1755 cat is a bad merge-tool and doesn't change:
1754 1756
1755 1757 $ beforemerge
1756 1758 [merge-tools]
1757 1759 false.whatever=
1758 1760 true.priority=1
1759 1761 true.executable=cat
1760 1762 # hg update -C 1
1761 1763 $ hg merge -y -r 2 --config merge-tools.true.checkchanged=1
1762 1764 merging f
1763 1765 revision 1
1764 1766 space
1765 1767 revision 0
1766 1768 space
1767 1769 revision 2
1768 1770 space
1769 1771 output file f appears unchanged
1770 1772 was merge successful (yn)? n
1771 1773 merging f failed!
1772 1774 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1773 1775 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
1774 1776 [1]
1775 1777 $ aftermerge
1776 1778 # cat f
1777 1779 revision 1
1778 1780 space
1779 1781 # hg stat
1780 1782 M f
1781 1783 ? f.orig
1782 1784 # hg resolve --list
1783 1785 U f
1784 1786
1785 1787 missingbinary is a merge-tool that doesn't exist:
1786 1788
1787 1789 $ echo "missingbinary.executable=doesnotexist" >> .hg/hgrc
1788 1790 $ beforemerge
1789 1791 [merge-tools]
1790 1792 false.whatever=
1791 1793 true.priority=1
1792 1794 true.executable=cat
1793 1795 missingbinary.executable=doesnotexist
1794 1796 # hg update -C 1
1795 1797 $ hg merge -y -r 2 --config ui.merge=missingbinary
1796 1798 couldn't find merge tool missingbinary (for pattern f)
1797 1799 merging f
1798 1800 couldn't find merge tool missingbinary (for pattern f)
1799 1801 revision 1
1800 1802 space
1801 1803 revision 0
1802 1804 space
1803 1805 revision 2
1804 1806 space
1805 1807 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1806 1808 (branch merge, don't forget to commit)
1807 1809
1808 1810 $ hg update -q -C 1
1809 1811 $ rm f
1810 1812
1811 1813 internal merge cannot handle symlinks and shouldn't try:
1812 1814
1813 1815 #if symlink
1814 1816
1815 1817 $ ln -s symlink f
1816 1818 $ hg commit -qm 'f is symlink'
1817 1819
1818 1820 #else
1819 1821
1820 1822 $ hg import --bypass -q - << EOF
1821 1823 > # HG changeset patch
1822 1824 > f is symlink
1823 1825 >
1824 1826 > diff --git a/f b/f
1825 1827 > old mode 100644
1826 1828 > new mode 120000
1827 1829 > --- a/f
1828 1830 > +++ b/f
1829 1831 > @@ -1,2 +1,1 @@
1830 1832 > -revision 1
1831 1833 > -space
1832 1834 > +symlink
1833 1835 > \ No newline at end of file
1834 1836 > EOF
1835 1837
1836 1838 Resolve 'other [destination] changed f which local [working copy] deleted' prompt
1837 1839 $ hg up -q -C --config ui.interactive=True << EOF
1838 1840 > c
1839 1841 > EOF
1840 1842
1841 1843 #endif
1842 1844
1843 1845 $ hg merge -r 2 --tool internal:merge
1844 1846 merging f
1845 1847 warning: internal :merge cannot merge symlinks for f
1846 1848 warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
1847 1849 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1848 1850 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
1849 1851 [1]
1850 1852
1851 1853 Verify naming of temporary files and that extension is preserved:
1852 1854
1853 1855 $ hg update -q -C 1
1854 1856 $ hg mv f f.txt
1855 1857 $ hg ci -qm "f.txt"
1856 1858 $ hg update -q -C 2
1857 1859 $ hg merge -y -r tip --tool echo --config merge-tools.echo.args='$base $local $other $output'
1858 1860 merging f and f.txt to f.txt
1859 1861 */f~base.* */f~local.*.txt */f~other.*.txt $TESTTMP/repo/f.txt (glob)
1860 1862 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1861 1863 (branch merge, don't forget to commit)
1862 1864
1863 1865 Verify naming of temporary files and that extension is preserved
1864 1866 (experimental.mergetempdirprefix version):
1865 1867
1866 1868 $ hg update -q -C 1
1867 1869 $ hg mv f f.txt
1868 1870 $ hg ci -qm "f.txt"
1869 1871 $ hg update -q -C 2
1870 1872 $ hg merge -y -r tip --tool echo \
1871 1873 > --config merge-tools.echo.args='$base $local $other $output' \
1872 1874 > --config experimental.mergetempdirprefix=$TESTTMP/hgmerge.
1873 1875 merging f and f.txt to f.txt
1874 1876 $TESTTMP/hgmerge.*/f~base $TESTTMP/hgmerge.*/f~local.txt $TESTTMP/hgmerge.*/f~other.txt $TESTTMP/repo/f.txt (glob)
1875 1877 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1876 1878 (branch merge, don't forget to commit)
1877 1879
1878 1880 Binary files capability checking
1879 1881
1880 1882 $ hg update -q -C 0
1881 1883 $ python <<EOF
1882 1884 > with open('b', 'wb') as fp:
1883 1885 > fp.write(b'\x00\x01\x02\x03')
1884 1886 > EOF
1885 1887 $ hg add b
1886 1888 $ hg commit -qm "add binary file (#1)"
1887 1889
1888 1890 $ hg update -q -C 0
1889 1891 $ python <<EOF
1890 1892 > with open('b', 'wb') as fp:
1891 1893 > fp.write(b'\x03\x02\x01\x00')
1892 1894 > EOF
1893 1895 $ hg add b
1894 1896 $ hg commit -qm "add binary file (#2)"
1895 1897
1896 1898 By default, binary files capability of internal merge tools is not
1897 1899 checked strictly.
1898 1900
1899 1901 (for merge-patterns, chosen unintentionally)
1900 1902
1901 1903 $ hg merge 9 \
1902 1904 > --config merge-patterns.b=:merge-other \
1903 1905 > --config merge-patterns.re:[a-z]=:other
1904 1906 warning: check merge-patterns configurations, if ':merge-other' for binary file 'b' is unintentional
1905 1907 (see 'hg help merge-tools' for binary files capability)
1906 1908 merging b
1907 1909 warning: b looks like a binary file.
1908 1910 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1909 1911 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
1910 1912 [1]
1913 (Testing that commands.merge.require-rev doesn't break --abort)
1911 1914 $ hg merge --abort -q
1912 1915
1913 1916 (for ui.merge, ignored unintentionally)
1914 1917
1915 1918 $ hg merge 9 \
1916 1919 > --config merge-tools.:other.binary=true \
1917 1920 > --config ui.merge=:other
1918 1921 tool :other (for pattern b) can't handle binary
1919 1922 tool true can't handle binary
1920 1923 tool :other can't handle binary
1921 1924 tool false can't handle binary
1922 1925 no tool found to merge b
1923 1926 file 'b' needs to be resolved.
1924 1927 You can keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved.
1925 1928 What do you want to do? u
1926 1929 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1927 1930 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
1928 1931 [1]
1929 1932 $ hg merge --abort -q
1930 1933
1931 1934 With merge.strict-capability-check=true, binary files capability of
1932 1935 internal merge tools is checked strictly.
1933 1936
1934 1937 $ f --hexdump b
1935 1938 b:
1936 1939 0000: 03 02 01 00 |....|
1937 1940
1938 1941 (for merge-patterns)
1939 1942
1940 1943 $ hg merge 9 --config merge.strict-capability-check=true \
1941 1944 > --config merge-tools.:merge-other.binary=true \
1942 1945 > --config merge-patterns.b=:merge-other \
1943 1946 > --config merge-patterns.re:[a-z]=:other
1944 1947 tool :merge-other (for pattern b) can't handle binary
1945 1948 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1946 1949 (branch merge, don't forget to commit)
1947 1950 $ f --hexdump b
1948 1951 b:
1949 1952 0000: 00 01 02 03 |....|
1950 1953 $ hg merge --abort -q
1951 1954
1952 1955 (for ui.merge)
1953 1956
1954 1957 $ hg merge 9 --config merge.strict-capability-check=true \
1955 1958 > --config ui.merge=:other
1956 1959 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1957 1960 (branch merge, don't forget to commit)
1958 1961 $ f --hexdump b
1959 1962 b:
1960 1963 0000: 00 01 02 03 |....|
1961 1964 $ hg merge --abort -q
1962 1965
1963 1966 Check that the extra information is printed correctly
1964 1967
1965 1968 $ hg merge 9 \
1966 1969 > --config merge-tools.testecho.executable='echo' \
1967 1970 > --config merge-tools.testecho.args='merge runs here ...' \
1968 1971 > --config merge-tools.testecho.binary=True \
1969 1972 > --config ui.merge=testecho \
1970 1973 > --config ui.pre-merge-tool-output-template='\n{label("extmerge.running_merge_tool", "Running merge tool for {path} ({toolpath}):")}\n{separate("\n", extmerge_section(local), extmerge_section(base), extmerge_section(other))}\n' \
1971 1974 > --config 'templatealias.extmerge_section(sect)="- {pad("{sect.name} ({sect.label})", 20, left=True)}: {revset(sect.node)%"{rev}:{shortest(node,8)} {desc|firstline} {separate(" ", tags, bookmarks, branch)}"}"'
1972 1975 merging b
1973 1976
1974 1977 Running merge tool for b ("*/bin/echo.exe"): (glob) (windows !)
1975 1978 Running merge tool for b (*/bin/echo): (glob) (no-windows !)
1976 1979 - local (working copy): 10:2d1f533d add binary file (#2) tip default
1977 1980 - base (base): -1:00000000 default
1978 1981 - other (merge rev): 9:1e7ad7d7 add binary file (#1) default
1979 1982 merge runs here ...
1980 1983 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1981 1984 (branch merge, don't forget to commit)
1982 1985
1983 1986 Check that debugpicktool examines which merge tool is chosen for
1984 1987 specified file as expected
1985 1988
1986 1989 $ beforemerge
1987 1990 [merge-tools]
1988 1991 false.whatever=
1989 1992 true.priority=1
1990 1993 true.executable=cat
1991 1994 missingbinary.executable=doesnotexist
1992 1995 # hg update -C 1
1993 1996
1994 1997 (default behavior: checking files in the working parent context)
1995 1998
1996 1999 $ hg manifest
1997 2000 f
1998 2001 $ hg debugpickmergetool
1999 2002 f = true
2000 2003
2001 2004 (-X/-I and file patterns limmit examination targets)
2002 2005
2003 2006 $ hg debugpickmergetool -X f
2004 2007 $ hg debugpickmergetool unknown
2005 2008 unknown: no such file in rev ef83787e2614
2006 2009
2007 2010 (--changedelete emulates merging change and delete)
2008 2011
2009 2012 $ hg debugpickmergetool --changedelete
2010 2013 f = :prompt
2011 2014
2012 2015 (-r REV causes checking files in specified revision)
2013 2016
2014 2017 $ hg manifest -r 8
2015 2018 f.txt
2016 2019 $ hg debugpickmergetool -r 8
2017 2020 f.txt = true
2018 2021
2019 2022 #if symlink
2020 2023
2021 2024 (symlink causes chosing :prompt)
2022 2025
2023 2026 $ hg debugpickmergetool -r 6d00b3726f6e
2024 2027 f = :prompt
2025 2028
2026 2029 (by default, it is assumed that no internal merge tools has symlinks
2027 2030 capability)
2028 2031
2029 2032 $ hg debugpickmergetool \
2030 2033 > -r 6d00b3726f6e \
2031 2034 > --config merge-tools.:merge-other.symlink=true \
2032 2035 > --config merge-patterns.f=:merge-other \
2033 2036 > --config merge-patterns.re:[f]=:merge-local \
2034 2037 > --config merge-patterns.re:[a-z]=:other
2035 2038 f = :prompt
2036 2039
2037 2040 $ hg debugpickmergetool \
2038 2041 > -r 6d00b3726f6e \
2039 2042 > --config merge-tools.:other.symlink=true \
2040 2043 > --config ui.merge=:other
2041 2044 f = :prompt
2042 2045
2043 2046 (with strict-capability-check=true, actual symlink capabilities are
2044 2047 checked striclty)
2045 2048
2046 2049 $ hg debugpickmergetool --config merge.strict-capability-check=true \
2047 2050 > -r 6d00b3726f6e \
2048 2051 > --config merge-tools.:merge-other.symlink=true \
2049 2052 > --config merge-patterns.f=:merge-other \
2050 2053 > --config merge-patterns.re:[f]=:merge-local \
2051 2054 > --config merge-patterns.re:[a-z]=:other
2052 2055 f = :other
2053 2056
2054 2057 $ hg debugpickmergetool --config merge.strict-capability-check=true \
2055 2058 > -r 6d00b3726f6e \
2056 2059 > --config ui.merge=:other
2057 2060 f = :other
2058 2061
2059 2062 $ hg debugpickmergetool --config merge.strict-capability-check=true \
2060 2063 > -r 6d00b3726f6e \
2061 2064 > --config merge-tools.:merge-other.symlink=true \
2062 2065 > --config ui.merge=:merge-other
2063 2066 f = :prompt
2064 2067
2065 2068 #endif
2066 2069
2067 2070 (--verbose shows some configurations)
2068 2071
2069 2072 $ hg debugpickmergetool --tool foobar -v
2070 2073 with --tool 'foobar'
2071 2074 f = foobar
2072 2075
2073 2076 $ HGMERGE=false hg debugpickmergetool -v
2074 2077 with HGMERGE='false'
2075 2078 f = false
2076 2079
2077 2080 $ hg debugpickmergetool --config ui.merge=false -v
2078 2081 with ui.merge='false'
2079 2082 f = false
2080 2083
2081 2084 (--debug shows errors detected intermediately)
2082 2085
2083 2086 $ hg debugpickmergetool --config merge-patterns.f=true --config merge-tools.true.executable=nonexistentmergetool --debug f
2084 2087 couldn't find merge tool true (for pattern f)
2085 2088 couldn't find merge tool true
2086 2089 f = false
2087 2090
2088 2091 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now