Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
13046:7cc4263e07a9 | 13047:6c375e07d673 |
---|---|
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from node import nullid | 8 from node import nullid |
9 from i18n import _ | 9 from i18n import _ |
10 import util, ignore, osutil, parsers | 10 import util, ignore, osutil, parsers, encoding |
11 import struct, os, stat, errno | 11 import struct, os, stat, errno |
12 import cStringIO | 12 import cStringIO |
13 | 13 |
14 _format = ">cllll" | 14 _format = ">cllll" |
15 propertycache = util.propertycache | 15 propertycache = util.propertycache |
199 | 199 |
200 def parents(self): | 200 def parents(self): |
201 return [self._validate(p) for p in self._pl] | 201 return [self._validate(p) for p in self._pl] |
202 | 202 |
203 def branch(self): | 203 def branch(self): |
204 return self._branch | 204 return encoding.tolocal(self._branch) |
205 | 205 |
206 def setparents(self, p1, p2=nullid): | 206 def setparents(self, p1, p2=nullid): |
207 self._dirty = self._dirtypl = True | 207 self._dirty = self._dirtypl = True |
208 self._pl = p1, p2 | 208 self._pl = p1, p2 |
209 | 209 |
210 def setbranch(self, branch): | 210 def setbranch(self, branch): |
211 if branch in ['tip', '.', 'null']: | 211 if branch in ['tip', '.', 'null']: |
212 raise util.Abort(_('the name \'%s\' is reserved') % branch) | 212 raise util.Abort(_('the name \'%s\' is reserved') % branch) |
213 self._branch = branch | 213 self._branch = encoding.fromlocal(branch) |
214 self._opener("branch", "w").write(branch + '\n') | 214 self._opener("branch", "w").write(self._branch + '\n') |
215 | 215 |
216 def _read(self): | 216 def _read(self): |
217 self._map = {} | 217 self._map = {} |
218 self._copymap = {} | 218 self._copymap = {} |
219 try: | 219 try: |