Comments
Patch
@@ -138,8 +138,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)
if pushop.remote.local():
missing = (set(pushop.repo.requirements)
- pushop.remote.local().supported)
if missing:
@@ -304,8 +304,14 @@ class localrepository(object):
self.filteredrevcache = {}
self.events = util.eventmanager()
+ # pushbefore is fired when a push operation is about to be performed.
+ # Event handlers will receive an exchange.pushoperation as a single
+ # argument. Event handlers can modify the pushop to change what will
+ # be done by the push operation.
+ self.events.register('pushbegin')
+
def close(self):
pass
def _restrictcapabilities(self, caps):
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