~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store.py

  • Committer: Robert Collins
  • Date: 2005-09-28 05:37:53 UTC
  • mfrom: (1092.3.4)
  • mto: This revision was merged to the branch mainline in revision 1397.
  • Revision ID: robertc@robertcollins.net-20050928053753-68e6e4c0642eccea
merge from symlink branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
unique ID.
22
22
"""
23
23
 
24
 
import os, tempfile, types, osutils, gzip, errno
 
24
import errno
 
25
import gzip
 
26
import os
 
27
import tempfile
 
28
import types
25
29
from stat import ST_SIZE
26
30
from StringIO import StringIO
 
31
 
27
32
from bzrlib.errors import BzrError
28
33
from bzrlib.trace import mutter
29
34
import bzrlib.ui
 
35
import bzrlib.osutils as osutils
30
36
from bzrlib.remotebranch import get_url
 
37
import urllib2
 
38
 
31
39
 
32
40
######################################################################
33
41
# stores
149
157
        pb.update('preparing to copy')
150
158
        to_copy = [id for id in ids if id not in self]
151
159
        if isinstance(other, ImmutableStore):
152
 
            return self.copy_multi_immutable(other, to_copy, pb)
 
160
            return self.copy_multi_immutable(other, to_copy, pb, 
 
161
                                             permit_failure=permit_failure)
153
162
        count = 0
154
163
        failed = set()
155
164
        for id in to_copy:
160
169
            else:
161
170
                try:
162
171
                    entry = other[id]
163
 
                except IndexError:
 
172
                except KeyError:
164
173
                    failed.add(id)
165
174
                    continue
166
175
                self.add(entry, id)
239
248
            if e.errno != errno.ENOENT:
240
249
                raise
241
250
 
242
 
        raise IndexError(fileid)
 
251
        raise KeyError(fileid)
243
252
 
244
253
 
245
254
class ImmutableScratchStore(ImmutableStore):
300
309
        p = self._path(fileid)
301
310
        try:
302
311
            return get_url(p, compressed=True)
303
 
        except:
 
312
        except urllib2.URLError:
 
313
            pass
 
314
        try:
 
315
            return get_url(p, compressed=False)
 
316
        except urllib2.URLError:
304
317
            raise KeyError(fileid)
305
318
 
306
 
 
307
319
class CachedStore:
308
320
    """A store that caches data locally, to avoid repeated downloads.
309
321
    The precacache method should be used to avoid server round-trips for
324
336
        """Copy a series of ids into the cache, before they are used.
325
337
        For remote stores that support pipelining or async downloads, this can
326
338
        increase speed considerably.
 
339
        Failures while prefetching are ignored.
327
340
        """
328
341
        mutter("Prefetch of ids %s" % ",".join(ids))
329
 
        self.cache_store.copy_multi(self.source_store, ids)
 
342
        self.cache_store.copy_multi(self.source_store, ids,
 
343
                                    permit_failure=True)