Skip to content

Commit

Permalink
Convert mercurial to use attribute group for 'mode'
Browse files Browse the repository at this point in the history
  • Loading branch information
seankelly committed Mar 3, 2015
1 parent ac2f957 commit 1ef6719
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions master/buildbot/steps/source/mercurial.py
Expand Up @@ -33,7 +33,6 @@ class Mercurial(Source):
name = "hg"

renderables = ["repourl"]
possible_modes = ('incremental', 'full')
possible_methods = (None, 'clean', 'fresh', 'clobber')
possible_branchTypes = ('inrepo', 'dirname')

Expand Down Expand Up @@ -77,9 +76,9 @@ def __init__(self, repourl=None, mode='incremental',
Source.__init__(self, **kwargs)

errors = []
if self.mode not in self.possible_modes:
if not self._hasAttrGroupMember('mode', self.mode):
errors.append("mode %s is not one of %s" %
(self.mode, self.possible_modes))
(self.mode, self._listAttrGroupMembers('mode')))
if self.method not in self.possible_methods:
errors.append("method %s is not one of %s" %
(self.method, self.possible_methods))
Expand Down Expand Up @@ -114,10 +113,7 @@ def checkInstall(hgInstalled):
elif self.branchType == 'inrepo':
self.update_branch = (branch or 'default')

if self.mode == 'full':
d.addCallback(lambda _: self.full())
elif self.mode == 'incremental':
d.addCallback(lambda _: self.incremental())
d.addCallback(self._getAttrGroupMember('mode', self.mode))

if patch:
d.addCallback(self.patch, patch)
Expand All @@ -127,7 +123,7 @@ def checkInstall(hgInstalled):
d.addErrback(self.failed)

@defer.inlineCallbacks
def full(self):
def mode_full(self, _):
if self.method == 'clobber':
yield self.clobber()
return
Expand All @@ -143,7 +139,7 @@ def full(self):
else:
raise ValueError("Unknown method, check your configuration")

def incremental(self):
def mode_incremental(self, _):
if self.method is not None:
raise ValueError(self.method)

Expand Down

0 comments on commit 1ef6719

Please sign in to comment.