~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Robert Collins
  • Date: 2006-01-18 03:09:39 UTC
  • mto: (1534.1.15 integration)
  • mto: This revision was merged to the branch mainline in revision 1550.
  • Revision ID: robertc@robertcollins.net-20060118030939-c5c7106140cf444f
Tweak storage towards mergability.

Show diffs side-by-side

added added

removed removed

Lines of Context:
107
107
    def unlock(self):
108
108
        self.control_files.unlock()
109
109
 
 
110
    @needs_read_lock
110
111
    def copy(self, destination):
111
 
        destination.control_weaves.copy_multi(self.control_weaves, 
 
112
        destination.lock_write()
 
113
        try:
 
114
            destination.control_weaves.copy_multi(self.control_weaves, 
112
115
                ['inventory'])
113
 
        copy_all(self.weave_store, destination.weave_store)
114
 
        copy_all(self.revision_store, destination.revision_store)
 
116
            copy_all(self.weave_store, destination.weave_store)
 
117
            copy_all(self.revision_store, destination.revision_store)
 
118
        finally:
 
119
            destination.unlock()
115
120
 
116
121
    def has_revision(self, revision_id):
117
122
        """True if this branch has a copy of the revision.
131
136
        except (IndexError, KeyError):
132
137
            raise bzrlib.errors.NoSuchRevision(self, revision_id)
133
138
 
 
139
    @needs_read_lock
134
140
    def get_revision_xml(self, revision_id):
135
141
        return self.get_revision_xml_file(revision_id).read()
136
142
 
 
143
    @needs_read_lock
137
144
    def get_revision(self, revision_id):
138
145
        """Return the Revision object for a named revision"""
139
146
        xml_file = self.get_revision_xml_file(revision_id)
148
155
        assert r.revision_id == revision_id
149
156
        return r
150
157
 
 
158
    @needs_read_lock
151
159
    def get_revision_sha1(self, revision_id):
152
160
        """Hash the stored value of a revision, and return it."""
153
161
        # In the future, revision entries will be signed. At that
163
171
        self.revision_store.add(StringIO(gpg_strategy.sign(plaintext)), 
164
172
                                revision_id, "sig")
165
173
 
 
174
    @needs_read_lock
166
175
    def get_inventory_weave(self):
167
176
        return self.control_weaves.get_weave('inventory',
168
177
            self.get_transaction())
169
178
 
 
179
    @needs_read_lock
170
180
    def get_inventory(self, revision_id):
171
181
        """Get Inventory object by hash."""
172
182
        xml = self.get_inventory_xml(revision_id)
173
183
        return bzrlib.xml5.serializer_v5.read_inventory_from_string(xml)
174
184
 
 
185
    @needs_read_lock
175
186
    def get_inventory_xml(self, revision_id):
176
187
        """Get inventory XML as a file object."""
177
188
        try:
181
192
        except IndexError:
182
193
            raise bzrlib.errors.HistoryMissing(self, 'inventory', revision_id)
183
194
 
 
195
    @needs_read_lock
184
196
    def get_inventory_sha1(self, revision_id):
185
197
        """Return the sha1 hash of the inventory entry
186
198
        """
187
199
        return self.get_revision(revision_id).inventory_sha1
188
200
 
 
201
    @needs_read_lock
189
202
    def get_revision_inventory(self, revision_id):
190
203
        """Return inventory of a past revision."""
191
204
        # TODO: Unify this with get_inventory()
201
214
        else:
202
215
            return self.get_inventory(revision_id)
203
216
 
 
217
    @needs_read_lock
204
218
    def revision_tree(self, revision_id):
205
219
        """Return Tree for a revision on this branch.
206
220
 
214
228
            inv = self.get_revision_inventory(revision_id)
215
229
            return RevisionTree(self, inv, revision_id)
216
230
 
 
231
    @needs_read_lock
217
232
    def get_ancestry(self, revision_id):
218
233
        """Return a list of revision-ids integrated by a revision.
219
234
        
248
263
    def get_transaction(self):
249
264
        return self.control_files.get_transaction()
250
265
 
 
266
    @needs_write_lock
251
267
    def sign_revision(self, revision_id, gpg_strategy):
252
268
        plaintext = Testament.from_revision(self, revision_id).as_short_text()
253
269
        self.store_revision_signature(gpg_strategy, plaintext, revision_id)