65
62
self.assertNotEqual(None, mismatch)
66
63
self.assertThat(mismatch.describe(), Equals("I am da tree is locked"))
69
class TestMatchesAncestry(TestCaseWithTransport):
71
def test__str__(self):
72
matcher = MatchesAncestry("A repository", "arevid")
74
"MatchesAncestry(repository='A repository', "
75
"revision_id='arevid')",
79
b = self.make_branch_builder('.')
81
revid1 = b.build_commit()
82
revid2 = b.build_commit()
84
branch = b.get_branch()
85
m = MatchesAncestry(branch.repository, revid2)
86
self.assertThat([revid2, revid1], m)
87
self.assertThat([revid1, revid2], m)
88
m = MatchesAncestry(branch.repository, revid1)
89
self.assertThat([revid1], m)
90
m = MatchesAncestry(branch.repository, "unknown")
91
self.assertThat(["unknown"], m)
93
def test_mismatch(self):
94
b = self.make_branch_builder('.')
96
revid1 = b.build_commit()
97
revid2 = b.build_commit()
99
branch = b.get_branch()
100
m = MatchesAncestry(branch.repository, revid1)
101
mismatch = m.match([])
102
self.assertIsNot(None, mismatch)
104
"mismatched ancestry for revision '%s' was ['%s'], expected []" % (
109
class TestHasLayout(TestCaseWithTransport):
111
def test__str__(self):
112
matcher = HasLayout([("a", "a-id")])
113
self.assertEqual("HasLayout([('a', 'a-id')])", str(matcher))
115
def test_match(self):
116
t = self.make_branch_and_tree('.')
117
self.build_tree(['a', 'b/', 'b/c'])
118
t.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id'])
119
self.assertThat(t, HasLayout(['', 'a', 'b/', 'b/c']))
120
self.assertThat(t, HasLayout(
121
[('', t.get_root_id()),
126
def test_mismatch(self):
127
t = self.make_branch_and_tree('.')
128
self.build_tree(['a', 'b/', 'b/c'])
129
t.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id'])
130
mismatch = HasLayout(['a']).match(t)
131
self.assertIsNot(None, mismatch)
133
"['a'] != [u'', u'a', u'b/', u'b/c']",
136
def test_no_dirs(self):
137
# Some tree/repository formats do not support versioned directories
138
t = self.make_branch_and_tree('.')
139
t.has_versioned_directories = lambda: False
140
self.build_tree(['a', 'b/', 'b/c'])
141
t.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id'])
142
self.assertIs(None, HasLayout(['', 'a', 'b/', 'b/c']).match(t))
143
self.assertIs(None, HasLayout(['', 'a', 'b/', 'b/c', 'd/']).match(t))
144
mismatch = HasLayout([u'', u'a', u'd/']).match(t)
145
self.assertIsNot(None, mismatch)
147
"[u'', u'a'] != [u'', u'a', u'b/', u'b/c']",