comparison hgsubversion/svncommands.py @ 464:0f7095f53ca3

Extend svnrepos with SubversionRepo and SVNMeta SubversionRepo and SVNMeta are now hidden behind svnremoterepo and svnlocalrepo. It unifies the way svn credentials are read from the command line and configuration file, at the cost of import cycle between svnrepo and wrappers. It is currently not a big deal thanks to demandimport.
author Patrick Mezard <pmezard@gmail.com>
date Sat, 18 Jul 2009 20:44:33 -0500
parents c82d5a9acecf
children 63cb630d667d
comparison
equal deleted inserted replaced
463:c82d5a9acecf 464:0f7095f53ca3
5 from mercurial import node 5 from mercurial import node
6 from mercurial import util as hgutil 6 from mercurial import util as hgutil
7 7
8 import maps 8 import maps
9 import svnwrap 9 import svnwrap
10 import svnmeta 10 import svnrepo
11 import util 11 import util
12 import utility_commands 12 import utility_commands
13 import svnexternals 13 import svnexternals
14 14
15 15
16 def verify(ui, repo, *args, **opts): 16 def verify(ui, repo, *args, **opts):
17 '''verify current revision against Subversion repository 17 '''verify current revision against Subversion repository
18 ''' 18 '''
19
20 if not args:
21 url = repo.ui.expandpath('default')
22 else:
23 url = args[0]
24
25 ctx = repo[opts.get('rev', '.')] 19 ctx = repo[opts.get('rev', '.')]
26 if 'close' in ctx.extra(): 20 if 'close' in ctx.extra():
27 ui.write('cannot verify closed branch') 21 ui.write('cannot verify closed branch')
28 return 0 22 return 0
29 srev = ctx.extra().get('convert_revision') 23 srev = ctx.extra().get('convert_revision')
31 raise hgutil.Abort('revision %s not from SVN' % ctx) 25 raise hgutil.Abort('revision %s not from SVN' % ctx)
32 26
33 srev = int(srev.split('@')[1]) 27 srev = int(srev.split('@')[1])
34 ui.write('verifying %s against r%i\n' % (ctx, srev)) 28 ui.write('verifying %s against r%i\n' % (ctx, srev))
35 29
36 url = util.normalize_url(url.rstrip('/')) 30
37 user, passwd = util.getuserpass(ui) 31 url = repo.ui.expandpath('default')
38 svn = svnwrap.SubversionRepo(url, user, passwd) 32 if args:
33 url = args[0]
34 svn = svnrepo.svnremoterepo(ui, url).svn
39 35
40 btypes = {'default': 'trunk'} 36 btypes = {'default': 'trunk'}
41 branchpath = btypes.get(ctx.branch(), 'branches/%s' % ctx.branch()) 37 branchpath = btypes.get(ctx.branch(), 'branches/%s' % ctx.branch())
42 svnfiles = set() 38 svnfiles = set()
43 result = 0 39 result = 0
70 dest = None 66 dest = None
71 if len(args) == 1: 67 if len(args) == 1:
72 dest = args[0] 68 dest = args[0]
73 elif len(args) > 1: 69 elif len(args) > 1:
74 raise hgutil.Abort('rebuildmeta takes 1 or no arguments') 70 raise hgutil.Abort('rebuildmeta takes 1 or no arguments')
71 uuid = None
75 url = repo.ui.expandpath(dest or 'default-push', dest or 'default') 72 url = repo.ui.expandpath(dest or 'default-push', dest or 'default')
76 uuid = None 73 svn = svnrepo.svnremoterepo(ui, url).svn
77 url = util.normalize_url(url.rstrip('/'))
78 user, passwd = util.getuserpass(ui)
79 svn = svnwrap.SubversionRepo(url, user, passwd)
80 subdir = svn.subdir 74 subdir = svn.subdir
81 svnmetadir = os.path.join(repo.path, 'svn') 75 svnmetadir = os.path.join(repo.path, 'svn')
82 if not os.path.exists(svnmetadir): 76 if not os.path.exists(svnmetadir):
83 os.makedirs(svnmetadir) 77 os.makedirs(svnmetadir)
84 78
222 """update to a specified Subversion revision number 216 """update to a specified Subversion revision number
223 """ 217 """
224 218
225 assert len(args) == 1 219 assert len(args) == 1
226 rev = int(args[0]) 220 rev = int(args[0])
227 meta = svnmeta.SVNMeta(repo) 221 meta = repo.svnmeta()
228 222
229 answers = [] 223 answers = []
230 for k, v in meta.revmap.iteritems(): 224 for k, v in meta.revmap.iteritems():
231 if k[0] == rev: 225 if k[0] == rev:
232 answers.append((v, k[1])) 226 answers.append((v, k[1]))