~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit_signature_commands.py

  • Committer: Vincent Ladeuil
  • Date: 2012-03-09 11:01:58 UTC
  • mto: This revision was merged to the branch mainline in revision 6489.
  • Revision ID: v.ladeuil+lp@free.fr-20120309110158-62om0ttqa0ooeuw5
Fix the forgotten reference to what's new as part of the 2.6 series initialization.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from __future__ import absolute_import
21
21
 
 
22
from bzrlib.lazy_import import lazy_import
 
23
lazy_import(globals(), """
22
24
from bzrlib import (
23
25
    controldir,
24
26
    errors,
25
27
    gpg,
26
28
    revision as _mod_revision,
27
29
    )
 
30
""")
28
31
from bzrlib.commands import Command
29
32
from bzrlib.option import Option
30
33
from bzrlib.i18n import gettext, ngettext
31
34
 
32
 
 
33
35
class cmd_sign_my_commits(Command):
34
36
    __doc__ = """Sign all commits by a given committer.
35
37
 
83
85
                        continue
84
86
                    # We have a revision without a signature who has a
85
87
                    # matching committer, start signing
86
 
                    self.outf.write("%s\n" % rev_id)
 
88
                    print rev_id
87
89
                    count += 1
88
90
                    if not dry_run:
89
91
                        repo.sign_revision(rev_id, gpg_strategy)
94
96
                repo.commit_write_group()
95
97
        finally:
96
98
            repo.unlock()
97
 
        self.outf.write(
98
 
            ngettext('Signed %d revision.\n', 'Signed %d revisions.\n', count) %
99
 
            count)
 
99
        print 'Signed %d revisions' % (count,)
100
100
 
101
101
 
102
102
class cmd_verify_signatures(Command):
131
131
        def write_verbose(string):
132
132
            self.outf.write("  " + string + "\n")
133
133
 
134
 
        self.add_cleanup(repo.lock_read().unlock)
135
134
        #get our list of revisions
136
135
        revisions = []
137
136
        if revision is not None:
152
151
            #all revisions by default including merges
153
152
            graph = repo.get_graph()
154
153
            revisions = []
 
154
            repo.lock_read()
155
155
            for rev_id, parents in graph.iter_ancestry(
156
156
                    [branch.last_revision()]):
157
157
                if _mod_revision.is_null(rev_id):
160
160
                    # Ignore ghosts
161
161
                    continue
162
162
                revisions.append(rev_id)
 
163
            repo.unlock()
163
164
        count, result, all_verifiable =\
164
 
                                gpg.bulk_verify_signatures(repo, revisions, gpg_strategy)
 
165
                                gpg_strategy.do_verifications(revisions, repo)
165
166
        if all_verifiable:
166
 
               write(gettext("All commits signed with verifiable keys"))
 
167
               write(gettext(
 
168
                            "All commits signed with verifiable keys"))
167
169
               if verbose:
168
 
                   write(gpg.verbose_valid_message(result))
 
170
                   write(gpg_strategy.verbose_valid_message(result))
169
171
               return 0
170
172
        else:
171
 
            write(gpg.valid_commits_message(count))
172
 
            if verbose:
173
 
               for message in gpg.verbose_valid_message(result):
174
 
                   write_verbose(message)
175
 
            write(gpg.expired_commit_message(count))
176
 
            if verbose:
177
 
               for message in gpg.verbose_expired_key_message(result, repo):
178
 
                   write_verbose(message)
179
 
            write(gpg.unknown_key_message(count))
180
 
            if verbose:
181
 
                for message in gpg.verbose_missing_key_message(result):
 
173
            write(gpg_strategy.valid_commits_message(count))
 
174
            if verbose:
 
175
               for message in gpg_strategy.verbose_valid_message(result):
 
176
                   write_verbose(message)
 
177
            write(gpg_strategy.expired_commit_message(count))
 
178
            if verbose:
 
179
               for message in gpg_strategy.verbose_expired_key_message(result,
 
180
                                                                          repo):
 
181
                   write_verbose(message)
 
182
            write(gpg_strategy.unknown_key_message(count))
 
183
            if verbose:
 
184
                for message in gpg_strategy.verbose_missing_key_message(result):
182
185
                    write_verbose(message)
183
 
            write(gpg.commit_not_valid_message(count))
 
186
            write(gpg_strategy.commit_not_valid_message(count))
184
187
            if verbose:
185
 
                for message in gpg.verbose_not_valid_message(result, repo):
 
188
                for message in gpg_strategy.verbose_not_valid_message(result,
 
189
                                                                        repo):
186
190
                   write_verbose(message)
187
 
            write(gpg.commit_not_signed_message(count))
 
191
            write(gpg_strategy.commit_not_signed_message(count))
188
192
            if verbose:
189
 
                for message in gpg.verbose_not_signed_message(result, repo):
 
193
                for message in gpg_strategy.verbose_not_signed_message(result,
 
194
                                                                          repo):
190
195
                    write_verbose(message)
191
196
            return 1