changeset 2805:a789b9d5b60c stable

topic: make command names valid as expected, even if ui.strict=true Before this patch, "hg topics" and "hg stack" cause unintentional "unknown command" failure, if ui.strict=true. In such case, "topics [TOPIC]" and "stack [TOPIC]" are required as a canonical name, because synopsis-like string is used as command name pattern of @command annotation for them. This patch also specifies additional "synopsis" for @command annotation, for intentional output in online help of these commands.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sun, 23 Jul 2017 13:30:28 +0900
parents bae174e0e0ac
children 7c5ea3c3ed43
files README hgext3rd/topic/__init__.py tests/test-topic-stack.t
diffstat 3 files changed, 30 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/README	Tue Jul 25 14:56:52 2017 +0200
+++ b/README	Sun Jul 23 13:30:28 2017 +0900
@@ -140,6 +140,7 @@
   - topic: allow 'hg prev' to me move to 't0',
   - topic: add a config option to enforce topic on new commit
     (experimental.enforce-topic)
+  - topic: make command names valid as expected, even if ui.strict=true
 
 6.5.0 -- 2017-07-02
 -------------------
--- a/hgext3rd/topic/__init__.py	Tue Jul 25 14:56:52 2017 +0200
+++ b/hgext3rd/topic/__init__.py	Sun Jul 23 13:30:28 2017 +0900
@@ -307,12 +307,13 @@
             'topics', 'topic', namemap=_namemap, nodemap=_nodemap,
             listnames=lambda repo: repo.topics))
 
-@command('topics [TOPIC]', [
+@command('topics', [
         ('', 'clear', False, 'clear active topic if any'),
         ('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')
-    ] + commands.formatteropts)
+    ] + commands.formatteropts,
+    _('hg topics [TOPIC]'))
 def topics(ui, repo, topic='', clear=False, rev=None, list=False, **opts):
     """View current topic, set current topic, change topic for a set of revisions, or see all topics.
 
@@ -365,7 +366,9 @@
 
     _listtopics(ui, repo, opts)
 
-@command('stack [TOPIC]', [] + commands.formatteropts)
+@command('stack', [
+    ] + commands.formatteropts,
+    _('hg stack [TOPIC]'))
 def cmdstack(ui, repo, topic='', **opts):
     """list all changesets in a topic and other information
 
--- a/tests/test-topic-stack.t	Tue Jul 25 14:56:52 2017 +0200
+++ b/tests/test-topic-stack.t	Sun Jul 23 13:30:28 2017 +0900
@@ -187,6 +187,29 @@
       }
   ]
 
+check that topics and stack are available even if ui.strict=true
+
+  $ hg topics
+   * foo
+  $ hg stack
+  ### topic: foo
+  ### branch: default
+  t4@ c_f (current)
+  t3: c_e
+  t2: c_d
+  t1: c_c
+  t0^ c_b (base)
+  $ hg topics --config ui.strict=true
+   * foo
+  $ hg stack --config ui.strict=true
+  ### topic: foo
+  ### branch: default
+  t4@ c_f (current)
+  t3: c_e
+  t2: c_d
+  t1: c_c
+  t0^ c_b (base)
+
 error case, nothing to list
 
   $ hg topic --clear