Rev 1515: Cache mapping as well in revision, split up lhs_revision_parent function. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk

Jelmer Vernooij jelmer at samba.org
Sat Aug 2 02:15:24 BST 2008


At http://people.samba.org/bzr/jelmer/bzr-svn/trunk

------------------------------------------------------------
revno: 1515
revision-id: jelmer at samba.org-20080802011519-qk0rb9n9ychtgn38
parent: jelmer at samba.org-20080802004146-v8h0ol221bjxpdbi
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Sat 2008-08-02 03:15:19 +0200
message:
  Cache mapping as well in revision, split up lhs_revision_parent function.
modified:
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
=== modified file 'repository.py'
--- a/repository.py	2008-08-02 00:41:46 +0000
+++ b/repository.py	2008-08-02 01:15:19 +0000
@@ -16,7 +16,7 @@
 """Subversion repository access."""
 
 import bzrlib
-from bzrlib import osutils, ui, urlutils, xml7
+from bzrlib import delta, osutils, ui, urlutils, xml7
 from bzrlib.branch import Branch, BranchCheckResult
 from bzrlib.errors import (InvalidRevisionId, NoSuchRevision, NotBranchError, 
                            UninitializableFormat)
@@ -462,6 +462,20 @@
 
         return SvnRevisionTree(self, revision_id)
 
+    def branch_prev_location(self, path, revnum, mapping):
+        assert isinstance(path, str)
+        assert isinstance(revnum, int)
+
+        iterator = self.iter_reverse_branch_changes(path, revnum, to_revnum=0,
+                                                    mapping=mapping, limit=2)
+        revmeta = iterator.next()
+        assert revmeta.branch_path == path
+        assert revmeta.revnum == revnum
+        try:
+            return iterator.next()
+        except StopIteration:
+            return None
+
     def lhs_revision_parent(self, path, revnum, mapping):
         """Find the mainline parent of the specified revision.
 
@@ -471,18 +485,10 @@
         :return: Revision id of the left-hand-side parent or None if 
                   this is the first revision
         """
-        assert isinstance(path, str)
-        assert isinstance(revnum, int)
-
-        iterator = self.iter_reverse_branch_changes(path, revnum, to_revnum=0,
-                                                    mapping=mapping, limit=2)
-        revmeta = iterator.next()
-        assert revmeta.branch_path == path
-        assert revmeta.revnum == revnum
-        try:
-            return iterator.next().get_revision_id(mapping)
-        except StopIteration:
+        parentrevmeta = self.branch_prev_location(path, revnum)
+        if parentrevmeta is None:
             return NULL_REVISION
+        return parentrevmeta.get_revision_id(mapping)
 
     def get_parent_map(self, revids):
         parent_map = {}
@@ -542,6 +548,7 @@
                        inventory_sha1="")
 
         rev.svn_meta = revmeta
+        rev.svn_mapping = mapping
         rev.svn_uuid = self.uuid
 
         mapping.import_revision(svn_revprops, svn_fileprops, self.uuid, path, 




More information about the bazaar-commits mailing list