Show More
@@ -43,7 +43,7 b' class showcmdfunc(registrar._funcregistr' | |||||
43 | # Used by _formatdoc(). |
|
43 | # Used by _formatdoc(). | |
44 | _docformat = '%s -- %s' |
|
44 | _docformat = '%s -- %s' | |
45 |
|
45 | |||
46 | def _extrasetup(self, name, func, fmtopic=None): |
|
46 | def _extrasetup(self, name, func, fmtopic=None, csettopic=None): | |
47 | """Called with decorator arguments to register a show view. |
|
47 | """Called with decorator arguments to register a show view. | |
48 |
|
48 | |||
49 | ``name`` is the sub-command name. |
|
49 | ``name`` is the sub-command name. | |
@@ -52,8 +52,16 b' class showcmdfunc(registrar._funcregistr' | |||||
52 |
|
52 | |||
53 | ``fmtopic`` is the topic in the style that will be rendered for |
|
53 | ``fmtopic`` is the topic in the style that will be rendered for | |
54 | this view. |
|
54 | this view. | |
|
55 | ||||
|
56 | ``csettopic`` is the topic in the style to be used for a changeset | |||
|
57 | printer. | |||
|
58 | ||||
|
59 | If ``fmtopic`` is specified, the view function will receive a | |||
|
60 | formatter instance. If ``csettopic`` is specified, the view | |||
|
61 | function will receive a changeset printer. | |||
55 | """ |
|
62 | """ | |
56 | func._fmtopic = fmtopic |
|
63 | func._fmtopic = fmtopic | |
|
64 | func._csettopic = csettopic | |||
57 |
|
65 | |||
58 | showview = showcmdfunc() |
|
66 | showview = showcmdfunc() | |
59 |
|
67 | |||
@@ -109,11 +117,21 b' def show(ui, repo, view=None, template=N' | |||||
109 | hint=_('run "hg show" to see available views')) |
|
117 | hint=_('run "hg show" to see available views')) | |
110 |
|
118 | |||
111 | template = template or 'show' |
|
119 | template = template or 'show' | |
112 | fmtopic = 'show%s' % views[view]._fmtopic |
|
|||
113 |
|
120 | |||
|
121 | fn = views[view] | |||
114 | ui.pager('show') |
|
122 | ui.pager('show') | |
115 | with ui.formatter(fmtopic, {'template': template}) as fm: |
|
123 | ||
116 | return views[view](ui, repo, fm) |
|
124 | if fn._fmtopic: | |
|
125 | fmtopic = 'show%s' % fn._fmtopic | |||
|
126 | with ui.formatter(fmtopic, {'template': template}) as fm: | |||
|
127 | return fn(ui, repo, fm) | |||
|
128 | elif fn._csettopic: | |||
|
129 | ref = 'show%s' % fn._csettopic | |||
|
130 | spec = formatter.lookuptemplate(ui, ref, template) | |||
|
131 | displayer = cmdutil.changeset_templater(ui, repo, spec, buffered=True) | |||
|
132 | return fn(ui, repo, displayer) | |||
|
133 | else: | |||
|
134 | return fn(ui, repo) | |||
117 |
|
135 | |||
118 | @showview('bookmarks', fmtopic='bookmarks') |
|
136 | @showview('bookmarks', fmtopic='bookmarks') | |
119 | def showbookmarks(ui, repo, fm): |
|
137 | def showbookmarks(ui, repo, fm): | |
@@ -189,15 +207,13 b' def underwayrevset(repo, subset, x):' | |||||
189 |
|
207 | |||
190 | return subset & relevant |
|
208 | return subset & relevant | |
191 |
|
209 | |||
192 |
@showview('work', |
|
210 | @showview('work', csettopic='work') | |
193 |
def showwork(ui, repo, |
|
211 | def showwork(ui, repo, displayer): | |
194 | """changesets that aren't finished""" |
|
212 | """changesets that aren't finished""" | |
195 | # TODO support date-based limiting when calling revset. |
|
213 | # TODO support date-based limiting when calling revset. | |
196 | revs = repo.revs('sort(_underway(), topo)') |
|
214 | revs = repo.revs('sort(_underway(), topo)') | |
197 |
|
215 | |||
198 | revdag = graphmod.dagwalker(repo, revs) |
|
216 | revdag = graphmod.dagwalker(repo, revs) | |
199 | tmpl = fm._t.load(fm._topic) |
|
|||
200 | displayer = cmdutil.makelogtemplater(ui, repo, tmpl, buffered=True) |
|
|||
201 |
|
217 | |||
202 | ui.setconfig('experimental', 'graphshorten', True) |
|
218 | ui.setconfig('experimental', 'graphshorten', True) | |
203 | cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges) |
|
219 | cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges) |
@@ -1,9 +1,12 b'' | |||||
1 | # TODO there are a few deficiencies in this file: |
|
1 | # TODO there are a few deficiencies in this file: | |
2 | # * Due to the way the file is loaded, references to other entities in the |
|
|||
3 | # template doesn't work. That requires us to inline. |
|
|||
4 | # * The "namespace" of the labels needs to be worked out. We currently |
|
2 | # * The "namespace" of the labels needs to be worked out. We currently | |
5 | # piggyback on existing values so color works. |
|
3 | # piggyback on existing values so color works. | |
6 | # * Obsolescence isn't considered for node labels. See _cset_labels in |
|
4 | # * Obsolescence isn't considered for node labels. See _cset_labels in | |
7 | # map-cmdline.default. |
|
5 | # map-cmdline.default. | |
8 | showbookmarks = '{if(active, "*", " ")} {pad(bookmark, longestbookmarklen + 4)}{shortest(node, 5)}\n' |
|
6 | showbookmarks = '{if(active, "*", " ")} {pad(bookmark, longestbookmarklen + 4)}{shortest(node, 5)}\n' | |
9 | showwork = '{label("log.changeset changeset.{phase}", shortest(node, 5))}{if(branches, " ({label("log.branch", branch)})")}{if(bookmarks, " ({label("log.bookmarks", bookmarks)})")} {label("log.description", desc|firstline)}' |
|
7 | ||
|
8 | showwork = '{cset_shortnode}{cset_names} {cset_shortdesc}' | |||
|
9 | ||||
|
10 | cset_shortnode = '{label("log.changeset changeset.{phase}", shortest(node, 5))}' | |||
|
11 | cset_names = '{if(branches, " ({label("log.branch", branch)})")}{if(bookmarks, " ({label("log.bookmarks", bookmarks)})")}' | |||
|
12 | cset_shortdesc = '{label("log.description", desc|firstline)}' |
General Comments 0
You need to be logged in to leave comments.
Login now