diff tests/test-rollback.t @ 15131:7c26ce9edbd2

rollback: only restore dirstate and branch when appropriate. If the working dir parent was destroyed by rollback, then the old behaviour is perfectly reasonable: restore dirstate, branch, and bookmarks. That way the working dir moves back to an existing changeset rather than becoming an orphan. But if the working dir parent was unaffected -- say, you updated to an older changeset and then did rollback -- then it's silly to restore dirstate and branch. So don't do that. Leave the status of the working dir alone. (But always restore bookmarks, because that file refers to changeset IDs that may have been destroyed.)
author Greg Ward <greg@gerg.ca>
date Sun, 18 Sep 2011 19:59:33 -0400
parents 3d44e68360a6
children 59e8bc22506e
line wrap: on
line diff
--- a/tests/test-rollback.t	Fri Sep 16 21:38:06 2011 -0400
+++ b/tests/test-rollback.t	Sun Sep 18 19:59:33 2011 -0400
@@ -64,6 +64,35 @@
   $ hg branch
   test
 
+working dir unaffected by rollback: do not restore dirstate et. al.
+  $ hg log --template '{rev}  {branch}  {desc|firstline}\n'
+  0  default  add a again
+  $ hg status
+  M a
+  $ hg bookmark foo
+  $ hg commit -m'modify a again'
+  $ echo b > b
+  $ hg commit -Am'add b'
+  adding b
+  $ hg log --template '{rev}  {branch}  {desc|firstline}\n'
+  2  test  add b
+  1  test  modify a again
+  0  default  add a again
+  $ hg update default
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg bookmark bar
+  $ cat .hg/undo.branch ; echo
+  test
+  $ hg rollback
+  repository tip rolled back to revision 1 (undo commit)
+  $ hg id -n
+  0
+  $ hg branch
+  default
+  $ cat .hg/bookmarks.current ; echo
+  bar
+  $ hg bookmark --delete foo
+
 rollback by pretxncommit saves commit message (issue 1635)
 
   $ echo a >> a
@@ -102,18 +131,18 @@
   adding changesets
   adding manifests
   adding file changes
-  added 2 changesets with 2 changes to 1 files
+  added 3 changesets with 2 changes to 1 files (+1 heads)
   updating to branch default
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cd u
   $ hg id default
-  8902593132ae
+  068774709090
 
 now rollback and observe that 'hg serve' reloads the repository and
 presents the correct tip changeset:
 
   $ hg -R ../t rollback
-  repository tip rolled back to revision 0 (undo commit)
+  repository tip rolled back to revision 1 (undo commit)
   working directory now based on revision 0
   $ hg id default
-  23b0221f3370
+  791dd2169706