Rev 4696: Handle attempted directory access to the source tree by tracing rather than post-success inspection. in http://people.canonical.com/~robertc/baz2.0/integration

Robert Collins robertc at robertcollins.net
Fri Sep 18 03:03:42 BST 2009


At http://people.canonical.com/~robertc/baz2.0/integration

------------------------------------------------------------
revno: 4696
revision-id: robertc at robertcollins.net-20090918020331-fkfwn81k549ddfie
parent: robertc at robertcollins.net-20090917230949-smyehlpvplo260ae
committer: Robert Collins <robertc at robertcollins.net>
branch nick: integration
timestamp: Fri 2009-09-18 12:03:31 +1000
message:
  Handle attempted directory access to the source tree by tracing rather than post-success inspection.
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2009-09-17 23:09:49 +0000
+++ b/bzrlib/tests/__init__.py	2009-09-18 02:03:31 +0000
@@ -972,17 +972,14 @@
         to be used in the test suite.
         """
         path = self.get_source_path()
-        self.disable_directory_isolation()
+        self.record_directory_isolation()
         try:
             try:
-                tree = workingtree.WorkingTree.open(path)
+                workingtree.WorkingTree.open(path)
             except (errors.NotBranchError, errors.NoWorkingTree):
                 return
         finally:
             self.enable_directory_isolation()
-        self.permit_url(tree.bzrdir.root_transport.base)
-        self.permit_url(tree.branch.bzrdir.root_transport.base)
-        self.permit_url(tree.branch.repository.bzrdir.root_transport.base)
 
     def _preopen_isolate_transport(self, transport):
         """Check that all transport openings are done in the test work area."""
@@ -1005,6 +1002,9 @@
     def _preopen_isolate_url(self, url):
         if not self._directory_isolation:
             return
+        if self._directory_isolation == 'record':
+            self._bzr_selftest_roots.append(url)
+            return
         # This prevents all transports, including e.g. sftp ones backed on disk
         # from working unless they are explicitly granted permission. We then
         # depend on the code that sets up test transports to check that they are
@@ -1014,6 +1014,13 @@
             raise errors.BzrError("Attempt to escape test isolation: %r %r"
                 % (url, self._bzr_selftest_roots))
 
+    def record_directory_isolation(self):
+        """Gather accessed directories to permit later access.
+        
+        This is used for tests that access the branch bzr is running from.
+        """
+        self._directory_isolation = "record"
+
     def start_server(self, transport_server, backing_server=None):
         """Start transport_server for this test.
 




More information about the bazaar-commits mailing list