Rev 2912: Fix bug #149113 so that executable is properly set on win32. in http://bzr.arbash-meinel.com/branches/bzr/0.92-dev/dirstate_error_149113
John Arbash Meinel
john at arbash-meinel.com
Tue Oct 16 22:24:04 BST 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.92-dev/dirstate_error_149113
------------------------------------------------------------
revno: 2912
revision-id: john at arbash-meinel.com-20071016211734-u0ce8cr11khccb65
parent: pqm at pqm.ubuntu.com-20071016112750-1q8brfaq6metpfn8
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate_error_149113
timestamp: Tue 2007-10-16 16:17:34 -0500
message:
Fix bug #149113 so that executable is properly set on win32.
The new path_content_summary() returns None when a platform
does not support the executable bit, asking the caller to
decide a policy.
This patch changes CommitBuilder.record_entry_contents()
so that it sets a policy of using the parent's value,
unless there are no parents, in which case it uses None.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/repository_implementations/test_commit_builder.py test_commit_builder.py-20060606110838-76e3ra5slucqus81-1
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2007-10-16 09:49:18 +0000
+++ b/NEWS 2007-10-16 21:17:34 +0000
@@ -80,6 +80,9 @@
BUG FIXES:
+ * Fix a problem with Win32 handling of the executable bit.
+ (John Arbash Meinel, #149113)
+
* ``bzr+ssh://`` and ``sftp://`` URLs that do not specify ports explicitly
no longer assume that means port 22. This allows people using OpenSSH to
override the default port in their ``~/.ssh/config`` if they wish. This
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2007-10-16 02:42:33 +0000
+++ b/bzrlib/repository.py 2007-10-16 21:17:34 +0000
@@ -313,6 +313,7 @@
# ancestors, we write a new node.
if len(heads) != 1:
store = True
+ parent_entry = None
if not store:
# There is a single head, look it up for comparison
parent_entry = parent_candiate_entries[heads[0]]
@@ -327,6 +328,14 @@
if kind != parent_entry.kind:
store = True
if kind == 'file':
+ if content_summary[2] is None:
+ if parent_entry is not None:
+ executable = parent_entry.executable
+ else:
+ executable = False
+ content_summary = (content_summary[0], content_summary[1],
+ executable,
+ ) + content_summary[3:]
if not store:
if (# if the file length changed we have to store:
parent_entry.text_size != content_summary[1] or
=== modified file 'bzrlib/tests/repository_implementations/test_commit_builder.py'
--- a/bzrlib/tests/repository_implementations/test_commit_builder.py 2007-10-04 05:50:44 +0000
+++ b/bzrlib/tests/repository_implementations/test_commit_builder.py 2007-10-16 21:17:34 +0000
@@ -536,3 +536,68 @@
def test_last_modified_file_link(self):
self._check_kind_change(self.make_file, self.make_link)
+
+ def test_record_entry_contents_exec_None(self):
+ # When content_summary returns None for executable, we will still set
+ # it to a value
+ tree = self.make_branch_and_tree('.')
+ self.build_tree(['file'])
+ tree.add(['file'], ['file-id'])
+
+ _orig_path_content_summary = tree.path_content_summary
+
+ def path_content_summary_exec_None(path):
+ summary = _orig_path_content_summary(path)
+ if path == 'file':
+ summary = (summary[0], summary[1], None) + summary[3:]
+ return summary
+
+ def path_content_summary_exec_True(path):
+ summary = _orig_path_content_summary(path)
+ if path == 'file':
+ summary = (summary[0], summary[1], True) + summary[3:]
+ return summary
+
+ def path_content_summary_exec_False(path):
+ summary = _orig_path_content_summary(path)
+ if path == 'file':
+ summary = (summary[0], summary[1], False) + summary[3:]
+ return summary
+
+
+ tree.path_content_summary = path_content_summary_exec_None
+ rev_id = tree.commit('')
+ rev_tree = tree.branch.repository.revision_tree(rev_id)
+ executable = rev_tree.inventory['file-id'].executable
+ self.assertIsNot(None, executable)
+ self.assertFalse(executable)
+
+ tree.path_content_summary = path_content_summary_exec_True
+ rev_id = self.mini_commit(tree, 'file', 'file', True, True)
+ rev_tree = tree.branch.repository.revision_tree(rev_id)
+ executable = rev_tree.inventory['file-id'].executable
+ self.assertIsNot(None, executable)
+ self.assertTrue(executable)
+
+ # Now with path_content_summary_exec_None, there should be no change
+ tree.path_content_summary = path_content_summary_exec_None
+ rev_id = self.mini_commit(tree, 'file', 'file', False, False)
+ rev_tree = tree.branch.repository.revision_tree(rev_id)
+ executable = rev_tree.inventory['file-id'].executable
+ self.assertIsNot(None, executable)
+ self.assertTrue(executable)
+
+ # Now we set the exec back to False, which should also be preserved
+ tree.path_content_summary = path_content_summary_exec_False
+ rev_id = self.mini_commit(tree, 'file', 'file', True, True)
+ rev_tree = tree.branch.repository.revision_tree(rev_id)
+ executable = rev_tree.inventory['file-id'].executable
+ self.assertIsNot(None, executable)
+ self.assertFalse(executable)
+
+ tree.path_content_summary = path_content_summary_exec_None
+ rev_id = self.mini_commit(tree, 'file', 'file', False, False)
+ rev_tree = tree.branch.repository.revision_tree(rev_id)
+ executable = rev_tree.inventory['file-id'].executable
+ self.assertIsNot(None, executable)
+ self.assertFalse(executable)
More information about the bazaar-commits
mailing list