Storage internals: UUID

Neil Martinsen-Burrell n.martinsen-burrell at
Fri Jun 8 04:55:31 UTC 2012

On Thu, Jun 7, 2012 at 7:32 PM, Daniel Carrera <dcarrera at> wrote:
> Hi Neil,
> On Friday, June 08, 2012 at 1:34 AM, Neil Martinsen-Burrell <nmb at> wrote:
>> Bazaar has a facility for defining new "revisionspecs" in plugins.
>> This means that you could define a way to specify revisions using
>> the "-r sha:165c2a8" syntax. See the code in bzrlib/ for
>> examples of how the existing "-r <type>:" revision specs work.  The
>> important method to define in your subclass of RevisionSpec is
>> RevisionSpec._as_revision_id(self, context_branch).  Then, register
>> your class with bzrlib.revisionspec.revspec_registry.register('sha',
>> revspec_subclass).
> Cool. I hadn't realized that the Bzr API was that flexible. Just a few questions:
> 1. Is the "sha1:" part necessary?

Yes, you need some way to specify how Bazaar should interpret the
revision specification that you give, since "-r 123" could mean
revision number 123, a SHA hash that starts with 123, the tag "123",
etc.  Bazaar does do a limited amount of "Do What I Mean" revision
specifications, to "bzr log -r bzr-2.6b1" works without having to
specify "bzr log -r tag:bzr-2.6b1", but that facility is not available
to plugins.

> 2. I need a way to search revisions according to the testament. One way I could do it is by producing a history log and doing a text search, but I wonder if there is a cleaner way to do that.

That is indeed the important part of the plugin.  Off the top of my
head, I would say that you want to iterate through the history of the
context_branch, making a testament for each revision and then checking
the Testament.as_sha1() of each revision.
Branch.iter_merge_sorted_revisions() will get you an iterator over the
history of the branch.


More information about the bazaar mailing list