remote-hg: fix bad file paths

Mercurial allows absolute file paths, and Git doesn't like that. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed Apr 11, 2013 at 07:23 UTC 20c4b59c352529bda3f5d44baba5e393badc2ee8
1 file changed +8 -2
contrib/remote-helpers/git-remote-hg
+8 -2
@@ -205,9 +205,15 @@ class Parser:
205 tz = ((tz / 100) * 3600) + ((tz % 100) * 60)
206 return (user, int(date), -tz)
207
208 +def fix_file_path(path):
209 + if not os.path.isabs(path):
210 + return path
211 + return os.path.relpath(path, '/')
212 +
213 def export_file(fc):
214 d = fc.data()
210 - print "M %s inline %s" % (gitmode(fc.flags()), fc.path())
215 + path = fix_file_path(fc.path())
216 + print "M %s inline %s" % (gitmode(fc.flags()), path)
217 print "data %d" % len(d)
218 print d
219
@@ -401,7 +407,7 @@ def export_ref(repo, name, kind, head):
407 for f in modified:
408 export_file(c.filectx(f))
409 for f in removed:
404 - print "D %s" % (f)
410 + print "D %s" % (fix_file_path(f))
411 print
412
413 count += 1