# HG changeset patch # User cmlenz # Date 1126607545 0 # Node ID d72c0587fae9648df95eb04b473188f8b71f7ace # Parent b5f7d8a4035e2c9d26aab55db62f8b303a9b6d77 * Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46. * Only display charts on build config page when reports are available. * BDB XML database is created lazily, i.e. only on write requests. diff --git a/bitten/master.py b/bitten/master.py --- a/bitten/master.py +++ b/bitten/master.py @@ -67,6 +67,21 @@ config.path) node = repos.get_node(config.path) for path, rev, chg in node.get_history(): + + # Don't follow moves/copies + if path != repos.normalize_path(config.path): + break + + # Make sure the repository directory isn't empty at this + # revision + old_node = repos.get_node(path, rev) + is_empty = True + for entry in old_node.get_entries(): + is_empty = False + break + if is_empty: + continue + enqueued = False for platform in TargetPlatform.select(self.env, config.name, db=db): @@ -99,6 +114,9 @@ return log.debug('Checking for pending builds...') for build in Build.select(self.env, status=Build.PENDING): + config = BuildConfig.fetch(self.env, name=build.config) + if not config.active: + continue for slave in self.slaves.get(build.platform, []): active_builds = Build.select(self.env, slave=slave.name, status=Build.IN_PROGRESS) diff --git a/bitten/store.py b/bitten/store.py --- a/bitten/store.py +++ b/bitten/store.py @@ -102,32 +102,31 @@ def __init__(self, path): self.path = path self.mgr = dbxml.XmlManager() - if not os.path.exists(path): - self.container = self.mgr.createContainer(self.path) - ctxt = self.mgr.createUpdateContext() - for name, index in self.indices: - self.container.addIndex('', name, index, ctxt) - else: - self.container = self.mgr.openContainer(self.path) def delete(self, config=None, build=None, step=None, type=None): + container = self._open_container() + if not container: + return ctxt = self.mgr.createUpdateContext() for elem in self.query('return $reports', config=config, build=build, step=step, type=type): - self.container.deleteDocument(elem._value.asDocument(), ctxt) + container.deleteDocument(elem._value.asDocument(), ctxt) def store(self, build, step, xml): assert xml.name == 'report' and 'type' in xml.attr + container = self._open_container(create=True) ctxt = self.mgr.createUpdateContext() doc = self.mgr.createDocument() doc.setContent(str(xml)) doc.setMetaData('', 'config', dbxml.XmlValue(build.config)) doc.setMetaData('', 'build', dbxml.XmlValue(build.id)) doc.setMetaData('', 'step', dbxml.XmlValue(step.name)) - self.container.putDocument(doc, ctxt, dbxml.DBXML_GEN_NAME) + container.putDocument(doc, ctxt, dbxml.DBXML_GEN_NAME) - def query(self, xquery, config=None, build=None, step=None, - type=None): + def query(self, xquery, config=None, build=None, step=None, type=None): + container = self._open_container() + if not container: + return ctxt = self.mgr.createQueryContext() constraints = [] @@ -143,14 +142,26 @@ query = "let $reports := collection('%s')/report" % self.path if constraints: query += '[%s]' % ' and '.join(constraints) - query += '\n' + xquery + query += '\n' + (xquery or 'return $reports') results = self.mgr.query(query, ctxt) for value in results: yield BDBXMLReportStore.XmlValueAdapter(value) def retrieve(self, build, step=None, type=None): - return self.query('return $reports', build=build, step=step, type=type) + return self.query('', build=build, step=step, type=type) + + def _open_container(self, create=False): + if not os.path.exists(self.path): + if not create: + return None + container = self.mgr.createContainer(self.path) + ctxt = self.mgr.createUpdateContext() + for name, index in self.indices: + container.addIndex('', name, index, ctxt) + else: + container = self.mgr.openContainer(self.path) + return container def get_store(env): diff --git a/bitten/trac_ext/templates/bitten_config.cs b/bitten/trac_ext/templates/bitten_config.cs --- a/bitten/trac_ext/templates/bitten_config.cs +++ b/bitten/trac_ext/templates/bitten_config.cs @@ -133,7 +133,7 @@ + if:len(config.platforms) && len(config.builds) ?>
Chgset