diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -177,10 +177,8 @@ def backout(ui, repo, node=None, rev=Non changeset is a child of the backed out changeset. If you back out a changeset other than the tip, a new head is - created. This head is the parent of the working directory. If - you back out an old changeset, your working directory will appear - old after the backout. You should merge the backout changeset - with another head. + created. This head will be the new tip and you should merge this + backout changeset with another head (current one by default). The --merge option remembers the parent of the working directory before starting the backout, then merges the new head with that @@ -243,9 +241,10 @@ def backout(ui, repo, node=None, rev=Non ui.status(_('changeset %s backs out changeset %s\n') % (nice(repo.changelog.tip()), nice(node))) if op1 != node: + hg.clean(repo, op1, show_stats=False) if opts['merge']: - ui.status(_('merging with changeset %s\n') % nice(op1)) - hg.merge(repo, hex(op1)) + ui.status(_('merging with changeset %s\n') % nice(repo.changelog.tip())) + hg.merge(repo, hex(repo.changelog.tip())) else: ui.status(_('the backout changeset is a new head - ' 'do not forget to merge\n')) diff --git a/tests/test-backout b/tests/test-backout --- a/tests/test-backout +++ b/tests/test-backout @@ -59,9 +59,10 @@ hg init merge cd merge echo line 1 > a +echo line 2 >> a hg commit -d '0 0' -A -m a - -echo line 2 >> a +# remove line 1 +echo line 2 > a hg commit -d '1 0' -m b echo line 3 >> a @@ -69,6 +70,7 @@ hg commit -d '2 0' -m c hg backout --merge -d '3 0' 1 hg commit -d '4 0' -m d +# check line 1 is back cat a echo '# backout should not back out subsequent changesets' @@ -82,6 +84,8 @@ echo 1 > b hg commit -d '2 0' -A -m c hg backout -d '3 0' 1 hg locate b +hg update -C tip +hg locate b cd .. hg init m diff --git a/tests/test-backout.out b/tests/test-backout.out --- a/tests/test-backout.out +++ b/tests/test-backout.out @@ -25,12 +25,14 @@ abort: cannot back out change on a diffe # backout with merge adding a reverting a -changeset 3:3eb045e364a4 backs out changeset 1:314f55b1bf23 -merging with changeset 2:b66ea5b77abb +changeset 3:26b8ccb9ad91 backs out changeset 1:5a50a024c182 +merging with changeset 3:26b8ccb9ad91 merging a 0 files updated, 1 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) line 1 +line 2 +line 3 # backout should not back out subsequent changesets adding a adding b @@ -38,6 +40,8 @@ reverting a changeset 3:3202beb76721 backs out changeset 1:22bca4c721e5 the backout changeset is a new head - do not forget to merge (use "backout --merge" if you want to auto-merge) +b +1 files updated, 0 files merged, 1 files removed, 0 files unresolved adding a adding b adding c diff --git a/tests/test-parse-date.out b/tests/test-parse-date.out --- a/tests/test-parse-date.out +++ b/tests/test-parse-date.out @@ -1,6 +1,6 @@ reverting a changeset 3:107ce1ee2b43 backs out changeset 1:25a1420a55f8 -merging with changeset 2:e6c3abc120e7 +merging with changeset 3:107ce1ee2b43 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) abort: invalid date: 'should fail'