From: Kyle J. McKay Date: Sat, 15 Mar 2014 23:48:10 +0000 (-0700) Subject: hg-fast-export.py: improve authors file compatibility X-Git-Url: http://crossforests.com/gitweb?a=commitdiff_plain;h=8822aa34e9647fa8f73b0f4a2509a0268d0b0078;p=python%2Ffast-export.git hg-fast-export.py: improve authors file compatibility The authors file format accepted by git-svnimport and git-cvsimport actually allows blank lines and comment lines that start with '#'. Ignore blank lines and lines starting with '#' as the first non-whitespace character to be compatible with the authors file format accepted by the referenced tools. --- diff --git a/hg-fast-export.py b/hg-fast-export.py index 0ce14a6..18bf9a0 100755 --- a/hg-fast-export.py +++ b/hg-fast-export.py @@ -255,17 +255,22 @@ def load_authors(filename): return cache f=open(filename,'r') l=0 + a=0 lre=re.compile('^([^=]+)[ ]*=[ ]*(.+)$') for line in f.readlines(): l+=1 + line=line.strip() + if line=='' or line[0]=='#': + continue m=lre.match(line) if m==None: sys.stderr.write('Invalid file format in [%s], line %d\n' % (filename,l)) continue # put key:value in cache, key without ^: cache[m.group(1).strip()]=m.group(2).strip() + a+=1 f.close() - sys.stderr.write('Loaded %d authors\n' % l) + sys.stderr.write('Loaded %d authors\n' % a) return cache def branchtip(repo, heads):