hgpoll.py

Sun, 17 May 2015 20:40:09 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sun, 17 May 2015 20:40:09 +0300
changeset 140
631451eecefc
parent 133
06808909d694
child 142
247454178654
permissions
-rw-r--r--

Update:
- added a config option to disable the REST server
- added a message to be printed when IRC connections are first attempted
- look up the long commit node to be inserted into commits.db to avoid precision loss

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
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
29 import hgapi
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
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
34 import os, sqlite3, subprocess
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
35 from datetime import datetime
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 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
37 import utility
132
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
38 import subprocess
133
Teemu Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
39 import random
Teemu Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
40 import math
Teemu Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
41
123
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
42 g_CommitsDb = None
132
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
43 ZDoomRevNumber = 0
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
44
123
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
45 def all_repo_names():
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
46 return Config.get_node ('hg').get_value ('repos', {}).keys()
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
48 class CommitsDb (object):
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
49 def __init__(self):
132
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
50 dbname = Config.get_node('hg').get_value('commits_db', 'commits.db')
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
51 needNew = not os.path.isfile (dbname)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
52 self.db = sqlite3.connect (dbname)
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
53
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
54 if needNew:
122
f899af683bbe - fixed a derp in commitsdb
Teemu Piippo <crimsondusk64@gmail.com>
parents: 121
diff changeset
55 self.create_new()
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
56
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
57 def create_new (self):
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
58 self.db.executescript ('''
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
59 DROP TABLE IF EXISTS COMMITS;
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
60 DROP TABLE IF EXISTS REPOS;
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
61 DROP TABLE IF EXISTS REPOCOMMITS;
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
62 CREATE TABLE IF NOT EXISTS COMMITS
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
63 (
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
64 Node text NOT NULL,
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
65 Dateversion text NOT NULL,
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
66 PRIMARY KEY (Node)
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
67 );
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
68 CREATE TABLE IF NOT EXISTS REPOS
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
69 (
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
70 Name text NOT NULL,
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
71 PRIMARY KEY (Name)
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
72 );
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
73 CREATE TABLE IF NOT EXISTS REPOCOMMITS
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
74 (
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
75 Reponame text,
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
76 Node text,
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
77 FOREIGN KEY (Reponame) REFERENCES REPOS(Name),
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
78 FOREIGN KEY (Node) REFERENCES COMMITS(Node)
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
79 );
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
80 ''')
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
81
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
82 print 'Building commits.db...'
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
83 for repo in all_repo_names():
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
84 print 'Adding commits from %s...' % repo
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
85
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
86 data = subprocess.check_output (['hg', '--cwd', repo, 'log', '--template',
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
87 '{node} {date|hgdate}\n']).splitlines()
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
88
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
89 for line in data:
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
90 changeset, timestamp, tz = line.split(' ')
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
91 self.add_commit (repo, changeset, int (timestamp))
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
92
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
93 self.commit()
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
94
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
95 def add_commit (self, repo, changeset, timestamp):
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
96 dateversion = datetime.utcfromtimestamp (timestamp).strftime ('%y%m%d-%H%M')
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
97 self.db.execute ('''
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
98 INSERT OR IGNORE INTO REPOS
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
99 VALUES (?)
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
100 ''', (repo,))
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
101
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
102 self.db.execute ('''
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
103 INSERT OR IGNORE INTO COMMITS
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
104 VALUES (?, ?)
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
105 ''', (changeset, dateversion))
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
106
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
107 self.db.execute ('''
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
108 INSERT INTO REPOCOMMITS
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
109 VALUES (?, ?)
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
110 ''', (repo, changeset))
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
111
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
112 def get_commit_repos (self, node):
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
113 cursor = self.db.execute ('''
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
114 SELECT Reponame
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
115 FROM REPOCOMMITS
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
116 WHERE Node LIKE ?
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
117 ''', (node + '%',))
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
118
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
119 results = cursor.fetchall()
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
120 return list (set (zip (*results)[0])) if results else []
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
122 def find_commit_by_dateversion (self, dateversion):
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
123 cursor = self.db.execute ('''
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
124 SELECT Node
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
125 FROM COMMITS
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
126 WHERE Dateversion = ?
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
127 ''', (dateversion,))
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
128 result = cursor.fetchone()
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
129 return result[0] if result else None
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
130
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
131 def commit(self):
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
132 self.db.commit()
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
133
110
b2770c43b752 - now in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
134 def color_for_repo (repo_name):
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
135 repo_name = repo_name.lower()
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
136 repoconfig = Config.get_node ('hg').get_node ('repos')
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
137
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
138 if repoconfig.has_node (repo_name):
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
139 return repoconfig.get_node(repo_name).get_value ('colorcode', 0)
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
140
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
141 return 0
110
b2770c43b752 - now in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
142
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
143 def prettify_bookmarks (bookmarks):
123
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
144 if bookmarks:
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
145 return "\0036 [\002%s\002]" % bookmarks
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
146 else:
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
147 return ''
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
148
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
149 def get_repo_info (reponame):
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
150 reponame = reponame.lower()
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
151 repoconfig = Config.get_node ('hg').get_node ('repos')
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
152
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
153 if repoconfig.has_node (reponame):
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
154 return repoconfig.get_node (reponame)
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
155
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
156 return None
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
158 ' Check if a repository exists '
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
159 def check_repo_exists (repo_name):
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
160 print 'Checking that %s exists...' % repo_name
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
161 zanrepo = hgapi.Repo (repo_name)
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
162
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
163 if not os.path.exists (repo_name):
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
164 os.makedirs (repo_name)
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
165
123
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
166 if not os.path.isfile (os.path.join (repo_name, '.hg', 'hgrc')):
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
167 # If the repo does not exist, clone it.
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
168 repo_url = get_repo_info (repo_name).get_value ('url')
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
169 try:
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
170 print ('Cloning %s...' % repo_name)
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
171 zanrepo.hg_clone (repo_url, repo_name)
123
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
172
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
173 # We need to un-alias a few things, they can be aliased on the host machine (e.g. mine)
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
174 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
175 try:
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
176 with open (os.path.join (repo_name, '.hg', 'hgrc'), 'a') as fp:
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
177 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
178 except Exception as e:
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
179 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
180 print ('Cloning done.')
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181 except Exception as e:
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
182 print ('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
183 quit (1)
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
184
88
Teemu Piippo <crimsondusk64@gmail.com>
parents: 87
diff changeset
185
Teemu Piippo <crimsondusk64@gmail.com>
parents: 87
diff changeset
186 class HgProcessError (Exception):
Teemu Piippo <crimsondusk64@gmail.com>
parents: 87
diff changeset
187 def __init__ (self, value):
Teemu Piippo <crimsondusk64@gmail.com>
parents: 87
diff changeset
188 self.message = value
Teemu Piippo <crimsondusk64@gmail.com>
parents: 87
diff changeset
189 def __str__ (self):
Teemu Piippo <crimsondusk64@gmail.com>
parents: 87
diff changeset
190 return self.message
Teemu Piippo <crimsondusk64@gmail.com>
parents: 87
diff changeset
191
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
192 def announce_ticket_resolved (ticket_id, cset):
91
Teemu Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
193 ticket_id = int (ticket_id)
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
194 reponames = g_CommitsDb.get_commit_repos (cset)
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
195
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
196 if not reponames:
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
197 raise HgProcessError ('Changeset %s does not appear to exist!' % cset)
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
198
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
199 for reponame in reponames:
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
200 repoinfo = get_repo_info (reponame)
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
201 if not repoinfo:
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
202 raise HgProcessError ('Unknown repo %s' % reponame)
91
Teemu Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
203
132
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
204 if not repoinfo.get_value ('extrarepo', default=False):
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
205 break
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
206 else:
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
207 raise HgProcessError ('Changeset %s is only committed to non-published repositories %s' %
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
208 (cset, reponames))
89
Teemu Piippo <crimsondusk64@gmail.com>
parents: 88
diff changeset
209
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
210 repo = hgapi.Repo (reponame)
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
211 repo_url = repoinfo.get_value ('url', default=None)
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
212
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
213 if not repo_url:
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
214 raise HgProcessError ('Repo %s has no url!' % reponame)
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
215
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
216 # Acquire additional data
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
217 moredata = get_commit_data (repo, cset,
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
218 r"{author|nonempty}\n{date(date, '%A %d %B %Y %H:%M:%S')}").split('\n')
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
219
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
220 if len (moredata) != 2:
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
221 raise HgProcessError ('malformed hg data while processing %s' % cset)
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
222
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
223 commit_author = moredata[0]
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
224 commit_date = moredata[1]
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
225 commit_email = ""
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
226 commit_message = repo.hg_command ('log', '-r', cset, '--template', '{desc}')
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
227
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
228 try:
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
229 ticket_data = Bt.get_issue (ticket_id)
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
230 except Exception as e:
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
231 raise HgProcessError ("error while processing %s: %s" % (cset, e))
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
232
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
233 # Remove the email address from the author if possible
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
234 rex = re.compile (r'^(.+) <([^>]+)>$.*')
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
235 match = rex.match (commit_author)
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
236 if match:
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
237 commit_author = match.group (1)
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
238 commit_email = match.group (2)
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
239
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
240 commit_diffstat = repo.hg_command ('diff', '--change', cset, '--stat')
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
241
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
242 if len(commit_diffstat) > 0:
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
243 # commit_diffstat = 'Changes in files:\n[code]\n' + commit_diffstat + '\n[/code]'
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
244 commit_diffstat = 'Changes in files:\n' + bbcodify(commit_diffstat)
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
245 else:
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
246 commit_diffstat = 'No changes in files.'
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
247
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
248 # Compare the email addresses against known developer usernames
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
249 commit_trackeruser = Config.find_developer_by_email (commit_email)
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
250
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
251 if commit_trackeruser != '':
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
252 commit_author += ' [%s]' % commit_trackeruser
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
253
115
2bb5c4578ee1 - more fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 112
diff changeset
254 commit_message = commit_message.replace ("\n", " ")
2bb5c4578ee1 - more fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 112
diff changeset
255
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
256 message = 'Issue addressed by commit %s: [b][url=%s/commits/%s]%s[/url][/b]' \
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
257 % (cset, repo_url, cset, commit_message)
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
258 message += "\nCommitted by %s on %s\n\n%s" \
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
259 % (commit_author, commit_date, commit_diffstat)
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
260
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
261 need_update = False
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
262
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
263 # If not already set, set handler
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
264 if not 'handler' in ticket_data:
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
265 ticket_data['handler'] = {'name': commit_trackeruser}
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
266 need_update = True
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
267
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
268 # Find out the status level of the ticket
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
269 needs_testing_level = 70
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
270
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
271 if ticket_data['status']['id'] < needs_testing_level:
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
272 ticket_data.status['id'] = needs_testing_level
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
273 need_update = True
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
274
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
275 # Set target version if not set
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
276 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
277 ticket_data['target_version'] = repoinfo.get_value ('version')
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
278 need_update = True
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
279
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
280 # Announce on IRC
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
281 for irc_client in Irc.all_clients:
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
282 for channel in irc_client.channels:
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
283 if channel.get_value ('btannounce', default=True):
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
284 irc_client.privmsg (channel.get_value ('name'),
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
285 "\003%d%s\003: commit\0035 %s\003 addresses issue\002\0032 %d\002" % (color_for_repo (reponame), reponame, cset, ticket_id))
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
286 irc_client.privmsg (channel.get_value ('name'),
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
287 "Read all about it here: " + Bt.get_ticket_url (ticket_id))
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
288
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
289 if need_update:
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
290 # We need to remove the note data, otherwise the ticket notes
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
291 # will get unnecessary updates. WTF, MantisBT?
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
292 ticket_data.notes = []
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
293 Bt.update_issue (ticket_id, ticket_data)
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
294
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
295 Bt.post_note (ticket_id, message)
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
296
123
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
297 def init():
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
298 global repocheck_timeout
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
299 global g_CommitsDb
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
300
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
301 for repo in all_repo_names():
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
302 check_repo_exists (repo)
123
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
303
140
631451eecefc Update:
Teemu Piippo <crimsondusk64@gmail.com>
parents: 133
diff changeset
304 g_CommitsDb = CommitsDb()
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
305 repocheck_timeout = time.time() + 15
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
306
132
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
307 global ZDoomRevNumber
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
308 try:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
309 ZDoomRevNumber = get_zdrev_number ('zandronum-merge-experiments', 'tip')
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
310 except Exception as e:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
311 print 'error while figuring out zdoom rev number: %s' % e
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
312
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
313 def get_commit_data (repo, rev, template):
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
314 return repo.hg_command ('log', '-l', '1', '-r', rev, '--template', template)
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
315
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
316 def decipher_hgapi_error (e):
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
317 # Blah, hgapi, why must your error messages be so mangled?
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
318 try:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
319 rawmsg = e.message.replace('\n', '').replace('" +','').replace('\t','')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
320 errmsg = re.compile (r'.*: tErr: (.*)Out:.*').match (rawmsg).group (1)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
321 return [True, errmsg]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
322 except:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
323 return [False, '']
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
324
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
325 def bbcodify (commit_diffstat):
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
326 result = ''
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
327
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
328 for line in commit_diffstat.split('\n'):
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
329 rex = re.compile (r'^(.*)\|(.*) (\+*)(-*)(.*)$')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
330 match = rex.match (line)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
331 if match:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
332 line = '%s|%s [color=#5F7]%s[/color][color=#F53]%s[/color]%s\n' \
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
333 % (match.group (1), match.group (2), match.group (3),
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
334 match.group (4), match.group (5))
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
335
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
336 # Tracker doesn't seem to like empty color tags
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
337 line = line.replace ('[color=#5F7][/color]', '').replace ('[color=#F53][/color]', '')
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
338
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
339 result += line
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
340
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
341 return result
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
342
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
343 def poll():
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
344 global repocheck_timeout
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
345 if time.time() < repocheck_timeout:
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
346 return
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
347
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
348 for reponame in all_repo_names():
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
349 poll_one_repo (reponame)
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
350
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
351 hgns = Config.get_node ('hg')
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
352 repocheck_timeout = time.time() + hgns.get_value ('checkinterval', default=15) * 60
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
353
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
354 def poll_one_repo (repo_name):
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
355 global repocheck_timeout
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
356 hgns = Config.get_node ('hg')
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
357
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
358 if not hgns.get_value ('track', default=True):
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
359 return
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
360
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
361 repo = hgapi.Repo (repo_name)
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
362 commit_data = []
123
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
363 delimeter = '^^^^^^^^^^'
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
364 delimeter2 = '@@@@@@@@@@'
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
365 print 'Checking %s for updates' % repo_name
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
366
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
367 try:
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
368 data = repo.hg_command ('incoming', '--quiet', '--template',
123
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
369 delimeter.join (['{node|short}', '{desc}']) + delimeter2).split (delimeter2)
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
370 except hgapi.hgapi.HgException as e:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
371 deciphered = decipher_hgapi_error (e)
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
372
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
373 if deciphered[0] and len(deciphered[1]) > 0:
123
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
374 Irc.broadcast ("error while using hg incoming on %s: %s" % (repo_name, deciphered[1]))
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
375
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
376 return
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
377 except Exception as e:
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
378 Irc.broadcast ("%s" % `e`)
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
379 return
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
380
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
381 if not data:
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
382 print ('No updates to %s' % repo_name)
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
383
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
384 for line in data:
123
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
385 if line:
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
386 commit_data.append (line.split (delimeter))
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
387
97
55d7d9aea160 - link rest to hg
Teemu Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
388 process_new_commits (repo_name, commit_data)
55d7d9aea160 - link rest to hg
Teemu Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
389
55d7d9aea160 - link rest to hg
Teemu Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
390 def process_new_commits (repo_name, commit_data):
108
8cf31b4d5fcb - we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents: 101
diff changeset
391 if len (commit_data) == 0:
8cf31b4d5fcb - we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents: 101
diff changeset
392 return
8cf31b4d5fcb - we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents: 101
diff changeset
393
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
394 repo_name = repo_name.lower()
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
395 repo_url = get_repo_info (repo_name).get_value ('url')
132
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
396 isExtraRepo = get_repo_info (repo_name).get_value ('extrarepo', False)
98
4edbdf390bd1 - fix previous commit
Teemu Piippo <crimsondusk64@gmail.com>
parents: 97
diff changeset
397 zanrepo = hgapi.Repo (repo_name)
110
b2770c43b752 - now in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
398 print '%d new commits on %s' % (len (commit_data), repo_name)
123
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
399 pull_args = []
132
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
400 messages = [[], [], []]
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
401 messageSizeClass = 2
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
402
108
8cf31b4d5fcb - we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents: 101
diff changeset
403 for commit in commit_data:
8cf31b4d5fcb - we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents: 101
diff changeset
404 pull_args.append ('-r');
8cf31b4d5fcb - we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents: 101
diff changeset
405 pull_args.append (commit[0]);
8cf31b4d5fcb - we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents: 101
diff changeset
406
8cf31b4d5fcb - we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents: 101
diff changeset
407 print 'Pulling new commits...'
8cf31b4d5fcb - we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents: 101
diff changeset
408 try:
8cf31b4d5fcb - we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents: 101
diff changeset
409 zanrepo.hg_command ('pull', *pull_args)
8cf31b4d5fcb - we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents: 101
diff changeset
410 except Exception as e:
8cf31b4d5fcb - we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents: 101
diff changeset
411 Irc.broadcast ('Warning: unable to pull: %s' % `e`)
8cf31b4d5fcb - we now need an explicit check against double-processing commits
Teemu Piippo <crimsondusk64@gmail.com>
parents: 101
diff changeset
412 return
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
413
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
414 for commit in commit_data:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
415 commit_node = commit[0]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
416 commit_message = commit[1]
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
417 print 'Processing new commit %s...' % commit_node
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
418
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
419 try:
123
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
420 existingrepos = g_CommitsDb.get_commit_repos (commit_node)
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
421 alreadyAdded = len (existingrepos) > 0
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
422
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
423 delim = '@@@@@@@@@@'
140
631451eecefc Update:
Teemu Piippo <crimsondusk64@gmail.com>
parents: 133
diff changeset
424 data = get_commit_data (zanrepo, commit_node, delim.join (['{node}', '{author}', '{bookmarks}', \
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
425 '{date|hgdate}'])).split (delim)
140
631451eecefc Update:
Teemu Piippo <crimsondusk64@gmail.com>
parents: 133
diff changeset
426 commit_full_node = data[0]
631451eecefc Update:
Teemu Piippo <crimsondusk64@gmail.com>
parents: 133
diff changeset
427 commit_author = data[1]
631451eecefc Update:
Teemu Piippo <crimsondusk64@gmail.com>
parents: 133
diff changeset
428 commit_bookmarks = prettify_bookmarks (data[2])
631451eecefc Update:
Teemu Piippo <crimsondusk64@gmail.com>
parents: 133
diff changeset
429 commit_time = int (data[3].split (' ')[0])
100
2a56ccf67782 - be more liberal on posting commit messages to IRC
Teemu Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
430 commit_url = '%s/commits/%s' % (repo_url, commit_node)
2a56ccf67782 - be more liberal on posting commit messages to IRC
Teemu Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
431 commit_email = ''
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
432
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
433 # If the commit was already in the commits database, it is not a new one and we should
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
434 # not react to it. Still add it to the db though so that the new repo name is added.
140
631451eecefc Update:
Teemu Piippo <crimsondusk64@gmail.com>
parents: 133
diff changeset
435 g_CommitsDb.add_commit (repo=repo_name, changeset=commit_full_node, timestamp=commit_time)
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
436 if alreadyAdded:
123
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
437 print ('''I already know of %s - they're in %s - not announcing.''' %
aeb0d0788869 - added commits.db and mercurial support restructure
Teemu Piippo <crimsondusk64@gmail.com>
parents: 122
diff changeset
438 (commit_node, existingrepos))
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
439 continue
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
440
100
2a56ccf67782 - be more liberal on posting commit messages to IRC
Teemu Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
441 # Remove the email address from the author if possible
2a56ccf67782 - be more liberal on posting commit messages to IRC
Teemu Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
442 rex = re.compile (r'^(.+) <([^>]+)>$.*')
2a56ccf67782 - be more liberal on posting commit messages to IRC
Teemu Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
443 match = rex.match (commit_author)
2a56ccf67782 - be more liberal on posting commit messages to IRC
Teemu Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
444 if match:
2a56ccf67782 - be more liberal on posting commit messages to IRC
Teemu Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
445 commit_author = match.group (1)
2a56ccf67782 - be more liberal on posting commit messages to IRC
Teemu Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
446 commit_email = match.group (2)
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
447
100
2a56ccf67782 - be more liberal on posting commit messages to IRC
Teemu Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
448 commit_trackeruser = Config.find_developer_by_email (commit_email)
2a56ccf67782 - be more liberal on posting commit messages to IRC
Teemu Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
449 committer = commit_trackeruser if commit_trackeruser != '' else commit_author
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
450
133
Teemu Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
451 commitDescriptor = """commit""" if int (math.ceil (random.random() * 100)) != 1 else """KERMIT"""
Teemu Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
452
Teemu Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
453 commitMessage = """\003%d%s\003: new %s\0035 %s%s\003 by\0032 %s\003: %s""" % \
Teemu Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
454 (color_for_repo (repo_name), repo_name, commitDescriptor, commit_node, commit_bookmarks,
132
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
455 committer, utility.shorten_link (commit_url))
112
cdafc1a0544e - stuff!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
456
132
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
457 messages[0].append (commitMessage)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
458 messages[1].append (commitMessage)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
459 messages[2].append (commitMessage)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
460 messages[1].append (' ' + commit_message.splitlines()[0])
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
461
132
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
462 for line in commit_message.splitlines()[0:4]:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
463 messages[2].append (' ' + line)
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
464
132
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
465 if not isExtraRepo:
100
2a56ccf67782 - be more liberal on posting commit messages to IRC
Teemu Piippo <crimsondusk64@gmail.com>
parents: 98
diff changeset
466 rex = re.compile (r'^.*(fixes|resolves|addresses|should fix) ([0-9]+).*$')
132
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
467
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
468 for line in commit_message.splitlines():
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
469 match = rex.match (line)
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 86
diff changeset
470
132
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
471 if match:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
472 announce_ticket_resolved (match.group (2), commit_node)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
473 break
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
474 except Exception as e:
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
475 Irc.broadcast ('Error while processing %s: %s' % (commit_node, e))
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
476 continue
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
477
132
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
478 fullMessageLength = len (''.join (messages[2]))
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
479
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
480 if fullMessageLength > 3000:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
481 messageSizeClass = 0
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
482 elif fullMessageLength > 768:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
483 messageSizeClass = 1
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
484
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
485 print ("""Message length in total: %d, using size class %d (%d)""" %\
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
486 (fullMessageLength, messageSizeClass, len (''.join (messages[messageSizeClass]))))
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
487
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
488 # Post it all on IRC now
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
489 for message in messages[messageSizeClass]:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
490 for irc_client in Irc.all_clients:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
491 for channel in irc_client.channels:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
492 if not channel.get_value ('btannounce', False):
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
493 continue
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
494
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
495 if isExtraRepo and not channel.get_value ('allpublishing', False):
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
496 continue
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
497
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
498 irc_client.privmsg (channel.get_value ('name'), message)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
499
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
500 # Hack for ZDoom upgrades
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
501 if repo_name == 'zandronum-merge-experiments':
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
502 check_zdoom_upgrade (repo_name, commit_node)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
503
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
504 g_CommitsDb.commit()
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 120
diff changeset
505
132
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
506 def make_progress_bar (p, barLength, colored=True):
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
507 BoldChar, ColorChar = (Irc.BoldChar, Irc.ColorChar)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
508 return BoldChar + '[' + BoldChar \
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
509 + ColorChar + '2,2' + ('=' * int (round (p * barLength))) \
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
510 + ColorChar + '1,1' + ('-' * int (barLength - round (p * barLength))) \
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
511 + ColorChar + BoldChar + ']' + BoldChar
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
512
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
513 ZDoomMin = 2560
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
514 ZDoomMax = 3794
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
515
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
516 def check_zdoom_upgrade (repo_name, commit_node):
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
517 zanrepo = hgapi.Repo (repo_name)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
518 try:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
519 global ZDoomRevNumber
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
520 newnumber = get_zdrev_number (repo_name, commit_node)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
521
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
522 if newnumber > ZDoomRevNumber:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
523 ZDoomRevNumber = newnumber
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
524 fraction = float (newnumber - ZDoomMin) / (ZDoomMax - ZDoomMin)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
525 # progressBar = make_progress_bar (fraction, 30, colored=True);
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
526
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
527 message = """ZDoom upgrade: r%d: %d revisions left (%d%% complete)""" %\
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
528 (newnumber, ZDoomMax - newnumber, round (fraction * 100))
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
529
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
530 for irc_client in Irc.all_clients:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
531 for channel in irc_client.channels:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
532 if not channel.get_value ('allpublishing', False):
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
533 continue
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
534 irc_client.privmsg (channel.get_value ('name'), message)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
535
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
536 update_zadev_topic()
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
537 except Exception as e:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
538 Irc.broadcast ('Error while dealing with ZDoom upgrade number: %s' % e)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
539
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
540 def update_zadev_topic():
140
631451eecefc Update:
Teemu Piippo <crimsondusk64@gmail.com>
parents: 133
diff changeset
541 return
132
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
542 fraction = float (ZDoomRevNumber - ZDoomMin) / (ZDoomMax - ZDoomMin)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
543 topicText = """ZDoom 2.6.1 progress: at r%d, %d revisions left (%d%% complete)""" %\
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
544 (ZDoomRevNumber, ZDoomMax - ZDoomRevNumber, round (fraction * 100))
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
545
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
546 try:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
547 Irc.ClientsByName['zandronum'].write ("""TOPIC #zadev :%s""" % topicText)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
548 Irc.ClientsByName['zandronum'].write ("""TOPIC #commits :%s""" % topicText)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
549 except Exception as e:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
550 Irc.broadcast ("""Error setting #zadev topic: %s""" % e)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
551
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
552 def get_zdrev_number (repo_name, commit_node):
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
553 zanrepo = hgapi.Repo (repo_name)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
554 subprocess.call (['hg', '--cwd', repo_name, 'revert', '-r', commit_node, 'src/version.h'])
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
555 rx = re.compile (r'#define\s+ZD_SVN_REVISION_NUMBER\s+([0-9]+)')
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
556 result = None
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
557
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
558 with open (repo_name + '/src/version.h') as version_file:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
559 for line in version_file:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
560 match = rx.match (line)
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
561 if match != None:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
562 result = int (match.group (1))
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
563 break
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
564
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
565 subprocess.call (['hg', '--cwd', repo_name, 'revert', '-r.', 'src/version.h'])
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
566
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
567 if result != None:
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
568 return result
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
569
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
570 raise ValueError ("""Could not find ZD_SVN_REVISION_NUMBER in version.h""")
a22c50f52a23 lots of new stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents: 124
diff changeset
571
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
572 def force_poll():
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
573 global repocheck_timeout
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
574 repocheck_timeout = 0
85
302e2bec51d8 - fixed bad find_developer_by_email call
Teemu Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
575 poll()

mercurial