143
96
self.acceptable_keys.append(pattern)
145
@deprecated_method(deprecated_in((2, 6, 0)))
146
98
def do_verifications(self, revisions, repository):
147
return bulk_verify_signatures(repository, revisions, self)
99
count = {SIGNATURE_VALID: 0,
100
SIGNATURE_KEY_MISSING: 0,
101
SIGNATURE_NOT_VALID: 0,
102
SIGNATURE_NOT_SIGNED: 0,
103
SIGNATURE_EXPIRED: 0}
105
all_verifiable = True
106
for rev_id in revisions:
107
verification_result, uid =\
108
repository.verify_revision(rev_id,self)
109
result.append([rev_id, verification_result, uid])
110
count[verification_result] += 1
111
if verification_result != SIGNATURE_VALID:
112
all_verifiable = False
113
return (count, result, all_verifiable)
149
@deprecated_method(deprecated_in((2, 6, 0)))
150
115
def valid_commits_message(self, count):
151
return valid_commits_message(count)
116
return gettext(u"{0} commits with valid signatures").format(
117
count[SIGNATURE_VALID])
153
@deprecated_method(deprecated_in((2, 6, 0)))
154
119
def unknown_key_message(self, count):
155
return unknown_key_message(count)
120
return ngettext(u"{0} commit with unknown key",
121
u"{0} commits with unknown keys",
122
count[SIGNATURE_KEY_MISSING]).format(
123
count[SIGNATURE_KEY_MISSING])
157
@deprecated_method(deprecated_in((2, 6, 0)))
158
125
def commit_not_valid_message(self, count):
159
return commit_not_valid_message(count)
126
return ngettext(u"{0} commit not valid",
127
u"{0} commits not valid",
128
count[SIGNATURE_NOT_VALID]).format(
129
count[SIGNATURE_NOT_VALID])
161
@deprecated_method(deprecated_in((2, 6, 0)))
162
131
def commit_not_signed_message(self, count):
163
return commit_not_signed_message(count)
132
return ngettext(u"{0} commit not signed",
133
u"{0} commits not signed",
134
count[SIGNATURE_NOT_SIGNED]).format(
135
count[SIGNATURE_NOT_SIGNED])
165
@deprecated_method(deprecated_in((2, 6, 0)))
166
137
def expired_commit_message(self, count):
167
return expired_commit_message(count)
138
return ngettext(u"{0} commit with key now expired",
139
u"{0} commits with key now expired",
140
count[SIGNATURE_EXPIRED]).format(
141
count[SIGNATURE_EXPIRED])
170
144
def _set_gpg_tty():
366
336
"No GnuPG key results for pattern: {0}"
367
337
).format(pattern))
369
@deprecated_method(deprecated_in((2, 6, 0)))
370
339
def do_verifications(self, revisions, repository,
371
340
process_events_callback=None):
372
341
"""do verifications on a set of revisions
374
343
:param revisions: list of revision ids to verify
375
344
:param repository: repository object
376
345
:param process_events_callback: method to call for GUI frontends that
377
want to keep their UI refreshed
346
want to keep their UI refreshed
379
348
:return: count dictionary of results of each type,
380
349
result list for each revision,
381
350
boolean True if all results are verified successfully
383
return bulk_verify_signatures(repository, revisions, self,
384
process_events_callback)
352
count = {SIGNATURE_VALID: 0,
353
SIGNATURE_KEY_MISSING: 0,
354
SIGNATURE_NOT_VALID: 0,
355
SIGNATURE_NOT_SIGNED: 0,
356
SIGNATURE_EXPIRED: 0}
358
all_verifiable = True
359
for rev_id in revisions:
360
verification_result, uid =\
361
repository.verify_revision(rev_id,self)
362
result.append([rev_id, verification_result, uid])
363
count[verification_result] += 1
364
if verification_result != SIGNATURE_VALID:
365
all_verifiable = False
366
if process_events_callback is not None:
367
process_events_callback()
368
return (count, result, all_verifiable)
386
@deprecated_method(deprecated_in((2, 6, 0)))
387
370
def verbose_valid_message(self, result):
388
371
"""takes a verify result and returns list of signed commits strings"""
389
return verbose_valid_message(result)
391
@deprecated_method(deprecated_in((2, 6, 0)))
373
for rev_id, validity, uid in result:
374
if validity == SIGNATURE_VALID:
375
signers.setdefault(uid, 0)
378
for uid, number in signers.items():
379
result.append( ngettext(u"{0} signed {1} commit",
380
u"{0} signed {1} commits",
381
number).format(uid, number) )
392
385
def verbose_not_valid_message(self, result, repo):
393
386
"""takes a verify result and returns list of not valid commit info"""
394
return verbose_not_valid_message(result, repo)
388
for rev_id, validity, empty in result:
389
if validity == SIGNATURE_NOT_VALID:
390
revision = repo.get_revision(rev_id)
391
authors = ', '.join(revision.get_apparent_authors())
392
signers.setdefault(authors, 0)
393
signers[authors] += 1
395
for authors, number in signers.items():
396
result.append( ngettext(u"{0} commit by author {1}",
397
u"{0} commits by author {1}",
398
number).format(number, authors) )
396
@deprecated_method(deprecated_in((2, 6, 0)))
397
401
def verbose_not_signed_message(self, result, repo):
398
402
"""takes a verify result and returns list of not signed commit info"""
399
return verbose_not_valid_message(result, repo)
404
for rev_id, validity, empty in result:
405
if validity == SIGNATURE_NOT_SIGNED:
406
revision = repo.get_revision(rev_id)
407
authors = ', '.join(revision.get_apparent_authors())
408
signers.setdefault(authors, 0)
409
signers[authors] += 1
411
for authors, number in signers.items():
412
result.append( ngettext(u"{0} commit by author {1}",
413
u"{0} commits by author {1}",
414
number).format(number, authors) )
401
@deprecated_method(deprecated_in((2, 6, 0)))
402
417
def verbose_missing_key_message(self, result):
403
418
"""takes a verify result and returns list of missing key info"""
404
return verbose_missing_key_message(result)
420
for rev_id, validity, fingerprint in result:
421
if validity == SIGNATURE_KEY_MISSING:
422
signers.setdefault(fingerprint, 0)
423
signers[fingerprint] += 1
425
for fingerprint, number in signers.items():
426
result.append( ngettext(u"Unknown key {0} signed {1} commit",
427
u"Unknown key {0} signed {1} commits",
428
number).format(fingerprint, number) )
406
@deprecated_method(deprecated_in((2, 6, 0)))
407
431
def verbose_expired_key_message(self, result, repo):
408
432
"""takes a verify result and returns list of expired key info"""
409
return verbose_expired_key_message(result, repo)
434
fingerprint_to_authors = {}
435
for rev_id, validity, fingerprint in result:
436
if validity == SIGNATURE_EXPIRED:
437
revision = repo.get_revision(rev_id)
438
authors = ', '.join(revision.get_apparent_authors())
439
signers.setdefault(fingerprint, 0)
440
signers[fingerprint] += 1
441
fingerprint_to_authors[fingerprint] = authors
443
for fingerprint, number in signers.items():
444
result.append(ngettext(u"{0} commit by author {1} with "\
445
"key {2} now expired",
446
u"{0} commits by author {1} with key {2} now "\
448
number).format(number,
449
fingerprint_to_authors[fingerprint], fingerprint) )
411
@deprecated_method(deprecated_in((2, 6, 0)))
412
452
def valid_commits_message(self, count):
413
453
"""returns message for number of commits"""
414
return valid_commits_message(count)
454
return gettext(u"{0} commits with valid signatures").format(
455
count[SIGNATURE_VALID])
416
@deprecated_method(deprecated_in((2, 6, 0)))
417
457
def unknown_key_message(self, count):
418
458
"""returns message for number of commits"""
419
return unknown_key_message(count)
459
return ngettext(u"{0} commit with unknown key",
460
u"{0} commits with unknown keys",
461
count[SIGNATURE_KEY_MISSING]).format(
462
count[SIGNATURE_KEY_MISSING])
421
@deprecated_method(deprecated_in((2, 6, 0)))
422
464
def commit_not_valid_message(self, count):
423
465
"""returns message for number of commits"""
424
return commit_not_valid_message(count)
466
return ngettext(u"{0} commit not valid",
467
u"{0} commits not valid",
468
count[SIGNATURE_NOT_VALID]).format(
469
count[SIGNATURE_NOT_VALID])
426
@deprecated_method(deprecated_in((2, 6, 0)))
427
471
def commit_not_signed_message(self, count):
428
472
"""returns message for number of commits"""
429
return commit_not_signed_message(count)
473
return ngettext(u"{0} commit not signed",
474
u"{0} commits not signed",
475
count[SIGNATURE_NOT_SIGNED]).format(
476
count[SIGNATURE_NOT_SIGNED])
431
@deprecated_method(deprecated_in((2, 6, 0)))
432
478
def expired_commit_message(self, count):
433
479
"""returns message for number of commits"""
434
return expired_commit_message(count)
437
def valid_commits_message(count):
438
"""returns message for number of commits"""
439
return gettext(u"{0} commits with valid signatures").format(
440
count[SIGNATURE_VALID])
443
def unknown_key_message(count):
444
"""returns message for number of commits"""
445
return ngettext(u"{0} commit with unknown key",
446
u"{0} commits with unknown keys",
447
count[SIGNATURE_KEY_MISSING]).format(
448
count[SIGNATURE_KEY_MISSING])
451
def commit_not_valid_message(count):
452
"""returns message for number of commits"""
453
return ngettext(u"{0} commit not valid",
454
u"{0} commits not valid",
455
count[SIGNATURE_NOT_VALID]).format(
456
count[SIGNATURE_NOT_VALID])
459
def commit_not_signed_message(count):
460
"""returns message for number of commits"""
461
return ngettext(u"{0} commit not signed",
462
u"{0} commits not signed",
463
count[SIGNATURE_NOT_SIGNED]).format(
464
count[SIGNATURE_NOT_SIGNED])
467
def expired_commit_message(count):
468
"""returns message for number of commits"""
469
return ngettext(u"{0} commit with key now expired",
470
u"{0} commits with key now expired",
471
count[SIGNATURE_EXPIRED]).format(
472
count[SIGNATURE_EXPIRED])
475
def verbose_expired_key_message(result, repo):
476
"""takes a verify result and returns list of expired key info"""
478
fingerprint_to_authors = {}
479
for rev_id, validity, fingerprint in result:
480
if validity == SIGNATURE_EXPIRED:
481
revision = repo.get_revision(rev_id)
482
authors = ', '.join(revision.get_apparent_authors())
483
signers.setdefault(fingerprint, 0)
484
signers[fingerprint] += 1
485
fingerprint_to_authors[fingerprint] = authors
487
for fingerprint, number in signers.items():
489
ngettext(u"{0} commit by author {1} with key {2} now expired",
490
u"{0} commits by author {1} with key {2} now expired",
492
number, fingerprint_to_authors[fingerprint], fingerprint))
496
def verbose_valid_message(result):
497
"""takes a verify result and returns list of signed commits strings"""
499
for rev_id, validity, uid in result:
500
if validity == SIGNATURE_VALID:
501
signers.setdefault(uid, 0)
504
for uid, number in signers.items():
505
result.append(ngettext(u"{0} signed {1} commit",
506
u"{0} signed {1} commits",
507
number).format(uid, number))
511
def verbose_not_valid_message(result, repo):
512
"""takes a verify result and returns list of not valid commit info"""
514
for rev_id, validity, empty in result:
515
if validity == SIGNATURE_NOT_VALID:
516
revision = repo.get_revision(rev_id)
517
authors = ', '.join(revision.get_apparent_authors())
518
signers.setdefault(authors, 0)
519
signers[authors] += 1
521
for authors, number in signers.items():
522
result.append(ngettext(u"{0} commit by author {1}",
523
u"{0} commits by author {1}",
524
number).format(number, authors))
528
def verbose_not_signed_message(result, repo):
529
"""takes a verify result and returns list of not signed commit info"""
531
for rev_id, validity, empty in result:
532
if validity == SIGNATURE_NOT_SIGNED:
533
revision = repo.get_revision(rev_id)
534
authors = ', '.join(revision.get_apparent_authors())
535
signers.setdefault(authors, 0)
536
signers[authors] += 1
538
for authors, number in signers.items():
539
result.append(ngettext(u"{0} commit by author {1}",
540
u"{0} commits by author {1}",
541
number).format(number, authors))
545
def verbose_missing_key_message(result):
546
"""takes a verify result and returns list of missing key info"""
548
for rev_id, validity, fingerprint in result:
549
if validity == SIGNATURE_KEY_MISSING:
550
signers.setdefault(fingerprint, 0)
551
signers[fingerprint] += 1
553
for fingerprint, number in signers.items():
554
result.append(ngettext(u"Unknown key {0} signed {1} commit",
555
u"Unknown key {0} signed {1} commits",
556
number).format(fingerprint, number))
480
return ngettext(u"{0} commit with key now expired",
481
u"{0} commits with key now expired",
482
count[SIGNATURE_EXPIRED]).format(
483
count[SIGNATURE_EXPIRED])