Rev 4744: (mbp) backup inherits .bzr permissions in file:///home/pqm/archives/thelove/bzr/2.0/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Mar 25 03:09:46 GMT 2010


At file:///home/pqm/archives/thelove/bzr/2.0/

------------------------------------------------------------
revno: 4744 [merge]
revision-id: pqm at pqm.ubuntu.com-20100325030945-uypmkeucy0sm31un
parent: pqm at pqm.ubuntu.com-20100325011401-mbg2ti6x3l3osi6a
parent: mbp at canonical.com-20100325020147-1exmha87clv5wosi
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.0
timestamp: Thu 2010-03-25 03:09:45 +0000
message:
  (mbp) backup inherits .bzr permissions
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/blackbox/test_upgrade.py test_upgrade.py-20060120060132-b41e5ed2f886ad28
  bzrlib/transport/__init__.py   transport.py-20050711165921-4978aa7ce1285ad5
  doc/developers/testing.txt     testing.txt-20080812140359-i70zzh6v2z7grqex-1
=== modified file 'NEWS'
--- a/NEWS	2010-03-24 23:33:37 +0000
+++ b/NEWS	2010-03-25 02:01:47 +0000
@@ -18,6 +18,10 @@
   both working tree and branch.
   (Danny van Heumen, #498409)
 
+* ``bzr upgrade`` now creates the ``backup.bzr`` directory with the same
+  permissions as ``.bzr`` directory on a POSIX OS.
+  (Parth Malwankar, #262450)
+
 
 bzr 2.0.5
 #########

=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2009-08-21 02:10:06 +0000
+++ b/bzrlib/bzrdir.py	2010-02-18 04:45:24 +0000
@@ -580,8 +580,6 @@
             # already exists, but it should instead either remove it or make
             # a new backup directory.
             #
-            # FIXME: bug 262450 -- the backup directory should have the same
-            # permissions as the .bzr directory (probably a bug in copy_tree)
             old_path = self.root_transport.abspath('.bzr')
             new_path = self.root_transport.abspath('backup.bzr')
             pb.note('making backup of %s' % (old_path,))

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2010-02-12 03:34:33 +0000
+++ b/bzrlib/tests/__init__.py	2010-03-18 05:49:26 +0000
@@ -4106,3 +4106,27 @@
             return result
 except ImportError:
     pass
+
+class _PosixPermissionsFeature(Feature):
+
+    def _probe(self):
+        def has_perms():
+            # create temporary file and check if specified perms are maintained.
+            import tempfile
+
+            write_perms = stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
+            f = tempfile.mkstemp(prefix='bzr_perms_chk_')
+            fd, name = f
+            os.close(fd)
+            os.chmod(name, write_perms)
+
+            read_perms = os.stat(name).st_mode & 0777
+            os.unlink(name)
+            return (write_perms == read_perms)
+
+        return (os.name == 'posix') and has_perms()
+
+    def feature_name(self):
+        return 'POSIX permissions support'
+
+posix_permissions_feature = _PosixPermissionsFeature()

=== modified file 'bzrlib/tests/blackbox/test_upgrade.py'
--- a/bzrlib/tests/blackbox/test_upgrade.py	2009-08-21 02:10:06 +0000
+++ b/bzrlib/tests/blackbox/test_upgrade.py	2010-03-18 05:49:26 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007, 2009 Canonical Ltd
+# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@
     TestCaseInTempDir,
     TestCaseWithTransport,
     TestUIFactory,
+    posix_permissions_feature,
     )
 from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
 from bzrlib.transport import get_transport
@@ -154,6 +155,18 @@
         self.run_bzr('init-repository --format=metaweave repo')
         self.run_bzr('upgrade --format=knit repo')
 
+    def test_upgrade_permission_check(self):
+        """'backup.bzr' should retain permissions of .bzr. Bug #262450"""
+        self.requireFeature(posix_permissions_feature)
+        import os, stat
+        old_perms = stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
+        backup_dir = 'backup.bzr'
+        self.run_bzr('init --format=1.6')
+        os.chmod('.bzr', old_perms)
+        self.run_bzr('upgrade')
+        new_perms = os.stat(backup_dir).st_mode & 0777
+        self.assertTrue(new_perms == old_perms)
+
 
 class SFTPTests(TestCaseWithSFTPServer):
     """Tests for upgrade over sftp."""

=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py	2009-08-04 11:40:59 +0000
+++ b/bzrlib/transport/__init__.py	2010-03-25 01:50:38 +0000
@@ -1058,7 +1058,11 @@
         """
         source = self.clone(from_relpath)
         target = self.clone(to_relpath)
-        target.mkdir('.')
+
+        # create target directory with the same rwx bits as source.
+        # use mask to ensure that bits other than rwx are ignored.
+        stat = self.stat(from_relpath)
+        target.mkdir('.', stat.st_mode & 0777)
         source.copy_tree_to_transport(target)
 
     def copy_tree_to_transport(self, to_transport):

=== modified file 'doc/developers/testing.txt'
--- a/doc/developers/testing.txt	2010-03-17 00:28:46 +0000
+++ b/doc/developers/testing.txt	2010-03-25 02:01:47 +0000
@@ -343,14 +343,20 @@
 
     self.requireFeature(StraceFeature)
 
-Features already defined in bzrlib.tests include:
+Available features
+~~~~~~~~~~~~~~~~~~
+
+Features already defined in bzrlib.tests or bzrlib.tests.features include:
 
  - SymlinkFeature,
  - HardlinkFeature,
  - OsFifoFeature,
  - UnicodeFilenameFeature,
- - FTPServerFeature, and
- - CaseInsensitiveFilesystemFeature.
+ - FTPServerFeature
+ - CaseInsensitiveFilesystemFeature
+ - posix_permissions_feature: the test can rely on unix-style 
+   permissions bits on files;
+   generally true on Unix but not on all filesystems
 
 
 Defining a new feature that tests can require




More information about the bazaar-commits mailing list