62
68
self.assertNotEqual(None, mismatch)
63
69
self.assertThat(mismatch.describe(), Equals("I am da tree is locked"))
72
class TestMatchesAncestry(TestCaseWithTransport):
74
def test__str__(self):
75
matcher = MatchesAncestry("A repository", "arevid")
77
"MatchesAncestry(repository='A repository', "
78
"revision_id='arevid')",
82
b = self.make_branch_builder('.')
84
revid1 = b.build_commit()
85
revid2 = b.build_commit()
87
branch = b.get_branch()
88
m = MatchesAncestry(branch.repository, revid2)
89
self.assertThat([revid2, revid1], m)
90
self.assertThat([revid1, revid2], m)
91
m = MatchesAncestry(branch.repository, revid1)
92
self.assertThat([revid1], m)
93
m = MatchesAncestry(branch.repository, "unknown")
94
self.assertThat(["unknown"], m)
96
def test_mismatch(self):
97
b = self.make_branch_builder('.')
99
revid1 = b.build_commit()
100
revid2 = b.build_commit()
102
branch = b.get_branch()
103
m = MatchesAncestry(branch.repository, revid1)
104
mismatch = m.match([])
105
self.assertIsNot(None, mismatch)
107
"mismatched ancestry for revision '%s' was ['%s'], expected []" % (
112
class TestHasLayout(TestCaseWithTransport):
114
def test__str__(self):
115
matcher = HasLayout([("a", "a-id")])
116
self.assertEqual("HasLayout([('a', 'a-id')])", str(matcher))
118
def test_match(self):
119
t = self.make_branch_and_tree('.')
120
self.build_tree(['a', 'b/', 'b/c'])
121
t.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id'])
122
self.assertThat(t, HasLayout(['', 'a', 'b/', 'b/c']))
123
self.assertThat(t, HasLayout(
124
[('', t.get_root_id()),
129
def test_mismatch(self):
130
t = self.make_branch_and_tree('.')
131
self.build_tree(['a', 'b/', 'b/c'])
132
t.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id'])
133
mismatch = HasLayout(['a']).match(t)
134
self.assertIsNot(None, mismatch)
136
"['a'] != [u'', u'a', u'b/', u'b/c']",
139
def test_no_dirs(self):
140
# Some tree/repository formats do not support versioned directories
141
t = self.make_branch_and_tree('.')
142
t.has_versioned_directories = lambda: False
143
self.build_tree(['a', 'b/', 'b/c'])
144
t.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id'])
145
self.assertIs(None, HasLayout(['', 'a', 'b/', 'b/c']).match(t))
146
self.assertIs(None, HasLayout(['', 'a', 'b/', 'b/c', 'd/']).match(t))
147
mismatch = HasLayout([u'', u'a', u'd/']).match(t)
148
self.assertIsNot(None, mismatch)
150
"[u'', u'a'] != [u'', u'a', u'b/', u'b/c']",
154
class TestContainsNoVfsCalls(TestCase):
156
def _make_call(self, method, args):
157
return CapturedCall(CallHookParams(method, args, None, None, None), 0)
159
def test__str__(self):
160
self.assertEqual("ContainsNoVfsCalls()", str(ContainsNoVfsCalls()))
162
def test_empty(self):
163
self.assertIs(None, ContainsNoVfsCalls().match([]))
165
def test_no_vfs_calls(self):
166
calls = [self._make_call("Branch.get_config_file", [])]
167
self.assertIs(None, ContainsNoVfsCalls().match(calls))
169
def test_ignores_unknown(self):
170
calls = [self._make_call("unknown", [])]
171
self.assertIs(None, ContainsNoVfsCalls().match(calls))
173
def test_match(self):
174
calls = [self._make_call("append", ["file"]),
175
self._make_call("Branch.get_config_file", [])]
176
mismatch = ContainsNoVfsCalls().match(calls)
177
self.assertIsNot(None, mismatch)
178
self.assertEquals([calls[0].call], mismatch.vfs_calls)
179
self.assertEquals("no VFS calls expected, got: append('file')""",
183
class TestRevisionHistoryMatches(TestCaseWithTransport):
185
def test_empty(self):
186
tree = self.make_branch_and_tree('.')
187
matcher = RevisionHistoryMatches([])
188
self.assertIs(None, matcher.match(tree.branch))
190
def test_matches(self):
191
tree = self.make_branch_and_tree('.')
192
tree.commit('msg1', rev_id='a')
193
tree.commit('msg2', rev_id='b')
194
matcher = RevisionHistoryMatches(['a', 'b'])
195
self.assertIs(None, matcher.match(tree.branch))
197
def test_mismatch(self):
198
tree = self.make_branch_and_tree('.')
199
tree.commit('msg1', rev_id='a')
200
tree.commit('msg2', rev_id='b')
201
matcher = RevisionHistoryMatches(['a', 'b', 'c'])
203
"['a', 'b', 'c'] != ['a', 'b']",
204
matcher.match(tree.branch).describe())