##// END OF EJS Templates
show: config option to register aliases for views...
Gregory Szorc -
r33132:99ce2f58 default
parent child Browse files
Show More
@@ -10,6 +10,19 b''
10 This extension provides the :hg:`show` command, which provides a central
10 This extension provides the :hg:`show` command, which provides a central
11 command for displaying commonly-accessed repository data and views of that
11 command for displaying commonly-accessed repository data and views of that
12 data.
12 data.
13
14 The following config options can influence operation.
15
16 ``commands``
17 ------------
18
19 ``show.aliasprefix``
20 List of strings that will register aliases for views. e.g. ``s`` will
21 effectively set config options ``alias.s<view> = show <view>`` for all
22 views. i.e. `hg swork` would execute `hg show work`.
23
24 Aliases that would conflict with existing registrations will not be
25 performed.
13 """
26 """
14
27
15 from __future__ import absolute_import
28 from __future__ import absolute_import
@@ -18,6 +31,7 b' from mercurial.i18n import _'
18 from mercurial.node import nullrev
31 from mercurial.node import nullrev
19 from mercurial import (
32 from mercurial import (
20 cmdutil,
33 cmdutil,
34 commands,
21 error,
35 error,
22 formatter,
36 formatter,
23 graphmod,
37 graphmod,
@@ -218,6 +232,25 b' def showwork(ui, repo, displayer):'
218 ui.setconfig('experimental', 'graphshorten', True)
232 ui.setconfig('experimental', 'graphshorten', True)
219 cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges)
233 cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges)
220
234
235 def extsetup(ui):
236 # Alias `hg <prefix><view>` to `hg show <view>`.
237 for prefix in ui.configlist('commands', 'show.aliasprefix'):
238 for view in showview._table:
239 name = '%s%s' % (prefix, view)
240
241 choice, allcommands = cmdutil.findpossible(name, commands.table,
242 strict=True)
243
244 # This alias is already a command name. Don't set it.
245 if name in choice:
246 continue
247
248 # Same for aliases.
249 if ui.config('alias', name):
250 continue
251
252 ui.setconfig('alias', name, 'show %s' % view, source='show')
253
221 # Adjust the docstring of the show command so it shows all registered views.
254 # Adjust the docstring of the show command so it shows all registered views.
222 # This is a bit hacky because it runs at the end of module load. When moved
255 # This is a bit hacky because it runs at the end of module load. When moved
223 # into core or when another extension wants to provide a view, we'll need
256 # into core or when another extension wants to provide a view, we'll need
@@ -127,4 +127,42 b' JSON works with no bookmarks'
127 [
127 [
128 ]
128 ]
129
129
130 commands.show.aliasprefix aliases values to `show <view>`
131
132 $ hg --config commands.show.aliasprefix=s sbookmarks
133 (no bookmarks set)
134
135 $ hg --config commands.show.aliasprefix=sh shwork
136 @ 7b570 commit for book2
137 o b757f commit for book1
138 o ba592 initial
139
140 $ hg --config commands.show.aliasprefix='s sh' swork
141 @ 7b570 commit for book2
142 o b757f commit for book1
143 o ba592 initial
144
145 $ hg --config commands.show.aliasprefix='s sh' shwork
146 @ 7b570 commit for book2
147 o b757f commit for book1
148 o ba592 initial
149
150 The aliases don't appear in `hg config`
151
152 $ hg --config commands.show.aliasprefix=s config alias
153 [1]
154
155 Doesn't overwrite existing alias
156
157 $ hg --config alias.swork='log -r .' --config commands.show.aliasprefix=s swork
158 changeset: 2:7b5709ab64cb
159 tag: tip
160 user: test
161 date: Thu Jan 01 00:00:00 1970 +0000
162 summary: commit for book2
163
164
165 $ hg --config alias.swork='log -r .' --config commands.show.aliasprefix=s config alias
166 alias.swork=log -r .
167
130 $ cd ..
168 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now