Tue, 02 Feb 2016 20:47:47 +0200
Stuff
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 |
165
8131cf387e3d
Be compatible with Mercurial 2.2.2. Thanks, Debian...
Teemu Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
42 | import datetime |
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: |
162
d24fe5e3e420
Added cdf (aka Φ(x)) to the calculator, removed unneeded list comprehensions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
80 | fp.write ('\n[alias]\n' + ''.join('%s=%s\n' % (x, x) for x in comms)) |
123
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', |
165
8131cf387e3d
Be compatible with Mercurial 2.2.2. Thanks, Debian...
Teemu Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
118 | date='date|hgdate', |
146
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 | |
165
8131cf387e3d
Be compatible with Mercurial 2.2.2. Thanks, Debian...
Teemu Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
122 | commit['date'] = datetime.datetime.utcfromtimestamp(int(commit['date'][0]) - int(commit['date'][1])) |
8131cf387e3d
Be compatible with Mercurial 2.2.2. Thanks, Debian...
Teemu Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
123 | commit['date'] = commit['date'].strftime('%A %d %B %Y %H:%M:%S') |
8131cf387e3d
Be compatible with Mercurial 2.2.2. Thanks, Debian...
Teemu Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
124 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
125 | diffstat = repo.hg ('diff', '--change', cset, '--stat') |
87 | 126 | |
127 | try: | |
128 | ticket_data = Bt.get_issue (ticket_id) | |
129 | except Exception as e: | |
121
ac07779f788d
- reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
130 | raise HgProcessError ("error while processing %s: %s" % (cset, e)) |
87 | 131 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
132 | 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
|
133 | diffstat = 'Changes in files:\n[code]\n' + diffstat + '\n[/code]' |
87 | 134 | else: |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
135 | diffstat = 'No changes in files.' |
87 | 136 | |
137 | # 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
|
138 | username = Config.find_developer_by_email (commit['email']) |
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 | if username: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
141 | commit['author'] += ' [%s]' % username |
87 | 142 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
143 | commit['message'] = commit['message'].replace ("\n", " ") |
115 | 144 | |
87 | 145 | 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
|
146 | % (cset, repo.url, cset, commit['message']) |
87 | 147 | 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
|
148 | % (commit['author'], commit['date'], diffstat) |
87 | 149 | |
150 | need_update = False | |
151 | ||
152 | # 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
|
153 | 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
|
154 | ticket_data['handler'] = {'name': username} |
87 | 155 | need_update = True |
156 | ||
157 | # Find out the status level of the ticket | |
158 | needs_testing_level = 70 | |
159 | ||
160 | if ticket_data['status']['id'] < needs_testing_level: | |
161 | ticket_data.status['id'] = needs_testing_level | |
162 | need_update = True | |
163 | ||
164 | # Set target version if not set | |
151 | 165 | if repo.version and not 'target_version' in ticket_data: |
166 | ticket_data['target_version'] = repo.version | |
87 | 167 | need_update = True |
168 | ||
169 | # Announce on IRC | |
170 | for irc_client in Irc.all_clients: | |
171 | for channel in irc_client.channels: | |
172 | if channel.get_value ('btannounce', default=True): | |
173 | irc_client.privmsg (channel.get_value ('name'), | |
167 | 174 | "\003%d%s\003: commit\0035 %s\003 addresses issue\002\0032 %d\002\003: %s" % \ |
175 | (repo.color, repo.name, cset, ticket_id, Bt.get_ticket_url(ticket_id))) | |
87 | 176 | |
177 | if need_update: | |
178 | # We need to remove the note data, otherwise the ticket notes | |
179 | # will get unnecessary updates. WTF, MantisBT? | |
180 | ticket_data.notes = [] | |
181 | Bt.update_issue (ticket_id, ticket_data) | |
182 | ||
183 | Bt.post_note (ticket_id, message) | |
184 | ||
123
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
185 | def init(): |
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
186 | global repocheck_timeout |
121
ac07779f788d
- reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
187 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
188 | 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
|
189 | check_repo_exists (name) |
123
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
190 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
191 | # 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
|
192 | HgCommitsDatabase() |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
193 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
194 | repocheck_timeout = time.time() + 15 |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
195 | |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
196 | def poll(): |
73
d67cc4fbc3f1
- modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
197 | global repocheck_timeout |
87 | 198 | |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | try: |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
200 | 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
|
201 | return |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
202 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
203 | 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
|
204 | 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
|
205 | maxcommits = 15 |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
206 | numcommits = 0 |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
207 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
208 | 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
|
209 | 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
|
210 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
211 | 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
|
212 | # 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
|
213 | 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
|
214 | 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
|
215 | return |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
216 | 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
|
217 | 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
|
218 | 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
|
219 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
220 | 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
|
221 | 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
|
222 | return |
87 | 223 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
224 | 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
|
225 | 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
|
226 | 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
|
227 | return len(commits) |
108
8cf31b4d5fcb
- we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents:
101
diff
changeset
|
228 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
229 | 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
|
230 | if not commits: |
108
8cf31b4d5fcb
- we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents:
101
diff
changeset
|
231 | return |
87 | 232 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
233 | 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
|
234 | 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
|
235 | messages = [[], [], []] |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
236 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
237 | 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
|
238 | 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
|
239 | pull_args.append (commit['node']); |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
240 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
241 | 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
|
242 | 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
|
243 | 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
|
244 | db = HgCommitsDatabase() |
87 | 245 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
246 | 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
|
247 | 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
|
248 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
249 | 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
|
250 | alreadyAdded = len (existingrepos) > 0 |
87 | 251 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
252 | 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
|
253 | fullnode='node', |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
254 | 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
|
255 | bookmarks='bookmarks', |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
256 | 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
|
257 | 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
|
258 | 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
|
259 | 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
|
260 | 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
|
261 | isMergeFromSandbox = False |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
262 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
263 | # 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
|
264 | # 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
|
265 | # 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
|
266 | 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
|
267 | timestamp=commit['time']) |
87 | 268 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
269 | if alreadyAdded: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
270 | 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
|
271 | isMergeFromSandbox = True |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
272 | 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
|
273 | (commit['node'], existingrepos)) |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
274 | else: |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
275 | 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
|
276 | (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
|
277 | continue |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
278 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
279 | username = Config.find_developer_by_email (commit['email']) |
167 | 280 | committer = username if username else commit['author'] |
152 | 281 | descriptor = """commit""" if random.randrange (100) != 0 else """KERMIT""" |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
282 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
283 | 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
|
284 | 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
|
285 | (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
|
286 | committer, utility.shorten_link (commit['url'])) |
87 | 287 | |
166 | 288 | multiline = ('\n' in commit['message']) or len(commit['message']) >= 256 |
289 | ||
290 | if not multiline: | |
291 | commitMessage += ": %s" % commit['message'] | |
292 | ||
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
293 | 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
|
294 | 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
|
295 | |
167 | 296 | if multiline: |
166 | 297 | messages[LENGTH_SHORT].append (' ' + commit['message'].splitlines()[0]) |
132 | 298 | |
166 | 299 | for line in commit['message'].splitlines()[:4]: |
300 | messages[LENGTH_FULL].append (' ' + line) | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
301 | else: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
302 | 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
|
303 | (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
|
304 | 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
|
305 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
306 | 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
|
307 | messages[length].append (commitMessage) |
87 | 308 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
309 | 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
|
310 | 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
|
311 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
312 | 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
|
313 | 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
|
314 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
315 | if match: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
316 | 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
|
317 | break |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
318 | |
132 | 319 | fullMessageLength = len (''.join (messages[2])) |
320 | ||
321 | if fullMessageLength > 3000: | |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
322 | messageSizeClass = LENGTH_MINIMUM |
132 | 323 | elif fullMessageLength > 768: |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
324 | messageSizeClass = LENGTH_SHORT |
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
325 | else: |
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
326 | messageSizeClass = LENGTH_FULL |
132 | 327 | |
328 | # Post it all on IRC now | |
153
497b7290977d
More Python 3 rework
Teemu Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
329 | for irc_client in Irc.all_clients: |
497b7290977d
More Python 3 rework
Teemu Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
330 | for channel in irc_client.channels: |
497b7290977d
More Python 3 rework
Teemu Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
331 | if not channel.get_value ('btannounce', False): |
497b7290977d
More Python 3 rework
Teemu Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
332 | continue |
132 | 333 | |
153
497b7290977d
More Python 3 rework
Teemu Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
334 | 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
|
335 | continue |
132 | 336 | |
153
497b7290977d
More Python 3 rework
Teemu Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
337 | for message in messages[messageSizeClass]: |
132 | 338 | irc_client.privmsg (channel.get_value ('name'), message) |
339 | ||
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
340 | db.commit() |
132 | 341 | |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
342 | def force_poll(): |
73
d67cc4fbc3f1
- modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
343 | global repocheck_timeout |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
344 | repocheck_timeout = 0 |
85
302e2bec51d8
- fixed bad find_developer_by_email call
Teemu Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
345 | poll() |