Mercurial > hg > autobot
annotate autobot/changes/poller.py @ 261:0927a07dfab3
remove commentted code
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 28 Dec 2011 20:43:53 -0800 |
parents | 5f286f64ce6e |
children | a13749f19067 |
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 |
245
5f286f64ce6e
convert to a datetime; i guess you gotta do that now
Jeff Hammel <jhammel@mozilla.com>
parents:
244
diff
changeset
|
19 from datetime import datetime |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
20 from twisted.python import log |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
21 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
|
22 |
124
f2f4bf7edbbc
need to import in this version
Jeff Hammel <jhammel@mozilla.com>
parents:
123
diff
changeset
|
23 from buildbot.changes import base, changes |
99
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 """ |
231
d4637641be6e
whitespace cleanup; logging
Jeff Hammel <jhammel@mozilla.com>
parents:
216
diff
changeset
|
30 |
245
5f286f64ce6e
convert to a datetime; i guess you gotta do that now
Jeff Hammel <jhammel@mozilla.com>
parents:
244
diff
changeset
|
31 src = '' |
5f286f64ce6e
convert to a datetime; i guess you gotta do that now
Jeff Hammel <jhammel@mozilla.com>
parents:
244
diff
changeset
|
32 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
33 compare_attrs = ["repourl", "branch", "workdir", |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
34 "pollInterval", "binary", "usetimestamps", |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
35 "category", "project"] |
231
d4637641be6e
whitespace cleanup; logging
Jeff Hammel <jhammel@mozilla.com>
parents:
216
diff
changeset
|
36 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
37 def __init__(self, repourl, binary=None, branch=None, |
231
d4637641be6e
whitespace cleanup; logging
Jeff Hammel <jhammel@mozilla.com>
parents:
216
diff
changeset
|
38 workdir=None, pollInterval=10*60, |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
39 usetimestamps=True, |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
40 category=None, project=None, |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
41 pollinterval=-2): |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
42 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
43 # 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
|
44 if pollinterval != -2: |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
45 pollInterval = pollinterval |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
46 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
47 if project is None: project = '' |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
48 self.repourl = repourl |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
49 self.branch = branch |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
50 self.pollInterval = pollInterval |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
51 self.lastChange = time.time() |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
52 self.lastPoll = time.time() |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
53 self.binary = binary |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
54 self.workdir = workdir |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
55 self.usetimestamps = usetimestamps |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
56 self.category = category |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
57 self.project = project |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
58 self.changeCount = 0 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
59 self.commitInfo = {} |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
60 self.initLock = defer.DeferredLock() |
231
d4637641be6e
whitespace cleanup; logging
Jeff Hammel <jhammel@mozilla.com>
parents:
216
diff
changeset
|
61 |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
62 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
|
63 self.workdir = tempfile.mkdtemp() |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
64 |
151
700693fad00a
cleanup a few things found in testing multiple builders
Jeff Hammel <jhammel@mozilla.com>
parents:
150
diff
changeset
|
65 self.name = '%s: %s#%s' % (self.__class__.__name__, repourl, branch) |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
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 def initRepository(self, _): |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
68 """initialize a repository or whatever""" |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
69 |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
70 # 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
|
71 d = defer.succeed(None) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
72 def make_dir(_): |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
73 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
|
74 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
|
75 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
|
76 os.makedirs(dirpath) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
77 d.addCallback(make_dir) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
78 |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
79 # perform the initialization |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
80 def processCommand(command): |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
81 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
|
82 command, env=dict(PATH=os.environ['PATH'])) |
181 | 83 # d.addCallback(self._convert_nonzero_to_failure) |
84 # d.addErrback(self._stop_on_failure) | |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
85 return d |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
86 for command in self.initializationCommands(): |
181 | 87 self.log('%s %s' % (self.binary, ' '.join(command))) |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
88 d.addCallback(lambda _: processCommand(command[:])) |
181 | 89 # XXX for some retarded reason, only the first one of these |
90 # seems actually to get called | |
91 # i don't know....all i do know is that i'm tired of writing | |
92 # twisted code | |
231
d4637641be6e
whitespace cleanup; logging
Jeff Hammel <jhammel@mozilla.com>
parents:
216
diff
changeset
|
93 |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
94 # finish up |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
95 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
|
96 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
|
97 d.addCallback(log_finished) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
98 return d |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
99 |
166
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
100 def log(self, msg): |
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
101 log.msg('%s: %s' % (self.name, msg)) |
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
102 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
103 def describe(self): |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
104 status = "" |
141 | 105 if not self.parent: |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
106 status = "[STOPPED - check log]" |
150 | 107 str = '%s watching the remote repository %s, branch: %s %s' \ |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
108 % (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
|
109 return str |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
110 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
111 def poll(self): |
113
5fd588ba6ff9
trying with a silly deferred list
Jeff Hammel <jhammel@mozilla.com>
parents:
112
diff
changeset
|
112 """poll for new changes""" |
231
d4637641be6e
whitespace cleanup; logging
Jeff Hammel <jhammel@mozilla.com>
parents:
216
diff
changeset
|
113 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
114 d = self._get_changes() |
105
cbc4130a179d
uncommenting change processing
Jeff Hammel <jhammel@mozilla.com>
parents:
104
diff
changeset
|
115 d.addCallback(self._process_changes) |
cbc4130a179d
uncommenting change processing
Jeff Hammel <jhammel@mozilla.com>
parents:
104
diff
changeset
|
116 d.addErrback(self._process_changes_failure) |
103 | 117 d.addCallback(self._catch_up) |
118 d.addErrback(self._catch_up_failure) | |
231
d4637641be6e
whitespace cleanup; logging
Jeff Hammel <jhammel@mozilla.com>
parents:
216
diff
changeset
|
119 return d |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
120 |
113
5fd588ba6ff9
trying with a silly deferred list
Jeff Hammel <jhammel@mozilla.com>
parents:
112
diff
changeset
|
121 ### 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
|
122 |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
123 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
|
124 self.preHash = _hash.strip() |
166
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
125 self.log("preHash 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
|
126 |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
127 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
|
128 self.postHash = _hash.strip() |
166
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
129 self.log("postHash 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
|
130 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
131 def _get_changes(self): |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
132 """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
|
133 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
134 self.lastPoll = time.time() |
172
b96f1e121451
i missed taking out a self.name in the logging refactor
Jeff Hammel <jhammel@mozilla.com>
parents:
171
diff
changeset
|
135 self.log('polling repo at %s : %s' % (self.repourl, self.lastPoll)) |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
136 |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
137 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
|
138 # 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
|
139 if not self.isInitialized(): |
177 | 140 self.log('Initializing new repository at %s' % self.workdir) |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
141 d.addCallback(self.initRepository) |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
142 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
143 # 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
|
144 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
|
145 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
|
146 |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
147 # update |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
148 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
|
149 |
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
150 # 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
|
151 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
|
152 d.addCallback(self._setPostHash) |
231
d4637641be6e
whitespace cleanup; logging
Jeff Hammel <jhammel@mozilla.com>
parents:
216
diff
changeset
|
153 |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
154 return d |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
155 |
113
5fd588ba6ff9
trying with a silly deferred list
Jeff Hammel <jhammel@mozilla.com>
parents:
112
diff
changeset
|
156 ### 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
|
157 |
113
5fd588ba6ff9
trying with a silly deferred list
Jeff Hammel <jhammel@mozilla.com>
parents:
112
diff
changeset
|
158 def _process_changes(self, _): |
166
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
159 """processes the changes between the preHash and the postHash""" |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
160 |
103 | 161 d = defer.succeed(None) |
162 | |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
163 # get the change list |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
164 self.changeCount = 0 |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
165 if self.preHash == self.postHash: |
103 | 166 return d |
167 | |
168 d.addCallback(self._change_list) | |
169 d.addCallback(self._process_change_list) | |
170 return d | |
171 | |
108 | 172 def _process_change_list(self, revList): |
104
41370b2f96e0
starting to get to the changelist
Jeff Hammel <jhammel@mozilla.com>
parents:
103
diff
changeset
|
173 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
174 self.changeCount = len(revList) |
166
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
175 self.log('processing %d changes: %s in "%s"' |
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
176 % (self.changeCount, revList, self.workdir) ) |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
177 |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
178 # get metadata for changes and send them to master |
116
c6fbb0d981e9
pass missing pointless argument
Jeff Hammel <jhammel@mozilla.com>
parents:
115
diff
changeset
|
179 d = defer.succeed(None) |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
180 for rev in revList: |
115
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
181 d.addCallback(self._process_change, rev) |
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
182 return d |
108 | 183 |
117
afc245e4e55d
wonders of throwing paper against walls
Jeff Hammel <jhammel@mozilla.com>
parents:
116
diff
changeset
|
184 def _process_change(self, something, rev): |
115
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
185 self.commitInfo = {} |
168
8528311427e0
replace a few more legacy logging instances
Jeff Hammel <jhammel@mozilla.com>
parents:
167
diff
changeset
|
186 self.log('processing change %s (something=%s)' % (rev, something)) |
115
3f94c56f8f47
further abstraction ::sigh::
Jeff Hammel <jhammel@mozilla.com>
parents:
114
diff
changeset
|
187 d = defer.succeed(None) |
119
bc1bd60006a0
hopefully really add some metadata
Jeff Hammel <jhammel@mozilla.com>
parents:
118
diff
changeset
|
188 d.addCallback(self._get_commit_timestamp, rev) |
bc1bd60006a0
hopefully really add some metadata
Jeff Hammel <jhammel@mozilla.com>
parents:
118
diff
changeset
|
189 d.addCallback(self._get_commit_name, rev) |
bc1bd60006a0
hopefully really add some metadata
Jeff Hammel <jhammel@mozilla.com>
parents:
118
diff
changeset
|
190 d.addCallback(self._get_commit_files, rev) |
bc1bd60006a0
hopefully really add some metadata
Jeff Hammel <jhammel@mozilla.com>
parents:
118
diff
changeset
|
191 d.addCallback(self._get_commit_comments, rev) |
bc1bd60006a0
hopefully really add some metadata
Jeff Hammel <jhammel@mozilla.com>
parents:
118
diff
changeset
|
192 d.addCallback(self._add_change, rev) |
231
d4637641be6e
whitespace cleanup; logging
Jeff Hammel <jhammel@mozilla.com>
parents:
216
diff
changeset
|
193 return d |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
194 |
122
1084bfdedf0a
more logging for debugging
Jeff Hammel <jhammel@mozilla.com>
parents:
121
diff
changeset
|
195 def _add_change(self, _, rev): |
119
bc1bd60006a0
hopefully really add some metadata
Jeff Hammel <jhammel@mozilla.com>
parents:
118
diff
changeset
|
196 log.msg("_add_change results: %s" % self.commitInfo) |
231
d4637641be6e
whitespace cleanup; logging
Jeff Hammel <jhammel@mozilla.com>
parents:
216
diff
changeset
|
197 |
245
5f286f64ce6e
convert to a datetime; i guess you gotta do that now
Jeff Hammel <jhammel@mozilla.com>
parents:
244
diff
changeset
|
198 # convert the timestamp into a datetime object |
5f286f64ce6e
convert to a datetime; i guess you gotta do that now
Jeff Hammel <jhammel@mozilla.com>
parents:
244
diff
changeset
|
199 # (required in buildbot 0.8.5) |
244
714a7a7f4ea7
figure out this timestamp nonsense
Jeff Hammel <jhammel@mozilla.com>
parents:
243
diff
changeset
|
200 timestamp = self.commitInfo['timestamp'] |
245
5f286f64ce6e
convert to a datetime; i guess you gotta do that now
Jeff Hammel <jhammel@mozilla.com>
parents:
244
diff
changeset
|
201 if isinstance(timestamp, int) or isinstance(timestamp, float): |
5f286f64ce6e
convert to a datetime; i guess you gotta do that now
Jeff Hammel <jhammel@mozilla.com>
parents:
244
diff
changeset
|
202 timestamp = datetime.fromtimestamp(timestamp) |
5f286f64ce6e
convert to a datetime; i guess you gotta do that now
Jeff Hammel <jhammel@mozilla.com>
parents:
244
diff
changeset
|
203 |
244
714a7a7f4ea7
figure out this timestamp nonsense
Jeff Hammel <jhammel@mozilla.com>
parents:
243
diff
changeset
|
204 self.log('timestamp: %s' % timestamp) |
714a7a7f4ea7
figure out this timestamp nonsense
Jeff Hammel <jhammel@mozilla.com>
parents:
243
diff
changeset
|
205 |
108 | 206 # send the change to the master |
123
4dfb966818b6
maybe were even changing things now
Jeff Hammel <jhammel@mozilla.com>
parents:
122
diff
changeset
|
207 c = changes.Change(who=self.commitInfo['name'], |
4dfb966818b6
maybe were even changing things now
Jeff Hammel <jhammel@mozilla.com>
parents:
122
diff
changeset
|
208 revision=rev, |
4dfb966818b6
maybe were even changing things now
Jeff Hammel <jhammel@mozilla.com>
parents:
122
diff
changeset
|
209 files=self.commitInfo['files'], |
4dfb966818b6
maybe were even changing things now
Jeff Hammel <jhammel@mozilla.com>
parents:
122
diff
changeset
|
210 comments=self.commitInfo['comments'], |
4dfb966818b6
maybe were even changing things now
Jeff Hammel <jhammel@mozilla.com>
parents:
122
diff
changeset
|
211 when=self.commitInfo['timestamp'], |
4dfb966818b6
maybe were even changing things now
Jeff Hammel <jhammel@mozilla.com>
parents:
122
diff
changeset
|
212 branch=self.branch, |
4dfb966818b6
maybe were even changing things now
Jeff Hammel <jhammel@mozilla.com>
parents:
122
diff
changeset
|
213 category=self.category, |
4dfb966818b6
maybe were even changing things now
Jeff Hammel <jhammel@mozilla.com>
parents:
122
diff
changeset
|
214 project=self.project, |
4dfb966818b6
maybe were even changing things now
Jeff Hammel <jhammel@mozilla.com>
parents:
122
diff
changeset
|
215 repository=self.repourl) |
237 | 216 log.msg("parent: %s, %s" % (self.parent, getattr(self.parent, 'module', None))) |
241
6c72a6f29fc8
update to the modern way of doing things? (or die trying)
Jeff Hammel <jhammel@mozilla.com>
parents:
238
diff
changeset
|
217 self.master.addChange(author=self.commitInfo['name'], |
6c72a6f29fc8
update to the modern way of doing things? (or die trying)
Jeff Hammel <jhammel@mozilla.com>
parents:
238
diff
changeset
|
218 revision=rev, |
242 | 219 files=self.commitInfo['files'], |
243 | 220 comments=self.commitInfo['comments'], |
244
714a7a7f4ea7
figure out this timestamp nonsense
Jeff Hammel <jhammel@mozilla.com>
parents:
243
diff
changeset
|
221 when_timestamp=timestamp, |
241
6c72a6f29fc8
update to the modern way of doing things? (or die trying)
Jeff Hammel <jhammel@mozilla.com>
parents:
238
diff
changeset
|
222 branch=self.branch, |
6c72a6f29fc8
update to the modern way of doing things? (or die trying)
Jeff Hammel <jhammel@mozilla.com>
parents:
238
diff
changeset
|
223 category=self.category, |
6c72a6f29fc8
update to the modern way of doing things? (or die trying)
Jeff Hammel <jhammel@mozilla.com>
parents:
238
diff
changeset
|
224 project=self.project, |
6c72a6f29fc8
update to the modern way of doing things? (or die trying)
Jeff Hammel <jhammel@mozilla.com>
parents:
238
diff
changeset
|
225 repository=self.repourl, |
245
5f286f64ce6e
convert to a datetime; i guess you gotta do that now
Jeff Hammel <jhammel@mozilla.com>
parents:
244
diff
changeset
|
226 src=self.src) |
123
4dfb966818b6
maybe were even changing things now
Jeff Hammel <jhammel@mozilla.com>
parents:
122
diff
changeset
|
227 self.lastChange = self.lastPoll |
122
1084bfdedf0a
more logging for debugging
Jeff Hammel <jhammel@mozilla.com>
parents:
121
diff
changeset
|
228 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
229 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
230 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
|
231 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
|
232 log.err(f) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
233 # 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
|
234 return None |
231
d4637641be6e
whitespace cleanup; logging
Jeff Hammel <jhammel@mozilla.com>
parents:
216
diff
changeset
|
235 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
236 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
|
237 log.err(f) |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
238 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
|
239 # 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
|
240 # 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
|
241 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
242 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
|
243 "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
|
244 (stdout, stderr, code) = res |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
245 if code != 0: |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
246 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
|
247 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
248 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
|
249 "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
|
250 if self.running: |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
251 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
|
252 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
|
253 return f |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
254 |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
255 |
213
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
256 ### |
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
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 |
245
5f286f64ce6e
convert to a datetime; i guess you gotta do that now
Jeff Hammel <jhammel@mozilla.com>
parents:
244
diff
changeset
|
261 src = 'hg' |
5f286f64ce6e
convert to a datetime; i guess you gotta do that now
Jeff Hammel <jhammel@mozilla.com>
parents:
244
diff
changeset
|
262 |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
263 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
|
264 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
|
265 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
266 def isInitialized(self): |
165
6396220f937e
stubbing a *working* gitpoller, thank you very much
Jeff Hammel <jhammel@mozilla.com>
parents:
164
diff
changeset
|
267 """is the repository initialized?""" |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
268 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
|
269 |
213
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
270 def checkoutBranch(self, _): |
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
271 """checkout the branch""" |
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
272 d = utils.getProcessOutput(self.binary, ['checkout', self.branch], |
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
273 path=self.workdir, |
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
274 env=dict(PATH=os.environ['PATH']), |
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
275 errortoo=True) |
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
276 return d |
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
277 |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
278 def initializationCommands(self): |
212
9f58383889c0
pretend that we checkout the branch of an hg repository, even though we know that this is a lie
Jeff Hammel <jhammel@mozilla.com>
parents:
211
diff
changeset
|
279 """commands to initialize a mercurial repository""" |
166
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
280 commands = [ [ 'clone', self.repourl, self.workdir ] ] |
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
281 if self.branch != 'default': |
212
9f58383889c0
pretend that we checkout the branch of an hg repository, even though we know that this is a lie
Jeff Hammel <jhammel@mozilla.com>
parents:
211
diff
changeset
|
282 commands.append(['-r', self.workdir, 'checkout', self.branch]) |
166
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
283 return commands |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
284 |
213
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
285 def update(self, _): |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
286 args = ['pull', self.repourl] |
213
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
287 d = utils.getProcessOutput(self.binary, args, path=self.workdir, |
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
288 env=dict(PATH=os.environ['PATH']), |
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
289 errortoo=True ) |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
290 return d |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
291 |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
292 |
213
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
293 def _fetch(self, _): |
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
294 d = self.checkoutBranch(None) |
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
295 d.addCallback(self.update) |
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
296 return d |
c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
Jeff Hammel <jhammel@mozilla.com>
parents:
212
diff
changeset
|
297 |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
298 def _hash(self, _): |
166
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
299 """commit hash""" |
99
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
300 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
|
301 path=self.workdir, |
34b1d30503fa
add a stub for an hg poller; doesnt work yet
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
302 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
|
303 return d |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
304 |
102
a09fab386ed7
unrolling this to look more like the installed version of gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
101
diff
changeset
|
305 |
103 | 306 def _change_list(self, _): |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
307 """ |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
308 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
|
309 processed. XXX the format is pretty particular |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
310 """ |
106 | 311 range = '%s:%s' % (self.preHash, self.postHash) |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
312 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
|
313 path=self.workdir, |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
314 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
|
315 def split_changes(raw_changes): |
41370b2f96e0
starting to get to the changelist
Jeff Hammel <jhammel@mozilla.com>
parents:
103
diff
changeset
|
316 changes = raw_changes.strip() |
41370b2f96e0
starting to get to the changelist
Jeff Hammel <jhammel@mozilla.com>
parents:
103
diff
changeset
|
317 if not changes: |
41370b2f96e0
starting to get to the changelist
Jeff Hammel <jhammel@mozilla.com>
parents:
103
diff
changeset
|
318 return [] |
121 | 319 return changes.split()[1:] |
104
41370b2f96e0
starting to get to the changelist
Jeff Hammel <jhammel@mozilla.com>
parents:
103
diff
changeset
|
320 d.addCallback(split_changes) |
231
d4637641be6e
whitespace cleanup; logging
Jeff Hammel <jhammel@mozilla.com>
parents:
216
diff
changeset
|
321 |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
322 return d |
231
d4637641be6e
whitespace cleanup; logging
Jeff Hammel <jhammel@mozilla.com>
parents:
216
diff
changeset
|
323 |
103 | 324 def _catch_up(self, rev): |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
325 if self.changeCount == 0: |
168
8528311427e0
replace a few more legacy logging instances
Jeff Hammel <jhammel@mozilla.com>
parents:
167
diff
changeset
|
326 self.log('%s: no changes, no catch_up' % self.postHash) |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
327 return |
168
8528311427e0
replace a few more legacy logging instances
Jeff Hammel <jhammel@mozilla.com>
parents:
167
diff
changeset
|
328 self.log('catching up to %s' % self.postHash) |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
329 args = ['update'] |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
330 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
|
331 d.addCallback(self._convert_nonzero_to_failure) |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
332 return d |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
333 |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
334 ### functions for retrieving various metadatas |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
335 |
108 | 336 ### timestamp |
337 | |
119
bc1bd60006a0
hopefully really add some metadata
Jeff Hammel <jhammel@mozilla.com>
parents:
118
diff
changeset
|
338 def _get_commit_timestamp(self, _, rev): |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
339 # unix timestamp |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
340 args = ['log', '-r', rev, '--template', '{date|hgdate}'] |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
341 d = utils.getProcessOutput(self.binary, args, path=self.workdir, env=dict(PATH=os.environ['PATH']), errortoo=False ) |
108 | 342 d.addCallback(self._get_commit_timestamp_from_output) |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
343 return d |
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
344 |
108 | 345 def _get_commit_timestamp_from_output(self, output): |
346 stripped_output = output.strip() | |
347 if self.usetimestamps: | |
348 try: | |
349 _stamp, offset = output.split() | |
350 stamp = float(_stamp) | |
351 except Exception, e: | |
352 log.msg('%s: caught exception converting output "%s" to timestamp' % (self.name, stripped_output)) | |
353 raise e | |
354 self.commitInfo['timestamp'] = stamp | |
355 else: | |
356 self.commitInfo['timestamp'] = None | |
357 | |
358 ### commit author ('name') | |
359 | |
119
bc1bd60006a0
hopefully really add some metadata
Jeff Hammel <jhammel@mozilla.com>
parents:
118
diff
changeset
|
360 def _get_commit_name(self, _, rev): |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
361 """get the author of a commit""" |
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
362 args = ['log', '-r', rev, '--template', '{author}'] |
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_name_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 |
110
36de30ff3008
relabel incorrectly labeled method
Jeff Hammel <jhammel@mozilla.com>
parents:
109
diff
changeset
|
367 def _get_commit_name_from_output(self, output): |
108 | 368 stripped_output = output.strip() |
369 if len(stripped_output) == 0: | |
370 raise EnvironmentError('could not get commit name for rev') | |
371 self.commitInfo['name'] = stripped_output | |
372 return self.commitInfo['name'] # for tests, or so gitpoller says | |
373 | |
374 ### files | |
375 | |
119
bc1bd60006a0
hopefully really add some metadata
Jeff Hammel <jhammel@mozilla.com>
parents:
118
diff
changeset
|
376 def _get_commit_files(self, _, rev): |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
377 """get the files associated with a commit""" |
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
378 args = ['log', '-r', rev, '--template', '{files}'] |
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
379 d = utils.getProcessOutput(self.binary, args, path=self.workdir, env=dict(PATH=os.environ['PATH']), errortoo=False ) |
108 | 380 d.addCallback(self._get_commit_files_from_output) |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
381 return d |
100
d80e96f7e547
flush out hgpoller; untested
Jeff Hammel <jhammel@mozilla.com>
parents:
99
diff
changeset
|
382 |
108 | 383 def _get_commit_files_from_output(self, output): |
120
9f7e39e52739
remember to call the function
Jeff Hammel <jhammel@mozilla.com>
parents:
119
diff
changeset
|
384 fileList = output.strip().split() |
108 | 385 self.commitInfo['files'] = fileList |
386 return self.commitInfo['files'] | |
387 | |
212
9f58383889c0
pretend that we checkout the branch of an hg repository, even though we know that this is a lie
Jeff Hammel <jhammel@mozilla.com>
parents:
211
diff
changeset
|
388 ### commit comments |
108 | 389 |
119
bc1bd60006a0
hopefully really add some metadata
Jeff Hammel <jhammel@mozilla.com>
parents:
118
diff
changeset
|
390 def _get_commit_comments(self, _, rev): |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
391 """get the commit message""" |
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
392 args = ['log', '-r', rev, '--template', '{desc}'] |
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
393 d = utils.getProcessOutput(self.binary, args, path=self.workdir, env=dict(PATH=os.environ['PATH']), errortoo=False ) |
108 | 394 d.addCallback(self._get_commit_comments_from_output) |
101
21ce7537d80d
* fix syntax and indentation errors
Jeff Hammel <jhammel@mozilla.com>
parents:
100
diff
changeset
|
395 return d |
108 | 396 |
397 def _get_commit_comments_from_output(self, output): | |
398 stripped_output = output.strip() | |
399 self.commitInfo['comments'] = stripped_output | |
400 return self.commitInfo['comments'] | |
163
c8596f7a9a29
remove *more* commented code
Jeff Hammel <jhammel@mozilla.com>
parents:
162
diff
changeset
|
401 |
c8596f7a9a29
remove *more* commented code
Jeff Hammel <jhammel@mozilla.com>
parents:
162
diff
changeset
|
402 |
c8596f7a9a29
remove *more* commented code
Jeff Hammel <jhammel@mozilla.com>
parents:
162
diff
changeset
|
403 ### |
c8596f7a9a29
remove *more* commented code
Jeff Hammel <jhammel@mozilla.com>
parents:
162
diff
changeset
|
404 |
c8596f7a9a29
remove *more* commented code
Jeff Hammel <jhammel@mozilla.com>
parents:
162
diff
changeset
|
405 class GitPoller(Poller): |
c8596f7a9a29
remove *more* commented code
Jeff Hammel <jhammel@mozilla.com>
parents:
162
diff
changeset
|
406 |
245
5f286f64ce6e
convert to a datetime; i guess you gotta do that now
Jeff Hammel <jhammel@mozilla.com>
parents:
244
diff
changeset
|
407 src = 'git' |
5f286f64ce6e
convert to a datetime; i guess you gotta do that now
Jeff Hammel <jhammel@mozilla.com>
parents:
244
diff
changeset
|
408 |
163
c8596f7a9a29
remove *more* commented code
Jeff Hammel <jhammel@mozilla.com>
parents:
162
diff
changeset
|
409 def __init__(self, repourl, binary='git', branch='master', **kwargs): |
c8596f7a9a29
remove *more* commented code
Jeff Hammel <jhammel@mozilla.com>
parents:
162
diff
changeset
|
410 Poller.__init__(self, repourl, binary=binary, branch=branch, **kwargs) |
165
6396220f937e
stubbing a *working* gitpoller, thank you very much
Jeff Hammel <jhammel@mozilla.com>
parents:
164
diff
changeset
|
411 |
6396220f937e
stubbing a *working* gitpoller, thank you very much
Jeff Hammel <jhammel@mozilla.com>
parents:
164
diff
changeset
|
412 def isInitialized(self): |
6396220f937e
stubbing a *working* gitpoller, thank you very much
Jeff Hammel <jhammel@mozilla.com>
parents:
164
diff
changeset
|
413 """is the repository initialized?""" |
6396220f937e
stubbing a *working* gitpoller, thank you very much
Jeff Hammel <jhammel@mozilla.com>
parents:
164
diff
changeset
|
414 return os.path.exists(os.path.join(self.workdir, '.git')) |
166
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
415 |
182 | 416 def checkoutBranch(self, _): |
417 """checkout the branch""" | |
418 # XXX I have no clue why I am doing this except that I'm working | |
419 # around twisted evidently not doing what I think its doing | |
420 # so in the face of a clearly superior architecture I will | |
421 # randomly stab around and hope to god that eventually, | |
422 # through sheer dumb luck, I can get on the proper branch | |
423 d = utils.getProcessOutput(self.binary, ['checkout', self.branch], | |
424 path=self.workdir, | |
425 env=dict(PATH=os.environ['PATH']), | |
426 errortoo=True) | |
427 return d | |
428 | |
429 | |
166
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
430 def initializationCommands(self): |
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
431 """commands needed to initialize the repository""" |
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
432 commands = [ [ 'clone', self.repourl, self.workdir ] ] |
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
433 if self.branch != 'master': |
216
85052c5ab8f1
hopefully fix up git magic --work-tree magic
Jeff Hammel <jhammel@mozilla.com>
parents:
213
diff
changeset
|
434 git_dir = self.workdir.rstrip('/') |
85052c5ab8f1
hopefully fix up git magic --work-tree magic
Jeff Hammel <jhammel@mozilla.com>
parents:
213
diff
changeset
|
435 commands.append(['--git-dir', git_dir + '/.git', |
85052c5ab8f1
hopefully fix up git magic --work-tree magic
Jeff Hammel <jhammel@mozilla.com>
parents:
213
diff
changeset
|
436 '--work-tree', git_dir, |
85052c5ab8f1
hopefully fix up git magic --work-tree magic
Jeff Hammel <jhammel@mozilla.com>
parents:
213
diff
changeset
|
437 'checkout', self.branch]) |
231
d4637641be6e
whitespace cleanup; logging
Jeff Hammel <jhammel@mozilla.com>
parents:
216
diff
changeset
|
438 log.msg('GitPoller: initializationCommands: %s' % commands) |
166
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
439 return commands |
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
440 |
182 | 441 def update(self, _): |
166
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
442 args = ['pull', 'origin', self.branch] |
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
443 d = utils.getProcessOutput(self.binary, args, path=self.workdir, |
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
444 env=dict(PATH=os.environ['PATH']), |
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
445 errortoo=True) |
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
446 return d |
231
d4637641be6e
whitespace cleanup; logging
Jeff Hammel <jhammel@mozilla.com>
parents:
216
diff
changeset
|
447 |
182 | 448 def _fetch(self, _): |
449 d = self.checkoutBranch(None) | |
450 d.addCallback(self.update) | |
451 return d | |
166
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
452 |
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
453 def _hash(self, _): |
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
454 """ |
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
455 get hash of where you are now: |
180
d7e79194e971
more blind stabbing in the dark and wasting everyones time
Jeff Hammel <jhammel@mozilla.com>
parents:
179
diff
changeset
|
456 git rev-parse HEAD |
231
d4637641be6e
whitespace cleanup; logging
Jeff Hammel <jhammel@mozilla.com>
parents:
216
diff
changeset
|
457 """ |
182 | 458 d = utils.getProcessOutput(self.binary, ['rev-parse', 'HEAD'], |
166
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
459 path=self.workdir, |
182 | 460 env=dict(PATH=os.environ['PATH']), errortoo=False) |
166
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
461 return d |
182 | 462 |
166
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
463 |
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
464 def _change_list(self, _): |
dba6bcae1575
* removal of some excessive logging
Jeff Hammel <jhammel@mozilla.com>
parents:
165
diff
changeset
|
465 range = '%s..%s' % (self.preHash, self.postHash) |
167
f603922dd5c8
stub gitpoller change list
Jeff Hammel <jhammel@mozilla.com>
parents:
166
diff
changeset
|
466 d = utils.getProcessOutput(self.binary, |
f603922dd5c8
stub gitpoller change list
Jeff Hammel <jhammel@mozilla.com>
parents:
166
diff
changeset
|
467 ['log', range, r'--format=%H'], |
f603922dd5c8
stub gitpoller change list
Jeff Hammel <jhammel@mozilla.com>
parents:
166
diff
changeset
|
468 path=self.workdir, |
f603922dd5c8
stub gitpoller change list
Jeff Hammel <jhammel@mozilla.com>
parents:
166
diff
changeset
|
469 env=dict(PATH=os.environ['PATH']), |
f603922dd5c8
stub gitpoller change list
Jeff Hammel <jhammel@mozilla.com>
parents:
166
diff
changeset
|
470 errortoo=False) |
f603922dd5c8
stub gitpoller change list
Jeff Hammel <jhammel@mozilla.com>
parents:
166
diff
changeset
|
471 def split_changes(raw_changes): |
f603922dd5c8
stub gitpoller change list
Jeff Hammel <jhammel@mozilla.com>
parents:
166
diff
changeset
|
472 changes = raw_changes.strip() |
f603922dd5c8
stub gitpoller change list
Jeff Hammel <jhammel@mozilla.com>
parents:
166
diff
changeset
|
473 if not changes: |
f603922dd5c8
stub gitpoller change list
Jeff Hammel <jhammel@mozilla.com>
parents:
166
diff
changeset
|
474 return [] |
f603922dd5c8
stub gitpoller change list
Jeff Hammel <jhammel@mozilla.com>
parents:
166
diff
changeset
|
475 return changes.split() |
f603922dd5c8
stub gitpoller change list
Jeff Hammel <jhammel@mozilla.com>
parents:
166
diff
changeset
|
476 d.addCallback(split_changes) |
f603922dd5c8
stub gitpoller change list
Jeff Hammel <jhammel@mozilla.com>
parents:
166
diff
changeset
|
477 return d |
169 | 478 |
171
af76bbcc4457
add a dummy catch up function; this should work (at least in theory) as-is, though it might be better to FETCH earlier and pull now
Jeff Hammel <jhammel@mozilla.com>
parents:
170
diff
changeset
|
479 def _catch_up(self, rev): |
af76bbcc4457
add a dummy catch up function; this should work (at least in theory) as-is, though it might be better to FETCH earlier and pull now
Jeff Hammel <jhammel@mozilla.com>
parents:
170
diff
changeset
|
480 if self.changeCount == 0: |
af76bbcc4457
add a dummy catch up function; this should work (at least in theory) as-is, though it might be better to FETCH earlier and pull now
Jeff Hammel <jhammel@mozilla.com>
parents:
170
diff
changeset
|
481 self.log('%s: no changes, no catch_up' % self.postHash) |
af76bbcc4457
add a dummy catch up function; this should work (at least in theory) as-is, though it might be better to FETCH earlier and pull now
Jeff Hammel <jhammel@mozilla.com>
parents:
170
diff
changeset
|
482 return |
af76bbcc4457
add a dummy catch up function; this should work (at least in theory) as-is, though it might be better to FETCH earlier and pull now
Jeff Hammel <jhammel@mozilla.com>
parents:
170
diff
changeset
|
483 self.log('catching up to %s' % self.postHash) |
af76bbcc4457
add a dummy catch up function; this should work (at least in theory) as-is, though it might be better to FETCH earlier and pull now
Jeff Hammel <jhammel@mozilla.com>
parents:
170
diff
changeset
|
484 |
af76bbcc4457
add a dummy catch up function; this should work (at least in theory) as-is, though it might be better to FETCH earlier and pull now
Jeff Hammel <jhammel@mozilla.com>
parents:
170
diff
changeset
|
485 # XXX keeping this in as a dummy for now |
af76bbcc4457
add a dummy catch up function; this should work (at least in theory) as-is, though it might be better to FETCH earlier and pull now
Jeff Hammel <jhammel@mozilla.com>
parents:
170
diff
changeset
|
486 # should *really* do fetch earlier and *now* do pull |
af76bbcc4457
add a dummy catch up function; this should work (at least in theory) as-is, though it might be better to FETCH earlier and pull now
Jeff Hammel <jhammel@mozilla.com>
parents:
170
diff
changeset
|
487 # (or whatever) |
af76bbcc4457
add a dummy catch up function; this should work (at least in theory) as-is, though it might be better to FETCH earlier and pull now
Jeff Hammel <jhammel@mozilla.com>
parents:
170
diff
changeset
|
488 args = ['status'] |
af76bbcc4457
add a dummy catch up function; this should work (at least in theory) as-is, though it might be better to FETCH earlier and pull now
Jeff Hammel <jhammel@mozilla.com>
parents:
170
diff
changeset
|
489 d = utils.getProcessOutputAndValue(self.binary, args, path=self.workdir, env=dict(PATH=os.environ['PATH'])) |
af76bbcc4457
add a dummy catch up function; this should work (at least in theory) as-is, though it might be better to FETCH earlier and pull now
Jeff Hammel <jhammel@mozilla.com>
parents:
170
diff
changeset
|
490 d.addCallback(self._convert_nonzero_to_failure) |
af76bbcc4457
add a dummy catch up function; this should work (at least in theory) as-is, though it might be better to FETCH earlier and pull now
Jeff Hammel <jhammel@mozilla.com>
parents:
170
diff
changeset
|
491 return d |
af76bbcc4457
add a dummy catch up function; this should work (at least in theory) as-is, though it might be better to FETCH earlier and pull now
Jeff Hammel <jhammel@mozilla.com>
parents:
170
diff
changeset
|
492 |
169 | 493 ### metadata for commits |
494 | |
495 ### timestamp | |
496 | |
182 | 497 def _get_commit_timestamp(self, _, rev): |
169 | 498 # unix timestamp |
499 args = ['log', rev, '--no-walk', r'--format=%ct'] | |
500 d = utils.getProcessOutput(self.binary, args, path=self.workdir, | |
501 env=dict(PATH=os.environ['PATH']), | |
502 errortoo=False ) | |
503 d.addCallback(self._get_commit_timestamp_from_output) | |
504 return d | |
505 | |
506 def _get_commit_timestamp_from_output(self, output): | |
507 stripped_output = output.strip() | |
508 if self.usetimestamps: | |
509 try: | |
510 stamp = float(stripped_output) | |
511 except Exception, e: | |
512 self.log('caught exception converting output \'%s\' to timestamp' % stripped_output) | |
513 raise e | |
514 self.commitInfo['timestamp'] = stamp | |
515 else: | |
516 self.commitInfo['timestamp'] = None | |
517 return self.commitInfo['timestamp'] # for tests | |
518 | |
519 ### commit author ('name') | |
170
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
520 |
182 | 521 def _get_commit_name(self, _, rev): |
170
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
522 args = ['log', rev, '--no-walk', r'--format=%aE'] |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
523 d = utils.getProcessOutput(self.binary, args, path=self.workdir, |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
524 env=dict(PATH=os.environ['PATH']), |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
525 errortoo=False ) |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
526 d.addCallback(self._get_commit_name_from_output) |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
527 return d |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
528 |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
529 def _get_commit_name_from_output(self, output): |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
530 stripped_output = output.strip() |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
531 if len(stripped_output) == 0: |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
532 raise EnvironmentError('could not get commit name for rev') |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
533 self.commitInfo['name'] = stripped_output |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
534 return self.commitInfo['name'] # for tests |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
535 |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
536 ### files |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
537 |
182 | 538 def _get_commit_files(self, _, rev): |
170
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
539 args = ['log', rev, '--name-only', '--no-walk', r'--format=%n'] |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
540 d = utils.getProcessOutput(self.binary, args, path=self.workdir, |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
541 env=dict(PATH=os.environ['PATH']), |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
542 errortoo=False ) |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
543 d.addCallback(self._get_commit_files_from_output) |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
544 return d |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
545 |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
546 def _get_commit_files_from_output(self, output): |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
547 fileList = output.split() |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
548 self.commitInfo['files'] = fileList |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
549 return self.commitInfo['files'] # for tests |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
550 |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
551 |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
552 ### comments |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
553 |
182 | 554 def _get_commit_comments(self, _, rev): |
170
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
555 args = ['log', rev, '--no-walk', r'--format=%s%n%b'] |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
556 d = utils.getProcessOutput(self.binary, args, path=self.workdir, |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
557 env=dict(PATH=os.environ['PATH']), |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
558 errortoo=False ) |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
559 d.addCallback(self._get_commit_comments_from_output) |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
560 return d |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
561 |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
562 def _get_commit_comments_from_output(self, output): |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
563 stripped_output = output.strip() |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
564 if len(stripped_output) == 0: |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
565 raise EnvironmentError('could not get commit comment for rev') |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
566 self.commitInfo['comments'] = stripped_output |
274d7dc787e3
the rest of the metadata for gitpoller
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
567 return self.commitInfo['comments'] # for tests |