14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
from bzrlib.selftest import TestCaseInTempDir, TestCase
17
from bzrlib.selftest import TestCaseInTempDir
18
from bzrlib.revision import is_ancestor, MultipleRevisionSources
19
from bzrlib.revision import combined_graph
20
21
def make_branches():
21
22
from bzrlib.branch import Branch
22
23
from bzrlib.commit import commit
24
25
os.mkdir("branch1")
25
br1 = Branch("branch1", init=True)
26
br1 = Branch.initialize("branch1")
27
28
commit(br1, "Commit one", rev_id="a@u-0-0")
28
29
commit(br1, "Commit two", rev_id="a@u-0-1")
29
30
commit(br1, "Commit three", rev_id="a@u-0-2")
31
32
os.mkdir("branch2")
32
br2 = Branch("branch2", init=True)
33
br2 = Branch.initialize("branch2")
33
34
br2.update_revisions(br1)
34
35
commit(br2, "Commit four", rev_id="b@u-0-3")
35
36
commit(br2, "Commit five", rev_id="b@u-0-4")
209
211
self.assertEqual(common_ancestor(revisions_2[6], revisions[5], sources),
213
class TestCreateSignedRevision(TestCaseInTempDir):
215
def test_create_signed_revision(self):
217
# create a revision, sign it, apply to the store.
221
class TestOperators(TestCase):
223
def test___eq__(self):
224
from bzrlib.revision import Revision, RevisionReference
225
revision1 = Revision("invid", "sha", "revid", 100, "boo", "john", [])
226
revision2 = Revision("invid", "sha", "revid", 100, "boo", "john", [])
227
revision3 = Revision("invid", "sha", "rev2id", 100, "bp", "john",
228
[RevisionReference("revid")])
229
self.assertEqual(revision1, revision1)
230
self.assertEqual(revision1, revision2)
231
self.assertNotEqual(revision1, revision3)
232
self.assertEqual(revision2, revision1)
233
self.assertEqual(revision2, revision2)
234
self.assertNotEqual(revision2, revision3)
235
self.assertNotEqual(revision3, revision1)
236
self.assertNotEqual(revision3, revision2)
237
self.assertEqual(revision3, revision3)
239
def test__eq__reference(self):
240
from bzrlib.revision import Revision, RevisionReference
241
ref1 = RevisionReference('revid', '1'*40)
242
ref2 = RevisionReference('revid', '1'*40)
243
ref3 = RevisionReference('revid', '2'*40)
244
ref4 = RevisionReference('revid2', '3'*40)
245
self.assertEqual(ref1, ref1)
246
self.assertEqual(ref1, ref2)
247
self.assertNotEqual(ref1, ref3)
248
self.assertNotEqual(ref1, ref4)
249
self.assertEqual(ref2, ref1)
250
self.assertEqual(ref2, ref2)
251
self.assertNotEqual(ref2, ref3)
252
self.assertNotEqual(ref2, ref4)
253
self.assertNotEqual(ref3, ref1)
254
self.assertNotEqual(ref3, ref2)
255
self.assertEqual(ref3, ref3)
256
self.assertNotEqual(ref3, ref4)
257
self.assertNotEqual(ref4, ref1)
258
self.assertNotEqual(ref4, ref2)
259
self.assertNotEqual(ref4, ref3)
260
self.assertEqual(ref4, ref4)
214
def test_combined(self):
216
Ensure it's not order-sensitive
218
br1, br2 = make_branches()
219
source = MultipleRevisionSources(br1, br2)
220
combined_1 = combined_graph(br1.last_patch(), br2.last_patch(), source)
221
combined_2 = combined_graph(br2.last_patch(), br1.last_patch(), source)
222
assert combined_1[1] == combined_2[1]
223
assert combined_1[2] == combined_2[2]
224
assert combined_1[3] == combined_2[3]
225
assert combined_1 == combined_2