Skip to content

Commit

Permalink
Let VCSes sometimes bypass clobber fallback.
Browse files Browse the repository at this point in the history
(Some fetch errors are detectably unrecoverable. In
these cases, it's better to keep DVCS clones around
for future use, instead of wiping them out for no reason.)
  • Loading branch information
Amber Yust committed Sep 29, 2010
1 parent 2018190 commit 705aed3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 11 additions & 0 deletions slave/buildslave/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@ def maybeDoVCFallback(self, rc):
return rc
if self.interrupted:
raise AbandonChain(1)
# Let VCS subclasses have an opportunity to handle
# unrecoverable errors without having to clobber the repo
self.maybeNotDoVCFallback(self, rc)
msg = "update failed, clobbering and trying again"
self.sendStatus({'header': msg + "\n"})
log.msg(msg)
Expand All @@ -382,6 +385,14 @@ def doVCFallback2(self, res):
d.addCallback(self._abandonOnFailure)
return d

def maybeNotDoVCFallback(self, rc):
"""Override this in a subclass if you want to detect unrecoverable
checkout errors where clobbering the repo wouldn't help, and stop
the current VC chain before it clobbers the repo for future builds.
Use 'raise AbandonChain' to pass up a halt if you do detect such."""
pass

def maybeDoVCRetry(self, res):
"""We get here somewhere after a VC chain has finished. res could
be::
Expand Down
9 changes: 8 additions & 1 deletion slave/buildslave/commands/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from buildslave.commands.base import SourceBaseCommand
from buildslave import runprocess
from buildslave.commands import utils
from buildslave.commands.base import AbandonChain


class Git(SourceBaseCommand):
Expand Down Expand Up @@ -102,6 +103,12 @@ def _didFetch(self, res):
command = ['reset', '--hard', head]
return self._dovccmd(command, self._didHeadCheckout)

def maybeNotDoVCFallback(self, res):
# If we were unable to find the branch/SHA on the remote,
# clobbering the repo won't help any, so just abort the chain
if "Couldn't find remote ref" in self.stderr:
raise AbandonChain(-1)

# Update first runs "git clean", removing local changes,
# if the branch to be checked out has changed. This, combined
# with the later "git reset" equates clobbering the repo,
Expand Down Expand Up @@ -131,7 +138,7 @@ def _doFetch(self, dummy):
command.append('--progress')
self.sendStatus({"header": "fetching branch %s from %s\n"
% (self.branch, self.repourl)})
return self._dovccmd(command, self._didFetch)
return self._dovccmd(command, self._didFetch, keepStderr=True)

def _didClean(self, dummy):
# After a clean, try to use the given revision if we have one.
Expand Down

0 comments on commit 705aed3

Please sign in to comment.