changeset 115:ed42f6e5705a

Clean up help text, document subcommands.
author Luke Opperman <luke@loppear.com>
date Thu, 20 Nov 2008 22:03:30 -0600
parents 3c5c2683eebb
children 30580c05dccc
files __init__.py svncommand.py util.py utility_commands.py
diffstat 4 files changed, 26 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/__init__.py
+++ b/__init__.py
@@ -6,6 +6,7 @@ from mercurial import hg
 import svncommand
 import fetch_command
 
+
 def svn(ui, repo, subcommand, *args, **opts):
     return svncommand.svncmd(ui, repo, subcommand, *args, **opts)
 
@@ -27,7 +28,8 @@ cmdtable = {
          [('u', 'svn_url', '', 'Path to the Subversion server.'),
           ('', 'stupid', False, 'Be stupid and use diffy replay.'),
           ],
-         'hg svn subcommand'),
+         svncommand.generate_help(),
+         ),
     "svnclone" :(svn_fetch,
          [('S', 'skipto_rev', '0', 'Skip commits before this revision.'),
           ('', 'stupid', False, 'Be stupid and use diffy replay.'),
--- a/svncommand.py
+++ b/svncommand.py
@@ -11,7 +11,7 @@ from mercurial import util as merc_util
 import svnwrap
 import hg_delta_editor
 import util
-from util import register_subcommand, svn_subcommands
+from util import register_subcommand, svn_subcommands, generate_help
 # dirty trick to force demandimport to run my decorator anyway.
 from utility_commands import print_wc_url
 from fetch_command import fetch_revisions
@@ -53,6 +53,7 @@ def svncmd(ui, repo, subcommand, *args, 
         else:
             raise
 
+
 @register_subcommand('help')
 def help_command(ui, args=None, **opts):
     """Get help on the subsubcommands.
@@ -75,8 +76,8 @@ def help_command(ui, args=None, **opts):
             doc = "No documentation available for %s." % subcommand
         ui.status(doc.strip(), '\n')
         return
-    ui.status('Valid commands: ', ' '.join(sorted(svn_subcommands.keys())),
-              '\n')
+    ui.status(generate_help())
+
 
 @register_subcommand('gentags')
 def generate_hg_tags(ui, hg_repo_path, **opts):
@@ -154,7 +155,8 @@ def verify_revision(ui, args, repo, forc
 
 @register_subcommand('verify_all_revisions')
 def verify_all_revisions(ui, args, repo, **opts):
-    """Verify all the converted revisions, optionally starting at a revision.
+    """Verify all the converted revisions
+    optionally starting at a revision.
 
     Note: This is *extremely* abusive of the Subversion server. It exports every
     revision of the code one revision at a time.
--- a/util.py
+++ b/util.py
@@ -13,6 +13,16 @@ def register_subcommand(name):
     return inner
 
 
+def generate_help():
+    ret = ['', 'hg svn subcommand\n', 'Subcommands:\n']
+
+    for name, func in sorted(svn_subcommands.items()):
+        short_description = (func.__doc__ or '').split('\n')[0]
+        ret.append(" %-10s  %s" % (name, short_description))
+
+    return "\n".join(ret) + '\n'
+
+
 def wipe_all_files(hg_wc_path):
     files = [f for f in os.listdir(hg_wc_path) if f != '.hg']
     for f in files:
--- a/utility_commands.py
+++ b/utility_commands.py
@@ -8,6 +8,8 @@ import hg_delta_editor
 
 @util.register_subcommand('url')
 def print_wc_url(ui, repo, hg_repo_path, **opts):
+    """Url of Subversion repository
+    """
     hge = hg_delta_editor.HgChangeReceiver(hg_repo_path,
                                            ui_=ui)
     ui.status(hge.url, '\n')
@@ -15,6 +17,8 @@ def print_wc_url(ui, repo, hg_repo_path,
 
 @util.register_subcommand('info')
 def run_svn_info(ui, repo, hg_repo_path, **opts):
+    """Like svn info details
+    """
     hge = hg_delta_editor.HgChangeReceiver(hg_repo_path,
                                            ui_=ui)
     svn_commit_hashes = dict(zip(hge.revmap.itervalues(),
@@ -54,8 +58,8 @@ Last Changed Date: %(date)s\n''' %
 
 @util.register_subcommand('parent')
 def print_parent_revision(ui, repo, hg_repo_path, **opts):
-    """Prints the hg hash and svn revision info for the nearest svn parent of
-    the current revision"""
+    """Display hg hash and svn revision of nearest svn parent
+    """
     hge = hg_delta_editor.HgChangeReceiver(hg_repo_path,
                                            ui_=ui)
     svn_commit_hashes = dict(zip(hge.revmap.itervalues(),
@@ -75,7 +79,7 @@ def print_parent_revision(ui, repo, hg_r
 
 @util.register_subcommand('rebase')
 def rebase_commits(ui, repo, hg_repo_path, **opts):
-    """Rebases the current unpushed revisions onto the top of the Subversion branch.
+    """Rebases current unpushed revisions onto Subversion head
 
     This moves a line of development from making its own head to the top of
     Subversion development, linearizing the changes. In order to make sure you