# HG changeset patch # User Alexis S. L. Carvalho # Date 2006-12-10 22:35:28 # Node ID 46abbed02b2d95b117b1ac1d2211136669714b33 # Parent db36a4f490f685e3557d2315d4c8ee078af2749f Use UTF-8 in .hg/branch diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -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) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -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 = "" diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -489,7 +489,6 @@ def update(repo, node, branchmerge, forc 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 diff --git a/tests/test-encoding b/tests/test-encoding --- a/tests/test-encoding +++ b/tests/test-encoding @@ -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 diff --git a/tests/test-encoding.out b/tests/test-encoding.out --- a/tests/test-encoding.out +++ b/tests/test-encoding.out @@ -165,3 +165,5 @@ date: Mon Jan 12 13:46:40 1970 +0 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!