Weave.join(), and progress indicator fixes
John Arbash Meinel
john at arbash-meinel.com
Mon Jan 30 01:06:51 GMT 2006
Robert Collins wrote:
> On Wed, 2006-01-25 at 12:06 -0600, John A Meinel wrote:
>> Can I get a review?
>>
>> John
>> =:->
>> plain text document attachment (fix-weave-join.patch)
>
>> === modified file 'bzrlib/tests/test_weave.py'
>> --- bzrlib/tests/test_weave.py
>> +++ bzrlib/tests/test_weave.py
>> @@ -991,3 +991,64 @@
>> self.assertRaises(errors.WeaveInvalidChecksum, w.check)
>>
>>
>> +class InstrumentedWeave(Weave):
>> + """Keep track of how many times functions are called."""
>> +
>> + _extract_count = 0
>> +
>> + def _extract(self, versions):
>> + self._extract_count += 1
>> + return Weave._extract(self, versions)
>> +
>
>
> This looks suspect to me - _extract_count is surely per instance not per
> class.
>
> I'd add __init__ here for clarity, even if in this case the attribute is
> being set onto the instances correctly.
>
I did add __init__ after all, I was thinking about the portion of the code.
Also, while I was tracking down Aaron's problem, I wrote this code:
=== modified file 'bzrlib/weave.py'
--- bzrlib/weave.py
+++ bzrlib/weave.py
@@ -946,7 +946,15 @@
if name in wa._name_map:
lines = wa.get_lines(name)
if name in wb._name_map:
- assert lines == wb.get_lines(name)
+ lines_b = wb.get_lines(name)
+ if lines != lines_b:
+ print '*** Weaves differ on content'
+ print '*** Revision: {%s}' % (name,)
+ import difflib
+ for line in difflib.unified_diff(lines, lines_b,
+ wa._weave_name, wb._weave_name):
+ print line
+ assert lines == lines_b
else:
lines = wb.get_lines(name)
wr.add(name, combined_parents[name], lines)
I would like to see something like it, since it gives you a diagnostic
output when reweave fails, rather than just a plain assertion error.
I suppose we could print it into the log if you would prefer not writing
it to the screen. (unified_diff helps highlight what is actually
different, rather than just printing the files).
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060129/816872c6/attachment.pgp
More information about the bazaar
mailing list