Log pulls too
authorPaul Crowley <paul@lshift.net>
Fri, 20 Feb 2009 15:24:15 +0000
changeset 55 2661b21688d4
parent 54 e2ca551c2822
child 56 9ea9a30cd060
Log pulls too
src/init/conf/remote-hgrc
src/logging.py
--- a/src/init/conf/remote-hgrc	Fri Feb 20 15:19:51 2009 +0000
+++ b/src/init/conf/remote-hgrc	Fri Feb 20 15:24:15 2009 +0000
@@ -6,4 +6,5 @@
 [hooks]
 pretxnchangegroup.access = python:access.hook
 changegroup.aaaaa_logging = python:logging.hook
+outgoing.aaaaa_logging = python:logging.hook
 
--- a/src/logging.py	Fri Feb 20 15:19:51 2009 +0000
+++ b/src/logging.py	Fri Feb 20 15:24:15 2009 +0000
@@ -15,17 +15,21 @@
 import changes
         
 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
-    if hooktype != 'changegroup':
+    if hooktype == 'changegroup':
+        op = "push"
+    elif hooktype == 'outgoing':
+        op = "pull"
+    else:
         raise mercurial.util.Abort(_('logging installed as wrong hook type,'
-            ' must be changegroup but is %s') % hooktype)
+            ' must be changegroup or outgoing but is %s') % hooktype)
     t = time.strftime("%Y-%m-%d_%H:%M:%S", time.gmtime())
     user = os.environ['REMOTE_USER']
     # FIXME: lock it
     log = open(repo.join("push-log"), "a+")
     try:
         for ctx in changes.changes(repo, node):
-            log.write("%s push key=%s changeset=%s\n" % 
-                (t, user, mercurial.node.hex(ctx.node())))
+            log.write("%s %s key=%s changeset=%s\n" % 
+                (t, op, user, mercurial.node.hex(ctx.node())))
     finally:
         log.close()