Skip to content

Commit

Permalink
Only persist non-runtime properties in rebuilds.
Browse files Browse the repository at this point in the history
Properties which are set at runtime by a build step
should not be persisted to a new build. Fixes #889.
  • Loading branch information
Amber Yust committed Oct 4, 2010
1 parent 790ba89 commit 3265cfc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
9 changes: 4 additions & 5 deletions master/buildbot/process/builder.py
Expand Up @@ -976,12 +976,11 @@ def rebuildBuild(self, bs, reason="<rebuild, no reason given>", extraProperties=
return

ss = bs.getSourceStamp(absolute=True)
# Make a copy so as not to modify the original build.
properties = Properties()
# Don't include runtime-set properties in a rebuild request
properties.updateFromPropertiesNoRuntime(bs.getProperties())
if extraProperties is None:
properties = bs.getProperties()
else:
# Make a copy so as not to modify the original build.
properties = Properties()
properties.updateFromProperties(bs.getProperties())
properties.updateFromProperties(extraProperties)
self.submitBuildRequest(ss, reason, props=properties)

Expand Down
4 changes: 2 additions & 2 deletions master/buildbot/process/buildstep.py
Expand Up @@ -671,8 +671,8 @@ def setProgress(self, metric, value):
def getProperty(self, propname):
return self.build.getProperty(propname)

def setProperty(self, propname, value, source="Step"):
self.build.setProperty(propname, value, source)
def setProperty(self, propname, value, source="Step", runtime=True):
self.build.setProperty(propname, value, source, runtime=runtime)

def startStep(self, remote):
"""Begin the step. This returns a Deferred that will fire when the
Expand Down
19 changes: 17 additions & 2 deletions master/buildbot/process/properties.py
Expand Up @@ -25,6 +25,9 @@ def __init__(self, **kwargs):
@param kwargs: initial property values (for testing)
"""
self.properties = {}
# Track keys which are 'runtime', and should not be
# persisted if a build is rebuilt
self.runtime = set()
self.pmap = PropertyMap(self)
if kwargs: self.update(kwargs, "TEST")

Expand Down Expand Up @@ -64,17 +67,29 @@ def asList(self):
def __repr__(self):
return repr(dict([ (k,v[0]) for k,v in self.properties.iteritems() ]))

def setProperty(self, name, value, source):
def setProperty(self, name, value, source, runtime=False):
self.properties[name] = (value, source)
if runtime:
self.runtime.add(name)

def update(self, dict, source):
def update(self, dict, source, runtime=False):
"""Update this object from a dictionary, with an explicit source specified."""
for k, v in dict.items():
self.properties[k] = (v, source)
if runtime:
self.runtime.add(k)

def updateFromProperties(self, other):
"""Update this object based on another object; the other object's """
self.properties.update(other.properties)
self.runtime.update(other.runtime)

def updateFromPropertiesNoRuntime(self, other):
"""Update this object based on another object, but don't
include properties that were marked as runtime."""
for k,v in other.properties.iteritems():
if k not in other.runtime:
self.properties[k] = v

def render(self, value):
"""
Expand Down

0 comments on commit 3265cfc

Please sign in to comment.