Skip to content

Commit

Permalink
Merge commit 'f857fdb82ba9af3d095d4acd3c95c7f629464fb0' into jinja
Browse files Browse the repository at this point in the history
Conflicts:
	buildbot/status/web/builder.py
	buildbot/status/web/slaves.py
  • Loading branch information
marcus-sonestedt committed Dec 12, 2009
2 parents ea7725e + f857fdb commit bcdbfaf
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 24 deletions.
13 changes: 10 additions & 3 deletions buildbot/changes/changes.py
Expand Up @@ -54,7 +54,8 @@ class Change:
revision = None # used to create a source-stamp

def __init__(self, who, files, comments, isdir=0, links=[],
revision=None, when=None, branch=None, category=None):
revision=None, when=None, branch=None, category=None,
revlink=''):
self.who = who
self.comments = comments
self.isdir = isdir
Expand All @@ -65,6 +66,7 @@ def __init__(self, who, files, comments, isdir=0, links=[],
self.when = when
self.branch = branch
self.category = category
self.revlink = revlink

# keep a sorted list of the files, for easier display
self.files = files[:]
Expand All @@ -87,9 +89,14 @@ def asHTML(self):
links.append('<a href="%s"><b>%s</b></a>' % (link[0], file))
else:
links.append('<b>%s</b>' % file)
revision = ""
revlink = ""
if self.revision:
revision = "Revision: <b>%s</b><br />\n" % self.revision
if getattr(self, 'revlink', ""):
revision = 'Revision: <a href="%s"><b>%s</b></a>\n' % (
self.revlink, self.revision)
else:
revision = "Revision: <b>%s</b><br />\n" % self.revision

branch = ""
if self.branch:
branch = "Branch: <b>%s</b><br />\n" % self.branch
Expand Down
4 changes: 3 additions & 1 deletion buildbot/changes/mail.py
Expand Up @@ -22,7 +22,7 @@ class MaildirSource(MaildirService, util.ComparableMixin):
"""
implements(IChangeSource)

compare_attrs = ["basedir", "pollinterval"]
compare_attrs = ["basedir", "pollinterval", "prefix"]
name = None

def __init__(self, maildir, prefix=None):
Expand Down Expand Up @@ -487,6 +487,8 @@ def parse(self, m, prefix=None):
class BzrLaunchpadEmailMaildirSource(MaildirSource):
name = "Launchpad"

compare_attrs = MaildirSource.compare_attrs + ["branchMap", "defaultBranch"]

def __init__(self, maildir, prefix=None, branchMap=None, defaultBranch=None, **kwargs):
self.branchMap = branchMap
self.defaultBranch = defaultBranch
Expand Down
22 changes: 20 additions & 2 deletions buildbot/changes/svnpoller.py
Expand Up @@ -13,6 +13,7 @@
from buildbot.changes.changes import Change

import xml.dom.minidom
import urllib

def _assert(condition, msg):
if condition:
Expand Down Expand Up @@ -57,7 +58,7 @@ class SVNPoller(base.ChangeSource, util.ComparableMixin):
def __init__(self, svnurl, split_file=None,
svnuser=None, svnpasswd=None,
pollinterval=10*60, histmax=100,
svnbin='svn'):
svnbin='svn', revlinktmpl=''):
"""
@type svnurl: string
@param svnurl: the SVN URL that describes the repository and
Expand Down Expand Up @@ -163,6 +164,13 @@ def __init__(self, svnurl, split_file=None,
@param svnbin: path to svn binary, defaults to just 'svn'. Use
this if your subversion command lives in an
unusual location.
@type revlinktmpl: string
@param revlinktmpl: A format string to use for hyperlinks to revision
information. For example, setting this to
"http://reposerver/websvn/revision.php?rev=%s"
would create suitable links on the build pages
to information in websvn on each revision.
"""

if svnurl.endswith("/"):
Expand All @@ -172,6 +180,8 @@ def __init__(self, svnurl, split_file=None,
self.svnuser = svnuser
self.svnpasswd = svnpasswd

self.revlinktmpl = revlinktmpl

self.svnbin = svnbin
self.pollinterval = pollinterval
self.histmax = histmax
Expand Down Expand Up @@ -389,6 +399,13 @@ def create_changes(self, new_logentries):
for el in new_logentries:
branch_files = [] # get oldest change first
revision = str(el.getAttribute("revision"))

revlink=''

if self.revlinktmpl:
if revision:
revlink = self.revlinktmpl % urllib.quote_plus(revision)

dbgMsg("Adding change revision %s" % (revision,))
# TODO: the rest of buildbot may not be ready for unicode 'who'
# values
Expand Down Expand Up @@ -439,7 +456,8 @@ def create_changes(self, new_logentries):
files=files,
comments=comments,
revision=revision,
branch=branch)
branch=branch,
revlink=revlink)
changes.append(c)

return changes
Expand Down
2 changes: 2 additions & 0 deletions buildbot/master.py
Expand Up @@ -822,6 +822,8 @@ def loadConfig_Sources(self, sources):
# shut down any that were removed, start any that were added
deleted_sources = [s for s in self.change_svc if s not in sources]
added_sources = [s for s in sources if s not in self.change_svc]
log.msg("adding %d new changesources, removing %d" %
(len(added_sources), len(deleted_sources)))
dl = [self.change_svc.removeSource(s) for s in deleted_sources]
def addNewOnes(res):
[self.change_svc.addSource(s) for s in added_sources]
Expand Down
2 changes: 2 additions & 0 deletions buildbot/scripts/runner.py
Expand Up @@ -429,6 +429,8 @@ def parseArgs(self, *args):
if len(args) < 4:
raise usage.UsageError("command needs more arguments")
basedir, master, name, passwd = args
if master[:5] == "http:":
raise usage.UsageError("<master> is not a URL - do not use URL")
self['basedir'] = basedir
self['master'] = master
self['name'] = name
Expand Down
9 changes: 5 additions & 4 deletions buildbot/status/web/slaves.py
Expand Up @@ -18,9 +18,9 @@ def getTitle(self, req):
return "Buildbot: %s" % html.escape(self.slavename)

def getChild(self, path, req):
if path == "shutdown":
s = self.getStatus(req)
slave = s.getSlave(self.slavename)
s = self.getStatus(req)
slave = s.getSlave(self.slavename)
if path == "shutdown" and self.getControl(req):
slave.setGraceful(True)
return Redirect(path_to_slave(req, slave))

Expand Down Expand Up @@ -61,7 +61,8 @@ def content(self, request, ctx):
slavename = self.slavename,
current = current_builds,
recent = recent_builds,
shutdown_url = request.childLink("shutdown"))
shutdown_url = request.childLink("shutdown"),
control = self.getControl(request))
return data

# /buildslaves
Expand Down
14 changes: 8 additions & 6 deletions buildbot/status/web/templates/buildslave.html
Expand Up @@ -6,12 +6,14 @@ <h1>Build Slave: {{ slavename }}</h1>

{% if not slave.isConnected %}
<h2>NOT CONNECTED</h2>
{% elif not slave.getGraceFul %}
<form method="POST" action="{{ shutdown_url }}">
<input type="submit" value="Gracefully Shutdown">
</form>
{% else %}
<p>Gracefully shutting down...</p>
{% elif control %}
{% if not slave.getGraceFul %}
<form method="POST" action="{{ shutdown_url }}">
<input type="submit" value="Gracefully Shutdown">
</form>
{% else %}
<p>Gracefully shutting down...</p>
{% endif %}
{% endif %}

{% if current %}
Expand Down
33 changes: 33 additions & 0 deletions buildbot/test/test_mailparse.py
Expand Up @@ -374,3 +374,36 @@ def test6(self):
self.failUnlessEqual(set(c.files),
set(["renamed with => tricky <= name RENAMED better_name.txt",
"better_name.txt MODIFIED"]))

# Test equality comparison (for working config reload).
def test_bzr_mail_reload(self):
s0 = mail.BzrLaunchpadEmailMaildirSource("/dir1")
s1 = mail.BzrLaunchpadEmailMaildirSource("/dir2")
self.failIfEqual(s0,s1)
s2 = mail.BzrLaunchpadEmailMaildirSource("/dir1", prefix = "lp:")
self.failIfEqual(s0,s2)
s3 = mail.BzrLaunchpadEmailMaildirSource("/dir1", prefix = "pl:")
self.failIfEqual(s2,s3)
s4 = mail.BzrLaunchpadEmailMaildirSource("/dir1",
branchMap = { "a" : "A" })
self.failIfEqual(s0,s4)
s5 = mail.BzrLaunchpadEmailMaildirSource("/dir1",
branchMap = { "a" : "A", "b" : "B" })
self.failIfEqual(s4,s5)
s6 = mail.BzrLaunchpadEmailMaildirSource("/dir1",
defaultBranch = "b1")
self.failIfEqual(s0,s6)
s7 = mail.BzrLaunchpadEmailMaildirSource("/dir1",
defaultBranch = "b2")
self.failIfEqual(s6,s7)
s8 = mail.BzrLaunchpadEmailMaildirSource("/dir1",
prefix = "lp",
branchMap = { "c" : "C" },
defaultBranch = "b3")
self.failIfEqual(s6,s8)
s9 = mail.BzrLaunchpadEmailMaildirSource("/dir1",
prefix = "lp",
branchMap = { "c" : "C" },
defaultBranch = "b3")
s9.dummy = 42
self.assertEqual(s8,s9)
2 changes: 1 addition & 1 deletion buildbot/test/test_scheduler.py
Expand Up @@ -51,7 +51,7 @@ def testNightly(self):
# converted into the local timezone, which happens to match what
# Nightly is going to do anyway.
MIN=60; HOUR=60*MIN; DAY=24*3600
now = time.mktime((2005, 11, 15, 0, 5, 36, 1, 319, 0))
now = time.mktime((2005, 11, 15, 0, 5, 36, 1, 319, -1))

s = scheduler.Nightly('nightly', ["a"], hour=3)
t = s.calculateNextRunTimeFrom(now)
Expand Down
19 changes: 12 additions & 7 deletions contrib/github_buildbot.py
Expand Up @@ -44,21 +44,26 @@

master = "localhost:9989"

remote = "origin"

branch = "master"

changes = []

class GitHubBuildBot(resource.Resource):

isLeaf = True
def render_POST(self, request):
self.payload = json.loads(request.args['payload'][0])
payload = json.loads(request.args['payload'][0])
try:
self.process_change()
self.process_change(payload)
except:
logging.error("Could not process change")
raise()

def process_change(self):
update_git_dir(self.payload['repository']['owner']['name'] , self.payload['repository']['name'])
[oldrev, newrev, refname] = self.payload['before'], self.payload['after'], self.payload['ref']
def process_change(self,payload):
update_git_dir(payload['repository']['owner']['name'] , payload['repository']['name'],remote,branch)
[oldrev, newrev, refname] = payload['before'], payload['after'], payload['ref']

# We only care about regular heads, i.e. branches
m = re.match(r"^refs\/heads\/(.+)$", refname)
Expand Down Expand Up @@ -238,12 +243,12 @@ def gen_update_branch_changes(oldrev, newrev, refname, branch):
if status:
logging.warning("git rev-list exited with status %d" % status)

def update_git_dir(user, repo):
def update_git_dir(user, repo, rem, brh):
tempdir = tempfile.gettempdir()
repodir = tempdir+"/"+repo
if os.path.exists(repodir):
os.chdir(repodir)
subprocess.call(['git','pull'])
subprocess.call(['git','pull',rem,brh])
else:
os.chdir(tempdir)
subprocess.call(['git','clone', 'git@'+ github+':'+user+'/'+repo+'.git'])
Expand Down
9 changes: 9 additions & 0 deletions docs/buildbot.texinfo
Expand Up @@ -4216,6 +4216,15 @@ buildmaster's @code{$PATH}), use this to tell @code{SVNPoller} where
to find it. The default value of ``svn'' will almost always be
sufficient.

@item revlinktmpl
This parameter allows a link to be provided for each revision (for example,
to websvn or viewvc). These links appear anywhere changes are shown, such
as on build or change pages. The proper form for this parameter is an URL
with the portion that will substitute for a revision number replaced by
''%s''. For example, @code{'http://myserver/websvn/revision.php?rev=%s'}
could be used to cause revision links to be created to a websvn repository
viewer.

@end table

@heading Branches
Expand Down

0 comments on commit bcdbfaf

Please sign in to comment.