In some locales Mercurial uses different encodings for commit messages
and file names. The --fe option allows the filename encoding to be
overridden.
When a mercurial repository does not use utf-8 for encoding author
strings and commit messages the "-e <encoding>" command line option
can be used to force fast-export to convert incoming meta data from
When a mercurial repository does not use utf-8 for encoding author
strings and commit messages the "-e <encoding>" command line option
can be used to force fast-export to convert incoming meta data from
+<encoding> to utf-8. This encoding option is also applied to file names.
+
+In some locales Mercurial uses different encodings for commit messages
+and file names. In that case, you can use "--fe <encoding>" command line
+option which overrides the -e option for file names.
As mercurial appears to be much less picky about the syntax of the
author information than git, an author mapping file can be given to
As mercurial appears to be much less picky about the syntax of the
author information than git, an author mapping file can be given to
return filename
def export_commit(ui,repo,revision,old_marks,max,count,authors,
return filename
def export_commit(ui,repo,revision,old_marks,max,count,authors,
- branchesmap,sob,brmap,hgtags,notes,encoding=''):
+ branchesmap,sob,brmap,hgtags,notes,encoding='',fn_encoding=''):
def get_branchname(name):
if brmap.has_key(name):
return brmap[name]
def get_branchname(name):
if brmap.has_key(name):
return brmap[name]
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)))
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]
+ if fn_encoding:
+ removed=[r.decode(fn_encoding).encode('utf8') for r in removed]
removed=[strip_leading_slash(x) for x in removed]
map(lambda r: wr('D %s' % r),removed)
removed=[strip_leading_slash(x) for x in removed]
map(lambda r: wr('D %s' % r),removed)
- export_file_contents(ctx,man,added,hgtags,encoding)
- export_file_contents(ctx,man,changed,hgtags,encoding)
+ export_file_contents(ctx,man,added,hgtags,fn_encoding)
+ export_file_contents(ctx,man,changed,hgtags,fn_encoding)
wr()
count=checkpoint(count)
wr()
count=checkpoint(count)
def hg2git(repourl,m,marksfile,mappingfile,headsfile,tipfile,
authors={},branchesmap={},tagsmap={},
def hg2git(repourl,m,marksfile,mappingfile,headsfile,tipfile,
authors={},branchesmap={},tagsmap={},
- sob=False,force=False,hgtags=False,notes=False,encoding=''):
+ sob=False,force=False,hgtags=False,notes=False,encoding='',fn_encoding=''):
_max=int(m)
old_marks=load_cache(marksfile,lambda s: int(s)-1)
_max=int(m)
old_marks=load_cache(marksfile,lambda s: int(s)-1)
brmap={}
for rev in range(min,max):
c=export_commit(ui,repo,rev,old_marks,max,c,authors,branchesmap,
brmap={}
for rev in range(min,max):
c=export_commit(ui,repo,rev,old_marks,max,c,authors,branchesmap,
- sob,brmap,hgtags,notes,encoding)
+ sob,brmap,hgtags,notes,encoding,fn_encoding)
state_cache['tip']=max
state_cache['repo']=repourl
state_cache['tip']=max
state_cache['repo']=repourl
default=False,help="Annotate commits with the hg hash as git notes in the hg namespace")
parser.add_option("-e",dest="encoding",
help="Assume commit and author strings retrieved from Mercurial are encoded in <encoding>")
default=False,help="Annotate commits with the hg hash as git notes in the hg namespace")
parser.add_option("-e",dest="encoding",
help="Assume commit and author strings retrieved from Mercurial are encoded in <encoding>")
+ parser.add_option("--fe",dest="fn_encoding",
+ help="Assume file names from Mercurial are encoded in <filename_encoding>")
(options,args)=parser.parse_args()
(options,args)=parser.parse_args()
if options.encoding!=None:
encoding=options.encoding
if options.encoding!=None:
encoding=options.encoding
+ fn_encoding=encoding
+ if options.fn_encoding!=None:
+ fn_encoding=options.fn_encoding
+
sys.exit(hg2git(options.repourl,m,options.marksfile,options.mappingfile,
options.headsfile, options.statusfile,
authors=a,branchesmap=b,tagsmap=t,
sob=options.sob,force=options.force,hgtags=options.hgtags,
sys.exit(hg2git(options.repourl,m,options.marksfile,options.mappingfile,
options.headsfile, options.statusfile,
authors=a,branchesmap=b,tagsmap=t,
sob=options.sob,force=options.force,hgtags=options.hgtags,
- notes=options.notes,encoding=encoding))
+ notes=options.notes,encoding=encoding,fn_encoding=fn_encoding))
hg namespace.
-e <encoding> Assume commit and author strings retrieved from
Mercurial are encoded in <encoding>
hg namespace.
-e <encoding> Assume commit and author strings retrieved from
Mercurial are encoded in <encoding>
+ --fe <filename_encoding> Assume filenames from Mercurial are encoded
+ in <filename_encoding>
"
case "$1" in
-h|--help)
"
case "$1" in
-h|--help)