1. Henrik Stuart
  2. repoman


repoman / tests / output / help.py

import sys
import os
import os.path
import shutil
import repoman
import repoman.help
import repoman.commands
from tests.pytest import run

# monkey patch various tables to control help output

# version string printed in help output
repoman.util.version = lambda: '1.0 unittest'

# command table
def command():
    '''help text'''
repoman.commands.commands = {
    'command': (command, ['cmd'], [
        ('b', 'branch', [], 'provide a list of branches to show (defaults to the working branch)'),
        ('', 'current', False, 'HIDDEN: use the current repository branch instead of the working branch (only useful when -b is not used)'),
        ('', 'style', '', 'display using template map file'),
        ], '[-b BRANCHES] [-l] [SOURCE]'),
    'common': (command, [], [], ''),
    # has to be here (otherwise help doesn't work ...)
    'help': (repoman.commands.help, [], [], '[COMMAND]'),
repoman.commands.globaloptions = [
    ('R', 'repository', '', 'operate on this repository (or module, for module commands)'),
    # has to be here (otherwise help -v and --config don't work ...)
    ('v', 'verbose', None, 'enable additional output'),
    ('', 'config', [], 'override/set configuration variable'),

# topic table
topic = '''Topic

    Very interesting topic lines.

    Empty lines are not ignored, so make sure the file is well-formed.
repoman.help.topics = {
        'topic': topic,

# extension
extension = '''"""Extension

   Very interesting extension lines.
import mercurial.commands
def extcmd(ui, f):
    """an extension command"""

cmdtable = {
    'extcmd': (extcmd, [], [], 'extension command')

print 'commandlist'
run('help -v')

print '\ncommand help'
run('help command')
run('help -v command')

print '\ntopic help'
run('help topic')

print '\nhelp failure'
run('help unknown')
run('help com')

print '\nextension help'
efn = 'help_test_extension.py'
    with open(efn, 'w') as f:
    run('--config "repo-extensions.extension=%s" help extension' % efn)
    run('--config "repo-extensions.extension=%s" help extcmd' % efn)
    run('--config "repo-extensions.extension=%s" help extunknown' % efn)
    if os.path.exists(efn): os.remove(efn)