hgpoll.py

changeset 111
44d9aea72947
parent 110
b2770c43b752
child 112
cdafc1a0544e
equal deleted inserted replaced
110:b2770c43b752 111:44d9aea72947
19 color = 3 19 color = 3
20 else: 20 else:
21 color = 0 21 color = 0
22 return color 22 return color
23 23
24 def prettify_bookmarks (bookmarks):
25 return "\0036 [\002%s\002]" % bookmarks
26
24 def make_commits_txt(): 27 def make_commits_txt():
25 global g_needCommitsTxtRebuild 28 global g_needCommitsTxtRebuild
26 29
27 if g_needCommitsTxtRebuild == False: 30 if g_needCommitsTxtRebuild == False:
28 return 31 return
221 for line in commit_diffstat.split('\n'): 224 for line in commit_diffstat.split('\n'):
222 rex = re.compile (r'^(.*)\|(.*) (\+*)(-*)(.*)$') 225 rex = re.compile (r'^(.*)\|(.*) (\+*)(-*)(.*)$')
223 match = rex.match (line) 226 match = rex.match (line)
224 if match: 227 if match:
225 line = '%s|%s [color=#5F7]%s[/color][color=#F53]%s[/color]%s\n' \ 228 line = '%s|%s [color=#5F7]%s[/color][color=#F53]%s[/color]%s\n' \
226 % (match.group (1), match.group (2), match.group (3), match.group (4), match.group 229 % (match.group (1), match.group (2), match.group (3),
227 (5)) 230 match.group (4), match.group (5))
228 231
229 # Tracker doesn't seem to like empty color tags 232 # Tracker doesn't seem to like empty color tags
230 line = line.replace ('[color=#5F7][/color]', '').replace ('[color=#F53][/color]', '') 233 line = line.replace ('[color=#5F7][/color]', '').replace ('[color=#F53][/color]', '')
231 234
232 result += line 235 result += line
347 commit_node = commit[0] 350 commit_node = commit[0]
348 commit_message = commit[1] 351 commit_message = commit[1]
349 print 'Processing new commit %s...' % commit_node 352 print 'Processing new commit %s...' % commit_node
350 353
351 try: 354 try:
352 commit_author = get_commit_data (zanrepo, commit_node, '{author}') 355 data = get_commit_data (zanrepo, commit_node, '{author}@@@@@@@@@@{bookmarks}').split ("@@@@@@@@@@")
356 commit_author = data[0]
357 commit_bookmarks = prettify_bookmarks (data[1])
353 commit_url = '%s/commits/%s' % (repo_url, commit_node) 358 commit_url = '%s/commits/%s' % (repo_url, commit_node)
354 commit_email = '' 359 commit_email = ''
355 360
356 # Remove the email address from the author if possible 361 # Remove the email address from the author if possible
357 rex = re.compile (r'^(.+) <([^>]+)>$.*') 362 rex = re.compile (r'^(.+) <([^>]+)>$.*')
365 370
366 for irc_client in Irc.all_clients: 371 for irc_client in Irc.all_clients:
367 for channel in irc_client.channels: 372 for channel in irc_client.channels:
368 if not usesandbox or channel.get_value ('btprivate', False): 373 if not usesandbox or channel.get_value ('btprivate', False):
369 irc_client.privmsg (channel.get_value ('name'), 374 irc_client.privmsg (channel.get_value ('name'),
370 "\003%d%s\003: new commit\0035 %s\003 by\0032 %s\003: %s" 375 "\003%d%s\003: new commit\0035 %s%s\003 by\0032 %s\003: %s"
371 % (color_for_repo (repo_name), repo_name, commit_node, committer, commit_url)) 376 % (color_for_repo (repo_name), repo_name, commit_node, commit_bookmarks,
377 committer, commit_url))
372 378
373 for line in commit_message.split ('\n'): 379 for line in commit_message.split ('\n'):
374 irc_client.privmsg (channel.get_value ('name'), line) 380 irc_client.privmsg (channel.get_value ('name'), line)
375 381
376 if not usesandbox: 382 if not usesandbox:

mercurial