[RFC] incremental annotation interface

Aaron Bentley aaron at aaronbentley.com
Fri Apr 25 15:56:38 BST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

We recently deprecated the VersionedFile.annotate_iter interface because
even though incremental operation is nice, it could not really be
implemented in an incremental way.  Here's an alternative API that could
provide genuinely incremental operation.

Instead of returning lines, we assume the user already has all the
lines, and they just want to know where they came from.  So we instead
return the ranges of lines that were associated with a given revision.

x = repo.iter_anno('rev3')
x.next()
('rev3', [(1, 2)])

This range is in the same form as the ranges used by xrange.  So (1, 2)
means line 1 only.  The ranges are always in terms of the text version
being annotated, not the revision-id returned.

This means that we can build up a list of which revisions are associated
with which lines.

line_revisions = [None] * len(lines)
for revision, ranges in repo.iter_anno('rev3'):
    for start, stop in ranges:
        for line_no in xrange(start, stop):
            lines_revisions[line_no] = revision

The format would also be relatively easy to serialize, and small, so we
could cache annotations in this format.

As with most kinds of incremental operation, there are two significant
benefits:
- - faster initial feedback
- - stopping early

One instance where stopping early would be an advantage is with the
annotation-based knit merge.  With iter_anno, we could stop annotating
once all the conflicted lines had been annotated.

Thoughts?

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIEfEm0F+nu1YWqI0RAgw+AKCB+DSeUuln90FFd6pf8JblcGj6JACfZ/MO
9GWbfDFtJDXLxW1yWMCfT9Y=
=eHUs
-----END PGP SIGNATURE-----



More information about the bazaar mailing list