Rev 5061: (robertc) bzrlib.branchbuilder.BranchBuilder.build_snapshot now in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Sun Feb 28 18:50:32 GMT 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5061 [merge]
revision-id: pqm at pqm.ubuntu.com-20100228185031-155sw5ndgh3tkl3w
parent: pqm at pqm.ubuntu.com-20100226141436-t8s3uqt5w9ktt04g
parent: robertc at robertcollins.net-20100227122733-2o3me3fkk3pk36ns
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sun 2010-02-28 18:50:31 +0000
message:
  (robertc) bzrlib.branchbuilder.BranchBuilder.build_snapshot now
  	accepts a message_callback in the same way that commit does.
  	(Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/branchbuilder.py        branchbuilder.py-20070427022007-zlxpqz2lannhk6y8-1
  bzrlib/tests/test_branchbuilder.py test_branchbuilder.p-20070427022007-zlxpqz2lannhk6y8-2
=== 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,




More information about the bazaar-commits mailing list