~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store/__init__.py

  • Committer: Robert Collins
  • Date: 2005-10-17 02:16:12 UTC
  • mto: This revision was merged to the branch mainline in revision 1459.
  • Revision ID: robertc@lifelesslap.robertcollins.net-20051017021612-1bc159c29da0e0fe
Teach store.copy_all about fileid suffixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
            if self.has_id(fileid):
112
112
                continue
113
113
            try:
114
 
                self._copy_one(fileid, other, pb)
 
114
                self._copy_one(fileid, None, other, pb)
 
115
                for suffix in self._suffixes:
 
116
                    try:
 
117
                        self._copy_one(fileid, suffix, other, pb)
 
118
                    except KeyError:
 
119
                        pass
115
120
                pb.update('copy', count, len(ids))
116
121
            except KeyError:
117
122
                if permit_failure:
122
127
        pb.clear()
123
128
        return count, failed
124
129
 
125
 
    def _copy_one(self, fileid, other, pb):
 
130
    def _copy_one(self, fileid, suffix, other, pb):
126
131
        """Most generic copy-one object routine.
127
132
        
128
133
        Subclasses can override this to provide an optimised
130
135
        should call this if they have no optimised facility for a 
131
136
        specific 'other'.
132
137
        """
133
 
        f = other.get(fileid)
134
 
        self.add(f, fileid)
 
138
        f = other.get(fileid, suffix)
 
139
        self.add(f, fileid, suffix)
135
140
 
136
141
 
137
142
class TransportStore(Store):
183
188
 
184
189
    def get(self, fileid, suffix=None):
185
190
        """See Store.get()."""
186
 
        if suffix is None:
 
191
        if suffix is None or suffix == 'gz':
187
192
            fn = self._relpath(fileid)
188
193
        else:
189
194
            fn = self._relpath(fileid, [suffix])
197
202
        super(TransportStore, self).__init__()
198
203
        self._transport = a_transport
199
204
        self._prefixed = prefixed
 
205
        # conflating the .gz extension and user suffixes was a mistake.
 
206
        # RBC 20051017 - TODO SOON, separate them again.
200
207
        self._suffixes = set()
201
208
 
202
209
    def __iter__(self):