comparison hgsubversion/wrappers.py @ 463:c82d5a9acecf

Unify svn credentials handling as config entries It has 2 benefits: - It generalizes the use of hgsubversion.username/password initiated in push/pull. - Command line options are no longer need to create SubversionRepo, so we can move this out of command handling code.
author Patrick Mezard <pmezard@gmail.com>
date Sat, 18 Jul 2009 20:44:33 -0500
parents db3a53a2cd76
children 0f7095f53ca3
comparison
equal deleted inserted replaced
462:e43e4d506e4d 463:c82d5a9acecf
51 source, revs, checkout = hg.parseurl(ui.expandpath(source)) 51 source, revs, checkout = hg.parseurl(ui.expandpath(source))
52 other = hg.repository(ui, source) 52 other = hg.repository(ui, source)
53 if 'subversion' not in other.capabilities: 53 if 'subversion' not in other.capabilities:
54 return orig(ui, repo, source, **opts) 54 return orig(ui, repo, source, **opts)
55 55
56 user, passwd = util.getuserpass(opts) 56 user, passwd = util.getuserpass(ui)
57 svn = svnwrap.SubversionRepo(other.svnurl, user, passwd) 57 svn = svnwrap.SubversionRepo(other.svnurl, user, passwd)
58 meta = svnmeta.SVNMeta(repo) 58 meta = svnmeta.SVNMeta(repo)
59 59
60 ui.status('incoming changes from %s\n' % other.svnurl) 60 ui.status('incoming changes from %s\n' % other.svnurl)
61 for r in svn.revisions(start=meta.revmap.seen): 61 for r in svn.revisions(start=meta.revmap.seen):
117 svnurl = util.normalize_url(repo.ui.expandpath(dest.svnurl)) 117 svnurl = util.normalize_url(repo.ui.expandpath(dest.svnurl))
118 old_encoding = util.swap_out_encoding() 118 old_encoding = util.swap_out_encoding()
119 # split of #rev; TODO: implement --rev/#rev support 119 # split of #rev; TODO: implement --rev/#rev support
120 svnurl, revs, checkout = hg.parseurl(svnurl, revs) 120 svnurl, revs, checkout = hg.parseurl(svnurl, revs)
121 # TODO: do credentials specified in the URL still work? 121 # TODO: do credentials specified in the URL still work?
122 user = repo.ui.config('hgsubversion', 'username') 122 user, passwd = util.getuserpass(ui)
123 passwd = repo.ui.config('hgsubversion', 'password')
124 svn = svnwrap.SubversionRepo(svnurl, user, passwd) 123 svn = svnwrap.SubversionRepo(svnurl, user, passwd)
125 meta = svnmeta.SVNMeta(repo, svn.uuid) 124 meta = svnmeta.SVNMeta(repo, svn.uuid)
126 125
127 # Strategy: 126 # Strategy:
128 # 1. Find all outgoing commits from this head 127 # 1. Find all outgoing commits from this head
229 have_replay = False 228 have_replay = False
230 elif not have_replay: 229 elif not have_replay:
231 repo.ui.note('fetching stupidly...\n') 230 repo.ui.note('fetching stupidly...\n')
232 231
233 # TODO: do credentials specified in the URL still work? 232 # TODO: do credentials specified in the URL still work?
234 user = repo.ui.config('hgsubversion', 'username') 233 user, passwd = util.getuserpass(repo.ui)
235 passwd = repo.ui.config('hgsubversion', 'password')
236 svn = svnwrap.SubversionRepo(svn_url, user, passwd) 234 svn = svnwrap.SubversionRepo(svn_url, user, passwd)
237 meta = svnmeta.SVNMeta(repo, svn.uuid, svn.subdir) 235 meta = svnmeta.SVNMeta(repo, svn.uuid, svn.subdir)
238 236
239 start = max(meta.revmap.seen, skipto_rev) 237 start = max(meta.revmap.seen, skipto_rev)
240 initializing_repo = meta.revmap.seen <= 0 238 initializing_repo = meta.revmap.seen <= 0