avoid a traceback with hg branch newbranch; hg up
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Fri, 16 Mar 2007 00:22:59 -0300
changeset 4231 83153299aab5
parent 4230 c93562fb12cc
child 4232 0d51eb296fb9
child 4238 ce6c364ebb2a
avoid a traceback with hg branch newbranch; hg up
mercurial/commands.py
tests/test-newbranch
tests/test-newbranch.out
--- a/mercurial/commands.py	Fri Mar 16 00:22:58 2007 -0300
+++ b/mercurial/commands.py	Fri Mar 16 00:22:59 2007 -0300
@@ -2563,7 +2563,10 @@
             node = repo.lookup(node)
         else:
             wc = repo.workingctx()
-            node = repo.branchtags()[wc.branch()]
+            try:
+                node = repo.branchtags()[wc.branch()]
+            except KeyError:
+                raise util.Abort(_("branch %s not found") % wc.branch())
     return node
 
 def verify(ui, repo):
--- a/tests/test-newbranch	Fri Mar 16 00:22:58 2007 -0300
+++ b/tests/test-newbranch	Fri Mar 16 00:22:59 2007 -0300
@@ -46,3 +46,7 @@
 hg up -q 1
 hg up -q
 hg id
+hg branch foobar
+hg up
+
+exit 0
--- a/tests/test-newbranch.out	Fri Mar 16 00:22:58 2007 -0300
+++ b/tests/test-newbranch.out	Fri Mar 16 00:22:59 2007 -0300
@@ -81,3 +81,4 @@
 % update with no arguments: tipmost revision of the current branch
 bf1bc2f45e83
 4909a3732169 (foo) tip
+abort: branch foobar not found