~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store/weave.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-02-18 02:33:47 UTC
  • mfrom: (1534.1.24 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060218023347-0952c65f668bfd68
Merge Robert Collins integration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
        return self._transport.get(self.filename(file_id))
68
68
 
69
69
    def _put(self, file_id, f):
70
 
        if self._prefixed:
71
 
            try:
72
 
                self._transport.mkdir(hash_prefix(file_id), mode=self._dir_mode)
73
 
            except FileExists:
74
 
                pass
75
 
        return self._transport.put(self.filename(file_id), f, mode=self._file_mode)
 
70
        # less round trips to mkdir on failure than mkdir always
 
71
        try:
 
72
            return self._transport.put(self.filename(file_id), f, mode=self._file_mode)
 
73
        except NoSuchFile:
 
74
            if not self._prefixed:
 
75
                raise
 
76
            self._transport.mkdir(hash_prefix(file_id), mode=self._dir_mode)
 
77
            return self._transport.put(self.filename(file_id), f, mode=self._file_mode)
76
78
 
77
79
    def get_weave(self, file_id, transaction):
78
80
        weave = transaction.map.find_weave(file_id)
162
164
        w.add_identical(old_rev_id, new_rev_id, parent_idxs)
163
165
        self.put_weave(file_id, w, transaction)
164
166
     
165
 
    def copy_multi(self, from_store, file_ids):
 
167
    def copy_multi(self, from_store, file_ids, pb=None):
166
168
        assert isinstance(from_store, WeaveStore)
167
 
        for f in file_ids:
 
169
        for count, f in enumerate(file_ids):
168
170
            mutter("copy weave {%s} into %s", f, self)
 
171
            if pb:
 
172
                pb.update('copy', count, len(file_ids))
169
173
            self._put(f, from_store._get(f))
 
174
        if pb:
 
175
            pb.clear()