[PATCH 4 of 6] exchange: add beforepush pyhook

Gregory Szorc gregory.szorc at gmail.com
Sat Jul 12 15:12:24 CDT 2014


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1405192510 25200
#      Sat Jul 12 12:15:10 2014 -0700
# Node ID b8382807ed1766b93799b94eaabe2774fbca65e2
# Parent  5a9b80c2b3e681e15a62a6692a03594149feb998
exchange: add beforepush pyhook

Now that we have a generic extensibility point for internal hooks,
localrepo.checkpush() can be re-implemented as one. This patch
establishes the "beforepush" pyhook to complement "afterpush".

localrepo.checkpush() will be removed in subsequent patches.

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -121,8 +121,9 @@ def push(repo, remote, force=False, revs
         msg = 'cannot lock source repository: %s\n' % err
         pushop.ui.debug(msg)
     try:
         pushop.repo.checkpush(pushop)
+        pushop.repo.runpyhook('beforepush', pushop=pushop)
         lock = None
         unbundle = pushop.remote.capable('unbundle')
         if not unbundle:
             lock = pushop.remote.lock()
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -302,8 +302,9 @@ class localrepository(object):
         self.filteredrevcache = {}
 
         # Maps names to list of callables.
         self._hooks = {
+            'beforepush': [],
             'afterpush': [],
         }
 
     def close(self):


More information about the Mercurial-devel mailing list