Package buildbot :: Module buildrequest
[frames] | no frames]

Source Code for Module buildbot.buildrequest

  1  # ***** BEGIN LICENSE BLOCK ***** 
  2  # Version: MPL 1.1/GPL 2.0/LGPL 2.1 
  3  # 
  4  # The contents of this file are subject to the Mozilla Public License Version 
  5  # 1.1 (the "License"); you may not use this file except in compliance with 
  6  # the License. You may obtain a copy of the License at 
  7  # http://www.mozilla.org/MPL/ 
  8  # 
  9  # Software distributed under the License is distributed on an "AS IS" basis, 
 10  # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
 11  # for the specific language governing rights and limitations under the 
 12  # License. 
 13  # 
 14  # The Original Code is Mozilla-specific Buildbot steps. 
 15  # 
 16  # The Initial Developer of the Original Code is 
 17  # Mozilla Foundation. 
 18  # Portions created by the Initial Developer are Copyright (C) 2009 
 19  # the Initial Developer. All Rights Reserved. 
 20  # 
 21  # Contributor(s): 
 22  #   Brian Warner <warner@lothar.com> 
 23  # 
 24  # Alternatively, the contents of this file may be used under the terms of 
 25  # either the GNU General Public License Version 2 or later (the "GPL"), or 
 26  # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 
 27  # in which case the provisions of the GPL or the LGPL are applicable instead 
 28  # of those above. If you wish to allow use of your version of this file only 
 29  # under the terms of either the GPL or the LGPL, and not to allow others to 
 30  # use your version of this file under the terms of the MPL, indicate your 
 31  # decision by deleting the provisions above and replace them with the notice 
 32  # and other provisions required by the GPL or the LGPL. If you do not delete 
 33  # the provisions above, a recipient may use your version of this file under 
 34  # the terms of any one of the MPL, the GPL or the LGPL. 
 35  # 
 36  # ***** END LICENSE BLOCK ***** 
 37   
 38  from buildbot import interfaces 
 39  from buildbot.process.properties import Properties 
 40   
41 -class BuildRequest:
42 """I represent a request to a specific Builder to run a single build. 43 44 I am generated by db.getBuildRequestWithNumber, and am used to tell the 45 Build about what it ought to be building. I am also used by the Builder 46 to let hook functions decide which requests should be handled first. 47 48 I have a SourceStamp which specifies what sources I will build. This may 49 specify a specific revision of the source tree (so source.branch, 50 source.revision, and source.patch are used). The .patch attribute is 51 either None or a tuple of (patchlevel, diff), consisting of a number to 52 use in 'patch -pN', and a unified-format context diff. 53 54 Alternatively, the SourceStamp may specify a set of Changes to be built, 55 contained in source.changes. In this case, I may be mergeable with other 56 BuildRequests on the same branch. 57 58 @type source: a L{buildbot.sourcestamp.SourceStamp} instance. 59 @ivar source: the source code that this BuildRequest use 60 61 @type reason: string 62 @ivar reason: the reason this Build is being requested. Schedulers 63 provide this, but for forced builds the user requesting the 64 build will provide a string. 65 66 @type properties: Properties object 67 @ivar properties: properties that should be applied to this build 68 'owner' property is used by Build objects to collect 69 the list returned by getInterestedUsers 70 71 @ivar status: the IBuildStatus object which tracks our status 72 73 @ivar submittedAt: a timestamp (seconds since epoch) when this request 74 was submitted to the Builder. This is used by the CVS 75 step to compute a checkout timestamp, as well as the 76 master to prioritize build requests from oldest to 77 newest. 78 """ 79 80 source = None 81 builder = None # XXXREMOVE 82 startCount = 0 # how many times we have tried to start this build # XXXREMOVE 83 submittedAt = None 84
85 - def __init__(self, reason, source, builderName, properties=None):
86 assert interfaces.ISourceStamp(source, None) 87 self.reason = reason 88 self.source = source 89 self.builderName = builderName 90 91 self.properties = Properties() 92 if properties: 93 self.properties.updateFromProperties(properties)
94
95 - def canBeMergedWith(self, other):
96 return self.source.canBeMergedWith(other.source)
97
98 - def mergeWith(self, others):
99 return self.source.mergeWith([o.source for o in others])
100
101 - def mergeReasons(self, others):
102 """Return a reason for the merged build request.""" 103 reasons = [] 104 for req in [self] + others: 105 if req.reason and req.reason not in reasons: 106 reasons.append(req.reason) 107 return ", ".join(reasons)
108 109 # IBuildRequestControl 110
111 - def cancel(self): # XXXREMOVE
112 """Cancel this request. This can only be successful if the Build has 113 not yet been started. 114 115 @return: a boolean indicating if the cancel was successful.""" 116 if self.builder: 117 return self.builder.cancelBuildRequest(self) 118 return False
119
120 - def getSubmitTime(self):
121 return self.submittedAt
122