[PATCH 3 of 3] branch: handle non-UTF-8 locales

Dan Villiom Podlaski Christiansen danchr at gmail.com
Fri Nov 12 10:40:20 CST 2010


# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
# Date 1289579971 -3600
# Node ID bdd5ed15cd095d45dc43c43c6ea43667311b542c
# Parent  0fa148bcfe7f0755236e4b9d0034c5cc7ac4771d
branch: handle non-UTF-8 locales.

When verifying that the branch given is different from those of the
two parents, the UTF-8 encoded branch name should be used. This fixes
an edge case in non-UTF-8 locales.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -491,7 +491,7 @@ def branch(ui, repo, label=None, **opts)
         utflabel = encoding.fromlocal(label)
         if not opts.get('force'):
             if (utflabel in repo.branchtags()
-                and label not in [p.branch() for p in repo.parents()]):
+                and utflabel not in [p.branch() for p in repo.parents()]):
                 raise util.Abort(_('a branch of the same name already exists'
                                    " (use 'hg update' to switch to it)"))
             elif utflabel in repo.tags() and repo.tagtype(utflabel):
diff --git a/tests/test-newbranch.t b/tests/test-newbranch.t
--- a/tests/test-newbranch.t
+++ b/tests/test-newbranch.t
@@ -357,3 +357,13 @@ Test updating to it with various locales
   $ HGENCODING=iso-8859-1 hg up `branchname`
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
+Test merging with it:
+
+  $ hg up default
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ HGENCODING=iso-8859-1 hg merge `branchname`
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ HGENCODING=iso-8859-1 hg branch `branchname`
+  marked working directory as branch b\xf8b (esc)
+


More information about the Mercurial-devel mailing list