mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
svncommands: make repo optional (useful for things like listauthors)
This commit is contained in:
parent
6b15b9efbb
commit
525ead6e57
@ -124,10 +124,9 @@ def svn(ui, repo, subcommand, *args, **opts):
|
|||||||
if key in opts:
|
if key in opts:
|
||||||
ui.setconfig('hgsubversion', key, opts[key])
|
ui.setconfig('hgsubversion', key, opts[key])
|
||||||
|
|
||||||
path = os.path.dirname(repo.path)
|
|
||||||
try:
|
try:
|
||||||
commandfunc = svncommands.table[subcommand]
|
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:
|
except core.SubversionException, e:
|
||||||
if e.apr_err == core.SVN_ERR_RA_SERF_SSL_CERT_UNTRUSTED:
|
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'
|
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': svnrepo, 'svn+ssh': svnrepo, 'svn+http': svnrepo,
|
||||||
'svn+https': svnrepo})
|
'svn+https': svnrepo})
|
||||||
|
|
||||||
|
commands.optionalrepo += ' svn'
|
||||||
|
|
||||||
cmdtable = {
|
cmdtable = {
|
||||||
"svn":
|
"svn":
|
||||||
(svn,
|
(svn,
|
||||||
|
@ -125,7 +125,7 @@ class TagMap(dict):
|
|||||||
repo.ui.warn('tag map outdated, running rebuildmeta...\n')
|
repo.ui.warn('tag map outdated, running rebuildmeta...\n')
|
||||||
f.close()
|
f.close()
|
||||||
os.unlink(self.path)
|
os.unlink(self.path)
|
||||||
svncommands.rebuildmeta(repo.ui, repo, os.path.dirname(repo.path), ())
|
svncommands.rebuildmeta(repo.ui, repo, ())
|
||||||
return
|
return
|
||||||
elif ver != self.VERSION:
|
elif ver != self.VERSION:
|
||||||
print 'tagmap too new -- please upgrade'
|
print 'tagmap too new -- please upgrade'
|
||||||
|
@ -5,6 +5,7 @@ import cPickle as pickle
|
|||||||
from mercurial import hg
|
from mercurial import hg
|
||||||
from mercurial import node
|
from mercurial import node
|
||||||
from mercurial import util as hgutil
|
from mercurial import util as hgutil
|
||||||
|
from mercurial import error
|
||||||
|
|
||||||
import maps
|
import maps
|
||||||
import svnwrap
|
import svnwrap
|
||||||
@ -13,10 +14,14 @@ import util
|
|||||||
import utility_commands
|
import utility_commands
|
||||||
import svnexternals
|
import svnexternals
|
||||||
|
|
||||||
|
|
||||||
def verify(ui, repo, *args, **opts):
|
def verify(ui, repo, *args, **opts):
|
||||||
'''verify current revision against Subversion repository
|
'''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', '.')]
|
ctx = repo[opts.get('rev', '.')]
|
||||||
if 'close' in ctx.extra():
|
if 'close' in ctx.extra():
|
||||||
ui.write('cannot verify closed branch')
|
ui.write('cannot verify closed branch')
|
||||||
@ -67,9 +72,14 @@ def verify(ui, repo, *args, **opts):
|
|||||||
return result
|
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
|
"""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
|
dest = None
|
||||||
if len(args) == 1:
|
if len(args) == 1:
|
||||||
dest = args[0]
|
dest = args[0]
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from mercurial import util as hgutil
|
from mercurial import util as hgutil
|
||||||
|
from mercurial import error
|
||||||
|
|
||||||
import svnwrap
|
import svnwrap
|
||||||
import svnrepo
|
import svnrepo
|
||||||
@ -9,6 +10,11 @@ import util
|
|||||||
def genignore(ui, repo, force=False, **opts):
|
def genignore(ui, repo, force=False, **opts):
|
||||||
"""generate .hgignore from svn:ignore properties.
|
"""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')
|
ignpath = repo.wjoin('.hgignore')
|
||||||
if not force and os.path.exists(ignpath):
|
if not force and os.path.exists(ignpath):
|
||||||
raise hgutil.Abort('not overwriting existing .hgignore, try --force?')
|
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')
|
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'
|
"""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()
|
meta = repo.svnmeta()
|
||||||
hashes = meta.revmap.hashes()
|
hashes = meta.revmap.hashes()
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ def _do_case(self, name, stupid, single):
|
|||||||
src, dest = hg.clone(u, self.wc_path, wc2_path, update=False)
|
src, dest = hg.clone(u, self.wc_path, wc2_path, update=False)
|
||||||
svncommands.rebuildmeta(u,
|
svncommands.rebuildmeta(u,
|
||||||
dest,
|
dest,
|
||||||
os.path.dirname(dest.path),
|
|
||||||
args=[test_util.fileurl(self.repo_path +
|
args=[test_util.fileurl(self.repo_path +
|
||||||
subdir), ])
|
subdir), ])
|
||||||
self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')),
|
self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')),
|
||||||
|
@ -116,7 +116,6 @@ rename a tag
|
|||||||
src, dest = hg.clone(repo.ui, self.wc_path, wc2_path, update=False)
|
src, dest = hg.clone(repo.ui, self.wc_path, wc2_path, update=False)
|
||||||
svncommands.rebuildmeta(repo.ui,
|
svncommands.rebuildmeta(repo.ui,
|
||||||
dest,
|
dest,
|
||||||
os.path.dirname(dest.path),
|
|
||||||
args=[test_util.fileurl(self.repo_path), ])
|
args=[test_util.fileurl(self.repo_path), ])
|
||||||
commands.pull(self.repo.ui, self.repo, stupid=stupid)
|
commands.pull(self.repo.ui, self.repo, stupid=stupid)
|
||||||
dtags, srctags = dest.tags(), self.repo.tags()
|
dtags, srctags = dest.tags(), self.repo.tags()
|
||||||
|
@ -34,7 +34,7 @@ class UtilityTests(test_util.TestBase):
|
|||||||
hg.update(self.repo, 'the_branch')
|
hg.update(self.repo, 'the_branch')
|
||||||
u = ui.ui()
|
u = ui.ui()
|
||||||
u.pushbuffer()
|
u.pushbuffer()
|
||||||
utility_commands.info(u, self.repo, self.wc_path)
|
utility_commands.info(u, self.repo)
|
||||||
actual = u.popbuffer()
|
actual = u.popbuffer()
|
||||||
expected = (expected_info_output %
|
expected = (expected_info_output %
|
||||||
{'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)',
|
{'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)
|
self.assertEqual(actual, expected)
|
||||||
hg.update(self.repo, 'default')
|
hg.update(self.repo, 'default')
|
||||||
u.pushbuffer()
|
u.pushbuffer()
|
||||||
utility_commands.info(u, self.repo, self.wc_path)
|
utility_commands.info(u, self.repo)
|
||||||
actual = u.popbuffer()
|
actual = u.popbuffer()
|
||||||
expected = (expected_info_output %
|
expected = (expected_info_output %
|
||||||
{'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)',
|
{'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)
|
self.assertEqual(actual, expected)
|
||||||
hg.update(self.repo, 'default')
|
hg.update(self.repo, 'default')
|
||||||
u.pushbuffer()
|
u.pushbuffer()
|
||||||
utility_commands.info(u, self.repo, self.wc_path, rev=3)
|
utility_commands.info(u, self.repo, rev=3)
|
||||||
actual = u.popbuffer()
|
actual = u.popbuffer()
|
||||||
expected = (expected_info_output %
|
expected = (expected_info_output %
|
||||||
{'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)',
|
{'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')
|
hg.update(self.repo, 'tip')
|
||||||
u = ui.ui()
|
u = ui.ui()
|
||||||
u.pushbuffer()
|
u.pushbuffer()
|
||||||
utility_commands.info(u, self.repo, self.wc_path)
|
utility_commands.info(u, self.repo)
|
||||||
actual = u.popbuffer()
|
actual = u.popbuffer()
|
||||||
expected = (expected_info_output %
|
expected = (expected_info_output %
|
||||||
{'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)',
|
{'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)',
|
||||||
|
Loading…
Reference in New Issue
Block a user