[PATCH 1 of 1] transfer branchmap branch names over the wire in utf-8

Henrik Stuart hg at hstuart.dk
Mon Oct 26 08:31:21 CDT 2009


# HG changeset patch
# User Henrik Stuart <henrik.stuart at edlund.dk>
# Date 1256560659 -3600
# Node ID b74b5341f15d93190663b67407630fce6f04d7c4
# Parent  07a62819b3096e5c05f0b799587f0f373470e9d7
transfer branchmap branch names over the wire in utf-8

diff -r 07a62819b309 -r b74b5341f15d mercurial/localrepo.py
--- a/mercurial/localrepo.py	Fri Oct 16 00:09:18 2009 +0200
+++ b/mercurial/localrepo.py	Mon Oct 26 13:37:39 2009 +0100
@@ -369,11 +369,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:
@@ -390,18 +403,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]
@@ -1192,7 +1200,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
diff -r 07a62819b309 -r b74b5341f15d tests/test-branchmap
--- /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`
diff -r 07a62819b309 -r b74b5341f15d tests/test-branchmap.out
--- /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
+



More information about the Mercurial-devel mailing list