[ANN] History-search/grep plugin
John A Meinel
john at arbash-meinel.com
Fri Feb 10 14:28:13 GMT 2006
John A Meinel wrote:
> Michael Ellerman wrote:
>> Hi guys,
>>
>> With a few pointers from Martin I hacked up a history-search plugin
>> yesterday. It basically does a grep through history and shows you
>> which revisions match your pattern.
>>
>
> I assume you mean it is searching through the texts, because 'bzr log
> --message foo' will search for 'foo' in the commit logs.
>
>
>> Actually it shows you the revision that introduced the pattern you're
>> looking for, it might also be nice to show which revision(s) deleted
>> the text, but I couldn't decide how that should work in the UI.
>>
>> It's _insanely_ fast, thanks to the weave, we can search bzr.dev for a
>> non-matching pattern in about 3 seconds. With lots of matches you end
>> spending all your time converting revids to revnos, so --show-ids
>> makes it a lot faster.
>
> If this is the slow point, simply create a cached dictionary. With:
>
> revid_to_revno = {}
> for idx, rev in enumerate(branch.revision_history()):
> revid_to_revno[rev] = idx+1
>
> The big problem is that branch.revid_to_revno() is doing a list.index()
> call, which has to scan through the whole list, versus a hash lookup in
> a dictionary.
>
> Since you know the specific problem, I think this bottleneck could
> easily be removed.
>
Now that I'm looking at your code, I think the other problem is that you
are building up a RevisionSpec, just to get at a revno.
I assume you didn't know about "Branch.revision_id_to_revno", but I
would still recommend building it up yourself with the above loop. It is
1 pass over the list, rather than N passes.
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060210/756ac091/attachment.pgp
More information about the bazaar
mailing list