diff mercurial/dirstate.py @ 13047:6c375e07d673

branch: operate on branch names in local string space where possible Previously, branch names were ideally manipulated as UTF-8 strings, because they were stored as UTF-8 in the dirstate and the changelog and could not be safely converted to the local encoding and back. However, only about 80% of branch name code was actually using the right encoding conventions. This patch uses the localstr addition to allow working on branch names as local strings, which simplifies handling so that the previously incorrect code becomes correct.
author Matt Mackall <mpm@selenic.com>
date Wed, 24 Nov 2010 15:56:32 -0600
parents e41e2b79883d
children 6f011cf52f9a
line wrap: on
line diff
--- a/mercurial/dirstate.py	Wed Nov 24 15:38:52 2010 -0600
+++ b/mercurial/dirstate.py	Wed Nov 24 15:56:32 2010 -0600
@@ -7,7 +7,7 @@
 
 from node import nullid
 from i18n import _
-import util, ignore, osutil, parsers
+import util, ignore, osutil, parsers, encoding
 import struct, os, stat, errno
 import cStringIO
 
@@ -201,7 +201,7 @@
         return [self._validate(p) for p in self._pl]
 
     def branch(self):
-        return self._branch
+        return encoding.tolocal(self._branch)
 
     def setparents(self, p1, p2=nullid):
         self._dirty = self._dirtypl = True
@@ -210,8 +210,8 @@
     def setbranch(self, branch):
         if branch in ['tip', '.', 'null']:
             raise util.Abort(_('the name \'%s\' is reserved') % branch)
-        self._branch = branch
-        self._opener("branch", "w").write(branch + '\n')
+        self._branch = encoding.fromlocal(branch)
+        self._opener("branch", "w").write(self._branch + '\n')
 
     def _read(self):
         self._map = {}