# HG changeset patch # User Dan Villiom Podlaski Christiansen # Date 1270049670 -7200 # Node ID 408869906fbf380596be9ccb4e4815417aa2abd7 # Parent e432b61c6d742a15542744d7f16e62605d93b65e Move the 'svn' metacommand into the 'svncommands' module. diff --git a/hgsubversion/__init__.py b/hgsubversion/__init__.py --- a/hgsubversion/__init__.py +++ b/hgsubversion/__init__.py @@ -37,8 +37,6 @@ demandimport.ignore.extend([ 'svn.ra', ]) -from svn import core - import svncommands import util import svnrepo @@ -107,44 +105,6 @@ def uisetup(ui): pass -def svn(ui, repo, subcommand, *args, **opts): - '''see detailed help for list of subcommands''' - - # guess command if prefix - if subcommand not in svncommands.table: - candidates = [] - for c in svncommands.table: - if c.startswith(subcommand): - candidates.append(c) - if len(candidates) == 1: - subcommand = candidates[0] - - # override subversion credentials - for key in ('username', 'password'): - if key in opts: - ui.setconfig('hgsubversion', key, opts[key]) - - try: - commandfunc = svncommands.table[subcommand] - return commandfunc(ui, args=args, repo=repo, **opts) - except core.SubversionException, e: - if e.apr_err == core.SVN_ERR_RA_SERF_SSL_CERT_UNTRUSTED: - raise hgutil.Abort('It appears svn does not trust the ssl cert for this site.\n' - 'Please try running svn ls on that url first.') - raise - except TypeError: - tb = traceback.extract_tb(sys.exc_info()[2]) - if len(tb) == 1: - ui.status('Bad arguments for subcommand %s\n' % subcommand) - else: - raise - except KeyError, e: - tb = traceback.extract_tb(sys.exc_info()[2]) - if len(tb) == 1: - ui.status('Unknown subcommand %s\n' % subcommand) - else: - raise -svn.__doc__ = svncommands._helpgen() def reposetup(ui, repo): if repo.local(): @@ -166,7 +126,7 @@ commands.optionalrepo += ' svn' cmdtable = { "svn": - (svn, + (svncommands.svn, [('u', 'svn-url', '', 'path to the Subversion server.'), ('', 'stupid', False, 'be stupid and use diffy replay.'), ('A', 'authors', '', 'username mapping filename'), diff --git a/hgsubversion/svncommands.py b/hgsubversion/svncommands.py --- a/hgsubversion/svncommands.py +++ b/hgsubversion/svncommands.py @@ -8,6 +8,8 @@ from mercurial import node from mercurial import util as hgutil from mercurial import error +from svn import core + import maps import svnwrap import svnrepo @@ -397,6 +399,45 @@ def _helpgen(): ret.append(" :%s: %s" % (name, short_description)) return '\n'.join(ret) + '\n' +def svn(ui, repo, subcommand, *args, **opts): + '''see detailed help for list of subcommands''' + + # guess command if prefix + if subcommand not in table: + candidates = [] + for c in table: + if c.startswith(subcommand): + candidates.append(c) + if len(candidates) == 1: + subcommand = candidates[0] + else: + raise error.AmbiguousCommand(subcommand, candidates) + + # override subversion credentials + for key in ('username', 'password'): + if key in opts: + ui.setconfig('hgsubversion', key, opts[key]) + + try: + commandfunc = table[subcommand] + return commandfunc(ui, args=args, repo=repo, **opts) + except core.SubversionException, e: + if e.apr_err == core.SVN_ERR_RA_SERF_SSL_CERT_UNTRUSTED: + raise hgutil.Abort('It appears svn does not trust the ssl cert for this site.\n' + 'Please try running svn ls on that url first.') + raise + except TypeError: + tb = traceback.extract_tb(sys.exc_info()[2]) + if len(tb) == 1: + ui.status('Bad arguments for subcommand %s\n' % subcommand) + else: + raise + except KeyError, e: + tb = traceback.extract_tb(sys.exc_info()[2]) + if len(tb) == 1: + ui.status('Unknown subcommand %s\n' % subcommand) + else: + raise table = { 'genignore': genignore, @@ -408,3 +449,4 @@ table = { 'updateexternals': svnexternals.updateexternals, 'verify': verify, } +svn.__doc__ = _helpgen()