Rev 3300: Fix up deprecation warnings for get_revision_graph. in http://people.ubuntu.com/~robertc/baz2.0/versioned_files

Robert Collins robertc at robertcollins.net
Thu Mar 27 00:27:45 GMT 2008


At http://people.ubuntu.com/~robertc/baz2.0/versioned_files

------------------------------------------------------------
revno: 3300
revision-id: robertc at robertcollins.net-20080327002741-1vrg4yekrlvv4lfn
parent: robertc at robertcollins.net-20080326215555-d8f6bca03zxtzmsb
committer: Robert Collins <robertc at robertcollins.net>
branch nick: versionedfile.apicleanup
timestamp: Thu 2008-03-27 11:27:41 +1100
message:
  Fix up deprecation warnings for get_revision_graph.
modified:
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
  bzrlib/tests/blackbox/test_serve.py test_serve.py-20060913064329-8t2pvmsikl4s3xhl-1
  bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2008-03-26 21:42:35 +0000
+++ b/bzrlib/remote.py	2008-03-27 00:27:41 +0000
@@ -364,6 +364,10 @@
     @symbol_versioning.deprecated_method(symbol_versioning.one_four)
     def get_revision_graph(self, revision_id=None):
         """See Repository.get_revision_graph()."""
+        return self._get_revision_graph(revision_id)
+
+    def _get_revision_graph(self, revision_id):
+        """Private method for using with old (< 1.2) servers to fallback."""
         if revision_id is None:
             revision_id = ''
         elif revision.is_null(revision_id):
@@ -894,7 +898,7 @@
             # To avoid having to disconnect repeatedly, we keep track of the
             # fact the server doesn't understand remote methods added in 1.2.
             medium._remote_is_at_least_1_2 = False
-            return self.get_revision_graph()
+            return self._get_revision_graph(None)
         elif response[0][0] not in ['ok']:
             reponse[1].cancel_read_body()
             raise errors.UnexpectedSmartServerResponse(response[0])

=== modified file 'bzrlib/tests/blackbox/test_serve.py'
--- a/bzrlib/tests/blackbox/test_serve.py	2007-07-11 19:44:51 +0000
+++ b/bzrlib/tests/blackbox/test_serve.py	2008-03-27 00:27:41 +0000
@@ -57,6 +57,16 @@
         self.assertEqual('', result[0])
         self.assertEqual('bzr: interrupted\n', result[1])
 
+    def make_read_requests(self, branch):
+        """Do some read only requests."""
+        branch.lock_read()
+        try:
+            branch.repository.all_revision_ids()
+            self.assertEqual(_mod_revision.NULL_REVISION,
+                             _mod_revision.ensure_null(branch.last_revision()))
+        finally:
+            branch.unlock()
+
     def start_server_inet(self, extra_options=()):
         """Start a bzr server subprocess using the --inet option.
 
@@ -107,9 +117,7 @@
 
         # We get a working branch
         branch = BzrDir.open_from_transport(transport).open_branch()
-        branch.repository.get_revision_graph()
-        self.assertEqual(_mod_revision.NULL_REVISION,
-                         _mod_revision.ensure_null(branch.last_revision()))
+        self.make_read_requests(branch)
         self.assertInetServerShutsdownCleanly(process)
 
     def test_bzr_serve_port_readonly(self):
@@ -127,12 +135,7 @@
 
         # Connect to the server
         branch = Branch.open(url)
-
-        # We get a working branch
-        branch.repository.get_revision_graph()
-        self.assertEqual(_mod_revision.NULL_REVISION,
-                         _mod_revision.ensure_null(branch.last_revision()))
-
+        self.make_read_requests(branch)
         self.assertServerFinishesCleanly(process)
 
     def test_bzr_connect_to_bzr_ssh(self):
@@ -208,10 +211,7 @@
                 path_to_branch = os.path.splitdrive(path_to_branch)[1]
             branch = Branch.open(
                 'bzr+ssh://fred:secret@localhost:%d%s' % (port, path_to_branch))
-            
-            branch.repository.get_revision_graph()
-            self.assertEqual(_mod_revision.NULL_REVISION,
-                             _mod_revision.ensure_null(branch.last_revision()))
+            self.make_read_requests(branch)
             # Check we can perform write operations
             branch.bzrdir.root_transport.mkdir('foo')
         finally:

=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py	2008-02-12 05:17:25 +0000
+++ b/bzrlib/tests/test_remote.py	2008-03-27 00:27:41 +0000
@@ -45,6 +45,7 @@
 from bzrlib.revision import NULL_REVISION
 from bzrlib.smart import server, medium
 from bzrlib.smart.client import _SmartClient
+from bzrlib.symbol_versioning import one_four
 from bzrlib.transport.memory import MemoryTransport
 from bzrlib.transport.remote import RemoteTransport
 
@@ -705,7 +706,8 @@
         transport_path = 'empty'
         repo, client = self.setup_fake_client_and_repository(
             responses, transport_path)
-        result = repo.get_revision_graph(NULL_REVISION)
+        result = self.applyDeprecated(one_four, repo.get_revision_graph,
+            NULL_REVISION)
         self.assertEqual([], client._calls)
         self.assertEqual({}, result)
 
@@ -720,7 +722,7 @@
         transport_path = 'sinhala'
         repo, client = self.setup_fake_client_and_repository(
             responses, transport_path)
-        result = repo.get_revision_graph()
+        result = self.applyDeprecated(one_four, repo.get_revision_graph)
         self.assertEqual(
             [('call_expecting_body', 'Repository.get_revision_graph',
              ('sinhala/', ''))],
@@ -740,7 +742,7 @@
         transport_path = 'sinhala'
         repo, client = self.setup_fake_client_and_repository(
             responses, transport_path)
-        result = repo.get_revision_graph(r2)
+        result = self.applyDeprecated(one_four, repo.get_revision_graph, r2)
         self.assertEqual(
             [('call_expecting_body', 'Repository.get_revision_graph',
              ('sinhala/', r2))],
@@ -755,7 +757,7 @@
             responses, transport_path)
         # also check that the right revision is reported in the error
         self.assertRaises(errors.NoSuchRevision,
-            repo.get_revision_graph, revid)
+            self.applyDeprecated, one_four, repo.get_revision_graph, revid)
         self.assertEqual(
             [('call_expecting_body', 'Repository.get_revision_graph',
              ('sinhala/', revid))],




More information about the bazaar-commits mailing list