[MERGE] 'bzr annotate' shows dotted revnos and --show-ids
aaron.bentley at utoronto.ca
Fri Dec 15 14:56:36 GMT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Vincent Ladeuil wrote:
>>>>>>"jam" == John Arbash Meinel <john at arbash-meinel.com> writes:
> jam> Vincent Ladeuil wrote:
> >>>>>>> "jam" == John Arbash Meinel <john at arbash-meinel.com> writes:
> jam> The attached patch updates 'bzr annotate' in 2
> jam> ways. First, it shows dotted revnos by default, instead
> jam> of showing 'merge'. Second, it allows you to specify
> jam> --show-ids and it will display revision ids instead of
> jam> revnos.
> >> Wow. Very nice.
> >> What about making _annotate_file a public function ?
> >> gannotate is currently doing mostly the same job but need to
> >> duplicate the code which is not nice.
> >> It also maintain a cache between revids and revno but in a
> >> slightly different way, so may be given access to your
> >> revision_id_to_revno mapping can be reused too.
> >> Vincent
> jam> Well we already have 'annotate_file' which is the public
> jam> function. We certainly could refactor it in some useful
> jam> way. I'm not sure what would be the most useful for
> jam> something like gannotate. So what if you do the
> jam> refactoring, along with fixing gannotate to use it?
> No problem. I didn't because Aaron was the author of both the
> versions and I didn't want to step on his toes. If it's not a
> problem for him, I'll give it a try (Aaron, do not hesitate to
> let your toes yell or give useful suggestions ;).
Sure, no worries. The gannotate code in particular is probably
optimized the wrong way these days.
Looking at the present _annotate_file, it looks like it could usefully
be split into two operations:
1. find a translation between revision_ids and display names. There are
several possible translations
a) revno or "merge"
b) revno or dotted revno
c) revno or revno of the merging revision
d) revid (no tranlation)
The function that generates a revid -> dotted_revno dict probably ought
to be a method on Repository.
2. iterate through annotated lines, but replace the revision_id with the
actual revision. Naive implmentation:
((repo.get_revision(r), l) for r,l in w.annotate_iter(rev_id))
A non-naive version would grab all revisions at once and reuse them.
Both of those operations would be useful for gannotate.
This changes the responsability of the existing annotate_file somewhat.
Now instead of this:
anno = "%-*s %-7s " % (max_revno_len, revno_str, author[:7])
It would do
author = rev.committer
author = extract_email_address(author)
pass # use the whole name
anno = "%-*s %-7s" % (max_display_len, display_name[rev.revision_id],
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the bazaar