summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-12-04 15:53:16 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-12-04 15:53:16 +0000
commitfc5d4e58753d113d898744c1924b13ddc34e526e (patch)
treed2f17a4258a3af5a6dee2ee4edc5a367103c5cc2
parent0861a2054145b9558f108e0662b35061db2a19ec (diff)
parentb9af32ba9f60b66ef1487438f97a37c54bf95b3b (diff)
downloadmorph-fc5d4e58753d113d898744c1924b13ddc34e526e.tar.gz
Merge branch 'sam/build-branch-fixes'
Reviewed-By: Richard Maw <richard.maw@codethink.co.uk> Reviewed-By: Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-rw-r--r--morphlib/buildbranch.py16
-rw-r--r--morphlib/gitdir.py10
-rw-r--r--morphlib/sysbranchdir.py6
3 files changed, 26 insertions, 6 deletions
diff --git a/morphlib/buildbranch.py b/morphlib/buildbranch.py
index 2d529133..2482bc9a 100644
--- a/morphlib/buildbranch.py
+++ b/morphlib/buildbranch.py
@@ -35,6 +35,15 @@ class BuildBranchCleanupError(cliapp.AppException):
% locals())
+class NoReposError(cliapp.AppException):
+ def __init__(self, bb, ignored):
+ self.bb = bb
+ cliapp.AppException.__init__(
+ self, "No repos were found in system branch (ignored %i which "
+ "didn't have the right morph.uuid setting)" % (ignored))
+
+
+
class BuildBranch(object):
'''Represent the sources modified in a system branch.
@@ -61,12 +70,12 @@ class BuildBranch(object):
self._branch_root = sb.get_config('branch.root')
branch_uuid = sb.get_config('branch.uuid')
- for gd in sb.list_git_directories():
+ for count, gd in enumerate(sb.list_git_directories()):
try:
repo_uuid = gd.get_config('morph.uuid')
except cliapp.AppException:
# Not a repository cloned by morph, ignore
- break
+ continue
build_ref = os.path.join('refs/heads', build_ref_prefix,
branch_uuid, repo_uuid)
# index is commit of workspace + uncommitted changes may want
@@ -76,6 +85,9 @@ class BuildBranch(object):
index.set_to_tree(gd.resolve_ref_to_tree(gd.HEAD))
self._to_push[gd] = (build_ref, index)
+ if len(self._to_push) == 0:
+ raise NoReposError(self, count)
+
rootinfo, = ((gd, index) for gd, (build_ref, index)
in self._to_push.iteritems()
if gd.get_config('morph.repository') == self._branch_root)
diff --git a/morphlib/gitdir.py b/morphlib/gitdir.py
index ed71e422..4c3efbd3 100644
--- a/morphlib/gitdir.py
+++ b/morphlib/gitdir.py
@@ -485,11 +485,15 @@ class GitDirectory(object):
self._config[key] = value
def get_config(self, key):
- '''Return value for a git repository configuration variable.'''
+ '''Return value for a git repository configuration variable.
+
+ If the variable is unset, this will raise cliapp.AppException.
+
+ '''
if key not in self._config:
- value = morphlib.git.gitcmd(self._runcmd, 'config', '-z', key)
- self._config[key] = value.rstrip('\0')
+ value = morphlib.git.gitcmd(self._runcmd, 'config', '-z', key)
+ self._config[key] = value.rstrip('\0')
return self._config[key]
def get_remote(self, *args, **kwargs):
diff --git a/morphlib/sysbranchdir.py b/morphlib/sysbranchdir.py
index 4351c6b3..4dbc5f6c 100644
--- a/morphlib/sysbranchdir.py
+++ b/morphlib/sysbranchdir.py
@@ -72,7 +72,11 @@ class SystemBranchDirectory(object):
def _find_git_directory(self, repo_url):
for gd in self.list_git_directories():
- if gd.get_config('morph.repository') == repo_url:
+ try:
+ gd_repo_url = gd.get_config('morph.repository')
+ except cliapp.AppException: # pragma: no cover
+ continue
+ if gd_repo_url == repo_url:
return gd.dirname
return None