diff -r aa5268900ba1 -r 31cbace4c0f1 hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Tue Aug 29 19:03:59 2017 +0530 +++ b/hgext3rd/topic/__init__.py Tue Aug 29 19:12:00 2017 +0530 @@ -73,6 +73,7 @@ patch, phases, registrar, + scmutil, templatefilters, util, ) @@ -315,7 +316,7 @@ ('', 'current', None, 'display the current topic only'), ] + commands.formatteropts, _('hg topics [TOPIC]')) -def topics(ui, repo, topic='', clear=False, rev=None, list=False, **opts): +def topics(ui, repo, topic=None, clear=False, rev=None, list=False, **opts): """View current topic, set current topic, change topic for a set of revisions, or see all topics. Clear topic on existing topiced revisions: @@ -353,6 +354,13 @@ if clear and topic: raise error.Abort(_("cannot use --clear when setting a topic")) + if topic: + topic = topic.strip() + if not topic: + raise error.Abort(_("topic name cannot consist entirely of whitespaces")) + # Have some restrictions on the topic name just like bookmark name + scmutil.checknewlabel(repo, topic, 'topic') + if list: if clear or rev: raise error.Abort(_("cannot use --clear or --rev with --list"))