~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store.py

  • Committer: Martin Pool
  • Date: 2005-06-27 01:36:22 UTC
  • Revision ID: mbp@sourcefrog.net-20050627013622-0d56be3e3105043e
Merge from aaron:

------------------------------------------------------------
revno: 763
committer: Aaron Bentley <abentley@panoramicfeedback.com>
timestamp: Thu 2005-06-23 17:30:28 -0400
message:
  Copy files in immutable stores directly.
------------------------------------------------------------
revno: 762
committer: Aaron Bentley <abentley@panoramicfeedback.com>
timestamp: Thu 2005-06-23 16:12:33 -0400
message:
  Fixed direct call of get_url in RemoteBranch.get_revision
------------------------------------------------------------
revno: 761
committer: Aaron Bentley <abentley@panoramicfeedback.com>
timestamp: Thu 2005-06-23 12:00:31 -0400
message:
  Added prefetch support to update_revisions
------------------------------------------------------------
revno: 760
committer: Aaron Bentley <abentley@panoramicfeedback.com>
timestamp: Thu 2005-06-23 11:57:54 -0400
message:
  Added cache support to branch and pull
------------------------------------------------------------
revno: 759
committer: Aaron Bentley <abentley@panoramicfeedback.com>
timestamp: Thu 2005-06-23 11:21:37 -0400
message:
  Added find_cached_branch to branch
------------------------------------------------------------
revno: 758
committer: Aaron Bentley <abentley@panoramicfeedback.com>
timestamp: Thu 2005-06-23 11:17:10 -0400
message:
  Added CachedStore type to reduce remote downloads

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
        pb = ProgressBar()
120
120
        pb.update('preparing to copy')
121
121
        to_copy = [id for id in ids if id not in self]
 
122
        if isinstance(other, ImmutableStore):
 
123
            return self.copy_multi_immutable(other, to_copy, pb)
122
124
        count = 0
123
125
        for id in to_copy:
124
126
            count += 1
127
129
        assert count == len(to_copy)
128
130
        pb.clear()
129
131
        return count
 
132
 
 
133
 
 
134
    def copy_multi_immutable(self, other, to_copy, pb):
 
135
        from shutil import copyfile
 
136
        count = 0
 
137
        for id in to_copy:
 
138
            p = self._path(id)
 
139
            other_p = other._path(id)
 
140
            try:
 
141
                copyfile(other_p, p)
 
142
            except IOError, e:
 
143
                if e.errno == errno.ENOENT:
 
144
                    copyfile(other_p+".gz", p+".gz")
 
145
                else:
 
146
                    raise
 
147
            
 
148
            count += 1
 
149
            pb.update('copy', count, len(to_copy))
 
150
        assert count == len(to_copy)
 
151
        pb.clear()
 
152
        return count
130
153
    
131
154
 
132
155
    def __contains__(self, fileid):