Use UTF-8 in .hg/branch

This commit is contained in:
Alexis S. L. Carvalho 2006-12-10 20:35:28 -02:00
parent ff6b40fc67
commit 63ae667098
5 changed files with 14 additions and 6 deletions

View File

@ -256,9 +256,9 @@ def branch(ui, repo, label=None):
"""
if label is not None:
repo.opener("branch", "w").write(label)
repo.opener("branch", "w").write(util.fromlocal(label) + '\n')
else:
b = repo.workingctx().branch()
b = util.tolocal(repo.workingctx().branch())
if b:
ui.write("%s\n" % b)
@ -1433,7 +1433,7 @@ def identify(ui, repo):
if not ui.quiet:
branch = repo.workingctx().branch()
branch = util.tolocal(repo.workingctx().branch())
if branch:
output.append("(%s)" % branch)

View File

@ -683,7 +683,11 @@ class localrepository(repo.repository):
m2 = self.manifest.read(c2[0])
if use_dirstate:
branchname = util.fromlocal(self.workingctx().branch())
branchname = self.workingctx().branch()
try:
branchname = branchname.decode('UTF-8').encode('UTF-8')
except UnicodeDecodeError:
raise util.Abort(_('branch name not in UTF-8!'))
else:
branchname = ""

View File

@ -489,7 +489,6 @@ def update(repo, node, branchmerge, force, partial, wlock):
repo.dirstate.setparents(fp1, fp2)
repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3])
if not branchmerge:
b = util.tolocal(p2.branch())
repo.opener("branch", "w").write(p2.branch() + "\n")
return stats

View File

@ -25,7 +25,7 @@ echo "utf-8" > a
HGENCODING=utf-8 hg ci -l utf-8 -d "1000000 0"
HGENCODING=latin-1 hg tag -d "1000000 0" `cat latin-1-tag`
cp latin-1-tag .hg/branch
HGENCODING=latin-1 hg branch `cat latin-1-tag`
HGENCODING=latin-1 hg ci -d "1000000 0" -m 'latin1 branch'
rm .hg/branch
@ -55,4 +55,7 @@ HGENCODING=utf-8 hg log
HGENCODING=dolphin hg log
HGENCODING=ascii hg branch `cat latin-1-tag`
cp latin-1-tag .hg/branch
HGENCODING=latin-1 hg ci -d "1000000 0" -m 'should fail'
exit 0

View File

@ -165,3 +165,5 @@ date: Mon Jan 12 13:46:40 1970 +0000
summary: latin-1 e': И = u'\xe9'
abort: unknown encoding: dolphin, please check your locale settings
abort: decoding near 'é': 'ascii' codec can't decode byte 0xe9 in position 0: ordinal not in range(128)!
abort: branch name not in UTF-8!