[merge][1.6][#234748] fix KnitCorrupt error in check on bzr.dev
John Arbash Meinel
john at arbash-meinel.com
Wed May 28 15:20:22 BST 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Martin Pool wrote:
| Happily to say the repository is not corrupt (and this is an
| increasingly poorly-named error) but there is a bug in the knit code
| for extracting several values at a time.
|
| The basic problem is of memory aliasing; we have a dict pointing to
| the contents of other file text and accidentally mutate a list within
| it. The previous code tried to protect against this but failed. The
| main point is that calling .text() on a KnitContent object will
| already take trailing eols into account so no special handling is
| needed here.
|
| I'd kind of like to remove more of the special-casing here of
| extraction of multiple files, but I guess it is there as an
| optimization so shouldn't be done without measurement.
|
| Thanks very much to spiv for tracking this down with me.
|
| This still needs a test and news entry but I thought I'd put up the
| core fix now.
|
|
Yeah, this is mostly because the two functions evolved slightly independently.
*I'm* pretty unhappy that KnitContent always stores a final newline and it gets
stripped off at random times. You can get different results in the knit if you
save the parent lines or not. Both ways are officially 'correct', but sometimes
it adds a final line to the delta claiming to re-add the missing newline.
I did manage to work out the logic to build texts more efficiently for annotate.
Specifically being able to stream the data out of the pack, and build what I
can, etc. The logic is rather ugly, but it is probably fairly well encapsulated
in _KnitAnnotator. (Though there it serves a dual purpose of getting all parent
texts as well as just the build dependencies for a given text.)
As for a test, I think if you add a text with no final newline, and then one
with, it might exercise this code path. (If necessary, add another one without a
final newline to make sure you get both transitions.)
BB:tweak
pending a test
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkg9aiYACgkQJdeBCYSNAAM/9QCgn1aF7LQ6zQPEJmqnXA3pEcvf
3kUAn3Vj2UEdUnMetVlsUttCCOJlJ3cy
=A0m2
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list