~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/blackbox.py

  • Committer: Robert Collins
  • Date: 2005-10-10 23:18:27 UTC
  • mfrom: (1437)
  • mto: This revision was merged to the branch mainline in revision 1438.
  • Revision ID: robertc@robertcollins.net-20051010231827-f9e2dda2e92bf565
mergeĀ fromĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
import os
32
32
 
33
33
from bzrlib.branch import Branch
 
34
from bzrlib.clone import copy_branch
34
35
from bzrlib.errors import BzrCommandError
35
36
from bzrlib.osutils import has_symlinks
36
37
from bzrlib.selftest import TestCaseInTempDir, BzrTestBase
265
266
        output = self.runbzr('diff -r last:3..last:1', backtick=1)
266
267
        self.assert_('\n+baz' in output)
267
268
 
 
269
    def test_diff_branches(self):
 
270
        self.build_tree(['branch1/', 'branch1/file', 'branch2/'])
 
271
        branch = Branch.initialize('branch1')
 
272
        branch.add(['file'])
 
273
        branch.commit('add file')
 
274
        copy_branch(branch, 'branch2')
 
275
        print >> open('branch2/file', 'w'), 'new content'
 
276
        branch2 = Branch.open('branch2')
 
277
        branch2.commit('update file')
 
278
        # should open branch1 and diff against branch2, 
 
279
        output = self.run_bzr_captured(['diff', '-r', 'branch:branch2', 'branch1'])
 
280
        self.assertEquals(("=== modified file 'file'\n"
 
281
                           "--- file\n"
 
282
                           "+++ file\n"
 
283
                           "@@ -1,1 +1,1 @@\n"
 
284
                           "-new content\n"
 
285
                           "+contents of branch1/file\n"
 
286
                           "\n", ''), output)
 
287
 
268
288
    def test_branch(self):
269
289
        """Branch from one branch to another."""
270
290
        os.mkdir('a')
344
364
        assert os.path.exists('sub/a.txt.OTHER')
345
365
        assert os.path.exists('sub/a.txt.BASE')
346
366
 
347
 
    def test_merge_with_missing_file(self):
348
 
        """Merge handles missing file conflicts"""
349
 
        os.mkdir('a')
350
 
        os.chdir('a')
351
 
        os.mkdir('sub')
352
 
        print >> file('sub/a.txt', 'wb'), "hello"
353
 
        print >> file('b.txt', 'wb'), "hello"
354
 
        print >> file('sub/c.txt', 'wb'), "hello"
355
 
        self.runbzr('init')
356
 
        self.runbzr('add')
357
 
        self.runbzr(('commit', '-m', 'added a'))
358
 
        self.runbzr('branch . ../b')
359
 
        print >> file('sub/a.txt', 'ab'), "there"
360
 
        print >> file('b.txt', 'ab'), "there"
361
 
        print >> file('sub/c.txt', 'ab'), "there"
362
 
        self.runbzr(('commit', '-m', 'Added there'))
363
 
        os.unlink('sub/a.txt')
364
 
        os.unlink('sub/c.txt')
365
 
        os.rmdir('sub')
366
 
        os.unlink('b.txt')
367
 
        self.runbzr(('commit', '-m', 'Removed a.txt'))
368
 
        os.chdir('../b')
369
 
        print >> file('sub/a.txt', 'ab'), "something"
370
 
        print >> file('b.txt', 'ab'), "something"
371
 
        print >> file('sub/c.txt', 'ab'), "something"
372
 
        self.runbzr(('commit', '-m', 'Modified a.txt'))
373
 
        self.runbzr('merge ../a/')
374
 
        assert os.path.exists('sub/a.txt.THIS')
375
 
        assert os.path.exists('sub/a.txt.BASE')
376
 
        os.chdir('../a')
377
 
        self.runbzr('merge ../b/')
378
 
        assert os.path.exists('sub/a.txt.OTHER')
379
 
        assert os.path.exists('sub/a.txt.BASE')
380
 
 
381
367
    def test_pull(self):
382
368
        """Pull changes from one branch to another."""
383
369
        os.mkdir('a')
728
714
            runbzr('remove d2/link1')
729
715
            assert self.capture('unknowns') == 'd2/link1\n'
730
716
            runbzr(['commit', '-m', '5: remove d2/link1'])
 
717
            # try with the rm alias
 
718
            runbzr('add d2/link1')
 
719
            runbzr(['commit', '-m', '6: add d2/link1'])
 
720
            runbzr('rm d2/link1')
 
721
            assert self.capture('unknowns') == 'd2/link1\n'
 
722
            runbzr(['commit', '-m', '7: remove d2/link1'])
731
723
    
732
724
            os.mkdir("d1")
733
725
            runbzr('add d1')
734
726
            runbzr('rename d2/link3 d1/link3new')
735
727
            assert self.capture('unknowns') == 'd2/link1\n'
736
 
            runbzr(['commit', '-m', '6: remove d2/link1, move/rename link3'])
 
728
            runbzr(['commit', '-m', '8: remove d2/link1, move/rename link3'])
737
729
            
738
730
            runbzr(['check'])
739
731
            
771
763
            assert listdir_sorted("d2")== [ "link3" ]
772
764
            chdir("..")
773
765
            
774
 
            runbzr(['export', '-r', '6', 'exp6.tmp'])
 
766
            runbzr(['export', '-r', '8', 'exp6.tmp'])
775
767
            chdir("exp6.tmp")
776
 
            assert listdir_sorted(".") == [ "d1", "d2", "link2" ]
 
768
            self.assertEqual(listdir_sorted("."), [ "d1", "d2", "link2"])
777
769
            assert listdir_sorted("d1") == [ "link3new" ]
778
770
            assert listdir_sorted("d2") == []
779
771
            assert os.readlink("d1/link3new") == "NOWHERE3"