From: Antoine Pelisse Date: Fri, 18 Oct 2013 17:03:41 GMT Subject: [PATCH] remote-hg: unquote C-style paths when exporting Message-ID: <1382115821-12586-1-git-send-email-apelisse@gmail.com> git-fast-import documentation says that paths can be C-style quoted. Unfortunately, the current remote-hg helper doesn't unquote quoted path and pass them as-is to Mercurial when the commit is created. This result in the following situation: - clone a mercurial repository with git - Add a file with space: `mkdir dir/foo\ bar` - Commit that new file, and push the change to mercurial - The mercurial repository as now a new directory named '"dir', which contains a file named 'foo bar"' Use python ast.literal_eval to unquote the string if it starts with ". It has been tested with quotes, spaces, and utf-8 encoded file-names. Signed-off-by: Antoine Pelisse --- contrib/remote-helpers/git-remote-hg | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg index 92d994e..0141949 100755 --- a/contrib/remote-helpers/git-remote-hg +++ b/contrib/remote-helpers/git-remote-hg @@ -14,6 +14,7 @@ from mercurial import hg, ui, bookmarks, context, encoding, node, error, extensions, discovery, util +import ast import re import sys import os @@ -742,6 +743,8 @@ def parse_commit(parser): f = { 'deleted' : True } else: die('Unknown file command: %s' % line) + if path.startswith('"'): + path = ast.literal_eval(path) files[path] = f # only export the commits if we are on an internal proxy repo -- 1.8.4.1.507.g9768648.dirty