~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store.py

  • Committer: Martin Pool
  • Date: 2005-06-22 09:35:24 UTC
  • Revision ID: mbp@sourcefrog.net-20050622093524-b15e2d374c2ae6ea
- move standard plugins from contrib/plugins to just ./plugins

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
            
91
91
        p = self._path(fileid)
92
92
        if os.access(p, os.F_OK) or os.access(p + '.gz', os.F_OK):
93
 
            from bzrlib.errors import bailout
94
93
            raise BzrError("store %r already contains id %r" % (self._basedir, fileid))
95
94
 
96
95
        fn = p
120
119
        pb = ProgressBar()
121
120
        pb.update('preparing to copy')
122
121
        to_copy = [id for id in ids if id not in self]
123
 
        if isinstance(other, ImmutableStore):
124
 
            return self.copy_multi_immutable(other, to_copy, pb)
125
122
        count = 0
126
123
        for id in to_copy:
127
124
            count += 1
130
127
        assert count == len(to_copy)
131
128
        pb.clear()
132
129
        return count
133
 
 
134
 
 
135
 
    def copy_multi_immutable(self, other, to_copy, pb):
136
 
        from shutil import copyfile
137
 
        count = 0
138
 
        for id in to_copy:
139
 
            p = self._path(id)
140
 
            other_p = other._path(id)
141
 
            try:
142
 
                copyfile(other_p, p)
143
 
            except IOError, e:
144
 
                if e.errno == errno.ENOENT:
145
 
                    copyfile(other_p+".gz", p+".gz")
146
 
                else:
147
 
                    raise
148
 
            
149
 
            count += 1
150
 
            pb.update('copy', count, len(to_copy))
151
 
        assert count == len(to_copy)
152
 
        pb.clear()
153
 
        return count
154
130
    
155
131
 
156
132
    def __contains__(self, fileid):