svncommands: make repo optional (useful for things like listauthors)

This commit is contained in:
Dirkjan Ochtman 2010-02-23 17:16:51 +01:00
parent 6b15b9efbb
commit 525ead6e57
7 changed files with 32 additions and 12 deletions

View File

@ -124,10 +124,9 @@ def svn(ui, repo, subcommand, *args, **opts):
if key in opts:
ui.setconfig('hgsubversion', key, opts[key])
path = os.path.dirname(repo.path)
try:
commandfunc = svncommands.table[subcommand]
return commandfunc(ui, args=args, hg_repo_path=path, repo=repo, **opts)
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'
@ -162,6 +161,8 @@ hg.schemes.update({ 'file': _lookup, 'http': svnrepo, 'https': svnrepo,
'svn': svnrepo, 'svn+ssh': svnrepo, 'svn+http': svnrepo,
'svn+https': svnrepo})
commands.optionalrepo += ' svn'
cmdtable = {
"svn":
(svn,

View File

@ -125,7 +125,7 @@ class TagMap(dict):
repo.ui.warn('tag map outdated, running rebuildmeta...\n')
f.close()
os.unlink(self.path)
svncommands.rebuildmeta(repo.ui, repo, os.path.dirname(repo.path), ())
svncommands.rebuildmeta(repo.ui, repo, ())
return
elif ver != self.VERSION:
print 'tagmap too new -- please upgrade'

View File

@ -5,6 +5,7 @@ import cPickle as pickle
from mercurial import hg
from mercurial import node
from mercurial import util as hgutil
from mercurial import error
import maps
import svnwrap
@ -13,10 +14,14 @@ import util
import utility_commands
import svnexternals
def verify(ui, repo, *args, **opts):
'''verify current revision against Subversion repository
'''
if repo is None:
raise error.RepoError("There is no Mercurial repository"
" here (.hg not found)")
ctx = repo[opts.get('rev', '.')]
if 'close' in ctx.extra():
ui.write('cannot verify closed branch')
@ -67,9 +72,14 @@ def verify(ui, repo, *args, **opts):
return result
def rebuildmeta(ui, repo, hg_repo_path, args, **opts):
def rebuildmeta(ui, repo, args, **opts):
"""rebuild hgsubversion metadata using values stored in revisions
"""
if repo is None:
raise error.RepoError("There is no Mercurial repository"
" here (.hg not found)")
dest = None
if len(args) == 1:
dest = args[0]

View File

@ -1,6 +1,7 @@
import os
from mercurial import util as hgutil
from mercurial import error
import svnwrap
import svnrepo
@ -9,6 +10,11 @@ import util
def genignore(ui, repo, force=False, **opts):
"""generate .hgignore from svn:ignore properties.
"""
if repo is None:
raise error.RepoError("There is no Mercurial repository"
" here (.hg not found)")
ignpath = repo.wjoin('.hgignore')
if not force and os.path.exists(ignpath):
raise hgutil.Abort('not overwriting existing .hgignore, try --force?')
@ -35,9 +41,14 @@ def genignore(ui, repo, force=False, **opts):
repo.wopener('.hgignore', 'w').write('\n'.join(ignorelines) + '\n')
def info(ui, repo, hg_repo_path, **opts):
def info(ui, repo, **opts):
"""show Subversion details similar to `svn info'
"""
if repo is None:
raise error.RepoError("There is no Mercurial repository"
" here (.hg not found)")
meta = repo.svnmeta()
hashes = meta.revmap.hashes()

View File

@ -22,7 +22,6 @@ def _do_case(self, name, stupid, single):
src, dest = hg.clone(u, self.wc_path, wc2_path, update=False)
svncommands.rebuildmeta(u,
dest,
os.path.dirname(dest.path),
args=[test_util.fileurl(self.repo_path +
subdir), ])
self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')),

View File

@ -116,7 +116,6 @@ rename a tag
src, dest = hg.clone(repo.ui, self.wc_path, wc2_path, update=False)
svncommands.rebuildmeta(repo.ui,
dest,
os.path.dirname(dest.path),
args=[test_util.fileurl(self.repo_path), ])
commands.pull(self.repo.ui, self.repo, stupid=stupid)
dtags, srctags = dest.tags(), self.repo.tags()

View File

@ -34,7 +34,7 @@ class UtilityTests(test_util.TestBase):
hg.update(self.repo, 'the_branch')
u = ui.ui()
u.pushbuffer()
utility_commands.info(u, self.repo, self.wc_path)
utility_commands.info(u, self.repo)
actual = u.popbuffer()
expected = (expected_info_output %
{'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)',
@ -45,7 +45,7 @@ class UtilityTests(test_util.TestBase):
self.assertEqual(actual, expected)
hg.update(self.repo, 'default')
u.pushbuffer()
utility_commands.info(u, self.repo, self.wc_path)
utility_commands.info(u, self.repo)
actual = u.popbuffer()
expected = (expected_info_output %
{'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)',
@ -56,7 +56,7 @@ class UtilityTests(test_util.TestBase):
self.assertEqual(actual, expected)
hg.update(self.repo, 'default')
u.pushbuffer()
utility_commands.info(u, self.repo, self.wc_path, rev=3)
utility_commands.info(u, self.repo, rev=3)
actual = u.popbuffer()
expected = (expected_info_output %
{'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)',
@ -71,7 +71,7 @@ class UtilityTests(test_util.TestBase):
hg.update(self.repo, 'tip')
u = ui.ui()
u.pushbuffer()
utility_commands.info(u, self.repo, self.wc_path)
utility_commands.info(u, self.repo)
actual = u.popbuffer()
expected = (expected_info_output %
{'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)',