/brz/remove-bazaar

To get this branch, use:
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.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
20
import os
21
import stat
22
7467.4.2 by Jelmer Vernooij
Add some tests.
23
from dulwich import __version__ as dulwich_version
7490.124.3 by Jelmer Vernooij
Simplify InterTree handling.
24
from dulwich.diff_tree import RenameDetector, tree_changes
7131.13.1 by Jelmer Vernooij
Don't show a delta for unchanged submodules.
25
from dulwich.index import IndexEntry
7490.124.3 by Jelmer Vernooij
Simplify InterTree handling.
26
from dulwich.object_store import (
27
    OverlayObjectStore,
28
    )
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
29
from dulwich.objects import (
7131.13.1 by Jelmer Vernooij
Don't show a delta for unchanged submodules.
30
    S_IFGITLINK,
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
31
    Blob,
32
    Tree,
33
    ZERO_SHA,
34
    )
35
6986.2.1 by Jelmer Vernooij
Move breezy.plugins.git to breezy.git.
36
from ... import (
6977.1.2 by Jelmer Vernooij
Deal with missing files properly in 'bzr st'.
37
    conflicts as _mod_conflicts,
7131.3.1 by Jelmer Vernooij
When opening working trees with .git files, open the right control transport.
38
    workingtree as _mod_workingtree,
6977.1.2 by Jelmer Vernooij
Deal with missing files properly in 'bzr st'.
39
    )
6986.2.1 by Jelmer Vernooij
Move breezy.plugins.git to breezy.git.
40
from ...delta import TreeDelta
7490.120.3 by Jelmer Vernooij
Split out InventoryTreeChange from TreeChange.
41
from ...bzr.inventorytree import InventoryTreeChange as TreeChange
6977.1.2 by Jelmer Vernooij
Deal with missing files properly in 'bzr st'.
42
from ..mapping import (
43
    default_mapping,
44
    )
6973.1.1 by Jelmer Vernooij
Make InterIndexGitTree suitable for use with MemoryGitTree.
45
from ..tree import (
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
7490.124.3 by Jelmer Vernooij
Simplify InterTree handling.
57
def changes_between_git_tree_and_working_copy(source_store, from_tree_sha, target,
58
                                              want_unchanged=False,
59
                                              want_unversioned=False,
60
                                              rename_detector=None,
61
                                              include_trees=True):
62
    """Determine the changes between a git tree and a working tree with index.
63
64
    """
65
    to_tree_sha, extras = target.git_snapshot(want_unversioned=want_unversioned)
66
    store = OverlayObjectStore([source_store, target.store])
67
    return tree_changes(
68
        store, from_tree_sha, to_tree_sha, include_trees=include_trees,
69
        rename_detector=rename_detector,
70
        want_unchanged=want_unchanged, change_type_same=True), extras
71
72
0.262.1 by Jelmer Vernooij
Fix WorkingTree.conflicts().
73
class GitWorkingTreeTests(TestCaseWithTransport):
74
75
    def setUp(self):
76
        super(GitWorkingTreeTests, self).setUp()
77
        self.tree = self.make_branch_and_tree('.', format="git")
78
0.369.1 by Jelmer Vernooij
Implement conflict handling.
79
    def test_conflict_list(self):
0.369.2 by Jelmer Vernooij
Fix tests.
80
        self.assertIsInstance(
7143.15.2 by Jelmer Vernooij
Run autopep8.
81
            self.tree.conflicts(),
82
            _mod_conflicts.ConflictList)
0.369.1 by Jelmer Vernooij
Implement conflict handling.
83
84
    def test_add_conflict(self):
85
        self.build_tree(['conflicted'])
86
        self.tree.add(['conflicted'])
87
        with self.tree.lock_tree_write():
7143.15.2 by Jelmer Vernooij
Run autopep8.
88
            self.tree.index[b'conflicted'] = self.tree.index[b'conflicted'][:9] + \
89
                (FLAG_STAGEMASK, )
0.415.3 by Jelmer Vernooij
Open index on demand.
90
            self.tree._index_dirty = True
0.369.1 by Jelmer Vernooij
Implement conflict handling.
91
        conflicts = self.tree.conflicts()
92
        self.assertEqual(1, len(conflicts))
0.385.1 by Jelmer Vernooij
Use specific_files argument to Tree.iter_entries_by_dir.
93
94
    def test_revert_empty(self):
95
        self.build_tree(['a'])
96
        self.tree.add(['a'])
97
        self.assertTrue(self.tree.is_versioned('a'))
98
        self.tree.revert(['a'])
99
        self.assertFalse(self.tree.is_versioned('a'))
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
100
7065.1.1 by Jelmer Vernooij
Properly handle ignored directories in Git.
101
    def test_is_ignored_directory(self):
102
        self.assertFalse(self.tree.is_ignored('a'))
103
        self.build_tree(['a/'])
104
        self.assertFalse(self.tree.is_ignored('a'))
105
        self.build_tree_contents([('.gitignore', 'a\n')])
106
        self.tree._ignoremanager = None
107
        self.assertTrue(self.tree.is_ignored('a'))
108
        self.build_tree_contents([('.gitignore', 'a/\n')])
109
        self.tree._ignoremanager = None
110
        self.assertTrue(self.tree.is_ignored('a'))
111
7265.3.1 by Jelmer Vernooij
Properly ignore .git files.
112
    def test_add_submodule_dir(self):
113
        subtree = self.make_branch_and_tree('asub', format='git')
114
        subtree.commit('Empty commit')
115
        self.tree.add(['asub'])
116
        with self.tree.lock_read():
117
            entry = self.tree.index[b'asub']
118
            self.assertEqual(entry.mode, S_IFGITLINK)
119
        self.assertEqual([], list(subtree.unknowns()))
120
121
    def test_add_submodule_file(self):
122
        os.mkdir('.git/modules')
123
        subbranch = self.make_branch('.git/modules/asub', format='git-bare')
124
        os.mkdir('asub')
125
        with open('asub/.git', 'w') as f:
126
            f.write('gitdir: ../.git/modules/asub\n')
127
        subtree = _mod_workingtree.WorkingTree.open('asub')
128
        subtree.commit('Empty commit')
129
        self.tree.add(['asub'])
130
        with self.tree.lock_read():
131
            entry = self.tree.index[b'asub']
132
            self.assertEqual(entry.mode, S_IFGITLINK)
133
        self.assertEqual([], list(subtree.unknowns()))
134
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
135
7131.3.1 by Jelmer Vernooij
When opening working trees with .git files, open the right control transport.
136
class GitWorkingTreeFileTests(TestCaseWithTransport):
137
138
    def setUp(self):
139
        super(GitWorkingTreeFileTests, self).setUp()
140
        self.tree = self.make_branch_and_tree('actual', format="git")
7143.15.2 by Jelmer Vernooij
Run autopep8.
141
        self.build_tree_contents(
142
            [('linked/',), ('linked/.git', 'gitdir: ../actual/.git')])
7131.3.1 by Jelmer Vernooij
When opening working trees with .git files, open the right control transport.
143
        self.wt = _mod_workingtree.WorkingTree.open('linked')
144
145
    def test_add(self):
146
        self.build_tree(['linked/somefile'])
147
        self.wt.add(["somefile"])
148
        self.wt.commit("Add somefile")
149
150
6977.1.2 by Jelmer Vernooij
Deal with missing files properly in 'bzr st'.
151
class TreeDeltaFromGitChangesTests(TestCase):
152
153
    def test_empty(self):
154
        delta = TreeDelta()
155
        changes = []
156
        self.assertEqual(
157
            delta,
7358.13.1 by Jelmer Vernooij
Drop file id roundtripping support in Git.
158
            tree_delta_from_git_changes(changes, (default_mapping, default_mapping)))
6977.1.2 by Jelmer Vernooij
Deal with missing files properly in 'bzr st'.
159
160
    def test_missing(self):
161
        delta = TreeDelta()
7467.4.2 by Jelmer Vernooij
Add some tests.
162
        delta.removed.append(
163
            TreeChange(
164
                b'git:a', ('a', 'a'), False, (True, True),
165
                (b'TREE_ROOT', b'TREE_ROOT'), ('a', 'a'), ('file', None),
166
                (True, False)))
167
        changes = [
168
            ('remove',
169
                (b'a', stat.S_IFREG | 0o755, b'a' * 40),
170
                (b'a', 0, b'a' * 40))]
6977.1.2 by Jelmer Vernooij
Deal with missing files properly in 'bzr st'.
171
        self.assertEqual(
172
            delta,
7358.13.1 by Jelmer Vernooij
Drop file id roundtripping support in Git.
173
            tree_delta_from_git_changes(changes, (default_mapping, default_mapping)))
6977.1.2 by Jelmer Vernooij
Deal with missing files properly in 'bzr st'.
174
175
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
176
class ChangesBetweenGitTreeAndWorkingCopyTests(TestCaseWithTransport):
177
178
    def setUp(self):
179
        super(ChangesBetweenGitTreeAndWorkingCopyTests, self).setUp()
180
        self.wt = self.make_branch_and_tree('.', format='git')
7131.13.1 by Jelmer Vernooij
Don't show a delta for unchanged submodules.
181
        self.store = self.wt.branch.repository._git.object_store
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
182
183
    def expectDelta(self, expected_changes,
7131.13.1 by Jelmer Vernooij
Don't show a delta for unchanged submodules.
184
                    expected_extras=None, want_unversioned=False,
7467.4.2 by Jelmer Vernooij
Add some tests.
185
                    tree_id=None, rename_detector=None):
7131.13.1 by Jelmer Vernooij
Don't show a delta for unchanged submodules.
186
        if tree_id is None:
187
            try:
188
                tree_id = self.store[self.wt.branch.repository._git.head()].tree
189
            except KeyError:
190
                tree_id = None
0.415.3 by Jelmer Vernooij
Open index on demand.
191
        with self.wt.lock_read():
192
            changes, extras = changes_between_git_tree_and_working_copy(
7467.4.2 by Jelmer Vernooij
Add some tests.
193
                self.store, tree_id, self.wt, want_unversioned=want_unversioned,
194
                rename_detector=rename_detector)
0.415.3 by Jelmer Vernooij
Open index on demand.
195
            self.assertEqual(expected_changes, list(changes))
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
196
        if expected_extras is None:
197
            expected_extras = set()
198
        self.assertEqual(set(expected_extras), set(extras))
199
200
    def test_empty(self):
201
        self.expectDelta(
7467.4.2 by Jelmer Vernooij
Add some tests.
202
            [('add', (None, None, None), (b'', stat.S_IFDIR, Tree().id))])
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
203
204
    def test_added_file(self):
205
        self.build_tree(['a'])
206
        self.wt.add(['a'])
6973.13.2 by Jelmer Vernooij
Fix some more tests.
207
        a = Blob.from_string(b'contents of a\n')
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
208
        t = Tree()
6973.13.2 by Jelmer Vernooij
Fix some more tests.
209
        t.add(b"a", stat.S_IFREG | 0o644, a.id)
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
210
        self.expectDelta(
7467.4.2 by Jelmer Vernooij
Add some tests.
211
            [('add', (None, None, None), (b'', stat.S_IFDIR, t.id)),
212
             ('add', (None, None, None), (b'a', stat.S_IFREG | 0o644, a.id))])
213
214
    def test_renamed_file(self):
215
        self.build_tree(['a'])
216
        self.wt.add(['a'])
217
        self.wt.rename_one('a', 'b')
218
        a = Blob.from_string(b'contents of a\n')
219
        self.store.add_object(a)
220
        oldt = Tree()
221
        oldt.add(b"a", stat.S_IFREG | 0o644, a.id)
222
        self.store.add_object(oldt)
223
        newt = Tree()
224
        newt.add(b"b", stat.S_IFREG | 0o644, a.id)
225
        self.store.add_object(newt)
226
        self.expectDelta(
227
            [('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)),
228
             ('delete', (b'a', stat.S_IFREG | 0o644, a.id), (None, None, None)),
229
             ('add', (None, None, None), (b'b', stat.S_IFREG | 0o644, a.id)),
230
             ],
231
            tree_id=oldt.id)
232
        if dulwich_version >= (0, 19, 15):
233
            self.expectDelta(
234
                [('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)),
235
                 ('rename', (b'a', stat.S_IFREG | 0o644, a.id), (b'b', stat.S_IFREG | 0o644, a.id))],
236
                tree_id=oldt.id, rename_detector=RenameDetector(self.store))
237
238
    def test_copied_file(self):
239
        self.build_tree(['a'])
240
        self.wt.add(['a'])
241
        self.wt.copy_one('a', 'b')
242
        a = Blob.from_string(b'contents of a\n')
243
        self.store.add_object(a)
244
        oldt = Tree()
245
        oldt.add(b"a", stat.S_IFREG | 0o644, a.id)
246
        self.store.add_object(oldt)
247
        newt = Tree()
248
        newt.add(b"a", stat.S_IFREG | 0o644, a.id)
249
        newt.add(b"b", stat.S_IFREG | 0o644, a.id)
250
        self.store.add_object(newt)
251
        self.expectDelta(
252
            [('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)),
253
             ('add', (None, None, None), (b'b', stat.S_IFREG | 0o644, a.id)),
254
             ],
255
            tree_id=oldt.id)
256
257
        if dulwich_version >= (0, 19, 15):
258
            self.expectDelta(
259
                [('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)),
260
                 ('copy', (b'a', stat.S_IFREG | 0o644, a.id), (b'b', stat.S_IFREG | 0o644, a.id))],
261
                tree_id=oldt.id, rename_detector=RenameDetector(self.store, find_copies_harder=True))
262
            self.expectDelta(
263
                [('modify', (b'', stat.S_IFDIR, oldt.id), (b'', stat.S_IFDIR, newt.id)),
264
                 ('add', (None, None, None), (b'b', stat.S_IFREG | 0o644, a.id)),
265
                 ],
266
                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.
267
268
    def test_added_unknown_file(self):
269
        self.build_tree(['a'])
270
        t = Tree()
271
        self.expectDelta(
7467.4.2 by Jelmer Vernooij
Add some tests.
272
            [('add', (None, None, None), (b'', stat.S_IFDIR, t.id))])
6973.13.2 by Jelmer Vernooij
Fix some more tests.
273
        a = Blob.from_string(b'contents of a\n')
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
274
        t = Tree()
6973.13.2 by Jelmer Vernooij
Fix some more tests.
275
        t.add(b"a", stat.S_IFREG | 0o644, a.id)
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
276
        self.expectDelta(
7467.4.2 by Jelmer Vernooij
Add some tests.
277
            [('add', (None, None, None), (b'', stat.S_IFDIR, t.id)),
278
             ('add', (None, None, None), (b'a', stat.S_IFREG | 0o644, a.id))],
6973.13.2 by Jelmer Vernooij
Fix some more tests.
279
            [b'a'],
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
280
            want_unversioned=True)
281
282
    def test_missing_added_file(self):
283
        self.build_tree(['a'])
284
        self.wt.add(['a'])
285
        os.unlink('a')
6973.13.2 by Jelmer Vernooij
Fix some more tests.
286
        a = Blob.from_string(b'contents of a\n')
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
287
        t = Tree()
6973.13.2 by Jelmer Vernooij
Fix some more tests.
288
        t.add(b"a", 0, ZERO_SHA)
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
289
        self.expectDelta(
7467.4.2 by Jelmer Vernooij
Add some tests.
290
            [('add', (None, None, None), (b'', stat.S_IFDIR, t.id)),
291
             ('add', (None, None, None), (b'a', 0, ZERO_SHA))],
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
292
            [])
293
294
    def test_missing_versioned_file(self):
295
        self.build_tree(['a'])
296
        self.wt.add(['a'])
297
        self.wt.commit('')
298
        os.unlink('a')
6973.13.2 by Jelmer Vernooij
Fix some more tests.
299
        a = Blob.from_string(b'contents of a\n')
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
300
        oldt = Tree()
6973.13.2 by Jelmer Vernooij
Fix some more tests.
301
        oldt.add(b"a", stat.S_IFREG | 0o644, a.id)
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
302
        newt = Tree()
6973.13.2 by Jelmer Vernooij
Fix some more tests.
303
        newt.add(b"a", 0, ZERO_SHA)
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
304
        self.expectDelta(
7467.4.2 by Jelmer Vernooij
Add some tests.
305
            [('modify',
306
                (b'', stat.S_IFDIR, oldt.id),
307
                (b'', stat.S_IFDIR, newt.id)),
308
             ('modify',
309
                 (b'a', stat.S_IFREG | 0o644, a.id),
310
                 (b'a', 0, ZERO_SHA))])
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
311
312
    def test_versioned_replace_by_dir(self):
313
        self.build_tree(['a'])
314
        self.wt.add(['a'])
315
        self.wt.commit('')
316
        os.unlink('a')
317
        os.mkdir('a')
6973.13.2 by Jelmer Vernooij
Fix some more tests.
318
        olda = Blob.from_string(b'contents of a\n')
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
319
        oldt = Tree()
6973.13.2 by Jelmer Vernooij
Fix some more tests.
320
        oldt.add(b"a", stat.S_IFREG | 0o644, olda.id)
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
321
        newt = Tree()
322
        newa = Tree()
6973.13.2 by Jelmer Vernooij
Fix some more tests.
323
        newt.add(b"a", stat.S_IFDIR, newa.id)
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
324
        self.expectDelta([
7467.4.2 by Jelmer Vernooij
Add some tests.
325
            ('modify',
326
                (b'', stat.S_IFDIR, oldt.id),
327
                (b'', stat.S_IFDIR, newt.id)),
328
            ('modify',
329
                (b'a', stat.S_IFREG | 0o644, olda.id),
330
                (b'a', stat.S_IFDIR, newa.id))
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
331
            ], want_unversioned=False)
332
        self.expectDelta([
7467.4.2 by Jelmer Vernooij
Add some tests.
333
            ('modify',
334
                (b'', stat.S_IFDIR, oldt.id),
335
                (b'', stat.S_IFDIR, newt.id)),
336
            ('modify',
337
                (b'a', stat.S_IFREG | 0o644, olda.id),
338
                (b'a', stat.S_IFDIR, newa.id)),
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
339
            ], want_unversioned=True)
340
341
    def test_extra(self):
342
        self.build_tree(['a'])
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
343
        newa = Blob.from_string(b'contents of a\n')
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
344
        newt = Tree()
6973.13.2 by Jelmer Vernooij
Fix some more tests.
345
        newt.add(b"a", stat.S_IFREG | 0o644, newa.id)
0.391.7 by Jelmer Vernooij
Fix reporting of missing files in .iter_changes.
346
        self.expectDelta([
7467.4.2 by Jelmer Vernooij
Add some tests.
347
            ('add',
348
                (None, None, None),
349
                (b'', stat.S_IFDIR, newt.id)),
350
            ('add',
351
                (None, None, None),
352
                (b'a', stat.S_IFREG | 0o644, newa.id)),
6973.13.2 by Jelmer Vernooij
Fix some more tests.
353
            ], [b'a'], want_unversioned=True)
7131.13.1 by Jelmer Vernooij
Don't show a delta for unchanged submodules.
354
355
    def test_submodule(self):
7296.1.3 by Jelmer Vernooij
Fix submodule test.
356
        self.subtree = self.make_branch_and_tree('a', format="git")
7131.13.1 by Jelmer Vernooij
Don't show a delta for unchanged submodules.
357
        a = Blob.from_string(b'irrelevant\n')
7296.1.3 by Jelmer Vernooij
Fix submodule test.
358
        self.build_tree_contents([('a/.git/HEAD', a.id)])
7131.13.1 by Jelmer Vernooij
Don't show a delta for unchanged submodules.
359
        with self.wt.lock_tree_write():
7131.13.3 by Jelmer Vernooij
Fix python3 compatibility.
360
            (index, index_path) = self.wt._lookup_index(b'a')
7183.2.1 by Martin
Fix E999 lint error for Python 2 flake8
361
            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.
362
            self.wt._index_dirty = True
363
        t = Tree()
7183.2.1 by Martin
Fix E999 lint error for Python 2 flake8
364
        t.add(b"a", S_IFGITLINK, a.id)
7131.13.1 by Jelmer Vernooij
Don't show a delta for unchanged submodules.
365
        self.store.add_object(t)
366
        self.expectDelta([], tree_id=t.id)
7452.1.1 by Jelmer Vernooij
Don't show submodules that are not checked out as deltas.
367
368
    def test_submodule_not_checked_out(self):
369
        a = Blob.from_string(b'irrelevant\n')
370
        with self.wt.lock_tree_write():
371
            (index, index_path) = self.wt._lookup_index(b'a')
372
            index[b'a'] = IndexEntry(0, 0, 0, 0, S_IFGITLINK, 0, 0, 0, a.id, 0)
373
            self.wt._index_dirty = True
374
        os.mkdir(self.wt.abspath('a'))
375
        t = Tree()
376
        t.add(b"a", S_IFGITLINK, a.id)
377
        self.store.add_object(t)
378
        self.expectDelta([], tree_id=t.id)