diff -r 736ab58641f0 -r 5c0b6af37b21 hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Mon Aug 28 17:10:41 2017 +0200 +++ b/hgext3rd/topic/__init__.py Mon Aug 28 17:15:08 2017 +0200 @@ -312,6 +312,7 @@ ('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 @@ 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 @@ 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 = 'topic.active' + fm.startitem() + fm.write('topic', namemask, repo.currenttopic, label=label) + fm.end() + else: + _listtopics(ui, repo, opts) + return ret @command('stack', [ ] + commands.formatteropts,