Comments
Patch
@@ -154,8 +154,9 @@ def push(repo, remote, force=False, revs
we have outgoing changesets but refused to push
- other values as described by addchangegroup()
'''
pushop = pushoperation(repo, remote, force, revs, newbranch)
+ repo.events.pushbegin(pushop=pushop)
if pushop.remote.local():
missing = (set(pushop.repo.requirements)
- pushop.remote.local().supported)
if missing:
@@ -1782,4 +1782,14 @@ def islocal(path):
return True
class localrepoevents(util.eventmanager):
'''Defines events for localrepository instances.'''
+
+ def pushbegin(pushop):
+ '''Event that signals a push operation is about to be performed.
+
+ Event handlers receive an exchange.pushoperation as a single argument.
+
+ Expected use cases include policy checking a push's parameters and
+ modifying what a push attempts to do.
+ '''
+
new file mode 100644
@@ -0,0 +1,30 @@
+ $ cat >> events.py << EOF
+ > from mercurial import exchange
+ > def pushbegin(pushop):
+ > assert isinstance(pushop, exchange.pushoperation)
+ > pushop.ui.write('pushbegin %s\n' % pushop.repo.path)
+ > def reposetup(ui, repo):
+ > repo.events.pushbegin += pushbegin
+ > EOF
+
+ $ hg init server
+ $ hg init client
+ $ cd client
+ $ cat >> .hg/hgrc << EOF
+ > [extensions]
+ > events = $TESTTMP/events.py
+ > EOF
+
+Ensure push-related events are firing
+
+ $ touch foo
+ $ hg commit -A -m 'initial'
+ adding foo
+ $ hg push ../server
+ pushing to ../server
+ pushbegin $TESTTMP/client/.hg
+ searching for changes
+ adding changesets
+ adding manifests
+ adding file changes
+ added 1 changesets with 1 changes to 1 files