Skip to content

Commit

Permalink
Merge branch 'master' into nine
Browse files Browse the repository at this point in the history
Conflicts:
	master/buildbot/changes/base.py
	master/buildbot/changes/bonsaipoller.py
	master/buildbot/changes/gitpoller.py
	master/buildbot/changes/hgpoller.py
	master/buildbot/changes/p4poller.py
	master/buildbot/changes/svnpoller.py
	master/buildbot/status/mail.py
	master/buildbot/test/unit/test_changes_base.py
	master/docs/manual/cfg-statustargets.rst
  • Loading branch information
djmitche committed Jan 8, 2014
2 parents 39c60d3 + 5748fe2 commit d071e40
Show file tree
Hide file tree
Showing 15 changed files with 872 additions and 112 deletions.
8 changes: 6 additions & 2 deletions master/buildbot/changes/base.py
Expand Up @@ -65,11 +65,15 @@ class PollingChangeSource(ChangeSource):
pollInterval = 60
"time (in seconds) between calls to C{poll}"

pollAtLaunch = False
"determines when the first poll occurs. True = immediately on launch, False = wait for one pollInterval."

_loop = None

def __init__(self, name=None, pollInterval=60 * 10):
def __init__(self, name=None, pollInterval=60 * 10, pollAtLaunch=False):
ChangeSource.__init__(self, name)
self.pollInterval = pollInterval
self.pollAtLaunch = pollAtLaunch

self.doPoll = misc.SerializedInvocation(self.doPoll)

Expand All @@ -93,7 +97,7 @@ def poll(self):

def startLoop(self):
self._loop = task.LoopingCall(self.doPoll)
self._loop.start(self.pollInterval, now=False)
self._loop.start(self.pollInterval, now=self.pollAtLaunch)

def stopLoop(self):
if self._loop and self._loop.running:
Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/changes/bonsaipoller.py
Expand Up @@ -220,12 +220,12 @@ def _getRevision(self):

class BonsaiPoller(base.PollingChangeSource):
compare_attrs = ("bonsaiURL", "pollInterval", "tree",
"module", "branch", "cvsroot")
"module", "branch", "cvsroot", "pollAtLaunch")

def __init__(self, bonsaiURL, module, branch, tree="default",
cvsroot="/cvsroot", pollInterval=30, project=''):
cvsroot="/cvsroot", pollInterval=30, project='', pollAtLaunch=False):

base.PollingChangeSource.__init__(self, name=bonsaiURL, pollInterval=pollInterval)
base.PollingChangeSource.__init__(self, name=bonsaiURL, pollInterval=pollInterval, pollAtLaunch=pollAtLaunch)

self.bonsaiURL = bonsaiURL
self.module = module
Expand Down
72 changes: 57 additions & 15 deletions master/buildbot/changes/gitpoller.py
Expand Up @@ -35,14 +35,14 @@ class GitPoller(base.PollingChangeSource, StateMixin):

compare_attrs = ("repourl", "branches", "workdir",
"pollInterval", "gitbin", "usetimestamps",
"category", "project")
"category", "project", "pollAtLaunch")

def __init__(self, repourl, branches=None, branch=None,
workdir=None, pollInterval=10 * 60,
gitbin='git', usetimestamps=True,
category=None, project=None,
pollinterval=-2, fetch_refspec=None,
encoding='utf-8', name=None):
encoding='utf-8', name=None, pollAtLaunch=False):

# for backward compatibility; the parameter used to be spelled with 'i'
if pollinterval != -2:
Expand All @@ -52,7 +52,8 @@ def __init__(self, repourl, branches=None, branch=None,
name = repourl

base.PollingChangeSource.__init__(self, name=name,
pollInterval=pollInterval)
pollInterval=pollInterval,
pollAtLaunch=pollAtLaunch)

if project is None:
project = ''
Expand Down Expand Up @@ -99,29 +100,73 @@ def setLastRev(lastRev):
return d

def describe(self):
status = ""
str = ('GitPoller watching the remote git repository ' +
self.repourl)

if self.branches:
if self.branches is True:
str += ', branches: ALL'
elif not callable(self.branches):
str += ', branches: ' + ', '.join(self.branches)

if not self.master:
status = "[STOPPED - check log]"
str = ('GitPoller watching the remote git repository %s, branches: %s %s'
% (self.repourl, ', '.join(self.branches), status))
str += " [STOPPED - check log]"

return str

def _getBranches(self):
d = self._dovccmd('ls-remote', [self.repourl])

@d.addCallback
def parseRemote(rows):
branches = []
for row in rows.splitlines():
if not '\t' in row:
# Not a useful line
continue
sha, ref = row.split("\t")
branches.append(ref)
return branches
return d

def _headsFilter(self, branch):
"""Filter out remote references that don't begin with 'refs/heads'."""
return branch.startswith("refs/heads/")

def _removeHeads(self, branch):
"""Remove 'refs/heads/' prefix from remote references."""
if branch.startswith("refs/heads/"):
branch = branch[11:]
return branch

def _trackerBranch(self, branch):
return "refs/buildbot/%s/%s" % (urllib.quote(self.repourl, ''),
self._removeHeads(branch))

@defer.inlineCallbacks
def poll(self):
yield self._dovccmd('init', ['--bare', self.workdir])

branches = self.branches
if branches is True or callable(branches):
branches = yield self._getBranches()
if callable(self.branches):
branches = filter(self.branches, branches)
else:
branches = filter(self._headsFilter, branches)

refspecs = [
'+%s:%s' % (branch, self._localBranch(branch))
for branch in self.branches
'+%s:%s' % (self._removeHeads(branch), self._trackerBranch(branch))
for branch in branches
]
yield self._dovccmd('fetch',
[self.repourl] + refspecs, path=self.workdir)

revs = {}
for branch in self.branches:
for branch in branches:
try:
revs[branch] = rev = yield self._dovccmd('rev-parse',
[self._localBranch(branch)], path=self.workdir)
revs[branch] = rev = yield self._dovccmd(
'rev-parse', [self._trackerBranch(branch)], path=self.workdir)
yield self._process_changes(rev, branch)
except:
log.err(_why="trying to poll branch %s of %s"
Expand Down Expand Up @@ -256,6 +301,3 @@ def _convert_nonzero_to_failure(res):
return stdout.strip()
d.addCallback(_convert_nonzero_to_failure)
return d

def _localBranch(self, branch):
return "refs/buildbot/%s/%s" % (urllib.quote(self.repourl, ''), branch)
6 changes: 3 additions & 3 deletions master/buildbot/changes/hgpoller.py
Expand Up @@ -33,15 +33,15 @@ class HgPoller(base.PollingChangeSource):

compare_attrs = ("repourl", "branch", "workdir",
"pollInterval", "hgpoller", "usetimestamps",
"category", "project")
"category", "project", "pollAtLaunch")

db_class_name = 'HgPoller'

def __init__(self, repourl, branch='default',
workdir=None, pollInterval=10 * 60,
hgbin='hg', usetimestamps=True,
category=None, project='', pollinterval=-2,
encoding='utf-8', name=None):
encoding='utf-8', name=None, pollAtLaunch=False):

# for backward compatibility; the parameter used to be spelled with 'i'
if pollinterval != -2:
Expand All @@ -53,7 +53,7 @@ def __init__(self, repourl, branch='default',
self.repourl = repourl
self.branch = branch
base.PollingChangeSource.__init__(
self, name=name, pollInterval=pollInterval)
self, name=name, pollInterval=pollInterval, pollAtLaunch=pollAtLaunch)
self.encoding = encoding
self.lastChange = time.time()
self.lastPoll = time.time()
Expand Down
8 changes: 5 additions & 3 deletions master/buildbot/changes/p4poller.py
Expand Up @@ -55,7 +55,7 @@ class P4Source(base.PollingChangeSource, util.ComparableMixin):
them to the change master."""

compare_attrs = ("p4port", "p4user", "p4passwd", "p4base",
"p4bin", "pollInterval")
"p4bin", "pollInterval", "pollAtLaunch")

env_vars = ["P4CLIENT", "P4PORT", "P4PASSWD", "P4USER",
"P4CHARSET", "PATH"]
Expand All @@ -76,7 +76,7 @@ def __init__(self, p4port=None, p4user=None, p4passwd=None,
split_file=lambda branchfile: (None, branchfile),
pollInterval=60 * 10, histmax=None, pollinterval=-2,
encoding='utf8', project=None, name=None,
server_tz=None):
server_tz=None, pollAtLaunch=False):

# for backward compatibility; the parameter used to be spelled with 'i'
if pollinterval != -2:
Expand All @@ -85,7 +85,9 @@ def __init__(self, p4port=None, p4user=None, p4passwd=None,
if name is None:
name = "P4Source:%s:%s" % (p4port, p4base)

base.PollingChangeSource.__init__(self, name=name, pollInterval=pollInterval)
base.PollingChangeSource.__init__(self, name=name,
pollInterval=pollInterval,
pollAtLaunch=pollAtLaunch)

if project is None:
project = ''
Expand Down
8 changes: 5 additions & 3 deletions master/buildbot/changes/svnpoller.py
Expand Up @@ -79,7 +79,7 @@ class SVNPoller(base.PollingChangeSource, util.ComparableMixin):
compare_attrs = ("svnurl", "split_file",
"svnuser", "svnpasswd", "project",
"pollInterval", "histmax",
"svnbin", "category", "cachepath")
"svnbin", "category", "cachepath", "pollAtLaunch")

parent = None # filled in when we're added
last_change = None
Expand All @@ -90,7 +90,7 @@ def __init__(self, svnurl, split_file=None,
pollInterval=10 * 60, histmax=100,
svnbin='svn', revlinktmpl='', category=None,
project='', cachepath=None, pollinterval=-2,
extra_args=None, name=None):
extra_args=None, name=None, pollAtLaunch=False):

# for backward compatibility; the parameter used to be spelled with 'i'
if pollinterval != -2:
Expand All @@ -99,7 +99,9 @@ def __init__(self, svnurl, split_file=None,
if name is None:
name = svnurl

base.PollingChangeSource.__init__(self, name=name, pollInterval=pollInterval)
base.PollingChangeSource.__init__(self, name=name,
pollInterval=pollInterval,
pollAtLaunch=pollAtLaunch)

if svnurl.endswith("/"):
svnurl = svnurl[:-1] # strip the trailing slash
Expand Down

0 comments on commit d071e40

Please sign in to comment.