bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
4763.2.4
by John Arbash Meinel
merge bzr.2.1 in preparation for NEWS entry. |
1 |
# Copyright (C) 2007, 2009, 2010 Canonical Ltd
|
2776.1.7
by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2776.1.7
by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a |
16 |
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
17 |
"""Test that all Trees implement path_content_summary."""
|
2776.1.7
by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a |
18 |
|
19 |
import os |
|
20 |
||
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
21 |
from breezy import ( |
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
22 |
osutils, |
23 |
tests, |
|
24 |
)
|
|
25 |
||
7490.85.1
by Jelmer Vernooij
Factor out PreviewTree. |
26 |
from breezy.transform import ( |
27 |
PreviewTree, |
|
7490.77.6
by Jelmer Vernooij
Fix tests. |
28 |
)
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
29 |
from breezy.tests import ( |
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
30 |
features, |
31 |
per_tree, |
|
32 |
)
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
33 |
from breezy.tests.features import ( |
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
34 |
SymlinkFeature, |
35 |
)
|
|
4523.1.4
by Martin Pool
Rename remaining *_implementations tests |
36 |
|
37 |
||
38 |
class TestPathContentSummary(per_tree.TestCaseWithTree): |
|
2776.1.7
by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a |
39 |
|
40 |
def _convert_tree(self, tree): |
|
4523.1.4
by Martin Pool
Rename remaining *_implementations tests |
41 |
result = per_tree.TestCaseWithTree._convert_tree(self, tree) |
2776.1.7
by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a |
42 |
result.lock_read() |
43 |
self.addCleanup(result.unlock) |
|
44 |
return result |
|
45 |
||
4595.11.17
by Martin Pool
Update tests for path_content_summary to reflect it may not return the size |
46 |
def check_content_summary_size(self, tree, summary, expected_size): |
47 |
# if the tree supports content filters, then it's allowed to leave out
|
|
48 |
# the size because it might be difficult to compute. otherwise, it
|
|
49 |
# must be present and correct
|
|
50 |
returned_size = summary[1] |
|
51 |
if returned_size == expected_size or ( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
52 |
tree.supports_content_filtering() |
53 |
and returned_size is None): |
|
4595.11.17
by Martin Pool
Update tests for path_content_summary to reflect it may not return the size |
54 |
pass
|
55 |
else: |
|
56 |
self.fail("invalid size in summary: %r" % (returned_size,)) |
|
57 |
||
2776.1.7
by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a |
58 |
def test_symlink_content_summary(self): |
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
59 |
self.requireFeature(SymlinkFeature) |
2776.1.7
by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a |
60 |
tree = self.make_branch_and_tree('tree') |
61 |
os.symlink('target', 'tree/path') |
|
62 |
tree.add(['path']) |
|
63 |
summary = self._convert_tree(tree).path_content_summary('path') |
|
64 |
self.assertEqual(('symlink', None, None, 'target'), summary) |
|
65 |
||
3949.6.1
by Jelmer Vernooij
Support symlinks with non-ascii characters in the symlink filename. |
66 |
def test_unicode_symlink_content_summary(self): |
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
67 |
self.requireFeature(features.SymlinkFeature) |
68 |
self.requireFeature(features.UnicodeFilenameFeature) |
|
3949.6.1
by Jelmer Vernooij
Support symlinks with non-ascii characters in the symlink filename. |
69 |
tree = self.make_branch_and_tree('tree') |
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
70 |
os.symlink('target', u'tree/\u03b2-path'.encode(osutils._fs_enc)) |
3949.6.1
by Jelmer Vernooij
Support symlinks with non-ascii characters in the symlink filename. |
71 |
tree.add([u'\u03b2-path']) |
72 |
summary = self._convert_tree(tree).path_content_summary(u'\u03b2-path') |
|
73 |
self.assertEqual(('symlink', None, None, 'target'), summary) |
|
74 |
||
4095.3.1
by Vincent Ladeuil
Fix #339055 and #277444 by handling non ascii symlink targets. |
75 |
def test_unicode_symlink_target_summary(self): |
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
76 |
self.requireFeature(features.SymlinkFeature) |
77 |
self.requireFeature(features.UnicodeFilenameFeature) |
|
4095.3.1
by Vincent Ladeuil
Fix #339055 and #277444 by handling non ascii symlink targets. |
78 |
tree = self.make_branch_and_tree('tree') |
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
79 |
os.symlink(u'tree/\u03b2-path'.encode(osutils._fs_enc), 'tree/link') |
4095.3.1
by Vincent Ladeuil
Fix #339055 and #277444 by handling non ascii symlink targets. |
80 |
tree.add(['link']) |
81 |
summary = self._convert_tree(tree).path_content_summary('link') |
|
82 |
self.assertEqual(('symlink', None, None, u'tree/\u03b2-path'), summary) |
|
83 |
||
2776.1.7
by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a |
84 |
def test_missing_content_summary(self): |
85 |
tree = self.make_branch_and_tree('tree') |
|
86 |
summary = self._convert_tree(tree).path_content_summary('path') |
|
87 |
self.assertEqual(('missing', None, None, None), summary) |
|
88 |
||
89 |
def test_file_content_summary_executable(self): |
|
90 |
tree = self.make_branch_and_tree('tree') |
|
91 |
self.build_tree(['tree/path']) |
|
92 |
tree.add(['path']) |
|
7490.77.2
by Jelmer Vernooij
Split out git and bzr-specific transforms. |
93 |
with tree.transform() as tt: |
7350.3.4
by Jelmer Vernooij
Use context managers. |
94 |
tt.set_executability(True, tt.trans_id_tree_path('path')) |
95 |
tt.apply() |
|
2776.1.7
by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a |
96 |
summary = self._convert_tree(tree).path_content_summary('path') |
97 |
self.assertEqual(4, len(summary)) |
|
98 |
self.assertEqual('file', summary[0]) |
|
4595.11.17
by Martin Pool
Update tests for path_content_summary to reflect it may not return the size |
99 |
self.check_content_summary_size(tree, summary, 22) |
2776.1.7
by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a |
100 |
# executable
|
101 |
self.assertEqual(True, summary[2]) |
|
102 |
# may have hash,
|
|
103 |
self.assertSubset((summary[3],), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
104 |
(None, b'0c352290ae1c26ca7f97d5b2906c4624784abd60')) |
2776.1.7
by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a |
105 |
|
4789.15.1
by John Arbash Meinel
Have a defined result for Tree.path_content_summary() for unversioned files. |
106 |
def test_file_content_summary_not_versioned(self): |
107 |
tree = self.make_branch_and_tree('tree') |
|
108 |
self.build_tree(['tree/path']) |
|
109 |
tree = self._convert_tree(tree) |
|
110 |
summary = tree.path_content_summary('path') |
|
111 |
self.assertEqual(4, len(summary)) |
|
112 |
if isinstance(tree, (per_tree.DirStateRevisionTree, |
|
113 |
per_tree.RevisionTree)): |
|
114 |
self.assertEqual('missing', summary[0]) |
|
115 |
self.assertIs(None, summary[2]) |
|
116 |
self.assertIs(None, summary[3]) |
|
7490.85.1
by Jelmer Vernooij
Factor out PreviewTree. |
117 |
elif isinstance(tree, PreviewTree): |
4789.15.1
by John Arbash Meinel
Have a defined result for Tree.path_content_summary() for unversioned files. |
118 |
self.expectFailure('PreviewTree returns "missing" for unversioned' |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
119 |
'files', self.assertEqual, 'file', summary[0]) |
4789.15.1
by John Arbash Meinel
Have a defined result for Tree.path_content_summary() for unversioned files. |
120 |
self.assertEqual('file', summary[0]) |
121 |
else: |
|
122 |
self.assertEqual('file', summary[0]) |
|
123 |
self.check_content_summary_size(tree, summary, 22) |
|
124 |
self.assertEqual(False, summary[2]) |
|
125 |
self.assertSubset((summary[3],), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
126 |
(None, b'0c352290ae1c26ca7f97d5b2906c4624784abd60')) |
4789.15.1
by John Arbash Meinel
Have a defined result for Tree.path_content_summary() for unversioned files. |
127 |
|
2776.1.7
by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a |
128 |
def test_file_content_summary_non_exec(self): |
129 |
tree = self.make_branch_and_tree('tree') |
|
130 |
self.build_tree(['tree/path']) |
|
131 |
tree.add(['path']) |
|
132 |
summary = self._convert_tree(tree).path_content_summary('path') |
|
133 |
self.assertEqual(4, len(summary)) |
|
134 |
self.assertEqual('file', summary[0]) |
|
4595.11.17
by Martin Pool
Update tests for path_content_summary to reflect it may not return the size |
135 |
self.check_content_summary_size(tree, summary, 22) |
2776.1.7
by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a |
136 |
# not executable
|
6379.7.1
by Jelmer Vernooij
Add and use WorkingTree._supports_executable. |
137 |
self.assertEqual(False, summary[2]) |
2776.1.7
by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a |
138 |
# may have hash,
|
139 |
self.assertSubset((summary[3],), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
140 |
(None, b'0c352290ae1c26ca7f97d5b2906c4624784abd60')) |
2776.1.7
by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a |
141 |
|
142 |
def test_dir_content_summary(self): |
|
143 |
tree = self.make_branch_and_tree('tree') |
|
144 |
self.build_tree(['tree/path/']) |
|
145 |
tree.add(['path']) |
|
7096.3.2
by Jelmer Vernooij
Fix some git tests. |
146 |
converted_tree = self._convert_tree(tree) |
147 |
summary = converted_tree.path_content_summary('path') |
|
148 |
if converted_tree.has_versioned_directories() or converted_tree.has_filename('path'): |
|
149 |
self.assertEqual(('directory', None, None, None), summary) |
|
150 |
else: |
|
151 |
self.assertEqual(('missing', None, None, None), summary) |
|
2776.1.7
by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a |
152 |
|
153 |
def test_tree_content_summary(self): |
|
154 |
tree = self.make_branch_and_tree('tree') |
|
155 |
if not tree.branch.repository._format.supports_tree_reference: |
|
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
156 |
raise tests.TestNotApplicable("Tree references not supported.") |
5786.1.1
by John Arbash Meinel
Fix bug #764677. WT.inventory should correctly return TreeReference |
157 |
subtree = self.make_branch_and_tree('tree/path') |
6926.2.8
by Jelmer Vernooij
Fix some more tests. |
158 |
subtree.commit('') |
5786.1.1
by John Arbash Meinel
Fix bug #764677. WT.inventory should correctly return TreeReference |
159 |
tree.add(['path']) |
2776.1.7
by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a |
160 |
summary = self._convert_tree(tree).path_content_summary('path') |
161 |
self.assertEqual(4, len(summary)) |
|
162 |
self.assertEqual('tree-reference', summary[0]) |