15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
from bzrlib.tests import TestCaseInTempDir, TestCase
19
from bzrlib.osutils import has_symlinks
18
from bzrlib.selftest import TestCaseInTempDir, TestCase
19
from bzrlib.selftest.blackbox import has_symlinks
22
22
except ImportError:
26
from bzrtools.baz_import import (import_version, revision_id,
27
cmd_baz_import, make_archive, map_file_id)
29
from bzrlib.plugins.bzrtools.baz_import import (import_version,
25
from bzrlib.plugins.bzrtools.baz_import import (import_version, revision_id,
27
from bzrlib.errors import NoSuchRevision
35
29
from StringIO import StringIO
37
31
from testresources import (TestResource, TestLoader, OptimisingTestSuite,
41
from bzrlib.errors import NoSuchRevision
43
from bzrtools.fai import namespace_previous
45
from bzrlib.plugins.bzrtools.fai import namespace_previous
33
from bzrlib.plugins.bzrtools.fai import namespace_previous
46
34
from bzrlib.branch import Branch
50
from unittest import TestSuite
38
return OptimisingTestSuite()
52
39
return TestLoader().loadTestsFromName(__name__)
95
82
# tree, two commits, includes merge of other branch
96
83
self._empty_merged_tag_2 = 'demo@DONOTUSE/c--empty-tag-2--0'
97
self._empty_merged_tag_2_bzr_base = revision_id(
98
self._empty_merged_tag_2 + '--base-0')
99
self._empty_merged_tag_2_bzr = revision_id(
100
self._empty_merged_tag_2 + '--patch-1')
84
self._empty_merged_tag_2_bzr_base = revision_id(self._empty_merged_tag_2 + '--base-0')
85
self._empty_merged_tag_2_bzr = revision_id(self._empty_merged_tag_2 + '--patch-1')
101
86
pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation(
102
87
pybaz.Version(self._empty_merged_tag_2))
103
88
tree = pybaz.Revision(self._empty_merged_tag_2 + '--base-0').get (
127
111
self.make_import_symlink()
128
112
self.make_missing_ancestor()
129
self.make_inbranch_continuation()
131
114
def make_import_symlink(self):
132
115
self._import_symlink = 'demo@DONOTUSE/c--import-symlink--0'
133
self._import_symlink_bzr = revision_id(
134
self._import_symlink + '--base-0')
116
self._import_symlink_bzr = revision_id(self._import_symlink + '--base-0')
135
117
os.mkdir(os.path.join(self._tmpdir, 'tree'))
136
118
tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'),
137
119
self._import_symlink)
138
link_path = os.path.join(self._tmpdir, 'tree', 'alink')
139
os.symlink('missing-file-name', link_path)
120
os.symlink('missing-file-name',
121
os.path.join(self._tmpdir, 'tree', 'alink'))
140
122
tree.add_tag('alink')
141
123
id_file = open(os.path.join(tree, '.arch-ids', 'alink.id'), 'w')
142
124
id_file.write('symlink_tag\n')
144
126
msg = tree.log_message()
145
127
msg["summary"] = "Import with a symlink"
146
128
tree.import_(msg)
148
f = file(link_path, 'w')
149
f.write('Not a symlink no more!')
151
msg = tree.log_message()
152
msg["summary"] = "Turn a symlink into a file"
154
129
shutil.rmtree(os.path.join(self._tmpdir, 'tree'))
156
131
def make_empty_import(self):
157
132
self._import = 'demo@DONOTUSE/c--import--0'
158
133
os.mkdir(os.path.join(self._tmpdir, 'tree'))
159
tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'),
134
tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'), self._import)
161
135
msg = tree.log_message()
162
136
msg["summary"] = "I am importing now"
163
137
tree.import_(msg)
192
168
os.mkdir(os.path.join(self._tmpdir, 'archivegone-bzr', 'c'))
193
169
import_version(os.path.join(self._tmpdir, 'archivegone-bzr',
195
pybaz.Version(self._missing_import))
171
pybaz.Version(self._missing_import),
196
173
# and make it inaccessible
197
174
pybaz.Archive('demo-gone@DONOTUSE').unregister()
199
def make_inbranch_continuation(self):
200
self._inbranch_tag = 'demo@DONOTUSE/c--inbranch-tag--0'
201
self._inbranch_tag_base = self._inbranch_tag + '--base-0'
202
self._inbranch_tag_base_bzr = revision_id(self._inbranch_tag_base)
203
pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation(
204
pybaz.Version(self._inbranch_tag))
205
self._inbranch_tag_head = self._inbranch_tag + '--patch-1'
206
self._inbranch_tag_head_bzr = revision_id(self._inbranch_tag_head)
207
pybaz.Revision(self._inbranch_tag_base).make_continuation(
208
pybaz.Version(self._inbranch_tag))
211
177
def _makeResource(self):
212
178
return BazTreeResource()
224
190
TestCaseInTempDir.setUp(self)
225
191
ResourcedTestCase.setUpResources(self)
226
192
os.environ['HOME'] = self._baz._homedir
193
self.output = StringIO()
228
195
def tearDown(self):
229
196
ResourcedTestCase.tearDownResources(self)
230
197
TestCaseInTempDir.tearDown(self)
199
def collect(self, text):
200
self.output.write(text)
201
self.output.write("\n")
232
203
def test_import_empty(self):
233
import_version('output', pybaz.Version(self._baz._import))
204
import_version('output', pybaz.Version(self._baz._import), self.collect)
234
205
# expected results:
235
# one commit, no files, revision identifier of
236
# 'demo@DONOTUSE_c--import--0--base-0'
206
# one commit, no files, revision identifier of 'demo@DONOTUSE_c--import--0--base-0'
237
207
branch = Branch.open('output')
238
repo = branch.repository
239
208
self.assertEqual(branch.revision_history(),
240
209
['Arch-1:demo@DONOTUSE%c--import--0--base-0'])
241
rev = repo.get_revision('Arch-1:demo@DONOTUSE%c--import--0--base-0')
210
rev = branch.get_revision('Arch-1:demo@DONOTUSE%c--import--0--base-0')
243
import_version('output2', pybaz.Version('demo@DONOTUSE/c--import--0'))
212
import_version('output2', pybaz.Version('demo@DONOTUSE/c--import--0'),
244
214
branch2 = Branch.open('output2')
245
repo2 = branch2.repository
246
215
self.assertEqual(branch.revision_history(), branch2.revision_history())
247
rev2 = repo2.get_revision('Arch-1:demo@DONOTUSE%c--import--0--base-0')
216
rev2 = branch2.get_revision('Arch-1:demo@DONOTUSE%c--import--0--base-0')
248
217
# they must be the same
249
218
self.assertEqual(rev, rev2)
264
234
self.assertEqual(branch.revision_history(),
265
235
['Arch-1:demo@DONOTUSE%c--import--0--base-0',
266
236
self._baz._empty_tag_bzr])
267
rev = branch.repository.get_revision(self._baz._empty_tag_bzr)
237
rev = branch.get_revision(self._baz._empty_tag_bzr)
269
import_version('output2', pybaz.Version(self._baz._empty_tag))
239
import_version('output2', pybaz.Version(self._baz._empty_tag),
270
241
branch2 = Branch.open('output2')
271
242
self.assertEqual(branch.revision_history(), branch2.revision_history())
272
rev2 = branch2.repository.get_revision(self._baz._empty_tag_bzr)
243
rev2 = branch2.get_revision(self._baz._empty_tag_bzr)
273
244
# they must be the same
274
245
self.assertEqual(rev, rev2)
276
247
# and we should get some expected values:
277
248
self.assertEqual(rev.committer, "Test User<test@example.org>")
278
self.assertEqual(rev.message,
279
"tag of demo@DONOTUSE/c--import--0--base-0")
249
self.assertEqual(rev.message, "tag of demo@DONOTUSE/c--import--0--base-0")
280
250
self.assertEqual(rev.revision_id, self._baz._empty_tag_bzr)
282
252
def test_empty_merged_tagged(self):
283
import_version('output', pybaz.Version(self._baz._empty_merged_tag))
253
import_version('output', pybaz.Version(self._baz._empty_merged_tag),
284
255
# expected results:
285
256
# two commits, no files, revision identifiers of
286
257
# 'demo@DONOTUSE_c--import--0--base-0' and
289
260
# and a merged revision from the latter of
290
261
# self._baz._empty_tag_bzr
291
262
branch = Branch.open('output')
292
repo = branch.repository
293
263
self.assertEqual(branch.revision_history(),
294
264
['Arch-1:demo@DONOTUSE%c--import--0--base-0',
295
265
self._baz._empty_merged_tag_bzr_base,
296
266
self._baz._empty_merged_tag_bzr])
298
import_version('output2', pybaz.Version(self._baz._empty_merged_tag))
268
import_version('output2', pybaz.Version(self._baz._empty_merged_tag),
299
270
branch2 = Branch.open('output2')
300
repo2 = branch2.repository
301
271
# and import what we should be merged up against for checking with.
302
import_version('output3', pybaz.Version(self._baz._empty_tag))
272
import_version('output3', pybaz.Version(self._baz._empty_tag),
303
274
branch3 = Branch.open('output3')
305
276
self.assertEqual(branch.revision_history(), branch2.revision_history())
306
self.assertNotEqual(branch.revision_history(),
307
branch3.revision_history())
277
self.assertNotEqual(branch.revision_history(), branch3.revision_history())
308
278
# check revisions in the history.
309
rev = repo.get_revision(self._baz._empty_merged_tag_bzr_base)
310
rev2 = repo2.get_revision(self._baz._empty_merged_tag_bzr_base)
279
rev = branch.get_revision(self._baz._empty_merged_tag_bzr_base)
280
rev2 = branch2.get_revision(self._baz._empty_merged_tag_bzr_base)
311
281
# they must be the same
312
282
self.assertEqual(rev, rev2)
313
283
# and we should get some expected values:
314
284
self.assertEqual(rev.committer, "Test User<test@example.org>")
315
self.assertEqual(rev.message,
316
"tag of demo@DONOTUSE/c--import--0--base-0")
285
self.assertEqual(rev.message, "tag of demo@DONOTUSE/c--import--0--base-0")
317
286
self.assertEqual(rev.revision_id, self._baz._empty_merged_tag_bzr_base)
318
287
self.assertEqual(['Arch-1:demo@DONOTUSE%c--import--0--base-0'],
321
290
# check next revisions in the history.
322
rev = repo.get_revision(self._baz._empty_merged_tag_bzr)
323
rev2 = repo2.get_revision(self._baz._empty_merged_tag_bzr)
291
rev = branch.get_revision(self._baz._empty_merged_tag_bzr)
292
rev2 = branch2.get_revision(self._baz._empty_merged_tag_bzr)
324
293
# they must be the same
325
294
self.assertEqual(rev, rev2)
326
295
# and we should get some expected values:
345
315
# and a merged revision from the latter of
346
316
# self._baz._empty_merged_tag_bzr
347
317
branch = Branch.open('output')
348
repo = branch.repository
349
318
self.assertEqual(branch.revision_history(),
350
319
['Arch-1:demo@DONOTUSE%c--import--0--base-0',
351
320
self._baz._empty_merged_tag_2_bzr_base,
352
321
self._baz._empty_merged_tag_2_bzr])
354
import_version('output2', pybaz.Version(self._baz._empty_merged_tag_2))
323
import_version('output2', pybaz.Version(self._baz._empty_merged_tag_2),
355
325
branch2 = Branch.open('output2')
356
repo2 = branch2.repository
357
326
# and import what we should be merged up against for checking with.
358
import_version('output3', pybaz.Version(self._baz._empty_merged_tag))
327
import_version('output3', pybaz.Version(self._baz._empty_merged_tag),
359
329
branch3 = Branch.open('output3')
361
331
self.assertEqual(branch.revision_history(), branch2.revision_history())
362
self.assertNotEqual(branch.revision_history(),
363
branch3.revision_history())
332
self.assertNotEqual(branch.revision_history(), branch3.revision_history())
364
333
# check revisions in the history.
365
rev = repo.get_revision(self._baz._empty_merged_tag_2_bzr_base)
366
rev2 = repo2.get_revision(self._baz._empty_merged_tag_2_bzr_base)
334
rev = branch.get_revision(self._baz._empty_merged_tag_2_bzr_base)
335
rev2 = branch2.get_revision(self._baz._empty_merged_tag_2_bzr_base)
367
336
# they must be the same
368
337
self.assertEqual(rev, rev2)
369
338
# and we should get some expected values:
370
339
self.assertEqual(rev.committer, "Test User<test@example.org>")
371
self.assertEqual(rev.message,
372
"tag of demo@DONOTUSE/c--import--0--base-0")
373
self.assertEqual(rev.revision_id,
374
self._baz._empty_merged_tag_2_bzr_base)
340
self.assertEqual(rev.message, "tag of demo@DONOTUSE/c--import--0--base-0")
341
self.assertEqual(rev.revision_id, self._baz._empty_merged_tag_2_bzr_base)
376
343
# check next revisions in the history.
377
rev = repo.get_revision(self._baz._empty_merged_tag_2_bzr)
378
rev2 = repo2.get_revision(self._baz._empty_merged_tag_2_bzr)
344
rev = branch.get_revision(self._baz._empty_merged_tag_2_bzr)
345
rev2 = branch2.get_revision(self._baz._empty_merged_tag_2_bzr)
379
346
# they must be the same
380
347
self.assertEqual(rev, rev2)
381
348
# and we should get some expected values:
392
359
# self.assertEqual(branch.missing_revisions(branch3), [])
394
361
def test_import_symlink(self):
395
import_version('output', pybaz.Version(self._baz._import_symlink),
362
import_version('output', pybaz.Version(self._baz._import_symlink),
397
364
# expected results:
398
# two commits, no files, revision identifier of
399
# 'demo@DONOTUSE_c--import--0--base-0'
365
# one commit, no files, revision identifier of 'demo@DONOTUSE_c--import--0--base-0'
400
366
branch = Branch.open('output')
401
367
self.assertEqual(branch.revision_history(),
402
368
[self._baz._import_symlink_bzr])
403
rev = branch.repository.get_revision(self._baz._import_symlink_bzr)
369
rev = branch.get_revision(self._baz._import_symlink_bzr)
405
371
import_version('output2', pybaz.Version(self._baz._import_symlink),
407
373
branch2 = Branch.open('output2')
408
374
self.assertEqual(branch.revision_history(), branch2.revision_history())
409
rev2 = branch2.repository.get_revision(self._baz._import_symlink_bzr)
375
rev2 = branch2.get_revision(self._baz._import_symlink_bzr)
410
376
# they must be the same
411
377
self.assertEqual(rev, rev2)
416
382
self.assertEqual(rev.revision_id, self._baz._import_symlink_bzr)
418
384
# and we want the symlink alink with target 'missing-file-name'
419
inv = branch.repository.get_inventory(rev.revision_id)
385
inv = branch.get_inventory(rev.revision_id)
420
386
self.assertEqual(inv.path2id('alink'), 'x_symlink_tag')
421
387
entry = inv['x_symlink_tag']
422
388
self.assertEqual(entry.kind, 'symlink')
423
389
self.assertEqual(entry.symlink_target, 'missing-file-name')
425
# current bzr doesn't handle type changes
426
self.assertRaises(AssertionError, import_version, 'output3',
427
pybaz.Version(self._baz._import_symlink))
429
391
def test_missing_ancestor(self):
430
import_version('output', pybaz.Version(self._baz._missing_ancestor))
392
import_version('output', pybaz.Version(self._baz._missing_ancestor),
431
394
# expected results:
432
395
# one commits, no files, revision identifiers of
433
396
# 'demo@DONOTUSE_c--gone--0--base-0' and
435
398
branch = Branch.open('output')
436
399
self.assertEqual(branch.revision_history(),
437
400
[self._baz._missing_ancestor_bzr])
438
rev = branch.repository.get_revision(self._baz._missing_ancestor_bzr)
401
rev = branch.get_revision(self._baz._missing_ancestor_bzr)
440
import_version('output2', pybaz.Version(self._baz._missing_ancestor))
403
import_version('output2', pybaz.Version(self._baz._missing_ancestor),
441
405
branch2 = Branch.open('output2')
442
406
self.assertEqual(branch.revision_history(), branch2.revision_history())
443
rev2 = branch2.repository.get_revision(self._baz._missing_ancestor_bzr)
407
rev2 = branch2.get_revision(self._baz._missing_ancestor_bzr)
444
408
# they must be the same
445
409
self.assertEqual(rev, rev2)
447
411
# and we should get some expected values:
448
412
self.assertEqual(rev.committer, "Test User<test@example.org>")
449
self.assertEqual(rev.message,
450
"tag of demo-gone@DONOTUSE/c--import--0--base-0")
413
self.assertEqual(rev.message, "tag of demo-gone@DONOTUSE/c--import--0--base-0")
451
414
self.assertEqual(rev.revision_id, self._baz._missing_ancestor_bzr)
452
415
self.assertEqual(rev.parent_ids[0], self._baz._missing_import_bzr)
453
416
self.assertEqual(1, len(rev.parent_ids))
455
418
# must NOT be able to get the merged evision
456
self.assertRaises(NoSuchRevision, branch.repository.get_revision,
419
self.assertRaises(NoSuchRevision, branch.get_revision,
457
420
self._baz._missing_import_bzr)
459
422
def test_missing_ancestor_reusing_history(self):
460
423
import_version('output', pybaz.Version(self._baz._missing_ancestor),
461
425
reuse_history_from=[self._baz._missing_import_imported])
462
426
# expected results:
463
427
# one commits, no files, revision identifiers of
467
431
self.assertEqual(branch.revision_history(),
468
432
[self._baz._missing_import_bzr,
469
433
self._baz._missing_ancestor_bzr])
470
rev = branch.repository.get_revision(self._baz._missing_ancestor_bzr)
434
rev = branch.get_revision(self._baz._missing_ancestor_bzr)
472
436
import_version('output2', pybaz.Version(self._baz._missing_ancestor),
473
438
reuse_history_from=[self._baz._missing_import_imported])
474
439
branch2 = Branch.open('output2')
475
440
self.assertEqual(branch.revision_history(), branch2.revision_history())
476
rev2 = branch2.repository.get_revision(self._baz._missing_ancestor_bzr)
441
rev2 = branch2.get_revision(self._baz._missing_ancestor_bzr)
477
442
# they must be the same
478
443
self.assertEqual(rev, rev2)
480
445
# must be able to get the missing base revision
481
branch.repository.get_revision(self._baz._missing_import_bzr)
446
branch.get_revision(self._baz._missing_import_bzr)
483
448
# and we should get some expected values:
484
449
self.assertEqual(rev.committer, "Test User<test@example.org>")
485
self.assertEqual(rev.message,
486
"tag of demo-gone@DONOTUSE/c--import--0--base-0")
450
self.assertEqual(rev.message, "tag of demo-gone@DONOTUSE/c--import--0--base-0")
487
451
self.assertEqual(rev.revision_id, self._baz._missing_ancestor_bzr)
488
452
self.assertEqual(rev.parent_ids[0], self._baz._missing_import_bzr)
489
453
self.assertEqual(1, len(rev.parent_ids))
491
455
def test_bad_file_id(self):
492
import_version('output', pybaz.Version(self._baz._bad_id_tag))
456
import_version('output', pybaz.Version(self._baz._bad_id_tag),
493
458
# expected results:
494
459
# three commits, one files, revision identifiers of
495
460
# 'demo@DONOTUSE_c--import--0--base-0' ,
500
465
['Arch-1:demo@DONOTUSE%c--import--0--base-0',
501
466
self._baz._bad_id_tag_bzr_base,
502
467
self._baz._bad_id_tag_bzr])
503
rev = branch.repository.get_revision(self._baz._bad_id_tag_bzr)
504
inv = branch.repository.get_inventory(self._baz._bad_id_tag_bzr)
468
rev = branch.get_revision(self._baz._bad_id_tag_bzr)
469
inv = branch.get_inventory(self._baz._bad_id_tag_bzr)
505
470
self.assertEqual(inv.path2id('path'), 'x_this_id%2fneeds%25escaping')
506
471
self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping'))
508
473
def test_appending_revisions_already_present(self):
509
474
import_version('output', pybaz.Version(self._baz._bad_id_tag),
475
self.collect, max_count=2)
511
476
# expected results:
512
477
# three commits, one files, revision identifiers of
513
478
# 'demo@DONOTUSE_c--import--0--base-0' ,
524
489
self.assertEqual(branch.revision_history(),
525
490
['Arch-1:demo@DONOTUSE%c--import--0--base-0'])
527
import_version('output', pybaz.Version(self._baz._bad_id_tag))
492
import_version('output', pybaz.Version(self._baz._bad_id_tag),
528
494
branch = Branch.open('output')
529
495
self.assertEqual(branch.revision_history(),
530
496
['Arch-1:demo@DONOTUSE%c--import--0--base-0',
531
497
self._baz._bad_id_tag_bzr_base,
532
498
self._baz._bad_id_tag_bzr])
533
rev = branch.repository.get_revision(self._baz._bad_id_tag_bzr)
534
inv = branch.repository.get_inventory(self._baz._bad_id_tag_bzr)
499
rev = branch.get_revision(self._baz._bad_id_tag_bzr)
500
inv = branch.get_inventory(self._baz._bad_id_tag_bzr)
535
501
self.assertEqual(inv.path2id('path'), 'x_this_id%2fneeds%25escaping')
536
502
self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping'))
538
504
def test_appending_revisions_all_already_present(self):
539
import_version('output', pybaz.Version(self._baz._bad_id_tag))
505
import_version('output', pybaz.Version(self._baz._bad_id_tag),
540
507
# expected results:
541
508
# three commits, one files, revision identifiers of
542
509
# 'demo@DONOTUSE_c--import--0--base-0' ,
554
521
self.assertEqual(branch.revision_history(),
555
522
['Arch-1:demo@DONOTUSE%c--import--0--base-0'])
557
import_version('output', pybaz.Version(self._baz._bad_id_tag))
524
import_version('output', pybaz.Version(self._baz._bad_id_tag),
558
526
branch = Branch.open('output')
559
527
self.assertEqual(branch.revision_history(),
560
528
['Arch-1:demo@DONOTUSE%c--import--0--base-0',
561
529
self._baz._bad_id_tag_bzr_base,
562
530
self._baz._bad_id_tag_bzr])
563
rev = branch.repository.get_revision(self._baz._bad_id_tag_bzr)
564
inv = branch.repository.get_inventory(self._baz._bad_id_tag_bzr)
531
rev = branch.get_revision(self._baz._bad_id_tag_bzr)
532
inv = branch.get_inventory(self._baz._bad_id_tag_bzr)
565
533
self.assertEqual(inv.path2id('path'), 'x_this_id%2fneeds%25escaping')
566
534
self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping'))
568
def test_inbranch_conversion(self):
569
import_version('output', pybaz.Version(self._baz._inbranch_tag))
571
# three commits, no files, revision identifiers of
572
# 'demo@DONOTUSE_c--import--0--base-0' and
573
# self._baz._inbranch_tag_base_bzr
574
# self._baz._inbranch_tag_head_bzr
576
branch = Branch.open('output')
577
self.assertEqual(branch.revision_history(),
578
['Arch-1:demo@DONOTUSE%c--import--0--base-0',
579
self._baz._inbranch_tag_base_bzr,
580
self._baz._inbranch_tag_head_bzr])
582
import_version('output2', pybaz.Version(self._baz._inbranch_tag))
583
branch2 = Branch.open('output2')
585
self.assertEqual(branch.revision_history(), branch2.revision_history())
586
# check revisions in the history.
587
rev = branch.repository.get_revision(self._baz._inbranch_tag_base_bzr)
588
rev2 = branch2.repository.get_revision(self._baz._inbranch_tag_base_bzr)
589
# they must be the same
590
self.assertEqual(rev, rev2)
591
# and we should get some expected values:
592
self.assertEqual(rev.committer, "Test User<test@example.org>")
593
self.assertEqual(rev.message, "tag of demo@DONOTUSE/c--import--0--base-0")
594
self.assertEqual(rev.revision_id, self._baz._inbranch_tag_base_bzr)
596
# check next revisions in the history.
597
rev = branch.repository.get_revision(self._baz._inbranch_tag_head_bzr)
598
rev2 = branch2.repository.get_revision(self._baz._inbranch_tag_head_bzr)
599
# they must be the same
600
self.assertEqual(rev, rev2)
601
# and we should get some expected values:
602
self.assertEqual(rev.committer, "Test User<test@example.org>")
603
self.assertEqual(rev.message, "tag of demo@DONOTUSE/c--inbranch-tag--0--base-0")
604
self.assertEqual(rev.revision_id, self._baz._inbranch_tag_head_bzr)
605
self.assertEqual(rev.parent_ids,
606
[self._baz._inbranch_tag_base_bzr])
608
def test_no_commits_same_as_missing(self):
611
branch = bzrlib.bzrdir.BzrDir.create_branch_convenience(path)
612
import_version(path, pybaz.Version(self._baz._import))
614
# one commit, revision identifier of
615
# 'demo@DONOTUSE_c--import--0--base-0'
616
self.assertEqual(branch.revision_history(),
617
['Arch-1:demo@DONOTUSE%c--import--0--base-0'])
620
537
class TestNamespacePrevious(TestCase):
716
633
command = cmd_baz_import()
717
634
command.run(os.path.join(self._tmpdir, 'output'), 'demo@DONOTUSE')
718
635
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output')))
719
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output',
721
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output',
722
'c1', '0.2','branch')))
723
walk_len = len(list(os.walk(os.path.join(self._tmpdir,'output'))))
724
self.assertEqual(20, walk_len)
636
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output', 'c','+trunk')))
637
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output', 'c1', '0.2','branch')))
639
len(list(os.walk(os.path.join(self._tmpdir,'output')))))
726
641
def test_run_twice(self):
727
642
self.make_import('c--0')