hgpoll.py

Mon, 10 Nov 2014 02:42:57 +0200

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Mon, 10 Nov 2014 02:42:57 +0200
changeset 77
8f45af91a4f3
parent 76
a2fe9ba3041a
child 85
302e2bec51d8
permissions
-rw-r--r--

- added missing global statement

73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
1 import hgapi
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
2 import time
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
3 import re
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
4 import bt as Bt
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
5 import irc as Irc
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
6 from datetime import datetime
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 from configfile import Config
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 g_needCommitsTxtRebuild = True
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 def make_commits_txt():
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 global g_needCommitsTxtRebuild
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
12
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 if g_needCommitsTxtRebuild == False:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 return
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
15
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 print 'Building commits.txt...'
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 # Update zandronum-everything
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18 repo = hgapi.Repo ('zandronum-everything')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 repo.hg_command ('pull', '../zandronum-sandbox')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 repo.hg_command ('pull', '../zandronum-sandbox-stable')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 data = repo.hg_command ('log', '--template', '{node} {date|hgdate}\n')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 f = open ('commits.txt', 'w')
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
23
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 for line in data.split ('\n'):
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 if line == '':
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 continue
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
27
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 words = line.split (' ')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 timestamp = int (words[1])
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 f.write ('%s %s\n' % (words[0], datetime.utcfromtimestamp (timestamp).strftime ('%y%m%d-%H%M')))
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
31
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 f.close()
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 g_needCommitsTxtRebuild = False
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 ' Check if a repository exists '
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 def check_repo_exists (repo_name, repo_owner):
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 print 'Checking that %s exists...' % repo_name
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 zanrepo = hgapi.Repo (repo_name)
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
40
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 try:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 zanrepo.hg_command ('id', '.')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 except hgapi.hgapi.HgException:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 # If the repo does not exist, clone it. zandronum-everything can be spawned off other repos though
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 if repo_name == 'zandronum-everything':
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 if not os.path.exists (repo_name):
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 os.makedirs (repo_name)
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
48
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 global g_needCommitsTxtRebuild
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 g_needCommitsTxtRebuild = True
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 print 'Init %s' % repo_name
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 zanrepo.hg_command ('init')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 print 'Cloning zandronum-sandbox into %s' % repo_name
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 zanrepo.hg_command ('pull', '../zandronum-sandbox')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 print 'Cloning zandronum-sandbox-stable into %s' % repo_name
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 zanrepo.hg_command ('pull', '../zandronum-sandbox-stable')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 print 'Done'
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 make_commits_txt()
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 return
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
60
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 try:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 print 'Cloning %s...' % repo_name
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 zanrepo.hg_clone (repo_url, repo_name)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 print 'Cloning done.'
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 except Exception as e:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 print 'Unable to clone %s from %s: %s' % (repo_name, repo_url, str (`e`))
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
67 quit (1)
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
69 def init():
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
70 check_repo_exists ('zandronum', 'Torr_Samaho')
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
71 check_repo_exists ('zandronum-stable', 'Torr_Samaho')
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
72 check_repo_exists ('zandronum-sandbox', 'crimsondusk')
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
73 check_repo_exists ('zandronum-sandbox-stable', 'crimsondusk')
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
74 check_repo_exists ('zandronum-everything', '')
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
75 global repocheck_timeout
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
76 repocheck_timeout = (time.time()) + 15
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 def get_commit_data (zanrepo, rev, template):
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 return zanrepo.hg_command ('log', '-l', '1', '-r', rev, '--template', template)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
80
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
81 def decipher_hgapi_error (e):
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82 # Blah, hgapi, why must your error messages be so mangled?
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 try:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
84 rawmsg = e.message.replace('\n', '').replace('" +','').replace('\t','')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85 errmsg = re.compile (r'.*: tErr: (.*)Out:.*').match (rawmsg).group (1)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 return [True, errmsg]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 except:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88 return [False, '']
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
90 def bbcodify (commit_diffstat):
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
91 result = ''
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
92
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 for line in commit_diffstat.split('\n'):
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94 rex = re.compile (r'^(.*)\|(.*) (\+*)(-*)(.*)$')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95 match = rex.match (line)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 if match:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 line = '%s|%s [color=#5F7]%s[/color][color=#F53]%s[/color]%s\n' \
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98 % (match.group (1), match.group (2), match.group (3), match.group (4), match.group (5))
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
99
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100 # Tracker doesn't seem to like empty color tags
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101 line = line.replace ('[color=#5F7][/color]', '').replace ('[color=#F53][/color]', '')
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
102
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103 result += line
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
104
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
105 return result
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
106
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
107 def poll():
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
108 global repocheck_timeout
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
109 if time.time() < repocheck_timeout:
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
110 return
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
111
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112 for n in ['zandronum-stable', 'zandronum', 'zandronum-sandbox', 'zandronum-sandbox-stable']:
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
113 poll_one_repo (n)
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
114
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
115 hgns = Config.get_node ('hg')
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
116 repocheck_timeout = time.time() + hgns.get_value ('checkinterval', default=15) * 60
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
118 def poll_one_repo (repo_name):
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119 global repocheck_timeout
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120 hgns = Config.get_node ('hg')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 if not hgns.get_value ('track', default=True):
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123 return
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
124
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125 usestable = repo_name == 'zandronum-stable'
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126 usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable'
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
127 repo_owner = 'Torr_Samaho' if not usesandbox else 'crimsondusk'
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128 repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129 num_commits = 0
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 zanrepo = hgapi.Repo (repo_name)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131 commit_data = []
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 delimeter = '@@@@@@@@@@'
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
133 print 'Checking %s for updates' % repo_name
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
134
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
135 try:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136 data = zanrepo.hg_command ('incoming', '--quiet', '--template',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137 '{node|short} {desc}' + delimeter)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138 except hgapi.hgapi.HgException as e:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139 deciphered = decipher_hgapi_error (e)
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
140
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
141 if deciphered[0] and len(deciphered[1]) > 0:
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
142 Irc.broadcast ("error while using hg import on %s: %s" % (repo_name, deciphered[1]))
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
143
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 return
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145 except Exception as e:
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
146 Irc.broadcast ("%s" % `e`)
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147 return
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
148
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
149 for line in data.split (delimeter):
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
150 if line == '':
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151 continue
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
152
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
153 rex = re.compile (r'([^ ]+) (.+)')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
154 match = rex.match (line)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
155 failed = False
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
156
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157 if not match:
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
158 Irc.broadcast ('malformed hg data: %s' % line)
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
159 continue
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
160
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
161 commit_node = match.group (1)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
162 commit_message = match.group (2)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
163 commit_data.append ([commit_node, commit_message])
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
164
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
165 print '%d new commits on %s' % (len (commit_data), repo_name)
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
166
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
167 if len (commit_data) > 0:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168 pull_args = [];
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
169
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
170 for commit in commit_data:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
171 pull_args.append ('-r');
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
172 pull_args.append (commit[0]);
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
173
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
174 print 'Pulling new commits...'
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
175 try:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176 zanrepo.hg_command ('pull', *pull_args)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
177
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
178 # Also pull these commits to the zandronum main repository
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
179 if usestable:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
180 devrepo = hgapi.Repo ('zandronum')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181 devrepo.hg_command ('pull', '../zandronum-stable', *pull_args)
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
182
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
183 # Pull everything into sandboxes too
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
184 if not usesandbox:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
185 devrepo = hgapi.Repo ('zandronum-sandbox')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
187
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
188 devrepo = hgapi.Repo ('zandronum-sandbox-stable')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
189 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args)
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
190
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
191 devrepo = hgapi.Repo ('zandronum-everything')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
192 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
193
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
194 global g_needCommitsTxtRebuild
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
195 g_needCommitsTxtRebuild = True
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
196 except Exception as e:
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
197 Irc.broadcast ('Warning: unable to pull: %s' % `e`)
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
198 return
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
199
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
200 for commit in commit_data:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201 commit_node = commit[0]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
202 commit_message = commit[1]
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
203 print 'Processing new commit %s...' % commit_node
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
204
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
205 try:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
206 if usesandbox:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207 commit_author = get_commit_data (zanrepo, commit_node, '{author}')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
208 commit_url = '%s/commits/%s' % (repo_url, commit_node)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
209 commit_email = ''
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
210
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211 # Remove the email address from the author if possible
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
212 rex = re.compile (r'^(.+) <([^>]+)>$.*')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
213 match = rex.match (commit_author)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
214 if match:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
215 commit_author = match.group (1)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
216 commit_email = match.group (2)
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
217
76
a2fe9ba3041a - various fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 73
diff changeset
218 commit_trackeruser = Config.find_developer_by_email (commit_email)
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
219 committer = commit_trackeruser if commit_trackeruser != '' else commit_author
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
220
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
221 for irc_client in Irc.all_clients:
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
222 for channel in irc_client.channels:
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
223 if channel.get_value ('btprivate', False):
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
224 irc_client.privmsg (channel.get_value ('name'),
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
225 "%s: new commit %s by %s: %s"
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
226 % (repo_name, commit_node, committer, commit_url))
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
227
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
228 for line in commit_message.split ('\n'):
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
229 irc_client.privmsg (channel.get_value ('name'), line)
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
230
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
231 num_commits += 1
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
232 continue
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
233
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
234 rex = re.compile (r'^.*(fixes|resolves|addresses|should fix) ([0-9]+).*$')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
235 match = rex.match (commit_message)
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
236
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
237 if not match:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
238 continue # no "fixes" message in the commit
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
239
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
240 ticket_id = int (match.group (2))
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
241
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
242 # Acquire additional data
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
243 moredata = get_commit_data (zanrepo, commit_node,
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
244 '{author|nonempty}\n{date(date, \'%A %d %B %Y %T\')}').split('\n')
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
245
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
246 if len (moredata) != 2:
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
247 Irc.broadcast ('error while processing %s: malformed hg data' % commit_node)
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
248 continue
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
249
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
250 commit_author = moredata[0]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
251 commit_date = moredata[1]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
252 commit_email = ""
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
253
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
254 try:
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
255 ticket_data = Bt.get_issue (ticket_id)
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
256 except Exception as e:
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
257 Irc.broadcast ('error while processing %s: %s' % (commit_node, `e`))
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
258 continue
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
259
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
260 # Remove the email address from the author if possible
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
261 rex = re.compile (r'^(.+) <([^>]+)>$.*')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
262 match = rex.match (commit_author)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
263 if match:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
264 commit_author = match.group (1)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
265 commit_email = match.group (2)
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
266
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
267 commit_diffstat = zanrepo.hg_command ('diff', '--change', commit_node, '--stat')
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
268
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
269 if len(commit_diffstat) > 0:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
270 # commit_diffstat = 'Changes in files:\n[code]\n' + commit_diffstat + '\n[/code]'
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
271 commit_diffstat = 'Changes in files:\n' + bbcodify(commit_diffstat)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
272 else:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
273 commit_diffstat = 'No changes in files.'
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
274
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
275 # Compare the email addresses against known developer usernames
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
276 commit_trackeruser = find_developer_by_email (commit_email)
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
277
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
278 if commit_trackeruser != '':
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
279 commit_author += ' [%s]' % commit_trackeruser
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
280
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
281 message = 'Issue addressed by commit %s: [b][url=%s/commits/%s]%s[/url][/b]' \
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
282 % (commit_node, repo_url, commit_node, commit_message)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
283 message += "\nCommitted by %s on %s\n\n%s" \
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
284 % (commit_author, commit_date, commit_diffstat)
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
285
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
286 need_update = False
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
287
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
288 # If not already set, set handler
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
289 if not 'handler' in ticket_data:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
290 ticket_data['handler'] = {'name': commit_trackeruser}
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
291 need_update = True
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
292
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
293 # Find out the status level of the ticket
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
294 needs_testing_level = 70
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
295
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
296 if ticket_data['status']['id'] < needs_testing_level:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
297 ticket_data.status['id'] = needs_testing_level
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
298 need_update = True
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
299
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
300 # Set target version if not set
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
301 if not 'target_version' in ticket_data:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
302 ticket_data['target_version'] = '1.4' if repo_name == 'zandronum-stable' else '2.0'
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
303 need_update = True
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
304 elif (ticket_data['target_version'] == '2.0' or ticket_data['target_version'] == '2.0-beta') \
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
305 and repo_name == 'zandronum-stable':
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
306 # Target version was 2.0 but this was just committed to zandronum-stable, adjust
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
307 ticket_data['target_version'] = '1.4'
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
308 need_update = True
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
309 elif ticket_data['target_version'] == '2.0-beta':
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
310 # Fix target version from 2.0-beta to 2.0
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
311 ticket_data['target_version'] = '2.0'
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
312 need_update = True
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
313
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
314 # Announce on IRC
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
315 for irc_client in Irc.all_clients:
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
316 for channel in irc_client.channels:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
317 if channel.get_value ('btannounce', default=True):
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
318 irc_client.privmsg (channel.get_value ('name'),
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
319 "%s: commit %s fixes issue %d: %s"
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
320 % (repo_name, commit_node, ticket_id, commit_message))
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
321 irc_client.privmsg (channel.get_value ('name'),
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
322 "Read all about it here: " + Bt.get_ticket_url (ticket_id))
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
323
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
324 if need_update:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
325 # We need to remove the note data, otherwise the ticket notes
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
326 # will get unnecessary updates. WTF, MantisBT?
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
327 ticket_data.notes = []
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
328 Bt.update_issue (ticket_id, ticket_data)
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
329
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
330 Bt.post_note (ticket_id, message)
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
331 num_commits += 1
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
332 except Exception as e:
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
333 Irc.broadcast ('Error while processing %s: %s' % (commit_node, e))
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
334 continue
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
335
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
336 def force_poll():
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
337 global repocheck_timeout
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
338 repocheck_timeout = 0
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
339 poll()

mercurial