~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Robert Collins
  • Date: 2005-10-16 02:25:11 UTC
  • mto: This revision was merged to the branch mainline in revision 1459.
  • Revision ID: robertc@lifelesslap.robertcollins.net-20051016022511-0bd5ebf69bd26bd2
Pull up _relpath with gz suffix for CompressedTextStore into TransportStore

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
 
import bzrlib.gpg as gpg
88
80
from bzrlib.revision import Revision
89
 
from bzrlib.testament import Testament
90
81
from bzrlib.trace import mutter, note, warning
91
82
from bzrlib.xml5 import serializer_v5
92
83
from bzrlib.inventory import Inventory, ROOT_ID
154
145
            working inventory.
155
146
    """
156
147
    def __init__(self,
157
 
                 reporter=None,
158
 
                 config=None):
 
148
                 reporter=None):
159
149
        if reporter is not None:
160
150
            self.reporter = reporter
161
151
        else:
162
152
            self.reporter = NullCommitReporter()
163
 
        if config is not None:
164
 
            self.config = config
165
 
        else:
166
 
            self.config = None
 
153
 
167
154
        
168
155
    def commit(self,
169
156
               branch, message,
173
160
               specific_files=None,
174
161
               rev_id=None,
175
162
               allow_pointless=True,
176
 
               strict=False,
177
163
               verbose=False,
178
164
               revprops=None):
179
165
        """Commit working copy as a new revision.
192
178
        allow_pointless -- If true (default), commit even if nothing
193
179
            has changed and no merges are recorded.
194
180
 
195
 
        strict -- If true, don't allow a commit if the working tree
196
 
            contains unknown files.
197
 
 
198
181
        revprops -- Properties for new revision
199
182
        """
200
183
        mutter('preparing to commit')
206
189
        self.allow_pointless = allow_pointless
207
190
        self.revprops = revprops
208
191
 
209
 
        if strict and branch.unknowns():
210
 
            raise StrictCommitFailed()
211
 
 
212
192
        if timestamp is None:
213
193
            self.timestamp = time.time()
214
194
        else:
215
195
            self.timestamp = long(timestamp)
216
196
            
217
 
        if self.config is None:
218
 
            self.config = bzrlib.config.BranchConfig(self.branch)
219
 
 
 
197
        config = bzrlib.config.BranchConfig(self.branch)
220
198
        if rev_id is None:
221
 
            self.rev_id = _gen_revision_id(self.config, self.timestamp)
 
199
            self.rev_id = _gen_revision_id(config, self.timestamp)
222
200
        else:
223
201
            self.rev_id = rev_id
224
202
 
225
203
        if committer is None:
226
 
            self.committer = self.config.username()
 
204
            self.committer = config.username()
227
205
        else:
228
206
            assert isinstance(committer, basestring), type(committer)
229
207
            self.committer = committer
336
314
        rev_tmp = StringIO()
337
315
        serializer_v5.write_revision(self.rev, rev_tmp)
338
316
        rev_tmp.seek(0)
339
 
        if self.config.signature_needed():
340
 
            plaintext = Testament(self.rev, self.new_inv).as_short_text()
341
 
            self.branch.store_revision_signature(gpg.GPGStrategy(self.config),
342
 
                                                 plaintext, self.rev_id)
343
317
        self.branch.revision_store.add(rev_tmp, self.rev_id)
344
318
        mutter('new revision_id is {%s}', self.rev_id)
345
319