Mercurial > hgsubversion
comparison __init__.py @ 253:c3d5c4ae9c7c
Work with simple command table instead of decorators.
| author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
|---|---|
| date | Fri, 10 Apr 2009 23:09:59 +0200 |
| parents | 23b02f892d9b |
| children | 7932d098cb5f |
comparison
equal
deleted
inserted
replaced
| 252:4d3bcd2f26ed | 253:c3d5c4ae9c7c |
|---|---|
| 24 | 24 |
| 25 import svncommands | 25 import svncommands |
| 26 import tag_repo | 26 import tag_repo |
| 27 import util | 27 import util |
| 28 | 28 |
| 29 from util import svn_subcommands, svn_commands_nourl | |
| 30 | |
| 31 def reposetup(ui, repo): | 29 def reposetup(ui, repo): |
| 32 if not util.is_svn_repo(repo): | 30 if not util.is_svn_repo(repo): |
| 33 return | 31 return |
| 34 | 32 |
| 35 repo.__class__ = tag_repo.generate_repo_class(ui, repo) | 33 repo.__class__ = tag_repo.generate_repo_class(ui, repo) |
| 37 | 35 |
| 38 def svn(ui, repo, subcommand, *args, **opts): | 36 def svn(ui, repo, subcommand, *args, **opts): |
| 39 '''see detailed help for list of subcommands''' | 37 '''see detailed help for list of subcommands''' |
| 40 | 38 |
| 41 # guess command if prefix | 39 # guess command if prefix |
| 42 if subcommand not in svn_subcommands: | 40 if subcommand not in svncommands.table: |
| 43 candidates = [] | 41 candidates = [] |
| 44 for c in svn_subcommands: | 42 for c in svncommands.table: |
| 45 if c.startswith(subcommand): | 43 if c.startswith(subcommand): |
| 46 candidates.append(c) | 44 candidates.append(c) |
| 47 if len(candidates) == 1: | 45 if len(candidates) == 1: |
| 48 subcommand = candidates[0] | 46 subcommand = candidates[0] |
| 49 | 47 |
| 50 path = os.path.dirname(repo.path) | 48 path = os.path.dirname(repo.path) |
| 51 try: | 49 try: |
| 52 commandfunc = svn_subcommands[subcommand] | 50 commandfunc = svncommands.table[subcommand] |
| 53 if commandfunc not in svn_commands_nourl: | 51 if commandfunc not in svncommands.nourl: |
| 54 opts['svn_url'] = open(os.path.join(repo.path, 'svn', 'url')).read() | 52 opts['svn_url'] = open(os.path.join(repo.path, 'svn', 'url')).read() |
| 55 return commandfunc(ui, args=args, hg_repo_path=path, repo=repo, **opts) | 53 return commandfunc(ui, args=args, hg_repo_path=path, repo=repo, **opts) |
| 56 except core.SubversionException, e: | 54 except core.SubversionException, e: |
| 57 if e.apr_err == core.SVN_ERR_RA_SERF_SSL_CERT_UNTRUSTED: | 55 if e.apr_err == core.SVN_ERR_RA_SERF_SSL_CERT_UNTRUSTED: |
| 58 raise hgutil.Abort('It appears svn does not trust the ssl cert for this site.\n' | 56 raise hgutil.Abort('It appears svn does not trust the ssl cert for this site.\n' |
| 109 'remap file to exclude paths or include only certain paths'), | 107 'remap file to exclude paths or include only certain paths'), |
| 110 ('', 'force', False, 'force an operation to happen'), | 108 ('', 'force', False, 'force an operation to happen'), |
| 111 ('', 'username', '', 'username for authentication'), | 109 ('', 'username', '', 'username for authentication'), |
| 112 ('', 'password', '', 'password for authentication'), | 110 ('', 'password', '', 'password for authentication'), |
| 113 ], | 111 ], |
| 114 svncommands.generate_help(), | 112 svncommands._helpgen(), |
| 115 ), | 113 ), |
| 116 "svnclone": | 114 "svnclone": |
| 117 (svn_fetch, | 115 (svn_fetch, |
| 118 [('S', 'skipto-rev', '0', 'skip commits before this revision.'), | 116 [('S', 'skipto-rev', '0', 'skip commits before this revision.'), |
| 119 ('', 'stupid', False, 'be stupid and use diffy replay.'), | 117 ('', 'stupid', False, 'be stupid and use diffy replay.'), |
