Sat, 08 Aug 2015 14:21:51 +0300
whitespace
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 |
121
ac07779f788d
- reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
42 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
43 | Repositories = [] |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
44 | RepositoriesByName = {} |
110 | 45 | |
111 | 46 | def prettify_bookmarks (bookmarks): |
123
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
47 | if bookmarks: |
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
48 | return "\0036 [\002%s\002]" % bookmarks |
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
49 | else: |
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
50 | return '' |
111 | 51 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
52 | 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
|
53 | 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
|
54 | name = name.lower() |
87 | 55 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
56 | 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
|
57 | 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
|
58 | 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
|
59 | 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
|
60 | else: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
61 | repo = RepositoriesByName[name] |
87 | 62 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
63 | return repo |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
65 | def check_repo_exists (name): |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
66 | ' Check if a 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
|
67 | print ('Checking that %s exists...' % name) |
87 | 68 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
69 | repo = get_repo_by_name (name) |
121
ac07779f788d
- reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
70 | |
146
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 os.path.exists (repo.name): |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
72 | os.makedirs (repo.name) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
73 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
74 | if not repo.is_valid(): |
121
ac07779f788d
- reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
75 | # 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
|
76 | try: |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
77 | repo.clone() |
123
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
78 | |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
79 | # We need to un-alias a few things, they may be aliased on the host machine (e.g. mine) |
123
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
80 | 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
|
81 | try: |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
82 | 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
|
83 | 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
|
84 | 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
|
85 | 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
|
86 | print ('Cloning done.') |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | 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
|
88 | raise HgProcessError ('Unable to clone %s from %s: %s' % (repo.name, repo.url, e)) |
73
d67cc4fbc3f1
- modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
89 | quit (1) |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
91 | 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
|
92 | 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
|
93 | '''(.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
|
94 | |
88 | 95 | class HgProcessError (Exception): |
96 | def __init__ (self, value): | |
97 | self.message = value | |
98 | def __str__ (self): | |
99 | return self.message | |
100 | ||
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
101 | 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
|
102 | 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
|
103 | if repo.published: |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
104 | return True |
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
105 | |
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
106 | return False |
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
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 | def announce_ticket_resolved (ticket_id, cset, db): |
91 | 109 | 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
|
110 | repos = db.get_commit_repos (cset) |
121
ac07779f788d
- reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
111 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
112 | 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
|
113 | 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
|
114 | break |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
115 | else: |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
116 | 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
|
117 | (cset, ', '.join (repos))) |
87 | 118 | |
119 | # 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
|
120 | 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
|
121 | 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
|
122 | 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
|
123 | 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
|
124 | message='desc') |
87 | 125 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
126 | diffstat = repo.hg ('diff', '--change', cset, '--stat') |
87 | 127 | |
128 | try: | |
129 | ticket_data = Bt.get_issue (ticket_id) | |
130 | except Exception as e: | |
121
ac07779f788d
- reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
131 | raise HgProcessError ("error while processing %s: %s" % (cset, e)) |
87 | 132 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
133 | 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
|
134 | diffstat = 'Changes in files:\n[code]\n' + diffstat + '\n[/code]' |
87 | 135 | else: |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
136 | diffstat = 'No changes in files.' |
87 | 137 | |
138 | # 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
|
139 | username = Config.find_developer_by_email (commit['email']) |
87 | 140 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
141 | if username: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
142 | commit['author'] += ' [%s]' % username |
87 | 143 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
144 | commit['message'] = commit['message'].replace ("\n", " ") |
115 | 145 | |
87 | 146 | 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
|
147 | % (cset, repo.url, cset, commit['message']) |
87 | 148 | 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
|
149 | % (commit['author'], commit['date'], diffstat) |
87 | 150 | |
151 | need_update = False | |
152 | ||
153 | # 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
|
154 | 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
|
155 | ticket_data['handler'] = {'name': username} |
87 | 156 | need_update = True |
157 | ||
158 | # Find out the status level of the ticket | |
159 | needs_testing_level = 70 | |
160 | ||
161 | if ticket_data['status']['id'] < needs_testing_level: | |
162 | ticket_data.status['id'] = needs_testing_level | |
163 | need_update = True | |
164 | ||
165 | # Set target version if not set | |
166 | if not 'target_version' in ticket_data: | |
121
ac07779f788d
- reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
167 | ticket_data['target_version'] = repoinfo.get_value ('version') |
87 | 168 | need_update = True |
169 | ||
170 | # Announce on IRC | |
171 | for irc_client in Irc.all_clients: | |
172 | for channel in irc_client.channels: | |
173 | if channel.get_value ('btannounce', default=True): | |
174 | irc_client.privmsg (channel.get_value ('name'), | |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
175 | "\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
|
176 | (repo.color, repo.name, cset, ticket_id)) |
87 | 177 | irc_client.privmsg (channel.get_value ('name'), |
178 | "Read all about it here: " + Bt.get_ticket_url (ticket_id)) | |
179 | ||
180 | if need_update: | |
181 | # We need to remove the note data, otherwise the ticket notes | |
182 | # will get unnecessary updates. WTF, MantisBT? | |
183 | ticket_data.notes = [] | |
184 | Bt.update_issue (ticket_id, ticket_data) | |
185 | ||
186 | Bt.post_note (ticket_id, message) | |
187 | ||
123
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
188 | def init(): |
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
diff
changeset
|
189 | global repocheck_timeout |
121
ac07779f788d
- reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents:
120
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 | 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
|
192 | check_repo_exists (name) |
123
aeb0d0788869
- added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents:
122
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 | # 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
|
195 | HgCommitsDatabase() |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
196 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
197 | repocheck_timeout = time.time() + 15 |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
198 | |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | def poll(): |
73
d67cc4fbc3f1
- modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
200 | global repocheck_timeout |
87 | 201 | |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
202 | try: |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
203 | 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
|
204 | return |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
205 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
206 | 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
|
207 | 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
|
208 | maxcommits = 15 |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
209 | numcommits = 0 |
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 | 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
|
212 | 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
|
213 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
214 | 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
|
215 | # 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
|
216 | 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
|
217 | 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
|
218 | return |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
219 | 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
|
220 | 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
|
221 | 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
|
222 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
223 | 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
|
224 | 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
|
225 | return |
87 | 226 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
227 | 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
|
228 | 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
|
229 | 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 | return len(commits) |
108
8cf31b4d5fcb
- we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents:
101
diff
changeset
|
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 | 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
|
233 | if not commits: |
108
8cf31b4d5fcb
- we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents:
101
diff
changeset
|
234 | return |
87 | 235 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
236 | 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
|
237 | 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
|
238 | messages = [[], [], []] |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
239 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
240 | 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
|
241 | 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
|
242 | pull_args.append (commit['node']); |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
243 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
244 | 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
|
245 | 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
|
246 | 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
|
247 | db = HgCommitsDatabase() |
87 | 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 | 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
|
250 | 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
|
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 | 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
|
253 | alreadyAdded = len (existingrepos) > 0 |
87 | 254 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
255 | 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
|
256 | fullnode='node', |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
257 | 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
|
258 | bookmarks='bookmarks', |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
259 | 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
|
260 | 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
|
261 | 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
|
262 | 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
|
263 | 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
|
264 | isMergeFromSandbox = False |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
265 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
266 | # 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
|
267 | # 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
|
268 | # 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
|
269 | 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
|
270 | timestamp=commit['time']) |
87 | 271 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
272 | if alreadyAdded: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
273 | 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
|
274 | isMergeFromSandbox = True |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
275 | 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
|
276 | (commit['node'], existingrepos)) |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
277 | else: |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
278 | 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
|
279 | (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
|
280 | continue |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
281 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
282 | username = Config.find_developer_by_email (commit['email']) |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
283 | committer = username if username else commit['author'] |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
284 | descriptor = """commit""" if int (random.random() * 100) != 0 else """KERMIT""" |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
285 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
286 | 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
|
287 | 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
|
288 | (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
|
289 | committer, utility.shorten_link (commit['url'])) |
87 | 290 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
291 | 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
|
292 | 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
|
293 | |
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_SHORT].append (' ' + commit['message'].splitlines()[0]) |
132 | 295 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
296 | 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
|
297 | 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
|
298 | else: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
299 | 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
|
300 | (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
|
301 | 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
|
302 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
303 | 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
|
304 | messages[length].append (commitMessage) |
87 | 305 | |
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
306 | 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
|
307 | 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
|
308 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
309 | 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
|
310 | 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
|
311 | |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
312 | if match: |
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
313 | 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
|
314 | break |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
315 | |
145
588aff83bb87
- Encode messages in the hgpoll module so that joining them won't result in an error if they cannot be coded to ascii
Teemu Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
316 | # Encode messages |
588aff83bb87
- Encode messages in the hgpoll module so that joining them won't result in an error if they cannot be coded to ascii
Teemu Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
317 | for messagelist in messages: |
588aff83bb87
- Encode messages in the hgpoll module so that joining them won't result in an error if they cannot be coded to ascii
Teemu Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
318 | for i in range (0, len (messagelist)): |
588aff83bb87
- Encode messages in the hgpoll module so that joining them won't result in an error if they cannot be coded to ascii
Teemu Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
319 | messagelist[i] = messagelist[i].decode ("utf-8", "ignore").encode("ascii", "ignore") |
588aff83bb87
- Encode messages in the hgpoll module so that joining them won't result in an error if they cannot be coded to ascii
Teemu Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
320 | |
132 | 321 | fullMessageLength = len (''.join (messages[2])) |
322 | ||
323 | if fullMessageLength > 3000: | |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
324 | messageSizeClass = LENGTH_MINIMUM |
132 | 325 | elif fullMessageLength > 768: |
144
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
326 | messageSizeClass = LENGTH_SHORT |
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
327 | else: |
b3d1b356e544
- Remove hgapi dependence
Teemu Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
328 | messageSizeClass = LENGTH_FULL |
132 | 329 | |
330 | # Post it all on IRC now | |
331 | for message in messages[messageSizeClass]: | |
332 | for irc_client in Irc.all_clients: | |
333 | for channel in irc_client.channels: | |
334 | if not channel.get_value ('btannounce', False): | |
335 | continue | |
336 | ||
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
337 | if not repo.published and not channel.get_value ('allpublishing', False): |
132 | 338 | continue |
339 | ||
340 | irc_client.privmsg (channel.get_value ('name'), message) | |
341 | ||
146
c17b82b1f573
Mercurial handling major overhaul. Also get some stuff ready for Python 3
Teemu Piippo <tsapii@utu.fi>
parents:
145
diff
changeset
|
342 | db.commit() |
132 | 343 | |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
344 | def force_poll(): |
73
d67cc4fbc3f1
- modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
345 | global repocheck_timeout |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
346 | repocheck_timeout = 0 |
85
302e2bec51d8
- fixed bad find_developer_by_email call
Teemu Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
347 | poll() |