##// END OF EJS Templates
rebase: prevent creating divergence...
Laurent Charignon -
r27746:f0e9f38d default
parent child Browse files
Show More
@@ -1,1247 +1,1258 b''
1 1 # rebase.py - rebasing feature for mercurial
2 2 #
3 3 # Copyright 2008 Stefano Tortarolo <stefano.tortarolo at gmail dot 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 '''command to move sets of revisions to a different ancestor
9 9
10 10 This extension lets you rebase changesets in an existing Mercurial
11 11 repository.
12 12
13 13 For more information:
14 14 https://mercurial-scm.org/wiki/RebaseExtension
15 15 '''
16 16
17 17 from mercurial import hg, util, repair, merge, cmdutil, commands, bookmarks
18 18 from mercurial import extensions, patch, scmutil, phases, obsolete, error
19 19 from mercurial import copies, repoview, revset
20 20 from mercurial.commands import templateopts
21 21 from mercurial.node import nullrev, nullid, hex, short
22 22 from mercurial.lock import release
23 23 from mercurial.i18n import _
24 24 import os, errno
25 25
26 26 # The following constants are used throughout the rebase module. The ordering of
27 27 # their values must be maintained.
28 28
29 29 # Indicates that a revision needs to be rebased
30 30 revtodo = -1
31 31 nullmerge = -2
32 32 revignored = -3
33 33 # successor in rebase destination
34 34 revprecursor = -4
35 35 # plain prune (no successor)
36 36 revpruned = -5
37 37 revskipped = (revignored, revprecursor, revpruned)
38 38
39 39 cmdtable = {}
40 40 command = cmdutil.command(cmdtable)
41 41 # Note for extension authors: ONLY specify testedwith = 'internal' for
42 42 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
43 43 # be specifying the version(s) of Mercurial they are tested with, or
44 44 # leave the attribute unspecified.
45 45 testedwith = 'internal'
46 46
47 47 def _nothingtorebase():
48 48 return 1
49 49
50 50 def _makeextrafn(copiers):
51 51 """make an extrafn out of the given copy-functions.
52 52
53 53 A copy function takes a context and an extra dict, and mutates the
54 54 extra dict as needed based on the given context.
55 55 """
56 56 def extrafn(ctx, extra):
57 57 for c in copiers:
58 58 c(ctx, extra)
59 59 return extrafn
60 60
61 61 def _destrebase(repo):
62 62 # Destination defaults to the latest revision in the
63 63 # current branch
64 64 branch = repo[None].branch()
65 65 return repo[branch].rev()
66 66
67 67 revsetpredicate = revset.extpredicate()
68 68
69 69 @revsetpredicate('_destrebase')
70 70 def _revsetdestrebase(repo, subset, x):
71 71 # ``_rebasedefaultdest()``
72 72
73 73 # default destination for rebase.
74 74 # # XXX: Currently private because I expect the signature to change.
75 75 # # XXX: - taking rev as arguments,
76 76 # # XXX: - bailing out in case of ambiguity vs returning all data.
77 77 # # XXX: - probably merging with the merge destination.
78 78 # i18n: "_rebasedefaultdest" is a keyword
79 79 revset.getargs(x, 0, 0, _("_rebasedefaultdest takes no arguments"))
80 80 return subset & revset.baseset([_destrebase(repo)])
81 81
82 82 @command('rebase',
83 83 [('s', 'source', '',
84 84 _('rebase the specified changeset and descendants'), _('REV')),
85 85 ('b', 'base', '',
86 86 _('rebase everything from branching point of specified changeset'),
87 87 _('REV')),
88 88 ('r', 'rev', [],
89 89 _('rebase these revisions'),
90 90 _('REV')),
91 91 ('d', 'dest', '',
92 92 _('rebase onto the specified changeset'), _('REV')),
93 93 ('', 'collapse', False, _('collapse the rebased changesets')),
94 94 ('m', 'message', '',
95 95 _('use text as collapse commit message'), _('TEXT')),
96 96 ('e', 'edit', False, _('invoke editor on commit messages')),
97 97 ('l', 'logfile', '',
98 98 _('read collapse commit message from file'), _('FILE')),
99 99 ('k', 'keep', False, _('keep original changesets')),
100 100 ('', 'keepbranches', False, _('keep original branch names')),
101 101 ('D', 'detach', False, _('(DEPRECATED)')),
102 102 ('i', 'interactive', False, _('(DEPRECATED)')),
103 103 ('t', 'tool', '', _('specify merge tool')),
104 104 ('c', 'continue', False, _('continue an interrupted rebase')),
105 105 ('a', 'abort', False, _('abort an interrupted rebase'))] +
106 106 templateopts,
107 107 _('[-s REV | -b REV] [-d REV] [OPTION]'))
108 108 def rebase(ui, repo, **opts):
109 109 """move changeset (and descendants) to a different branch
110 110
111 111 Rebase uses repeated merging to graft changesets from one part of
112 112 history (the source) onto another (the destination). This can be
113 113 useful for linearizing *local* changes relative to a master
114 114 development tree.
115 115
116 116 Published commits cannot be rebased (see :hg:`help phases`).
117 117 To copy commits, see :hg:`help graft`.
118 118
119 119 If you don't specify a destination changeset (``-d/--dest``),
120 120 rebase uses the current branch tip as the destination. (The
121 121 destination changeset is not modified by rebasing, but new
122 122 changesets are added as its descendants.)
123 123
124 124 There are three ways to select changesets::
125 125
126 126 1. Explicitly select them using ``--rev``.
127 127
128 128 2. Use ``--source`` to select a root changeset and include all of its
129 129 descendants.
130 130
131 131 3. Use ``--base`` to select a changeset; rebase will find ancestors
132 132 and their descendants which are not also ancestors of the destination.
133 133
134 134 Rebase will destroy original changesets unless you use ``--keep``.
135 135 It will also move your bookmarks (even if you do).
136 136
137 137 Some changesets may be dropped if they do not contribute changes
138 138 (e.g. merges from the destination branch).
139 139
140 140 Unlike ``merge``, rebase will do nothing if you are at the branch tip of
141 141 a named branch with two heads. You will need to explicitly specify source
142 142 and/or destination.
143 143
144 144 If a rebase is interrupted to manually resolve a conflict, it can be
145 145 continued with --continue/-c or aborted with --abort/-a.
146 146
147 147 .. container:: verbose
148 148
149 149 Examples:
150 150
151 151 - move "local changes" (current commit back to branching point)
152 152 to the current branch tip after a pull::
153 153
154 154 hg rebase
155 155
156 156 - move a single changeset to the stable branch::
157 157
158 158 hg rebase -r 5f493448 -d stable
159 159
160 160 - splice a commit and all its descendants onto another part of history::
161 161
162 162 hg rebase --source c0c3 --dest 4cf9
163 163
164 164 - rebase everything on a branch marked by a bookmark onto the
165 165 default branch::
166 166
167 167 hg rebase --base myfeature --dest default
168 168
169 169 - collapse a sequence of changes into a single commit::
170 170
171 171 hg rebase --collapse -r 1520:1525 -d .
172 172
173 173 - move a named branch while preserving its name::
174 174
175 175 hg rebase -r "branch(featureX)" -d 1.3 --keepbranches
176 176
177 177 Returns 0 on success, 1 if nothing to rebase or there are
178 178 unresolved conflicts.
179 179
180 180 """
181 181 originalwd = target = None
182 182 activebookmark = None
183 183 external = nullrev
184 184 # Mapping between the old revision id and either what is the new rebased
185 185 # revision or what needs to be done with the old revision. The state dict
186 186 # will be what contains most of the rebase progress state.
187 187 state = {}
188 188 skipped = set()
189 189 targetancestors = set()
190 190
191 191
192 192 lock = wlock = None
193 193 try:
194 194 wlock = repo.wlock()
195 195 lock = repo.lock()
196 196
197 197 # Validate input and define rebasing points
198 198 destf = opts.get('dest', None)
199 199 srcf = opts.get('source', None)
200 200 basef = opts.get('base', None)
201 201 revf = opts.get('rev', [])
202 202 contf = opts.get('continue')
203 203 abortf = opts.get('abort')
204 204 collapsef = opts.get('collapse', False)
205 205 collapsemsg = cmdutil.logmessage(ui, opts)
206 206 date = opts.get('date', None)
207 207 e = opts.get('extrafn') # internal, used by e.g. hgsubversion
208 208 extrafns = []
209 209 if e:
210 210 extrafns = [e]
211 211 keepf = opts.get('keep', False)
212 212 keepbranchesf = opts.get('keepbranches', False)
213 213 # keepopen is not meant for use on the command line, but by
214 214 # other extensions
215 215 keepopen = opts.get('keepopen', False)
216 216
217 217 if opts.get('interactive'):
218 218 try:
219 219 if extensions.find('histedit'):
220 220 enablehistedit = ''
221 221 except KeyError:
222 222 enablehistedit = " --config extensions.histedit="
223 223 help = "hg%s help -e histedit" % enablehistedit
224 224 msg = _("interactive history editing is supported by the "
225 225 "'histedit' extension (see \"%s\")") % help
226 226 raise error.Abort(msg)
227 227
228 228 if collapsemsg and not collapsef:
229 229 raise error.Abort(
230 230 _('message can only be specified with collapse'))
231 231
232 232 if contf or abortf:
233 233 if contf and abortf:
234 234 raise error.Abort(_('cannot use both abort and continue'))
235 235 if collapsef:
236 236 raise error.Abort(
237 237 _('cannot use collapse with continue or abort'))
238 238 if srcf or basef or destf:
239 239 raise error.Abort(
240 240 _('abort and continue do not allow specifying revisions'))
241 241 if abortf and opts.get('tool', False):
242 242 ui.warn(_('tool option will be ignored\n'))
243 243
244 244 try:
245 245 (originalwd, target, state, skipped, collapsef, keepf,
246 246 keepbranchesf, external, activebookmark) = restorestatus(repo)
247 247 except error.RepoLookupError:
248 248 if abortf:
249 249 clearstatus(repo)
250 250 repo.ui.warn(_('rebase aborted (no revision is removed,'
251 251 ' only broken state is cleared)\n'))
252 252 return 0
253 253 else:
254 254 msg = _('cannot continue inconsistent rebase')
255 255 hint = _('use "hg rebase --abort" to clear broken state')
256 256 raise error.Abort(msg, hint=hint)
257 257 if abortf:
258 258 return abort(repo, originalwd, target, state,
259 259 activebookmark=activebookmark)
260 260 else:
261 261 if srcf and basef:
262 262 raise error.Abort(_('cannot specify both a '
263 263 'source and a base'))
264 264 if revf and basef:
265 265 raise error.Abort(_('cannot specify both a '
266 266 'revision and a base'))
267 267 if revf and srcf:
268 268 raise error.Abort(_('cannot specify both a '
269 269 'revision and a source'))
270 270
271 271 cmdutil.checkunfinished(repo)
272 272 cmdutil.bailifchanged(repo)
273 273
274 274 if destf:
275 275 dest = scmutil.revsingle(repo, destf)
276 276 else:
277 277 dest = repo[_destrebase(repo)]
278 278 destf = str(dest)
279 279
280 280 if revf:
281 281 rebaseset = scmutil.revrange(repo, revf)
282 282 if not rebaseset:
283 283 ui.status(_('empty "rev" revision set - '
284 284 'nothing to rebase\n'))
285 285 return _nothingtorebase()
286 286 elif srcf:
287 287 src = scmutil.revrange(repo, [srcf])
288 288 if not src:
289 289 ui.status(_('empty "source" revision set - '
290 290 'nothing to rebase\n'))
291 291 return _nothingtorebase()
292 292 rebaseset = repo.revs('(%ld)::', src)
293 293 assert rebaseset
294 294 else:
295 295 base = scmutil.revrange(repo, [basef or '.'])
296 296 if not base:
297 297 ui.status(_('empty "base" revision set - '
298 298 "can't compute rebase set\n"))
299 299 return _nothingtorebase()
300 300 commonanc = repo.revs('ancestor(%ld, %d)', base, dest).first()
301 301 if commonanc is not None:
302 302 rebaseset = repo.revs('(%d::(%ld) - %d)::',
303 303 commonanc, base, commonanc)
304 304 else:
305 305 rebaseset = []
306 306
307 307 if not rebaseset:
308 308 # transform to list because smartsets are not comparable to
309 309 # lists. This should be improved to honor laziness of
310 310 # smartset.
311 311 if list(base) == [dest.rev()]:
312 312 if basef:
313 313 ui.status(_('nothing to rebase - %s is both "base"'
314 314 ' and destination\n') % dest)
315 315 else:
316 316 ui.status(_('nothing to rebase - working directory '
317 317 'parent is also destination\n'))
318 318 elif not repo.revs('%ld - ::%d', base, dest):
319 319 if basef:
320 320 ui.status(_('nothing to rebase - "base" %s is '
321 321 'already an ancestor of destination '
322 322 '%s\n') %
323 323 ('+'.join(str(repo[r]) for r in base),
324 324 dest))
325 325 else:
326 326 ui.status(_('nothing to rebase - working '
327 327 'directory parent is already an '
328 328 'ancestor of destination %s\n') % dest)
329 329 else: # can it happen?
330 330 ui.status(_('nothing to rebase from %s to %s\n') %
331 331 ('+'.join(str(repo[r]) for r in base), dest))
332 332 return _nothingtorebase()
333 333
334 334 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
335 335 if (not (keepf or allowunstable)
336 336 and repo.revs('first(children(%ld) - %ld)',
337 337 rebaseset, rebaseset)):
338 338 raise error.Abort(
339 339 _("can't remove original changesets with"
340 340 " unrebased descendants"),
341 341 hint=_('use --keep to keep original changesets'))
342 342
343 343 obsoletenotrebased = {}
344 344 if ui.configbool('experimental', 'rebaseskipobsolete'):
345 345 rebasesetrevs = set(rebaseset)
346 346 rebaseobsrevs = set(r for r in rebasesetrevs
347 347 if repo[r].obsolete())
348 348 obsoletenotrebased = _computeobsoletenotrebased(repo,
349 349 rebaseobsrevs,
350 350 dest)
351 351 rebaseobsskipped = set(obsoletenotrebased)
352 352
353 # Obsolete node with successors not in dest leads to divergence
354 divergenceok = ui.configbool('rebase',
355 'allowdivergence')
356 divergencebasecandidates = rebaseobsrevs - rebaseobsskipped
357
358 if divergencebasecandidates and not divergenceok:
359 msg = _("this rebase will cause divergence")
360 h = _("to force the rebase please set "
361 "rebase.allowdivergence=True")
362 raise error.Abort(msg, hint=h)
363
353 364 # - plain prune (no successor) changesets are rebased
354 365 # - split changesets are not rebased if at least one of the
355 366 # changeset resulting from the split is an ancestor of dest
356 367 rebaseset = rebasesetrevs - rebaseobsskipped
357 368 if rebasesetrevs and not rebaseset:
358 369 msg = _('all requested changesets have equivalents '
359 370 'or were marked as obsolete')
360 371 hint = _('to force the rebase, set the config '
361 372 'experimental.rebaseskipobsolete to False')
362 373 raise error.Abort(msg, hint=hint)
363 374
364 375 result = buildstate(repo, dest, rebaseset, collapsef,
365 376 obsoletenotrebased)
366 377
367 378 if not result:
368 379 # Empty state built, nothing to rebase
369 380 ui.status(_('nothing to rebase\n'))
370 381 return _nothingtorebase()
371 382
372 383 root = min(rebaseset)
373 384 if not keepf and not repo[root].mutable():
374 385 raise error.Abort(_("can't rebase public changeset %s")
375 386 % repo[root],
376 387 hint=_('see "hg help phases" for details'))
377 388
378 389 originalwd, target, state = result
379 390 if collapsef:
380 391 targetancestors = repo.changelog.ancestors([target],
381 392 inclusive=True)
382 393 external = externalparent(repo, state, targetancestors)
383 394
384 395 if dest.closesbranch() and not keepbranchesf:
385 396 ui.status(_('reopening closed branch head %s\n') % dest)
386 397
387 398 if keepbranchesf and collapsef:
388 399 branches = set()
389 400 for rev in state:
390 401 branches.add(repo[rev].branch())
391 402 if len(branches) > 1:
392 403 raise error.Abort(_('cannot collapse multiple named '
393 404 'branches'))
394 405
395 406 # Rebase
396 407 if not targetancestors:
397 408 targetancestors = repo.changelog.ancestors([target], inclusive=True)
398 409
399 410 # Keep track of the current bookmarks in order to reset them later
400 411 currentbookmarks = repo._bookmarks.copy()
401 412 activebookmark = activebookmark or repo._activebookmark
402 413 if activebookmark:
403 414 bookmarks.deactivate(repo)
404 415
405 416 extrafn = _makeextrafn(extrafns)
406 417
407 418 sortedstate = sorted(state)
408 419 total = len(sortedstate)
409 420 pos = 0
410 421 for rev in sortedstate:
411 422 ctx = repo[rev]
412 423 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
413 424 ctx.description().split('\n', 1)[0])
414 425 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
415 426 if names:
416 427 desc += ' (%s)' % ' '.join(names)
417 428 pos += 1
418 429 if state[rev] == revtodo:
419 430 ui.status(_('rebasing %s\n') % desc)
420 431 ui.progress(_("rebasing"), pos, ("%d:%s" % (rev, ctx)),
421 432 _('changesets'), total)
422 433 p1, p2, base = defineparents(repo, rev, target, state,
423 434 targetancestors)
424 435 storestatus(repo, originalwd, target, state, collapsef, keepf,
425 436 keepbranchesf, external, activebookmark)
426 437 if len(repo[None].parents()) == 2:
427 438 repo.ui.debug('resuming interrupted rebase\n')
428 439 else:
429 440 try:
430 441 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
431 442 'rebase')
432 443 stats = rebasenode(repo, rev, p1, base, state,
433 444 collapsef, target)
434 445 if stats and stats[3] > 0:
435 446 raise error.InterventionRequired(
436 447 _('unresolved conflicts (see hg '
437 448 'resolve, then hg rebase --continue)'))
438 449 finally:
439 450 ui.setconfig('ui', 'forcemerge', '', 'rebase')
440 451 if not collapsef:
441 452 merging = p2 != nullrev
442 453 editform = cmdutil.mergeeditform(merging, 'rebase')
443 454 editor = cmdutil.getcommiteditor(editform=editform, **opts)
444 455 newnode = concludenode(repo, rev, p1, p2, extrafn=extrafn,
445 456 editor=editor,
446 457 keepbranches=keepbranchesf,
447 458 date=date)
448 459 else:
449 460 # Skip commit if we are collapsing
450 461 repo.dirstate.beginparentchange()
451 462 repo.setparents(repo[p1].node())
452 463 repo.dirstate.endparentchange()
453 464 newnode = None
454 465 # Update the state
455 466 if newnode is not None:
456 467 state[rev] = repo[newnode].rev()
457 468 ui.debug('rebased as %s\n' % short(newnode))
458 469 else:
459 470 if not collapsef:
460 471 ui.warn(_('note: rebase of %d:%s created no changes '
461 472 'to commit\n') % (rev, ctx))
462 473 skipped.add(rev)
463 474 state[rev] = p1
464 475 ui.debug('next revision set to %s\n' % p1)
465 476 elif state[rev] == nullmerge:
466 477 ui.debug('ignoring null merge rebase of %s\n' % rev)
467 478 elif state[rev] == revignored:
468 479 ui.status(_('not rebasing ignored %s\n') % desc)
469 480 elif state[rev] == revprecursor:
470 481 targetctx = repo[obsoletenotrebased[rev]]
471 482 desctarget = '%d:%s "%s"' % (targetctx.rev(), targetctx,
472 483 targetctx.description().split('\n', 1)[0])
473 484 msg = _('note: not rebasing %s, already in destination as %s\n')
474 485 ui.status(msg % (desc, desctarget))
475 486 elif state[rev] == revpruned:
476 487 msg = _('note: not rebasing %s, it has no successor\n')
477 488 ui.status(msg % desc)
478 489 else:
479 490 ui.status(_('already rebased %s as %s\n') %
480 491 (desc, repo[state[rev]]))
481 492
482 493 ui.progress(_('rebasing'), None)
483 494 ui.note(_('rebase merging completed\n'))
484 495
485 496 if collapsef and not keepopen:
486 497 p1, p2, _base = defineparents(repo, min(state), target,
487 498 state, targetancestors)
488 499 editopt = opts.get('edit')
489 500 editform = 'rebase.collapse'
490 501 if collapsemsg:
491 502 commitmsg = collapsemsg
492 503 else:
493 504 commitmsg = 'Collapsed revision'
494 505 for rebased in state:
495 506 if rebased not in skipped and state[rebased] > nullmerge:
496 507 commitmsg += '\n* %s' % repo[rebased].description()
497 508 editopt = True
498 509 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
499 510 newnode = concludenode(repo, rev, p1, external, commitmsg=commitmsg,
500 511 extrafn=extrafn, editor=editor,
501 512 keepbranches=keepbranchesf,
502 513 date=date)
503 514 if newnode is None:
504 515 newrev = target
505 516 else:
506 517 newrev = repo[newnode].rev()
507 518 for oldrev in state.iterkeys():
508 519 if state[oldrev] > nullmerge:
509 520 state[oldrev] = newrev
510 521
511 522 if 'qtip' in repo.tags():
512 523 updatemq(repo, state, skipped, **opts)
513 524
514 525 if currentbookmarks:
515 526 # Nodeids are needed to reset bookmarks
516 527 nstate = {}
517 528 for k, v in state.iteritems():
518 529 if v > nullmerge:
519 530 nstate[repo[k].node()] = repo[v].node()
520 531 # XXX this is the same as dest.node() for the non-continue path --
521 532 # this should probably be cleaned up
522 533 targetnode = repo[target].node()
523 534
524 535 # restore original working directory
525 536 # (we do this before stripping)
526 537 newwd = state.get(originalwd, originalwd)
527 538 if newwd < 0:
528 539 # original directory is a parent of rebase set root or ignored
529 540 newwd = originalwd
530 541 if newwd not in [c.rev() for c in repo[None].parents()]:
531 542 ui.note(_("update back to initial working directory parent\n"))
532 543 hg.updaterepo(repo, newwd, False)
533 544
534 545 if not keepf:
535 546 collapsedas = None
536 547 if collapsef:
537 548 collapsedas = newnode
538 549 clearrebased(ui, repo, state, skipped, collapsedas)
539 550
540 551 tr = None
541 552 try:
542 553 tr = repo.transaction('bookmark')
543 554 if currentbookmarks:
544 555 updatebookmarks(repo, targetnode, nstate, currentbookmarks, tr)
545 556 if activebookmark not in repo._bookmarks:
546 557 # active bookmark was divergent one and has been deleted
547 558 activebookmark = None
548 559 tr.close()
549 560 finally:
550 561 release(tr)
551 562 clearstatus(repo)
552 563
553 564 ui.note(_("rebase completed\n"))
554 565 util.unlinkpath(repo.sjoin('undo'), ignoremissing=True)
555 566 if skipped:
556 567 ui.note(_("%d revisions have been skipped\n") % len(skipped))
557 568
558 569 if (activebookmark and
559 570 repo['.'].node() == repo._bookmarks[activebookmark]):
560 571 bookmarks.activate(repo, activebookmark)
561 572
562 573 finally:
563 574 release(lock, wlock)
564 575
565 576 def externalparent(repo, state, targetancestors):
566 577 """Return the revision that should be used as the second parent
567 578 when the revisions in state is collapsed on top of targetancestors.
568 579 Abort if there is more than one parent.
569 580 """
570 581 parents = set()
571 582 source = min(state)
572 583 for rev in state:
573 584 if rev == source:
574 585 continue
575 586 for p in repo[rev].parents():
576 587 if (p.rev() not in state
577 588 and p.rev() not in targetancestors):
578 589 parents.add(p.rev())
579 590 if not parents:
580 591 return nullrev
581 592 if len(parents) == 1:
582 593 return parents.pop()
583 594 raise error.Abort(_('unable to collapse on top of %s, there is more '
584 595 'than one external parent: %s') %
585 596 (max(targetancestors),
586 597 ', '.join(str(p) for p in sorted(parents))))
587 598
588 599 def concludenode(repo, rev, p1, p2, commitmsg=None, editor=None, extrafn=None,
589 600 keepbranches=False, date=None):
590 601 '''Commit the wd changes with parents p1 and p2. Reuse commit info from rev
591 602 but also store useful information in extra.
592 603 Return node of committed revision.'''
593 604 dsguard = cmdutil.dirstateguard(repo, 'rebase')
594 605 try:
595 606 repo.setparents(repo[p1].node(), repo[p2].node())
596 607 ctx = repo[rev]
597 608 if commitmsg is None:
598 609 commitmsg = ctx.description()
599 610 keepbranch = keepbranches and repo[p1].branch() != ctx.branch()
600 611 extra = ctx.extra().copy()
601 612 if not keepbranches:
602 613 del extra['branch']
603 614 extra['rebase_source'] = ctx.hex()
604 615 if extrafn:
605 616 extrafn(ctx, extra)
606 617
607 618 backup = repo.ui.backupconfig('phases', 'new-commit')
608 619 try:
609 620 targetphase = max(ctx.phase(), phases.draft)
610 621 repo.ui.setconfig('phases', 'new-commit', targetphase, 'rebase')
611 622 if keepbranch:
612 623 repo.ui.setconfig('ui', 'allowemptycommit', True)
613 624 # Commit might fail if unresolved files exist
614 625 if date is None:
615 626 date = ctx.date()
616 627 newnode = repo.commit(text=commitmsg, user=ctx.user(),
617 628 date=date, extra=extra, editor=editor)
618 629 finally:
619 630 repo.ui.restoreconfig(backup)
620 631
621 632 repo.dirstate.setbranch(repo[newnode].branch())
622 633 dsguard.close()
623 634 return newnode
624 635 finally:
625 636 release(dsguard)
626 637
627 638 def rebasenode(repo, rev, p1, base, state, collapse, target):
628 639 'Rebase a single revision rev on top of p1 using base as merge ancestor'
629 640 # Merge phase
630 641 # Update to target and merge it with local
631 642 if repo['.'].rev() != p1:
632 643 repo.ui.debug(" update to %d:%s\n" % (p1, repo[p1]))
633 644 merge.update(repo, p1, False, True)
634 645 else:
635 646 repo.ui.debug(" already in target\n")
636 647 repo.dirstate.write(repo.currenttransaction())
637 648 repo.ui.debug(" merge against %d:%s\n" % (rev, repo[rev]))
638 649 if base is not None:
639 650 repo.ui.debug(" detach base %d:%s\n" % (base, repo[base]))
640 651 # When collapsing in-place, the parent is the common ancestor, we
641 652 # have to allow merging with it.
642 653 stats = merge.update(repo, rev, True, True, base, collapse,
643 654 labels=['dest', 'source'])
644 655 if collapse:
645 656 copies.duplicatecopies(repo, rev, target)
646 657 else:
647 658 # If we're not using --collapse, we need to
648 659 # duplicate copies between the revision we're
649 660 # rebasing and its first parent, but *not*
650 661 # duplicate any copies that have already been
651 662 # performed in the destination.
652 663 p1rev = repo[rev].p1().rev()
653 664 copies.duplicatecopies(repo, rev, p1rev, skiprev=target)
654 665 return stats
655 666
656 667 def nearestrebased(repo, rev, state):
657 668 """return the nearest ancestors of rev in the rebase result"""
658 669 rebased = [r for r in state if state[r] > nullmerge]
659 670 candidates = repo.revs('max(%ld and (::%d))', rebased, rev)
660 671 if candidates:
661 672 return state[candidates.first()]
662 673 else:
663 674 return None
664 675
665 676 def defineparents(repo, rev, target, state, targetancestors):
666 677 'Return the new parent relationship of the revision that will be rebased'
667 678 parents = repo[rev].parents()
668 679 p1 = p2 = nullrev
669 680
670 681 p1n = parents[0].rev()
671 682 if p1n in targetancestors:
672 683 p1 = target
673 684 elif p1n in state:
674 685 if state[p1n] == nullmerge:
675 686 p1 = target
676 687 elif state[p1n] in revskipped:
677 688 p1 = nearestrebased(repo, p1n, state)
678 689 if p1 is None:
679 690 p1 = target
680 691 else:
681 692 p1 = state[p1n]
682 693 else: # p1n external
683 694 p1 = target
684 695 p2 = p1n
685 696
686 697 if len(parents) == 2 and parents[1].rev() not in targetancestors:
687 698 p2n = parents[1].rev()
688 699 # interesting second parent
689 700 if p2n in state:
690 701 if p1 == target: # p1n in targetancestors or external
691 702 p1 = state[p2n]
692 703 elif state[p2n] in revskipped:
693 704 p2 = nearestrebased(repo, p2n, state)
694 705 if p2 is None:
695 706 # no ancestors rebased yet, detach
696 707 p2 = target
697 708 else:
698 709 p2 = state[p2n]
699 710 else: # p2n external
700 711 if p2 != nullrev: # p1n external too => rev is a merged revision
701 712 raise error.Abort(_('cannot use revision %d as base, result '
702 713 'would have 3 parents') % rev)
703 714 p2 = p2n
704 715 repo.ui.debug(" future parents are %d and %d\n" %
705 716 (repo[p1].rev(), repo[p2].rev()))
706 717
707 718 if rev == min(state):
708 719 # Case (1) initial changeset of a non-detaching rebase.
709 720 # Let the merge mechanism find the base itself.
710 721 base = None
711 722 elif not repo[rev].p2():
712 723 # Case (2) detaching the node with a single parent, use this parent
713 724 base = repo[rev].p1().rev()
714 725 else:
715 726 # Assuming there is a p1, this is the case where there also is a p2.
716 727 # We are thus rebasing a merge and need to pick the right merge base.
717 728 #
718 729 # Imagine we have:
719 730 # - M: current rebase revision in this step
720 731 # - A: one parent of M
721 732 # - B: other parent of M
722 733 # - D: destination of this merge step (p1 var)
723 734 #
724 735 # Consider the case where D is a descendant of A or B and the other is
725 736 # 'outside'. In this case, the right merge base is the D ancestor.
726 737 #
727 738 # An informal proof, assuming A is 'outside' and B is the D ancestor:
728 739 #
729 740 # If we pick B as the base, the merge involves:
730 741 # - changes from B to M (actual changeset payload)
731 742 # - changes from B to D (induced by rebase) as D is a rebased
732 743 # version of B)
733 744 # Which exactly represent the rebase operation.
734 745 #
735 746 # If we pick A as the base, the merge involves:
736 747 # - changes from A to M (actual changeset payload)
737 748 # - changes from A to D (with include changes between unrelated A and B
738 749 # plus changes induced by rebase)
739 750 # Which does not represent anything sensible and creates a lot of
740 751 # conflicts. A is thus not the right choice - B is.
741 752 #
742 753 # Note: The base found in this 'proof' is only correct in the specified
743 754 # case. This base does not make sense if is not D a descendant of A or B
744 755 # or if the other is not parent 'outside' (especially not if the other
745 756 # parent has been rebased). The current implementation does not
746 757 # make it feasible to consider different cases separately. In these
747 758 # other cases we currently just leave it to the user to correctly
748 759 # resolve an impossible merge using a wrong ancestor.
749 760 for p in repo[rev].parents():
750 761 if state.get(p.rev()) == p1:
751 762 base = p.rev()
752 763 break
753 764 else: # fallback when base not found
754 765 base = None
755 766
756 767 # Raise because this function is called wrong (see issue 4106)
757 768 raise AssertionError('no base found to rebase on '
758 769 '(defineparents called wrong)')
759 770 return p1, p2, base
760 771
761 772 def isagitpatch(repo, patchname):
762 773 'Return true if the given patch is in git format'
763 774 mqpatch = os.path.join(repo.mq.path, patchname)
764 775 for line in patch.linereader(file(mqpatch, 'rb')):
765 776 if line.startswith('diff --git'):
766 777 return True
767 778 return False
768 779
769 780 def updatemq(repo, state, skipped, **opts):
770 781 'Update rebased mq patches - finalize and then import them'
771 782 mqrebase = {}
772 783 mq = repo.mq
773 784 original_series = mq.fullseries[:]
774 785 skippedpatches = set()
775 786
776 787 for p in mq.applied:
777 788 rev = repo[p.node].rev()
778 789 if rev in state:
779 790 repo.ui.debug('revision %d is an mq patch (%s), finalize it.\n' %
780 791 (rev, p.name))
781 792 mqrebase[rev] = (p.name, isagitpatch(repo, p.name))
782 793 else:
783 794 # Applied but not rebased, not sure this should happen
784 795 skippedpatches.add(p.name)
785 796
786 797 if mqrebase:
787 798 mq.finish(repo, mqrebase.keys())
788 799
789 800 # We must start import from the newest revision
790 801 for rev in sorted(mqrebase, reverse=True):
791 802 if rev not in skipped:
792 803 name, isgit = mqrebase[rev]
793 804 repo.ui.note(_('updating mq patch %s to %s:%s\n') %
794 805 (name, state[rev], repo[state[rev]]))
795 806 mq.qimport(repo, (), patchname=name, git=isgit,
796 807 rev=[str(state[rev])])
797 808 else:
798 809 # Rebased and skipped
799 810 skippedpatches.add(mqrebase[rev][0])
800 811
801 812 # Patches were either applied and rebased and imported in
802 813 # order, applied and removed or unapplied. Discard the removed
803 814 # ones while preserving the original series order and guards.
804 815 newseries = [s for s in original_series
805 816 if mq.guard_re.split(s, 1)[0] not in skippedpatches]
806 817 mq.fullseries[:] = newseries
807 818 mq.seriesdirty = True
808 819 mq.savedirty()
809 820
810 821 def updatebookmarks(repo, targetnode, nstate, originalbookmarks, tr):
811 822 'Move bookmarks to their correct changesets, and delete divergent ones'
812 823 marks = repo._bookmarks
813 824 for k, v in originalbookmarks.iteritems():
814 825 if v in nstate:
815 826 # update the bookmarks for revs that have moved
816 827 marks[k] = nstate[v]
817 828 bookmarks.deletedivergent(repo, [targetnode], k)
818 829 marks.recordchange(tr)
819 830
820 831 def storestatus(repo, originalwd, target, state, collapse, keep, keepbranches,
821 832 external, activebookmark):
822 833 'Store the current status to allow recovery'
823 834 f = repo.vfs("rebasestate", "w")
824 835 f.write(repo[originalwd].hex() + '\n')
825 836 f.write(repo[target].hex() + '\n')
826 837 f.write(repo[external].hex() + '\n')
827 838 f.write('%d\n' % int(collapse))
828 839 f.write('%d\n' % int(keep))
829 840 f.write('%d\n' % int(keepbranches))
830 841 f.write('%s\n' % (activebookmark or ''))
831 842 for d, v in state.iteritems():
832 843 oldrev = repo[d].hex()
833 844 if v >= 0:
834 845 newrev = repo[v].hex()
835 846 elif v == revtodo:
836 847 # To maintain format compatibility, we have to use nullid.
837 848 # Please do remove this special case when upgrading the format.
838 849 newrev = hex(nullid)
839 850 else:
840 851 newrev = v
841 852 f.write("%s:%s\n" % (oldrev, newrev))
842 853 f.close()
843 854 repo.ui.debug('rebase status stored\n')
844 855
845 856 def clearstatus(repo):
846 857 'Remove the status files'
847 858 _clearrebasesetvisibiliy(repo)
848 859 util.unlinkpath(repo.join("rebasestate"), ignoremissing=True)
849 860
850 861 def restorestatus(repo):
851 862 'Restore a previously stored status'
852 863 keepbranches = None
853 864 target = None
854 865 collapse = False
855 866 external = nullrev
856 867 activebookmark = None
857 868 state = {}
858 869
859 870 try:
860 871 f = repo.vfs("rebasestate")
861 872 for i, l in enumerate(f.read().splitlines()):
862 873 if i == 0:
863 874 originalwd = repo[l].rev()
864 875 elif i == 1:
865 876 target = repo[l].rev()
866 877 elif i == 2:
867 878 external = repo[l].rev()
868 879 elif i == 3:
869 880 collapse = bool(int(l))
870 881 elif i == 4:
871 882 keep = bool(int(l))
872 883 elif i == 5:
873 884 keepbranches = bool(int(l))
874 885 elif i == 6 and not (len(l) == 81 and ':' in l):
875 886 # line 6 is a recent addition, so for backwards compatibility
876 887 # check that the line doesn't look like the oldrev:newrev lines
877 888 activebookmark = l
878 889 else:
879 890 oldrev, newrev = l.split(':')
880 891 if newrev in (str(nullmerge), str(revignored),
881 892 str(revprecursor), str(revpruned)):
882 893 state[repo[oldrev].rev()] = int(newrev)
883 894 elif newrev == nullid:
884 895 state[repo[oldrev].rev()] = revtodo
885 896 # Legacy compat special case
886 897 else:
887 898 state[repo[oldrev].rev()] = repo[newrev].rev()
888 899
889 900 except IOError as err:
890 901 if err.errno != errno.ENOENT:
891 902 raise
892 903 raise error.Abort(_('no rebase in progress'))
893 904
894 905 if keepbranches is None:
895 906 raise error.Abort(_('.hg/rebasestate is incomplete'))
896 907
897 908 skipped = set()
898 909 # recompute the set of skipped revs
899 910 if not collapse:
900 911 seen = set([target])
901 912 for old, new in sorted(state.items()):
902 913 if new != revtodo and new in seen:
903 914 skipped.add(old)
904 915 seen.add(new)
905 916 repo.ui.debug('computed skipped revs: %s\n' %
906 917 (' '.join(str(r) for r in sorted(skipped)) or None))
907 918 repo.ui.debug('rebase status resumed\n')
908 919 _setrebasesetvisibility(repo, state.keys())
909 920 return (originalwd, target, state, skipped,
910 921 collapse, keep, keepbranches, external, activebookmark)
911 922
912 923 def needupdate(repo, state):
913 924 '''check whether we should `update --clean` away from a merge, or if
914 925 somehow the working dir got forcibly updated, e.g. by older hg'''
915 926 parents = [p.rev() for p in repo[None].parents()]
916 927
917 928 # Are we in a merge state at all?
918 929 if len(parents) < 2:
919 930 return False
920 931
921 932 # We should be standing on the first as-of-yet unrebased commit.
922 933 firstunrebased = min([old for old, new in state.iteritems()
923 934 if new == nullrev])
924 935 if firstunrebased in parents:
925 936 return True
926 937
927 938 return False
928 939
929 940 def abort(repo, originalwd, target, state, activebookmark=None):
930 941 '''Restore the repository to its original state. Additional args:
931 942
932 943 activebookmark: the name of the bookmark that should be active after the
933 944 restore'''
934 945
935 946 try:
936 947 # If the first commits in the rebased set get skipped during the rebase,
937 948 # their values within the state mapping will be the target rev id. The
938 949 # dstates list must must not contain the target rev (issue4896)
939 950 dstates = [s for s in state.values() if s >= 0 and s != target]
940 951 immutable = [d for d in dstates if not repo[d].mutable()]
941 952 cleanup = True
942 953 if immutable:
943 954 repo.ui.warn(_("warning: can't clean up public changesets %s\n")
944 955 % ', '.join(str(repo[r]) for r in immutable),
945 956 hint=_('see "hg help phases" for details'))
946 957 cleanup = False
947 958
948 959 descendants = set()
949 960 if dstates:
950 961 descendants = set(repo.changelog.descendants(dstates))
951 962 if descendants - set(dstates):
952 963 repo.ui.warn(_("warning: new changesets detected on target branch, "
953 964 "can't strip\n"))
954 965 cleanup = False
955 966
956 967 if cleanup:
957 968 # Update away from the rebase if necessary
958 969 if needupdate(repo, state):
959 970 merge.update(repo, originalwd, False, True)
960 971
961 972 # Strip from the first rebased revision
962 973 rebased = filter(lambda x: x >= 0 and x != target, state.values())
963 974 if rebased:
964 975 strippoints = [
965 976 c.node() for c in repo.set('roots(%ld)', rebased)]
966 977 # no backup of rebased cset versions needed
967 978 repair.strip(repo.ui, repo, strippoints)
968 979
969 980 if activebookmark and activebookmark in repo._bookmarks:
970 981 bookmarks.activate(repo, activebookmark)
971 982
972 983 finally:
973 984 clearstatus(repo)
974 985 repo.ui.warn(_('rebase aborted\n'))
975 986 return 0
976 987
977 988 def buildstate(repo, dest, rebaseset, collapse, obsoletenotrebased):
978 989 '''Define which revisions are going to be rebased and where
979 990
980 991 repo: repo
981 992 dest: context
982 993 rebaseset: set of rev
983 994 '''
984 995 _setrebasesetvisibility(repo, rebaseset)
985 996
986 997 # This check isn't strictly necessary, since mq detects commits over an
987 998 # applied patch. But it prevents messing up the working directory when
988 999 # a partially completed rebase is blocked by mq.
989 1000 if 'qtip' in repo.tags() and (dest.node() in
990 1001 [s.node for s in repo.mq.applied]):
991 1002 raise error.Abort(_('cannot rebase onto an applied mq patch'))
992 1003
993 1004 roots = list(repo.set('roots(%ld)', rebaseset))
994 1005 if not roots:
995 1006 raise error.Abort(_('no matching revisions'))
996 1007 roots.sort()
997 1008 state = {}
998 1009 detachset = set()
999 1010 for root in roots:
1000 1011 commonbase = root.ancestor(dest)
1001 1012 if commonbase == root:
1002 1013 raise error.Abort(_('source is ancestor of destination'))
1003 1014 if commonbase == dest:
1004 1015 samebranch = root.branch() == dest.branch()
1005 1016 if not collapse and samebranch and root in dest.children():
1006 1017 repo.ui.debug('source is a child of destination\n')
1007 1018 return None
1008 1019
1009 1020 repo.ui.debug('rebase onto %d starting from %s\n' % (dest, root))
1010 1021 state.update(dict.fromkeys(rebaseset, revtodo))
1011 1022 # Rebase tries to turn <dest> into a parent of <root> while
1012 1023 # preserving the number of parents of rebased changesets:
1013 1024 #
1014 1025 # - A changeset with a single parent will always be rebased as a
1015 1026 # changeset with a single parent.
1016 1027 #
1017 1028 # - A merge will be rebased as merge unless its parents are both
1018 1029 # ancestors of <dest> or are themselves in the rebased set and
1019 1030 # pruned while rebased.
1020 1031 #
1021 1032 # If one parent of <root> is an ancestor of <dest>, the rebased
1022 1033 # version of this parent will be <dest>. This is always true with
1023 1034 # --base option.
1024 1035 #
1025 1036 # Otherwise, we need to *replace* the original parents with
1026 1037 # <dest>. This "detaches" the rebased set from its former location
1027 1038 # and rebases it onto <dest>. Changes introduced by ancestors of
1028 1039 # <root> not common with <dest> (the detachset, marked as
1029 1040 # nullmerge) are "removed" from the rebased changesets.
1030 1041 #
1031 1042 # - If <root> has a single parent, set it to <dest>.
1032 1043 #
1033 1044 # - If <root> is a merge, we cannot decide which parent to
1034 1045 # replace, the rebase operation is not clearly defined.
1035 1046 #
1036 1047 # The table below sums up this behavior:
1037 1048 #
1038 1049 # +------------------+----------------------+-------------------------+
1039 1050 # | | one parent | merge |
1040 1051 # +------------------+----------------------+-------------------------+
1041 1052 # | parent in | new parent is <dest> | parents in ::<dest> are |
1042 1053 # | ::<dest> | | remapped to <dest> |
1043 1054 # +------------------+----------------------+-------------------------+
1044 1055 # | unrelated source | new parent is <dest> | ambiguous, abort |
1045 1056 # +------------------+----------------------+-------------------------+
1046 1057 #
1047 1058 # The actual abort is handled by `defineparents`
1048 1059 if len(root.parents()) <= 1:
1049 1060 # ancestors of <root> not ancestors of <dest>
1050 1061 detachset.update(repo.changelog.findmissingrevs([commonbase.rev()],
1051 1062 [root.rev()]))
1052 1063 for r in detachset:
1053 1064 if r not in state:
1054 1065 state[r] = nullmerge
1055 1066 if len(roots) > 1:
1056 1067 # If we have multiple roots, we may have "hole" in the rebase set.
1057 1068 # Rebase roots that descend from those "hole" should not be detached as
1058 1069 # other root are. We use the special `revignored` to inform rebase that
1059 1070 # the revision should be ignored but that `defineparents` should search
1060 1071 # a rebase destination that make sense regarding rebased topology.
1061 1072 rebasedomain = set(repo.revs('%ld::%ld', rebaseset, rebaseset))
1062 1073 for ignored in set(rebasedomain) - set(rebaseset):
1063 1074 state[ignored] = revignored
1064 1075 for r in obsoletenotrebased:
1065 1076 if obsoletenotrebased[r] is None:
1066 1077 state[r] = revpruned
1067 1078 else:
1068 1079 state[r] = revprecursor
1069 1080 return repo['.'].rev(), dest.rev(), state
1070 1081
1071 1082 def clearrebased(ui, repo, state, skipped, collapsedas=None):
1072 1083 """dispose of rebased revision at the end of the rebase
1073 1084
1074 1085 If `collapsedas` is not None, the rebase was a collapse whose result if the
1075 1086 `collapsedas` node."""
1076 1087 if obsolete.isenabled(repo, obsolete.createmarkersopt):
1077 1088 markers = []
1078 1089 for rev, newrev in sorted(state.items()):
1079 1090 if newrev >= 0:
1080 1091 if rev in skipped:
1081 1092 succs = ()
1082 1093 elif collapsedas is not None:
1083 1094 succs = (repo[collapsedas],)
1084 1095 else:
1085 1096 succs = (repo[newrev],)
1086 1097 markers.append((repo[rev], succs))
1087 1098 if markers:
1088 1099 obsolete.createmarkers(repo, markers)
1089 1100 else:
1090 1101 rebased = [rev for rev in state if state[rev] > nullmerge]
1091 1102 if rebased:
1092 1103 stripped = []
1093 1104 for root in repo.set('roots(%ld)', rebased):
1094 1105 if set(repo.changelog.descendants([root.rev()])) - set(state):
1095 1106 ui.warn(_("warning: new changesets detected "
1096 1107 "on source branch, not stripping\n"))
1097 1108 else:
1098 1109 stripped.append(root.node())
1099 1110 if stripped:
1100 1111 # backup the old csets by default
1101 1112 repair.strip(ui, repo, stripped, "all")
1102 1113
1103 1114
1104 1115 def pullrebase(orig, ui, repo, *args, **opts):
1105 1116 'Call rebase after pull if the latter has been invoked with --rebase'
1106 1117 ret = None
1107 1118 if opts.get('rebase'):
1108 1119 wlock = lock = None
1109 1120 try:
1110 1121 wlock = repo.wlock()
1111 1122 lock = repo.lock()
1112 1123 if opts.get('update'):
1113 1124 del opts['update']
1114 1125 ui.debug('--update and --rebase are not compatible, ignoring '
1115 1126 'the update flag\n')
1116 1127
1117 1128 movemarkfrom = repo['.'].node()
1118 1129 revsprepull = len(repo)
1119 1130 origpostincoming = commands.postincoming
1120 1131 def _dummy(*args, **kwargs):
1121 1132 pass
1122 1133 commands.postincoming = _dummy
1123 1134 try:
1124 1135 ret = orig(ui, repo, *args, **opts)
1125 1136 finally:
1126 1137 commands.postincoming = origpostincoming
1127 1138 revspostpull = len(repo)
1128 1139 if revspostpull > revsprepull:
1129 1140 # --rev option from pull conflict with rebase own --rev
1130 1141 # dropping it
1131 1142 if 'rev' in opts:
1132 1143 del opts['rev']
1133 1144 # positional argument from pull conflicts with rebase's own
1134 1145 # --source.
1135 1146 if 'source' in opts:
1136 1147 del opts['source']
1137 1148 rebase(ui, repo, **opts)
1138 1149 branch = repo[None].branch()
1139 1150 dest = repo[branch].rev()
1140 1151 if dest != repo['.'].rev():
1141 1152 # there was nothing to rebase we force an update
1142 1153 hg.update(repo, dest)
1143 1154 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
1144 1155 ui.status(_("updating bookmark %s\n")
1145 1156 % repo._activebookmark)
1146 1157 finally:
1147 1158 release(lock, wlock)
1148 1159 else:
1149 1160 if opts.get('tool'):
1150 1161 raise error.Abort(_('--tool can only be used with --rebase'))
1151 1162 ret = orig(ui, repo, *args, **opts)
1152 1163
1153 1164 return ret
1154 1165
1155 1166 def _setrebasesetvisibility(repo, revs):
1156 1167 """store the currently rebased set on the repo object
1157 1168
1158 1169 This is used by another function to prevent rebased revision to because
1159 1170 hidden (see issue4505)"""
1160 1171 repo = repo.unfiltered()
1161 1172 revs = set(revs)
1162 1173 repo._rebaseset = revs
1163 1174 # invalidate cache if visibility changes
1164 1175 hiddens = repo.filteredrevcache.get('visible', set())
1165 1176 if revs & hiddens:
1166 1177 repo.invalidatevolatilesets()
1167 1178
1168 1179 def _clearrebasesetvisibiliy(repo):
1169 1180 """remove rebaseset data from the repo"""
1170 1181 repo = repo.unfiltered()
1171 1182 if '_rebaseset' in vars(repo):
1172 1183 del repo._rebaseset
1173 1184
1174 1185 def _rebasedvisible(orig, repo):
1175 1186 """ensure rebased revs stay visible (see issue4505)"""
1176 1187 blockers = orig(repo)
1177 1188 blockers.update(getattr(repo, '_rebaseset', ()))
1178 1189 return blockers
1179 1190
1180 1191 def _computeobsoletenotrebased(repo, rebaseobsrevs, dest):
1181 1192 """return a mapping obsolete => successor for all obsolete nodes to be
1182 1193 rebased that have a successors in the destination
1183 1194
1184 1195 obsolete => None entries in the mapping indicate nodes with no succesor"""
1185 1196 obsoletenotrebased = {}
1186 1197
1187 1198 # Build a mapping successor => obsolete nodes for the obsolete
1188 1199 # nodes to be rebased
1189 1200 allsuccessors = {}
1190 1201 cl = repo.changelog
1191 1202 for r in rebaseobsrevs:
1192 1203 node = cl.node(r)
1193 1204 for s in obsolete.allsuccessors(repo.obsstore, [node]):
1194 1205 try:
1195 1206 allsuccessors[cl.rev(s)] = cl.rev(node)
1196 1207 except LookupError:
1197 1208 pass
1198 1209
1199 1210 if allsuccessors:
1200 1211 # Look for successors of obsolete nodes to be rebased among
1201 1212 # the ancestors of dest
1202 1213 ancs = cl.ancestors([repo[dest].rev()],
1203 1214 stoprev=min(allsuccessors),
1204 1215 inclusive=True)
1205 1216 for s in allsuccessors:
1206 1217 if s in ancs:
1207 1218 obsoletenotrebased[allsuccessors[s]] = s
1208 1219 elif (s == allsuccessors[s] and
1209 1220 allsuccessors.values().count(s) == 1):
1210 1221 # plain prune
1211 1222 obsoletenotrebased[s] = None
1212 1223
1213 1224 return obsoletenotrebased
1214 1225
1215 1226 def summaryhook(ui, repo):
1216 1227 if not os.path.exists(repo.join('rebasestate')):
1217 1228 return
1218 1229 try:
1219 1230 state = restorestatus(repo)[2]
1220 1231 except error.RepoLookupError:
1221 1232 # i18n: column positioning for "hg summary"
1222 1233 msg = _('rebase: (use "hg rebase --abort" to clear broken state)\n')
1223 1234 ui.write(msg)
1224 1235 return
1225 1236 numrebased = len([i for i in state.itervalues() if i >= 0])
1226 1237 # i18n: column positioning for "hg summary"
1227 1238 ui.write(_('rebase: %s, %s (rebase --continue)\n') %
1228 1239 (ui.label(_('%d rebased'), 'rebase.rebased') % numrebased,
1229 1240 ui.label(_('%d remaining'), 'rebase.remaining') %
1230 1241 (len(state) - numrebased)))
1231 1242
1232 1243 def uisetup(ui):
1233 1244 #Replace pull with a decorator to provide --rebase option
1234 1245 entry = extensions.wrapcommand(commands.table, 'pull', pullrebase)
1235 1246 entry[1].append(('', 'rebase', None,
1236 1247 _("rebase working directory to branch head")))
1237 1248 entry[1].append(('t', 'tool', '',
1238 1249 _("specify merge tool for rebase")))
1239 1250 cmdutil.summaryhooks.add('rebase', summaryhook)
1240 1251 cmdutil.unfinishedstates.append(
1241 1252 ['rebasestate', False, False, _('rebase in progress'),
1242 1253 _("use 'hg rebase --continue' or 'hg rebase --abort'")])
1243 1254 cmdutil.afterresolvedstates.append(
1244 1255 ['rebasestate', _('hg rebase --continue')])
1245 1256 # ensure rebased rev are not hidden
1246 1257 extensions.wrapfunction(repoview, '_getdynamicblockers', _rebasedvisible)
1247 1258 revsetpredicate.setup()
@@ -1,1986 +1,1993 b''
1 1 The Mercurial system uses a set of configuration files to control
2 2 aspects of its behavior.
3 3
4 4 Troubleshooting
5 5 ===============
6 6
7 7 If you're having problems with your configuration,
8 8 :hg:`config --debug` can help you understand what is introducing
9 9 a setting into your environment.
10 10
11 11 See :hg:`help config.syntax` and :hg:`help config.files`
12 12 for information about how and where to override things.
13 13
14 14 Structure
15 15 =========
16 16
17 17 The configuration files use a simple ini-file format. A configuration
18 18 file consists of sections, led by a ``[section]`` header and followed
19 19 by ``name = value`` entries::
20 20
21 21 [ui]
22 22 username = Firstname Lastname <firstname.lastname@example.net>
23 23 verbose = True
24 24
25 25 The above entries will be referred to as ``ui.username`` and
26 26 ``ui.verbose``, respectively. See :hg:`help config.syntax`.
27 27
28 28 Files
29 29 =====
30 30
31 31 Mercurial reads configuration data from several files, if they exist.
32 32 These files do not exist by default and you will have to create the
33 33 appropriate configuration files yourself: global configuration like
34 34 the username setting is typically put into
35 35 ``%USERPROFILE%\mercurial.ini`` or ``$HOME/.hgrc`` and local
36 36 configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
37 37
38 38 The names of these files depend on the system on which Mercurial is
39 39 installed. ``*.rc`` files from a single directory are read in
40 40 alphabetical order, later ones overriding earlier ones. Where multiple
41 41 paths are given below, settings from earlier paths override later
42 42 ones.
43 43
44 44 .. container:: verbose.unix
45 45
46 46 On Unix, the following files are consulted:
47 47
48 48 - ``<repo>/.hg/hgrc`` (per-repository)
49 49 - ``$HOME/.hgrc`` (per-user)
50 50 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
51 51 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
52 52 - ``/etc/mercurial/hgrc`` (per-system)
53 53 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
54 54 - ``<internal>/default.d/*.rc`` (defaults)
55 55
56 56 .. container:: verbose.windows
57 57
58 58 On Windows, the following files are consulted:
59 59
60 60 - ``<repo>/.hg/hgrc`` (per-repository)
61 61 - ``%USERPROFILE%\.hgrc`` (per-user)
62 62 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
63 63 - ``%HOME%\.hgrc`` (per-user)
64 64 - ``%HOME%\Mercurial.ini`` (per-user)
65 65 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
66 66 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
67 67 - ``<install-dir>\Mercurial.ini`` (per-installation)
68 68 - ``<internal>/default.d/*.rc`` (defaults)
69 69
70 70 .. note::
71 71
72 72 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
73 73 is used when running 32-bit Python on 64-bit Windows.
74 74
75 75 .. container:: verbose.plan9
76 76
77 77 On Plan9, the following files are consulted:
78 78
79 79 - ``<repo>/.hg/hgrc`` (per-repository)
80 80 - ``$home/lib/hgrc`` (per-user)
81 81 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
82 82 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
83 83 - ``/lib/mercurial/hgrc`` (per-system)
84 84 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
85 85 - ``<internal>/default.d/*.rc`` (defaults)
86 86
87 87 Per-repository configuration options only apply in a
88 88 particular repository. This file is not version-controlled, and
89 89 will not get transferred during a "clone" operation. Options in
90 90 this file override options in all other configuration files. On
91 91 Plan 9 and Unix, most of this file will be ignored if it doesn't
92 92 belong to a trusted user or to a trusted group. See
93 93 :hg:`help config.trusted` for more details.
94 94
95 95 Per-user configuration file(s) are for the user running Mercurial. On
96 96 Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``. Options in these
97 97 files apply to all Mercurial commands executed by this user in any
98 98 directory. Options in these files override per-system and per-installation
99 99 options.
100 100
101 101 Per-installation configuration files are searched for in the
102 102 directory where Mercurial is installed. ``<install-root>`` is the
103 103 parent directory of the **hg** executable (or symlink) being run. For
104 104 example, if installed in ``/shared/tools/bin/hg``, Mercurial will look
105 105 in ``/shared/tools/etc/mercurial/hgrc``. Options in these files apply
106 106 to all Mercurial commands executed by any user in any directory.
107 107
108 108 Per-installation configuration files are for the system on
109 109 which Mercurial is running. Options in these files apply to all
110 110 Mercurial commands executed by any user in any directory. Registry
111 111 keys contain PATH-like strings, every part of which must reference
112 112 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
113 113 be read. Mercurial checks each of these locations in the specified
114 114 order until one or more configuration files are detected.
115 115
116 116 Per-system configuration files are for the system on which Mercurial
117 117 is running. Options in these files apply to all Mercurial commands
118 118 executed by any user in any directory. Options in these files
119 119 override per-installation options.
120 120
121 121 Mercurial comes with some default configuration. The default configuration
122 122 files are installed with Mercurial and will be overwritten on upgrades. Default
123 123 configuration files should never be edited by users or administrators but can
124 124 be overridden in other configuration files. So far the directory only contains
125 125 merge tool configuration but packagers can also put other default configuration
126 126 there.
127 127
128 128 Syntax
129 129 ======
130 130
131 131 A configuration file consists of sections, led by a ``[section]`` header
132 132 and followed by ``name = value`` entries (sometimes called
133 133 ``configuration keys``)::
134 134
135 135 [spam]
136 136 eggs=ham
137 137 green=
138 138 eggs
139 139
140 140 Each line contains one entry. If the lines that follow are indented,
141 141 they are treated as continuations of that entry. Leading whitespace is
142 142 removed from values. Empty lines are skipped. Lines beginning with
143 143 ``#`` or ``;`` are ignored and may be used to provide comments.
144 144
145 145 Configuration keys can be set multiple times, in which case Mercurial
146 146 will use the value that was configured last. As an example::
147 147
148 148 [spam]
149 149 eggs=large
150 150 ham=serrano
151 151 eggs=small
152 152
153 153 This would set the configuration key named ``eggs`` to ``small``.
154 154
155 155 It is also possible to define a section multiple times. A section can
156 156 be redefined on the same and/or on different configuration files. For
157 157 example::
158 158
159 159 [foo]
160 160 eggs=large
161 161 ham=serrano
162 162 eggs=small
163 163
164 164 [bar]
165 165 eggs=ham
166 166 green=
167 167 eggs
168 168
169 169 [foo]
170 170 ham=prosciutto
171 171 eggs=medium
172 172 bread=toasted
173 173
174 174 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
175 175 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
176 176 respectively. As you can see there only thing that matters is the last
177 177 value that was set for each of the configuration keys.
178 178
179 179 If a configuration key is set multiple times in different
180 180 configuration files the final value will depend on the order in which
181 181 the different configuration files are read, with settings from earlier
182 182 paths overriding later ones as described on the ``Files`` section
183 183 above.
184 184
185 185 A line of the form ``%include file`` will include ``file`` into the
186 186 current configuration file. The inclusion is recursive, which means
187 187 that included files can include other files. Filenames are relative to
188 188 the configuration file in which the ``%include`` directive is found.
189 189 Environment variables and ``~user`` constructs are expanded in
190 190 ``file``. This lets you do something like::
191 191
192 192 %include ~/.hgrc.d/$HOST.rc
193 193
194 194 to include a different configuration file on each computer you use.
195 195
196 196 A line with ``%unset name`` will remove ``name`` from the current
197 197 section, if it has been set previously.
198 198
199 199 The values are either free-form text strings, lists of text strings,
200 200 or Boolean values. Boolean values can be set to true using any of "1",
201 201 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
202 202 (all case insensitive).
203 203
204 204 List values are separated by whitespace or comma, except when values are
205 205 placed in double quotation marks::
206 206
207 207 allow_read = "John Doe, PhD", brian, betty
208 208
209 209 Quotation marks can be escaped by prefixing them with a backslash. Only
210 210 quotation marks at the beginning of a word is counted as a quotation
211 211 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
212 212
213 213 Sections
214 214 ========
215 215
216 216 This section describes the different sections that may appear in a
217 217 Mercurial configuration file, the purpose of each section, its possible
218 218 keys, and their possible values.
219 219
220 220 ``alias``
221 221 ---------
222 222
223 223 Defines command aliases.
224 224
225 225 Aliases allow you to define your own commands in terms of other
226 226 commands (or aliases), optionally including arguments. Positional
227 227 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
228 228 are expanded by Mercurial before execution. Positional arguments not
229 229 already used by ``$N`` in the definition are put at the end of the
230 230 command to be executed.
231 231
232 232 Alias definitions consist of lines of the form::
233 233
234 234 <alias> = <command> [<argument>]...
235 235
236 236 For example, this definition::
237 237
238 238 latest = log --limit 5
239 239
240 240 creates a new command ``latest`` that shows only the five most recent
241 241 changesets. You can define subsequent aliases using earlier ones::
242 242
243 243 stable5 = latest -b stable
244 244
245 245 .. note::
246 246
247 247 It is possible to create aliases with the same names as
248 248 existing commands, which will then override the original
249 249 definitions. This is almost always a bad idea!
250 250
251 251 An alias can start with an exclamation point (``!``) to make it a
252 252 shell alias. A shell alias is executed with the shell and will let you
253 253 run arbitrary commands. As an example, ::
254 254
255 255 echo = !echo $@
256 256
257 257 will let you do ``hg echo foo`` to have ``foo`` printed in your
258 258 terminal. A better example might be::
259 259
260 260 purge = !$HG status --no-status --unknown -0 | xargs -0 rm
261 261
262 262 which will make ``hg purge`` delete all unknown files in the
263 263 repository in the same manner as the purge extension.
264 264
265 265 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
266 266 expand to the command arguments. Unmatched arguments are
267 267 removed. ``$0`` expands to the alias name and ``$@`` expands to all
268 268 arguments separated by a space. ``"$@"`` (with quotes) expands to all
269 269 arguments quoted individually and separated by a space. These expansions
270 270 happen before the command is passed to the shell.
271 271
272 272 Shell aliases are executed in an environment where ``$HG`` expands to
273 273 the path of the Mercurial that was used to execute the alias. This is
274 274 useful when you want to call further Mercurial commands in a shell
275 275 alias, as was done above for the purge alias. In addition,
276 276 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
277 277 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
278 278
279 279 .. note::
280 280
281 281 Some global configuration options such as ``-R`` are
282 282 processed before shell aliases and will thus not be passed to
283 283 aliases.
284 284
285 285
286 286 ``annotate``
287 287 ------------
288 288
289 289 Settings used when displaying file annotations. All values are
290 290 Booleans and default to False. See :hg:`help config.diff` for
291 291 related options for the diff command.
292 292
293 293 ``ignorews``
294 294 Ignore white space when comparing lines.
295 295
296 296 ``ignorewsamount``
297 297 Ignore changes in the amount of white space.
298 298
299 299 ``ignoreblanklines``
300 300 Ignore changes whose lines are all blank.
301 301
302 302
303 303 ``auth``
304 304 --------
305 305
306 306 Authentication credentials for HTTP authentication. This section
307 307 allows you to store usernames and passwords for use when logging
308 308 *into* HTTP servers. See :hg:`help config.web` if
309 309 you want to configure *who* can login to your HTTP server.
310 310
311 311 Each line has the following format::
312 312
313 313 <name>.<argument> = <value>
314 314
315 315 where ``<name>`` is used to group arguments into authentication
316 316 entries. Example::
317 317
318 318 foo.prefix = hg.intevation.org/mercurial
319 319 foo.username = foo
320 320 foo.password = bar
321 321 foo.schemes = http https
322 322
323 323 bar.prefix = secure.example.org
324 324 bar.key = path/to/file.key
325 325 bar.cert = path/to/file.cert
326 326 bar.schemes = https
327 327
328 328 Supported arguments:
329 329
330 330 ``prefix``
331 331 Either ``*`` or a URI prefix with or without the scheme part.
332 332 The authentication entry with the longest matching prefix is used
333 333 (where ``*`` matches everything and counts as a match of length
334 334 1). If the prefix doesn't include a scheme, the match is performed
335 335 against the URI with its scheme stripped as well, and the schemes
336 336 argument, q.v., is then subsequently consulted.
337 337
338 338 ``username``
339 339 Optional. Username to authenticate with. If not given, and the
340 340 remote site requires basic or digest authentication, the user will
341 341 be prompted for it. Environment variables are expanded in the
342 342 username letting you do ``foo.username = $USER``. If the URI
343 343 includes a username, only ``[auth]`` entries with a matching
344 344 username or without a username will be considered.
345 345
346 346 ``password``
347 347 Optional. Password to authenticate with. If not given, and the
348 348 remote site requires basic or digest authentication, the user
349 349 will be prompted for it.
350 350
351 351 ``key``
352 352 Optional. PEM encoded client certificate key file. Environment
353 353 variables are expanded in the filename.
354 354
355 355 ``cert``
356 356 Optional. PEM encoded client certificate chain file. Environment
357 357 variables are expanded in the filename.
358 358
359 359 ``schemes``
360 360 Optional. Space separated list of URI schemes to use this
361 361 authentication entry with. Only used if the prefix doesn't include
362 362 a scheme. Supported schemes are http and https. They will match
363 363 static-http and static-https respectively, as well.
364 364 (default: https)
365 365
366 366 If no suitable authentication entry is found, the user is prompted
367 367 for credentials as usual if required by the remote.
368 368
369 369
370 370 ``committemplate``
371 371 ------------------
372 372
373 373 ``changeset``
374 374 String: configuration in this section is used as the template to
375 375 customize the text shown in the editor when committing.
376 376
377 377 In addition to pre-defined template keywords, commit log specific one
378 378 below can be used for customization:
379 379
380 380 ``extramsg``
381 381 String: Extra message (typically 'Leave message empty to abort
382 382 commit.'). This may be changed by some commands or extensions.
383 383
384 384 For example, the template configuration below shows as same text as
385 385 one shown by default::
386 386
387 387 [committemplate]
388 388 changeset = {desc}\n\n
389 389 HG: Enter commit message. Lines beginning with 'HG:' are removed.
390 390 HG: {extramsg}
391 391 HG: --
392 392 HG: user: {author}\n{ifeq(p2rev, "-1", "",
393 393 "HG: branch merge\n")
394 394 }HG: branch '{branch}'\n{if(activebookmark,
395 395 "HG: bookmark '{activebookmark}'\n") }{subrepos %
396 396 "HG: subrepo {subrepo}\n" }{file_adds %
397 397 "HG: added {file}\n" }{file_mods %
398 398 "HG: changed {file}\n" }{file_dels %
399 399 "HG: removed {file}\n" }{if(files, "",
400 400 "HG: no files changed\n")}
401 401
402 402 .. note::
403 403
404 404 For some problematic encodings (see :hg:`help win32mbcs` for
405 405 detail), this customization should be configured carefully, to
406 406 avoid showing broken characters.
407 407
408 408 For example, if a multibyte character ending with backslash (0x5c) is
409 409 followed by the ASCII character 'n' in the customized template,
410 410 the sequence of backslash and 'n' is treated as line-feed unexpectedly
411 411 (and the multibyte character is broken, too).
412 412
413 413 Customized template is used for commands below (``--edit`` may be
414 414 required):
415 415
416 416 - :hg:`backout`
417 417 - :hg:`commit`
418 418 - :hg:`fetch` (for merge commit only)
419 419 - :hg:`graft`
420 420 - :hg:`histedit`
421 421 - :hg:`import`
422 422 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
423 423 - :hg:`rebase`
424 424 - :hg:`shelve`
425 425 - :hg:`sign`
426 426 - :hg:`tag`
427 427 - :hg:`transplant`
428 428
429 429 Configuring items below instead of ``changeset`` allows showing
430 430 customized message only for specific actions, or showing different
431 431 messages for each action.
432 432
433 433 - ``changeset.backout`` for :hg:`backout`
434 434 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
435 435 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
436 436 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
437 437 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
438 438 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
439 439 - ``changeset.gpg.sign`` for :hg:`sign`
440 440 - ``changeset.graft`` for :hg:`graft`
441 441 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
442 442 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
443 443 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
444 444 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
445 445 - ``changeset.import.bypass`` for :hg:`import --bypass`
446 446 - ``changeset.import.normal.merge`` for :hg:`import` on merges
447 447 - ``changeset.import.normal.normal`` for :hg:`import` on other
448 448 - ``changeset.mq.qnew`` for :hg:`qnew`
449 449 - ``changeset.mq.qfold`` for :hg:`qfold`
450 450 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
451 451 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
452 452 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
453 453 - ``changeset.rebase.normal`` for :hg:`rebase` on other
454 454 - ``changeset.shelve.shelve`` for :hg:`shelve`
455 455 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
456 456 - ``changeset.tag.remove`` for :hg:`tag --remove`
457 457 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
458 458 - ``changeset.transplant.normal`` for :hg:`transplant` on other
459 459
460 460 These dot-separated lists of names are treated as hierarchical ones.
461 461 For example, ``changeset.tag.remove`` customizes the commit message
462 462 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
463 463 commit message for :hg:`tag` regardless of ``--remove`` option.
464 464
465 465 When the external editor is invoked for a commit, the corresponding
466 466 dot-separated list of names without the ``changeset.`` prefix
467 467 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
468 468 variable.
469 469
470 470 In this section, items other than ``changeset`` can be referred from
471 471 others. For example, the configuration to list committed files up
472 472 below can be referred as ``{listupfiles}``::
473 473
474 474 [committemplate]
475 475 listupfiles = {file_adds %
476 476 "HG: added {file}\n" }{file_mods %
477 477 "HG: changed {file}\n" }{file_dels %
478 478 "HG: removed {file}\n" }{if(files, "",
479 479 "HG: no files changed\n")}
480 480
481 481 ``decode/encode``
482 482 -----------------
483 483
484 484 Filters for transforming files on checkout/checkin. This would
485 485 typically be used for newline processing or other
486 486 localization/canonicalization of files.
487 487
488 488 Filters consist of a filter pattern followed by a filter command.
489 489 Filter patterns are globs by default, rooted at the repository root.
490 490 For example, to match any file ending in ``.txt`` in the root
491 491 directory only, use the pattern ``*.txt``. To match any file ending
492 492 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
493 493 For each file only the first matching filter applies.
494 494
495 495 The filter command can start with a specifier, either ``pipe:`` or
496 496 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
497 497
498 498 A ``pipe:`` command must accept data on stdin and return the transformed
499 499 data on stdout.
500 500
501 501 Pipe example::
502 502
503 503 [encode]
504 504 # uncompress gzip files on checkin to improve delta compression
505 505 # note: not necessarily a good idea, just an example
506 506 *.gz = pipe: gunzip
507 507
508 508 [decode]
509 509 # recompress gzip files when writing them to the working dir (we
510 510 # can safely omit "pipe:", because it's the default)
511 511 *.gz = gzip
512 512
513 513 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
514 514 with the name of a temporary file that contains the data to be
515 515 filtered by the command. The string ``OUTFILE`` is replaced with the name
516 516 of an empty temporary file, where the filtered data must be written by
517 517 the command.
518 518
519 519 .. note::
520 520
521 521 The tempfile mechanism is recommended for Windows systems,
522 522 where the standard shell I/O redirection operators often have
523 523 strange effects and may corrupt the contents of your files.
524 524
525 525 This filter mechanism is used internally by the ``eol`` extension to
526 526 translate line ending characters between Windows (CRLF) and Unix (LF)
527 527 format. We suggest you use the ``eol`` extension for convenience.
528 528
529 529
530 530 ``defaults``
531 531 ------------
532 532
533 533 (defaults are deprecated. Don't use them. Use aliases instead.)
534 534
535 535 Use the ``[defaults]`` section to define command defaults, i.e. the
536 536 default options/arguments to pass to the specified commands.
537 537
538 538 The following example makes :hg:`log` run in verbose mode, and
539 539 :hg:`status` show only the modified files, by default::
540 540
541 541 [defaults]
542 542 log = -v
543 543 status = -m
544 544
545 545 The actual commands, instead of their aliases, must be used when
546 546 defining command defaults. The command defaults will also be applied
547 547 to the aliases of the commands defined.
548 548
549 549
550 550 ``diff``
551 551 --------
552 552
553 553 Settings used when displaying diffs. Everything except for ``unified``
554 554 is a Boolean and defaults to False. See :hg:`help config.annotate`
555 555 for related options for the annotate command.
556 556
557 557 ``git``
558 558 Use git extended diff format.
559 559
560 560 ``nobinary``
561 561 Omit git binary patches.
562 562
563 563 ``nodates``
564 564 Don't include dates in diff headers.
565 565
566 566 ``noprefix``
567 567 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
568 568
569 569 ``showfunc``
570 570 Show which function each change is in.
571 571
572 572 ``ignorews``
573 573 Ignore white space when comparing lines.
574 574
575 575 ``ignorewsamount``
576 576 Ignore changes in the amount of white space.
577 577
578 578 ``ignoreblanklines``
579 579 Ignore changes whose lines are all blank.
580 580
581 581 ``unified``
582 582 Number of lines of context to show.
583 583
584 584 ``email``
585 585 ---------
586 586
587 587 Settings for extensions that send email messages.
588 588
589 589 ``from``
590 590 Optional. Email address to use in "From" header and SMTP envelope
591 591 of outgoing messages.
592 592
593 593 ``to``
594 594 Optional. Comma-separated list of recipients' email addresses.
595 595
596 596 ``cc``
597 597 Optional. Comma-separated list of carbon copy recipients'
598 598 email addresses.
599 599
600 600 ``bcc``
601 601 Optional. Comma-separated list of blind carbon copy recipients'
602 602 email addresses.
603 603
604 604 ``method``
605 605 Optional. Method to use to send email messages. If value is ``smtp``
606 606 (default), use SMTP (see the ``[smtp]`` section for configuration).
607 607 Otherwise, use as name of program to run that acts like sendmail
608 608 (takes ``-f`` option for sender, list of recipients on command line,
609 609 message on stdin). Normally, setting this to ``sendmail`` or
610 610 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
611 611
612 612 ``charsets``
613 613 Optional. Comma-separated list of character sets considered
614 614 convenient for recipients. Addresses, headers, and parts not
615 615 containing patches of outgoing messages will be encoded in the
616 616 first character set to which conversion from local encoding
617 617 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
618 618 conversion fails, the text in question is sent as is.
619 619 (default: '')
620 620
621 621 Order of outgoing email character sets:
622 622
623 623 1. ``us-ascii``: always first, regardless of settings
624 624 2. ``email.charsets``: in order given by user
625 625 3. ``ui.fallbackencoding``: if not in email.charsets
626 626 4. ``$HGENCODING``: if not in email.charsets
627 627 5. ``utf-8``: always last, regardless of settings
628 628
629 629 Email example::
630 630
631 631 [email]
632 632 from = Joseph User <joe.user@example.com>
633 633 method = /usr/sbin/sendmail
634 634 # charsets for western Europeans
635 635 # us-ascii, utf-8 omitted, as they are tried first and last
636 636 charsets = iso-8859-1, iso-8859-15, windows-1252
637 637
638 638
639 639 ``extensions``
640 640 --------------
641 641
642 642 Mercurial has an extension mechanism for adding new features. To
643 643 enable an extension, create an entry for it in this section.
644 644
645 645 If you know that the extension is already in Python's search path,
646 646 you can give the name of the module, followed by ``=``, with nothing
647 647 after the ``=``.
648 648
649 649 Otherwise, give a name that you choose, followed by ``=``, followed by
650 650 the path to the ``.py`` file (including the file name extension) that
651 651 defines the extension.
652 652
653 653 To explicitly disable an extension that is enabled in an hgrc of
654 654 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
655 655 or ``foo = !`` when path is not supplied.
656 656
657 657 Example for ``~/.hgrc``::
658 658
659 659 [extensions]
660 660 # (the color extension will get loaded from Mercurial's path)
661 661 color =
662 662 # (this extension will get loaded from the file specified)
663 663 myfeature = ~/.hgext/myfeature.py
664 664
665 665
666 666 ``format``
667 667 ----------
668 668
669 669 ``usegeneraldelta``
670 670 Enable or disable the "generaldelta" repository format which improves
671 671 repository compression by allowing "revlog" to store delta against arbitrary
672 672 revision instead of the previous stored one. This provides significant
673 673 improvement for repositories with branches.
674 674
675 675 Repositories with this on-disk format require Mercurial version 1.9.
676 676
677 677 Enabled by default.
678 678
679 679 ``dotencode``
680 680 Enable or disable the "dotencode" repository format which enhances
681 681 the "fncache" repository format (which has to be enabled to use
682 682 dotencode) to avoid issues with filenames starting with ._ on
683 683 Mac OS X and spaces on Windows.
684 684
685 685 Repositories with this on-disk format require Mercurial version 1.7.
686 686
687 687 Enabled by default.
688 688
689 689 ``usefncache``
690 690 Enable or disable the "fncache" repository format which enhances
691 691 the "store" repository format (which has to be enabled to use
692 692 fncache) to allow longer filenames and avoids using Windows
693 693 reserved names, e.g. "nul".
694 694
695 695 Repositories with this on-disk format require Mercurial version 1.1.
696 696
697 697 Enabled by default.
698 698
699 699 ``usestore``
700 700 Enable or disable the "store" repository format which improves
701 701 compatibility with systems that fold case or otherwise mangle
702 702 filenames. Disabling this option will allow you to store longer filenames
703 703 in some situations at the expense of compatibility.
704 704
705 705 Repositories with this on-disk format require Mercurial version 0.9.4.
706 706
707 707 Enabled by default.
708 708
709 709 ``graph``
710 710 ---------
711 711
712 712 Web graph view configuration. This section let you change graph
713 713 elements display properties by branches, for instance to make the
714 714 ``default`` branch stand out.
715 715
716 716 Each line has the following format::
717 717
718 718 <branch>.<argument> = <value>
719 719
720 720 where ``<branch>`` is the name of the branch being
721 721 customized. Example::
722 722
723 723 [graph]
724 724 # 2px width
725 725 default.width = 2
726 726 # red color
727 727 default.color = FF0000
728 728
729 729 Supported arguments:
730 730
731 731 ``width``
732 732 Set branch edges width in pixels.
733 733
734 734 ``color``
735 735 Set branch edges color in hexadecimal RGB notation.
736 736
737 737 ``hooks``
738 738 ---------
739 739
740 740 Commands or Python functions that get automatically executed by
741 741 various actions such as starting or finishing a commit. Multiple
742 742 hooks can be run for the same action by appending a suffix to the
743 743 action. Overriding a site-wide hook can be done by changing its
744 744 value or setting it to an empty string. Hooks can be prioritized
745 745 by adding a prefix of ``priority.`` to the hook name on a new line
746 746 and setting the priority. The default priority is 0.
747 747
748 748 Example ``.hg/hgrc``::
749 749
750 750 [hooks]
751 751 # update working directory after adding changesets
752 752 changegroup.update = hg update
753 753 # do not use the site-wide hook
754 754 incoming =
755 755 incoming.email = /my/email/hook
756 756 incoming.autobuild = /my/build/hook
757 757 # force autobuild hook to run before other incoming hooks
758 758 priority.incoming.autobuild = 1
759 759
760 760 Most hooks are run with environment variables set that give useful
761 761 additional information. For each hook below, the environment
762 762 variables it is passed are listed with names of the form ``$HG_foo``.
763 763
764 764 ``changegroup``
765 765 Run after a changegroup has been added via push, pull or unbundle. ID of the
766 766 first new changeset is in ``$HG_NODE`` and last in ``$HG_NODE_LAST``. URL
767 767 from which changes came is in ``$HG_URL``.
768 768
769 769 ``commit``
770 770 Run after a changeset has been created in the local repository. ID
771 771 of the newly created changeset is in ``$HG_NODE``. Parent changeset
772 772 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
773 773
774 774 ``incoming``
775 775 Run after a changeset has been pulled, pushed, or unbundled into
776 776 the local repository. The ID of the newly arrived changeset is in
777 777 ``$HG_NODE``. URL that was source of changes came is in ``$HG_URL``.
778 778
779 779 ``outgoing``
780 780 Run after sending changes from local repository to another. ID of
781 781 first changeset sent is in ``$HG_NODE``. Source of operation is in
782 782 ``$HG_SOURCE``; Also see :hg:`help config.preoutgoing` hook.
783 783
784 784 ``post-<command>``
785 785 Run after successful invocations of the associated command. The
786 786 contents of the command line are passed as ``$HG_ARGS`` and the result
787 787 code in ``$HG_RESULT``. Parsed command line arguments are passed as
788 788 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
789 789 the python data internally passed to <command>. ``$HG_OPTS`` is a
790 790 dictionary of options (with unspecified options set to their defaults).
791 791 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
792 792
793 793 ``pre-<command>``
794 794 Run before executing the associated command. The contents of the
795 795 command line are passed as ``$HG_ARGS``. Parsed command line arguments
796 796 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
797 797 representations of the data internally passed to <command>. ``$HG_OPTS``
798 798 is a dictionary of options (with unspecified options set to their
799 799 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
800 800 failure, the command doesn't execute and Mercurial returns the failure
801 801 code.
802 802
803 803 ``prechangegroup``
804 804 Run before a changegroup is added via push, pull or unbundle. Exit
805 805 status 0 allows the changegroup to proceed. Non-zero status will
806 806 cause the push, pull or unbundle to fail. URL from which changes
807 807 will come is in ``$HG_URL``.
808 808
809 809 ``precommit``
810 810 Run before starting a local commit. Exit status 0 allows the
811 811 commit to proceed. Non-zero status will cause the commit to fail.
812 812 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
813 813
814 814 ``prelistkeys``
815 815 Run before listing pushkeys (like bookmarks) in the
816 816 repository. Non-zero status will cause failure. The key namespace is
817 817 in ``$HG_NAMESPACE``.
818 818
819 819 ``preoutgoing``
820 820 Run before collecting changes to send from the local repository to
821 821 another. Non-zero status will cause failure. This lets you prevent
822 822 pull over HTTP or SSH. Also prevents against local pull, push
823 823 (outbound) or bundle commands, but not effective, since you can
824 824 just copy files instead then. Source of operation is in
825 825 ``$HG_SOURCE``. If "serve", operation is happening on behalf of remote
826 826 SSH or HTTP repository. If "push", "pull" or "bundle", operation
827 827 is happening on behalf of repository on same system.
828 828
829 829 ``prepushkey``
830 830 Run before a pushkey (like a bookmark) is added to the
831 831 repository. Non-zero status will cause the key to be rejected. The
832 832 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
833 833 the old value (if any) is in ``$HG_OLD``, and the new value is in
834 834 ``$HG_NEW``.
835 835
836 836 ``pretag``
837 837 Run before creating a tag. Exit status 0 allows the tag to be
838 838 created. Non-zero status will cause the tag to fail. ID of
839 839 changeset to tag is in ``$HG_NODE``. Name of tag is in ``$HG_TAG``. Tag is
840 840 local if ``$HG_LOCAL=1``, in repository if ``$HG_LOCAL=0``.
841 841
842 842 ``pretxnopen``
843 843 Run before any new repository transaction is open. The reason for the
844 844 transaction will be in ``$HG_TXNNAME`` and a unique identifier for the
845 845 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
846 846 transaction from being opened.
847 847
848 848 ``pretxnclose``
849 849 Run right before the transaction is actually finalized. Any repository change
850 850 will be visible to the hook program. This lets you validate the transaction
851 851 content or change it. Exit status 0 allows the commit to proceed. Non-zero
852 852 status will cause the transaction to be rolled back. The reason for the
853 853 transaction opening will be in ``$HG_TXNNAME`` and a unique identifier for
854 854 the transaction will be in ``HG_TXNID``. The rest of the available data will
855 855 vary according the transaction type. New changesets will add ``$HG_NODE`` (id
856 856 of the first added changeset), ``$HG_NODE_LAST`` (id of the last added
857 857 changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables, bookmarks and phases
858 858 changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``, etc.
859 859
860 860 ``txnclose``
861 861 Run after any repository transaction has been committed. At this
862 862 point, the transaction can no longer be rolled back. The hook will run
863 863 after the lock is released. See :hg:`help config.pretxnclose` docs for
864 864 details about available variables.
865 865
866 866 ``txnabort``
867 867 Run when a transaction is aborted. See :hg:`help config.pretxnclose`
868 868 docs for details about available variables.
869 869
870 870 ``pretxnchangegroup``
871 871 Run after a changegroup has been added via push, pull or unbundle, but before
872 872 the transaction has been committed. Changegroup is visible to hook program.
873 873 This lets you validate incoming changes before accepting them. Passed the ID
874 874 of the first new changeset in ``$HG_NODE`` and last in ``$HG_NODE_LAST``.
875 875 Exit status 0 allows the transaction to commit. Non-zero status will cause
876 876 the transaction to be rolled back and the push, pull or unbundle will fail.
877 877 URL that was source of changes is in ``$HG_URL``.
878 878
879 879 ``pretxncommit``
880 880 Run after a changeset has been created but the transaction not yet
881 881 committed. Changeset is visible to hook program. This lets you
882 882 validate commit message and changes. Exit status 0 allows the
883 883 commit to proceed. Non-zero status will cause the transaction to
884 884 be rolled back. ID of changeset is in ``$HG_NODE``. Parent changeset
885 885 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
886 886
887 887 ``preupdate``
888 888 Run before updating the working directory. Exit status 0 allows
889 889 the update to proceed. Non-zero status will prevent the update.
890 890 Changeset ID of first new parent is in ``$HG_PARENT1``. If merge, ID
891 891 of second new parent is in ``$HG_PARENT2``.
892 892
893 893 ``listkeys``
894 894 Run after listing pushkeys (like bookmarks) in the repository. The
895 895 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
896 896 dictionary containing the keys and values.
897 897
898 898 ``pushkey``
899 899 Run after a pushkey (like a bookmark) is added to the
900 900 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
901 901 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
902 902 value is in ``$HG_NEW``.
903 903
904 904 ``tag``
905 905 Run after a tag is created. ID of tagged changeset is in ``$HG_NODE``.
906 906 Name of tag is in ``$HG_TAG``. Tag is local if ``$HG_LOCAL=1``, in
907 907 repository if ``$HG_LOCAL=0``.
908 908
909 909 ``update``
910 910 Run after updating the working directory. Changeset ID of first
911 911 new parent is in ``$HG_PARENT1``. If merge, ID of second new parent is
912 912 in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
913 913 update failed (e.g. because conflicts not resolved), ``$HG_ERROR=1``.
914 914
915 915 .. note::
916 916
917 917 It is generally better to use standard hooks rather than the
918 918 generic pre- and post- command hooks as they are guaranteed to be
919 919 called in the appropriate contexts for influencing transactions.
920 920 Also, hooks like "commit" will be called in all contexts that
921 921 generate a commit (e.g. tag) and not just the commit command.
922 922
923 923 .. note::
924 924
925 925 Environment variables with empty values may not be passed to
926 926 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
927 927 will have an empty value under Unix-like platforms for non-merge
928 928 changesets, while it will not be available at all under Windows.
929 929
930 930 The syntax for Python hooks is as follows::
931 931
932 932 hookname = python:modulename.submodule.callable
933 933 hookname = python:/path/to/python/module.py:callable
934 934
935 935 Python hooks are run within the Mercurial process. Each hook is
936 936 called with at least three keyword arguments: a ui object (keyword
937 937 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
938 938 keyword that tells what kind of hook is used. Arguments listed as
939 939 environment variables above are passed as keyword arguments, with no
940 940 ``HG_`` prefix, and names in lower case.
941 941
942 942 If a Python hook returns a "true" value or raises an exception, this
943 943 is treated as a failure.
944 944
945 945
946 946 ``hostfingerprints``
947 947 --------------------
948 948
949 949 Fingerprints of the certificates of known HTTPS servers.
950 950 A HTTPS connection to a server with a fingerprint configured here will
951 951 only succeed if the servers certificate matches the fingerprint.
952 952 This is very similar to how ssh known hosts works.
953 953 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
954 954 The CA chain and web.cacerts is not used for servers with a fingerprint.
955 955
956 956 For example::
957 957
958 958 [hostfingerprints]
959 959 hg.intevation.org = fa:1f:d9:48:f1:e7:74:30:38:8d:d8:58:b6:94:b8:58:28:7d:8b:d0
960 960
961 961 This feature is only supported when using Python 2.6 or later.
962 962
963 963
964 964 ``http_proxy``
965 965 --------------
966 966
967 967 Used to access web-based Mercurial repositories through a HTTP
968 968 proxy.
969 969
970 970 ``host``
971 971 Host name and (optional) port of the proxy server, for example
972 972 "myproxy:8000".
973 973
974 974 ``no``
975 975 Optional. Comma-separated list of host names that should bypass
976 976 the proxy.
977 977
978 978 ``passwd``
979 979 Optional. Password to authenticate with at the proxy server.
980 980
981 981 ``user``
982 982 Optional. User name to authenticate with at the proxy server.
983 983
984 984 ``always``
985 985 Optional. Always use the proxy, even for localhost and any entries
986 986 in ``http_proxy.no``. (default: False)
987 987
988 988 ``merge``
989 989 ---------
990 990
991 991 This section specifies behavior during merges and updates.
992 992
993 993 ``checkignored``
994 994 Controls behavior when an ignored file on disk has the same name as a tracked
995 995 file in the changeset being merged or updated to, and has different
996 996 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
997 997 abort on such files. With ``warn``, warn on such files and back them up as
998 998 .orig. With ``ignore``, don't print a warning and back them up as
999 999 .orig. (default: ``abort``)
1000 1000
1001 1001 ``checkunknown``
1002 1002 Controls behavior when an unknown file that isn't ignored has the same name
1003 1003 as a tracked file in the changeset being merged or updated to, and has
1004 1004 different contents. Similar to ``merge.checkignored``, except for files that
1005 1005 are not ignored. (default: ``abort``)
1006 1006
1007 1007 ``merge-patterns``
1008 1008 ------------------
1009 1009
1010 1010 This section specifies merge tools to associate with particular file
1011 1011 patterns. Tools matched here will take precedence over the default
1012 1012 merge tool. Patterns are globs by default, rooted at the repository
1013 1013 root.
1014 1014
1015 1015 Example::
1016 1016
1017 1017 [merge-patterns]
1018 1018 **.c = kdiff3
1019 1019 **.jpg = myimgmerge
1020 1020
1021 1021 ``merge-tools``
1022 1022 ---------------
1023 1023
1024 1024 This section configures external merge tools to use for file-level
1025 1025 merges. This section has likely been preconfigured at install time.
1026 1026 Use :hg:`config merge-tools` to check the existing configuration.
1027 1027 Also see :hg:`help merge-tools` for more details.
1028 1028
1029 1029 Example ``~/.hgrc``::
1030 1030
1031 1031 [merge-tools]
1032 1032 # Override stock tool location
1033 1033 kdiff3.executable = ~/bin/kdiff3
1034 1034 # Specify command line
1035 1035 kdiff3.args = $base $local $other -o $output
1036 1036 # Give higher priority
1037 1037 kdiff3.priority = 1
1038 1038
1039 1039 # Changing the priority of preconfigured tool
1040 1040 meld.priority = 0
1041 1041
1042 1042 # Disable a preconfigured tool
1043 1043 vimdiff.disabled = yes
1044 1044
1045 1045 # Define new tool
1046 1046 myHtmlTool.args = -m $local $other $base $output
1047 1047 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1048 1048 myHtmlTool.priority = 1
1049 1049
1050 1050 Supported arguments:
1051 1051
1052 1052 ``priority``
1053 1053 The priority in which to evaluate this tool.
1054 1054 (default: 0)
1055 1055
1056 1056 ``executable``
1057 1057 Either just the name of the executable or its pathname. On Windows,
1058 1058 the path can use environment variables with ${ProgramFiles} syntax.
1059 1059 (default: the tool name)
1060 1060
1061 1061 ``args``
1062 1062 The arguments to pass to the tool executable. You can refer to the
1063 1063 files being merged as well as the output file through these
1064 1064 variables: ``$base``, ``$local``, ``$other``, ``$output``. The meaning
1065 1065 of ``$local`` and ``$other`` can vary depending on which action is being
1066 1066 performed. During and update or merge, ``$local`` represents the original
1067 1067 state of the file, while ``$other`` represents the commit you are updating
1068 1068 to or the commit you are merging with. During a rebase ``$local``
1069 1069 represents the destination of the rebase, and ``$other`` represents the
1070 1070 commit being rebased.
1071 1071 (default: ``$local $base $other``)
1072 1072
1073 1073 ``premerge``
1074 1074 Attempt to run internal non-interactive 3-way merge tool before
1075 1075 launching external tool. Options are ``true``, ``false``, ``keep`` or
1076 1076 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1077 1077 premerge fails. The ``keep-merge3`` will do the same but include information
1078 1078 about the base of the merge in the marker (see internal :merge3 in
1079 1079 :hg:`help merge-tools`).
1080 1080 (default: True)
1081 1081
1082 1082 ``binary``
1083 1083 This tool can merge binary files. (default: False, unless tool
1084 1084 was selected by file pattern match)
1085 1085
1086 1086 ``symlink``
1087 1087 This tool can merge symlinks. (default: False)
1088 1088
1089 1089 ``check``
1090 1090 A list of merge success-checking options:
1091 1091
1092 1092 ``changed``
1093 1093 Ask whether merge was successful when the merged file shows no changes.
1094 1094 ``conflicts``
1095 1095 Check whether there are conflicts even though the tool reported success.
1096 1096 ``prompt``
1097 1097 Always prompt for merge success, regardless of success reported by tool.
1098 1098
1099 1099 ``fixeol``
1100 1100 Attempt to fix up EOL changes caused by the merge tool.
1101 1101 (default: False)
1102 1102
1103 1103 ``gui``
1104 1104 This tool requires a graphical interface to run. (default: False)
1105 1105
1106 1106 ``regkey``
1107 1107 Windows registry key which describes install location of this
1108 1108 tool. Mercurial will search for this key first under
1109 1109 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1110 1110 (default: None)
1111 1111
1112 1112 ``regkeyalt``
1113 1113 An alternate Windows registry key to try if the first key is not
1114 1114 found. The alternate key uses the same ``regname`` and ``regappend``
1115 1115 semantics of the primary key. The most common use for this key
1116 1116 is to search for 32bit applications on 64bit operating systems.
1117 1117 (default: None)
1118 1118
1119 1119 ``regname``
1120 1120 Name of value to read from specified registry key.
1121 1121 (default: the unnamed (default) value)
1122 1122
1123 1123 ``regappend``
1124 1124 String to append to the value read from the registry, typically
1125 1125 the executable name of the tool.
1126 1126 (default: None)
1127 1127
1128 1128
1129 1129 ``patch``
1130 1130 ---------
1131 1131
1132 1132 Settings used when applying patches, for instance through the 'import'
1133 1133 command or with Mercurial Queues extension.
1134 1134
1135 1135 ``eol``
1136 1136 When set to 'strict' patch content and patched files end of lines
1137 1137 are preserved. When set to ``lf`` or ``crlf``, both files end of
1138 1138 lines are ignored when patching and the result line endings are
1139 1139 normalized to either LF (Unix) or CRLF (Windows). When set to
1140 1140 ``auto``, end of lines are again ignored while patching but line
1141 1141 endings in patched files are normalized to their original setting
1142 1142 on a per-file basis. If target file does not exist or has no end
1143 1143 of line, patch line endings are preserved.
1144 1144 (default: strict)
1145 1145
1146 1146 ``fuzz``
1147 1147 The number of lines of 'fuzz' to allow when applying patches. This
1148 1148 controls how much context the patcher is allowed to ignore when
1149 1149 trying to apply a patch.
1150 1150 (default: 2)
1151 1151
1152 1152 ``paths``
1153 1153 ---------
1154 1154
1155 1155 Assigns symbolic names and behavior to repositories.
1156 1156
1157 1157 Options are symbolic names defining the URL or directory that is the
1158 1158 location of the repository. Example::
1159 1159
1160 1160 [paths]
1161 1161 my_server = https://example.com/my_repo
1162 1162 local_path = /home/me/repo
1163 1163
1164 1164 These symbolic names can be used from the command line. To pull
1165 1165 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1166 1166 :hg:`push local_path`.
1167 1167
1168 1168 Options containing colons (``:``) denote sub-options that can influence
1169 1169 behavior for that specific path. Example::
1170 1170
1171 1171 [paths]
1172 1172 my_server = https://example.com/my_path
1173 1173 my_server:pushurl = ssh://example.com/my_path
1174 1174
1175 1175 The following sub-options can be defined:
1176 1176
1177 1177 ``pushurl``
1178 1178 The URL to use for push operations. If not defined, the location
1179 1179 defined by the path's main entry is used.
1180 1180
1181 1181 The following special named paths exist:
1182 1182
1183 1183 ``default``
1184 1184 The URL or directory to use when no source or remote is specified.
1185 1185
1186 1186 :hg:`clone` will automatically define this path to the location the
1187 1187 repository was cloned from.
1188 1188
1189 1189 ``default-push``
1190 1190 (deprecated) The URL or directory for the default :hg:`push` location.
1191 1191 ``default:pushurl`` should be used instead.
1192 1192
1193 1193 ``phases``
1194 1194 ----------
1195 1195
1196 1196 Specifies default handling of phases. See :hg:`help phases` for more
1197 1197 information about working with phases.
1198 1198
1199 1199 ``publish``
1200 1200 Controls draft phase behavior when working as a server. When true,
1201 1201 pushed changesets are set to public in both client and server and
1202 1202 pulled or cloned changesets are set to public in the client.
1203 1203 (default: True)
1204 1204
1205 1205 ``new-commit``
1206 1206 Phase of newly-created commits.
1207 1207 (default: draft)
1208 1208
1209 1209 ``checksubrepos``
1210 1210 Check the phase of the current revision of each subrepository. Allowed
1211 1211 values are "ignore", "follow" and "abort". For settings other than
1212 1212 "ignore", the phase of the current revision of each subrepository is
1213 1213 checked before committing the parent repository. If any of those phases is
1214 1214 greater than the phase of the parent repository (e.g. if a subrepo is in a
1215 1215 "secret" phase while the parent repo is in "draft" phase), the commit is
1216 1216 either aborted (if checksubrepos is set to "abort") or the higher phase is
1217 1217 used for the parent repository commit (if set to "follow").
1218 1218 (default: follow)
1219 1219
1220 1220
1221 1221 ``profiling``
1222 1222 -------------
1223 1223
1224 1224 Specifies profiling type, format, and file output. Two profilers are
1225 1225 supported: an instrumenting profiler (named ``ls``), and a sampling
1226 1226 profiler (named ``stat``).
1227 1227
1228 1228 In this section description, 'profiling data' stands for the raw data
1229 1229 collected during profiling, while 'profiling report' stands for a
1230 1230 statistical text report generated from the profiling data. The
1231 1231 profiling is done using lsprof.
1232 1232
1233 1233 ``type``
1234 1234 The type of profiler to use.
1235 1235 (default: ls)
1236 1236
1237 1237 ``ls``
1238 1238 Use Python's built-in instrumenting profiler. This profiler
1239 1239 works on all platforms, but each line number it reports is the
1240 1240 first line of a function. This restriction makes it difficult to
1241 1241 identify the expensive parts of a non-trivial function.
1242 1242 ``stat``
1243 1243 Use a third-party statistical profiler, statprof. This profiler
1244 1244 currently runs only on Unix systems, and is most useful for
1245 1245 profiling commands that run for longer than about 0.1 seconds.
1246 1246
1247 1247 ``format``
1248 1248 Profiling format. Specific to the ``ls`` instrumenting profiler.
1249 1249 (default: text)
1250 1250
1251 1251 ``text``
1252 1252 Generate a profiling report. When saving to a file, it should be
1253 1253 noted that only the report is saved, and the profiling data is
1254 1254 not kept.
1255 1255 ``kcachegrind``
1256 1256 Format profiling data for kcachegrind use: when saving to a
1257 1257 file, the generated file can directly be loaded into
1258 1258 kcachegrind.
1259 1259
1260 1260 ``frequency``
1261 1261 Sampling frequency. Specific to the ``stat`` sampling profiler.
1262 1262 (default: 1000)
1263 1263
1264 1264 ``output``
1265 1265 File path where profiling data or report should be saved. If the
1266 1266 file exists, it is replaced. (default: None, data is printed on
1267 1267 stderr)
1268 1268
1269 1269 ``sort``
1270 1270 Sort field. Specific to the ``ls`` instrumenting profiler.
1271 1271 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1272 1272 ``inlinetime``.
1273 1273 (default: inlinetime)
1274 1274
1275 1275 ``limit``
1276 1276 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1277 1277 (default: 30)
1278 1278
1279 1279 ``nested``
1280 1280 Show at most this number of lines of drill-down info after each main entry.
1281 1281 This can help explain the difference between Total and Inline.
1282 1282 Specific to the ``ls`` instrumenting profiler.
1283 1283 (default: 5)
1284 1284
1285 1285 ``progress``
1286 1286 ------------
1287 1287
1288 1288 Mercurial commands can draw progress bars that are as informative as
1289 1289 possible. Some progress bars only offer indeterminate information, while others
1290 1290 have a definite end point.
1291 1291
1292 1292 ``delay``
1293 1293 Number of seconds (float) before showing the progress bar. (default: 3)
1294 1294
1295 1295 ``changedelay``
1296 1296 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1297 1297 that value will be used instead. (default: 1)
1298 1298
1299 1299 ``refresh``
1300 1300 Time in seconds between refreshes of the progress bar. (default: 0.1)
1301 1301
1302 1302 ``format``
1303 1303 Format of the progress bar.
1304 1304
1305 1305 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1306 1306 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1307 1307 last 20 characters of the item, but this can be changed by adding either
1308 1308 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1309 1309 first num characters.
1310 1310
1311 1311 (default: topic bar number estimate)
1312 1312
1313 1313 ``width``
1314 1314 If set, the maximum width of the progress information (that is, min(width,
1315 1315 term width) will be used).
1316 1316
1317 1317 ``clear-complete``
1318 1318 Clear the progress bar after it's done. (default: True)
1319 1319
1320 1320 ``disable``
1321 1321 If true, don't show a progress bar.
1322 1322
1323 1323 ``assume-tty``
1324 1324 If true, ALWAYS show a progress bar, unless disable is given.
1325 1325
1326 ``rebase``
1327 ----------
1328
1329 ``allowdivergence``
1330 Default to False, when True allow creating divergence when performing
1331 rebase of obsolete changesets.
1332
1326 1333 ``revsetalias``
1327 1334 ---------------
1328 1335
1329 1336 Alias definitions for revsets. See :hg:`help revsets` for details.
1330 1337
1331 1338 ``server``
1332 1339 ----------
1333 1340
1334 1341 Controls generic server settings.
1335 1342
1336 1343 ``uncompressed``
1337 1344 Whether to allow clients to clone a repository using the
1338 1345 uncompressed streaming protocol. This transfers about 40% more
1339 1346 data than a regular clone, but uses less memory and CPU on both
1340 1347 server and client. Over a LAN (100 Mbps or better) or a very fast
1341 1348 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1342 1349 regular clone. Over most WAN connections (anything slower than
1343 1350 about 6 Mbps), uncompressed streaming is slower, because of the
1344 1351 extra data transfer overhead. This mode will also temporarily hold
1345 1352 the write lock while determining what data to transfer.
1346 1353 (default: True)
1347 1354
1348 1355 ``preferuncompressed``
1349 1356 When set, clients will try to use the uncompressed streaming
1350 1357 protocol. (default: False)
1351 1358
1352 1359 ``validate``
1353 1360 Whether to validate the completeness of pushed changesets by
1354 1361 checking that all new file revisions specified in manifests are
1355 1362 present. (default: False)
1356 1363
1357 1364 ``maxhttpheaderlen``
1358 1365 Instruct HTTP clients not to send request headers longer than this
1359 1366 many bytes. (default: 1024)
1360 1367
1361 1368 ``bundle1``
1362 1369 Whether to allow clients to push and pull using the legacy bundle1
1363 1370 exchange format. (default: True)
1364 1371
1365 1372 ``bundle1gd``
1366 1373 Like ``bundle1`` but only used if the repository is using the
1367 1374 *generaldelta* storage format. (default: True)
1368 1375
1369 1376 ``bundle1.push``
1370 1377 Whether to allow clients to push using the legacy bundle1 exchange
1371 1378 format. (default: True)
1372 1379
1373 1380 ``bundle1gd.push``
1374 1381 Like ``bundle1.push`` but only used if the repository is using the
1375 1382 *generaldelta* storage format. (default: True)
1376 1383
1377 1384 ``bundle1.pull``
1378 1385 Whether to allow clients to pull using the legacy bundle1 exchange
1379 1386 format. (default: True)
1380 1387
1381 1388 ``bundle1gd.pull``
1382 1389 Like ``bundle1.pull`` but only used if the repository is using the
1383 1390 *generaldelta* storage format. (default: True)
1384 1391
1385 1392 Large repositories using the *generaldelta* storage format should
1386 1393 consider setting this option because converting *generaldelta*
1387 1394 repositories to the exchange format required by the bundle1 data
1388 1395 format can consume a lot of CPU.
1389 1396
1390 1397 ``smtp``
1391 1398 --------
1392 1399
1393 1400 Configuration for extensions that need to send email messages.
1394 1401
1395 1402 ``host``
1396 1403 Host name of mail server, e.g. "mail.example.com".
1397 1404
1398 1405 ``port``
1399 1406 Optional. Port to connect to on mail server. (default: 465 if
1400 1407 ``tls`` is smtps; 25 otherwise)
1401 1408
1402 1409 ``tls``
1403 1410 Optional. Method to enable TLS when connecting to mail server: starttls,
1404 1411 smtps or none. (default: none)
1405 1412
1406 1413 ``verifycert``
1407 1414 Optional. Verification for the certificate of mail server, when
1408 1415 ``tls`` is starttls or smtps. "strict", "loose" or False. For
1409 1416 "strict" or "loose", the certificate is verified as same as the
1410 1417 verification for HTTPS connections (see ``[hostfingerprints]`` and
1411 1418 ``[web] cacerts`` also). For "strict", sending email is also
1412 1419 aborted, if there is no configuration for mail server in
1413 1420 ``[hostfingerprints]`` and ``[web] cacerts``. --insecure for
1414 1421 :hg:`email` overwrites this as "loose". (default: strict)
1415 1422
1416 1423 ``username``
1417 1424 Optional. User name for authenticating with the SMTP server.
1418 1425 (default: None)
1419 1426
1420 1427 ``password``
1421 1428 Optional. Password for authenticating with the SMTP server. If not
1422 1429 specified, interactive sessions will prompt the user for a
1423 1430 password; non-interactive sessions will fail. (default: None)
1424 1431
1425 1432 ``local_hostname``
1426 1433 Optional. The hostname that the sender can use to identify
1427 1434 itself to the MTA.
1428 1435
1429 1436
1430 1437 ``subpaths``
1431 1438 ------------
1432 1439
1433 1440 Subrepository source URLs can go stale if a remote server changes name
1434 1441 or becomes temporarily unavailable. This section lets you define
1435 1442 rewrite rules of the form::
1436 1443
1437 1444 <pattern> = <replacement>
1438 1445
1439 1446 where ``pattern`` is a regular expression matching a subrepository
1440 1447 source URL and ``replacement`` is the replacement string used to
1441 1448 rewrite it. Groups can be matched in ``pattern`` and referenced in
1442 1449 ``replacements``. For instance::
1443 1450
1444 1451 http://server/(.*)-hg/ = http://hg.server/\1/
1445 1452
1446 1453 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1447 1454
1448 1455 Relative subrepository paths are first made absolute, and the
1449 1456 rewrite rules are then applied on the full (absolute) path. The rules
1450 1457 are applied in definition order.
1451 1458
1452 1459 ``trusted``
1453 1460 -----------
1454 1461
1455 1462 Mercurial will not use the settings in the
1456 1463 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
1457 1464 user or to a trusted group, as various hgrc features allow arbitrary
1458 1465 commands to be run. This issue is often encountered when configuring
1459 1466 hooks or extensions for shared repositories or servers. However,
1460 1467 the web interface will use some safe settings from the ``[web]``
1461 1468 section.
1462 1469
1463 1470 This section specifies what users and groups are trusted. The
1464 1471 current user is always trusted. To trust everybody, list a user or a
1465 1472 group with name ``*``. These settings must be placed in an
1466 1473 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
1467 1474 user or service running Mercurial.
1468 1475
1469 1476 ``users``
1470 1477 Comma-separated list of trusted users.
1471 1478
1472 1479 ``groups``
1473 1480 Comma-separated list of trusted groups.
1474 1481
1475 1482
1476 1483 ``ui``
1477 1484 ------
1478 1485
1479 1486 User interface controls.
1480 1487
1481 1488 ``archivemeta``
1482 1489 Whether to include the .hg_archival.txt file containing meta data
1483 1490 (hashes for the repository base and for tip) in archives created
1484 1491 by the :hg:`archive` command or downloaded via hgweb.
1485 1492 (default: True)
1486 1493
1487 1494 ``askusername``
1488 1495 Whether to prompt for a username when committing. If True, and
1489 1496 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
1490 1497 be prompted to enter a username. If no username is entered, the
1491 1498 default ``USER@HOST`` is used instead.
1492 1499 (default: False)
1493 1500
1494 1501 ``clonebundles``
1495 1502 Whether the "clone bundles" feature is enabled.
1496 1503
1497 1504 When enabled, :hg:`clone` may download and apply a server-advertised
1498 1505 bundle file from a URL instead of using the normal exchange mechanism.
1499 1506
1500 1507 This can likely result in faster and more reliable clones.
1501 1508
1502 1509 (default: True)
1503 1510
1504 1511 ``clonebundlefallback``
1505 1512 Whether failure to apply an advertised "clone bundle" from a server
1506 1513 should result in fallback to a regular clone.
1507 1514
1508 1515 This is disabled by default because servers advertising "clone
1509 1516 bundles" often do so to reduce server load. If advertised bundles
1510 1517 start mass failing and clients automatically fall back to a regular
1511 1518 clone, this would add significant and unexpected load to the server
1512 1519 since the server is expecting clone operations to be offloaded to
1513 1520 pre-generated bundles. Failing fast (the default behavior) ensures
1514 1521 clients don't overwhelm the server when "clone bundle" application
1515 1522 fails.
1516 1523
1517 1524 (default: False)
1518 1525
1519 1526 ``clonebundleprefers``
1520 1527 Defines preferences for which "clone bundles" to use.
1521 1528
1522 1529 Servers advertising "clone bundles" may advertise multiple available
1523 1530 bundles. Each bundle may have different attributes, such as the bundle
1524 1531 type and compression format. This option is used to prefer a particular
1525 1532 bundle over another.
1526 1533
1527 1534 The following keys are defined by Mercurial:
1528 1535
1529 1536 BUNDLESPEC
1530 1537 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
1531 1538 e.g. ``gzip-v2`` or ``bzip2-v1``.
1532 1539
1533 1540 COMPRESSION
1534 1541 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
1535 1542
1536 1543 Server operators may define custom keys.
1537 1544
1538 1545 Example values: ``COMPRESSION=bzip2``,
1539 1546 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
1540 1547
1541 1548 By default, the first bundle advertised by the server is used.
1542 1549
1543 1550 ``commitsubrepos``
1544 1551 Whether to commit modified subrepositories when committing the
1545 1552 parent repository. If False and one subrepository has uncommitted
1546 1553 changes, abort the commit.
1547 1554 (default: False)
1548 1555
1549 1556 ``debug``
1550 1557 Print debugging information. (default: False)
1551 1558
1552 1559 ``editor``
1553 1560 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
1554 1561
1555 1562 ``fallbackencoding``
1556 1563 Encoding to try if it's not possible to decode the changelog using
1557 1564 UTF-8. (default: ISO-8859-1)
1558 1565
1559 1566 ``graphnodetemplate``
1560 1567 The template used to print changeset nodes in an ASCII revision graph.
1561 1568 (default: ``{graphnode}``)
1562 1569
1563 1570 ``ignore``
1564 1571 A file to read per-user ignore patterns from. This file should be
1565 1572 in the same format as a repository-wide .hgignore file. Filenames
1566 1573 are relative to the repository root. This option supports hook syntax,
1567 1574 so if you want to specify multiple ignore files, you can do so by
1568 1575 setting something like ``ignore.other = ~/.hgignore2``. For details
1569 1576 of the ignore file format, see the ``hgignore(5)`` man page.
1570 1577
1571 1578 ``interactive``
1572 1579 Allow to prompt the user. (default: True)
1573 1580
1574 1581 ``logtemplate``
1575 1582 Template string for commands that print changesets.
1576 1583
1577 1584 ``merge``
1578 1585 The conflict resolution program to use during a manual merge.
1579 1586 For more information on merge tools see :hg:`help merge-tools`.
1580 1587 For configuring merge tools see the ``[merge-tools]`` section.
1581 1588
1582 1589 ``mergemarkers``
1583 1590 Sets the merge conflict marker label styling. The ``detailed``
1584 1591 style uses the ``mergemarkertemplate`` setting to style the labels.
1585 1592 The ``basic`` style just uses 'local' and 'other' as the marker label.
1586 1593 One of ``basic`` or ``detailed``.
1587 1594 (default: ``basic``)
1588 1595
1589 1596 ``mergemarkertemplate``
1590 1597 The template used to print the commit description next to each conflict
1591 1598 marker during merge conflicts. See :hg:`help templates` for the template
1592 1599 format.
1593 1600
1594 1601 Defaults to showing the hash, tags, branches, bookmarks, author, and
1595 1602 the first line of the commit description.
1596 1603
1597 1604 If you use non-ASCII characters in names for tags, branches, bookmarks,
1598 1605 authors, and/or commit descriptions, you must pay attention to encodings of
1599 1606 managed files. At template expansion, non-ASCII characters use the encoding
1600 1607 specified by the ``--encoding`` global option, ``HGENCODING`` or other
1601 1608 environment variables that govern your locale. If the encoding of the merge
1602 1609 markers is different from the encoding of the merged files,
1603 1610 serious problems may occur.
1604 1611
1605 1612 ``origbackuppath``
1606 1613 The path to a directory used to store generated .orig files. If the path is
1607 1614 not a directory, one will be created.
1608 1615
1609 1616 ``patch``
1610 1617 An optional external tool that ``hg import`` and some extensions
1611 1618 will use for applying patches. By default Mercurial uses an
1612 1619 internal patch utility. The external tool must work as the common
1613 1620 Unix ``patch`` program. In particular, it must accept a ``-p``
1614 1621 argument to strip patch headers, a ``-d`` argument to specify the
1615 1622 current directory, a file name to patch, and a patch file to take
1616 1623 from stdin.
1617 1624
1618 1625 It is possible to specify a patch tool together with extra
1619 1626 arguments. For example, setting this option to ``patch --merge``
1620 1627 will use the ``patch`` program with its 2-way merge option.
1621 1628
1622 1629 ``portablefilenames``
1623 1630 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
1624 1631 (default: ``warn``)
1625 1632 If set to ``warn`` (or ``true``), a warning message is printed on POSIX
1626 1633 platforms, if a file with a non-portable filename is added (e.g. a file
1627 1634 with a name that can't be created on Windows because it contains reserved
1628 1635 parts like ``AUX``, reserved characters like ``:``, or would cause a case
1629 1636 collision with an existing file).
1630 1637 If set to ``ignore`` (or ``false``), no warning is printed.
1631 1638 If set to ``abort``, the command is aborted.
1632 1639 On Windows, this configuration option is ignored and the command aborted.
1633 1640
1634 1641 ``quiet``
1635 1642 Reduce the amount of output printed. (default: False)
1636 1643
1637 1644 ``remotecmd``
1638 1645 Remote command to use for clone/push/pull operations. (default: ``hg``)
1639 1646
1640 1647 ``report_untrusted``
1641 1648 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
1642 1649 trusted user or group. (default: True)
1643 1650
1644 1651 ``slash``
1645 1652 Display paths using a slash (``/``) as the path separator. This
1646 1653 only makes a difference on systems where the default path
1647 1654 separator is not the slash character (e.g. Windows uses the
1648 1655 backslash character (``\``)).
1649 1656 (default: False)
1650 1657
1651 1658 ``statuscopies``
1652 1659 Display copies in the status command.
1653 1660
1654 1661 ``ssh``
1655 1662 Command to use for SSH connections. (default: ``ssh``)
1656 1663
1657 1664 ``strict``
1658 1665 Require exact command names, instead of allowing unambiguous
1659 1666 abbreviations. (default: False)
1660 1667
1661 1668 ``style``
1662 1669 Name of style to use for command output.
1663 1670
1664 1671 ``supportcontact``
1665 1672 A URL where users should report a Mercurial traceback. Use this if you are a
1666 1673 large organisation with its own Mercurial deployment process and crash
1667 1674 reports should be addressed to your internal support.
1668 1675
1669 1676 ``timeout``
1670 1677 The timeout used when a lock is held (in seconds), a negative value
1671 1678 means no timeout. (default: 600)
1672 1679
1673 1680 ``traceback``
1674 1681 Mercurial always prints a traceback when an unknown exception
1675 1682 occurs. Setting this to True will make Mercurial print a traceback
1676 1683 on all exceptions, even those recognized by Mercurial (such as
1677 1684 IOError or MemoryError). (default: False)
1678 1685
1679 1686 ``username``
1680 1687 The committer of a changeset created when running "commit".
1681 1688 Typically a person's name and email address, e.g. ``Fred Widget
1682 1689 <fred@example.com>``. Environment variables in the
1683 1690 username are expanded.
1684 1691
1685 1692 (default: ``$EMAIL`` or ``username@hostname``. If the username in
1686 1693 hgrc is empty, e.g. if the system admin set ``username =`` in the
1687 1694 system hgrc, it has to be specified manually or in a different
1688 1695 hgrc file)
1689 1696
1690 1697 ``verbose``
1691 1698 Increase the amount of output printed. (default: False)
1692 1699
1693 1700
1694 1701 ``web``
1695 1702 -------
1696 1703
1697 1704 Web interface configuration. The settings in this section apply to
1698 1705 both the builtin webserver (started by :hg:`serve`) and the script you
1699 1706 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
1700 1707 and WSGI).
1701 1708
1702 1709 The Mercurial webserver does no authentication (it does not prompt for
1703 1710 usernames and passwords to validate *who* users are), but it does do
1704 1711 authorization (it grants or denies access for *authenticated users*
1705 1712 based on settings in this section). You must either configure your
1706 1713 webserver to do authentication for you, or disable the authorization
1707 1714 checks.
1708 1715
1709 1716 For a quick setup in a trusted environment, e.g., a private LAN, where
1710 1717 you want it to accept pushes from anybody, you can use the following
1711 1718 command line::
1712 1719
1713 1720 $ hg --config web.allow_push=* --config web.push_ssl=False serve
1714 1721
1715 1722 Note that this will allow anybody to push anything to the server and
1716 1723 that this should not be used for public servers.
1717 1724
1718 1725 The full set of options is:
1719 1726
1720 1727 ``accesslog``
1721 1728 Where to output the access log. (default: stdout)
1722 1729
1723 1730 ``address``
1724 1731 Interface address to bind to. (default: all)
1725 1732
1726 1733 ``allow_archive``
1727 1734 List of archive format (bz2, gz, zip) allowed for downloading.
1728 1735 (default: empty)
1729 1736
1730 1737 ``allowbz2``
1731 1738 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
1732 1739 revisions.
1733 1740 (default: False)
1734 1741
1735 1742 ``allowgz``
1736 1743 (DEPRECATED) Whether to allow .tar.gz downloading of repository
1737 1744 revisions.
1738 1745 (default: False)
1739 1746
1740 1747 ``allowpull``
1741 1748 Whether to allow pulling from the repository. (default: True)
1742 1749
1743 1750 ``allow_push``
1744 1751 Whether to allow pushing to the repository. If empty or not set,
1745 1752 pushing is not allowed. If the special value ``*``, any remote
1746 1753 user can push, including unauthenticated users. Otherwise, the
1747 1754 remote user must have been authenticated, and the authenticated
1748 1755 user name must be present in this list. The contents of the
1749 1756 allow_push list are examined after the deny_push list.
1750 1757
1751 1758 ``allow_read``
1752 1759 If the user has not already been denied repository access due to
1753 1760 the contents of deny_read, this list determines whether to grant
1754 1761 repository access to the user. If this list is not empty, and the
1755 1762 user is unauthenticated or not present in the list, then access is
1756 1763 denied for the user. If the list is empty or not set, then access
1757 1764 is permitted to all users by default. Setting allow_read to the
1758 1765 special value ``*`` is equivalent to it not being set (i.e. access
1759 1766 is permitted to all users). The contents of the allow_read list are
1760 1767 examined after the deny_read list.
1761 1768
1762 1769 ``allowzip``
1763 1770 (DEPRECATED) Whether to allow .zip downloading of repository
1764 1771 revisions. This feature creates temporary files.
1765 1772 (default: False)
1766 1773
1767 1774 ``archivesubrepos``
1768 1775 Whether to recurse into subrepositories when archiving.
1769 1776 (default: False)
1770 1777
1771 1778 ``baseurl``
1772 1779 Base URL to use when publishing URLs in other locations, so
1773 1780 third-party tools like email notification hooks can construct
1774 1781 URLs. Example: ``http://hgserver/repos/``.
1775 1782
1776 1783 ``cacerts``
1777 1784 Path to file containing a list of PEM encoded certificate
1778 1785 authority certificates. Environment variables and ``~user``
1779 1786 constructs are expanded in the filename. If specified on the
1780 1787 client, then it will verify the identity of remote HTTPS servers
1781 1788 with these certificates.
1782 1789
1783 1790 This feature is only supported when using Python 2.6 or later. If you wish
1784 1791 to use it with earlier versions of Python, install the backported
1785 1792 version of the ssl library that is available from
1786 1793 ``http://pypi.python.org``.
1787 1794
1788 1795 To disable SSL verification temporarily, specify ``--insecure`` from
1789 1796 command line.
1790 1797
1791 1798 You can use OpenSSL's CA certificate file if your platform has
1792 1799 one. On most Linux systems this will be
1793 1800 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
1794 1801 generate this file manually. The form must be as follows::
1795 1802
1796 1803 -----BEGIN CERTIFICATE-----
1797 1804 ... (certificate in base64 PEM encoding) ...
1798 1805 -----END CERTIFICATE-----
1799 1806 -----BEGIN CERTIFICATE-----
1800 1807 ... (certificate in base64 PEM encoding) ...
1801 1808 -----END CERTIFICATE-----
1802 1809
1803 1810 ``cache``
1804 1811 Whether to support caching in hgweb. (default: True)
1805 1812
1806 1813 ``certificate``
1807 1814 Certificate to use when running :hg:`serve`.
1808 1815
1809 1816 ``collapse``
1810 1817 With ``descend`` enabled, repositories in subdirectories are shown at
1811 1818 a single level alongside repositories in the current path. With
1812 1819 ``collapse`` also enabled, repositories residing at a deeper level than
1813 1820 the current path are grouped behind navigable directory entries that
1814 1821 lead to the locations of these repositories. In effect, this setting
1815 1822 collapses each collection of repositories found within a subdirectory
1816 1823 into a single entry for that subdirectory. (default: False)
1817 1824
1818 1825 ``comparisoncontext``
1819 1826 Number of lines of context to show in side-by-side file comparison. If
1820 1827 negative or the value ``full``, whole files are shown. (default: 5)
1821 1828
1822 1829 This setting can be overridden by a ``context`` request parameter to the
1823 1830 ``comparison`` command, taking the same values.
1824 1831
1825 1832 ``contact``
1826 1833 Name or email address of the person in charge of the repository.
1827 1834 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
1828 1835
1829 1836 ``deny_push``
1830 1837 Whether to deny pushing to the repository. If empty or not set,
1831 1838 push is not denied. If the special value ``*``, all remote users are
1832 1839 denied push. Otherwise, unauthenticated users are all denied, and
1833 1840 any authenticated user name present in this list is also denied. The
1834 1841 contents of the deny_push list are examined before the allow_push list.
1835 1842
1836 1843 ``deny_read``
1837 1844 Whether to deny reading/viewing of the repository. If this list is
1838 1845 not empty, unauthenticated users are all denied, and any
1839 1846 authenticated user name present in this list is also denied access to
1840 1847 the repository. If set to the special value ``*``, all remote users
1841 1848 are denied access (rarely needed ;). If deny_read is empty or not set,
1842 1849 the determination of repository access depends on the presence and
1843 1850 content of the allow_read list (see description). If both
1844 1851 deny_read and allow_read are empty or not set, then access is
1845 1852 permitted to all users by default. If the repository is being
1846 1853 served via hgwebdir, denied users will not be able to see it in
1847 1854 the list of repositories. The contents of the deny_read list have
1848 1855 priority over (are examined before) the contents of the allow_read
1849 1856 list.
1850 1857
1851 1858 ``descend``
1852 1859 hgwebdir indexes will not descend into subdirectories. Only repositories
1853 1860 directly in the current path will be shown (other repositories are still
1854 1861 available from the index corresponding to their containing path).
1855 1862
1856 1863 ``description``
1857 1864 Textual description of the repository's purpose or contents.
1858 1865 (default: "unknown")
1859 1866
1860 1867 ``encoding``
1861 1868 Character encoding name. (default: the current locale charset)
1862 1869 Example: "UTF-8".
1863 1870
1864 1871 ``errorlog``
1865 1872 Where to output the error log. (default: stderr)
1866 1873
1867 1874 ``guessmime``
1868 1875 Control MIME types for raw download of file content.
1869 1876 Set to True to let hgweb guess the content type from the file
1870 1877 extension. This will serve HTML files as ``text/html`` and might
1871 1878 allow cross-site scripting attacks when serving untrusted
1872 1879 repositories. (default: False)
1873 1880
1874 1881 ``hidden``
1875 1882 Whether to hide the repository in the hgwebdir index.
1876 1883 (default: False)
1877 1884
1878 1885 ``ipv6``
1879 1886 Whether to use IPv6. (default: False)
1880 1887
1881 1888 ``logoimg``
1882 1889 File name of the logo image that some templates display on each page.
1883 1890 The file name is relative to ``staticurl``. That is, the full path to
1884 1891 the logo image is "staticurl/logoimg".
1885 1892 If unset, ``hglogo.png`` will be used.
1886 1893
1887 1894 ``logourl``
1888 1895 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
1889 1896 will be used.
1890 1897
1891 1898 ``maxchanges``
1892 1899 Maximum number of changes to list on the changelog. (default: 10)
1893 1900
1894 1901 ``maxfiles``
1895 1902 Maximum number of files to list per changeset. (default: 10)
1896 1903
1897 1904 ``maxshortchanges``
1898 1905 Maximum number of changes to list on the shortlog, graph or filelog
1899 1906 pages. (default: 60)
1900 1907
1901 1908 ``name``
1902 1909 Repository name to use in the web interface.
1903 1910 (default: current working directory)
1904 1911
1905 1912 ``port``
1906 1913 Port to listen on. (default: 8000)
1907 1914
1908 1915 ``prefix``
1909 1916 Prefix path to serve from. (default: '' (server root))
1910 1917
1911 1918 ``push_ssl``
1912 1919 Whether to require that inbound pushes be transported over SSL to
1913 1920 prevent password sniffing. (default: True)
1914 1921
1915 1922 ``refreshinterval``
1916 1923 How frequently directory listings re-scan the filesystem for new
1917 1924 repositories, in seconds. This is relevant when wildcards are used
1918 1925 to define paths. Depending on how much filesystem traversal is
1919 1926 required, refreshing may negatively impact performance.
1920 1927
1921 1928 Values less than or equal to 0 always refresh.
1922 1929 (default: 20)
1923 1930
1924 1931 ``staticurl``
1925 1932 Base URL to use for static files. If unset, static files (e.g. the
1926 1933 hgicon.png favicon) will be served by the CGI script itself. Use
1927 1934 this setting to serve them directly with the HTTP server.
1928 1935 Example: ``http://hgserver/static/``.
1929 1936
1930 1937 ``stripes``
1931 1938 How many lines a "zebra stripe" should span in multi-line output.
1932 1939 Set to 0 to disable. (default: 1)
1933 1940
1934 1941 ``style``
1935 1942 Which template map style to use. The available options are the names of
1936 1943 subdirectories in the HTML templates path. (default: ``paper``)
1937 1944 Example: ``monoblue``.
1938 1945
1939 1946 ``templates``
1940 1947 Where to find the HTML templates. The default path to the HTML templates
1941 1948 can be obtained from ``hg debuginstall``.
1942 1949
1943 1950 ``websub``
1944 1951 ----------
1945 1952
1946 1953 Web substitution filter definition. You can use this section to
1947 1954 define a set of regular expression substitution patterns which
1948 1955 let you automatically modify the hgweb server output.
1949 1956
1950 1957 The default hgweb templates only apply these substitution patterns
1951 1958 on the revision description fields. You can apply them anywhere
1952 1959 you want when you create your own templates by adding calls to the
1953 1960 "websub" filter (usually after calling the "escape" filter).
1954 1961
1955 1962 This can be used, for example, to convert issue references to links
1956 1963 to your issue tracker, or to convert "markdown-like" syntax into
1957 1964 HTML (see the examples below).
1958 1965
1959 1966 Each entry in this section names a substitution filter.
1960 1967 The value of each entry defines the substitution expression itself.
1961 1968 The websub expressions follow the old interhg extension syntax,
1962 1969 which in turn imitates the Unix sed replacement syntax::
1963 1970
1964 1971 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
1965 1972
1966 1973 You can use any separator other than "/". The final "i" is optional
1967 1974 and indicates that the search must be case insensitive.
1968 1975
1969 1976 Examples::
1970 1977
1971 1978 [websub]
1972 1979 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
1973 1980 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
1974 1981 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
1975 1982
1976 1983 ``worker``
1977 1984 ----------
1978 1985
1979 1986 Parallel master/worker configuration. We currently perform working
1980 1987 directory updates in parallel on Unix-like systems, which greatly
1981 1988 helps performance.
1982 1989
1983 1990 ``numcpus``
1984 1991 Number of CPUs to use for parallel operations. A zero or
1985 1992 negative value is treated as ``use the default``.
1986 1993 (default: 4 or the number of CPUs on the system, whichever is larger)
@@ -1,714 +1,807 b''
1 1 ==========================
2 2 Test rebase with obsolete
3 3 ==========================
4 4
5 5 Enable obsolete
6 6
7 7 $ cat >> $HGRCPATH << EOF
8 8 > [ui]
9 9 > logtemplate= {rev}:{node|short} {desc|firstline}
10 10 > [experimental]
11 11 > evolution=createmarkers,allowunstable
12 12 > [phases]
13 13 > publish=False
14 14 > [extensions]
15 15 > rebase=
16 16 > EOF
17 17
18 18 Setup rebase canonical repo
19 19
20 20 $ hg init base
21 21 $ cd base
22 22 $ hg unbundle "$TESTDIR/bundles/rebase.hg"
23 23 adding changesets
24 24 adding manifests
25 25 adding file changes
26 26 added 8 changesets with 7 changes to 7 files (+2 heads)
27 27 (run 'hg heads' to see heads, 'hg merge' to merge)
28 28 $ hg up tip
29 29 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
30 30 $ hg log -G
31 31 @ 7:02de42196ebe H
32 32 |
33 33 | o 6:eea13746799a G
34 34 |/|
35 35 o | 5:24b6387c8c8c F
36 36 | |
37 37 | o 4:9520eea781bc E
38 38 |/
39 39 | o 3:32af7686d403 D
40 40 | |
41 41 | o 2:5fddd98957c8 C
42 42 | |
43 43 | o 1:42ccdea3bb16 B
44 44 |/
45 45 o 0:cd010b8cd998 A
46 46
47 47 $ cd ..
48 48
49 49 simple rebase
50 50 ---------------------------------
51 51
52 52 $ hg clone base simple
53 53 updating to branch default
54 54 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
55 55 $ cd simple
56 56 $ hg up 32af7686d403
57 57 3 files updated, 0 files merged, 2 files removed, 0 files unresolved
58 58 $ hg rebase -d eea13746799a
59 59 rebasing 1:42ccdea3bb16 "B"
60 60 rebasing 2:5fddd98957c8 "C"
61 61 rebasing 3:32af7686d403 "D"
62 62 $ hg log -G
63 63 @ 10:8eeb3c33ad33 D
64 64 |
65 65 o 9:2327fea05063 C
66 66 |
67 67 o 8:e4e5be0395b2 B
68 68 |
69 69 | o 7:02de42196ebe H
70 70 | |
71 71 o | 6:eea13746799a G
72 72 |\|
73 73 | o 5:24b6387c8c8c F
74 74 | |
75 75 o | 4:9520eea781bc E
76 76 |/
77 77 o 0:cd010b8cd998 A
78 78
79 79 $ hg log --hidden -G
80 80 @ 10:8eeb3c33ad33 D
81 81 |
82 82 o 9:2327fea05063 C
83 83 |
84 84 o 8:e4e5be0395b2 B
85 85 |
86 86 | o 7:02de42196ebe H
87 87 | |
88 88 o | 6:eea13746799a G
89 89 |\|
90 90 | o 5:24b6387c8c8c F
91 91 | |
92 92 o | 4:9520eea781bc E
93 93 |/
94 94 | x 3:32af7686d403 D
95 95 | |
96 96 | x 2:5fddd98957c8 C
97 97 | |
98 98 | x 1:42ccdea3bb16 B
99 99 |/
100 100 o 0:cd010b8cd998 A
101 101
102 102 $ hg debugobsolete
103 103 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 e4e5be0395b2cbd471ed22a26b1b6a1a0658a794 0 (*) {'user': 'test'} (glob)
104 104 5fddd98957c8a54a4d436dfe1da9d87f21a1b97b 2327fea05063f39961b14cb69435a9898dc9a245 0 (*) {'user': 'test'} (glob)
105 105 32af7686d403cf45b5d95f2d70cebea587ac806a 8eeb3c33ad33d452c89e5dcf611c347f978fb42b 0 (*) {'user': 'test'} (glob)
106 106
107 107
108 108 $ cd ..
109 109
110 110 empty changeset
111 111 ---------------------------------
112 112
113 113 $ hg clone base empty
114 114 updating to branch default
115 115 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
116 116 $ cd empty
117 117 $ hg up eea13746799a
118 118 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
119 119
120 120 We make a copy of both the first changeset in the rebased and some other in the
121 121 set.
122 122
123 123 $ hg graft 42ccdea3bb16 32af7686d403
124 124 grafting 1:42ccdea3bb16 "B"
125 125 grafting 3:32af7686d403 "D"
126 126 $ hg rebase -s 42ccdea3bb16 -d .
127 127 rebasing 1:42ccdea3bb16 "B"
128 128 note: rebase of 1:42ccdea3bb16 created no changes to commit
129 129 rebasing 2:5fddd98957c8 "C"
130 130 rebasing 3:32af7686d403 "D"
131 131 note: rebase of 3:32af7686d403 created no changes to commit
132 132 $ hg log -G
133 133 o 10:5ae4c968c6ac C
134 134 |
135 135 @ 9:08483444fef9 D
136 136 |
137 137 o 8:8877864f1edb B
138 138 |
139 139 | o 7:02de42196ebe H
140 140 | |
141 141 o | 6:eea13746799a G
142 142 |\|
143 143 | o 5:24b6387c8c8c F
144 144 | |
145 145 o | 4:9520eea781bc E
146 146 |/
147 147 o 0:cd010b8cd998 A
148 148
149 149 $ hg log --hidden -G
150 150 o 10:5ae4c968c6ac C
151 151 |
152 152 @ 9:08483444fef9 D
153 153 |
154 154 o 8:8877864f1edb B
155 155 |
156 156 | o 7:02de42196ebe H
157 157 | |
158 158 o | 6:eea13746799a G
159 159 |\|
160 160 | o 5:24b6387c8c8c F
161 161 | |
162 162 o | 4:9520eea781bc E
163 163 |/
164 164 | x 3:32af7686d403 D
165 165 | |
166 166 | x 2:5fddd98957c8 C
167 167 | |
168 168 | x 1:42ccdea3bb16 B
169 169 |/
170 170 o 0:cd010b8cd998 A
171 171
172 172 $ hg debugobsolete
173 173 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 0 {cd010b8cd998f3981a5a8115f94f8da4ab506089} (*) {'user': 'test'} (glob)
174 174 5fddd98957c8a54a4d436dfe1da9d87f21a1b97b 5ae4c968c6aca831df823664e706c9d4aa34473d 0 (*) {'user': 'test'} (glob)
175 175 32af7686d403cf45b5d95f2d70cebea587ac806a 0 {5fddd98957c8a54a4d436dfe1da9d87f21a1b97b} (*) {'user': 'test'} (glob)
176 176
177 177
178 178 More complex case were part of the rebase set were already rebased
179 179
180 180 $ hg rebase --rev 'desc(D)' --dest 'desc(H)'
181 181 rebasing 9:08483444fef9 "D"
182 182 $ hg debugobsolete
183 183 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 0 {cd010b8cd998f3981a5a8115f94f8da4ab506089} (*) {'user': 'test'} (glob)
184 184 5fddd98957c8a54a4d436dfe1da9d87f21a1b97b 5ae4c968c6aca831df823664e706c9d4aa34473d 0 (*) {'user': 'test'} (glob)
185 185 32af7686d403cf45b5d95f2d70cebea587ac806a 0 {5fddd98957c8a54a4d436dfe1da9d87f21a1b97b} (*) {'user': 'test'} (glob)
186 186 08483444fef91d6224f6655ee586a65d263ad34c 4596109a6a4328c398bde3a4a3b6737cfade3003 0 (*) {'user': 'test'} (glob)
187 187 $ hg log -G
188 188 @ 11:4596109a6a43 D
189 189 |
190 190 | o 10:5ae4c968c6ac C
191 191 | |
192 192 | x 9:08483444fef9 D
193 193 | |
194 194 | o 8:8877864f1edb B
195 195 | |
196 196 o | 7:02de42196ebe H
197 197 | |
198 198 | o 6:eea13746799a G
199 199 |/|
200 200 o | 5:24b6387c8c8c F
201 201 | |
202 202 | o 4:9520eea781bc E
203 203 |/
204 204 o 0:cd010b8cd998 A
205 205
206 206 $ hg rebase --source 'desc(B)' --dest 'tip' --config experimental.rebaseskipobsolete=True
207 207 rebasing 8:8877864f1edb "B"
208 208 note: not rebasing 9:08483444fef9 "D", already in destination as 11:4596109a6a43 "D"
209 209 rebasing 10:5ae4c968c6ac "C"
210 210 $ hg debugobsolete
211 211 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 0 {cd010b8cd998f3981a5a8115f94f8da4ab506089} (*) {'user': 'test'} (glob)
212 212 5fddd98957c8a54a4d436dfe1da9d87f21a1b97b 5ae4c968c6aca831df823664e706c9d4aa34473d 0 (*) {'user': 'test'} (glob)
213 213 32af7686d403cf45b5d95f2d70cebea587ac806a 0 {5fddd98957c8a54a4d436dfe1da9d87f21a1b97b} (*) {'user': 'test'} (glob)
214 214 08483444fef91d6224f6655ee586a65d263ad34c 4596109a6a4328c398bde3a4a3b6737cfade3003 0 (*) {'user': 'test'} (glob)
215 215 8877864f1edb05d0e07dc4ba77b67a80a7b86672 462a34d07e599b87ea08676a449373fe4e2e1347 0 (*) {'user': 'test'} (glob)
216 216 5ae4c968c6aca831df823664e706c9d4aa34473d 98f6af4ee9539e14da4465128f894c274900b6e5 0 (*) {'user': 'test'} (glob)
217 217 $ hg log --rev 'divergent()'
218 218 $ hg log -G
219 219 o 13:98f6af4ee953 C
220 220 |
221 221 o 12:462a34d07e59 B
222 222 |
223 223 @ 11:4596109a6a43 D
224 224 |
225 225 o 7:02de42196ebe H
226 226 |
227 227 | o 6:eea13746799a G
228 228 |/|
229 229 o | 5:24b6387c8c8c F
230 230 | |
231 231 | o 4:9520eea781bc E
232 232 |/
233 233 o 0:cd010b8cd998 A
234 234
235 235 $ hg log --style default --debug -r 4596109a6a4328c398bde3a4a3b6737cfade3003
236 236 changeset: 11:4596109a6a4328c398bde3a4a3b6737cfade3003
237 237 phase: draft
238 238 parent: 7:02de42196ebee42ef284b6780a87cdc96e8eaab6
239 239 parent: -1:0000000000000000000000000000000000000000
240 240 manifest: 11:a91006e3a02f1edf631f7018e6e5684cf27dd905
241 241 user: Nicolas Dumazet <nicdumz.commits@gmail.com>
242 242 date: Sat Apr 30 15:24:48 2011 +0200
243 243 files+: D
244 244 extra: branch=default
245 245 extra: rebase_source=08483444fef91d6224f6655ee586a65d263ad34c
246 246 extra: source=32af7686d403cf45b5d95f2d70cebea587ac806a
247 247 description:
248 248 D
249 249
250 250
251 251 $ hg up -qr 'desc(G)'
252 252 $ hg graft 4596109a6a4328c398bde3a4a3b6737cfade3003
253 253 grafting 11:4596109a6a43 "D"
254 254 $ hg up -qr 'desc(E)'
255 255 $ hg rebase -s tip -d .
256 256 rebasing 14:0f4c66d0b70f "D" (tip)
257 257 $ hg log --style default --debug -r tip
258 258 changeset: 15:884f358981b4d32069bb539e0e95d49a35eb81d0
259 259 tag: tip
260 260 phase: draft
261 261 parent: 4:9520eea781bcca16c1e15acc0ba14335a0e8e5ba
262 262 parent: -1:0000000000000000000000000000000000000000
263 263 manifest: 15:648e8ede73ae3e497d093d3a4c8fcc2daa864f42
264 264 user: Nicolas Dumazet <nicdumz.commits@gmail.com>
265 265 date: Sat Apr 30 15:24:48 2011 +0200
266 266 files+: D
267 267 extra: branch=default
268 268 extra: intermediate-source=4596109a6a4328c398bde3a4a3b6737cfade3003
269 269 extra: rebase_source=0f4c66d0b70f8e1ce4aec01f8e95cf24ee923afa
270 270 extra: source=32af7686d403cf45b5d95f2d70cebea587ac806a
271 271 description:
272 272 D
273 273
274 274
275 275 $ cd ..
276 276
277 277 collapse rebase
278 278 ---------------------------------
279 279
280 280 $ hg clone base collapse
281 281 updating to branch default
282 282 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
283 283 $ cd collapse
284 284 $ hg rebase -s 42ccdea3bb16 -d eea13746799a --collapse
285 285 rebasing 1:42ccdea3bb16 "B"
286 286 rebasing 2:5fddd98957c8 "C"
287 287 rebasing 3:32af7686d403 "D"
288 288 $ hg log -G
289 289 o 8:4dc2197e807b Collapsed revision
290 290 |
291 291 | @ 7:02de42196ebe H
292 292 | |
293 293 o | 6:eea13746799a G
294 294 |\|
295 295 | o 5:24b6387c8c8c F
296 296 | |
297 297 o | 4:9520eea781bc E
298 298 |/
299 299 o 0:cd010b8cd998 A
300 300
301 301 $ hg log --hidden -G
302 302 o 8:4dc2197e807b Collapsed revision
303 303 |
304 304 | @ 7:02de42196ebe H
305 305 | |
306 306 o | 6:eea13746799a G
307 307 |\|
308 308 | o 5:24b6387c8c8c F
309 309 | |
310 310 o | 4:9520eea781bc E
311 311 |/
312 312 | x 3:32af7686d403 D
313 313 | |
314 314 | x 2:5fddd98957c8 C
315 315 | |
316 316 | x 1:42ccdea3bb16 B
317 317 |/
318 318 o 0:cd010b8cd998 A
319 319
320 320 $ hg id --debug -r tip
321 321 4dc2197e807bae9817f09905b50ab288be2dbbcf tip
322 322 $ hg debugobsolete
323 323 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 4dc2197e807bae9817f09905b50ab288be2dbbcf 0 (*) {'user': 'test'} (glob)
324 324 5fddd98957c8a54a4d436dfe1da9d87f21a1b97b 4dc2197e807bae9817f09905b50ab288be2dbbcf 0 (*) {'user': 'test'} (glob)
325 325 32af7686d403cf45b5d95f2d70cebea587ac806a 4dc2197e807bae9817f09905b50ab288be2dbbcf 0 (*) {'user': 'test'} (glob)
326 326
327 327 $ cd ..
328 328
329 329 Rebase set has hidden descendants
330 330 ---------------------------------
331 331
332 332 We rebase a changeset which has a hidden changeset. The hidden changeset must
333 333 not be rebased.
334 334
335 335 $ hg clone base hidden
336 336 updating to branch default
337 337 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
338 338 $ cd hidden
339 339 $ hg rebase -s 5fddd98957c8 -d eea13746799a
340 340 rebasing 2:5fddd98957c8 "C"
341 341 rebasing 3:32af7686d403 "D"
342 342 $ hg rebase -s 42ccdea3bb16 -d 02de42196ebe
343 343 rebasing 1:42ccdea3bb16 "B"
344 344 $ hg log -G
345 345 o 10:7c6027df6a99 B
346 346 |
347 347 | o 9:cf44d2f5a9f4 D
348 348 | |
349 349 | o 8:e273c5e7d2d2 C
350 350 | |
351 351 @ | 7:02de42196ebe H
352 352 | |
353 353 | o 6:eea13746799a G
354 354 |/|
355 355 o | 5:24b6387c8c8c F
356 356 | |
357 357 | o 4:9520eea781bc E
358 358 |/
359 359 o 0:cd010b8cd998 A
360 360
361 361 $ hg log --hidden -G
362 362 o 10:7c6027df6a99 B
363 363 |
364 364 | o 9:cf44d2f5a9f4 D
365 365 | |
366 366 | o 8:e273c5e7d2d2 C
367 367 | |
368 368 @ | 7:02de42196ebe H
369 369 | |
370 370 | o 6:eea13746799a G
371 371 |/|
372 372 o | 5:24b6387c8c8c F
373 373 | |
374 374 | o 4:9520eea781bc E
375 375 |/
376 376 | x 3:32af7686d403 D
377 377 | |
378 378 | x 2:5fddd98957c8 C
379 379 | |
380 380 | x 1:42ccdea3bb16 B
381 381 |/
382 382 o 0:cd010b8cd998 A
383 383
384 384 $ hg debugobsolete
385 385 5fddd98957c8a54a4d436dfe1da9d87f21a1b97b e273c5e7d2d29df783dce9f9eaa3ac4adc69c15d 0 (*) {'user': 'test'} (glob)
386 386 32af7686d403cf45b5d95f2d70cebea587ac806a cf44d2f5a9f4297a62be94cbdd3dff7c7dc54258 0 (*) {'user': 'test'} (glob)
387 387 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 7c6027df6a99d93f461868e5433f63bde20b6dfb 0 (*) {'user': 'test'} (glob)
388 388
389 389 Test that rewriting leaving instability behind is allowed
390 390 ---------------------------------------------------------------------
391 391
392 392 $ hg log -r 'children(8)'
393 393 9:cf44d2f5a9f4 D (no-eol)
394 394 $ hg rebase -r 8
395 395 rebasing 8:e273c5e7d2d2 "C"
396 396 $ hg log -G
397 397 o 11:0d8f238b634c C
398 398 |
399 399 o 10:7c6027df6a99 B
400 400 |
401 401 | o 9:cf44d2f5a9f4 D
402 402 | |
403 403 | x 8:e273c5e7d2d2 C
404 404 | |
405 405 @ | 7:02de42196ebe H
406 406 | |
407 407 | o 6:eea13746799a G
408 408 |/|
409 409 o | 5:24b6387c8c8c F
410 410 | |
411 411 | o 4:9520eea781bc E
412 412 |/
413 413 o 0:cd010b8cd998 A
414 414
415 415
416 416
417 417 Test multiple root handling
418 418 ------------------------------------
419 419
420 420 $ hg rebase --dest 4 --rev '7+11+9'
421 421 rebasing 7:02de42196ebe "H"
422 422 rebasing 9:cf44d2f5a9f4 "D"
423 423 not rebasing ignored 10:7c6027df6a99 "B"
424 424 rebasing 11:0d8f238b634c "C" (tip)
425 425 $ hg log -G
426 426 o 14:1e8370e38cca C
427 427 |
428 428 | o 13:102b4c1d889b D
429 429 | |
430 430 @ | 12:bfe264faf697 H
431 431 |/
432 432 | o 10:7c6027df6a99 B
433 433 | |
434 434 | x 7:02de42196ebe H
435 435 | |
436 436 +---o 6:eea13746799a G
437 437 | |/
438 438 | o 5:24b6387c8c8c F
439 439 | |
440 440 o | 4:9520eea781bc E
441 441 |/
442 442 o 0:cd010b8cd998 A
443 443
444 444 $ cd ..
445 445
446 446 test on rebase dropping a merge
447 447
448 448 (setup)
449 449
450 450 $ hg init dropmerge
451 451 $ cd dropmerge
452 452 $ hg unbundle "$TESTDIR/bundles/rebase.hg"
453 453 adding changesets
454 454 adding manifests
455 455 adding file changes
456 456 added 8 changesets with 7 changes to 7 files (+2 heads)
457 457 (run 'hg heads' to see heads, 'hg merge' to merge)
458 458 $ hg up 3
459 459 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
460 460 $ hg merge 7
461 461 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
462 462 (branch merge, don't forget to commit)
463 463 $ hg ci -m 'M'
464 464 $ echo I > I
465 465 $ hg add I
466 466 $ hg ci -m I
467 467 $ hg log -G
468 468 @ 9:4bde274eefcf I
469 469 |
470 470 o 8:53a6a128b2b7 M
471 471 |\
472 472 | o 7:02de42196ebe H
473 473 | |
474 474 | | o 6:eea13746799a G
475 475 | |/|
476 476 | o | 5:24b6387c8c8c F
477 477 | | |
478 478 | | o 4:9520eea781bc E
479 479 | |/
480 480 o | 3:32af7686d403 D
481 481 | |
482 482 o | 2:5fddd98957c8 C
483 483 | |
484 484 o | 1:42ccdea3bb16 B
485 485 |/
486 486 o 0:cd010b8cd998 A
487 487
488 488 (actual test)
489 489
490 490 $ hg rebase --dest 6 --rev '((desc(H) + desc(D))::) - desc(M)'
491 491 rebasing 3:32af7686d403 "D"
492 492 rebasing 7:02de42196ebe "H"
493 493 not rebasing ignored 8:53a6a128b2b7 "M"
494 494 rebasing 9:4bde274eefcf "I" (tip)
495 495 $ hg log -G
496 496 @ 12:acd174b7ab39 I
497 497 |
498 498 o 11:6c11a6218c97 H
499 499 |
500 500 | o 10:b5313c85b22e D
501 501 |/
502 502 | o 8:53a6a128b2b7 M
503 503 | |\
504 504 | | x 7:02de42196ebe H
505 505 | | |
506 506 o---+ 6:eea13746799a G
507 507 | | |
508 508 | | o 5:24b6387c8c8c F
509 509 | | |
510 510 o---+ 4:9520eea781bc E
511 511 / /
512 512 x | 3:32af7686d403 D
513 513 | |
514 514 o | 2:5fddd98957c8 C
515 515 | |
516 516 o | 1:42ccdea3bb16 B
517 517 |/
518 518 o 0:cd010b8cd998 A
519 519
520 520
521 521 Test hidden changesets in the rebase set (issue4504)
522 522
523 523 $ hg up --hidden 9
524 524 3 files updated, 0 files merged, 1 files removed, 0 files unresolved
525 525 $ echo J > J
526 526 $ hg add J
527 527 $ hg commit -m J
528 528 $ hg debugobsolete `hg log --rev . -T '{node}'`
529 529
530 530 $ hg rebase --rev .~1::. --dest 'max(desc(D))' --traceback
531 531 rebasing 9:4bde274eefcf "I"
532 532 rebasing 13:06edfc82198f "J" (tip)
533 533 $ hg log -G
534 534 @ 15:5ae8a643467b J
535 535 |
536 536 o 14:9ad579b4a5de I
537 537 |
538 538 | o 12:acd174b7ab39 I
539 539 | |
540 540 | o 11:6c11a6218c97 H
541 541 | |
542 542 o | 10:b5313c85b22e D
543 543 |/
544 544 | o 8:53a6a128b2b7 M
545 545 | |\
546 546 | | x 7:02de42196ebe H
547 547 | | |
548 548 o---+ 6:eea13746799a G
549 549 | | |
550 550 | | o 5:24b6387c8c8c F
551 551 | | |
552 552 o---+ 4:9520eea781bc E
553 553 / /
554 554 x | 3:32af7686d403 D
555 555 | |
556 556 o | 2:5fddd98957c8 C
557 557 | |
558 558 o | 1:42ccdea3bb16 B
559 559 |/
560 560 o 0:cd010b8cd998 A
561 561
562 562 $ hg up 14 -C
563 563 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
564 564 $ echo "K" > K
565 565 $ hg add K
566 566 $ hg commit --amend -m "K"
567 567 $ echo "L" > L
568 568 $ hg add L
569 569 $ hg commit -m "L"
570 570 $ hg up '.^'
571 571 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
572 572 $ echo "M" > M
573 573 $ hg add M
574 574 $ hg commit --amend -m "M"
575 575 $ hg log -G
576 576 @ 20:bfaedf8eb73b M
577 577 |
578 578 | o 18:97219452e4bd L
579 579 | |
580 580 | x 17:fc37a630c901 K
581 581 |/
582 582 | o 15:5ae8a643467b J
583 583 | |
584 584 | x 14:9ad579b4a5de I
585 585 |/
586 586 | o 12:acd174b7ab39 I
587 587 | |
588 588 | o 11:6c11a6218c97 H
589 589 | |
590 590 o | 10:b5313c85b22e D
591 591 |/
592 592 | o 8:53a6a128b2b7 M
593 593 | |\
594 594 | | x 7:02de42196ebe H
595 595 | | |
596 596 o---+ 6:eea13746799a G
597 597 | | |
598 598 | | o 5:24b6387c8c8c F
599 599 | | |
600 600 o---+ 4:9520eea781bc E
601 601 / /
602 602 x | 3:32af7686d403 D
603 603 | |
604 604 o | 2:5fddd98957c8 C
605 605 | |
606 606 o | 1:42ccdea3bb16 B
607 607 |/
608 608 o 0:cd010b8cd998 A
609 609
610 610 $ hg rebase -s 14 -d 18 --config experimental.rebaseskipobsolete=True
611 611 note: not rebasing 14:9ad579b4a5de "I", already in destination as 17:fc37a630c901 "K"
612 612 rebasing 15:5ae8a643467b "J"
613 613
614 614 $ cd ..
615 615
616 616 Skip obsolete changeset even with multiple hops
617 617 -----------------------------------------------
618 618
619 619 setup
620 620
621 621 $ hg init obsskip
622 622 $ cd obsskip
623 623 $ cat << EOF >> .hg/hgrc
624 624 > [experimental]
625 625 > rebaseskipobsolete = True
626 626 > [extensions]
627 627 > strip =
628 628 > EOF
629 629 $ echo A > A
630 630 $ hg add A
631 631 $ hg commit -m A
632 632 $ echo B > B
633 633 $ hg add B
634 634 $ hg commit -m B0
635 635 $ hg commit --amend -m B1
636 636 $ hg commit --amend -m B2
637 637 $ hg up --hidden 'desc(B0)'
638 638 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
639 639 $ echo C > C
640 640 $ hg add C
641 641 $ hg commit -m C
642 642
643 643 Rebase finds its way in a chain of marker
644 644
645 645 $ hg rebase -d 'desc(B2)'
646 646 note: not rebasing 1:a8b11f55fb19 "B0", already in destination as 3:261e70097290 "B2"
647 647 rebasing 4:212cb178bcbb "C" (tip)
648 648
649 649 Even when the chain include missing node
650 650
651 651 $ hg up --hidden 'desc(B0)'
652 652 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
653 653 $ echo D > D
654 654 $ hg add D
655 655 $ hg commit -m D
656 656 $ hg --hidden strip -r 'desc(B1)'
657 657 saved backup bundle to $TESTTMP/obsskip/.hg/strip-backup/86f6414ccda7-b1c452ee-backup.hg (glob)
658 658
659 659 $ hg rebase -d 'desc(B2)'
660 660 note: not rebasing 1:a8b11f55fb19 "B0", already in destination as 2:261e70097290 "B2"
661 661 rebasing 5:1a79b7535141 "D" (tip)
662 662 $ hg up 4
663 663 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
664 664 $ echo "O" > O
665 665 $ hg add O
666 666 $ hg commit -m O
667 667 $ echo "P" > P
668 668 $ hg add P
669 669 $ hg commit -m P
670 670 $ hg log -G
671 671 @ 8:8d47583e023f P
672 672 |
673 673 o 7:360bbaa7d3ce O
674 674 |
675 675 | o 6:9c48361117de D
676 676 | |
677 677 o | 4:ff2c4d47b71d C
678 678 |/
679 679 o 2:261e70097290 B2
680 680 |
681 681 o 0:4a2df7238c3b A
682 682
683 683 $ hg debugobsolete `hg log -r 7 -T '{node}\n'` --config experimental.evolution=all
684 684 $ hg rebase -d 6 -r "4::"
685 685 rebasing 4:ff2c4d47b71d "C"
686 686 note: not rebasing 7:360bbaa7d3ce "O", it has no successor
687 687 rebasing 8:8d47583e023f "P" (tip)
688 688
689 689 If all the changeset to be rebased are obsolete and present in the destination, we
690 690 should display a friendly error message
691 691
692 692 $ hg log -G
693 693 @ 10:121d9e3bc4c6 P
694 694 |
695 695 o 9:4be60e099a77 C
696 696 |
697 697 o 6:9c48361117de D
698 698 |
699 699 o 2:261e70097290 B2
700 700 |
701 701 o 0:4a2df7238c3b A
702 702
703 703
704 704 $ hg up 9
705 705 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
706 706 $ echo "non-relevant change" > nonrelevant
707 707 $ hg add nonrelevant
708 708 $ hg commit -m nonrelevant
709 709 created new head
710 710 $ hg debugobsolete `hg log -r 11 -T '{node}\n'` --config experimental.evolution=all
711 711 $ hg rebase -r . -d 10
712 712 abort: all requested changesets have equivalents or were marked as obsolete
713 713 (to force the rebase, set the config experimental.rebaseskipobsolete to False)
714 714 [255]
715
716 If a rebase is going to create divergence, it should abort
717
718 $ hg log -G
719 @ 11:f44da1f4954c nonrelevant
720 |
721 | o 10:121d9e3bc4c6 P
722 |/
723 o 9:4be60e099a77 C
724 |
725 o 6:9c48361117de D
726 |
727 o 2:261e70097290 B2
728 |
729 o 0:4a2df7238c3b A
730
731
732 $ hg up 9
733 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
734 $ echo "john" > doe
735 $ hg add doe
736 $ hg commit -m "john doe"
737 created new head
738 $ hg up 10
739 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
740 $ echo "foo" > bar
741 $ hg add bar
742 $ hg commit --amend -m "10'"
743 $ hg up 10 --hidden
744 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
745 $ echo "bar" > foo
746 $ hg add foo
747 $ hg commit -m "bar foo"
748 $ hg log -G
749 @ 15:73568ab6879d bar foo
750 |
751 | o 14:77d874d096a2 10'
752 | |
753 | | o 12:3eb461388009 john doe
754 | |/
755 x | 10:121d9e3bc4c6 P
756 |/
757 o 9:4be60e099a77 C
758 |
759 o 6:9c48361117de D
760 |
761 o 2:261e70097290 B2
762 |
763 o 0:4a2df7238c3b A
764
765 $ hg summary
766 parent: 15:73568ab6879d tip
767 bar foo
768 branch: default
769 commit: (clean)
770 update: 2 new changesets, 3 branch heads (merge)
771 phases: 8 draft
772 unstable: 1 changesets
773 $ hg rebase -s 10 -d 12
774 abort: this rebase will cause divergence
775 (to force the rebase please set rebase.allowdivergence=True)
776 [255]
777 $ hg log -G
778 @ 15:73568ab6879d bar foo
779 |
780 | o 14:77d874d096a2 10'
781 | |
782 | | o 12:3eb461388009 john doe
783 | |/
784 x | 10:121d9e3bc4c6 P
785 |/
786 o 9:4be60e099a77 C
787 |
788 o 6:9c48361117de D
789 |
790 o 2:261e70097290 B2
791 |
792 o 0:4a2df7238c3b A
793
794 With rebase.allowdivergence=True, rebase can create divergence
795
796 $ hg rebase -s 10 -d 12 --config rebase.allowdivergence=True
797 rebasing 10:121d9e3bc4c6 "P"
798 rebasing 15:73568ab6879d "bar foo" (tip)
799 $ hg summary
800 parent: 17:61bd55f69bc4 tip
801 bar foo
802 branch: default
803 commit: (clean)
804 update: 1 new changesets, 2 branch heads (merge)
805 phases: 8 draft
806 divergent: 2 changesets
807
General Comments 0
You need to be logged in to leave comments. Login now