~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:56:54 UTC
  • mfrom: (1185.16.59)
  • Revision ID: robertc@robertcollins.net-20051017115654-662239e1587524a8
mergeĀ fromĀ martin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
# merges from, then it should still be reported as newly added
57
57
# relative to the basis revision.
58
58
 
59
 
# TODO: Do checks that the tree can be committed *before* running the 
60
 
# editor; this should include checks for a pointless commit and for 
61
 
# unknown or missing files.
62
 
 
63
 
# TODO: If commit fails, leave the message in a file somewhere.
64
 
 
65
59
 
66
60
import os
67
61
import re
81
75
import bzrlib.config
82
76
from bzrlib.errors import (BzrError, PointlessCommit,
83
77
                           HistoryMissing,
84
 
                           ConflictsInTree,
85
 
                           StrictCommitFailed
 
78
                           ConflictsInTree
86
79
                           )
87
80
import bzrlib.gpg as gpg
88
81
from bzrlib.revision import Revision
89
 
from bzrlib.testament import Testament
90
82
from bzrlib.trace import mutter, note, warning
91
83
from bzrlib.xml5 import serializer_v5
92
84
from bzrlib.inventory import Inventory, ROOT_ID
173
165
               specific_files=None,
174
166
               rev_id=None,
175
167
               allow_pointless=True,
176
 
               strict=False,
177
168
               verbose=False,
178
169
               revprops=None):
179
170
        """Commit working copy as a new revision.
192
183
        allow_pointless -- If true (default), commit even if nothing
193
184
            has changed and no merges are recorded.
194
185
 
195
 
        strict -- If true, don't allow a commit if the working tree
196
 
            contains unknown files.
197
 
 
198
186
        revprops -- Properties for new revision
199
187
        """
200
188
        mutter('preparing to commit')
206
194
        self.allow_pointless = allow_pointless
207
195
        self.revprops = revprops
208
196
 
209
 
        if strict:
210
 
            # raise an exception as soon as we find a single unknown.
211
 
            for unknown in branch.unknowns():
212
 
                raise StrictCommitFailed()
213
 
 
214
197
        if timestamp is None:
215
198
            self.timestamp = time.time()
216
199
        else:
266
249
 
267
250
            self._record_inventory()
268
251
            self._make_revision()
 
252
            self.reporter.completed(self.branch.revno()+1, self.rev_id)
269
253
            self.branch.append_revision(self.rev_id)
270
254
            self.branch.set_pending_merges([])
271
 
            self.reporter.completed(self.branch.revno()+1, self.rev_id)
272
 
            if self.config.post_commit() is not None:
273
 
                hooks = self.config.post_commit().split(' ')
274
 
                # this would be nicer with twisted.python.reflect.namedAny
275
 
                for hook in hooks:
276
 
                    result = eval(hook + '(branch, rev_id)',
277
 
                                  {'branch':self.branch,
278
 
                                   'bzrlib':bzrlib,
279
 
                                   'rev_id':self.rev_id})
280
255
        finally:
281
256
            self.branch.unlock()
282
257
 
346
321
        rev_tmp = StringIO()
347
322
        serializer_v5.write_revision(self.rev, rev_tmp)
348
323
        rev_tmp.seek(0)
 
324
        self.branch.revision_store.add(rev_tmp, self.rev_id)
349
325
        if self.config.signature_needed():
350
 
            plaintext = Testament(self.rev, self.new_inv).as_short_text()
351
 
            self.branch.store_revision_signature(gpg.GPGStrategy(self.config),
352
 
                                                 plaintext, self.rev_id)
353
 
        self.branch.revision_store.add(rev_tmp, self.rev_id)
 
326
            self.branch.sign_revision(self.rev_id, gpg.GPGStrategy(self.config))
354
327
        mutter('new revision_id is {%s}', self.rev_id)
355
328
 
356
329
    def _remove_deleted(self):