mirror of
https://github.com/mnauw/git-remote-hg.git
synced 2025-11-10 21:25:40 +01:00
remote-hg: unquote C-style paths when exporting
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 results in the following situation:
- clone a mercurial repository with git
- add a file with space in a directory: `>dir/foo\ bar`
- commit that new file, and push the change to mercurial
- the mercurial repository now has a new directory named '"dir',
which contains a file named 'foo bar"'
Use Python str.decode('string-escape') to unquote the string if it
starts and ends with ". It has been tested with quotes, spaces, and
utf-8 encoded file-names.
Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Felipe Contreras
parent
c002dbbcce
commit
f7aa491f81
@@ -703,6 +703,11 @@ def get_merge_files(repo, p1, p2, files):
|
||||
f = { 'ctx' : repo[p1][e] }
|
||||
files[e] = f
|
||||
|
||||
def c_style_unescape(string):
|
||||
if string[0] == string[-1] == '"':
|
||||
return string.decode('string-escape')[1:-1]
|
||||
return string
|
||||
|
||||
def parse_commit(parser):
|
||||
from_mark = merge_mark = None
|
||||
|
||||
@@ -742,6 +747,7 @@ def parse_commit(parser):
|
||||
f = { 'deleted' : True }
|
||||
else:
|
||||
die('Unknown file command: %s' % line)
|
||||
path = c_style_unescape(path).decode('utf-8')
|
||||
files[path] = f
|
||||
|
||||
# only export the commits if we are on an internal proxy repo
|
||||
|
||||
Reference in New Issue
Block a user