def test_suspend_multi(self): c = Connector() (doc, rev1, rev_s1) = self.createSuspendDoc() with c.update(doc, rev1) as w: w.writeAll('FILE', 'forward') w.commit() rev2 = w.getRev() with c.update(doc, rev2) as w: w.writeAll('FILE', 'Hail to the king, baby!') w.suspend() rev_s2 = w.getRev() l = c.lookup_doc(doc) self.assertEqual(l.revs(), [rev2]) self.assertEqual(len(l.preRevs()), 2) self.assertTrue(rev_s1 in l.preRevs()) self.assertTrue(rev_s2 in l.preRevs()) s = c.stat(rev_s1) self.assertEqual(s.parents(), [rev1]) s = c.stat(rev_s2) self.assertEqual(s.parents(), [rev2]) self.assertRevContent(rev1, {'FILE': 'ok'}) self.assertRevContent(rev_s1, {'FILE': 'update'}) self.assertRevContent(rev2, {'FILE': 'forward'}) self.assertRevContent(rev_s2, {'FILE': 'Hail to the king, baby!'})
def test_suspend_multi(self): c = Connector() (doc, rev1, rev_s1) = self.createSuspendDoc() with c.update(doc, rev1) as w: w.writeAll('FILE', 'forward') w.commit() rev2 = w.getRev() with c.update(doc, rev2) as w: w.writeAll('FILE', 'Hail to the king, baby!') w.suspend() rev_s2 = w.getRev() l = c.lookup_doc(doc) self.assertEqual(l.revs(), [rev2]) self.assertEqual(len(l.preRevs()), 2) self.assertTrue(rev_s1 in l.preRevs()) self.assertTrue(rev_s2 in l.preRevs()) s = c.stat(rev_s1) self.assertEqual(s.parents(), [rev1]) s = c.stat(rev_s2) self.assertEqual(s.parents(), [rev2]) self.assertRevContent(rev1, {'FILE' : 'ok'}) self.assertRevContent(rev_s1, {'FILE' : 'update'}) self.assertRevContent(rev2, {'FILE' : 'forward'}) self.assertRevContent(rev_s2, {'FILE' : 'Hail to the king, baby!'})
def test_update_change(self): c = Connector() w = self.create("public.data", "test.foo", [self.store1]) w.commit() doc = w.getDoc() rev1 = w.getRev() with c.update(doc, rev1, "test.baz") as w: w.commit() rev2 = w.getRev() s = c.stat(rev1) self.assertEqual(s.creator(), "test.foo") s = c.stat(rev2) self.assertEqual(s.creator(), "test.baz")
def test_fork(self): c = Connector() w = self.create("public.data", "test.foo", [self.store1]) w.commit() doc1 = w.getDoc() rev1 = w.getRev() w = self.fork(rev1, "test.bar") w.commit() doc2 = w.getDoc() rev2 = w.getRev() s = c.stat(rev1) self.assertEqual(s.creator(), "test.foo") s = c.stat(rev2) self.assertEqual(s.creator(), "test.bar")
def test_create_keep_handle(self): c = Connector() with c.create("public.data", "test.foo", [self.store1]) as w: w.commit() doc = w.getDoc() rev = w.getRev() # perform a GC cycle self.gc(self.store1) l = c.lookup_doc(doc) self.assertEqual(l.revs(), [rev]) self.assertEqual(l.preRevs(), []) c.stat(rev)
def test_update_keep(self): c = Connector() w = self.create("test.format.foo", "test.ignore", [self.store1]) self.assertEqual(w.getType(), "test.format.foo") w.commit() doc = w.getDoc() rev1 = w.getRev() with c.update(doc, rev1, "test.ignore") as w: self.assertEqual(w.getType(), "test.format.foo") w.write('FILE', 'update') w.commit() rev2 = w.getRev() s = c.stat(rev1) self.assertEqual(s.type(), "test.format.foo") s = c.stat(rev2) self.assertEqual(s.type(), "test.format.foo")
def test_create(self): c = Connector() w = self.create("test.format", "test.ignore", [self.store1]) self.assertEqual(w.getType(), "test.format") w.commit() doc = w.getDoc() rev = w.getRev() s = c.stat(rev) self.assertEqual(s.type(), "test.format")
def test_fork_change(self): c = Connector() w = self.create("test.format.foo", "test.ignore", [self.store1]) self.assertEqual(w.getType(), "test.format.foo") w.commit() doc1 = w.getDoc() rev1 = w.getRev() w = self.fork(rev1, "test.ignore") w.write('FILE', 'update') self.assertEqual(w.getType(), "test.format.foo") w.setType("test.format.bar") self.assertEqual(w.getType(), "test.format.bar") w.commit() doc2 = w.getDoc() rev2 = w.getRev() s = c.stat(rev1) self.assertEqual(s.type(), "test.format.foo") s = c.stat(rev2) self.assertEqual(s.type(), "test.format.bar")
def test_fork_keep_handle(self): c = Connector() w = self.create("test.format.foo", "test.ignore", [self.store1]) self.assertEqual(w.getType(), "test.format.foo") w.commit() doc1 = w.getDoc() rev1 = w.getRev() with c.fork(rev1, "test.ignore") as w: w.write('FILE', 'update') w.commit() doc2 = w.getDoc() rev2 = w.getRev() # perform a GC cycle self.gc(self.store1) l = c.lookup_doc(doc2) self.assertEqual(l.revs(), [rev2]) self.assertEqual(l.preRevs(), []) c.stat(rev2)
def test_resume_suspend_orig(self): c = Connector() (doc, rev1, rev2) = self.createSuspendDoc() with c.resume(doc, rev2) as w: w.suspend() rev3 = w.getRev() l = c.lookup_doc(doc) self.assertEqual(l.revs(), [rev1]) self.assertEqual(l.preRevs(), [rev3]) s = c.stat(rev3) self.assertEqual(s.parents(), [rev1]) self.assertRevContent(rev1, {'FILE' : 'ok'}) self.assertRevContent(rev3, {'FILE' : 'update'})
def test_resume_commit(self): c = Connector() (doc, rev1, rev2) = self.createSuspendDoc() with c.resume(doc, rev2) as w: w.writeAll('FILE', 'What are you waiting for, christmas?') w.commit() rev3 = w.getRev() l = c.lookup_doc(doc) self.assertEqual(l.revs(), [rev3]) self.assertEqual(len(l.preRevs()), 0) s = c.stat(rev3) self.assertEqual(s.parents(), [rev1]) self.assertRevContent(rev1, {'FILE' : 'ok'}) self.assertRevContent(rev3, {'FILE' : 'What are you waiting for, christmas?'})
def test_resume_suspend_orig(self): c = Connector() (doc, rev1, rev2) = self.createSuspendDoc() with c.resume(doc, rev2) as w: w.suspend() rev3 = w.getRev() l = c.lookup_doc(doc) self.assertEqual(l.revs(), [rev1]) self.assertEqual(l.preRevs(), [rev3]) s = c.stat(rev3) self.assertEqual(s.parents(), [rev1]) self.assertRevContent(rev1, {'FILE': 'ok'}) self.assertRevContent(rev3, {'FILE': 'update'})
def test_resume_commit(self): c = Connector() (doc, rev1, rev2) = self.createSuspendDoc() with c.resume(doc, rev2) as w: w.writeAll('FILE', 'What are you waiting for, christmas?') w.commit() rev3 = w.getRev() l = c.lookup_doc(doc) self.assertEqual(l.revs(), [rev3]) self.assertEqual(len(l.preRevs()), 0) s = c.stat(rev3) self.assertEqual(s.parents(), [rev1]) self.assertRevContent(rev1, {'FILE': 'ok'}) self.assertRevContent(rev3, {'FILE': 'What are you waiting for, christmas?'})