1
2 import os.path
3
4 from zope.interface import implements
5 from twisted.cred import credentials
6 from twisted.spread import pb
7 from twisted.application.internet import TCPClient
8 from twisted.python import log
9
10 import cvstoys.common
11
12 from buildbot.interfaces import IChangeSource
13 from buildbot.pbutil import ReconnectingPBClientFactory
14 from buildbot.changes.changes import Change
15 from buildbot import util
16
19 try:
20 self.source.notify(root, files, message, user)
21 except Exception:
22 print "notify failed"
23 log.err()
24
27
51
53 """This source will connect to a FreshCVS server associated with one or
54 more CVS repositories. Each time a change is committed to a repository,
55 the server will send us a message describing the change. This message is
56 used to build a Change object, which is then submitted to the
57 ChangeMaster.
58
59 This class handles freshcvs daemons which use newcred. CVSToys-1.0.9
60 does not, later versions might.
61 """
62
63 implements(IChangeSource)
64 compare_attrs = ["host", "port", "username", "password", "prefix"]
65
66 changemaster = None
67 connected = False
68
69 - def __init__(self, host, port, user, passwd, prefix=None):
85
87 return "<FreshCVSSource where=%s, prefix=%s>" % \
88 ((self.host, self.port), self.prefix)
89
91 online = ""
92 if not self.connected:
93 online = " [OFFLINE]"
94 return "freshcvs %s:%s%s" % (self.host, self.port, online)
95
96 - def notify(self, root, files, message, user):
97 pathnames = []
98 isdir = 0
99 for f in files:
100 if not isinstance(f, (cvstoys.common.VersionedPatch,
101 cvstoys.common.Directory)):
102 continue
103 pathname, filename = f.pathname, f.filename
104
105 if isinstance(f, cvstoys.common.Directory):
106 isdir = 1
107 path = os.path.join(pathname, filename)
108 log.msg("FreshCVS notify '%s'" % path)
109 if self.prefix:
110 if path.startswith(self.prefix):
111 path = path[len(self.prefix):]
112 else:
113 continue
114 pathnames.append(path)
115 if pathnames:
116
117 when=util.now()
118 c = Change(user, pathnames, message, isdir, when=when)
119 self.parent.addChange(c)
120
122 """This is for older freshcvs daemons (from CVSToys-1.0.9 and earlier).
123 """
124
125 - def __init__(self, host, port, user, passwd,
126 serviceName="cvstoys.notify", prefix=None):
136
138 return "<FreshCVSSourceOldcred where=%s, prefix=%s>" % \
139 ((self.host, self.port), self.prefix)
140
141
142
143 FreshCVSSource = FreshCVSSourceNewcred
144