summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhillip Smyth <phillipsmyth@Nexus-x240.dyn.ducie.codethink.co.uk>2018-05-29 13:46:38 +0100
committerPhillip Smyth <phillipsmyth@Nexus-x240.dyn.ducie.codethink.co.uk>2018-06-22 11:28:10 +0100
commit6029c7a3a38223938c606dc292e95d42c68f7cec (patch)
treea10351bc94d095bc4c6ec67d61a7b925ebeaf445
parent0fd230671d0c865b976ff1d9a4f70ae8ff631cfb (diff)
downloadbuildstream-reduce_history_in_cache.tar.gz
Updating .bzr plugin to omit the .bzr dirreduce_history_in_cache
-rw-r--r--buildstream/plugins/sources/bzr.py2
-rw-r--r--buildstream/plugins/sources/git.py87
2 files changed, 47 insertions, 42 deletions
diff --git a/buildstream/plugins/sources/bzr.py b/buildstream/plugins/sources/bzr.py
index b499d49d3..36be98297 100644
--- a/buildstream/plugins/sources/bzr.py
+++ b/buildstream/plugins/sources/bzr.py
@@ -121,6 +121,8 @@ class BzrSource(Source):
self._get_branch_dir(), directory],
fail="Failed to checkout revision {} from branch {} to {}"
.format(self.ref, self._get_branch_dir(), directory))
+ # Remove .bzr dir
+ shutil.rmtree(os.path.join(directory, ".bzr"))
def init_workspace(self, directory):
url = os.path.join(self.url, self.tracking)
diff --git a/buildstream/plugins/sources/git.py b/buildstream/plugins/sources/git.py
index 4b53c7f51..5d655e4b9 100644
--- a/buildstream/plugins/sources/git.py
+++ b/buildstream/plugins/sources/git.py
@@ -158,7 +158,6 @@ class GitMirror():
if all_tags:
tags_since_sha = self.source.check_output([self.source.host_git,
'tag',
- '--sort',
'--contains',
self.ref],
cwd=self.mirror)[1]
@@ -167,60 +166,64 @@ class GitMirror():
preceeding_tags = [x for x in all_tags if x not in tags_since_sha]
if preceeding_tags:
last_tag_before_ref = preceeding_tags[-1]
+ print("\nWe have a tag!!!!!\n")
else:
- last_tag_before_ref = 'HEAD'
-
- # find number of commits since last_tag_before_ref
- target_depth = self.source.check_output([self.source.host_git,
- 'rev-list',
- '--count',
- 'HEAD...{}'.format(last_tag_before_ref)])[1]
-
+ last_tag_before_ref = self.ref
+ print("\nWe have No tag!!!!!\n")
else:
- target_depth = self.source.check_output([self.source.host_git,
- 'rev-list',
- '--count',
- 'HEAD...{}'.format(self.ref)], cwd=self.mirror)[1]
-
- if int(target_depth) == 0:
- target_depth = 1
-
- branch = self.source.check_output([self.source.host_git,
- 'rev-parse',
- '--abbrev-ref',
- 'HEAD'], cwd=self.mirror)[1]
+ last_tag_before_ref = self.ref
+ print("\nWe have No tag!!!!!\n")
self.source.call([self.source.host_git,
'init',
fullpath])
- self.source.call([self.source.host_git,
- 'fetch',
- '--depth={}'.format(int(target_depth)),
- 'ext::git -c uploadpack.allowReachableSHA1InWant=true %s {}'
- .format(shlex.quote(self.mirror)),
- self.ref],
- env=dict(os.environ, GIT_ALLOW_PROTOCOL="ext"), cwd=fullpath)
+ rev_list = self.source.check_output([self.source.host_git,
+ 'rev-list',
+ '-n1',
+ '--parents',
+ last_tag_before_ref],
+ cwd=self.mirror)[1]
- self.source.call([self.source.host_git,
- 'checkout',
- 'FETCH_HEAD'], cwd=fullpath)
+ rev_list = [x.strip() for x in rev_list.split(' ')]
+ rev_list.pop(0)
+
+ print("ref: {}".format(last_tag_before_ref))
+ print("Rev List: {}".format(rev_list))
- if "master" not in branch:
+ # Adding ext::git line allows bst to fetch a specific commit using its SHA
+ # without changing the remote configuration
+ r = self.source.check_output([self.source.host_git,
+ 'log'], cwd=self.mirror)
+
+ print("r1: {}".format(r))
+ if not rev_list:
+ print("\n\n\nBANANA1\n\n\n")
self.source.call([self.source.host_git,
- 'branch',
- '-D',
- 'master'], cwd=fullpath)
+ 'fetch',
+ 'ext::git -c uploadpack.allowReachableSHA1InWant=true %s {}'
+ .format(shlex.quote(self.mirror)),
+ self.ref],
+ env=dict(os.environ, GIT_ALLOW_PROTOCOL="ext"), cwd=fullpath)
- self.source.call([self.source.host_git,
- 'reflog',
- 'expire',
- '--expire-unreachable=all'
- '--all'], cwd=fullpath)
+ else:
+ print("\n\n\nBANANA2\n\n\n")
+ self.source.call([self.source.host_git,
+ 'fetch'] +
+ ['--shallow-exclude={}'.format(parent) for parent in rev_list] +
+ ['ext::git -c uploadpack.allowReachableSHA1InWant=true %s {}'
+ .format(shlex.quote(self.mirror)),
+ self.ref],
+ env=dict(os.environ, GIT_ALLOW_PROTOCOL="ext"), cwd=fullpath)
self.source.call([self.source.host_git,
- 'repack',
- '-ad'], cwd=fullpath)
+ 'checkout',
+ 'FETCH_HEAD'], cwd=fullpath)
+
+ r = self.source.check_output([self.source.host_git,
+ 'log'], cwd=fullpath)
+
+ print("r2: {}".format(r))
def init_workspace(self, directory):
fullpath = os.path.join(directory, self.path)