/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: Jelmer Vernooij
  • Date: 2017-05-21 19:09:26 UTC
  • mfrom: (6622.1.36 breezy)
  • Revision ID: jelmer@jelmer.uk-20170521190926-5vtz8xaf0e9ylrpc
Merge rename to breezy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
from testtools.matchers import DocTestMatches
26
26
 
27
 
from bzrlib import (
 
27
from breezy import (
28
28
    config,
29
29
    osutils,
30
30
    ignores,
31
31
    msgeditor,
32
32
    )
33
 
from bzrlib.controldir import ControlDir
34
 
from bzrlib.tests import (
 
33
from breezy.controldir import ControlDir
 
34
from breezy.tests import (
35
35
    test_foreign,
36
36
    features,
37
37
    )
38
 
from bzrlib.tests import TestCaseWithTransport
39
 
from bzrlib.tests.matchers import ContainsNoVfsCalls
 
38
from breezy.tests import TestCaseWithTransport
 
39
from breezy.tests.matchers import ContainsNoVfsCalls
40
40
 
41
41
 
42
42
class TestCommit(TestCaseWithTransport):
50
50
        self.assertEqual('', out)
51
51
        # Two ugly bits here.
52
52
        # 1) We really don't want 'aborting commit write group' anymore.
53
 
        # 2) bzr: ERROR: is a really long line, so we wrap it with '\'
 
53
        # 2) brz: ERROR: is a really long line, so we wrap it with '\'
54
54
        self.assertThat(
55
55
            err,
56
56
            DocTestMatches("""\
57
57
Committing to: ...
58
 
bzr: ERROR: No changes to commit.\
59
 
 Please 'bzr add' the files you want to commit,\
 
58
brz: ERROR: No changes to commit.\
 
59
 Please 'brz add' the files you want to commit,\
60
60
 or use --unchanged to force an empty commit.
61
61
""", flags=doctest.ELLIPSIS|doctest.REPORT_UDIFF))
62
62
 
262
262
 
263
263
    def test_commit_sanitizes_CR_in_message(self):
264
264
        # See bug #433779, basically Emacs likes to pass '\r\n' style line
265
 
        # endings to 'bzr commit -m ""' which breaks because we don't allow
 
265
        # endings to 'brz commit -m ""' which breaks because we don't allow
266
266
        # '\r' in commit messages. (Mostly because of issues where XML style
267
267
        # formats arbitrarily strip it out of the data while parsing.)
268
268
        # To make life easier for users, we just always translate '\r\n' =>
280
280
 
281
281
    def test_commit_merge_reports_all_modified_files(self):
282
282
        # the commit command should show all the files that are shown by
283
 
        # bzr diff or bzr status when committing, even when they were not
 
283
        # brz diff or brz status when committing, even when they were not
284
284
        # changed by the user but rather through doing a merge.
285
285
        this_tree = self.make_branch_and_tree('this')
286
286
        # we need a bunch of files and dirs, to perform one action on each.
378
378
        # commit to the original branch to make the checkout out of date
379
379
        tree.commit('message branch', allow_pointless=True)
380
380
        # now commit to the checkout should emit
381
 
        # ERROR: Out of date with the branch, 'bzr update' is suggested
 
381
        # ERROR: Out of date with the branch, 'brz update' is suggested
382
382
        output = self.run_bzr('commit --unchanged -m checkout_message '
383
383
                             'checkout', retcode=3)
384
384
        self.assertEqual(output,
385
385
                         ('',
386
 
                          "bzr: ERROR: Working tree is out of date, please "
387
 
                          "run 'bzr update'.\n"))
 
386
                          "brz: ERROR: Working tree is out of date, please "
 
387
                          "run 'brz update'.\n"))
388
388
 
389
389
    def test_local_commit_unbound(self):
390
390
        # a --local commit on an unbound branch is an error
391
391
        self.make_branch_and_tree('.')
392
392
        out, err = self.run_bzr('commit --local', retcode=3)
393
393
        self.assertEqualDiff('', out)
394
 
        self.assertEqualDiff('bzr: ERROR: Cannot perform local-only commits '
 
394
        self.assertEqualDiff('brz: ERROR: Cannot perform local-only commits '
395
395
                             'on unbound branches.\n', err)
396
396
 
397
397
    def test_commit_a_text_merge_in_a_checkout(self):
621
621
        self.build_tree(['tree/hello.txt'])
622
622
        tree.add('hello.txt')
623
623
        self.run_bzr_error(
624
 
            ["bzr: ERROR: No tracker specified for bug 123. Use the form "
 
624
            ["brz: ERROR: No tracker specified for bug 123. Use the form "
625
625
            "'tracker:id' or specify a default bug tracker using the "
626
626
            "`bugtracker` option.\n"
627
 
            "See \"bzr help bugs\" for more information on this feature. "
 
627
            "See \"brz help bugs\" for more information on this feature. "
628
628
            "Commit refused."],
629
629
            'commit -m add-b --fixes=123',
630
630
            working_dir='tree')
640
640
        tree.add('hello.txt')
641
641
        self.run_bzr_error(
642
642
            ["Did not understand bug identifier orange: Must be an integer. "
643
 
             "See \"bzr help bugs\" for more information on this feature.\n"
 
643
             "See \"brz help bugs\" for more information on this feature.\n"
644
644
             "Commit refused."],
645
645
            'commit -m add-b --fixes=lp:orange',
646
646
            working_dir='tree')
652
652
        tree.add('hello.txt')
653
653
        self.run_bzr_error(
654
654
            [r"Invalid bug orange:apples:bananas. Must be in the form of "
655
 
             r"'tracker:id'\. See \"bzr help bugs\" for more information on "
 
655
             r"'tracker:id'\. See \"brz help bugs\" for more information on "
656
656
             r"this feature.\nCommit refused\."],
657
657
            'commit -m add-b --fixes=orange:apples:bananas',
658
658
            working_dir='tree')
754
754
        out, err = self.run_bzr("commit -m hello "
755
755
            "--commit-time='NOT A TIME' tree/hello.txt", retcode=3)
756
756
        self.assertStartsWith(
757
 
            err, "bzr: ERROR: Could not parse --commit-time:")
 
757
            err, "brz: ERROR: Could not parse --commit-time:")
758
758
 
759
759
    def test_commit_time_missing_tz(self):
760
760
        tree = self.make_branch_and_tree('tree')
763
763
        out, err = self.run_bzr("commit -m hello "
764
764
            "--commit-time='2009-10-10 08:00:00' tree/hello.txt", retcode=3)
765
765
        self.assertStartsWith(
766
 
            err, "bzr: ERROR: Could not parse --commit-time:")
 
766
            err, "brz: ERROR: Could not parse --commit-time:")
767
767
        # Test that it is actually checking and does not simply crash with
768
768
        # some other exception
769
769
        self.assertContainsString(err, "missing a timezone offset")
796
796
        out, err = self.run_bzr(['commit', '--unchanged', '-mfoo', 'checkout'],
797
797
            retcode=3)
798
798
        self.assertContainsRe(err,
799
 
            r'^bzr: ERROR: Cannot lock.*readonly transport')
 
799
            r'^brz: ERROR: Cannot lock.*readonly transport')
800
800
 
801
801
    def setup_editor(self):
802
802
        # Test that commit template hooks work
804
804
            f = file('fed.bat', 'w')
805
805
            f.write('@rem dummy fed')
806
806
            f.close()
807
 
            self.overrideEnv('BZR_EDITOR', "fed.bat")
 
807
            self.overrideEnv('BRZ_EDITOR', "fed.bat")
808
808
        else:
809
809
            f = file('fed.sh', 'wb')
810
810
            f.write('#!/bin/sh\n')
811
811
            f.close()
812
812
            os.chmod('fed.sh', 0755)
813
 
            self.overrideEnv('BZR_EDITOR', "./fed.sh")
 
813
            self.overrideEnv('BRZ_EDITOR', "./fed.sh")
814
814
 
815
815
    def setup_commit_with_template(self):
816
816
        self.setup_editor()
829
829
        out, err = self.run_bzr("commit tree/hello.txt", retcode=3,
830
830
            stdin="y\n")
831
831
        self.assertContainsRe(err,
832
 
            "bzr: ERROR: Empty commit message specified")
 
832
            "brz: ERROR: Empty commit message specified")
833
833
 
834
834
    def test_commit_hook_template_accepted(self):
835
835
        tree = self.setup_commit_with_template()
865
865
            f.write('hello')
866
866
        self.run_bzr(['add'], working_dir='foo')
867
867
        self.overrideEnv('EMAIL', None)
868
 
        self.overrideEnv('BZR_EMAIL', None)
 
868
        self.overrideEnv('BRZ_EMAIL', None)
869
869
        # Also, make sure that it's not inferred from mailname.
870
870
        self.overrideAttr(config, '_auto_user_id',
871
871
            lambda: (None, None))