Show More
@@ -865,11 +865,22 b' def backout(ui, repo, rev, **opts):' | |||||
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 |
p |
|
868 | p1, p2 = repo.changelog.parents(node) | |
869 |
if p |
|
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) | |
@@ -2829,6 +2840,7 b' table = {' | |||||
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'))], |
@@ -60,4 +60,40 b" hg commit -d '2 0' -A -m c" | |||||
60 | hg backout -d '3 0' 1 |
|
60 | hg backout -d '3 0' 1 | |
61 | hg locate b |
|
61 | hg locate b | |
62 |
|
62 | |||
|
63 | cd .. | |||
|
64 | hg init m | |||
|
65 | cd m | |||
|
66 | echo a > a | |||
|
67 | hg commit -d '0 0' -A -m a | |||
|
68 | echo b > b | |||
|
69 | hg commit -d '1 0' -A -m b | |||
|
70 | echo c > c | |||
|
71 | hg commit -d '2 0' -A -m b | |||
|
72 | hg update 1 | |||
|
73 | echo d > d | |||
|
74 | hg commit -d '3 0' -A -m c | |||
|
75 | hg merge 2 | |||
|
76 | hg commit -d '4 0' -A -m d | |||
|
77 | ||||
|
78 | echo '# backout of merge should fail' | |||
|
79 | ||||
|
80 | hg backout 4 | |||
|
81 | ||||
|
82 | echo '# backout of merge with bad parent should fail' | |||
|
83 | ||||
|
84 | hg backout --parent 0 4 | |||
|
85 | ||||
|
86 | echo '# backout of non-merge with parent should fail' | |||
|
87 | ||||
|
88 | hg backout --parent 0 3 | |||
|
89 | ||||
|
90 | echo '# backout with valid parent should be ok' | |||
|
91 | ||||
|
92 | hg backout -d '5 0' --parent 2 4 | |||
|
93 | ||||
|
94 | hg rollback | |||
|
95 | hg update -C | |||
|
96 | ||||
|
97 | hg backout -d '6 0' --parent 3 4 | |||
|
98 | ||||
63 | exit 0 |
|
99 | exit 0 |
General Comments 0
You need to be logged in to leave comments.
Login now