Rev 3643: (jam) Fix bug #259855, in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Aug 21 20:07:03 BST 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3643
revision-id: pqm at pqm.ubuntu.com-20080821190656-7uoj39e0c3q3b893
parent: pqm at pqm.ubuntu.com-20080820164550-e4vt9gdxv8hlic7n
parent: john at arbash-meinel.com-20080821162035-1zr12m9rx6llkrrq
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2008-08-21 20:06:56 +0100
message:
(jam) Fix bug #259855,
if Transport.stat() returns 0 for permission bits, ignore it
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/tests/branch_implementations/test_permissions.py test_permissions.py-20060210110243-245c01403bf0fde6
------------------------------------------------------------
revno: 3641.2.2
revision-id: john at arbash-meinel.com-20080821162035-1zr12m9rx6llkrrq
parent: john at arbash-meinel.com-20080821161257-39lgj4it2n7kw30g
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: ftp_mode_259855
timestamp: Thu 2008-08-21 11:20:35 -0500
message:
NEWS
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
------------------------------------------------------------
revno: 3641.2.1
revision-id: john at arbash-meinel.com-20080821161257-39lgj4it2n7kw30g
parent: pqm at pqm.ubuntu.com-20080819152536-6oobtmrum8e34h8l
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: ftp_mode_259855
timestamp: Thu 2008-08-21 11:12:57 -0500
message:
Fix bug #259855, if a Transport returns 0 for permission bits, ignore it
modified:
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/tests/branch_implementations/test_permissions.py test_permissions.py-20060210110243-245c01403bf0fde6
=== modified file 'NEWS'
--- a/NEWS 2008-08-20 16:14:09 +0000
+++ b/NEWS 2008-08-21 19:06:56 +0000
@@ -32,6 +32,13 @@
* ``bzr rm`` is now aliased to ``bzr del`` for the convenience of svn
users. (Robert Collins, #205416)
+ * ``FTPTransport.stat()`` would return ``0000`` as the permission bits
+ for the containing ``.bzr/`` directory (it does not implement
+ permissions). This would cause us to set all subdirectories to
+ ``0700`` and files to ``0600`` rather than leaving them unmodified.
+ Now we ignore ``0000`` as the permissions and assume they are
+ invalid. (John Arbash Meinel, #259855)
+
* Running ``bzr st PATH_TO_TREE`` will no longer suppress merge
status. Status is also about 7% faster on mozilla sized trees
when the path to the root of the tree has been given. Users of
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2008-08-20 16:14:09 +0000
+++ b/bzrlib/bzrdir.py 2008-08-21 19:06:56 +0000
@@ -637,7 +637,7 @@
def _find_creation_modes(self):
"""Determine the appropriate modes for files and directories.
-
+
They're always set to be consistent with the base directory,
assuming that this transport allows setting modes.
"""
@@ -656,9 +656,14 @@
# directories and files are read-write for this user. This is
# mostly a workaround for filesystems which lie about being able to
# write to a directory (cygwin & win32)
- self._dir_mode = (st.st_mode & 07777) | 00700
- # Remove the sticky and execute bits for files
- self._file_mode = self._dir_mode & ~07111
+ if (st.st_mode & 07777 == 00000):
+ # FTP allows stat but does not return dir/file modes
+ self._dir_mode = None
+ self._file_mode = None
+ else:
+ self._dir_mode = (st.st_mode & 07777) | 00700
+ # Remove the sticky and execute bits for files
+ self._file_mode = self._dir_mode & ~07111
def _get_file_mode(self):
"""Return Unix mode for newly created files, or None.
=== modified file 'bzrlib/tests/branch_implementations/test_permissions.py'
--- a/bzrlib/tests/branch_implementations/test_permissions.py 2008-05-21 03:01:10 +0000
+++ b/bzrlib/tests/branch_implementations/test_permissions.py 2008-08-21 16:12:57 +0000
@@ -22,35 +22,48 @@
So if the directory is group writable, the files and subdirs should be as well.
"""
-# TODO: jam 20051215 Currently the default behavior for 'bzr branch' is just
+# TODO: jam 20051215 Currently the default behavior for 'bzr branch' is just
# defined by the local umask. This isn't terrible, is it
# the truly desired behavior?
-
+
import os
import sys
import stat
from StringIO import StringIO
+from bzrlib import tests
from bzrlib.branch import Branch
from bzrlib.bzrdir import BzrDir
from bzrlib.lockable_files import LockableFiles
from bzrlib.remote import RemoteBranchFormat
-from bzrlib.tests import TestCaseWithTransport, TestSkipped
from bzrlib.tests.test_permissions import chmod_r, check_mode_r
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
from bzrlib.transport import get_transport
from bzrlib.workingtree import WorkingTree
-class TestPermissions(TestCaseWithTransport):
+class _NullPermsStat(object):
+ """A class that proxy's a stat result and strips permissions."""
+
+ def __init__(self, orig_stat):
+ self._orig_stat = orig_stat
+ # We strip all permission bits from st_mode
+ self.st_mode = orig_stat.st_mode & ~07777
+
+ def __getattr__(self, name):
+ return getattr(self._orig_stat, name)
+
+
+class TestPermissions(tests.TestCaseWithTransport):
def test_new_branch(self):
if isinstance(self.branch_format, RemoteBranchFormat):
# Remote branch format have no permission logic in them; there's
# nothing to test here.
- return
+ raise tests.TestNotApplicable('Remote branches have no'
+ ' permission logic')
if sys.platform == 'win32':
- raise TestSkipped('chmod has no effect on win32')
+ raise tests.TestNotApplicable('chmod has no effect on win32')
# also, these are BzrBranch format specific things..
os.mkdir('a')
mode = stat.S_IMODE(os.stat('a').st_mode)
@@ -87,3 +100,21 @@
self.assertEqualMode(0700, b.control_files._dir_mode)
self.assertEqualMode(0600, b.control_files._file_mode)
check_mode_r(self, 'd/.bzr', 00600, 00700)
+
+ def test_mode_0(self):
+ """Test when a transport returns null permissions for .bzr"""
+ if isinstance(self.branch_format, RemoteBranchFormat):
+ # Remote branch format have no permission logic in them; there's
+ # nothing to test here.
+ raise tests.TestNotApplicable('Remote branches have no'
+ ' permission logic')
+ self.make_branch_and_tree('.')
+ bzrdir = BzrDir.open('.')
+ # Monkey patch the transport
+ _orig_stat = bzrdir.transport.stat
+ def null_perms_stat(*args, **kwargs):
+ result = _orig_stat(*args, **kwargs)
+ return _NullPermsStat(result)
+ bzrdir.transport.stat = null_perms_stat
+ self.assertIs(None, bzrdir._get_dir_mode())
+ self.assertIs(None, bzrdir._get_file_mode())
More information about the bazaar-commits
mailing list