Patchwork [6,of,6] exchange: add pushfinish event

login
register
mail settings
Submitter Gregory Szorc
Date Aug. 19, 2014, 5:30 a.m.
Message ID <cded6e3926fd89054367.1408426218@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/5506/
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 1408425615 25200
#      Mon Aug 18 22:20:15 2014 -0700
# Node ID cded6e3926fd890543674aaab95569e6a9c96b6e
# Parent  31241503398485f7c8076808e41f8395968d9a04
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.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -197,8 +197,9 @@  def push(repo, remote, force=False, revs
         if locallock is not None:
             locallock.release()
 
     _pushbookmark(pushop)
+    pushop.repo.events.pushfinish(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
@@ -323,8 +323,14 @@  class localrepository(object):
         # would have completed or been rolled back. Event handlers receive the
         # exchange.pushoperation instance for the push.
         self.events.register('pushafterdatasent')
 
+        # pushfinish is fired at the end of a push operation, after the local
+        # repository lock is released. Event handlers receive the
+        # exchange.pushoperation instance for the push. The event is meant
+        # to inspect what happened or to change the result code from the push.
+        self.events.register('pushfinish')
+
     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
@@ -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,6 @@  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
+>>>>>>> source