[MERGE] Add debugging flag for merges
Aaron Bentley
aaron.bentley at utoronto.ca
Thu Dec 6 20:05:07 GMT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Vincent,
Vincent Ladeuil wrote:
> Vincent Ladeuil has voted comment.
> Status is now: Semi-approved
> Comment:
> + if 'merge' in debug.debug_flags:
> + plan = list(plan)
> + trans_id = self.tt.trans_id_file_id(file_id)
> + name = self.tt.final_name(trans_id) + '.plan'
> + contents = ('%10s|%s' % l for l in plan)
> + self.tt.new_file(name, self.tt.final_parent(trans_id),
> contents)
>
> why not simply :
> contents = ('%10s|%s' % l for l in list(plan))
plan is an iterator used as a parameter to the PlanWeaveMerge
constructor. (See the first context line at the end of the diff).
I cannot dump an iterator to a file without exhausting it. Exhausting
the iterator would mean it would not work properly when passed to
PlanWeaveMerge.
In order to reuse the iterator, I must copy it into a container.
> the previous 'plan = list(plan)' is a bit scary as it introduced a
> side-effect only when debugging
The parameter of PlanWeaveMerge must be an iterable, but it is not
required to be an iterator. A list is just as good as an iterator for
this purpose.
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHWFXz0F+nu1YWqI0RAr2oAJ9hA7OocKTYLrbLf4IWdkiJUwGRGQCfQW7D
RPWrSP6DuRnamiNzlCz3Q0k=
=K0TR
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list