Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 27890:ce76c4d2b85c
backout: commit changeset by default (BC)
Add --no-commit flag to prevent it. This should make the hg user
experience a little better. Some discussion can be found here:
http://markmail.org/message/7jm7ro2ias6hxywy
author | Ruslan Sayfutdinov <sayfutdinov@fb.com> |
---|---|
date | Fri, 15 Jan 2016 13:46:33 -0800 |
parents | a30b582b8be4 |
children | 2cc44efcb7cf |
comparison
equal
deleted
inserted
replaced
27889:88aa4da0cba8 | 27890:ce76c4d2b85c |
---|---|
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 |
646 hg._showstats(repo, stats) | 651 hg._showstats(repo, stats) |
647 if stats[3]: | 652 if stats[3]: |
648 repo.ui.status(_("use 'hg resolve' to retry unresolved " | 653 repo.ui.status(_("use 'hg resolve' to retry unresolved " |
649 "file merges\n")) | 654 "file merges\n")) |
650 return 1 | 655 return 1 |
651 elif not commit: | 656 elif opts.get('no_commit'): |
652 msg = _("changeset %s backed out, " | 657 msg = _("changeset %s backed out, " |
653 "don't forget to commit.\n") | 658 "don't forget to commit.\n") |
654 ui.status(msg % short(node)) | 659 ui.status(msg % short(node)) |
655 return 0 | 660 return 0 |
656 finally: | 661 finally: |