mirror of
https://github.com/frej/fast-export.git
synced 2026-03-18 07:10:13 +01:00
Basic support for an author map
As git-(cvs|svn)import support it, make futrue git-hgimport :) support it, too. Signed-off-by: Rocco Rutte <pdmef@gmx.net>
This commit is contained in:
27
hg2git.py
27
hg2git.py
@@ -264,6 +264,25 @@ def export_tags(ui,repo,marks_cache,start,end,count,authors):
|
||||
count=checkpoint(count)
|
||||
return count
|
||||
|
||||
def load_authors(filename):
|
||||
cache={}
|
||||
if not os.path.exists(filename):
|
||||
return cache
|
||||
f=open(filename,'r')
|
||||
l=0
|
||||
lre=re.compile('^([^= ]+)[ ]*=[ ]*(.+)$')
|
||||
for line in f.readlines():
|
||||
l+=1
|
||||
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)]=m.group(2)
|
||||
f.close()
|
||||
sys.stderr.write('Loaded %d authors\n' % l)
|
||||
return cache
|
||||
|
||||
def load_cache(filename):
|
||||
cache={}
|
||||
if not os.path.exists(filename):
|
||||
@@ -362,6 +381,8 @@ if __name__=='__main__':
|
||||
help="URL of repo to import")
|
||||
parser.add_option("-s",action="store_true",dest="sob",
|
||||
default=False,help="Enable parsing Signed-off-by lines")
|
||||
parser.add_option("-A","--authors",dest="authorfile",
|
||||
help="Read authormap from AUTHORFILE")
|
||||
|
||||
(options,args)=parser.parse_args()
|
||||
|
||||
@@ -373,5 +394,9 @@ if __name__=='__main__':
|
||||
if options.marksfile==None: bail(parser,'--status')
|
||||
if options.marksfile==None: bail(parser,'--repo')
|
||||
|
||||
a={}
|
||||
if options.authorfile!=None:
|
||||
a=load_authors(options.authorfile)
|
||||
|
||||
sys.exit(hg2git(options.repourl,m,options.marksfile,options.headsfile,
|
||||
options.statusfile,sob=options.sob))
|
||||
options.statusfile,authors=a,sob=options.sob))
|
||||
|
||||
Reference in New Issue
Block a user