Patchwork [4,of,5,v6] changelog: branchinfo is a low level function - it should return UTF-8

login
register
mail settings
Submitter Mads Kiilerich
Date Oct. 18, 2014, 6:43 p.m.
Message ID <16f60e8b47b29373d18d.1413657816@ssl.google-analytics.com>
Download mbox | patch
Permalink /patch/6411/
State Deferred
Headers show

Comments

Mads Kiilerich - Oct. 18, 2014, 6:43 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1413657752 -7200
#      Sat Oct 18 20:42:32 2014 +0200
# Node ID 16f60e8b47b29373d18d74ab35e673aef3aebfa5
# Parent  0ea7f28d7f1a2625d9729f482cbc62e30e4c5626
changelog: branchinfo is a low level function - it should return UTF-8

This will make sure we don't get encoding folding issues from the current local
encoding in the branch name cache.

(The branchmap should probably also operate on raw branch names when updating
the branch maps.)

Patch

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -369,8 +369,8 @@  class revbranchcache(object):
             self._nameslocal[branchidx] = b
             return b, close
 
-        b, close = self._repo.changelog.branchinfo(rev)
-        butf8 = encoding.fromlocal(b)
+        butf8, close = self._repo.changelog.branchinfo(rev)
+        b = encoding.tolocal(butf8)
         if butf8 in self._branchnamesindex:
             branchidx = self._branchnamesindex[butf8]
         else:
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -350,9 +350,9 @@  class changelog(revlog.revlog):
         return self.addrevision(text, transaction, len(self), p1, p2)
 
     def branchinfo(self, rev):
-        """return the branch name and open/close state of a revision
+        """return the UTF-8 branch name and open/close state of a revision
 
         This function exists because creating a changectx object
         just to access this is costly."""
         extra = self.read(rev)[5]
-        return encoding.tolocal(extra.get("branch")), 'close' in extra
+        return extra.get("branch"), 'close' in extra