Rev 3582: Allow setting the commit message. in http://bzr.arbash-meinel.com/branches/bzr/1.7-dev/branch_builder
John Arbash Meinel
john at arbash-meinel.com
Tue Jul 22 20:46:05 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.7-dev/branch_builder
------------------------------------------------------------
revno: 3582
revision-id: john at arbash-meinel.com-20080722194501-mmxs3jkr6wqm7lj6
parent: john at arbash-meinel.com-20080722192731-6ibtoplxbb52wz43
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: branch_builder
timestamp: Tue 2008-07-22 14:45:01 -0500
message:
Allow setting the commit message.
-------------- next part --------------
=== modified file 'bzrlib/branchbuilder.py'
--- a/bzrlib/branchbuilder.py 2008-07-22 19:26:36 +0000
+++ b/bzrlib/branchbuilder.py 2008-07-22 19:45:01 +0000
@@ -76,11 +76,11 @@
finally:
self._branch.unlock()
- def build_snapshot(self, revision_id, parent_ids, actions):
+ def build_snapshot(self, revision_id, parent_ids, actions,
+ message=None):
"""Build a commit, shaped in a specific way.
- :param revision_id: The handle for the new commit, could be none, as it
- will be returned, though it is put in the commit message.
+ :param revision_id: The handle for the new commit, can be None
:param parent_ids: A list of parent_ids to use for the commit.
It can be None, which indicates to use the last commit.
:param actions: A list of actions to perform. Supported actions are:
@@ -88,6 +88,8 @@
('modify', ('file-id', 'new-content'))
('unversion', 'file-id')
# not supported yet: ('rename', ('orig-path', 'new-path'))
+ :param message: An optional commit message, if not supplied, a default
+ commit message will be written.
;return: The revision_id of the new commit
"""
if parent_ids is not None:
@@ -144,7 +146,9 @@
for file_id, content in new_contents.iteritems():
tree.put_file_bytes_non_atomic(file_id, content)
- return tree.commit('commit %s' % (revision_id,), rev_id=revision_id)
+ if message is None:
+ message = u'commit %d' % (self._branch.revno() + 1,)
+ return tree.commit(message, rev_id=revision_id)
finally:
tree.unlock()
=== modified file 'bzrlib/tests/test_branchbuilder.py'
--- a/bzrlib/tests/test_branchbuilder.py 2008-07-22 18:57:57 +0000
+++ b/bzrlib/tests/test_branchbuilder.py 2008-07-22 19:45:01 +0000
@@ -130,6 +130,23 @@
(u'b', 'b-id', 'directory'),
], rev_tree)
+ def test_commit_message_default(self):
+ builder = BranchBuilder(self.get_transport().clone('foo'))
+ rev_id = builder.build_snapshot(None, None,
+ [('add', (u'', None, 'directory', None))])
+ branch = builder.get_branch()
+ rev = branch.repository.get_revision(rev_id)
+ self.assertEqual(u'commit 1', rev.message)
+
+ def test_commit_message_supplied(self):
+ builder = BranchBuilder(self.get_transport().clone('foo'))
+ rev_id = builder.build_snapshot(None, None,
+ [('add', (u'', None, 'directory', None))],
+ message=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,
More information about the bazaar-commits
mailing list