Mercurial > hg > autobot
annotate autobot/changes/poller.py @ 116:c6fbb0d981e9
pass missing pointless argument
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 22 Jan 2011 18:12:54 -0800 |
parents | 3f94c56f8f47 |
children | afc245e4e55d |
rev | line source |
---|---|
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
1 # This file is part of Buildbot. Buildbot is free software: you can |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
2 # redistribute it and/or modify it under the terms of the GNU General Public |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
3 # License as published by the Free Software Foundation, version 2. |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
4 # |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
5 # This program is distributed in the hope that it will be useful, but WITHOUT |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
8 # details. |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
9 # |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
10 # You should have received a copy of the GNU General Public License along with |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 # this program; if not, write to the Free Software Foundation, Inc., 51 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
13 # |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
14 # Copyright Buildbot Team Members |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
15 |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
16 import os |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
17 import time |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
18 import tempfile |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
19 from twisted.python import log |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
20 from twisted.internet import defer, utils |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
21 |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
22 #from buildbot.util import deferredLocked |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
23 from buildbot.changes import base |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
24 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
25 class Poller(base.PollingChangeSource): |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
26 """ |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
27 This will poll a remote resource for changes and submit |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
28 them to the change master. |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
29 """ |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
30 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
31 compare_attrs = ["repourl", "branch", "workdir", |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
32 "pollInterval", "binary", "usetimestamps", |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
33 "category", "project"] |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
34 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
35 def __init__(self, repourl, binary=None, branch=None, |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
36 workdir=None, pollInterval=10*60, |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
37 usetimestamps=True, |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
38 category=None, project=None, |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
39 pollinterval=-2): |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
40 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
41 # for backward compatibility; the parameter used to be spelled with 'i' |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
42 if pollinterval != -2: |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
43 pollInterval = pollinterval |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
44 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
45 if project is None: project = '' |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
46 self.repourl = repourl |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
47 self.branch = branch |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
48 self.pollInterval = pollInterval |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
49 self.lastChange = time.time() |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
50 self.lastPoll = time.time() |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
51 self.binary = binary |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
52 self.workdir = workdir |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
53 self.usetimestamps = usetimestamps |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
54 self.category = category |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
55 self.project = project |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
56 self.changeCount = 0 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
57 self.commitInfo = {} |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
58 self.initLock = defer.DeferredLock() |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
59 |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
60 if not self.workdir: |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
61 self.workdir = tempfile.mkdtemp() |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
62 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
63 self.name = self.__class__.__name__ |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
64 |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
65 # def startService(self): |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
66 |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
67 # base.PollingChangeSource.startService(self) |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
68 |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
69 # # initialize the repository we'll use to get changes; note that |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
70 # # startService is not an event-driven method, so this method will |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
71 # # instead acquire self.initLock immediately when it is called. |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
72 # if not self.isInitialized(): |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
73 # log.msg('Initializing new repository') |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
74 # # d = self.initRepository() |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
75 # # d.addErrback(log.err, 'while initializing %s repository at %s' % (self.name, self.workdir)) |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
76 # else: |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
77 # log.msg("%s repository already exists" % self.name) |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
78 |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
79 # log.msg("%s startService with repository %s" % (self.name, self.workdir)) |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
80 |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
81 # # call this *after* initRepository, so that the initLock is locked first |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
82 |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
83 |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
84 def initRepository(self, _): |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
85 """initialize a repository or whatever""" |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
86 |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
87 # make the directory, if necessary |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
88 d = defer.succeed(None) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
89 def make_dir(_): |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
90 dirpath = os.path.dirname(self.workdir.rstrip(os.sep)) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
91 if not os.path.exists(dirpath): |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
92 log.msg('%s: creating parent directories for workdir' % self.name) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
93 os.makedirs(dirpath) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
94 d.addCallback(make_dir) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
95 |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
96 # perform the initialization |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
97 def processCommand(command): |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
98 d = utils.getProcessOutputAndValue(self.binary, |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
99 command, env=dict(PATH=os.environ['PATH'])) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
100 d.addCallback(self._convert_nonzero_to_failure) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
101 d.addErrback(self._stop_on_failure) |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
102 return d |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
103 for command in self.initializationCommands(): |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
104 d.addCallback(lambda _: processCommand(command[:])) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
105 |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
106 # finish up |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
107 def log_finished(_): |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
108 log.msg("%s: finished initializing working dir %s from %s" % (self.name, self.workdir, self.repourl)) |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
109 d.addCallback(log_finished) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
110 return d |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
111 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
112 def describe(self): |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
113 status = "" |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
114 if not self.master: |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
115 status = "[STOPPED - check log]" |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
116 str = '%s watching the remote git repository %s, branch: %s %s' \ |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
117 % (self.name, self.repourl, self.branch, status) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
118 return str |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
119 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
120 def poll(self): |
113
5fd588ba6ff9
trying with a silly deferred list
Jeff Hammel <jhammel@mozilla.com>
parents:
112
diff
changeset
|
121 """poll for new changes""" |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
122 d = self._get_changes() |
105
cbc4130a179d
uncommenting change processing
Jeff Hammel <jhammel@mozilla.com>
parents:
104
diff
changeset
|
123 d.addCallback(self._process_changes) |
cbc4130a179d
uncommenting change processing
Jeff Hammel <jhammel@mozilla.com>
parents:
104
diff
changeset
|
124 d.addErrback(self._process_changes_failure) |
103 | 125 d.addCallback(self._catch_up) |
126 d.addErrback(self._catch_up_failure) | |
113
5fd588ba6ff9
trying with a silly deferred list
Jeff Hammel <jhammel@mozilla.com>
parents:
112
diff
changeset
|
127 return d |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
128 |
113
5fd588ba6ff9
trying with a silly deferred list
Jeff Hammel <jhammel@mozilla.com>
parents:
112
diff
changeset
|
129 ### functions relating to hashing |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
130 |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
131 def _setPreHash(self, _hash): |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
132 self.preHash = _hash.strip() |
103 | 133 log.msg("The secret key is %s" % self.preHash) |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
134 |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
135 def _setPostHash(self, _hash): |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
136 self.postHash = _hash.strip() |
103 | 137 log.msg("The *NEW* secret key is %s" % self.postHash) |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
138 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
139 def _get_changes(self): |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
140 """update the changes if the hash doesnt match""" |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
141 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
142 self.lastPoll = time.time() |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
143 log.msg('%s: polling repo at %s : %s' % (self.name, self.repourl, self.lastPoll)) |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
144 |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
145 d = defer.succeed(None) |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
146 # ensure the repository is initialized |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
147 if not self.isInitialized(): |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
148 log.msg('Initialing new repository') |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
149 d.addCallback(self.initRepository) |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
150 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
151 # get the hash before updating |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
152 log.msg("About to get prehash") |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
153 d.addCallback(self._hash) |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
154 d.addCallback(self._setPreHash) |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
155 |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
156 # update |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
157 d.addCallback(self._fetch) |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
158 |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
159 # set the post hash |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
160 d.addCallback(self._hash) |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
161 d.addCallback(self._setPostHash) |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
162 |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
163 return d |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
164 |
113
5fd588ba6ff9
trying with a silly deferred list
Jeff Hammel <jhammel@mozilla.com>
parents:
112
diff
changeset
|
165 ### functions related to processing changes |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
166 |
113
5fd588ba6ff9
trying with a silly deferred list
Jeff Hammel <jhammel@mozilla.com>
parents:
112
diff
changeset
|
167 def _process_changes(self, _): |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
168 |
103 | 169 d = defer.succeed(None) |
170 | |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
171 # get the change list |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
172 self.changeCount = 0 |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
173 if self.preHash == self.postHash: |
103 | 174 return d |
175 | |
176 d.addCallback(self._change_list) | |
177 d.addCallback(self._process_change_list) | |
178 return d | |
179 | |
108 | 180 def _process_change_list(self, revList): |
104
41370b2f96e0
starting to get to the changelist
Jeff Hammel <jhammel@mozilla.com>
parents:
103
diff
changeset
|
181 |
109
2cd364f793e2
now its revList, not changelist
Jeff Hammel <jhammel@mozilla.com>
parents:
108
diff
changeset
|
182 log.msg('this is the changelist: %s' % revList) |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
183 self.changeCount = len(revList) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
184 log.msg('%s: processing %d changes: %s in "%s"' |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
185 % (self.name, self.changeCount, revList, self.workdir) ) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
186 |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
187 # get metadata for changes and send them to master |
116
c6fbb0d981e9
pass missing pointless argument
Jeff Hammel <jhammel@mozilla.com>
parents:
115
diff
changeset
|
188 d = defer.succeed(None) |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
189 for rev in revList: |
115
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
190 d.addCallback(self._process_change, rev) |
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
191 |
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
192 return d |
108 | 193 |
115
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
194 def _process_change(self, rev): |
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
195 self.commitInfo = {} |
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
196 log.msg('%s: processing change %s' % rev) |
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
197 d = defer.succeed(None) |
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
198 return d |
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
199 # # get metadata |
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
200 # dl = defer.DeferredList([ |
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
201 # self._get_commit_timestamp(rev), |
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
202 # self._get_commit_name(rev), |
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
203 # self._get_commit_files(rev), |
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
204 # self._get_commit_comments(rev), |
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
205 # ], consumeErrors=True) |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
206 |
115
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
207 # # add the change, apparently |
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
208 # dl.addCallback(self._add_change, rev) |
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
209 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
210 |
108 | 211 def _add_change(self, change): |
212 log.msg("_add_change results") | |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
213 |
108 | 214 |
215 | |
216 # send the change to the master | |
103 | 217 # timestamp, name, files, comments = [ r[1] for r in results ] |
218 # d = self.master.addChange( | |
219 # who=name, | |
220 # revision=rev, | |
221 # files=files, | |
222 # comments=comments, | |
223 # when=timestamp, | |
224 # branch=self.branch, | |
225 # category=self.category, | |
226 # project=self.project, | |
227 # repository=self.repourl) | |
228 # wfd = defer.waitForDeferred(d) | |
229 # yield wfd | |
230 # results = wfd.getResult() | |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
231 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
232 def _process_changes_failure(self, f): |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
233 log.msg('%s: repo poll failed' % self.name) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
234 log.err(f) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
235 # eat the failure to continue along the defered chain - we still want to catch up |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
236 return None |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
237 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
238 def _catch_up_failure(self, f): |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
239 log.err(f) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
240 log.msg('%s: please resolve issues in local repo: %s' % (self.name, self.workdir)) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
241 # this used to stop the service, but this is (a) unfriendly to tests and (b) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
242 # likely to leave the error message lost in a sea of other log messages |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
243 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
244 def _convert_nonzero_to_failure(self, res): |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
245 "utility method to handle the result of getProcessOutputAndValue" |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
246 (stdout, stderr, code) = res |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
247 if code != 0: |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
248 raise EnvironmentError('command failed with exit code %d: %s' % (code, stderr)) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
249 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
250 def _stop_on_failure(self, f): |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
251 "utility method to stop the service when a failure occurs" |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
252 if self.running: |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
253 d = defer.maybeDeferred(lambda : self.stopService()) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
254 d.addErrback(log.err, 'while stopping broken %s service' % self.name) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
255 return f |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
256 |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
257 |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
258 class HgPoller(Poller): |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
259 """poller for a mercurial source""" |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
260 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
261 def __init__(self, repourl, binary='hg', branch='default', **kwargs): |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
262 Poller.__init__(self, repourl, binary=binary, branch=branch, **kwargs) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
263 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
264 def isInitialized(self): |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
265 return os.path.exists(os.path.join(self.workdir, '.hg')) |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
266 |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
267 def initializationCommands(self): |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
268 return [ [ 'clone', self.repourl, self.workdir ] ] |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
269 |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
270 def _fetch(self, _): |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
271 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
272 # get a deferred object that performs the fetch |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
273 args = ['pull', self.repourl] |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
274 # This command always produces data on stderr, but we actually do not care |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
275 # about the stderr or stdout from this command. We set errortoo=True to |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
276 # avoid an errback from the deferred. The callback which will be added to this |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
277 # deferred will not use the response. |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
278 d = utils.getProcessOutput(self.binary, args, path=self.workdir, env=dict(PATH=os.environ['PATH']), errortoo=True ) |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
279 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
280 return d |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
281 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
282 |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
283 def _hash(self, _): |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
284 d = utils.getProcessOutput(self.binary, ['tip', '--template', '{node}\\n'], |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
285 path=self.workdir, |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
286 env=dict(PATH=os.environ['PATH']), errortoo=False ) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
287 return d |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
288 |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
289 |
103 | 290 def _change_list(self, _): |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
291 """ |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
292 return a deferred something-or-other that has the changes to be |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
293 processed. XXX the format is pretty particular |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
294 """ |
106 | 295 range = '%s:%s' % (self.preHash, self.postHash) |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
296 d = utils.getProcessOutput(self.binary, ['log', '-r', range, '--template', '{node}\\n'], |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
297 path=self.workdir, |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
298 env=dict(PATH=os.environ['PATH']), errortoo=False ) |
104
41370b2f96e0
starting to get to the changelist
Jeff Hammel <jhammel@mozilla.com>
parents:
103
diff
changeset
|
299 def split_changes(raw_changes): |
41370b2f96e0
starting to get to the changelist
Jeff Hammel <jhammel@mozilla.com>
parents:
103
diff
changeset
|
300 changes = raw_changes.strip() |
41370b2f96e0
starting to get to the changelist
Jeff Hammel <jhammel@mozilla.com>
parents:
103
diff
changeset
|
301 if not changes: |
41370b2f96e0
starting to get to the changelist
Jeff Hammel <jhammel@mozilla.com>
parents:
103
diff
changeset
|
302 return [] |
107
2de1c1410b77
reversed, not reverse, and make it a list
Jeff Hammel <jhammel@mozilla.com>
parents:
106
diff
changeset
|
303 return list(reversed(changes.split())) |
104
41370b2f96e0
starting to get to the changelist
Jeff Hammel <jhammel@mozilla.com>
parents:
103
diff
changeset
|
304 d.addCallback(split_changes) |
41370b2f96e0
starting to get to the changelist
Jeff Hammel <jhammel@mozilla.com>
parents:
103
diff
changeset
|
305 |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
306 return d |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
307 |
103 | 308 def _catch_up(self, rev): |
309 log.msg('%s: catching up to %s' % (self.name, self.postHash)) | |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
310 if self.changeCount == 0: |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
311 log.msg('%s: no changes, no catch_up' % self.name) |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
312 return |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
313 args = ['update'] |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
314 d = utils.getProcessOutputAndValue(self.binary, args, path=self.workdir, env=dict(PATH=os.environ['PATH'])) |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
315 d.addCallback(self._convert_nonzero_to_failure) |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
316 return d |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
317 |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
318 ### functions for retrieving various metadatas |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
319 |
108 | 320 ### timestamp |
321 | |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
322 def _get_commit_timestamp(self, rev): |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
323 # unix timestamp |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
324 args = ['log', '-r', rev, '--template', '{date|hgdate}'] |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
325 d = utils.getProcessOutput(self.binary, args, path=self.workdir, env=dict(PATH=os.environ['PATH']), errortoo=False ) |
108 | 326 d.addCallback(self._get_commit_timestamp_from_output) |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
327 return d |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
328 |
108 | 329 def _get_commit_timestamp_from_output(self, output): |
330 stripped_output = output.strip() | |
331 if self.usetimestamps: | |
332 try: | |
333 _stamp, offset = output.split() | |
334 stamp = float(_stamp) | |
335 except Exception, e: | |
336 log.msg('%s: caught exception converting output "%s" to timestamp' % (self.name, stripped_output)) | |
337 raise e | |
338 self.commitInfo['timestamp'] = stamp | |
339 else: | |
340 self.commitInfo['timestamp'] = None | |
341 | |
342 ### commit author ('name') | |
343 | |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
344 def _get_commit_name(self, rev): |
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
345 """get the author of a commit""" |
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
346 args = ['log', '-r', rev, '--template', '{author}'] |
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
347 d = utils.getProcessOutput(self.binary, args, path=self.workdir, env=dict(PATH=os.environ['PATH']), errortoo=False ) |
108 | 348 d.addCallback(self._get_commit_name_from_output) |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
349 return d |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
350 |
110
36de30ff3008
relabel incorrectly labeled method
Jeff Hammel <jhammel@mozilla.com>
parents:
109
diff
changeset
|
351 def _get_commit_name_from_output(self, output): |
108 | 352 stripped_output = output.strip() |
353 if len(stripped_output) == 0: | |
354 raise EnvironmentError('could not get commit name for rev') | |
355 self.commitInfo['name'] = stripped_output | |
356 return self.commitInfo['name'] # for tests, or so gitpoller says | |
357 | |
358 ### files | |
359 | |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
360 def _get_commit_files(self, rev): |
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
361 """get the files associated with a commit""" |
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
362 args = ['log', '-r', rev, '--template', '{files}'] |
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
363 d = utils.getProcessOutput(self.binary, args, path=self.workdir, env=dict(PATH=os.environ['PATH']), errortoo=False ) |
108 | 364 d.addCallback(self._get_commit_files_from_output) |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
365 return d |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
366 |
108 | 367 def _get_commit_files_from_output(self, output): |
368 fileList = output.strip.split() | |
369 self.commitInfo['files'] = fileList | |
370 return self.commitInfo['files'] | |
371 | |
372 ### comments | |
373 | |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
374 def _get_commit_comments(self, rev): |
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
375 """get the commit message""" |
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
376 args = ['log', '-r', rev, '--template', '{desc}'] |
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
377 d = utils.getProcessOutput(self.binary, args, path=self.workdir, env=dict(PATH=os.environ['PATH']), errortoo=False ) |
108 | 378 d.addCallback(self._get_commit_comments_from_output) |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
379 return d |
108 | 380 |
381 def _get_commit_comments_from_output(self, output): | |
382 stripped_output = output.strip() | |
383 self.commitInfo['comments'] = stripped_output | |
384 return self.commitInfo['comments'] |