[MERGE] Root entry has a revision id
John Arbash Meinel
john at arbash-meinel.com
Mon Aug 14 19:38:29 BST 2006
Aaron Bentley wrote:
> Hi all,
>
> This is another patch in the make-root-less-weird series.
>
> This patch ensures that the root entry has a revision id in all
> RevisionTrees and BundleTrees.
>
> Since the stored inventory doesn't always have its revision id recorded,
> this is determined when the RevisionTree or BundleTree is generated.
>
> Updates to commit were necessary to ensure that the revision id was
> appropriately set there, as well.
>
> The inventory change is due to the commit changes. It
> 1. Allows inventories to be generated that don't have root entries
> 2. Allows root entries to be added the same way other entries are added.
>
> Although commit can now call record_entry_contents on a root entry, this
> does not create a weave or knit for the root entry. Similarly, other
> CommitBuilders may choose to ignore the root entry if appropriate.
>
> I have tried to maintain backwards compatibility two ways:
> 1. commit should work with old CommitBuilders (e.g. the bzr-svn one)
> 2. other CommitBuilder clients (are there any?) should work with new
> CommitBuilders.
>
> Oh, and I nuked a bare except and added some comments.
>
> Aaron
...
+
+
+class BundleInfo08(BundleInfo):
+ def _update_tree(self, bundle_tree, revision_id):
+ bundle_tree.note_last_changed('', revision_id)
+ BundleInfo._update_tree(self, bundle_tree, revision_id)
Why does BundleInfo08 need to exist, rather than just updating BundleInfo?
=== modified file 'bzrlib/commit.py'
--- bzrlib/commit.py 2006-08-05 22:33:36 +0000
+++ bzrlib/commit.py 2006-08-08 17:43:56 +0000
@@ -308,8 +308,11 @@
raise PointlessCommit()
self._emit_progress_update()
- # TODO: Now the new inventory is known, check for conflicts
and prompt the
- # user for a commit message.
+ # TODO: Now the new inventory is known, check for conflicts and
+ # prompt the user for a commit message.
+ # ADHB 2006-08-08: If this is done, populate_new_inv should
not add
+ # weave lines, because nothing should be recorded until it
is known
+ # that commit will succeed.
self.builder.finish_inventory()
self._emit_progress_update()
self.rev_id = self.builder.commit(self.message)
@@ -502,10 +505,13 @@
# in bugs like #46635. Any reason not to use/enhance
Tree.changes_from?
# ADHB 11-07-2006
mutter("Selecting files for commit with filter %s",
self.specific_files)
- # at this point we dont copy the root entry:
entries = self.work_inv.iter_entries()
- entries.next()
- self._emit_progress_update()
+ if not self.builder.record_root_entry:
+ warnings.warn('CommitBuilders should support recording the
root'
+ ' entry as of bzr 0.10.', DeprecationWarning, stacklevel=2)
+ self.builder.new_inventory.add(self.basis_inv.root.copy())
+ entries.next()
+ self._emit_progress_update()
for path, new_ie in entries:
self._emit_progress_update()
file_id = new_ie.file_id
I'm guessing this should actually be stacklevel=1. Since the direct
caller is the one that is being warned. stacklevel=2 is generally used
for wrappers, IIRC.
...
v- Same thing about stacklevel here.
def finish_inventory(self):
"""Tell the builder that the inventory is finished."""
+ if self.new_inventory.root is None:
+ warn('Root entry should be supplied to
record_entry_contents, as'
+ ' of bzr 0.10.',
+ DeprecationWarning, stacklevel=2)
+ self.new_inventory.add(InventoryDirectory(ROOT_ID, '', None))
...
v- I'm pretty sure we're using 'assertEqual(expected, actual)'
+ def test_root_entry_has_revision(self):
+ tree = self.make_branch_and_tree('.')
+ tree.commit('message', rev_id='rev_id')
+ self.assertEqual(tree.basis_tree().inventory.root.revision,
'rev_id')
+ rev_tree =
tree.branch.repository.revision_tree(tree.last_revision())
+ self.assertEqual(rev_tree.inventory.root.revision, 'rev_id')
+
class TestCaseWithComplexRepository(TestCaseWithRepository):
So the NewCommitBuilder => _CommitBuilder stuff needs to happen. And a
couple other small things. Otherwise +1 from me.
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060814/bf6ca8f7/attachment.pgp
More information about the bazaar
mailing list