271
268
zf = ZipFile('../first-zip')
272
269
self.assert_('first-zip/hello' in zf.namelist(), zf.namelist())
274
def test_branch(self):
275
"""Branch from one branch to another."""
278
self.example_branch()
280
self.runbzr('branch a b')
281
b = bzrlib.branch.Branch.open('b')
282
self.assertEqual('b\n', b.control_files.get_utf8('branch-name').read())
283
self.runbzr('branch a c -r 1')
285
self.runbzr('commit -m foo --unchanged')
288
def test_branch_basis(self):
289
# ensure that basis really does grab from the basis by having incomplete source
290
tree = self.make_branch_and_tree('commit_tree')
291
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
293
tree.commit('revision 1', rev_id='1')
294
source = self.make_branch_and_tree('source')
295
# this gives us an incomplete repository
296
tree.bzrdir.open_repository().copy_content_into(source.branch.repository)
297
tree.commit('revision 2', rev_id='2', allow_pointless=True)
298
tree.bzrdir.open_branch().copy_content_into(source.branch)
299
tree.copy_content_into(source)
300
self.assertFalse(source.branch.repository.has_revision('2'))
302
self.runbzr('branch source target --basis commit_tree')
303
target = bzrdir.BzrDir.open('target')
304
self.assertEqual('2', target.open_branch().last_revision())
305
self.assertEqual('2', target.open_workingtree().last_revision())
306
self.assertTrue(target.open_branch().repository.has_revision('2'))
308
271
def test_inventory(self):
309
272
bzr = self.runbzr
310
273
def output_equals(value, *args):
499
462
self.runbzr('pull ../a --remember')
500
463
self.runbzr('pull')
502
def test_add_reports(self):
503
"""add command prints the names of added files."""
505
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt', 'CVS'])
506
out = self.run_bzr_captured(['add'], retcode=0)[0]
507
# the ordering is not defined at the moment
508
results = sorted(out.rstrip('\n').split('\n'))
509
self.assertEquals(['If you wish to add some of these files, please'\
510
' add them by name.',
514
'ignored 1 file(s) matching "CVS"'],
516
out = self.run_bzr_captured(['add', '-v'], retcode=0)[0]
517
results = sorted(out.rstrip('\n').split('\n'))
518
self.assertEquals(['If you wish to add some of these files, please'\
519
' add them by name.',
520
'ignored CVS matching "CVS"'],
523
def test_add_quiet_is(self):
524
"""add -q does not print the names of added files."""
526
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt'])
527
out = self.run_bzr_captured(['add', '-q'], retcode=0)[0]
528
# the ordering is not defined at the moment
529
results = sorted(out.rstrip('\n').split('\n'))
530
self.assertEquals([''], results)
532
def test_add_in_unversioned(self):
533
"""Try to add a file in an unversioned directory.
535
"bzr add" should add the parent(s) as necessary.
538
self.build_tree(['inertiatic/', 'inertiatic/esp'])
539
self.assertEquals(self.capture('unknowns'), 'inertiatic\n')
540
self.run_bzr('add', 'inertiatic/esp')
541
self.assertEquals(self.capture('unknowns'), '')
543
# Multiple unversioned parents
544
self.build_tree(['veil/', 'veil/cerpin/', 'veil/cerpin/taxt'])
545
self.assertEquals(self.capture('unknowns'), 'veil\n')
546
self.run_bzr('add', 'veil/cerpin/taxt')
547
self.assertEquals(self.capture('unknowns'), '')
549
# Check whacky paths work
550
self.build_tree(['cicatriz/', 'cicatriz/esp'])
551
self.assertEquals(self.capture('unknowns'), 'cicatriz\n')
552
self.run_bzr('add', 'inertiatic/../cicatriz/esp')
553
self.assertEquals(self.capture('unknowns'), '')
555
def test_add_in_versioned(self):
556
"""Try to add a file in a versioned directory.
558
"bzr add" should do this happily.
561
self.build_tree(['inertiatic/', 'inertiatic/esp'])
562
self.assertEquals(self.capture('unknowns'), 'inertiatic\n')
563
self.run_bzr('add', '--no-recurse', 'inertiatic')
564
self.assertEquals(self.capture('unknowns'), 'inertiatic/esp\n')
565
self.run_bzr('add', 'inertiatic/esp')
566
self.assertEquals(self.capture('unknowns'), '')
568
def test_subdir_add(self):
569
"""Add in subdirectory should add only things from there down"""
570
from bzrlib.workingtree import WorkingTree
572
eq = self.assertEqual
576
t = self.make_branch_and_tree('.')
578
self.build_tree(['src/', 'README'])
580
eq(sorted(t.unknowns()),
583
self.run_bzr('add', 'src')
585
self.build_tree(['src/foo.c'])
590
self.assertEquals(self.capture('unknowns'), 'README\n')
591
eq(len(t.read_working_inventory()), 3)
595
self.assertEquals(self.capture('unknowns'), '')
596
self.run_bzr('check')
598
465
def test_unknown_command(self):
599
466
"""Handling of unknown command."""
600
467
out, err = self.run_bzr_captured(['fluffy-badger'],