From 474be07e38461cb7313fe44fa505115e4b4eb118 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 23 Jul 2009 22:59:48 -0700 Subject: [PATCH] Workaround for #601 in console. - This should really be fixed by fixing getBuild()... --- buildbot/status/web/console.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/buildbot/status/web/console.py b/buildbot/status/web/console.py index 0f60cb3889d..8455d1f4dc7 100755 --- a/buildbot/status/web/console.py +++ b/buildbot/status/web/console.py @@ -127,6 +127,18 @@ def head(self, request): ## Data gathering functions ## + def getHeadBuild(self, builder): + """Get the most recent build for the given builder. + """ + build = builder.getBuild(-1) + + # HACK: Work around #601, the head build may be None if it is + # locked. + if build is None: + build = builder.getBuild(-2) + + return build + def fetchChangesFromHistory(self, status, max_depth, max_builds, debugInfo): """Look at the history of the builders and try to fetch as many changes as possible. We need this when the main source does not contain enough @@ -147,7 +159,7 @@ def fetchChangesFromHistory(self, status, max_depth, max_builds, debugInfo): break builder = status.getBuilder(builderName) - build = builder.getBuild(-1) + build = self.getHeadBuild(builder) depth = 0 while build and depth < max_depth and build_count < max_builds: depth += 1 @@ -268,7 +280,7 @@ def getBuildsForRevision(self, request, builder, builderName, lastRevision, revision = lastRevision builds = [] - build = builder.getBuild(-1) + build = self.getHeadBuild(builder) number = 0 while build and number < numBuilds: debugInfo["builds_scanned"] += 1 @@ -461,7 +473,7 @@ def displaySlaveLine(self, status, builderList, debugInfo, subs): else: # If not offline, then display the result of the last # finished build. - build = status.getBuilder(builder).getBuild(-1) + build = self.getHeadBuild(status.getBuilder(builder)) while build and not build.isFinished(): build = build.getPreviousBuild()