~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store.py

  • Committer: Martin Pool
  • Date: 2005-09-13 23:42:32 UTC
  • mto: (1185.8.2) (974.1.91)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: mbp@sourcefrog.net-20050913234232-4d901f2d843a35f3
- ignore .DS_Store by default

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import os, tempfile, types, osutils, gzip, errno
25
25
from stat import ST_SIZE
26
26
from StringIO import StringIO
 
27
from bzrlib.errors import BzrError
27
28
from bzrlib.trace import mutter
28
29
import bzrlib.ui
29
30
 
67
68
    def __init__(self, basedir):
68
69
        self._basedir = basedir
69
70
 
70
 
    def _path(self, id):
71
 
        if '\\' in id or '/' in id:
72
 
            raise ValueError("invalid store id %r" % id)
73
 
        return os.path.join(self._basedir, id)
 
71
    def _path(self, entry_id):
 
72
        if not isinstance(entry_id, basestring):
 
73
            raise TypeError(type(entry_id))
 
74
        if '\\' in entry_id or '/' in entry_id:
 
75
            raise ValueError("invalid store id %r" % entry_id)
 
76
        return os.path.join(self._basedir, entry_id)
74
77
 
75
78
    def __repr__(self):
76
79
        return "%s(%r)" % (self.__class__.__name__, self._basedir)
123
126
        pb.update('preparing to copy')
124
127
        to_copy = [id for id in ids if id not in self]
125
128
        if isinstance(other, ImmutableStore):
126
 
            return self.copy_multi_immutable(other, to_copy, pb)
 
129
            return self.copy_multi_immutable(other, to_copy, pb, 
 
130
                                             permit_failure=permit_failure)
127
131
        count = 0
 
132
        failed = set()
128
133
        for id in to_copy:
129
134
            count += 1
130
135
            pb.update('copy', count, len(to_copy))
133
138
            else:
134
139
                try:
135
140
                    entry = other[id]
136
 
                except IndexError:
137
 
                    failures.add(id)
 
141
                except KeyError:
 
142
                    failed.add(id)
138
143
                    continue
139
144
                self.add(entry, id)
140
145
                
141
 
        assert count == len(to_copy)
 
146
        if not permit_failure:
 
147
            assert count == len(to_copy)
142
148
        pb.clear()
143
 
        return count, []
 
149
        return count, failed
144
150
 
145
151
    def copy_multi_immutable(self, other, to_copy, pb, permit_failure=False):
146
152
        from shutil import copyfile
208
214
            if e.errno != errno.ENOENT:
209
215
                raise
210
216
 
211
 
        raise IndexError(fileid)
 
217
        raise KeyError(fileid)
212
218
 
213
219
 
214
220
    def total_size(self):