Rev 369: Fix get_fileid_map() bugs. in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev
Jelmer Vernooij
jelmer at samba.org
Wed Jan 3 05:24:57 GMT 2007
------------------------------------------------------------
revno: 369
revision-id: jelmer at samba.org-20070103052419-l1ynpmaau0qyl9rq
parent: jelmer at samba.org-20070102191726-egizz156i4uclg8i
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Wed 2007-01-03 06:24:19 +0100
message:
Fix get_fileid_map() bugs.
modified:
fileids.py fileids.py-20060714013623-u5iiyqqnko11grcf-1
tests/test_fileids.py test_fileids.py-20060622131341-19gyrlgqy8yl2od5-1
=== modified file 'fileids.py'
--- a/fileids.py 2007-01-01 22:18:53 +0000
+++ b/fileids.py 2007-01-03 05:24:19 +0000
@@ -197,7 +197,7 @@
# Mark all parent paths as changed
for p in revmap:
parts = p.split("/")
- for j in range(1, len(parts)):
+ for j in range(1, len(parts)+1):
parent = "/".join(parts[0:len(parts)-j])
assert map.has_key(parent), "Parent item %s of %s doesn't exist in map" % (parent, p)
if map[parent][1] == revid:
=== modified file 'tests/test_fileids.py'
--- a/tests/test_fileids.py 2007-01-02 05:45:43 +0000
+++ b/tests/test_fileids.py 2007-01-03 05:24:19 +0000
@@ -16,7 +16,7 @@
from bzrlib.bzrdir import BzrDir
from bzrlib.errors import NoSuchRevision
-from bzrlib.inventory import Inventory
+from bzrlib.inventory import Inventory, ROOT_ID
from bzrlib.repository import Repository
from bzrlib.trace import mutter
from bzrlib.tests import TestSkipped, TestCase
@@ -24,8 +24,9 @@
import sha
import format
-from fileids import SimpleFileIdMap, generate_file_id
+from fileids import SimpleFileIdMap, generate_file_id, generate_svn_file_id
from repository import MAPPING_VERSION
+from scheme import TrunkBranchingScheme
from tests import TestCaseWithSubversionRepository, RENAMES
class TestComplexFileids(TestCaseWithSubversionRepository):
@@ -153,6 +154,9 @@
return sha.new(str).hexdigest()
class TestFileIdGenerator(TestCase):
+ def test_generate_file_id_root(self):
+ self.assertEqual(ROOT_ID, generate_file_id("svn-v2:2 at uuid-bp", ""))
+
def test_generate_file_id_path(self):
self.assertEqual("svn-v2:2 at uuid-bp-mypath",
generate_file_id("svn-v2:2 at uuid-bp", "mypath"))
@@ -243,3 +247,56 @@
renames={("svn-v%d:2 at uuid-" % MAPPING_VERSION): {"foo": "myid"}})
self.assertEqual("svn-v%d:1 at uuid--foo" % MAPPING_VERSION, map["foo"][0])
self.assertEqual("svn-v%d:1 at uuid-" % MAPPING_VERSION, map["foo"][1])
+
+class GetMapTests(TestCaseWithSubversionRepository):
+ def setUp(self):
+ super(GetMapTests, self).setUp()
+ self.repos_url = self.make_client("d", "dc")
+ self.repos = Repository.open(self.repos_url)
+
+ def test_empty(self):
+ self.assertEqual({"": (ROOT_ID, None)},
+ self.repos.get_fileid_map(0, ""))
+
+ def test_empty_trunk(self):
+ self.repos.set_branching_scheme(TrunkBranchingScheme())
+ self.build_tree({"dc/trunk": None})
+ self.client_add("dc/trunk")
+ self.client_commit("dc", "Msg")
+ self.assertEqual({"": (ROOT_ID, "svn-v%d:1@%s-trunk" % (MAPPING_VERSION,
+ self.repos.uuid))}, self.repos.get_fileid_map(1, "trunk"))
+
+ def test_change_parent(self):
+ self.repos.set_branching_scheme(TrunkBranchingScheme())
+ self.build_tree({"dc/trunk": None})
+ self.client_add("dc/trunk")
+ self.client_commit("dc", "Msg")
+ self.build_tree({"dc/trunk/file": 'data'})
+ self.client_add("dc/trunk/file")
+ self.client_commit("dc", "Msg")
+ self.assertEqual({"": (ROOT_ID, "svn-v%d:2@%s-trunk" % (MAPPING_VERSION, self.repos.uuid)), "file": (generate_svn_file_id(self.repos.uuid, 2, "trunk", "file"), "svn-v%d:2@%s-trunk" % (MAPPING_VERSION, self.repos.uuid))}, self.repos.get_fileid_map(2, "trunk"))
+
+ def test_change_updates(self):
+ self.repos.set_branching_scheme(TrunkBranchingScheme())
+ self.build_tree({"dc/trunk": None})
+ self.client_add("dc/trunk")
+ self.client_commit("dc", "Msg")
+ self.build_tree({"dc/trunk/file": 'data'})
+ self.client_add("dc/trunk/file")
+ self.client_commit("dc", "Msg")
+ self.build_tree({"dc/trunk/file": 'otherdata'})
+ self.client_commit("dc", "Msg")
+ self.assertEqual({"": (ROOT_ID, "svn-v%d:3@%s-trunk" % (MAPPING_VERSION, self.repos.uuid)), "file": (generate_svn_file_id(self.repos.uuid, 2, "trunk", "file"), "svn-v%d:3@%s-trunk" % (MAPPING_VERSION, self.repos.uuid))}, self.repos.get_fileid_map(3, "trunk"))
+
+ def test_sibling_unrelated(self):
+ self.repos.set_branching_scheme(TrunkBranchingScheme())
+ self.build_tree({"dc/trunk": None})
+ self.client_add("dc/trunk")
+ self.client_commit("dc", "Msg")
+ self.build_tree({"dc/trunk/file": 'data', 'dc/trunk/bar': 'data2'})
+ self.client_add("dc/trunk/file")
+ self.client_add("dc/trunk/bar")
+ self.client_commit("dc", "Msg")
+ self.build_tree({"dc/trunk/file": 'otherdata'})
+ self.client_commit("dc", "Msg")
+ self.assertEqual({"": (ROOT_ID, "svn-v%d:3@%s-trunk" % (MAPPING_VERSION, self.repos.uuid)), "bar": (generate_svn_file_id(self.repos.uuid, 2, "trunk", "bar"), "svn-v%d:2@%s-trunk" % (MAPPING_VERSION, self.repos.uuid)), "file": (generate_svn_file_id(self.repos.uuid, 2, "trunk", "file"), "svn-v%d:3@%s-trunk" % (MAPPING_VERSION, self.repos.uuid))}, self.repos.get_fileid_map(3, "trunk"))
More information about the bazaar-commits
mailing list