/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Aaron Bentley
  • Date: 2006-11-23 21:37:24 UTC
  • mto: This revision was merged to the branch mainline in revision 2155.
  • Revision ID: abentley@panoramicfeedback.com-20061123213724-pbn0jfgtwg3cln9h
Provide a message_callback parameter to tree.commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
# XXX: Can we do any better about making interrupted commits change
19
19
# nothing?  
20
20
 
21
 
# TODO: Separate 'prepare' phase where we find a list of potentially
22
 
# committed files.  We then can then pause the commit to prompt for a
23
 
# commit message, knowing the summary will be the same as what's
24
 
# actually used for the commit.  (But perhaps simpler to simply get
25
 
# the tree status, then use that for a selective commit?)
26
 
 
27
21
# The newly committed revision is going to have a shape corresponding
28
22
# to that of the working inventory.  Files that are not in the
29
23
# working tree and that were in the predecessor are reported as
59
53
# editor; this should include checks for a pointless commit and for 
60
54
# unknown or missing files.
61
55
 
62
 
# TODO: If commit fails, leave the message in a file somewhere.
63
 
 
64
56
# TODO: Change the parameter 'rev_id' to 'revision_id' to be consistent with
65
57
# the rest of the code; add a deprecation of the old name.
66
58
 
171
163
            self.config = None
172
164
        
173
165
    def commit(self,
174
 
               branch=DEPRECATED_PARAMETER, message=None,
 
166
               branch=DEPRECATED_PARAMETER, message=DEPRECATED_PARAMETER,
175
167
               timestamp=None,
176
168
               timezone=None,
177
169
               committer=None,
184
176
               working_tree=None,
185
177
               local=False,
186
178
               reporter=None,
187
 
               config=None):
 
179
               config=None,
 
180
               message_callback=None):
188
181
        """Commit working copy as a new revision.
189
182
 
190
183
        branch -- the deprecated branch to commit to. New callers should pass in 
191
184
                  working_tree instead
192
185
 
193
 
        message -- the commit message, a mandatory parameter
 
186
        message -- the commit message (it or message_callback is required)
194
187
 
195
188
        timestamp -- if not None, seconds-since-epoch for a
196
189
             postdated/predated commit.
225
218
        else:
226
219
            self.work_tree = working_tree
227
220
            self.branch = self.work_tree.branch
228
 
        if message is None:
229
 
            raise BzrError("The message keyword parameter is required for commit().")
 
221
        if message_callback is None:
 
222
            if deprecated_passed(message) and message is not None:
 
223
                symbol_versioning.warn("Commit.commit (message): The message"
 
224
                " parameter is deprecated as of bzr 0.14. Please use "
 
225
                "message_callback instead.", DeprecationWarning, stacklevel=2)
 
226
                message_callback = lambda: message
 
227
            else:
 
228
                raise BzrError("The message_callback keyword parameter is "
 
229
                               "required for commit().")
230
230
 
231
231
        self.bound_branch = None
232
232
        self.local = local
272
272
                   
273
273
            if self.config is None:
274
274
                self.config = self.branch.get_config()
275
 
      
276
 
            if isinstance(message, str):
277
 
                message = message.decode(bzrlib.user_encoding)
278
 
            assert isinstance(message, unicode), type(message)
279
 
            self.message = message
280
 
            self._escape_commit_message()
281
275
 
282
276
            self.work_inv = self.work_tree.inventory
283
277
            self.basis_tree = self.work_tree.basis_tree()
317
311
            # that commit will succeed.
318
312
            self.builder.finish_inventory()
319
313
            self._emit_progress_update()
 
314
            message = message_callback()
 
315
            if isinstance(message, str):
 
316
                message = message.decode(bzrlib.user_encoding)
 
317
            assert isinstance(message, unicode), type(message)
 
318
            self.message = message
 
319
            self._escape_commit_message()
 
320
 
320
321
            self.rev_id = self.builder.commit(self.message)
321
322
            self._emit_progress_update()
322
323
            # revision data is in the local branch now.