]>
Commit | Line | Data |
---|---|---|
7aeaa2fc SR |
1 | import os |
2 | import subprocess | |
3 | ||
460d1026 SR |
4 | from git_remote_helpers.util import check_call |
5 | ||
7aeaa2fc SR |
6 | |
7 | class GitImporter(object): | |
8 | """An importer for testgit repositories. | |
9 | ||
10 | This importer simply delegates to git fast-import. | |
11 | """ | |
12 | ||
13 | def __init__(self, repo): | |
14 | """Creates a new importer for the specified repo. | |
15 | """ | |
16 | ||
17 | self.repo = repo | |
18 | ||
19 | def do_import(self, base): | |
20 | """Imports a fast-import stream to the given directory. | |
21 | ||
22 | Simply delegates to git fast-import. | |
23 | """ | |
24 | ||
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')) | |
31 | ||
32 | if not os.path.exists(dirname): | |
33 | os.makedirs(dirname) | |
34 | ||
35 | args = ["git", "--git-dir=" + gitdir, "fast-import", "--quiet", "--export-marks=" + path] | |
36 | ||
37 | if os.path.exists(path): | |
38 | args.append("--import-marks=" + path) | |
39 | ||
460d1026 | 40 | check_call(args) |