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):
96
90
c.commit_timezone = 60 * 5
97
91
c.author_timezone = 60 * 3
98
92
c.author = "Author"
99
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)
93
rev = BzrGitMappingv1().import_commit(c)
104
94
self.assertEquals("Some message", rev.message)
105
95
self.assertEquals("Committer", rev.committer)
106
96
self.assertEquals("Author", rev.properties['author'])
121
111
c.author_timezone = 60 * 3
122
112
c.author = u"Authér".encode("iso8859-1")
123
113
c.encoding = "iso8859-1"
124
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)
114
rev = BzrGitMappingv1().import_commit(c)
129
115
self.assertEquals(u"Authér", rev.properties['author'])
130
116
self.assertEquals("iso8859-1", rev.properties["git-explicit-encoding"])
131
117
self.assertTrue("git-implicit-encoding" not in rev.properties)
140
126
c.commit_timezone = 60 * 5
141
127
c.author_timezone = 60 * 3
142
128
c.author = u"Authér".encode("latin1")
143
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)
129
rev = BzrGitMappingv1().import_commit(c)
148
130
self.assertEquals(u"Authér", rev.properties['author'])
149
131
self.assertEquals("latin1", rev.properties["git-implicit-encoding"])
150
132
self.assertTrue("git-explicit-encoding" not in rev.properties)
159
141
c.commit_timezone = 60 * 5
160
142
c.author_timezone = 60 * 3
161
143
c.author = u"Authér".encode("utf-8")
162
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)
144
rev = BzrGitMappingv1().import_commit(c)
167
145
self.assertEquals(u"Authér", rev.properties['author'])
168
146
self.assertTrue("git-explicit-encoding" not in rev.properties)
169
147
self.assertTrue("git-implicit-encoding" not in rev.properties)
180
158
def assertRoundtripRevision(self, orig_rev):
181
159
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))
187
if self.mapping.roundtripping:
188
self.assertEquals({"testament3-sha1": "testamentsha"} , verifiers)
189
self.assertEquals(orig_rev.revision_id, roundtrip_revid)
190
self.assertEquals(orig_rev.properties, rev.properties)
191
self.assertEquals(orig_rev.committer, rev.committer)
192
self.assertEquals(orig_rev.timestamp, rev.timestamp)
193
self.assertEquals(orig_rev.timezone, rev.timezone)
194
self.assertEquals(orig_rev.message, rev.message)
195
self.assertEquals(list(orig_rev.parent_ids), list(rev.parent_ids))
197
self.assertEquals({}, verifiers)
160
self._lookup_parent, True)
161
rev = self.mapping.import_commit(commit)
162
self.assertEquals(orig_rev.revision_id, rev.revision_id)
163
self.assertEquals(orig_rev.properties, rev.properties)
164
self.assertEquals(orig_rev.committer, rev.committer)
165
self.assertEquals(orig_rev.timestamp, rev.timestamp)
166
self.assertEquals(orig_rev.timezone, rev.timezone)
167
self.assertEquals(orig_rev.message, rev.message)
168
self.assertEquals(list(orig_rev.parent_ids), list(rev.parent_ids))
199
170
def test_simple_commit(self):
200
171
r = Revision(self.mapping.revision_id_foreign_to_bzr("edf99e6c56495c620f20d5dacff9859ff7119261"))
250
221
raise NotImplementedError(self.assertRoundtripBlob)
252
223
def assertRoundtripCommit(self, commit1):
253
rev, roundtrip_revid, verifiers = self.mapping.import_commit(
254
commit1, self.mapping.revision_id_foreign_to_bzr)
224
rev = self.mapping.import_commit(commit1)
255
225
commit2 = self.mapping.export_commit(rev, "12341212121212", None,
257
227
self.assertEquals(commit1.committer, commit2.committer)
258
228
self.assertEquals(commit1.commit_time, commit2.commit_time)
259
229
self.assertEquals(commit1.commit_timezone, commit2.commit_timezone)