Skip to content
This repository was archived by the owner on May 16, 2024. It is now read-only.

Commit 1181a0a

Browse files
committed
Allow name sanitizer to be disabled with --no-auto-sanitize
Make it possible to completely disable the name sanitizer by the --no-auto-sanitize flag. Previously the sanitizer was run on user remapped names. As the sanitizer rewrites perfectly legal git names (such as __.*) this is probably not what the user wants. Closes frej#155.
1 parent 7ab47e0 commit 1181a0a

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ name the -B and -T options allow a mapping file to be specified to
101101
rename branches and tags (respectively). The syntax of the mapping
102102
file is the same as for the author mapping.
103103

104+
When the -B and -T flags are used, you will probably want to use the
105+
-n flag to disable the built-in (broken in many cases) sanitizing of
106+
branch/tag names. In the future -n will become the default, but in
107+
order to not break existing incremental conversions, the default
108+
remains with the old behavior.
109+
104110
Content filtering
105111
-----------------
106112

hg-fast-export.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
subrepo_cache={}
3232
submodule_mappings=None
3333

34+
# True if fast export should automatically try to sanitize
35+
# author/branch/tag names.
36+
auto_sanitize = None
37+
3438
def gitmode(flags):
3539
return 'l' in flags and '120000' or 'x' in flags and '100755' or '100644'
3640

@@ -226,6 +230,8 @@ def dot(name):
226230
if name[0] == '.': return '_'+name[1:]
227231
return name
228232

233+
if not auto_sanitize:
234+
return mapping.get(name,name)
229235
n=mapping.get(name,name)
230236
p=re.compile('([[ ~^:?\\\\*]|\.\.)')
231237
n=p.sub('_', n)
@@ -532,6 +538,9 @@ def bail(parser,opt):
532538

533539
parser=OptionParser()
534540

541+
parser.add_option("-n", "--no-auto-sanitize",action="store_false",
542+
dest="auto_sanitize",default=True,
543+
help="Do not perform built-in (broken in many cases) sanitizing of names")
535544
parser.add_option("-m","--max",type="int",dest="max",
536545
help="Maximum hg revision to import")
537546
parser.add_option("--mapping",dest="mappingfile",
@@ -580,6 +589,7 @@ def bail(parser,opt):
580589
(options,args)=parser.parse_args()
581590

582591
m=-1
592+
auto_sanitize = options.auto_sanitize
583593
if options.max!=None: m=options.max
584594

585595
if options.marksfile==None: bail(parser,'--marks')

hg-fast-export.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Options:
7070
-B <file> Read branch map from file
7171
-T <file> Read tags map from file
7272
-M <name> Set the default branch name (defaults to 'master')
73+
-n Do not perform built-in (broken in many cases) sanitizing
74+
of branch/tag names.
7375
-o <name> Use <name> as branch namespace to track upstream (eg 'origin')
7476
--hg-hash Annotate commits with the hg hash as git notes in the
7577
hg namespace.

0 commit comments

Comments
 (0)