French translation: copy -> copie.
[git/dscho.git] / git_remote_helpers / git / importer.py
blobb7d6107933ee036da736283652ead0a797aea12b
1 import os
2 import subprocess
4 from git_remote_helpers.util import check_call
7 class GitImporter(object):
8     """An importer for testgit repositories.
10     This importer simply delegates to git fast-import.
11     """
13     def __init__(self, repo):
14         """Creates a new importer for the specified repo.
15         """
17         self.repo = repo
19     def do_import(self, base):
20         """Imports a fast-import stream to the given directory.
22         Simply delegates to git fast-import.
23         """
25         dirname = self.repo.get_base_path(base)
26         if self.repo.local():
27             gitdir = self.repo.gitpath
28         else:
29             gitdir = os.path.abspath(os.path.join(dirname, '.git'))
30         path = os.path.abspath(os.path.join(dirname, 'git.marks'))
32         if not os.path.exists(dirname):
33             os.makedirs(dirname)
35         args = ["git", "--git-dir=" + gitdir, "fast-import", "--quiet", "--export-marks=" + path]
37         if os.path.exists(path):
38             args.append("--import-marks=" + path)
40         check_call(args)