changeset 6058:88b4d726332a

Do not abort rollback if undo.branch isn't available, but warn.
author Thomas Arendsen Hein <thomas@intevation.de>
date Sat, 09 Feb 2008 19:39:01 +0100
parents 218d5b9aa466
children d74c5e99d05b
files mercurial/localrepo.py tests/test-rollback tests/test-rollback.out
diffstat 3 files changed, 21 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sat Feb 09 19:13:57 2008 +0100
+++ b/mercurial/localrepo.py	Sat Feb 09 19:39:01 2008 +0100
@@ -579,8 +579,13 @@
                 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)
+                try:
+                    branch = self.opener("undo.branch").read()
+                    self.dirstate.setbranch(branch)
+                except IOError:
+                    self.ui.warn(_("Named branch could not be reset, "
+                                   "current branch still is: %s\n")
+                                 % util.tolocal(self.dirstate.branch()))
                 self.invalidate()
                 self.dirstate.invalidate()
             else:
--- a/tests/test-rollback	Sat Feb 09 19:13:57 2008 +0100
+++ b/tests/test-rollback	Sat Feb 09 19:39:01 2008 +0100
@@ -14,8 +14,15 @@
 hg parents
 hg status
 
-# Test issue 902
+echo % Test issue 902
 hg commit -m "test"
 hg branch test
 hg rollback
 hg branch
+
+echo % Test rollback of hg before issue 902 was fixed
+hg commit -m "test"
+hg branch test
+rm .hg/undo.branch
+hg rollback
+hg branch
--- a/tests/test-rollback.out	Sat Feb 09 19:13:57 2008 +0100
+++ b/tests/test-rollback.out	Sat Feb 09 19:39:01 2008 +0100
@@ -16,6 +16,12 @@
 checking files
 0 files, 0 changesets, 0 total revisions
 A a
+% Test issue 902
 marked working directory as branch test
 rolling back last transaction
 default
+% Test rollback of hg before issue 902 was fixed
+marked working directory as branch test
+rolling back last transaction
+Named branch could not be reset, current branch still is: test
+test