~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store.py

  • Committer: aaron.bentley at utoronto
  • Date: 2005-08-26 01:50:01 UTC
  • mto: (974.1.47)
  • mto: This revision was merged to the branch mainline in revision 1178.
  • Revision ID: aaron.bentley@utoronto.ca-20050826015001-d8b6e6330cb6401a
Merged from bzr.24

Show diffs side-by-side

added added

removed removed

Lines of Context:
110
110
            af.close()
111
111
 
112
112
 
113
 
    def copy_multi(self, other, ids):
 
113
    def copy_multi(self, other, ids, permit_failure=False):
114
114
        """Copy texts for ids from other into self.
115
115
 
116
116
        If an id is present in self, it is skipped.  A count of copied
123
123
        if isinstance(other, ImmutableStore):
124
124
            return self.copy_multi_immutable(other, to_copy, pb)
125
125
        count = 0
 
126
        failed = set()
126
127
        for id in to_copy:
127
128
            count += 1
128
129
            pb.update('copy', count, len(to_copy))
129
 
            self.add(other[id], id)
130
 
        assert count == len(to_copy)
 
130
            if not permit_failure:
 
131
                self.add(other[id], id)
 
132
            else:
 
133
                try:
 
134
                    entry = other[id]
 
135
                except IndexError:
 
136
                    failed.add(id)
 
137
                    continue
 
138
                self.add(entry, id)
 
139
                
 
140
        if not permit_failure:
 
141
            assert count == len(to_copy)
131
142
        pb.clear()
132
 
        return count
133
 
 
134
 
 
135
 
    def copy_multi_immutable(self, other, to_copy, pb):
 
143
        return count, failed
 
144
 
 
145
 
 
146
    def copy_multi_immutable(self, other, to_copy, pb, permit_failure=False):
136
147
        from shutil import copyfile
137
148
        count = 0
 
149
        failed = set()
138
150
        for id in to_copy:
139
151
            p = self._path(id)
140
152
            other_p = other._path(id)
142
154
                copyfile(other_p, p)
143
155
            except IOError, e:
144
156
                if e.errno == errno.ENOENT:
145
 
                    copyfile(other_p+".gz", p+".gz")
 
157
                    if not permit_failure:
 
158
                        copyfile(other_p+".gz", p+".gz")
 
159
                    else:
 
160
                        try:
 
161
                            copyfile(other_p+".gz", p+".gz")
 
162
                        except IOError, e:
 
163
                            if e.errno == errno.ENOENT:
 
164
                                failed.add(id)
 
165
                            else:
 
166
                                raise
146
167
                else:
147
168
                    raise
148
169
            
150
171
            pb.update('copy', count, len(to_copy))
151
172
        assert count == len(to_copy)
152
173
        pb.clear()
153
 
        return count
 
174
        return count, failed
154
175
    
155
176
 
156
177
    def __contains__(self, fileid):