Skip to content

Commit

Permalink
Merge tardyp/buildbot:sschanges (PR #1504)
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Jan 25, 2015
2 parents 21d68dd + 18fa7d1 commit 67d4413
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
14 changes: 11 additions & 3 deletions master/buildbot/data/changes.py
Expand Up @@ -61,16 +61,24 @@ class ChangesEndpoint(FixerMixin, base.Endpoint):
pathPatterns = """
/changes
/builds/n:buildid/changes
/sourcestamps/n:ssid/changes
"""
rootLinkName = 'changes'

@defer.inlineCallbacks
def get(self, resultSpec, kwargs):
buildid = kwargs.get('buildid')
if buildid is None:
changes = yield self.master.db.changes.getChanges()
else:
ssid = kwargs.get('ssid')
if buildid is not None:
changes = yield self.master.db.changes.getChangesForBuild(buildid)
elif ssid is not None:
change = yield self.master.db.changes.getChangeFromSSid(ssid)
if change is not None:
changes = [change]
else:
changes = []
else:
changes = yield self.master.db.changes.getChanges()

changes = [(yield self._fixChange(ch)) for ch in changes]
defer.returnValue(changes)
Expand Down
16 changes: 14 additions & 2 deletions master/buildbot/process/buildrequest.py
Expand Up @@ -118,6 +118,18 @@ def asDict(self):
return result


class TempChange(object):
# temporary fake change

def __init__(self, d):
for k, v in d.items():
setattr(self, k, v)
self.properties = properties.Properties()
for k, v in d['properties'].items():
self.properties.setProperty(k, v[0], v[1])
self.who = d['author']


class BuildRequest(object):

"""
Expand Down Expand Up @@ -217,8 +229,8 @@ def _make_br(cls, brid, brdict, master):
else:
ss.patch = None
ss.patch_info = (None, None)
ss.changes = []
# XXX: sourcestamps don't have changes anymore; this affects merging!!
changes = yield master.data.get(("sourcestamps", ss.ssid, "changes"))
ss.changes = [TempChange(change) for change in changes]

defer.returnValue(buildrequest)

Expand Down
3 changes: 3 additions & 0 deletions master/buildbot/test/fake/fakedb.py
Expand Up @@ -832,6 +832,9 @@ def getChangesCount(self):
def getChangesForBuild(self, buildid):
pass

def getChangeFromSSid(self, ssid):
pass

def _chdict(self, row):
chdict = row.copy()
del chdict['uids']
Expand Down
9 changes: 7 additions & 2 deletions master/docs/developer/rtype-change.rst
Expand Up @@ -38,9 +38,15 @@ Changes
.. bb:rpath:: /builds/:buildid/changes
:pathkey integer buildid: the ID of the build

This path lists all changes related to a build

.. bb:rpath:: /sourcestamps/:ssid/changes
:pathkey integer ssid: the ID of the sourcestamp

This path lists all changes related to a sourcestamp


.. bb:rpath:: /changes/:changeid
Expand Down Expand Up @@ -81,4 +87,3 @@ All update methods are available as attributes of ``master.data.updates``.
All parameters labeled 'unicode' must be unicode strings and not bytestrings.
Filenames in ``files``, and property names, must also be unicode strings.
This is tested by the fake implementation.

0 comments on commit 67d4413

Please sign in to comment.