Rev 5092: (mbp, for parthm) check permissions on .bzr are copied to backup.bzr in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Mar 17 10:08:42 GMT 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5092 [merge]
revision-id: pqm at pqm.ubuntu.com-20100317100840-xld2z96vzr6bpc5s
parent: pqm at pqm.ubuntu.com-20100316164600-8676mg9xmv60l4c3
parent: parth.malwankar at gmail.com-20100317053611-xpmn8gili6j191in
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2010-03-17 10:08:40 +0000
message:
(mbp, for parthm) check permissions on .bzr are copied to backup.bzr
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/tests/blackbox/test_upgrade.py test_upgrade.py-20060120060132-b41e5ed2f886ad28
bzrlib/tests/features.py features.py-20090820042958-jglgza3wrn03ha9e-1
bzrlib/transport/__init__.py transport.py-20050711165921-4978aa7ce1285ad5
=== modified file 'NEWS'
--- a/NEWS 2010-03-12 19:59:50 +0000
+++ b/NEWS 2010-03-17 05:36:11 +0000
@@ -95,6 +95,10 @@
the kept file on content conflicts where one side deleted the file.
(Vincent Ladeuil, #529968)
+* ``bzr upgrade`` now creates the ``backup.bzr`` directory with the same
+ permissions as ``.bzr`` directory on a POSIX OS.
+ (Parth Malwankar, #262450)
+
* ``bzr upgrade`` now names backup directory as ``backup.bzr.~N~`` instead
of ``backup.bzr``. This directory is ignored by bzr commands such as
``add``.
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2010-03-11 11:07:32 +0000
+++ b/bzrlib/bzrdir.py 2010-03-17 05:36:11 +0000
@@ -602,8 +602,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_dir)
ui.ui_factory.note('making backup of %s\n to %s' % (old_path, new_path,))
=== modified file 'bzrlib/tests/blackbox/test_upgrade.py'
--- a/bzrlib/tests/blackbox/test_upgrade.py 2010-02-15 11:28:35 +0000
+++ b/bzrlib/tests/blackbox/test_upgrade.py 2010-03-17 05:36:11 +0000
@@ -15,12 +15,15 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
"""Black box tests for the upgrade ui."""
+import os
+import stat
from bzrlib import (
bzrdir,
repository,
)
from bzrlib.tests import (
+ features,
TestCaseInTempDir,
TestCaseWithTransport,
)
@@ -146,6 +149,17 @@
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(features.PosixPermissionsFeature)
+ old_perms = stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
+ backup_dir = 'backup.bzr.~1~'
+ 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)
+
def test_upgrade_with_existing_backup_dir(self):
self.make_format_5_branch()
=== modified file 'bzrlib/tests/features.py'
--- a/bzrlib/tests/features.py 2010-02-23 07:43:11 +0000
+++ b/bzrlib/tests/features.py 2010-03-03 14:55:44 +0000
@@ -14,6 +14,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+import os
+import stat
from bzrlib import tests
from bzrlib.symbol_versioning import deprecated_in
@@ -23,3 +25,27 @@
paramiko = tests.ModuleAvailableFeature('paramiko')
pycurl = tests.ModuleAvailableFeature('pycurl')
subunit = tests.ModuleAvailableFeature('subunit')
+
+class _PosixPermissionsFeature(tests.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'
+
+PosixPermissionsFeature = _PosixPermissionsFeature()
=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py 2010-03-05 05:30:19 +0000
+++ b/bzrlib/transport/__init__.py 2010-03-17 05:36:11 +0000
@@ -1060,7 +1060,12 @@
"""
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):
More information about the bazaar-commits
mailing list