Skip to content

Commit

Permalink
remote-hg: fix bad file paths
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Felipe Contreras authored and Junio C Hamano committed Apr 11, 2013
1 parent 7b21ec2 commit 20c4b59
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions contrib/remote-helpers/git-remote-hg
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,15 @@ class Parser:
tz = ((tz / 100) * 3600) + ((tz % 100) * 60)
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):
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 d

Expand Down Expand Up @@ -401,7 +407,7 @@ def export_ref(repo, name, kind, head):
for f in modified:
export_file(c.filectx(f))
for f in removed:
print "D %s" % (f)
print "D %s" % (fix_file_path(f))
print

count += 1
Expand Down

0 comments on commit 20c4b59

Please sign in to comment.