Mercurial > hg
annotate mercurial/exthelper.py @ 42073:80103ed2e8ee
crecord: new keys g & G to navigate to the top and bottom respectively
This patch introduces two new keys 'g' and 'G' that helps to navigate to the
top and bottom of the file/hunk/line respectively. This is inline with the shortcuts
used in man, less, more and such tools that makes it convenient to navigate
swiftly.
'g' or HOME navigates to the top most file in the ncurses window.
'G' or END navigates to the bottom most file/hunk/line depending on the whether
the fold is active or not.
If the bottom most file is folded, it navigates to that file and stops there.
If the bottom most file is unfolded, it navigates to the bottom most hunk in
that file and stops there. If the bottom most hunk is unfolded, it navigates to
the bottom most line in that hunk.
Differential Revision: https://phab.mercurial-scm.org/D6178
author | Arun Chandrasekaran <aruncxy@gmail.com> |
---|---|
date | Mon, 01 Apr 2019 22:11:54 -0700 |
parents | c9e1104e6272 |
children | c07dcf7a0247 |
rev | line source |
---|---|
41044
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, |
41060
7250cbaabde0
exthelper: support the option argument when registering a command
Matt Harbison <matt_harbison@yahoo.com>
parents:
41057
diff
changeset
|
16 error, |
41044
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 registrar, |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
19 ) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
20 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
21 class exthelper(object): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
22 """Helper for modular extension setup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
23 |
41071
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
24 A single helper should be instantiated for each module of an |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
25 extension, where a command or function needs to be wrapped, or a |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
26 command, extension hook, fileset, revset or template needs to be |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
27 registered. Helper methods are then used as decorators for |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
28 these various purposes. If an extension spans multiple modules, |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
29 all helper instances should be merged in the main module. |
41044
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
30 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
31 All decorators return the original function and may be chained. |
41071
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
32 |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
33 Aside from the helper functions with examples below, several |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
34 registrar method aliases are available for adding commands, |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
35 configitems, filesets, revsets, and templates. Simply decorate |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
36 the appropriate methods, and assign the corresponding exthelper |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
37 variable to a module level variable of the extension. The |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
38 extension loading mechanism will handle the rest. |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
39 |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
40 example:: |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
41 |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
42 # ext.py |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
43 eh = exthelper.exthelper() |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
44 |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
45 # As needed: |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
46 cmdtable = eh.cmdtable |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
47 configtable = eh.configtable |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
48 filesetpredicate = eh.filesetpredicate |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
49 revsetpredicate = eh.revsetpredicate |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
50 templatekeyword = eh.templatekeyword |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
51 |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
52 @eh.command('mynewcommand', |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
53 [('r', 'rev', [], _('operate on these revisions'))], |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
54 _('-r REV...'), |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
55 helpcategory=command.CATEGORY_XXX) |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
56 def newcommand(ui, repo, *revs, **opts): |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
57 # implementation goes here |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
58 |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
59 eh.configitem('experimental', 'foo', |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
60 default=False, |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
61 ) |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
62 |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
63 @eh.filesetpredicate('lfs()') |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
64 def filesetbabar(mctx, x): |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
65 return mctx.predicate(...) |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
66 |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
67 @eh.revsetpredicate('hidden') |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
68 def revsetbabar(repo, subset, x): |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
69 args = revset.getargs(x, 0, 0, 'babar accept no argument') |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
70 return [r for r in subset if 'babar' in repo[r].description()] |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
71 |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
72 @eh.templatekeyword('babar') |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
73 def kwbabar(ctx): |
c81bb97b0cac
exthelper: add some examples for using registrar aliases
Matt Harbison <matt_harbison@yahoo.com>
parents:
41070
diff
changeset
|
74 return 'babar' |
41044
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
75 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
76 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
77 def __init__(self): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
78 self._uipopulatecallables = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
79 self._uicallables = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
80 self._extcallables = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
81 self._repocallables = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
82 self._commandwrappers = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
83 self._extcommandwrappers = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
84 self._functionwrappers = [] |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
85 self.cmdtable = {} |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
86 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
|
87 self.configtable = {} |
41045
c1476d095d57
exthelper: simplify configitem registration
Matt Harbison <matt_harbison@yahoo.com>
parents:
41044
diff
changeset
|
88 self.configitem = registrar.configitem(self.configtable) |
41070
8f40e21ca842
exthelper: reintroduce the ability to register filesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
41069
diff
changeset
|
89 self.filesetpredicate = registrar.filesetpredicate() |
41066
0358cca1dccf
exthelper: reintroduce the ability to register revsets
Matt Harbison <matt_harbison@yahoo.com>
parents:
41060
diff
changeset
|
90 self.revsetpredicate = registrar.revsetpredicate() |
41069
70ca0e846d25
exthelper: reintroduce the ability to register templates
Matt Harbison <matt_harbison@yahoo.com>
parents:
41066
diff
changeset
|
91 self.templatekeyword = registrar.templatekeyword() |
41044
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
92 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
93 def merge(self, other): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
94 self._uicallables.extend(other._uicallables) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
95 self._uipopulatecallables.extend(other._uipopulatecallables) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
96 self._extcallables.extend(other._extcallables) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
97 self._repocallables.extend(other._repocallables) |
41082
4d40f6bb4cef
exthelper: switch to using the registrar merging method
Matt Harbison <matt_harbison@yahoo.com>
parents:
41071
diff
changeset
|
98 self.filesetpredicate._merge(other.filesetpredicate) |
4d40f6bb4cef
exthelper: switch to using the registrar merging method
Matt Harbison <matt_harbison@yahoo.com>
parents:
41071
diff
changeset
|
99 self.revsetpredicate._merge(other.revsetpredicate) |
4d40f6bb4cef
exthelper: switch to using the registrar merging method
Matt Harbison <matt_harbison@yahoo.com>
parents:
41071
diff
changeset
|
100 self.templatekeyword._merge(other.templatekeyword) |
41044
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
101 self._commandwrappers.extend(other._commandwrappers) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
102 self._extcommandwrappers.extend(other._extcommandwrappers) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
103 self._functionwrappers.extend(other._functionwrappers) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
104 self.cmdtable.update(other.cmdtable) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
105 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
|
106 if section in self.configtable: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
107 self.configtable[section].update(items) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
108 else: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
109 self.configtable[section] = items |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
110 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
111 def finaluisetup(self, ui): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
112 """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
|
113 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
114 The following operations belong here: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
115 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
116 - 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
|
117 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
|
118 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
|
119 passed to runcommand |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
120 - Command wraps (extensions.wrapcommand) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
121 - 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
|
122 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
|
123 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
|
124 during extsetup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
125 - 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
|
126 module members |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
127 - 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
|
128 - pushkey setup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
129 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
130 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
|
131 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
|
132 if opts: |
41060
7250cbaabde0
exthelper: support the option argument when registering a command
Matt Harbison <matt_harbison@yahoo.com>
parents:
41057
diff
changeset
|
133 for opt in opts: |
7250cbaabde0
exthelper: support the option argument when registering a command
Matt Harbison <matt_harbison@yahoo.com>
parents:
41057
diff
changeset
|
134 entry[1].append(opt) |
41044
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
135 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
|
136 extensions.wrapfunction(cont, funcname, wrapper) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
137 for c in self._uicallables: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
138 c(ui) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
139 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
140 def finaluipopulate(self, ui): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
141 """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
|
142 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
143 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
|
144 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
145 - Set up additional ui members |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
146 - Update configuration by ``ui.setconfig()`` |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
147 - Extend the class dynamically |
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 for c in self._uipopulatecallables: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
150 c(ui) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
151 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
152 def finalextsetup(self, ui): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
153 """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
|
154 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
155 The following operations belong here: |
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 - 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
|
158 extensions.find('mq')) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
159 - 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
|
160 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
161 knownexts = {} |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
162 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
163 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
|
164 if ext not in knownexts: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
165 try: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
166 e = extensions.find(ext) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
167 except KeyError: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
168 # 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
|
169 # it. |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
170 continue |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
171 knownexts[ext] = e.cmdtable |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
172 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
|
173 if opts: |
41060
7250cbaabde0
exthelper: support the option argument when registering a command
Matt Harbison <matt_harbison@yahoo.com>
parents:
41057
diff
changeset
|
174 for opt in opts: |
7250cbaabde0
exthelper: support the option argument when registering a command
Matt Harbison <matt_harbison@yahoo.com>
parents:
41057
diff
changeset
|
175 entry[1].append(opt) |
41044
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 for c in self._extcallables: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
178 c(ui) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
179 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
180 def finalreposetup(self, ui, repo): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
181 """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
|
182 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
183 The following operations belong here: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
184 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
185 - 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
|
186 - Modify configuration variables |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
187 - 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
|
188 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
189 for c in self._repocallables: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
190 c(ui, repo) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
191 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
192 def uisetup(self, call): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
193 """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
|
194 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
195 example:: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
196 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
197 @eh.uisetup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
198 def setupbabar(ui): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
199 print 'this is uisetup!' |
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 self._uicallables.append(call) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
202 return call |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
203 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
204 def uipopulate(self, call): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
205 """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
|
206 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
207 example:: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
208 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
209 @eh.uipopulate |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
210 def setupfoo(ui): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
211 print 'this is uipopulate!' |
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 self._uipopulatecallables.append(call) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
214 return call |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
215 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
216 def extsetup(self, call): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
217 """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
|
218 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
219 example:: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
220 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
221 @eh.extsetup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
222 def setupcelestine(ui): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
223 print 'this is extsetup!' |
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 self._extcallables.append(call) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
226 return call |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
227 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
228 def reposetup(self, call): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
229 """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
|
230 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
231 example:: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
232 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
233 @eh.reposetup |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
234 def setupzephir(ui, repo): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
235 print 'this is reposetup!' |
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 self._repocallables.append(call) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
238 return call |
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 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
|
241 """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
|
242 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
243 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
|
244 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
|
245 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
246 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
|
247 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
|
248 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
|
249 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
|
250 installed during `extsetup`. |
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 example:: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
253 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
254 @eh.wrapcommand('summary') |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
255 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
|
256 ui.note('Barry!') |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
257 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
|
258 |
41060
7250cbaabde0
exthelper: support the option argument when registering a command
Matt Harbison <matt_harbison@yahoo.com>
parents:
41057
diff
changeset
|
259 The `opts` argument allows specifying a list of tuples for additional |
7250cbaabde0
exthelper: support the option argument when registering a command
Matt Harbison <matt_harbison@yahoo.com>
parents:
41057
diff
changeset
|
260 arguments for the command. See ``mercurial.fancyopts.fancyopts()`` for |
7250cbaabde0
exthelper: support the option argument when registering a command
Matt Harbison <matt_harbison@yahoo.com>
parents:
41057
diff
changeset
|
261 the format of the tuple. |
41044
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
262 |
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 if opts is None: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
265 opts = [] |
41060
7250cbaabde0
exthelper: support the option argument when registering a command
Matt Harbison <matt_harbison@yahoo.com>
parents:
41057
diff
changeset
|
266 else: |
7250cbaabde0
exthelper: support the option argument when registering a command
Matt Harbison <matt_harbison@yahoo.com>
parents:
41057
diff
changeset
|
267 for opt in opts: |
7250cbaabde0
exthelper: support the option argument when registering a command
Matt Harbison <matt_harbison@yahoo.com>
parents:
41057
diff
changeset
|
268 if not isinstance(opt, tuple): |
7250cbaabde0
exthelper: support the option argument when registering a command
Matt Harbison <matt_harbison@yahoo.com>
parents:
41057
diff
changeset
|
269 raise error.ProgrammingError('opts must be list of tuples') |
7250cbaabde0
exthelper: support the option argument when registering a command
Matt Harbison <matt_harbison@yahoo.com>
parents:
41057
diff
changeset
|
270 if len(opt) not in (4, 5): |
7250cbaabde0
exthelper: support the option argument when registering a command
Matt Harbison <matt_harbison@yahoo.com>
parents:
41057
diff
changeset
|
271 msg = 'each opt tuple must contain 4 or 5 values' |
7250cbaabde0
exthelper: support the option argument when registering a command
Matt Harbison <matt_harbison@yahoo.com>
parents:
41057
diff
changeset
|
272 raise error.ProgrammingError(msg) |
7250cbaabde0
exthelper: support the option argument when registering a command
Matt Harbison <matt_harbison@yahoo.com>
parents:
41057
diff
changeset
|
273 |
41044
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
274 def dec(wrapper): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
275 if extension is None: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
276 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
|
277 else: |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
278 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
|
279 opts)) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
280 return wrapper |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
281 return dec |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
282 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
283 def wrapfunction(self, container, funcname): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
284 """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
|
285 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
286 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
|
287 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
|
288 (there is no extension support) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
289 |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
290 example:: |
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 @eh.function(discovery, 'checkheads') |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
293 def wrapfunction(orig, *args, **kwargs): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
294 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
|
295 return orig(*args, **kwargs) |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
296 """ |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
297 def dec(wrapper): |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
298 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
|
299 return wrapper |
fe606f2dcae9
extensions: import the exthelper class from evolve 980565468003 (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
300 return dec |