33
33
class TestGitShaMap:
35
35
def test_commit(self):
36
self.map.add_entry("5686645d49063c73d35436192dfc9a160c672301",
36
self.map.start_write_group()
37
self.map._add_entry("5686645d49063c73d35436192dfc9a160c672301",
37
38
"commit", ("myrevid", "cc9462f7f8263ef5adfbeff2fb936bb36b504cba"))
39
self.map.commit_write_group()
39
41
("commit", ("myrevid", "cc9462f7f8263ef5adfbeff2fb936bb36b504cba")),
40
42
self.map.lookup_git_sha("5686645d49063c73d35436192dfc9a160c672301"))
42
44
def test_lookup_notfound(self):
43
self.assertRaises(KeyError,
45
self.assertRaises(KeyError,
44
46
self.map.lookup_git_sha, "5686645d49063c73d35436192dfc9a160c672301")
46
48
def test_blob(self):
47
49
thesha = "5686645d49063c73d35436192dfc9a160c672301"
48
self.map.add_entry(thesha, "blob", ("myfileid", "myrevid"))
50
self.map.start_write_group()
51
self.map._add_entry(thesha, "blob", ("myfileid", "myrevid"))
52
self.map.commit_write_group()
50
54
("blob", ("myfileid", "myrevid")),
51
55
self.map.lookup_git_sha(thesha))
52
self.assertEquals(thesha, self.map.lookup_blob("myfileid", "myrevid"))
56
invshamap = self.map.get_inventory_sha_map("myrevid")
57
self.assertEquals(thesha, invshamap.lookup_blob("myfileid"))
54
59
def test_tree(self):
55
60
thesha = "5686645d49063c73d35436192dfc9a160c672301"
56
self.map.add_entry(thesha,
61
self.map.start_write_group()
62
self.map._add_entry(thesha,
57
63
"tree", ("somepath", "myrevid"))
64
self.map.commit_write_group()
59
66
("tree", ("somepath", "myrevid")),
60
67
self.map.lookup_git_sha(thesha))
61
self.assertEquals(thesha, self.map.lookup_tree("somepath", "myrevid"))
63
69
def test_revids(self):
64
self.map.add_entry("5686645d49063c73d35436192dfc9a160c672301",
70
self.map.start_write_group()
71
self.map._add_entry("5686645d49063c73d35436192dfc9a160c672301",
65
72
"commit", ("myrevid", "cc9462f7f8263ef5adfbeff2fb936bb36b504cba"))
73
self.map.commit_write_group()
66
74
self.assertEquals(["myrevid"], list(self.map.revids()))
76
def test_missing_revisions(self):
77
self.map.start_write_group()
78
self.map._add_entry("5686645d49063c73d35436192dfc9a160c672301",
79
"commit", ("myrevid", "cc9462f7f8263ef5adfbeff2fb936bb36b504cba"))
80
self.map.commit_write_group()
81
self.assertEquals(set(["lala", "bla"]),
82
set(self.map.missing_revisions(["myrevid", "lala", "bla"])))
69
85
class DictGitShaMapTests(TestCase,TestGitShaMap):