~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

(jelmer) Support verifying remote signatures without VFS calls. (Jelmer
 Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    controldir,
25
25
    debug,
26
26
    errors,
 
27
    gpg,
27
28
    graph,
28
29
    lock,
29
30
    lockdir,
32
33
    revision as _mod_revision,
33
34
    static_tuple,
34
35
    symbol_versioning,
 
36
    testament as _mod_testament,
35
37
    urlutils,
36
38
    vf_repository,
37
39
    )
2177
2179
 
2178
2180
    @needs_write_lock
2179
2181
    def sign_revision(self, revision_id, gpg_strategy):
2180
 
        self._ensure_real()
2181
 
        return self._real_repository.sign_revision(revision_id, gpg_strategy)
 
2182
        testament = _mod_testament.Testament.from_revision(self, revision_id)
 
2183
        plaintext = testament.as_short_text()
 
2184
        self.store_revision_signature(gpg_strategy, plaintext, revision_id)
2182
2185
 
2183
2186
    @property
2184
2187
    def texts(self):
2240
2243
            raise SmartProtocolError('unexpected response code %s' % (response,))
2241
2244
        return (response[0] == 'yes')
2242
2245
 
 
2246
    @needs_read_lock
2243
2247
    def verify_revision_signature(self, revision_id, gpg_strategy):
2244
 
        self._ensure_real()
2245
 
        return self._real_repository.verify_revision_signature(
2246
 
            revision_id, gpg_strategy)
 
2248
        if not self.has_signature_for_revision_id(revision_id):
 
2249
            return gpg.SIGNATURE_NOT_SIGNED, None
 
2250
        signature = self.get_signature_text(revision_id)
 
2251
 
 
2252
        testament = _mod_testament.Testament.from_revision(self, revision_id)
 
2253
        plaintext = testament.as_short_text()
 
2254
 
 
2255
        return gpg_strategy.verify(signature, plaintext)
2247
2256
 
2248
2257
    def item_keys_introduced_by(self, revision_ids, _files_pb=None):
2249
2258
        self._ensure_real()