130
133
t.add(['a', 'b', 'b/c'], [b'a-id', b'b-id', b'c-id'])
131
134
mismatch = HasLayout(['a']).match(t)
132
135
self.assertIsNot(None, mismatch)
134
set(("['', 'a', 'b/', 'b/c']", "['a']")),
135
set(mismatch.describe().split(" != ")))
138
set(("['', 'a', 'b/', 'b/c']", "['a']")),
139
set(mismatch.describe().split(" != ")))
142
set(("[u'', u'a', u'b/', u'b/c']", "['a']")),
143
set(mismatch.describe().split(" != ")))
137
145
def test_no_dirs(self):
138
146
# Some tree/repository formats do not support versioned directories
144
152
self.assertIs(None, HasLayout(['', 'a', 'b/', 'b/c', 'd/']).match(t))
145
153
mismatch = HasLayout([u'', u'a', u'd/']).match(t)
146
154
self.assertIsNot(None, mismatch)
148
set(("['', 'a', 'b/', 'b/c']", "['', 'a']")),
149
set(mismatch.describe().split(" != ")))
157
set(("['', 'a', 'b/', 'b/c']", "['', 'a']")),
158
set(mismatch.describe().split(" != ")))
161
set(("[u'', u'a', u'b/', u'b/c']", "[u'', u'a']")),
162
set(mismatch.describe().split(" != ")))
152
165
class TestHasPathRelations(TestCaseWithTransport):
175
188
self.assertIsNot(None, mismatch)
191
class TestContainsNoVfsCalls(TestCase):
193
def _make_call(self, method, args):
194
return CapturedCall(CallHookParams(method, args, None, None, None), 0)
196
def test__str__(self):
197
self.assertEqual("ContainsNoVfsCalls()", str(ContainsNoVfsCalls()))
199
def test_empty(self):
200
self.assertIs(None, ContainsNoVfsCalls().match([]))
202
def test_no_vfs_calls(self):
203
calls = [self._make_call("Branch.get_config_file", [])]
204
self.assertIs(None, ContainsNoVfsCalls().match(calls))
206
def test_ignores_unknown(self):
207
calls = [self._make_call("unknown", [])]
208
self.assertIs(None, ContainsNoVfsCalls().match(calls))
210
def test_match(self):
211
calls = [self._make_call(b"append", [b"file"]),
212
self._make_call(b"Branch.get_config_file", [])]
213
mismatch = ContainsNoVfsCalls().match(calls)
214
self.assertIsNot(None, mismatch)
215
self.assertEqual([calls[0].call], mismatch.vfs_calls)
216
self.assertIn(mismatch.describe(), [
217
"no VFS calls expected, got: b'append'(b'file')",
218
"no VFS calls expected, got: append('file')"])
178
221
class TestRevisionHistoryMatches(TestCaseWithTransport):
180
223
def test_empty(self):
194
237
tree.commit('msg1', rev_id=b'a')
195
238
tree.commit('msg2', rev_id=b'b')
196
239
matcher = RevisionHistoryMatches([b'a', b'b', b'c'])
198
set(("[b'a', b'b']", "[b'a', b'b', b'c']")),
199
set(matcher.match(tree.branch).describe().split(" != ")))
242
set(("[b'a', b'b']", "[b'a', b'b', b'c']")),
243
set(matcher.match(tree.branch).describe().split(" != ")))
246
set(("['a', 'b']", "['a', 'b', 'c']")),
247
set(matcher.match(tree.branch).describe().split(" != ")))