Rev 6192: Merge 2.4 into trunk resolving conflicts in http://bazaar.launchpad.net/~vila/bzr/integration/

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Oct 6 07:43:14 UTC 2011


At http://bazaar.launchpad.net/~vila/bzr/integration/

------------------------------------------------------------
revno: 6192 [merge]
revision-id: v.ladeuil+lp at free.fr-20111006074313-w3f2t8lgzy04pjjb
parent: pqm at pqm.ubuntu.com-20111005141234-pjarq2hlunfrrrse
parent: pqm at pqm.ubuntu.com-20111005090757-ismvukuzugd4tsp0
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: trunk
timestamp: Thu 2011-10-06 09:43:13 +0200
message:
  Merge 2.4 into trunk resolving conflicts
modified:
  bzrlib/diff-delta.c            diffdelta.c-20090226042143-l9wzxynyuxnb5hus-1
  bzrlib/osutils.py              osutils.py-20050309040759-eeaff12fbf77ac86
  bzrlib/tests/stub_sftp.py      stub_sftp.py-20051027032739-0e7ef4f7bab0e174
  bzrlib/tests/test_osutils.py   test_osutils.py-20051201224856-e48ee24c12182989
  bzrlib/transport/local.py      local_transport.py-20050711165921-9b1f142bfe480c24
  bzrlib/urlutils.py             urlutils.py-20060502195429-e8a161ecf8fac004
  bzrlib/version.py              version.py-20060816024207-ves6ult9a11taj9t-1
  doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
-------------- next part --------------
=== modified file 'bzrlib/diff-delta.c'
--- a/bzrlib/diff-delta.c	2011-05-16 14:26:54 +0000
+++ b/bzrlib/diff-delta.c	2011-09-30 16:29:17 +0000
@@ -720,6 +720,11 @@
 
     max_num_entries = (src->size - 1)  / RABIN_WINDOW;
 
+    if (!max_num_entries) {
+        *fresh = old_index;
+        return DELTA_OK;
+    }
+
     /* allocate an array to hold whatever entries we find */
     entries = malloc(sizeof(*entry) * max_num_entries);
     if (!entries) /* malloc failure */

=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py	2011-09-16 10:41:45 +0000
+++ b/bzrlib/osutils.py	2011-10-06 07:43:13 +0000
@@ -279,13 +279,28 @@
     # copy posixpath.abspath, but use os.getcwdu instead
     if not posixpath.isabs(path):
         path = posixpath.join(getcwd(), path)
-    return posixpath.normpath(path)
+    return _posix_normpath(path)
 
 
 def _posix_realpath(path):
     return posixpath.realpath(path.encode(_fs_enc)).decode(_fs_enc)
 
 
+def _posix_normpath(path):
+    path = posixpath.normpath(path)
+    # Bug 861008: posixpath.normpath() returns a path normalized according to
+    # the POSIX standard, which stipulates (for compatibility reasons) that two
+    # leading slashes must not be simplified to one, and only if there are 3 or
+    # more should they be simplified as one. So we treat the leading 2 slashes
+    # as a special case here by simply removing the first slash, as we consider
+    # that breaking POSIX compatibility for this obscure feature is acceptable.
+    # This is not a paranoid precaution, as we notably get paths like this when
+    # the repo is hosted at the root of the filesystem, i.e. in "/".    
+    if path.startswith('//'):
+        path = path[1:]
+    return path
+
+
 def _win32_fixdrive(path):
     """Force drive letters to be consistent.
 
@@ -379,7 +394,7 @@
 abspath = _posix_abspath
 realpath = _posix_realpath
 pathjoin = os.path.join
-normpath = os.path.normpath
+normpath = _posix_normpath
 getcwd = os.getcwdu
 rename = os.rename
 dirname = os.path.dirname

=== modified file 'bzrlib/tests/stub_sftp.py'
--- a/bzrlib/tests/stub_sftp.py	2011-08-15 12:37:25 +0000
+++ b/bzrlib/tests/stub_sftp.py	2011-10-06 07:43:13 +0000
@@ -118,9 +118,9 @@
     else:
         def canonicalize(self, path):
             if os.path.isabs(path):
-                return os.path.normpath(path)
+                return osutils.normpath(path)
             else:
-                return os.path.normpath('/' + os.path.join(self.home, path))
+                return osutils.normpath('/' + os.path.join(self.home, path))
 
     def chattr(self, path, attr):
         try:

=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py	2011-07-08 23:01:39 +0000
+++ b/bzrlib/tests/test_osutils.py	2011-10-06 07:43:13 +0000
@@ -818,6 +818,16 @@
         self.assertEqual(None, osutils.safe_file_id(None))
 
 
+class TestPosixFuncs(tests.TestCase):
+    """Test that the posix version of normpath returns an appropriate path
+       when used with 2 leading slashes."""
+
+    def test_normpath(self):
+        self.assertEqual('/etc/shadow', osutils._posix_normpath('/etc/shadow'))
+        self.assertEqual('/etc/shadow', osutils._posix_normpath('//etc/shadow'))
+        self.assertEqual('/etc/shadow', osutils._posix_normpath('///etc/shadow'))
+
+
 class TestWin32Funcs(tests.TestCase):
     """Test that _win32 versions of os utilities return appropriate paths."""
 

=== modified file 'bzrlib/transport/local.py'
--- a/bzrlib/transport/local.py	2011-08-31 01:35:15 +0000
+++ b/bzrlib/transport/local.py	2011-10-06 07:43:13 +0000
@@ -567,7 +567,7 @@
         self._local_base = urlutils._win32_local_path_from_url(base)
 
     def abspath(self, relpath):
-        path = osutils.normpath(osutils.pathjoin(
+        path = osutils._win32_normpath(osutils.pathjoin(
                     self._local_base, urlutils.unescape(relpath)))
         return urlutils._win32_local_path_to_url(path)
 

=== modified file 'bzrlib/urlutils.py'
--- a/bzrlib/urlutils.py	2011-09-04 23:22:47 +0000
+++ b/bzrlib/urlutils.py	2011-10-06 07:43:13 +0000
@@ -22,7 +22,7 @@
 
 from bzrlib.lazy_import import lazy_import
 lazy_import(globals(), """
-from posixpath import split as _posix_split, normpath as _posix_normpath
+from posixpath import split as _posix_split
 import urllib
 import urlparse
 
@@ -201,8 +201,7 @@
     """
     # importing directly from posixpath allows us to test this
     # on non-posix platforms
-    return 'file://' + escape(_posix_normpath(
-        osutils._posix_abspath(path)))
+    return 'file://' + escape(osutils._posix_abspath(path))
 
 
 def _win32_local_path_from_url(url):

=== modified file 'bzrlib/version.py'
--- a/bzrlib/version.py	2010-04-30 11:03:59 +0000
+++ b/bzrlib/version.py	2011-10-04 18:43:55 +0000
@@ -73,7 +73,7 @@
     else:
         to_file.write(bzrlib.__path__[0] + '\n')
     if show_config:
-        config_dir = os.path.normpath(config.config_dir())  # use native slashes
+        config_dir = osutils.normpath(config.config_dir())  # use native slashes
         if not isinstance(config_dir, unicode):
             config_dir = config_dir.decode(osutils.get_user_encoding())
         to_file.write("  Bazaar configuration: %s\n" % (config_dir,))

=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt	2011-09-28 16:50:40 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt	2011-10-06 07:43:13 +0000
@@ -32,6 +32,11 @@
 Bug Fixes
 *********
 
+* Fixed an infinite loop when creating a repo at the root of the filesystem, 
+  i.e. "/", due to posixpath.normpath() not collapsing 2 leading slashes into 
+  one, thus respecting the POSIX standard, but making relpath() loop infinitely.
+  (Florian Vichot, #861008)
+
 * Fixed loading of external merge tools from config to properly decode
   command-lines which contain embedded quotes. (Gordon Tyler, #828803)
 
@@ -39,6 +44,10 @@
   stat fields into four bytes in dirstate pack_stat implementations.
   (Martin Packman, #683191 #706957)
 
+* Return early from create_delta_index_from_delta given tiny inputs. This
+  avoids raising a spurious MemoryError on certain platforms such as AIX.
+  (John Arbash Meinel, #856731)
+  
 Documentation
 *************
 



More information about the bazaar-commits mailing list