[RFC] Inventory delta support for CommitBuilder

Ian Clatworthy ian.clatworthy at internode.on.net
Mon Aug 27 05:51:59 BST 2007


Attached are some changes I'd like some feedback on before I proceed with:

* writing more supporting tests
* making associated changes to commit.py.

The background to this is that we want to change commit so that the main
iterator only tells us about things that have changed or may have
changed. The implication is that CommitBuilder needs to accept an
inventory delta (against the current basis inventory) rather than build
the new inventory from scratch each time by looping over every item.

In terms of an API, the current algorithm is:

  builder = repository.get_commit_builder(...)
  for each item in the new inventory:
      builder.record_entry_contents(...)
  builder.finish_inventory()
  builder.commit(...)

The proposed new algorithm is:

  builder = repository.get_commit_builder(new_inv_from_scratch=False)
  # determine changes (deletions/modifications/additions) via
  # something like ...
  for each potential difference:
      builder.update_entry_contents(...)
  builder.finish_inventory(changes)
  builder.commit(...)

That implies the following:

1. The logic in apply_inventory_delta() on MutableTree should largely
   move down to Inventory.apply_delta(). BTW, as well as being called
   inside builder.finish_inventory(), I want Inventory.apply_delta()
   so that certain changes detected during commit processing (e.g.
   SHAs & sizes of new files) can be passed back to the working tree
   as an atomic transaction.

2. Most of the logic in CommitBuilder.record_entry_contents() should
   be moved into update_entry_contents(). This new routine doesn't
   add the InventoryEntry to builder.new_inventory but does still
   update the repository with the new content, if any.

3. repository.get_commit_builder() should support a new flag indicating
   what mode the CommitBuilder is to be used in: building the
   inventory from scratch each time or otherwise. I think we need to
   do this to provide a transition period for plug-ins to move to the
   new incremental way of doing things.

Does that all make sense? If so, is it consistent enough with the
direction being taken with packs & inventories? I'm guessing here that
the above might just be an incremental step but it does seem a necessary
one yes?

If anyone wants to apply the attached bundle, go ahead. All tests pass
including some new ones for testing CommitBuilders built with
new_inv_from_scratch=False. Having said that, applying the bundle won't
buy you anything just yet performance wise (because the commit.py code
still uses the old API and will do until the new stuff is better tested).

Ian C.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: inv_delta_commit_rfc.patch
Type: text/x-patch
Size: 36683 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070827/d1a4328a/attachment-0001.bin 


More information about the bazaar mailing list