# HG changeset patch # User Paul Crowley # Date 1235151270 0 # Node ID f96de2d99f001e5b1f152cb549dcdc3ba58c251d # Parent 207a413897b453daccbba0c96356e76944b28653 give logging module a more specific name diff -r 207a413897b4 -r f96de2d99f00 install --- a/install Fri Feb 20 15:47:52 2009 +0000 +++ b/install Fri Feb 20 17:34:30 2009 +0000 @@ -9,7 +9,7 @@ install -o root -g root -t /usr/local/lib/mercurial-server -m 644 \ src/changes.py \ src/access.py \ - src/logging.py \ + src/servelog.py \ src/ruleset.py install -o root -g root -d /usr/local/lib/mercurial-server/init install -o root -g root -t /usr/local/lib/mercurial-server/init \ diff -r 207a413897b4 -r f96de2d99f00 src/init/conf/remote-hgrc --- a/src/init/conf/remote-hgrc Fri Feb 20 15:47:52 2009 +0000 +++ b/src/init/conf/remote-hgrc Fri Feb 20 17:34:30 2009 +0000 @@ -2,10 +2,10 @@ [extensions] access = /usr/local/lib/mercurial-server/access.py -logging = /usr/local/lib/mercurial-server/logging.py +servelog = /usr/local/lib/mercurial-server/servelog.py [hooks] pretxnchangegroup.access = python:access.hook -changegroup.aaaaa_logging = python:logging.hook -outgoing.aaaaa_logging = python:logging.hook +changegroup.aaaaa_servelog = python:servelog.hook +outgoing.aaaaa_servelog = python:servelog.hook diff -r 207a413897b4 -r f96de2d99f00 src/logging.py --- a/src/logging.py Fri Feb 20 15:47:52 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -# Copyright 2008-2009 LShift Ltd -# -# Authors: -# Paul Crowley -# -# This software may be used and distributed according to the terms -# of the GNU General Public License, incorporated herein by reference. - -from mercurial.i18n import _ -import mercurial.util -import mercurial.node - -import os -import time -import changes - -def hook(ui, repo, hooktype, node=None, source=None, **kwargs): - if hooktype == 'changegroup': - op = "push" - elif hooktype == 'outgoing': - op = "pull" - else: - raise mercurial.util.Abort(_('logging installed as wrong hook type,' - ' 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("serve-log"), "a+") - try: - for ctx in changes.changes(repo, node): - log.write("%s %s key=%s changeset=%s\n" % - (t, op, user, mercurial.node.hex(ctx.node()))) - finally: - log.close() - diff -r 207a413897b4 -r f96de2d99f00 src/servelog.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/servelog.py Fri Feb 20 17:34:30 2009 +0000 @@ -0,0 +1,35 @@ +# Copyright 2008-2009 LShift Ltd +# +# Authors: +# Paul Crowley +# +# This software may be used and distributed according to the terms +# of the GNU General Public License, incorporated herein by reference. + +from mercurial.i18n import _ +import mercurial.util +import mercurial.node + +import os +import time +import changes + +def hook(ui, repo, hooktype, node=None, source=None, **kwargs): + if hooktype == 'changegroup': + op = "push" + elif hooktype == 'outgoing': + op = "pull" + else: + raise mercurial.util.Abort(_('servelog installed as wrong hook type,' + ' 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("serve-log"), "a+") + try: + for ctx in changes.changes(repo, node): + log.write("%s %s key=%s changeset=%s\n" % + (t, op, user, mercurial.node.hex(ctx.node()))) + finally: + log.close() +