Mercurial > hgsubversion
changeset 599:408869906fbf
Move the 'svn' metacommand into the 'svncommands' module.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Wed, 31 Mar 2010 17:34:30 +0200 |
parents | e432b61c6d74 |
children | a42e9c9bbb8a |
files | hgsubversion/__init__.py hgsubversion/svncommands.py |
diffstat | 2 files changed, 43 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- 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'),
--- 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()