comparison mercurial/commands.py @ 23615:7cfe58983bff

backout: add --commit option Mercurial backout command makes a commmit by default only when the backed out revision is the parent of working directory and doesn't commit in any other case. The --commit option changes behaviour of backout to make a commit whenever possible (i.e. there is no unresolved conflicts). This behaviour seems more intuitive to many use (especially git users migrating to hg).
author Mateusz Kwapich <mitrandir@fb.com>
date Wed, 17 Dec 2014 17:26:12 -0800
parents 21446f4d5c62
children 3d4aa20b775d
comparison
equal deleted inserted replaced
23614:cd79fb4d75fd 23615:7cfe58983bff
423 archival.archive(repo, dest, node, kind, not opts.get('no_decode'), 423 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
424 matchfn, prefix, subrepos=opts.get('subrepos')) 424 matchfn, prefix, subrepos=opts.get('subrepos'))
425 425
426 @command('backout', 426 @command('backout',
427 [('', 'merge', None, _('merge with old dirstate parent after backout')), 427 [('', 'merge', None, _('merge with old dirstate parent after backout')),
428 ('', 'commit', None, _('commit if no conflicts were encountered')),
428 ('', 'parent', '', 429 ('', 'parent', '',
429 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')), 430 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
430 ('r', 'rev', '', _('revision to backout'), _('REV')), 431 ('r', 'rev', '', _('revision to backout'), _('REV')),
431 ('e', 'edit', False, _('invoke editor on commit messages')), 432 ('e', 'edit', False, _('invoke editor on commit messages')),
432 ] + mergetoolopts + walkopts + commitopts + commitopts2, 433 ] + mergetoolopts + walkopts + commitopts + commitopts2,
433 _('[OPTION]... [-r] REV')) 434 _('[OPTION]... [-r] REV'))
434 def backout(ui, repo, node=None, rev=None, **opts): 435 def backout(ui, repo, node=None, rev=None, commit=False, **opts):
435 '''reverse effect of earlier changeset 436 '''reverse effect of earlier changeset
436 437
437 Prepare a new changeset with the effect of REV undone in the 438 Prepare a new changeset with the effect of REV undone in the
438 current working directory. 439 current working directory.
439 440
517 repo.dirstate.endparentchange() 518 repo.dirstate.endparentchange()
518 hg._showstats(repo, stats) 519 hg._showstats(repo, stats)
519 if stats[3]: 520 if stats[3]:
520 repo.ui.status(_("use 'hg resolve' to retry unresolved " 521 repo.ui.status(_("use 'hg resolve' to retry unresolved "
521 "file merges\n")) 522 "file merges\n"))
522 else: 523 return 1
524 elif not commit:
523 msg = _("changeset %s backed out, " 525 msg = _("changeset %s backed out, "
524 "don't forget to commit.\n") 526 "don't forget to commit.\n")
525 ui.status(msg % short(node)) 527 ui.status(msg % short(node))
526 return stats[3] > 0 528 return 0
527 finally: 529 finally:
528 ui.setconfig('ui', 'forcemerge', '', '') 530 ui.setconfig('ui', 'forcemerge', '', '')
529 else: 531 else:
530 hg.clean(repo, node, show_stats=False) 532 hg.clean(repo, node, show_stats=False)
531 repo.dirstate.setbranch(branch) 533 repo.dirstate.setbranch(branch)