comparison __init__.py @ 326:33736e2e25f0

alternate approach for supporting svn schemes for repository paths We now intercept the operations in the local repo class, and handle the relevant operation ourselves. This frees us from wrapping all relevant commands and replicating their functionality. The implementation is incomplete; only one test has been modified to use the standard Mercurial API with the changed URLs. Once changed, those tests will likely reveal bugs or missing features in the new wrappers. Also, new wrappers will be needed for handling conversion flags such as -A/--authormap.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Thu, 07 May 2009 20:50:53 +0200
parents ce676eff002b
children 48ec2d62dc29
comparison
equal deleted inserted replaced
320:1ba8ed29148e 326:33736e2e25f0
16 import sys 16 import sys
17 import traceback 17 import traceback
18 18
19 from mercurial import commands 19 from mercurial import commands
20 from mercurial import extensions 20 from mercurial import extensions
21 from mercurial import hg
21 from mercurial import util as hgutil 22 from mercurial import util as hgutil
22 23
23 from svn import core 24 from svn import core
24 25
25 import svncommands 26 import svncommands
26 import tag_repo 27 import tag_repo
27 import util 28 import util
28 import wrappers 29 import wrappers
29 import svnexternals 30 import svnexternals
30
31 def reposetup(ui, repo):
32 if not util.is_svn_repo(repo):
33 return
34
35 repo.__class__ = tag_repo.generate_repo_class(ui, repo)
36 31
37 def uisetup(ui): 32 def uisetup(ui):
38 """Do our UI setup. 33 """Do our UI setup.
39 34
40 Does the following wrappings: 35 Does the following wrappings:
53 "show svn-style diffs, default against svn parent")) 48 "show svn-style diffs, default against svn parent"))
54 entry = extensions.wrapcommand(commands.table, 'push', 49 entry = extensions.wrapcommand(commands.table, 'push',
55 wrappers.push) 50 wrappers.push)
56 entry[1].append(('', 'svn', None, "push to subversion")) 51 entry[1].append(('', 'svn', None, "push to subversion"))
57 entry[1].append(('', 'svn-stupid', None, "use stupid replay during push to svn")) 52 entry[1].append(('', 'svn-stupid', None, "use stupid replay during push to svn"))
58 entry = extensions.wrapcommand(commands.table, 'pull',
59 wrappers.pull)
60 entry[1].append(('', 'svn', None, "pull from subversion"))
61 entry[1].append(('', 'svn-stupid', None, "use stupid replay during pull from svn"))
62
63 entry = extensions.wrapcommand(commands.table, 'clone',
64 wrappers.clone)
65 entry[1].extend([#('', 'skipto-rev', '0', 'skip commits before this revision.'),
66 ('', 'svn-stupid', False, 'be stupid and use diffy replay.'),
67 ('', 'svn-tag-locations', 'tags', 'Relative path to Subversion tags.'),
68 ('', 'svn-authors', '', 'username mapping filename'),
69 ('', 'svn-filemap', '',
70 'remap file to exclude paths or include only certain paths'),
71 ])
72 53
73 try: 54 try:
74 rebase = extensions.find('rebase') 55 rebase = extensions.find('rebase')
75 if rebase: 56 if rebase:
76 entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', wrappers.rebase) 57 entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', wrappers.rebase)
113 if len(tb) == 1: 94 if len(tb) == 1:
114 ui.status('Unknown subcommand %s\n' % subcommand) 95 ui.status('Unknown subcommand %s\n' % subcommand)
115 else: 96 else:
116 raise 97 raise
117 98
99 def reposetup(ui, repo):
100 if repo.local():
101 tag_repo.generate_repo_class(ui, repo)
118 102
103 for scheme in ('svn', 'svn+ssh', 'svn+http', 'svn+file'):
104 hg.schemes[scheme] = tag_repo
119 105
120 cmdtable = { 106 cmdtable = {
121 "svn": 107 "svn":
122 (svn, 108 (svn,
123 [('u', 'svn-url', '', 'path to the Subversion server.'), 109 [('u', 'svn-url', '', 'path to the Subversion server.'),