diff options
author | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2012-09-14 09:32:45 +0100 |
---|---|---|
committer | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2012-09-14 17:14:16 +0100 |
commit | dd4f52f311467240ea2749c773d46b751478381d (patch) | |
tree | f6939600c12ad695bf375e452657c8e13f2c9bf2 /morphlib/builder2.py | |
parent | 8d98f5692fb974d081dfb74a64e2f4b861b27461 (diff) | |
download | morph-dd4f52f311467240ea2749c773d46b751478381d.tar.gz |
Rework git caches to be bare mirrors of the repos.
This reworks the code for managing and using the git caches in morph to treat
the caches as bare repositories which are mirrors of where we clone from. In
addition we correctly prune the branches during updates, so that we don't end
up accumulating pointless branches over and over. This is even more important
with branch-and-merge generating temporary build refs for things.
Diffstat (limited to 'morphlib/builder2.py')
-rw-r--r-- | morphlib/builder2.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/morphlib/builder2.py b/morphlib/builder2.py index 0b986540..72165ce7 100644 --- a/morphlib/builder2.py +++ b/morphlib/builder2.py @@ -308,16 +308,14 @@ class ChunkBuilder(BuilderBase): cache_dir = os.path.dirname(self.artifact.source.repo.path) - def extract_repo(path, sha1, destdir): + def extract_repo(repo, sha1, destdir): self.app.status(msg='Extracting %(source)s into %(target)s', - source=path, + source=repo.original_name, target=destdir) - if not os.path.exists(destdir): - os.mkdir(destdir) - morphlib.git.copy_repository(self.app.runcmd, path, destdir) - morphlib.git.checkout_ref(self.app.runcmd, destdir, sha1) + + repo.checkout(sha1, destdir) morphlib.git.reset_workdir(self.app.runcmd, destdir) - submodules = morphlib.git.Submodules(self.app, path, sha1) + submodules = morphlib.git.Submodules(self.app, repo.path, sha1) try: submodules.load() except morphlib.git.NoModulesFileError: @@ -327,14 +325,14 @@ class ChunkBuilder(BuilderBase): for sub in submodules: cached_repo = self.repo_cache.get_repo(sub.url) sub_dir = os.path.join(destdir, sub.path) - tuples.append((cached_repo.path, sub.commit, sub_dir)) + tuples.append((cached_repo, sub.commit, sub_dir)) return tuples s = self.artifact.source - todo = [(s.repo.path, s.sha1, srcdir)] + todo = [(s.repo, s.sha1, srcdir)] while todo: - path, sha1, srcdir = todo.pop() - todo += extract_repo(path, sha1, srcdir) + repo, sha1, srcdir = todo.pop() + todo += extract_repo(repo, sha1, srcdir) self.set_mtime_recursively(srcdir) def set_mtime_recursively(self, root): # pragma: no cover |