Mercurial > hg
changeset 3862:46abbed02b2d
Use UTF-8 in .hg/branch
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Sun, 10 Dec 2006 20:35:28 -0200 |
parents | db36a4f490f6 |
children | 1ef8ada4370f |
files | mercurial/commands.py mercurial/context.py mercurial/localrepo.py mercurial/merge.py tests/test-encoding tests/test-encoding.out |
diffstat | 5 files changed, 14 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Sun Dec 10 23:03:53 2006 +0100 +++ b/mercurial/commands.py Sun Dec 10 20:35:28 2006 -0200 @@ -256,9 +256,9 @@ """ 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 @@ if not ui.quiet: - branch = repo.workingctx().branch() + branch = util.tolocal(repo.workingctx().branch()) if branch: output.append("(%s)" % branch)
--- a/mercurial/localrepo.py Sun Dec 10 23:03:53 2006 +0100 +++ b/mercurial/localrepo.py Sun Dec 10 20:35:28 2006 -0200 @@ -683,7 +683,11 @@ 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 = ""
--- a/mercurial/merge.py Sun Dec 10 23:03:53 2006 +0100 +++ b/mercurial/merge.py Sun Dec 10 20:35:28 2006 -0200 @@ -489,7 +489,6 @@ 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
--- a/tests/test-encoding Sun Dec 10 23:03:53 2006 +0100 +++ b/tests/test-encoding Sun Dec 10 20:35:28 2006 -0200 @@ -25,7 +25,7 @@ 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=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
--- a/tests/test-encoding.out Sun Dec 10 23:03:53 2006 +0100 +++ b/tests/test-encoding.out Sun Dec 10 20:35:28 2006 -0200 @@ -165,3 +165,5 @@ 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!