Rev 6388: (jelmer) Make the check to see whether executable bits are supported in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Dec 19 17:39:36 UTC 2011
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6388 [merge]
revision-id: pqm at pqm.ubuntu.com-20111219173935-49wnc1pb71e653iz
parent: pqm at pqm.ubuntu.com-20111219171434-i0b4ir0invs9il2v
parent: jelmer at canonical.com-20111219170404-jbnemko9kced81ya
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2011-12-19 17:39:35 +0000
message:
(jelmer) Make the check to see whether executable bits are supported
per-workingtree, rather than global. (Jelmer Vernooij)
modified:
bzrlib/tests/per_tree/test_path_content_summary.py test_path_content_su-20070904100855-3vrwedz6akn34kl5-1
bzrlib/tests/per_workingtree/test_executable.py test_executable.py-20060628162557-tr7h57kl80l3ma8i-1
bzrlib/tests/per_workingtree/test_workingtree.py test_workingtree.py-20060203003124-817757d3e31444fb
bzrlib/transform.py transform.py-20060105172343-dd99e54394d91687
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
=== modified file 'bzrlib/tests/per_tree/test_path_content_summary.py'
--- a/bzrlib/tests/per_tree/test_path_content_summary.py 2011-06-14 01:26:41 +0000
+++ b/bzrlib/tests/per_tree/test_path_content_summary.py 2011-12-16 17:34:46 +0000
@@ -133,10 +133,7 @@
self.assertEqual('file', summary[0])
self.check_content_summary_size(tree, summary, 22)
# not executable
- if osutils.supports_executable:
- self.assertEqual(False, summary[2])
- else:
- self.assertEqual(None, summary[2])
+ self.assertEqual(False, summary[2])
# may have hash,
self.assertSubset((summary[3],),
(None, '0c352290ae1c26ca7f97d5b2906c4624784abd60'))
=== modified file 'bzrlib/tests/per_workingtree/test_executable.py'
--- a/bzrlib/tests/per_workingtree/test_executable.py 2011-05-13 12:51:05 +0000
+++ b/bzrlib/tests/per_workingtree/test_executable.py 2011-12-19 16:59:14 +0000
@@ -189,9 +189,7 @@
self.assertFalse(b_executable)
def test_use_exec_from_basis(self):
- if osutils.supports_executable():
- self.assertEqual(self.wt._is_executable_from_path_and_stat_from_stat,
- self.wt._is_executable_from_path_and_stat)
- else:
- self.assertEqual(self.wt._is_executable_from_path_and_stat_from_basis,
- self.wt._is_executable_from_path_and_stat)
+ self.wt._supports_executable = lambda: False
+ self.addCleanup(self.wt.lock_read().unlock)
+ self.assertTrue(self.wt.is_executable(self.a_id))
+ self.assertFalse(self.wt.is_executable(self.b_id))
=== modified file 'bzrlib/tests/per_workingtree/test_workingtree.py'
--- a/bzrlib/tests/per_workingtree/test_workingtree.py 2011-11-08 19:09:55 +0000
+++ b/bzrlib/tests/per_workingtree/test_workingtree.py 2011-12-16 17:34:46 +0000
@@ -960,6 +960,24 @@
tree = tree.bzrdir.open_workingtree()
self.assertFalse(tree.case_sensitive)
+ def test_supports_executable(self):
+ self.build_tree(['filename'])
+ tree = self.make_branch_and_tree('.')
+ tree.add('filename')
+ self.assertIsInstance(tree._supports_executable(), bool)
+ if tree._supports_executable():
+ tree.lock_read()
+ try:
+ self.assertFalse(tree.is_executable(tree.path2id('filename')))
+ finally:
+ tree.unlock()
+ os.chmod('filename', 0755)
+ self.addCleanup(tree.lock_read().unlock)
+ self.assertTrue(tree.is_executable(tree.path2id('filename')))
+ else:
+ self.addCleanup(tree.lock_read().unlock)
+ self.assertFalse(tree.is_executable(tree.path2id('filename')))
+
def test_all_file_ids_with_missing(self):
tree = self.make_branch_and_tree('tree')
tree.lock_write()
=== modified file 'bzrlib/transform.py'
--- a/bzrlib/transform.py 2011-12-18 12:46:49 +0000
+++ b/bzrlib/transform.py 2011-12-19 17:39:35 +0000
@@ -763,7 +763,7 @@
def _set_executability(self, path, trans_id):
"""Set the executability of versioned files """
- if supports_executable():
+ if self._tree._supports_executable():
new_executability = self._new_executability[trans_id]
abspath = self._tree.abspath(path)
current_mode = os.stat(abspath).st_mode
@@ -1233,6 +1233,11 @@
finally:
TreeTransformBase.finalize(self)
+ def _limbo_supports_executable(self):
+ """Check if the limbo path supports the executable bit."""
+ # FIXME: Check actual file system capabilities of limbodir
+ return osutils.supports_executable()
+
def _limbo_name(self, trans_id):
"""Generate the limbo name of a file"""
limbo_name = self._limbo_files.get(trans_id)
@@ -2321,7 +2326,7 @@
if kind == 'file':
statval = os.lstat(limbo_name)
size = statval.st_size
- if not supports_executable():
+ if not tt._limbo_supports_executable():
executable = False
else:
executable = statval.st_mode & S_IEXEC
=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py 2011-12-19 13:23:58 +0000
+++ b/bzrlib/workingtree.py 2011-12-19 17:39:35 +0000
@@ -89,7 +89,6 @@
realpath,
safe_unicode,
splitpath,
- supports_executable,
)
from bzrlib.trace import mutter, note
from bzrlib.revision import CURRENT_REVISION
@@ -233,6 +232,12 @@
"""See `Tree.has_versioned_directories`."""
return self._format.supports_versioned_directories
+ def _supports_executable(self):
+ if sys.platform == 'win32':
+ return False
+ # FIXME: Ideally this should check the file system
+ return True
+
def break_lock(self):
"""Break a lock if one is present from another instance.
@@ -1117,7 +1122,7 @@
else:
mode = stat_value.st_mode
kind = osutils.file_kind_from_stat_mode(mode)
- if not supports_executable():
+ if not self._supports_executable():
executable = entry is not None and entry.executable
else:
executable = bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
@@ -2192,21 +2197,20 @@
mode = stat_result.st_mode
return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
- if not supports_executable():
- def is_executable(self, file_id, path=None):
+ def is_executable(self, file_id, path=None):
+ if not self._supports_executable():
return self._inventory[file_id].executable
-
- _is_executable_from_path_and_stat = \
- _is_executable_from_path_and_stat_from_basis
- else:
- def is_executable(self, file_id, path=None):
+ else:
if not path:
path = self.id2path(file_id)
mode = os.lstat(self.abspath(path)).st_mode
return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
- _is_executable_from_path_and_stat = \
- _is_executable_from_path_and_stat_from_stat
+ def _is_executable_from_path_and_stat(self, path, stat_result):
+ if not self._supports_executable():
+ return self._is_executable_from_path_and_stat_from_basis(path, stat_result)
+ else:
+ return self._is_executable_from_path_and_stat_from_stat(path, stat_result)
@needs_tree_write_lock
def _add(self, files, ids, kinds):
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2011-12-19 13:23:58 +0000
+++ b/bzrlib/workingtree_4.py 2011-12-19 17:39:35 +0000
@@ -478,25 +478,17 @@
return False # Missing entries are not executable
return entry[1][0][3] # Executable?
- if not osutils.supports_executable():
- def is_executable(self, file_id, path=None):
- """Test if a file is executable or not.
+ def is_executable(self, file_id, path=None):
+ """Test if a file is executable or not.
- Note: The caller is expected to take a read-lock before calling this.
- """
+ Note: The caller is expected to take a read-lock before calling this.
+ """
+ if not self._supports_executable():
entry = self._get_entry(file_id=file_id, path=path)
if entry == (None, None):
return False
return entry[1][0][3]
-
- _is_executable_from_path_and_stat = \
- _is_executable_from_path_and_stat_from_basis
- else:
- def is_executable(self, file_id, path=None):
- """Test if a file is executable or not.
-
- Note: The caller is expected to take a read-lock before calling this.
- """
+ else:
self._must_be_locked()
if not path:
path = self.id2path(file_id)
More information about the bazaar-commits
mailing list