Mercurial > hg-stable
annotate mercurial/exthelper.py @ 41047:fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
This should help make extensions that wrap a lot of stuff more comprehendible.
It was copied unmodified, except:
- fix up the imports
- rename final_xxxsetup() -> finalxxxsetup() to appease checkcode
- avoid a [] default arg to wrapcommand()
.. api::
Add `exthelper` class to simplify extension writing by allowing functions,
commands, and configitems to be registered via annotations. The previous
APIs are still available for use.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 22 Dec 2018 21:06:24 -0500 |
parents | |
children | c1476d095d57 |
rev | line source |
---|---|
41047
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
1 # Copyright 2012 Logilab SA <contact@logilab.fr> |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
2 # Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
3 # Octobus <contact@octobus.net> |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
4 # |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
7 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
8 ##################################################################### |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
9 ### Extension helper ### |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
10 ##################################################################### |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
11 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
12 from __future__ import absolute_import |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
13 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
14 from . import ( |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
15 commands, |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
16 configitems, |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
17 extensions, |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
18 fileset as filesetmod, |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
19 registrar, |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
20 revset as revsetmod, |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
21 templatekw as templatekwmod, |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
22 ) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
23 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
24 class exthelper(object): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
25 """Helper for modular extension setup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
26 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
27 A single helper should be instantiated for each extension. Helper |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
28 methods are then used as decorators for various purpose. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
29 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
30 All decorators return the original function and may be chained. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
31 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
32 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
33 def __init__(self): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
34 self._uipopulatecallables = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
35 self._uicallables = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
36 self._extcallables = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
37 self._repocallables = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
38 self._revsetsymbols = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
39 self._filesetsymbols = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
40 self._templatekws = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
41 self._commandwrappers = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
42 self._extcommandwrappers = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
43 self._functionwrappers = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
44 self._duckpunchers = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
45 self.cmdtable = {} |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
46 self.command = registrar.command(self.cmdtable) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
47 if '^init' in commands.table: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
48 olddoregister = self.command._doregister |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
49 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
50 def _newdoregister(self, name, *args, **kwargs): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
51 if kwargs.pop('helpbasic', False): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
52 name = '^' + name |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
53 return olddoregister(self, name, *args, **kwargs) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
54 self.command._doregister = _newdoregister |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
55 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
56 self.configtable = {} |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
57 self._configitem = registrar.configitem(self.configtable) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
58 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
59 def configitem(self, section, config, default=configitems.dynamicdefault): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
60 """Register a config item. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
61 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
62 self._configitem(section, config, default=default) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
63 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
64 def merge(self, other): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
65 self._uicallables.extend(other._uicallables) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
66 self._uipopulatecallables.extend(other._uipopulatecallables) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
67 self._extcallables.extend(other._extcallables) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
68 self._repocallables.extend(other._repocallables) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
69 self._revsetsymbols.extend(other._revsetsymbols) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
70 self._filesetsymbols.extend(other._filesetsymbols) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
71 self._templatekws.extend(other._templatekws) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
72 self._commandwrappers.extend(other._commandwrappers) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
73 self._extcommandwrappers.extend(other._extcommandwrappers) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
74 self._functionwrappers.extend(other._functionwrappers) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
75 self._duckpunchers.extend(other._duckpunchers) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
76 self.cmdtable.update(other.cmdtable) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
77 for section, items in other.configtable.iteritems(): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
78 if section in self.configtable: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
79 self.configtable[section].update(items) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
80 else: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
81 self.configtable[section] = items |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
82 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
83 def finaluisetup(self, ui): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
84 """Method to be used as the extension uisetup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
85 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
86 The following operations belong here: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
87 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
88 - Changes to ui.__class__ . The ui object that will be used to run the |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
89 command has not yet been created. Changes made here will affect ui |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
90 objects created after this, and in particular the ui that will be |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
91 passed to runcommand |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
92 - Command wraps (extensions.wrapcommand) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
93 - Changes that need to be visible to other extensions: because |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
94 initialization occurs in phases (all extensions run uisetup, then all |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
95 run extsetup), a change made here will be visible to other extensions |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
96 during extsetup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
97 - Monkeypatch or wrap function (extensions.wrapfunction) of dispatch |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
98 module members |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
99 - Setup of pre-* and post-* hooks |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
100 - pushkey setup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
101 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
102 for cont, funcname, func in self._duckpunchers: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
103 setattr(cont, funcname, func) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
104 for command, wrapper, opts in self._commandwrappers: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
105 entry = extensions.wrapcommand(commands.table, command, wrapper) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
106 if opts: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
107 for short, long, val, msg in opts: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
108 entry[1].append((short, long, val, msg)) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
109 for cont, funcname, wrapper in self._functionwrappers: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
110 extensions.wrapfunction(cont, funcname, wrapper) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
111 for c in self._uicallables: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
112 c(ui) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
113 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
114 def finaluipopulate(self, ui): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
115 """Method to be used as the extension uipopulate |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
116 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
117 This is called once per ui instance to: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
118 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
119 - Set up additional ui members |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
120 - Update configuration by ``ui.setconfig()`` |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
121 - Extend the class dynamically |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
122 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
123 for c in self._uipopulatecallables: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
124 c(ui) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
125 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
126 def finalextsetup(self, ui): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
127 """Method to be used as a the extension extsetup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
128 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
129 The following operations belong here: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
130 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
131 - Changes depending on the status of other extensions. (if |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
132 extensions.find('mq')) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
133 - Add a global option to all commands |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
134 - Register revset functions |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
135 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
136 knownexts = {} |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
137 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
138 revsetpredicate = registrar.revsetpredicate() |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
139 for name, symbol in self._revsetsymbols: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
140 revsetpredicate(name)(symbol) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
141 revsetmod.loadpredicate(ui, 'evolve', revsetpredicate) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
142 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
143 filesetpredicate = registrar.filesetpredicate() |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
144 for name, symbol in self._filesetsymbols: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
145 filesetpredicate(name)(symbol) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
146 # TODO: Figure out the calling extension name |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
147 filesetmod.loadpredicate(ui, 'exthelper', filesetpredicate) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
148 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
149 templatekeyword = registrar.templatekeyword() |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
150 for name, kw, requires in self._templatekws: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
151 if requires is not None: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
152 templatekeyword(name, requires=requires)(kw) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
153 else: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
154 templatekeyword(name)(kw) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
155 templatekwmod.loadkeyword(ui, 'evolve', templatekeyword) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
156 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
157 for ext, command, wrapper, opts in self._extcommandwrappers: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
158 if ext not in knownexts: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
159 try: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
160 e = extensions.find(ext) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
161 except KeyError: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
162 # Extension isn't enabled, so don't bother trying to wrap |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
163 # it. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
164 continue |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
165 knownexts[ext] = e.cmdtable |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
166 entry = extensions.wrapcommand(knownexts[ext], command, wrapper) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
167 if opts: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
168 for short, long, val, msg in opts: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
169 entry[1].append((short, long, val, msg)) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
170 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
171 for c in self._extcallables: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
172 c(ui) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
173 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
174 def finalreposetup(self, ui, repo): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
175 """Method to be used as the extension reposetup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
176 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
177 The following operations belong here: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
178 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
179 - All hooks but pre-* and post-* |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
180 - Modify configuration variables |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
181 - Changes to repo.__class__, repo.dirstate.__class__ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
182 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
183 for c in self._repocallables: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
184 c(ui, repo) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
185 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
186 def uisetup(self, call): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
187 """Decorated function will be executed during uisetup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
188 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
189 example:: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
190 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
191 @eh.uisetup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
192 def setupbabar(ui): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
193 print 'this is uisetup!' |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
194 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
195 self._uicallables.append(call) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
196 return call |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
197 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
198 def uipopulate(self, call): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
199 """Decorated function will be executed during uipopulate |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
200 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
201 example:: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
202 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
203 @eh.uipopulate |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
204 def setupfoo(ui): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
205 print 'this is uipopulate!' |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
206 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
207 self._uipopulatecallables.append(call) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
208 return call |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
209 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
210 def extsetup(self, call): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
211 """Decorated function will be executed during extsetup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
212 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
213 example:: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
214 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
215 @eh.extsetup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
216 def setupcelestine(ui): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
217 print 'this is extsetup!' |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
218 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
219 self._extcallables.append(call) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
220 return call |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
221 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
222 def reposetup(self, call): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
223 """Decorated function will be executed during reposetup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
224 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
225 example:: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
226 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
227 @eh.reposetup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
228 def setupzephir(ui, repo): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
229 print 'this is reposetup!' |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
230 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
231 self._repocallables.append(call) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
232 return call |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
233 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
234 def revset(self, symbolname): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
235 """Decorated function is a revset symbol |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
236 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
237 The name of the symbol must be given as the decorator argument. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
238 The symbol is added during `extsetup`. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
239 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
240 example:: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
241 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
242 @eh.revset('hidden') |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
243 def revsetbabar(repo, subset, x): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
244 args = revset.getargs(x, 0, 0, 'babar accept no argument') |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
245 return [r for r in subset if 'babar' in repo[r].description()] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
246 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
247 def dec(symbol): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
248 self._revsetsymbols.append((symbolname, symbol)) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
249 return symbol |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
250 return dec |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
251 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
252 def fileset(self, symbolname): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
253 """Decorated function is a fileset symbol |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
254 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
255 The name of the symbol must be given as the decorator argument. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
256 The symbol is added during `extsetup`. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
257 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
258 example:: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
259 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
260 @eh.fileset('lfs()') |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
261 def filesetbabar(mctx, x): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
262 return mctx.predicate(...) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
263 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
264 def dec(symbol): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
265 self._filesetsymbols.append((symbolname, symbol)) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
266 return symbol |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
267 return dec |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
268 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
269 def templatekw(self, keywordname, requires=None): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
270 """Decorated function is a template keyword |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
271 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
272 The name of the keyword must be given as the decorator argument. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
273 The symbol is added during `extsetup`. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
274 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
275 example:: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
276 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
277 @eh.templatekw('babar') |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
278 def kwbabar(ctx): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
279 return 'babar' |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
280 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
281 def dec(keyword): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
282 self._templatekws.append((keywordname, keyword, requires)) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
283 return keyword |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
284 return dec |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
285 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
286 def wrapcommand(self, command, extension=None, opts=None): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
287 """Decorated function is a command wrapper |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
288 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
289 The name of the command must be given as the decorator argument. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
290 The wrapping is installed during `uisetup`. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
291 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
292 If the second option `extension` argument is provided, the wrapping |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
293 will be applied in the extension commandtable. This argument must be a |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
294 string that will be searched using `extension.find` if not found and |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
295 Abort error is raised. If the wrapping applies to an extension, it is |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
296 installed during `extsetup`. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
297 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
298 example:: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
299 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
300 @eh.wrapcommand('summary') |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
301 def wrapsummary(orig, ui, repo, *args, **kwargs): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
302 ui.note('Barry!') |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
303 return orig(ui, repo, *args, **kwargs) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
304 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
305 The `opts` argument allows specifying additional arguments for the |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
306 command. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
307 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
308 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
309 if opts is None: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
310 opts = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
311 def dec(wrapper): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
312 if extension is None: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
313 self._commandwrappers.append((command, wrapper, opts)) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
314 else: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
315 self._extcommandwrappers.append((extension, command, wrapper, |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
316 opts)) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
317 return wrapper |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
318 return dec |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
319 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
320 def wrapfunction(self, container, funcname): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
321 """Decorated function is a function wrapper |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
322 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
323 This function takes two arguments, the container and the name of the |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
324 function to wrap. The wrapping is performed during `uisetup`. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
325 (there is no extension support) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
326 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
327 example:: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
328 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
329 @eh.function(discovery, 'checkheads') |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
330 def wrapfunction(orig, *args, **kwargs): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
331 ui.note('His head smashed in and his heart cut out') |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
332 return orig(*args, **kwargs) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
333 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
334 def dec(wrapper): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
335 self._functionwrappers.append((container, funcname, wrapper)) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
336 return wrapper |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
337 return dec |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
338 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
339 def addattr(self, container, funcname): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
340 """Decorated function is to be added to the container |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
341 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
342 This function takes two arguments, the container and the name of the |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
343 function to wrap. The wrapping is performed during `uisetup`. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
344 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
345 example:: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
346 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
347 @eh.function(context.changectx, 'babar') |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
348 def babar(ctx): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
349 return 'babar' in ctx.description |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
350 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
351 def dec(func): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
352 self._duckpunchers.append((container, funcname, func)) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
353 return func |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
354 return dec |