Skip to content

Commit 20c4b59

Browse files
felipecgitster
authored andcommitted
remote-hg: fix bad file paths
Mercurial allows absolute file paths, and Git doesn't like that. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7b21ec2 commit 20c4b59

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

contrib/remote-helpers/git-remote-hg

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,15 @@ class Parser:
205205
tz = ((tz / 100) * 3600) + ((tz % 100) * 60)
206206
return (user, int(date), -tz)
207207

208+
def fix_file_path(path):
209+
if not os.path.isabs(path):
210+
return path
211+
return os.path.relpath(path, '/')
212+
208213
def export_file(fc):
209214
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)
211217
print "data %d" % len(d)
212218
print d
213219

@@ -401,7 +407,7 @@ def export_ref(repo, name, kind, head):
401407
for f in modified:
402408
export_file(c.filectx(f))
403409
for f in removed:
404-
print "D %s" % (f)
410+
print "D %s" % (fix_file_path(f))
405411
print
406412

407413
count += 1

0 commit comments

Comments
 (0)