当前位置: 首页>>代码示例>>Python>>正文


Python Connector.preRevs方法代码示例

本文整理汇总了Python中peerdrive.Connector.preRevs方法的典型用法代码示例。如果您正苦于以下问题:Python Connector.preRevs方法的具体用法?Python Connector.preRevs怎么用?Python Connector.preRevs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在peerdrive.Connector的用法示例。


在下文中一共展示了Connector.preRevs方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_transitive_keep

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import preRevs [as 别名]
	def test_transitive_keep(self):
		with Connector().create(self.store1, "public.data", "test.ignore") as w1:
			with Connector().create(self.store1, "public.data", "test.ignore") as w2:
				w2.write('FILE', 'test')
				w2.commit()
				doc2 = w2.getDoc()
				rev2 = w2.getRev()

				# create a reference from w1 to w2
				w1.write('PDSD', struct.dumps([struct.DocLink(self.store2, doc2)]))
				w1.commit()
				doc1 = w1.getDoc()
				rev1 = w1.getRev()

			# w2 is closed now, w1 still open, should prevent gc
			self.gc(self.store1)

			l = Connector().lookupDoc(doc1)
			self.assertEqual(l.revs(), [rev1])
			self.assertEqual(l.preRevs(), [])
			self.assertEqual(Connector().lookupRev(rev1), [self.store1])
			l = Connector().lookupDoc(doc2)
			self.assertEqual(l.revs(), [rev2])
			self.assertEqual(l.preRevs(), [])
			self.assertEqual(Connector().lookupRev(rev2), [self.store1])
开发者ID:wizzk42,项目名称:peerdrive,代码行数:27,代码来源:tests.py

示例2: test_suspend_multi

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import preRevs [as 别名]
	def test_suspend_multi(self):
		(doc, rev1, rev_s1) = self.createSuspendDoc()

		with Connector().update(self.store1, doc, rev1) as w:
			w.writeAll('FILE', 'forward')
			w.commit()
			rev2 = w.getRev()

		with Connector().update(self.store1, doc, rev2) as w:
			w.writeAll('FILE', 'Hail to the king, baby!')
			w.suspend()
			rev_s2 = w.getRev()

		l = Connector().lookupDoc(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 = Connector().stat(rev_s1)
		self.assertEqual(s.parents(), [rev1])
		s = Connector().stat(rev_s2)
		self.assertEqual(s.parents(), [rev2])

		self.assertRevContent(self.store1, rev1, {'FILE' : 'ok'})
		self.assertRevContent(self.store1, rev_s1, {'FILE' : 'update'})
		self.assertRevContent(self.store1, rev2, {'FILE' : 'forward'})
		self.assertRevContent(self.store1, rev_s2, {'FILE' : 'Hail to the king, baby!'})
开发者ID:wizzk42,项目名称:peerdrive,代码行数:30,代码来源:tests.py

示例3: test_resume_abort

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import preRevs [as 别名]
	def test_resume_abort(self):
		(doc, rev1, rev2) = self.createSuspendDoc()

		with Connector().resume(self.store1, doc, rev2) as w:
			w.writeAll('FILE', 'Hail to the king, baby!')

			l = Connector().lookupDoc(doc)
			self.assertEqual(l.revs(), [rev1])
			self.assertEqual(l.preRevs(), [rev2])

			w.close()

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [rev1])
		self.assertEqual(l.preRevs(), [rev2])
		self.assertRevContent(self.store1, rev1, {'FILE' : 'ok'})
		self.assertRevContent(self.store1, rev2, {'FILE' : 'update'})
开发者ID:wizzk42,项目名称:peerdrive,代码行数:19,代码来源:tests.py

示例4: test_suspend

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import preRevs [as 别名]
	def test_suspend(self):
		(doc, rev1, rev2) = self.createSuspendDoc()

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [rev1])
		self.assertEqual(l.preRevs(), [rev2])
		self.assertRevContent(self.store1, rev1, {'FILE' : 'ok'})
		self.assertRevContent(self.store1, rev2, {'FILE' : 'update'})
开发者ID:wizzk42,项目名称:peerdrive,代码行数:10,代码来源:tests.py

示例5: test_resume_wrong

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import preRevs [as 别名]
	def test_resume_wrong(self):
		(doc, rev1, rev2) = self.createSuspendDoc()
		self.assertRaises(IOError, Connector().resume, self.store1, doc, rev1)

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [rev1])
		self.assertEqual(l.preRevs(), [rev2])
		self.assertRevContent(self.store1, rev1, {'FILE' : 'ok'})
		self.assertRevContent(self.store1, rev2, {'FILE' : 'update'})
开发者ID:wizzk42,项目名称:peerdrive,代码行数:11,代码来源:tests.py

示例6: test_create_keep_handle

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import preRevs [as 别名]
	def test_create_keep_handle(self):
		with Connector().create(self.store1, "public.data", "test.ignore") as w:
			w.commit()
			doc = w.getDoc()
			rev = w.getRev()

			# perform a GC cycle
			self.gc(self.store1)

			l = Connector().lookupDoc(doc)
			self.assertEqual(l.revs(), [rev])
			self.assertEqual(l.preRevs(), [])

			Connector().stat(rev)
开发者ID:wizzk42,项目名称:peerdrive,代码行数:16,代码来源:tests.py

示例7: test_collect

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import preRevs [as 别名]
	def test_collect(self):
		# deliberately close handle after creating!
		with Connector().create(self.store1, "public.data", "test.ignore") as w:
			w.commit()
			doc = w.getDoc()
			rev = w.getRev()

		# perform a GC cycle
		self.gc(self.store1)

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [])
		self.assertEqual(l.preRevs(), [])
		self.assertRaises(IOError, Connector().stat, rev)
开发者ID:wizzk42,项目名称:peerdrive,代码行数:16,代码来源:tests.py

示例8: test_resume_suspend_orig

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import preRevs [as 别名]
	def test_resume_suspend_orig(self):
		(doc, rev1, rev2) = self.createSuspendDoc()

		with Connector().resume(self.store1, doc, rev2) as w:
			w.suspend()
			rev3 = w.getRev()

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [rev1])
		self.assertEqual(l.preRevs(), [rev3])

		s = Connector().stat(rev3)
		self.assertEqual(s.parents(), [rev1])

		self.assertRevContent(self.store1, rev1, {'FILE' : 'ok'})
		self.assertRevContent(self.store1, rev3, {'FILE' : 'update'})
开发者ID:wizzk42,项目名称:peerdrive,代码行数:18,代码来源:tests.py

示例9: test_resume_commit

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import preRevs [as 别名]
	def test_resume_commit(self):
		(doc, rev1, rev2) = self.createSuspendDoc()

		with Connector().resume(self.store1, doc, rev2) as w:
			w.writeAll('FILE', 'What are you waiting for, christmas?')
			w.commit()
			rev3 = w.getRev()

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [rev3])
		self.assertEqual(len(l.preRevs()), 0)

		s = Connector().stat(rev3)
		self.assertEqual(s.parents(), [rev1])
		self.assertRevContent(self.store1, rev1, {'FILE' : 'ok'})
		self.assertRevContent(self.store1, rev3, {'FILE' : 'What are you waiting for, christmas?'})
开发者ID:wizzk42,项目名称:peerdrive,代码行数:18,代码来源:tests.py

示例10: test_resume_suspend_mod

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import preRevs [as 别名]
    def test_resume_suspend_mod(self):
        (doc, rev1, rev2) = self.createSuspendDoc()

        with Connector().resume(self.store1, doc, rev2) as w:
            w.writeAll("FILE", "What are you waiting for, christmas?")
            w.suspend()
            rev3 = w.getRev()

        l = Connector().lookupDoc(doc)
        self.assertEqual(l.revs(), [rev1])
        self.assertEqual(l.preRevs(), [rev3])

        s = Connector().stat(rev3)
        self.assertEqual(s.parents(), [rev1])

        self.assertRevContent(self.store1, rev1, {"FILE": "ok"})
        self.assertRevContent(self.store1, rev3, {"FILE": "What are you waiting for, christmas?"})
开发者ID:peerdrive,项目名称:peerdrive,代码行数:19,代码来源:tests.py

示例11: test_forget

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import preRevs [as 别名]
	def test_forget(self):
		(doc, rev1, rev_s1) = self.createSuspendDoc()

		with Connector().update(self.store1, doc, rev1) as w:
			w.writeAll('FILE', 'forward')
			w.commit()
			rev2 = w.getRev()

		with Connector().update(self.store1, doc, rev2) as w:
			w.writeAll('FILE', 'Hail to the king, baby!')
			w.suspend()
			rev_s2 = w.getRev()

		self.assertRaises(IOError, Connector().forget, self.store1, doc, rev1)
		Connector().forget(self.store1, doc, rev_s1)

		l = Connector().lookupDoc(doc)
		self.assertEqual(l.revs(), [rev2])
		self.assertEqual(l.preRevs(), [rev_s2])
开发者ID:wizzk42,项目名称:peerdrive,代码行数:21,代码来源:tests.py

示例12: test_fork_keep_handle

# 需要导入模块: from peerdrive import Connector [as 别名]
# 或者: from peerdrive.Connector import preRevs [as 别名]
	def test_fork_keep_handle(self):
		w = self.create(self.store1, "test.format.foo")
		self.assertEqual(w.getType(), "test.format.foo")
		w.commit()
		doc1 = w.getDoc()
		rev1 = w.getRev()

		with Connector().fork(self.store1, 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 = Connector().lookupDoc(doc2)
			self.assertEqual(l.revs(), [rev2])
			self.assertEqual(l.preRevs(), [])
			Connector().stat(rev2)
开发者ID:wizzk42,项目名称:peerdrive,代码行数:22,代码来源:tests.py


注:本文中的peerdrive.Connector.preRevs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。