hgpoll.py

changeset 112
cdafc1a0544e
parent 111
44d9aea72947
child 115
2bb5c4578ee1
equal deleted inserted replaced
111:44d9aea72947 112:cdafc1a0544e
15 color = 2 15 color = 2
16 elif repo_name == 'zandronum-sandbox': 16 elif repo_name == 'zandronum-sandbox':
17 color = 7 17 color = 7
18 elif repo_name == 'zandronum-sandbox-stable': 18 elif repo_name == 'zandronum-sandbox-stable':
19 color = 3 19 color = 3
20 elif repo_name == 'zfc9000':
21 color = 6
20 else: 22 else:
21 color = 0 23 color = 0
22 return color 24 return color
23 25
24 def prettify_bookmarks (bookmarks): 26 def prettify_bookmarks (bookmarks):
42 if line == '': 44 if line == '':
43 continue 45 continue
44 46
45 words = line.split (' ') 47 words = line.split (' ')
46 timestamp = int (words[1]) 48 timestamp = int (words[1])
47 f.write ('%s %s\n' % (words[0], datetime.utcfromtimestamp (timestamp).strftime 49 f.write ('%s %s\n' % (words[0], datetime.utcfromtimestamp (timestamp).strftime ('%y%m%d-%H%M')))
48 ('%y%m%d-%H%M')))
49 50
50 f.close() 51 f.close()
51 g_needCommitsTxtRebuild = False 52 g_needCommitsTxtRebuild = False
52 53
53 ' Check if a repository exists ' 54 ' Check if a repository exists '
201 check_repo_exists ('zandronum', 'Torr_Samaho') 202 check_repo_exists ('zandronum', 'Torr_Samaho')
202 check_repo_exists ('zandronum-stable', 'Torr_Samaho') 203 check_repo_exists ('zandronum-stable', 'Torr_Samaho')
203 check_repo_exists ('zandronum-sandbox', 'crimsondusk') 204 check_repo_exists ('zandronum-sandbox', 'crimsondusk')
204 check_repo_exists ('zandronum-sandbox-stable', 'crimsondusk') 205 check_repo_exists ('zandronum-sandbox-stable', 'crimsondusk')
205 check_repo_exists ('zandronum-everything', '') 206 check_repo_exists ('zandronum-everything', '')
207 check_repo_exists ('zfc9000', 'crimsondusk')
206 global repocheck_timeout 208 global repocheck_timeout
207 repocheck_timeout = (time.time()) + 15 209 repocheck_timeout = (time.time()) + 15
208 210
209 def get_commit_data (zanrepo, rev, template): 211 def get_commit_data (zanrepo, rev, template):
210 return zanrepo.hg_command ('log', '-l', '1', '-r', rev, '--template', template) 212 return zanrepo.hg_command ('log', '-l', '1', '-r', rev, '--template', template)
239 def poll(): 241 def poll():
240 global repocheck_timeout 242 global repocheck_timeout
241 if time.time() < repocheck_timeout: 243 if time.time() < repocheck_timeout:
242 return 244 return
243 245
244 for n in ['zandronum-stable', 'zandronum', 'zandronum-sandbox', 'zandronum-sandbox-stable']: 246 for n in ['zandronum-stable', 'zandronum', 'zandronum-sandbox', 'zandronum-sandbox-stable', 'zfc9000']:
245 poll_one_repo (n) 247 poll_one_repo (n)
246 248
247 hgns = Config.get_node ('hg') 249 hgns = Config.get_node ('hg')
248 repocheck_timeout = time.time() + hgns.get_value ('checkinterval', default=15) * 60 250 repocheck_timeout = time.time() + hgns.get_value ('checkinterval', default=15) * 60
249 251
253 255
254 if not hgns.get_value ('track', default=True): 256 if not hgns.get_value ('track', default=True):
255 return 257 return
256 258
257 usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable' 259 usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable'
258 repo_owner = 'Torr_Samaho' if not usesandbox else 'crimsondusk' 260 repo_owner = 'Torr_Samaho' if (not usesandbox and repo_name != 'zfc9000') else 'crimsondusk'
259 zanrepo = hgapi.Repo (repo_name) 261 zanrepo = hgapi.Repo (repo_name)
260 commit_data = [] 262 commit_data = []
261 delimeter = '@@@@@@@@@@' 263 delimeter = '@@@@@@@@@@'
262 # print 'Checking %s for updates' % repo_name 264 # print 'Checking %s for updates' % repo_name
263 265
297 if len (commit_data) == 0: 299 if len (commit_data) == 0:
298 return 300 return
299 301
300 usestable = repo_name == 'zandronum-stable' 302 usestable = repo_name == 'zandronum-stable'
301 usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable' 303 usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable'
302 repo_owner = 'Torr_Samaho' if not usesandbox else 'crimsondusk' 304 repo_owner = 'Torr_Samaho' if (not usesandbox and repo_name != 'zfc9000') else 'crimsondusk'
303 repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name) 305 repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name)
304 num_commits = 0 306 num_commits = 0
305 zanrepo = hgapi.Repo (repo_name) 307 zanrepo = hgapi.Repo (repo_name)
306 print '%d new commits on %s' % (len (commit_data), repo_name) 308 print '%d new commits on %s' % (len (commit_data), repo_name)
307 309
322 324
323 print 'Pulling new commits...' 325 print 'Pulling new commits...'
324 try: 326 try:
325 zanrepo.hg_command ('pull', *pull_args) 327 zanrepo.hg_command ('pull', *pull_args)
326 328
327 # Also pull these commits to the zandronum main repository 329 if repo_name[0:9] == 'zandronum':
328 if usestable: 330 # Also pull these commits to the zandronum main repository
329 devrepo = hgapi.Repo ('zandronum') 331 if usestable:
330 devrepo.hg_command ('pull', '../zandronum-stable', *pull_args) 332 devrepo = hgapi.Repo ('zandronum')
331 # Pull everything into sandboxes too 333 devrepo.hg_command ('pull', '../zandronum-stable', *pull_args)
332 if not usesandbox: 334 # Pull everything into sandboxes too
333 devrepo = hgapi.Repo ('zandronum-sandbox') 335 if not usesandbox:
336 devrepo = hgapi.Repo ('zandronum-sandbox')
337 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args)
338
339 devrepo = hgapi.Repo ('zandronum-sandbox-stable')
340 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args)
341
342 devrepo = hgapi.Repo ('zandronum-everything')
334 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args) 343 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args)
335 344
336 devrepo = hgapi.Repo ('zandronum-sandbox-stable') 345 global g_needCommitsTxtRebuild
337 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args) 346 g_needCommitsTxtRebuild = True
338
339 devrepo = hgapi.Repo ('zandronum-everything')
340 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args)
341
342 global g_needCommitsTxtRebuild
343 g_needCommitsTxtRebuild = True
344 347
345 except Exception as e: 348 except Exception as e:
346 Irc.broadcast ('Warning: unable to pull: %s' % `e`) 349 Irc.broadcast ('Warning: unable to pull: %s' % `e`)
347 return 350 return
348 351
368 commit_trackeruser = Config.find_developer_by_email (commit_email) 371 commit_trackeruser = Config.find_developer_by_email (commit_email)
369 committer = commit_trackeruser if commit_trackeruser != '' else commit_author 372 committer = commit_trackeruser if commit_trackeruser != '' else commit_author
370 373
371 for irc_client in Irc.all_clients: 374 for irc_client in Irc.all_clients:
372 for channel in irc_client.channels: 375 for channel in irc_client.channels:
373 if not usesandbox or channel.get_value ('btprivate', False): 376 if not channel.get_value ('btannounce', False):
377 continue
378
379 if (not usesandbox and repo_name != 'zfc9000') or channel.get_value ('btprivate', False):
374 irc_client.privmsg (channel.get_value ('name'), 380 irc_client.privmsg (channel.get_value ('name'),
375 "\003%d%s\003: new commit\0035 %s%s\003 by\0032 %s\003: %s" 381 "\003%d%s\003: new commit\0035 %s%s\003 by\0032 %s\003: %s"
376 % (color_for_repo (repo_name), repo_name, commit_node, commit_bookmarks, 382 % (color_for_repo (repo_name), repo_name, commit_node, commit_bookmarks,
377 committer, commit_url)) 383 committer, commit_url))
378 384

mercurial