diff --git a/README.md b/README.md index 3329b7d0..0a5673bd 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,12 @@ name the -B and -T options allow a mapping file to be specified to rename branches and tags (respectively). The syntax of the mapping file is the same as for the author mapping. +When the -B and -T flags are used, you will probably want to use the +-n flag to disable the built-in (broken in many cases) sanitizing of +branch/tag names. In the future -n will become the default, but in +order to not break existing incremental conversions, the default +remains with the old behavior. + Content filtering ----------------- diff --git a/hg-fast-export.py b/hg-fast-export.py index 72d9c7fa..4709276c 100755 --- a/hg-fast-export.py +++ b/hg-fast-export.py @@ -31,6 +31,10 @@ subrepo_cache={} submodule_mappings=None +# True if fast export should automatically try to sanitize +# author/branch/tag names. +auto_sanitize = None + def gitmode(flags): return 'l' in flags and '120000' or 'x' in flags and '100755' or '100644' @@ -226,6 +230,8 @@ def dot(name): if name[0] == '.': return '_'+name[1:] return name + if not auto_sanitize: + return mapping.get(name,name) n=mapping.get(name,name) p=re.compile('([[ ~^:?\\\\*]|\.\.)') n=p.sub('_', n) @@ -532,6 +538,9 @@ def bail(parser,opt): parser=OptionParser() + parser.add_option("-n", "--no-auto-sanitize",action="store_false", + dest="auto_sanitize",default=True, + help="Do not perform built-in (broken in many cases) sanitizing of names") parser.add_option("-m","--max",type="int",dest="max", help="Maximum hg revision to import") parser.add_option("--mapping",dest="mappingfile", @@ -580,6 +589,7 @@ def bail(parser,opt): (options,args)=parser.parse_args() m=-1 + auto_sanitize = options.auto_sanitize if options.max!=None: m=options.max if options.marksfile==None: bail(parser,'--marks') diff --git a/hg-fast-export.sh b/hg-fast-export.sh index a4cb90e3..e1f2f508 100755 --- a/hg-fast-export.sh +++ b/hg-fast-export.sh @@ -70,6 +70,8 @@ Options: -B Read branch map from file -T Read tags map from file -M Set the default branch name (defaults to 'master') + -n Do not perform built-in (broken in many cases) sanitizing + of branch/tag names. -o Use as branch namespace to track upstream (eg 'origin') --hg-hash Annotate commits with the hg hash as git notes in the hg namespace.