Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: scripts/master/buildbucket/buildbot_gateway.py

Issue 2157703002: buildbucket: support unique change urls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: nits Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « scripts/master/buildbucket/__init__.py ('k') | scripts/master/buildbucket/changestore.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """This file encapsulates most of buildbot API for BuildBucketIntegrator.""" 5 """This file encapsulates most of buildbot API for BuildBucketIntegrator."""
6 6
7 from buildbot.changes.changes import Change 7 from buildbot.changes.changes import Change
8 from buildbot.interfaces import IControl 8 from buildbot.interfaces import IControl
9 from buildbot.process.buildrequest import BuildRequest 9 from buildbot.process.buildrequest import BuildRequest
10 from buildbot.status import builder as build_results 10 from buildbot.status import builder as build_results
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 self.master = master 83 self.master = master
84 84
85 def find_changes_by_revision(self, revision): 85 def find_changes_by_revision(self, revision):
86 """Searches for Changes in database by |revision| and returns change ids.""" 86 """Searches for Changes in database by |revision| and returns change ids."""
87 def find(conn): 87 def find(conn):
88 table = self.master.db.model.changes 88 table = self.master.db.model.changes
89 q = sa.select([table.c.changeid]).where(table.c.revision == revision) 89 q = sa.select([table.c.changeid]).where(table.c.revision == revision)
90 return [row.changeid for row in conn.execute(q)] 90 return [row.changeid for row in conn.execute(q)]
91 return self.master.db.pool.do(find) 91 return self.master.db.pool.do(find)
92 92
93 def find_changes_by_revlink(self, revlink):
94 """Searches for Changes in database by |revlink| and returns change ids."""
95 def find(conn):
96 table = self.master.db.model.changes
97 q = sa.select([table.c.changeid]).where(table.c.revlink == revlink)
98 return [row.changeid for row in conn.execute(q)]
99 return self.master.db.pool.do(find)
100
93 @inlineCallbacks 101 @inlineCallbacks
94 def get_change_by_id(self, change_id): 102 def get_change_by_id(self, change_id):
95 """Returns buildot.changes.changes.Change as Deferred for |change_id|.""" 103 """Returns buildot.changes.changes.Change as Deferred for |change_id|."""
96 chdict = yield self.master.db.changes.getChange(change_id) 104 chdict = yield self.master.db.changes.getChange(change_id)
97 change = yield Change.fromChdict(self.master, chdict) 105 change = yield Change.fromChdict(self.master, chdict)
98 returnValue(change) 106 returnValue(change)
99 107
100 def get_cache(self, name, miss_fn): 108 def get_cache(self, name, miss_fn):
101 """Returns a buildbot.util.lru.AsyncLRUCache by |name|. 109 """Returns a buildbot.util.lru.AsyncLRUCache by |name|.
102 110
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 return self.master.getStatus().getURLForThing(build) 189 return self.master.getStatus().getURLForThing(build)
182 190
183 def stop_build(self, build, reason): 191 def stop_build(self, build, reason):
184 """Stops the |build|.""" 192 """Stops the |build|."""
185 control = IControl(self.master) # request IControl from self.master. 193 control = IControl(self.master) # request IControl from self.master.
186 builder_control = control.getBuilder(build.getBuilder().getName()) 194 builder_control = control.getBuilder(build.getBuilder().getName())
187 assert builder_control 195 assert builder_control
188 build_control = builder_control.getBuild(build.getNumber()) 196 build_control = builder_control.getBuild(build.getNumber())
189 assert build_control 197 assert build_control
190 build_control.stopBuild(reason) 198 build_control.stopBuild(reason)
OLDNEW
« no previous file with comments | « scripts/master/buildbucket/__init__.py ('k') | scripts/master/buildbucket/changestore.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698