Mercurial > hgsubversion
changeset 247:1272e87546ed
Move help, update into svncommands.
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Wed, 08 Apr 2009 18:59:50 +0200 |
parents | 074f27c68818 |
children | a9134fa28d15 |
files | __init__.py svncommand.py svncommands.py |
diffstat | 3 files changed, 54 insertions(+), 55 deletions(-) [+] |
line wrap: on
line diff
--- a/__init__.py +++ b/__init__.py @@ -82,7 +82,7 @@ cmdtable = { ('', 'username', '', 'username for authentication'), ('', 'password', '', 'password for authentication'), ], - svncommand.generate_help(), + svncommands.generate_help(), ), "svnclone": (svn_fetch,
--- a/svncommand.py +++ b/svncommand.py @@ -2,11 +2,7 @@ import os import sys import traceback -from mercurial import hg -from mercurial import node - -import util -from util import register_subcommand, svn_subcommands, generate_help, svn_commands_nourl +from util import svn_subcommands, svn_commands_nourl # dirty trick to force demandimport to run my decorator anyway. from svncommands import pull, diff, rebuildmeta from utility_commands import print_wc_url @@ -43,52 +39,3 @@ def svncmd(ui, repo, subcommand, *args, ui.status('Unknown subcommand %s\n' % subcommand) else: raise - - -def help_command(ui, args=None, **opts): - """show help for a given subcommands or a help overview - """ - if args: - subcommand = args[0] - if subcommand not in svn_subcommands: - candidates = [] - for c in svn_subcommands: - if c.startswith(subcommand): - candidates.append(c) - if len(candidates) == 1: - subcommand = candidates[0] - elif len(candidates) > 1: - ui.status('Ambiguous command. Could have been:\n%s\n' % - ' '.join(candidates)) - return - doc = svn_subcommands[subcommand].__doc__ - if doc is None: - doc = "No documentation available for %s." % subcommand - ui.status(doc.strip(), '\n') - return - ui.status(generate_help()) -help_command = register_subcommand('help')(help_command) - -def update(ui, args, repo, clean=False, **opts): - """update to a specified Subversion revision number - """ - assert len(args) == 1 - rev = int(args[0]) - path = os.path.join(repo.path, 'svn', 'rev_map') - answers = [] - for k,v in util.parse_revmap(path).iteritems(): - if k[0] == rev: - answers.append((v, k[1])) - if len(answers) == 1: - if clean: - return hg.clean(repo, answers[0][0]) - return hg.update(repo, answers[0][0]) - elif len(answers) == 0: - ui.status('Revision %s did not produce an hg revision.\n' % rev) - return 1 - else: - ui.status('Ambiguous revision!\n') - ui.status('\n'.join(['%s on %s' % (node.hex(a[0]), a[1]) for a in - answers]+[''])) - return 1 -update = register_subcommand('up')(update)
--- a/svncommands.py +++ b/svncommands.py @@ -16,6 +16,8 @@ import cmdutil import util import utility_commands +from util import generate_help, svn_subcommands, register_subcommand + def pull(ui, svn_url, hg_repo_path, skipto_rev=0, stupid=None, tag_locations='tags', authors=None, filemap=None, **opts): @@ -329,3 +331,53 @@ def rebuildmeta(ui, repo, hg_repo_path, tagsinfofile.close() rebuildmeta = util.register_subcommand('rebuildmeta')(rebuildmeta) rebuildmeta = util.command_needs_no_url(rebuildmeta) + + +def help(ui, args=None, **opts): + """show help for a given subcommands or a help overview + """ + if args: + subcommand = args[0] + if subcommand not in svn_subcommands: + candidates = [] + for c in svn_subcommands: + if c.startswith(subcommand): + candidates.append(c) + if len(candidates) == 1: + subcommand = candidates[0] + elif len(candidates) > 1: + ui.status('Ambiguous command. Could have been:\n%s\n' % + ' '.join(candidates)) + return + doc = svn_subcommands[subcommand].__doc__ + if doc is None: + doc = "No documentation available for %s." % subcommand + ui.status(doc.strip(), '\n') + return + ui.status(generate_help()) +help = register_subcommand('help')(help) + + +def update(ui, args, repo, clean=False, **opts): + """update to a specified Subversion revision number + """ + assert len(args) == 1 + rev = int(args[0]) + path = os.path.join(repo.path, 'svn', 'rev_map') + answers = [] + for k,v in util.parse_revmap(path).iteritems(): + if k[0] == rev: + answers.append((v, k[1])) + if len(answers) == 1: + if clean: + return hg.clean(repo, answers[0][0]) + return hg.update(repo, answers[0][0]) + elif len(answers) == 0: + ui.status('Revision %s did not produce an hg revision.\n' % rev) + return 1 + else: + ui.status('Ambiguous revision!\n') + ui.status('\n'.join(['%s on %s' % (node.hex(a[0]), a[1]) for a in + answers]+[''])) + return 1 +update = register_subcommand('up')(update)