93
93
output, error = self.run_bzr(['checkout', 'gitbranch', 'bzrbranch'])
94
94
self.assertEqual(error,
95
'Fetching from Git to Bazaar repository. '
96
'For better performance, fetch into a Git repository.\n')
95
'Fetching from Git to Bazaar repository. '
96
'For better performance, fetch into a Git repository.\n')
97
97
self.assertEqual(output, '')
99
99
def test_branch_ls(self):
174
174
output, error = self.run_bzr(['diff', '--format=git'], retcode=1)
175
175
self.assertEqual(error, '')
176
176
self.assertEqual(output,
177
'diff --git /dev/null b/a\n'
180
'index 0000000..c197bd8 100644\n'
177
'diff --git /dev/null b/a\n'
180
'index 0000000..c197bd8 100644\n'
186
186
def test_git_import_uncolocated(self):
187
187
r = GitRepo.init("a", mkdir=True)
188
188
self.build_tree(["a/file"])
190
r.do_commit(ref=b"refs/heads/abranch", committer=b"Joe <joe@example.com>", message=b"Dummy")
191
r.do_commit(ref=b"refs/heads/bbranch", committer=b"Joe <joe@example.com>", message=b"Dummy")
190
r.do_commit(ref=b"refs/heads/abranch",
191
committer=b"Joe <joe@example.com>", message=b"Dummy")
192
r.do_commit(ref=b"refs/heads/bbranch",
193
committer=b"Joe <joe@example.com>", message=b"Dummy")
192
194
self.run_bzr(["git-import", "a", "b"])
193
self.assertEqual(set([".bzr", "abranch", "bbranch"]), set(os.listdir("b")))
196
set([".bzr", "abranch", "bbranch"]), set(os.listdir("b")))
195
198
def test_git_import(self):
196
199
r = GitRepo.init("a", mkdir=True)
197
200
self.build_tree(["a/file"])
199
r.do_commit(ref=b"refs/heads/abranch", committer=b"Joe <joe@example.com>", message=b"Dummy")
200
r.do_commit(ref=b"refs/heads/bbranch", committer=b"Joe <joe@example.com>", message=b"Dummy")
202
r.do_commit(ref=b"refs/heads/abranch",
203
committer=b"Joe <joe@example.com>", message=b"Dummy")
204
r.do_commit(ref=b"refs/heads/bbranch",
205
committer=b"Joe <joe@example.com>", message=b"Dummy")
201
206
self.run_bzr(["git-import", "--colocated", "a", "b"])
202
207
self.assertEqual(set([".bzr"]), set(os.listdir("b")))
203
208
self.assertEqual(set(["abranch", "bbranch"]),
204
set(ControlDir.open("b").get_branches().keys()))
209
set(ControlDir.open("b").get_branches().keys()))
206
211
def test_git_import_incremental(self):
207
212
r = GitRepo.init("a", mkdir=True)
208
213
self.build_tree(["a/file"])
210
r.do_commit(ref=b"refs/heads/abranch", committer=b"Joe <joe@example.com>", message=b"Dummy")
215
r.do_commit(ref=b"refs/heads/abranch",
216
committer=b"Joe <joe@example.com>", message=b"Dummy")
211
217
self.run_bzr(["git-import", "--colocated", "a", "b"])
212
218
self.run_bzr(["git-import", "--colocated", "a", "b"])
213
219
self.assertEqual(set([".bzr"]), set(os.listdir("b")))
218
224
r = GitRepo.init("a", mkdir=True)
219
225
self.build_tree(["a/file"])
221
cid = r.do_commit(ref=b"refs/heads/abranch", committer=b"Joe <joe@example.com>", message=b"Dummy")
227
cid = r.do_commit(ref=b"refs/heads/abranch",
228
committer=b"Joe <joe@example.com>", message=b"Dummy")
222
229
r[b"refs/tags/atag"] = cid
223
230
self.run_bzr(["git-import", "--colocated", "a", "b"])
224
231
self.assertEqual(set([".bzr"]), set(os.listdir("b")))
225
232
b = ControlDir.open("b")
226
233
self.assertEqual(["abranch"], list(b.get_branches().keys()))
227
234
self.assertEqual(["atag"],
228
list(b.open_branch("abranch").tags.get_tag_dict().keys()))
235
list(b.open_branch("abranch").tags.get_tag_dict().keys()))
230
237
def test_git_import_colo(self):
231
238
r = GitRepo.init("a", mkdir=True)
232
239
self.build_tree(["a/file"])
234
r.do_commit(ref=b"refs/heads/abranch", committer=b"Joe <joe@example.com>", message=b"Dummy")
235
r.do_commit(ref=b"refs/heads/bbranch", committer=b"Joe <joe@example.com>", message=b"Dummy")
241
r.do_commit(ref=b"refs/heads/abranch",
242
committer=b"Joe <joe@example.com>", message=b"Dummy")
243
r.do_commit(ref=b"refs/heads/bbranch",
244
committer=b"Joe <joe@example.com>", message=b"Dummy")
236
245
self.make_controldir("b", format="development-colo")
237
246
self.run_bzr(["git-import", "--colocated", "a", "b"])
238
247
self.assertEqual(
243
252
r = GitRepo.init("a", mkdir=True)
244
253
self.build_tree(["a/file"])
246
cid = r.do_commit(ref=b"refs/heads/abranch", committer=b"Joe <joe@example.com>", message=b"Dummy")
255
cid = r.do_commit(ref=b"refs/heads/abranch",
256
committer=b"Joe <joe@example.com>", message=b"Dummy")
247
257
r[b"refs/tags/atag"] = cid
248
258
(stdout, stderr) = self.run_bzr(["git-refs", "a"])
249
259
self.assertEqual(stderr, "")
250
260
self.assertEqual(stdout,
251
'refs/heads/abranch -> ' + cid.decode('ascii') + '\n'
252
'refs/tags/atag -> ' + cid.decode('ascii') + '\n')
261
'refs/heads/abranch -> ' + cid.decode('ascii') + '\n'
262
'refs/tags/atag -> ' + cid.decode('ascii') + '\n')
254
264
def test_git_refs_from_bzr(self):
255
265
tree = self.make_branch_and_tree('a')
256
266
self.build_tree(["a/file"])
257
267
tree.add(["file"])
258
revid = tree.commit(committer=b"Joe <joe@example.com>", message=b"Dummy")
269
committer=b"Joe <joe@example.com>", message=b"Dummy")
259
270
tree.branch.tags.set_tag("atag", revid)
260
271
(stdout, stderr) = self.run_bzr(["git-refs", "a"])
261
272
self.assertEqual(stderr, "")
282
293
self.build_tree_contents([("gitr/foo", b"hello from git")])
283
294
self.repo.stage("foo")
284
295
self.repo.do_commit(
285
b"message", committer=b"Somebody <user@example.com>",
286
commit_timestamp=1526330165, commit_timezone=0,
287
author_timestamp=1526330165, author_timezone=0,
288
merge_heads=[b'aa' * 20])
296
b"message", committer=b"Somebody <user@example.com>",
297
commit_timestamp=1526330165, commit_timezone=0,
298
author_timestamp=1526330165, author_timezone=0,
299
merge_heads=[b'aa' * 20])
290
301
def test_log_shallow(self):
291
302
# Check that bzr log does not fail and includes the revision.
292
303
output, error = self.run_bzr(['log', 'gitr'], retcode=3)
293
self.assertEqual(error, 'brz: ERROR: Further revision history missing.\n')
305
error, 'brz: ERROR: Further revision history missing.\n')
294
306
self.assertEqual(output,
295
'------------------------------------------------------------\n'
296
'revision-id: git-v1:' + self.repo.head().decode('ascii') + '\n'
297
'git commit: ' + self.repo.head().decode('ascii') + '\n'
298
'committer: Somebody <user@example.com>\n'
299
'timestamp: Mon 2018-05-14 20:36:05 +0000\n'
307
'------------------------------------------------------------\n'
308
'revision-id: git-v1:' + self.repo.head().decode('ascii') + '\n'
309
'git commit: ' + self.repo.head().decode('ascii') + '\n'
310
'committer: Somebody <user@example.com>\n'
311
'timestamp: Mon 2018-05-14 20:36:05 +0000\n'
303
315
def test_version_info_rio(self):
304
316
output, error = self.run_bzr(['version-info', '--rio', 'gitr'])
313
325
def test_version_info_custom_with_revno(self):
314
326
output, error = self.run_bzr(
315
['version-info', '--custom',
316
'--template=VERSION_INFO r{revno})\n', 'gitr'], retcode=3)
317
self.assertEqual(error, 'brz: ERROR: Variable {revno} is not available.\n')
327
['version-info', '--custom',
328
'--template=VERSION_INFO r{revno})\n', 'gitr'], retcode=3)
330
error, 'brz: ERROR: Variable {revno} is not available.\n')
318
331
self.assertEqual(output, 'VERSION_INFO r')
320
333
def test_version_info_custom_without_revno(self):
321
334
output, error = self.run_bzr(
322
['version-info', '--custom', '--template=VERSION_INFO \n',
335
['version-info', '--custom', '--template=VERSION_INFO \n',
324
337
self.assertEqual(error, '')
325
338
self.assertEqual(output, 'VERSION_INFO \n')