/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/test_cmdline.py

  • Committer: Vincent Ladeuil
  • Date: 2009-10-06 14:40:37 UTC
  • mto: (4728.1.2 integration)
  • mto: This revision was merged to the branch mainline in revision 4731.
  • Revision ID: v.ladeuil+lp@free.fr-20091006144037-o76rgosv9hj3td0y
Simplify mutable_tree.has_changes() and update call sites.

* bzrlib/workingtree.py:
(WorkingTree.merge_from_branch): Add a force parameter. Replace
the check_basis() call by the corresponding code, taken the new
'force' parameter into account.

* bzrlib/tests/test_status.py:
(TestStatus.make_multiple_pending_tree): Add force=True on
supplementary merges.

* bzrlib/tests/test_reconfigure.py:
(TestReconfigure): Add a test for pending merges.

* bzrlib/tests/test_msgeditor.py:
(MsgEditorTest.make_multiple_pending_tree): Add force=True on
supplementary merges.

* bzrlib/tests/blackbox/test_uncommit.py:
(TestUncommit.test_uncommit_octopus_merge): Add force=True on
supplementary merges.

* bzrlib/send.py:
(send): Use the simplified has_changes(). Fix typo in comment too.

* bzrlib/reconfigure.py:
(Reconfigure._check): Use the simplified has_changes().

* bzrlib/mutabletree.py:
(MutableTree.has_changes): Make the tree parameter optional but
retain it for tests. Add a pending merges check.

* bzrlib/merge.py:
(Merger.ensure_revision_trees, Merger.file_revisions,
Merger.check_basis, Merger.compare_basis): Deprecate.

* bzrlib/bundle/apply_bundle.py:
(merge_bundle): Replace the check_basis() call by the
corresponding code.

* bzrlib/builtins.py:
(cmd_remove_tree.run, cmd_push.run, cmd_merge.run): Use the
simplified has_changes().
(cmd_merge.run): Replace the check_basis call() by the corresponding
code (minus the alredy done has_changes() check).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2010 Canonical Ltd
2
 
#
3
 
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License as published by
5
 
# the Free Software Foundation; either version 2 of the License, or
6
 
# (at your option) any later version.
7
 
#
8
 
# This program is distributed in the hope that it will be useful,
9
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
# GNU General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU General Public License
14
 
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
 
18
 
from bzrlib import (
19
 
    cmdline,
20
 
    tests)
21
 
 
22
 
class TestSplitter(tests.TestCase):
23
 
 
24
 
    def assertAsTokens(self, expected, line, single_quotes_allowed=False):
25
 
        s = cmdline.Splitter(line, single_quotes_allowed=single_quotes_allowed)
26
 
        self.assertEqual(expected, list(s))
27
 
 
28
 
    def test_simple(self):
29
 
        self.assertAsTokens([(False, u'foo'), (False, u'bar'), (False, u'baz')],
30
 
                            u'foo bar baz')
31
 
 
32
 
    def test_ignore_multiple_spaces(self):
33
 
        self.assertAsTokens([(False, u'foo'), (False, u'bar')], u'foo  bar')
34
 
 
35
 
    def test_ignore_leading_space(self):
36
 
        self.assertAsTokens([(False, u'foo'), (False, u'bar')], u'  foo bar')
37
 
 
38
 
    def test_ignore_trailing_space(self):
39
 
        self.assertAsTokens([(False, u'foo'), (False, u'bar')], u'foo bar  ')
40
 
 
41
 
    def test_posix_quotations(self):
42
 
        self.assertAsTokens([(True, u'foo bar')], u"'foo bar'",
43
 
            single_quotes_allowed=True)
44
 
        self.assertAsTokens([(True, u'foo bar')], u"'fo''o b''ar'",
45
 
            single_quotes_allowed=True)
46
 
        self.assertAsTokens([(True, u'foo bar')], u'"fo""o b""ar"',
47
 
            single_quotes_allowed=True)
48
 
        self.assertAsTokens([(True, u'foo bar')], u'"fo"\'o b\'"ar"',
49
 
            single_quotes_allowed=True)
50
 
 
51
 
    def test_nested_quotations(self):
52
 
        self.assertAsTokens([(True, u'foo"" bar')], u"\"foo\\\"\\\" bar\"")
53
 
        self.assertAsTokens([(True, u'foo\'\' bar')], u"\"foo'' bar\"")
54
 
        self.assertAsTokens([(True, u'foo\'\' bar')], u"\"foo'' bar\"",
55
 
            single_quotes_allowed=True)
56
 
        self.assertAsTokens([(True, u'foo"" bar')], u"'foo\"\" bar'",
57
 
            single_quotes_allowed=True)
58
 
 
59
 
    def test_empty_result(self):
60
 
        self.assertAsTokens([], u'')
61
 
        self.assertAsTokens([], u'    ')
62
 
 
63
 
    def test_quoted_empty(self):
64
 
        self.assertAsTokens([(True, '')], u'""')
65
 
        self.assertAsTokens([(False, u"''")], u"''")
66
 
        self.assertAsTokens([(True, '')], u"''", single_quotes_allowed=True)
67
 
 
68
 
    def test_unicode_chars(self):
69
 
        self.assertAsTokens([(False, u'f\xb5\xee'), (False, u'\u1234\u3456')],
70
 
                             u'f\xb5\xee \u1234\u3456')
71
 
 
72
 
    def test_newline_in_quoted_section(self):
73
 
        self.assertAsTokens([(True, u'foo\nbar\nbaz\n')], u'"foo\nbar\nbaz\n"')
74
 
        self.assertAsTokens([(True, u'foo\nbar\nbaz\n')], u"'foo\nbar\nbaz\n'",
75
 
            single_quotes_allowed=True)
76
 
 
77
 
    def test_escape_chars(self):
78
 
        self.assertAsTokens([(False, u'foo\\bar')], u'foo\\bar')
79
 
 
80
 
    def test_escape_quote(self):
81
 
        self.assertAsTokens([(True, u'foo"bar')], u'"foo\\"bar"')
82
 
        self.assertAsTokens([(True, u'foo\\"bar')], u'"foo\\\\\\"bar"')
83
 
        self.assertAsTokens([(True, u'foo\\bar')], u'"foo\\\\"bar"')
84
 
 
85
 
    def test_double_escape(self):
86
 
        self.assertAsTokens([(True, u'foo\\\\bar')], u'"foo\\\\bar"')
87
 
        self.assertAsTokens([(False, u'foo\\\\bar')], u"foo\\\\bar")
88
 
 
89
 
    def test_multiple_quoted_args(self):
90
 
        self.assertAsTokens([(True, u'x x'), (True, u'y y')],
91
 
            u'"x x" "y y"')
92
 
        self.assertAsTokens([(True, u'x x'), (True, u'y y')],
93
 
            u'"x x" \'y y\'', single_quotes_allowed=True)