From 10155a778c8b80433dd7a9938bc663287ed5ea63 Mon Sep 17 00:00:00 2001 From: Jared Grubb Date: Sun, 17 May 2015 12:34:23 -0700 Subject: [PATCH] Git._fetch: move to defer.inlineCallbacks --- master/buildbot/steps/source/git.py | 36 ++++++++++++----------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/master/buildbot/steps/source/git.py b/master/buildbot/steps/source/git.py index 63f3044c8da..49d5bb88d86 100644 --- a/master/buildbot/steps/source/git.py +++ b/master/buildbot/steps/source/git.py @@ -373,6 +373,7 @@ def evaluateCommand(_): return cmd.rc return d + @defer.inlineCallbacks def _fetch(self, _): command = ['fetch', '-t', self.repourl, self.branch] # If the 'progress' option is set, tell git fetch to output @@ -382,28 +383,21 @@ def _fetch(self, _): if self.prog: command.append('--progress') - d = self._dovccmd(command) + yield self._dovccmd(command) - @d.addCallback - def checkout(_): - if self.revision: - rev = self.revision - else: - rev = 'FETCH_HEAD' - command = ['reset', '--hard', rev, '--'] - abandonOnFailure = not self.retryFetch and not self.clobberOnFailure - return self._dovccmd(command, abandonOnFailure) - - if self.branch != 'HEAD': - @d.addCallback - def renameBranch(res): - if res != RC_SUCCESS: - return res - d = self._dovccmd(['branch', '-M', self.branch], abandonOnFailure=False) - # Ignore errors - d.addCallback(lambda _: res) - return d - return d + if self.revision: + rev = self.revision + else: + rev = 'FETCH_HEAD' + command = ['reset', '--hard', rev, '--'] + abandonOnFailure = not self.retryFetch and not self.clobberOnFailure + res = yield self._dovccmd(command, abandonOnFailure) + + if res == RC_SUCCESS and self.branch != 'HEAD': + # Ignore errors + yield self._dovccmd(['branch', '-M', self.branch], abandonOnFailure=False) + + defer.returnValue(res) @defer.inlineCallbacks def _fetchOrFallback(self, _=None):