-# Copyright (C) 2005-2006 Jelmer Vernooij <jelmer@samba.org>
+# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
import unittest
import bzrlib
-__version__ = '0.3.0'
-required_bzr_version = (0,15)
+from bzrlib.trace import warning
+
+__version__ = '0.4.0'
+COMPATIBLE_BZR_VERSIONS = [(0, 15), (0, 16), (0, 17)]
def check_bzrlib_version(desired):
"""Check that bzrlib is compatible.
- If version is < desired version, assume incompatible.
- If version == desired version, assume completely compatible
- If version == desired version + 1, assume compatible, with deprecations
+ If version is < all compatible version, assume incompatible.
+ If version is compatible version + 1, assume compatible, with deprecations
Otherwise, assume incompatible.
"""
- desired_plus = (desired[0], desired[1]+1)
bzrlib_version = bzrlib.version_info[:2]
- if bzrlib_version == desired:
+ if bzrlib_version in desired:
return
- try:
- from bzrlib.trace import warning
- except ImportError:
- # get the message out any way we can
- from warnings import warn as warning
- if bzrlib_version < desired:
+ if bzrlib_version < desired[0]:
warning('Installed bzr version %s is too old to be used with bzr-svn'
' %s.' % (bzrlib.__version__, __version__))
# Not using BzrNewError, because it may not exist.
warning('bzr-svn is not up to date with installed bzr version %s.'
' \nThere should be a newer version of bzr-svn available.'
% (bzrlib.__version__))
- if bzrlib_version != desired_plus:
+ if not (bzrlib_version[0], bzrlib_version[1]-1) in desired:
raise Exception, 'Version mismatch'
def check_subversion_version():
"""Check that Subversion is compatible.
"""
- from bzrlib.trace import warning
- try:
- from svn.delta import svn_delta_invoke_txdelta_window_handler
- except:
- warning('Installed Subversion version does not have updated Python bindings. See the bzr-svn README for details.')
+ import svn.delta
+ if not hasattr(svn.delta, 'svn_delta_invoke_txdelta_window_handler'):
+ warning('Installed Subversion version does not have updated Python '
+ 'bindings. See the bzr-svn README for details.')
raise bzrlib.errors.BzrError("incompatible python subversion bindings")
-check_bzrlib_version(required_bzr_version)
+check_bzrlib_version(COMPATIBLE_BZR_VERSIONS)
check_subversion_version()
import branch
import transport
import checkout
-def convert_svn_exception(unbound):
- """Decorator that catches particular Subversion exceptions and
- converts them to Bazaar exceptions.
- """
- def convert(self, *args, **kwargs):
- try:
- unbound(self, *args, **kwargs)
- except SubversionException, (msg, num):
- if num == svn.core.SVN_ERR_RA_SVN_CONNECTION_CLOSED:
- raise ConnectionReset(msg=msg)
- else:
- raise
-
- convert.__doc__ = unbound.__doc__
- convert.__name__ = unbound.__name__
- return convert
-
from bzrlib.transport import register_transport
register_transport('svn://', transport.SvnRaTransport)
register_transport('svn+', transport.SvnRaTransport)
from bzrlib.repository import InterRepository
-from fetch import InterSvnRepository
+from fetch import InterFromSvnRepository
+from commit import InterToSvnRepository
BzrDirFormat.register_control_format(format.SvnFormat)
+import svn.core
+_subr_version = svn.core.svn_subr_version()
+
BzrDirFormat.register_control_format(checkout.SvnWorkingTreeDirFormat)
-InterRepository.register_optimiser(InterSvnRepository)
+InterRepository.register_optimiser(InterFromSvnRepository)
+InterRepository.register_optimiser(InterToSvnRepository)
from bzrlib.branch import Branch
from bzrlib.commands import Command, register_command, display_command, Option
takes_args = ['from_location', 'to_location?']
takes_options = [Option('trees', help='Create working trees'),
Option('shared', help='Create shared repository'),
- Option('all', help='Convert all revisions, even those not in current branch history (implies --shared)'),
+ Option('all',
+ help='Convert all revisions, even those not in '
+ 'current branch history (implies --shared)'),
Option('scheme', type=get_scheme,
help='Branching scheme (none, trunk, or trunk-INT)')]
def test_suite():
- from unittest import TestSuite, TestLoader
+ from unittest import TestSuite
import tests
-
suite = TestSuite()
-
suite.addTest(tests.test_suite())
-
return suite
if __name__ == '__main__':
print ("This is a Bazaar plugin. Copy this directory to ~/.bazaar/plugins "
"to use it.\n")
+ runner = unittest.TextTestRunner()
+ runner.run(test_suite())
else:
- sys.path.append(os.path.dirname(__file__))
-
+ sys.path.append(os.path.dirname(os.path.abspath(__file__)))