Skip to content

Commit

Permalink
Merge branch 'svnpollercache' of git://github.com/Jc2k/buildbot
Browse files Browse the repository at this point in the history
* 'svnpollercache' of git://github.com/Jc2k/buildbot:
  Add option to preserve last processed revision between restarts
  • Loading branch information
Dustin J. Mitchell committed Oct 26, 2010
2 parents 698dc20 + af28533 commit 198a805
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
27 changes: 25 additions & 2 deletions master/buildbot/changes/svnpoller.py
Expand Up @@ -44,7 +44,7 @@ class SVNPoller(base.ChangeSource, util.ComparableMixin):
compare_attrs = ["svnurl", "split_file_function",
"svnuser", "svnpasswd",
"pollinterval", "histmax",
"svnbin", "category"]
"svnbin", "category", "cachepath"]

parent = None # filled in when we're added
last_change = None
Expand All @@ -54,7 +54,8 @@ class SVNPoller(base.ChangeSource, util.ComparableMixin):
def __init__(self, svnurl, split_file=None,
svnuser=None, svnpasswd=None,
pollinterval=10*60, histmax=100,
svnbin='svn', revlinktmpl='', category=None, project=None):
svnbin='svn', revlinktmpl='', category=None,
project=None, cachepath=None):
"""
@type svnurl: string
@param svnurl: the SVN URL that describes the repository and
Expand Down Expand Up @@ -177,6 +178,11 @@ def __init__(self, svnurl, split_file=None,
@param project A single project that the changes are associated with
the repository, added to the changes, for the use in
change filters
@type cachepath string
@param cachepath A path to a file that can be used to store the last
rev that was processed, so we can grab changes that
happened while we were offline
"""

if svnurl.endswith("/"):
Expand All @@ -200,6 +206,18 @@ def __init__(self, svnurl, split_file=None,
self.category = category
self.project = project

self.cachepath = cachepath
if self.cachepath and os.path.exists(self.cachepath):
try:
f = open(self.cachepath, "r")
self.last_change = int(f.read().strip())
log.msg("SVNPoller(%s) setting last_change to %s" % (self.svnurl, self.last_change))
f.close()
except:
self.cachepath = None
log.msg("SVNPoller(%s) cache file corrupt, skipping and not using" % self.svnurl)
log.err()

def split_file(self, path):
# use getattr() to avoid turning this function into a bound method,
# which would require it to have an extra 'self' argument
Expand Down Expand Up @@ -486,6 +504,11 @@ def submit_changes(self, changes):
self.parent.addChange(c)

def finished_ok(self, res):
if self.cachepath:
f = open(self.cachepath, "w")
f.write(str(self.last_change))
f.close()

log.msg("SVNPoller finished polling %s" % res)
assert self.working
self.working = False
Expand Down
5 changes: 5 additions & 0 deletions master/docs/cfg-changesources.texinfo
Expand Up @@ -1098,6 +1098,11 @@ with the portion that will substitute for a revision number replaced by
could be used to cause revision links to be created to a websvn repository
viewer.

@item cachepath
If specified, buildbot will cache processed revisions between restarts. This
means you don't miss changes that were committed if the master is down for any
reason.

@end table

@heading Branches
Expand Down

0 comments on commit 198a805

Please sign in to comment.