[PATCH 1 of 3 evolve-ext] exthelper: add prereposetup functions

Durham Goode durham at fb.com
Wed Mar 18 02:17:26 UTC 2015


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1426644159 25200
#      Tue Mar 17 19:02:39 2015 -0700
# Branch stable
# Node ID e9da6b7083a5869a59b3ed14d709761aa2d30822
# Parent  9523c027a240fe4ed5d9bb1afdd9960f66c9ba0c
exthelper: add prereposetup functions

Adds a decorator to exthelper for prereposetup functions. These are functions
that must run during reposetup but before all the normal reposetup functions are
run. For instance, these functions can modified the repo's ui.config to contain
new values.

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -113,6 +113,7 @@ class exthelper(object):
         self._uicallables = []
         self._extcallables = []
         self._repocallables = []
+        self._prerepocallables = []
         self._revsetsymbols = []
         self._templatekws = []
         self._commandwrappers = []
@@ -182,6 +183,8 @@ class exthelper(object):
         - Modify configuration variables
         - Changes to repo.__class__, repo.dirstate.__class__
         """
+        for c in self._prerepocallables:
+            c(ui, repo)
         for c in self._repocallables:
             c(ui, repo)
 
@@ -209,6 +212,18 @@ class exthelper(object):
         self._extcallables.append(call)
         return call
 
+    def prereposetup(self, call):
+        """Decorated function will be executed just before reposetup
+
+        example::
+
+            @eh.prereposetup
+            def setupzephir(ui, repo):
+                print 'this is pre-reposetup!'
+        """
+        self._prerepocallables.append(call)
+        return call
+
     def reposetup(self, call):
         """Decorated function will be executed during reposetup
 


More information about the Mercurial-devel mailing list