Patchwork [5,of,6] exchange: add pushafterdatasent event

login
register
mail settings
Submitter Gregory Szorc
Date Aug. 19, 2014, 5:30 a.m.
Message ID <31241503398485f7c807.1408426217@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/5505/
State Changes Requested
Headers show

Comments

Gregory Szorc - Aug. 19, 2014, 5:30 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1408424867 25200
#      Mon Aug 18 22:07:47 2014 -0700
# Node ID 31241503398485f7c8076808e41f8395968d9a04
# Parent  8548dee3e8f6699c0e2c530f1d5fa7e1009a540c
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.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -188,8 +188,9 @@  def push(repo, remote, force=False, revs
                 _pushbundle2(pushop)
             _pushchangeset(pushop)
             _pushsyncphase(pushop)
             _pushobsolete(pushop)
+            pushop.repo.events.pushafterdatasent(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
@@ -316,8 +316,15 @@  class localrepository(object):
         # Event handlers receive the exchange.pushoperation instance for the
         # in-progress push.
         self.events.register('pushafterdiscovery')
 
+        # pushafterdatasent is fired during a push operation, after all
+        # local data has been transmitted 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 the
+        # exchange.pushoperation instance for the push.
+        self.events.register('pushafterdatasent')
+
     def close(self):
         pass
 
     def _restrictcapabilities(self, caps):
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