本文整理汇总了Python中dulwich.server.ProtocolGraphWalker._is_satisfied方法的典型用法代码示例。如果您正苦于以下问题:Python ProtocolGraphWalker._is_satisfied方法的具体用法?Python ProtocolGraphWalker._is_satisfied怎么用?Python ProtocolGraphWalker._is_satisfied使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dulwich.server.ProtocolGraphWalker
的用法示例。
在下文中一共展示了ProtocolGraphWalker._is_satisfied方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProtocolGraphWalkerTestCase
# 需要导入模块: from dulwich.server import ProtocolGraphWalker [as 别名]
# 或者: from dulwich.server.ProtocolGraphWalker import _is_satisfied [as 别名]
class ProtocolGraphWalkerTestCase(TestCase):
def setUp(self):
super(ProtocolGraphWalkerTestCase, self).setUp()
# Create the following commit tree:
# 3---5
# /
# 1---2---4
commits = [
make_commit(id=ONE, parents=[], commit_time=111),
make_commit(id=TWO, parents=[ONE], commit_time=222),
make_commit(id=THREE, parents=[ONE], commit_time=333),
make_commit(id=FOUR, parents=[TWO], commit_time=444),
make_commit(id=FIVE, parents=[THREE], commit_time=555),
]
self._repo = MemoryRepo.init_bare(commits, {})
backend = DictBackend({'/': self._repo})
self._walker = ProtocolGraphWalker(
TestUploadPackHandler(backend, ['/', 'host=lolcats'], TestProto()),
self._repo.object_store, self._repo.get_peeled)
def test_is_satisfied_no_haves(self):
self.assertFalse(self._walker._is_satisfied([], ONE, 0))
self.assertFalse(self._walker._is_satisfied([], TWO, 0))
self.assertFalse(self._walker._is_satisfied([], THREE, 0))
def test_is_satisfied_have_root(self):
self.assertTrue(self._walker._is_satisfied([ONE], ONE, 0))
self.assertTrue(self._walker._is_satisfied([ONE], TWO, 0))
self.assertTrue(self._walker._is_satisfied([ONE], THREE, 0))
def test_is_satisfied_have_branch(self):
self.assertTrue(self._walker._is_satisfied([TWO], TWO, 0))
# wrong branch
self.assertFalse(self._walker._is_satisfied([TWO], THREE, 0))
def test_all_wants_satisfied(self):
self._walker.set_wants([FOUR, FIVE])
# trivial case: wants == haves
self.assertTrue(self._walker.all_wants_satisfied([FOUR, FIVE]))
# cases that require walking the commit tree
self.assertTrue(self._walker.all_wants_satisfied([ONE]))
self.assertFalse(self._walker.all_wants_satisfied([TWO]))
self.assertFalse(self._walker.all_wants_satisfied([THREE]))
self.assertTrue(self._walker.all_wants_satisfied([TWO, THREE]))
def test_split_proto_line(self):
allowed = ('want', 'done', None)
self.assertEqual(('want', ONE),
_split_proto_line('want %s\n' % ONE, allowed))
self.assertEqual(('want', TWO),
_split_proto_line('want %s\n' % TWO, allowed))
self.assertRaises(GitProtocolError, _split_proto_line,
'want xxxx\n', allowed)
self.assertRaises(UnexpectedCommandError, _split_proto_line,
'have %s\n' % THREE, allowed)
self.assertRaises(GitProtocolError, _split_proto_line,
'foo %s\n' % FOUR, allowed)
self.assertRaises(GitProtocolError, _split_proto_line, 'bar', allowed)
self.assertEqual(('done', None), _split_proto_line('done\n', allowed))
self.assertEqual((None, None), _split_proto_line('', allowed))
def test_determine_wants(self):
self.assertEqual([], self._walker.determine_wants({}))
self.assertEqual(None, self._walker.proto.get_received_line())
self._walker.proto.set_output([
'want %s multi_ack' % ONE,
'want %s' % TWO,
])
heads = {
'refs/heads/ref1': ONE,
'refs/heads/ref2': TWO,
'refs/heads/ref3': THREE,
}
self._repo.refs._update(heads)
self.assertEqual([ONE, TWO], self._walker.determine_wants(heads))
self._walker.advertise_refs = True
self.assertEqual([], self._walker.determine_wants(heads))
self._walker.advertise_refs = False
self._walker.proto.set_output(['want %s multi_ack' % FOUR])
self.assertRaises(GitProtocolError, self._walker.determine_wants, heads)
self._walker.proto.set_output([])
self.assertEqual([], self._walker.determine_wants(heads))
self._walker.proto.set_output(['want %s multi_ack' % ONE, 'foo'])
self.assertRaises(GitProtocolError, self._walker.determine_wants, heads)
self._walker.proto.set_output(['want %s multi_ack' % FOUR])
self.assertRaises(GitProtocolError, self._walker.determine_wants, heads)
def test_determine_wants_advertisement(self):
self._walker.proto.set_output([])
# advertise branch tips plus tag
heads = {
'refs/heads/ref4': FOUR,
'refs/heads/ref5': FIVE,
#.........这里部分代码省略.........
示例2: ProtocolGraphWalkerTestCase
# 需要导入模块: from dulwich.server import ProtocolGraphWalker [as 别名]
# 或者: from dulwich.server.ProtocolGraphWalker import _is_satisfied [as 别名]
class ProtocolGraphWalkerTestCase(TestCase):
def setUp(self):
# Create the following commit tree:
# 3---5
# /
# 1---2---4
self._objects = {
ONE: TestCommit(ONE, [], 111),
TWO: TestCommit(TWO, [ONE], 222),
THREE: TestCommit(THREE, [ONE], 333),
FOUR: TestCommit(FOUR, [TWO], 444),
FIVE: TestCommit(FIVE, [THREE], 555),
}
self._walker = ProtocolGraphWalker(
TestHandler(self._objects, TestProto()))
def test_is_satisfied_no_haves(self):
self.assertFalse(self._walker._is_satisfied([], ONE, 0))
self.assertFalse(self._walker._is_satisfied([], TWO, 0))
self.assertFalse(self._walker._is_satisfied([], THREE, 0))
def test_is_satisfied_have_root(self):
self.assertTrue(self._walker._is_satisfied([ONE], ONE, 0))
self.assertTrue(self._walker._is_satisfied([ONE], TWO, 0))
self.assertTrue(self._walker._is_satisfied([ONE], THREE, 0))
def test_is_satisfied_have_branch(self):
self.assertTrue(self._walker._is_satisfied([TWO], TWO, 0))
# wrong branch
self.assertFalse(self._walker._is_satisfied([TWO], THREE, 0))
def test_all_wants_satisfied(self):
self._walker.set_wants([FOUR, FIVE])
# trivial case: wants == haves
self.assertTrue(self._walker.all_wants_satisfied([FOUR, FIVE]))
# cases that require walking the commit tree
self.assertTrue(self._walker.all_wants_satisfied([ONE]))
self.assertFalse(self._walker.all_wants_satisfied([TWO]))
self.assertFalse(self._walker.all_wants_satisfied([THREE]))
self.assertTrue(self._walker.all_wants_satisfied([TWO, THREE]))
def test_read_proto_line(self):
self._walker.proto.set_output([
'want %s' % ONE,
'want %s' % TWO,
'have %s' % THREE,
'foo %s' % FOUR,
'bar',
'done',
])
self.assertEquals(('want', ONE), self._walker.read_proto_line())
self.assertEquals(('want', TWO), self._walker.read_proto_line())
self.assertEquals(('have', THREE), self._walker.read_proto_line())
self.assertRaises(GitProtocolError, self._walker.read_proto_line)
self.assertRaises(GitProtocolError, self._walker.read_proto_line)
self.assertEquals(('done', None), self._walker.read_proto_line())
self.assertEquals((None, None), self._walker.read_proto_line())
def test_determine_wants(self):
self.assertRaises(GitProtocolError, self._walker.determine_wants, {})
self._walker.proto.set_output([
'want %s multi_ack' % ONE,
'want %s' % TWO,
])
heads = {'ref1': ONE, 'ref2': TWO, 'ref3': THREE}
self.assertEquals([ONE, TWO], self._walker.determine_wants(heads))
self._walker.proto.set_output(['want %s multi_ack' % FOUR])
self.assertRaises(GitProtocolError, self._walker.determine_wants, heads)
self._walker.proto.set_output([])
self.assertEquals([], self._walker.determine_wants(heads))
self._walker.proto.set_output(['want %s multi_ack' % ONE, 'foo'])
self.assertRaises(GitProtocolError, self._walker.determine_wants, heads)
self._walker.proto.set_output(['want %s multi_ack' % FOUR])
self.assertRaises(GitProtocolError, self._walker.determine_wants, heads)
示例3: ProtocolGraphWalkerTestCase
# 需要导入模块: from dulwich.server import ProtocolGraphWalker [as 别名]
# 或者: from dulwich.server.ProtocolGraphWalker import _is_satisfied [as 别名]
class ProtocolGraphWalkerTestCase(TestCase):
def setUp(self):
# Create the following commit tree:
# 3---5
# /
# 1---2---4
self._objects = {
ONE: TestCommit(ONE, [], 111),
TWO: TestCommit(TWO, [ONE], 222),
THREE: TestCommit(THREE, [ONE], 333),
FOUR: TestCommit(FOUR, [TWO], 444),
FIVE: TestCommit(FIVE, [THREE], 555),
}
self._walker = ProtocolGraphWalker(
TestUploadPackHandler(self._objects, TestProto()),
self._objects, None)
def test_is_satisfied_no_haves(self):
self.assertFalse(self._walker._is_satisfied([], ONE, 0))
self.assertFalse(self._walker._is_satisfied([], TWO, 0))
self.assertFalse(self._walker._is_satisfied([], THREE, 0))
def test_is_satisfied_have_root(self):
self.assertTrue(self._walker._is_satisfied([ONE], ONE, 0))
self.assertTrue(self._walker._is_satisfied([ONE], TWO, 0))
self.assertTrue(self._walker._is_satisfied([ONE], THREE, 0))
def test_is_satisfied_have_branch(self):
self.assertTrue(self._walker._is_satisfied([TWO], TWO, 0))
# wrong branch
self.assertFalse(self._walker._is_satisfied([TWO], THREE, 0))
def test_all_wants_satisfied(self):
self._walker.set_wants([FOUR, FIVE])
# trivial case: wants == haves
self.assertTrue(self._walker.all_wants_satisfied([FOUR, FIVE]))
# cases that require walking the commit tree
self.assertTrue(self._walker.all_wants_satisfied([ONE]))
self.assertFalse(self._walker.all_wants_satisfied([TWO]))
self.assertFalse(self._walker.all_wants_satisfied([THREE]))
self.assertTrue(self._walker.all_wants_satisfied([TWO, THREE]))
def test_read_proto_line(self):
self._walker.proto.set_output([
'want %s' % ONE,
'want %s' % TWO,
'have %s' % THREE,
'foo %s' % FOUR,
'bar',
'done',
])
self.assertEquals(('want', ONE), self._walker.read_proto_line())
self.assertEquals(('want', TWO), self._walker.read_proto_line())
self.assertEquals(('have', THREE), self._walker.read_proto_line())
self.assertRaises(GitProtocolError, self._walker.read_proto_line)
self.assertRaises(GitProtocolError, self._walker.read_proto_line)
self.assertEquals(('done', None), self._walker.read_proto_line())
self.assertEquals((None, None), self._walker.read_proto_line())
def test_determine_wants(self):
self.assertRaises(GitProtocolError, self._walker.determine_wants, {})
self._walker.proto.set_output([
'want %s multi_ack' % ONE,
'want %s' % TWO,
])
heads = {'ref1': ONE, 'ref2': TWO, 'ref3': THREE}
self._walker.get_peeled = heads.get
self.assertEquals([ONE, TWO], self._walker.determine_wants(heads))
self._walker.proto.set_output(['want %s multi_ack' % FOUR])
self.assertRaises(GitProtocolError, self._walker.determine_wants, heads)
self._walker.proto.set_output([])
self.assertEquals([], self._walker.determine_wants(heads))
self._walker.proto.set_output(['want %s multi_ack' % ONE, 'foo'])
self.assertRaises(GitProtocolError, self._walker.determine_wants, heads)
self._walker.proto.set_output(['want %s multi_ack' % FOUR])
self.assertRaises(GitProtocolError, self._walker.determine_wants, heads)
def test_determine_wants_advertisement(self):
self._walker.proto.set_output([])
# advertise branch tips plus tag
heads = {'ref4': FOUR, 'ref5': FIVE, 'tag6': SIX}
peeled = {'ref4': FOUR, 'ref5': FIVE, 'tag6': FIVE}
self._walker.get_peeled = peeled.get
self._walker.determine_wants(heads)
lines = []
while True:
line = self._walker.proto.get_received_line()
if line == 'None':
break
# strip capabilities list if present
if '\x00' in line:
line = line[:line.index('\x00')]
lines.append(line.rstrip())
#.........这里部分代码省略.........
示例4: ProtocolGraphWalkerTestCase
# 需要导入模块: from dulwich.server import ProtocolGraphWalker [as 别名]
# 或者: from dulwich.server.ProtocolGraphWalker import _is_satisfied [as 别名]
class ProtocolGraphWalkerTestCase(TestCase):
def setUp(self):
super(ProtocolGraphWalkerTestCase, self).setUp()
# Create the following commit tree:
# 3---5
# /
# 1---2---4
commits = [
make_commit(id=ONE, parents=[], commit_time=111),
make_commit(id=TWO, parents=[ONE], commit_time=222),
make_commit(id=THREE, parents=[ONE], commit_time=333),
make_commit(id=FOUR, parents=[TWO], commit_time=444),
make_commit(id=FIVE, parents=[THREE], commit_time=555),
]
self._repo = MemoryRepo.init_bare(commits, {})
backend = DictBackend({"/": self._repo})
self._walker = ProtocolGraphWalker(
TestUploadPackHandler(backend, ["/", "host=lolcats"], TestProto()),
self._repo.object_store,
self._repo.get_peeled,
)
def test_is_satisfied_no_haves(self):
self.assertFalse(self._walker._is_satisfied([], ONE, 0))
self.assertFalse(self._walker._is_satisfied([], TWO, 0))
self.assertFalse(self._walker._is_satisfied([], THREE, 0))
def test_is_satisfied_have_root(self):
self.assertTrue(self._walker._is_satisfied([ONE], ONE, 0))
self.assertTrue(self._walker._is_satisfied([ONE], TWO, 0))
self.assertTrue(self._walker._is_satisfied([ONE], THREE, 0))
def test_is_satisfied_have_branch(self):
self.assertTrue(self._walker._is_satisfied([TWO], TWO, 0))
# wrong branch
self.assertFalse(self._walker._is_satisfied([TWO], THREE, 0))
def test_all_wants_satisfied(self):
self._walker.set_wants([FOUR, FIVE])
# trivial case: wants == haves
self.assertTrue(self._walker.all_wants_satisfied([FOUR, FIVE]))
# cases that require walking the commit tree
self.assertTrue(self._walker.all_wants_satisfied([ONE]))
self.assertFalse(self._walker.all_wants_satisfied([TWO]))
self.assertFalse(self._walker.all_wants_satisfied([THREE]))
self.assertTrue(self._walker.all_wants_satisfied([TWO, THREE]))
def test_split_proto_line(self):
allowed = ("want", "done", None)
self.assertEqual(("want", ONE), _split_proto_line("want %s\n" % ONE, allowed))
self.assertEqual(("want", TWO), _split_proto_line("want %s\n" % TWO, allowed))
self.assertRaises(GitProtocolError, _split_proto_line, "want xxxx\n", allowed)
self.assertRaises(UnexpectedCommandError, _split_proto_line, "have %s\n" % THREE, allowed)
self.assertRaises(GitProtocolError, _split_proto_line, "foo %s\n" % FOUR, allowed)
self.assertRaises(GitProtocolError, _split_proto_line, "bar", allowed)
self.assertEqual(("done", None), _split_proto_line("done\n", allowed))
self.assertEqual((None, None), _split_proto_line("", allowed))
def test_determine_wants(self):
self._walker.proto.set_output([None])
self.assertEqual([], self._walker.determine_wants({}))
self.assertEqual(None, self._walker.proto.get_received_line())
self._walker.proto.set_output(["want %s multi_ack" % ONE, "want %s" % TWO, None])
heads = {"refs/heads/ref1": ONE, "refs/heads/ref2": TWO, "refs/heads/ref3": THREE}
self._repo.refs._update(heads)
self.assertEqual([ONE, TWO], self._walker.determine_wants(heads))
self._walker.advertise_refs = True
self.assertEqual([], self._walker.determine_wants(heads))
self._walker.advertise_refs = False
self._walker.proto.set_output(["want %s multi_ack" % FOUR, None])
self.assertRaises(GitProtocolError, self._walker.determine_wants, heads)
self._walker.proto.set_output([None])
self.assertEqual([], self._walker.determine_wants(heads))
self._walker.proto.set_output(["want %s multi_ack" % ONE, "foo", None])
self.assertRaises(GitProtocolError, self._walker.determine_wants, heads)
self._walker.proto.set_output(["want %s multi_ack" % FOUR, None])
self.assertRaises(GitProtocolError, self._walker.determine_wants, heads)
def test_determine_wants_advertisement(self):
self._walker.proto.set_output([None])
# advertise branch tips plus tag
heads = {"refs/heads/ref4": FOUR, "refs/heads/ref5": FIVE, "refs/heads/tag6": SIX}
self._repo.refs._update(heads)
self._repo.refs._update_peeled(heads)
self._repo.refs._update_peeled({"refs/heads/tag6": FIVE})
self._walker.determine_wants(heads)
lines = []
while True:
line = self._walker.proto.get_received_line()
if line is None:
break
# strip capabilities list if present
if "\x00" in line:
line = line[: line.index("\x00")]
#.........这里部分代码省略.........