[PATCH] transfer branchmap branch names over the wire in utf-8
Henrik Stuart
hg at hstuart.dk
Mon Oct 26 10:26:58 UTC 2009
# HG changeset patch
# User Henrik Stuart <henrik.stuart at edlund.dk>
# Date 1256552644 -3600
# Node ID 02987e66bc417e0522a05d8aa8076ad09648d377
# Parent 07a62819b3096e5c05f0b799587f0f373470e9d7
transfer branchmap branch names over the wire in utf-8
diff -r 07a62819b309 -r 02987e66bc41 mercurial/hgweb/protocol.py
--- a/mercurial/hgweb/protocol.py Fri Oct 16 00:09:18 2009 +0200
+++ b/mercurial/hgweb/protocol.py Mon Oct 26 11:24:04 2009 +0100
@@ -9,6 +9,7 @@
from mercurial import util, streamclone
from mercurial.node import bin, hex
from mercurial import changegroup as changegroupmod
+from mercurial.encoding import fromlocal
from common import ErrorResponse, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
# __all__ is populated with the allowed commands. Be sure to add to it if
@@ -42,7 +43,7 @@
branches = repo.branchmap()
heads = []
for branch, nodes in branches.iteritems():
- branchname = urllib.quote(branch)
+ branchname = urllib.quote(fromlocal(branch))
branchnodes = [hex(node) for node in nodes]
heads.append('%s %s' % (branchname, ' '.join(branchnodes)))
resp = '\n'.join(heads)
diff -r 07a62819b309 -r 02987e66bc41 mercurial/httprepo.py
--- a/mercurial/httprepo.py Fri Oct 16 00:09:18 2009 +0200
+++ b/mercurial/httprepo.py Mon Oct 26 11:24:04 2009 +0100
@@ -8,6 +8,7 @@
from node import bin, hex, nullid
from i18n import _
+from encoding import tolocal
import repo, changegroup, statichttprepo, error, url, util
import os, urllib, urllib2, urlparse, zlib, httplib
import errno, socket
@@ -151,7 +152,7 @@
branchmap = {}
for branchpart in d.splitlines():
branchheads = branchpart.split(' ')
- branchname = urllib.unquote(branchheads[0])
+ branchname = tolocal(urllib.unquote(branchheads[0]))
branchheads = [bin(x) for x in branchheads[1:]]
branchmap[branchname] = branchheads
return branchmap
diff -r 07a62819b309 -r 02987e66bc41 mercurial/sshrepo.py
--- a/mercurial/sshrepo.py Fri Oct 16 00:09:18 2009 +0200
+++ b/mercurial/sshrepo.py Mon Oct 26 11:24:04 2009 +0100
@@ -7,6 +7,7 @@
from node import bin, hex
from i18n import _
+from encoding import tolocal
import repo, util, error
import re, urllib
@@ -172,7 +173,7 @@
branchmap = {}
for branchpart in d.splitlines():
branchheads = branchpart.split(' ')
- branchname = urllib.unquote(branchheads[0])
+ branchname = tolocal(urllib.unquote(branchheads[0]))
branchheads = [bin(x) for x in branchheads[1:]]
branchmap[branchname] = branchheads
return branchmap
diff -r 07a62819b309 -r 02987e66bc41 mercurial/sshserver.py
--- a/mercurial/sshserver.py Fri Oct 16 00:09:18 2009 +0200
+++ b/mercurial/sshserver.py Mon Oct 26 11:24:04 2009 +0100
@@ -8,6 +8,7 @@
from i18n import _
from node import bin, hex
+from encoding import fromlocal
import streamclone, util, hook
import os, sys, tempfile, urllib
@@ -68,7 +69,7 @@
branchmap = self.repo.branchmap()
heads = []
for branch, nodes in branchmap.iteritems():
- branchname = urllib.quote(branch)
+ branchname = fromlocal(urllib.quote(branch))
branchnodes = [hex(node) for node in nodes]
heads.append('%s %s' % (branchname, ' '.join(branchnodes)))
self.respond('\n'.join(heads))
diff -r 07a62819b309 -r 02987e66bc41 tests/test-branchmap
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-branchmap Mon Oct 26 11:24:04 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
+hg -R a --encoding utf-8 log
+
+kill `cat hg.pid`
diff -r 07a62819b309 -r 02987e66bc41 tests/test-branchmap.out
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-branchmap.out Mon Oct 26 11:24:04 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:20060
+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