Package buildbot :: Package changes :: Module pb
[frames] | no frames]

Source Code for Module buildbot.changes.pb

  1  # -*- test-case-name: buildbot.test.test_changes -*- 
  2   
  3  from twisted.python import log 
  4   
  5  from buildbot.pbutil import NewCredPerspective 
  6  from buildbot.changes import base, changes 
  7   
8 -class ChangePerspective(NewCredPerspective):
9
10 - def __init__(self, changemaster, prefix):
11 self.changemaster = changemaster 12 self.prefix = prefix
13
14 - def attached(self, mind):
15 return self
16 - def detached(self, mind):
17 pass
18
19 - def perspective_addChange(self, changedict):
20 log.msg("perspective_addChange called") 21 pathnames = [] 22 prefixpaths = None 23 for path in changedict['files']: 24 if self.prefix: 25 if not path.startswith(self.prefix): 26 # this file does not start with the prefix, so ignore it 27 continue 28 path = path[len(self.prefix):] 29 pathnames.append(path) 30 31 if pathnames: 32 change = changes.Change(changedict['who'], 33 pathnames, 34 changedict['comments'], 35 branch=changedict.get('branch'), 36 revision=changedict.get('revision'), 37 revlink=changedict.get('revlink', ''), 38 category=changedict.get('category'), 39 when=changedict.get('when'), 40 properties=changedict.get('properties', {}) 41 ) 42 self.changemaster.addChange(change)
43
44 -class PBChangeSource(base.ChangeSource):
45 compare_attrs = ["user", "passwd", "port", "prefix"] 46
47 - def __init__(self, user="change", passwd="changepw", port=None, 48 prefix=None, sep=None):
49 """I listen on a TCP port for Changes from 'buildbot sendchange'. 50 51 I am a ChangeSource which will accept Changes from a remote source. I 52 share a TCP listening port with the buildslaves. 53 54 The 'buildbot sendchange' command, the contrib/svn_buildbot.py tool, 55 and the contrib/bzr_buildbot.py tool know how to send changes to me. 56 57 @type prefix: string (or None) 58 @param prefix: if set, I will ignore any filenames that do not start 59 with this string. Moreover I will remove this string 60 from all filenames before creating the Change object 61 and delivering it to the Schedulers. This is useful 62 for changes coming from version control systems that 63 represent branches as parent directories within the 64 repository (like SVN and Perforce). Use a prefix of 65 'trunk/' or 'project/branches/foobranch/' to only 66 follow one branch and to get correct tree-relative 67 filenames. 68 69 @param sep: DEPRECATED (with an axe). sep= was removed in 70 buildbot-0.7.4 . Instead of using it, you should use 71 prefix= with a trailing directory separator. This 72 docstring (and the better-than-nothing error message 73 which occurs when you use it) will be removed in 0.7.5 . 74 """ 75 76 # sep= was removed in 0.7.4 . This more-helpful-than-nothing error 77 # message will be removed in 0.7.5 . 78 assert sep is None, "prefix= is now a complete string, do not use sep=" 79 # TODO: current limitations 80 assert user == "change" 81 assert passwd == "changepw" 82 assert port == None 83 self.user = user 84 self.passwd = passwd 85 self.port = port 86 self.prefix = prefix
87
88 - def describe(self):
89 # TODO: when the dispatcher is fixed, report the specific port 90 #d = "PB listener on port %d" % self.port 91 d = "PBChangeSource listener on all-purpose slaveport" 92 if self.prefix is not None: 93 d += " (prefix '%s')" % self.prefix 94 return d
95
96 - def startService(self):
97 base.ChangeSource.startService(self) 98 # our parent is the ChangeMaster object 99 # find the master's Dispatch object and register our username 100 # TODO: the passwd should be registered here too 101 master = self.parent.parent 102 master.dispatcher.register(self.user, self)
103
104 - def stopService(self):
105 base.ChangeSource.stopService(self) 106 # unregister our username 107 master = self.parent.parent 108 master.dispatcher.unregister(self.user)
109
110 - def getPerspective(self):
111 return ChangePerspective(self.parent, self.prefix)
112