author | Paul Crowley <paul@lshift.net> |
Tue, 24 Feb 2009 09:49:56 +0000 | |
changeset 63 | b75177d307e5 |
parent 62 | f1e319d3672a |
permissions | -rw-r--r-- |
54 | 1 |
# Copyright 2008-2009 LShift Ltd |
2 |
# |
|
3 |
# Authors: |
|
4 |
# Paul Crowley <paul@lshift.net> |
|
5 |
# |
|
6 |
# This software may be used and distributed according to the terms |
|
7 |
# of the GNU General Public License, incorporated herein by reference. |
|
8 |
||
9 |
from mercurial.i18n import _ |
|
10 |
import mercurial.util |
|
11 |
import mercurial.node |
|
12 |
||
13 |
import os |
|
14 |
import time |
|
15 |
import changes |
|
16 |
||
17 |
def hook(ui, repo, hooktype, node=None, source=None, **kwargs): |
|
55 | 18 |
if hooktype == 'changegroup': |
19 |
op = "push" |
|
20 |
elif hooktype == 'outgoing': |
|
21 |
op = "pull" |
|
22 |
else: |
|
59
f96de2d99f00
give logging module a more specific name
Paul Crowley <paul@lshift.net>
parents:
56
diff
changeset
|
23 |
raise mercurial.util.Abort(_('servelog installed as wrong hook type,' |
55 | 24 |
' must be changegroup or outgoing but is %s') % hooktype) |
54 | 25 |
t = time.strftime("%Y-%m-%d_%H:%M:%S", time.gmtime()) |
26 |
user = os.environ['REMOTE_USER'] |
|
27 |
# FIXME: lock it |
|
56
9ea9a30cd060
Give log more appropriate name now it has pulls too
Paul Crowley <paul@lshift.net>
parents:
55
diff
changeset
|
28 |
log = open(repo.join("serve-log"), "a+") |
54 | 29 |
try: |
30 |
for ctx in changes.changes(repo, node): |
|
55 | 31 |
log.write("%s %s key=%s changeset=%s\n" % |
32 |
(t, op, user, mercurial.node.hex(ctx.node()))) |
|
54 | 33 |
finally: |
34 |
log.close() |