Mon, 05 Oct 2015 23:35:44 +0300
Calculator now supports variables
124
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
1 | ''' |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
2 | Copyright 2014-2015 Teemu Piippo |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
3 | All rights reserved. |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
4 | |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
5 | Redistribution and use in source and binary forms, with or without |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
6 | modification, are permitted provided that the following conditions |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
7 | are met: |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
8 | |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
9 | 1. Redistributions of source code must retain the above copyright |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
10 | notice, this list of conditions and the following disclaimer. |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
11 | 2. Redistributions in binary form must reproduce the above copyright |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
12 | notice, this list of conditions and the following disclaimer in the |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
13 | documentation and/or other materials provided with the distribution. |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
14 | 3. The name of the author may not be used to endorse or promote products |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
15 | derived from this software without specific prior written permission. |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
16 | |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
17 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
18 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
20 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
22 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
26 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
27 | ''' |
7b2cd8b1ba86
- now with extra license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents:
123
diff
changeset
|
28 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
29 | from __future__ import print_function |
73
d67cc4fbc3f1
- modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
30 | import time |
d67cc4fbc3f1
- modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
31 | import re |
d67cc4fbc3f1
- modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
32 | import bt as Bt |
d67cc4fbc3f1
- modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
33 | import irc as Irc |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
34 | import os |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | from configfile import Config |
120
9880bb697149
- added doomseeker support, fixed up mod_bridge, now shortens new commit links with bit.ly
Teemu Piippo <crimsondusk64@gmail.com>
parents:
115
diff
changeset
|
36 | import utility |
133 | 37 | import random |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
38 | from hgrepo import HgRepository |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
39 | from hgdb import HgCommitsDatabase |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
40 | import traceback |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
41 | import sys |
158
f96730dee026
Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
153
diff
changeset
|
42 | from munge import munge |
121
ac07779f788d
- reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
43 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
44 | Repositories = [] |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
45 | RepositoriesByName = {} |
110 | 46 | |
111 | 47 | def prettify_bookmarks (bookmarks): |
123
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
48 | if bookmarks: |
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
49 | return "\0036 [\002%s\002]" % bookmarks |
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
50 | else: |
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
51 | return '' |
111 | 52 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
53 | def get_repo_by_name (name): |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
54 | global Repositories, RepositoriesByName |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
55 | name = name.lower() |
87 | 56 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
57 | if name not in RepositoriesByName: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
58 | repo = HgRepository (name) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
59 | Repositories.append (repo) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
60 | RepositoriesByName[name] = repo |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
61 | else: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
62 | repo = RepositoriesByName[name] |
87 | 63 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
64 | return repo |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
66 | def check_repo_exists (name): |
153
497b7290977d
More Python 3 rework
Teemu Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
67 | ' Ensures that the repository exists ' |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
68 | repo = get_repo_by_name (name) |
153
497b7290977d
More Python 3 rework
Teemu Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
69 | os.makedirs (repo.name, exist_ok = True) |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
70 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
71 | if not repo.is_valid(): |
121
ac07779f788d
- reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
72 | # If the repo does not exist, clone it. |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | try: |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
74 | repo.clone() |
123
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
75 | |
152 | 76 | # We need to un-alias a few things in case they're aliased |
123
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
77 | comms=['log', 'incoming', 'pull', 'commit', 'push', 'outgoing', 'strip', 'transplant'] |
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
78 | try: |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
79 | with open (os.path.join (repo.name, '.hg', 'hgrc'), 'a') as fp: |
123
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
80 | fp.write ('\n[alias]\n' + ''.join(['%s=%s\n' % (x, x) for x in comms])) |
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
81 | except Exception as e: |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
82 | print ('Warning: unable to alter hgrc of %s: %s' % repo.name, e) |
121
ac07779f788d
- reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
83 | print ('Cloning done.') |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | except Exception as e: |
152 | 85 | raise HgProcessError ('Unable to clone %s from %s: %s' % (repo.name, repo.clone_url, e)) |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
87 | if not repo.is_valid(): |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
88 | raise HgProcessError ('''%s is not a valid repository after cloning ''' |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
89 | '''(.hg is missing)''' % repo.name) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
90 | |
88 | 91 | class HgProcessError (Exception): |
92 | def __init__ (self, value): | |
93 | self.message = value | |
94 | def __str__ (self): | |
95 | return self.message | |
96 | ||
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
97 | def contains_published_repositories (repos): |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
98 | for repo in repos: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
99 | if repo.published: |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
100 | return True |
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
101 | |
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
102 | return False |
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
103 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
104 | def announce_ticket_resolved (ticket_id, cset, db): |
91 | 105 | ticket_id = int (ticket_id) |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
106 | repos = db.get_commit_repos (cset) |
121
ac07779f788d
- reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
107 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
108 | for repo in repos: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
109 | if repo.published: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
110 | break |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
111 | else: |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
112 | raise HgProcessError ('Changeset %s is only committed to non-published repositories: %s' % |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
113 | (cset, ', '.join (repos))) |
87 | 114 | |
115 | # Acquire additional data | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
116 | commit = repo.get_commit_data (rev=cset, |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
117 | author='author|person', |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
118 | date='date(date, "%A %d %B %Y %H:%M:%S")', |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
119 | email='author|email', |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
120 | message='desc') |
87 | 121 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
122 | diffstat = repo.hg ('diff', '--change', cset, '--stat') |
87 | 123 | |
124 | try: | |
125 | ticket_data = Bt.get_issue (ticket_id) | |
126 | except Exception as e: | |
121
ac07779f788d
- reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
127 | raise HgProcessError ("error while processing %s: %s" % (cset, e)) |
87 | 128 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
129 | if len(diffstat) > 0: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
130 | diffstat = 'Changes in files:\n[code]\n' + diffstat + '\n[/code]' |
87 | 131 | else: |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
132 | diffstat = 'No changes in files.' |
87 | 133 | |
134 | # Compare the email addresses against known developer usernames | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
135 | username = Config.find_developer_by_email (commit['email']) |
87 | 136 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
137 | if username: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
138 | commit['author'] += ' [%s]' % username |
87 | 139 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
140 | commit['message'] = commit['message'].replace ("\n", " ") |
115 | 141 | |
87 | 142 | message = 'Issue addressed by commit %s: [b][url=%s/commits/%s]%s[/url][/b]' \ |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
143 | % (cset, repo.url, cset, commit['message']) |
87 | 144 | message += "\nCommitted by %s on %s\n\n%s" \ |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
145 | % (commit['author'], commit['date'], diffstat) |
87 | 146 | |
147 | need_update = False | |
148 | ||
149 | # If not already set, set handler | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
150 | if username and not 'handler' in ticket_data: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
151 | ticket_data['handler'] = {'name': username} |
87 | 152 | need_update = True |
153 | ||
154 | # Find out the status level of the ticket | |
155 | needs_testing_level = 70 | |
156 | ||
157 | if ticket_data['status']['id'] < needs_testing_level: | |
158 | ticket_data.status['id'] = needs_testing_level | |
159 | need_update = True | |
160 | ||
161 | # Set target version if not set | |
151 | 162 | if repo.version and not 'target_version' in ticket_data: |
163 | ticket_data['target_version'] = repo.version | |
87 | 164 | need_update = True |
165 | ||
166 | # Announce on IRC | |
167 | for irc_client in Irc.all_clients: | |
168 | for channel in irc_client.channels: | |
169 | if channel.get_value ('btannounce', default=True): | |
170 | irc_client.privmsg (channel.get_value ('name'), | |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
171 | "\003%d%s\003: commit\0035 %s\003 addresses issue\002\0032 %d\002" % \ |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
172 | (repo.color, repo.name, cset, ticket_id)) |
87 | 173 | irc_client.privmsg (channel.get_value ('name'), |
174 | "Read all about it here: " + Bt.get_ticket_url (ticket_id)) | |
175 | ||
176 | if need_update: | |
177 | # We need to remove the note data, otherwise the ticket notes | |
178 | # will get unnecessary updates. WTF, MantisBT? | |
179 | ticket_data.notes = [] | |
180 | Bt.update_issue (ticket_id, ticket_data) | |
181 | ||
182 | Bt.post_note (ticket_id, message) | |
183 | ||
123
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
184 | def init(): |
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
185 | global repocheck_timeout |
121
ac07779f788d
- reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
186 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
187 | for name in Config.get_node ('hg').get_value ('repos', {}).keys(): |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
188 | check_repo_exists (name) |
123
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
189 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
190 | # Let the database check if commits.db needs to be built |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
191 | HgCommitsDatabase() |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
192 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
193 | repocheck_timeout = time.time() + 15 |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
194 | |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
195 | def poll(): |
73
d67cc4fbc3f1
- modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
196 | global repocheck_timeout |
87 | 197 | |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
198 | try: |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
199 | if time.time() < repocheck_timeout: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
200 | return |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
201 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
202 | hgns = Config.get_node ('hg') |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
203 | repocheck_timeout = time.time() + hgns.get_value ('checkinterval', default=15) * 60 |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
204 | maxcommits = 15 |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
205 | numcommits = 0 |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
206 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
207 | for repo in Repositories: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
208 | numcommits += poll_one_repo (repo, maxcommits=maxcommits - numcommits) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
209 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
210 | if numcommits >= maxcommits: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
211 | # There may be more coming so recheck sooner |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
212 | print ('Processed %d commits, checking for new commits in 1 minute...' % numcommits) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
213 | repocheck_timeout = time.time() + 60 |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
214 | return |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
215 | except Exception as e: |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
216 | print (traceback.format_exception (*sys.exc_info())) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
217 | Irc.broadcast (str (e)) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
218 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
219 | def poll_one_repo (repo, maxcommits): |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
220 | if not Config.get_node ('hg').get_value ('track', default=True): |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
221 | return |
87 | 222 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
223 | print ('Checking %s for updates' % repo.name) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
224 | commits = repo.incoming (maxcommits=maxcommits, node='node|short', message='desc') |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
225 | process_new_commits (repo, commits) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
226 | return len(commits) |
108
8cf31b4d5fcb
- we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents:
101
diff
changeset
|
227 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
228 | def process_new_commits (repo, commits): |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
229 | if not commits: |
108
8cf31b4d5fcb
- we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents:
101
diff
changeset
|
230 | return |
87 | 231 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
232 | print ('%d new commits on %s' % (len (commits), repo.name)) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
233 | pull_args = ['pull'] |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
234 | messages = [[], [], []] |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
235 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
236 | for commit in commits: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
237 | pull_args.append ('-r'); |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
238 | pull_args.append (commit['node']); |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
239 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
240 | print ('Pulling new commits...') |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
241 | repo.hg (*pull_args) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
242 | LENGTH_MINIMUM, LENGTH_SHORT, LENGTH_FULL = range (0, 3) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
243 | db = HgCommitsDatabase() |
87 | 244 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
245 | for commit in commits: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
246 | print ('Processing new commit %s...' % commit['node']) |
121
ac07779f788d
- reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
247 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
248 | existingrepos = db.get_commit_repos (commit['node']) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
249 | alreadyAdded = len (existingrepos) > 0 |
87 | 250 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
251 | commit = dict (commit, **repo.get_commit_data (rev=commit['node'], |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
252 | fullnode='node', |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
253 | author='author|person', |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
254 | bookmarks='bookmarks', |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
255 | date='date|hgdate', |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
256 | email='author|email')) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
257 | commit['bookmarks'] = prettify_bookmarks (commit['bookmarks']) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
258 | commit['time'] = int (commit['date'].split (' ')[0]) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
259 | commit['url'] = '%s/commits/%s' % (repo.url, commit['node']) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
260 | isMergeFromSandbox = False |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
261 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
262 | # If the commit was already in the commits database, it is not a new one and we should |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
263 | # not react to it (unless a merge from sandbox). Still add it to the db though so that |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
264 | # the new repo name is added. |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
265 | db.add_commit (repo=repo, changeset=commit['fullnode'], |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
266 | timestamp=commit['time']) |
87 | 267 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
268 | if alreadyAdded: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
269 | if not contains_published_repositories (existingrepos) and repo.published: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
270 | isMergeFromSandbox = True |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
271 | print ('''%s appears to be a merge from sandbox (exists in %s)''' % |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
272 | (commit['node'], existingrepos)) |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
273 | else: |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
274 | print ('''I already know of %s - they're in %s - not announcing.''' % |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
275 | (commit['node'], existingrepos)) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
276 | continue |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
277 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
278 | username = Config.find_developer_by_email (commit['email']) |
158
f96730dee026
Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
153
diff
changeset
|
279 | committer = munge (username if username else commit['author']) |
152 | 280 | descriptor = """commit""" if random.randrange (100) != 0 else """KERMIT""" |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
281 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
282 | if not isMergeFromSandbox: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
283 | commitMessage = """\003%d%s\003: new %s\0035 %s%s\003 by\0032 %s\003: %s""" % \ |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
284 | (repo.color, repo.name, descriptor, commit['node'], commit['bookmarks'], |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
285 | committer, utility.shorten_link (commit['url'])) |
87 | 286 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
287 | for length in [LENGTH_MINIMUM, LENGTH_SHORT, LENGTH_FULL]: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
288 | messages[length].append (commitMessage) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
289 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
290 | messages[LENGTH_SHORT].append (' ' + commit['message'].splitlines()[0]) |
132 | 291 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
292 | for line in commit['message'].splitlines()[:4]: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
293 | messages[LENGTH_FULL].append (' ' + line) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
294 | else: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
295 | commitMessage = """\003%d%s\003: %s\0035 %s\003 by\0032 %s\003 was pulled: %s""" % \ |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
296 | (repo.color, repo.name, descriptor, commit['node'], committer, |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
297 | utility.shorten_link (commit['url'])) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
298 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
299 | for length in [LENGTH_MINIMUM, LENGTH_SHORT, LENGTH_FULL]: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
300 | messages[length].append (commitMessage) |
87 | 301 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
302 | if repo.published: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
303 | rex = re.compile (r'^.*(fixes|resolves|addresses|should fix) ([0-9]+).*$') |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
304 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
305 | for line in commit['message'].splitlines(): |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
306 | match = rex.match (line) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
307 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
308 | if match: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
309 | announce_ticket_resolved (match.group (2), commit['node'], db) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
310 | break |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
311 | |
132 | 312 | fullMessageLength = len (''.join (messages[2])) |
313 | ||
314 | if fullMessageLength > 3000: | |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
315 | messageSizeClass = LENGTH_MINIMUM |
132 | 316 | elif fullMessageLength > 768: |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
317 | messageSizeClass = LENGTH_SHORT |
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
318 | else: |
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
319 | messageSizeClass = LENGTH_FULL |
132 | 320 | |
321 | # Post it all on IRC now | |
153
497b7290977d
More Python 3 rework
Teemu Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
322 | for irc_client in Irc.all_clients: |
497b7290977d
More Python 3 rework
Teemu Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
323 | for channel in irc_client.channels: |
497b7290977d
More Python 3 rework
Teemu Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
324 | if not channel.get_value ('btannounce', False): |
497b7290977d
More Python 3 rework
Teemu Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
325 | continue |
132 | 326 | |
153
497b7290977d
More Python 3 rework
Teemu Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
327 | if not repo.published and not channel.get_value ('allpublishing', False): |
497b7290977d
More Python 3 rework
Teemu Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
328 | continue |
132 | 329 | |
153
497b7290977d
More Python 3 rework
Teemu Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
330 | for message in messages[messageSizeClass]: |
132 | 331 | irc_client.privmsg (channel.get_value ('name'), message) |
332 | ||
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
333 | db.commit() |
132 | 334 | |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
335 | def force_poll(): |
73
d67cc4fbc3f1
- modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
336 | global repocheck_timeout |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
337 | repocheck_timeout = 0 |
85
302e2bec51d8
- fixed bad find_developer_by_email call
Teemu Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
338 | poll() |