Rev 432: Start filling in code to create the revid cache. in file:///home/jelmer/bzr-svn/customrevids/

Jelmer Vernooij jelmer at samba.org
Thu May 17 13:38:17 BST 2007


At file:///home/jelmer/bzr-svn/customrevids/

------------------------------------------------------------
revno: 432
revision-id: jelmer at samba.org-20070517123813-4iij1urq1vea0spi
parent: jelmer at samba.org-20070517110929-wc2u2ow9zbbausfn
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: customrevids
timestamp: Thu 2007-05-17 13:38:13 +0100
message:
  Start filling in code to create the revid cache.
modified:
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
  revids.py                      revids.py-20070416220458-36vfa0730cchevp1-1
=== modified file 'repository.py'
--- a/repository.py	2007-05-17 11:09:29 +0000
+++ b/repository.py	2007-05-17 12:38:13 +0000
@@ -41,7 +41,7 @@
 import errors
 import logwalker
 from revids import (generate_svn_revision_id, parse_svn_revision_id, 
-                    MAPPING_VERSION)
+                    MAPPING_VERSION, RevidMap)
 from tree import SvnRevisionTree
 
 SVN_PROP_BZR_PREFIX = 'bzr:'
@@ -145,6 +145,7 @@
 
         self.branchprop_list = BranchPropertyList(self._log, self.cachedb)
         self.fileid_map = SimpleFileIdMap(self, self.cachedb)
+        self.revmap = RevidMap(self.cachedb)
 
     def set_branching_scheme(self, scheme):
         self.scheme = scheme
@@ -214,9 +215,7 @@
                 ancestry.append(self.generate_revision_id(rev, branch))
 
         ancestry.append(None)
-
         ancestry.reverse()
-
         return ancestry
 
     def has_revision(self, revision_id):
@@ -389,6 +388,7 @@
         :return: Tuple with branch path and revision number.
         """
 
+        # Try a simple parse
         try:
             (uuid, branch_path, revnum) = parse_svn_revision_id(revid)
             if uuid == self.uuid:
@@ -396,8 +396,22 @@
         except InvalidRevisionId:
             pass
 
-        # FIXME: Look up in revision id map
-        return self.revmap.lookup_revid(revid)
+        # Check the record out of the revmap, if it exists
+        try:
+            (branch_path, min_revnum, max_revnum, scheme) = self.revmap.lookup_revid(revid)
+            # 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)
 
     def get_inventory_xml(self, revision_id):
         return bzrlib.xml5.serializer_v5.write_inventory_to_string(

=== modified file 'revids.py'
--- a/revids.py	2007-05-17 11:09:29 +0000
+++ b/revids.py	2007-05-17 12:38:13 +0000
@@ -88,16 +88,16 @@
         else:
             self.cachedb = cache_db
         self.cachedb.executescript("""
-        create table if not exists revmap (revid text, path text, revnum integer, scheme text);
+        create table if not exists revmap (revid text, path text, min_revnum integer, max_revnum integer, scheme text);
         create index if not exists revid on revmap (revid);
         """)
         self.cachedb.commit()
     
     def lookup_revid(self, revid):
         for branch, revnum, scheme in self.cachedb.execute(
-                "select path, revnum, scheme from revmap where revid='%s'" % revid):
-            return branch, revnum, scheme
+                "select path, min_revnum, max_revnum, scheme from revmap where revid='%s'" % revid):
+            return branch, min_revnum, max_revnum, scheme
         raise NoSuchRevision(self, revid)
 
-    def insert_revid(self, revid, branch, revnum, scheme):
-        self.cachedb.execute("insert into revmap (revid, path, revnum, scheme) VALUES (?, ?, ?, ?)", (revid, branch, revnum, scheme))
+    def insert_revid(self, revid, branch, min_revnum, max_revnum, scheme):
+        self.cachedb.execute("insert into revmap (revid, path, min_revnum, max_revnum, scheme) VALUES (?, ?, ?, ?, ?)", (revid, branch, min_revnum, max_revnum, scheme))




More information about the bazaar-commits mailing list