Rev 2787: Move content summary generation outside of record_entry_contents. in http://people.ubuntu.com/~robertc/baz2.0/commit

Robert Collins robertc at robertcollins.net
Thu Sep 6 02:09:16 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/commit

------------------------------------------------------------
revno: 2787
revision-id: robertc at robertcollins.net-20070906010906-2so4bg4lr3y8wlqd
parent: robertc at robertcollins.net-20070905230807-xxl20o4evg2wrswh
committer: Robert Collins <robertc at robertcollins.net>
branch nick: commit
timestamp: Thu 2007-09-06 11:09:06 +1000
message:
  Move content summary generation outside of record_entry_contents.
modified:
  bzrlib/commit.py               commit.py-20050511101309-79ec1a0168e0e825
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/tests/repository_implementations/test_commit_builder.py test_commit_builder.py-20060606110838-76e3ra5slucqus81-1
=== modified file 'bzrlib/commit.py'
--- a/bzrlib/commit.py	2007-09-05 23:08:07 +0000
+++ b/bzrlib/commit.py	2007-09-06 01:09:06 +0000
@@ -713,13 +713,17 @@
                     continue
             # TODO: have the builder do the nested commit just-in-time IF and
             # only if needed.
-            try:
-                kind = self.work_tree.kind(file_id)
-                # TODO: specific_files filtering before nested tree processing
-                if kind == 'tree-reference' and self.builder.recursive == 'down':
-                    self._commit_nested_tree(file_id, path)
-            except errors.NoSuchFile:
-                pass
+            content_summary = self.work_tree.path_content_summary(path)
+            if content_summary[0] == 'tree-reference':
+                # enforce repository nested tree policy.
+                if (not self.work_tree.supports_tree_reference() or
+                    # repository does not support it either.
+                    not self.branch.repository._format.supports_tree_reference()):
+                    content_summary = ('directory',) + content_summary[1:]
+            kind = content_summary[0]
+            # TODO: specific_files filtering before nested tree processing
+            if kind == 'tree-reference' and self.builder.recursive == 'down':
+                self._commit_nested_tree(file_id, path)
 
             # Record an entry for this item
             # Note: I don't particularly want to have the existing_ie
@@ -727,7 +731,7 @@
             # without it thanks to a unicode normalisation issue. :-(
             definitely_changed = kind != existing_ie.kind
             self._record_entry(path, file_id, specific_files, kind, name,
-                parent_id, definitely_changed, existing_ie)
+                parent_id, definitely_changed, existing_ie, content_summary)
 
         # Unversion IDs that were found to be deleted
         self.work_tree.unversion(deleted_ids)
@@ -758,7 +762,7 @@
             pass
 
     def _record_entry(self, path, file_id, specific_files, kind, name,
-                      parent_id, definitely_changed, existing_ie=None):
+        parent_id, definitely_changed, existing_ie, content_summary):
         "Record the new inventory entry for a path if any."
         # mutter('check %s {%s}', path, file_id)
         if (not specific_files or 
@@ -777,8 +781,8 @@
                 # this entry is new and not being committed
                 ie = None
         if ie is not None:
-            self.builder.record_entry_contents(ie, self.parent_invs, 
-                path, self.work_tree)
+            self.builder.record_entry_contents(ie, self.parent_invs,
+                path, self.work_tree, content_summary)
             self._report_change(ie, path)
         return ie
 

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2007-09-05 05:51:34 +0000
+++ b/bzrlib/repository.py	2007-09-06 01:09:06 +0000
@@ -2198,14 +2198,15 @@
                 ' record_entry_contents, as of bzr 0.10.',
                  DeprecationWarning, stacklevel=2)
             self.record_entry_contents(tree.inventory.root.copy(), parent_invs,
-                                       '', tree)
+                '', tree, tree.path_content_summary(''))
         else:
             # In this revision format, root entries have no knit or weave When
             # serializing out to disk and back in root.revision is always
             # _new_revision_id
             ie.revision = self._new_revision_id
 
-    def record_entry_contents(self, ie, parent_invs, path, tree):
+    def record_entry_contents(self, ie, parent_invs, path, tree,
+        content_summary):
         """Record the content of ie from tree into the commit if needed.
 
         Side effect: sets ie.revision when unchanged
@@ -2215,11 +2216,12 @@
             commit.
         :param path: The path the entry is at in the tree.
         :param tree: The tree which contains this entry and should be used to 
-        obtain content.
+            obtain content.
+        :param content_summary: Summary data from the tree about the paths
+            content - stat, length, exec, sha/link target.
         """
         if self.new_inventory.root is None:
             self._check_root(ie, parent_invs, tree)
-        content_summary = tree.path_content_summary(path)
         kind = content_summary[0]
         # XXX: repository specific check for nested tree support goes here - if
         # the repo doesn't want nested trees we skip it ?

=== modified file 'bzrlib/tests/repository_implementations/test_commit_builder.py'
--- a/bzrlib/tests/repository_implementations/test_commit_builder.py	2007-09-05 05:51:34 +0000
+++ b/bzrlib/tests/repository_implementations/test_commit_builder.py	2007-09-06 01:09:06 +0000
@@ -46,7 +46,8 @@
                 tree.unlock()
             parent_tree = tree.branch.repository.revision_tree(None)
             parent_invs = []
-            builder.record_entry_contents(ie, parent_invs, '', tree)
+            builder.record_entry_contents(ie, parent_invs, '', tree,
+                tree.path_content_summary(''))
 
     def test_finish_inventory(self):
         tree = self.make_branch_and_tree(".")
@@ -127,7 +128,8 @@
             builder = tree.branch.get_commit_builder([])
             self.callDeprecated(['Root entry should be supplied to'
                 ' record_entry_contents, as of bzr 0.10.'],
-                builder.record_entry_contents, entry, [], 'foo', tree)
+                builder.record_entry_contents, entry, [], 'foo', tree,
+                    tree.path_content_summary('foo'))
             builder.finish_inventory()
             rev_id = builder.commit('foo bar')
         finally:



More information about the bazaar-commits mailing list