Code

pull: introduce a pull.rebase option to enable --rebase
[git.git] / git_remote_helpers / git / importer.py
1 import os
2 import subprocess
5 class GitImporter(object):
6     """An importer for testgit repositories.
8     This importer simply delegates to git fast-import.
9     """
11     def __init__(self, repo):
12         """Creates a new importer for the specified repo.
13         """
15         self.repo = repo
17     def do_import(self, base):
18         """Imports a fast-import stream to the given directory.
20         Simply delegates to git fast-import.
21         """
23         dirname = self.repo.get_base_path(base)
24         if self.repo.local:
25             gitdir = self.repo.gitpath
26         else:
27             gitdir = os.path.abspath(os.path.join(dirname, '.git'))
28         path = os.path.abspath(os.path.join(dirname, 'git.marks'))
30         if not os.path.exists(dirname):
31             os.makedirs(dirname)
33         args = ["git", "--git-dir=" + gitdir, "fast-import", "--quiet", "--export-marks=" + path]
35         if os.path.exists(path):
36             args.append("--import-marks=" + path)
38         child = subprocess.Popen(args)
39         if child.wait() != 0:
40             raise CalledProcessError