/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/git/tests/test_blackbox.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-15 19:09:08 UTC
  • mto: This revision was merged to the branch mainline in revision 7339.
  • Revision ID: jelmer@jelmer.uk-20190615190908-gyjn0ye90vu2lhim
Print sensible error message when an invalid argument is specified for an option.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2007 David Allouche <ddaa@ddaa.net>
 
2
# Copyright (C) 2007-2018 Jelmer Vernooij <jelmer@jelmer.uk>
 
3
#
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; either version 2 of the License, or
 
7
# (at your option) any later version.
 
8
#
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program; if not, write to the Free Software
 
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
17
 
 
18
"""Black-box tests for bzr-git."""
 
19
 
 
20
from __future__ import absolute_import
 
21
 
 
22
from dulwich.repo import (
 
23
    Repo as GitRepo,
 
24
    )
 
25
 
 
26
import os
 
27
 
 
28
from ...controldir import (
 
29
    ControlDir,
 
30
    )
 
31
 
 
32
from ...tests.blackbox import ExternalBase
 
33
from ...workingtree import WorkingTree
 
34
 
 
35
from .. import (
 
36
    tests,
 
37
    )
 
38
from ...tests.features import PluginLoadedFeature
 
39
 
 
40
 
 
41
class TestGitBlackBox(ExternalBase):
 
42
 
 
43
    def simple_commit(self):
 
44
        # Create a git repository with a revision.
 
45
        repo = GitRepo.init(self.test_dir)
 
46
        builder = tests.GitBranchBuilder()
 
47
        builder.set_file('a', b'text for a\n', False)
 
48
        r1 = builder.commit(b'Joe Foo <joe@foo.com>', u'<The commit message>')
 
49
        return repo, builder.finish()[r1]
 
50
 
 
51
    def test_nick(self):
 
52
        r = GitRepo.init(self.test_dir)
 
53
        dir = ControlDir.open(self.test_dir)
 
54
        dir.create_branch()
 
55
        output, error = self.run_bzr(['nick'])
 
56
        self.assertEqual("master\n", output)
 
57
 
 
58
    def test_branches(self):
 
59
        self.simple_commit()
 
60
        output, error = self.run_bzr(['branches'])
 
61
        self.assertEqual("* master\n", output)
 
62
 
 
63
    def test_info(self):
 
64
        self.simple_commit()
 
65
        output, error = self.run_bzr(['info'])
 
66
        self.assertEqual(error, '')
 
67
        self.assertEqual(
 
68
            output,
 
69
            'Standalone tree (format: git)\n'
 
70
            'Location:\n'
 
71
            '            light checkout root: .\n'
 
72
            '  checkout of co-located branch: master\n')
 
73
 
 
74
    def test_ignore(self):
 
75
        self.simple_commit()
 
76
        output, error = self.run_bzr(['ignore', 'foo'])
 
77
        self.assertEqual(error, '')
 
78
        self.assertEqual(output, '')
 
79
        self.assertFileEqual("foo\n", ".gitignore")
 
80
 
 
81
    def test_cat_revision(self):
 
82
        self.simple_commit()
 
83
        output, error = self.run_bzr(['cat-revision', '-r-1'], retcode=3)
 
84
        self.assertContainsRe(
 
85
            error,
 
86
            'brz: ERROR: Repository .* does not support access to raw '
 
87
            'revision texts')
 
88
        self.assertEqual(output, '')
 
89
 
 
90
    def test_branch(self):
 
91
        os.mkdir("gitbranch")
 
92
        GitRepo.init(os.path.join(self.test_dir, "gitbranch"))
 
93
        os.chdir('gitbranch')
 
94
        builder = tests.GitBranchBuilder()
 
95
        builder.set_file(b'a', b'text for a\n', False)
 
96
        builder.commit(b'Joe Foo <joe@foo.com>', b'<The commit message>')
 
97
        builder.finish()
 
98
        os.chdir('..')
 
99
 
 
100
        output, error = self.run_bzr(['branch', 'gitbranch', 'bzrbranch'])
 
101
        self.assertTrue(
 
102
            (error == 'Branched 1 revision(s).\n') or
 
103
            (error == 'Branched 1 revision.\n'),
 
104
            error)
 
105
 
 
106
    def test_checkout(self):
 
107
        os.mkdir("gitbranch")
 
108
        GitRepo.init(os.path.join(self.test_dir, "gitbranch"))
 
109
        os.chdir('gitbranch')
 
110
        builder = tests.GitBranchBuilder()
 
111
        builder.set_file(b'a', b'text for a\n', False)
 
112
        builder.commit(b'Joe Foo <joe@foo.com>', b'<The commit message>')
 
113
        builder.finish()
 
114
        os.chdir('..')
 
115
 
 
116
        output, error = self.run_bzr(['checkout', 'gitbranch', 'bzrbranch'])
 
117
        self.assertEqual(error,
 
118
                         'Fetching from Git to Bazaar repository. '
 
119
                         'For better performance, fetch into a Git repository.\n')
 
120
        self.assertEqual(output, '')
 
121
 
 
122
    def test_branch_ls(self):
 
123
        self.simple_commit()
 
124
        output, error = self.run_bzr(['ls', '-r-1'])
 
125
        self.assertEqual(error, '')
 
126
        self.assertEqual(output, "a\n")
 
127
 
 
128
    def test_init(self):
 
129
        self.run_bzr("init --format=git repo")
 
130
 
 
131
    def test_info_verbose(self):
 
132
        self.simple_commit()
 
133
 
 
134
        output, error = self.run_bzr(['info', '-v'])
 
135
        self.assertEqual(error, '')
 
136
        self.assertTrue("Standalone tree (format: git)" in output)
 
137
        self.assertTrue("control: Local Git Repository" in output)
 
138
        self.assertTrue("branch: Local Git Branch" in output)
 
139
        self.assertTrue("repository: Git Repository" in output)
 
140
 
 
141
    def test_push_roundtripping(self):
 
142
        self.knownFailure("roundtripping is not yet supported")
 
143
        self.with_roundtripping()
 
144
        os.mkdir("bla")
 
145
        GitRepo.init(os.path.join(self.test_dir, "bla"))
 
146
        self.run_bzr(['init', 'foo'])
 
147
        self.run_bzr(['commit', '--unchanged', '-m', 'bla', 'foo'])
 
148
        # when roundtripping is supported
 
149
        output, error = self.run_bzr(['push', '-d', 'foo', 'bla'])
 
150
        self.assertEqual(b"", output)
 
151
        self.assertTrue(error.endswith(b"Created new branch.\n"))
 
152
 
 
153
    def test_push_lossy_non_mainline(self):
 
154
        self.run_bzr(['init', '--git', 'bla'])
 
155
        self.run_bzr(['init', 'foo'])
 
156
        self.run_bzr(['commit', '--unchanged', '-m', 'bla', 'foo'])
 
157
        self.run_bzr(['branch', 'foo', 'foo1'])
 
158
        self.run_bzr(['commit', '--unchanged', '-m', 'bla', 'foo1'])
 
159
        self.run_bzr(['commit', '--unchanged', '-m', 'bla', 'foo'])
 
160
        self.run_bzr(['merge', '-d', 'foo', 'foo1'])
 
161
        self.run_bzr(['commit', '--unchanged', '-m', 'merge', 'foo'])
 
162
        output, error = self.run_bzr(['push', '--lossy', '-r1.1.1', '-d', 'foo', 'bla'])
 
163
        self.assertEqual("", output)
 
164
        self.assertEqual(
 
165
            'Pushing from a Bazaar to a Git repository. For better '
 
166
            'performance, push into a Bazaar repository.\n'
 
167
            'Pushed up to revision 2.\n', error)
 
168
 
 
169
    def test_log(self):
 
170
        # Smoke test for "bzr log" in a git repository.
 
171
        self.simple_commit()
 
172
 
 
173
        # Check that bzr log does not fail and includes the revision.
 
174
        output, error = self.run_bzr(['log'])
 
175
        self.assertEqual(error, '')
 
176
        self.assertTrue(
 
177
            '<The commit message>' in output,
 
178
            "Commit message was not found in output:\n%s" % (output,))
 
179
 
 
180
    def test_log_verbose(self):
 
181
        # Smoke test for "bzr log -v" in a git repository.
 
182
        self.simple_commit()
 
183
 
 
184
        # Check that bzr log does not fail and includes the revision.
 
185
        output, error = self.run_bzr(['log', '-v'])
 
186
 
 
187
    def test_tags(self):
 
188
        git_repo, commit_sha1 = self.simple_commit()
 
189
        git_repo.refs[b"refs/tags/foo"] = commit_sha1
 
190
 
 
191
        output, error = self.run_bzr(['tags'])
 
192
        self.assertEqual(error, '')
 
193
        self.assertEqual(output, "foo                  1\n")
 
194
 
 
195
    def test_tag(self):
 
196
        self.simple_commit()
 
197
 
 
198
        output, error = self.run_bzr(["tag", "bar"])
 
199
 
 
200
        # bzr <= 2.2 emits this message in the output stream
 
201
        # bzr => 2.3 emits this message in the error stream
 
202
        self.assertEqual(error + output, 'Created tag bar.\n')
 
203
 
 
204
    def test_init_repo(self):
 
205
        output, error = self.run_bzr(["init", "--format=git", "bla.git"])
 
206
        self.assertEqual(error, '')
 
207
        self.assertEqual(output, 'Created a standalone tree (format: git)\n')
 
208
 
 
209
    def test_diff_format(self):
 
210
        tree = self.make_branch_and_tree('.')
 
211
        self.build_tree(['a'])
 
212
        tree.add(['a'])
 
213
        output, error = self.run_bzr(['diff', '--format=git'], retcode=1)
 
214
        self.assertEqual(error, '')
 
215
        # Some older versions of Dulwich (< 0.19.12) formatted diffs slightly differently.
 
216
        from dulwich import __version__ as dulwich_version
 
217
        if dulwich_version < (0, 19, 12):
 
218
            self.assertEqual(output,
 
219
                             'diff --git /dev/null b/a\n'
 
220
                             'old mode 0\n'
 
221
                             'new mode 100644\n'
 
222
                             'index 0000000..c197bd8 100644\n'
 
223
                             '--- /dev/null\n'
 
224
                             '+++ b/a\n'
 
225
                             '@@ -0,0 +1 @@\n'
 
226
                             '+contents of a\n')
 
227
        else:
 
228
            self.assertEqual(output,
 
229
                             'diff --git a/a b/a\n'
 
230
                             'old file mode 0\n'
 
231
                             'new file mode 100644\n'
 
232
                             'index 0000000..c197bd8 100644\n'
 
233
                             '--- /dev/null\n'
 
234
                             '+++ b/a\n'
 
235
                             '@@ -0,0 +1 @@\n'
 
236
                             '+contents of a\n')
 
237
 
 
238
    def test_git_import_uncolocated(self):
 
239
        r = GitRepo.init("a", mkdir=True)
 
240
        self.build_tree(["a/file"])
 
241
        r.stage("file")
 
242
        r.do_commit(ref=b"refs/heads/abranch",
 
243
                    committer=b"Joe <joe@example.com>", message=b"Dummy")
 
244
        r.do_commit(ref=b"refs/heads/bbranch",
 
245
                    committer=b"Joe <joe@example.com>", message=b"Dummy")
 
246
        self.run_bzr(["git-import", "a", "b"])
 
247
        self.assertEqual(
 
248
            set([".bzr", "abranch", "bbranch"]), set(os.listdir("b")))
 
249
 
 
250
    def test_git_import(self):
 
251
        r = GitRepo.init("a", mkdir=True)
 
252
        self.build_tree(["a/file"])
 
253
        r.stage("file")
 
254
        r.do_commit(ref=b"refs/heads/abranch",
 
255
                    committer=b"Joe <joe@example.com>", message=b"Dummy")
 
256
        r.do_commit(ref=b"refs/heads/bbranch",
 
257
                    committer=b"Joe <joe@example.com>", message=b"Dummy")
 
258
        self.run_bzr(["git-import", "--colocated", "a", "b"])
 
259
        self.assertEqual(set([".bzr"]), set(os.listdir("b")))
 
260
        self.assertEqual(set(["abranch", "bbranch"]),
 
261
                         set(ControlDir.open("b").get_branches().keys()))
 
262
 
 
263
    def test_git_import_incremental(self):
 
264
        r = GitRepo.init("a", mkdir=True)
 
265
        self.build_tree(["a/file"])
 
266
        r.stage("file")
 
267
        r.do_commit(ref=b"refs/heads/abranch",
 
268
                    committer=b"Joe <joe@example.com>", message=b"Dummy")
 
269
        self.run_bzr(["git-import", "--colocated", "a", "b"])
 
270
        self.run_bzr(["git-import", "--colocated", "a", "b"])
 
271
        self.assertEqual(set([".bzr"]), set(os.listdir("b")))
 
272
        b = ControlDir.open("b")
 
273
        self.assertEqual(["abranch"], list(b.get_branches().keys()))
 
274
 
 
275
    def test_git_import_tags(self):
 
276
        r = GitRepo.init("a", mkdir=True)
 
277
        self.build_tree(["a/file"])
 
278
        r.stage("file")
 
279
        cid = r.do_commit(ref=b"refs/heads/abranch",
 
280
                          committer=b"Joe <joe@example.com>", message=b"Dummy")
 
281
        r[b"refs/tags/atag"] = cid
 
282
        self.run_bzr(["git-import", "--colocated", "a", "b"])
 
283
        self.assertEqual(set([".bzr"]), set(os.listdir("b")))
 
284
        b = ControlDir.open("b")
 
285
        self.assertEqual(["abranch"], list(b.get_branches().keys()))
 
286
        self.assertEqual(["atag"],
 
287
                         list(b.open_branch("abranch").tags.get_tag_dict().keys()))
 
288
 
 
289
    def test_git_import_colo(self):
 
290
        r = GitRepo.init("a", mkdir=True)
 
291
        self.build_tree(["a/file"])
 
292
        r.stage("file")
 
293
        r.do_commit(ref=b"refs/heads/abranch",
 
294
                    committer=b"Joe <joe@example.com>", message=b"Dummy")
 
295
        r.do_commit(ref=b"refs/heads/bbranch",
 
296
                    committer=b"Joe <joe@example.com>", message=b"Dummy")
 
297
        self.make_controldir("b", format="development-colo")
 
298
        self.run_bzr(["git-import", "--colocated", "a", "b"])
 
299
        self.assertEqual(
 
300
            set([b.name for b in ControlDir.open("b").list_branches()]),
 
301
            set(["abranch", "bbranch"]))
 
302
 
 
303
    def test_git_refs_from_git(self):
 
304
        r = GitRepo.init("a", mkdir=True)
 
305
        self.build_tree(["a/file"])
 
306
        r.stage("file")
 
307
        cid = r.do_commit(ref=b"refs/heads/abranch",
 
308
                          committer=b"Joe <joe@example.com>", message=b"Dummy")
 
309
        r[b"refs/tags/atag"] = cid
 
310
        (stdout, stderr) = self.run_bzr(["git-refs", "a"])
 
311
        self.assertEqual(stderr, "")
 
312
        self.assertEqual(stdout,
 
313
                         'refs/heads/abranch -> ' + cid.decode('ascii') + '\n'
 
314
                         'refs/tags/atag -> ' + cid.decode('ascii') + '\n')
 
315
 
 
316
    def test_git_refs_from_bzr(self):
 
317
        tree = self.make_branch_and_tree('a')
 
318
        self.build_tree(["a/file"])
 
319
        tree.add(["file"])
 
320
        revid = tree.commit(
 
321
            committer=b"Joe <joe@example.com>", message=b"Dummy")
 
322
        tree.branch.tags.set_tag("atag", revid)
 
323
        (stdout, stderr) = self.run_bzr(["git-refs", "a"])
 
324
        self.assertEqual(stderr, "")
 
325
        self.assertTrue("refs/tags/atag -> " in stdout)
 
326
        self.assertTrue("HEAD -> " in stdout)
 
327
 
 
328
    def test_check(self):
 
329
        r = GitRepo.init("gitr", mkdir=True)
 
330
        self.build_tree_contents([("gitr/foo", b"hello from git")])
 
331
        r.stage("foo")
 
332
        r.do_commit(b"message", committer=b"Somebody <user@example.com>")
 
333
        out, err = self.run_bzr(["check", "gitr"])
 
334
        self.maxDiff = None
 
335
        self.assertEqual(out, '')
 
336
        self.assertTrue(err.endswith, '3 objects\n')
 
337
 
 
338
 
 
339
class ShallowTests(ExternalBase):
 
340
 
 
341
    def setUp(self):
 
342
        super(ShallowTests, self).setUp()
 
343
        # Smoke test for "bzr log" in a git repository with shallow depth.
 
344
        self.repo = GitRepo.init('gitr', mkdir=True)
 
345
        self.build_tree_contents([("gitr/foo", b"hello from git")])
 
346
        self.repo.stage("foo")
 
347
        self.repo.do_commit(
 
348
            b"message", committer=b"Somebody <user@example.com>",
 
349
            author=b"Somebody <user@example.com>",
 
350
            commit_timestamp=1526330165, commit_timezone=0,
 
351
            author_timestamp=1526330165, author_timezone=0,
 
352
            merge_heads=[b'aa' * 20])
 
353
 
 
354
    def test_log_shallow(self):
 
355
        # Check that bzr log does not fail and includes the revision.
 
356
        output, error = self.run_bzr(['log', 'gitr'], retcode=3)
 
357
        self.assertEqual(
 
358
            error, 'brz: ERROR: Further revision history missing.\n')
 
359
        self.assertEqual(output,
 
360
                         '------------------------------------------------------------\n'
 
361
                         'revision-id: git-v1:' + self.repo.head().decode('ascii') + '\n'
 
362
                         'git commit: ' + self.repo.head().decode('ascii') + '\n'
 
363
                         'committer: Somebody <user@example.com>\n'
 
364
                         'timestamp: Mon 2018-05-14 20:36:05 +0000\n'
 
365
                         'message:\n'
 
366
                         '  message\n')
 
367
 
 
368
    def test_version_info_rio(self):
 
369
        output, error = self.run_bzr(['version-info', '--rio', 'gitr'])
 
370
        self.assertEqual(error, '')
 
371
        self.assertNotIn('revno:', output)
 
372
 
 
373
    def test_version_info_python(self):
 
374
        output, error = self.run_bzr(['version-info', '--python', 'gitr'])
 
375
        self.assertEqual(error, '')
 
376
        self.assertNotIn('revno:', output)
 
377
 
 
378
    def test_version_info_custom_with_revno(self):
 
379
        output, error = self.run_bzr(
 
380
            ['version-info', '--custom',
 
381
             '--template=VERSION_INFO r{revno})\n', 'gitr'], retcode=3)
 
382
        self.assertEqual(
 
383
            error, 'brz: ERROR: Variable {revno} is not available.\n')
 
384
        self.assertEqual(output, 'VERSION_INFO r')
 
385
 
 
386
    def test_version_info_custom_without_revno(self):
 
387
        output, error = self.run_bzr(
 
388
            ['version-info', '--custom', '--template=VERSION_INFO \n',
 
389
             'gitr'])
 
390
        self.assertEqual(error, '')
 
391
        self.assertEqual(output, 'VERSION_INFO \n')
 
392
 
 
393
 
 
394
class SwitchTests(ExternalBase):
 
395
 
 
396
    def test_switch_branch(self):
 
397
        # Create a git repository with a revision.
 
398
        repo = GitRepo.init(self.test_dir)
 
399
        builder = tests.GitBranchBuilder()
 
400
        builder.set_branch(b'refs/heads/oldbranch')
 
401
        builder.set_file('a', b'text for a\n', False)
 
402
        builder.commit(b'Joe Foo <joe@foo.com>', u'<The commit message>')
 
403
        builder.set_branch(b'refs/heads/newbranch')
 
404
        builder.reset()
 
405
        builder.set_file('a', b'text for new a\n', False)
 
406
        builder.commit(b'Joe Foo <joe@foo.com>', u'<The commit message>')
 
407
        builder.finish()
 
408
 
 
409
        repo.refs.set_symbolic_ref(b'HEAD', b'refs/heads/newbranch')
 
410
 
 
411
        repo.reset_index()
 
412
 
 
413
        output, error = self.run_bzr('switch oldbranch')
 
414
        self.assertEqual(output, '')
 
415
        self.assertTrue(error.startswith('Updated to revision 1.\n'), error)
 
416
 
 
417
        self.assertFileEqual("text for a\n", 'a')
 
418
        tree = WorkingTree.open('.')
 
419
        with tree.lock_read():
 
420
            basis_tree = tree.basis_tree()
 
421
            with basis_tree.lock_read():
 
422
                self.assertEqual([], list(tree.iter_changes(basis_tree)))
 
423
 
 
424
 
 
425
class GrepTests(ExternalBase):
 
426
 
 
427
    def test_simple_grep(self):
 
428
        tree = self.make_branch_and_tree('.', format='git')
 
429
        self.build_tree_contents([('a', 'text for a\n')])
 
430
        tree.add(['a'])
 
431
        output, error = self.run_bzr('grep text')
 
432
        self.assertEqual(output, 'a:text for a\n')
 
433
        self.assertEqual(error, '')
 
434
 
 
435
 
 
436
class ReconcileTests(ExternalBase):
 
437
 
 
438
    def test_simple_reconcile(self):
 
439
        tree = self.make_branch_and_tree('.', format='git')
 
440
        self.build_tree_contents([('a', 'text for a\n')])
 
441
        tree.add(['a'])
 
442
        output, error = self.run_bzr('reconcile')
 
443
        self.assertContainsRe(
 
444
            output,
 
445
            'Reconciling branch file://.*\n'
 
446
            'Reconciling repository file://.*\n'
 
447
            'Reconciliation complete.\n')
 
448
        self.assertEqual(error, '')
 
449
 
 
450
 
 
451
class StatusTests(ExternalBase):
 
452
 
 
453
    def test_empty_dir(self):
 
454
        tree = self.make_branch_and_tree('.', format='git')
 
455
        self.build_tree(['a/', 'a/foo'])
 
456
        self.build_tree_contents([('.gitignore', 'foo\n')])
 
457
        tree.add(['.gitignore'])
 
458
        tree.commit('add ignore')
 
459
        output, error = self.run_bzr('st')
 
460
        self.assertEqual(output, '')
 
461
        self.assertEqual(error, '')
 
462
 
 
463
 
 
464
class StatsTests(ExternalBase):
 
465
 
 
466
    def test_simple_stats(self):
 
467
        self.requireFeature(PluginLoadedFeature('stats'))
 
468
        tree = self.make_branch_and_tree('.', format='git')
 
469
        self.build_tree_contents([('a', 'text for a\n')])
 
470
        tree.add(['a'])
 
471
        tree.commit('a commit', committer='Somebody <somebody@example.com>')
 
472
        output, error = self.run_bzr('stats')
 
473
        self.assertEqual(output, '   1 Somebody <somebody@example.com>\n')
 
474
 
 
475
 
 
476
class GitObjectsTests(ExternalBase):
 
477
 
 
478
    def run_simple(self, format):
 
479
        tree = self.make_branch_and_tree('.', format=format)
 
480
        self.build_tree(['a/', 'a/foo'])
 
481
        tree.add(['a'])
 
482
        tree.commit('add a')
 
483
        output, error = self.run_bzr('git-objects')
 
484
        shas = list(output.splitlines())
 
485
        self.assertEqual([40, 40], [len(s) for s in shas])
 
486
        self.assertEqual(error, '')
 
487
 
 
488
        output, error = self.run_bzr('git-object %s' % shas[0])
 
489
        self.assertEqual('', error)
 
490
 
 
491
    def test_in_native(self):
 
492
        self.run_simple(format='git')
 
493
 
 
494
    def test_in_bzr(self):
 
495
        self.run_simple(format='2a')
 
496
 
 
497
 
 
498
class GitApplyTests(ExternalBase):
 
499
 
 
500
    def test_apply(self):
 
501
        b = self.make_branch_and_tree('.')
 
502
 
 
503
        with open('foo.patch', 'w') as f:
 
504
            f.write("""\
 
505
From bdefb25fab801e6af0a70e965f60cb48f2b759fa Mon Sep 17 00:00:00 2001
 
506
From: Dmitry Bogatov <KAction@debian.org>
 
507
Date: Fri, 8 Feb 2019 23:28:30 +0000
 
508
Subject: [PATCH] Add fixed for out-of-date-standards-version
 
509
 
 
510
---
 
511
 message           | 3 +++
 
512
 1 files changed, 14 insertions(+)
 
513
 create mode 100644 message
 
514
 
 
515
diff --git a/message b/message
 
516
new file mode 100644
 
517
index 0000000..05ec0b1
 
518
--- /dev/null
 
519
+++ b/message
 
520
@@ -0,0 +1,3 @@
 
521
+Update standards version, no changes needed.
 
522
+Certainty: certain
 
523
+Fixed-Lintian-Tags: out-of-date-standards-version
 
524
""")
 
525
        output, error = self.run_bzr('git-apply foo.patch')
 
526
        self.assertContainsRe(
 
527
            error,
 
528
            'Committing to: .*\n'
 
529
            'Committed revision 1.\n')