524 archival.archive(repo, dest, node, kind, not opts.get('no_decode'), |
524 archival.archive(repo, dest, node, kind, not opts.get('no_decode'), |
525 matchfn, prefix, subrepos=opts.get('subrepos')) |
525 matchfn, prefix, subrepos=opts.get('subrepos')) |
526 |
526 |
527 @command('backout', |
527 @command('backout', |
528 [('', 'merge', None, _('merge with old dirstate parent after backout')), |
528 [('', 'merge', None, _('merge with old dirstate parent after backout')), |
529 ('', 'commit', None, _('commit if no conflicts were encountered')), |
529 ('', 'commit', None, |
|
530 _('commit if no conflicts were encountered (DEPRECATED)')), |
|
531 ('', 'no-commit', None, _('do not commit')), |
530 ('', 'parent', '', |
532 ('', 'parent', '', |
531 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')), |
533 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')), |
532 ('r', 'rev', '', _('revision to backout'), _('REV')), |
534 ('r', 'rev', '', _('revision to backout'), _('REV')), |
533 ('e', 'edit', False, _('invoke editor on commit messages')), |
535 ('e', 'edit', False, _('invoke editor on commit messages')), |
534 ] + mergetoolopts + walkopts + commitopts + commitopts2, |
536 ] + mergetoolopts + walkopts + commitopts + commitopts2, |
535 _('[OPTION]... [-r] REV')) |
537 _('[OPTION]... [-r] REV')) |
536 def backout(ui, repo, node=None, rev=None, commit=False, **opts): |
538 def backout(ui, repo, node=None, rev=None, **opts): |
537 '''reverse effect of earlier changeset |
539 '''reverse effect of earlier changeset |
538 |
540 |
539 Prepare a new changeset with the effect of REV undone in the |
541 Prepare a new changeset with the effect of REV undone in the |
540 current working directory. |
542 current working directory. If no conflicts were encountered, |
|
543 it will be committed immediately. |
541 |
544 |
542 If REV is the parent of the working directory, then this new changeset |
545 If REV is the parent of the working directory, then this new changeset |
543 is committed automatically. Otherwise, hg needs to merge the |
546 is committed automatically (unless --no-commit is specified). |
544 changes and the merged result is left uncommitted. |
|
545 |
547 |
546 .. note:: |
548 .. note:: |
547 |
549 |
548 :hg:`backout` cannot be used to fix either an unwanted or |
550 :hg:`backout` cannot be used to fix either an unwanted or |
549 incorrect merge. |
551 incorrect merge. |
558 hg backout -r . |
560 hg backout -r . |
559 |
561 |
560 - Reverse the effect of previous bad revision 23:: |
562 - Reverse the effect of previous bad revision 23:: |
561 |
563 |
562 hg backout -r 23 |
564 hg backout -r 23 |
|
565 |
|
566 - Reverse the effect of previous bad revision 23 and |
|
567 leave changes uncommitted:: |
|
568 |
|
569 hg backout -r 23 --no-commit |
563 hg commit -m "Backout revision 23" |
570 hg commit -m "Backout revision 23" |
564 |
|
565 - Reverse the effect of previous bad revision 23 and |
|
566 commit the backout immediately:: |
|
567 |
|
568 hg backout -r 23 --commit |
|
569 |
571 |
570 By default, the pending changeset will have one parent, |
572 By default, the pending changeset will have one parent, |
571 maintaining a linear history. With --merge, the pending |
573 maintaining a linear history. With --merge, the pending |
572 changeset will instead have two parents: the old parent of the |
574 changeset will instead have two parents: the old parent of the |
573 working directory and a new child of REV that simply undoes REV. |
575 working directory and a new child of REV that simply undoes REV. |
587 ''' |
589 ''' |
588 wlock = lock = None |
590 wlock = lock = None |
589 try: |
591 try: |
590 wlock = repo.wlock() |
592 wlock = repo.wlock() |
591 lock = repo.lock() |
593 lock = repo.lock() |
592 return _dobackout(ui, repo, node, rev, commit, **opts) |
594 return _dobackout(ui, repo, node, rev, **opts) |
593 finally: |
595 finally: |
594 release(lock, wlock) |
596 release(lock, wlock) |
595 |
597 |
596 def _dobackout(ui, repo, node=None, rev=None, commit=False, **opts): |
598 def _dobackout(ui, repo, node=None, rev=None, **opts): |
|
599 if opts.get('commit') and opts.get('no_commit'): |
|
600 raise error.Abort(_("cannot use --commit with --no-commit")) |
|
601 |
597 if rev and node: |
602 if rev and node: |
598 raise error.Abort(_("please specify just one revision")) |
603 raise error.Abort(_("please specify just one revision")) |
599 |
604 |
600 if not rev: |
605 if not rev: |
601 rev = node |
606 rev = node |