restore branch after rollback (issue 902)
authorAlexandre Vassalotti <mercurial-bugs@selenic.com>
Mon, 07 Jan 2008 15:26:12 -0600
changeset 5814 dd5a501cb97f
parent 5813 3ef279074c77
child 5815 0637d97a8cb4
restore branch after rollback (issue 902)
mercurial/localrepo.py
tests/test-hup.out
tests/test-rollback
tests/test-rollback.out
--- a/mercurial/localrepo.py	Sun Jan 06 15:40:32 2008 +0100
+++ b/mercurial/localrepo.py	Mon Jan 07 15:26:12 2008 -0600
@@ -525,9 +525,11 @@
         except IOError:
             ds = ""
         self.opener("journal.dirstate", "w").write(ds)
+        self.opener("journal.branch", "w").write(self.dirstate.branch())
 
         renames = [(self.sjoin("journal"), self.sjoin("undo")),
-                   (self.join("journal.dirstate"), self.join("undo.dirstate"))]
+                   (self.join("journal.dirstate"), self.join("undo.dirstate")),
+                   (self.join("journal.branch"), self.join("undo.branch"))]
         tr = transaction.transaction(self.ui.warn, self.sopener,
                                        self.sjoin("journal"),
                                        aftertrans(renames))
@@ -557,6 +559,8 @@
                 self.ui.status(_("rolling back last transaction\n"))
                 transaction.rollback(self.sopener, self.sjoin("undo"))
                 util.rename(self.join("undo.dirstate"), self.join("dirstate"))
+                branch = self.opener("undo.branch").read()
+                self.dirstate.setbranch(branch)
                 self.invalidate()
                 self.dirstate.invalidate()
             else:
--- a/tests/test-hup.out	Sun Jan 06 15:40:32 2008 +0100
+++ b/tests/test-hup.out	Mon Jan 07 15:26:12 2008 -0600
@@ -4,4 +4,4 @@
 transaction abort!
 rollback completed
 killed!
-.hg/00changelog.i .hg/journal.dirstate .hg/requires .hg/store .hg/store/00changelog.i .hg/store/00changelog.i.a
+.hg/00changelog.i .hg/journal.branch .hg/journal.dirstate .hg/requires .hg/store .hg/store/00changelog.i .hg/store/00changelog.i.a
--- a/tests/test-rollback	Sun Jan 06 15:40:32 2008 +0100
+++ b/tests/test-rollback	Mon Jan 07 15:26:12 2008 -0600
@@ -13,3 +13,9 @@
 hg verify
 hg parents
 hg status
+
+# Test issue 902
+hg commit -m "test"
+hg branch test
+hg rollback
+hg branch
--- a/tests/test-rollback.out	Sun Jan 06 15:40:32 2008 +0100
+++ b/tests/test-rollback.out	Mon Jan 07 15:26:12 2008 -0600
@@ -16,3 +16,6 @@
 checking files
 0 files, 0 changesets, 0 total revisions
 A a
+marked working directory as branch test
+rolling back last transaction
+default