From 55446d29be48a92710d34d41632d6279f7a9dbe6 Mon Sep 17 00:00:00 2001 From: Pierre Tardy Date: Fri, 23 Jan 2015 21:40:54 +0100 Subject: [PATCH 1/3] populate the sourcestamp change list Some build step are needing change properties to be mixed in build properties --- master/buildbot/process/buildrequest.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/master/buildbot/process/buildrequest.py b/master/buildbot/process/buildrequest.py index 87649bef900..c4707de6282 100644 --- a/master/buildbot/process/buildrequest.py +++ b/master/buildbot/process/buildrequest.py @@ -118,6 +118,18 @@ def asDict(self): return result +class TempChange(object): + # temporary fake change; attributes are added below + + 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): """ @@ -218,6 +230,9 @@ def _make_br(cls, brid, brdict, master): 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!! defer.returnValue(buildrequest) From 3f160a806dd8795e6ffc5b8c241c89f3cc4160fd Mon Sep 17 00:00:00 2001 From: Pierre Tardy Date: Fri, 23 Jan 2015 21:50:41 +0100 Subject: [PATCH 2/3] fix tests Signed-off-by: Pierre Tardy --- master/buildbot/test/fake/fakedb.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/master/buildbot/test/fake/fakedb.py b/master/buildbot/test/fake/fakedb.py index 9b4f4ea6ffd..3b4b4db1514 100644 --- a/master/buildbot/test/fake/fakedb.py +++ b/master/buildbot/test/fake/fakedb.py @@ -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'] From 18fa7d18367d38aee7113bfe361aebc90b41ccf0 Mon Sep 17 00:00:00 2001 From: Pierre Tardy Date: Fri, 23 Jan 2015 22:04:56 +0100 Subject: [PATCH 3/3] use data api to get the change for a sourcestamp Signed-off-by: Pierre Tardy --- master/buildbot/data/changes.py | 14 +++++++++++--- master/buildbot/process/buildrequest.py | 9 +++------ master/docs/developer/rtype-change.rst | 9 +++++++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/master/buildbot/data/changes.py b/master/buildbot/data/changes.py index d6c10196a78..73bf8dff564 100644 --- a/master/buildbot/data/changes.py +++ b/master/buildbot/data/changes.py @@ -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) diff --git a/master/buildbot/process/buildrequest.py b/master/buildbot/process/buildrequest.py index c4707de6282..c1f2d264bc1 100644 --- a/master/buildbot/process/buildrequest.py +++ b/master/buildbot/process/buildrequest.py @@ -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(): @@ -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) diff --git a/master/docs/developer/rtype-change.rst b/master/docs/developer/rtype-change.rst index a17b4027ef5..0199766d981 100644 --- a/master/docs/developer/rtype-change.rst +++ b/master/docs/developer/rtype-change.rst @@ -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 @@ -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. -