From d202200fd9daa75cdb37d4cf067d4ca00e269535 Mon Sep 17 00:00:00 2001 From: zed Date: Sun, 26 Oct 2014 20:53:20 +0300 Subject: [PATCH] Make -e option apply to imported filenames When the -e option is given, convert imported filenames just as we do for metadata and author information. --- hg-fast-export.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hg-fast-export.py b/hg-fast-export.py index b693364..0c683c5 100755 --- a/hg-fast-export.py +++ b/hg-fast-export.py @@ -122,7 +122,7 @@ def get_author(logmessage,committer,authors): return r return committer -def export_file_contents(ctx,manifest,files,hgtags): +def export_file_contents(ctx,manifest,files,hgtags,encoding=''): count=0 max=len(files) for file in files: @@ -131,7 +131,11 @@ def export_file_contents(ctx,manifest,files,hgtags): sys.stderr.write('Skip %s\n' % (file)) continue d=ctx.filectx(file).data() - wr('M %s inline %s' % (gitmode(manifest.flags(file)),file)) + if encoding: + filename=file.decode(encoding).encode('utf8') + else: + filename=file + wr('M %s inline %s' % (gitmode(manifest.flags(file)),filename)) wr('data %d' % len(d)) # had some trouble with size() wr(d) count+=1 @@ -214,9 +218,12 @@ def export_commit(ui,repo,revision,old_marks,max,count,authors,sob,brmap,hgtags, sys.stderr.write('%s: Exporting %s revision %d/%d with %d/%d/%d added/changed/removed files\n' % (branch,type,revision+1,max,len(added),len(changed),len(removed))) + if encoding: + removed=[r.decode(encoding).encode('utf8') for r in removed] + map(lambda r: wr('D %s' % r),removed) - export_file_contents(ctx,man,added,hgtags) - export_file_contents(ctx,man,changed,hgtags) + export_file_contents(ctx,man,added,hgtags,encoding) + export_file_contents(ctx,man,changed,hgtags,encoding) wr() count=checkpoint(count) -- 2.11.0