# HG changeset patch # User Paul Crowley # Date 1235142530 0 # Node ID f9eb98bb0791e1895d3f3f23dea56b60578a79b4 # Parent d87eeeae29a50f7b4447d37f7db44003ffd51bc8 Encapsulate change finding with backwards compatibility diff -r d87eeeae29a5 -r f9eb98bb0791 install --- a/install Fri Feb 20 14:29:48 2009 +0000 +++ b/install Fri Feb 20 15:08:50 2009 +0000 @@ -7,6 +7,7 @@ src/hg-ssh \ src/do-refresh-auth install -o root -g root -t /usr/local/lib/mercurial-server -m 644 \ + src/changes.py \ src/access.py \ src/ruleset.py install -o root -g root -d /usr/local/lib/mercurial-server/init diff -r d87eeeae29a5 -r f9eb98bb0791 src/access.py --- a/src/access.py Fri Feb 20 14:29:48 2009 +0000 +++ b/src/access.py Fri Feb 20 15:08:50 2009 +0000 @@ -13,6 +13,7 @@ import os import ruleset +import changes class Checker(object): '''acl checker.''' @@ -40,14 +41,11 @@ raise mercurial.util.Abort(_('%s: access denied for changeset %s') % (__name__, ctx.short())) - def hook(ui, repo, hooktype, node=None, source=None, **kwargs): if hooktype != 'pretxnchangegroup': raise mercurial.util.Abort(_('config error - hook type "%s" cannot stop ' 'incoming changesets') % hooktype) c = Checker(ui, repo) - start = repo.changectx(node).rev() - end = repo.changelog.count() - for rev in xrange(start, end): - c.check(repo.changectx(rev)) + for ctx in changes.changes(repo, node): + c.check(ctx) diff -r d87eeeae29a5 -r f9eb98bb0791 src/changes.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/changes.py Fri Feb 20 15:08:50 2009 +0000 @@ -0,0 +1,19 @@ +# Copyright 2008-2009 LShift Ltd +# Copyright 2006 Vadim Gelfer +# +# Authors: +# Paul Crowley +# Vadim Gelfer +# +# This software may be used and distributed according to the terms +# of the GNU General Public License, incorporated herein by reference. + +def changes(repo, node): + start = repo.changectx(node).rev() + try: + end = len(repo.changelog) + except: + end = repo.changelog.count() + for rev in xrange(start, end): + yield repo.changectx(rev) +