hgpoll.py

changeset 108
8cf31b4d5fcb
parent 101
5e32ab7ae823
child 109
87ad0c1b3405
equal deleted inserted replaced
107:14e1d18d2a2a 108:8cf31b4d5fcb
276 commit_data.append ([commit_node, commit_message]) 276 commit_data.append ([commit_node, commit_message])
277 277
278 process_new_commits (repo_name, commit_data) 278 process_new_commits (repo_name, commit_data)
279 279
280 def process_new_commits (repo_name, commit_data): 280 def process_new_commits (repo_name, commit_data):
281 if len (commit_data) == 0:
282 return
283
281 usestable = repo_name == 'zandronum-stable' 284 usestable = repo_name == 'zandronum-stable'
282 usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable' 285 usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable'
283 repo_owner = 'Torr_Samaho' if not usesandbox else 'crimsondusk' 286 repo_owner = 'Torr_Samaho' if not usesandbox else 'crimsondusk'
284 repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name) 287 repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name)
285 num_commits = 0 288 num_commits = 0
286 zanrepo = hgapi.Repo (repo_name) 289 zanrepo = hgapi.Repo (repo_name)
287 Irc.broadcast ('%d new commits on %s' % (len (commit_data), repo_name)) 290 Irc.broadcast ('%d new commits on %s' % (len (commit_data), repo_name))
288 291
289 if len (commit_data) > 0: 292 # Drop commits that we already have
290 pull_args = []; 293 i = 0
291 294 while i < len (commit_data):
292 for commit in commit_data:
293 pull_args.append ('-r');
294 pull_args.append (commit[0]);
295
296 print 'Pulling new commits...'
297 try: 295 try:
298 zanrepo.hg_command ('pull', *pull_args) 296 zanrepo.hg_command ('log', '-r' commit_data[i][0])
299 297 del commit_data[i]
300 # Also pull these commits to the zandronum main repository 298 except:
301 if usestable: 299 i += 1
302 devrepo = hgapi.Repo ('zandronum') 300
303 devrepo.hg_command ('pull', '../zandronum-stable', *pull_args) 301 pull_args = [];
304 302
305 # Pull everything into sandboxes too 303 for commit in commit_data:
306 if not usesandbox: 304 pull_args.append ('-r');
307 devrepo = hgapi.Repo ('zandronum-sandbox') 305 pull_args.append (commit[0]);
308 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args) 306
309 307 print 'Pulling new commits...'
310 devrepo = hgapi.Repo ('zandronum-sandbox-stable') 308 try:
311 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args) 309 zanrepo.hg_command ('pull', *pull_args)
312 310
313 devrepo = hgapi.Repo ('zandronum-everything') 311 # Also pull these commits to the zandronum main repository
312 if usestable:
313 devrepo = hgapi.Repo ('zandronum')
314 devrepo.hg_command ('pull', '../zandronum-stable', *pull_args)
315 # Pull everything into sandboxes too
316 if not usesandbox:
317 devrepo = hgapi.Repo ('zandronum-sandbox')
314 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args) 318 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args)
315 319
316 global g_needCommitsTxtRebuild 320 devrepo = hgapi.Repo ('zandronum-sandbox-stable')
317 g_needCommitsTxtRebuild = True 321 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args)
318 except Exception as e: 322
319 Irc.broadcast ('Warning: unable to pull: %s' % `e`) 323 devrepo = hgapi.Repo ('zandronum-everything')
320 return 324 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args)
325
326 global g_needCommitsTxtRebuild
327 g_needCommitsTxtRebuild = True
328
329 except Exception as e:
330 Irc.broadcast ('Warning: unable to pull: %s' % `e`)
331 return
321 332
322 for commit in commit_data: 333 for commit in commit_data:
323 commit_node = commit[0] 334 commit_node = commit[0]
324 commit_message = commit[1] 335 commit_message = commit[1]
325 print 'Processing new commit %s...' % commit_node 336 print 'Processing new commit %s...' % commit_node

mercurial