118
118
def test_match(self):
119
119
t = self.make_branch_and_tree('.')
120
120
self.build_tree(['a', 'b/', 'b/c'])
121
t.add(['a', 'b', 'b/c'], [b'a-id', b'b-id', b'c-id'])
121
t.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id'])
122
122
self.assertThat(t, HasLayout(['', 'a', 'b/', 'b/c']))
123
123
self.assertThat(t, HasLayout(
124
124
[('', t.get_root_id()),
129
129
def test_mismatch(self):
130
130
t = self.make_branch_and_tree('.')
131
131
self.build_tree(['a', 'b/', 'b/c'])
132
t.add(['a', 'b', 'b/c'], [b'a-id', b'b-id', b'c-id'])
132
t.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id'])
133
133
mismatch = HasLayout(['a']).match(t)
134
134
self.assertIsNot(None, mismatch)
136
set(("[u'', u'a', u'b/', u'b/c']", "['a']")),
137
set(mismatch.describe().split(" != ")))
136
"['a'] != [u'', u'a', u'b/', u'b/c']",
139
139
def test_no_dirs(self):
140
140
# Some tree/repository formats do not support versioned directories
141
141
t = self.make_branch_and_tree('.')
142
142
t.has_versioned_directories = lambda: False
143
143
self.build_tree(['a', 'b/', 'b/c'])
144
t.add(['a', 'b', 'b/c'], [b'a-id', b'b-id', b'c-id'])
144
t.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id'])
145
145
self.assertIs(None, HasLayout(['', 'a', 'b/', 'b/c']).match(t))
146
146
self.assertIs(None, HasLayout(['', 'a', 'b/', 'b/c', 'd/']).match(t))
147
147
mismatch = HasLayout([u'', u'a', u'd/']).match(t)
148
148
self.assertIsNot(None, mismatch)
150
set(("[u'', u'a', u'b/', u'b/c']", "[u'', u'a']")),
151
set(mismatch.describe().split(" != ")))
154
class TestHasPathRelations(TestCaseWithTransport):
156
def test__str__(self):
157
t = self.make_branch_and_tree('.')
158
matcher = HasPathRelations(t, [("a", "b")])
159
self.assertEqual("HasPathRelations(%r, [('a', 'b')])" % t, str(matcher))
161
def test_match(self):
162
t = self.make_branch_and_tree('.')
163
self.build_tree(['a', 'b/', 'b/c'])
164
t.add(['a', 'b', 'b/c'])
165
self.assertThat(t, HasPathRelations(t,
171
def test_mismatch(self):
172
t = self.make_branch_and_tree('.')
173
self.build_tree(['a', 'b/', 'b/c'])
174
t.add(['a', 'b', 'b/c'])
175
mismatch = HasPathRelations(t, [('a', 'a')]).match(t)
176
self.assertIsNot(None, mismatch)
150
"[u'', u'a'] != [u'', u'a', u'b/', u'b/c']",
179
154
class TestContainsNoVfsCalls(TestCase):
215
190
def test_matches(self):
216
191
tree = self.make_branch_and_tree('.')
217
tree.commit('msg1', rev_id=b'a')
218
tree.commit('msg2', rev_id=b'b')
192
tree.commit('msg1', rev_id='a')
193
tree.commit('msg2', rev_id='b')
219
194
matcher = RevisionHistoryMatches(['a', 'b'])
220
195
self.assertIs(None, matcher.match(tree.branch))
222
197
def test_mismatch(self):
223
198
tree = self.make_branch_and_tree('.')
224
tree.commit('msg1', rev_id=b'a')
225
tree.commit('msg2', rev_id=b'b')
199
tree.commit('msg1', rev_id='a')
200
tree.commit('msg2', rev_id='b')
226
201
matcher = RevisionHistoryMatches(['a', 'b', 'c'])
228
set(("['a', 'b']", "['a', 'b', 'c']")),
229
set(matcher.match(tree.branch).describe().split(" != ")))
203
"['a', 'b', 'c'] != ['a', 'b']",
204
matcher.match(tree.branch).describe())