70
65
self.map.start_write_group()
71
66
updater = self.cache.get_updater(Revision("myrevid"))
72
67
c = self._get_test_commit()
73
updater.add_object(c, {
74
"testament3-sha1": "cc9462f7f8263ef5adf8eff2fb936bb36b504cba"},
68
updater.add_object(c, None)
77
70
self.map.commit_write_group()
79
("commit", ("myrevid",
80
"cc9462f7f8263ef5adfbeff2fb936bb36b504cba",
81
{"testament3-sha1": "cc9462f7f8263ef5adf8eff2fb936bb36b504cba"},
72
("commit", ("myrevid", "cc9462f7f8263ef5adfbeff2fb936bb36b504cba")),
83
73
self.map.lookup_git_sha(c.id))
84
74
self.assertEquals(c.id, self.map.lookup_commit("myrevid"))
90
80
def test_blob(self):
91
81
self.map.start_write_group()
92
82
updater = self.cache.get_updater(Revision("myrevid"))
93
updater.add_object(self._get_test_commit(), { "testament3-sha1": "Test" }, None)
83
updater.add_object(self._get_test_commit(), None)
95
85
b.data = "TEH BLOB"
96
86
ie = InventoryFile("myfileid", "somename", ROOT_ID)
97
87
ie.revision = "myrevid"
98
updater.add_object(b, ie, None)
88
updater.add_object(b, ie)
100
90
self.map.commit_write_group()
101
91
self.assertEquals(
107
97
def test_tree(self):
108
98
self.map.start_write_group()
109
99
updater = self.cache.get_updater(Revision("myrevid"))
110
updater.add_object(self._get_test_commit(), {
111
"testament3-sha1": "mytestamentsha" }, None)
100
updater.add_object(self._get_test_commit(), None)
113
102
t.add(stat.S_IFREG, "somename", Blob().id)
114
103
ie = InventoryDirectory("fileid", "myname", ROOT_ID)
115
104
ie.revision = "irrelevant"
116
updater.add_object(t, ie, "")
105
updater.add_object(t, ie)
118
107
self.map.commit_write_group()
119
108
self.assertEquals(("tree", ("fileid", "myrevid")),
120
109
self.map.lookup_git_sha(t.id))
121
# It's possible for a backend to not implement lookup_tree
123
self.assertEquals(t.id,
124
self.map.lookup_tree_id("fileid", "myrevid"))
125
except NotImplementedError:
128
111
def test_revids(self):
129
112
self.map.start_write_group()
130
113
updater = self.cache.get_updater(Revision("myrevid"))
131
114
c = self._get_test_commit()
132
updater.add_object(c, {"testament3-sha1": "mtestament"}, None)
115
updater.add_object(c, None)
134
117
self.map.commit_write_group()
135
118
self.assertEquals(["myrevid"], list(self.map.revids()))
138
121
self.map.start_write_group()
139
122
updater = self.cache.get_updater(Revision("myrevid"))
140
123
c = self._get_test_commit()
141
updater.add_object(c, {"testament3-sha1": "testament"}, None)
124
updater.add_object(c, None)
143
126
self.map.commit_write_group()
144
127
self.assertEquals(set(["lala", "bla"]),
170
153
except ImportError:
171
154
raise UnavailableFeature("Missing tdb")
172
155
self.map = self.cache.idmap
175
class IndexGitShaMapTests(TestCaseInTempDir,TestGitShaMap):
178
TestCaseInTempDir.setUp(self)
179
transport = get_transport(self.test_dir)
180
IndexGitCacheFormat().initialize(transport)
181
self.cache = IndexBzrGitCache(transport)
182
self.map = self.cache.idmap