Created
October 16, 2010 16:21
-
-
Save anonymous/629983 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Prehook ran successfully. | |
Sat Oct 16 18:17:49 CEST 2010 Eric Kow <kowey@darcs.net> | |
* Fix incorrect import. | |
{ | |
hunk ./detectors/statusauditor.py 24 | |
+import roundup.exceptions | |
hunk ./detectors/statusauditor.py 124 | |
- raise Reject, "Sorry! darcswatch is only allowed to set status to "\ | |
+ raise roundup.exceptions.Reject, "Sorry! darcswatch is only allowed to set status to "\ | |
} | |
Sat Oct 16 18:14:21 CEST 2010 Eric Kow <kowey@darcs.net> | |
* Fix undefined variable name. | |
hunk ./detectors/statusauditor.py 121 | |
- authid = msg.get(msgid, 'author') | |
+ authid = db.msg.get(msgid, 'author') | |
Sat Oct 16 18:12:17 CEST 2010 Eric Kow <kowey@darcs.net> | |
* Missing import. | |
hunk ./detectors/statusauditor.py 23 | |
+from roundup import roundupdb | |
+ | |
Sat Oct 16 18:07:44 CEST 2010 Eric Kow <kowey@darcs.net> | |
* Argh, used the wrong variable name. | |
hunk ./detectors/statusauditor.py 144 | |
- messages.append(msgid) | |
+ new_messages.append(msgid) | |
Sat Oct 16 18:01:17 CEST 2010 Eric Kow <kowey@darcs.net> | |
* Argh, misnamed variable. | |
hunk ./detectors/statusauditor.py 99 | |
- if not new_values.has_key('status'): | |
+ if not newvalues.has_key('status'): | |
Sat Oct 16 17:49:43 CEST 2010 Eric Kow <kowey@darcs.net> | |
* Argh, syntax error. | |
hunk ./detectors/statusauditor.py 116 | |
- for msgid in determineNewMessages(cl, nodeid, newvalues) | |
+ for msgid in determineNewMessages(cl, nodeid, newvalues): | |
Sat Oct 16 17:47:34 CEST 2010 Eric Kow <kowey@darcs.net> | |
* Only allow darcswatch to set needs-review if status still needs-screening. | |
{ | |
hunk ./detectors/statusauditor.py 94 | |
+def avoid_darcswatch_race(db, cl, nodeid, newvalues): | |
+ ''' Only allow darcswatch to set status to needs-review if the | |
+ status is still needs-screening | |
+ ''' | |
+ | |
+ if not new_values.has_key('status'): | |
+ return | |
+ needs_screening_id = db.patchstatus.lookup('needs-screening') | |
+ needs_review_id = db.patchstatus.lookup('needs-review') | |
+ current_status = cl.get(nodeid, 'status') | |
+ new_status = newvalues['status'] | |
+ | |
+ if current_status == needs_screening_id: | |
+ # doesn't really matter what we do here | |
+ return | |
+ if new_status != needs_review_id: | |
+ # other statuses, eg. accepted, rejected etc | |
+ # have no such restriction | |
+ return | |
+ | |
+ # here, we know we have (!needs-screening) -> needs-review | |
+ # which we must reject if it comes from darcswatch | |
+ for msgid in determineNewMessages(cl, nodeid, newvalues) | |
+ try: | |
+ darcswatch_id = db.user.lookup('darcswatch') | |
+ authid = msg.get(msgid, 'author') | |
+ if authid == darcswatch_id: | |
+ raise Reject, "Sorry! darcswatch is only allowed to set status to "\ | |
+ "needs-review if the status is still needs-screening, "\ | |
+ "but it's been beaten to the punch" | |
+ except roundupdb.MessageSendError, message: | |
+ raise roundupdb.DetectorError, message | |
+ | |
+def determineNewMessages(cl, nodeid, newvalues): | |
+ ''' Figure a list of the messages that are being added to the given | |
+ node in this transaction. | |
+ ''' | |
+ messages_before = cl.get(nodeid, 'messages') | |
+ if newvalues.has_key('messages'): | |
+ messages_after = newvalues['messages'] | |
+ else: | |
+ messages_after = [] | |
+ | |
+ b = {} | |
+ for msgid in messages_before: | |
+ b[msgid] = 1 | |
+ | |
+ new_messages = [] | |
+ for msgid in messages_after: | |
+ if not b.has_key(msgid): | |
+ messages.append(msgid) | |
+ return new_messages | |
+ | |
hunk ./detectors/statusauditor.py 153 | |
+ db.patch.audit('set', avoid_darcswatch_race) | |
} | |
Posthook ran successfully. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment