Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 2614:8ba1c31f6864
backout: allow backout of merge changeset with --parent option.
--parent allows to choose which parent of merge to revert to.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Fri, 14 Jul 2006 23:19:15 -0700 |
parents | 479e26afa10f |
children | 8367b67ad397 |
line wrap: on
line diff
--- a/mercurial/commands.py Fri Jul 14 14:51:36 2006 -0700 +++ b/mercurial/commands.py Fri Jul 14 23:19:15 2006 -0700 @@ -865,11 +865,22 @@ if op2 != nullid: raise util.Abort(_('outstanding uncommitted merge')) node = repo.lookup(rev) - parent, p2 = repo.changelog.parents(node) - if parent == nullid: + p1, p2 = repo.changelog.parents(node) + if p1 == nullid: raise util.Abort(_('cannot back out a change with no parents')) if p2 != nullid: - raise util.Abort(_('cannot back out a merge')) + if not opts['parent']: + raise util.Abort(_('cannot back out a merge changeset without ' + '--parent')) + p = repo.lookup(opts['parent']) + if p not in (p1, p2): + raise util.Abort(_('%s is not a parent of %s' % + (short(p), short(node)))) + parent = p + else: + if opts['parent']: + raise util.Abort(_('cannot use --parent on non-merge changeset')) + parent = p1 repo.update(node, force=True, show_stats=False) revert_opts = opts.copy() revert_opts['rev'] = hex(parent) @@ -2829,6 +2840,7 @@ ('m', 'message', '', _('use <text> as commit message')), ('l', 'logfile', '', _('read commit message from <file>')), ('d', 'date', '', _('record datecode as commit date')), + ('', 'parent', '', _('parent to choose when backing out merge')), ('u', 'user', '', _('record user as committer')), ('I', 'include', [], _('include names matching the given patterns')), ('X', 'exclude', [], _('exclude names matching the given patterns'))],