# HG changeset patch # User Matt Harbison # Date 1543765685 -3600 # Node ID 12e3f24f794beb22f2baa18d84db46cbd7da2376 # Parent ac4bb904f5d8773823ea588bd3c8a2c302bea030 extensions: add uipopulate() support to exthelper diff -r ac4bb904f5d8 -r 12e3f24f794b hgext3rd/evolve/exthelper.py --- a/hgext3rd/evolve/exthelper.py Sun Dec 02 16:45:08 2018 +0100 +++ b/hgext3rd/evolve/exthelper.py Sun Dec 02 16:48:05 2018 +0100 @@ -28,6 +28,7 @@ """ def __init__(self): + self._uipopulatecallables = [] self._uicallables = [] self._extcallables = [] self._repocallables = [] @@ -58,6 +59,7 @@ def merge(self, other): self._uicallables.extend(other._uicallables) + self._uipopulatecallables.extend(other._uipopulatecallables) self._extcallables.extend(other._extcallables) self._repocallables.extend(other._repocallables) self._revsetsymbols.extend(other._revsetsymbols) @@ -104,6 +106,18 @@ for c in self._uicallables: c(ui) + def final_uipopulate(self, ui): + """Method to be used as the extension uipopulate + + This is called once per ui instance to: + + - Set up additional ui members + - Update configuration by ``ui.setconfig()`` + - Extend the class dynamically + """ + for c in self._uipopulatecallables: + c(ui) + def final_extsetup(self, ui): """Method to be used as a the extension extsetup @@ -170,6 +184,18 @@ self._uicallables.append(call) return call + def uipopulate(self, call): + """Decorated function will be executed during uipopulate + + example:: + + @eh.uipopulate + def setupfoo(ui): + print 'this is uipopulate!' + """ + self._uipopulatecallables.append(call) + return call + def extsetup(self, call): """Decorated function will be executed during extsetup