143
99
self.acceptable_keys.append(pattern)
145
@deprecated_method(deprecated_in((2, 6, 0)))
146
101
def do_verifications(self, revisions, repository):
147
return bulk_verify_signatures(repository, revisions, self)
102
count = {SIGNATURE_VALID: 0,
103
SIGNATURE_KEY_MISSING: 0,
104
SIGNATURE_NOT_VALID: 0,
105
SIGNATURE_NOT_SIGNED: 0,
106
SIGNATURE_EXPIRED: 0}
108
all_verifiable = True
109
for rev_id in revisions:
110
verification_result, uid =\
111
repository.verify_revision_signature(rev_id,self)
112
result.append([rev_id, verification_result, uid])
113
count[verification_result] += 1
114
if verification_result != SIGNATURE_VALID:
115
all_verifiable = False
116
return (count, result, all_verifiable)
149
@deprecated_method(deprecated_in((2, 6, 0)))
150
118
def valid_commits_message(self, count):
151
return valid_commits_message(count)
119
return gettext(u"{0} commits with valid signatures").format(
120
count[SIGNATURE_VALID])
153
@deprecated_method(deprecated_in((2, 6, 0)))
154
122
def unknown_key_message(self, count):
155
return unknown_key_message(count)
123
return ngettext(u"{0} commit with unknown key",
124
u"{0} commits with unknown keys",
125
count[SIGNATURE_KEY_MISSING]).format(
126
count[SIGNATURE_KEY_MISSING])
157
@deprecated_method(deprecated_in((2, 6, 0)))
158
128
def commit_not_valid_message(self, count):
159
return commit_not_valid_message(count)
129
return ngettext(u"{0} commit not valid",
130
u"{0} commits not valid",
131
count[SIGNATURE_NOT_VALID]).format(
132
count[SIGNATURE_NOT_VALID])
161
@deprecated_method(deprecated_in((2, 6, 0)))
162
134
def commit_not_signed_message(self, count):
163
return commit_not_signed_message(count)
135
return ngettext(u"{0} commit not signed",
136
u"{0} commits not signed",
137
count[SIGNATURE_NOT_SIGNED]).format(
138
count[SIGNATURE_NOT_SIGNED])
165
@deprecated_method(deprecated_in((2, 6, 0)))
166
140
def expired_commit_message(self, count):
167
return expired_commit_message(count)
141
return ngettext(u"{0} commit with key now expired",
142
u"{0} commits with key now expired",
143
count[SIGNATURE_EXPIRED]).format(
144
count[SIGNATURE_EXPIRED])
170
147
def _set_gpg_tty():
358
343
"No GnuPG key results for pattern: {0}"
359
344
).format(pattern))
361
@deprecated_method(deprecated_in((2, 6, 0)))
362
346
def do_verifications(self, revisions, repository,
363
347
process_events_callback=None):
364
348
"""do verifications on a set of revisions
366
350
:param revisions: list of revision ids to verify
367
351
:param repository: repository object
368
352
:param process_events_callback: method to call for GUI frontends that
369
want to keep their UI refreshed
353
want to keep their UI refreshed
371
355
:return: count dictionary of results of each type,
372
356
result list for each revision,
373
357
boolean True if all results are verified successfully
375
return bulk_verify_signatures(repository, revisions, self,
376
process_events_callback)
359
count = {SIGNATURE_VALID: 0,
360
SIGNATURE_KEY_MISSING: 0,
361
SIGNATURE_NOT_VALID: 0,
362
SIGNATURE_NOT_SIGNED: 0,
363
SIGNATURE_EXPIRED: 0}
365
all_verifiable = True
366
for rev_id in revisions:
367
verification_result, uid =\
368
repository.verify_revision_signature(rev_id, self)
369
result.append([rev_id, verification_result, uid])
370
count[verification_result] += 1
371
if verification_result != SIGNATURE_VALID:
372
all_verifiable = False
373
if process_events_callback is not None:
374
process_events_callback()
375
return (count, result, all_verifiable)
378
@deprecated_method(deprecated_in((2, 6, 0)))
379
377
def verbose_valid_message(self, result):
380
378
"""takes a verify result and returns list of signed commits strings"""
381
return verbose_valid_message(result)
383
@deprecated_method(deprecated_in((2, 6, 0)))
380
for rev_id, validity, uid in result:
381
if validity == SIGNATURE_VALID:
382
signers.setdefault(uid, 0)
385
for uid, number in signers.items():
386
result.append( ngettext(u"{0} signed {1} commit",
387
u"{0} signed {1} commits",
388
number).format(uid, number) )
384
392
def verbose_not_valid_message(self, result, repo):
385
393
"""takes a verify result and returns list of not valid commit info"""
386
return verbose_not_valid_message(result, repo)
395
for rev_id, validity, empty in result:
396
if validity == SIGNATURE_NOT_VALID:
397
revision = repo.get_revision(rev_id)
398
authors = ', '.join(revision.get_apparent_authors())
399
signers.setdefault(authors, 0)
400
signers[authors] += 1
402
for authors, number in signers.items():
403
result.append( ngettext(u"{0} commit by author {1}",
404
u"{0} commits by author {1}",
405
number).format(number, authors) )
388
@deprecated_method(deprecated_in((2, 6, 0)))
389
408
def verbose_not_signed_message(self, result, repo):
390
409
"""takes a verify result and returns list of not signed commit info"""
391
return verbose_not_valid_message(result, repo)
411
for rev_id, validity, empty in result:
412
if validity == SIGNATURE_NOT_SIGNED:
413
revision = repo.get_revision(rev_id)
414
authors = ', '.join(revision.get_apparent_authors())
415
signers.setdefault(authors, 0)
416
signers[authors] += 1
418
for authors, number in signers.items():
419
result.append( ngettext(u"{0} commit by author {1}",
420
u"{0} commits by author {1}",
421
number).format(number, authors) )
393
@deprecated_method(deprecated_in((2, 6, 0)))
394
424
def verbose_missing_key_message(self, result):
395
425
"""takes a verify result and returns list of missing key info"""
396
return verbose_missing_key_message(result)
427
for rev_id, validity, fingerprint in result:
428
if validity == SIGNATURE_KEY_MISSING:
429
signers.setdefault(fingerprint, 0)
430
signers[fingerprint] += 1
432
for fingerprint, number in signers.items():
433
result.append( ngettext(u"Unknown key {0} signed {1} commit",
434
u"Unknown key {0} signed {1} commits",
435
number).format(fingerprint, number) )
398
@deprecated_method(deprecated_in((2, 6, 0)))
399
438
def verbose_expired_key_message(self, result, repo):
400
439
"""takes a verify result and returns list of expired key info"""
401
return verbose_expired_key_message(result, repo)
441
fingerprint_to_authors = {}
442
for rev_id, validity, fingerprint in result:
443
if validity == SIGNATURE_EXPIRED:
444
revision = repo.get_revision(rev_id)
445
authors = ', '.join(revision.get_apparent_authors())
446
signers.setdefault(fingerprint, 0)
447
signers[fingerprint] += 1
448
fingerprint_to_authors[fingerprint] = authors
450
for fingerprint, number in signers.items():
452
ngettext(u"{0} commit by author {1} with key {2} now expired",
453
u"{0} commits by author {1} with key {2} now expired",
455
number, fingerprint_to_authors[fingerprint], fingerprint) )
403
@deprecated_method(deprecated_in((2, 6, 0)))
404
458
def valid_commits_message(self, count):
405
459
"""returns message for number of commits"""
406
return valid_commits_message(count)
460
return gettext(u"{0} commits with valid signatures").format(
461
count[SIGNATURE_VALID])
408
@deprecated_method(deprecated_in((2, 6, 0)))
409
463
def unknown_key_message(self, count):
410
464
"""returns message for number of commits"""
411
return unknown_key_message(count)
465
return ngettext(u"{0} commit with unknown key",
466
u"{0} commits with unknown keys",
467
count[SIGNATURE_KEY_MISSING]).format(
468
count[SIGNATURE_KEY_MISSING])
413
@deprecated_method(deprecated_in((2, 6, 0)))
414
470
def commit_not_valid_message(self, count):
415
471
"""returns message for number of commits"""
416
return commit_not_valid_message(count)
472
return ngettext(u"{0} commit not valid",
473
u"{0} commits not valid",
474
count[SIGNATURE_NOT_VALID]).format(
475
count[SIGNATURE_NOT_VALID])
418
@deprecated_method(deprecated_in((2, 6, 0)))
419
477
def commit_not_signed_message(self, count):
420
478
"""returns message for number of commits"""
421
return commit_not_signed_message(count)
479
return ngettext(u"{0} commit not signed",
480
u"{0} commits not signed",
481
count[SIGNATURE_NOT_SIGNED]).format(
482
count[SIGNATURE_NOT_SIGNED])
423
@deprecated_method(deprecated_in((2, 6, 0)))
424
484
def expired_commit_message(self, count):
425
485
"""returns message for number of commits"""
426
return expired_commit_message(count)
429
def valid_commits_message(count):
430
"""returns message for number of commits"""
431
return gettext(u"{0} commits with valid signatures").format(
432
count[SIGNATURE_VALID])
435
def unknown_key_message(count):
436
"""returns message for number of commits"""
437
return ngettext(u"{0} commit with unknown key",
438
u"{0} commits with unknown keys",
439
count[SIGNATURE_KEY_MISSING]).format(
440
count[SIGNATURE_KEY_MISSING])
443
def commit_not_valid_message(count):
444
"""returns message for number of commits"""
445
return ngettext(u"{0} commit not valid",
446
u"{0} commits not valid",
447
count[SIGNATURE_NOT_VALID]).format(
448
count[SIGNATURE_NOT_VALID])
451
def commit_not_signed_message(count):
452
"""returns message for number of commits"""
453
return ngettext(u"{0} commit not signed",
454
u"{0} commits not signed",
455
count[SIGNATURE_NOT_SIGNED]).format(
456
count[SIGNATURE_NOT_SIGNED])
459
def expired_commit_message(count):
460
"""returns message for number of commits"""
461
return ngettext(u"{0} commit with key now expired",
462
u"{0} commits with key now expired",
463
count[SIGNATURE_EXPIRED]).format(
464
count[SIGNATURE_EXPIRED])
467
def verbose_expired_key_message(result, repo):
468
"""takes a verify result and returns list of expired key info"""
470
fingerprint_to_authors = {}
471
for rev_id, validity, fingerprint in result:
472
if validity == SIGNATURE_EXPIRED:
473
revision = repo.get_revision(rev_id)
474
authors = ', '.join(revision.get_apparent_authors())
475
signers.setdefault(fingerprint, 0)
476
signers[fingerprint] += 1
477
fingerprint_to_authors[fingerprint] = authors
479
for fingerprint, number in signers.items():
481
ngettext(u"{0} commit by author {1} with key {2} now expired",
482
u"{0} commits by author {1} with key {2} now expired",
484
number, fingerprint_to_authors[fingerprint], fingerprint))
488
def verbose_valid_message(result):
489
"""takes a verify result and returns list of signed commits strings"""
491
for rev_id, validity, uid in result:
492
if validity == SIGNATURE_VALID:
493
signers.setdefault(uid, 0)
496
for uid, number in signers.items():
497
result.append(ngettext(u"{0} signed {1} commit",
498
u"{0} signed {1} commits",
499
number).format(uid, number))
503
def verbose_not_valid_message(result, repo):
504
"""takes a verify result and returns list of not valid commit info"""
506
for rev_id, validity, empty in result:
507
if validity == SIGNATURE_NOT_VALID:
508
revision = repo.get_revision(rev_id)
509
authors = ', '.join(revision.get_apparent_authors())
510
signers.setdefault(authors, 0)
511
signers[authors] += 1
513
for authors, number in signers.items():
514
result.append(ngettext(u"{0} commit by author {1}",
515
u"{0} commits by author {1}",
516
number).format(number, authors))
520
def verbose_not_signed_message(result, repo):
521
"""takes a verify result and returns list of not signed commit info"""
523
for rev_id, validity, empty in result:
524
if validity == SIGNATURE_NOT_SIGNED:
525
revision = repo.get_revision(rev_id)
526
authors = ', '.join(revision.get_apparent_authors())
527
signers.setdefault(authors, 0)
528
signers[authors] += 1
530
for authors, number in signers.items():
531
result.append(ngettext(u"{0} commit by author {1}",
532
u"{0} commits by author {1}",
533
number).format(number, authors))
537
def verbose_missing_key_message(result):
538
"""takes a verify result and returns list of missing key info"""
540
for rev_id, validity, fingerprint in result:
541
if validity == SIGNATURE_KEY_MISSING:
542
signers.setdefault(fingerprint, 0)
543
signers[fingerprint] += 1
545
for fingerprint, number in signers.items():
546
result.append(ngettext(u"Unknown key {0} signed {1} commit",
547
u"Unknown key {0} signed {1} commits",
548
number).format(fingerprint, number))
486
return ngettext(u"{0} commit with key now expired",
487
u"{0} commits with key now expired",
488
count[SIGNATURE_EXPIRED]).format(
489
count[SIGNATURE_EXPIRED])