hgsubversion fails when using foreign characters in the repository URL

Issue #197 resolved
Simao Mata
created an issue


hg clone fails when using a repository URL containing characters like "ç, ã" or spaces.

I am running the command:

{{{ hg clone "svn+http://url/repos/myproject/04 - Implementação (Solução em desenvolvimento)/" myproject.hg unknown exception encountered, details follow report bug details to http://mercurial.selenic.com/bts/ or mercurial@selenic.com Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] Mercurial Distributed SCM (version 1.6.1023) Extensions loaded: fixfrozenexts, svn Traceback (most recent call last): File "hg", line 36, in <module> File "mercurial\dispatch.pyo", line 16, in run File "mercurial\dispatch.pyo", line 34, in dispatch File "mercurial\dispatch.pyo", line 54, in _runcatch File "mercurial\dispatch.pyo", line 483, in _dispatch File "mercurial\dispatch.pyo", line 351, in runcommand File "mercurial\dispatch.pyo", line 534, in _runcommand File "mercurial\dispatch.pyo", line 488, in checkargs File "mercurial\dispatch.pyo", line 481, in <lambda> File "mercurial\util.pyo", line 420, in check File "mercurial\extensions.pyo", line 129, in wrap File "mercurial\util.pyo", line 420, in check File "c:\Users\Simao Mata\hgsubversion\hgsubversion\wrappers.py", line 406, in clone update=not opts.get('noupdate')) File "mercurial\hg.pyo", line 334, in clone File "mercurial\localrepo.pyo", line 1853, in clone File "c:\Users\Simao Mata\hgsubversion\hgsubversion\svnrepo.py", line 48, in wrapper return fn(self, args, opts) File "c:\Users\Simao Mata\hgsubversion\hgsubversion\svnrepo.py", line 63, in pull return wrappers.pull(self, remote, heads, force) File "c:\Users\Simao Mata\hgsubversion\hgsubversion\wrappers.py", line 223, in pull svn = source.svn File "mercurial\util.pyo", line 163, in get File "c:\Users\Simao Mata\hgsubversion\hgsubversion\svnrepo.py", line 103, in svn return svnwrap.SubversionRepo(self.svnauth) File "c:\Users\Simao Mata\hgsubversion\hgsubversion\svnwrap\svn_swig_wrapper.py", line 224, in init self.init_ra_and_client() File "c:\Users\Simao Mata\hgsubversion\hgsubversion\svnwrap\svn_swig_wrapper.py", line 255, in init_ra_and_client url = self.svn_url.encode('utf-8') UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 56: ordinal not in range(128) }}}

Comments (14)

  1. Simao Mata reporter


    Thanks for your patch Dan.

    Your patch worked, but one of the files referenced in the patch is not under version control (svnwrap/subvertpy_wrapper.py)

    hgsubversion is working now.

    Thank you!

  2. Dan Villiom Podlaski Christiansen

    You're right; those weren't handled properly. They weren't before either, but I managed to fix it :-)

    It seems to me the call to str.encode() didn't do what you wanted it to do. AFAICT it encodes the string as a Unicode object using the default encoding — often ASCII — and then decodes it as a bytestring. This had no effect on URI-encoded bytestrings. Such strings would be passed to Subversion correctly, but they would break conversion when the editor received the decoded paths. Always decoding the URL fixes this.

    I've attached an updated patch; it tests both scenarios.

  3. Dominik Guder


    I also get wired checkout if there are unicode chars in file names not just the url. I tried the diff above but it didn't solve my issue

    A German "weiß" (color white) will become "weiß" in file system and 'weic39f' (with tilde before c3 and 9f) in .hg\store\data folder.

    I'm using TortoiseHg 1.1.3 with hg 1.6.3 on Windows XP Pro 32bit. Maybe you can give me a hint where to look at, since I'm not be able to debug hgsubversion on windows with WinPdb 1.4.8

    Thanks so far Dominik

  4. Log in to comment