~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/repository.py

  • Committer: John Arbash Meinel
  • Date: 2012-09-06 11:19:35 UTC
  • mto: (6437.63.7 2.5)
  • mto: This revision was merged to the branch mainline in revision 6563.
  • Revision ID: john@arbash-meinel.com-20120906111935-m4p8prgxohkg9ywy
record_stream wasn't being iterated to completion.

This meant that we didn't always finalize a nested_progress_bar.
Which meant that our test suite thought we were at a depth >1.
Which meant that ProgressRecordingUIFactory was discarding
the update messages.
So wrap the progress bar in a try/finally. That way when the
generator exits, we get a proper cleanup.
Note that record_stream is generally driven by iterating the
stream and stepping it, so it isn't too surprising that
we weren't stepping that one final time to trigger generator
teardown.

Show diffs side-by-side

added added

removed removed

Lines of Context:
736
736
        self.seed_state()
737
737
        pb = ui.ui_factory.nested_progress_bar()
738
738
        rc = self._record_counter
739
 
        # Make and consume sub generators, one per substream type:
740
 
        while self.first_bytes is not None:
741
 
            substream = NetworkRecordStream(self.iter_substream_bytes())
742
 
            # after substream is fully consumed, self.current_type is set to
743
 
            # the next type, and self.first_bytes is set to the matching bytes.
744
 
            yield self.current_type, wrap_and_count(pb, rc, substream)
745
 
        if rc:
746
 
            pb.update('Done', rc.max, rc.max)
747
 
        pb.finished()
 
739
        try:
 
740
            # Make and consume sub generators, one per substream type:
 
741
            while self.first_bytes is not None:
 
742
                substream = NetworkRecordStream(self.iter_substream_bytes())
 
743
                # after substream is fully consumed, self.current_type is set
 
744
                # to the next type, and self.first_bytes is set to the matching
 
745
                # bytes.
 
746
                yield self.current_type, wrap_and_count(pb, rc, substream)
 
747
        finally:
 
748
            if rc:
 
749
                pb.update('Done', rc.max, rc.max)
 
750
            pb.finished()
748
751
 
749
752
    def seed_state(self):
750
753
        """Prepare the _ByteStreamDecoder to decode from the pack stream."""