bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.358.2
by Jelmer Vernooij
Refresh copyright headers, add my email. |
1 |
# Copyright (C) 2010-2018 Jelmer Vernooij <jelmer@jelmer.uk>
|
|
0.262.1
by Jelmer Vernooij
Fix WorkingTree.conflicts(). |
2 |
# Copyright (C) 2011 Canonical Ltd.
|
3 |
#
|
|
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
|
0.358.1
by Jelmer Vernooij
Fix FSF address. |
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
0.262.1
by Jelmer Vernooij
Fix WorkingTree.conflicts(). |
17 |
|
18 |
"""Tests for Git working trees."""
|
|
19 |
||
|
0.358.3
by Jelmer Vernooij
Enable absolute import. |
20 |
from __future__ import absolute_import |
21 |
||
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
22 |
import os |
23 |
import stat |
|
24 |
||
|
7467.4.2
by Jelmer Vernooij
Add some tests. |
25 |
from dulwich import __version__ as dulwich_version |
26 |
from dulwich.diff_tree import RenameDetector |
|
|
7131.13.1
by Jelmer Vernooij
Don't show a delta for unchanged submodules. |
27 |
from dulwich.index import IndexEntry |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
28 |
from dulwich.objects import ( |
|
7131.13.1
by Jelmer Vernooij
Don't show a delta for unchanged submodules. |
29 |
S_IFGITLINK, |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
30 |
Blob, |
31 |
Tree, |
|
32 |
ZERO_SHA, |
|
33 |
)
|
|
34 |
||
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
35 |
from ... import ( |
|
6977.1.2
by Jelmer Vernooij
Deal with missing files properly in 'bzr st'. |
36 |
conflicts as _mod_conflicts, |
|
7131.3.1
by Jelmer Vernooij
When opening working trees with .git files, open the right control transport. |
37 |
workingtree as _mod_workingtree, |
|
6977.1.2
by Jelmer Vernooij
Deal with missing files properly in 'bzr st'. |
38 |
)
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
39 |
from ...delta import TreeDelta |
|
7358.11.3
by Jelmer Vernooij
TreeDelta holds TreeChange objects rather than tuples of various sizes. |
40 |
from ...tree import TreeChange |
|
6977.1.2
by Jelmer Vernooij
Deal with missing files properly in 'bzr st'. |
41 |
from ..mapping import ( |
42 |
default_mapping, |
|
43 |
)
|
|
|
6973.1.1
by Jelmer Vernooij
Make InterIndexGitTree suitable for use with MemoryGitTree. |
44 |
from ..tree import ( |
45 |
changes_between_git_tree_and_working_copy, |
|
|
6977.1.2
by Jelmer Vernooij
Deal with missing files properly in 'bzr st'. |
46 |
tree_delta_from_git_changes, |
|
6973.1.1
by Jelmer Vernooij
Make InterIndexGitTree suitable for use with MemoryGitTree. |
47 |
)
|
|
0.369.1
by Jelmer Vernooij
Implement conflict handling. |
48 |
from ..workingtree import ( |
49 |
FLAG_STAGEMASK, |
|
|
0.262.1
by Jelmer Vernooij
Fix WorkingTree.conflicts(). |
50 |
)
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
51 |
from ...tests import ( |
|
6977.1.2
by Jelmer Vernooij
Deal with missing files properly in 'bzr st'. |
52 |
TestCase, |
53 |
TestCaseWithTransport, |
|
54 |
)
|
|
|
0.262.1
by Jelmer Vernooij
Fix WorkingTree.conflicts(). |
55 |
|
56 |
||
57 |
class GitWorkingTreeTests(TestCaseWithTransport): |
|
58 |
||
59 |
def setUp(self): |
|
60 |
super(GitWorkingTreeTests, self).setUp() |
|
61 |
self.tree = self.make_branch_and_tree('.', format="git") |
|
62 |
||
|
0.369.1
by Jelmer Vernooij
Implement conflict handling. |
63 |
def test_conflict_list(self): |
|
0.369.2
by Jelmer Vernooij
Fix tests. |
64 |
self.assertIsInstance( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
65 |
self.tree.conflicts(), |
66 |
_mod_conflicts.ConflictList) |
|
|
0.369.1
by Jelmer Vernooij
Implement conflict handling. |
67 |
|
68 |
def test_add_conflict(self): |
|
69 |
self.build_tree(['conflicted']) |
|
70 |
self.tree.add(['conflicted']) |
|
71 |
with self.tree.lock_tree_write(): |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
72 |
self.tree.index[b'conflicted'] = self.tree.index[b'conflicted'][:9] + \ |
73 |
(FLAG_STAGEMASK, ) |
|
|
0.415.3
by Jelmer Vernooij
Open index on demand. |
74 |
self.tree._index_dirty = True |
|
0.369.1
by Jelmer Vernooij
Implement conflict handling. |
75 |
conflicts = self.tree.conflicts() |
76 |
self.assertEqual(1, len(conflicts)) |
|
|
0.385.1
by Jelmer Vernooij
Use specific_files argument to Tree.iter_entries_by_dir. |
77 |
|
78 |
def test_revert_empty(self): |
|
79 |
self.build_tree(['a']) |
|
80 |
self.tree.add(['a']) |
|
81 |
self.assertTrue(self.tree.is_versioned('a')) |
|
82 |
self.tree.revert(['a']) |
|
83 |
self.assertFalse(self.tree.is_versioned('a')) |
|
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
84 |
|
|
7065.1.1
by Jelmer Vernooij
Properly handle ignored directories in Git. |
85 |
def test_is_ignored_directory(self): |
86 |
self.assertFalse(self.tree.is_ignored('a')) |
|
87 |
self.build_tree(['a/']) |
|
88 |
self.assertFalse(self.tree.is_ignored('a')) |
|
89 |
self.build_tree_contents([('.gitignore', 'a\n')]) |
|
90 |
self.tree._ignoremanager = None |
|
91 |
self.assertTrue(self.tree.is_ignored('a')) |
|
92 |
self.build_tree_contents([('.gitignore', 'a/\n')]) |
|
93 |
self.tree._ignoremanager = None |
|
94 |
self.assertTrue(self.tree.is_ignored('a')) |
|
95 |
||
|
7265.3.1
by Jelmer Vernooij
Properly ignore .git files. |
96 |
def test_add_submodule_dir(self): |
97 |
subtree = self.make_branch_and_tree('asub', format='git') |
|
98 |
subtree.commit('Empty commit') |
|
99 |
self.tree.add(['asub']) |
|
100 |
with self.tree.lock_read(): |
|
101 |
entry = self.tree.index[b'asub'] |
|
102 |
self.assertEqual(entry.mode, S_IFGITLINK) |
|
103 |
self.assertEqual([], list(subtree.unknowns())) |
|
104 |
||
105 |
def test_add_submodule_file(self): |
|
106 |
os.mkdir('.git/modules') |
|
107 |
subbranch = self.make_branch('.git/modules/asub', format='git-bare') |
|
108 |
os.mkdir('asub') |
|
109 |
with open('asub/.git', 'w') as f: |
|
110 |
f.write('gitdir: ../.git/modules/asub\n') |
|
111 |
subtree = _mod_workingtree.WorkingTree.open('asub') |
|
112 |
subtree.commit('Empty commit') |
|
113 |
self.tree.add(['asub']) |
|
114 |
with self.tree.lock_read(): |
|
115 |
entry = self.tree.index[b'asub'] |
|
116 |
self.assertEqual(entry.mode, S_IFGITLINK) |
|
117 |
self.assertEqual([], list(subtree.unknowns())) |
|
118 |
||
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
119 |
|
|
7131.3.1
by Jelmer Vernooij
When opening working trees with .git files, open the right control transport. |
120 |
class GitWorkingTreeFileTests(TestCaseWithTransport): |
121 |
||
122 |
def setUp(self): |
|
123 |
super(GitWorkingTreeFileTests, self).setUp() |
|
124 |
self.tree = self.make_branch_and_tree('actual', format="git") |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
125 |
self.build_tree_contents( |
126 |
[('linked/',), ('linked/.git', 'gitdir: ../actual/.git')]) |
|
|
7131.3.1
by Jelmer Vernooij
When opening working trees with .git files, open the right control transport. |
127 |
self.wt = _mod_workingtree.WorkingTree.open('linked') |
128 |
||
129 |
def test_add(self): |
|
130 |
self.build_tree(['linked/somefile']) |
|
131 |
self.wt.add(["somefile"]) |
|
132 |
self.wt.commit("Add somefile") |
|
133 |
||
134 |
||
|
6977.1.2
by Jelmer Vernooij
Deal with missing files properly in 'bzr st'. |
135 |
class TreeDeltaFromGitChangesTests(TestCase): |
136 |
||
137 |
def test_empty(self): |
|
138 |
delta = TreeDelta() |
|
139 |
changes = [] |
|
140 |
self.assertEqual( |
|
141 |
delta, |
|
|
7358.13.1
by Jelmer Vernooij
Drop file id roundtripping support in Git. |
142 |
tree_delta_from_git_changes(changes, (default_mapping, default_mapping))) |
|
6977.1.2
by Jelmer Vernooij
Deal with missing files properly in 'bzr st'. |
143 |
|
144 |
def test_missing(self): |
|
145 |
delta = TreeDelta() |
|
|
7467.4.2
by Jelmer Vernooij
Add some tests. |
146 |
delta.removed.append( |
147 |
TreeChange( |
|
148 |
b'git:a', ('a', 'a'), False, (True, True), |
|
149 |
(b'TREE_ROOT', b'TREE_ROOT'), ('a', 'a'), ('file', None), |
|
150 |
(True, False))) |
|
151 |
changes = [ |
|
152 |
('remove', |
|
153 |
(b'a', stat.S_IFREG | 0o755, b'a' * 40), |
|
154 |
(b'a', 0, b'a' * 40))] |
|
|
6977.1.2
by Jelmer Vernooij
Deal with missing files properly in 'bzr st'. |
155 |
self.assertEqual( |
156 |
delta, |
|
|
7358.13.1
by Jelmer Vernooij
Drop file id roundtripping support in Git. |
157 |
tree_delta_from_git_changes(changes, (default_mapping, default_mapping))) |
|
6977.1.2
by Jelmer Vernooij
Deal with missing files properly in 'bzr st'. |
158 |
|
159 |
||
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
160 |
class ChangesBetweenGitTreeAndWorkingCopyTests(TestCaseWithTransport): |
161 |
||
162 |
def setUp(self): |
|
163 |
super(ChangesBetweenGitTreeAndWorkingCopyTests, self).setUp() |
|
164 |
self.wt = self.make_branch_and_tree('.', format='git') |
|
|
7131.13.1
by Jelmer Vernooij
Don't show a delta for unchanged submodules. |
165 |
self.store = self.wt.branch.repository._git.object_store |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
166 |
|
167 |
def expectDelta(self, expected_changes, |
|
|
7131.13.1
by Jelmer Vernooij
Don't show a delta for unchanged submodules. |
168 |
expected_extras=None, want_unversioned=False, |
|
7467.4.2
by Jelmer Vernooij
Add some tests. |
169 |
tree_id=None, rename_detector=None): |
|
7131.13.1
by Jelmer Vernooij
Don't show a delta for unchanged submodules. |
170 |
if tree_id is None: |
171 |
try: |
|
172 |
tree_id = self.store[self.wt.branch.repository._git.head()].tree |
|
173 |
except KeyError: |
|
174 |
tree_id = None |
|
|
0.415.3
by Jelmer Vernooij
Open index on demand. |
175 |
with self.wt.lock_read(): |
176 |
changes, extras = changes_between_git_tree_and_working_copy( |
|
|
7467.4.2
by Jelmer Vernooij
Add some tests. |
177 |
self.store, tree_id, self.wt, want_unversioned=want_unversioned, |
178 |
rename_detector=rename_detector) |
|
|
0.415.3
by Jelmer Vernooij
Open index on demand. |
179 |
self.assertEqual(expected_changes, list(changes)) |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
180 |
if expected_extras is None: |
181 |
expected_extras = set() |
|
182 |
self.assertEqual(set(expected_extras), set(extras)) |
|
183 |
||
184 |
def test_empty(self): |
|
185 |
self.expectDelta( |
|
|
7467.4.2
by Jelmer Vernooij
Add some tests. |
186 |
[('add', (None, None, None), (b'', stat.S_IFDIR, Tree().id))]) |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
187 |
|
188 |
def test_added_file(self): |
|
189 |
self.build_tree(['a']) |
|
190 |
self.wt.add(['a']) |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
191 |
a = Blob.from_string(b'contents of a\n') |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
192 |
t = Tree() |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
193 |
t.add(b"a", stat.S_IFREG | 0o644, a.id) |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
194 |
self.expectDelta( |
|
7467.4.2
by Jelmer Vernooij
Add some tests. |
195 |
[('add', (None, None, None), (b'', stat.S_IFDIR, t.id)), |
196 |
('add', (None, None, None), (b'a', stat.S_IFREG | 0o644, a.id))]) |
|
197 |
||
198 |
def test_renamed_file(self): |
|
199 |
self.build_tree(['a']) |
|
200 |
self.wt.add(['a']) |
|
201 |
self.wt.rename_one('a', 'b') |
|
202 |
a = Blob.from_string(b'contents of a\n') |
|
203 |
self.store.add_object(a) |
|
204 |
oldt = Tree() |
|
205 |
oldt.add(b"a", stat.S_IFREG | 0o644, a.id) |
|
206 |
self.store.add_object(oldt) |
|
207 |
newt = Tree() |
|
208 |
newt.add(b"b", stat.S_IFREG | 0o644, a.id) |
|
209 |
self.store.add_object(newt) |
|
210 |
self.expectDelta( |
|
211 |
[('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)), |
|
212 |
('delete', (b'a', stat.S_IFREG | 0o644, a.id), (None, None, None)), |
|
213 |
('add', (None, None, None), (b'b', stat.S_IFREG | 0o644, a.id)), |
|
214 |
],
|
|
215 |
tree_id=oldt.id) |
|
216 |
if dulwich_version >= (0, 19, 15): |
|
217 |
self.expectDelta( |
|
218 |
[('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)), |
|
219 |
('rename', (b'a', stat.S_IFREG | 0o644, a.id), (b'b', stat.S_IFREG | 0o644, a.id))], |
|
220 |
tree_id=oldt.id, rename_detector=RenameDetector(self.store)) |
|
221 |
||
222 |
def test_copied_file(self): |
|
223 |
self.build_tree(['a']) |
|
224 |
self.wt.add(['a']) |
|
225 |
self.wt.copy_one('a', 'b') |
|
226 |
a = Blob.from_string(b'contents of a\n') |
|
227 |
self.store.add_object(a) |
|
228 |
oldt = Tree() |
|
229 |
oldt.add(b"a", stat.S_IFREG | 0o644, a.id) |
|
230 |
self.store.add_object(oldt) |
|
231 |
newt = Tree() |
|
232 |
newt.add(b"a", stat.S_IFREG | 0o644, a.id) |
|
233 |
newt.add(b"b", stat.S_IFREG | 0o644, a.id) |
|
234 |
self.store.add_object(newt) |
|
235 |
self.expectDelta( |
|
236 |
[('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)), |
|
237 |
('add', (None, None, None), (b'b', stat.S_IFREG | 0o644, a.id)), |
|
238 |
],
|
|
239 |
tree_id=oldt.id) |
|
240 |
||
241 |
if dulwich_version >= (0, 19, 15): |
|
242 |
self.expectDelta( |
|
243 |
[('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)), |
|
244 |
('copy', (b'a', stat.S_IFREG | 0o644, a.id), (b'b', stat.S_IFREG | 0o644, a.id))], |
|
245 |
tree_id=oldt.id, rename_detector=RenameDetector(self.store, find_copies_harder=True)) |
|
246 |
self.expectDelta( |
|
247 |
[('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)), |
|
248 |
('add', (None, None, None), (b'b', stat.S_IFREG | 0o644, a.id)), |
|
249 |
],
|
|
250 |
tree_id=oldt.id, rename_detector=RenameDetector(self.store, find_copies_harder=False)) |
|
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
251 |
|
252 |
def test_added_unknown_file(self): |
|
253 |
self.build_tree(['a']) |
|
254 |
t = Tree() |
|
255 |
self.expectDelta( |
|
|
7467.4.2
by Jelmer Vernooij
Add some tests. |
256 |
[('add', (None, None, None), (b'', stat.S_IFDIR, t.id))]) |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
257 |
a = Blob.from_string(b'contents of a\n') |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
258 |
t = Tree() |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
259 |
t.add(b"a", stat.S_IFREG | 0o644, a.id) |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
260 |
self.expectDelta( |
|
7467.4.2
by Jelmer Vernooij
Add some tests. |
261 |
[('add', (None, None, None), (b'', stat.S_IFDIR, t.id)), |
262 |
('add', (None, None, None), (b'a', stat.S_IFREG | 0o644, a.id))], |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
263 |
[b'a'], |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
264 |
want_unversioned=True) |
265 |
||
266 |
def test_missing_added_file(self): |
|
267 |
self.build_tree(['a']) |
|
268 |
self.wt.add(['a']) |
|
269 |
os.unlink('a') |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
270 |
a = Blob.from_string(b'contents of a\n') |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
271 |
t = Tree() |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
272 |
t.add(b"a", 0, ZERO_SHA) |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
273 |
self.expectDelta( |
|
7467.4.2
by Jelmer Vernooij
Add some tests. |
274 |
[('add', (None, None, None), (b'', stat.S_IFDIR, t.id)), |
275 |
('add', (None, None, None), (b'a', 0, ZERO_SHA))], |
|
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
276 |
[])
|
277 |
||
278 |
def test_missing_versioned_file(self): |
|
279 |
self.build_tree(['a']) |
|
280 |
self.wt.add(['a']) |
|
281 |
self.wt.commit('') |
|
282 |
os.unlink('a') |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
283 |
a = Blob.from_string(b'contents of a\n') |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
284 |
oldt = Tree() |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
285 |
oldt.add(b"a", stat.S_IFREG | 0o644, a.id) |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
286 |
newt = Tree() |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
287 |
newt.add(b"a", 0, ZERO_SHA) |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
288 |
self.expectDelta( |
|
7467.4.2
by Jelmer Vernooij
Add some tests. |
289 |
[('modify', |
290 |
(b'', stat.S_IFDIR, oldt.id), |
|
291 |
(b'', stat.S_IFDIR, newt.id)), |
|
292 |
('modify', |
|
293 |
(b'a', stat.S_IFREG | 0o644, a.id), |
|
294 |
(b'a', 0, ZERO_SHA))]) |
|
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
295 |
|
296 |
def test_versioned_replace_by_dir(self): |
|
297 |
self.build_tree(['a']) |
|
298 |
self.wt.add(['a']) |
|
299 |
self.wt.commit('') |
|
300 |
os.unlink('a') |
|
301 |
os.mkdir('a') |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
302 |
olda = Blob.from_string(b'contents of a\n') |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
303 |
oldt = Tree() |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
304 |
oldt.add(b"a", stat.S_IFREG | 0o644, olda.id) |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
305 |
newt = Tree() |
306 |
newa = Tree() |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
307 |
newt.add(b"a", stat.S_IFDIR, newa.id) |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
308 |
self.expectDelta([ |
|
7467.4.2
by Jelmer Vernooij
Add some tests. |
309 |
('modify', |
310 |
(b'', stat.S_IFDIR, oldt.id), |
|
311 |
(b'', stat.S_IFDIR, newt.id)), |
|
312 |
('modify', |
|
313 |
(b'a', stat.S_IFREG | 0o644, olda.id), |
|
314 |
(b'a', stat.S_IFDIR, newa.id)) |
|
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
315 |
], want_unversioned=False) |
316 |
self.expectDelta([ |
|
|
7467.4.2
by Jelmer Vernooij
Add some tests. |
317 |
('modify', |
318 |
(b'', stat.S_IFDIR, oldt.id), |
|
319 |
(b'', stat.S_IFDIR, newt.id)), |
|
320 |
('modify', |
|
321 |
(b'a', stat.S_IFREG | 0o644, olda.id), |
|
322 |
(b'a', stat.S_IFDIR, newa.id)), |
|
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
323 |
], want_unversioned=True) |
324 |
||
325 |
def test_extra(self): |
|
326 |
self.build_tree(['a']) |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
327 |
newa = Blob.from_string(b'contents of a\n') |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
328 |
newt = Tree() |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
329 |
newt.add(b"a", stat.S_IFREG | 0o644, newa.id) |
|
0.391.7
by Jelmer Vernooij
Fix reporting of missing files in .iter_changes. |
330 |
self.expectDelta([ |
|
7467.4.2
by Jelmer Vernooij
Add some tests. |
331 |
('add', |
332 |
(None, None, None), |
|
333 |
(b'', stat.S_IFDIR, newt.id)), |
|
334 |
('add', |
|
335 |
(None, None, None), |
|
336 |
(b'a', stat.S_IFREG | 0o644, newa.id)), |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
337 |
], [b'a'], want_unversioned=True) |
|
7131.13.1
by Jelmer Vernooij
Don't show a delta for unchanged submodules. |
338 |
|
339 |
def test_submodule(self): |
|
|
7296.1.3
by Jelmer Vernooij
Fix submodule test. |
340 |
self.subtree = self.make_branch_and_tree('a', format="git") |
|
7131.13.1
by Jelmer Vernooij
Don't show a delta for unchanged submodules. |
341 |
a = Blob.from_string(b'irrelevant\n') |
|
7296.1.3
by Jelmer Vernooij
Fix submodule test. |
342 |
self.build_tree_contents([('a/.git/HEAD', a.id)]) |
|
7131.13.1
by Jelmer Vernooij
Don't show a delta for unchanged submodules. |
343 |
with self.wt.lock_tree_write(): |
|
7131.13.3
by Jelmer Vernooij
Fix python3 compatibility. |
344 |
(index, index_path) = self.wt._lookup_index(b'a') |
|
7183.2.1
by Martin
Fix E999 lint error for Python 2 flake8 |
345 |
index[b'a'] = IndexEntry(0, 0, 0, 0, S_IFGITLINK, 0, 0, 0, a.id, 0) |
|
7131.13.1
by Jelmer Vernooij
Don't show a delta for unchanged submodules. |
346 |
self.wt._index_dirty = True |
347 |
t = Tree() |
|
|
7183.2.1
by Martin
Fix E999 lint error for Python 2 flake8 |
348 |
t.add(b"a", S_IFGITLINK, a.id) |
|
7131.13.1
by Jelmer Vernooij
Don't show a delta for unchanged submodules. |
349 |
self.store.add_object(t) |
350 |
self.expectDelta([], tree_id=t.id) |
|
|
7452.1.1
by Jelmer Vernooij
Don't show submodules that are not checked out as deltas. |
351 |
|
352 |
def test_submodule_not_checked_out(self): |
|
353 |
a = Blob.from_string(b'irrelevant\n') |
|
354 |
with self.wt.lock_tree_write(): |
|
355 |
(index, index_path) = self.wt._lookup_index(b'a') |
|
356 |
index[b'a'] = IndexEntry(0, 0, 0, 0, S_IFGITLINK, 0, 0, 0, a.id, 0) |
|
357 |
self.wt._index_dirty = True |
|
358 |
os.mkdir(self.wt.abspath('a')) |
|
359 |
t = Tree() |
|
360 |
t.add(b"a", S_IFGITLINK, a.id) |
|
361 |
self.store.add_object(t) |
|
362 |
self.expectDelta([], tree_id=t.id) |