~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store/weave.py

  • Committer: Martin Pool
  • Date: 2006-03-06 11:20:10 UTC
  • mfrom: (1593 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1611.
  • Revision ID: mbp@sourcefrog.net-20060306112010-17c0170dde5d1eea
[merge] large merge to sync with bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /usr/bin/python
2
 
 
3
1
# Copyright (C) 2005 Canonical Ltd
4
2
 
5
3
# This program is free software; you can redistribute it and/or modify
67
65
        return self._transport.get(self.filename(file_id))
68
66
 
69
67
    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)
 
68
        # less round trips to mkdir on failure than mkdir always
 
69
        try:
 
70
            return self._transport.put(self.filename(file_id), f, mode=self._file_mode)
 
71
        except NoSuchFile:
 
72
            if not self._prefixed:
 
73
                raise
 
74
            self._transport.mkdir(hash_prefix(file_id), mode=self._dir_mode)
 
75
            return self._transport.put(self.filename(file_id), f, mode=self._file_mode)
76
76
 
77
77
    def get_weave(self, file_id, transaction):
78
78
        weave = transaction.map.find_weave(file_id)
162
162
        w.add_identical(old_rev_id, new_rev_id, parent_idxs)
163
163
        self.put_weave(file_id, w, transaction)
164
164
     
165
 
    def copy_multi(self, from_store, file_ids):
 
165
    def copy_multi(self, from_store, file_ids, pb=None):
166
166
        assert isinstance(from_store, WeaveStore)
167
 
        for f in file_ids:
 
167
        for count, f in enumerate(file_ids):
168
168
            mutter("copy weave {%s} into %s", f, self)
 
169
            if pb:
 
170
                pb.update('copy', count, len(file_ids))
169
171
            self._put(f, from_store._get(f))
 
172
        if pb:
 
173
            pb.clear()