Map revision 0 in Subversion to a custom Bazaar revision rather than NULL_REVISION...
authorJelmer Vernooij <jelmer@samba.org>
Fri, 16 Mar 2007 00:25:16 +0000 (01:25 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 16 Mar 2007 00:25:16 +0000 (01:25 +0100)
this is the revision that introduces the tree root.

fetch.py
fileids.py
logwalker.py
repository.py
tests/test_branch.py
tests/test_commit.py
tests/test_fileids.py
tests/test_logwalker.py
tests/test_repos.py
tests/test_upgrade.py

index 98fd16a2a95479eecfd869df8bf0a052f18cb663..0c845776fd1285cc4c7187c9619840d0c1055c51 100644 (file)
--- a/fetch.py
+++ b/fetch.py
@@ -82,14 +82,19 @@ class RevisionBuildEditor(svn.delta.Editor):
         return rev
 
     def open_root(self, base_revnum, baton):
-        file_id = self.id_map[""]
-        if self.inventory.root is None:
+        if self.old_inventory.root is None:
+            # First time the root is set
+            file_id = generate_file_id(self.revid, "")
             self.dir_baserev[file_id] = []
-            ie = self.inventory.add_path("", 'directory', file_id)
         else:
-            self.dir_baserev[file_id] = [self.inventory.revision_id]
-            ie = self.inventory[file_id]
+            assert self.old_inventory.root.revision is not None
+            if self.id_map.has_key(""):
+                file_id = self.id_map[""]
+            else:
+                file_id = self.old_inventory.root.file_id
+            self.dir_baserev[file_id] = [self.old_inventory.root.revision]
 
+        ie = self.inventory.add_path("", 'directory', file_id)
         ie.revision = self.revid
         return file_id
 
@@ -364,7 +369,7 @@ class InterSvnRepository(InterRepository):
                 parent_revid = parents[revid]
 
                 if parent_revid is None:
-                    parent_inv = Inventory()
+                    parent_inv = Inventory(root_id=None)
                 elif prev_revid != parent_revid:
                     parent_inv = self.target.get_inventory(parent_revid)
                 else:
index f8326cb9ba20018efb31f63e06ba36ee247476d3..3543aa922d2f9de9daa134b0e3c67e5020029f15 100644 (file)
@@ -15,7 +15,6 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 from bzrlib.errors import RevisionNotPresent, NotBranchError
-from bzrlib.inventory import ROOT_ID
 from bzrlib.knit import KnitVersionedFile
 from bzrlib.revision import NULL_REVISION
 from bzrlib.trace import mutter
@@ -147,7 +146,9 @@ class FileIdMap(object):
         todo = []
         next_parent_revs = []
         if revnum == 0:
-            return {}
+            assert branch == ""
+            return {"": (generate_svn_file_id(uuid, revnum, branch, ""), 
+                    self.repos.generate_revision_id(revnum, branch))}
 
         # No history -> empty map
         for (bp, paths, rev) in self.repos.follow_branch_history(branch, revnum):
@@ -164,7 +165,7 @@ class FileIdMap(object):
             return map
 
         if len(next_parent_revs) == 0:
-            if self._log.scheme.is_branch(""):
+            if self.repos.scheme.is_branch(""):
                 map = {"": (generate_svn_file_id(uuid, 0, "", ""), NULL_REVISION)}
             else:
                 map = {}
index 48e5921d77148e238f4a51865159846299966b26..fb15bce1cd090d2124559af4772226ed234bfc36 100644 (file)
@@ -158,7 +158,7 @@ class LogWalker(object):
 
         path = path.strip("/")
 
-        while revnum > 0:
+        while revnum >= 0:
             revpaths = self.get_revision_paths(revnum, path)
 
             if revpaths != {}:
@@ -207,11 +207,13 @@ class LogWalker(object):
         :param revnum: Revision number.
         :returns: Tuple with author, log message and date of the revision.
         """
-        assert revnum >= 1
+        assert revnum >= 0
         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()
-        return (author, _escape_commit_message(base64.b64decode(message)), date)
+        if message is not None:
+            message = _escape_commit_message(base64.b64decode(message))
+        return (author, message, date)
 
     def find_latest_change(self, path, revnum, recurse=False):
         """Find latest revision that touched path.
index 70b0d5cd2c3a937744070faeb890fa2c73a05e47..3f0bf71f6855312fbf416c3425637777b83c3c01 100644 (file)
@@ -102,8 +102,7 @@ def generate_svn_revision_id(uuid, revnum, path, scheme="undefined"):
     assert isinstance(revnum, int)
     assert isinstance(path, basestring)
     assert revnum >= 0
-    if revnum == 0:
-        return NULL_REVISION
+    assert revnum > 0 or path == ""
     return "%s%s:%s:%s:%d" % (REVISION_ID_PREFIX, scheme, uuid, \
                    escape_svn_path(path.strip("/")), revnum)
 
@@ -264,8 +263,9 @@ class SvnRepository(Repository):
                                     SVN_PROP_BZR_MERGE, "").splitlines():
             ancestry.extend(l.split("\n"))
 
-        for (branch, rev) in self.follow_branch(path, revnum - 1):
-            ancestry.append(self.generate_revision_id(rev, branch))
+        if revnum > 0:
+            for (branch, rev) in self.follow_branch(path, revnum - 1):
+                ancestry.append(self.generate_revision_id(rev, branch))
 
         ancestry.append(None)
 
@@ -454,7 +454,7 @@ class SvnRepository(Repository):
             self.get_revision(revision_id))
 
     def follow_history(self, revnum):
-        while revnum > 0:
+        while revnum >= 0:
             yielded_paths = []
             paths = self._log.get_revision_paths(revnum)
             for p in paths:
@@ -476,7 +476,7 @@ class SvnRepository(Repository):
             raise errors.NotSvnBranchPath(branch_path, revnum)
         branch_path = branch_path.strip("/")
 
-        while revnum > 0:
+        while revnum >= 0:
             paths = self._log.get_revision_paths(revnum, branch_path)
             if paths == {}:
                 revnum-=1
index 7e92186a2c15d0a36613b2b8356a644751fe0e88..79d0926916229abbe3bf45ddfef5ed185eb7f6ce 100644 (file)
@@ -17,7 +17,6 @@
 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
 
@@ -28,6 +27,7 @@ import svn.core, svn.client
 
 from branch import FakeControlFiles, SvnBranchFormat
 from convert import load_dumpfile
+from fileids import generate_svn_file_id
 import format
 from repository import MAPPING_VERSION, generate_svn_revision_id
 from tests import TestCaseWithSubversionRepository
@@ -37,7 +37,7 @@ class WorkingSubversionBranch(TestCaseWithSubversionRepository):
         repos_url = self.make_client("a", "dc")
         branch = Branch.open(repos_url)
         branch.revision_history()
-        self.assertEqual(None, branch.last_revision())
+        self.assertEqual(branch.generate_revision_id(0), branch.last_revision())
 
     def test_set_parent(self):
         repos_url = self.make_client('a', 'dc')
@@ -48,7 +48,8 @@ class WorkingSubversionBranch(TestCaseWithSubversionRepository):
         repos_url = self.make_client('a', 'dc')
         bzrdir = BzrDir.open("svn+"+repos_url)
         branch = bzrdir.open_branch()
-        self.assertEqual(None, branch.last_revision())
+        self.assertEqual(branch.generate_revision_id(0),
+                         branch.last_revision())
 
         self.build_tree({'dc/foo': "data"})
         self.client_add("dc/foo")
@@ -78,7 +79,7 @@ class WorkingSubversionBranch(TestCaseWithSubversionRepository):
     def test_get_root_id_empty(self):
         repos_url = self.make_client('a', 'dc')
         branch = Branch.open("svn+"+repos_url)
-        self.assertEqual(ROOT_ID, branch.get_root_id())
+        self.assertEqual(generate_svn_file_id(branch.repository.uuid, 0, "", ""), branch.get_root_id())
 
     def test_get_root_id_trunk(self):
         repos_url = self.make_client('a', 'dc')
@@ -86,7 +87,7 @@ class WorkingSubversionBranch(TestCaseWithSubversionRepository):
         self.client_add("dc/trunk")
         self.client_commit("dc", "msg")
         branch = Branch.open("svn+"+repos_url+"/trunk")
-        self.assertEqual(ROOT_ID, branch.get_root_id())
+        self.assertEqual(generate_svn_file_id(branch.repository.uuid, 1, "trunk", ""), branch.get_root_id())
 
     def test_break_lock(self):
         repos_url = self.make_client('a', 'dc')
@@ -127,7 +128,7 @@ class WorkingSubversionBranch(TestCaseWithSubversionRepository):
         repos_url = self.make_client('a', 'dc')
 
         branch = Branch.open("svn+"+repos_url)
-        self.assertEqual([], branch.revision_history())
+        self.assertEqual([branch.generate_revision_id(0)], branch.revision_history())
 
         self.build_tree({'dc/foo': "data"})
         self.client_add("dc/foo")
@@ -136,7 +137,8 @@ class WorkingSubversionBranch(TestCaseWithSubversionRepository):
         branch = Branch.open("svn+"+repos_url)
         repos = Repository.open("svn+"+repos_url)
 
-        self.assertEqual([repos.generate_revision_id(1, "")], 
+        self.assertEqual([repos.generate_revision_id(0, ""), 
+                    repos.generate_revision_id(1, "")], 
                 branch.revision_history())
 
         self.build_tree({'dc/foo': "data34"})
@@ -146,6 +148,7 @@ class WorkingSubversionBranch(TestCaseWithSubversionRepository):
         repos = Repository.open("svn+"+repos_url)
 
         self.assertEqual([
+            repos.generate_revision_id(0, ""),
             repos.generate_revision_id(1, ""),
             repos.generate_revision_id(2, "")],
             branch.revision_history())
index bbf1dc9663a0f9643a28288dc9db7ff31d1992ff..51a9b951296f8bb19e6f3445100b69efeca94977 100644 (file)
@@ -91,7 +91,7 @@ class TestNativeCommit(TestCaseWithSubversionRepository):
         wt = WorkingTree.open("dc")
         wt.set_pending_merges(["some-ghost-revision"])
         wt.commit(message="data")
-        self.assertEqual(["some-ghost-revision"],
+        self.assertEqual([wt.branch.generate_revision_id(0), "some-ghost-revision"],
                          wt.branch.repository.revision_parents(
                              wt.branch.last_revision()))
         self.assertEqual("some-ghost-revision\n", 
index b44982b9e9409805a0d43b35d0c49a1dd5f540f7..3b44a1470aa090b0eddbcde51c95b3dfaecdc24a 100644 (file)
@@ -16,7 +16,7 @@
 
 from bzrlib.bzrdir import BzrDir
 from bzrlib.errors import NoSuchRevision
-from bzrlib.inventory import Inventory, ROOT_ID
+from bzrlib.inventory import Inventory
 from bzrlib.repository import Repository
 from bzrlib.trace import mutter
 from bzrlib.tests import TestSkipped, TestCase
@@ -153,7 +153,7 @@ def sha1(str):
 
 class TestFileIdGenerator(TestCase):
     def test_generate_file_id_root(self):
-        self.assertEqual(ROOT_ID, generate_file_id(generate_svn_revision_id("uuid", 2, "bp"), ""))
+        self.assertEqual("2@uuid:bp:", generate_file_id(generate_svn_revision_id("uuid", 2, "bp"), ""))
 
     def test_generate_file_id_path(self):
         self.assertEqual("2@uuid:bp:mypath", 
@@ -207,7 +207,7 @@ class TestFileMapping(TestCase):
 
     def test_simple_add(self):
         map = self.apply_mappings({generate_svn_revision_id("uuid", 1, ""): {"": ('A', None, None), "foo": ('A', None, None)}})
-        self.assertEqual({'': ('TREE_ROOT', generate_svn_revision_id("uuid", 1, "")),
+        self.assertEqual({'': ('1@uuid::', generate_svn_revision_id("uuid", 1, "")),
             'foo': ("1@uuid::foo", 
                                        generate_svn_revision_id("uuid", 1, ""))
                          }, map)
@@ -270,7 +270,7 @@ class GetMapTests(TestCaseWithSubversionRepository):
         self.repos = Repository.open(self.repos_url)
 
     def test_empty(self):
-        self.assertEqual({"": (ROOT_ID, None)}, 
+        self.assertEqual({"": (generate_svn_file_id(self.repos.uuid, 0, "", ""), self.repos.generate_revision_id(0, ""))}, 
                          self.repos.get_fileid_map(0, ""))
 
     def test_empty_trunk(self):
@@ -278,7 +278,7 @@ class GetMapTests(TestCaseWithSubversionRepository):
         self.build_tree({"dc/trunk": None})
         self.client_add("dc/trunk")
         self.client_commit("dc", "Msg")
-        self.assertEqual({"": (ROOT_ID, self.repos.generate_revision_id(1, "trunk"))}, self.repos.get_fileid_map(1, "trunk"))
+        self.assertEqual({"": (generate_svn_file_id(self.repos.uuid, 1, "trunk", ""), self.repos.generate_revision_id(1, "trunk"))}, self.repos.get_fileid_map(1, "trunk"))
 
     def test_change_parent(self):
         self.repos.set_branching_scheme(TrunkBranchingScheme())
@@ -288,7 +288,7 @@ class GetMapTests(TestCaseWithSubversionRepository):
         self.build_tree({"dc/trunk/file": 'data'})
         self.client_add("dc/trunk/file")
         self.client_commit("dc", "Msg")
-        self.assertEqual({"": (ROOT_ID, self.repos.generate_revision_id(2, "trunk")), "file": (generate_svn_file_id(self.repos.uuid, 2, "trunk", "file"), self.repos.generate_revision_id(2, "trunk"))}, self.repos.get_fileid_map(2, "trunk"))
+        self.assertEqual({"": (generate_svn_file_id(self.repos.uuid, 1, "trunk", ""), self.repos.generate_revision_id(2, "trunk")), "file": (generate_svn_file_id(self.repos.uuid, 2, "trunk", "file"), self.repos.generate_revision_id(2, "trunk"))}, self.repos.get_fileid_map(2, "trunk"))
 
     def test_change_updates(self):
         self.repos.set_branching_scheme(TrunkBranchingScheme())
@@ -300,7 +300,7 @@ class GetMapTests(TestCaseWithSubversionRepository):
         self.client_commit("dc", "Msg")
         self.build_tree({"dc/trunk/file": 'otherdata'})
         self.client_commit("dc", "Msg")
-        self.assertEqual({"": (ROOT_ID, self.repos.generate_revision_id(3, "trunk")), "file": (generate_svn_file_id(self.repos.uuid, 2, "trunk", "file"), self.repos.generate_revision_id(3, "trunk"))}, self.repos.get_fileid_map(3, "trunk"))
+        self.assertEqual({"": (generate_svn_file_id(self.repos.uuid, 1, "trunk", ""), self.repos.generate_revision_id(3, "trunk")), "file": (generate_svn_file_id(self.repos.uuid, 2, "trunk", "file"), self.repos.generate_revision_id(3, "trunk"))}, self.repos.get_fileid_map(3, "trunk"))
 
     def test_sibling_unrelated(self):
         self.repos.set_branching_scheme(TrunkBranchingScheme())
@@ -313,7 +313,7 @@ class GetMapTests(TestCaseWithSubversionRepository):
         self.client_commit("dc", "Msg")
         self.build_tree({"dc/trunk/file": 'otherdata'})
         self.client_commit("dc", "Msg")
-        self.assertEqual({"": (ROOT_ID, self.repos.generate_revision_id(3, "trunk")), "bar": (generate_svn_file_id(self.repos.uuid, 2, "trunk", "bar"), self.repos.generate_revision_id(2, "trunk")), "file": (generate_svn_file_id(self.repos.uuid, 2, "trunk", "file"), self.repos.generate_revision_id(3, "trunk"))}, self.repos.get_fileid_map(3, "trunk"))
+        self.assertEqual({"": (generate_svn_file_id(self.repos.uuid, 1, "trunk", ""), self.repos.generate_revision_id(3, "trunk")), "bar": (generate_svn_file_id(self.repos.uuid, 2, "trunk", "bar"), self.repos.generate_revision_id(2, "trunk")), "file": (generate_svn_file_id(self.repos.uuid, 2, "trunk", "file"), self.repos.generate_revision_id(3, "trunk"))}, self.repos.get_fileid_map(3, "trunk"))
 
     def test_copy(self):
         self.repos.set_branching_scheme(TrunkBranchingScheme())
@@ -326,7 +326,7 @@ class GetMapTests(TestCaseWithSubversionRepository):
         self.client_copy("dc/trunk/file", "dc/trunk/bar")
         self.client_commit("dc", "Msg")
         self.assertEqual({
-            "": (ROOT_ID, self.repos.generate_revision_id(3, "trunk")), 
+            "": (generate_svn_file_id(self.repos.uuid, 1, "trunk", ""), self.repos.generate_revision_id(3, "trunk")), 
             "bar": (generate_svn_file_id(self.repos.uuid, 3, "trunk", "bar"), self.repos.generate_revision_id(3, "trunk")), "file": (generate_svn_file_id(self.repos.uuid, 2, "trunk", "file"), self.repos.generate_revision_id(2, "trunk"))}, self.repos.get_fileid_map(3, "trunk"))
 
     def test_copy_nested_modified(self):
@@ -341,7 +341,7 @@ class GetMapTests(TestCaseWithSubversionRepository):
         self.build_tree({"dc/trunk/bar/file": "data2"})
         self.client_commit("dc", "Msg")
         self.assertEqual({
-          "": (ROOT_ID
+          "": (generate_svn_file_id(self.repos.uuid, 1, "trunk", "")
             self.repos.generate_revision_id(3, "trunk")), 
           "dir": (generate_svn_file_id(self.repos.uuid, 2, "trunk", "dir"), 
                 self.repos.generate_revision_id(2, "trunk")),
index b18e3683c1217ae55b74f1a127f5238f972b8fd9..614d264592f830465e2b0425d32490ab397902c3 100644 (file)
@@ -42,7 +42,7 @@ class TestLogWalker(TestCaseWithSubversionRepository):
 
         walker = logwalker.LogWalker(transport=SvnRaTransport(repos_url))
 
-        self.assertEqual(1, len(list(walker.follow_path("", 1))))
+        self.assertEqual(2, len(list(walker.follow_path("", 1))))
 
     def test_get_revision_paths(self):
         repos_url = self.make_client("a", "dc")
@@ -74,7 +74,7 @@ class TestLogWalker(TestCaseWithSubversionRepository):
 
         walker = logwalker.LogWalker(transport=SvnRaTransport(repos_url))
 
-        self.assertEqual(1, len(list(walker.follow_path("", 1))))
+        self.assertEqual(2, len(list(walker.follow_path("", 1))))
 
     def test_branch_log_specific(self):
         repos_url = self.make_client("a", "dc")
@@ -274,8 +274,8 @@ class TestLogWalker(TestCaseWithSubversionRepository):
 
         for (branch, paths, rev) in walker.follow_path("", 1):
            self.assertEqual(branch, "")
-           self.assertTrue(paths.has_key("foo"))
-           self.assertEqual(rev, 1)
+           self.assertTrue(rev == 0 or paths.has_key("foo"))
+           self.assertTrue(rev in (0,1))
 
     def test_follow_history_nohist(self):
         repos_url = self.make_client("a", "dc")
@@ -294,8 +294,8 @@ class TestLogWalker(TestCaseWithSubversionRepository):
 
         for (branch, paths, rev) in walker.follow_path("", 1):
            self.assertEqual(branch, "")
-           self.assertTrue(paths.has_key("foo"))
-           self.assertEqual(rev, 1)
+           self.assertTrue(rev == 0 or paths.has_key("foo"))
+           self.assertTrue(rev in (0,1))
 
         iter = walker.follow_path("", 2)
         self.assertRaises(NoSuchRevision, list, iter)
@@ -404,6 +404,16 @@ class TestLogWalker(TestCaseWithSubversionRepository):
 
         self.assertEqual(("trunk", 1), walker.get_previous("anotherfile", 2))
 
+    def test_get_revision_info_zero(self):
+        repos_url = self.make_client("a", "dc")
+
+        walker = logwalker.LogWalker(transport=SvnRaTransport(repos_url))
+
+        info = walker.get_revision_info(0)
+
+        self.assertEqual("", info[0])
+        self.assertEqual(None, info[1])
+
     def test_get_revision_info(self):
         repos_url = self.make_client("a", "dc")
         self.build_tree({'dc/trunk/afile': "data"})
index df4bb1b02949a0984d796fb8a67e164316da07d1..8d58254836c34497894d2107ca111800dcb31981 100644 (file)
@@ -31,6 +31,7 @@ import svn.fs
 
 from convert import load_dumpfile
 import errors
+from fileids import generate_file_id, generate_svn_file_id
 import format
 from scheme import TrunkBranchingScheme, NoBranchingScheme
 from transport import SvnRaTransport
@@ -60,7 +61,7 @@ class TestSubversionRepositoryWorks(TestCaseWithSubversionRepository):
 
         repos = Repository.open(repos_url)
 
-        self.assertEqual(1, len(list(repos.follow_branch_history("", 1))))
+        self.assertEqual(2, len(list(repos.follow_branch_history("", 1))))
 
     def test_make_working_trees(self):
         repos_url = self.make_client("a", "dc")
@@ -73,6 +74,12 @@ class TestSubversionRepositoryWorks(TestCaseWithSubversionRepository):
         repos.set_make_working_trees(True)
         self.assertFalse(repos.make_working_trees())
 
+    def test_get_fileid_map(self):
+        repos_url = self.make_client("a", "dc")
+        repos = Repository.open(repos_url)
+        revid = repos.generate_revision_id(0, "")
+        self.assertEqual({"": (generate_file_id(revid, ""), revid)}, repos.get_fileid_map(0, ""))
+
     def test_add_revision(self):
         repos_url = self.make_client("a", "dc")
         repos = Repository.open(repos_url)
@@ -109,7 +116,7 @@ class TestSubversionRepositoryWorks(TestCaseWithSubversionRepository):
 
         repos = Repository.open(repos_url)
 
-        self.assertEqual(1, len(list(repos.follow_history(1))))
+        self.assertEqual(2, len(list(repos.follow_history(1))))
 
     def test_all_revs_empty(self):
         repos_url = self.make_client("a", "dc")
@@ -323,6 +330,9 @@ class TestSubversionRepositoryWorks(TestCaseWithSubversionRepository):
         self.client_commit("dc", "Second Message")
         repository = Repository.open("svn+%s" % repos_url)
         self.assertEqual([],
+                repository.revision_parents(
+                    repository.generate_revision_id(0, "")))
+        self.assertEqual([repository.generate_revision_id(0, "")],
                 repository.revision_parents(
                     repository.generate_revision_id(1, "")))
         self.assertEqual([
@@ -351,6 +361,9 @@ class TestSubversionRepositoryWorks(TestCaseWithSubversionRepository):
         self.client_commit("dc", "Second Message")
         repository = Repository.open("svn+%s" % repos_url)
         self.assertEqual([],
+                repository.revision_parents(
+                    repository.generate_revision_id(0, "")))
+        self.assertEqual([repository.generate_revision_id(0, "")],
                 repository.revision_parents(
                     repository.generate_revision_id(1, "")))
         self.assertEqual([repository.generate_revision_id(1, ""),
@@ -390,23 +403,30 @@ class TestSubversionRepositoryWorks(TestCaseWithSubversionRepository):
         self.client_commit("dc", "Third Message")
         repository = Repository.open("svn+%s" % repos_url)
         self.assertEqual([None, 
+            repository.generate_revision_id(0, ""),
             repository.generate_revision_id(1, ""),
             repository.generate_revision_id(2, "")],
                 repository.get_ancestry(
                     repository.generate_revision_id(3, "")))
         self.assertEqual([None, 
+            repository.generate_revision_id(0, ""),
             repository.generate_revision_id(1, "")],
                 repository.get_ancestry(
                     repository.generate_revision_id(2, "")))
-        self.assertEqual([None],
+        self.assertEqual([None,
+                    repository.generate_revision_id(0, "")],
                 repository.get_ancestry(
                     repository.generate_revision_id(1, "")))
+        self.assertEqual([None],
+                repository.get_ancestry(
+                    repository.generate_revision_id(0, "")))
         self.assertEqual([None], repository.get_ancestry(None))
 
     def test_get_revision_graph_empty(self):
         repos_url = self.make_client('d', 'dc')
         repository = Repository.open("svn+%s" % repos_url)
-        self.assertEqual({}, repository.get_revision_graph(NULL_REVISION))
+        self.assertEqual({generate_svn_file_id(repository.uuid, 0, "", ""): []}, 
+                repository.get_revision_graph(NULL_REVISION))
 
     def test_get_revision_graph_invalid(self):
         repos_url = self.make_client('d', 'dc')
@@ -417,7 +437,8 @@ class TestSubversionRepositoryWorks(TestCaseWithSubversionRepository):
     def test_get_revision_graph_all_empty(self):
         repos_url = self.make_client('d', 'dc')
         repository = Repository.open(repos_url)
-        self.assertEqual({}, repository.get_revision_graph())
+        self.assertEqual({generate_svn_file_id(repository.uuid, 0, "", ""): []}, 
+                repository.get_revision_graph())
 
     def test_get_revision_graph_all(self):
         repos_url = self.make_client('d', 'dc')
@@ -446,21 +467,29 @@ class TestSubversionRepositoryWorks(TestCaseWithSubversionRepository):
         self.client_commit("dc", "Third Message")
         repository = Repository.open("svn+%s" % repos_url)
         self.assertEqual({
+            repository.generate_revision_id(0, ""): [],
            repository.generate_revision_id(3, ""): [
                repository.generate_revision_id(2, "")],
            repository.generate_revision_id(2, ""): [
                repository.generate_revision_id(1, "")], 
-           repository.generate_revision_id(1, ""): []},
+           repository.generate_revision_id(1, ""): [
+               repository.generate_revision_id(0, "")]},
                 repository.get_revision_graph(
                     repository.generate_revision_id(3, "")))
         self.assertEqual({
+            repository.generate_revision_id(0, ""): [],
            repository.generate_revision_id(2, ""): [
                repository.generate_revision_id(1, "")],
-           repository.generate_revision_id(1, ""): []},
+           repository.generate_revision_id(1, ""): [
+                repository.generate_revision_id(0, "")
+               ]},
                 repository.get_revision_graph(
                     repository.generate_revision_id(2, "")))
         self.assertEqual({
-            repository.generate_revision_id(1, ""): []},
+            repository.generate_revision_id(0, ""): [],
+            repository.generate_revision_id(1, ""): [
+                repository.generate_revision_id(0, "")
+                ]},
                 repository.get_revision_graph(
                     repository.generate_revision_id(1, "")))
 
@@ -473,9 +502,13 @@ class TestSubversionRepositoryWorks(TestCaseWithSubversionRepository):
         self.client_commit("dc", "Second Message")
         repository = Repository.open("svn+%s" % repos_url)
         self.assertEqual([None],
+                repository.get_ancestry(
+                    repository.generate_revision_id(0, "")))
+        self.assertEqual([None, repository.generate_revision_id(0, "")],
                 repository.get_ancestry(
                     repository.generate_revision_id(1, "")))
         self.assertEqual([None, 
+            repository.generate_revision_id(0, ""),
             repository.generate_revision_id(1, "")], 
                 repository.get_ancestry(
                     repository.generate_revision_id(2, "")))
@@ -490,15 +523,18 @@ class TestSubversionRepositoryWorks(TestCaseWithSubversionRepository):
         self.client_commit("dc", "Second Message")
         repository = Repository.open("svn+%s" % repos_url)
         self.assertEqual([None],
+                repository.get_ancestry(
+                    repository.generate_revision_id(0, "")))
+        self.assertEqual([None, repository.generate_revision_id(0, "")],
                 repository.get_ancestry(
                     repository.generate_revision_id(1, "")))
         self.assertEqual([None, 
+            repository.generate_revision_id(0, ""),
             repository.generate_revision_id(1, ""), 
                           "a-parent"], 
                 repository.get_ancestry(
                     repository.generate_revision_id(2, "")))
 
-
     def test_get_inventory(self):
         repos_url = self.make_client('d', 'dc')
         repository = Repository.open("svn+%s" % repos_url)
@@ -535,11 +571,11 @@ class TestSubversionRepositoryWorks(TestCaseWithSubversionRepository):
                u"svn-v%d-undefined:%s:bla%%2Fbloe:1" % (MAPPING_VERSION, repository.uuid), 
             repository.generate_revision_id(1, "bla/bloe"))
 
-    def test_generate_revision_id_none(self):
+    def test_generate_revision_id_zero(self):
         repos_url = self.make_client('d', 'dc')
         repository = Repository.open("svn+%s" % repos_url)
-        self.assertEqual(NULL_REVISION
-                repository.generate_revision_id(0, "bla/bloe"))
+        self.assertEqual("svn-v%d-undefined:%s::0" % (MAPPING_VERSION, repository.uuid)
+                repository.generate_revision_id(0, ""))
 
     def test_parse_revision_id(self):
         repos_url = self.make_client('d', 'dc')
@@ -555,7 +591,7 @@ class TestSubversionRepositoryWorks(TestCaseWithSubversionRepository):
         repository = Repository.open("svn+%s" % repos_url)
         self.assertRaises(NoSuchRevision, 
             repository.parse_revision_id, 
-                generate_svn_revision_id("invaliduuid", 0, "bloe"))
+                generate_svn_revision_id("invaliduuid", 0, ""))
         
     def test_check(self):
         repos_url = self.make_client('d', 'dc')
@@ -1973,7 +2009,12 @@ class TestSvnRevisionTree(TestCaseWithSubversionRepository):
         self.assertEqual(self.inventory, self.tree.inventory)
 
     def test_get_parent_ids(self):
-        self.assertEqual([], self.tree.get_parent_ids())
+        self.assertEqual([self.repos.generate_revision_id(0, "")], self.tree.get_parent_ids())
+
+    def test_get_parent_ids_zero(self):
+        tree = self.repos.revision_tree(
+                self.repos.generate_revision_id(0, ""))
+        self.assertEqual([], tree.get_parent_ids())
 
     def test_get_revision_id(self):
         self.assertEqual(self.repos.generate_revision_id(1, ""),
index 2e74b922a0c57d921929d5dcd0722015e091b552..5b056ac00b23b0fdefbcef012ec5d1986373cc17 100644 (file)
@@ -250,7 +250,8 @@ class UpgradeTests(TestCaseWithSubversionRepository):
         wt.commit(message='fix it again', rev_id="anotherrev")
 
         upgrade_branch(b, oldrepos, allow_change=True)
-        self.assertEqual([oldrepos.generate_revision_id(1, ""),
+        self.assertEqual([oldrepos.generate_revision_id(0, ""),
+                          oldrepos.generate_revision_id(1, ""),
                           "customrev-svn%d-upgrade" % MAPPING_VERSION,
                           "anotherrev-svn%d-upgrade" % MAPPING_VERSION
                           ], b.revision_history())