~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/blackbox.py

  • Committer: Robert Collins
  • Date: 2005-09-12 12:39:58 UTC
  • mfrom: (1185.3.4)
  • mto: (1185.1.10)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: robertc@robertcollins.net-20050912123958-7982e808f291f439
merge up with head

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
"""
28
28
 
29
29
import sys
 
30
import os
30
31
 
31
32
from bzrlib.selftest import TestCaseInTempDir, BzrTestBase
32
33
from bzrlib.branch import Branch
122
123
        assert file('.bzrignore', 'rb').read() == '*.blah\ngarh\n'
123
124
 
124
125
    def test_revert(self):
125
 
        import os
126
126
        self.runbzr('init')
127
127
 
128
128
        file('hello', 'wt').write('foo')
194
194
 
195
195
    def test_merge(self):
196
196
        from bzrlib.branch import Branch
197
 
        import os
198
197
        
199
198
        os.mkdir('a')
200
199
        os.chdir('a')
216
215
        a = Branch('.')
217
216
        b = Branch('../b')
218
217
        a.get_revision_xml(b.last_patch())
219
 
        print "Pending: %s" % a.pending_merges()
220
 
#        assert a.pending_merges() == [b.last_patch()], "Assertion %s %s" \
221
 
#        % (a.pending_merges(), b.last_patch())
 
218
        self.log('pending merges: %s', a.pending_merges())
 
219
        #        assert a.pending_merges() == [b.last_patch()], "Assertion %s %s" \
 
220
        #        % (a.pending_merges(), b.last_patch())
 
221
 
 
222
    def test_pull(self):
 
223
        """Pull changes from one branch to another."""
 
224
        os.mkdir('a')
 
225
        os.chdir('a')
 
226
 
 
227
        self.example_branch()
 
228
        os.chdir('..')
 
229
        self.runbzr('branch a b')
 
230
        os.chdir('b')
 
231
        self.runbzr('commit -m blah --unchanged')
 
232
        os.chdir('../a')
 
233
        a = Branch('.')
 
234
        b = Branch('../b')
 
235
        assert a.revision_history() == b.revision_history()[:-1]
 
236
        self.runbzr('pull ../b')
 
237
        assert a.revision_history() == b.revision_history()
 
238
        self.runbzr('commit -m blah2 --unchanged')
 
239
        os.chdir('../b')
 
240
        self.runbzr('commit -m blah3 --unchanged')
 
241
        self.runbzr('pull ../a', retcode=1)
 
242
        os.chdir('../a')
 
243
        self.runbzr('merge ../b')
 
244
        self.runbzr('commit -m blah4 --unchanged')
 
245
        os.chdir('../b')
 
246
        self.runbzr('pull ../a')
 
247
        assert a.revision_history()[-1] == b.revision_history()[-1]
 
248
        
 
249
 
 
250
    def test_add_reports(self):
 
251
        """add command prints the names of added files."""
 
252
        b = Branch('.', init=True)
 
253
        self.build_tree(['top.txt', 'dir/', 'dir/sub.txt'])
 
254
 
 
255
        from cStringIO import StringIO
 
256
        out = StringIO()
 
257
 
 
258
        ret = self.apply_redirected(None, out, None,
 
259
                                    run_bzr,
 
260
                                    ['add'])
 
261
        self.assertEquals(ret, 0)
 
262
 
 
263
        # the ordering is not defined at the moment
 
264
        results = sorted(out.getvalue().rstrip('\n').split('\n'))
 
265
        self.assertEquals(['added dir',
 
266
                           'added dir/sub.txt',
 
267
                           'added top.txt',],
 
268
                          results)
 
269
 
222
270
 
223
271
class OldTests(ExternalBase):
224
272
    """old tests moved from ./testbzr."""
226
274
    def test_bzr(self):
227
275
        from os import chdir, mkdir
228
276
        from os.path import exists
229
 
        import os
230
277
 
231
278
        runbzr = self.runbzr
232
279
        backtick = self.backtick