Rev 2215: Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. in sftp://bazaar.launchpad.net/%7Ebzr/bzr/hpss/

Andrew Bennetts andrew.bennetts at canonical.com
Fri Apr 13 07:19:41 BST 2007


At sftp://bazaar.launchpad.net/%7Ebzr/bzr/hpss/

------------------------------------------------------------
revno: 2215
revision-id: andrew.bennetts at canonical.com-20070413061840-gb25wprbcivfeyuo
parent: andrew.bennetts at canonical.com-20070413054830-3kb1ryz3yiwo7vpv
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss
timestamp: Fri 2007-04-13 16:18:40 +1000
message:
  Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs.
modified:
  bzrlib/tests/test_smart.py     test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
=== modified file 'bzrlib/tests/test_smart.py'
--- a/bzrlib/tests/test_smart.py	2007-04-12 16:22:21 +0000
+++ b/bzrlib/tests/test_smart.py	2007-04-13 06:18:40 +0000
@@ -199,7 +199,7 @@
         tree.lock_write()
         tree.add('')
         r1 = tree.commit('1st commit')
-        r2 = tree.commit('2nd commit', rev_id=u'\xc8')
+        r2 = tree.commit('2nd commit', rev_id=u'\xc8'.encode('utf-8'))
         tree.unlock()
         self.assertEqual(
             SmartServerResponse(('ok', ), ('\x00'.join([r1, r2]))),
@@ -243,10 +243,9 @@
         tree = self.make_branch_and_memory_tree('.')
         tree.lock_write()
         tree.add('')
-        rev_id = u'\xc8'
-        rev_id_utf8 = rev_id.encode('utf-8')
+        rev_id_utf8 = u'\xc8'.encode('utf-8')
         r1 = tree.commit('1st commit')
-        r2 = tree.commit('2nd commit', rev_id=rev_id)
+        r2 = tree.commit('2nd commit', rev_id=rev_id_utf8)
         tree.unlock()
         self.assertEqual(
             SmartServerResponse(('ok', '2', rev_id_utf8)),
@@ -316,9 +315,8 @@
         tree = self.make_branch_and_memory_tree('.')
         tree.lock_write()
         tree.add('')
-        rev_id = u'\xc8'
-        rev_id_utf8 = rev_id.encode('utf-8')
-        r1 = tree.commit('1st commit', rev_id=rev_id)
+        rev_id_utf8 = u'\xc8'.encode('utf-8')
+        r1 = tree.commit('1st commit', rev_id=rev_id_utf8)
         r2 = tree.commit('2nd commit')
         tree.unlock()
         branch_token = tree.branch.lock_write()
@@ -340,9 +338,8 @@
         tree = self.make_branch_and_memory_tree('.')
         tree.lock_write()
         tree.add('')
-        rev_id = u'\xc8'
-        rev_id_utf8 = rev_id.encode('utf-8')
-        r1 = tree.commit('1st commit', rev_id=rev_id)
+        rev_id_utf8 = u'\xc8'.encode('utf-8')
+        r1 = tree.commit('1st commit', rev_id=rev_id_utf8)
         r2 = tree.commit('2nd commit')
         tree.unlock()
         tree.branch.set_revision_history([])
@@ -522,7 +519,7 @@
         tree.lock_write()
         tree.add('')
         r1 = tree.commit('1st commit')
-        r2 = tree.commit('2nd commit', rev_id=u'\xc8')
+        r2 = tree.commit('2nd commit', rev_id=u'\xc8'.encode('utf-8'))
         tree.unlock()
 
         # the lines of revision_id->revision_parent_list has no guaranteed
@@ -540,13 +537,13 @@
         tree = self.make_branch_and_memory_tree('.')
         tree.lock_write()
         tree.add('')
-        r1 = tree.commit('1st commit', rev_id=u'\xc9')
-        r2 = tree.commit('2nd commit', rev_id=u'\xc8')
+        rev_id_utf8 = u'\xc9'.encode('utf-8')
+        r1 = tree.commit('1st commit', rev_id=rev_id_utf8)
+        r2 = tree.commit('2nd commit', rev_id=u'\xc8'.encode('utf-8'))
         tree.unlock()
 
-        self.assertEqual(SmartServerResponse(('ok', ),
-            u'\xc9'.encode('utf8')),
-            request.execute(backing.local_abspath(''), u'\xc9'.encode('utf8')))
+        self.assertEqual(SmartServerResponse(('ok', ), rev_id_utf8),
+            request.execute(backing.local_abspath(''), rev_id_utf8))
     
     def test_no_such_revision(self):
         backing = self.get_transport()
@@ -580,12 +577,12 @@
         tree = self.make_branch_and_memory_tree('.')
         tree.lock_write()
         tree.add('')
-        r1 = tree.commit('a commit', rev_id=u'\xc8abc')
+        rev_id_utf8 = u'\xc8abc'.encode('utf-8')
+        r1 = tree.commit('a commit', rev_id=rev_id_utf8)
         tree.unlock()
-        self.assertTrue(tree.branch.repository.has_revision(u'\xc8abc'))
+        self.assertTrue(tree.branch.repository.has_revision(rev_id_utf8))
         self.assertEqual(SmartServerResponse(('ok', )),
-            request.execute(backing.local_abspath(''),
-                u'\xc8abc'.encode('utf8')))
+            request.execute(backing.local_abspath(''), rev_id_utf8))
 
 
 class TestSmartServerRepositoryGatherStats(tests.TestCaseWithTransport):
@@ -604,14 +601,15 @@
     def test_revid_with_committers(self):
         """For a revid we get more infos."""
         backing = self.get_transport()
-        rev_id = u'\xc8abc'
+        rev_id_utf8 = u'\xc8abc'.encode('utf-8')
         request = smart.repository.SmartServerRepositoryGatherStats(backing)
         tree = self.make_branch_and_memory_tree('.')
         tree.lock_write()
         tree.add('')
         # Let's build a predictable result
         tree.commit('a commit', timestamp=123456.2, timezone=3600)
-        tree.commit('a commit', timestamp=654321.4, timezone=0, rev_id=rev_id)
+        tree.commit('a commit', timestamp=654321.4, timezone=0,
+                    rev_id=rev_id_utf8)
         tree.unlock()
 
         stats = tree.branch.repository.gather_stats()
@@ -622,12 +620,12 @@
                          'size: %d\n' % size)
         self.assertEqual(SmartServerResponse(('ok', ), expected_body),
                          request.execute(backing.local_abspath(''),
-                                         rev_id.encode('utf8'), 'no'))
+                                         rev_id_utf8, 'no'))
 
     def test_not_empty_repository_with_committers(self):
         """For a revid and requesting committers we get the whole thing."""
         backing = self.get_transport()
-        rev_id = u'\xc8abc'
+        rev_id_utf8 = u'\xc8abc'.encode('utf-8')
         request = smart.repository.SmartServerRepositoryGatherStats(backing)
         tree = self.make_branch_and_memory_tree('.')
         tree.lock_write()
@@ -636,7 +634,7 @@
         tree.commit('a commit', timestamp=123456.2, timezone=3600,
                     committer='foo')
         tree.commit('a commit', timestamp=654321.4, timezone=0,
-                    committer='bar', rev_id=rev_id)
+                    committer='bar', rev_id=rev_id_utf8)
         tree.unlock()
         stats = tree.branch.repository.gather_stats()
 
@@ -648,7 +646,7 @@
                          'size: %d\n' % size)
         self.assertEqual(SmartServerResponse(('ok', ), expected_body),
                          request.execute(backing.local_abspath(''),
-                                         rev_id.encode('utf8'), 'yes'))
+                                         rev_id_utf8, 'yes'))
 
 
 class TestSmartServerRepositoryIsShared(tests.TestCaseWithTransport):




More information about the bazaar-commits mailing list