/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 breezy/tests/blackbox/test_commit.py

  • Committer: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    msgeditor,
32
32
    )
33
33
from ...controldir import ControlDir
34
 
from ...sixish import PY3
35
34
from .. import (
36
35
    test_foreign,
37
36
    features,
38
37
    )
39
38
from .. import TestCaseWithTransport
40
 
from ..matchers import ContainsNoVfsCalls
 
39
from ..test_bedding import override_whoami
41
40
 
42
41
 
43
42
class TestCommit(TestCaseWithTransport):
146
145
        out, err = self.run_bzr(['commit', '-m', file_name])
147
146
        reflags = re.MULTILINE | re.DOTALL | re.UNICODE
148
147
        te = osutils.get_terminal_encoding()
149
 
        self.assertContainsRe(err if PY3 else err.decode(te),
 
148
        self.assertContainsRe(err,
150
149
                              u'The commit message is a file name:',
151
150
                              flags=reflags)
152
151
 
165
164
            out, err = self.run_bzr(['commit', '-m', file_name])
166
165
            reflags = re.MULTILINE | re.DOTALL | re.UNICODE
167
166
            te = osutils.get_terminal_encoding()
168
 
            self.assertContainsRe(err if PY3 else err.decode(te, 'replace'),
 
167
            self.assertContainsRe(err,
169
168
                                  u'The commit message is a file name:',
170
169
                                  flags=reflags)
171
170
        finally:
187
186
        tree.add(["f"])
188
187
        out, err = self.run_bzr_raw(["commit", "-m", "Wrong filename", u"\xa7"],
189
188
                                    encoding="iso-8859-5", retcode=3)
190
 
        if not PY3:
191
 
            self.expectFailure("Error messages are always written as UTF-8",
192
 
                               self.assertNotContainsString, err, b"\xc2\xa7")
193
 
        else:
194
 
            self.assertNotContainsString(err, b"\xc2\xa7")
 
189
        self.assertNotContainsString(err, b"\xc2\xa7")
195
190
        self.assertContainsRe(err, b"(?m)not versioned: \"\xfd\"$")
196
191
 
197
192
    def test_warn_about_forgotten_commit_message(self):
315
310
        this_tree.commit('create_files')
316
311
        other_dir = this_tree.controldir.sprout('other')
317
312
        other_tree = other_dir.open_workingtree()
318
 
        other_tree.lock_write()
319
 
        # perform the needed actions on the files and dirs.
320
 
        try:
 
313
        with other_tree.lock_write():
 
314
            # perform the needed actions on the files and dirs.
321
315
            other_tree.rename_one('dirtorename', 'renameddir')
322
316
            other_tree.rename_one('dirtoreparent', 'renameddir/reparenteddir')
323
317
            other_tree.rename_one('filetorename', 'renamedfile')
331
325
            other_tree.add('newfile')
332
326
            other_tree.add('newdir/')
333
327
            other_tree.commit('modify all sample files and dirs.')
334
 
        finally:
335
 
            other_tree.unlock()
336
328
        this_tree.merge_from_branch(other_tree.branch)
337
329
        out, err = self.run_bzr('commit -m added', working_dir='this')
338
330
        self.assertEqual('', out)
868
860
        with open('foo/foo.txt', 'w') as f:
869
861
            f.write('hello')
870
862
        self.run_bzr(['add'], working_dir='foo')
871
 
        self.overrideEnv('EMAIL', None)
872
 
        self.overrideEnv('BRZ_EMAIL', None)
873
 
        # Also, make sure that it's not inferred from mailname.
874
 
        self.overrideAttr(config, '_auto_user_id',
875
 
                          lambda: (None, None))
 
863
        override_whoami(self)
876
864
        self.run_bzr_error(
877
865
            ['Unable to determine your name'],
878
866
            ['commit', '-m', 'initial'], working_dir='foo')
906
894
 
907
895
        self.run_bzr('ci -m "non-ascii mv"')
908
896
 
909
 
 
910
 
class TestSmartServerCommit(TestCaseWithTransport):
911
 
 
912
 
    def test_commit_to_lightweight(self):
913
 
        self.setup_smart_server_with_call_log()
914
 
        t = self.make_branch_and_tree('from')
915
 
        for count in range(9):
916
 
            t.commit(message='commit %d' % count)
917
 
        out, err = self.run_bzr(['checkout', '--lightweight', self.get_url('from'),
918
 
                                 'target'])
919
 
        self.reset_smart_call_log()
920
 
        self.build_tree(['target/afile'])
921
 
        self.run_bzr(['add', 'target/afile'])
922
 
        out, err = self.run_bzr(['commit', '-m', 'do something', 'target'])
923
 
        # This figure represent the amount of work to perform this use case. It
924
 
        # is entirely ok to reduce this number if a test fails due to rpc_count
925
 
        # being too low. If rpc_count increases, more network roundtrips have
926
 
        # become necessary for this use case. Please do not adjust this number
927
 
        # upwards without agreement from bzr's network support maintainers.
928
 
        self.assertLength(211, self.hpss_calls)
929
 
        self.assertLength(2, self.hpss_connections)
930
 
        self.expectFailure("commit still uses VFS calls",
931
 
                           self.assertThat, self.hpss_calls, ContainsNoVfsCalls)