src/mercurialserver/servelog.py
changeset 78 2a3407a14654
parent 67 fd16d9a1234b
child 242 03d8f07230b3
equal deleted inserted replaced
77:8d14aac93b5d 78:2a3407a14654
    10 import mercurial.util
    10 import mercurial.util
    11 import mercurial.node
    11 import mercurial.node
    12 
    12 
    13 import os
    13 import os
    14 import time
    14 import time
    15 from mercurialserver import changes
    15 from mercurialserver import ruleset, changes
    16         
    16 
    17 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
    17 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
    18     if hooktype == 'changegroup':
    18     if hooktype == 'changegroup':
    19         op = "push"
    19         op = "push"
    20     elif hooktype == 'outgoing':
    20     elif hooktype == 'outgoing':
    21         op = "pull"
    21         op = "pull"
    22     else:
    22     else:
    23         raise mercurial.util.Abort(_('servelog installed as wrong hook type,'
    23         raise mercurial.util.Abort(_('servelog installed as wrong hook type,'
    24             ' must be changegroup or outgoing but is %s') % hooktype)
    24             ' must be changegroup or outgoing but is %s') % hooktype)
    25     t = time.strftime("%Y-%m-%d_%H:%M:%S", time.gmtime())
    25     t = time.strftime("%Y-%m-%d_%H:%M:%S", time.gmtime())
    26     user = os.environ['REMOTE_USER']
    26     user = ruleset.rules.get('user')
    27     # FIXME: lock it
    27     # FIXME: lock it
    28     log = open(repo.join("serve-log"), "a+")
    28     log = open(repo.join("serve-log"), "a+")
    29     try:
    29     try:
    30         for ctx in changes.changes(repo, node):
    30         for ctx in changes.changes(repo, node):
    31             log.write("%s %s key=%s changeset=%s\n" % 
    31             log.write("%s %s key=%s changeset=%s\n" %