diff mercurial/commands.py @ 4207:7e1c8a565a4f

Move branch read/write to dirstate where it belongs
author Matt Mackall <mpm@selenic.com>
date Tue, 13 Mar 2007 18:50:02 -0500
parents f9bbcebcacea
children dbc3846c09a1 3be4785f8994
line wrap: on
line diff
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -255,12 +255,10 @@ def branch(ui, repo, label=None):
     current branch name.
     """
 
-    if label is not None:
-        repo.opener("branch", "w").write(util.fromlocal(label) + '\n')
+    if label:
+        repo.dirstate.setbranch(util.fromlocal(label))
     else:
-        b = util.tolocal(repo.workingctx().branch())
-        if b:
-            ui.write("%s\n" % b)
+        ui.write("%s\n" % util.tolocal(repo.dirstate.branch()))
 
 def branches(ui, repo):
     """list repository named branches