~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-09-05 02:36:00 UTC
  • mfrom: (2747.6.13 52479)
  • Revision ID: pqm@pqm.ubuntu.com-20070905023600-6h6s51el362b171a
The location being committed to is displayed.  (Daniel Watkins, #52479)

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
        self.build_tree(['hello.txt'])
36
36
        out,err = self.run_bzr('commit -m empty', retcode=3)
37
37
        self.assertEqual('', out)
38
 
        self.assertStartsWith(err, 'bzr: ERROR: no changes to commit.'
 
38
        self.assertContainsRe(err, 'bzr: ERROR: no changes to commit\.'
39
39
                                  ' use --unchanged to commit anyhow\n')
40
40
 
41
41
    def test_commit_success(self):
75
75
        tree.add("hello.txt")
76
76
        out,err = self.run_bzr('commit -m added')
77
77
        self.assertEqual('', out)
78
 
        self.assertEqual('added hello.txt\n'
79
 
                         'Committed revision 1.\n',
80
 
                         err)
 
78
        self.assertContainsRe(err, '^Committing revision 1 to ".*"\.\n'
 
79
                              'added hello.txt\n'
 
80
                              'Committed revision 1.\n$',)
81
81
 
82
82
    def prepare_simple_history(self):
83
83
        """Prepare and return a working tree with one commit of one file"""
94
94
        self.build_tree_contents([('hello.txt', 'new contents')])
95
95
        out, err = self.run_bzr('commit -m modified')
96
96
        self.assertEqual('', out)
97
 
        self.assertEqual('modified hello.txt\n'
98
 
                         'Committed revision 2.\n',
99
 
                         err)
 
97
        self.assertContainsRe(err, '^Committing revision 2 to ".*"\.\n'
 
98
                              'modified hello\.txt\n'
 
99
                              'Committed revision 2\.\n$')
100
100
 
101
101
    def test_verbose_commit_renamed(self):
102
102
        # Verbose commit of renamed file should say so
104
104
        wt.rename_one('hello.txt', 'gutentag.txt')
105
105
        out, err = self.run_bzr('commit -m renamed')
106
106
        self.assertEqual('', out)
107
 
        self.assertEqual('renamed hello.txt => gutentag.txt\n'
108
 
                         'Committed revision 2.\n',
109
 
                         err)
 
107
        self.assertContainsRe(err, '^Committing revision 2 to ".*"\.\n'
 
108
                              'renamed hello\.txt => gutentag\.txt\n'
 
109
                              'Committed revision 2\.$\n')
110
110
 
111
111
    def test_verbose_commit_moved(self):
112
112
        # Verbose commit of file moved to new directory should say so
116
116
        wt.rename_one('hello.txt', 'subdir/hello.txt')
117
117
        out, err = self.run_bzr('commit -m renamed')
118
118
        self.assertEqual('', out)
119
 
        self.assertEqualDiff('added subdir\n'
120
 
                             'renamed hello.txt => subdir/hello.txt\n'
121
 
                             'Committed revision 2.\n',
122
 
                             err)
 
119
        self.assertContainsRe(err, '^Committing revision 2 to ".*"\.\n'
 
120
                              'added subdir\n'
 
121
                              'renamed hello\.txt => subdir/hello\.txt\n'
 
122
                              'Committed revision 2\.\n$')
123
123
 
124
124
    def test_verbose_commit_with_unknown(self):
125
125
        """Unknown files should not be listed by default in verbose output"""
129
129
        wt.add(['hello.txt'])
130
130
        out,err = self.run_bzr('commit -m added')
131
131
        self.assertEqual('', out)
132
 
        self.assertEqual('added hello.txt\n'
133
 
                         'Committed revision 1.\n',
134
 
                         err)
 
132
        self.assertContainsRe(err, '^Committing revision 1 to ".*"\.\n'
 
133
                              'added hello\.txt\n'
 
134
                              'Committed revision 1\.\n$')
135
135
 
136
136
    def test_verbose_commit_with_unchanged(self):
137
137
        """Unchanged files should not be listed by default in verbose output"""
142
142
        tree.add("hello.txt")
143
143
        out,err = self.run_bzr('commit -m added')
144
144
        self.assertEqual('', out)
145
 
        self.assertEqual('added hello.txt\n'
146
 
                         'Committed revision 2.\n',
147
 
                         err)
 
145
        self.assertContainsRe(err, '^Committing revision 2 to ".*"\.\n'
 
146
                              'added hello\.txt\n'
 
147
                              'Committed revision 2\.$\n')
 
148
 
 
149
    def test_verbose_commit_includes_master_location(self):
 
150
        """Location of master is displayed when committing to bound branch"""
 
151
        a_tree = self.make_branch_and_tree('a')
 
152
        self.build_tree(['a/b'])
 
153
        a_tree.add('b')
 
154
        a_tree.commit(message='Initial message')
 
155
 
 
156
        b_tree = a_tree.branch.create_checkout('b')
 
157
        expected = "%s/" % (os.path.abspath('a'), )
 
158
        out, err = self.run_bzr('commit -m blah --unchanged', working_dir='b')
 
159
        self.assertEqual(err, 'Committing revision 2 to "%s".\n'
 
160
                         'Committed revision 2.\n' % expected)
148
161
 
149
162
    def test_commit_merge_reports_all_modified_files(self):
150
163
        # the commit command should show all the files that are shown by
198
211
        this_tree.merge_from_branch(other_tree.branch)
199
212
        os.chdir('this')
200
213
        out,err = self.run_bzr('commit -m added')
201
 
        os.chdir('..')
202
214
        self.assertEqual('', out)
 
215
        expected = '%s/' % (os.getcwd(), )
203
216
        self.assertEqualDiff(
 
217
            'Committing revision 2 to "%s".\n'
204
218
            'modified filetomodify\n'
205
219
            'added newdir\n'
206
220
            'added newfile\n'
210
224
            'renamed filetorename => renamedfile\n'
211
225
            'deleted dirtoremove\n'
212
226
            'deleted filetoremove\n'
213
 
            'Committed revision 2.\n',
 
227
            'Committed revision 2.\n' % (expected, ),
214
228
            err)
215
229
 
216
230
    def test_empty_commit_message(self):
367
381
        output, err = self.run_bzr(
368
382
            'commit -m hello --fixes=lp:23452 tree/hello.txt')
369
383
        self.assertEqual('', output)
370
 
        self.assertEqual('added hello.txt\nCommitted revision 1.\n', err)
 
384
        self.assertContainsRe(err, 'Committing revision 1 to ".*"\.\n'
 
385
                              'added hello\.txt\n'
 
386
                              'Committed revision 1\.\n')
371
387
 
372
388
    def test_no_bugs_no_properties(self):
373
389
        """If no bugs are fixed, the bugs property is not set.