91
91
def test_missing(self):
92
92
delta = TreeDelta()
93
delta.removed.append(('a', 'a-id', 'file'))
94
changes = [(('a', 'a'), (stat.S_IFREG | 0o755, 0), ('a' * 40, 'a' * 40))]
93
delta.removed.append(('a', b'a-id', 'file'))
94
changes = [(('a', 'a'), (stat.S_IFREG | 0o755, 0), (b'a' * 40, b'a' * 40))]
97
97
tree_delta_from_git_changes(changes, default_mapping,
98
(GitFileIdMap({'a': 'a-id'}, default_mapping),
99
GitFileIdMap({'a': 'a-id'}, default_mapping))))
98
(GitFileIdMap({'a': b'a-id'}, default_mapping),
99
GitFileIdMap({'a': b'a-id'}, default_mapping))))
102
102
class ChangesBetweenGitTreeAndWorkingCopyTests(TestCaseWithTransport):
127
127
def test_added_file(self):
128
128
self.build_tree(['a'])
129
129
self.wt.add(['a'])
130
a = Blob.from_string('contents of a\n')
130
a = Blob.from_string(b'contents of a\n')
132
t.add("a", stat.S_IFREG | 0o644, a.id)
132
t.add(b"a", stat.S_IFREG | 0o644, a.id)
133
133
self.expectDelta(
134
[((None, ''), (None, stat.S_IFDIR), (None, t.id)),
135
((None, 'a'), (None, stat.S_IFREG | 0o644), (None, a.id))])
134
[((None, b''), (None, stat.S_IFDIR), (None, t.id)),
135
((None, b'a'), (None, stat.S_IFREG | 0o644), (None, a.id))])
137
137
def test_added_unknown_file(self):
138
138
self.build_tree(['a'])
140
140
self.expectDelta(
141
[((None, ''), (None, stat.S_IFDIR), (None, t.id))])
142
a = Blob.from_string('contents of a\n')
141
[((None, b''), (None, stat.S_IFDIR), (None, t.id))])
142
a = Blob.from_string(b'contents of a\n')
144
t.add("a", stat.S_IFREG | 0o644, a.id)
144
t.add(b"a", stat.S_IFREG | 0o644, a.id)
145
145
self.expectDelta(
146
[((None, ''), (None, stat.S_IFDIR), (None, t.id)),
147
((None, 'a'), (None, stat.S_IFREG | 0o644), (None, a.id))],
146
[((None, b''), (None, stat.S_IFDIR), (None, t.id)),
147
((None, b'a'), (None, stat.S_IFREG | 0o644), (None, a.id))],
149
149
want_unversioned=True)
151
151
def test_missing_added_file(self):
152
152
self.build_tree(['a'])
153
153
self.wt.add(['a'])
155
a = Blob.from_string('contents of a\n')
155
a = Blob.from_string(b'contents of a\n')
157
t.add("a", 0, ZERO_SHA)
157
t.add(b"a", 0, ZERO_SHA)
158
158
self.expectDelta(
159
[((None, ''), (None, stat.S_IFDIR), (None, t.id)),
160
((None, 'a'), (None, 0), (None, ZERO_SHA))],
159
[((None, b''), (None, stat.S_IFDIR), (None, t.id)),
160
((None, b'a'), (None, 0), (None, ZERO_SHA))],
163
163
def test_missing_versioned_file(self):
165
165
self.wt.add(['a'])
166
166
self.wt.commit('')
168
a = Blob.from_string('contents of a\n')
168
a = Blob.from_string(b'contents of a\n')
170
oldt.add("a", stat.S_IFREG | 0o644, a.id)
170
oldt.add(b"a", stat.S_IFREG | 0o644, a.id)
172
newt.add("a", 0, ZERO_SHA)
172
newt.add(b"a", 0, ZERO_SHA)
173
173
self.expectDelta(
174
[(('', ''), (stat.S_IFDIR, stat.S_IFDIR), (oldt.id, newt.id)),
175
(('a', 'a'), (stat.S_IFREG|0o644, 0), (a.id, ZERO_SHA))])
174
[((b'', b''), (stat.S_IFDIR, stat.S_IFDIR), (oldt.id, newt.id)),
175
((b'a', b'a'), (stat.S_IFREG|0o644, 0), (a.id, ZERO_SHA))])
177
177
def test_versioned_replace_by_dir(self):
178
178
self.build_tree(['a'])
180
180
self.wt.commit('')
183
olda = Blob.from_string('contents of a\n')
183
olda = Blob.from_string(b'contents of a\n')
185
oldt.add("a", stat.S_IFREG | 0o644, olda.id)
185
oldt.add(b"a", stat.S_IFREG | 0o644, olda.id)
188
newt.add("a", stat.S_IFDIR, newa.id)
188
newt.add(b"a", stat.S_IFDIR, newa.id)
189
189
self.expectDelta([
191
191
(stat.S_IFDIR, stat.S_IFDIR),
192
192
(oldt.id, newt.id)),
193
(('a', 'a'), (stat.S_IFREG | 0o644, stat.S_IFDIR), (olda.id, newa.id))
193
((b'a', b'a'), (stat.S_IFREG | 0o644, stat.S_IFDIR), (olda.id, newa.id))
194
194
], want_unversioned=False)
195
195
self.expectDelta([
197
197
(stat.S_IFDIR, stat.S_IFDIR),
198
198
(oldt.id, newt.id)),
199
(('a', 'a'), (stat.S_IFREG | 0o644, stat.S_IFDIR), (olda.id, newa.id))
199
((b'a', b'a'), (stat.S_IFREG | 0o644, stat.S_IFDIR), (olda.id, newa.id))
200
200
], want_unversioned=True)
202
202
def test_extra(self):
203
203
self.build_tree(['a'])
204
204
newa = Blob.from_string(b'contents of a\n')
206
newt.add("a", stat.S_IFREG | 0o644, newa.id)
206
newt.add(b"a", stat.S_IFREG | 0o644, newa.id)
207
207
self.expectDelta([
209
209
(None, stat.S_IFDIR),
210
210
(None, newt.id)),
211
((None, 'a'), (None, stat.S_IFREG | 0o644), (None, newa.id))
212
], ['a'], want_unversioned=True)
211
((None, b'a'), (None, stat.S_IFREG | 0o644), (None, newa.id))
212
], [b'a'], want_unversioned=True)