mercurial/commands.py
changeset 2614 8ba1c31f6864
parent 2613 479e26afa10f
child 2618 8367b67ad397
equal deleted inserted replaced
2613:479e26afa10f 2614:8ba1c31f6864
   863     bail_if_changed(repo)
   863     bail_if_changed(repo)
   864     op1, op2 = repo.dirstate.parents()
   864     op1, op2 = repo.dirstate.parents()
   865     if op2 != nullid:
   865     if op2 != nullid:
   866         raise util.Abort(_('outstanding uncommitted merge'))
   866         raise util.Abort(_('outstanding uncommitted merge'))
   867     node = repo.lookup(rev)
   867     node = repo.lookup(rev)
   868     parent, p2 = repo.changelog.parents(node)
   868     p1, p2 = repo.changelog.parents(node)
   869     if parent == nullid:
   869     if p1 == nullid:
   870         raise util.Abort(_('cannot back out a change with no parents'))
   870         raise util.Abort(_('cannot back out a change with no parents'))
   871     if p2 != nullid:
   871     if p2 != nullid:
   872         raise util.Abort(_('cannot back out a merge'))
   872         if not opts['parent']:
       
   873             raise util.Abort(_('cannot back out a merge changeset without '
       
   874                                '--parent'))
       
   875         p = repo.lookup(opts['parent'])
       
   876         if p not in (p1, p2):
       
   877             raise util.Abort(_('%s is not a parent of %s' %
       
   878                                (short(p), short(node))))
       
   879         parent = p
       
   880     else:
       
   881         if opts['parent']:
       
   882             raise util.Abort(_('cannot use --parent on non-merge changeset'))
       
   883         parent = p1
   873     repo.update(node, force=True, show_stats=False)
   884     repo.update(node, force=True, show_stats=False)
   874     revert_opts = opts.copy()
   885     revert_opts = opts.copy()
   875     revert_opts['rev'] = hex(parent)
   886     revert_opts['rev'] = hex(parent)
   876     revert(ui, repo, **revert_opts)
   887     revert(ui, repo, **revert_opts)
   877     commit_opts = opts.copy()
   888     commit_opts = opts.copy()
  2827          [('', 'merge', None,
  2838          [('', 'merge', None,
  2828            _('merge with old dirstate parent after backout')),
  2839            _('merge with old dirstate parent after backout')),
  2829           ('m', 'message', '', _('use <text> as commit message')),
  2840           ('m', 'message', '', _('use <text> as commit message')),
  2830           ('l', 'logfile', '', _('read commit message from <file>')),
  2841           ('l', 'logfile', '', _('read commit message from <file>')),
  2831           ('d', 'date', '', _('record datecode as commit date')),
  2842           ('d', 'date', '', _('record datecode as commit date')),
       
  2843           ('', 'parent', '', _('parent to choose when backing out merge')),
  2832           ('u', 'user', '', _('record user as committer')),
  2844           ('u', 'user', '', _('record user as committer')),
  2833           ('I', 'include', [], _('include names matching the given patterns')),
  2845           ('I', 'include', [], _('include names matching the given patterns')),
  2834           ('X', 'exclude', [], _('exclude names matching the given patterns'))],
  2846           ('X', 'exclude', [], _('exclude names matching the given patterns'))],
  2835          _('hg backout [OPTION]... REV')),
  2847          _('hg backout [OPTION]... REV')),
  2836     "bundle":
  2848     "bundle":