Rev 387: Fix message_callback argument to commit() in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev

Jelmer Vernooij jelmer at samba.org
Mon Jan 8 16:37:40 GMT 2007


------------------------------------------------------------
revno: 387
revision-id: jelmer at samba.org-20070108163623-wutkgf1ul9ef0kg1
parent: jelmer at samba.org-20070108160335-ddcgxfqunj2fch2u
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Mon 2007-01-08 17:36:23 +0100
message:
  Fix message_callback argument to commit()
modified:
  checkout.py                    workingtree.py-20060306120941-b083cb0fdd4a69de
  tests/test_workingtree.py      test_workingtree.py-20060622191524-0di7bc3q1ckdbybb-1
=== modified file 'checkout.py'
--- a/checkout.py	2007-01-08 16:03:35 +0000
+++ b/checkout.py	2007-01-08 16:36:23 +0000
@@ -64,7 +64,6 @@
         self.client_ctx = svn.client.create_context()
         self.pool = Pool()
         self.client_ctx.log_msg_func2 = svn.client.svn_swig_py_get_commit_log_func
-        self.client_ctx.log_msg_baton2 = self.log_message_func
         self.client_ctx.auth_baton = _create_auth_baton(self.pool)
 
         wc = self._get_wc()
@@ -380,12 +379,9 @@
             svn.wc.adm_close(wc)
         self.base_revid = revid
 
-    def log_message_func(self, items, pool):
-        """ Simple log message provider for unit tests. """
-        return self._message
-
-    def commit(self, message=None, revprops=None, timestamp=None, timezone=None, committer=None, rev_id=None, allow_pointless=True, 
-            strict=False, verbose=False, local=False, reporter=None, config=None, specific_files=None):
+    def commit(self, message=None, message_callback=None, revprops=None, timestamp=None, timezone=None, committer=None, 
+               rev_id=None, allow_pointless=True, strict=False, verbose=False, local=False, reporter=None, config=None, 
+               specific_files=None):
         assert timestamp is None
         assert timezone is None
         assert rev_id is None
@@ -395,9 +391,17 @@
         else:
             specific_files = [self.basedir.encode('utf8')]
 
-        assert isinstance(message, basestring)
-        self._message = message
+        if message_callback is not None:
+            def log_message_func(items, pool):
+                """ Simple log message provider for unit tests. """
+                return message_callback(self)
+        else:
+            assert isinstance(message, basestring)
+            def log_message_func(items, pool):
+                """ Simple log message provider for unit tests. """
+                return message
 
+        self.client_ctx.log_msg_baton2 = log_message_func
         commit_info = svn.client.commit3(specific_files, True, False, self.client_ctx)
 
         revid = self.branch.repository.generate_revision_id(

=== modified file 'tests/test_workingtree.py'
--- a/tests/test_workingtree.py	2007-01-08 16:03:35 +0000
+++ b/tests/test_workingtree.py	2007-01-08 16:36:23 +0000
@@ -330,6 +330,14 @@
         self.assertEqual("a-uuid-foo:/branch/path:1\n", 
                          self.client_get_prop("dc", "svk:merge"))
 
+    def test_commit_callback(self):
+        self.make_client('a', 'dc')
+        self.build_tree({"dc/bl": "data"})
+        self.client_add("dc/bl")
+        tree = WorkingTree.open("dc")
+        orig_tree = tree.basis_tree()
+        tree.commit(message_callback=lambda x: "data")
+
     def test_update_after_commit(self):
         self.make_client('a', 'dc')
         self.build_tree({"dc/bl": "data"})




More information about the bazaar-commits mailing list