transfer branchmap branch names over the wire in utf-8
authorHenrik Stuart <henrik.stuart@edlund.dk>
Mon, 26 Oct 2009 13:37:39 +0100
changeset 9671 9471d9a900b4
parent 9670 7d56b6ffef72
child 9672 5bbf4f130684
transfer branchmap branch names over the wire in utf-8
mercurial/localrepo.py
tests/test-branchmap
tests/test-branchmap.out
--- a/mercurial/localrepo.py	Fri Oct 30 13:40:23 2009 +0200
+++ b/mercurial/localrepo.py	Mon Oct 26 13:37:39 2009 +0100
@@ -319,11 +319,24 @@
 
         return partial
 
-    def branchmap(self):
+    def lbranchmap(self):
         tip = self.changelog.tip()
         if self.branchcache is not None and self._branchcachetip == tip:
             return self.branchcache
 
+        partial = self.branchmap()
+
+        # the branch cache is stored on disk as UTF-8, but in the local
+        # charset internally
+        for k, v in partial.iteritems():
+            self.branchcache[encoding.tolocal(k)] = v
+        return self.branchcache
+
+    def branchmap(self):
+        tip = self.changelog.tip()
+        if self._ubranchcache is not None and self._branchcachetip == tip:
+            return self._ubranchcache
+
         oldtip = self._branchcachetip
         self._branchcachetip = tip
         if self.branchcache is None:
@@ -340,18 +353,13 @@
         # this private cache holds all heads (not just tips)
         self._ubranchcache = partial
 
-        # the branch cache is stored on disk as UTF-8, but in the local
-        # charset internally
-        for k, v in partial.iteritems():
-            self.branchcache[encoding.tolocal(k)] = v
-        return self.branchcache
-
+        return self._ubranchcache
 
     def branchtags(self):
         '''return a dict where branch names map to the tipmost head of
         the branch, open heads come before closed'''
         bt = {}
-        for bn, heads in self.branchmap().iteritems():
+        for bn, heads in self.lbranchmap().iteritems():
             head = None
             for i in range(len(heads)-1, -1, -1):
                 h = heads[i]
@@ -1168,7 +1176,7 @@
         '''
         if branch is None:
             branch = self[None].branch()
-        branches = self.branchmap()
+        branches = self.lbranchmap()
         if branch not in branches:
             return []
         # the cache returns heads ordered lowest to highest
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-branchmap	Mon Oct 26 13:37:39 2009 +0100
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+hgserve()
+{
+    hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid -E errors.log -v $@ \
+        | sed -e 's/:[0-9][0-9]*//g' -e 's/http:\/\/[^/]*\//http:\/\/localhost\//'
+    cat hg.pid >> "$DAEMON_PIDS"
+}
+
+hg init a
+hg --encoding utf-8 -R a branch æ
+echo foo > a/foo
+hg -R a ci -Am foo
+
+hgserve -R a --config web.push_ssl=False --config web.allow_push=* --encoding latin1
+hg clone http://localhost:$HGPORT1 b
+hg --encoding utf-8 -R b log
+echo bar >> b/foo
+hg -R b ci -m bar
+hg --encoding utf-8 -R b push | sed "s/$HGPORT1/PORT/"
+hg -R a --encoding utf-8 log
+
+kill `cat hg.pid`
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-branchmap.out	Mon Oct 26 13:37:39 2009 +0100
@@ -0,0 +1,36 @@
+marked working directory as branch æ
+adding foo
+listening at http://localhost/ (bound to 127.0.0.1)
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+updating working directory
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+changeset:   0:867c11ce77b8
+branch:      æ
+tag:         tip
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     foo
+
+pushing to http://localhost:PORT
+searching for changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+changeset:   1:58e7c90d67cb
+branch:      æ
+tag:         tip
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     bar
+
+changeset:   0:867c11ce77b8
+branch:      æ
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     foo
+