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>
This commit is contained in:
Felipe Contreras 2013-04-11 07:23:16 -05:00 committed by Junio C Hamano
parent 7b21ec24a5
commit 20c4b59c35

View File

@ -205,9 +205,15 @@ class Parser:
tz = ((tz / 100) * 3600) + ((tz % 100) * 60) tz = ((tz / 100) * 3600) + ((tz % 100) * 60)
return (user, int(date), -tz) return (user, int(date), -tz)
def fix_file_path(path):
if not os.path.isabs(path):
return path
return os.path.relpath(path, '/')
def export_file(fc): def export_file(fc):
d = fc.data() d = fc.data()
print "M %s inline %s" % (gitmode(fc.flags()), fc.path()) path = fix_file_path(fc.path())
print "M %s inline %s" % (gitmode(fc.flags()), path)
print "data %d" % len(d) print "data %d" % len(d)
print d print d
@ -401,7 +407,7 @@ def export_ref(repo, name, kind, head):
for f in modified: for f in modified:
export_file(c.filectx(f)) export_file(c.filectx(f))
for f in removed: for f in removed:
print "D %s" % (f) print "D %s" % (fix_file_path(f))
print print
count += 1 count += 1