[PATCH 5 of 6 events v3] exchange: add pushafterdatasent event
Gregory Szorc
gregory.szorc at gmail.com
Sun Sep 28 16:01:43 CDT 2014
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1408424867 25200
# Mon Aug 18 22:07:47 2014 -0700
# Node ID 9bb4dc20ca19670079f246b6ee8d1e4688a0a25d
# Parent 5fae746b4551e2c593aca077d25f8b6a4e5b6159
exchange: add pushafterdatasent event
Extensions may wish to perform functionality after a push has
transferred data but while a lock on the local repo is still held.
The pushafterdatasent event facilities that.
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -205,8 +205,9 @@ def push(repo, remote, force=False, revs
_pushchangeset(pushop)
_pushsyncphase(pushop)
_pushobsolete(pushop)
_pushbookmark(pushop)
+ pushop.repo.events.pushafterdatasent(pushop=pushop)
finally:
if lock is not None:
lock.release()
finally:
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1805,4 +1805,18 @@ class localrepoevents(util.eventmanager)
Expected use cases of this event include examining and possibly
modifying the set of outgoing nodes and heads.
'''
+
+ def pushafterdatasent(pushop):
+ '''Event fired during push, after all local data has been transmitted.
+
+ This event is fired after all local data has been sent to the remote,
+ but before the local repository lock is released. The transaction on
+ the remote would have completed or been rolled back.
+
+ Event handlers receive an exchange.pushoperation instance for the
+ push. It will be populated with the results of the push.
+
+ Expected use cases include performing additional functionality after
+ push that still needs to be done inside a local repository lock.
+ '''
diff --git a/tests/test-events.t b/tests/test-events.t
--- a/tests/test-events.t
+++ b/tests/test-events.t
@@ -7,11 +7,16 @@
> def pushafterdiscovery(pushop):
> assert isinstance(pushop, exchange.pushoperation)
> pushop.ui.write('pushafterdiscovery %s\n' % pushop.repo.path)
>
+ > def pushafterdatasent(pushop):
+ > assert isinstance(pushop, exchange.pushoperation)
+ > pushop.ui.write('pushafterdatasent %s\n' % pushop.repo.path)
+ >
> def reposetup(ui, repo):
> repo.events.pushbegin += pushbegin
> repo.events.pushafterdiscovery += pushafterdiscovery
+ > repo.events.pushafterdatasent += pushafterdatasent
> EOF
$ hg init server
$ hg init client
@@ -34,4 +39,5 @@ Ensure push-related events are firing
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
+ pushafterdatasent $TESTTMP/client/.hg
More information about the Mercurial-devel
mailing list