~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store/compressed_text.py

  • Committer: Robert Collins
  • Date: 2005-10-17 01:40:24 UTC
  • mto: This revision was merged to the branch mainline in revision 1459.
  • Revision ID: robertc@lifelesslap.robertcollins.net-20051017014024-1c0d392828f918c3
Unroll the multiple-copy logic enough to remove the duplicate iteration and yet retain the optimised gzip->gzip copy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
        sio.seek(0)
79
79
        self._transport.put(fn, sio)
80
80
 
81
 
    def _do_copy(self, other, to_copy, pb, permit_failure=False):
82
 
        if isinstance(other, CompressedTextStore):
83
 
            return self._copy_multi_text(other, to_copy, pb,
84
 
                    permit_failure=permit_failure)
85
 
        return super(CompressedTextStore, self)._do_copy(other, to_copy,
86
 
                pb, permit_failure=permit_failure)
87
 
 
88
 
    def _copy_multi_text(self, other, to_copy, pb,
89
 
            permit_failure=False):
90
 
        # Because of _transport, we can no longer assume
91
 
        # that they are on the same filesystem, we can, however
92
 
        # assume that we only need to copy the exact bytes,
93
 
        # we don't need to process the files.
94
 
 
95
 
        failed = set()
96
 
        if permit_failure:
97
 
            new_to_copy = set()
98
 
            for fileid, has in zip(to_copy, other.has(to_copy)):
99
 
                if has:
100
 
                    new_to_copy.add(fileid)
101
 
                else:
102
 
                    failed.add(fileid)
103
 
            to_copy = new_to_copy
104
 
            #mutter('_copy_multi_text copying %s, failed %s' % (to_copy, failed))
105
 
 
106
 
        paths = [self._relpath(fileid) for fileid in to_copy]
107
 
        count = other._transport.copy_to(paths, self._transport, pb=pb)
108
 
        assert count == len(to_copy)
109
 
        return count, failed
 
81
    def _copy_one(self, fileid, other, pb):
 
82
        if not (isinstance(other, CompressedTextStore)
 
83
            and other._prefixed == self._prefixed):
 
84
            return super(CompressedTextStore, self)._copy_one(fileid, 
 
85
                                                              other, pb)
 
86
        path = self._relpath(fileid)
 
87
        assert other._transport.copy_to([path], self._transport, pb=pb) == 1
110
88
 
111
89
    def __init__(self, transport, prefixed=False):
112
90
        super(CompressedTextStore, self).__init__(transport, prefixed)