~ubuntu-branches/ubuntu/lucid/bzr/lucid-proposed

« back to all changes in this revision

Viewing changes to bzrlib/store/weave.py

  • Committer: Bazaar Package Importer
  • Author(s): Jeff Bailey
  • Date: 2006-03-20 08:31:00 UTC
  • mfrom: (1.1.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20060320083100-ovdi2ssuw0epcx8s
Tags: 0.8~200603200831-0ubuntu1
* Snapshot uploaded to Dapper at Martin Pool's request.

* Disable testsuite for upload.  Fakeroot and the testsuite don't
  play along.

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()