##// END OF EJS Templates
mergetools: add new conflict marker format with diffs in...
Martin von Zweigbergk -
r46724:bdc2bf68 default
parent child Browse files
Show More
@@ -1,1266 +1,1293 b''
1 1 # filemerge.py - file-level merge handling for Mercurial
2 2 #
3 3 # Copyright 2006, 2007, 2008 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 contextlib
11 11 import os
12 12 import re
13 13 import shutil
14 14
15 15 from .i18n import _
16 16 from .node import (
17 17 hex,
18 18 nullid,
19 19 short,
20 20 )
21 21 from .pycompat import (
22 22 getattr,
23 23 open,
24 24 )
25 25
26 26 from . import (
27 27 encoding,
28 28 error,
29 29 formatter,
30 30 match,
31 31 pycompat,
32 32 registrar,
33 33 scmutil,
34 34 simplemerge,
35 35 tagmerge,
36 36 templatekw,
37 37 templater,
38 38 templateutil,
39 39 util,
40 40 )
41 41
42 42 from .utils import (
43 43 procutil,
44 44 stringutil,
45 45 )
46 46
47 47
48 48 def _toolstr(ui, tool, part, *args):
49 49 return ui.config(b"merge-tools", tool + b"." + part, *args)
50 50
51 51
52 52 def _toolbool(ui, tool, part, *args):
53 53 return ui.configbool(b"merge-tools", tool + b"." + part, *args)
54 54
55 55
56 56 def _toollist(ui, tool, part):
57 57 return ui.configlist(b"merge-tools", tool + b"." + part)
58 58
59 59
60 60 internals = {}
61 61 # Merge tools to document.
62 62 internalsdoc = {}
63 63
64 64 internaltool = registrar.internalmerge()
65 65
66 66 # internal tool merge types
67 67 nomerge = internaltool.nomerge
68 68 mergeonly = internaltool.mergeonly # just the full merge, no premerge
69 69 fullmerge = internaltool.fullmerge # both premerge and merge
70 70
71 71 # IMPORTANT: keep the last line of this prompt very short ("What do you want to
72 72 # do?") because of issue6158, ideally to <40 English characters (to allow other
73 73 # languages that may take more columns to still have a chance to fit in an
74 74 # 80-column screen).
75 75 _localchangedotherdeletedmsg = _(
76 76 b"file '%(fd)s' was deleted in other%(o)s but was modified in local%(l)s.\n"
77 77 b"You can use (c)hanged version, (d)elete, or leave (u)nresolved.\n"
78 78 b"What do you want to do?"
79 79 b"$$ &Changed $$ &Delete $$ &Unresolved"
80 80 )
81 81
82 82 _otherchangedlocaldeletedmsg = _(
83 83 b"file '%(fd)s' was deleted in local%(l)s but was modified in other%(o)s.\n"
84 84 b"You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.\n"
85 85 b"What do you want to do?"
86 86 b"$$ &Changed $$ &Deleted $$ &Unresolved"
87 87 )
88 88
89 89
90 90 class absentfilectx(object):
91 91 """Represents a file that's ostensibly in a context but is actually not
92 92 present in it.
93 93
94 94 This is here because it's very specific to the filemerge code for now --
95 95 other code is likely going to break with the values this returns."""
96 96
97 97 def __init__(self, ctx, f):
98 98 self._ctx = ctx
99 99 self._f = f
100 100
101 101 def __bytes__(self):
102 102 return b'absent file %s@%s' % (self._f, self._ctx)
103 103
104 104 def path(self):
105 105 return self._f
106 106
107 107 def size(self):
108 108 return None
109 109
110 110 def data(self):
111 111 return None
112 112
113 113 def filenode(self):
114 114 return nullid
115 115
116 116 _customcmp = True
117 117
118 118 def cmp(self, fctx):
119 119 """compare with other file context
120 120
121 121 returns True if different from fctx.
122 122 """
123 123 return not (
124 124 fctx.isabsent()
125 125 and fctx.changectx() == self.changectx()
126 126 and fctx.path() == self.path()
127 127 )
128 128
129 129 def flags(self):
130 130 return b''
131 131
132 132 def changectx(self):
133 133 return self._ctx
134 134
135 135 def isbinary(self):
136 136 return False
137 137
138 138 def isabsent(self):
139 139 return True
140 140
141 141
142 142 def _findtool(ui, tool):
143 143 if tool in internals:
144 144 return tool
145 145 cmd = _toolstr(ui, tool, b"executable", tool)
146 146 if cmd.startswith(b'python:'):
147 147 return cmd
148 148 return findexternaltool(ui, tool)
149 149
150 150
151 151 def _quotetoolpath(cmd):
152 152 if cmd.startswith(b'python:'):
153 153 return cmd
154 154 return procutil.shellquote(cmd)
155 155
156 156
157 157 def findexternaltool(ui, tool):
158 158 for kn in (b"regkey", b"regkeyalt"):
159 159 k = _toolstr(ui, tool, kn)
160 160 if not k:
161 161 continue
162 162 p = util.lookupreg(k, _toolstr(ui, tool, b"regname"))
163 163 if p:
164 164 p = procutil.findexe(p + _toolstr(ui, tool, b"regappend", b""))
165 165 if p:
166 166 return p
167 167 exe = _toolstr(ui, tool, b"executable", tool)
168 168 return procutil.findexe(util.expandpath(exe))
169 169
170 170
171 171 def _picktool(repo, ui, path, binary, symlink, changedelete):
172 172 strictcheck = ui.configbool(b'merge', b'strict-capability-check')
173 173
174 174 def hascapability(tool, capability, strict=False):
175 175 if tool in internals:
176 176 return strict and internals[tool].capabilities.get(capability)
177 177 return _toolbool(ui, tool, capability)
178 178
179 179 def supportscd(tool):
180 180 return tool in internals and internals[tool].mergetype == nomerge
181 181
182 182 def check(tool, pat, symlink, binary, changedelete):
183 183 tmsg = tool
184 184 if pat:
185 185 tmsg = _(b"%s (for pattern %s)") % (tool, pat)
186 186 if not _findtool(ui, tool):
187 187 if pat: # explicitly requested tool deserves a warning
188 188 ui.warn(_(b"couldn't find merge tool %s\n") % tmsg)
189 189 else: # configured but non-existing tools are more silent
190 190 ui.note(_(b"couldn't find merge tool %s\n") % tmsg)
191 191 elif symlink and not hascapability(tool, b"symlink", strictcheck):
192 192 ui.warn(_(b"tool %s can't handle symlinks\n") % tmsg)
193 193 elif binary and not hascapability(tool, b"binary", strictcheck):
194 194 ui.warn(_(b"tool %s can't handle binary\n") % tmsg)
195 195 elif changedelete and not supportscd(tool):
196 196 # the nomerge tools are the only tools that support change/delete
197 197 # conflicts
198 198 pass
199 199 elif not procutil.gui() and _toolbool(ui, tool, b"gui"):
200 200 ui.warn(_(b"tool %s requires a GUI\n") % tmsg)
201 201 else:
202 202 return True
203 203 return False
204 204
205 205 # internal config: ui.forcemerge
206 206 # forcemerge comes from command line arguments, highest priority
207 207 force = ui.config(b'ui', b'forcemerge')
208 208 if force:
209 209 toolpath = _findtool(ui, force)
210 210 if changedelete and not supportscd(toolpath):
211 211 return b":prompt", None
212 212 else:
213 213 if toolpath:
214 214 return (force, _quotetoolpath(toolpath))
215 215 else:
216 216 # mimic HGMERGE if given tool not found
217 217 return (force, force)
218 218
219 219 # HGMERGE takes next precedence
220 220 hgmerge = encoding.environ.get(b"HGMERGE")
221 221 if hgmerge:
222 222 if changedelete and not supportscd(hgmerge):
223 223 return b":prompt", None
224 224 else:
225 225 return (hgmerge, hgmerge)
226 226
227 227 # then patterns
228 228
229 229 # whether binary capability should be checked strictly
230 230 binarycap = binary and strictcheck
231 231
232 232 for pat, tool in ui.configitems(b"merge-patterns"):
233 233 mf = match.match(repo.root, b'', [pat])
234 234 if mf(path) and check(tool, pat, symlink, binarycap, changedelete):
235 235 if binary and not hascapability(tool, b"binary", strict=True):
236 236 ui.warn(
237 237 _(
238 238 b"warning: check merge-patterns configurations,"
239 239 b" if %r for binary file %r is unintentional\n"
240 240 b"(see 'hg help merge-tools'"
241 241 b" for binary files capability)\n"
242 242 )
243 243 % (pycompat.bytestr(tool), pycompat.bytestr(path))
244 244 )
245 245 toolpath = _findtool(ui, tool)
246 246 return (tool, _quotetoolpath(toolpath))
247 247
248 248 # then merge tools
249 249 tools = {}
250 250 disabled = set()
251 251 for k, v in ui.configitems(b"merge-tools"):
252 252 t = k.split(b'.')[0]
253 253 if t not in tools:
254 254 tools[t] = int(_toolstr(ui, t, b"priority"))
255 255 if _toolbool(ui, t, b"disabled"):
256 256 disabled.add(t)
257 257 names = tools.keys()
258 258 tools = sorted(
259 259 [(-p, tool) for tool, p in tools.items() if tool not in disabled]
260 260 )
261 261 uimerge = ui.config(b"ui", b"merge")
262 262 if uimerge:
263 263 # external tools defined in uimerge won't be able to handle
264 264 # change/delete conflicts
265 265 if check(uimerge, path, symlink, binary, changedelete):
266 266 if uimerge not in names and not changedelete:
267 267 return (uimerge, uimerge)
268 268 tools.insert(0, (None, uimerge)) # highest priority
269 269 tools.append((None, b"hgmerge")) # the old default, if found
270 270 for p, t in tools:
271 271 if check(t, None, symlink, binary, changedelete):
272 272 toolpath = _findtool(ui, t)
273 273 return (t, _quotetoolpath(toolpath))
274 274
275 275 # internal merge or prompt as last resort
276 276 if symlink or binary or changedelete:
277 277 if not changedelete and len(tools):
278 278 # any tool is rejected by capability for symlink or binary
279 279 ui.warn(_(b"no tool found to merge %s\n") % path)
280 280 return b":prompt", None
281 281 return b":merge", None
282 282
283 283
284 284 def _eoltype(data):
285 285 """Guess the EOL type of a file"""
286 286 if b'\0' in data: # binary
287 287 return None
288 288 if b'\r\n' in data: # Windows
289 289 return b'\r\n'
290 290 if b'\r' in data: # Old Mac
291 291 return b'\r'
292 292 if b'\n' in data: # UNIX
293 293 return b'\n'
294 294 return None # unknown
295 295
296 296
297 297 def _matcheol(file, back):
298 298 """Convert EOL markers in a file to match origfile"""
299 299 tostyle = _eoltype(back.data()) # No repo.wread filters?
300 300 if tostyle:
301 301 data = util.readfile(file)
302 302 style = _eoltype(data)
303 303 if style:
304 304 newdata = data.replace(style, tostyle)
305 305 if newdata != data:
306 306 util.writefile(file, newdata)
307 307
308 308
309 309 @internaltool(b'prompt', nomerge)
310 310 def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
311 311 """Asks the user which of the local `p1()` or the other `p2()` version to
312 312 keep as the merged version."""
313 313 ui = repo.ui
314 314 fd = fcd.path()
315 315 uipathfn = scmutil.getuipathfn(repo)
316 316
317 317 # Avoid prompting during an in-memory merge since it doesn't support merge
318 318 # conflicts.
319 319 if fcd.changectx().isinmemory():
320 320 raise error.InMemoryMergeConflictsError(
321 321 b'in-memory merge does not support file conflicts'
322 322 )
323 323
324 324 prompts = partextras(labels)
325 325 prompts[b'fd'] = uipathfn(fd)
326 326 try:
327 327 if fco.isabsent():
328 328 index = ui.promptchoice(_localchangedotherdeletedmsg % prompts, 2)
329 329 choice = [b'local', b'other', b'unresolved'][index]
330 330 elif fcd.isabsent():
331 331 index = ui.promptchoice(_otherchangedlocaldeletedmsg % prompts, 2)
332 332 choice = [b'other', b'local', b'unresolved'][index]
333 333 else:
334 334 # IMPORTANT: keep the last line of this prompt ("What do you want to
335 335 # do?") very short, see comment next to _localchangedotherdeletedmsg
336 336 # at the top of the file for details.
337 337 index = ui.promptchoice(
338 338 _(
339 339 b"file '%(fd)s' needs to be resolved.\n"
340 340 b"You can keep (l)ocal%(l)s, take (o)ther%(o)s, or leave "
341 341 b"(u)nresolved.\n"
342 342 b"What do you want to do?"
343 343 b"$$ &Local $$ &Other $$ &Unresolved"
344 344 )
345 345 % prompts,
346 346 2,
347 347 )
348 348 choice = [b'local', b'other', b'unresolved'][index]
349 349
350 350 if choice == b'other':
351 351 return _iother(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
352 352 elif choice == b'local':
353 353 return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
354 354 elif choice == b'unresolved':
355 355 return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
356 356 except error.ResponseExpected:
357 357 ui.write(b"\n")
358 358 return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
359 359
360 360
361 361 @internaltool(b'local', nomerge)
362 362 def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
363 363 """Uses the local `p1()` version of files as the merged version."""
364 364 return 0, fcd.isabsent()
365 365
366 366
367 367 @internaltool(b'other', nomerge)
368 368 def _iother(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
369 369 """Uses the other `p2()` version of files as the merged version."""
370 370 if fco.isabsent():
371 371 # local changed, remote deleted -- 'deleted' picked
372 372 _underlyingfctxifabsent(fcd).remove()
373 373 deleted = True
374 374 else:
375 375 _underlyingfctxifabsent(fcd).write(fco.data(), fco.flags())
376 376 deleted = False
377 377 return 0, deleted
378 378
379 379
380 380 @internaltool(b'fail', nomerge)
381 381 def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
382 382 """
383 383 Rather than attempting to merge files that were modified on both
384 384 branches, it marks them as unresolved. The resolve command must be
385 385 used to resolve these conflicts."""
386 386 # for change/delete conflicts write out the changed version, then fail
387 387 if fcd.isabsent():
388 388 _underlyingfctxifabsent(fcd).write(fco.data(), fco.flags())
389 389 return 1, False
390 390
391 391
392 392 def _underlyingfctxifabsent(filectx):
393 393 """Sometimes when resolving, our fcd is actually an absentfilectx, but
394 394 we want to write to it (to do the resolve). This helper returns the
395 395 underyling workingfilectx in that case.
396 396 """
397 397 if filectx.isabsent():
398 398 return filectx.changectx()[filectx.path()]
399 399 else:
400 400 return filectx
401 401
402 402
403 403 def _premerge(repo, fcd, fco, fca, toolconf, files, labels=None):
404 404 tool, toolpath, binary, symlink, scriptfn = toolconf
405 405 if symlink or fcd.isabsent() or fco.isabsent():
406 406 return 1
407 407 unused, unused, unused, back = files
408 408
409 409 ui = repo.ui
410 410
411 411 validkeep = [b'keep', b'keep-merge3']
412 412
413 413 # do we attempt to simplemerge first?
414 414 try:
415 415 premerge = _toolbool(ui, tool, b"premerge", not binary)
416 416 except error.ConfigError:
417 417 premerge = _toolstr(ui, tool, b"premerge", b"").lower()
418 418 if premerge not in validkeep:
419 419 _valid = b', '.join([b"'" + v + b"'" for v in validkeep])
420 420 raise error.ConfigError(
421 421 _(b"%s.premerge not valid ('%s' is neither boolean nor %s)")
422 422 % (tool, premerge, _valid)
423 423 )
424 424
425 425 if premerge:
426 426 if premerge == b'keep-merge3':
427 427 if not labels:
428 428 labels = _defaultconflictlabels
429 429 if len(labels) < 3:
430 430 labels.append(b'base')
431 431 r = simplemerge.simplemerge(ui, fcd, fca, fco, quiet=True, label=labels)
432 432 if not r:
433 433 ui.debug(b" premerge successful\n")
434 434 return 0
435 435 if premerge not in validkeep:
436 436 # restore from backup and try again
437 437 _restorebackup(fcd, back)
438 438 return 1 # continue merging
439 439
440 440
441 441 def _mergecheck(repo, mynode, orig, fcd, fco, fca, toolconf):
442 442 tool, toolpath, binary, symlink, scriptfn = toolconf
443 443 uipathfn = scmutil.getuipathfn(repo)
444 444 if symlink:
445 445 repo.ui.warn(
446 446 _(b'warning: internal %s cannot merge symlinks for %s\n')
447 447 % (tool, uipathfn(fcd.path()))
448 448 )
449 449 return False
450 450 if fcd.isabsent() or fco.isabsent():
451 451 repo.ui.warn(
452 452 _(
453 453 b'warning: internal %s cannot merge change/delete '
454 454 b'conflict for %s\n'
455 455 )
456 456 % (tool, uipathfn(fcd.path()))
457 457 )
458 458 return False
459 459 return True
460 460
461 461
462 462 def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, mode):
463 463 """
464 464 Uses the internal non-interactive simple merge algorithm for merging
465 465 files. It will fail if there are any conflicts and leave markers in
466 466 the partially merged file. Markers will have two sections, one for each side
467 467 of merge, unless mode equals 'union' which suppresses the markers."""
468 468 ui = repo.ui
469 469
470 470 r = simplemerge.simplemerge(ui, fcd, fca, fco, label=labels, mode=mode)
471 471 return True, r, False
472 472
473 473
474 474 @internaltool(
475 475 b'union',
476 476 fullmerge,
477 477 _(
478 478 b"warning: conflicts while merging %s! "
479 479 b"(edit, then use 'hg resolve --mark')\n"
480 480 ),
481 481 precheck=_mergecheck,
482 482 )
483 483 def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
484 484 """
485 485 Uses the internal non-interactive simple merge algorithm for merging
486 486 files. It will use both left and right sides for conflict regions.
487 487 No markers are inserted."""
488 488 return _merge(
489 489 repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, b'union'
490 490 )
491 491
492 492
493 493 @internaltool(
494 494 b'merge',
495 495 fullmerge,
496 496 _(
497 497 b"warning: conflicts while merging %s! "
498 498 b"(edit, then use 'hg resolve --mark')\n"
499 499 ),
500 500 precheck=_mergecheck,
501 501 )
502 502 def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
503 503 """
504 504 Uses the internal non-interactive simple merge algorithm for merging
505 505 files. It will fail if there are any conflicts and leave markers in
506 506 the partially merged file. Markers will have two sections, one for each side
507 507 of merge."""
508 508 return _merge(
509 509 repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, b'merge'
510 510 )
511 511
512 512
513 513 @internaltool(
514 514 b'merge3',
515 515 fullmerge,
516 516 _(
517 517 b"warning: conflicts while merging %s! "
518 518 b"(edit, then use 'hg resolve --mark')\n"
519 519 ),
520 520 precheck=_mergecheck,
521 521 )
522 522 def _imerge3(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
523 523 """
524 524 Uses the internal non-interactive simple merge algorithm for merging
525 525 files. It will fail if there are any conflicts and leave markers in
526 526 the partially merged file. Marker will have three sections, one from each
527 527 side of the merge and one for the base content."""
528 528 if not labels:
529 529 labels = _defaultconflictlabels
530 530 if len(labels) < 3:
531 531 labels.append(b'base')
532 532 return _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels)
533 533
534 534
535 @internaltool(
536 b'mergediff',
537 fullmerge,
538 _(
539 b"warning: conflicts while merging %s! "
540 b"(edit, then use 'hg resolve --mark')\n"
541 ),
542 precheck=_mergecheck,
543 )
544 def _imerge_diff(
545 repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None
546 ):
547 """
548 Uses the internal non-interactive simple merge algorithm for merging
549 files. It will fail if there are any conflicts and leave markers in
550 the partially merged file. The marker will have two sections, one with the
551 content from one side of the merge, and one with a diff from the base
552 content to the content on the other side. (experimental)"""
553 if not labels:
554 labels = _defaultconflictlabels
555 if len(labels) < 3:
556 labels.append(b'base')
557 return _merge(
558 repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, b'mergediff'
559 )
560
561
535 562 def _imergeauto(
536 563 repo,
537 564 mynode,
538 565 orig,
539 566 fcd,
540 567 fco,
541 568 fca,
542 569 toolconf,
543 570 files,
544 571 labels=None,
545 572 localorother=None,
546 573 ):
547 574 """
548 575 Generic driver for _imergelocal and _imergeother
549 576 """
550 577 assert localorother is not None
551 578 r = simplemerge.simplemerge(
552 579 repo.ui, fcd, fca, fco, label=labels, localorother=localorother
553 580 )
554 581 return True, r
555 582
556 583
557 584 @internaltool(b'merge-local', mergeonly, precheck=_mergecheck)
558 585 def _imergelocal(*args, **kwargs):
559 586 """
560 587 Like :merge, but resolve all conflicts non-interactively in favor
561 588 of the local `p1()` changes."""
562 589 success, status = _imergeauto(localorother=b'local', *args, **kwargs)
563 590 return success, status, False
564 591
565 592
566 593 @internaltool(b'merge-other', mergeonly, precheck=_mergecheck)
567 594 def _imergeother(*args, **kwargs):
568 595 """
569 596 Like :merge, but resolve all conflicts non-interactively in favor
570 597 of the other `p2()` changes."""
571 598 success, status = _imergeauto(localorother=b'other', *args, **kwargs)
572 599 return success, status, False
573 600
574 601
575 602 @internaltool(
576 603 b'tagmerge',
577 604 mergeonly,
578 605 _(
579 606 b"automatic tag merging of %s failed! "
580 607 b"(use 'hg resolve --tool :merge' or another merge "
581 608 b"tool of your choice)\n"
582 609 ),
583 610 )
584 611 def _itagmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
585 612 """
586 613 Uses the internal tag merge algorithm (experimental).
587 614 """
588 615 success, status = tagmerge.merge(repo, fcd, fco, fca)
589 616 return success, status, False
590 617
591 618
592 619 @internaltool(b'dump', fullmerge, binary=True, symlink=True)
593 620 def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
594 621 """
595 622 Creates three versions of the files to merge, containing the
596 623 contents of local, other and base. These files can then be used to
597 624 perform a merge manually. If the file to be merged is named
598 625 ``a.txt``, these files will accordingly be named ``a.txt.local``,
599 626 ``a.txt.other`` and ``a.txt.base`` and they will be placed in the
600 627 same directory as ``a.txt``.
601 628
602 629 This implies premerge. Therefore, files aren't dumped, if premerge
603 630 runs successfully. Use :forcedump to forcibly write files out.
604 631 """
605 632 a = _workingpath(repo, fcd)
606 633 fd = fcd.path()
607 634
608 635 from . import context
609 636
610 637 if isinstance(fcd, context.overlayworkingfilectx):
611 638 raise error.InMemoryMergeConflictsError(
612 639 b'in-memory merge does not support the :dump tool.'
613 640 )
614 641
615 642 util.writefile(a + b".local", fcd.decodeddata())
616 643 repo.wwrite(fd + b".other", fco.data(), fco.flags())
617 644 repo.wwrite(fd + b".base", fca.data(), fca.flags())
618 645 return False, 1, False
619 646
620 647
621 648 @internaltool(b'forcedump', mergeonly, binary=True, symlink=True)
622 649 def _forcedump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
623 650 """
624 651 Creates three versions of the files as same as :dump, but omits premerge.
625 652 """
626 653 return _idump(
627 654 repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=labels
628 655 )
629 656
630 657
631 658 def _xmergeimm(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
632 659 # In-memory merge simply raises an exception on all external merge tools,
633 660 # for now.
634 661 #
635 662 # It would be possible to run most tools with temporary files, but this
636 663 # raises the question of what to do if the user only partially resolves the
637 664 # file -- we can't leave a merge state. (Copy to somewhere in the .hg/
638 665 # directory and tell the user how to get it is my best idea, but it's
639 666 # clunky.)
640 667 raise error.InMemoryMergeConflictsError(
641 668 b'in-memory merge does not support external merge tools'
642 669 )
643 670
644 671
645 672 def _describemerge(ui, repo, mynode, fcl, fcb, fco, env, toolpath, args):
646 673 tmpl = ui.config(b'command-templates', b'pre-merge-tool-output')
647 674 if not tmpl:
648 675 return
649 676
650 677 mappingdict = templateutil.mappingdict
651 678 props = {
652 679 b'ctx': fcl.changectx(),
653 680 b'node': hex(mynode),
654 681 b'path': fcl.path(),
655 682 b'local': mappingdict(
656 683 {
657 684 b'ctx': fcl.changectx(),
658 685 b'fctx': fcl,
659 686 b'node': hex(mynode),
660 687 b'name': _(b'local'),
661 688 b'islink': b'l' in fcl.flags(),
662 689 b'label': env[b'HG_MY_LABEL'],
663 690 }
664 691 ),
665 692 b'base': mappingdict(
666 693 {
667 694 b'ctx': fcb.changectx(),
668 695 b'fctx': fcb,
669 696 b'name': _(b'base'),
670 697 b'islink': b'l' in fcb.flags(),
671 698 b'label': env[b'HG_BASE_LABEL'],
672 699 }
673 700 ),
674 701 b'other': mappingdict(
675 702 {
676 703 b'ctx': fco.changectx(),
677 704 b'fctx': fco,
678 705 b'name': _(b'other'),
679 706 b'islink': b'l' in fco.flags(),
680 707 b'label': env[b'HG_OTHER_LABEL'],
681 708 }
682 709 ),
683 710 b'toolpath': toolpath,
684 711 b'toolargs': args,
685 712 }
686 713
687 714 # TODO: make all of this something that can be specified on a per-tool basis
688 715 tmpl = templater.unquotestring(tmpl)
689 716
690 717 # Not using cmdutil.rendertemplate here since it causes errors importing
691 718 # things for us to import cmdutil.
692 719 tres = formatter.templateresources(ui, repo)
693 720 t = formatter.maketemplater(
694 721 ui, tmpl, defaults=templatekw.keywords, resources=tres
695 722 )
696 723 ui.status(t.renderdefault(props))
697 724
698 725
699 726 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels):
700 727 tool, toolpath, binary, symlink, scriptfn = toolconf
701 728 uipathfn = scmutil.getuipathfn(repo)
702 729 if fcd.isabsent() or fco.isabsent():
703 730 repo.ui.warn(
704 731 _(b'warning: %s cannot merge change/delete conflict for %s\n')
705 732 % (tool, uipathfn(fcd.path()))
706 733 )
707 734 return False, 1, None
708 735 unused, unused, unused, back = files
709 736 localpath = _workingpath(repo, fcd)
710 737 args = _toolstr(repo.ui, tool, b"args")
711 738
712 739 with _maketempfiles(
713 740 repo, fco, fca, repo.wvfs.join(back.path()), b"$output" in args
714 741 ) as temppaths:
715 742 basepath, otherpath, localoutputpath = temppaths
716 743 outpath = b""
717 744 mylabel, otherlabel = labels[:2]
718 745 if len(labels) >= 3:
719 746 baselabel = labels[2]
720 747 else:
721 748 baselabel = b'base'
722 749 env = {
723 750 b'HG_FILE': fcd.path(),
724 751 b'HG_MY_NODE': short(mynode),
725 752 b'HG_OTHER_NODE': short(fco.changectx().node()),
726 753 b'HG_BASE_NODE': short(fca.changectx().node()),
727 754 b'HG_MY_ISLINK': b'l' in fcd.flags(),
728 755 b'HG_OTHER_ISLINK': b'l' in fco.flags(),
729 756 b'HG_BASE_ISLINK': b'l' in fca.flags(),
730 757 b'HG_MY_LABEL': mylabel,
731 758 b'HG_OTHER_LABEL': otherlabel,
732 759 b'HG_BASE_LABEL': baselabel,
733 760 }
734 761 ui = repo.ui
735 762
736 763 if b"$output" in args:
737 764 # read input from backup, write to original
738 765 outpath = localpath
739 766 localpath = localoutputpath
740 767 replace = {
741 768 b'local': localpath,
742 769 b'base': basepath,
743 770 b'other': otherpath,
744 771 b'output': outpath,
745 772 b'labellocal': mylabel,
746 773 b'labelother': otherlabel,
747 774 b'labelbase': baselabel,
748 775 }
749 776 args = util.interpolate(
750 777 br'\$',
751 778 replace,
752 779 args,
753 780 lambda s: procutil.shellquote(util.localpath(s)),
754 781 )
755 782 if _toolbool(ui, tool, b"gui"):
756 783 repo.ui.status(
757 784 _(b'running merge tool %s for file %s\n')
758 785 % (tool, uipathfn(fcd.path()))
759 786 )
760 787 if scriptfn is None:
761 788 cmd = toolpath + b' ' + args
762 789 repo.ui.debug(b'launching merge tool: %s\n' % cmd)
763 790 _describemerge(ui, repo, mynode, fcd, fca, fco, env, toolpath, args)
764 791 r = ui.system(
765 792 cmd, cwd=repo.root, environ=env, blockedtag=b'mergetool'
766 793 )
767 794 else:
768 795 repo.ui.debug(
769 796 b'launching python merge script: %s:%s\n' % (toolpath, scriptfn)
770 797 )
771 798 r = 0
772 799 try:
773 800 # avoid cycle cmdutil->merge->filemerge->extensions->cmdutil
774 801 from . import extensions
775 802
776 803 mod = extensions.loadpath(toolpath, b'hgmerge.%s' % tool)
777 804 except Exception:
778 805 raise error.Abort(
779 806 _(b"loading python merge script failed: %s") % toolpath
780 807 )
781 808 mergefn = getattr(mod, scriptfn, None)
782 809 if mergefn is None:
783 810 raise error.Abort(
784 811 _(b"%s does not have function: %s") % (toolpath, scriptfn)
785 812 )
786 813 argslist = procutil.shellsplit(args)
787 814 # avoid cycle cmdutil->merge->filemerge->hook->extensions->cmdutil
788 815 from . import hook
789 816
790 817 ret, raised = hook.pythonhook(
791 818 ui, repo, b"merge", toolpath, mergefn, {b'args': argslist}, True
792 819 )
793 820 if raised:
794 821 r = 1
795 822 repo.ui.debug(b'merge tool returned: %d\n' % r)
796 823 return True, r, False
797 824
798 825
799 826 def _formatconflictmarker(ctx, template, label, pad):
800 827 """Applies the given template to the ctx, prefixed by the label.
801 828
802 829 Pad is the minimum width of the label prefix, so that multiple markers
803 830 can have aligned templated parts.
804 831 """
805 832 if ctx.node() is None:
806 833 ctx = ctx.p1()
807 834
808 835 props = {b'ctx': ctx}
809 836 templateresult = template.renderdefault(props)
810 837
811 838 label = (b'%s:' % label).ljust(pad + 1)
812 839 mark = b'%s %s' % (label, templateresult)
813 840
814 841 if mark:
815 842 mark = mark.splitlines()[0] # split for safety
816 843
817 844 # 8 for the prefix of conflict marker lines (e.g. '<<<<<<< ')
818 845 return stringutil.ellipsis(mark, 80 - 8)
819 846
820 847
821 848 _defaultconflictlabels = [b'local', b'other']
822 849
823 850
824 851 def _formatlabels(repo, fcd, fco, fca, labels, tool=None):
825 852 """Formats the given labels using the conflict marker template.
826 853
827 854 Returns a list of formatted labels.
828 855 """
829 856 cd = fcd.changectx()
830 857 co = fco.changectx()
831 858 ca = fca.changectx()
832 859
833 860 ui = repo.ui
834 861 template = ui.config(b'command-templates', b'mergemarker')
835 862 if tool is not None:
836 863 template = _toolstr(ui, tool, b'mergemarkertemplate', template)
837 864 template = templater.unquotestring(template)
838 865 tres = formatter.templateresources(ui, repo)
839 866 tmpl = formatter.maketemplater(
840 867 ui, template, defaults=templatekw.keywords, resources=tres
841 868 )
842 869
843 870 pad = max(len(l) for l in labels)
844 871
845 872 newlabels = [
846 873 _formatconflictmarker(cd, tmpl, labels[0], pad),
847 874 _formatconflictmarker(co, tmpl, labels[1], pad),
848 875 ]
849 876 if len(labels) > 2:
850 877 newlabels.append(_formatconflictmarker(ca, tmpl, labels[2], pad))
851 878 return newlabels
852 879
853 880
854 881 def partextras(labels):
855 882 """Return a dictionary of extra labels for use in prompts to the user
856 883
857 884 Intended use is in strings of the form "(l)ocal%(l)s".
858 885 """
859 886 if labels is None:
860 887 return {
861 888 b"l": b"",
862 889 b"o": b"",
863 890 }
864 891
865 892 return {
866 893 b"l": b" [%s]" % labels[0],
867 894 b"o": b" [%s]" % labels[1],
868 895 }
869 896
870 897
871 898 def _restorebackup(fcd, back):
872 899 # TODO: Add a workingfilectx.write(otherfilectx) path so we can use
873 900 # util.copy here instead.
874 901 fcd.write(back.data(), fcd.flags())
875 902
876 903
877 904 def _makebackup(repo, ui, wctx, fcd, premerge):
878 905 """Makes and returns a filectx-like object for ``fcd``'s backup file.
879 906
880 907 In addition to preserving the user's pre-existing modifications to `fcd`
881 908 (if any), the backup is used to undo certain premerges, confirm whether a
882 909 merge changed anything, and determine what line endings the new file should
883 910 have.
884 911
885 912 Backups only need to be written once (right before the premerge) since their
886 913 content doesn't change afterwards.
887 914 """
888 915 if fcd.isabsent():
889 916 return None
890 917 # TODO: Break this import cycle somehow. (filectx -> ctx -> fileset ->
891 918 # merge -> filemerge). (I suspect the fileset import is the weakest link)
892 919 from . import context
893 920
894 921 back = scmutil.backuppath(ui, repo, fcd.path())
895 922 inworkingdir = back.startswith(repo.wvfs.base) and not back.startswith(
896 923 repo.vfs.base
897 924 )
898 925 if isinstance(fcd, context.overlayworkingfilectx) and inworkingdir:
899 926 # If the backup file is to be in the working directory, and we're
900 927 # merging in-memory, we must redirect the backup to the memory context
901 928 # so we don't disturb the working directory.
902 929 relpath = back[len(repo.wvfs.base) + 1 :]
903 930 if premerge:
904 931 wctx[relpath].write(fcd.data(), fcd.flags())
905 932 return wctx[relpath]
906 933 else:
907 934 if premerge:
908 935 # Otherwise, write to wherever path the user specified the backups
909 936 # should go. We still need to switch based on whether the source is
910 937 # in-memory so we can use the fast path of ``util.copy`` if both are
911 938 # on disk.
912 939 if isinstance(fcd, context.overlayworkingfilectx):
913 940 util.writefile(back, fcd.data())
914 941 else:
915 942 a = _workingpath(repo, fcd)
916 943 util.copyfile(a, back)
917 944 # A arbitraryfilectx is returned, so we can run the same functions on
918 945 # the backup context regardless of where it lives.
919 946 return context.arbitraryfilectx(back, repo=repo)
920 947
921 948
922 949 @contextlib.contextmanager
923 950 def _maketempfiles(repo, fco, fca, localpath, uselocalpath):
924 951 """Writes out `fco` and `fca` as temporary files, and (if uselocalpath)
925 952 copies `localpath` to another temporary file, so an external merge tool may
926 953 use them.
927 954 """
928 955 tmproot = None
929 956 tmprootprefix = repo.ui.config(b'experimental', b'mergetempdirprefix')
930 957 if tmprootprefix:
931 958 tmproot = pycompat.mkdtemp(prefix=tmprootprefix)
932 959
933 960 def maketempfrompath(prefix, path):
934 961 fullbase, ext = os.path.splitext(path)
935 962 pre = b"%s~%s" % (os.path.basename(fullbase), prefix)
936 963 if tmproot:
937 964 name = os.path.join(tmproot, pre)
938 965 if ext:
939 966 name += ext
940 967 f = open(name, "wb")
941 968 else:
942 969 fd, name = pycompat.mkstemp(prefix=pre + b'.', suffix=ext)
943 970 f = os.fdopen(fd, "wb")
944 971 return f, name
945 972
946 973 def tempfromcontext(prefix, ctx):
947 974 f, name = maketempfrompath(prefix, ctx.path())
948 975 data = repo.wwritedata(ctx.path(), ctx.data())
949 976 f.write(data)
950 977 f.close()
951 978 return name
952 979
953 980 b = tempfromcontext(b"base", fca)
954 981 c = tempfromcontext(b"other", fco)
955 982 d = localpath
956 983 if uselocalpath:
957 984 # We start off with this being the backup filename, so remove the .orig
958 985 # to make syntax-highlighting more likely.
959 986 if d.endswith(b'.orig'):
960 987 d, _ = os.path.splitext(d)
961 988 f, d = maketempfrompath(b"local", d)
962 989 with open(localpath, b'rb') as src:
963 990 f.write(src.read())
964 991 f.close()
965 992
966 993 try:
967 994 yield b, c, d
968 995 finally:
969 996 if tmproot:
970 997 shutil.rmtree(tmproot)
971 998 else:
972 999 util.unlink(b)
973 1000 util.unlink(c)
974 1001 # if not uselocalpath, d is the 'orig'/backup file which we
975 1002 # shouldn't delete.
976 1003 if d and uselocalpath:
977 1004 util.unlink(d)
978 1005
979 1006
980 1007 def _filemerge(premerge, repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
981 1008 """perform a 3-way merge in the working directory
982 1009
983 1010 premerge = whether this is a premerge
984 1011 mynode = parent node before merge
985 1012 orig = original local filename before merge
986 1013 fco = other file context
987 1014 fca = ancestor file context
988 1015 fcd = local file context for current/destination file
989 1016
990 1017 Returns whether the merge is complete, the return value of the merge, and
991 1018 a boolean indicating whether the file was deleted from disk."""
992 1019
993 1020 if not fco.cmp(fcd): # files identical?
994 1021 return True, None, False
995 1022
996 1023 ui = repo.ui
997 1024 fd = fcd.path()
998 1025 uipathfn = scmutil.getuipathfn(repo)
999 1026 fduipath = uipathfn(fd)
1000 1027 binary = fcd.isbinary() or fco.isbinary() or fca.isbinary()
1001 1028 symlink = b'l' in fcd.flags() + fco.flags()
1002 1029 changedelete = fcd.isabsent() or fco.isabsent()
1003 1030 tool, toolpath = _picktool(repo, ui, fd, binary, symlink, changedelete)
1004 1031 scriptfn = None
1005 1032 if tool in internals and tool.startswith(b'internal:'):
1006 1033 # normalize to new-style names (':merge' etc)
1007 1034 tool = tool[len(b'internal') :]
1008 1035 if toolpath and toolpath.startswith(b'python:'):
1009 1036 invalidsyntax = False
1010 1037 if toolpath.count(b':') >= 2:
1011 1038 script, scriptfn = toolpath[7:].rsplit(b':', 1)
1012 1039 if not scriptfn:
1013 1040 invalidsyntax = True
1014 1041 # missing :callable can lead to spliting on windows drive letter
1015 1042 if b'\\' in scriptfn or b'/' in scriptfn:
1016 1043 invalidsyntax = True
1017 1044 else:
1018 1045 invalidsyntax = True
1019 1046 if invalidsyntax:
1020 1047 raise error.Abort(_(b"invalid 'python:' syntax: %s") % toolpath)
1021 1048 toolpath = script
1022 1049 ui.debug(
1023 1050 b"picked tool '%s' for %s (binary %s symlink %s changedelete %s)\n"
1024 1051 % (
1025 1052 tool,
1026 1053 fduipath,
1027 1054 pycompat.bytestr(binary),
1028 1055 pycompat.bytestr(symlink),
1029 1056 pycompat.bytestr(changedelete),
1030 1057 )
1031 1058 )
1032 1059
1033 1060 if tool in internals:
1034 1061 func = internals[tool]
1035 1062 mergetype = func.mergetype
1036 1063 onfailure = func.onfailure
1037 1064 precheck = func.precheck
1038 1065 isexternal = False
1039 1066 else:
1040 1067 if wctx.isinmemory():
1041 1068 func = _xmergeimm
1042 1069 else:
1043 1070 func = _xmerge
1044 1071 mergetype = fullmerge
1045 1072 onfailure = _(b"merging %s failed!\n")
1046 1073 precheck = None
1047 1074 isexternal = True
1048 1075
1049 1076 toolconf = tool, toolpath, binary, symlink, scriptfn
1050 1077
1051 1078 if mergetype == nomerge:
1052 1079 r, deleted = func(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
1053 1080 return True, r, deleted
1054 1081
1055 1082 if premerge:
1056 1083 if orig != fco.path():
1057 1084 ui.status(
1058 1085 _(b"merging %s and %s to %s\n")
1059 1086 % (uipathfn(orig), uipathfn(fco.path()), fduipath)
1060 1087 )
1061 1088 else:
1062 1089 ui.status(_(b"merging %s\n") % fduipath)
1063 1090
1064 1091 ui.debug(b"my %s other %s ancestor %s\n" % (fcd, fco, fca))
1065 1092
1066 1093 if precheck and not precheck(repo, mynode, orig, fcd, fco, fca, toolconf):
1067 1094 if onfailure:
1068 1095 if wctx.isinmemory():
1069 1096 raise error.InMemoryMergeConflictsError(
1070 1097 b'in-memory merge does not support merge conflicts'
1071 1098 )
1072 1099 ui.warn(onfailure % fduipath)
1073 1100 return True, 1, False
1074 1101
1075 1102 back = _makebackup(repo, ui, wctx, fcd, premerge)
1076 1103 files = (None, None, None, back)
1077 1104 r = 1
1078 1105 try:
1079 1106 internalmarkerstyle = ui.config(b'ui', b'mergemarkers')
1080 1107 if isexternal:
1081 1108 markerstyle = _toolstr(ui, tool, b'mergemarkers')
1082 1109 else:
1083 1110 markerstyle = internalmarkerstyle
1084 1111
1085 1112 if not labels:
1086 1113 labels = _defaultconflictlabels
1087 1114 formattedlabels = labels
1088 1115 if markerstyle != b'basic':
1089 1116 formattedlabels = _formatlabels(
1090 1117 repo, fcd, fco, fca, labels, tool=tool
1091 1118 )
1092 1119
1093 1120 if premerge and mergetype == fullmerge:
1094 1121 # conflict markers generated by premerge will use 'detailed'
1095 1122 # settings if either ui.mergemarkers or the tool's mergemarkers
1096 1123 # setting is 'detailed'. This way tools can have basic labels in
1097 1124 # space-constrained areas of the UI, but still get full information
1098 1125 # in conflict markers if premerge is 'keep' or 'keep-merge3'.
1099 1126 premergelabels = labels
1100 1127 labeltool = None
1101 1128 if markerstyle != b'basic':
1102 1129 # respect 'tool's mergemarkertemplate (which defaults to
1103 1130 # command-templates.mergemarker)
1104 1131 labeltool = tool
1105 1132 if internalmarkerstyle != b'basic' or markerstyle != b'basic':
1106 1133 premergelabels = _formatlabels(
1107 1134 repo, fcd, fco, fca, premergelabels, tool=labeltool
1108 1135 )
1109 1136
1110 1137 r = _premerge(
1111 1138 repo, fcd, fco, fca, toolconf, files, labels=premergelabels
1112 1139 )
1113 1140 # complete if premerge successful (r is 0)
1114 1141 return not r, r, False
1115 1142
1116 1143 needcheck, r, deleted = func(
1117 1144 repo,
1118 1145 mynode,
1119 1146 orig,
1120 1147 fcd,
1121 1148 fco,
1122 1149 fca,
1123 1150 toolconf,
1124 1151 files,
1125 1152 labels=formattedlabels,
1126 1153 )
1127 1154
1128 1155 if needcheck:
1129 1156 r = _check(repo, r, ui, tool, fcd, files)
1130 1157
1131 1158 if r:
1132 1159 if onfailure:
1133 1160 if wctx.isinmemory():
1134 1161 raise error.InMemoryMergeConflictsError(
1135 1162 b'in-memory merge '
1136 1163 b'does not support '
1137 1164 b'merge conflicts'
1138 1165 )
1139 1166 ui.warn(onfailure % fduipath)
1140 1167 _onfilemergefailure(ui)
1141 1168
1142 1169 return True, r, deleted
1143 1170 finally:
1144 1171 if not r and back is not None:
1145 1172 back.remove()
1146 1173
1147 1174
1148 1175 def _haltmerge():
1149 1176 msg = _(b'merge halted after failed merge (see hg resolve)')
1150 1177 raise error.InterventionRequired(msg)
1151 1178
1152 1179
1153 1180 def _onfilemergefailure(ui):
1154 1181 action = ui.config(b'merge', b'on-failure')
1155 1182 if action == b'prompt':
1156 1183 msg = _(b'continue merge operation (yn)?$$ &Yes $$ &No')
1157 1184 if ui.promptchoice(msg, 0) == 1:
1158 1185 _haltmerge()
1159 1186 if action == b'halt':
1160 1187 _haltmerge()
1161 1188 # default action is 'continue', in which case we neither prompt nor halt
1162 1189
1163 1190
1164 1191 def hasconflictmarkers(data):
1165 1192 return bool(
1166 1193 re.search(b"^(<<<<<<< .*|=======|>>>>>>> .*)$", data, re.MULTILINE)
1167 1194 )
1168 1195
1169 1196
1170 1197 def _check(repo, r, ui, tool, fcd, files):
1171 1198 fd = fcd.path()
1172 1199 uipathfn = scmutil.getuipathfn(repo)
1173 1200 unused, unused, unused, back = files
1174 1201
1175 1202 if not r and (
1176 1203 _toolbool(ui, tool, b"checkconflicts")
1177 1204 or b'conflicts' in _toollist(ui, tool, b"check")
1178 1205 ):
1179 1206 if hasconflictmarkers(fcd.data()):
1180 1207 r = 1
1181 1208
1182 1209 checked = False
1183 1210 if b'prompt' in _toollist(ui, tool, b"check"):
1184 1211 checked = True
1185 1212 if ui.promptchoice(
1186 1213 _(b"was merge of '%s' successful (yn)?$$ &Yes $$ &No")
1187 1214 % uipathfn(fd),
1188 1215 1,
1189 1216 ):
1190 1217 r = 1
1191 1218
1192 1219 if (
1193 1220 not r
1194 1221 and not checked
1195 1222 and (
1196 1223 _toolbool(ui, tool, b"checkchanged")
1197 1224 or b'changed' in _toollist(ui, tool, b"check")
1198 1225 )
1199 1226 ):
1200 1227 if back is not None and not fcd.cmp(back):
1201 1228 if ui.promptchoice(
1202 1229 _(
1203 1230 b" output file %s appears unchanged\n"
1204 1231 b"was merge successful (yn)?"
1205 1232 b"$$ &Yes $$ &No"
1206 1233 )
1207 1234 % uipathfn(fd),
1208 1235 1,
1209 1236 ):
1210 1237 r = 1
1211 1238
1212 1239 if back is not None and _toolbool(ui, tool, b"fixeol"):
1213 1240 _matcheol(_workingpath(repo, fcd), back)
1214 1241
1215 1242 return r
1216 1243
1217 1244
1218 1245 def _workingpath(repo, ctx):
1219 1246 return repo.wjoin(ctx.path())
1220 1247
1221 1248
1222 1249 def premerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
1223 1250 return _filemerge(
1224 1251 True, repo, wctx, mynode, orig, fcd, fco, fca, labels=labels
1225 1252 )
1226 1253
1227 1254
1228 1255 def filemerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
1229 1256 return _filemerge(
1230 1257 False, repo, wctx, mynode, orig, fcd, fco, fca, labels=labels
1231 1258 )
1232 1259
1233 1260
1234 1261 def loadinternalmerge(ui, extname, registrarobj):
1235 1262 """Load internal merge tool from specified registrarobj"""
1236 1263 for name, func in pycompat.iteritems(registrarobj._table):
1237 1264 fullname = b':' + name
1238 1265 internals[fullname] = func
1239 1266 internals[b'internal:' + name] = func
1240 1267 internalsdoc[fullname] = func
1241 1268
1242 1269 capabilities = sorted([k for k, v in func.capabilities.items() if v])
1243 1270 if capabilities:
1244 1271 capdesc = b" (actual capabilities: %s)" % b', '.join(
1245 1272 capabilities
1246 1273 )
1247 1274 func.__doc__ = func.__doc__ + pycompat.sysstr(b"\n\n%s" % capdesc)
1248 1275
1249 1276 # to put i18n comments into hg.pot for automatically generated texts
1250 1277
1251 1278 # i18n: "binary" and "symlink" are keywords
1252 1279 # i18n: this text is added automatically
1253 1280 _(b" (actual capabilities: binary, symlink)")
1254 1281 # i18n: "binary" is keyword
1255 1282 # i18n: this text is added automatically
1256 1283 _(b" (actual capabilities: binary)")
1257 1284 # i18n: "symlink" is keyword
1258 1285 # i18n: this text is added automatically
1259 1286 _(b" (actual capabilities: symlink)")
1260 1287
1261 1288
1262 1289 # load built-in merge tools explicitly to setup internalsdoc
1263 1290 loadinternalmerge(None, None, internaltool)
1264 1291
1265 1292 # tell hggettext to extract docstrings from these functions:
1266 1293 i18nfunctions = internals.values()
@@ -1,523 +1,591 b''
1 1 # Copyright (C) 2004, 2005 Canonical Ltd
2 2 #
3 3 # This program is free software; you can redistribute it and/or modify
4 4 # it under the terms of the GNU General Public License as published by
5 5 # the Free Software Foundation; either version 2 of the License, or
6 6 # (at your option) any later version.
7 7 #
8 8 # This program is distributed in the hope that it will be useful,
9 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 11 # GNU General Public License for more details.
12 12 #
13 13 # You should have received a copy of the GNU General Public License
14 14 # along with this program; if not, see <http://www.gnu.org/licenses/>.
15 15
16 16 # mbp: "you know that thing where cvs gives you conflict markers?"
17 17 # s: "i hate that."
18 18
19 19 from __future__ import absolute_import
20 20
21 21 from .i18n import _
22 22 from . import (
23 23 error,
24 24 mdiff,
25 25 node as nodemod,
26 26 pycompat,
27 27 util,
28 28 )
29 29 from .utils import stringutil
30 30
31 31
32 32 class CantReprocessAndShowBase(Exception):
33 33 pass
34 34
35 35
36 36 def intersect(ra, rb):
37 37 """Given two ranges return the range where they intersect or None.
38 38
39 39 >>> intersect((0, 10), (0, 6))
40 40 (0, 6)
41 41 >>> intersect((0, 10), (5, 15))
42 42 (5, 10)
43 43 >>> intersect((0, 10), (10, 15))
44 44 >>> intersect((0, 9), (10, 15))
45 45 >>> intersect((0, 9), (7, 15))
46 46 (7, 9)
47 47 """
48 48 assert ra[0] <= ra[1]
49 49 assert rb[0] <= rb[1]
50 50
51 51 sa = max(ra[0], rb[0])
52 52 sb = min(ra[1], rb[1])
53 53 if sa < sb:
54 54 return sa, sb
55 55 else:
56 56 return None
57 57
58 58
59 59 def compare_range(a, astart, aend, b, bstart, bend):
60 60 """Compare a[astart:aend] == b[bstart:bend], without slicing."""
61 61 if (aend - astart) != (bend - bstart):
62 62 return False
63 63 for ia, ib in zip(
64 64 pycompat.xrange(astart, aend), pycompat.xrange(bstart, bend)
65 65 ):
66 66 if a[ia] != b[ib]:
67 67 return False
68 68 else:
69 69 return True
70 70
71 71
72 72 class Merge3Text(object):
73 73 """3-way merge of texts.
74 74
75 75 Given strings BASE, OTHER, THIS, tries to produce a combined text
76 76 incorporating the changes from both BASE->OTHER and BASE->THIS."""
77 77
78 78 def __init__(self, basetext, atext, btext, base=None, a=None, b=None):
79 79 self.basetext = basetext
80 80 self.atext = atext
81 81 self.btext = btext
82 82 if base is None:
83 83 base = mdiff.splitnewlines(basetext)
84 84 if a is None:
85 85 a = mdiff.splitnewlines(atext)
86 86 if b is None:
87 87 b = mdiff.splitnewlines(btext)
88 88 self.base = base
89 89 self.a = a
90 90 self.b = b
91 91
92 92 def merge_lines(
93 93 self,
94 94 name_a=None,
95 95 name_b=None,
96 96 name_base=None,
97 97 start_marker=b'<<<<<<<',
98 98 mid_marker=b'=======',
99 99 end_marker=b'>>>>>>>',
100 100 base_marker=None,
101 101 localorother=None,
102 102 minimize=False,
103 103 ):
104 104 """Return merge in cvs-like form."""
105 105 self.conflicts = False
106 106 newline = b'\n'
107 107 if len(self.a) > 0:
108 108 if self.a[0].endswith(b'\r\n'):
109 109 newline = b'\r\n'
110 110 elif self.a[0].endswith(b'\r'):
111 111 newline = b'\r'
112 112 if name_a and start_marker:
113 113 start_marker = start_marker + b' ' + name_a
114 114 if name_b and end_marker:
115 115 end_marker = end_marker + b' ' + name_b
116 116 if name_base and base_marker:
117 117 base_marker = base_marker + b' ' + name_base
118 118 merge_regions = self.merge_regions()
119 119 if minimize:
120 120 merge_regions = self.minimize(merge_regions)
121 121 for t in merge_regions:
122 122 what = t[0]
123 123 if what == b'unchanged':
124 124 for i in range(t[1], t[2]):
125 125 yield self.base[i]
126 126 elif what == b'a' or what == b'same':
127 127 for i in range(t[1], t[2]):
128 128 yield self.a[i]
129 129 elif what == b'b':
130 130 for i in range(t[1], t[2]):
131 131 yield self.b[i]
132 132 elif what == b'conflict':
133 133 if localorother == b'local':
134 134 for i in range(t[3], t[4]):
135 135 yield self.a[i]
136 136 elif localorother == b'other':
137 137 for i in range(t[5], t[6]):
138 138 yield self.b[i]
139 139 else:
140 140 self.conflicts = True
141 141 if start_marker is not None:
142 142 yield start_marker + newline
143 143 for i in range(t[3], t[4]):
144 144 yield self.a[i]
145 145 if base_marker is not None:
146 146 yield base_marker + newline
147 147 for i in range(t[1], t[2]):
148 148 yield self.base[i]
149 149 if mid_marker is not None:
150 150 yield mid_marker + newline
151 151 for i in range(t[5], t[6]):
152 152 yield self.b[i]
153 153 if end_marker is not None:
154 154 yield end_marker + newline
155 155 else:
156 156 raise ValueError(what)
157 157
158 158 def merge_groups(self):
159 159 """Yield sequence of line groups. Each one is a tuple:
160 160
161 161 'unchanged', lines
162 162 Lines unchanged from base
163 163
164 164 'a', lines
165 165 Lines taken from a
166 166
167 167 'same', lines
168 168 Lines taken from a (and equal to b)
169 169
170 170 'b', lines
171 171 Lines taken from b
172 172
173 173 'conflict', base_lines, a_lines, b_lines
174 174 Lines from base were changed to either a or b and conflict.
175 175 """
176 176 for t in self.merge_regions():
177 177 what = t[0]
178 178 if what == b'unchanged':
179 179 yield what, self.base[t[1] : t[2]]
180 180 elif what == b'a' or what == b'same':
181 181 yield what, self.a[t[1] : t[2]]
182 182 elif what == b'b':
183 183 yield what, self.b[t[1] : t[2]]
184 184 elif what == b'conflict':
185 185 yield (
186 186 what,
187 187 self.base[t[1] : t[2]],
188 188 self.a[t[3] : t[4]],
189 189 self.b[t[5] : t[6]],
190 190 )
191 191 else:
192 192 raise ValueError(what)
193 193
194 194 def merge_regions(self):
195 195 """Return sequences of matching and conflicting regions.
196 196
197 197 This returns tuples, where the first value says what kind we
198 198 have:
199 199
200 200 'unchanged', start, end
201 201 Take a region of base[start:end]
202 202
203 203 'same', astart, aend
204 204 b and a are different from base but give the same result
205 205
206 206 'a', start, end
207 207 Non-clashing insertion from a[start:end]
208 208
209 209 'conflict', zstart, zend, astart, aend, bstart, bend
210 210 Conflict between a and b, with z as common ancestor
211 211
212 212 Method is as follows:
213 213
214 214 The two sequences align only on regions which match the base
215 215 and both descendants. These are found by doing a two-way diff
216 216 of each one against the base, and then finding the
217 217 intersections between those regions. These "sync regions"
218 218 are by definition unchanged in both and easily dealt with.
219 219
220 220 The regions in between can be in any of three cases:
221 221 conflicted, or changed on only one side.
222 222 """
223 223
224 224 # section a[0:ia] has been disposed of, etc
225 225 iz = ia = ib = 0
226 226
227 227 for region in self.find_sync_regions():
228 228 zmatch, zend, amatch, aend, bmatch, bend = region
229 229 # print 'match base [%d:%d]' % (zmatch, zend)
230 230
231 231 matchlen = zend - zmatch
232 232 assert matchlen >= 0
233 233 assert matchlen == (aend - amatch)
234 234 assert matchlen == (bend - bmatch)
235 235
236 236 len_a = amatch - ia
237 237 len_b = bmatch - ib
238 238 len_base = zmatch - iz
239 239 assert len_a >= 0
240 240 assert len_b >= 0
241 241 assert len_base >= 0
242 242
243 243 # print 'unmatched a=%d, b=%d' % (len_a, len_b)
244 244
245 245 if len_a or len_b:
246 246 # try to avoid actually slicing the lists
247 247 equal_a = compare_range(
248 248 self.a, ia, amatch, self.base, iz, zmatch
249 249 )
250 250 equal_b = compare_range(
251 251 self.b, ib, bmatch, self.base, iz, zmatch
252 252 )
253 253 same = compare_range(self.a, ia, amatch, self.b, ib, bmatch)
254 254
255 255 if same:
256 256 yield b'same', ia, amatch
257 257 elif equal_a and not equal_b:
258 258 yield b'b', ib, bmatch
259 259 elif equal_b and not equal_a:
260 260 yield b'a', ia, amatch
261 261 elif not equal_a and not equal_b:
262 262 yield b'conflict', iz, zmatch, ia, amatch, ib, bmatch
263 263 else:
264 264 raise AssertionError(b"can't handle a=b=base but unmatched")
265 265
266 266 ia = amatch
267 267 ib = bmatch
268 268 iz = zmatch
269 269
270 270 # if the same part of the base was deleted on both sides
271 271 # that's OK, we can just skip it.
272 272
273 273 if matchlen > 0:
274 274 assert ia == amatch
275 275 assert ib == bmatch
276 276 assert iz == zmatch
277 277
278 278 yield b'unchanged', zmatch, zend
279 279 iz = zend
280 280 ia = aend
281 281 ib = bend
282 282
283 283 def minimize(self, merge_regions):
284 284 """Trim conflict regions of lines where A and B sides match.
285 285
286 286 Lines where both A and B have made the same changes at the beginning
287 287 or the end of each merge region are eliminated from the conflict
288 288 region and are instead considered the same.
289 289 """
290 290 for region in merge_regions:
291 291 if region[0] != b"conflict":
292 292 yield region
293 293 continue
294 294 # pytype thinks this tuple contains only 3 things, but
295 295 # that's clearly not true because this code successfully
296 296 # executes. It might be wise to rework merge_regions to be
297 297 # some kind of attrs type.
298 298 (
299 299 issue,
300 300 z1,
301 301 z2,
302 302 a1,
303 303 a2,
304 304 b1,
305 305 b2,
306 306 ) = region # pytype: disable=bad-unpacking
307 307 alen = a2 - a1
308 308 blen = b2 - b1
309 309
310 310 # find matches at the front
311 311 ii = 0
312 312 while (
313 313 ii < alen and ii < blen and self.a[a1 + ii] == self.b[b1 + ii]
314 314 ):
315 315 ii += 1
316 316 startmatches = ii
317 317
318 318 # find matches at the end
319 319 ii = 0
320 320 while (
321 321 ii < alen
322 322 and ii < blen
323 323 and self.a[a2 - ii - 1] == self.b[b2 - ii - 1]
324 324 ):
325 325 ii += 1
326 326 endmatches = ii
327 327
328 328 if startmatches > 0:
329 329 yield b'same', a1, a1 + startmatches
330 330
331 331 yield (
332 332 b'conflict',
333 333 z1,
334 334 z2,
335 335 a1 + startmatches,
336 336 a2 - endmatches,
337 337 b1 + startmatches,
338 338 b2 - endmatches,
339 339 )
340 340
341 341 if endmatches > 0:
342 342 yield b'same', a2 - endmatches, a2
343 343
344 344 def find_sync_regions(self):
345 345 """Return a list of sync regions, where both descendants match the base.
346 346
347 347 Generates a list of (base1, base2, a1, a2, b1, b2). There is
348 348 always a zero-length sync region at the end of all the files.
349 349 """
350 350
351 351 ia = ib = 0
352 352 amatches = mdiff.get_matching_blocks(self.basetext, self.atext)
353 353 bmatches = mdiff.get_matching_blocks(self.basetext, self.btext)
354 354 len_a = len(amatches)
355 355 len_b = len(bmatches)
356 356
357 357 sl = []
358 358
359 359 while ia < len_a and ib < len_b:
360 360 abase, amatch, alen = amatches[ia]
361 361 bbase, bmatch, blen = bmatches[ib]
362 362
363 363 # there is an unconflicted block at i; how long does it
364 364 # extend? until whichever one ends earlier.
365 365 i = intersect((abase, abase + alen), (bbase, bbase + blen))
366 366 if i:
367 367 intbase = i[0]
368 368 intend = i[1]
369 369 intlen = intend - intbase
370 370
371 371 # found a match of base[i[0], i[1]]; this may be less than
372 372 # the region that matches in either one
373 373 assert intlen <= alen
374 374 assert intlen <= blen
375 375 assert abase <= intbase
376 376 assert bbase <= intbase
377 377
378 378 asub = amatch + (intbase - abase)
379 379 bsub = bmatch + (intbase - bbase)
380 380 aend = asub + intlen
381 381 bend = bsub + intlen
382 382
383 383 assert self.base[intbase:intend] == self.a[asub:aend], (
384 384 self.base[intbase:intend],
385 385 self.a[asub:aend],
386 386 )
387 387
388 388 assert self.base[intbase:intend] == self.b[bsub:bend]
389 389
390 390 sl.append((intbase, intend, asub, aend, bsub, bend))
391 391
392 392 # advance whichever one ends first in the base text
393 393 if (abase + alen) < (bbase + blen):
394 394 ia += 1
395 395 else:
396 396 ib += 1
397 397
398 398 intbase = len(self.base)
399 399 abase = len(self.a)
400 400 bbase = len(self.b)
401 401 sl.append((intbase, intbase, abase, abase, bbase, bbase))
402 402
403 403 return sl
404 404
405 405 def find_unconflicted(self):
406 406 """Return a list of ranges in base that are not conflicted."""
407 407 am = mdiff.get_matching_blocks(self.basetext, self.atext)
408 408 bm = mdiff.get_matching_blocks(self.basetext, self.btext)
409 409
410 410 unc = []
411 411
412 412 while am and bm:
413 413 # there is an unconflicted block at i; how long does it
414 414 # extend? until whichever one ends earlier.
415 415 a1 = am[0][0]
416 416 a2 = a1 + am[0][2]
417 417 b1 = bm[0][0]
418 418 b2 = b1 + bm[0][2]
419 419 i = intersect((a1, a2), (b1, b2))
420 420 if i:
421 421 unc.append(i)
422 422
423 423 if a2 < b2:
424 424 del am[0]
425 425 else:
426 426 del bm[0]
427 427
428 428 return unc
429 429
430 430
431 431 def _verifytext(text, path, ui, opts):
432 432 """verifies that text is non-binary (unless opts[text] is passed,
433 433 then we just warn)"""
434 434 if stringutil.binary(text):
435 435 msg = _(b"%s looks like a binary file.") % path
436 436 if not opts.get('quiet'):
437 437 ui.warn(_(b'warning: %s\n') % msg)
438 438 if not opts.get('text'):
439 439 raise error.Abort(msg)
440 440 return text
441 441
442 442
443 443 def _picklabels(defaults, overrides):
444 444 if len(overrides) > 3:
445 445 raise error.Abort(_(b"can only specify three labels."))
446 446 result = defaults[:]
447 447 for i, override in enumerate(overrides):
448 448 result[i] = override
449 449 return result
450 450
451 451
452 452 def is_not_null(ctx):
453 453 if not util.safehasattr(ctx, "node"):
454 454 return False
455 455 return ctx.node() != nodemod.nullid
456 456
457 457
458 def _mergediff(m3, name_a, name_b, name_base):
459 lines = []
460 conflicts = False
461 for group in m3.merge_groups():
462 if group[0] == b'conflict':
463 base_lines, a_lines, b_lines = group[1:]
464 base_text = b''.join(base_lines)
465 b_blocks = list(
466 mdiff.allblocks(
467 base_text,
468 b''.join(b_lines),
469 lines1=base_lines,
470 lines2=b_lines,
471 )
472 )
473 a_blocks = list(
474 mdiff.allblocks(
475 base_text,
476 b''.join(a_lines),
477 lines1=base_lines,
478 lines2=b_lines,
479 )
480 )
481
482 def matching_lines(blocks):
483 return sum(
484 block[1] - block[0]
485 for block, kind in blocks
486 if kind == b'='
487 )
488
489 def diff_lines(blocks, lines1, lines2):
490 for block, kind in blocks:
491 if kind == b'=':
492 for line in lines1[block[0] : block[1]]:
493 yield b' ' + line
494 else:
495 for line in lines1[block[0] : block[1]]:
496 yield b'-' + line
497 for line in lines2[block[2] : block[3]]:
498 yield b'+' + line
499
500 lines.append(b"<<<<<<<\n")
501 if matching_lines(a_blocks) < matching_lines(b_blocks):
502 lines.append(b"======= %s\n" % name_a)
503 lines.extend(a_lines)
504 lines.append(b"------- %s\n" % name_base)
505 lines.append(b"+++++++ %s\n" % name_b)
506 lines.extend(diff_lines(b_blocks, base_lines, b_lines))
507 else:
508 lines.append(b"------- %s\n" % name_base)
509 lines.append(b"+++++++ %s\n" % name_a)
510 lines.extend(diff_lines(a_blocks, base_lines, a_lines))
511 lines.append(b"======= %s\n" % name_b)
512 lines.extend(b_lines)
513 lines.append(b">>>>>>>\n")
514 conflicts = True
515 else:
516 lines.extend(group[1])
517 return lines, conflicts
518
519
458 520 def simplemerge(ui, localctx, basectx, otherctx, **opts):
459 521 """Performs the simplemerge algorithm.
460 522
461 523 The merged result is written into `localctx`.
462 524 """
463 525
464 526 def readctx(ctx):
465 527 # Merges were always run in the working copy before, which means
466 528 # they used decoded data, if the user defined any repository
467 529 # filters.
468 530 #
469 531 # Maintain that behavior today for BC, though perhaps in the future
470 532 # it'd be worth considering whether merging encoded data (what the
471 533 # repository usually sees) might be more useful.
472 534 return _verifytext(ctx.decodeddata(), ctx.path(), ui, opts)
473 535
474 536 mode = opts.get('mode', b'merge')
475 537 name_a, name_b, name_base = None, None, None
476 538 if mode != b'union':
477 539 name_a, name_b, name_base = _picklabels(
478 540 [localctx.path(), otherctx.path(), None], opts.get('label', [])
479 541 )
480 542
481 543 try:
482 544 localtext = readctx(localctx)
483 545 basetext = readctx(basectx)
484 546 othertext = readctx(otherctx)
485 547 except error.Abort:
486 548 return 1
487 549
488 550 m3 = Merge3Text(basetext, localtext, othertext)
489 551 extrakwargs = {
490 552 b"localorother": opts.get("localorother", None),
491 553 b'minimize': True,
492 554 }
493 555 if mode == b'union':
494 556 extrakwargs[b'start_marker'] = None
495 557 extrakwargs[b'mid_marker'] = None
496 558 extrakwargs[b'end_marker'] = None
497 559 elif name_base is not None:
498 560 extrakwargs[b'base_marker'] = b'|||||||'
499 561 extrakwargs[b'name_base'] = name_base
500 562 extrakwargs[b'minimize'] = False
501 563
502 lines = m3.merge_lines(
503 name_a=name_a, name_b=name_b, **pycompat.strkwargs(extrakwargs)
504 )
564 if mode == b'mergediff':
565 lines, conflicts = _mergediff(m3, name_a, name_b, name_base)
566 else:
567 lines = list(
568 m3.merge_lines(
569 name_a=name_a, name_b=name_b, **pycompat.strkwargs(extrakwargs)
570 )
571 )
572 conflicts = m3.conflicts
505 573
506 574 # merge flags if necessary
507 575 flags = localctx.flags()
508 576 localflags = set(pycompat.iterbytestr(flags))
509 577 otherflags = set(pycompat.iterbytestr(otherctx.flags()))
510 578 if is_not_null(basectx) and localflags != otherflags:
511 579 baseflags = set(pycompat.iterbytestr(basectx.flags()))
512 580 commonflags = localflags & otherflags
513 581 addedflags = (localflags ^ otherflags) - baseflags
514 582 flags = b''.join(sorted(commonflags | addedflags))
515 583
516 584 mergedtext = b''.join(lines)
517 585 if opts.get('print'):
518 586 ui.fout.write(mergedtext)
519 587 else:
520 588 localctx.write(mergedtext, flags)
521 589
522 if m3.conflicts and not mode == b'union':
590 if conflicts and not mode == b'union':
523 591 return 1
@@ -1,49 +1,56 b''
1 1 == New Features ==
2 2
3 3 * There is a new config section for templates used by hg commands. It
4 4 is called `[command-templates]`. Some existing config options have
5 5 been deprecated in favor of config options in the new
6 6 section. These are: `ui.logtemplate` to `command-templates.log`,
7 7 `ui.graphnodetemplate` to `command-templates.graphnode`,
8 8 `ui.mergemarkertemplate` to `command-templates.mergemarker`,
9 9 `ui.pre-merge-tool-output-template` to
10 10 `command-templates.pre-merge-tool-output`.
11 11
12 12 * There is a new set of config options for the template used for the
13 13 one-line commit summary displayed by various commands, such as `hg
14 14 rebase`. The main one is `command-templates.oneline-summary`. That
15 15 can be overridden per command with
16 16 `command-templates.oneline-summary.<command>`, where `<command>`
17 17 can be e.g. `rebase`. As part of this effort, the default format
18 18 from `hg rebase` was reorganized a bit.
19 19
20 20 * `hg strip`, from the strip extension, is now a core command, `hg
21 21 debugstrip`. The extension remains for compatibility.
22 22
23 23 * `hg diff` now supports `--from <rev>` and `--to <rev>` arguments as
24 24 clearer alternatives to `-r <revs>`. `-r <revs>` has been
25 25 deprecated.
26 26
27 27 * The memory footprint per changeset during pull/unbundle
28 28 operations has been further reduced.
29 29
30 * There is a new internal merge tool called `internal:mergediff` (can
31 be set as the value for the `merge` config in the `[ui]`
32 section). It resolves merges the same was as `internal:merge` and
33 `internal:merge3`, but it shows conflicts differently. Instead of
34 showing 2 or 3 snapshots of the conflicting pieces of code, it
35 shows one snapshot and a diff. This may be useful when at least one
36 side of the conflict is similar to the base.
30 37
31 38 == New Experimental Features ==
32 39
33 40 * `experimental.single-head-per-branch:public-changes-only` can be used
34 41 restrict the single head check to public revision. This is useful for
35 42 overlay repository that have both a publishing and non-publishing view
36 43 of the same storage.
37 44
38 45
39 46 == Bug Fixes ==
40 47
41 48
42 49
43 50 == Backwards Compatibility Changes ==
44 51
45 52
46 53
47 54 == Internal API Changes ==
48 55
49 56
@@ -1,348 +1,422 b''
1 1 $ hg init
2 2 $ cat << EOF > a
3 3 > Small Mathematical Series.
4 4 > One
5 5 > Two
6 6 > Three
7 7 > Four
8 8 > Five
9 9 > Hop we are done.
10 10 > EOF
11 11 $ hg add a
12 12 $ hg commit -m ancestor
13 13 $ cat << EOF > a
14 14 > Small Mathematical Series.
15 15 > 1
16 16 > 2
17 17 > 3
18 18 > 4
19 19 > 5
20 20 > Hop we are done.
21 21 > EOF
22 22 $ hg commit -m branch1
23 23 $ hg co 0
24 24 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
25 25 $ cat << EOF > a
26 26 > Small Mathematical Series.
27 27 > 1
28 28 > 2
29 29 > 3
30 30 > 6
31 31 > 8
32 32 > Hop we are done.
33 33 > EOF
34 34 $ hg commit -m branch2
35 35 created new head
36 36
37 37 $ hg merge 1
38 38 merging a
39 39 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
40 40 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
41 41 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
42 42 [1]
43 43
44 44 $ hg id
45 45 618808747361+c0c68e4fe667+ tip
46 46
47 47 $ echo "[commands]" >> $HGRCPATH
48 48 $ echo "status.verbose=true" >> $HGRCPATH
49 49 $ hg status
50 50 M a
51 51 ? a.orig
52 52 # The repository is in an unfinished *merge* state.
53 53
54 54 # Unresolved merge conflicts:
55 55 #
56 56 # a
57 57 #
58 58 # To mark files as resolved: hg resolve --mark FILE
59 59
60 60 # To continue: hg commit
61 61 # To abort: hg merge --abort
62 62
63 63 $ hg status -Tjson
64 64 [
65 65 {
66 66 "itemtype": "file",
67 67 "path": "a",
68 68 "status": "M",
69 69 "unresolved": true
70 70 },
71 71 {
72 72 "itemtype": "file",
73 73 "path": "a.orig",
74 74 "status": "?"
75 75 },
76 76 {
77 77 "itemtype": "morestatus",
78 78 "unfinished": "merge",
79 79 "unfinishedmsg": "To continue: hg commit\nTo abort: hg merge --abort"
80 80 }
81 81 ]
82 82
83 83 $ hg status -0
84 84 M a\x00? a.orig\x00 (no-eol) (esc)
85 85 $ cat a
86 86 Small Mathematical Series.
87 87 1
88 88 2
89 89 3
90 90 <<<<<<< working copy: 618808747361 - test: branch2
91 91 6
92 92 8
93 93 =======
94 94 4
95 95 5
96 96 >>>>>>> merge rev: c0c68e4fe667 - test: branch1
97 97 Hop we are done.
98 98
99 99 $ hg status --config commands.status.verbose=0
100 100 M a
101 101 ? a.orig
102 102
103 103 Verify custom conflict markers
104 104
105 105 $ hg up -q --clean .
106 106 $ cat <<EOF >> .hg/hgrc
107 107 > [command-templates]
108 108 > mergemarker = '{author} {rev}'
109 109 > EOF
110 110
111 111 $ hg merge 1
112 112 merging a
113 113 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
114 114 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
115 115 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
116 116 [1]
117 117
118 118 $ cat a
119 119 Small Mathematical Series.
120 120 1
121 121 2
122 122 3
123 123 <<<<<<< working copy: test 2
124 124 6
125 125 8
126 126 =======
127 127 4
128 128 5
129 129 >>>>>>> merge rev: test 1
130 130 Hop we are done.
131 131
132 132 Verify custom conflict markers with legacy config name
133 133
134 134 $ hg up -q --clean .
135 135 $ cat <<EOF >> .hg/hgrc
136 136 > [ui]
137 137 > mergemarkertemplate = '{author} {rev}'
138 138 > EOF
139 139
140 140 $ hg merge 1
141 141 merging a
142 142 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
143 143 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
144 144 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
145 145 [1]
146 146
147 147 $ cat a
148 148 Small Mathematical Series.
149 149 1
150 150 2
151 151 3
152 152 <<<<<<< working copy: test 2
153 153 6
154 154 8
155 155 =======
156 156 4
157 157 5
158 158 >>>>>>> merge rev: test 1
159 159 Hop we are done.
160 160
161 161 Verify line splitting of custom conflict marker which causes multiple lines
162 162
163 163 $ hg up -q --clean .
164 164 $ cat >> .hg/hgrc <<EOF
165 165 > [command-templates]
166 166 > mergemarker={author} {rev}\nfoo\nbar\nbaz
167 167 > EOF
168 168
169 169 $ hg -q merge 1
170 170 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
171 171 [1]
172 172
173 173 $ cat a
174 174 Small Mathematical Series.
175 175 1
176 176 2
177 177 3
178 178 <<<<<<< working copy: test 2
179 179 6
180 180 8
181 181 =======
182 182 4
183 183 5
184 184 >>>>>>> merge rev: test 1
185 185 Hop we are done.
186 186
187 187 Verify line trimming of custom conflict marker using multi-byte characters
188 188
189 189 $ hg up -q --clean .
190 190 $ "$PYTHON" <<EOF
191 191 > fp = open('logfile', 'wb')
192 192 > fp.write(b'12345678901234567890123456789012345678901234567890' +
193 193 > b'1234567890') # there are 5 more columns for 80 columns
194 194 >
195 195 > # 2 x 4 = 8 columns, but 3 x 4 = 12 bytes
196 196 > fp.write(u'\u3042\u3044\u3046\u3048'.encode('utf-8'))
197 197 >
198 198 > fp.close()
199 199 > EOF
200 200 $ hg add logfile
201 201 $ hg --encoding utf-8 commit --logfile logfile
202 202
203 203 $ cat >> .hg/hgrc <<EOF
204 204 > [command-templates]
205 205 > mergemarker={desc|firstline}
206 206 > EOF
207 207
208 208 $ hg -q --encoding utf-8 merge 1
209 209 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
210 210 [1]
211 211
212 212 $ cat a
213 213 Small Mathematical Series.
214 214 1
215 215 2
216 216 3
217 217 <<<<<<< working copy: 1234567890123456789012345678901234567890123456789012345...
218 218 6
219 219 8
220 220 =======
221 221 4
222 222 5
223 223 >>>>>>> merge rev: branch1
224 224 Hop we are done.
225 225
226 226 Verify basic conflict markers
227 227
228 228 $ hg up -q --clean 2
229 229 $ printf "\n[ui]\nmergemarkers=basic\n" >> .hg/hgrc
230 230
231 231 $ hg merge 1
232 232 merging a
233 233 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
234 234 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
235 235 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
236 236 [1]
237 237
238 238 $ cat a
239 239 Small Mathematical Series.
240 240 1
241 241 2
242 242 3
243 243 <<<<<<< working copy
244 244 6
245 245 8
246 246 =======
247 247 4
248 248 5
249 249 >>>>>>> merge rev
250 250 Hop we are done.
251 251
252 252 internal:merge3
253 253
254 254 $ hg up -q --clean .
255 255
256 256 $ hg merge 1 --tool internal:merge3
257 257 merging a
258 258 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
259 259 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
260 260 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
261 261 [1]
262 262 $ cat a
263 263 Small Mathematical Series.
264 264 <<<<<<< working copy
265 265 1
266 266 2
267 267 3
268 268 6
269 269 8
270 270 ||||||| base
271 271 One
272 272 Two
273 273 Three
274 274 Four
275 275 Five
276 276 =======
277 277 1
278 278 2
279 279 3
280 280 4
281 281 5
282 282 >>>>>>> merge rev
283 283 Hop we are done.
284 284
285 internal:mergediff
286
287 $ hg co -C 1
288 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
289 $ cat << EOF > a
290 > Small Mathematical Series.
291 > 1
292 > 2
293 > 3
294 > 4
295 > 4.5
296 > 5
297 > Hop we are done.
298 > EOF
299 $ hg co -m 2 -t internal:mergediff
300 merging a
301 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
302 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
303 use 'hg resolve' to retry unresolved file merges
304 [1]
305 $ cat a
306 Small Mathematical Series.
307 1
308 2
309 3
310 <<<<<<<
311 ------- base
312 +++++++ working copy
313 4
314 +4.5
315 5
316 ======= destination
317 6
318 8
319 >>>>>>>
320 Hop we are done.
321 Test the same thing as above but modify a bit more so we instead get the working
322 copy in full and the diff from base to destination.
323 $ hg co -C 1
324 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
325 $ cat << EOF > a
326 > Small Mathematical Series.
327 > 1
328 > 2
329 > 3.5
330 > 4.5
331 > 5.5
332 > Hop we are done.
333 > EOF
334 $ hg co -m 2 -t internal:mergediff
335 merging a
336 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
337 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
338 use 'hg resolve' to retry unresolved file merges
339 [1]
340 $ cat a
341 Small Mathematical Series.
342 1
343 2
344 <<<<<<<
345 ======= working copy
346 3.5
347 4.5
348 5.5
349 ------- base
350 +++++++ destination
351 3
352 -4
353 -5
354 +6
355 +8
356 >>>>>>>
357 Hop we are done.
358
285 359 Add some unconflicting changes on each head, to make sure we really
286 360 are merging, unlike :local and :other
287 361
288 362 $ hg up -C
289 363 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
290 364 updated to "e0693e20f496: 123456789012345678901234567890123456789012345678901234567890????"
291 365 1 other heads for branch "default"
292 366 $ printf "\n\nEnd of file\n" >> a
293 367 $ hg ci -m "Add some stuff at the end"
294 368 $ hg up -r 1
295 369 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
296 370 $ printf "Start of file\n\n\n" > tmp
297 371 $ cat a >> tmp
298 372 $ mv tmp a
299 373 $ hg ci -m "Add some stuff at the beginning"
300 374
301 375 Now test :merge-other and :merge-local
302 376
303 377 $ hg merge
304 378 merging a
305 379 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
306 380 1 files updated, 0 files merged, 0 files removed, 1 files unresolved
307 381 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
308 382 [1]
309 383 $ hg resolve --tool :merge-other a
310 384 merging a
311 385 (no more unresolved files)
312 386 $ cat a
313 387 Start of file
314 388
315 389
316 390 Small Mathematical Series.
317 391 1
318 392 2
319 393 3
320 394 6
321 395 8
322 396 Hop we are done.
323 397
324 398
325 399 End of file
326 400
327 401 $ hg up -C
328 402 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
329 403 updated to "18b51d585961: Add some stuff at the beginning"
330 404 1 other heads for branch "default"
331 405 $ hg merge --tool :merge-local
332 406 merging a
333 407 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
334 408 (branch merge, don't forget to commit)
335 409 $ cat a
336 410 Start of file
337 411
338 412
339 413 Small Mathematical Series.
340 414 1
341 415 2
342 416 3
343 417 4
344 418 5
345 419 Hop we are done.
346 420
347 421
348 422 End of file
@@ -1,3924 +1,3931 b''
1 1 Short help:
2 2
3 3 $ hg
4 4 Mercurial Distributed SCM
5 5
6 6 basic commands:
7 7
8 8 add add the specified files on the next commit
9 9 annotate show changeset information by line for each file
10 10 clone make a copy of an existing repository
11 11 commit commit the specified files or all outstanding changes
12 12 diff diff repository (or selected files)
13 13 export dump the header and diffs for one or more changesets
14 14 forget forget the specified files on the next commit
15 15 init create a new repository in the given directory
16 16 log show revision history of entire repository or files
17 17 merge merge another revision into working directory
18 18 pull pull changes from the specified source
19 19 push push changes to the specified destination
20 20 remove remove the specified files on the next commit
21 21 serve start stand-alone webserver
22 22 status show changed files in the working directory
23 23 summary summarize working directory state
24 24 update update working directory (or switch revisions)
25 25
26 26 (use 'hg help' for the full list of commands or 'hg -v' for details)
27 27
28 28 $ hg -q
29 29 add add the specified files on the next commit
30 30 annotate show changeset information by line for each file
31 31 clone make a copy of an existing repository
32 32 commit commit the specified files or all outstanding changes
33 33 diff diff repository (or selected files)
34 34 export dump the header and diffs for one or more changesets
35 35 forget forget the specified files on the next commit
36 36 init create a new repository in the given directory
37 37 log show revision history of entire repository or files
38 38 merge merge another revision into working directory
39 39 pull pull changes from the specified source
40 40 push push changes to the specified destination
41 41 remove remove the specified files on the next commit
42 42 serve start stand-alone webserver
43 43 status show changed files in the working directory
44 44 summary summarize working directory state
45 45 update update working directory (or switch revisions)
46 46
47 47 Extra extensions will be printed in help output in a non-reliable order since
48 48 the extension is unknown.
49 49 #if no-extraextensions
50 50
51 51 $ hg help
52 52 Mercurial Distributed SCM
53 53
54 54 list of commands:
55 55
56 56 Repository creation:
57 57
58 58 clone make a copy of an existing repository
59 59 init create a new repository in the given directory
60 60
61 61 Remote repository management:
62 62
63 63 incoming show new changesets found in source
64 64 outgoing show changesets not found in the destination
65 65 paths show aliases for remote repositories
66 66 pull pull changes from the specified source
67 67 push push changes to the specified destination
68 68 serve start stand-alone webserver
69 69
70 70 Change creation:
71 71
72 72 commit commit the specified files or all outstanding changes
73 73
74 74 Change manipulation:
75 75
76 76 backout reverse effect of earlier changeset
77 77 graft copy changes from other branches onto the current branch
78 78 merge merge another revision into working directory
79 79
80 80 Change organization:
81 81
82 82 bookmarks create a new bookmark or list existing bookmarks
83 83 branch set or show the current branch name
84 84 branches list repository named branches
85 85 phase set or show the current phase name
86 86 tag add one or more tags for the current or given revision
87 87 tags list repository tags
88 88
89 89 File content management:
90 90
91 91 annotate show changeset information by line for each file
92 92 cat output the current or given revision of files
93 93 copy mark files as copied for the next commit
94 94 diff diff repository (or selected files)
95 95 grep search for a pattern in specified files
96 96
97 97 Change navigation:
98 98
99 99 bisect subdivision search of changesets
100 100 heads show branch heads
101 101 identify identify the working directory or specified revision
102 102 log show revision history of entire repository or files
103 103
104 104 Working directory management:
105 105
106 106 add add the specified files on the next commit
107 107 addremove add all new files, delete all missing files
108 108 files list tracked files
109 109 forget forget the specified files on the next commit
110 110 remove remove the specified files on the next commit
111 111 rename rename files; equivalent of copy + remove
112 112 resolve redo merges or set/view the merge status of files
113 113 revert restore files to their checkout state
114 114 root print the root (top) of the current working directory
115 115 shelve save and set aside changes from the working directory
116 116 status show changed files in the working directory
117 117 summary summarize working directory state
118 118 unshelve restore a shelved change to the working directory
119 119 update update working directory (or switch revisions)
120 120
121 121 Change import/export:
122 122
123 123 archive create an unversioned archive of a repository revision
124 124 bundle create a bundle file
125 125 export dump the header and diffs for one or more changesets
126 126 import import an ordered set of patches
127 127 unbundle apply one or more bundle files
128 128
129 129 Repository maintenance:
130 130
131 131 manifest output the current or given revision of the project manifest
132 132 recover roll back an interrupted transaction
133 133 verify verify the integrity of the repository
134 134
135 135 Help:
136 136
137 137 config show combined config settings from all hgrc files
138 138 help show help for a given topic or a help overview
139 139 version output version and copyright information
140 140
141 141 additional help topics:
142 142
143 143 Mercurial identifiers:
144 144
145 145 filesets Specifying File Sets
146 146 hgignore Syntax for Mercurial Ignore Files
147 147 patterns File Name Patterns
148 148 revisions Specifying Revisions
149 149 urls URL Paths
150 150
151 151 Mercurial output:
152 152
153 153 color Colorizing Outputs
154 154 dates Date Formats
155 155 diffs Diff Formats
156 156 templating Template Usage
157 157
158 158 Mercurial configuration:
159 159
160 160 config Configuration Files
161 161 environment Environment Variables
162 162 extensions Using Additional Features
163 163 flags Command-line flags
164 164 hgweb Configuring hgweb
165 165 merge-tools Merge Tools
166 166 pager Pager Support
167 167
168 168 Concepts:
169 169
170 170 bundlespec Bundle File Formats
171 171 glossary Glossary
172 172 phases Working with Phases
173 173 subrepos Subrepositories
174 174
175 175 Miscellaneous:
176 176
177 177 deprecated Deprecated Features
178 178 internals Technical implementation topics
179 179 scripting Using Mercurial from scripts and automation
180 180
181 181 (use 'hg help -v' to show built-in aliases and global options)
182 182
183 183 $ hg -q help
184 184 Repository creation:
185 185
186 186 clone make a copy of an existing repository
187 187 init create a new repository in the given directory
188 188
189 189 Remote repository management:
190 190
191 191 incoming show new changesets found in source
192 192 outgoing show changesets not found in the destination
193 193 paths show aliases for remote repositories
194 194 pull pull changes from the specified source
195 195 push push changes to the specified destination
196 196 serve start stand-alone webserver
197 197
198 198 Change creation:
199 199
200 200 commit commit the specified files or all outstanding changes
201 201
202 202 Change manipulation:
203 203
204 204 backout reverse effect of earlier changeset
205 205 graft copy changes from other branches onto the current branch
206 206 merge merge another revision into working directory
207 207
208 208 Change organization:
209 209
210 210 bookmarks create a new bookmark or list existing bookmarks
211 211 branch set or show the current branch name
212 212 branches list repository named branches
213 213 phase set or show the current phase name
214 214 tag add one or more tags for the current or given revision
215 215 tags list repository tags
216 216
217 217 File content management:
218 218
219 219 annotate show changeset information by line for each file
220 220 cat output the current or given revision of files
221 221 copy mark files as copied for the next commit
222 222 diff diff repository (or selected files)
223 223 grep search for a pattern in specified files
224 224
225 225 Change navigation:
226 226
227 227 bisect subdivision search of changesets
228 228 heads show branch heads
229 229 identify identify the working directory or specified revision
230 230 log show revision history of entire repository or files
231 231
232 232 Working directory management:
233 233
234 234 add add the specified files on the next commit
235 235 addremove add all new files, delete all missing files
236 236 files list tracked files
237 237 forget forget the specified files on the next commit
238 238 remove remove the specified files on the next commit
239 239 rename rename files; equivalent of copy + remove
240 240 resolve redo merges or set/view the merge status of files
241 241 revert restore files to their checkout state
242 242 root print the root (top) of the current working directory
243 243 shelve save and set aside changes from the working directory
244 244 status show changed files in the working directory
245 245 summary summarize working directory state
246 246 unshelve restore a shelved change to the working directory
247 247 update update working directory (or switch revisions)
248 248
249 249 Change import/export:
250 250
251 251 archive create an unversioned archive of a repository revision
252 252 bundle create a bundle file
253 253 export dump the header and diffs for one or more changesets
254 254 import import an ordered set of patches
255 255 unbundle apply one or more bundle files
256 256
257 257 Repository maintenance:
258 258
259 259 manifest output the current or given revision of the project manifest
260 260 recover roll back an interrupted transaction
261 261 verify verify the integrity of the repository
262 262
263 263 Help:
264 264
265 265 config show combined config settings from all hgrc files
266 266 help show help for a given topic or a help overview
267 267 version output version and copyright information
268 268
269 269 additional help topics:
270 270
271 271 Mercurial identifiers:
272 272
273 273 filesets Specifying File Sets
274 274 hgignore Syntax for Mercurial Ignore Files
275 275 patterns File Name Patterns
276 276 revisions Specifying Revisions
277 277 urls URL Paths
278 278
279 279 Mercurial output:
280 280
281 281 color Colorizing Outputs
282 282 dates Date Formats
283 283 diffs Diff Formats
284 284 templating Template Usage
285 285
286 286 Mercurial configuration:
287 287
288 288 config Configuration Files
289 289 environment Environment Variables
290 290 extensions Using Additional Features
291 291 flags Command-line flags
292 292 hgweb Configuring hgweb
293 293 merge-tools Merge Tools
294 294 pager Pager Support
295 295
296 296 Concepts:
297 297
298 298 bundlespec Bundle File Formats
299 299 glossary Glossary
300 300 phases Working with Phases
301 301 subrepos Subrepositories
302 302
303 303 Miscellaneous:
304 304
305 305 deprecated Deprecated Features
306 306 internals Technical implementation topics
307 307 scripting Using Mercurial from scripts and automation
308 308
309 309 Test extension help:
310 310 $ hg help extensions --config extensions.rebase= --config extensions.children=
311 311 Using Additional Features
312 312 """""""""""""""""""""""""
313 313
314 314 Mercurial has the ability to add new features through the use of
315 315 extensions. Extensions may add new commands, add options to existing
316 316 commands, change the default behavior of commands, or implement hooks.
317 317
318 318 To enable the "foo" extension, either shipped with Mercurial or in the
319 319 Python search path, create an entry for it in your configuration file,
320 320 like this:
321 321
322 322 [extensions]
323 323 foo =
324 324
325 325 You may also specify the full path to an extension:
326 326
327 327 [extensions]
328 328 myfeature = ~/.hgext/myfeature.py
329 329
330 330 See 'hg help config' for more information on configuration files.
331 331
332 332 Extensions are not loaded by default for a variety of reasons: they can
333 333 increase startup overhead; they may be meant for advanced usage only; they
334 334 may provide potentially dangerous abilities (such as letting you destroy
335 335 or modify history); they might not be ready for prime time; or they may
336 336 alter some usual behaviors of stock Mercurial. It is thus up to the user
337 337 to activate extensions as needed.
338 338
339 339 To explicitly disable an extension enabled in a configuration file of
340 340 broader scope, prepend its path with !:
341 341
342 342 [extensions]
343 343 # disabling extension bar residing in /path/to/extension/bar.py
344 344 bar = !/path/to/extension/bar.py
345 345 # ditto, but no path was supplied for extension baz
346 346 baz = !
347 347
348 348 enabled extensions:
349 349
350 350 children command to display child changesets (DEPRECATED)
351 351 rebase command to move sets of revisions to a different ancestor
352 352
353 353 disabled extensions:
354 354
355 355 acl hooks for controlling repository access
356 356 blackbox log repository events to a blackbox for debugging
357 357 bugzilla hooks for integrating with the Bugzilla bug tracker
358 358 censor erase file content at a given revision
359 359 churn command to display statistics about repository history
360 360 clonebundles advertise pre-generated bundles to seed clones
361 361 closehead close arbitrary heads without checking them out first
362 362 convert import revisions from foreign VCS repositories into
363 363 Mercurial
364 364 eol automatically manage newlines in repository files
365 365 extdiff command to allow external programs to compare revisions
366 366 factotum http authentication with factotum
367 367 fastexport export repositories as git fast-import stream
368 368 githelp try mapping git commands to Mercurial commands
369 369 gpg commands to sign and verify changesets
370 370 hgk browse the repository in a graphical way
371 371 highlight syntax highlighting for hgweb (requires Pygments)
372 372 histedit interactive history editing
373 373 keyword expand keywords in tracked files
374 374 largefiles track large binary files
375 375 mq manage a stack of patches
376 376 notify hooks for sending email push notifications
377 377 patchbomb command to send changesets as (a series of) patch emails
378 378 purge command to delete untracked files from the working
379 379 directory
380 380 relink recreates hardlinks between repository clones
381 381 schemes extend schemes with shortcuts to repository swarms
382 382 share share a common history between several working directories
383 383 transplant command to transplant changesets from another branch
384 384 win32mbcs allow the use of MBCS paths with problematic encodings
385 385 zeroconf discover and advertise repositories on the local network
386 386
387 387 #endif
388 388
389 389 Verify that deprecated extensions are included if --verbose:
390 390
391 391 $ hg -v help extensions | grep children
392 392 children command to display child changesets (DEPRECATED)
393 393
394 394 Verify that extension keywords appear in help templates
395 395
396 396 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
397 397
398 398 Test short command list with verbose option
399 399
400 400 $ hg -v help shortlist
401 401 Mercurial Distributed SCM
402 402
403 403 basic commands:
404 404
405 405 abort abort an unfinished operation (EXPERIMENTAL)
406 406 add add the specified files on the next commit
407 407 annotate, blame
408 408 show changeset information by line for each file
409 409 clone make a copy of an existing repository
410 410 commit, ci commit the specified files or all outstanding changes
411 411 continue resumes an interrupted operation (EXPERIMENTAL)
412 412 diff diff repository (or selected files)
413 413 export dump the header and diffs for one or more changesets
414 414 forget forget the specified files on the next commit
415 415 init create a new repository in the given directory
416 416 log, history show revision history of entire repository or files
417 417 merge merge another revision into working directory
418 418 pull pull changes from the specified source
419 419 push push changes to the specified destination
420 420 remove, rm remove the specified files on the next commit
421 421 serve start stand-alone webserver
422 422 status, st show changed files in the working directory
423 423 summary, sum summarize working directory state
424 424 update, up, checkout, co
425 425 update working directory (or switch revisions)
426 426
427 427 global options ([+] can be repeated):
428 428
429 429 -R --repository REPO repository root directory or name of overlay bundle
430 430 file
431 431 --cwd DIR change working directory
432 432 -y --noninteractive do not prompt, automatically pick the first choice for
433 433 all prompts
434 434 -q --quiet suppress output
435 435 -v --verbose enable additional output
436 436 --color TYPE when to colorize (boolean, always, auto, never, or
437 437 debug)
438 438 --config CONFIG [+] set/override config option (use 'section.name=value')
439 439 --debug enable debugging output
440 440 --debugger start debugger
441 441 --encoding ENCODE set the charset encoding (default: ascii)
442 442 --encodingmode MODE set the charset encoding mode (default: strict)
443 443 --traceback always print a traceback on exception
444 444 --time time how long the command takes
445 445 --profile print command execution profile
446 446 --version output version information and exit
447 447 -h --help display help and exit
448 448 --hidden consider hidden changesets
449 449 --pager TYPE when to paginate (boolean, always, auto, or never)
450 450 (default: auto)
451 451
452 452 (use 'hg help' for the full list of commands)
453 453
454 454 $ hg add -h
455 455 hg add [OPTION]... [FILE]...
456 456
457 457 add the specified files on the next commit
458 458
459 459 Schedule files to be version controlled and added to the repository.
460 460
461 461 The files will be added to the repository at the next commit. To undo an
462 462 add before that, see 'hg forget'.
463 463
464 464 If no names are given, add all files to the repository (except files
465 465 matching ".hgignore").
466 466
467 467 Returns 0 if all files are successfully added.
468 468
469 469 options ([+] can be repeated):
470 470
471 471 -I --include PATTERN [+] include names matching the given patterns
472 472 -X --exclude PATTERN [+] exclude names matching the given patterns
473 473 -S --subrepos recurse into subrepositories
474 474 -n --dry-run do not perform actions, just print output
475 475
476 476 (some details hidden, use --verbose to show complete help)
477 477
478 478 Verbose help for add
479 479
480 480 $ hg add -hv
481 481 hg add [OPTION]... [FILE]...
482 482
483 483 add the specified files on the next commit
484 484
485 485 Schedule files to be version controlled and added to the repository.
486 486
487 487 The files will be added to the repository at the next commit. To undo an
488 488 add before that, see 'hg forget'.
489 489
490 490 If no names are given, add all files to the repository (except files
491 491 matching ".hgignore").
492 492
493 493 Examples:
494 494
495 495 - New (unknown) files are added automatically by 'hg add':
496 496
497 497 $ ls
498 498 foo.c
499 499 $ hg status
500 500 ? foo.c
501 501 $ hg add
502 502 adding foo.c
503 503 $ hg status
504 504 A foo.c
505 505
506 506 - Specific files to be added can be specified:
507 507
508 508 $ ls
509 509 bar.c foo.c
510 510 $ hg status
511 511 ? bar.c
512 512 ? foo.c
513 513 $ hg add bar.c
514 514 $ hg status
515 515 A bar.c
516 516 ? foo.c
517 517
518 518 Returns 0 if all files are successfully added.
519 519
520 520 options ([+] can be repeated):
521 521
522 522 -I --include PATTERN [+] include names matching the given patterns
523 523 -X --exclude PATTERN [+] exclude names matching the given patterns
524 524 -S --subrepos recurse into subrepositories
525 525 -n --dry-run do not perform actions, just print output
526 526
527 527 global options ([+] can be repeated):
528 528
529 529 -R --repository REPO repository root directory or name of overlay bundle
530 530 file
531 531 --cwd DIR change working directory
532 532 -y --noninteractive do not prompt, automatically pick the first choice for
533 533 all prompts
534 534 -q --quiet suppress output
535 535 -v --verbose enable additional output
536 536 --color TYPE when to colorize (boolean, always, auto, never, or
537 537 debug)
538 538 --config CONFIG [+] set/override config option (use 'section.name=value')
539 539 --debug enable debugging output
540 540 --debugger start debugger
541 541 --encoding ENCODE set the charset encoding (default: ascii)
542 542 --encodingmode MODE set the charset encoding mode (default: strict)
543 543 --traceback always print a traceback on exception
544 544 --time time how long the command takes
545 545 --profile print command execution profile
546 546 --version output version information and exit
547 547 -h --help display help and exit
548 548 --hidden consider hidden changesets
549 549 --pager TYPE when to paginate (boolean, always, auto, or never)
550 550 (default: auto)
551 551
552 552 Test the textwidth config option
553 553
554 554 $ hg root -h --config ui.textwidth=50
555 555 hg root
556 556
557 557 print the root (top) of the current working
558 558 directory
559 559
560 560 Print the root directory of the current
561 561 repository.
562 562
563 563 Returns 0 on success.
564 564
565 565 options:
566 566
567 567 -T --template TEMPLATE display with template
568 568
569 569 (some details hidden, use --verbose to show
570 570 complete help)
571 571
572 572 Test help option with version option
573 573
574 574 $ hg add -h --version
575 575 Mercurial Distributed SCM (version *) (glob)
576 576 (see https://mercurial-scm.org for more information)
577 577
578 578 Copyright (C) 2005-* Matt Mackall and others (glob)
579 579 This is free software; see the source for copying conditions. There is NO
580 580 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
581 581
582 582 $ hg add --skjdfks
583 583 hg add: option --skjdfks not recognized
584 584 hg add [OPTION]... [FILE]...
585 585
586 586 add the specified files on the next commit
587 587
588 588 options ([+] can be repeated):
589 589
590 590 -I --include PATTERN [+] include names matching the given patterns
591 591 -X --exclude PATTERN [+] exclude names matching the given patterns
592 592 -S --subrepos recurse into subrepositories
593 593 -n --dry-run do not perform actions, just print output
594 594
595 595 (use 'hg add -h' to show more help)
596 596 [255]
597 597
598 598 Test ambiguous command help
599 599
600 600 $ hg help ad
601 601 list of commands:
602 602
603 603 add add the specified files on the next commit
604 604 addremove add all new files, delete all missing files
605 605
606 606 (use 'hg help -v ad' to show built-in aliases and global options)
607 607
608 608 Test command without options
609 609
610 610 $ hg help verify
611 611 hg verify
612 612
613 613 verify the integrity of the repository
614 614
615 615 Verify the integrity of the current repository.
616 616
617 617 This will perform an extensive check of the repository's integrity,
618 618 validating the hashes and checksums of each entry in the changelog,
619 619 manifest, and tracked files, as well as the integrity of their crosslinks
620 620 and indices.
621 621
622 622 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
623 623 information about recovery from corruption of the repository.
624 624
625 625 Returns 0 on success, 1 if errors are encountered.
626 626
627 627 options:
628 628
629 629 (some details hidden, use --verbose to show complete help)
630 630
631 631 $ hg help diff
632 632 hg diff [OPTION]... ([-c REV] | [--from REV1] [--to REV2]) [FILE]...
633 633
634 634 diff repository (or selected files)
635 635
636 636 Show differences between revisions for the specified files.
637 637
638 638 Differences between files are shown using the unified diff format.
639 639
640 640 Note:
641 641 'hg diff' may generate unexpected results for merges, as it will
642 642 default to comparing against the working directory's first parent
643 643 changeset if no revisions are specified.
644 644
645 645 By default, the working directory files are compared to its first parent.
646 646 To see the differences from another revision, use --from. To see the
647 647 difference to another revision, use --to. For example, 'hg diff --from .^'
648 648 will show the differences from the working copy's grandparent to the
649 649 working copy, 'hg diff --to .' will show the diff from the working copy to
650 650 its parent (i.e. the reverse of the default), and 'hg diff --from 1.0 --to
651 651 1.2' will show the diff between those two revisions.
652 652
653 653 Alternatively you can specify -c/--change with a revision to see the
654 654 changes in that changeset relative to its first parent (i.e. 'hg diff -c
655 655 42' is equivalent to 'hg diff --from 42^ --to 42')
656 656
657 657 Without the -a/--text option, diff will avoid generating diffs of files it
658 658 detects as binary. With -a, diff will generate a diff anyway, probably
659 659 with undesirable results.
660 660
661 661 Use the -g/--git option to generate diffs in the git extended diff format.
662 662 For more information, read 'hg help diffs'.
663 663
664 664 Returns 0 on success.
665 665
666 666 options ([+] can be repeated):
667 667
668 668 --from REV1 revision to diff from
669 669 --to REV2 revision to diff to
670 670 -c --change REV change made by revision
671 671 -a --text treat all files as text
672 672 -g --git use git extended diff format
673 673 --binary generate binary diffs in git mode (default)
674 674 --nodates omit dates from diff headers
675 675 --noprefix omit a/ and b/ prefixes from filenames
676 676 -p --show-function show which function each change is in
677 677 --reverse produce a diff that undoes the changes
678 678 -w --ignore-all-space ignore white space when comparing lines
679 679 -b --ignore-space-change ignore changes in the amount of white space
680 680 -B --ignore-blank-lines ignore changes whose lines are all blank
681 681 -Z --ignore-space-at-eol ignore changes in whitespace at EOL
682 682 -U --unified NUM number of lines of context to show
683 683 --stat output diffstat-style summary of changes
684 684 --root DIR produce diffs relative to subdirectory
685 685 -I --include PATTERN [+] include names matching the given patterns
686 686 -X --exclude PATTERN [+] exclude names matching the given patterns
687 687 -S --subrepos recurse into subrepositories
688 688
689 689 (some details hidden, use --verbose to show complete help)
690 690
691 691 $ hg help status
692 692 hg status [OPTION]... [FILE]...
693 693
694 694 aliases: st
695 695
696 696 show changed files in the working directory
697 697
698 698 Show status of files in the repository. If names are given, only files
699 699 that match are shown. Files that are clean or ignored or the source of a
700 700 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
701 701 -C/--copies or -A/--all are given. Unless options described with "show
702 702 only ..." are given, the options -mardu are used.
703 703
704 704 Option -q/--quiet hides untracked (unknown and ignored) files unless
705 705 explicitly requested with -u/--unknown or -i/--ignored.
706 706
707 707 Note:
708 708 'hg status' may appear to disagree with diff if permissions have
709 709 changed or a merge has occurred. The standard diff format does not
710 710 report permission changes and diff only reports changes relative to one
711 711 merge parent.
712 712
713 713 If one revision is given, it is used as the base revision. If two
714 714 revisions are given, the differences between them are shown. The --change
715 715 option can also be used as a shortcut to list the changed files of a
716 716 revision from its first parent.
717 717
718 718 The codes used to show the status of files are:
719 719
720 720 M = modified
721 721 A = added
722 722 R = removed
723 723 C = clean
724 724 ! = missing (deleted by non-hg command, but still tracked)
725 725 ? = not tracked
726 726 I = ignored
727 727 = origin of the previous file (with --copies)
728 728
729 729 Returns 0 on success.
730 730
731 731 options ([+] can be repeated):
732 732
733 733 -A --all show status of all files
734 734 -m --modified show only modified files
735 735 -a --added show only added files
736 736 -r --removed show only removed files
737 737 -d --deleted show only missing files
738 738 -c --clean show only files without changes
739 739 -u --unknown show only unknown (not tracked) files
740 740 -i --ignored show only ignored files
741 741 -n --no-status hide status prefix
742 742 -C --copies show source of copied files
743 743 -0 --print0 end filenames with NUL, for use with xargs
744 744 --rev REV [+] show difference from revision
745 745 --change REV list the changed files of a revision
746 746 -I --include PATTERN [+] include names matching the given patterns
747 747 -X --exclude PATTERN [+] exclude names matching the given patterns
748 748 -S --subrepos recurse into subrepositories
749 749 -T --template TEMPLATE display with template
750 750
751 751 (some details hidden, use --verbose to show complete help)
752 752
753 753 $ hg -q help status
754 754 hg status [OPTION]... [FILE]...
755 755
756 756 show changed files in the working directory
757 757
758 758 $ hg help foo
759 759 abort: no such help topic: foo
760 760 (try 'hg help --keyword foo')
761 761 [255]
762 762
763 763 $ hg skjdfks
764 764 hg: unknown command 'skjdfks'
765 765 (use 'hg help' for a list of commands)
766 766 [255]
767 767
768 768 Typoed command gives suggestion
769 769 $ hg puls
770 770 hg: unknown command 'puls'
771 771 (did you mean one of pull, push?)
772 772 [255]
773 773
774 774 Not enabled extension gets suggested
775 775
776 776 $ hg rebase
777 777 hg: unknown command 'rebase'
778 778 'rebase' is provided by the following extension:
779 779
780 780 rebase command to move sets of revisions to a different ancestor
781 781
782 782 (use 'hg help extensions' for information on enabling extensions)
783 783 [255]
784 784
785 785 Disabled extension gets suggested
786 786 $ hg --config extensions.rebase=! rebase
787 787 hg: unknown command 'rebase'
788 788 'rebase' is provided by the following extension:
789 789
790 790 rebase command to move sets of revisions to a different ancestor
791 791
792 792 (use 'hg help extensions' for information on enabling extensions)
793 793 [255]
794 794
795 795 Checking that help adapts based on the config:
796 796
797 797 $ hg help diff --config ui.tweakdefaults=true | egrep -e '^ *(-g|config)'
798 798 -g --[no-]git use git extended diff format (default: on from
799 799 config)
800 800
801 801 Make sure that we don't run afoul of the help system thinking that
802 802 this is a section and erroring out weirdly.
803 803
804 804 $ hg .log
805 805 hg: unknown command '.log'
806 806 (did you mean log?)
807 807 [255]
808 808
809 809 $ hg log.
810 810 hg: unknown command 'log.'
811 811 (did you mean log?)
812 812 [255]
813 813 $ hg pu.lh
814 814 hg: unknown command 'pu.lh'
815 815 (did you mean one of pull, push?)
816 816 [255]
817 817
818 818 $ cat > helpext.py <<EOF
819 819 > import os
820 820 > from mercurial import commands, fancyopts, registrar
821 821 >
822 822 > def func(arg):
823 823 > return '%sfoo' % arg
824 824 > class customopt(fancyopts.customopt):
825 825 > def newstate(self, oldstate, newparam, abort):
826 826 > return '%sbar' % oldstate
827 827 > cmdtable = {}
828 828 > command = registrar.command(cmdtable)
829 829 >
830 830 > @command(b'nohelp',
831 831 > [(b'', b'longdesc', 3, b'x'*67),
832 832 > (b'n', b'', None, b'normal desc'),
833 833 > (b'', b'newline', b'', b'line1\nline2'),
834 834 > (b'', b'default-off', False, b'enable X'),
835 835 > (b'', b'default-on', True, b'enable Y'),
836 836 > (b'', b'callableopt', func, b'adds foo'),
837 837 > (b'', b'customopt', customopt(''), b'adds bar'),
838 838 > (b'', b'customopt-withdefault', customopt('foo'), b'adds bar')],
839 839 > b'hg nohelp',
840 840 > norepo=True)
841 841 > @command(b'debugoptADV', [(b'', b'aopt', None, b'option is (ADVANCED)')])
842 842 > @command(b'debugoptDEP', [(b'', b'dopt', None, b'option is (DEPRECATED)')])
843 843 > @command(b'debugoptEXP', [(b'', b'eopt', None, b'option is (EXPERIMENTAL)')])
844 844 > def nohelp(ui, *args, **kwargs):
845 845 > pass
846 846 >
847 847 > @command(b'hashelp', [], b'hg hashelp', norepo=True)
848 848 > def hashelp(ui, *args, **kwargs):
849 849 > """Extension command's help"""
850 850 >
851 851 > def uisetup(ui):
852 852 > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext')
853 853 > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext')
854 854 > ui.setconfig(b'alias', b'hgalias:doc', b'My doc', b'helpext')
855 855 > ui.setconfig(b'alias', b'hgalias:category', b'navigation', b'helpext')
856 856 > ui.setconfig(b'alias', b'hgaliasnodoc', b'summary', b'helpext')
857 857 >
858 858 > EOF
859 859 $ echo '[extensions]' >> $HGRCPATH
860 860 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
861 861
862 862 Test for aliases
863 863
864 864 $ hg help | grep hgalias
865 865 hgalias My doc
866 866
867 867 $ hg help hgalias
868 868 hg hgalias [--remote]
869 869
870 870 alias for: hg summary
871 871
872 872 My doc
873 873
874 874 defined by: helpext
875 875
876 876 options:
877 877
878 878 --remote check for push and pull
879 879
880 880 (some details hidden, use --verbose to show complete help)
881 881 $ hg help hgaliasnodoc
882 882 hg hgaliasnodoc [--remote]
883 883
884 884 alias for: hg summary
885 885
886 886 summarize working directory state
887 887
888 888 This generates a brief summary of the working directory state, including
889 889 parents, branch, commit status, phase and available updates.
890 890
891 891 With the --remote option, this will check the default paths for incoming
892 892 and outgoing changes. This can be time-consuming.
893 893
894 894 Returns 0 on success.
895 895
896 896 defined by: helpext
897 897
898 898 options:
899 899
900 900 --remote check for push and pull
901 901
902 902 (some details hidden, use --verbose to show complete help)
903 903
904 904 $ hg help shellalias
905 905 hg shellalias
906 906
907 907 shell alias for: echo hi
908 908
909 909 (no help text available)
910 910
911 911 defined by: helpext
912 912
913 913 (some details hidden, use --verbose to show complete help)
914 914
915 915 Test command with no help text
916 916
917 917 $ hg help nohelp
918 918 hg nohelp
919 919
920 920 (no help text available)
921 921
922 922 options:
923 923
924 924 --longdesc VALUE
925 925 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
926 926 xxxxxxxxxxxxxxxxxxxxxxx (default: 3)
927 927 -n -- normal desc
928 928 --newline VALUE line1 line2
929 929 --default-off enable X
930 930 --[no-]default-on enable Y (default: on)
931 931 --callableopt VALUE adds foo
932 932 --customopt VALUE adds bar
933 933 --customopt-withdefault VALUE adds bar (default: foo)
934 934
935 935 (some details hidden, use --verbose to show complete help)
936 936
937 937 Test that default list of commands includes extension commands that have help,
938 938 but not those that don't, except in verbose mode, when a keyword is passed, or
939 939 when help about the extension is requested.
940 940
941 941 #if no-extraextensions
942 942
943 943 $ hg help | grep hashelp
944 944 hashelp Extension command's help
945 945 $ hg help | grep nohelp
946 946 [1]
947 947 $ hg help -v | grep nohelp
948 948 nohelp (no help text available)
949 949
950 950 $ hg help -k nohelp
951 951 Commands:
952 952
953 953 nohelp hg nohelp
954 954
955 955 Extension Commands:
956 956
957 957 nohelp (no help text available)
958 958
959 959 $ hg help helpext
960 960 helpext extension - no help text available
961 961
962 962 list of commands:
963 963
964 964 hashelp Extension command's help
965 965 nohelp (no help text available)
966 966
967 967 (use 'hg help -v helpext' to show built-in aliases and global options)
968 968
969 969 #endif
970 970
971 971 Test list of internal help commands
972 972
973 973 $ hg help debug
974 974 debug commands (internal and unsupported):
975 975
976 976 debugancestor
977 977 find the ancestor revision of two revisions in a given index
978 978 debugantivirusrunning
979 979 attempt to trigger an antivirus scanner to see if one is active
980 980 debugapplystreamclonebundle
981 981 apply a stream clone bundle file
982 982 debugbackupbundle
983 983 lists the changesets available in backup bundles
984 984 debugbuilddag
985 985 builds a repo with a given DAG from scratch in the current
986 986 empty repo
987 987 debugbundle lists the contents of a bundle
988 988 debugcapabilities
989 989 lists the capabilities of a remote peer
990 990 debugchangedfiles
991 991 list the stored files changes for a revision
992 992 debugcheckstate
993 993 validate the correctness of the current dirstate
994 994 debugcolor show available color, effects or style
995 995 debugcommands
996 996 list all available commands and options
997 997 debugcomplete
998 998 returns the completion list associated with the given command
999 999 debugcreatestreamclonebundle
1000 1000 create a stream clone bundle file
1001 1001 debugdag format the changelog or an index DAG as a concise textual
1002 1002 description
1003 1003 debugdata dump the contents of a data file revision
1004 1004 debugdate parse and display a date
1005 1005 debugdeltachain
1006 1006 dump information about delta chains in a revlog
1007 1007 debugdirstate
1008 1008 show the contents of the current dirstate
1009 1009 debugdiscovery
1010 1010 runs the changeset discovery protocol in isolation
1011 1011 debugdownload
1012 1012 download a resource using Mercurial logic and config
1013 1013 debugextensions
1014 1014 show information about active extensions
1015 1015 debugfileset parse and apply a fileset specification
1016 1016 debugformat display format information about the current repository
1017 1017 debugfsinfo show information detected about current filesystem
1018 1018 debuggetbundle
1019 1019 retrieves a bundle from a repo
1020 1020 debugignore display the combined ignore pattern and information about
1021 1021 ignored files
1022 1022 debugindex dump index data for a storage primitive
1023 1023 debugindexdot
1024 1024 dump an index DAG as a graphviz dot file
1025 1025 debugindexstats
1026 1026 show stats related to the changelog index
1027 1027 debuginstall test Mercurial installation
1028 1028 debugknown test whether node ids are known to a repo
1029 1029 debuglocks show or modify state of locks
1030 1030 debugmanifestfulltextcache
1031 1031 show, clear or amend the contents of the manifest fulltext
1032 1032 cache
1033 1033 debugmergestate
1034 1034 print merge state
1035 1035 debugnamecomplete
1036 1036 complete "names" - tags, open branch names, bookmark names
1037 1037 debugnodemap write and inspect on disk nodemap
1038 1038 debugobsolete
1039 1039 create arbitrary obsolete marker
1040 1040 debugoptADV (no help text available)
1041 1041 debugoptDEP (no help text available)
1042 1042 debugoptEXP (no help text available)
1043 1043 debugp1copies
1044 1044 dump copy information compared to p1
1045 1045 debugp2copies
1046 1046 dump copy information compared to p2
1047 1047 debugpathcomplete
1048 1048 complete part or all of a tracked path
1049 1049 debugpathcopies
1050 1050 show copies between two revisions
1051 1051 debugpeer establish a connection to a peer repository
1052 1052 debugpickmergetool
1053 1053 examine which merge tool is chosen for specified file
1054 1054 debugpushkey access the pushkey key/value protocol
1055 1055 debugpvec (no help text available)
1056 1056 debugrebuilddirstate
1057 1057 rebuild the dirstate as it would look like for the given
1058 1058 revision
1059 1059 debugrebuildfncache
1060 1060 rebuild the fncache file
1061 1061 debugrename dump rename information
1062 1062 debugrequires
1063 1063 print the current repo requirements
1064 1064 debugrevlog show data and statistics about a revlog
1065 1065 debugrevlogindex
1066 1066 dump the contents of a revlog index
1067 1067 debugrevspec parse and apply a revision specification
1068 1068 debugserve run a server with advanced settings
1069 1069 debugsetparents
1070 1070 manually set the parents of the current working directory
1071 1071 debugsidedata
1072 1072 dump the side data for a cl/manifest/file revision
1073 1073 debugssl test a secure connection to a server
1074 1074 debugstrip strip changesets and all their descendants from the repository
1075 1075 debugsub (no help text available)
1076 1076 debugsuccessorssets
1077 1077 show set of successors for revision
1078 1078 debugtagscache
1079 1079 display the contents of .hg/cache/hgtagsfnodes1
1080 1080 debugtemplate
1081 1081 parse and apply a template
1082 1082 debuguigetpass
1083 1083 show prompt to type password
1084 1084 debuguiprompt
1085 1085 show plain prompt
1086 1086 debugupdatecaches
1087 1087 warm all known caches in the repository
1088 1088 debugupgraderepo
1089 1089 upgrade a repository to use different features
1090 1090 debugwalk show how files match on given patterns
1091 1091 debugwhyunstable
1092 1092 explain instabilities of a changeset
1093 1093 debugwireargs
1094 1094 (no help text available)
1095 1095 debugwireproto
1096 1096 send wire protocol commands to a server
1097 1097
1098 1098 (use 'hg help -v debug' to show built-in aliases and global options)
1099 1099
1100 1100 internals topic renders index of available sub-topics
1101 1101
1102 1102 $ hg help internals
1103 1103 Technical implementation topics
1104 1104 """""""""""""""""""""""""""""""
1105 1105
1106 1106 To access a subtopic, use "hg help internals.{subtopic-name}"
1107 1107
1108 1108 bid-merge Bid Merge Algorithm
1109 1109 bundle2 Bundle2
1110 1110 bundles Bundles
1111 1111 cbor CBOR
1112 1112 censor Censor
1113 1113 changegroups Changegroups
1114 1114 config Config Registrar
1115 1115 extensions Extension API
1116 1116 mergestate Mergestate
1117 1117 requirements Repository Requirements
1118 1118 revlogs Revision Logs
1119 1119 wireprotocol Wire Protocol
1120 1120 wireprotocolrpc
1121 1121 Wire Protocol RPC
1122 1122 wireprotocolv2
1123 1123 Wire Protocol Version 2
1124 1124
1125 1125 sub-topics can be accessed
1126 1126
1127 1127 $ hg help internals.changegroups
1128 1128 Changegroups
1129 1129 """"""""""""
1130 1130
1131 1131 Changegroups are representations of repository revlog data, specifically
1132 1132 the changelog data, root/flat manifest data, treemanifest data, and
1133 1133 filelogs.
1134 1134
1135 1135 There are 3 versions of changegroups: "1", "2", and "3". From a high-
1136 1136 level, versions "1" and "2" are almost exactly the same, with the only
1137 1137 difference being an additional item in the *delta header*. Version "3"
1138 1138 adds support for storage flags in the *delta header* and optionally
1139 1139 exchanging treemanifests (enabled by setting an option on the
1140 1140 "changegroup" part in the bundle2).
1141 1141
1142 1142 Changegroups when not exchanging treemanifests consist of 3 logical
1143 1143 segments:
1144 1144
1145 1145 +---------------------------------+
1146 1146 | | | |
1147 1147 | changeset | manifest | filelogs |
1148 1148 | | | |
1149 1149 | | | |
1150 1150 +---------------------------------+
1151 1151
1152 1152 When exchanging treemanifests, there are 4 logical segments:
1153 1153
1154 1154 +-------------------------------------------------+
1155 1155 | | | | |
1156 1156 | changeset | root | treemanifests | filelogs |
1157 1157 | | manifest | | |
1158 1158 | | | | |
1159 1159 +-------------------------------------------------+
1160 1160
1161 1161 The principle building block of each segment is a *chunk*. A *chunk* is a
1162 1162 framed piece of data:
1163 1163
1164 1164 +---------------------------------------+
1165 1165 | | |
1166 1166 | length | data |
1167 1167 | (4 bytes) | (<length - 4> bytes) |
1168 1168 | | |
1169 1169 +---------------------------------------+
1170 1170
1171 1171 All integers are big-endian signed integers. Each chunk starts with a
1172 1172 32-bit integer indicating the length of the entire chunk (including the
1173 1173 length field itself).
1174 1174
1175 1175 There is a special case chunk that has a value of 0 for the length
1176 1176 ("0x00000000"). We call this an *empty chunk*.
1177 1177
1178 1178 Delta Groups
1179 1179 ============
1180 1180
1181 1181 A *delta group* expresses the content of a revlog as a series of deltas,
1182 1182 or patches against previous revisions.
1183 1183
1184 1184 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
1185 1185 to signal the end of the delta group:
1186 1186
1187 1187 +------------------------------------------------------------------------+
1188 1188 | | | | | |
1189 1189 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
1190 1190 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
1191 1191 | | | | | |
1192 1192 +------------------------------------------------------------------------+
1193 1193
1194 1194 Each *chunk*'s data consists of the following:
1195 1195
1196 1196 +---------------------------------------+
1197 1197 | | |
1198 1198 | delta header | delta data |
1199 1199 | (various by version) | (various) |
1200 1200 | | |
1201 1201 +---------------------------------------+
1202 1202
1203 1203 The *delta data* is a series of *delta*s that describe a diff from an
1204 1204 existing entry (either that the recipient already has, or previously
1205 1205 specified in the bundle/changegroup).
1206 1206
1207 1207 The *delta header* is different between versions "1", "2", and "3" of the
1208 1208 changegroup format.
1209 1209
1210 1210 Version 1 (headerlen=80):
1211 1211
1212 1212 +------------------------------------------------------+
1213 1213 | | | | |
1214 1214 | node | p1 node | p2 node | link node |
1215 1215 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1216 1216 | | | | |
1217 1217 +------------------------------------------------------+
1218 1218
1219 1219 Version 2 (headerlen=100):
1220 1220
1221 1221 +------------------------------------------------------------------+
1222 1222 | | | | | |
1223 1223 | node | p1 node | p2 node | base node | link node |
1224 1224 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1225 1225 | | | | | |
1226 1226 +------------------------------------------------------------------+
1227 1227
1228 1228 Version 3 (headerlen=102):
1229 1229
1230 1230 +------------------------------------------------------------------------------+
1231 1231 | | | | | | |
1232 1232 | node | p1 node | p2 node | base node | link node | flags |
1233 1233 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
1234 1234 | | | | | | |
1235 1235 +------------------------------------------------------------------------------+
1236 1236
1237 1237 The *delta data* consists of "chunklen - 4 - headerlen" bytes, which
1238 1238 contain a series of *delta*s, densely packed (no separators). These deltas
1239 1239 describe a diff from an existing entry (either that the recipient already
1240 1240 has, or previously specified in the bundle/changegroup). The format is
1241 1241 described more fully in "hg help internals.bdiff", but briefly:
1242 1242
1243 1243 +---------------------------------------------------------------+
1244 1244 | | | | |
1245 1245 | start offset | end offset | new length | content |
1246 1246 | (4 bytes) | (4 bytes) | (4 bytes) | (<new length> bytes) |
1247 1247 | | | | |
1248 1248 +---------------------------------------------------------------+
1249 1249
1250 1250 Please note that the length field in the delta data does *not* include
1251 1251 itself.
1252 1252
1253 1253 In version 1, the delta is always applied against the previous node from
1254 1254 the changegroup or the first parent if this is the first entry in the
1255 1255 changegroup.
1256 1256
1257 1257 In version 2 and up, the delta base node is encoded in the entry in the
1258 1258 changegroup. This allows the delta to be expressed against any parent,
1259 1259 which can result in smaller deltas and more efficient encoding of data.
1260 1260
1261 1261 The *flags* field holds bitwise flags affecting the processing of revision
1262 1262 data. The following flags are defined:
1263 1263
1264 1264 32768
1265 1265 Censored revision. The revision's fulltext has been replaced by censor
1266 1266 metadata. May only occur on file revisions.
1267 1267
1268 1268 16384
1269 1269 Ellipsis revision. Revision hash does not match data (likely due to
1270 1270 rewritten parents).
1271 1271
1272 1272 8192
1273 1273 Externally stored. The revision fulltext contains "key:value" "\n"
1274 1274 delimited metadata defining an object stored elsewhere. Used by the LFS
1275 1275 extension.
1276 1276
1277 1277 For historical reasons, the integer values are identical to revlog version
1278 1278 1 per-revision storage flags and correspond to bits being set in this
1279 1279 2-byte field. Bits were allocated starting from the most-significant bit,
1280 1280 hence the reverse ordering and allocation of these flags.
1281 1281
1282 1282 Changeset Segment
1283 1283 =================
1284 1284
1285 1285 The *changeset segment* consists of a single *delta group* holding
1286 1286 changelog data. The *empty chunk* at the end of the *delta group* denotes
1287 1287 the boundary to the *manifest segment*.
1288 1288
1289 1289 Manifest Segment
1290 1290 ================
1291 1291
1292 1292 The *manifest segment* consists of a single *delta group* holding manifest
1293 1293 data. If treemanifests are in use, it contains only the manifest for the
1294 1294 root directory of the repository. Otherwise, it contains the entire
1295 1295 manifest data. The *empty chunk* at the end of the *delta group* denotes
1296 1296 the boundary to the next segment (either the *treemanifests segment* or
1297 1297 the *filelogs segment*, depending on version and the request options).
1298 1298
1299 1299 Treemanifests Segment
1300 1300 ---------------------
1301 1301
1302 1302 The *treemanifests segment* only exists in changegroup version "3", and
1303 1303 only if the 'treemanifest' param is part of the bundle2 changegroup part
1304 1304 (it is not possible to use changegroup version 3 outside of bundle2).
1305 1305 Aside from the filenames in the *treemanifests segment* containing a
1306 1306 trailing "/" character, it behaves identically to the *filelogs segment*
1307 1307 (see below). The final sub-segment is followed by an *empty chunk*
1308 1308 (logically, a sub-segment with filename size 0). This denotes the boundary
1309 1309 to the *filelogs segment*.
1310 1310
1311 1311 Filelogs Segment
1312 1312 ================
1313 1313
1314 1314 The *filelogs segment* consists of multiple sub-segments, each
1315 1315 corresponding to an individual file whose data is being described:
1316 1316
1317 1317 +--------------------------------------------------+
1318 1318 | | | | | |
1319 1319 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
1320 1320 | | | | | (4 bytes) |
1321 1321 | | | | | |
1322 1322 +--------------------------------------------------+
1323 1323
1324 1324 The final filelog sub-segment is followed by an *empty chunk* (logically,
1325 1325 a sub-segment with filename size 0). This denotes the end of the segment
1326 1326 and of the overall changegroup.
1327 1327
1328 1328 Each filelog sub-segment consists of the following:
1329 1329
1330 1330 +------------------------------------------------------+
1331 1331 | | | |
1332 1332 | filename length | filename | delta group |
1333 1333 | (4 bytes) | (<length - 4> bytes) | (various) |
1334 1334 | | | |
1335 1335 +------------------------------------------------------+
1336 1336
1337 1337 That is, a *chunk* consisting of the filename (not terminated or padded)
1338 1338 followed by N chunks constituting the *delta group* for this file. The
1339 1339 *empty chunk* at the end of each *delta group* denotes the boundary to the
1340 1340 next filelog sub-segment.
1341 1341
1342 1342 non-existent subtopics print an error
1343 1343
1344 1344 $ hg help internals.foo
1345 1345 abort: no such help topic: internals.foo
1346 1346 (try 'hg help --keyword foo')
1347 1347 [255]
1348 1348
1349 1349 test advanced, deprecated and experimental options are hidden in command help
1350 1350 $ hg help debugoptADV
1351 1351 hg debugoptADV
1352 1352
1353 1353 (no help text available)
1354 1354
1355 1355 options:
1356 1356
1357 1357 (some details hidden, use --verbose to show complete help)
1358 1358 $ hg help debugoptDEP
1359 1359 hg debugoptDEP
1360 1360
1361 1361 (no help text available)
1362 1362
1363 1363 options:
1364 1364
1365 1365 (some details hidden, use --verbose to show complete help)
1366 1366
1367 1367 $ hg help debugoptEXP
1368 1368 hg debugoptEXP
1369 1369
1370 1370 (no help text available)
1371 1371
1372 1372 options:
1373 1373
1374 1374 (some details hidden, use --verbose to show complete help)
1375 1375
1376 1376 test advanced, deprecated and experimental options are shown with -v
1377 1377 $ hg help -v debugoptADV | grep aopt
1378 1378 --aopt option is (ADVANCED)
1379 1379 $ hg help -v debugoptDEP | grep dopt
1380 1380 --dopt option is (DEPRECATED)
1381 1381 $ hg help -v debugoptEXP | grep eopt
1382 1382 --eopt option is (EXPERIMENTAL)
1383 1383
1384 1384 #if gettext
1385 1385 test deprecated option is hidden with translation with untranslated description
1386 1386 (use many globy for not failing on changed transaction)
1387 1387 $ LANGUAGE=sv hg help debugoptDEP
1388 1388 hg debugoptDEP
1389 1389
1390 1390 (*) (glob)
1391 1391
1392 1392 options:
1393 1393
1394 1394 (some details hidden, use --verbose to show complete help)
1395 1395 #endif
1396 1396
1397 1397 Test commands that collide with topics (issue4240)
1398 1398
1399 1399 $ hg config -hq
1400 1400 hg config [-u] [NAME]...
1401 1401
1402 1402 show combined config settings from all hgrc files
1403 1403 $ hg showconfig -hq
1404 1404 hg config [-u] [NAME]...
1405 1405
1406 1406 show combined config settings from all hgrc files
1407 1407
1408 1408 Test a help topic
1409 1409
1410 1410 $ hg help dates
1411 1411 Date Formats
1412 1412 """"""""""""
1413 1413
1414 1414 Some commands allow the user to specify a date, e.g.:
1415 1415
1416 1416 - backout, commit, import, tag: Specify the commit date.
1417 1417 - log, revert, update: Select revision(s) by date.
1418 1418
1419 1419 Many date formats are valid. Here are some examples:
1420 1420
1421 1421 - "Wed Dec 6 13:18:29 2006" (local timezone assumed)
1422 1422 - "Dec 6 13:18 -0600" (year assumed, time offset provided)
1423 1423 - "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
1424 1424 - "Dec 6" (midnight)
1425 1425 - "13:18" (today assumed)
1426 1426 - "3:39" (3:39AM assumed)
1427 1427 - "3:39pm" (15:39)
1428 1428 - "2006-12-06 13:18:29" (ISO 8601 format)
1429 1429 - "2006-12-6 13:18"
1430 1430 - "2006-12-6"
1431 1431 - "12-6"
1432 1432 - "12/6"
1433 1433 - "12/6/6" (Dec 6 2006)
1434 1434 - "today" (midnight)
1435 1435 - "yesterday" (midnight)
1436 1436 - "now" - right now
1437 1437
1438 1438 Lastly, there is Mercurial's internal format:
1439 1439
1440 1440 - "1165411109 0" (Wed Dec 6 13:18:29 2006 UTC)
1441 1441
1442 1442 This is the internal representation format for dates. The first number is
1443 1443 the number of seconds since the epoch (1970-01-01 00:00 UTC). The second
1444 1444 is the offset of the local timezone, in seconds west of UTC (negative if
1445 1445 the timezone is east of UTC).
1446 1446
1447 1447 The log command also accepts date ranges:
1448 1448
1449 1449 - "<DATE" - at or before a given date/time
1450 1450 - ">DATE" - on or after a given date/time
1451 1451 - "DATE to DATE" - a date range, inclusive
1452 1452 - "-DAYS" - within a given number of days from today
1453 1453
1454 1454 Test repeated config section name
1455 1455
1456 1456 $ hg help config.host
1457 1457 "http_proxy.host"
1458 1458 Host name and (optional) port of the proxy server, for example
1459 1459 "myproxy:8000".
1460 1460
1461 1461 "smtp.host"
1462 1462 Host name of mail server, e.g. "mail.example.com".
1463 1463
1464 1464
1465 1465 Test section name with dot
1466 1466
1467 1467 $ hg help config.ui.username
1468 1468 "ui.username"
1469 1469 The committer of a changeset created when running "commit". Typically
1470 1470 a person's name and email address, e.g. "Fred Widget
1471 1471 <fred@example.com>". Environment variables in the username are
1472 1472 expanded.
1473 1473
1474 1474 (default: "$EMAIL" or "username@hostname". If the username in hgrc is
1475 1475 empty, e.g. if the system admin set "username =" in the system hgrc,
1476 1476 it has to be specified manually or in a different hgrc file)
1477 1477
1478 1478
1479 1479 $ hg help config.annotate.git
1480 1480 abort: help section not found: config.annotate.git
1481 1481 [255]
1482 1482
1483 1483 $ hg help config.update.check
1484 1484 "commands.update.check"
1485 1485 Determines what level of checking 'hg update' will perform before
1486 1486 moving to a destination revision. Valid values are "abort", "none",
1487 1487 "linear", and "noconflict". "abort" always fails if the working
1488 1488 directory has uncommitted changes. "none" performs no checking, and
1489 1489 may result in a merge with uncommitted changes. "linear" allows any
1490 1490 update as long as it follows a straight line in the revision history,
1491 1491 and may trigger a merge with uncommitted changes. "noconflict" will
1492 1492 allow any update which would not trigger a merge with uncommitted
1493 1493 changes, if any are present. (default: "linear")
1494 1494
1495 1495
1496 1496 $ hg help config.commands.update.check
1497 1497 "commands.update.check"
1498 1498 Determines what level of checking 'hg update' will perform before
1499 1499 moving to a destination revision. Valid values are "abort", "none",
1500 1500 "linear", and "noconflict". "abort" always fails if the working
1501 1501 directory has uncommitted changes. "none" performs no checking, and
1502 1502 may result in a merge with uncommitted changes. "linear" allows any
1503 1503 update as long as it follows a straight line in the revision history,
1504 1504 and may trigger a merge with uncommitted changes. "noconflict" will
1505 1505 allow any update which would not trigger a merge with uncommitted
1506 1506 changes, if any are present. (default: "linear")
1507 1507
1508 1508
1509 1509 $ hg help config.ommands.update.check
1510 1510 abort: help section not found: config.ommands.update.check
1511 1511 [255]
1512 1512
1513 1513 Unrelated trailing paragraphs shouldn't be included
1514 1514
1515 1515 $ hg help config.extramsg | grep '^$'
1516 1516
1517 1517
1518 1518 Test capitalized section name
1519 1519
1520 1520 $ hg help scripting.HGPLAIN > /dev/null
1521 1521
1522 1522 Help subsection:
1523 1523
1524 1524 $ hg help config.charsets |grep "Email example:" > /dev/null
1525 1525 [1]
1526 1526
1527 1527 Show nested definitions
1528 1528 ("profiling.type"[break]"ls"[break]"stat"[break])
1529 1529
1530 1530 $ hg help config.type | egrep '^$'|wc -l
1531 1531 \s*3 (re)
1532 1532
1533 1533 $ hg help config.profiling.type.ls
1534 1534 "profiling.type.ls"
1535 1535 Use Python's built-in instrumenting profiler. This profiler works on
1536 1536 all platforms, but each line number it reports is the first line of
1537 1537 a function. This restriction makes it difficult to identify the
1538 1538 expensive parts of a non-trivial function.
1539 1539
1540 1540
1541 1541 Separate sections from subsections
1542 1542
1543 1543 $ hg help config.format | egrep '^ ("|-)|^\s*$' | uniq
1544 1544 "format"
1545 1545 --------
1546 1546
1547 1547 "usegeneraldelta"
1548 1548
1549 1549 "dotencode"
1550 1550
1551 1551 "usefncache"
1552 1552
1553 1553 "usestore"
1554 1554
1555 1555 "sparse-revlog"
1556 1556
1557 1557 "revlog-compression"
1558 1558
1559 1559 "bookmarks-in-store"
1560 1560
1561 1561 "profiling"
1562 1562 -----------
1563 1563
1564 1564 "format"
1565 1565
1566 1566 "progress"
1567 1567 ----------
1568 1568
1569 1569 "format"
1570 1570
1571 1571
1572 1572 Last item in help config.*:
1573 1573
1574 1574 $ hg help config.`hg help config|grep '^ "'| \
1575 1575 > tail -1|sed 's![ "]*!!g'`| \
1576 1576 > grep 'hg help -c config' > /dev/null
1577 1577 [1]
1578 1578
1579 1579 note to use help -c for general hg help config:
1580 1580
1581 1581 $ hg help config |grep 'hg help -c config' > /dev/null
1582 1582
1583 1583 Test templating help
1584 1584
1585 1585 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1586 1586 desc String. The text of the changeset description.
1587 1587 diffstat String. Statistics of changes with the following format:
1588 1588 firstline Any text. Returns the first line of text.
1589 1589 nonempty Any text. Returns '(none)' if the string is empty.
1590 1590
1591 1591 Test deprecated items
1592 1592
1593 1593 $ hg help -v templating | grep currentbookmark
1594 1594 currentbookmark
1595 1595 $ hg help templating | (grep currentbookmark || true)
1596 1596
1597 1597 Test help hooks
1598 1598
1599 1599 $ cat > helphook1.py <<EOF
1600 1600 > from mercurial import help
1601 1601 >
1602 1602 > def rewrite(ui, topic, doc):
1603 1603 > return doc + b'\nhelphook1\n'
1604 1604 >
1605 1605 > def extsetup(ui):
1606 1606 > help.addtopichook(b'revisions', rewrite)
1607 1607 > EOF
1608 1608 $ cat > helphook2.py <<EOF
1609 1609 > from mercurial import help
1610 1610 >
1611 1611 > def rewrite(ui, topic, doc):
1612 1612 > return doc + b'\nhelphook2\n'
1613 1613 >
1614 1614 > def extsetup(ui):
1615 1615 > help.addtopichook(b'revisions', rewrite)
1616 1616 > EOF
1617 1617 $ echo '[extensions]' >> $HGRCPATH
1618 1618 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1619 1619 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1620 1620 $ hg help revsets | grep helphook
1621 1621 helphook1
1622 1622 helphook2
1623 1623
1624 1624 help -c should only show debug --debug
1625 1625
1626 1626 $ hg help -c --debug|egrep debug|wc -l|egrep '^\s*0\s*$'
1627 1627 [1]
1628 1628
1629 1629 help -c should only show deprecated for -v
1630 1630
1631 1631 $ hg help -c -v|egrep DEPRECATED|wc -l|egrep '^\s*0\s*$'
1632 1632 [1]
1633 1633
1634 1634 Test -s / --system
1635 1635
1636 1636 $ hg help config.files -s windows |grep 'etc/mercurial' | \
1637 1637 > wc -l | sed -e 's/ //g'
1638 1638 0
1639 1639 $ hg help config.files --system unix | grep 'USER' | \
1640 1640 > wc -l | sed -e 's/ //g'
1641 1641 0
1642 1642
1643 1643 Test -e / -c / -k combinations
1644 1644
1645 1645 $ hg help -c|egrep '^[A-Z].*:|^ debug'
1646 1646 Commands:
1647 1647 $ hg help -e|egrep '^[A-Z].*:|^ debug'
1648 1648 Extensions:
1649 1649 $ hg help -k|egrep '^[A-Z].*:|^ debug'
1650 1650 Topics:
1651 1651 Commands:
1652 1652 Extensions:
1653 1653 Extension Commands:
1654 1654 $ hg help -c schemes
1655 1655 abort: no such help topic: schemes
1656 1656 (try 'hg help --keyword schemes')
1657 1657 [255]
1658 1658 $ hg help -e schemes |head -1
1659 1659 schemes extension - extend schemes with shortcuts to repository swarms
1660 1660 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1661 1661 Commands:
1662 1662 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1663 1663 Extensions:
1664 1664 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1665 1665 Extensions:
1666 1666 Commands:
1667 1667 $ hg help -c commit > /dev/null
1668 1668 $ hg help -e -c commit > /dev/null
1669 1669 $ hg help -e commit
1670 1670 abort: no such help topic: commit
1671 1671 (try 'hg help --keyword commit')
1672 1672 [255]
1673 1673
1674 1674 Test keyword search help
1675 1675
1676 1676 $ cat > prefixedname.py <<EOF
1677 1677 > '''matched against word "clone"
1678 1678 > '''
1679 1679 > EOF
1680 1680 $ echo '[extensions]' >> $HGRCPATH
1681 1681 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1682 1682 $ hg help -k clone
1683 1683 Topics:
1684 1684
1685 1685 config Configuration Files
1686 1686 extensions Using Additional Features
1687 1687 glossary Glossary
1688 1688 phases Working with Phases
1689 1689 subrepos Subrepositories
1690 1690 urls URL Paths
1691 1691
1692 1692 Commands:
1693 1693
1694 1694 bookmarks create a new bookmark or list existing bookmarks
1695 1695 clone make a copy of an existing repository
1696 1696 paths show aliases for remote repositories
1697 1697 pull pull changes from the specified source
1698 1698 update update working directory (or switch revisions)
1699 1699
1700 1700 Extensions:
1701 1701
1702 1702 clonebundles advertise pre-generated bundles to seed clones
1703 1703 narrow create clones which fetch history data for subset of files
1704 1704 (EXPERIMENTAL)
1705 1705 prefixedname matched against word "clone"
1706 1706 relink recreates hardlinks between repository clones
1707 1707
1708 1708 Extension Commands:
1709 1709
1710 1710 qclone clone main and patch repository at same time
1711 1711
1712 1712 Test unfound topic
1713 1713
1714 1714 $ hg help nonexistingtopicthatwillneverexisteverever
1715 1715 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1716 1716 (try 'hg help --keyword nonexistingtopicthatwillneverexisteverever')
1717 1717 [255]
1718 1718
1719 1719 Test unfound keyword
1720 1720
1721 1721 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1722 1722 abort: no matches
1723 1723 (try 'hg help' for a list of topics)
1724 1724 [255]
1725 1725
1726 1726 Test omit indicating for help
1727 1727
1728 1728 $ cat > addverboseitems.py <<EOF
1729 1729 > r'''extension to test omit indicating.
1730 1730 >
1731 1731 > This paragraph is never omitted (for extension)
1732 1732 >
1733 1733 > .. container:: verbose
1734 1734 >
1735 1735 > This paragraph is omitted,
1736 1736 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1737 1737 >
1738 1738 > This paragraph is never omitted, too (for extension)
1739 1739 > '''
1740 1740 > from __future__ import absolute_import
1741 1741 > from mercurial import commands, help
1742 1742 > testtopic = br"""This paragraph is never omitted (for topic).
1743 1743 >
1744 1744 > .. container:: verbose
1745 1745 >
1746 1746 > This paragraph is omitted,
1747 1747 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1748 1748 >
1749 1749 > This paragraph is never omitted, too (for topic)
1750 1750 > """
1751 1751 > def extsetup(ui):
1752 1752 > help.helptable.append(([b"topic-containing-verbose"],
1753 1753 > b"This is the topic to test omit indicating.",
1754 1754 > lambda ui: testtopic))
1755 1755 > EOF
1756 1756 $ echo '[extensions]' >> $HGRCPATH
1757 1757 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1758 1758 $ hg help addverboseitems
1759 1759 addverboseitems extension - extension to test omit indicating.
1760 1760
1761 1761 This paragraph is never omitted (for extension)
1762 1762
1763 1763 This paragraph is never omitted, too (for extension)
1764 1764
1765 1765 (some details hidden, use --verbose to show complete help)
1766 1766
1767 1767 no commands defined
1768 1768 $ hg help -v addverboseitems
1769 1769 addverboseitems extension - extension to test omit indicating.
1770 1770
1771 1771 This paragraph is never omitted (for extension)
1772 1772
1773 1773 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1774 1774 extension)
1775 1775
1776 1776 This paragraph is never omitted, too (for extension)
1777 1777
1778 1778 no commands defined
1779 1779 $ hg help topic-containing-verbose
1780 1780 This is the topic to test omit indicating.
1781 1781 """"""""""""""""""""""""""""""""""""""""""
1782 1782
1783 1783 This paragraph is never omitted (for topic).
1784 1784
1785 1785 This paragraph is never omitted, too (for topic)
1786 1786
1787 1787 (some details hidden, use --verbose to show complete help)
1788 1788 $ hg help -v topic-containing-verbose
1789 1789 This is the topic to test omit indicating.
1790 1790 """"""""""""""""""""""""""""""""""""""""""
1791 1791
1792 1792 This paragraph is never omitted (for topic).
1793 1793
1794 1794 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1795 1795 topic)
1796 1796
1797 1797 This paragraph is never omitted, too (for topic)
1798 1798
1799 1799 Test section lookup
1800 1800
1801 1801 $ hg help revset.merge
1802 1802 "merge()"
1803 1803 Changeset is a merge changeset.
1804 1804
1805 1805 $ hg help glossary.dag
1806 1806 DAG
1807 1807 The repository of changesets of a distributed version control system
1808 1808 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1809 1809 of nodes and edges, where nodes correspond to changesets and edges
1810 1810 imply a parent -> child relation. This graph can be visualized by
1811 1811 graphical tools such as 'hg log --graph'. In Mercurial, the DAG is
1812 1812 limited by the requirement for children to have at most two parents.
1813 1813
1814 1814
1815 1815 $ hg help hgrc.paths
1816 1816 "paths"
1817 1817 -------
1818 1818
1819 1819 Assigns symbolic names and behavior to repositories.
1820 1820
1821 1821 Options are symbolic names defining the URL or directory that is the
1822 1822 location of the repository. Example:
1823 1823
1824 1824 [paths]
1825 1825 my_server = https://example.com/my_repo
1826 1826 local_path = /home/me/repo
1827 1827
1828 1828 These symbolic names can be used from the command line. To pull from
1829 1829 "my_server": 'hg pull my_server'. To push to "local_path": 'hg push
1830 1830 local_path'.
1831 1831
1832 1832 Options containing colons (":") denote sub-options that can influence
1833 1833 behavior for that specific path. Example:
1834 1834
1835 1835 [paths]
1836 1836 my_server = https://example.com/my_path
1837 1837 my_server:pushurl = ssh://example.com/my_path
1838 1838
1839 1839 The following sub-options can be defined:
1840 1840
1841 1841 "pushurl"
1842 1842 The URL to use for push operations. If not defined, the location
1843 1843 defined by the path's main entry is used.
1844 1844
1845 1845 "pushrev"
1846 1846 A revset defining which revisions to push by default.
1847 1847
1848 1848 When 'hg push' is executed without a "-r" argument, the revset defined
1849 1849 by this sub-option is evaluated to determine what to push.
1850 1850
1851 1851 For example, a value of "." will push the working directory's revision
1852 1852 by default.
1853 1853
1854 1854 Revsets specifying bookmarks will not result in the bookmark being
1855 1855 pushed.
1856 1856
1857 1857 The following special named paths exist:
1858 1858
1859 1859 "default"
1860 1860 The URL or directory to use when no source or remote is specified.
1861 1861
1862 1862 'hg clone' will automatically define this path to the location the
1863 1863 repository was cloned from.
1864 1864
1865 1865 "default-push"
1866 1866 (deprecated) The URL or directory for the default 'hg push' location.
1867 1867 "default:pushurl" should be used instead.
1868 1868
1869 1869 $ hg help glossary.mcguffin
1870 1870 abort: help section not found: glossary.mcguffin
1871 1871 [255]
1872 1872
1873 1873 $ hg help glossary.mc.guffin
1874 1874 abort: help section not found: glossary.mc.guffin
1875 1875 [255]
1876 1876
1877 1877 $ hg help template.files
1878 1878 files List of strings. All files modified, added, or removed by
1879 1879 this changeset.
1880 1880 files(pattern)
1881 1881 All files of the current changeset matching the pattern. See
1882 1882 'hg help patterns'.
1883 1883
1884 1884 Test section lookup by translated message
1885 1885
1886 1886 str.lower() instead of encoding.lower(str) on translated message might
1887 1887 make message meaningless, because some encoding uses 0x41(A) - 0x5a(Z)
1888 1888 as the second or later byte of multi-byte character.
1889 1889
1890 1890 For example, "\x8bL\x98^" (translation of "record" in ja_JP.cp932)
1891 1891 contains 0x4c (L). str.lower() replaces 0x4c(L) by 0x6c(l) and this
1892 1892 replacement makes message meaningless.
1893 1893
1894 1894 This tests that section lookup by translated string isn't broken by
1895 1895 such str.lower().
1896 1896
1897 1897 $ "$PYTHON" <<EOF
1898 1898 > def escape(s):
1899 1899 > return b''.join(b'\\u%x' % ord(uc) for uc in s.decode('cp932'))
1900 1900 > # translation of "record" in ja_JP.cp932
1901 1901 > upper = b"\x8bL\x98^"
1902 1902 > # str.lower()-ed section name should be treated as different one
1903 1903 > lower = b"\x8bl\x98^"
1904 1904 > with open('ambiguous.py', 'wb') as fp:
1905 1905 > fp.write(b"""# ambiguous section names in ja_JP.cp932
1906 1906 > u'''summary of extension
1907 1907 >
1908 1908 > %s
1909 1909 > ----
1910 1910 >
1911 1911 > Upper name should show only this message
1912 1912 >
1913 1913 > %s
1914 1914 > ----
1915 1915 >
1916 1916 > Lower name should show only this message
1917 1917 >
1918 1918 > subsequent section
1919 1919 > ------------------
1920 1920 >
1921 1921 > This should be hidden at 'hg help ambiguous' with section name.
1922 1922 > '''
1923 1923 > """ % (escape(upper), escape(lower)))
1924 1924 > EOF
1925 1925
1926 1926 $ cat >> $HGRCPATH <<EOF
1927 1927 > [extensions]
1928 1928 > ambiguous = ./ambiguous.py
1929 1929 > EOF
1930 1930
1931 1931 $ "$PYTHON" <<EOF | sh
1932 1932 > from mercurial.utils import procutil
1933 1933 > upper = b"\x8bL\x98^"
1934 1934 > procutil.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % upper)
1935 1935 > EOF
1936 1936 \x8bL\x98^ (esc)
1937 1937 ----
1938 1938
1939 1939 Upper name should show only this message
1940 1940
1941 1941
1942 1942 $ "$PYTHON" <<EOF | sh
1943 1943 > from mercurial.utils import procutil
1944 1944 > lower = b"\x8bl\x98^"
1945 1945 > procutil.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % lower)
1946 1946 > EOF
1947 1947 \x8bl\x98^ (esc)
1948 1948 ----
1949 1949
1950 1950 Lower name should show only this message
1951 1951
1952 1952
1953 1953 $ cat >> $HGRCPATH <<EOF
1954 1954 > [extensions]
1955 1955 > ambiguous = !
1956 1956 > EOF
1957 1957
1958 1958 Show help content of disabled extensions
1959 1959
1960 1960 $ cat >> $HGRCPATH <<EOF
1961 1961 > [extensions]
1962 1962 > ambiguous = !./ambiguous.py
1963 1963 > EOF
1964 1964 $ hg help -e ambiguous
1965 1965 ambiguous extension - (no help text available)
1966 1966
1967 1967 (use 'hg help extensions' for information on enabling extensions)
1968 1968
1969 1969 Test dynamic list of merge tools only shows up once
1970 1970 $ hg help merge-tools
1971 1971 Merge Tools
1972 1972 """""""""""
1973 1973
1974 1974 To merge files Mercurial uses merge tools.
1975 1975
1976 1976 A merge tool combines two different versions of a file into a merged file.
1977 1977 Merge tools are given the two files and the greatest common ancestor of
1978 1978 the two file versions, so they can determine the changes made on both
1979 1979 branches.
1980 1980
1981 1981 Merge tools are used both for 'hg resolve', 'hg merge', 'hg update', 'hg
1982 1982 backout' and in several extensions.
1983 1983
1984 1984 Usually, the merge tool tries to automatically reconcile the files by
1985 1985 combining all non-overlapping changes that occurred separately in the two
1986 1986 different evolutions of the same initial base file. Furthermore, some
1987 1987 interactive merge programs make it easier to manually resolve conflicting
1988 1988 merges, either in a graphical way, or by inserting some conflict markers.
1989 1989 Mercurial does not include any interactive merge programs but relies on
1990 1990 external tools for that.
1991 1991
1992 1992 Available merge tools
1993 1993 =====================
1994 1994
1995 1995 External merge tools and their properties are configured in the merge-
1996 1996 tools configuration section - see hgrc(5) - but they can often just be
1997 1997 named by their executable.
1998 1998
1999 1999 A merge tool is generally usable if its executable can be found on the
2000 2000 system and if it can handle the merge. The executable is found if it is an
2001 2001 absolute or relative executable path or the name of an application in the
2002 2002 executable search path. The tool is assumed to be able to handle the merge
2003 2003 if it can handle symlinks if the file is a symlink, if it can handle
2004 2004 binary files if the file is binary, and if a GUI is available if the tool
2005 2005 requires a GUI.
2006 2006
2007 2007 There are some internal merge tools which can be used. The internal merge
2008 2008 tools are:
2009 2009
2010 2010 ":dump"
2011 2011 Creates three versions of the files to merge, containing the contents of
2012 2012 local, other and base. These files can then be used to perform a merge
2013 2013 manually. If the file to be merged is named "a.txt", these files will
2014 2014 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
2015 2015 they will be placed in the same directory as "a.txt".
2016 2016
2017 2017 This implies premerge. Therefore, files aren't dumped, if premerge runs
2018 2018 successfully. Use :forcedump to forcibly write files out.
2019 2019
2020 2020 (actual capabilities: binary, symlink)
2021 2021
2022 2022 ":fail"
2023 2023 Rather than attempting to merge files that were modified on both
2024 2024 branches, it marks them as unresolved. The resolve command must be used
2025 2025 to resolve these conflicts.
2026 2026
2027 2027 (actual capabilities: binary, symlink)
2028 2028
2029 2029 ":forcedump"
2030 2030 Creates three versions of the files as same as :dump, but omits
2031 2031 premerge.
2032 2032
2033 2033 (actual capabilities: binary, symlink)
2034 2034
2035 2035 ":local"
2036 2036 Uses the local 'p1()' version of files as the merged version.
2037 2037
2038 2038 (actual capabilities: binary, symlink)
2039 2039
2040 2040 ":merge"
2041 2041 Uses the internal non-interactive simple merge algorithm for merging
2042 2042 files. It will fail if there are any conflicts and leave markers in the
2043 2043 partially merged file. Markers will have two sections, one for each side
2044 2044 of merge.
2045 2045
2046 2046 ":merge-local"
2047 2047 Like :merge, but resolve all conflicts non-interactively in favor of the
2048 2048 local 'p1()' changes.
2049 2049
2050 2050 ":merge-other"
2051 2051 Like :merge, but resolve all conflicts non-interactively in favor of the
2052 2052 other 'p2()' changes.
2053 2053
2054 2054 ":merge3"
2055 2055 Uses the internal non-interactive simple merge algorithm for merging
2056 2056 files. It will fail if there are any conflicts and leave markers in the
2057 2057 partially merged file. Marker will have three sections, one from each
2058 2058 side of the merge and one for the base content.
2059 2059
2060 ":mergediff"
2061 Uses the internal non-interactive simple merge algorithm for merging
2062 files. It will fail if there are any conflicts and leave markers in the
2063 partially merged file. The marker will have two sections, one with the
2064 content from one side of the merge, and one with a diff from the base
2065 content to the content on the other side. (experimental)
2066
2060 2067 ":other"
2061 2068 Uses the other 'p2()' version of files as the merged version.
2062 2069
2063 2070 (actual capabilities: binary, symlink)
2064 2071
2065 2072 ":prompt"
2066 2073 Asks the user which of the local 'p1()' or the other 'p2()' version to
2067 2074 keep as the merged version.
2068 2075
2069 2076 (actual capabilities: binary, symlink)
2070 2077
2071 2078 ":tagmerge"
2072 2079 Uses the internal tag merge algorithm (experimental).
2073 2080
2074 2081 ":union"
2075 2082 Uses the internal non-interactive simple merge algorithm for merging
2076 2083 files. It will use both left and right sides for conflict regions. No
2077 2084 markers are inserted.
2078 2085
2079 2086 Internal tools are always available and do not require a GUI but will by
2080 2087 default not handle symlinks or binary files. See next section for detail
2081 2088 about "actual capabilities" described above.
2082 2089
2083 2090 Choosing a merge tool
2084 2091 =====================
2085 2092
2086 2093 Mercurial uses these rules when deciding which merge tool to use:
2087 2094
2088 2095 1. If a tool has been specified with the --tool option to merge or
2089 2096 resolve, it is used. If it is the name of a tool in the merge-tools
2090 2097 configuration, its configuration is used. Otherwise the specified tool
2091 2098 must be executable by the shell.
2092 2099 2. If the "HGMERGE" environment variable is present, its value is used and
2093 2100 must be executable by the shell.
2094 2101 3. If the filename of the file to be merged matches any of the patterns in
2095 2102 the merge-patterns configuration section, the first usable merge tool
2096 2103 corresponding to a matching pattern is used.
2097 2104 4. If ui.merge is set it will be considered next. If the value is not the
2098 2105 name of a configured tool, the specified value is used and must be
2099 2106 executable by the shell. Otherwise the named tool is used if it is
2100 2107 usable.
2101 2108 5. If any usable merge tools are present in the merge-tools configuration
2102 2109 section, the one with the highest priority is used.
2103 2110 6. If a program named "hgmerge" can be found on the system, it is used -
2104 2111 but it will by default not be used for symlinks and binary files.
2105 2112 7. If the file to be merged is not binary and is not a symlink, then
2106 2113 internal ":merge" is used.
2107 2114 8. Otherwise, ":prompt" is used.
2108 2115
2109 2116 For historical reason, Mercurial treats merge tools as below while
2110 2117 examining rules above.
2111 2118
2112 2119 step specified via binary symlink
2113 2120 ----------------------------------
2114 2121 1. --tool o/o o/o
2115 2122 2. HGMERGE o/o o/o
2116 2123 3. merge-patterns o/o(*) x/?(*)
2117 2124 4. ui.merge x/?(*) x/?(*)
2118 2125
2119 2126 Each capability column indicates Mercurial behavior for internal/external
2120 2127 merge tools at examining each rule.
2121 2128
2122 2129 - "o": "assume that a tool has capability"
2123 2130 - "x": "assume that a tool does not have capability"
2124 2131 - "?": "check actual capability of a tool"
2125 2132
2126 2133 If "merge.strict-capability-check" configuration is true, Mercurial checks
2127 2134 capabilities of merge tools strictly in (*) cases above (= each capability
2128 2135 column becomes "?/?"). It is false by default for backward compatibility.
2129 2136
2130 2137 Note:
2131 2138 After selecting a merge program, Mercurial will by default attempt to
2132 2139 merge the files using a simple merge algorithm first. Only if it
2133 2140 doesn't succeed because of conflicting changes will Mercurial actually
2134 2141 execute the merge program. Whether to use the simple merge algorithm
2135 2142 first can be controlled by the premerge setting of the merge tool.
2136 2143 Premerge is enabled by default unless the file is binary or a symlink.
2137 2144
2138 2145 See the merge-tools and ui sections of hgrc(5) for details on the
2139 2146 configuration of merge tools.
2140 2147
2141 2148 Compression engines listed in `hg help bundlespec`
2142 2149
2143 2150 $ hg help bundlespec | grep gzip
2144 2151 "v1" bundles can only use the "gzip", "bzip2", and "none" compression
2145 2152 An algorithm that produces smaller bundles than "gzip".
2146 2153 This engine will likely produce smaller bundles than "gzip" but will be
2147 2154 "gzip"
2148 2155 better compression than "gzip". It also frequently yields better (?)
2149 2156
2150 2157 Test usage of section marks in help documents
2151 2158
2152 2159 $ cd "$TESTDIR"/../doc
2153 2160 $ "$PYTHON" check-seclevel.py
2154 2161 $ cd $TESTTMP
2155 2162
2156 2163 #if serve
2157 2164
2158 2165 Test the help pages in hgweb.
2159 2166
2160 2167 Dish up an empty repo; serve it cold.
2161 2168
2162 2169 $ hg init "$TESTTMP/test"
2163 2170 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
2164 2171 $ cat hg.pid >> $DAEMON_PIDS
2165 2172
2166 2173 $ get-with-headers.py $LOCALIP:$HGPORT "help"
2167 2174 200 Script output follows
2168 2175
2169 2176 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2170 2177 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2171 2178 <head>
2172 2179 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2173 2180 <meta name="robots" content="index, nofollow" />
2174 2181 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2175 2182 <script type="text/javascript" src="/static/mercurial.js"></script>
2176 2183
2177 2184 <title>Help: Index</title>
2178 2185 </head>
2179 2186 <body>
2180 2187
2181 2188 <div class="container">
2182 2189 <div class="menu">
2183 2190 <div class="logo">
2184 2191 <a href="https://mercurial-scm.org/">
2185 2192 <img src="/static/hglogo.png" alt="mercurial" /></a>
2186 2193 </div>
2187 2194 <ul>
2188 2195 <li><a href="/shortlog">log</a></li>
2189 2196 <li><a href="/graph">graph</a></li>
2190 2197 <li><a href="/tags">tags</a></li>
2191 2198 <li><a href="/bookmarks">bookmarks</a></li>
2192 2199 <li><a href="/branches">branches</a></li>
2193 2200 </ul>
2194 2201 <ul>
2195 2202 <li class="active">help</li>
2196 2203 </ul>
2197 2204 </div>
2198 2205
2199 2206 <div class="main">
2200 2207 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2201 2208
2202 2209 <form class="search" action="/log">
2203 2210
2204 2211 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2205 2212 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2206 2213 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2207 2214 </form>
2208 2215 <table class="bigtable">
2209 2216 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
2210 2217
2211 2218 <tr><td>
2212 2219 <a href="/help/bundlespec">
2213 2220 bundlespec
2214 2221 </a>
2215 2222 </td><td>
2216 2223 Bundle File Formats
2217 2224 </td></tr>
2218 2225 <tr><td>
2219 2226 <a href="/help/color">
2220 2227 color
2221 2228 </a>
2222 2229 </td><td>
2223 2230 Colorizing Outputs
2224 2231 </td></tr>
2225 2232 <tr><td>
2226 2233 <a href="/help/config">
2227 2234 config
2228 2235 </a>
2229 2236 </td><td>
2230 2237 Configuration Files
2231 2238 </td></tr>
2232 2239 <tr><td>
2233 2240 <a href="/help/dates">
2234 2241 dates
2235 2242 </a>
2236 2243 </td><td>
2237 2244 Date Formats
2238 2245 </td></tr>
2239 2246 <tr><td>
2240 2247 <a href="/help/deprecated">
2241 2248 deprecated
2242 2249 </a>
2243 2250 </td><td>
2244 2251 Deprecated Features
2245 2252 </td></tr>
2246 2253 <tr><td>
2247 2254 <a href="/help/diffs">
2248 2255 diffs
2249 2256 </a>
2250 2257 </td><td>
2251 2258 Diff Formats
2252 2259 </td></tr>
2253 2260 <tr><td>
2254 2261 <a href="/help/environment">
2255 2262 environment
2256 2263 </a>
2257 2264 </td><td>
2258 2265 Environment Variables
2259 2266 </td></tr>
2260 2267 <tr><td>
2261 2268 <a href="/help/extensions">
2262 2269 extensions
2263 2270 </a>
2264 2271 </td><td>
2265 2272 Using Additional Features
2266 2273 </td></tr>
2267 2274 <tr><td>
2268 2275 <a href="/help/filesets">
2269 2276 filesets
2270 2277 </a>
2271 2278 </td><td>
2272 2279 Specifying File Sets
2273 2280 </td></tr>
2274 2281 <tr><td>
2275 2282 <a href="/help/flags">
2276 2283 flags
2277 2284 </a>
2278 2285 </td><td>
2279 2286 Command-line flags
2280 2287 </td></tr>
2281 2288 <tr><td>
2282 2289 <a href="/help/glossary">
2283 2290 glossary
2284 2291 </a>
2285 2292 </td><td>
2286 2293 Glossary
2287 2294 </td></tr>
2288 2295 <tr><td>
2289 2296 <a href="/help/hgignore">
2290 2297 hgignore
2291 2298 </a>
2292 2299 </td><td>
2293 2300 Syntax for Mercurial Ignore Files
2294 2301 </td></tr>
2295 2302 <tr><td>
2296 2303 <a href="/help/hgweb">
2297 2304 hgweb
2298 2305 </a>
2299 2306 </td><td>
2300 2307 Configuring hgweb
2301 2308 </td></tr>
2302 2309 <tr><td>
2303 2310 <a href="/help/internals">
2304 2311 internals
2305 2312 </a>
2306 2313 </td><td>
2307 2314 Technical implementation topics
2308 2315 </td></tr>
2309 2316 <tr><td>
2310 2317 <a href="/help/merge-tools">
2311 2318 merge-tools
2312 2319 </a>
2313 2320 </td><td>
2314 2321 Merge Tools
2315 2322 </td></tr>
2316 2323 <tr><td>
2317 2324 <a href="/help/pager">
2318 2325 pager
2319 2326 </a>
2320 2327 </td><td>
2321 2328 Pager Support
2322 2329 </td></tr>
2323 2330 <tr><td>
2324 2331 <a href="/help/patterns">
2325 2332 patterns
2326 2333 </a>
2327 2334 </td><td>
2328 2335 File Name Patterns
2329 2336 </td></tr>
2330 2337 <tr><td>
2331 2338 <a href="/help/phases">
2332 2339 phases
2333 2340 </a>
2334 2341 </td><td>
2335 2342 Working with Phases
2336 2343 </td></tr>
2337 2344 <tr><td>
2338 2345 <a href="/help/revisions">
2339 2346 revisions
2340 2347 </a>
2341 2348 </td><td>
2342 2349 Specifying Revisions
2343 2350 </td></tr>
2344 2351 <tr><td>
2345 2352 <a href="/help/scripting">
2346 2353 scripting
2347 2354 </a>
2348 2355 </td><td>
2349 2356 Using Mercurial from scripts and automation
2350 2357 </td></tr>
2351 2358 <tr><td>
2352 2359 <a href="/help/subrepos">
2353 2360 subrepos
2354 2361 </a>
2355 2362 </td><td>
2356 2363 Subrepositories
2357 2364 </td></tr>
2358 2365 <tr><td>
2359 2366 <a href="/help/templating">
2360 2367 templating
2361 2368 </a>
2362 2369 </td><td>
2363 2370 Template Usage
2364 2371 </td></tr>
2365 2372 <tr><td>
2366 2373 <a href="/help/urls">
2367 2374 urls
2368 2375 </a>
2369 2376 </td><td>
2370 2377 URL Paths
2371 2378 </td></tr>
2372 2379 <tr><td>
2373 2380 <a href="/help/topic-containing-verbose">
2374 2381 topic-containing-verbose
2375 2382 </a>
2376 2383 </td><td>
2377 2384 This is the topic to test omit indicating.
2378 2385 </td></tr>
2379 2386
2380 2387
2381 2388 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
2382 2389
2383 2390 <tr><td>
2384 2391 <a href="/help/abort">
2385 2392 abort
2386 2393 </a>
2387 2394 </td><td>
2388 2395 abort an unfinished operation (EXPERIMENTAL)
2389 2396 </td></tr>
2390 2397 <tr><td>
2391 2398 <a href="/help/add">
2392 2399 add
2393 2400 </a>
2394 2401 </td><td>
2395 2402 add the specified files on the next commit
2396 2403 </td></tr>
2397 2404 <tr><td>
2398 2405 <a href="/help/annotate">
2399 2406 annotate
2400 2407 </a>
2401 2408 </td><td>
2402 2409 show changeset information by line for each file
2403 2410 </td></tr>
2404 2411 <tr><td>
2405 2412 <a href="/help/clone">
2406 2413 clone
2407 2414 </a>
2408 2415 </td><td>
2409 2416 make a copy of an existing repository
2410 2417 </td></tr>
2411 2418 <tr><td>
2412 2419 <a href="/help/commit">
2413 2420 commit
2414 2421 </a>
2415 2422 </td><td>
2416 2423 commit the specified files or all outstanding changes
2417 2424 </td></tr>
2418 2425 <tr><td>
2419 2426 <a href="/help/continue">
2420 2427 continue
2421 2428 </a>
2422 2429 </td><td>
2423 2430 resumes an interrupted operation (EXPERIMENTAL)
2424 2431 </td></tr>
2425 2432 <tr><td>
2426 2433 <a href="/help/diff">
2427 2434 diff
2428 2435 </a>
2429 2436 </td><td>
2430 2437 diff repository (or selected files)
2431 2438 </td></tr>
2432 2439 <tr><td>
2433 2440 <a href="/help/export">
2434 2441 export
2435 2442 </a>
2436 2443 </td><td>
2437 2444 dump the header and diffs for one or more changesets
2438 2445 </td></tr>
2439 2446 <tr><td>
2440 2447 <a href="/help/forget">
2441 2448 forget
2442 2449 </a>
2443 2450 </td><td>
2444 2451 forget the specified files on the next commit
2445 2452 </td></tr>
2446 2453 <tr><td>
2447 2454 <a href="/help/init">
2448 2455 init
2449 2456 </a>
2450 2457 </td><td>
2451 2458 create a new repository in the given directory
2452 2459 </td></tr>
2453 2460 <tr><td>
2454 2461 <a href="/help/log">
2455 2462 log
2456 2463 </a>
2457 2464 </td><td>
2458 2465 show revision history of entire repository or files
2459 2466 </td></tr>
2460 2467 <tr><td>
2461 2468 <a href="/help/merge">
2462 2469 merge
2463 2470 </a>
2464 2471 </td><td>
2465 2472 merge another revision into working directory
2466 2473 </td></tr>
2467 2474 <tr><td>
2468 2475 <a href="/help/pull">
2469 2476 pull
2470 2477 </a>
2471 2478 </td><td>
2472 2479 pull changes from the specified source
2473 2480 </td></tr>
2474 2481 <tr><td>
2475 2482 <a href="/help/push">
2476 2483 push
2477 2484 </a>
2478 2485 </td><td>
2479 2486 push changes to the specified destination
2480 2487 </td></tr>
2481 2488 <tr><td>
2482 2489 <a href="/help/remove">
2483 2490 remove
2484 2491 </a>
2485 2492 </td><td>
2486 2493 remove the specified files on the next commit
2487 2494 </td></tr>
2488 2495 <tr><td>
2489 2496 <a href="/help/serve">
2490 2497 serve
2491 2498 </a>
2492 2499 </td><td>
2493 2500 start stand-alone webserver
2494 2501 </td></tr>
2495 2502 <tr><td>
2496 2503 <a href="/help/status">
2497 2504 status
2498 2505 </a>
2499 2506 </td><td>
2500 2507 show changed files in the working directory
2501 2508 </td></tr>
2502 2509 <tr><td>
2503 2510 <a href="/help/summary">
2504 2511 summary
2505 2512 </a>
2506 2513 </td><td>
2507 2514 summarize working directory state
2508 2515 </td></tr>
2509 2516 <tr><td>
2510 2517 <a href="/help/update">
2511 2518 update
2512 2519 </a>
2513 2520 </td><td>
2514 2521 update working directory (or switch revisions)
2515 2522 </td></tr>
2516 2523
2517 2524
2518 2525
2519 2526 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
2520 2527
2521 2528 <tr><td>
2522 2529 <a href="/help/addremove">
2523 2530 addremove
2524 2531 </a>
2525 2532 </td><td>
2526 2533 add all new files, delete all missing files
2527 2534 </td></tr>
2528 2535 <tr><td>
2529 2536 <a href="/help/archive">
2530 2537 archive
2531 2538 </a>
2532 2539 </td><td>
2533 2540 create an unversioned archive of a repository revision
2534 2541 </td></tr>
2535 2542 <tr><td>
2536 2543 <a href="/help/backout">
2537 2544 backout
2538 2545 </a>
2539 2546 </td><td>
2540 2547 reverse effect of earlier changeset
2541 2548 </td></tr>
2542 2549 <tr><td>
2543 2550 <a href="/help/bisect">
2544 2551 bisect
2545 2552 </a>
2546 2553 </td><td>
2547 2554 subdivision search of changesets
2548 2555 </td></tr>
2549 2556 <tr><td>
2550 2557 <a href="/help/bookmarks">
2551 2558 bookmarks
2552 2559 </a>
2553 2560 </td><td>
2554 2561 create a new bookmark or list existing bookmarks
2555 2562 </td></tr>
2556 2563 <tr><td>
2557 2564 <a href="/help/branch">
2558 2565 branch
2559 2566 </a>
2560 2567 </td><td>
2561 2568 set or show the current branch name
2562 2569 </td></tr>
2563 2570 <tr><td>
2564 2571 <a href="/help/branches">
2565 2572 branches
2566 2573 </a>
2567 2574 </td><td>
2568 2575 list repository named branches
2569 2576 </td></tr>
2570 2577 <tr><td>
2571 2578 <a href="/help/bundle">
2572 2579 bundle
2573 2580 </a>
2574 2581 </td><td>
2575 2582 create a bundle file
2576 2583 </td></tr>
2577 2584 <tr><td>
2578 2585 <a href="/help/cat">
2579 2586 cat
2580 2587 </a>
2581 2588 </td><td>
2582 2589 output the current or given revision of files
2583 2590 </td></tr>
2584 2591 <tr><td>
2585 2592 <a href="/help/config">
2586 2593 config
2587 2594 </a>
2588 2595 </td><td>
2589 2596 show combined config settings from all hgrc files
2590 2597 </td></tr>
2591 2598 <tr><td>
2592 2599 <a href="/help/copy">
2593 2600 copy
2594 2601 </a>
2595 2602 </td><td>
2596 2603 mark files as copied for the next commit
2597 2604 </td></tr>
2598 2605 <tr><td>
2599 2606 <a href="/help/files">
2600 2607 files
2601 2608 </a>
2602 2609 </td><td>
2603 2610 list tracked files
2604 2611 </td></tr>
2605 2612 <tr><td>
2606 2613 <a href="/help/graft">
2607 2614 graft
2608 2615 </a>
2609 2616 </td><td>
2610 2617 copy changes from other branches onto the current branch
2611 2618 </td></tr>
2612 2619 <tr><td>
2613 2620 <a href="/help/grep">
2614 2621 grep
2615 2622 </a>
2616 2623 </td><td>
2617 2624 search for a pattern in specified files
2618 2625 </td></tr>
2619 2626 <tr><td>
2620 2627 <a href="/help/hashelp">
2621 2628 hashelp
2622 2629 </a>
2623 2630 </td><td>
2624 2631 Extension command's help
2625 2632 </td></tr>
2626 2633 <tr><td>
2627 2634 <a href="/help/heads">
2628 2635 heads
2629 2636 </a>
2630 2637 </td><td>
2631 2638 show branch heads
2632 2639 </td></tr>
2633 2640 <tr><td>
2634 2641 <a href="/help/help">
2635 2642 help
2636 2643 </a>
2637 2644 </td><td>
2638 2645 show help for a given topic or a help overview
2639 2646 </td></tr>
2640 2647 <tr><td>
2641 2648 <a href="/help/hgalias">
2642 2649 hgalias
2643 2650 </a>
2644 2651 </td><td>
2645 2652 My doc
2646 2653 </td></tr>
2647 2654 <tr><td>
2648 2655 <a href="/help/hgaliasnodoc">
2649 2656 hgaliasnodoc
2650 2657 </a>
2651 2658 </td><td>
2652 2659 summarize working directory state
2653 2660 </td></tr>
2654 2661 <tr><td>
2655 2662 <a href="/help/identify">
2656 2663 identify
2657 2664 </a>
2658 2665 </td><td>
2659 2666 identify the working directory or specified revision
2660 2667 </td></tr>
2661 2668 <tr><td>
2662 2669 <a href="/help/import">
2663 2670 import
2664 2671 </a>
2665 2672 </td><td>
2666 2673 import an ordered set of patches
2667 2674 </td></tr>
2668 2675 <tr><td>
2669 2676 <a href="/help/incoming">
2670 2677 incoming
2671 2678 </a>
2672 2679 </td><td>
2673 2680 show new changesets found in source
2674 2681 </td></tr>
2675 2682 <tr><td>
2676 2683 <a href="/help/manifest">
2677 2684 manifest
2678 2685 </a>
2679 2686 </td><td>
2680 2687 output the current or given revision of the project manifest
2681 2688 </td></tr>
2682 2689 <tr><td>
2683 2690 <a href="/help/nohelp">
2684 2691 nohelp
2685 2692 </a>
2686 2693 </td><td>
2687 2694 (no help text available)
2688 2695 </td></tr>
2689 2696 <tr><td>
2690 2697 <a href="/help/outgoing">
2691 2698 outgoing
2692 2699 </a>
2693 2700 </td><td>
2694 2701 show changesets not found in the destination
2695 2702 </td></tr>
2696 2703 <tr><td>
2697 2704 <a href="/help/paths">
2698 2705 paths
2699 2706 </a>
2700 2707 </td><td>
2701 2708 show aliases for remote repositories
2702 2709 </td></tr>
2703 2710 <tr><td>
2704 2711 <a href="/help/phase">
2705 2712 phase
2706 2713 </a>
2707 2714 </td><td>
2708 2715 set or show the current phase name
2709 2716 </td></tr>
2710 2717 <tr><td>
2711 2718 <a href="/help/recover">
2712 2719 recover
2713 2720 </a>
2714 2721 </td><td>
2715 2722 roll back an interrupted transaction
2716 2723 </td></tr>
2717 2724 <tr><td>
2718 2725 <a href="/help/rename">
2719 2726 rename
2720 2727 </a>
2721 2728 </td><td>
2722 2729 rename files; equivalent of copy + remove
2723 2730 </td></tr>
2724 2731 <tr><td>
2725 2732 <a href="/help/resolve">
2726 2733 resolve
2727 2734 </a>
2728 2735 </td><td>
2729 2736 redo merges or set/view the merge status of files
2730 2737 </td></tr>
2731 2738 <tr><td>
2732 2739 <a href="/help/revert">
2733 2740 revert
2734 2741 </a>
2735 2742 </td><td>
2736 2743 restore files to their checkout state
2737 2744 </td></tr>
2738 2745 <tr><td>
2739 2746 <a href="/help/root">
2740 2747 root
2741 2748 </a>
2742 2749 </td><td>
2743 2750 print the root (top) of the current working directory
2744 2751 </td></tr>
2745 2752 <tr><td>
2746 2753 <a href="/help/shellalias">
2747 2754 shellalias
2748 2755 </a>
2749 2756 </td><td>
2750 2757 (no help text available)
2751 2758 </td></tr>
2752 2759 <tr><td>
2753 2760 <a href="/help/shelve">
2754 2761 shelve
2755 2762 </a>
2756 2763 </td><td>
2757 2764 save and set aside changes from the working directory
2758 2765 </td></tr>
2759 2766 <tr><td>
2760 2767 <a href="/help/tag">
2761 2768 tag
2762 2769 </a>
2763 2770 </td><td>
2764 2771 add one or more tags for the current or given revision
2765 2772 </td></tr>
2766 2773 <tr><td>
2767 2774 <a href="/help/tags">
2768 2775 tags
2769 2776 </a>
2770 2777 </td><td>
2771 2778 list repository tags
2772 2779 </td></tr>
2773 2780 <tr><td>
2774 2781 <a href="/help/unbundle">
2775 2782 unbundle
2776 2783 </a>
2777 2784 </td><td>
2778 2785 apply one or more bundle files
2779 2786 </td></tr>
2780 2787 <tr><td>
2781 2788 <a href="/help/unshelve">
2782 2789 unshelve
2783 2790 </a>
2784 2791 </td><td>
2785 2792 restore a shelved change to the working directory
2786 2793 </td></tr>
2787 2794 <tr><td>
2788 2795 <a href="/help/verify">
2789 2796 verify
2790 2797 </a>
2791 2798 </td><td>
2792 2799 verify the integrity of the repository
2793 2800 </td></tr>
2794 2801 <tr><td>
2795 2802 <a href="/help/version">
2796 2803 version
2797 2804 </a>
2798 2805 </td><td>
2799 2806 output version and copyright information
2800 2807 </td></tr>
2801 2808
2802 2809
2803 2810 </table>
2804 2811 </div>
2805 2812 </div>
2806 2813
2807 2814
2808 2815
2809 2816 </body>
2810 2817 </html>
2811 2818
2812 2819
2813 2820 $ get-with-headers.py $LOCALIP:$HGPORT "help/add"
2814 2821 200 Script output follows
2815 2822
2816 2823 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2817 2824 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2818 2825 <head>
2819 2826 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2820 2827 <meta name="robots" content="index, nofollow" />
2821 2828 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2822 2829 <script type="text/javascript" src="/static/mercurial.js"></script>
2823 2830
2824 2831 <title>Help: add</title>
2825 2832 </head>
2826 2833 <body>
2827 2834
2828 2835 <div class="container">
2829 2836 <div class="menu">
2830 2837 <div class="logo">
2831 2838 <a href="https://mercurial-scm.org/">
2832 2839 <img src="/static/hglogo.png" alt="mercurial" /></a>
2833 2840 </div>
2834 2841 <ul>
2835 2842 <li><a href="/shortlog">log</a></li>
2836 2843 <li><a href="/graph">graph</a></li>
2837 2844 <li><a href="/tags">tags</a></li>
2838 2845 <li><a href="/bookmarks">bookmarks</a></li>
2839 2846 <li><a href="/branches">branches</a></li>
2840 2847 </ul>
2841 2848 <ul>
2842 2849 <li class="active"><a href="/help">help</a></li>
2843 2850 </ul>
2844 2851 </div>
2845 2852
2846 2853 <div class="main">
2847 2854 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2848 2855 <h3>Help: add</h3>
2849 2856
2850 2857 <form class="search" action="/log">
2851 2858
2852 2859 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2853 2860 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2854 2861 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2855 2862 </form>
2856 2863 <div id="doc">
2857 2864 <p>
2858 2865 hg add [OPTION]... [FILE]...
2859 2866 </p>
2860 2867 <p>
2861 2868 add the specified files on the next commit
2862 2869 </p>
2863 2870 <p>
2864 2871 Schedule files to be version controlled and added to the
2865 2872 repository.
2866 2873 </p>
2867 2874 <p>
2868 2875 The files will be added to the repository at the next commit. To
2869 2876 undo an add before that, see 'hg forget'.
2870 2877 </p>
2871 2878 <p>
2872 2879 If no names are given, add all files to the repository (except
2873 2880 files matching &quot;.hgignore&quot;).
2874 2881 </p>
2875 2882 <p>
2876 2883 Examples:
2877 2884 </p>
2878 2885 <ul>
2879 2886 <li> New (unknown) files are added automatically by 'hg add':
2880 2887 <pre>
2881 2888 \$ ls (re)
2882 2889 foo.c
2883 2890 \$ hg status (re)
2884 2891 ? foo.c
2885 2892 \$ hg add (re)
2886 2893 adding foo.c
2887 2894 \$ hg status (re)
2888 2895 A foo.c
2889 2896 </pre>
2890 2897 <li> Specific files to be added can be specified:
2891 2898 <pre>
2892 2899 \$ ls (re)
2893 2900 bar.c foo.c
2894 2901 \$ hg status (re)
2895 2902 ? bar.c
2896 2903 ? foo.c
2897 2904 \$ hg add bar.c (re)
2898 2905 \$ hg status (re)
2899 2906 A bar.c
2900 2907 ? foo.c
2901 2908 </pre>
2902 2909 </ul>
2903 2910 <p>
2904 2911 Returns 0 if all files are successfully added.
2905 2912 </p>
2906 2913 <p>
2907 2914 options ([+] can be repeated):
2908 2915 </p>
2909 2916 <table>
2910 2917 <tr><td>-I</td>
2911 2918 <td>--include PATTERN [+]</td>
2912 2919 <td>include names matching the given patterns</td></tr>
2913 2920 <tr><td>-X</td>
2914 2921 <td>--exclude PATTERN [+]</td>
2915 2922 <td>exclude names matching the given patterns</td></tr>
2916 2923 <tr><td>-S</td>
2917 2924 <td>--subrepos</td>
2918 2925 <td>recurse into subrepositories</td></tr>
2919 2926 <tr><td>-n</td>
2920 2927 <td>--dry-run</td>
2921 2928 <td>do not perform actions, just print output</td></tr>
2922 2929 </table>
2923 2930 <p>
2924 2931 global options ([+] can be repeated):
2925 2932 </p>
2926 2933 <table>
2927 2934 <tr><td>-R</td>
2928 2935 <td>--repository REPO</td>
2929 2936 <td>repository root directory or name of overlay bundle file</td></tr>
2930 2937 <tr><td></td>
2931 2938 <td>--cwd DIR</td>
2932 2939 <td>change working directory</td></tr>
2933 2940 <tr><td>-y</td>
2934 2941 <td>--noninteractive</td>
2935 2942 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2936 2943 <tr><td>-q</td>
2937 2944 <td>--quiet</td>
2938 2945 <td>suppress output</td></tr>
2939 2946 <tr><td>-v</td>
2940 2947 <td>--verbose</td>
2941 2948 <td>enable additional output</td></tr>
2942 2949 <tr><td></td>
2943 2950 <td>--color TYPE</td>
2944 2951 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
2945 2952 <tr><td></td>
2946 2953 <td>--config CONFIG [+]</td>
2947 2954 <td>set/override config option (use 'section.name=value')</td></tr>
2948 2955 <tr><td></td>
2949 2956 <td>--debug</td>
2950 2957 <td>enable debugging output</td></tr>
2951 2958 <tr><td></td>
2952 2959 <td>--debugger</td>
2953 2960 <td>start debugger</td></tr>
2954 2961 <tr><td></td>
2955 2962 <td>--encoding ENCODE</td>
2956 2963 <td>set the charset encoding (default: ascii)</td></tr>
2957 2964 <tr><td></td>
2958 2965 <td>--encodingmode MODE</td>
2959 2966 <td>set the charset encoding mode (default: strict)</td></tr>
2960 2967 <tr><td></td>
2961 2968 <td>--traceback</td>
2962 2969 <td>always print a traceback on exception</td></tr>
2963 2970 <tr><td></td>
2964 2971 <td>--time</td>
2965 2972 <td>time how long the command takes</td></tr>
2966 2973 <tr><td></td>
2967 2974 <td>--profile</td>
2968 2975 <td>print command execution profile</td></tr>
2969 2976 <tr><td></td>
2970 2977 <td>--version</td>
2971 2978 <td>output version information and exit</td></tr>
2972 2979 <tr><td>-h</td>
2973 2980 <td>--help</td>
2974 2981 <td>display help and exit</td></tr>
2975 2982 <tr><td></td>
2976 2983 <td>--hidden</td>
2977 2984 <td>consider hidden changesets</td></tr>
2978 2985 <tr><td></td>
2979 2986 <td>--pager TYPE</td>
2980 2987 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
2981 2988 </table>
2982 2989
2983 2990 </div>
2984 2991 </div>
2985 2992 </div>
2986 2993
2987 2994
2988 2995
2989 2996 </body>
2990 2997 </html>
2991 2998
2992 2999
2993 3000 $ get-with-headers.py $LOCALIP:$HGPORT "help/remove"
2994 3001 200 Script output follows
2995 3002
2996 3003 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2997 3004 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2998 3005 <head>
2999 3006 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3000 3007 <meta name="robots" content="index, nofollow" />
3001 3008 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3002 3009 <script type="text/javascript" src="/static/mercurial.js"></script>
3003 3010
3004 3011 <title>Help: remove</title>
3005 3012 </head>
3006 3013 <body>
3007 3014
3008 3015 <div class="container">
3009 3016 <div class="menu">
3010 3017 <div class="logo">
3011 3018 <a href="https://mercurial-scm.org/">
3012 3019 <img src="/static/hglogo.png" alt="mercurial" /></a>
3013 3020 </div>
3014 3021 <ul>
3015 3022 <li><a href="/shortlog">log</a></li>
3016 3023 <li><a href="/graph">graph</a></li>
3017 3024 <li><a href="/tags">tags</a></li>
3018 3025 <li><a href="/bookmarks">bookmarks</a></li>
3019 3026 <li><a href="/branches">branches</a></li>
3020 3027 </ul>
3021 3028 <ul>
3022 3029 <li class="active"><a href="/help">help</a></li>
3023 3030 </ul>
3024 3031 </div>
3025 3032
3026 3033 <div class="main">
3027 3034 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3028 3035 <h3>Help: remove</h3>
3029 3036
3030 3037 <form class="search" action="/log">
3031 3038
3032 3039 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3033 3040 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3034 3041 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3035 3042 </form>
3036 3043 <div id="doc">
3037 3044 <p>
3038 3045 hg remove [OPTION]... FILE...
3039 3046 </p>
3040 3047 <p>
3041 3048 aliases: rm
3042 3049 </p>
3043 3050 <p>
3044 3051 remove the specified files on the next commit
3045 3052 </p>
3046 3053 <p>
3047 3054 Schedule the indicated files for removal from the current branch.
3048 3055 </p>
3049 3056 <p>
3050 3057 This command schedules the files to be removed at the next commit.
3051 3058 To undo a remove before that, see 'hg revert'. To undo added
3052 3059 files, see 'hg forget'.
3053 3060 </p>
3054 3061 <p>
3055 3062 -A/--after can be used to remove only files that have already
3056 3063 been deleted, -f/--force can be used to force deletion, and -Af
3057 3064 can be used to remove files from the next revision without
3058 3065 deleting them from the working directory.
3059 3066 </p>
3060 3067 <p>
3061 3068 The following table details the behavior of remove for different
3062 3069 file states (columns) and option combinations (rows). The file
3063 3070 states are Added [A], Clean [C], Modified [M] and Missing [!]
3064 3071 (as reported by 'hg status'). The actions are Warn, Remove
3065 3072 (from branch) and Delete (from disk):
3066 3073 </p>
3067 3074 <table>
3068 3075 <tr><td>opt/state</td>
3069 3076 <td>A</td>
3070 3077 <td>C</td>
3071 3078 <td>M</td>
3072 3079 <td>!</td></tr>
3073 3080 <tr><td>none</td>
3074 3081 <td>W</td>
3075 3082 <td>RD</td>
3076 3083 <td>W</td>
3077 3084 <td>R</td></tr>
3078 3085 <tr><td>-f</td>
3079 3086 <td>R</td>
3080 3087 <td>RD</td>
3081 3088 <td>RD</td>
3082 3089 <td>R</td></tr>
3083 3090 <tr><td>-A</td>
3084 3091 <td>W</td>
3085 3092 <td>W</td>
3086 3093 <td>W</td>
3087 3094 <td>R</td></tr>
3088 3095 <tr><td>-Af</td>
3089 3096 <td>R</td>
3090 3097 <td>R</td>
3091 3098 <td>R</td>
3092 3099 <td>R</td></tr>
3093 3100 </table>
3094 3101 <p>
3095 3102 <b>Note:</b>
3096 3103 </p>
3097 3104 <p>
3098 3105 'hg remove' never deletes files in Added [A] state from the
3099 3106 working directory, not even if &quot;--force&quot; is specified.
3100 3107 </p>
3101 3108 <p>
3102 3109 Returns 0 on success, 1 if any warnings encountered.
3103 3110 </p>
3104 3111 <p>
3105 3112 options ([+] can be repeated):
3106 3113 </p>
3107 3114 <table>
3108 3115 <tr><td>-A</td>
3109 3116 <td>--after</td>
3110 3117 <td>record delete for missing files</td></tr>
3111 3118 <tr><td>-f</td>
3112 3119 <td>--force</td>
3113 3120 <td>forget added files, delete modified files</td></tr>
3114 3121 <tr><td>-S</td>
3115 3122 <td>--subrepos</td>
3116 3123 <td>recurse into subrepositories</td></tr>
3117 3124 <tr><td>-I</td>
3118 3125 <td>--include PATTERN [+]</td>
3119 3126 <td>include names matching the given patterns</td></tr>
3120 3127 <tr><td>-X</td>
3121 3128 <td>--exclude PATTERN [+]</td>
3122 3129 <td>exclude names matching the given patterns</td></tr>
3123 3130 <tr><td>-n</td>
3124 3131 <td>--dry-run</td>
3125 3132 <td>do not perform actions, just print output</td></tr>
3126 3133 </table>
3127 3134 <p>
3128 3135 global options ([+] can be repeated):
3129 3136 </p>
3130 3137 <table>
3131 3138 <tr><td>-R</td>
3132 3139 <td>--repository REPO</td>
3133 3140 <td>repository root directory or name of overlay bundle file</td></tr>
3134 3141 <tr><td></td>
3135 3142 <td>--cwd DIR</td>
3136 3143 <td>change working directory</td></tr>
3137 3144 <tr><td>-y</td>
3138 3145 <td>--noninteractive</td>
3139 3146 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
3140 3147 <tr><td>-q</td>
3141 3148 <td>--quiet</td>
3142 3149 <td>suppress output</td></tr>
3143 3150 <tr><td>-v</td>
3144 3151 <td>--verbose</td>
3145 3152 <td>enable additional output</td></tr>
3146 3153 <tr><td></td>
3147 3154 <td>--color TYPE</td>
3148 3155 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
3149 3156 <tr><td></td>
3150 3157 <td>--config CONFIG [+]</td>
3151 3158 <td>set/override config option (use 'section.name=value')</td></tr>
3152 3159 <tr><td></td>
3153 3160 <td>--debug</td>
3154 3161 <td>enable debugging output</td></tr>
3155 3162 <tr><td></td>
3156 3163 <td>--debugger</td>
3157 3164 <td>start debugger</td></tr>
3158 3165 <tr><td></td>
3159 3166 <td>--encoding ENCODE</td>
3160 3167 <td>set the charset encoding (default: ascii)</td></tr>
3161 3168 <tr><td></td>
3162 3169 <td>--encodingmode MODE</td>
3163 3170 <td>set the charset encoding mode (default: strict)</td></tr>
3164 3171 <tr><td></td>
3165 3172 <td>--traceback</td>
3166 3173 <td>always print a traceback on exception</td></tr>
3167 3174 <tr><td></td>
3168 3175 <td>--time</td>
3169 3176 <td>time how long the command takes</td></tr>
3170 3177 <tr><td></td>
3171 3178 <td>--profile</td>
3172 3179 <td>print command execution profile</td></tr>
3173 3180 <tr><td></td>
3174 3181 <td>--version</td>
3175 3182 <td>output version information and exit</td></tr>
3176 3183 <tr><td>-h</td>
3177 3184 <td>--help</td>
3178 3185 <td>display help and exit</td></tr>
3179 3186 <tr><td></td>
3180 3187 <td>--hidden</td>
3181 3188 <td>consider hidden changesets</td></tr>
3182 3189 <tr><td></td>
3183 3190 <td>--pager TYPE</td>
3184 3191 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
3185 3192 </table>
3186 3193
3187 3194 </div>
3188 3195 </div>
3189 3196 </div>
3190 3197
3191 3198
3192 3199
3193 3200 </body>
3194 3201 </html>
3195 3202
3196 3203
3197 3204 $ get-with-headers.py $LOCALIP:$HGPORT "help/dates"
3198 3205 200 Script output follows
3199 3206
3200 3207 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3201 3208 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3202 3209 <head>
3203 3210 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3204 3211 <meta name="robots" content="index, nofollow" />
3205 3212 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3206 3213 <script type="text/javascript" src="/static/mercurial.js"></script>
3207 3214
3208 3215 <title>Help: dates</title>
3209 3216 </head>
3210 3217 <body>
3211 3218
3212 3219 <div class="container">
3213 3220 <div class="menu">
3214 3221 <div class="logo">
3215 3222 <a href="https://mercurial-scm.org/">
3216 3223 <img src="/static/hglogo.png" alt="mercurial" /></a>
3217 3224 </div>
3218 3225 <ul>
3219 3226 <li><a href="/shortlog">log</a></li>
3220 3227 <li><a href="/graph">graph</a></li>
3221 3228 <li><a href="/tags">tags</a></li>
3222 3229 <li><a href="/bookmarks">bookmarks</a></li>
3223 3230 <li><a href="/branches">branches</a></li>
3224 3231 </ul>
3225 3232 <ul>
3226 3233 <li class="active"><a href="/help">help</a></li>
3227 3234 </ul>
3228 3235 </div>
3229 3236
3230 3237 <div class="main">
3231 3238 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3232 3239 <h3>Help: dates</h3>
3233 3240
3234 3241 <form class="search" action="/log">
3235 3242
3236 3243 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3237 3244 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3238 3245 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3239 3246 </form>
3240 3247 <div id="doc">
3241 3248 <h1>Date Formats</h1>
3242 3249 <p>
3243 3250 Some commands allow the user to specify a date, e.g.:
3244 3251 </p>
3245 3252 <ul>
3246 3253 <li> backout, commit, import, tag: Specify the commit date.
3247 3254 <li> log, revert, update: Select revision(s) by date.
3248 3255 </ul>
3249 3256 <p>
3250 3257 Many date formats are valid. Here are some examples:
3251 3258 </p>
3252 3259 <ul>
3253 3260 <li> &quot;Wed Dec 6 13:18:29 2006&quot; (local timezone assumed)
3254 3261 <li> &quot;Dec 6 13:18 -0600&quot; (year assumed, time offset provided)
3255 3262 <li> &quot;Dec 6 13:18 UTC&quot; (UTC and GMT are aliases for +0000)
3256 3263 <li> &quot;Dec 6&quot; (midnight)
3257 3264 <li> &quot;13:18&quot; (today assumed)
3258 3265 <li> &quot;3:39&quot; (3:39AM assumed)
3259 3266 <li> &quot;3:39pm&quot; (15:39)
3260 3267 <li> &quot;2006-12-06 13:18:29&quot; (ISO 8601 format)
3261 3268 <li> &quot;2006-12-6 13:18&quot;
3262 3269 <li> &quot;2006-12-6&quot;
3263 3270 <li> &quot;12-6&quot;
3264 3271 <li> &quot;12/6&quot;
3265 3272 <li> &quot;12/6/6&quot; (Dec 6 2006)
3266 3273 <li> &quot;today&quot; (midnight)
3267 3274 <li> &quot;yesterday&quot; (midnight)
3268 3275 <li> &quot;now&quot; - right now
3269 3276 </ul>
3270 3277 <p>
3271 3278 Lastly, there is Mercurial's internal format:
3272 3279 </p>
3273 3280 <ul>
3274 3281 <li> &quot;1165411109 0&quot; (Wed Dec 6 13:18:29 2006 UTC)
3275 3282 </ul>
3276 3283 <p>
3277 3284 This is the internal representation format for dates. The first number
3278 3285 is the number of seconds since the epoch (1970-01-01 00:00 UTC). The
3279 3286 second is the offset of the local timezone, in seconds west of UTC
3280 3287 (negative if the timezone is east of UTC).
3281 3288 </p>
3282 3289 <p>
3283 3290 The log command also accepts date ranges:
3284 3291 </p>
3285 3292 <ul>
3286 3293 <li> &quot;&lt;DATE&quot; - at or before a given date/time
3287 3294 <li> &quot;&gt;DATE&quot; - on or after a given date/time
3288 3295 <li> &quot;DATE to DATE&quot; - a date range, inclusive
3289 3296 <li> &quot;-DAYS&quot; - within a given number of days from today
3290 3297 </ul>
3291 3298
3292 3299 </div>
3293 3300 </div>
3294 3301 </div>
3295 3302
3296 3303
3297 3304
3298 3305 </body>
3299 3306 </html>
3300 3307
3301 3308
3302 3309 $ get-with-headers.py $LOCALIP:$HGPORT "help/pager"
3303 3310 200 Script output follows
3304 3311
3305 3312 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3306 3313 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3307 3314 <head>
3308 3315 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3309 3316 <meta name="robots" content="index, nofollow" />
3310 3317 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3311 3318 <script type="text/javascript" src="/static/mercurial.js"></script>
3312 3319
3313 3320 <title>Help: pager</title>
3314 3321 </head>
3315 3322 <body>
3316 3323
3317 3324 <div class="container">
3318 3325 <div class="menu">
3319 3326 <div class="logo">
3320 3327 <a href="https://mercurial-scm.org/">
3321 3328 <img src="/static/hglogo.png" alt="mercurial" /></a>
3322 3329 </div>
3323 3330 <ul>
3324 3331 <li><a href="/shortlog">log</a></li>
3325 3332 <li><a href="/graph">graph</a></li>
3326 3333 <li><a href="/tags">tags</a></li>
3327 3334 <li><a href="/bookmarks">bookmarks</a></li>
3328 3335 <li><a href="/branches">branches</a></li>
3329 3336 </ul>
3330 3337 <ul>
3331 3338 <li class="active"><a href="/help">help</a></li>
3332 3339 </ul>
3333 3340 </div>
3334 3341
3335 3342 <div class="main">
3336 3343 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3337 3344 <h3>Help: pager</h3>
3338 3345
3339 3346 <form class="search" action="/log">
3340 3347
3341 3348 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3342 3349 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3343 3350 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3344 3351 </form>
3345 3352 <div id="doc">
3346 3353 <h1>Pager Support</h1>
3347 3354 <p>
3348 3355 Some Mercurial commands can produce a lot of output, and Mercurial will
3349 3356 attempt to use a pager to make those commands more pleasant.
3350 3357 </p>
3351 3358 <p>
3352 3359 To set the pager that should be used, set the application variable:
3353 3360 </p>
3354 3361 <pre>
3355 3362 [pager]
3356 3363 pager = less -FRX
3357 3364 </pre>
3358 3365 <p>
3359 3366 If no pager is set in the user or repository configuration, Mercurial uses the
3360 3367 environment variable $PAGER. If $PAGER is not set, pager.pager from the default
3361 3368 or system configuration is used. If none of these are set, a default pager will
3362 3369 be used, typically 'less' on Unix and 'more' on Windows.
3363 3370 </p>
3364 3371 <p>
3365 3372 You can disable the pager for certain commands by adding them to the
3366 3373 pager.ignore list:
3367 3374 </p>
3368 3375 <pre>
3369 3376 [pager]
3370 3377 ignore = version, help, update
3371 3378 </pre>
3372 3379 <p>
3373 3380 To ignore global commands like 'hg version' or 'hg help', you have
3374 3381 to specify them in your user configuration file.
3375 3382 </p>
3376 3383 <p>
3377 3384 To control whether the pager is used at all for an individual command,
3378 3385 you can use --pager=&lt;value&gt;:
3379 3386 </p>
3380 3387 <ul>
3381 3388 <li> use as needed: 'auto'.
3382 3389 <li> require the pager: 'yes' or 'on'.
3383 3390 <li> suppress the pager: 'no' or 'off' (any unrecognized value will also work).
3384 3391 </ul>
3385 3392 <p>
3386 3393 To globally turn off all attempts to use a pager, set:
3387 3394 </p>
3388 3395 <pre>
3389 3396 [ui]
3390 3397 paginate = never
3391 3398 </pre>
3392 3399 <p>
3393 3400 which will prevent the pager from running.
3394 3401 </p>
3395 3402
3396 3403 </div>
3397 3404 </div>
3398 3405 </div>
3399 3406
3400 3407
3401 3408
3402 3409 </body>
3403 3410 </html>
3404 3411
3405 3412
3406 3413 Sub-topic indexes rendered properly
3407 3414
3408 3415 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals"
3409 3416 200 Script output follows
3410 3417
3411 3418 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3412 3419 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3413 3420 <head>
3414 3421 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3415 3422 <meta name="robots" content="index, nofollow" />
3416 3423 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3417 3424 <script type="text/javascript" src="/static/mercurial.js"></script>
3418 3425
3419 3426 <title>Help: internals</title>
3420 3427 </head>
3421 3428 <body>
3422 3429
3423 3430 <div class="container">
3424 3431 <div class="menu">
3425 3432 <div class="logo">
3426 3433 <a href="https://mercurial-scm.org/">
3427 3434 <img src="/static/hglogo.png" alt="mercurial" /></a>
3428 3435 </div>
3429 3436 <ul>
3430 3437 <li><a href="/shortlog">log</a></li>
3431 3438 <li><a href="/graph">graph</a></li>
3432 3439 <li><a href="/tags">tags</a></li>
3433 3440 <li><a href="/bookmarks">bookmarks</a></li>
3434 3441 <li><a href="/branches">branches</a></li>
3435 3442 </ul>
3436 3443 <ul>
3437 3444 <li><a href="/help">help</a></li>
3438 3445 </ul>
3439 3446 </div>
3440 3447
3441 3448 <div class="main">
3442 3449 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3443 3450
3444 3451 <form class="search" action="/log">
3445 3452
3446 3453 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3447 3454 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3448 3455 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3449 3456 </form>
3450 3457 <table class="bigtable">
3451 3458 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
3452 3459
3453 3460 <tr><td>
3454 3461 <a href="/help/internals.bid-merge">
3455 3462 bid-merge
3456 3463 </a>
3457 3464 </td><td>
3458 3465 Bid Merge Algorithm
3459 3466 </td></tr>
3460 3467 <tr><td>
3461 3468 <a href="/help/internals.bundle2">
3462 3469 bundle2
3463 3470 </a>
3464 3471 </td><td>
3465 3472 Bundle2
3466 3473 </td></tr>
3467 3474 <tr><td>
3468 3475 <a href="/help/internals.bundles">
3469 3476 bundles
3470 3477 </a>
3471 3478 </td><td>
3472 3479 Bundles
3473 3480 </td></tr>
3474 3481 <tr><td>
3475 3482 <a href="/help/internals.cbor">
3476 3483 cbor
3477 3484 </a>
3478 3485 </td><td>
3479 3486 CBOR
3480 3487 </td></tr>
3481 3488 <tr><td>
3482 3489 <a href="/help/internals.censor">
3483 3490 censor
3484 3491 </a>
3485 3492 </td><td>
3486 3493 Censor
3487 3494 </td></tr>
3488 3495 <tr><td>
3489 3496 <a href="/help/internals.changegroups">
3490 3497 changegroups
3491 3498 </a>
3492 3499 </td><td>
3493 3500 Changegroups
3494 3501 </td></tr>
3495 3502 <tr><td>
3496 3503 <a href="/help/internals.config">
3497 3504 config
3498 3505 </a>
3499 3506 </td><td>
3500 3507 Config Registrar
3501 3508 </td></tr>
3502 3509 <tr><td>
3503 3510 <a href="/help/internals.extensions">
3504 3511 extensions
3505 3512 </a>
3506 3513 </td><td>
3507 3514 Extension API
3508 3515 </td></tr>
3509 3516 <tr><td>
3510 3517 <a href="/help/internals.mergestate">
3511 3518 mergestate
3512 3519 </a>
3513 3520 </td><td>
3514 3521 Mergestate
3515 3522 </td></tr>
3516 3523 <tr><td>
3517 3524 <a href="/help/internals.requirements">
3518 3525 requirements
3519 3526 </a>
3520 3527 </td><td>
3521 3528 Repository Requirements
3522 3529 </td></tr>
3523 3530 <tr><td>
3524 3531 <a href="/help/internals.revlogs">
3525 3532 revlogs
3526 3533 </a>
3527 3534 </td><td>
3528 3535 Revision Logs
3529 3536 </td></tr>
3530 3537 <tr><td>
3531 3538 <a href="/help/internals.wireprotocol">
3532 3539 wireprotocol
3533 3540 </a>
3534 3541 </td><td>
3535 3542 Wire Protocol
3536 3543 </td></tr>
3537 3544 <tr><td>
3538 3545 <a href="/help/internals.wireprotocolrpc">
3539 3546 wireprotocolrpc
3540 3547 </a>
3541 3548 </td><td>
3542 3549 Wire Protocol RPC
3543 3550 </td></tr>
3544 3551 <tr><td>
3545 3552 <a href="/help/internals.wireprotocolv2">
3546 3553 wireprotocolv2
3547 3554 </a>
3548 3555 </td><td>
3549 3556 Wire Protocol Version 2
3550 3557 </td></tr>
3551 3558
3552 3559
3553 3560
3554 3561
3555 3562
3556 3563 </table>
3557 3564 </div>
3558 3565 </div>
3559 3566
3560 3567
3561 3568
3562 3569 </body>
3563 3570 </html>
3564 3571
3565 3572
3566 3573 Sub-topic topics rendered properly
3567 3574
3568 3575 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals.changegroups"
3569 3576 200 Script output follows
3570 3577
3571 3578 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3572 3579 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3573 3580 <head>
3574 3581 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3575 3582 <meta name="robots" content="index, nofollow" />
3576 3583 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3577 3584 <script type="text/javascript" src="/static/mercurial.js"></script>
3578 3585
3579 3586 <title>Help: internals.changegroups</title>
3580 3587 </head>
3581 3588 <body>
3582 3589
3583 3590 <div class="container">
3584 3591 <div class="menu">
3585 3592 <div class="logo">
3586 3593 <a href="https://mercurial-scm.org/">
3587 3594 <img src="/static/hglogo.png" alt="mercurial" /></a>
3588 3595 </div>
3589 3596 <ul>
3590 3597 <li><a href="/shortlog">log</a></li>
3591 3598 <li><a href="/graph">graph</a></li>
3592 3599 <li><a href="/tags">tags</a></li>
3593 3600 <li><a href="/bookmarks">bookmarks</a></li>
3594 3601 <li><a href="/branches">branches</a></li>
3595 3602 </ul>
3596 3603 <ul>
3597 3604 <li class="active"><a href="/help">help</a></li>
3598 3605 </ul>
3599 3606 </div>
3600 3607
3601 3608 <div class="main">
3602 3609 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3603 3610 <h3>Help: internals.changegroups</h3>
3604 3611
3605 3612 <form class="search" action="/log">
3606 3613
3607 3614 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3608 3615 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3609 3616 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3610 3617 </form>
3611 3618 <div id="doc">
3612 3619 <h1>Changegroups</h1>
3613 3620 <p>
3614 3621 Changegroups are representations of repository revlog data, specifically
3615 3622 the changelog data, root/flat manifest data, treemanifest data, and
3616 3623 filelogs.
3617 3624 </p>
3618 3625 <p>
3619 3626 There are 3 versions of changegroups: &quot;1&quot;, &quot;2&quot;, and &quot;3&quot;. From a
3620 3627 high-level, versions &quot;1&quot; and &quot;2&quot; are almost exactly the same, with the
3621 3628 only difference being an additional item in the *delta header*. Version
3622 3629 &quot;3&quot; adds support for storage flags in the *delta header* and optionally
3623 3630 exchanging treemanifests (enabled by setting an option on the
3624 3631 &quot;changegroup&quot; part in the bundle2).
3625 3632 </p>
3626 3633 <p>
3627 3634 Changegroups when not exchanging treemanifests consist of 3 logical
3628 3635 segments:
3629 3636 </p>
3630 3637 <pre>
3631 3638 +---------------------------------+
3632 3639 | | | |
3633 3640 | changeset | manifest | filelogs |
3634 3641 | | | |
3635 3642 | | | |
3636 3643 +---------------------------------+
3637 3644 </pre>
3638 3645 <p>
3639 3646 When exchanging treemanifests, there are 4 logical segments:
3640 3647 </p>
3641 3648 <pre>
3642 3649 +-------------------------------------------------+
3643 3650 | | | | |
3644 3651 | changeset | root | treemanifests | filelogs |
3645 3652 | | manifest | | |
3646 3653 | | | | |
3647 3654 +-------------------------------------------------+
3648 3655 </pre>
3649 3656 <p>
3650 3657 The principle building block of each segment is a *chunk*. A *chunk*
3651 3658 is a framed piece of data:
3652 3659 </p>
3653 3660 <pre>
3654 3661 +---------------------------------------+
3655 3662 | | |
3656 3663 | length | data |
3657 3664 | (4 bytes) | (&lt;length - 4&gt; bytes) |
3658 3665 | | |
3659 3666 +---------------------------------------+
3660 3667 </pre>
3661 3668 <p>
3662 3669 All integers are big-endian signed integers. Each chunk starts with a 32-bit
3663 3670 integer indicating the length of the entire chunk (including the length field
3664 3671 itself).
3665 3672 </p>
3666 3673 <p>
3667 3674 There is a special case chunk that has a value of 0 for the length
3668 3675 (&quot;0x00000000&quot;). We call this an *empty chunk*.
3669 3676 </p>
3670 3677 <h2>Delta Groups</h2>
3671 3678 <p>
3672 3679 A *delta group* expresses the content of a revlog as a series of deltas,
3673 3680 or patches against previous revisions.
3674 3681 </p>
3675 3682 <p>
3676 3683 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
3677 3684 to signal the end of the delta group:
3678 3685 </p>
3679 3686 <pre>
3680 3687 +------------------------------------------------------------------------+
3681 3688 | | | | | |
3682 3689 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
3683 3690 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
3684 3691 | | | | | |
3685 3692 +------------------------------------------------------------------------+
3686 3693 </pre>
3687 3694 <p>
3688 3695 Each *chunk*'s data consists of the following:
3689 3696 </p>
3690 3697 <pre>
3691 3698 +---------------------------------------+
3692 3699 | | |
3693 3700 | delta header | delta data |
3694 3701 | (various by version) | (various) |
3695 3702 | | |
3696 3703 +---------------------------------------+
3697 3704 </pre>
3698 3705 <p>
3699 3706 The *delta data* is a series of *delta*s that describe a diff from an existing
3700 3707 entry (either that the recipient already has, or previously specified in the
3701 3708 bundle/changegroup).
3702 3709 </p>
3703 3710 <p>
3704 3711 The *delta header* is different between versions &quot;1&quot;, &quot;2&quot;, and
3705 3712 &quot;3&quot; of the changegroup format.
3706 3713 </p>
3707 3714 <p>
3708 3715 Version 1 (headerlen=80):
3709 3716 </p>
3710 3717 <pre>
3711 3718 +------------------------------------------------------+
3712 3719 | | | | |
3713 3720 | node | p1 node | p2 node | link node |
3714 3721 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3715 3722 | | | | |
3716 3723 +------------------------------------------------------+
3717 3724 </pre>
3718 3725 <p>
3719 3726 Version 2 (headerlen=100):
3720 3727 </p>
3721 3728 <pre>
3722 3729 +------------------------------------------------------------------+
3723 3730 | | | | | |
3724 3731 | node | p1 node | p2 node | base node | link node |
3725 3732 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3726 3733 | | | | | |
3727 3734 +------------------------------------------------------------------+
3728 3735 </pre>
3729 3736 <p>
3730 3737 Version 3 (headerlen=102):
3731 3738 </p>
3732 3739 <pre>
3733 3740 +------------------------------------------------------------------------------+
3734 3741 | | | | | | |
3735 3742 | node | p1 node | p2 node | base node | link node | flags |
3736 3743 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
3737 3744 | | | | | | |
3738 3745 +------------------------------------------------------------------------------+
3739 3746 </pre>
3740 3747 <p>
3741 3748 The *delta data* consists of &quot;chunklen - 4 - headerlen&quot; bytes, which contain a
3742 3749 series of *delta*s, densely packed (no separators). These deltas describe a diff
3743 3750 from an existing entry (either that the recipient already has, or previously
3744 3751 specified in the bundle/changegroup). The format is described more fully in
3745 3752 &quot;hg help internals.bdiff&quot;, but briefly:
3746 3753 </p>
3747 3754 <pre>
3748 3755 +---------------------------------------------------------------+
3749 3756 | | | | |
3750 3757 | start offset | end offset | new length | content |
3751 3758 | (4 bytes) | (4 bytes) | (4 bytes) | (&lt;new length&gt; bytes) |
3752 3759 | | | | |
3753 3760 +---------------------------------------------------------------+
3754 3761 </pre>
3755 3762 <p>
3756 3763 Please note that the length field in the delta data does *not* include itself.
3757 3764 </p>
3758 3765 <p>
3759 3766 In version 1, the delta is always applied against the previous node from
3760 3767 the changegroup or the first parent if this is the first entry in the
3761 3768 changegroup.
3762 3769 </p>
3763 3770 <p>
3764 3771 In version 2 and up, the delta base node is encoded in the entry in the
3765 3772 changegroup. This allows the delta to be expressed against any parent,
3766 3773 which can result in smaller deltas and more efficient encoding of data.
3767 3774 </p>
3768 3775 <p>
3769 3776 The *flags* field holds bitwise flags affecting the processing of revision
3770 3777 data. The following flags are defined:
3771 3778 </p>
3772 3779 <dl>
3773 3780 <dt>32768
3774 3781 <dd>Censored revision. The revision's fulltext has been replaced by censor metadata. May only occur on file revisions.
3775 3782 <dt>16384
3776 3783 <dd>Ellipsis revision. Revision hash does not match data (likely due to rewritten parents).
3777 3784 <dt>8192
3778 3785 <dd>Externally stored. The revision fulltext contains &quot;key:value&quot; &quot;\n&quot; delimited metadata defining an object stored elsewhere. Used by the LFS extension.
3779 3786 </dl>
3780 3787 <p>
3781 3788 For historical reasons, the integer values are identical to revlog version 1
3782 3789 per-revision storage flags and correspond to bits being set in this 2-byte
3783 3790 field. Bits were allocated starting from the most-significant bit, hence the
3784 3791 reverse ordering and allocation of these flags.
3785 3792 </p>
3786 3793 <h2>Changeset Segment</h2>
3787 3794 <p>
3788 3795 The *changeset segment* consists of a single *delta group* holding
3789 3796 changelog data. The *empty chunk* at the end of the *delta group* denotes
3790 3797 the boundary to the *manifest segment*.
3791 3798 </p>
3792 3799 <h2>Manifest Segment</h2>
3793 3800 <p>
3794 3801 The *manifest segment* consists of a single *delta group* holding manifest
3795 3802 data. If treemanifests are in use, it contains only the manifest for the
3796 3803 root directory of the repository. Otherwise, it contains the entire
3797 3804 manifest data. The *empty chunk* at the end of the *delta group* denotes
3798 3805 the boundary to the next segment (either the *treemanifests segment* or the
3799 3806 *filelogs segment*, depending on version and the request options).
3800 3807 </p>
3801 3808 <h3>Treemanifests Segment</h3>
3802 3809 <p>
3803 3810 The *treemanifests segment* only exists in changegroup version &quot;3&quot;, and
3804 3811 only if the 'treemanifest' param is part of the bundle2 changegroup part
3805 3812 (it is not possible to use changegroup version 3 outside of bundle2).
3806 3813 Aside from the filenames in the *treemanifests segment* containing a
3807 3814 trailing &quot;/&quot; character, it behaves identically to the *filelogs segment*
3808 3815 (see below). The final sub-segment is followed by an *empty chunk* (logically,
3809 3816 a sub-segment with filename size 0). This denotes the boundary to the
3810 3817 *filelogs segment*.
3811 3818 </p>
3812 3819 <h2>Filelogs Segment</h2>
3813 3820 <p>
3814 3821 The *filelogs segment* consists of multiple sub-segments, each
3815 3822 corresponding to an individual file whose data is being described:
3816 3823 </p>
3817 3824 <pre>
3818 3825 +--------------------------------------------------+
3819 3826 | | | | | |
3820 3827 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
3821 3828 | | | | | (4 bytes) |
3822 3829 | | | | | |
3823 3830 +--------------------------------------------------+
3824 3831 </pre>
3825 3832 <p>
3826 3833 The final filelog sub-segment is followed by an *empty chunk* (logically,
3827 3834 a sub-segment with filename size 0). This denotes the end of the segment
3828 3835 and of the overall changegroup.
3829 3836 </p>
3830 3837 <p>
3831 3838 Each filelog sub-segment consists of the following:
3832 3839 </p>
3833 3840 <pre>
3834 3841 +------------------------------------------------------+
3835 3842 | | | |
3836 3843 | filename length | filename | delta group |
3837 3844 | (4 bytes) | (&lt;length - 4&gt; bytes) | (various) |
3838 3845 | | | |
3839 3846 +------------------------------------------------------+
3840 3847 </pre>
3841 3848 <p>
3842 3849 That is, a *chunk* consisting of the filename (not terminated or padded)
3843 3850 followed by N chunks constituting the *delta group* for this file. The
3844 3851 *empty chunk* at the end of each *delta group* denotes the boundary to the
3845 3852 next filelog sub-segment.
3846 3853 </p>
3847 3854
3848 3855 </div>
3849 3856 </div>
3850 3857 </div>
3851 3858
3852 3859
3853 3860
3854 3861 </body>
3855 3862 </html>
3856 3863
3857 3864
3858 3865 $ get-with-headers.py 127.0.0.1:$HGPORT "help/unknowntopic"
3859 3866 404 Not Found
3860 3867
3861 3868 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3862 3869 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3863 3870 <head>
3864 3871 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3865 3872 <meta name="robots" content="index, nofollow" />
3866 3873 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3867 3874 <script type="text/javascript" src="/static/mercurial.js"></script>
3868 3875
3869 3876 <title>test: error</title>
3870 3877 </head>
3871 3878 <body>
3872 3879
3873 3880 <div class="container">
3874 3881 <div class="menu">
3875 3882 <div class="logo">
3876 3883 <a href="https://mercurial-scm.org/">
3877 3884 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial" /></a>
3878 3885 </div>
3879 3886 <ul>
3880 3887 <li><a href="/shortlog">log</a></li>
3881 3888 <li><a href="/graph">graph</a></li>
3882 3889 <li><a href="/tags">tags</a></li>
3883 3890 <li><a href="/bookmarks">bookmarks</a></li>
3884 3891 <li><a href="/branches">branches</a></li>
3885 3892 </ul>
3886 3893 <ul>
3887 3894 <li><a href="/help">help</a></li>
3888 3895 </ul>
3889 3896 </div>
3890 3897
3891 3898 <div class="main">
3892 3899
3893 3900 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3894 3901 <h3>error</h3>
3895 3902
3896 3903
3897 3904 <form class="search" action="/log">
3898 3905
3899 3906 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3900 3907 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3901 3908 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3902 3909 </form>
3903 3910
3904 3911 <div class="description">
3905 3912 <p>
3906 3913 An error occurred while processing your request:
3907 3914 </p>
3908 3915 <p>
3909 3916 Not Found
3910 3917 </p>
3911 3918 </div>
3912 3919 </div>
3913 3920 </div>
3914 3921
3915 3922
3916 3923
3917 3924 </body>
3918 3925 </html>
3919 3926
3920 3927 [1]
3921 3928
3922 3929 $ killdaemons.py
3923 3930
3924 3931 #endif
General Comments 0
You need to be logged in to leave comments. Login now