Rev 358: Add tests for load_dumpfile. in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev
Jelmer Vernooij
jelmer at samba.org
Tue Jan 2 00:46:29 GMT 2007
------------------------------------------------------------
revno: 358
revision-id: jelmer at samba.org-20070102004553-kz46oy53p72cgm6j
parent: jelmer at samba.org-20070101221853-z74gmy058bm6z1j0
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Tue 2007-01-02 01:45:53 +0100
message:
Add tests for load_dumpfile.
modified:
convert.py svn2bzr.py-20051018015439-cb4563bff29e632d
tests/test_convert.py test_convert.py-20060705203611-b1l0bapeku6foco0-1
=== modified file 'convert.py'
--- a/convert.py 2007-01-01 17:00:10 +0000
+++ b/convert.py 2007-01-02 00:45:53 +0000
@@ -53,6 +53,13 @@
except NoSuchFile:
needed.append((transport, urlutils.dirname(relpath)))
+
+class NotDumpFile(BzrError):
+ _fmt = """%(dumpfile)s is not a dump file."""
+ def __init__(self, dumpfile):
+ self.dumpfile = dumpfile
+
+
def load_dumpfile(dumpfile, outputdir):
import svn
from svn.core import SubversionException
@@ -62,8 +69,8 @@
file = open(dumpfile)
svn.repos.load_fs2(repos, file, StringIO(),
svn.repos.load_uuid_default, '', 0, 0, None)
- except SubversionException, (svn.core.SVN_ERR_STREAM_MALFORMED_DATA, _):
- raise BzrError("%s is not a dump file" % dumpfile)
+ except SubversionException, (svn.core.SVN_ERR_STREAM_MALFORMED_DATA, _):
+ raise NotDumpFile(dumpfile)
return repos
=== modified file 'tests/test_convert.py'
--- a/tests/test_convert.py 2007-01-01 16:07:12 +0000
+++ b/tests/test_convert.py 2007-01-02 00:45:53 +0000
@@ -18,14 +18,47 @@
from bzrlib.bzrdir import BzrDir
from bzrlib.errors import NotBranchError
from bzrlib.repository import Repository
+from bzrlib.tests import TestCase, TestCaseInTempDir
from bzrlib.trace import mutter
import os
-from convert import convert_repository
+from convert import convert_repository, NotDumpFile, load_dumpfile
from repository import MAPPING_VERSION
from scheme import TrunkBranchingScheme, NoBranchingScheme
from tests import TestCaseWithSubversionRepository
+import svn.repos
+
+class TestLoadDumpfile(TestCaseInTempDir):
+ def test_loaddumpfile(self):
+ dumpfile = os.path.join(self.test_dir, "dumpfile")
+ open(dumpfile, 'w').write(
+"""SVN-fs-dump-format-version: 2
+
+UUID: 6987ef2d-cd6b-461f-9991-6f1abef3bd59
+
+Revision-number: 0
+Prop-content-length: 56
+Content-length: 56
+
+K 8
+svn:date
+V 27
+2006-07-02T13:14:51.972532Z
+PROPS-END
+""")
+ load_dumpfile(dumpfile, "d")
+ repos = svn.repos.open("d")
+ fs = svn.repos.fs(repos)
+ self.assertEqual("6987ef2d-cd6b-461f-9991-6f1abef3bd59",
+ svn.fs.get_uuid(fs))
+
+ def test_loaddumpfile_invalid(self):
+ dumpfile = os.path.join(self.test_dir, "dumpfile")
+ open(dumpfile, 'w').write("""FooBar""")
+ self.assertRaises(NotDumpFile, load_dumpfile, dumpfile, "d")
+
+
class TestConversion(TestCaseWithSubversionRepository):
def setUp(self):
super(TestConversion, self).setUp()
More information about the bazaar-commits
mailing list