Rev 476: Try to avoid using revision_history() for performance reasons. in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev

Jelmer Vernooij jelmer at samba.org
Fri Jun 1 14:30:38 BST 2007


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

------------------------------------------------------------
revno: 476
revision-id: jelmer at samba.org-20070601133034-bhha7815r794nxny
parent: jelmer at samba.org-20070530234844-fdypogjbpz4bqibi
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Fri 2007-06-01 15:30:34 +0200
message:
  Try to avoid using revision_history() for performance reasons.
modified:
  branch.py                      svnbranch.py-20051017135706-11c749eb0dab04a7
  checkout.py                    workingtree.py-20060306120941-b083cb0fdd4a69de
  commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
  convert.py                     svn2bzr.py-20051018015439-cb4563bff29e632d
  fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
  revids.py                      revids.py-20070416220458-36vfa0730cchevp1-1
  upgrade.py                     upgrade.py-20070106192108-0rakplee2lzah4gs-1
=== modified file 'branch.py'
--- a/branch.py	2007-05-30 18:10:08 +0000
+++ b/branch.py	2007-06-01 13:30:34 +0000
@@ -79,14 +79,14 @@
         checkout_branch.pull(self, stop_revision=revision_id)
         return checkout.create_workingtree(revision_id)
 
-    """Look up the matching revision number on the mainline of the 
-    branch.
-
-    :param revid: Revision id to look up.
-    :return: Revision number on the branch. 
-    :raises NoSuchRevision: If the revision id was not found.
-    """
     def lookup_revision_id(self, revid):
+        """Look up the matching revision number on the mainline of the 
+        branch.
+
+        :param revid: Revision id to look up.
+        :return: Revision number on the branch. 
+        :raises NoSuchRevision: If the revision id was not found.
+        """
         (bp, revnum) = self.repository.lookup_revision_id(revid)
         assert bp.strip("/") == self.branch_path.strip("/"), \
                 "Got %r, expected %r" % (bp, self.branch_path)
@@ -103,7 +103,6 @@
             revnum = self.lookup_revision_id(revision_id)
             rev.kind = svn.core.svn_opt_revision_number
             rev.value.number = revnum
-            mutter('hist: %r' % self.revision_history())
 
         client_ctx = svn.client.create_context()
         client_ctx.config = svn_config
@@ -121,6 +120,7 @@
 
     def generate_revision_id(self, revnum):
         """Generate a new revision id for a revision on this branch."""
+        assert isinstance(revnum, int)
         # FIXME: What if this branch had a different name in the past?
         return self.repository.generate_revision_id(revnum, self.branch_path)
        
@@ -175,13 +175,14 @@
                 return self.repository.generate_revision_id(rev, branch)
             return None
 
-        ph = self.revision_history()
+        ph = self._revision_history
         if ph:
             return ph[-1]
         else:
             return None
 
-    def pull(self, source, overwrite=False, stop_revision=None):
+    def pull(self, source, overwrite=False, stop_revision=None, 
+             _hook_master=None, _run_hooks=True):
         result = PullResult()
         result.source_branch = source
         result.master_branch = None
@@ -220,7 +221,6 @@
             return
         if isinstance(other, SvnBranch) and \
             other.repository.uuid == self.repository.uuid:
-
             # FIXME: Make sure branches haven't diverged
             # FIXME: svn.ra.del_dir(self.base_path)
             # FIXME: svn.ra.copy_dir(other.base_path, self.base_path)
@@ -260,19 +260,6 @@
         self.copy_content_into(result, revision_id=revision_id)
         return result
 
-    def copy_content_into(self, destination, revision_id=None):
-        new_history = self.revision_history()
-        if revision_id is not None:
-            try:
-                new_history = new_history[:new_history.index(revision_id) + 1]
-            except ValueError:
-                rev = self.repository.get_revision(revision_id)
-                new_history = rev.get_history(self.repository)[1:]
-        destination.set_revision_history(new_history)
-        parent = self.get_parent()
-        if parent:
-            destination.set_parent(parent)
-
     def __str__(self):
         return '%s(%r)' % (self.__class__.__name__, self.base)
 

=== modified file 'checkout.py'
--- a/checkout.py	2007-05-30 18:10:08 +0000
+++ b/checkout.py	2007-06-01 13:30:34 +0000
@@ -463,16 +463,17 @@
 
         self.client_ctx.log_msg_baton2 = None
 
-        revid = self.branch.repository.generate_revision_id(
-                commit_info.revision, self.branch.branch_path)
+        revid = self.branch.generate_revision_id(commit_info.revision)
 
         self.base_revid = revid
         self.base_revnum = commit_info.revision
         self.base_tree = SvnBasisTree(self)
 
+        self.branch.repository._latest_revnum = commit_info.revision
+
         #FIXME: Use public API:
-        self.branch.revision_history()
-        self.branch._revision_history.append(revid)
+        if self.branch._revision_history is not None:
+            self.branch._revision_history.append(revid)
 
         return revid
 

=== modified file 'commit.py'
--- a/commit.py	2007-05-18 18:01:27 +0000
+++ b/commit.py	2007-06-01 13:30:34 +0000
@@ -339,12 +339,13 @@
         svn.delta.editor_invoke_close_edit(self.editor, editor_baton)
 
         assert self.revnum is not None
-        revid = self.repository.generate_revision_id(self.revnum, 
-                                                    self.branch.branch_path)
+        revid = self.branch.generate_revision_id(self.revnum)
+
+        self.repository._latest_revnum = self.revnum
 
         #FIXME: Use public API:
-        self.branch.revision_history()
-        self.branch._revision_history.append(revid)
+        if self.branch._revision_history is not None:
+            self.branch._revision_history.append(revid)
 
         mutter('commit %d finished. author: %r, date: %r' % 
                (self.revnum, self.author, self.date))

=== modified file 'convert.py'
--- a/convert.py	2007-05-17 16:52:31 +0000
+++ b/convert.py	2007-06-01 13:30:34 +0000
@@ -136,6 +136,7 @@
                 except NotBranchError:
                     target_branch = target_dir.create_branch()
                     target_branch.set_parent(source_branch_url)
+                # FIXME: don't use revision_history()
                 if not revid in target_branch.revision_history():
                     source_branch = Branch.open(source_branch_url)
                     # Check if target_branch contains a subset of 

=== modified file 'fetch.py'
--- a/fetch.py	2007-05-19 00:12:08 +0000
+++ b/fetch.py	2007-06-01 13:30:34 +0000
@@ -467,7 +467,6 @@
     @staticmethod
     def is_compatible(source, target):
         """Be compatible with SvnRepository."""
-        mutter("Checking from %r %r" % (source, target))
         # FIXME: Also check target uses VersionedFile
         return isinstance(source, SvnRepository)
 

=== modified file 'revids.py'
--- a/revids.py	2007-05-20 21:32:33 +0000
+++ b/revids.py	2007-06-01 13:30:34 +0000
@@ -16,6 +16,7 @@
 
 from bzrlib.errors import (InvalidRevisionId, NoSuchRevision, 
                            NotBranchError, UninitializableFormat)
+from bzrlib.trace import mutter
 
 MAPPING_VERSION = 3
 REVISION_ID_PREFIX = "svn-v%d-" % MAPPING_VERSION
@@ -90,6 +91,7 @@
         self.cachedb.commit()
     
     def lookup_revid(self, revid):
+        mutter('lookup branch revid %r' % revid)
         ret = self.cachedb.execute(
             "select path, min_revnum, max_revnum, scheme from revmap where revid='%s'" % revid).fetchone()
         if ret is None:
@@ -97,6 +99,7 @@
         return (str(ret[0]), ret[1], ret[2], ret[3])
 
     def lookup_branch_revnum(self, revnum, path):
+        mutter('lookup branch revnum %r, %r' % (revnum, path))
         # FIXME: SCHEME MISSING
         revid = self.cachedb.execute(
                 "select revid from revmap where max_revnum = min_revnum and min_revnum='%s' and path='%s'" % (revnum, path)).fetchone()

=== modified file 'upgrade.py'
--- a/upgrade.py	2007-05-30 23:18:47 +0000
+++ b/upgrade.py	2007-06-01 13:30:34 +0000
@@ -63,7 +63,6 @@
             if newinv.has_filename(path):
                 new_id[ie.file_id] = newinv.path2id(path)
 
-    mutter('new id %r' % new_id)
     i = 0
     class MapTree:
         def __init__(self, oldtree, map):
@@ -91,26 +90,25 @@
     oldinv = repository.get_revision_inventory(oldrevid)
     total = len(oldinv)
     pb = ui.ui_factory.nested_progress_bar()
+    transact = repository.get_transaction()
     try:
         for path, ie in oldinv.iter_entries():
-            pb.update('upgrading revision', i, total)
+            pb.update('upgrading file', i, total)
             i += 1
             new_ie = ie.copy()
             if new_ie.revision == oldrevid:
                 new_ie.revision = None
             def lookup(file_id):
-                if new_id.has_key(file_id):
+                try:
                     return new_id[file_id]
-                return file_id
+                except KeyError:
+                    return file_id
 
             new_ie.file_id = lookup(new_ie.file_id)
             new_ie.parent_id = lookup(new_ie.parent_id)
-            versionedfile = repository.weave_store.get_weave_or_empty(new_ie.file_id, 
-                    repository.get_transaction())
-            if not versionedfile.has_version(newrevid):
-                builder.record_entry_contents(new_ie, 
-                       map(repository.get_revision_inventory, new_parents), 
-                       path, oldtree)
+            builder.record_entry_contents(new_ie, 
+                   map(repository.get_revision_inventory, new_parents), 
+                   path, oldtree)
     finally:
         pb.finished()
 
@@ -171,11 +169,12 @@
     :param svn_repository: Repository to fetch new revisions from
     :param allow_change: Allow changes in mappings.
     """
+    revid = branch.last_revision()
     renames = upgrade_repository(branch.repository, svn_repository, 
-              branch.last_revision(), allow_change)
+              revid, allow_change)
     mutter('renames %r' % renames)
     if len(renames) > 0:
-        branch.generate_revision_history(renames[branch.last_revision()])
+        branch.generate_revision_history(renames[revid])
 
 
 def revision_changed(oldrev, newrev):




More information about the bazaar-commits mailing list