# HG changeset patch # User Thomas Arendsen Hein # Date 2008-02-09 18:39:01 # Node ID 88b4d726332a1301e43d7e4285a8b44f18a187bc # Parent 218d5b9aa46637c86de577473e486233b509ecdb Do not abort rollback if undo.branch isn't available, but warn. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -579,8 +579,13 @@ class localrepository(repo.repository): 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: diff --git a/tests/test-rollback b/tests/test-rollback --- a/tests/test-rollback +++ b/tests/test-rollback @@ -14,8 +14,15 @@ hg verify 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 diff --git a/tests/test-rollback.out b/tests/test-rollback.out --- a/tests/test-rollback.out +++ b/tests/test-rollback.out @@ -16,6 +16,12 @@ crosschecking files in changesets and ma 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