Read about our upcoming Code of Conduct on this issue

Commit 22f8fec5 authored by Pulkit Goyal's avatar Pulkit Goyal
Browse files

topics: add a current flag to display current topic

This patch adds a current flag which can be used by user to display the current
parent 736ab58641f0
......@@ -121,6 +121,11 @@ expected test change only, no code change should happen there.
6.7.0 - in progress
* topic: gain a --current flag
6.6.0 -- 2017-07-25
......@@ -312,6 +312,7 @@ def reposetup(ui, repo):
('r', 'rev', '', 'revset of existing revisions', _('REV')),
('l', 'list', False, 'show the stack of changeset in the topic'),
('', 'age', False, 'show when you last touched the topics'),
('', 'current', None, 'display the current topic only'),
] + commands.formatteropts,
_('hg topics [TOPIC]'))
def topics(ui, repo, topic='', clear=False, rev=None, list=False, **opts):
......@@ -338,6 +339,13 @@ def topics(ui, repo, topic='', clear=False, rev=None, list=False, **opts):
The active topic (if any) will be prepended with a "*".
The --verbose version of this command display various information on the state of each topic."""
current = opts.get('current')
if current and topic:
raise error.Abort(_("cannot use --current when setting a topic"))
if current and clear:
raise error.Abort(_("cannot use --current and --clear"))
if list:
if clear or rev:
raise error.Abort(_("cannot use --clear or --rev with --list"))
......@@ -375,7 +383,21 @@ def topics(ui, repo, topic='', clear=False, rev=None, list=False, **opts):
if topic:
return _changecurrenttopic(repo, topic)
_listtopics(ui, repo, opts)
# `hg topic --current`
ret = 0
if current and not repo.currenttopic:
ui.write_err(_('no active topic\n'))
ret = 1
elif current:
fm = ui.formatter('topic', opts)
namemask = '%s\n'
label = ''
fm.write('topic', namemask, repo.currenttopic, label=label)
_listtopics(ui, repo, opts)
return ret
@command('stack', [
] + commands.formatteropts,
......@@ -47,6 +47,7 @@
-r --rev REV revset of existing revisions
-l --list show the stack of changeset in the topic
--age show when you last touched the topics
--current display the current topic only
(some details hidden, use --verbose to show complete help)
$ hg topics
......@@ -72,6 +73,15 @@ Create some changes:
Still no topics
$ hg topics
$ hg topics --current
no active topic
$ hg topics --current somerandomtopic
abort: cannot use --current when setting a topic
$ hg topics --current --clear
abort: cannot use --current and --clear
Test commit flag and help text
......@@ -104,6 +114,8 @@ Make a topic
$ hg topics
* fran
$ hg topics --current
$ echo >> fran work >> beta
$ hg ci -m 'start on fran'
$ hg co narf
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment