~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Robert Collins
  • Date: 2005-10-17 11:41:07 UTC
  • mfrom: (1442.1.60)
  • Revision ID: robertc@robertcollins.net-20051017114107-f5586285d825c105
Merge in first part of GPG support.

This adds check_signatures config support, triams back the transport api
to be leaner and easier to hook in suffixes - non primary streams in the store
associated with the fileid that primary data is stored in, a gpg module which
will encapsulate all signing and checking operations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
                           HistoryMissing,
78
78
                           ConflictsInTree
79
79
                           )
 
80
import bzrlib.gpg as gpg
80
81
from bzrlib.revision import Revision
81
82
from bzrlib.trace import mutter, note, warning
82
83
from bzrlib.xml5 import serializer_v5
145
146
            working inventory.
146
147
    """
147
148
    def __init__(self,
148
 
                 reporter=None):
 
149
                 reporter=None,
 
150
                 config=None):
149
151
        if reporter is not None:
150
152
            self.reporter = reporter
151
153
        else:
152
154
            self.reporter = NullCommitReporter()
153
 
 
 
155
        if config is not None:
 
156
            self.config = config
 
157
        else:
 
158
            self.config = None
154
159
        
155
160
    def commit(self,
156
161
               branch, message,
194
199
        else:
195
200
            self.timestamp = long(timestamp)
196
201
            
197
 
        config = bzrlib.config.BranchConfig(self.branch)
 
202
        if self.config is None:
 
203
            self.config = bzrlib.config.BranchConfig(self.branch)
 
204
 
198
205
        if rev_id is None:
199
 
            self.rev_id = _gen_revision_id(config, self.timestamp)
 
206
            self.rev_id = _gen_revision_id(self.config, self.timestamp)
200
207
        else:
201
208
            self.rev_id = rev_id
202
209
 
203
210
        if committer is None:
204
 
            self.committer = config.username()
 
211
            self.committer = self.config.username()
205
212
        else:
206
213
            assert isinstance(committer, basestring), type(committer)
207
214
            self.committer = committer
315
322
        serializer_v5.write_revision(self.rev, rev_tmp)
316
323
        rev_tmp.seek(0)
317
324
        self.branch.revision_store.add(rev_tmp, self.rev_id)
 
325
        if self.config.signature_needed():
 
326
            self.branch.sign_revision(self.rev_id, gpg.GPGStrategy(self.config))
318
327
        mutter('new revision_id is {%s}', self.rev_id)
319
328
 
320
329
    def _remove_deleted(self):