Rev 3234: (James Henstridge) Fix MemoryTransport._abspath() for relpath='' in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Sun Feb 24 01:38:23 GMT 2008


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

------------------------------------------------------------
revno: 3234
revision-id:pqm at pqm.ubuntu.com-20080224013817-4ps9nmrzjtg9ugtz
parent: pqm at pqm.ubuntu.com-20080224000013-u7w012v4b2q8287b
parent: james at jamesh.id.au-20080204093207-rny3wzjxli69ee3y
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sun 2008-02-24 01:38:17 +0000
message:
  (James Henstridge) Fix MemoryTransport._abspath() for relpath=''
   (bug #188855)
modified:
  bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
  bzrlib/transport/memory.py     memory.py-20051016101338-cd008dbdf69f04fc
    ------------------------------------------------------------
    revno: 3211.6.2
    revision-id:james at jamesh.id.au-20080204093207-rny3wzjxli69ee3y
    parent: james at jamesh.id.au-20080204092703-nu8kzumi57auimwv
    committer: James Henstridge <james at jamesh.id.au>
    branch nick: bzr.bug-188855
    timestamp: Mon 2008-02-04 18:32:07 +0900
    message:
      Remove unnecessary line break.
    modified:
      bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
    ------------------------------------------------------------
    revno: 3211.6.1
    revision-id:james at jamesh.id.au-20080204092703-nu8kzumi57auimwv
    parent: pqm at pqm.ubuntu.com-20080201053934-q32y2nk5vvo13c6v
    committer: James Henstridge <james at jamesh.id.au>
    branch nick: bzr.bug-188855
    timestamp: Mon 2008-02-04 18:27:03 +0900
    message:
      * Remove relpath='' special case in MemoryTransport._abspath(), which 
        gave incorrect results for cloned transports.
      * Add a Transport.list_dir() test for a cloned transport.
    modified:
      bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
      bzrlib/transport/memory.py     memory.py-20051016101338-cd008dbdf69f04fc
=== modified file 'bzrlib/tests/test_transport_implementations.py'
--- a/bzrlib/tests/test_transport_implementations.py	2007-12-24 10:31:24 +0000
+++ b/bzrlib/tests/test_transport_implementations.py	2008-02-04 09:32:07 +0000
@@ -1066,12 +1066,12 @@
             self.assertRaises(TransportNotPossible, t.list_dir, '.')
             return
 
-        def sorted_list(d):
-            l = list(t.list_dir(d))
+        def sorted_list(d, transport):
+            l = list(transport.list_dir(d))
             l.sort()
             return l
 
-        self.assertEqual([], sorted_list('.'))
+        self.assertEqual([], sorted_list('.', t))
         # c2 is precisely one letter longer than c here to test that
         # suffixing is not confused.
         # a%25b checks that quoting is done consistently across transports
@@ -1083,8 +1083,13 @@
             self.build_tree(tree_names)
 
         self.assertEqual(
-            ['a', 'a%2525b', 'b', 'c', 'c2'], sorted_list('.'))
-        self.assertEqual(['d', 'e'], sorted_list('c'))
+            ['a', 'a%2525b', 'b', 'c', 'c2'], sorted_list('', t))
+        self.assertEqual(
+            ['a', 'a%2525b', 'b', 'c', 'c2'], sorted_list('.', t))
+        self.assertEqual(['d', 'e'], sorted_list('c', t))
+
+        # Cloning the transport produces an equivalent listing
+        self.assertEqual(['d', 'e'], sorted_list('', t.clone('c')))
 
         if not t.is_readonly():
             t.delete('c/d')
@@ -1093,8 +1098,8 @@
             os.unlink('c/d')
             os.unlink('b')
             
-        self.assertEqual(['a', 'a%2525b', 'c', 'c2'], sorted_list('.'))
-        self.assertEqual(['e'], sorted_list('c'))
+        self.assertEqual(['a', 'a%2525b', 'c', 'c2'], sorted_list('.', t))
+        self.assertEqual(['e'], sorted_list('c', t))
 
         self.assertListRaises(PathError, t.list_dir, 'q')
         self.assertListRaises(PathError, t.list_dir, 'c/f')

=== modified file 'bzrlib/transport/memory.py'
--- a/bzrlib/transport/memory.py	2007-11-22 09:49:39 +0000
+++ b/bzrlib/transport/memory.py	2008-02-04 09:27:03 +0000
@@ -261,9 +261,7 @@
     def _abspath(self, relpath):
         """Generate an internal absolute path."""
         relpath = urlutils.unescape(relpath)
-        if relpath == '':
-            return '/'
-        if relpath[0] == '/':
+        if relpath[:1] == '/':
             return relpath
         cwd_parts = self._cwd.split('/')
         rel_parts = relpath.split('/')




More information about the bazaar-commits mailing list