Created: 2010-03-26 by gagern
Contributors: Jelmer Vernooij
Status: DraftBzrSpecification
Summary
This spec recommends the introduction of an API to determine when the contents of a directory was last modified, similar to the way svn handles things.
Rationale
This information is required for trac-bzr, as Trac is using subversion semantics. It is also required for bzr-git in order to create git tree objects. And it might be of interest to users as well, so frontend might to provide it.
Further Details
As outlined, there is a number of parties interested in obtaining this information. How to best obtain it might change as bzr develops, so having the API inside bzr not only removes code redundancy but also ensures that apps will use the method most suitable for their bazaar implementation.
Definition
From a theoretical point of view, we are talking about a map (d, r1) -> r2, mapping tuples of directory file identifiers and "current" revision identifiers to "last modified" revision identifiers. The result r2 should be the most recent revision to modify the directory d.
- Renaming a dir modifies the dir
- Renaming a parent of a dir modifies the dir
- Modifying, creating or deleting a file or directory within a dir modifies the dir
- Merging content into a dir modifies the dir unless all content is taken from the same parent, i.e. unless the dir has the same content as it had in one of the parents
- If two parents have the same content for a directory, recursion should choose the first one
Use Cases
Implementation
A method in InventoryEntry would be the most suitable place to implement this. For files, this would simply return revision.
Caches and Plugins
The implementation should provide a hook, so plugins can help provide the data in question.
It is assumed that obtaining this information from large bzr repositories using the current data format will take considerable time. So the function is expected to perform rather poorly, albeit perhaps better than what application developers would do on their own.
In order to improve performace, a caching plugin could be written to make that information more readily available. Different plugins could be devised for this hook, trying out different approaches and balancing speed versus resource consumption in different ways.
UI Changes
No changes required, although some UI to display this information e.g. in ls is conceivable later on.
Code Changes
Added method: InventoryEntry.get_last_modified()
Discussion
Some IRC discussion: http://irclogs.ubuntu.com/2010/03/26/%23bzr.html#t17:25
Unresolved Issues
