hgpoll.py

changeset 167
032c90f1727b
parent 166
2ddfa9840eea
equal deleted inserted replaced
166:2ddfa9840eea 167:032c90f1727b
37 import random 37 import random
38 from hgrepo import HgRepository 38 from hgrepo import HgRepository
39 from hgdb import HgCommitsDatabase 39 from hgdb import HgCommitsDatabase
40 import traceback 40 import traceback
41 import sys 41 import sys
42 from munge import munge
43 import datetime 42 import datetime
44 43
45 Repositories = [] 44 Repositories = []
46 RepositoriesByName = {} 45 RepositoriesByName = {}
47 46
170 # Announce on IRC 169 # Announce on IRC
171 for irc_client in Irc.all_clients: 170 for irc_client in Irc.all_clients:
172 for channel in irc_client.channels: 171 for channel in irc_client.channels:
173 if channel.get_value ('btannounce', default=True): 172 if channel.get_value ('btannounce', default=True):
174 irc_client.privmsg (channel.get_value ('name'), 173 irc_client.privmsg (channel.get_value ('name'),
175 "\003%d%s\003: commit\0035 %s\003 addresses issue\002\0032 %d\002: %s" % \ 174 "\003%d%s\003: commit\0035 %s\003 addresses issue\002\0032 %d\002\003: %s" % \
176 (repo.color, repo.name, cset, ticket_id), Bt.get_ticket_url(ticket_id)) 175 (repo.color, repo.name, cset, ticket_id, Bt.get_ticket_url(ticket_id)))
177 176
178 if need_update: 177 if need_update:
179 # We need to remove the note data, otherwise the ticket notes 178 # We need to remove the note data, otherwise the ticket notes
180 # will get unnecessary updates. WTF, MantisBT? 179 # will get unnecessary updates. WTF, MantisBT?
181 ticket_data.notes = [] 180 ticket_data.notes = []
276 print ('''I already know of %s - they're in %s - not announcing.''' % 275 print ('''I already know of %s - they're in %s - not announcing.''' %
277 (commit['node'], existingrepos)) 276 (commit['node'], existingrepos))
278 continue 277 continue
279 278
280 username = Config.find_developer_by_email (commit['email']) 279 username = Config.find_developer_by_email (commit['email'])
281 committer = munge (username if username else commit['author']) 280 committer = username if username else commit['author']
282 descriptor = """commit""" if random.randrange (100) != 0 else """KERMIT""" 281 descriptor = """commit""" if random.randrange (100) != 0 else """KERMIT"""
283 282
284 if not isMergeFromSandbox: 283 if not isMergeFromSandbox:
285 commitMessage = """\003%d%s\003: new %s\0035 %s%s\003 by\0032 %s\003: %s""" % \ 284 commitMessage = """\003%d%s\003: new %s\0035 %s%s\003 by\0032 %s\003: %s""" % \
286 (repo.color, repo.name, descriptor, commit['node'], commit['bookmarks'], 285 (repo.color, repo.name, descriptor, commit['node'], commit['bookmarks'],
292 commitMessage += ": %s" % commit['message'] 291 commitMessage += ": %s" % commit['message']
293 292
294 for length in [LENGTH_MINIMUM, LENGTH_SHORT, LENGTH_FULL]: 293 for length in [LENGTH_MINIMUM, LENGTH_SHORT, LENGTH_FULL]:
295 messages[length].append (commitMessage) 294 messages[length].append (commitMessage)
296 295
297 if not multiline: 296 if multiline:
298 messages[LENGTH_SHORT].append (' ' + commit['message'].splitlines()[0]) 297 messages[LENGTH_SHORT].append (' ' + commit['message'].splitlines()[0])
299 298
300 for line in commit['message'].splitlines()[:4]: 299 for line in commit['message'].splitlines()[:4]:
301 messages[LENGTH_FULL].append (' ' + line) 300 messages[LENGTH_FULL].append (' ' + line)
302 else: 301 else:

mercurial