Show More
@@ -1,222 +1,222 b'' | |||||
1 | # show.py - Extension implementing `hg show` |
|
1 | # show.py - Extension implementing `hg show` | |
2 | # |
|
2 | # | |
3 | # Copyright 2017 Gregory Szorc <gregory.szorc@gmail.com> |
|
3 | # Copyright 2017 Gregory Szorc <gregory.szorc@gmail.com> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | """unified command to show various repository information (EXPERIMENTAL) |
|
8 | """unified command to show various repository information (EXPERIMENTAL) | |
9 |
|
9 | |||
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 | """ |
|
13 | """ | |
14 |
|
14 | |||
15 | from __future__ import absolute_import |
|
15 | from __future__ import absolute_import | |
16 |
|
16 | |||
17 | from mercurial.i18n import _ |
|
17 | from mercurial.i18n import _ | |
18 | from mercurial.node import nullrev |
|
18 | from mercurial.node import nullrev | |
19 | from mercurial import ( |
|
19 | from mercurial import ( | |
20 | cmdutil, |
|
20 | cmdutil, | |
21 | error, |
|
21 | error, | |
22 | formatter, |
|
22 | formatter, | |
23 | graphmod, |
|
23 | graphmod, | |
24 | pycompat, |
|
24 | pycompat, | |
25 | registrar, |
|
25 | registrar, | |
26 | revset, |
|
26 | revset, | |
27 | revsetlang, |
|
27 | revsetlang, | |
28 | ) |
|
28 | ) | |
29 |
|
29 | |||
30 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
|
30 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | |
31 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
|
31 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | |
32 | # be specifying the version(s) of Mercurial they are tested with, or |
|
32 | # be specifying the version(s) of Mercurial they are tested with, or | |
33 | # leave the attribute unspecified. |
|
33 | # leave the attribute unspecified. | |
34 | testedwith = 'ships-with-hg-core' |
|
34 | testedwith = 'ships-with-hg-core' | |
35 |
|
35 | |||
36 | cmdtable = {} |
|
36 | cmdtable = {} | |
37 | command = cmdutil.command(cmdtable) |
|
37 | command = cmdutil.command(cmdtable) | |
38 | revsetpredicate = registrar.revsetpredicate() |
|
38 | revsetpredicate = registrar.revsetpredicate() | |
39 |
|
39 | |||
40 | class showcmdfunc(registrar._funcregistrarbase): |
|
40 | class showcmdfunc(registrar._funcregistrarbase): | |
41 | """Register a function to be invoked for an `hg show <thing>`.""" |
|
41 | """Register a function to be invoked for an `hg show <thing>`.""" | |
42 |
|
42 | |||
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): | |
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. | |
50 |
|
50 | |||
51 | ``func`` is the function being decorated. |
|
51 | ``func`` is the function being decorated. | |
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 | """ |
|
55 | """ | |
56 | func._fmtopic = fmtopic |
|
56 | func._fmtopic = fmtopic | |
57 |
|
57 | |||
58 | showview = showcmdfunc() |
|
58 | showview = showcmdfunc() | |
59 |
|
59 | |||
60 | @command('show', [ |
|
60 | @command('show', [ | |
61 | # TODO: Switch this template flag to use commands.formatteropts if |
|
61 | # TODO: Switch this template flag to use commands.formatteropts if | |
62 | # 'hg show' becomes stable before --template/-T is stable. For now, |
|
62 | # 'hg show' becomes stable before --template/-T is stable. For now, | |
63 | # we are putting it here without the '(EXPERIMENTAL)' flag because it |
|
63 | # we are putting it here without the '(EXPERIMENTAL)' flag because it | |
64 | # is an important part of the 'hg show' user experience and the entire |
|
64 | # is an important part of the 'hg show' user experience and the entire | |
65 | # 'hg show' experience is experimental. |
|
65 | # 'hg show' experience is experimental. | |
66 | ('T', 'template', '', ('display with template'), _('TEMPLATE')), |
|
66 | ('T', 'template', '', ('display with template'), _('TEMPLATE')), | |
67 | ], _('VIEW')) |
|
67 | ], _('VIEW')) | |
68 | def show(ui, repo, view=None, template=None): |
|
68 | def show(ui, repo, view=None, template=None): | |
69 | """show various repository information |
|
69 | """show various repository information | |
70 |
|
70 | |||
71 | A requested view of repository data is displayed. |
|
71 | A requested view of repository data is displayed. | |
72 |
|
72 | |||
73 | If no view is requested, the list of available views is shown and the |
|
73 | If no view is requested, the list of available views is shown and the | |
74 | command aborts. |
|
74 | command aborts. | |
75 |
|
75 | |||
76 | .. note:: |
|
76 | .. note:: | |
77 |
|
77 | |||
78 | There are no backwards compatibility guarantees for the output of this |
|
78 | There are no backwards compatibility guarantees for the output of this | |
79 | command. Output may change in any future Mercurial release. |
|
79 | command. Output may change in any future Mercurial release. | |
80 |
|
80 | |||
81 | Consumers wanting stable command output should specify a template via |
|
81 | Consumers wanting stable command output should specify a template via | |
82 | ``-T/--template``. |
|
82 | ``-T/--template``. | |
83 |
|
83 | |||
84 | List of available views: |
|
84 | List of available views: | |
85 | """ |
|
85 | """ | |
86 | if ui.plain() and not template: |
|
86 | if ui.plain() and not template: | |
87 | hint = _('invoke with -T/--template to control output format') |
|
87 | hint = _('invoke with -T/--template to control output format') | |
88 | raise error.Abort(_('must specify a template in plain mode'), hint=hint) |
|
88 | raise error.Abort(_('must specify a template in plain mode'), hint=hint) | |
89 |
|
89 | |||
90 | views = showview._table |
|
90 | views = showview._table | |
91 |
|
91 | |||
92 | if not view: |
|
92 | if not view: | |
93 | ui.pager('show') |
|
93 | ui.pager('show') | |
94 | # TODO consider using formatter here so available views can be |
|
94 | # TODO consider using formatter here so available views can be | |
95 | # rendered to custom format. |
|
95 | # rendered to custom format. | |
96 | ui.write(_('available views:\n')) |
|
96 | ui.write(_('available views:\n')) | |
97 | ui.write('\n') |
|
97 | ui.write('\n') | |
98 |
|
98 | |||
99 | for name, func in sorted(views.items()): |
|
99 | for name, func in sorted(views.items()): | |
100 | ui.write(('%s\n') % func.__doc__) |
|
100 | ui.write(('%s\n') % func.__doc__) | |
101 |
|
101 | |||
102 | ui.write('\n') |
|
102 | ui.write('\n') | |
103 | raise error.Abort(_('no view requested'), |
|
103 | raise error.Abort(_('no view requested'), | |
104 | hint=_('use "hg show VIEW" to choose a view')) |
|
104 | hint=_('use "hg show VIEW" to choose a view')) | |
105 |
|
105 | |||
106 | # TODO use same logic as dispatch to perform prefix matching. |
|
106 | # TODO use same logic as dispatch to perform prefix matching. | |
107 | if view not in views: |
|
107 | if view not in views: | |
108 | raise error.Abort(_('unknown view: %s') % view, |
|
108 | raise error.Abort(_('unknown view: %s') % view, | |
109 | hint=_('run "hg show" to see available views')) |
|
109 | hint=_('run "hg show" to see available views')) | |
110 |
|
110 | |||
111 | template = template or 'show' |
|
111 | template = template or 'show' | |
112 | fmtopic = 'show%s' % views[view]._fmtopic |
|
112 | fmtopic = 'show%s' % views[view]._fmtopic | |
113 |
|
113 | |||
114 | ui.pager('show') |
|
114 | ui.pager('show') | |
115 | with ui.formatter(fmtopic, {'template': template}) as fm: |
|
115 | with ui.formatter(fmtopic, {'template': template}) as fm: | |
116 | return views[view](ui, repo, fm) |
|
116 | return views[view](ui, repo, fm) | |
117 |
|
117 | |||
118 | @showview('bookmarks', fmtopic='bookmarks') |
|
118 | @showview('bookmarks', fmtopic='bookmarks') | |
119 | def showbookmarks(ui, repo, fm): |
|
119 | def showbookmarks(ui, repo, fm): | |
120 | """bookmarks and their associated changeset""" |
|
120 | """bookmarks and their associated changeset""" | |
121 | marks = repo._bookmarks |
|
121 | marks = repo._bookmarks | |
122 | if not len(marks): |
|
122 | if not len(marks): | |
123 | # This is a bit hacky. Ideally, templates would have a way to |
|
123 | # This is a bit hacky. Ideally, templates would have a way to | |
124 | # specify an empty output, but we shouldn't corrupt JSON while |
|
124 | # specify an empty output, but we shouldn't corrupt JSON while | |
125 | # waiting for this functionality. |
|
125 | # waiting for this functionality. | |
126 | if not isinstance(fm, formatter.jsonformatter): |
|
126 | if not isinstance(fm, formatter.jsonformatter): | |
127 | ui.write(_('(no bookmarks set)\n')) |
|
127 | ui.write(_('(no bookmarks set)\n')) | |
128 | return |
|
128 | return | |
129 |
|
129 | |||
130 | active = repo._activebookmark |
|
130 | active = repo._activebookmark | |
131 | longestname = max(len(b) for b in marks) |
|
131 | longestname = max(len(b) for b in marks) | |
132 | # TODO consider exposing longest shortest(node). |
|
132 | # TODO consider exposing longest shortest(node). | |
133 |
|
133 | |||
134 | for bm, node in sorted(marks.items()): |
|
134 | for bm, node in sorted(marks.items()): | |
135 | fm.startitem() |
|
135 | fm.startitem() | |
136 | fm.context(ctx=repo[node]) |
|
136 | fm.context(ctx=repo[node]) | |
137 | fm.write('bookmark', '%s', bm) |
|
137 | fm.write('bookmark', '%s', bm) | |
138 | fm.write('node', fm.hexfunc(node), fm.hexfunc(node)) |
|
138 | fm.write('node', fm.hexfunc(node), fm.hexfunc(node)) | |
139 | fm.data(active=bm == active, |
|
139 | fm.data(active=bm == active, | |
140 | longestbookmarklen=longestname) |
|
140 | longestbookmarklen=longestname) | |
141 |
|
141 | |||
142 | @revsetpredicate('_underway([commitage[, headage]])') |
|
142 | @revsetpredicate('_underway([commitage[, headage]])') | |
143 | def underwayrevset(repo, subset, x): |
|
143 | def underwayrevset(repo, subset, x): | |
144 | args = revset.getargsdict(x, 'underway', 'commitage headage') |
|
144 | args = revset.getargsdict(x, 'underway', 'commitage headage') | |
145 | if 'commitage' not in args: |
|
145 | if 'commitage' not in args: | |
146 | args['commitage'] = None |
|
146 | args['commitage'] = None | |
147 | if 'headage' not in args: |
|
147 | if 'headage' not in args: | |
148 | args['headage'] = None |
|
148 | args['headage'] = None | |
149 |
|
149 | |||
150 | # We assume callers of this revset add a topographical sort on the |
|
150 | # We assume callers of this revset add a topographical sort on the | |
151 | # result. This means there is no benefit to making the revset lazy |
|
151 | # result. This means there is no benefit to making the revset lazy | |
152 | # since the topographical sort needs to consume all revs. |
|
152 | # since the topographical sort needs to consume all revs. | |
153 | # |
|
153 | # | |
154 | # With this in mind, we build up the set manually instead of constructing |
|
154 | # With this in mind, we build up the set manually instead of constructing | |
155 | # a complex revset. This enables faster execution. |
|
155 | # a complex revset. This enables faster execution. | |
156 |
|
156 | |||
157 | # Mutable changesets (non-public) are the most important changesets |
|
157 | # Mutable changesets (non-public) are the most important changesets | |
158 | # to return. ``not public()`` will also pull in obsolete changesets if |
|
158 | # to return. ``not public()`` will also pull in obsolete changesets if | |
159 | # there is a non-obsolete changeset with obsolete ancestors. This is |
|
159 | # there is a non-obsolete changeset with obsolete ancestors. This is | |
160 | # why we exclude obsolete changesets from this query. |
|
160 | # why we exclude obsolete changesets from this query. | |
161 | rs = 'not public() and not obsolete()' |
|
161 | rs = 'not public() and not obsolete()' | |
162 | rsargs = [] |
|
162 | rsargs = [] | |
163 | if args['commitage']: |
|
163 | if args['commitage']: | |
164 | rs += ' and date(%s)' |
|
164 | rs += ' and date(%s)' | |
165 | rsargs.append(revsetlang.getstring(args['commitage'], |
|
165 | rsargs.append(revsetlang.getstring(args['commitage'], | |
166 | _('commitage requires a string'))) |
|
166 | _('commitage requires a string'))) | |
167 |
|
167 | |||
168 | mutable = repo.revs(rs, *rsargs) |
|
168 | mutable = repo.revs(rs, *rsargs) | |
169 | relevant = revset.baseset(mutable) |
|
169 | relevant = revset.baseset(mutable) | |
170 |
|
170 | |||
171 | # Add parents of mutable changesets to provide context. |
|
171 | # Add parents of mutable changesets to provide context. | |
172 | relevant += repo.revs('parents(%ld)', mutable) |
|
172 | relevant += repo.revs('parents(%ld)', mutable) | |
173 |
|
173 | |||
174 | # We also pull in (public) heads if they a) aren't closing a branch |
|
174 | # We also pull in (public) heads if they a) aren't closing a branch | |
175 | # b) are recent. |
|
175 | # b) are recent. | |
176 | rs = 'head() and not closed()' |
|
176 | rs = 'head() and not closed()' | |
177 | rsargs = [] |
|
177 | rsargs = [] | |
178 | if args['headage']: |
|
178 | if args['headage']: | |
179 | rs += ' and date(%s)' |
|
179 | rs += ' and date(%s)' | |
180 | rsargs.append(revsetlang.getstring(args['headage'], |
|
180 | rsargs.append(revsetlang.getstring(args['headage'], | |
181 | _('headage requires a string'))) |
|
181 | _('headage requires a string'))) | |
182 |
|
182 | |||
183 | relevant += repo.revs(rs, *rsargs) |
|
183 | relevant += repo.revs(rs, *rsargs) | |
184 |
|
184 | |||
185 | # Add working directory parent. |
|
185 | # Add working directory parent. | |
186 | wdirrev = repo['.'].rev() |
|
186 | wdirrev = repo['.'].rev() | |
187 | if wdirrev != nullrev: |
|
187 | if wdirrev != nullrev: | |
188 | relevant += revset.baseset(set([wdirrev])) |
|
188 | relevant += revset.baseset(set([wdirrev])) | |
189 |
|
189 | |||
190 | return subset & relevant |
|
190 | return subset & relevant | |
191 |
|
191 | |||
192 |
@showview(' |
|
192 | @showview('work', fmtopic='work') | |
193 |
def show |
|
193 | def showwork(ui, repo, fm): | |
194 | """changesets that aren't finished""" |
|
194 | """changesets that aren't finished""" | |
195 | # TODO support date-based limiting when calling revset. |
|
195 | # TODO support date-based limiting when calling revset. | |
196 | revs = repo.revs('sort(_underway(), topo)') |
|
196 | revs = repo.revs('sort(_underway(), topo)') | |
197 |
|
197 | |||
198 | revdag = graphmod.dagwalker(repo, revs) |
|
198 | revdag = graphmod.dagwalker(repo, revs) | |
199 | displayer = cmdutil.changeset_templater(ui, repo, None, None, |
|
199 | displayer = cmdutil.changeset_templater(ui, repo, None, None, | |
200 | tmpl=fm._t.load(fm._topic), |
|
200 | tmpl=fm._t.load(fm._topic), | |
201 | mapfile=None, buffered=True) |
|
201 | mapfile=None, buffered=True) | |
202 |
|
202 | |||
203 | ui.setconfig('experimental', 'graphshorten', True) |
|
203 | ui.setconfig('experimental', 'graphshorten', True) | |
204 | cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges) |
|
204 | cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges) | |
205 |
|
205 | |||
206 | # Adjust the docstring of the show command so it shows all registered views. |
|
206 | # Adjust the docstring of the show command so it shows all registered views. | |
207 | # This is a bit hacky because it runs at the end of module load. When moved |
|
207 | # This is a bit hacky because it runs at the end of module load. When moved | |
208 | # into core or when another extension wants to provide a view, we'll need |
|
208 | # into core or when another extension wants to provide a view, we'll need | |
209 | # to do this more robustly. |
|
209 | # to do this more robustly. | |
210 | # TODO make this more robust. |
|
210 | # TODO make this more robust. | |
211 | def _updatedocstring(): |
|
211 | def _updatedocstring(): | |
212 | longest = max(map(len, showview._table.keys())) |
|
212 | longest = max(map(len, showview._table.keys())) | |
213 | entries = [] |
|
213 | entries = [] | |
214 | for key in sorted(showview._table.keys()): |
|
214 | for key in sorted(showview._table.keys()): | |
215 | entries.append(pycompat.sysstr(' %s %s' % ( |
|
215 | entries.append(pycompat.sysstr(' %s %s' % ( | |
216 | key.ljust(longest), showview._table[key]._origdoc))) |
|
216 | key.ljust(longest), showview._table[key]._origdoc))) | |
217 |
|
217 | |||
218 | cmdtable['show'][0].__doc__ = pycompat.sysstr('%s\n\n%s\n ') % ( |
|
218 | cmdtable['show'][0].__doc__ = pycompat.sysstr('%s\n\n%s\n ') % ( | |
219 | cmdtable['show'][0].__doc__.rstrip(), |
|
219 | cmdtable['show'][0].__doc__.rstrip(), | |
220 | pycompat.sysstr('\n\n').join(entries)) |
|
220 | pycompat.sysstr('\n\n').join(entries)) | |
221 |
|
221 | |||
222 | _updatedocstring() |
|
222 | _updatedocstring() |
@@ -1,3 +1,3 b'' | |||||
1 | # TODO add label() once we figure out which namespace the labels belong on. |
|
1 | # TODO add label() once we figure out which namespace the labels belong on. | |
2 | showbookmarks = '{if(active, "*", " ")} {pad(bookmark, longestbookmarklen + 4)}{shortest(node, 5)}\n' |
|
2 | showbookmarks = '{if(active, "*", " ")} {pad(bookmark, longestbookmarklen + 4)}{shortest(node, 5)}\n' | |
3 |
show |
|
3 | showwork = '{shortest(node, 5)}{if(branches, " ({branch})")}{if(bookmarks, " ({bookmarks})")} {desc|firstline}' |
@@ -1,168 +1,168 b'' | |||||
1 | $ cat >> $HGRCPATH << EOF |
|
1 | $ cat >> $HGRCPATH << EOF | |
2 | > [extensions] |
|
2 | > [extensions] | |
3 | > show = |
|
3 | > show = | |
4 | > EOF |
|
4 | > EOF | |
5 |
|
5 | |||
6 | $ hg init repo0 |
|
6 | $ hg init repo0 | |
7 | $ cd repo0 |
|
7 | $ cd repo0 | |
8 |
|
8 | |||
9 | Command works on an empty repo |
|
9 | Command works on an empty repo | |
10 |
|
10 | |||
11 |
$ hg show |
|
11 | $ hg show work | |
12 |
|
12 | |||
13 | Single draft changeset shown |
|
13 | Single draft changeset shown | |
14 |
|
14 | |||
15 | $ echo 0 > foo |
|
15 | $ echo 0 > foo | |
16 | $ hg -q commit -A -m 'commit 0' |
|
16 | $ hg -q commit -A -m 'commit 0' | |
17 |
|
17 | |||
18 |
$ hg show |
|
18 | $ hg show work | |
19 | @ 9f171 commit 0 |
|
19 | @ 9f171 commit 0 | |
20 |
|
20 | |||
21 | Even when it isn't the wdir |
|
21 | Even when it isn't the wdir | |
22 |
|
22 | |||
23 | $ hg -q up null |
|
23 | $ hg -q up null | |
24 |
|
24 | |||
25 |
$ hg show |
|
25 | $ hg show work | |
26 | o 9f171 commit 0 |
|
26 | o 9f171 commit 0 | |
27 |
|
27 | |||
28 | Single changeset is still there when public because it is a head |
|
28 | Single changeset is still there when public because it is a head | |
29 |
|
29 | |||
30 | $ hg phase --public -r 0 |
|
30 | $ hg phase --public -r 0 | |
31 |
$ hg show |
|
31 | $ hg show work | |
32 | o 9f171 commit 0 |
|
32 | o 9f171 commit 0 | |
33 |
|
33 | |||
34 | A draft child will show both it and public parent |
|
34 | A draft child will show both it and public parent | |
35 |
|
35 | |||
36 | $ hg -q up 0 |
|
36 | $ hg -q up 0 | |
37 | $ echo 1 > foo |
|
37 | $ echo 1 > foo | |
38 | $ hg commit -m 'commit 1' |
|
38 | $ hg commit -m 'commit 1' | |
39 |
|
39 | |||
40 |
$ hg show |
|
40 | $ hg show work | |
41 | @ 181cc commit 1 |
|
41 | @ 181cc commit 1 | |
42 | o 9f171 commit 0 |
|
42 | o 9f171 commit 0 | |
43 |
|
43 | |||
44 | Multiple draft children will be shown |
|
44 | Multiple draft children will be shown | |
45 |
|
45 | |||
46 | $ echo 2 > foo |
|
46 | $ echo 2 > foo | |
47 | $ hg commit -m 'commit 2' |
|
47 | $ hg commit -m 'commit 2' | |
48 |
|
48 | |||
49 |
$ hg show |
|
49 | $ hg show work | |
50 | @ 128c8 commit 2 |
|
50 | @ 128c8 commit 2 | |
51 | o 181cc commit 1 |
|
51 | o 181cc commit 1 | |
52 | o 9f171 commit 0 |
|
52 | o 9f171 commit 0 | |
53 |
|
53 | |||
54 | Bumping first draft changeset to public will hide its parent |
|
54 | Bumping first draft changeset to public will hide its parent | |
55 |
|
55 | |||
56 | $ hg phase --public -r 1 |
|
56 | $ hg phase --public -r 1 | |
57 |
$ hg show |
|
57 | $ hg show work | |
58 | @ 128c8 commit 2 |
|
58 | @ 128c8 commit 2 | |
59 | o 181cc commit 1 |
|
59 | o 181cc commit 1 | |
60 | | |
|
60 | | | |
61 | ~ |
|
61 | ~ | |
62 |
|
62 | |||
63 | Multiple DAG heads will be shown |
|
63 | Multiple DAG heads will be shown | |
64 |
|
64 | |||
65 | $ hg -q up -r 1 |
|
65 | $ hg -q up -r 1 | |
66 | $ echo 3 > foo |
|
66 | $ echo 3 > foo | |
67 | $ hg commit -m 'commit 3' |
|
67 | $ hg commit -m 'commit 3' | |
68 | created new head |
|
68 | created new head | |
69 |
|
69 | |||
70 |
$ hg show |
|
70 | $ hg show work | |
71 | @ f0abc commit 3 |
|
71 | @ f0abc commit 3 | |
72 | | o 128c8 commit 2 |
|
72 | | o 128c8 commit 2 | |
73 | |/ |
|
73 | |/ | |
74 | o 181cc commit 1 |
|
74 | o 181cc commit 1 | |
75 | | |
|
75 | | | |
76 | ~ |
|
76 | ~ | |
77 |
|
77 | |||
78 | Even when wdir is something else |
|
78 | Even when wdir is something else | |
79 |
|
79 | |||
80 | $ hg -q up null |
|
80 | $ hg -q up null | |
81 |
|
81 | |||
82 |
$ hg show |
|
82 | $ hg show work | |
83 | o f0abc commit 3 |
|
83 | o f0abc commit 3 | |
84 | | o 128c8 commit 2 |
|
84 | | o 128c8 commit 2 | |
85 | |/ |
|
85 | |/ | |
86 | o 181cc commit 1 |
|
86 | o 181cc commit 1 | |
87 | | |
|
87 | | | |
88 | ~ |
|
88 | ~ | |
89 |
|
89 | |||
90 | Draft child shows public head (multiple heads) |
|
90 | Draft child shows public head (multiple heads) | |
91 |
|
91 | |||
92 | $ hg -q up 0 |
|
92 | $ hg -q up 0 | |
93 | $ echo 4 > foo |
|
93 | $ echo 4 > foo | |
94 | $ hg commit -m 'commit 4' |
|
94 | $ hg commit -m 'commit 4' | |
95 | created new head |
|
95 | created new head | |
96 |
|
96 | |||
97 |
$ hg show |
|
97 | $ hg show work | |
98 | @ 668ca commit 4 |
|
98 | @ 668ca commit 4 | |
99 | | o f0abc commit 3 |
|
99 | | o f0abc commit 3 | |
100 | | | o 128c8 commit 2 |
|
100 | | | o 128c8 commit 2 | |
101 | | |/ |
|
101 | | |/ | |
102 | | o 181cc commit 1 |
|
102 | | o 181cc commit 1 | |
103 | |/ |
|
103 | |/ | |
104 | o 9f171 commit 0 |
|
104 | o 9f171 commit 0 | |
105 |
|
105 | |||
106 | $ cd .. |
|
106 | $ cd .. | |
107 |
|
107 | |||
108 | Branch name appears in output |
|
108 | Branch name appears in output | |
109 |
|
109 | |||
110 | $ hg init branches |
|
110 | $ hg init branches | |
111 | $ cd branches |
|
111 | $ cd branches | |
112 | $ echo 0 > foo |
|
112 | $ echo 0 > foo | |
113 | $ hg -q commit -A -m 'commit 0' |
|
113 | $ hg -q commit -A -m 'commit 0' | |
114 | $ echo 1 > foo |
|
114 | $ echo 1 > foo | |
115 | $ hg commit -m 'commit 1' |
|
115 | $ hg commit -m 'commit 1' | |
116 | $ echo 2 > foo |
|
116 | $ echo 2 > foo | |
117 | $ hg commit -m 'commit 2' |
|
117 | $ hg commit -m 'commit 2' | |
118 | $ hg phase --public -r . |
|
118 | $ hg phase --public -r . | |
119 | $ hg -q up -r 1 |
|
119 | $ hg -q up -r 1 | |
120 | $ hg branch mybranch |
|
120 | $ hg branch mybranch | |
121 | marked working directory as branch mybranch |
|
121 | marked working directory as branch mybranch | |
122 | (branches are permanent and global, did you want a bookmark?) |
|
122 | (branches are permanent and global, did you want a bookmark?) | |
123 | $ echo 3 > foo |
|
123 | $ echo 3 > foo | |
124 | $ hg commit -m 'commit 3' |
|
124 | $ hg commit -m 'commit 3' | |
125 | $ echo 4 > foo |
|
125 | $ echo 4 > foo | |
126 | $ hg commit -m 'commit 4' |
|
126 | $ hg commit -m 'commit 4' | |
127 |
|
127 | |||
128 |
$ hg show |
|
128 | $ hg show work | |
129 | @ f8dd3 (mybranch) commit 4 |
|
129 | @ f8dd3 (mybranch) commit 4 | |
130 | o 90cfc (mybranch) commit 3 |
|
130 | o 90cfc (mybranch) commit 3 | |
131 | | o 128c8 commit 2 |
|
131 | | o 128c8 commit 2 | |
132 | |/ |
|
132 | |/ | |
133 | o 181cc commit 1 |
|
133 | o 181cc commit 1 | |
134 | | |
|
134 | | | |
135 | ~ |
|
135 | ~ | |
136 |
|
136 | |||
137 | $ cd .. |
|
137 | $ cd .. | |
138 |
|
138 | |||
139 | Bookmark name appears in output |
|
139 | Bookmark name appears in output | |
140 |
|
140 | |||
141 | $ hg init bookmarks |
|
141 | $ hg init bookmarks | |
142 | $ cd bookmarks |
|
142 | $ cd bookmarks | |
143 | $ echo 0 > foo |
|
143 | $ echo 0 > foo | |
144 | $ hg -q commit -A -m 'commit 0' |
|
144 | $ hg -q commit -A -m 'commit 0' | |
145 | $ echo 1 > foo |
|
145 | $ echo 1 > foo | |
146 | $ hg commit -m 'commit 1' |
|
146 | $ hg commit -m 'commit 1' | |
147 | $ echo 2 > foo |
|
147 | $ echo 2 > foo | |
148 | $ hg commit -m 'commit 2' |
|
148 | $ hg commit -m 'commit 2' | |
149 | $ hg phase --public -r . |
|
149 | $ hg phase --public -r . | |
150 | $ hg bookmark @ |
|
150 | $ hg bookmark @ | |
151 | $ hg -q up -r 1 |
|
151 | $ hg -q up -r 1 | |
152 | $ echo 3 > foo |
|
152 | $ echo 3 > foo | |
153 | $ hg commit -m 'commit 3' |
|
153 | $ hg commit -m 'commit 3' | |
154 | created new head |
|
154 | created new head | |
155 | $ echo 4 > foo |
|
155 | $ echo 4 > foo | |
156 | $ hg commit -m 'commit 4' |
|
156 | $ hg commit -m 'commit 4' | |
157 | $ hg bookmark mybook |
|
157 | $ hg bookmark mybook | |
158 |
|
158 | |||
159 |
$ hg show |
|
159 | $ hg show work | |
160 | @ cac82 (mybook) commit 4 |
|
160 | @ cac82 (mybook) commit 4 | |
161 | o f0abc commit 3 |
|
161 | o f0abc commit 3 | |
162 | | o 128c8 (@) commit 2 |
|
162 | | o 128c8 (@) commit 2 | |
163 | |/ |
|
163 | |/ | |
164 | o 181cc commit 1 |
|
164 | o 181cc commit 1 | |
165 | | |
|
165 | | | |
166 | ~ |
|
166 | ~ | |
167 |
|
167 | |||
168 | $ cd .. |
|
168 | $ cd .. |
@@ -1,130 +1,130 b'' | |||||
1 | $ cat >> $HGRCPATH << EOF |
|
1 | $ cat >> $HGRCPATH << EOF | |
2 | > [extensions] |
|
2 | > [extensions] | |
3 | > show = |
|
3 | > show = | |
4 | > EOF |
|
4 | > EOF | |
5 |
|
5 | |||
6 | No arguments shows available views |
|
6 | No arguments shows available views | |
7 |
|
7 | |||
8 | $ hg init empty |
|
8 | $ hg init empty | |
9 | $ cd empty |
|
9 | $ cd empty | |
10 | $ hg show |
|
10 | $ hg show | |
11 | available views: |
|
11 | available views: | |
12 |
|
12 | |||
13 | bookmarks -- bookmarks and their associated changeset |
|
13 | bookmarks -- bookmarks and their associated changeset | |
14 |
|
|
14 | work -- changesets that aren't finished | |
15 |
|
15 | |||
16 | abort: no view requested |
|
16 | abort: no view requested | |
17 | (use "hg show VIEW" to choose a view) |
|
17 | (use "hg show VIEW" to choose a view) | |
18 | [255] |
|
18 | [255] | |
19 |
|
19 | |||
20 | `hg help show` prints available views |
|
20 | `hg help show` prints available views | |
21 |
|
21 | |||
22 | $ hg help show |
|
22 | $ hg help show | |
23 | hg show VIEW |
|
23 | hg show VIEW | |
24 |
|
24 | |||
25 | show various repository information |
|
25 | show various repository information | |
26 |
|
26 | |||
27 | A requested view of repository data is displayed. |
|
27 | A requested view of repository data is displayed. | |
28 |
|
28 | |||
29 | If no view is requested, the list of available views is shown and the |
|
29 | If no view is requested, the list of available views is shown and the | |
30 | command aborts. |
|
30 | command aborts. | |
31 |
|
31 | |||
32 | Note: |
|
32 | Note: | |
33 | There are no backwards compatibility guarantees for the output of this |
|
33 | There are no backwards compatibility guarantees for the output of this | |
34 | command. Output may change in any future Mercurial release. |
|
34 | command. Output may change in any future Mercurial release. | |
35 |
|
35 | |||
36 | Consumers wanting stable command output should specify a template via |
|
36 | Consumers wanting stable command output should specify a template via | |
37 | "-T/--template". |
|
37 | "-T/--template". | |
38 |
|
38 | |||
39 | List of available views: |
|
39 | List of available views: | |
40 |
|
40 | |||
41 | bookmarks bookmarks and their associated changeset |
|
41 | bookmarks bookmarks and their associated changeset | |
42 |
|
42 | |||
43 |
|
|
43 | work changesets that aren't finished | |
44 |
|
44 | |||
45 | (use 'hg help -e show' to show help for the show extension) |
|
45 | (use 'hg help -e show' to show help for the show extension) | |
46 |
|
46 | |||
47 | options: |
|
47 | options: | |
48 |
|
48 | |||
49 | -T --template TEMPLATE display with template |
|
49 | -T --template TEMPLATE display with template | |
50 |
|
50 | |||
51 | (some details hidden, use --verbose to show complete help) |
|
51 | (some details hidden, use --verbose to show complete help) | |
52 |
|
52 | |||
53 | Unknown view prints error |
|
53 | Unknown view prints error | |
54 |
|
54 | |||
55 | $ hg show badview |
|
55 | $ hg show badview | |
56 | abort: unknown view: badview |
|
56 | abort: unknown view: badview | |
57 | (run "hg show" to see available views) |
|
57 | (run "hg show" to see available views) | |
58 | [255] |
|
58 | [255] | |
59 |
|
59 | |||
60 | HGPLAIN results in abort |
|
60 | HGPLAIN results in abort | |
61 |
|
61 | |||
62 | $ HGPLAIN=1 hg show bookmarks |
|
62 | $ HGPLAIN=1 hg show bookmarks | |
63 | abort: must specify a template in plain mode |
|
63 | abort: must specify a template in plain mode | |
64 | (invoke with -T/--template to control output format) |
|
64 | (invoke with -T/--template to control output format) | |
65 | [255] |
|
65 | [255] | |
66 |
|
66 | |||
67 | But not if a template is specified |
|
67 | But not if a template is specified | |
68 |
|
68 | |||
69 | $ HGPLAIN=1 hg show bookmarks -T '{bookmark}\n' |
|
69 | $ HGPLAIN=1 hg show bookmarks -T '{bookmark}\n' | |
70 | (no bookmarks set) |
|
70 | (no bookmarks set) | |
71 |
|
71 | |||
72 | $ cd .. |
|
72 | $ cd .. | |
73 |
|
73 | |||
74 | bookmarks view with no bookmarks prints empty message |
|
74 | bookmarks view with no bookmarks prints empty message | |
75 |
|
75 | |||
76 | $ hg init books |
|
76 | $ hg init books | |
77 | $ cd books |
|
77 | $ cd books | |
78 | $ touch f0 |
|
78 | $ touch f0 | |
79 | $ hg -q commit -A -m initial |
|
79 | $ hg -q commit -A -m initial | |
80 |
|
80 | |||
81 | $ hg show bookmarks |
|
81 | $ hg show bookmarks | |
82 | (no bookmarks set) |
|
82 | (no bookmarks set) | |
83 |
|
83 | |||
84 | bookmarks view shows bookmarks in an aligned table |
|
84 | bookmarks view shows bookmarks in an aligned table | |
85 |
|
85 | |||
86 | $ echo book1 > f0 |
|
86 | $ echo book1 > f0 | |
87 | $ hg commit -m 'commit for book1' |
|
87 | $ hg commit -m 'commit for book1' | |
88 | $ echo book2 > f0 |
|
88 | $ echo book2 > f0 | |
89 | $ hg commit -m 'commit for book2' |
|
89 | $ hg commit -m 'commit for book2' | |
90 |
|
90 | |||
91 | $ hg bookmark -r 1 book1 |
|
91 | $ hg bookmark -r 1 book1 | |
92 | $ hg bookmark a-longer-bookmark |
|
92 | $ hg bookmark a-longer-bookmark | |
93 |
|
93 | |||
94 | $ hg show bookmarks |
|
94 | $ hg show bookmarks | |
95 | * a-longer-bookmark 7b570 |
|
95 | * a-longer-bookmark 7b570 | |
96 | book1 b757f |
|
96 | book1 b757f | |
97 |
|
97 | |||
98 | A custom bookmarks template works |
|
98 | A custom bookmarks template works | |
99 |
|
99 | |||
100 | $ hg show bookmarks -T '{node} {bookmark} {active}\n' |
|
100 | $ hg show bookmarks -T '{node} {bookmark} {active}\n' | |
101 | 7b5709ab64cbc34da9b4367b64afff47f2c4ee83 a-longer-bookmark True |
|
101 | 7b5709ab64cbc34da9b4367b64afff47f2c4ee83 a-longer-bookmark True | |
102 | b757f780b8ffd71267c6ccb32e0882d9d32a8cc0 book1 False |
|
102 | b757f780b8ffd71267c6ccb32e0882d9d32a8cc0 book1 False | |
103 |
|
103 | |||
104 | bookmarks JSON works |
|
104 | bookmarks JSON works | |
105 |
|
105 | |||
106 | $ hg show bookmarks -T json |
|
106 | $ hg show bookmarks -T json | |
107 | [ |
|
107 | [ | |
108 | { |
|
108 | { | |
109 | "active": true, |
|
109 | "active": true, | |
110 | "bookmark": "a-longer-bookmark", |
|
110 | "bookmark": "a-longer-bookmark", | |
111 | "longestbookmarklen": 17, |
|
111 | "longestbookmarklen": 17, | |
112 | "node": "7b5709ab64cbc34da9b4367b64afff47f2c4ee83" |
|
112 | "node": "7b5709ab64cbc34da9b4367b64afff47f2c4ee83" | |
113 | }, |
|
113 | }, | |
114 | { |
|
114 | { | |
115 | "active": false, |
|
115 | "active": false, | |
116 | "bookmark": "book1", |
|
116 | "bookmark": "book1", | |
117 | "longestbookmarklen": 17, |
|
117 | "longestbookmarklen": 17, | |
118 | "node": "b757f780b8ffd71267c6ccb32e0882d9d32a8cc0" |
|
118 | "node": "b757f780b8ffd71267c6ccb32e0882d9d32a8cc0" | |
119 | } |
|
119 | } | |
120 | ] |
|
120 | ] | |
121 |
|
121 | |||
122 | JSON works with no bookmarks |
|
122 | JSON works with no bookmarks | |
123 |
|
123 | |||
124 | $ hg book -d a-longer-bookmark |
|
124 | $ hg book -d a-longer-bookmark | |
125 | $ hg book -d book1 |
|
125 | $ hg book -d book1 | |
126 | $ hg show bookmarks -T json |
|
126 | $ hg show bookmarks -T json | |
127 | [ |
|
127 | [ | |
128 | ] |
|
128 | ] | |
129 |
|
129 | |||
130 | $ cd .. |
|
130 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now