git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] remote-hg: unquote C-style paths when exporting
@ 2013-10-18 17:03 Antoine Pelisse
  2013-10-22 19:13 ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Antoine Pelisse @ 2013-10-18 17:03 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras, Antoine Pelisse

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 <apelisse@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-10-23 15:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-18 17:03 [PATCH] remote-hg: unquote C-style paths when exporting Antoine Pelisse
2013-10-22 19:13 ` Junio C Hamano
2013-10-22 20:49   ` Antoine Pelisse
2013-10-23  0:45     ` Felipe Contreras
2013-10-23  8:38       ` Antoine Pelisse
2013-10-23 15:44         ` Re* " Junio C Hamano
2013-10-23 15:53           ` Antoine Pelisse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).