Merge lp:~abentley/bzr/is_executable into lp:bzr

Proposed by Aaron Bentley
Status: Superseded
Proposed branch: lp:~abentley/bzr/is_executable
Merge into: lp:bzr
Diff against target: 207 lines (+98/-7) (has conflicts)
8 files modified
bzr (+4/-0)
bzrlib/__init__.py (+4/-0)
bzrlib/revisiontree.py (+1/-1)
bzrlib/tests/per_tree/__init__.py (+1/-0)
bzrlib/tests/per_tree/test_is_executable.py (+37/-0)
bzrlib/tests/test_transform.py (+3/-3)
bzrlib/workingtree_4.py (+1/-1)
doc/en/release-notes/bzr-2.3.txt (+47/-2)
Text conflict in bzr
Text conflict in bzrlib/__init__.py
Text conflict in doc/en/release-notes/bzr-2.3.txt
To merge this branch: bzr merge lp:~abentley/bzr/is_executable
Reviewer Review Type Date Requested Status
bzr-core Pending
Review via email: mp+42203@code.launchpad.net

This proposal supersedes a proposal from 2010-11-29.

This proposal has been superseded by a proposal from 2010-11-30.

Description of the change

Hi all,

This branch fixes RevisionTree.is_executable to treat directories and symlinks
the same way as other Tree implementations-- to return False rather than None.
The revised behaviour is also consistent with RevisionTree._comparison_data.

This problem filters up and affects Launchpad's incremental diffs for merge
proposals (which are disabled until this issue can be resolved), causing them
to erroneously report property changes on directories and symlinks
that have not changed.

Three tests have been affected, but FWICT, they were testing actual behaviour,
not desirable behaviour. Specifically, the ROOT_ENTRY should only be included
in iter_changes-style output when it has changed, when it has a new child, or
when include_unchanged is specified.

To post a comment you must log in.
Revision history for this message
Andrew Bennetts (spiv) wrote : Posted in a previous version of this proposal

The fix itself seems good.

(I already said this on IRC, but for the benefit of people looking at this page) The change to behaviour seems in principle reasonable, but I'd be nervous about landing it in the stable branch. I'm not sure how likely this is, but it's at least plausible that a plugin might be depending on the root entry being emitted in that case. So my preference is to land this just on lp:bzr.

One extremely minor nit is that the preferred way to do locking and addCleanup is now as a one-liner:

    self.addCleanup(tree.lock_read().unlock)

So if you wish, you could make that tweak, but it's not a big deal at all.

I'm going to vote "Abstain" because the key decision about whether to land this on 2.2 is up to the RM rather than a reviewer, I think.

review: Abstain
Revision history for this message
John A Meinel (jameinel) wrote : Posted in a previous version of this proposal

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/29/2010 5:50 PM, Aaron Bentley wrote:
> Aaron Bentley has proposed merging lp:~abentley/bzr/is_executable into lp:bzr/2.2.
>
> Requested reviews:
> bzr-core (bzr-core)
>
>
> Hi all,
>
> This branch fixes RevisionTree.is_executable to treat directories and symlinks
> the same way as other Tree implementations-- to return False rather than None.
> The revised behaviour is also consistent with RevisionTree._comparison_data.
>
> This problem filters up and affects Launchpad's incremental diffs for merge
> proposals (which are disabled until this issue can be resolved), causing them
> to erroneously report property changes on directories and symlinks
> that have not changed.
>
> Three tests have been affected, but FWICT, they were testing actual behaviour,
> not desirable behaviour. Specifically, the ROOT_ENTRY should only be included
> in iter_changes-style output when it has changed, when it has a new child, or
> when include_unchanged is specified.

I'm a little concerned about doing this in a stable series. I think the
patch is definitely worthy for trunk.

I'm guessing you did it this way because you want it in the launchpad
codebase?

 review: needs_information

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkz1EVsACgkQJdeBCYSNAAN72ACgx2ecqEd8iGOT/Nb/rGTb0KtJ
4jMAn2bc2xDxFQ08Efy6ppdJSgksKdXM
=RuBa
-----END PGP SIGNATURE-----

review: Needs Information
Revision history for this message
Aaron Bentley (abentley) wrote : Posted in a previous version of this proposal

I proposed for 2.2 because I want it for Launchpad, and because it seemed like a small change. I didn't imagine that clients would actually care about the executability of symlinks or directories, but I can think of at least one client (difftacular, used by Launchpad) that cares that the output of RevisionTree.iter_changes(PreviewTree) is sane.

So on balance, it still seems like a reasonable change to make in a stable series. That said, I can propose a more conservative patch for 2.2 that will merely correct the output of RevisionTree.iter_changes(PreviewTree). Or I guess I could fix in in difftactular, though I'd rather not.

Revision history for this message
Martin Pool (mbp) wrote : Posted in a previous version of this proposal

Keeping 2.2 stable is very important. It's also desirable to keep Launchpad on the stable branch and to have them actually running that branch, not something diverged from it. This also seems at least plausibly like a bug that could be justified to fix in 2.2, assuming the fix is safe.

With regard to assessing safety, it would help to say in the cover letter and NEWS what the behaviour was before. If it crashes, then it seems unlikely that anyone was counting on that behaviour. But I see from the diff it's obviously None.

Consistency with other Trees is a pretty good reason to change it.

=== modified file 'bzrlib/tests/test_transform.py'
--- bzrlib/tests/test_transform.py 2010-10-06 21:29:58 +0000
+++ bzrlib/tests/test_transform.py 2010-11-29 23:49:57 +0000
@@ -2344,7 +2344,7 @@
                   ('TREE_ROOT', 'TREE_ROOT'), ('a', 'a'), ('file', 'file'),
                   (False, False))
 ROOT_ENTRY = ('TREE_ROOT', ('', ''), False, (True, True), (None, None),
- ('', ''), ('directory', 'directory'), (False, None))
+ ('', ''), ('directory', 'directory'), (False, False))

 class TestTransformPreview(tests.TestCaseWithTransport):
@@ -2437,13 +2437,13 @@
         revision_tree, preview_tree = self.get_tree_and_preview_tree()
         changes = preview_tree.iter_changes(revision_tree,
                                             specific_files=[''])
- self.assertEqual([ROOT_ENTRY, A_ENTRY], list(changes))
+ self.assertEqual([A_ENTRY], list(changes))

     def test_want_unversioned(self):
         revision_tree, preview_tree = self.get_tree_and_preview_tree()
         changes = preview_tree.iter_changes(revision_tree,
                                             want_unversioned=True)
- self.assertEqual([ROOT_ENTRY, A_ENTRY], list(changes))
+ self.assertEqual([A_ENTRY], list(changes))

     def test_ignore_extra_trees_no_specific_files(self):
         # extra_trees is harmless without specific_files, so we'll silently

So that's a consequence of the value now being the same in all trees, therefore it's not detected as changing?

It seems like if we do break any API clients, it might be through side effects of things like this, rather than because they directly care about the is_executable value.

We could try testing the 2.2-related branches or releases with this patch.

Revision history for this message
Martin Pool (mbp) wrote : Posted in a previous version of this proposal

Aaron told me on irc that he checked this against some core plugins, and found no new failures, so I think we should merge this to 2.2.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzr'
2--- bzr 2010-10-08 10:50:51 +0000
3+++ bzr 2010-11-30 03:56:32 +0000
4@@ -23,7 +23,11 @@
5 import warnings
6
7 # update this on each release
8+<<<<<<< TREE
9 _script_version = (2, 3, 0)
10+=======
11+_script_version = (2, 2, 3)
12+>>>>>>> MERGE-SOURCE
13
14 try:
15 version_info = sys.version_info
16
17=== modified file 'bzrlib/__init__.py'
18--- bzrlib/__init__.py 2010-11-26 15:57:20 +0000
19+++ bzrlib/__init__.py 2010-11-30 03:56:32 +0000
20@@ -52,7 +52,11 @@
21 # Python version 2.0 is (2, 0, 0, 'final', 0)." Additionally we use a
22 # releaselevel of 'dev' for unreleased under-development code.
23
24+<<<<<<< TREE
25 version_info = (2, 3, 0, 'dev', 4)
26+=======
27+version_info = (2, 2, 3, 'dev', 0)
28+>>>>>>> MERGE-SOURCE
29
30 # API compatibility version
31 api_minimum_version = (2, 3, 0)
32
33=== modified file 'bzrlib/revisiontree.py'
34--- bzrlib/revisiontree.py 2010-05-06 23:41:35 +0000
35+++ bzrlib/revisiontree.py 2010-11-30 03:56:32 +0000
36@@ -110,7 +110,7 @@
37 def is_executable(self, file_id, path=None):
38 ie = self._inventory[file_id]
39 if ie.kind != "file":
40- return None
41+ return False
42 return ie.executable
43
44 def has_filename(self, filename):
45
46=== modified file 'bzrlib/tests/per_tree/__init__.py'
47--- bzrlib/tests/per_tree/__init__.py 2010-08-21 16:06:24 +0000
48+++ bzrlib/tests/per_tree/__init__.py 2010-11-30 03:56:32 +0000
49@@ -381,6 +381,7 @@
50 'get_symlink_target',
51 'inv',
52 'iter_search_rules',
53+ 'is_executable',
54 'list_files',
55 'locking',
56 'path_content_summary',
57
58=== added file 'bzrlib/tests/per_tree/test_is_executable.py'
59--- bzrlib/tests/per_tree/test_is_executable.py 1970-01-01 00:00:00 +0000
60+++ bzrlib/tests/per_tree/test_is_executable.py 2010-11-30 03:56:32 +0000
61@@ -0,0 +1,37 @@
62+# Copyright (C) 2010 Canonical Ltd
63+#
64+# This program is free software; you can redistribute it and/or modify
65+# it under the terms of the GNU General Public License as published by
66+# the Free Software Foundation; either version 2 of the License, or
67+# (at your option) any later version.
68+#
69+# This program is distributed in the hope that it will be useful,
70+# but WITHOUT ANY WARRANTY; without even the implied warranty of
71+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
72+# GNU General Public License for more details.
73+#
74+# You should have received a copy of the GNU General Public License
75+# along with this program; if not, write to the Free Software
76+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
77+
78+from bzrlib.tests import (
79+ per_tree,
80+ SymlinkFeature,
81+ )
82+
83+
84+class TestIsExecutable(per_tree.TestCaseWithTree):
85+
86+ def test_is_executable_dir(self):
87+ tree = self.get_tree_with_subdirs_and_all_supported_content_types(
88+ False)
89+ tree.lock_read()
90+ self.addCleanup(tree.unlock)
91+ self.assertEqual(False, tree.is_executable('1top-dir'))
92+
93+ def test_is_executable_symlink(self):
94+ self.requireFeature(SymlinkFeature)
95+ tree = self.get_tree_with_subdirs_and_all_content_types()
96+ tree.lock_read()
97+ self.addCleanup(tree.unlock)
98+ self.assertEqual(False, tree.is_executable('symlink'))
99
100=== modified file 'bzrlib/tests/test_transform.py'
101--- bzrlib/tests/test_transform.py 2010-11-19 08:34:39 +0000
102+++ bzrlib/tests/test_transform.py 2010-11-30 03:56:32 +0000
103@@ -2381,7 +2381,7 @@
104 ('TREE_ROOT', 'TREE_ROOT'), ('a', 'a'), ('file', 'file'),
105 (False, False))
106 ROOT_ENTRY = ('TREE_ROOT', ('', ''), False, (True, True), (None, None),
107- ('', ''), ('directory', 'directory'), (False, None))
108+ ('', ''), ('directory', 'directory'), (False, False))
109
110
111 class TestTransformPreview(tests.TestCaseWithTransport):
112@@ -2474,13 +2474,13 @@
113 revision_tree, preview_tree = self.get_tree_and_preview_tree()
114 changes = preview_tree.iter_changes(revision_tree,
115 specific_files=[''])
116- self.assertEqual([ROOT_ENTRY, A_ENTRY], list(changes))
117+ self.assertEqual([A_ENTRY], list(changes))
118
119 def test_want_unversioned(self):
120 revision_tree, preview_tree = self.get_tree_and_preview_tree()
121 changes = preview_tree.iter_changes(revision_tree,
122 want_unversioned=True)
123- self.assertEqual([ROOT_ENTRY, A_ENTRY], list(changes))
124+ self.assertEqual([A_ENTRY], list(changes))
125
126 def test_ignore_extra_trees_no_specific_files(self):
127 # extra_trees is harmless without specific_files, so we'll silently
128
129=== modified file 'bzrlib/workingtree_4.py'
130--- bzrlib/workingtree_4.py 2010-08-03 13:31:06 +0000
131+++ bzrlib/workingtree_4.py 2010-11-30 03:56:32 +0000
132@@ -1867,7 +1867,7 @@
133 def is_executable(self, file_id, path=None):
134 ie = self.inventory[file_id]
135 if ie.kind != "file":
136- return None
137+ return False
138 return ie.executable
139
140 def is_locked(self):
141
142=== modified file 'doc/en/release-notes/bzr-2.3.txt'
143--- doc/en/release-notes/bzr-2.3.txt 2010-11-29 01:23:53 +0000
144+++ doc/en/release-notes/bzr-2.3.txt 2010-11-30 03:56:32 +0000
145@@ -5,9 +5,47 @@
146 .. toctree::
147 :maxdepth: 1
148
149+<<<<<<< TREE
150 bzr 2.3b4
151-#########
152-
153+=======
154+bzr 2.2.3
155+#########
156+
157+:2.2.3: NOT RELEASED YET
158+
159+Compatibility Breaks
160+********************
161+
162+New Features
163+************
164+
165+Bug Fixes
166+*********
167+
168+* RevisionTree.is_executable handles directories and symlinks like other types
169+ and functions. (Aaron Bentley, #681885)
170+
171+Improvements
172+************
173+
174+Documentation
175+*************
176+
177+API Changes
178+***********
179+
180+Internals
181+*********
182+
183+Testing
184+*******
185+
186+
187+bzr 2.2.2
188+>>>>>>> MERGE-SOURCE
189+#########
190+
191+<<<<<<< TREE
192 :2.3.b4: NOT RELEASED YET
193
194 External Compatibility Breaks
195@@ -42,6 +80,13 @@
196 * Read configuration files in $XDG_CONFIG_HOME/bazaar on Unix if there is
197 already a directory there. (Neil Martinsen-Burrell, #195397)
198
199+=======
200+:2.2.2: 2010-11-25
201+
202+This is a bugfix release. None of these bugfixes are critical, but upgrading
203+is recommended for all users on earlier 2.2 releases.
204+
205+>>>>>>> MERGE-SOURCE
206 Bug Fixes
207 *********
208