changeset 4894:f9743b13de6d

help: categorizing evolve and topic commands This makes them show up under the right categories in 'hg help'. Differential Revision: https://phab.mercurial-scm.org/D6999
author Rodrigo Damazio <rdamazio@google.com>
date Sun, 06 Oct 2019 02:30:12 -0400
parents d3ad50b40a4e
children 33785e94097a
files hgext3rd/evolve/__init__.py hgext3rd/evolve/cmdrewrite.py hgext3rd/evolve/compat.py hgext3rd/evolve/evolvecmd.py hgext3rd/evolve/exthelper.py hgext3rd/evolve/obshistory.py hgext3rd/evolve/rewind.py hgext3rd/topic/__init__.py hgext3rd/topic/compat.py tests/test-topic.t
diffstat 10 files changed, 71 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/__init__.py	Thu Oct 10 08:22:41 2019 +0700
+++ b/hgext3rd/evolve/__init__.py	Sun Oct 06 02:30:12 2019 -0400
@@ -465,7 +465,8 @@
     _alias, statuscmd = cmdutil.findcmd(b'status', commands.table)
     pstatusopts = [o for o in statuscmd[1] if o[1] != b'rev']
 
-    @eh.command(b'pstatus', pstatusopts)
+    @eh.command(b'pstatus', pstatusopts,
+                **compat.helpcategorykwargs('CATEGORY_WORKING_DIRECTORY'))
     def pstatus(ui, repo, *args, **kwargs):
         """show status combining committed and uncommited changes
 
@@ -480,7 +481,8 @@
     _alias, diffcmd = cmdutil.findcmd(b'diff', commands.table)
     pdiffopts = [o for o in diffcmd[1] if o[1] != b'rev']
 
-    @eh.command(b'pdiff', pdiffopts)
+    @eh.command(b'pdiff', pdiffopts,
+                **compat.helpcategorykwargs('CATEGORY_WORKING_DIRECTORY'))
     def pdiff(ui, repo, *args, **kwargs):
         """show diff combining committed and uncommited changes
 
@@ -989,7 +991,8 @@
      (b'n', b'dry-run', False,
         _(b'do not perform actions, just print what would be done'))],
     b'[OPTION]...',
-    helpbasic=True)
+    helpbasic=True,
+    **compat.helpcategorykwargs('CATEGORY_WORKING_DIRECTORY'))
 def cmdprevious(ui, repo, **opts):
     """update to parent revision
 
@@ -1048,7 +1051,8 @@
      (b'n', b'dry-run', False,
       _(b'do not perform actions, just print what would be done'))],
     b'[OPTION]...',
-    helpbasic=True)
+    helpbasic=True,
+    **compat.helpcategorykwargs('CATEGORY_WORKING_DIRECTORY'))
 def cmdnext(ui, repo, **opts):
     """update to next child revision
 
@@ -1339,8 +1343,16 @@
         if entry[0] == b"evolution":
             break
     else:
-        help.helptable.append(([b"evolution"], _(b"Safely Rewriting History"),
-                               _helploader))
+        if util.safehasattr(help, 'TOPIC_CATEGORY_CONCEPTS'):
+            help.helptable.append(([b"evolution"],
+                                   _(b"Safely Rewriting History"),
+                                   _helploader,
+                                   help.TOPIC_CATEGORY_CONCEPTS))
+        else:
+            # hg <= 4.7 (c303d65d2e34)
+            help.helptable.append(([b"evolution"],
+                                   _(b"Safely Rewriting History"),
+                                   _helploader))
         help.helptable.sort()
 
 evolvestateversion = 0
--- a/hgext3rd/evolve/cmdrewrite.py	Thu Oct 10 08:22:41 2019 +0700
+++ b/hgext3rd/evolve/cmdrewrite.py	Sun Oct 06 02:30:12 2019 -0400
@@ -109,7 +109,8 @@
      (b'n', b'note', b'', _(b'store a note on amend'), _(b'TEXT')),
      ] + walkopts + commitopts + commitopts2 + commitopts3 + interactiveopt,
     _(b'[OPTION]... [FILE]...'),
-    helpbasic=True)
+    helpbasic=True,
+    **compat.helpcategorykwargs('CATEGORY_COMMITTING'))
 def amend(ui, repo, *pats, **opts):
     """combine a changeset with updates and replace it with a new one
 
@@ -454,7 +455,8 @@
      (b'', b'revert', False, _(b'discard working directory changes after uncommit')),
      (b'n', b'note', b'', _(b'store a note on uncommit'), _(b'TEXT')),
      ] + commands.walkopts + commitopts + commitopts2 + commitopts3,
-    _(b'[OPTION]... [NAME]'))
+    _(b'[OPTION]... [NAME]'),
+    **compat.helpcategorykwargs('CATEGORY_CHANGE_MANAGEMENT'))
 def uncommit(ui, repo, *pats, **opts):
     """move changes from parent revision to working directory
 
@@ -690,7 +692,8 @@
      (b'n', b'note', b'', _(b'store a note on fold'), _(b'TEXT')),
      ] + commitopts + commitopts2 + commitopts3,
     _(b'hg fold [OPTION]... [-r] REV'),
-    helpbasic=True)
+    helpbasic=True,
+    **compat.helpcategorykwargs('CATEGORY_CHANGE_MANAGEMENT'))
 def fold(ui, repo, *revs, **opts):
     """fold multiple revisions into a single one
 
@@ -820,7 +823,8 @@
      (b'', b'fold', None, _(b"also fold specified revisions into one")),
      (b'n', b'note', b'', _(b'store a note on metaedit'), _(b'TEXT')),
      ] + commitopts + commitopts2 + commitopts3,
-    _(b'hg metaedit [OPTION]... [-r] [REV]'))
+    _(b'hg metaedit [OPTION]... [-r] [REV]'),
+    **compat.helpcategorykwargs('CATEGORY_CHANGE_MANAGEMENT'))
 def metaedit(ui, repo, *revs, **opts):
     """edit commit information
 
@@ -979,7 +983,8 @@
      (b'B', b'bookmark', [], _(b"remove revs only reachable from given"
                                b" bookmark"), _(b'BOOKMARK'))] + metadataopts,
     _(b'[OPTION] [-r] REV...'),
-    helpbasic=True)
+    helpbasic=True,
+    **compat.helpcategorykwargs('CATEGORY_CHANGE_MANAGEMENT'))
 # XXX -U  --noupdate option to prevent wc update and or bookmarks update ?
 def cmdprune(ui, repo, *revs, **opts):
     """mark changesets as obsolete or succeeded by another changeset
@@ -1173,7 +1178,8 @@
      (b'n', b'note', b'', _(b"store a note on split"), _(b'TEXT')),
      ] + commitopts + commitopts2 + commitopts3,
     _(b'hg split [OPTION] [-r REV] [FILES]'),
-    helpbasic=True)
+    helpbasic=True,
+    **compat.helpcategorykwargs('CATEGORY_CHANGE_MANAGEMENT'))
 def cmdsplit(ui, repo, *pats, **opts):
     """split a changeset into smaller changesets
 
@@ -1348,7 +1354,8 @@
       b'mark the new revision as successor of the old one potentially creating '
       b'divergence')],
     # allow to choose the seed ?
-    _(b'[-r] revs'))
+    _(b'[-r] revs'),
+    **compat.helpcategorykwargs('CATEGORY_CHANGE_MANAGEMENT'))
 def touch(ui, repo, *revs, **opts):
     """create successors identical to their predecessors but the changeset ID
 
@@ -1449,7 +1456,8 @@
      (b'c', b'continue', False, b'continue interrupted pick'),
      (b'a', b'abort', False, b'abort interrupted pick'),
      ] + mergetoolopts,
-    _(b'[-r] rev'))
+    _(b'[-r] rev'),
+    **compat.helpcategorykwargs('CATEGORY_CHANGE_MANAGEMENT'))
 def cmdpick(ui, repo, *revs, **opts):
     """move a commit on the top of working directory parent and updates to it."""
 
--- a/hgext3rd/evolve/compat.py	Thu Oct 10 08:22:41 2019 +0700
+++ b/hgext3rd/evolve/compat.py	Sun Oct 06 02:30:12 2019 -0400
@@ -17,6 +17,7 @@
     obsolete,
     obsutil,
     pycompat,
+    registrar,
     repair,
     scmutil,
     util,
@@ -515,3 +516,12 @@
                      if meta.get(b'operation'))
 
     return sorted(operations)
+
+# help category compatibility
+# hg <= 4.7 (c303d65d2e34)
+def helpcategorykwargs(categoryname):
+    """Backwards-compatible specification of the helpategory argument."""
+    category = getattr(registrar.command, categoryname, None)
+    if not category:
+        return {}
+    return {'helpcategory': category}
--- a/hgext3rd/evolve/evolvecmd.py	Thu Oct 10 08:22:41 2019 +0700
+++ b/hgext3rd/evolve/evolvecmd.py	Sun Oct 06 02:30:12 2019 -0400
@@ -1505,7 +1505,8 @@
                               b' in the repo')),
      ] + mergetoolopts,
     _(b'[OPTIONS]...'),
-    helpbasic=True
+    helpbasic=True,
+    **compat.helpcategorykwargs('CATEGORY_CHANGE_MANAGEMENT')
 )
 def evolve(ui, repo, **opts):
     """solve troubled changesets in your repository
--- a/hgext3rd/evolve/exthelper.py	Thu Oct 10 08:22:41 2019 +0700
+++ b/hgext3rd/evolve/exthelper.py	Sun Oct 06 02:30:12 2019 -0400
@@ -50,7 +50,7 @@
         @eh.command('mynewcommand',
             [('r', 'rev', [], _('operate on these revisions'))],
             _('-r REV...'),
-            helpcategory=command.CATEGORY_XXX)
+            **compat.helpcategorykwargs('CATEGORY_XXX'))
         def newcommand(ui, repo, *revs, **opts):
             # implementation goes here
 
--- a/hgext3rd/evolve/obshistory.py	Thu Oct 10 08:22:41 2019 +0700
+++ b/hgext3rd/evolve/obshistory.py	Sun Oct 06 02:30:12 2019 -0400
@@ -50,7 +50,8 @@
      (b'p', b'patch', False, _(b'show the patch between two obs versions')),
      (b'f', b'filternonlocal', False, _(b'filter out non local commits')),
      ] + commands.formatteropts,
-    _(b'hg olog [OPTION]... [REV]'))
+    _(b'hg olog [OPTION]... [REV]'),
+    **compat.helpcategorykwargs('CATEGORY_CHANGE_NAVIGATION'))
 def cmdobshistory(ui, repo, *revs, **opts):
     """show the obsolescence history of the specified revisions
 
--- a/hgext3rd/evolve/rewind.py	Thu Oct 10 08:22:41 2019 +0700
+++ b/hgext3rd/evolve/rewind.py	Sun Oct 06 02:30:12 2019 -0400
@@ -36,7 +36,8 @@
       _(b"do not modify working directory during rewind")),
      ],
     _(b'[--as-divergence] [--exact] [--keep] [--to REV]... [--from REV]...'),
-    helpbasic=True)
+    helpbasic=True,
+    **compat.helpcategorykwargs('CATEGORY_CHANGE_MANAGEMENT'))
 def rewind(ui, repo, **opts):
     """rewind a stack of changesets to a previous state
 
--- a/hgext3rd/topic/__init__.py	Thu Oct 10 08:22:41 2019 +0700
+++ b/hgext3rd/topic/__init__.py	Sun Oct 06 02:30:12 2019 -0400
@@ -634,7 +634,8 @@
         (b'', b'age', False, b'show when you last touched the topics'),
         (b'', b'current', None, b'display the current topic only'),
     ] + commands.formatteropts,
-    _(b'hg topics [TOPIC]'))
+    _(b'hg topics [TOPIC]'),
+    **compat.helpcategorykwargs('CATEGORY_CHANGE_ORGANIZATION'))
 def topics(ui, repo, topic=None, **opts):
     """View current topic, set current topic, change topic for a set of revisions, or see all topics.
 
@@ -777,7 +778,8 @@
         (b'c', b'children', None,
             _(b'display data about children outside of the stack'))
     ] + commands.formatteropts,
-    _(b'hg stack [TOPIC]'))
+    _(b'hg stack [TOPIC]'),
+    **compat.helpcategorykwargs('CATEGORY_CHANGE_NAVIGATION'))
 def cmdstack(ui, repo, topic=b'', **opts):
     """list all changesets in a topic and other information
 
--- a/hgext3rd/topic/compat.py	Thu Oct 10 08:22:41 2019 +0700
+++ b/hgext3rd/topic/compat.py	Sun Oct 06 02:30:12 2019 -0400
@@ -10,6 +10,7 @@
 from mercurial import (
     obsolete,
     pycompat,
+    registrar,
 )
 
 getmarkers = None
@@ -34,3 +35,12 @@
     def branchmapitems(branchmap):
         return branchmap.iteritems()
     # py3-transform: on
+
+# help category compatibility
+# hg <= 4.7 (c303d65d2e34)
+def helpcategorykwargs(categoryname):
+    """Backwards-compatible specification of the helpategory argument."""
+    category = getattr(registrar.command, categoryname, None)
+    if not category:
+        return {}
+    return {'helpcategory': category}
--- a/tests/test-topic.t	Thu Oct 10 08:22:41 2019 +0700
+++ b/tests/test-topic.t	Sun Oct 06 02:30:12 2019 -0400
@@ -122,10 +122,15 @@
   
   list of commands:
   
-   stack         list all changesets in a topic and other information
+  Change organization:
+  
    topics        View current topic, set current topic, change topic for a set
                  of revisions, or see all topics.
   
+  Change navigation:
+  
+   stack         list all changesets in a topic and other information
+  
   (use 'hg help -v topic' to show built-in aliases and global options)
   $ hg help topics
   hg topics [TOPIC]