summaryrefslogtreecommitdiff
path: root/buildstream/_artifactcache
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2017-07-14 13:59:20 +0200
committerJürg Billeter <j@bitron.ch>2017-07-14 14:13:51 +0200
commit2d6807196ad7472c556f4521f78436e0929977ec (patch)
tree858ca92877a8ae753867bcb16d77f78d6e8b75fc /buildstream/_artifactcache
parent2b4e3d2f9c9b2a00011a815a19276c5419a6e702 (diff)
downloadbuildstream-2d6807196ad7472c556f4521f78436e0929977ec.tar.gz
_artifactcache/pushreceive.py: Support pushing multiple refs
Diffstat (limited to 'buildstream/_artifactcache')
-rw-r--r--buildstream/_artifactcache/artifactcache.py2
-rw-r--r--buildstream/_artifactcache/pushreceive.py21
2 files changed, 17 insertions, 6 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index 9435321c8..c3b754aab 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -245,7 +245,7 @@ class ArtifactCache():
pushed = push_artifact(temp_repo.get_path().get_path(),
self.context.artifact_push,
self.context.artifact_push_port,
- ref, output_file)
+ [ref], output_file)
except PushException as e:
raise _ArtifactError("Failed to push artifact {}: {}".format(ref, e)) from e
diff --git a/buildstream/_artifactcache/pushreceive.py b/buildstream/_artifactcache/pushreceive.py
index 77bec445a..df2085969 100644
--- a/buildstream/_artifactcache/pushreceive.py
+++ b/buildstream/_artifactcache/pushreceive.py
@@ -444,9 +444,20 @@ class OSTreePusher(object):
# Collect commits and objects to push
commits = set()
+ ref_count = 0
for branch, revs in update_refs.items():
logging.info('Updating {} {} to {}'.format(branch, revs[0], revs[1]))
- needed = self.needed_commits(revs[0], revs[1], commits)
+ try:
+ self.needed_commits(revs[0], revs[1], commits)
+ ref_count += 1
+ except PushExistsException:
+ if exc_info is None:
+ exc_info = sys.exc_info()
+
+ # Re-raise PushExistsException if all refs exist already
+ if ref_count == 0:
+ raise exc_info[0].with_traceback(exc_info[1], exc_info[2])
+
logging.info('Enumerating objects to send')
objects = self.needed_objects(commits)
@@ -560,7 +571,7 @@ class OSTreeReceiver(object):
# repo: The local repository path
# remote: The ssh remote url to push to
# remote_port: The ssh port at the remote url
-# branch: The ref to push
+# branches: The refs to push
# output: The output where logging should go
#
# Returns:
@@ -570,12 +581,12 @@ class OSTreeReceiver(object):
# Raises:
# PushException if there was an error
#
-def push(repo, remote, remote_port, branch, output):
+def push(repo, remote, remote_port, branches, output):
logging.basicConfig(format='%(module)s: %(levelname)s: %(message)s',
level=logging.INFO, stream=output)
- pusher = OSTreePusher(repo, remote, remote_port, [branch], True, False, output=output)
+ pusher = OSTreePusher(repo, remote, remote_port, branches, True, False, output=output)
def terminate_push():
pusher.close()
@@ -590,7 +601,7 @@ def push(repo, remote, remote_port, branch, output):
except PushExistsException:
# If the commit already existed, just bail out
# on the push and dont bother re-raising the error
- logging.info("Ref {} was already present in remote {}".format(branch, remote))
+ logging.info("Ref {} was already present in remote {}".format(branches, remote))
terminate_push()
return False