Skip to content

Commit

Permalink
Make sure that SourceStamp.revision=None is not 'None' when using the
Browse files Browse the repository at this point in the history
latest change's revision to calculate the SourceStamp's revision

Fixes: buildbot#864
  • Loading branch information
Chris AtLee committed Jun 22, 2010
1 parent a9fcc09 commit 6e717ac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
12 changes: 7 additions & 5 deletions master/buildbot/sourcestamp.py
Expand Up @@ -41,27 +41,29 @@ class SourceStamp(util.ComparableMixin, styles.Versioned):

def __init__(self, branch=None, revision=None, patch=None,
changes=None, project='', repository=''):
if revision is not None:
if isinstance(revision, int):
revision = str(revision)
if patch is not None:
assert len(patch) == 2
assert int(patch[0]) != -1
self.branch = branch
self.revision = revision
self.patch = patch
self.project = project
self.repository = repository
if changes:
self.changes = tuple(changes)
# set branch and revision to most recent change
self.branch = changes[-1].branch
self.revision = str(changes[-1].revision)
revision = changes[-1].revision
if not self.project:
self.project = changes[-1].project
if not self.repository:
self.repository = changes[-1].repository

if revision is not None:
if isinstance(revision, int):
revision = str(revision)

self.revision = revision

def canBeMergedWith(self, other):
if other.repository != self.repository:
return False
Expand Down
11 changes: 11 additions & 0 deletions master/buildbot/test/regressions/test_sourcestamp_revision.py
@@ -0,0 +1,11 @@
from twisted.trial import unittest

from buildbot.sourcestamp import SourceStamp
from buildbot.changes.changes import Change

class TestSourceStampRevision(unittest.TestCase):
def testNoRevision(self):
c = Change(who="catlee", files=["foo"], comments="", branch="b1", revision=None)
ss = SourceStamp(changes=[c])

self.assertEquals(ss.revision, None)

0 comments on commit 6e717ac

Please sign in to comment.