Rev 360: More tests! in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev

Jelmer Vernooij jelmer at samba.org
Tue Jan 2 02:40:15 GMT 2007


------------------------------------------------------------
revno: 360
revision-id: jelmer at samba.org-20070102023936-utvizor7j13a0rze
parent: jelmer at samba.org-20070102011143-vht8hgu5s3kmuxf3
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Tue 2007-01-02 03:39:36 +0100
message:
  More tests!
modified:
  branch.py                      svnbranch.py-20051017135706-11c749eb0dab04a7
  fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
  logwalker.py                   logwalker.py-20060621215743-c13fhfnyzh1xzwh2-1
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
  tests/test_branch.py           test_branch.py-20060508162215-74ffeb5d608f8e20
  tests/test_checkout.py         test_checkout.py-20070101154110-eevkc29qj0q7udz5-1
  tests/test_radir.py            test_radir.py-20061231173434-31utf9o4byu7wktm-1
  tests/test_repos.py            test_repos.py-20060508151940-ddc49a59257ca712
  tests/test_scheme.py           test_scheme.py-20060621221855-va2xabhlxpmc9llx-1
  tests/test_transport.py        test_transport.py-20060621232111-xh7xvoblzsrgj79t-1
  tree.py                        tree.py-20060624222557-dudlwqcmkf22lt2s-1
=== modified file 'branch.py'
--- a/branch.py	2007-01-02 01:11:43 +0000
+++ b/branch.py	2007-01-02 02:39:36 +0000
@@ -118,14 +118,17 @@
         self._revision_history.reverse()
 
     def get_root_id(self):
-        inv = self.repository.get_inventory(self.last_revision())
+        if self.last_revision() is None:
+            inv = Inventory()
+        else:
+            inv = self.repository.get_inventory(self.last_revision())
         return inv.root.file_id
 
     def _get_nick(self):
         try:
             if self.branch_path == "":
                 return None
-            return self.branch_path
+            return self.branch_path.strip("/")
         except ValueError:
             return None
 

=== modified file 'fetch.py'
--- a/fetch.py	2007-01-01 22:18:53 +0000
+++ b/fetch.py	2007-01-02 02:39:36 +0000
@@ -89,9 +89,6 @@
         self.inventory.revision_id = self.revid
         return ROOT_ID
 
-    def relpath(self, path):
-        return path.strip("/")
-
     def _get_existing_id(self, parent_id, path):
         if self.id_map.has_key(path):
             return self.id_map[path]
@@ -281,7 +278,6 @@
     """Svn to any repository actions."""
 
     _matching_repo_format = SvnRepositoryFormat()
-    """The format to test with."""
 
     @needs_write_lock
     def copy_content(self, revision_id=None, basis=None):

=== modified file 'logwalker.py'
--- a/logwalker.py	2007-01-01 06:30:20 +0000
+++ b/logwalker.py	2007-01-02 02:39:36 +0000
@@ -211,8 +211,6 @@
         if revnum > self.saved_revnum:
             self.fetch_revisions(revnum)
         (author, message, date) = self.db.execute("select author, message, date from revision where revno="+ str(revnum)).fetchone()
-        if author is None:
-            author = None
         return (author, _escape_commit_message(base64.b64decode(message)), date)
 
     def find_latest_change(self, path, revnum, recurse=False):

=== modified file 'repository.py'
--- a/repository.py	2007-01-01 22:18:53 +0000
+++ b/repository.py	2007-01-02 02:39:36 +0000
@@ -119,24 +119,6 @@
     return "%s%d@%s-%s" % (REVISION_ID_PREFIX, revnum, uuid, escape_svn_path(path.strip("/")))
 
 
-def parse_revision_id(self, revid):
-    """Parse an existing Subversion-based revision id.
-
-    :param revid: The revision id.
-    :raises: NoSuchRevision
-    :return: Tuple with branch path and revision number.
-    """
-    try:
-        (uuid, branch_path, revnum) = parse_svn_revision_id(revid)
-    except InvalidRevisionId:
-        raise NoSuchRevision(self, revid)
-
-    if uuid != self.uuid:
-        raise NoSuchRevision(self, revid)
-
-    return (branch_path, revnum)
-
-
 def svk_feature_to_revision_id(feature):
     """Create a revision id from a svk feature identifier.
 

=== modified file 'tests/test_branch.py'
--- a/tests/test_branch.py	2007-01-02 01:11:43 +0000
+++ b/tests/test_branch.py	2007-01-02 02:39:36 +0000
@@ -17,6 +17,7 @@
 from bzrlib.branch import Branch
 from bzrlib.bzrdir import BzrDir, BzrDirTestProviderAdapter, BzrDirFormat
 from bzrlib.errors import NoSuchFile
+from bzrlib.inventory import ROOT_ID
 from bzrlib.repository import Repository
 from bzrlib.trace import mutter
 
@@ -63,6 +64,11 @@
         branch = Branch.open("svn+"+repos_url)
         self.assertRaises(NotImplementedError, branch.set_revision_history, [])
 
+    def test_get_root_id(self):
+        repos_url = self.make_client('a', 'dc')
+        branch = Branch.open("svn+"+repos_url)
+        self.assertEqual(ROOT_ID, branch.get_root_id())
+
     def test_set_push_location(self):
         repos_url = self.make_client('a', 'dc')
         branch = Branch.open("svn+"+repos_url)
@@ -121,6 +127,17 @@
 
         self.assertIs(None, branch.nick)
 
+    def test_get_nick_path(self):
+        repos_url = self.make_client('a', 'dc')
+
+        self.build_tree({'dc/trunk': "data"})
+        self.client_add("dc/trunk")
+        self.client_commit("dc", "My Message")
+
+        branch = Branch.open("svn+"+repos_url+"/trunk")
+
+        self.assertEqual("trunk", branch.nick)
+
     def test_get_revprops(self):
         repos_url = self.make_client('a', 'dc')
 

=== modified file 'tests/test_checkout.py'
--- a/tests/test_checkout.py	2007-01-01 15:41:47 +0000
+++ b/tests/test_checkout.py	2007-01-02 02:39:36 +0000
@@ -18,10 +18,27 @@
 from bzrlib.errors import NoRepositoryPresent
 from bzrlib.tests import TestCase
 
+from checkout import SvnWorkingTreeFormat
 from format import SvnRemoteAccess
 from repository import SvnRepository
 from tests import TestCaseWithSubversionRepository
 
+class TestWorkingTreeFormat(TestCase):
+    def setUp(self):
+        super(TestWorkingTreeFormat, self).setUp()
+        self.format = SvnWorkingTreeFormat()
+
+    def test_get_format_desc(self):
+        self.assertEqual("Subversion Working Copy", 
+                         self.format.get_format_description())
+
+    def test_initialize(self):
+        self.assertRaises(NotImplementedError, self.format.initialize, None)
+
+    def test_open(self):
+        self.assertRaises(NotImplementedError, self.format.open, None)
+
+
 class TestCheckout(TestCaseWithSubversionRepository):
     def test_not_for_writing(self):
         repos_url = self.make_client("d", "dc")

=== modified file 'tests/test_radir.py'
--- a/tests/test_radir.py	2006-12-31 20:03:11 +0000
+++ b/tests/test_radir.py	2007-01-02 02:39:36 +0000
@@ -15,14 +15,40 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 from bzrlib.bzrdir import BzrDir
-from bzrlib.errors import NoRepositoryPresent
+from bzrlib.errors import NoRepositoryPresent, NotBranchError, NotLocalUrl
 from bzrlib.tests import TestCase
+from bzrlib.transport import get_transport
 
 from format import SvnRemoteAccess
 from repository import SvnRepository
 from tests import TestCaseWithSubversionRepository
 
 class TestRemoteAccess(TestCaseWithSubversionRepository):
+    def test_clone(self):
+        repos_url = self.make_client("d", "dc")
+        self.build_tree({"dc/foo": None})
+        self.client_add("dc/foo")
+        self.client_commit("dc", "msg")
+        x = BzrDir.open("dc")
+        self.assertRaises(NotImplementedError, x.clone, "dir")
+
+    def test_open_workingtree(self):
+        repos_url = self.make_client("d", "dc")
+        x = BzrDir.open(repos_url)
+        self.assertRaises(NotLocalUrl, x.open_workingtree)
+
+    def test_create_workingtree(self):
+        repos_url = self.make_client("d", "dc")
+        x = BzrDir.open(repos_url)
+        self.assertRaises(NotLocalUrl, x.create_workingtree)
+
+    def test_bad_dir(self):
+        repos_url = self.make_client("d", "dc")
+        self.build_tree({"dc/foo": None})
+        self.client_add("dc/foo")
+        self.client_commit("dc", "msg")
+        self.assertRaises(NotBranchError, BzrDir.open, repos_url+"/foo")
+
     def test_create(self):
         repos_url = self.make_client("d", "dc")
         x = BzrDir.open(repos_url)

=== modified file 'tests/test_repos.py'
--- a/tests/test_repos.py	2007-01-01 21:49:06 +0000
+++ b/tests/test_repos.py	2007-01-02 02:39:36 +0000
@@ -61,6 +61,21 @@
 
         self.assertEqual(1, len(list(repos.follow_branch_history("", 1))))
 
+    def test_make_working_trees(self):
+        repos_url = self.make_client("a", "dc")
+        repos = Repository.open(repos_url)
+        self.assertFalse(repos.make_working_trees())
+
+    def test_repr(self):
+        repos_url = self.make_client("a", "dc")
+        self.build_tree({'dc/foo': "data"})
+        self.client_add("dc/foo")
+        self.client_commit("dc", "My Message")
+
+        repos = Repository.open(repos_url)
+
+        self.assertEqual("SvnRepository('file://%s/')" % os.path.join(self.test_dir, "a"), repos.__repr__())
+
     def test_get_branch_invalid_revision(self):
         repos_url = self.make_client("a", "dc")
         repos = Repository.open(repos_url)
@@ -444,6 +459,13 @@
         self.assertEqual(("bloe", 0), 
             repository.parse_revision_id(
                 "svn-v%d:0@%s-bloe" % (MAPPING_VERSION, repository.uuid)))
+
+    def test_parse_revision_id_invalid_uuid(self):
+        repos_url = self.make_client('d', 'dc')
+        repository = Repository.open("svn+%s" % repos_url)
+        self.assertRaises(NoSuchRevision, 
+            repository.parse_revision_id, 
+                "svn-v%d:0 at invaliduuid-bloe" % MAPPING_VERSION)
         
     def test_check(self):
         repos_url = self.make_client('d', 'dc')

=== modified file 'tests/test_scheme.py'
--- a/tests/test_scheme.py	2006-12-28 17:01:54 +0000
+++ b/tests/test_scheme.py	2007-01-02 02:39:36 +0000
@@ -57,6 +57,9 @@
 
 
 class NoScheme(TestCase):
+    def test_str(self):
+        self.assertEqual("null", NoBranchingScheme().__str__())
+
     def test_is_branch_empty(self):
         self.assertTrue(NoBranchingScheme().is_branch(""))
 
@@ -275,3 +278,8 @@
         self.assertIsInstance(scheme, TrunkBranchingScheme)
         self.assertEqual(0, scheme.level)
 
+    def test_str0(self):
+        self.assertEqual("trunk0", TrunkBranchingScheme().__str__())
+
+    def test_str1(self):
+        self.assertEqual("trunk1", TrunkBranchingScheme(1).__str__())

=== modified file 'tests/test_transport.py'
--- a/tests/test_transport.py	2006-12-31 20:03:11 +0000
+++ b/tests/test_transport.py	2007-01-02 02:39:36 +0000
@@ -91,6 +91,19 @@
         t = SvnRaTransport(repos_url)
         self.assertEqual("%s/dir" % repos_url, t.clone('dir').base)
 
+    def test_clone_none(self):
+        repos_url = self.make_client('d', 'dc')
+        self.build_tree({"dc/dir": None, "dc/bl": "data"})
+        self.client_add("dc/dir")
+        self.client_add("dc/bl")
+        self.client_commit("dc", "Bla")
+
+        t = SvnRaTransport(repos_url)
+        tt = t.clone()
+        self.assertEqual(tt.base, t.base)
+        tt.reparent(os.path.join(t.base, "dir"))
+        self.assertNotEqual(tt.base, t.base)
+
     def test_mkdir(self):
         repos_url = self.make_client('d', 'dc')
         t = SvnRaTransport(repos_url)

=== modified file 'tree.py'
--- a/tree.py	2007-01-01 21:49:06 +0000
+++ b/tree.py	2007-01-02 02:39:36 +0000
@@ -97,12 +97,6 @@
     def open_root(self, revnum, baton):
         return ROOT_ID
 
-    def relpath(self, path):
-        bp, rp = self.tree._repository.scheme.unprefix(path)
-        if bp == self.tree.branch_path:
-            return rp
-        return None
-
     def add_directory(self, path, parent_baton, copyfrom_path, copyfrom_revnum, pool):
         file_id, revision_id = self.tree.id_map[path]
         ie = self.tree._inventory.add_path(path, 'directory', file_id)




More information about the bazaar-commits mailing list