Rev 391: use new fns in testsuite in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev

Jelmer Vernooij jelmer at samba.org
Tue Jan 9 04:25:32 GMT 2007


------------------------------------------------------------
revno: 391
revision-id: jelmer at samba.org-20070109042501-mxmvqxudr3il7ym6
parent: jelmer at samba.org-20070109032200-i8fd1603lsc4q1cm
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Tue 2007-01-09 05:25:01 +0100
message:
  use new fns in testsuite
modified:
  tests/test_branch.py           test_branch.py-20060508162215-74ffeb5d608f8e20
  tests/test_commit.py           test_commit.py-20060624213521-l5kcufywkh9mnilk-1
  tests/test_convert.py          test_convert.py-20060705203611-b1l0bapeku6foco0-1
  tests/test_fileids.py          test_fileids.py-20060622131341-19gyrlgqy8yl2od5-1
=== modified file 'tests/test_branch.py'
--- a/tests/test_branch.py	2007-01-09 03:22:00 +0000
+++ b/tests/test_branch.py	2007-01-09 04:25:01 +0000
@@ -29,7 +29,7 @@
 from branch import FakeControlFiles, SvnBranchFormat
 from convert import load_dumpfile
 import format
-from repository import MAPPING_VERSION
+from repository import MAPPING_VERSION, generate_svn_revision_id
 from tests import TestCaseWithSubversionRepository
 
 class WorkingSubversionBranch(TestCaseWithSubversionRepository):
@@ -58,7 +58,7 @@
         branch = bzrdir.open_branch()
         repos = bzrdir.find_repository()
 
-        self.assertEqual("svn-v%d:1@%s-" % (MAPPING_VERSION, repos.uuid), 
+        self.assertEqual(repos.generate_revision_id(1, ""), 
                 branch.last_revision())
 
         self.build_tree({'dc/foo': "data2"})
@@ -67,7 +67,7 @@
         branch = Branch.open("svn+"+repos_url)
         repos = Repository.open("svn+"+repos_url)
 
-        self.assertEqual("svn-v%d:2@%s-" % (MAPPING_VERSION, repos.uuid), 
+        self.assertEqual(repos.generate_revision_id(2, ""),
                 branch.last_revision())
 
     def test_set_revision_history(self):
@@ -136,7 +136,7 @@
         branch = Branch.open("svn+"+repos_url)
         repos = Repository.open("svn+"+repos_url)
 
-        self.assertEqual(["svn-v%d:1@%s-" % (MAPPING_VERSION, repos.uuid)], 
+        self.assertEqual([repos.generate_revision_id(1, "")], 
                 branch.revision_history())
 
         self.build_tree({'dc/foo': "data34"})
@@ -146,8 +146,8 @@
         repos = Repository.open("svn+"+repos_url)
 
         self.assertEqual([
-            "svn-v%d:1@%s-" % (MAPPING_VERSION, repos.uuid), 
-            "svn-v%d:2@%s-" % (MAPPING_VERSION, repos.uuid)],
+            repos.generate_revision_id(1, ""),
+            repos.generate_revision_id(2, "")],
             branch.revision_history())
 
     def test_get_nick_none(self):
@@ -418,12 +418,12 @@
 
         uuid = "6f95bc5c-e18d-4021-aca8-49ed51dbcb75"
         tree = newbranch.repository.revision_tree(
-                "svn-v%d:7@%s-branches%%2ffoobranch" % (MAPPING_VERSION, uuid))
+                generate_svn_revision_id(uuid, 7, "branches/foobranch"))
 
         weave = tree.get_weave(tree.inventory.path2id("hosts"))
         self.assertEqual([
-            'svn-v%d:6@%s-branches%%2ffoobranch' % (MAPPING_VERSION, uuid), 
-            'svn-v%d:7@%s-branches%%2ffoobranch' % (MAPPING_VERSION, uuid)],
+            generate_svn_revision_id(uuid, 6, "branches/foobranch"),
+            generate_svn_revision_id(uuid, 7, "branches/foobranch")],
                           weave.versions())
  
 
@@ -463,14 +463,14 @@
 
         uuid = olddir.find_repository().uuid
         tree = newbranch.repository.revision_tree(
-                "svn-v%d:6@%s-branches%%2ffoobranch" % (MAPPING_VERSION, uuid))
+                generate_svn_revision_id(uuid, 6, "branches/foobranch"))
 
         weave = tree.get_weave(tree.inventory.path2id("hosts"))
         self.assertEqual([
-            'svn-v%d:1@%s-trunk' % (MAPPING_VERSION, uuid), 
-            'svn-v%d:2@%s-trunk' % (MAPPING_VERSION, uuid), 
-            'svn-v%d:3@%s-trunk' % (MAPPING_VERSION, uuid), 
-            'svn-v%d:6@%s-branches%%2ffoobranch' % (MAPPING_VERSION, uuid)],
+            generate_svn_revision_id(uuid, 1, "trunk"),
+            generate_svn_revision_id(uuid, 2, "trunk"),
+            generate_svn_revision_id(uuid, 3, "trunk"),
+            generate_svn_revision_id(uuid, 6, "branches/foobranch")],
                           weave.versions())
 
     def test_check(self):
@@ -496,7 +496,7 @@
 
         newtree = oldbranch.create_checkout("e")
         self.assertTrue(newtree.branch.repository.has_revision(
-           'svn-v%d:1@%s-trunk' % (MAPPING_VERSION, oldbranch.repository.uuid)))
+           oldbranch.generate_revision_id(1)))
 
         self.assertTrue(os.path.exists("e/.bzr"))
         self.assertFalse(os.path.exists("e/.svn"))
@@ -513,9 +513,7 @@
         oldbranch = Branch.open(url)
 
         newtree = oldbranch.create_checkout("e", lightweight=True)
-        self.assertEqual(
-           'svn-v%d:1@%s-trunk' % (MAPPING_VERSION, oldbranch.repository.uuid),
-           newtree.base_revid)
+        self.assertEqual(oldbranch.generate_revision_id(1), newtree.base_revid)
         self.assertTrue(os.path.exists("e/.svn"))
         self.assertFalse(os.path.exists("e/.bzr"))
 
@@ -534,10 +532,8 @@
         oldbranch = Branch.open(url)
 
         newtree = oldbranch.create_checkout("e", revision_id=
-           'svn-v%d:1@%s-trunk' % (MAPPING_VERSION, oldbranch.repository.uuid),
-                lightweight=True)
-        self.assertEqual(
-           'svn-v%d:1@%s-trunk' % (MAPPING_VERSION, oldbranch.repository.uuid),
+           oldbranch.generate_revision_id(1), lightweight=True)
+        self.assertEqual(oldbranch.generate_revision_id(1),
            newtree.base_revid)
         self.assertTrue(os.path.exists("e/.svn"))
         self.assertFalse(os.path.exists("e/.bzr"))

=== modified file 'tests/test_commit.py'
--- a/tests/test_commit.py	2007-01-03 22:24:00 +0000
+++ b/tests/test_commit.py	2007-01-09 04:25:01 +0000
@@ -33,13 +33,11 @@
         self.build_tree({'dc/foo/bla': "data"})
         self.client_add("dc/foo")
         wt = WorkingTree.open("dc")
-        self.assertEqual(
-            "svn-v%d:1@%s-" % (MAPPING_VERSION, wt.branch.repository.uuid), 
-                         wt.commit(message="data"))
+        self.assertEqual(wt.branch.generate_revision_id(1), 
+                wt.commit(message="data"))
         self.client_update("dc")
-        self.assertEqual(
-            "svn-v%d:1@%s-" % (MAPPING_VERSION, wt.branch.repository.uuid), 
-                         wt.branch.last_revision())
+        self.assertEqual(wt.branch.generate_revision_id(1), 
+                wt.branch.last_revision())
         wt = WorkingTree.open("dc")
         new_inventory = wt.branch.repository.get_inventory(
                             wt.branch.last_revision())
@@ -52,11 +50,9 @@
         self.client_add("dc/foo")
         wt = WorkingTree.open("dc")
         self.assertEqual(
-            "svn-v%d:1@%s-" % (MAPPING_VERSION, wt.branch.repository.uuid), 
-                         wt.commit(message="data"))
+            wt.branch.generate_revision_id(1), wt.commit(message="data"))
         self.assertEqual(
-                "svn-v%d:1@%s-" % (MAPPING_VERSION, wt.branch.repository.uuid), 
-                         wt.branch.last_revision())
+                wt.branch.generate_revision_id(1), wt.branch.last_revision())
         new_revision = wt.branch.repository.get_revision(
                             wt.branch.last_revision())
         self.assertEqual(wt.branch.last_revision(), new_revision.revision_id)
@@ -70,7 +66,7 @@
         wt.set_pending_merges(["some-ghost-revision"])
         wt.commit(message="data")
         self.assertEqual(
-                'svn-v%d:1@%s-' % (MAPPING_VERSION, wt.branch.repository.uuid), 
+                wt.branch.generate_revision_id(1),
                 wt.branch.last_revision())
 
     def test_commit_parents(self):
@@ -149,7 +145,7 @@
         wt.set_pending_merges(["some-ghost-revision"])
         wt.commit(message="data")
         self.assertEqual([
-            "svn-v%d:1@%s-" % (MAPPING_VERSION, wt.branch.repository.uuid), 
+            wt.branch.generate_revision_id(1),
             "some-ghost-revision"],
             wt.branch.repository.revision_parents(wt.branch.last_revision()))
         self.assertEqual("some-ghost-revision\n", 
@@ -243,15 +239,15 @@
         self.olddir.open_branch().pull(self.newdir.open_branch())
 
         repos = self.olddir.find_repository()
-        inv = repos.get_inventory("svn-v%d:2@%s-" % (MAPPING_VERSION, repos.uuid))
-        self.assertEqual("svn-v%d:2@%s-" % (MAPPING_VERSION, repos.uuid), 
+        inv = repos.get_inventory(repos.generate_revision_id(2, ""))
+        self.assertEqual(repos.generate_revision_id(2, ""),
                          inv[inv.path2id('foo/bla')].revision)
         self.assertTrue(wt.branch.last_revision() in 
-         repos.revision_parents("svn-v%d:2@%s-" % (MAPPING_VERSION, repos.uuid)))
-        self.assertEqual("svn-v%d:2@%s-" % (MAPPING_VERSION, repos.uuid), 
+          repos.revision_parents(repos.generate_revision_id(2, "")))
+        self.assertEqual(repos.generate_revision_id(2, ""),
                         self.olddir.open_branch().last_revision())
         self.assertEqual("other data", 
-            repos.revision_tree("svn-v%d:2@%s-" % (MAPPING_VERSION, repos.uuid)).get_file_text( inv.path2id("foo/bla")))
+            repos.revision_tree(repos.generate_revision_id(2, "")).get_file_text( inv.path2id("foo/bla")))
 
     def test_simple(self):
         self.build_tree({'dc/file': 'data'})
@@ -262,12 +258,12 @@
         self.olddir.open_branch().pull(self.newdir.open_branch())
 
         repos = self.olddir.find_repository()
-        inv = repos.get_inventory("svn-v%d:2@%s-" % (MAPPING_VERSION, repos.uuid))
+        inv = repos.get_inventory(repos.generate_revision_id(2, ""))
         self.assertTrue(inv.has_filename('file'))
         self.assertTrue(wt.branch.last_revision() in 
             repos.revision_parents(
-                "svn-v%d:2@%s-" % (MAPPING_VERSION, repos.uuid)))
-        self.assertEqual("svn-v%d:2@%s-" % (MAPPING_VERSION, repos.uuid), 
+                repos.generate_revision_id(2, "")))
+        self.assertEqual(repos.generate_revision_id(2, ""),
                         self.olddir.open_branch().last_revision())
 
     def test_pull_after_push(self):
@@ -279,16 +275,16 @@
         self.olddir.open_branch().pull(self.newdir.open_branch())
 
         repos = self.olddir.find_repository()
-        inv = repos.get_inventory("svn-v%d:2@%s-" % (MAPPING_VERSION, repos.uuid))
+        inv = repos.get_inventory(repos.generate_revision_id(2, ""))
         self.assertTrue(inv.has_filename('file'))
         self.assertTrue(wt.branch.last_revision() in 
-                         repos.revision_parents("svn-v%d:2@%s-" % (MAPPING_VERSION, repos.uuid)))
-        self.assertEqual("svn-v%d:2@%s-" % (MAPPING_VERSION, repos.uuid), 
+                         repos.revision_parents(repos.generate_revision_id(2, "")))
+        self.assertEqual(repos.generate_revision_id(2, ""),
                         self.olddir.open_branch().last_revision())
 
         self.newdir.open_branch().pull(self.olddir.open_branch())
 
-        self.assertEqual("svn-v%d:2@%s-" % (MAPPING_VERSION, repos.uuid), 
+        self.assertEqual(repos.generate_revision_id(2, ""),
                         self.newdir.open_branch().last_revision())
 
     def test_message(self):
@@ -301,7 +297,7 @@
 
         repos = self.olddir.find_repository()
         self.assertEqual("Commit from Bzr",
-            repos.get_revision("svn-v%d:2@%s-" % (MAPPING_VERSION, repos.uuid)).message)
+            repos.get_revision(repos.generate_revision_id(2, "")).message)
 
     def test_multiple(self):
         self.build_tree({'dc/file': 'data'})
@@ -317,17 +313,17 @@
 
         repos = self.olddir.find_repository()
 
-        self.assertEqual("svn-v%d:3@%s-" % (MAPPING_VERSION, repos.uuid), 
+        self.assertEqual(repos.generate_revision_id(3, ""), 
                         self.olddir.open_branch().last_revision())
 
-        inv = repos.get_inventory("svn-v%d:2@%s-" % (MAPPING_VERSION, repos.uuid))
+        inv = repos.get_inventory(repos.generate_revision_id(2, ""))
         self.assertTrue(inv.has_filename('file'))
         self.assertFalse(inv.has_filename('adir'))
 
-        inv = repos.get_inventory("svn-v%d:3@%s-" % (MAPPING_VERSION, repos.uuid))
+        inv = repos.get_inventory(repos.generate_revision_id(3, ""))
         self.assertTrue(inv.has_filename('file'))
         self.assertTrue(inv.has_filename('adir'))
 
         self.assertTrue(wt.branch.last_revision() in 
-             repos.get_ancestry("svn-v%d:3@%s-" % (MAPPING_VERSION, repos.uuid)))
+             repos.get_ancestry(repos.generate_revision_id(3, "")))
 

=== modified file 'tests/test_convert.py'
--- a/tests/test_convert.py	2007-01-02 00:45:53 +0000
+++ b/tests/test_convert.py	2007-01-09 04:25:01 +0000
@@ -23,7 +23,7 @@
 
 import os
 from convert import convert_repository, NotDumpFile, load_dumpfile
-from repository import MAPPING_VERSION
+from repository import generate_svn_revision_id
 from scheme import TrunkBranchingScheme, NoBranchingScheme
 from tests import TestCaseWithSubversionRepository
 
@@ -80,7 +80,7 @@
                            all=False, create_shared_repo=True)
         oldrepos = Repository.open(self.repos_url)
         newrepos = Repository.open("e")
-        self.assertFalse(newrepos.has_revision("svn-v%d:2@%s-branches%%2fsomebranch" % (MAPPING_VERSION, oldrepos.uuid)))
+        self.assertFalse(newrepos.has_revision(oldrepos.generate_revision_id(2, "branches/somebranch")))
 
     def test_fetch_filebranch(self):
         self.build_tree({'dc/branches/somebranch': 'data'})
@@ -89,7 +89,7 @@
         convert_repository(self.repos_url, "e", TrunkBranchingScheme())
         oldrepos = Repository.open(self.repos_url)
         newrepos = Repository.open("e")
-        self.assertFalse(newrepos.has_revision("svn-v%d:2@%s-branches%%2fsomebranch" % (MAPPING_VERSION, oldrepos.uuid)))
+        self.assertFalse(newrepos.has_revision(oldrepos.generate_revision_id(2, "branches/somebranch")))
 
 
     def test_fetch_dead(self):
@@ -103,7 +103,7 @@
         oldrepos = Repository.open(self.repos_url)
         newrepos = Repository.open("e")
         mutter('q: %r' % newrepos.all_revision_ids())
-        self.assertTrue(newrepos.has_revision("svn-v%d:3@%s-branches%%2fsomebranch" % (MAPPING_VERSION, oldrepos.uuid)))
+        self.assertTrue(newrepos.has_revision(oldrepos.generate_revision_id(3, "branches/somebranch")))
 
     def test_shared_import_continue(self):
         BzrDir.create_repository("e", shared=True)
@@ -138,15 +138,12 @@
         self.build_tree({'dc/trunk/file': 'foodata'})
         self.client_commit("dc", "msg")
 
-        self.assertEqual("svn-v%d:2@%s-trunk" % 
-                        (MAPPING_VERSION, Repository.open(self.repos_url).uuid),
-                        Branch.open("e/trunk").last_revision())
+        self.assertEqual(Repository.open(self.repos_url).generate_revision_id(2, "trunk"), Branch.open("e/trunk").last_revision())
 
         convert_repository("svn+"+self.repos_url, "e", 
                 TrunkBranchingScheme(), True)
 
-        self.assertEqual("svn-v%d:3@%s-trunk" % 
-                        (MAPPING_VERSION, Repository.open(self.repos_url).uuid),
+        self.assertEqual(Repository.open(self.repos_url).generate_revision_id(3, "trunk"), 
                         Branch.open("e/trunk").last_revision())
 
  
@@ -275,4 +272,4 @@
                            TrunkBranchingScheme())
         branch = Branch.open(os.path.join(self.test_dir, "e", "trunk"))
         self.assertEqual("file://%s/e/trunk" % self.test_dir, branch.base.rstrip("/"))
-        self.assertEqual("svn-v%d:1 at 6987ef2d-cd6b-461f-9991-6f1abef3bd59-trunk" % MAPPING_VERSION, branch.last_revision())
+        self.assertEqual(generate_svn_revision_id("6987ef2d-cd6b-461f-9991-6f1abef3bd59", 1, 'trunk'), branch.last_revision())

=== modified file 'tests/test_fileids.py'
--- a/tests/test_fileids.py	2007-01-09 02:16:31 +0000
+++ b/tests/test_fileids.py	2007-01-09 04:25:01 +0000
@@ -52,9 +52,9 @@
         repository = Repository.open("svn+"+repos_url)
 
         inv1 = repository.get_inventory(
-                "svn-v%d:1@%s-" % (MAPPING_VERSION, repository.uuid))
+                repository.generate_revision_id(1, ""))
         inv2 = repository.get_inventory(
-                "svn-v%d:2@%s-" % (MAPPING_VERSION, repository.uuid))
+                repository.generate_revision_id(2, ""))
         mutter('inv1: %r' % inv1.entries())
         mutter('inv2: %r' % inv2.entries())
         if RENAMES:
@@ -79,9 +79,9 @@
         repository = bzrdir.find_repository()
 
         inv1 = repository.get_inventory(
-                "svn-v%d:1@%s-" % (MAPPING_VERSION, repository.uuid))
+                repository.generate_revision_id(1, ""))
         inv2 = repository.get_inventory(
-                "svn-v%d:2@%s-" % (MAPPING_VERSION, repository.uuid))
+                repository.generate_revision_id(2, ""))
         self.assertNotEqual(inv1.path2id("foo"), inv2.path2id("bar"))
         self.assertNotEqual(inv1.path2id("foo"), inv2.path2id("blie"))
         self.assertIs(None, inv1.path2id("bar"))
@@ -99,9 +99,9 @@
         repository = bzrdir.find_repository()
 
         inv1 = repository.get_inventory(
-                "svn-v%d:1@%s-" % (MAPPING_VERSION, repository.uuid))
+                repository.generate_revision_id(1, ""))
         inv2 = repository.get_inventory(
-                "svn-v%d:2@%s-" % (MAPPING_VERSION, repository.uuid))
+                repository.generate_revision_id(2, ""))
         self.assertNotEqual(None, inv1.path2id("foo"))
         self.assertIs(None, inv2.path2id("foo"))
 
@@ -119,9 +119,9 @@
         repository = bzrdir.find_repository()
 
         inv1 = repository.get_inventory(
-                "svn-v%d:1@%s-" % (MAPPING_VERSION, repository.uuid))
+                repository.generate_revision_id(1, ""))
         inv2 = repository.get_inventory(
-                "svn-v%d:2@%s-" % (MAPPING_VERSION, repository.uuid))
+                repository.generate_revision_id(2, ""))
         self.assertNotEqual(inv1.path2id("foo"), inv2.path2id("foo"))
 
     def test_copy_branch(self):
@@ -137,18 +137,16 @@
         repository = bzrdir.find_repository()
 
         inv1 = repository.get_inventory(
-                "svn-v%d:1@%s-trunk" % (MAPPING_VERSION, repository.uuid))
+                repository.generate_revision_id(1, "trunk"))
         inv2 = repository.get_inventory(
-                "svn-v%d:2@%s-branches%%2fmybranch" % (MAPPING_VERSION, repository.uuid))
+                repository.generate_revision_id(2, "branches/mybranch"))
         self.assertEqual(inv1.path2id("dir"), inv2.path2id("dir"))
         self.assertEqual(inv1.path2id("dir/file"), inv2.path2id("dir/file"))
 
         fileid, revid = repository.get_fileid_map(2, 
                             "branches/mybranch")["dir/file"]
         self.assertEqual(fileid, inv1.path2id("dir/file"))
-        self.assertEqual(
-                "svn-v%d:1@%s-trunk" % (MAPPING_VERSION, repository.uuid), 
-                revid)
+        self.assertEqual(repository.generate_revision_id(1, "trunk"), revid)
 
 def sha1(str):
     return sha.new(str).hexdigest()




More information about the bazaar-commits mailing list