Patchwork [4,of,6] exchange: add beforepush pyhook

login
register
mail settings
Submitter Gregory Szorc
Date July 12, 2014, 8:12 p.m.
Message ID <b8382807ed1766b93799.1405195944@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/5151/
State Changes Requested
Headers show

Comments

Gregory Szorc - July 12, 2014, 8:12 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@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.

Patch

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):