At http://bazaar.launchpad.net/~lifeless/bzr/msgeditor
------------------------------------------------------------ revno: 5061 revision-id: [email protected] parent: [email protected] committer: Robert Collins <[email protected]> branch nick: msgeditor timestamp: Sat 2010-02-27 23:27:33 +1100 message: ``bzrlib.branchbuilder.BranchBuilder.build_snapshot`` now accepts a ``message_callback`` in the same way that commit does. (Robert Collins) === modified file 'NEWS' --- a/NEWS 2010-02-26 04:43:31 +0000 +++ b/NEWS 2010-02-27 12:27:33 +0000 @@ -109,6 +109,9 @@ Internals ********* +* ``bzrlib.branchbuilder.BranchBuilder.build_snapshot`` now accepts a + ``message_callback`` in the same way that commit does. (Robert Collins) + * ``bzrlib.commands.run_bzr`` is more extensible: callers can supply the functions to load or disable plugins if they wish to use a different plugin mechanism; the --help, --version and no-command name code paths === modified file 'bzrlib/branchbuilder.py' --- a/bzrlib/branchbuilder.py 2009-08-05 02:12:22 +0000 +++ b/bzrlib/branchbuilder.py 2010-02-27 12:27:33 +0000 @@ -103,11 +103,11 @@ finally: tree.unlock() - def _do_commit(self, tree, message=None, **kwargs): + def _do_commit(self, tree, message=None, message_callback=None, **kwargs): reporter = commit.NullCommitReporter() - if message is None: + if message is None and message_callback is None: message = u'commit %d' % (self._branch.revno() + 1,) - return tree.commit(message, + return tree.commit(message, message_callback=message_callback, reporter=reporter, **kwargs) @@ -162,7 +162,7 @@ def build_snapshot(self, revision_id, parent_ids, actions, message=None, timestamp=None, allow_leftmost_as_ghost=False, - committer=None, timezone=None): + committer=None, timezone=None, message_callback=None): """Build a commit, shaped in a specific way. :param revision_id: The handle for the new commit, can be None @@ -175,6 +175,8 @@ ('rename', ('orig-path', 'new-path')) :param message: An optional commit message, if not supplied, a default commit message will be written. + :param message_callback: A message callback to use for the commit, as + per mutabletree.commit. :param timestamp: If non-None, set the timestamp of the commit to this value. :param timezone: An optional timezone for timestamp. @@ -244,7 +246,8 @@ for file_id, content in new_contents.iteritems(): tree.put_file_bytes_non_atomic(file_id, content) return self._do_commit(tree, message=message, rev_id=revision_id, - timestamp=timestamp, timezone=timezone, committer=committer) + timestamp=timestamp, timezone=timezone, committer=committer, + message_callback=message_callback) finally: tree.unlock() === modified file 'bzrlib/tests/test_branchbuilder.py' --- a/bzrlib/tests/test_branchbuilder.py 2009-05-07 05:08:46 +0000 +++ b/bzrlib/tests/test_branchbuilder.py 2010-02-27 12:27:33 +0000 @@ -171,6 +171,15 @@ rev = branch.repository.get_revision(rev_id) self.assertEqual(u'Foo', rev.message) + def test_commit_message_callback(self): + builder = BranchBuilder(self.get_transport().clone('foo')) + rev_id = builder.build_snapshot(None, None, + [('add', (u'', None, 'directory', None))], + message_callback=lambda x:u'Foo') + branch = builder.get_branch() + rev = branch.repository.get_revision(rev_id) + self.assertEqual(u'Foo', rev.message) + def test_modify_file(self): builder = self.build_a_rev() rev_id2 = builder.build_snapshot('B-id', None, -- bazaar-commits mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/bazaar-commits
