hgpoll.py

Fri, 28 Nov 2014 22:45:55 -0500

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Fri, 28 Nov 2014 22:45:55 -0500
changeset 94
2c93636202a5
parent 91
60ead38a61af
child 97
55d7d9aea160
permissions
-rw-r--r--

- argrrgh

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

mercurial