# HG changeset patch # User Thomas Arendsen Hein # Date 1258560540 -3600 # Node ID a1886801d4660e12bcf37da2e7b5036784faa3e5 # Parent d266aa7606ce82fa926a1d3389453d7cb7b8f200# Parent 7bb004fc14ecadc355cf5a65b9b055ffe7ef0f92 merge with crew-stable diff -r d266aa7606ce -r a1886801d466 mercurial/httprepo.py --- a/mercurial/httprepo.py Wed Nov 18 00:19:42 2009 +0100 +++ b/mercurial/httprepo.py Wed Nov 18 17:09:00 2009 +0100 @@ -154,10 +154,13 @@ for branchpart in d.splitlines(): branchheads = branchpart.split(' ') branchname = urllib.unquote(branchheads[0]) + # Earlier servers (1.3.x) send branch names in (their) local + # charset. The best we can do is assume it's identical to our + # own local charset, in case it's not utf-8. try: - branchname.decode('utf-8', 'strict') + branchname.decode('utf-8') except UnicodeDecodeError: - branchname = encoding.tolocal(branchname) + branchname = encoding.fromlocal(branchname) branchheads = [bin(x) for x in branchheads[1:]] branchmap[branchname] = branchheads return branchmap diff -r d266aa7606ce -r a1886801d466 mercurial/sshrepo.py --- a/mercurial/sshrepo.py Wed Nov 18 00:19:42 2009 +0100 +++ b/mercurial/sshrepo.py Wed Nov 18 17:09:00 2009 +0100 @@ -173,10 +173,13 @@ for branchpart in d.splitlines(): branchheads = branchpart.split(' ') branchname = urllib.unquote(branchheads[0]) + # Earlier servers (1.3.x) send branch names in (their) local + # charset. The best we can do is assume it's identical to our + # own local charset, in case it's not utf-8. try: - branchname.decode('utf-8', 'strict') + branchname.decode('utf-8') except UnicodeDecodeError: - branchname = encoding.tolocal(branchname) + branchname = encoding.fromlocal(branchname) branchheads = [bin(x) for x in branchheads[1:]] branchmap[branchname] = branchheads return branchmap diff -r d266aa7606ce -r a1886801d466 tests/test-branchmap --- a/tests/test-branchmap Wed Nov 18 00:19:42 2009 +0100 +++ b/tests/test-branchmap Wed Nov 18 17:09:00 2009 +0100 @@ -21,3 +21,38 @@ hg -R a --encoding utf-8 log kill `cat hg.pid` + + +# verify 7e7d56fe4833 (encoding fallback in branchmap to maintain compatibility with 1.3.x) + +cat < oldhg +import sys +from mercurial import ui, hg, commands + +class StdoutWrapper(object): + def __init__(self, stdout): + self._file = stdout + + def write(self, data): + if data == '47\n': + # latin1 encoding is one %xx (3 bytes) shorter + data = '44\n' + elif data.startswith('%C3%A6 '): + # translate to latin1 encoding + data = '%%E6 %s' % data[7:] + self._file.write(data) + + def __getattr__(self, name): + return getattr(self._file, name) + +sys.stdout = StdoutWrapper(sys.stdout) +sys.stderr = StdoutWrapper(sys.stderr) + +myui = ui.ui() +repo = hg.repository(myui, 'a') +commands.serve(myui, repo, stdio=True) +EOF + +echo baz >> b/foo +hg -R b ci -m baz +hg push -R b -e 'python oldhg' ssh://dummy/ --encoding latin1 diff -r d266aa7606ce -r a1886801d466 tests/test-branchmap.out --- a/tests/test-branchmap.out Wed Nov 18 00:19:42 2009 +0100 +++ b/tests/test-branchmap.out Wed Nov 18 17:09:00 2009 +0100 @@ -34,3 +34,9 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: foo +pushing to ssh://dummy/ +searching for changes +remote: adding changesets +remote: adding manifests +remote: adding file changes +remote: added 1 changesets with 1 changes to 1 files