/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/gpg.py

  • Committer: Jonathan Riddell
  • Date: 2011-06-23 12:08:21 UTC
  • mto: This revision was merged to the branch mainline in revision 6003.
  • Revision ID: jriddell@canonical.com-20110623120821-qv6mn82yanqb7j49
move code which does verifications of revisions from cmd_verify_signatures to gpg.do_verifications

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
                else:
90
90
                    self.acceptable_keys.append(pattern)
91
91
 
 
92
    def do_verifications(self, revisions, repository):
 
93
        count = {SIGNATURE_VALID: 0,
 
94
                 SIGNATURE_KEY_MISSING: 0,
 
95
                 SIGNATURE_NOT_VALID: 0,
 
96
                 SIGNATURE_NOT_SIGNED: 0}
 
97
        result = []
 
98
        all_verifiable = True
 
99
        for rev_id in revisions:
 
100
            verification_result, uid =\
 
101
                                repository.verify_revision(rev_id,self)
 
102
            result.append([rev_id, verification_result, uid])
 
103
            count[verification_result] += 1
 
104
            if verification_result != SIGNATURE_VALID:
 
105
                all_verifiable = False
 
106
        return (count, result, all_verifiable)
 
107
            
92
108
 
93
109
def _set_gpg_tty():
94
110
    tty = os.environ.get('TTY')
244
260
                    trace.note(i18n.gettext(
245
261
                            "No GnuPG key results for pattern: {}"
246
262
                                ).format(pattern))
 
263
 
 
264
    def do_verifications(self, revisions, repository):
 
265
        """do verifications on a set of revisions
 
266
        
 
267
        :param revisions: list of revision ids to verify
 
268
        :param repository: repository object
 
269
        
 
270
        :return: count dictionary of results of each type,
 
271
                 result list for each revision,
 
272
                 boolean True if all results are verified successfully
 
273
        """
 
274
        count = {SIGNATURE_VALID: 0,
 
275
                 SIGNATURE_KEY_MISSING: 0,
 
276
                 SIGNATURE_NOT_VALID: 0,
 
277
                 SIGNATURE_NOT_SIGNED: 0}
 
278
        result = []
 
279
        all_verifiable = True
 
280
        for rev_id in revisions:
 
281
            verification_result, uid =\
 
282
                                repository.verify_revision(rev_id,self)
 
283
            result.append([rev_id, verification_result, uid])
 
284
            count[verification_result] += 1
 
285
            if verification_result != SIGNATURE_VALID:
 
286
                all_verifiable = False
 
287
        return (count, result, all_verifiable)