56
56
def test_is_control_file(self):
57
57
mapping = BzrGitMappingv1()
58
if mapping.roundtripping:
59
self.assertTrue(mapping.is_control_file(".bzrdummy"))
60
self.assertTrue(mapping.is_control_file(".bzrfileids"))
58
self.assertTrue(mapping.is_control_file(".bzrdummy"))
59
self.assertTrue(mapping.is_control_file(".bzrfileids"))
61
60
self.assertFalse(mapping.is_control_file(".bzrfoo"))
63
def test_generate_file_id(self):
64
mapping = BzrGitMappingv1()
65
self.assertIsInstance(mapping.generate_file_id("la"), str)
66
self.assertIsInstance(mapping.generate_file_id(u"é"), str)
69
63
class FileidTests(tests.TestCase):
97
91
c.author_timezone = 60 * 3
98
92
c.author = "Author"
99
93
mapping = BzrGitMappingv1()
100
rev, roundtrip_revid, verifiers = mapping.import_commit(c,
101
mapping.revision_id_foreign_to_bzr)
102
self.assertEquals(None, roundtrip_revid)
103
self.assertEquals({}, verifiers)
94
rev = mapping.import_commit(c, mapping.revision_id_foreign_to_bzr)
104
95
self.assertEquals("Some message", rev.message)
105
96
self.assertEquals("Committer", rev.committer)
106
97
self.assertEquals("Author", rev.properties['author'])
122
113
c.author = u"Authér".encode("iso8859-1")
123
114
c.encoding = "iso8859-1"
124
115
mapping = BzrGitMappingv1()
125
rev, roundtrip_revid, verifiers = mapping.import_commit(c,
126
mapping.revision_id_foreign_to_bzr)
127
self.assertEquals(None, roundtrip_revid)
128
self.assertEquals({}, verifiers)
116
rev = mapping.import_commit(c, mapping.revision_id_foreign_to_bzr)
129
117
self.assertEquals(u"Authér", rev.properties['author'])
130
118
self.assertEquals("iso8859-1", rev.properties["git-explicit-encoding"])
131
119
self.assertTrue("git-implicit-encoding" not in rev.properties)
141
129
c.author_timezone = 60 * 3
142
130
c.author = u"Authér".encode("latin1")
143
131
mapping = BzrGitMappingv1()
144
rev, roundtrip_revid, verifiers = mapping.import_commit(c,
145
mapping.revision_id_foreign_to_bzr)
146
self.assertEquals(None, roundtrip_revid)
147
self.assertEquals({}, verifiers)
132
rev = mapping.import_commit(c, mapping.revision_id_foreign_to_bzr)
148
133
self.assertEquals(u"Authér", rev.properties['author'])
149
134
self.assertEquals("latin1", rev.properties["git-implicit-encoding"])
150
135
self.assertTrue("git-explicit-encoding" not in rev.properties)
160
145
c.author_timezone = 60 * 3
161
146
c.author = u"Authér".encode("utf-8")
162
147
mapping = BzrGitMappingv1()
163
rev, roundtrip_revid, verifiers = mapping.import_commit(c,
164
mapping.revision_id_foreign_to_bzr)
165
self.assertEquals(None, roundtrip_revid)
166
self.assertEquals({}, verifiers)
148
rev = mapping.import_commit(c, mapping.revision_id_foreign_to_bzr)
167
149
self.assertEquals(u"Authér", rev.properties['author'])
168
150
self.assertTrue("git-explicit-encoding" not in rev.properties)
169
151
self.assertTrue("git-implicit-encoding" not in rev.properties)
180
162
def assertRoundtripRevision(self, orig_rev):
181
163
commit = self.mapping.export_commit(orig_rev, "mysha",
182
self._lookup_parent, True, "testamentsha")
183
rev, roundtrip_revid, verifiers = self.mapping.import_commit(
184
commit, self.mapping.revision_id_foreign_to_bzr)
185
self.assertEquals(rev.revision_id,
186
self.mapping.revision_id_foreign_to_bzr(commit.id))
164
self._lookup_parent, True)
165
rev = self.mapping.import_commit(commit,
166
self.mapping.revision_id_foreign_to_bzr)
187
167
if self.mapping.roundtripping:
188
self.assertEquals({"testament3-sha1": "testamentsha"} , verifiers)
189
self.assertEquals(orig_rev.revision_id, roundtrip_revid)
168
self.assertEquals(orig_rev.revision_id, rev.revision_id)
190
169
self.assertEquals(orig_rev.properties, rev.properties)
191
170
self.assertEquals(orig_rev.committer, rev.committer)
192
171
self.assertEquals(orig_rev.timestamp, rev.timestamp)
193
172
self.assertEquals(orig_rev.timezone, rev.timezone)
194
173
self.assertEquals(orig_rev.message, rev.message)
195
174
self.assertEquals(list(orig_rev.parent_ids), list(rev.parent_ids))
197
self.assertEquals({}, verifiers)
199
176
def test_simple_commit(self):
200
177
r = Revision(self.mapping.revision_id_foreign_to_bzr("edf99e6c56495c620f20d5dacff9859ff7119261"))
250
227
raise NotImplementedError(self.assertRoundtripBlob)
252
229
def assertRoundtripCommit(self, commit1):
253
rev, roundtrip_revid, verifiers = self.mapping.import_commit(
254
commit1, self.mapping.revision_id_foreign_to_bzr)
230
rev = self.mapping.import_commit(commit1,
231
self.mapping.revision_id_foreign_to_bzr)
255
232
commit2 = self.mapping.export_commit(rev, "12341212121212", None,
257
234
self.assertEquals(commit1.committer, commit2.committer)
258
235
self.assertEquals(commit1.commit_time, commit2.commit_time)
259
236
self.assertEquals(commit1.commit_timezone, commit2.commit_timezone)