/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
7296.5.2 by Jelmer Vernooij
Import the patch command.
1
# Copyright (C) 2019 Breezy Developers
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 breezy.tests import TestCaseWithTransport
19
20
21
class TestPatch(TestCaseWithTransport):
22
23
    def test_patch(self):
24
        self.run_bzr('init')
25
        with open('myfile', 'w') as f:
26
            f.write('hello')
27
        self.run_bzr('add')
28
        self.run_bzr('commit -m hello')
29
        with open('myfile', 'w') as f:
30
            f.write('goodbye')
31
        with open('mypatch', 'w') as f:
32
            f.write(self.run_bzr('diff -p1', retcode=1)[0])
33
        self.run_bzr('revert')
34
        self.assertFileEqual('hello', 'myfile')
35
        self.run_bzr('patch -p1 --silent mypatch')
36
        self.assertFileEqual('goodbye', 'myfile')
7336.1.1 by Jelmer Vernooij
Print sensible error message when an invalid argument is specified for an option.
37
38
    def test_patch_invalid_strip(self):
39
        self.run_bzr_error(
40
            args="patch --strip=a",
41
            error_regexes=[
42
                'brz: ERROR: invalid value for option -p/--strip: a'])