88
88
print 'Signed %d revisions' % (count,)
91
class cmd_verify(Command):
92
__doc__ = """Sign all commits by a given committer.
94
If location is not specified the local tree is used.
95
If committer is not specified the default committer is used.
97
This does not sign commits that already have signatures.
99
# Note that this signs everything on the branch's ancestry
100
# (both mainline and merged), but not other revisions that may be in the
105
help='Don\'t actually sign anything, just print'
106
' the revisions that would be signed.'),
108
takes_args = ['location?', 'committer?']
110
def run(self, location=None, committer=None, dry_run=False):
112
bzrdir = _mod_bzrdir.BzrDir.open_containing('.')[0]
114
# Passed in locations should be exact
115
bzrdir = _mod_bzrdir.BzrDir.open(location)
116
branch = bzrdir.open_branch()
117
repo = branch.repository
118
branch_config = branch.get_config()
120
if committer is None:
121
committer = branch_config.username()
122
gpg_strategy = gpg.GPGStrategy(branch_config)
124
count = {gpg.SIGNATURE_VALID: 0,
125
gpg.SIGNATURE_KEY_MISSING: 0,
126
gpg.SIGNATURE_NOT_VALID: 0,
127
gpg.SIGNATURE_NOT_SIGNED: 0}
129
for rev_id in repo.get_ancestry(branch.last_revision())[1:]:
130
if not repo.has_signature_for_revision_id(rev_id):
131
result.append([rev_id, gpg.SIGNATURE_NOT_SIGNED])
133
rev = repo.get_revision(rev_id)
134
#if rev.committer != committer:
136
# We have a revision without a signature who has a
137
# matching committer, start signing
140
verification_result = repo.verify_revision(rev_id, gpg_strategy)
141
result.append([rev_id, verification_result])
142
count[verification_result] += 1
143
#print 'Signed %d revisions' % (count,)
144
print "result: " + str(result)
145
print "count: " + str(count)