diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-05-21 04:02:15 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-05-21 04:02:15 -0700 |
commit | af655431f53c20e3d0ed236544397c69974267f4 (patch) | |
tree | ddfc95bd3f768e98709cc2d7a445e64117d4c784 /git_remote_helpers/git/exporter.py | |
parent | 78f17935a306dfd7a1f32c923e0b05a094bf0c25 (diff) | |
parent | 63a2f6139c33b7231baad8e3bfcc218ef6b63418 (diff) | |
download | git-af655431f53c20e3d0ed236544397c69974267f4.tar.gz git-af655431f53c20e3d0ed236544397c69974267f4.tar.xz |
Merge branch 'sr/remote-helper-export'
* sr/remote-helper-export:
t5800: testgit helper requires Python support
Makefile: Simplify handling of python scripts
remote-helpers: add tests for testgit helper
remote-helpers: add testgit helper
remote-helpers: add support for an export command
remote-helpers: allow requesing the path to the .git directory
fast-import: always create marks_file directories
clone: also configure url for bare clones
clone: pass the remote name to remote_get
Conflicts:
Makefile
Diffstat (limited to 'git_remote_helpers/git/exporter.py')
-rw-r--r-- | git_remote_helpers/git/exporter.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/git_remote_helpers/git/exporter.py b/git_remote_helpers/git/exporter.py new file mode 100644 index 000000000..dfaab00b5 --- /dev/null +++ b/git_remote_helpers/git/exporter.py @@ -0,0 +1,51 @@ +import os +import subprocess +import sys + + +class GitExporter(object): + """An exporter for testgit repositories. + + The exporter simply delegates to git fast-export. + """ + + def __init__(self, repo): + """Creates a new exporter for the specified repo. + """ + + self.repo = repo + + def export_repo(self, base): + """Exports a fast-export stream for the given directory. + + Simply delegates to git fast-epxort and pipes it through sed + to make the refs show up under the prefix rather than the + default refs/heads. This is to demonstrate how the export + data can be stored under it's own ref (using the refspec + capability). + """ + + dirname = self.repo.get_base_path(base) + path = os.path.abspath(os.path.join(dirname, 'testgit.marks')) + + if not os.path.exists(dirname): + os.makedirs(dirname) + + print "feature relative-marks" + if os.path.exists(os.path.join(dirname, 'git.marks')): + print "feature import-marks=%s/git.marks" % self.repo.hash + print "feature export-marks=%s/git.marks" % self.repo.hash + sys.stdout.flush() + + args = ["git", "--git-dir=" + self.repo.gitpath, "fast-export", "--export-marks=" + path] + + if os.path.exists(path): + args.append("--import-marks=" + path) + + args.append("HEAD") + + p1 = subprocess.Popen(args, stdout=subprocess.PIPE) + + args = ["sed", "s_refs/heads/_" + self.repo.prefix + "_g"] + + subprocess.check_call(args, stdin=p1.stdout) |