~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store.py

  • Committer: Aaron Bentley
  • Date: 2005-09-12 02:53:07 UTC
  • mto: (1185.3.4)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: aaron.bentley@utoronto.ca-20050912025307-8c21544e8db1cbdb
added all_descendants and node_distances, exception when root doesn't exist

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
 
91
92
            
92
93
        p = self._path(fileid)
93
94
        if os.access(p, os.F_OK) or os.access(p + '.gz', os.F_OK):
94
 
            from bzrlib.errors import bailout
95
95
            raise BzrError("store %r already contains id %r" % (self._basedir, fileid))
96
96
 
97
97
        fn = p
114
114
    def copy_multi(self, other, ids, permit_failure=False):
115
115
        """Copy texts for ids from other into self.
116
116
 
117
 
        If an id is present in self, it is skipped.  A count of copied
118
 
        ids is returned, which may be less than len(ids).
 
117
        If an id is present in self, it is skipped.
 
118
 
 
119
        Returns (count_copied, failed), where failed is a collection of ids
 
120
        that could not be copied.
119
121
        """
120
122
        pb = bzrlib.ui.ui_factory.progress_bar()
121
123
        
124
126
        if isinstance(other, ImmutableStore):
125
127
            return self.copy_multi_immutable(other, to_copy, pb)
126
128
        count = 0
 
129
        failed = set()
127
130
        for id in to_copy:
128
131
            count += 1
129
132
            pb.update('copy', count, len(to_copy))
133
136
                try:
134
137
                    entry = other[id]
135
138
                except IndexError:
136
 
                    failures.add(id)
 
139
                    failed.add(id)
137
140
                    continue
138
141
                self.add(entry, id)
139
142
                
140
 
        assert count == len(to_copy)
 
143
        if not permit_failure:
 
144
            assert count == len(to_copy)
141
145
        pb.clear()
142
 
        return count
143
 
 
 
146
        return count, failed
144
147
 
145
148
    def copy_multi_immutable(self, other, to_copy, pb, permit_failure=False):
146
149
        from shutil import copyfile