~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_diff.py

  • Committer: Robert Collins
  • Date: 2006-02-28 04:52:34 UTC
  • mfrom: (1583 +trunk)
  • mto: (1594.2.4 integration)
  • mto: This revision was merged to the branch mainline in revision 1596.
  • Revision ID: robertc@robertcollins.net-20060228045234-d1856c4499648fb7
merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
        os.unlink('moo')
51
51
        self.runbzr('diff')
52
52
 
53
 
    def test_diff_branches(self):
 
53
    def example_branches(self):
54
54
        self.build_tree(['branch1/', 'branch1/file'], line_endings='binary')
55
55
        self.capture('init branch1')
56
56
        self.capture('add branch1/file')
58
58
        self.capture('branch branch1 branch2')
59
59
        print >> open('branch2/file', 'wb'), 'new content'
60
60
        self.run_bzr_captured(['commit', '-m', 'update file', 'branch2'])
 
61
 
 
62
    def test_diff_branches(self):
 
63
        self.example_branches()
61
64
        # should open branch1 and diff against branch2, 
62
65
        output = self.run_bzr_captured(['diff', '-r', 'branch:branch2', 
63
66
                                        'branch1'],
79
82
                              "+contents of branch1/file\n"
80
83
                              "\n", ''), output)
81
84
 
82
 
    def test_diff_to_working_tree(self):
 
85
    def example_branch2(self):
83
86
        self.build_tree(['branch1/', 'branch1/file1'], line_endings='binary')
84
87
        self.capture('init branch1')
85
88
        self.capture('add branch1/file1')
88
91
        
89
92
        print >> open('branch1/file1', 'wb'), 'repo line'
90
93
        self.run_bzr_captured(['commit', '-m', 'second commit', 'branch1'])
 
94
 
 
95
    def test_diff_to_working_tree(self):
 
96
        self.example_branch2()
91
97
        
92
98
        print >> open('branch1/file1', 'wb'), 'new line'
93
99
        output = self.run_bzr_captured(['diff', '-r', '1..', 'branch1'], retcode=1)
94
100
        self.assertTrue('\n-original line\n+new line\n' in output[0])
 
101
 
 
102
 
 
103
class TestCheckoutDiff(TestDiff):
 
104
 
 
105
    def example_branch(self):
 
106
        super(TestCheckoutDiff, self).example_branch()
 
107
        self.runbzr('checkout . checkout')
 
108
        os.chdir('checkout')
 
109
 
 
110
    def example_branch2(self):
 
111
        super(TestCheckoutDiff, self).example_branch2()
 
112
        os.mkdir('checkouts')
 
113
        self.runbzr('checkout branch1 checkouts/branch1')
 
114
        os.chdir('checkouts')
 
115
 
 
116
    def example_branches(self):
 
117
        super(TestCheckoutDiff, self).example_branches()
 
118
        os.mkdir('checkouts')
 
119
        self.runbzr('checkout branch1 checkouts/branch1')
 
120
        self.runbzr('checkout branch2 checkouts/branch2')
 
121
        os.chdir('checkouts')