[PATCH 6 of 6 events v3] exchange: add pushfinish event
Gregory Szorc
gregory.szorc at gmail.com
Sun Sep 28 16:01:44 CDT 2014
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1408425615 25200
# Mon Aug 18 22:20:15 2014 -0700
# Node ID 1b65349476f439879d151220d33a054699ccbe62
# Parent 9bb4dc20ca19670079f246b6ee8d1e4688a0a25d
exchange: add pushfinish event
The pushfinish event provides an extensibility point to see
what the final result of a push was. It also allows extensions to
change the result code of a push.
This commit rounds out events for pushing, having established
code injection points in nearly every place extensions may
want them.
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -213,8 +213,9 @@ def push(repo, remote, force=False, revs
finally:
if locallock is not None:
locallock.release()
+ pushop.repo.events.pushfinish(pushop=pushop)
return pushop.ret
# list of steps to perform discovery before push
pushdiscoveryorder = []
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1819,4 +1819,19 @@ class localrepoevents(util.eventmanager)
Expected use cases include performing additional functionality after
push that still needs to be done inside a local repository lock.
'''
+
+ def pushfinish(pushop):
+ '''Event fired at the end of a push operation.
+
+ This event is fired as the last operation as part of push. The local
+ repository lock has been released when this event fires.
+
+ Event handlers receive an exchange.pushoperation instance for the
+ push. It will be populated with the results of the push.
+
+ Generally speaking, if your post-push event handler modifies state,
+ this should be done inside the local repository lock as part of the
+ pushafterdatasent event.
+ '''
+
diff --git a/tests/test-events.t b/tests/test-events.t
--- a/tests/test-events.t
+++ b/tests/test-events.t
@@ -11,12 +11,17 @@
> def pushafterdatasent(pushop):
> assert isinstance(pushop, exchange.pushoperation)
> pushop.ui.write('pushafterdatasent %s\n' % pushop.repo.path)
>
+ > def pushfinish(pushop):
+ > assert isinstance(pushop, exchange.pushoperation)
+ > pushop.ui.write('pushfinish %s\n' % pushop.repo.path)
+ >
> def reposetup(ui, repo):
> repo.events.pushbegin += pushbegin
> repo.events.pushafterdiscovery += pushafterdiscovery
> repo.events.pushafterdatasent += pushafterdatasent
+ > repo.events.pushfinish += pushfinish
> EOF
$ hg init server
$ hg init client
@@ -40,4 +45,5 @@ Ensure push-related events are firing
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
pushafterdatasent $TESTTMP/client/.hg
+ pushfinish $TESTTMP/client/.hg
More information about the Mercurial-devel
mailing list