~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store.py

  • Committer: Martin Pool
  • Date: 2005-09-01 11:27:20 UTC
  • Revision ID: mbp@sourcefrog.net-20050901112720-f5ccb6b6627991de
- work properly when $EDITOR contains multiple words

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
28
27
from bzrlib.trace import mutter
29
28
import bzrlib.ui
30
29
 
68
67
    def __init__(self, basedir):
69
68
        self._basedir = basedir
70
69
 
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)
 
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)
77
74
 
78
75
    def __repr__(self):
79
76
        return "%s(%r)" % (self.__class__.__name__, self._basedir)
126
123
        pb.update('preparing to copy')
127
124
        to_copy = [id for id in ids if id not in self]
128
125
        if isinstance(other, ImmutableStore):
129
 
            return self.copy_multi_immutable(other, to_copy, pb, 
130
 
                                             permit_failure=permit_failure)
 
126
            return self.copy_multi_immutable(other, to_copy, pb)
131
127
        count = 0
132
 
        failed = set()
133
128
        for id in to_copy:
134
129
            count += 1
135
130
            pb.update('copy', count, len(to_copy))
138
133
            else:
139
134
                try:
140
135
                    entry = other[id]
141
 
                except KeyError:
142
 
                    failed.add(id)
 
136
                except IndexError:
 
137
                    failures.add(id)
143
138
                    continue
144
139
                self.add(entry, id)
145
140
                
146
 
        if not permit_failure:
147
 
            assert count == len(to_copy)
 
141
        assert count == len(to_copy)
148
142
        pb.clear()
149
 
        return count, failed
 
143
        return count, []
150
144
 
151
145
    def copy_multi_immutable(self, other, to_copy, pb, permit_failure=False):
152
146
        from shutil import copyfile
214
208
            if e.errno != errno.ENOENT:
215
209
                raise
216
210
 
217
 
        raise KeyError(fileid)
 
211
        raise IndexError(fileid)
218
212
 
219
213
 
220
214
    def total_size(self):