/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2012-01-23 19:08:05 UTC
  • mfrom: (6437.3.20 2.5)
  • mto: This revision was merged to the branch mainline in revision 6450.
  • Revision ID: jelmer@samba.org-20120123190805-hlcuihkt2dep44cw
merge bzr 2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006-2012 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
36
36
    features,
37
37
    )
38
38
from bzrlib.tests import TestCaseWithTransport
 
39
from bzrlib.tests.matchers import ContainsNoVfsCalls
39
40
 
40
41
 
41
42
class TestCommit(TestCaseWithTransport):
327
328
        finally:
328
329
            other_tree.unlock()
329
330
        this_tree.merge_from_branch(other_tree.branch)
330
 
        os.chdir('this')
331
 
        out,err = self.run_bzr('commit -m added')
 
331
        out, err = self.run_bzr('commit -m added', working_dir='this')
332
332
        self.assertEqual('', out)
333
333
        self.assertEqual(set([
334
 
            'Committing to: %s/' % osutils.getcwd(),
 
334
            'Committing to: %s/' % osutils.pathjoin(osutils.getcwd(), 'this'),
335
335
            'modified filetomodify',
336
336
            'added newdir',
337
337
            'added newfile',
471
471
        t.add(['file-a', 'dir-a', 'dir-a/file-b'])
472
472
        t.commit('Create')
473
473
        t.remove(['file-a', 'dir-a/file-b'])
474
 
        os.chdir('dir-a')
475
 
        result = self.run_bzr('commit . -m removed-file-b')[1]
 
474
        result = self.run_bzr('commit . -m removed-file-b',
 
475
                              working_dir='dir-a')[1]
476
476
        self.assertNotContainsRe(result, 'file-a')
477
 
        result = self.run_bzr('status')[0]
 
477
        result = self.run_bzr('status', working_dir='dir-a')[0]
478
478
        self.assertContainsRe(result, 'removed:\n  file-a')
479
479
 
480
480
    def test_strict_commit(self):
484
484
        self.build_tree(['tree/a'])
485
485
        tree.add('a')
486
486
        # A simple change should just work
487
 
        self.run_bzr('commit --strict -m adding-a',
488
 
                     working_dir='tree')
 
487
        self.run_bzr('commit --strict -m adding-a', working_dir='tree')
489
488
 
490
489
    def test_strict_commit_no_changes(self):
491
490
        """commit --strict gives "no changes" if there is nothing to commit"""
829
828
        """Ensure commit error if username is not set.
830
829
        """
831
830
        self.run_bzr(['init', 'foo'])
832
 
        os.chdir('foo')
833
 
        open('foo.txt', 'w').write('hello')
834
 
        self.run_bzr(['add'])
 
831
        with open('foo/foo.txt', 'w') as f:
 
832
            f.write('hello')
 
833
        self.run_bzr(['add'], working_dir='foo')
835
834
        self.overrideEnv('EMAIL', None)
836
835
        self.overrideEnv('BZR_EMAIL', None)
837
836
        # Also, make sure that it's not inferred from mailname.
838
837
        self.overrideAttr(config, '_auto_user_id',
839
838
            lambda: (None, None))
840
 
        out, err = self.run_bzr(['commit', '-m', 'initial'], 3)
841
 
        self.assertContainsRe(err, 'Unable to determine your name')
 
839
        self.run_bzr_error(
 
840
            ['Unable to determine your name'],
 
841
            ['commit', '-m', 'initial'], working_dir='foo')
842
842
 
843
843
    def test_commit_recursive_checkout(self):
844
844
        """Ensure that a commit to a recursive checkout fails cleanly.
845
845
        """
846
846
        self.run_bzr(['init', 'test_branch'])
847
847
        self.run_bzr(['checkout', 'test_branch', 'test_checkout'])
848
 
        os.chdir('test_checkout')
849
 
        self.run_bzr(['bind', '.']) # bind to self
850
 
        open('foo.txt', 'w').write('hello')
851
 
        self.run_bzr(['add'])
852
 
        out, err = self.run_bzr(['commit', '-m', 'addedfoo'], 3)
853
 
        self.assertEqual(out, '')
854
 
        self.assertContainsRe(err,
855
 
            'Branch.*test_checkout.*appears to be bound to itself')
 
848
        self.run_bzr(['bind', '.'], working_dir='test_checkout') # bind to self
 
849
        with open('test_checkout/foo.txt', 'w') as f:
 
850
            f.write('hello')
 
851
        self.run_bzr(['add'], working_dir='test_checkout')
 
852
        out, err = self.run_bzr_error(
 
853
            ['Branch.*test_checkout.*appears to be bound to itself'],
 
854
            ['commit', '-m', 'addedfoo'], working_dir='test_checkout')
 
855
 
 
856
    def test_mv_dirs_non_ascii(self):
 
857
        """Move directory with non-ascii name and containing files.
 
858
 
 
859
        Regression test for bug 185211.
 
860
        """
 
861
        tree = self.make_branch_and_tree('.')
 
862
        self.build_tree([u'abc\xa7/', u'abc\xa7/foo'])
 
863
 
 
864
        tree.add([u'abc\xa7/', u'abc\xa7/foo'])
 
865
        tree.commit('checkin')
 
866
 
 
867
        tree.rename_one(u'abc\xa7','abc')
 
868
 
 
869
        self.run_bzr('ci -m "non-ascii mv"')
856
870
 
857
871
 
858
872
class TestSmartServerCommit(TestCaseWithTransport):
873
887
        # being too low. If rpc_count increases, more network roundtrips have
874
888
        # become necessary for this use case. Please do not adjust this number
875
889
        # upwards without agreement from bzr's network support maintainers.
876
 
        self.assertLength(220, self.hpss_calls)
 
890
        self.assertLength(214, self.hpss_calls)
 
891
        self.assertLength(2, self.hpss_connections)
 
892
        self.expectFailure("commit still uses VFS calls",
 
893
            self.assertThat, self.hpss_calls, ContainsNoVfsCalls)