Skip to content

Commit

Permalink
use data api to get the change for a sourcestamp
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Tardy <pierre.tardy@intel.com>
  • Loading branch information
Pierre Tardy committed Jan 23, 2015
1 parent 3f160a8 commit 18fa7d1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 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
9 changes: 3 additions & 6 deletions master/buildbot/process/buildrequest.py
Expand Up @@ -119,7 +119,7 @@ def asDict(self):


class TempChange(object):
# temporary fake change; attributes are added below
# temporary fake change

def __init__(self, d):
for k, v in d.items():
Expand Down Expand Up @@ -229,11 +229,8 @@ def _make_br(cls, brid, brdict, master):
else:
ss.patch = None
ss.patch_info = (None, None)
ss.changes = []
change = yield master.db.changes.getChangeFromSSid(ss.ssid)
if change:
ss.changes.append(TempChange(change))
# 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
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 18fa7d1

Please sign in to comment.