Rev 2812: (robertc) Use a better api during commit to reduce overhead when adding texts. (Robert Collins) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Sep 11 03:00:31 BST 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2812
revision-id: pqm at pqm.ubuntu.com-20070911020027-bmt9h0jgy3zdlge3
parent: pqm at pqm.ubuntu.com-20070911010353-6lu7ek40rbjhj86o
parent: robertc at robertcollins.net-20070911002917-53h2vb7ex4xh00u7
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2007-09-11 03:00:27 +0100
message:
  (robertc) Use a better api during commit to reduce overhead when adding texts. (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/repofmt/weaverepo.py    presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
    ------------------------------------------------------------
    revno: 2803.2.2
    merged: robertc at robertcollins.net-20070911002917-53h2vb7ex4xh00u7
    parent: robertc at robertcollins.net-20070909220156-wmm9up3q0mzisrb2
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: commit-builder
    timestamp: Tue 2007-09-11 10:29:17 +1000
    message:
      Add comment for igc.
    ------------------------------------------------------------
    revno: 2803.2.1
    merged: robertc at robertcollins.net-20070909220156-wmm9up3q0mzisrb2
    parent: pqm at pqm.ubuntu.com-20070906050530-q58gvki4dedc4i6e
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: commit-builder
    timestamp: Mon 2007-09-10 08:01:56 +1000
    message:
      * CommitBuilder now advertises itself as requiring the root entry to be
        supplied. This only affects foreign repository implementations which reuse
        CommitBuilder directly and have changed record_entry_contents to require
        that the root not be supplied. This should be precisely zero plugins
        affected. (Robert Collins)
      
      * CommitBuilder now defaults to using add_lines_with_ghosts, reducing
        overhead on non-weave repositories which don't require all parents to be
        present. (Robert Collins)
=== modified file 'NEWS'
--- a/NEWS	2007-09-11 00:15:56 +0000
+++ b/NEWS	2007-09-11 02:00:27 +0000
@@ -188,6 +188,12 @@
    * ``Branch.append_revision`` is removed altogether; please use 
      ``Branch.set_last_revision_info`` instead.  (Martin Pool)
 
+   * CommitBuilder now advertises itself as requiring the root entry to be
+     supplied. This only affects foreign repository implementations which reuse
+     CommitBuilder directly and have changed record_entry_contents to require
+     that the root not be supplied. This should be precisely zero plugins
+     affected. (Robert Collins)
+
    * The ``add_lines`` methods on ``VersionedFile`` implementations has changed
      its return value to include the sha1 and length of the inserted text. This
      allows the avoidance of double-sha1 calculations during commit.
@@ -228,10 +234,14 @@
      This is done in order to mix the commit messages (which is a unicode
      string), and the diff which is a raw string. (Goffredo Baroncelli)
 
-    * Deprecated method ``find_previous_heads`` on
-      ``bzrlib.inventory.InventoryEntry``. This has been superseded by the use
-      of ``parent_candidates`` and a separate heads check via the repository
-      API. (Robert Collins)
+   * CommitBuilder now defaults to using add_lines_with_ghosts, reducing
+     overhead on non-weave repositories which don't require all parents to be
+     present. (Robert Collins)
+
+   * Deprecated method ``find_previous_heads`` on
+     ``bzrlib.inventory.InventoryEntry``. This has been superseded by the use
+     of ``parent_candidates`` and a separate heads check via the repository
+     API. (Robert Collins)
 
    * New trace function ``mutter_callsite`` will print out a subset of the
      stack to the log, which can be useful for gathering debug details.

=== modified file 'bzrlib/repofmt/weaverepo.py'
--- a/bzrlib/repofmt/weaverepo.py	2007-08-15 04:56:08 +0000
+++ b/bzrlib/repofmt/weaverepo.py	2007-09-09 22:01:56 +0000
@@ -14,8 +14,11 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+"""Deprecated weave-based repository formats.
 
-"""Old weave-based repository formats"""
+Weave based formats scaled linearly with history size and could not represent
+ghosts.
+"""
 
 from StringIO import StringIO
 
@@ -23,12 +26,14 @@
     bzrdir,
     lockable_files,
     lockdir,
+    osutils,
     weave,
     weavefile,
     xml5,
     )
 from bzrlib.decorators import needs_read_lock, needs_write_lock
 from bzrlib.repository import (
+    CommitBuilder,
     MetaDirRepository,
     MetaDirRepositoryFormat,
     Repository,
@@ -73,8 +78,11 @@
                            timezone=None, committer=None, revprops=None,
                            revision_id=None):
         self._check_ascii_revisionid(revision_id, self.get_commit_builder)
-        return Repository.get_commit_builder(self, branch, parents, config,
-            timestamp, timezone, committer, revprops, revision_id)
+        revision_id = osutils.safe_revision_id(revision_id)
+        result = WeaveCommitBuilder(self, parents, config, timestamp, timezone,
+                              committer, revprops, revision_id)
+        self.start_write_group()
+        return result
 
     @needs_read_lock
     def is_shared(self):
@@ -107,8 +115,11 @@
                            timezone=None, committer=None, revprops=None,
                            revision_id=None):
         self._check_ascii_revisionid(revision_id, self.get_commit_builder)
-        return MetaDirRepository.get_commit_builder(self, branch, parents,
-            config, timestamp, timezone, committer, revprops, revision_id)
+        revision_id = osutils.safe_revision_id(revision_id)
+        result = WeaveCommitBuilder(self, parents, config, timestamp, timezone,
+                              committer, revprops, revision_id)
+        self.start_write_group()
+        return result
 
 
 class PreSplitOutRepositoryFormat(RepositoryFormat):
@@ -398,6 +409,18 @@
             text_store=text_store)
 
 
+class WeaveCommitBuilder(CommitBuilder):
+    """A builder for weave based repos that don't support ghosts."""
+
+    def _add_text_to_weave(self, file_id, new_lines, parents):
+        versionedfile = self.repository.weave_store.get_weave_or_empty(
+            file_id, self.repository.get_transaction())
+        result = versionedfile.add_lines(
+            self._new_revision_id, parents, new_lines)[0:2]
+        versionedfile.clear_cache()
+        return result
+
+
 _legacy_formats = [RepositoryFormat4(),
                    RepositoryFormat5(),
                    RepositoryFormat6()]

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2007-09-03 22:17:20 +0000
+++ b/bzrlib/repository.py	2007-09-11 00:29:17 +0000
@@ -447,8 +447,8 @@
     def create_bundle(self, target, base, fileobj, format=None):
         return serializer.write_bundle(self, target, base, fileobj, format)
 
-    def get_commit_builder(self, branch, parents, config, timestamp=None, 
-                           timezone=None, committer=None, revprops=None, 
+    def get_commit_builder(self, branch, parents, config, timestamp=None,
+                           timezone=None, committer=None, revprops=None,
                            revision_id=None):
         """Obtain a CommitBuilder for this repository.
         
@@ -462,7 +462,7 @@
         :param revision_id: Optional revision id.
         """
         revision_id = osutils.safe_revision_id(revision_id)
-        result =_CommitBuilder(self, parents, config, timestamp, timezone,
+        result = CommitBuilder(self, parents, config, timestamp, timezone,
                               committer, revprops, revision_id)
         self.start_write_group()
         return result
@@ -2073,7 +2073,9 @@
     know the internals of the format of the repository.
     """
     
-    record_root_entry = False
+    # all clients should supply tree roots.
+    record_root_entry = True
+
     def __init__(self, repository, parents, config, timestamp=None, 
                  timezone=None, committer=None, revprops=None, 
                  revision_id=None):
@@ -2295,26 +2297,18 @@
     def _add_text_to_weave(self, file_id, new_lines, parents):
         versionedfile = self.repository.weave_store.get_weave_or_empty(
             file_id, self.repository.get_transaction())
-        result = versionedfile.add_lines(
+        # Don't change this to add_lines - add_lines_with_ghosts is cheaper
+        # than add_lines, and allows committing when a parent is ghosted for
+        # some reason.
+        result = versionedfile.add_lines_with_ghosts(
             self._new_revision_id, parents, new_lines)[0:2]
         versionedfile.clear_cache()
         return result
 
 
-class _CommitBuilder(CommitBuilder):
-    """Temporary class so old CommitBuilders are detected properly
-    
-    Note: CommitBuilder works whether or not root entry is recorded.
-    """
-
-    record_root_entry = True
-
-
 class RootCommitBuilder(CommitBuilder):
     """This commitbuilder actually records the root id"""
     
-    record_root_entry = True
-
     def _check_root(self, ie, parent_invs, tree):
         """Helper for record_entry_contents.
 




More information about the bazaar-commits mailing list