[PATCH 01 of 10] extensions: move uisetup and extsetup to standalone functions
Jun Wu
quark at fb.com
Thu Jun 30 16:58:56 UTC 2016
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1467279110 -3600
# Thu Jun 30 10:31:50 2016 +0100
# Node ID 8e7bc663d76a8ac51d9587e0e441e6688c5a57b1
# Parent 7dce56174916e09be39c690278942b4f7567b3f6
# Available At https://bitbucket.org/quark-zju/hg-draft
# hg pull https://bitbucket.org/quark-zju/hg-draft -r 8e7bc663d76a
extensions: move uisetup and extsetup to standalone functions
This is to make them wrap-able. chgserver wants to know if an extension
accesses config or environment variables during uisetup and extsetup and
include them in confighash accordingly.
diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -127,6 +127,21 @@ def load(ui, name, path):
fn(loaded=True)
return mod
+def _runuisetup(name, ui):
+ uisetup = getattr(_extensions[name], 'uisetup', None)
+ if uisetup:
+ uisetup(ui)
+
+def _runextsetup(name, ui):
+ extsetup = getattr(_extensions[name], 'extsetup', None)
+ if extsetup:
+ try:
+ extsetup(ui)
+ except TypeError:
+ if extsetup.func_code.co_argcount != 0:
+ raise
+ extsetup() # old extsetup with no ui argument
+
def loadall(ui):
result = ui.configitems("extensions")
newindex = len(_order)
@@ -148,19 +163,10 @@ def loadall(ui):
ui.traceback()
for name in _order[newindex:]:
- uisetup = getattr(_extensions[name], 'uisetup', None)
- if uisetup:
- uisetup(ui)
+ _runuisetup(name, ui)
for name in _order[newindex:]:
- extsetup = getattr(_extensions[name], 'extsetup', None)
- if extsetup:
- try:
- extsetup(ui)
- except TypeError:
- if extsetup.func_code.co_argcount != 0:
- raise
- extsetup() # old extsetup with no ui argument
+ _runextsetup(name, ui)
# Call aftercallbacks that were never met.
for shortname in _aftercallbacks:
More information about the Mercurial-devel
mailing list