Rev 3843: Fix “PermissionedDenied: "None"” from RemoteTransport.mkdir and similar. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Nov 21 01:28:00 GMT 2008


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

------------------------------------------------------------
revno: 3843
revision-id: pqm at pqm.ubuntu.com-20081121012757-5oqu1dnj8kugnqqd
parent: pqm at pqm.ubuntu.com-20081120045730-d6ik8z5dfnzcnab6
parent: andrew.bennetts at canonical.com-20081121005302-at9b9w1hn3rgvgmq
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2008-11-21 01:27:57 +0000
message:
  Fix “PermissionedDenied: "None"” from RemoteTransport.mkdir and similar.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
  bzrlib/transport/remote.py     ssh.py-20060608202016-c25gvf1ob7ypbus6-1
    ------------------------------------------------------------
    revno: 3840.1.4
    revision-id: andrew.bennetts at canonical.com-20081121005302-at9b9w1hn3rgvgmq
    parent: andrew.bennetts at canonical.com-20081121003306-vy11ysf5mrq2tqj5
    parent: pqm at pqm.ubuntu.com-20081120045730-d6ik8z5dfnzcnab6
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: remotetransport-permissiondenied
    timestamp: Fri 2008-11-21 11:53:02 +1100
    message:
      Merge bzr.dev, fix conflict in NEWS.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/__init__.py             __init__.py-20050309040759-33e65acf91bbcd5d
      bzrlib/_readdir_pyx.pyx        readdir.pyx-20060609152855-rm6v321vuaqyh9tu-1
      bzrlib/plugin.py               plugin.py-20050622060424-829b654519533d69
      bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
      bzrlib/tests/test_plugins.py   plugins.py-20050622075746-32002b55e5e943e9
    ------------------------------------------------------------
    revno: 3840.1.3
    revision-id: andrew.bennetts at canonical.com-20081121003306-vy11ysf5mrq2tqj5
    parent: andrew.bennetts at canonical.com-20081121002354-2zp6vdwnfqid065y
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: remotetransport-permissiondenied
    timestamp: Fri 2008-11-21 11:33:06 +1100
    message:
      Add NEWS entry.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 3840.1.2
    revision-id: andrew.bennetts at canonical.com-20081121002354-2zp6vdwnfqid065y
    parent: andrew.bennetts at canonical.com-20081120061707-amh7sobzz5ag9spb
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: remotetransport-permissiondenied
    timestamp: Fri 2008-11-21 11:23:54 +1100
    message:
      Improvements suggested by review.
    modified:
      bzrlib/transport/remote.py     ssh.py-20060608202016-c25gvf1ob7ypbus6-1
    ------------------------------------------------------------
    revno: 3840.1.1
    revision-id: andrew.bennetts at canonical.com-20081120061707-amh7sobzz5ag9spb
    parent: pqm at pqm.ubuntu.com-20081118222130-vczdog5my1bc6ta4
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: remotetransport-permissiondenied
    timestamp: Thu 2008-11-20 17:17:07 +1100
    message:
      Fix RemoteTransport's translation of errors involving paths; it wasn't passing orig_path to _translate_error.
    modified:
      bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
      bzrlib/transport/remote.py     ssh.py-20060608202016-c25gvf1ob7ypbus6-1
=== modified file 'NEWS'
--- a/NEWS	2008-11-20 04:17:17 +0000
+++ b/NEWS	2008-11-21 00:53:02 +0000
@@ -33,6 +33,10 @@
     * Don't call the system ``chdir()`` with an empty path. Sun OS seems
       to give an error in that case. (John Arbash Meinel, #297831)
 
+    * PermissionDenied errors from smart servers no longer cause
+      “PermissionDenied: "None"” on the client.
+      (Andrew Bennetts, #299254)
+      
     * TooManyConcurrentRequests no longer occur when a fetch fails and
       tries to abort a write group.  This allows the root cause (e.g. a
       network interruption) to be reported.  (Andrew Bennetts, #297014)

=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py	2008-11-18 21:43:36 +0000
+++ b/bzrlib/tests/test_remote.py	2008-11-20 06:17:07 +0000
@@ -1012,6 +1012,19 @@
             client._calls)
 
 
+class TestTransportMkdir(tests.TestCase):
+
+    def test_permissiondenied(self):
+        client = FakeClient()
+        client.add_error_response('PermissionDenied', 'remote path', 'extra')
+        transport = RemoteTransport('bzr://example.com/', medium=False,
+                                    _client=client)
+        exc = self.assertRaises(
+            errors.PermissionDenied, transport.mkdir, 'client path')
+        expected_error = errors.PermissionDenied('/client path', 'extra')
+        self.assertEqual(expected_error, exc)
+
+
 class TestRemoteSSHTransportAuthentication(tests.TestCaseInTempDir):
 
     def test_defaults_to_none(self):

=== modified file 'bzrlib/transport/remote.py'
--- a/bzrlib/transport/remote.py	2008-11-03 19:05:06 +0000
+++ b/bzrlib/transport/remote.py	2008-11-21 00:23:54 +0000
@@ -172,14 +172,24 @@
         try:
             return self._client.call(method, *args)
         except errors.ErrorFromSmartServer, err:
-            self._translate_error(err)
+            # The first argument, if present, is always a path.
+            if args:
+                context = {'relpath': args[0]}
+            else:
+                context = {}
+            self._translate_error(err, **context)
 
     def _call_with_body_bytes(self, method, args, body):
         """Call a method on the remote server with body bytes."""
         try:
             return self._client.call_with_body_bytes(method, args, body)
         except errors.ErrorFromSmartServer, err:
-            self._translate_error(err)
+            # The first argument, if present, is always a path.
+            if args:
+                context = {'relpath': args[0]}
+            else:
+                context = {}
+            self._translate_error(err, **context)
 
     def has(self, relpath):
         """Indicate whether a remote file of the given name exists or not.
@@ -347,7 +357,7 @@
                     [(c.start, c.length) for c in cur_request])
                 resp, response_handler = result
             except errors.ErrorFromSmartServer, err:
-                self._translate_error(err)
+                self._translate_error(err, relpath)
 
             if resp[0] != 'readv':
                 # This should raise an exception
@@ -411,8 +421,8 @@
         if resp[0] != 'ok':
             raise errors.UnexpectedSmartServerResponse(resp)
         
-    def _translate_error(self, err, orig_path=None):
-        remote._translate_error(err, path=orig_path)
+    def _translate_error(self, err, relpath=None):
+        remote._translate_error(err, path=relpath)
 
     def disconnect(self):
         self.get_smart_medium().disconnect()




More information about the bazaar-commits mailing list