[PATCH in crew-stable] subrepo: encode unicode path names (issue3610)

Bryan O'Sullivan bos at serpentine.com
Tue Sep 4 17:47:00 CDT 2012

# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1346798764 25200
# Branch stable
# Node ID cb12d3ce56072c55ad011e806d781873dc2cfe61
# Parent  0cec762790ed34c469ce67b8ca8223545c57e148
subrepo: encode unicode path names (issue3610)

Subversion 1.7 changes its XML output to include an explicit encoding tag:

  <?xml version="1.0" encoding="UTF-8"?>

This triggers xml.dom.minidom to always return unicode strings, causing
other parts of the code to explode.

We unconditionally encode path names before handing them back, which
works with both str (actually a no-op) and unicode values.

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -838,7 +838,7 @@
             name = ''.join(c.data for c
                            in e.getElementsByTagName('name')[0].childNodes
                            if c.nodeType == c.TEXT_NODE)
-            paths.append(name)
+            paths.append(name.encode('utf-8'))
         return paths
     def filedata(self, name):

More information about the Mercurial-devel mailing list