FIXME: hotpatch for compatibility with latest hg
[git] / git_remote_helpers / hg / importer.py
1 import os.path
2 import sys
3
4 from git_remote_helpers.hg import hgimport
5 from git_remote_helpers.fastimport import processor, parser
6
7
8 class GitImporter(object):
9     def __init__(self, repo):
10         self.repo = repo
11
12     def do_import(self, base):
13         sources = ["-"]
14
15         dirname = self.repo.get_base_path(base)
16
17         if not os.path.exists(dirname):
18             os.makedirs(dirname)
19
20         procc = hgimport.HgImportProcessor(self.repo.ui, self.repo)
21
22         marks_file = os.path.abspath(os.path.join(dirname, 'hg.marks'))
23
24         if os.path.exists(marks_file):
25             procc.load_marksfile(marks_file)
26
27         processor.parseMany(sources, parser.ImportParser, procc)
28
29         procc.write_marksfile(marks_file)