Rev 435: Add some tests for the custom revisions. in file:///home/jelmer/bzr-svn/customrevids/
Jelmer Vernooij
jelmer at samba.org
Fri May 18 01:43:39 BST 2007
At file:///home/jelmer/bzr-svn/customrevids/
------------------------------------------------------------
revno: 435
revision-id: jelmer at samba.org-20070518004338-7iyyvupsj2en6tld
parent: jelmer at samba.org-20070517190430-nkqegxcff1gdobe4
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: customrevids
timestamp: Fri 2007-05-18 01:43:38 +0100
message:
Add some tests for the custom revisions.
modified:
repository.py repository.py-20060306123302-1f8c5069b3fe0265
tests/test_repos.py test_repos.py-20060508151940-ddc49a59257ca712
tests/test_revids.py test_revids.py-20070516230044-d7x872cqi7xb4eow-1
=== modified file 'repository.py'
--- a/repository.py 2007-05-17 19:04:30 +0000
+++ b/repository.py 2007-05-18 00:43:38 +0000
@@ -384,7 +384,8 @@
if revid is not None:
return revid
- revid = self.branchprop_list.get_property_diff(path, revnum, SVN_PROP_BZR_REVISION_ID).strip("\n")
+ revid = self.branchprop_list.get_property_diff(path, revnum,
+ SVN_PROP_BZR_REVISION_ID).strip("\n")
if revid == "":
revid = generate_svn_revision_id(self.uuid, revnum, path)
@@ -403,6 +404,7 @@
# Try a simple parse
try:
(uuid, branch_path, revnum) = parse_svn_revision_id(revid)
+ assert isinstance(branch_path, str)
if uuid == self.uuid:
return (branch_path, revnum)
except InvalidRevisionId:
@@ -411,19 +413,38 @@
# Check the record out of the revmap, if it exists
try:
(branch_path, min_revnum, max_revnum, scheme) = self.revmap.lookup_revid(revid)
+ assert isinstance(branch_path, str)
# Entry already complete?
if min_revnum == max_revnum:
return (branch_path, min_revnum)
except NoSuchRevision:
- pass
- # FIXME: If there is no entry in the map, walk over all branches:
- # - FIXME: Look at their bzr:revision-id-vX
- # - FIXME If there are any new entries that are not yet in the cache, add them
- # Still not found?
- raise NoSuchRevision(self, revid)
-
- # FIXME Complete the entry
- return (branch_path, min_revnum)
+ # If there is no entry in the map, walk over all branches:
+ for (branch, revno, exists) in self.find_branches():
+ # Look at their bzr:revision-id-vX
+ revids = self.branchprop_list.get_property(branch, revno,
+ SVN_PROP_BZR_REVISION_ID, "")
+
+ # If there are any new entries that are not yet in the cache,
+ # add them
+ for r in revids:
+ self.revmap.insert_revid(revid, branch, 0, revno,
+ "undefined")
+
+ if revid in revids:
+ break
+
+ (branch_path, min_revnum, max_revnum, scheme) = self.revmap.lookup_revid(revid)
+ assert isinstance(branch_path, str)
+
+ # Find the branch property between min_revnum and max_revnum that
+ # added revid
+ i = min_revnum
+ while i <= max_revnum:
+ if self.branchprop_list.get_property_diff(branch_path, i, SVN_PROP_BZR_REVISION_ID).strip("\n") == revid:
+ self.revmap.insert_revid(revid, branch_path, i, i, "undefined")
+ return (branch_path, i)
+
+ raise AssertionError("Revision id was added incorrectly")
def get_inventory_xml(self, revision_id):
return bzrlib.xml5.serializer_v5.write_inventory_to_string(
@@ -617,6 +638,7 @@
"""Find all branches that were changed in the specified revision number.
:param revnum: Revision to search for branches.
+ :return: iterator that returns tuples with (path, revision number, still exists)
"""
if revnum is None:
revnum = self.transport.get_latest_revnum()
=== modified file 'tests/test_repos.py'
--- a/tests/test_repos.py 2007-05-17 19:04:30 +0000
+++ b/tests/test_repos.py 2007-05-18 00:43:38 +0000
@@ -35,7 +35,7 @@
from transport import SvnRaTransport
from tests import TestCaseWithSubversionRepository
from repository import (svk_feature_to_revision_id, revision_id_to_svk_feature,
- SvnRepositoryFormat)
+ SvnRepositoryFormat, SVN_PROP_BZR_REVISION_ID)
from revids import (MAPPING_VERSION, escape_svn_path, unescape_svn_path,
parse_svn_revision_id, generate_svn_revision_id)
@@ -77,6 +77,14 @@
revid = repos.generate_revision_id(0, "")
self.assertEqual({"": (generate_file_id(revid, ""), revid)}, repos.get_fileid_map(0, ""))
+ def test_generate_revision_id_forced_revid(self):
+ repos_url = self.make_client("a", "dc")
+ self.client_set_prop("dc", SVN_PROP_BZR_REVISION_ID, "someid\n")
+ self.client_commit("dc", "set id")
+ repos = Repository.open(repos_url)
+ revid = repos.generate_revision_id(1, "")
+ self.assertEquals("someid", revid)
+
def test_add_revision(self):
repos_url = self.make_client("a", "dc")
repos = Repository.open(repos_url)
@@ -2213,49 +2221,6 @@
self.assertFalse(self.inventory[
self.inventory.path2id("foo/bla")].executable)
-class RevisionIdMappingTest(TestCase):
- def test_generate_revid(self):
- self.assertEqual("svn-v%d-undefined:myuuid:branch:5" % MAPPING_VERSION,
- generate_svn_revision_id("myuuid", 5, "branch"))
-
- def test_generate_revid_nested(self):
- self.assertEqual("svn-v%d-undefined:myuuid:branch%%2Fpath:5" % MAPPING_VERSION,
- generate_svn_revision_id("myuuid", 5, "branch/path"))
-
- def test_generate_revid_special_char(self):
- self.assertEqual(u"svn-v%d-undefined:myuuid:branch%%2C:5" % MAPPING_VERSION,
- generate_svn_revision_id("myuuid", 5, u"branch\x2c"))
-
- def test_generate_revid_special_char_ascii(self):
- self.assertEqual("svn-v%d-undefined:myuuid:branch%%2C:5" % MAPPING_VERSION,
- generate_svn_revision_id("myuuid", 5, "branch\x2c"))
-
- def test_generate_revid_nordic(self):
- self.assertEqual("svn-v%d-undefined:myuuid:branch%%C3%%A6:5" % MAPPING_VERSION,
- generate_svn_revision_id("myuuid", 5, u"branch\xe6"))
-
- def test_parse_revid_simple(self):
- self.assertEqual(("uuid", "", 4),
- parse_svn_revision_id(
- "svn-v%d-undefined:uuid::4" % MAPPING_VERSION))
-
- def test_parse_revid_nested(self):
- self.assertEqual(("uuid", "bp/data", 4),
- parse_svn_revision_id(
- "svn-v%d-undefined:uuid:bp%%2Fdata:4" % MAPPING_VERSION))
-
- def test_svk_revid_map_root(self):
- self.assertEqual("svn-v%d-undefined:auuid::6" % MAPPING_VERSION,
- svk_feature_to_revision_id("auuid:/:6"))
-
- def test_svk_revid_map_nested(self):
- self.assertEqual("svn-v%d-undefined:auuid:bp:6" % MAPPING_VERSION,
- svk_feature_to_revision_id("auuid:/bp:6"))
-
- def test_revid_svk_map(self):
- self.assertEqual("auuid:/:6",
- revision_id_to_svk_feature("svn-v%d-undefined:auuid::6" % MAPPING_VERSION))
-
class EscapeTest(TestCase):
def test_escape_svn_path_none(self):
=== modified file 'tests/test_revids.py'
--- a/tests/test_revids.py 2007-05-17 19:03:19 +0000
+++ b/tests/test_revids.py 2007-05-18 00:43:38 +0000
@@ -18,6 +18,8 @@
from bzrlib.repository import Repository
from bzrlib.tests import TestCase
+from repository import (MAPPING_VERSION, svk_feature_to_revision_id,
+ revision_id_to_svk_feature)
from revids import RevidMap, parse_svn_revision_id, generate_svn_revision_id
from tests import TestCaseWithSubversionRepository
@@ -61,3 +63,49 @@
def test_parse_revision_id(self):
self.assertEquals(("myuuid", "bla", 5),
parse_svn_revision_id(generate_svn_revision_id("myuuid", 5, "bla")))
+
+
+class RevisionIdMappingTest(TestCase):
+ def test_generate_revid(self):
+ self.assertEqual("svn-v%d-undefined:myuuid:branch:5" % MAPPING_VERSION,
+ generate_svn_revision_id("myuuid", 5, "branch"))
+
+ def test_generate_revid_nested(self):
+ self.assertEqual("svn-v%d-undefined:myuuid:branch%%2Fpath:5" % MAPPING_VERSION,
+ generate_svn_revision_id("myuuid", 5, "branch/path"))
+
+ def test_generate_revid_special_char(self):
+ self.assertEqual(u"svn-v%d-undefined:myuuid:branch%%2C:5" % MAPPING_VERSION,
+ generate_svn_revision_id("myuuid", 5, u"branch\x2c"))
+
+ def test_generate_revid_special_char_ascii(self):
+ self.assertEqual("svn-v%d-undefined:myuuid:branch%%2C:5" % MAPPING_VERSION,
+ generate_svn_revision_id("myuuid", 5, "branch\x2c"))
+
+ def test_generate_revid_nordic(self):
+ self.assertEqual("svn-v%d-undefined:myuuid:branch%%C3%%A6:5" % MAPPING_VERSION,
+ generate_svn_revision_id("myuuid", 5, u"branch\xe6"))
+
+ def test_parse_revid_simple(self):
+ self.assertEqual(("uuid", "", 4),
+ parse_svn_revision_id(
+ "svn-v%d-undefined:uuid::4" % MAPPING_VERSION))
+
+ def test_parse_revid_nested(self):
+ self.assertEqual(("uuid", "bp/data", 4),
+ parse_svn_revision_id(
+ "svn-v%d-undefined:uuid:bp%%2Fdata:4" % MAPPING_VERSION))
+
+ def test_svk_revid_map_root(self):
+ self.assertEqual("svn-v%d-undefined:auuid::6" % MAPPING_VERSION,
+ svk_feature_to_revision_id("auuid:/:6"))
+
+ def test_svk_revid_map_nested(self):
+ self.assertEqual("svn-v%d-undefined:auuid:bp:6" % MAPPING_VERSION,
+ svk_feature_to_revision_id("auuid:/bp:6"))
+
+ def test_revid_svk_map(self):
+ self.assertEqual("auuid:/:6",
+ revision_id_to_svk_feature("svn-v%d-undefined:auuid::6" % MAPPING_VERSION))
+
+
More information about the bazaar-commits
mailing list