/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-03-04 05:10:44 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7294.
  • Revision ID: jelmer@jelmer.uk-20190304051044-vph4s8p9qvpy2qe9
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    )
31
31
 
32
32
from ...tests.blackbox import ExternalBase
 
33
from ...workingtree import WorkingTree
33
34
 
34
35
from .. import (
35
36
    tests,
36
37
    )
 
38
from ...tests.features import PluginLoadedFeature
37
39
 
38
40
 
39
41
class TestGitBlackBox(ExternalBase):
62
64
        self.simple_commit()
63
65
        output, error = self.run_bzr(['info'])
64
66
        self.assertEqual(error, '')
65
 
        self.assertTrue("Standalone tree (format: git)" in output)
 
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")
66
80
 
67
81
    def test_branch(self):
68
82
        os.mkdir("gitbranch")
294
308
        self.repo.stage("foo")
295
309
        self.repo.do_commit(
296
310
            b"message", committer=b"Somebody <user@example.com>",
 
311
            author=b"Somebody <user@example.com>",
297
312
            commit_timestamp=1526330165, commit_timezone=0,
298
313
            author_timestamp=1526330165, author_timezone=0,
299
314
            merge_heads=[b'aa' * 20])
338
353
        self.assertEqual(output, 'VERSION_INFO \n')
339
354
 
340
355
 
 
356
class SwitchTests(ExternalBase):
 
357
 
 
358
    def test_switch_branch(self):
 
359
        # Create a git repository with a revision.
 
360
        repo = GitRepo.init(self.test_dir)
 
361
        builder = tests.GitBranchBuilder()
 
362
        builder.set_branch(b'refs/heads/oldbranch')
 
363
        builder.set_file('a', b'text for a\n', False)
 
364
        builder.commit(b'Joe Foo <joe@foo.com>', u'<The commit message>')
 
365
        builder.set_branch(b'refs/heads/newbranch')
 
366
        builder.reset()
 
367
        builder.set_file('a', b'text for new a\n', False)
 
368
        builder.commit(b'Joe Foo <joe@foo.com>', u'<The commit message>')
 
369
        builder.finish()
 
370
 
 
371
        repo.refs.set_symbolic_ref(b'HEAD', b'refs/heads/newbranch')
 
372
 
 
373
        repo.reset_index()
 
374
 
 
375
        output, error = self.run_bzr('switch oldbranch')
 
376
        self.assertEqual(output, '')
 
377
        self.assertTrue(error.startswith('Updated to revision 1.\n'), error)
 
378
 
 
379
        self.assertFileEqual("text for a\n", 'a')
 
380
        tree = WorkingTree.open('.')
 
381
        with tree.lock_read():
 
382
            basis_tree = tree.basis_tree()
 
383
            with basis_tree.lock_read():
 
384
                self.assertEqual([], list(tree.iter_changes(basis_tree)))
 
385
 
 
386
 
341
387
class GrepTests(ExternalBase):
342
388
 
343
389
    def test_simple_grep(self):
347
393
        output, error = self.run_bzr('grep text')
348
394
        self.assertEqual(output, 'a:text for a\n')
349
395
        self.assertEqual(error, '')
 
396
 
 
397
 
 
398
class ReconcileTests(ExternalBase):
 
399
 
 
400
    def test_simple_reconcile(self):
 
401
        tree = self.make_branch_and_tree('.', format='git')
 
402
        self.build_tree_contents([('a', 'text for a\n')])
 
403
        tree.add(['a'])
 
404
        output, error = self.run_bzr('reconcile')
 
405
        self.assertContainsRe(
 
406
            output,
 
407
            'Reconciling branch file://.*\n'
 
408
            'Reconciling repository file://.*\n'
 
409
            'Reconciliation complete.\n')
 
410
        self.assertEqual(error, '')
 
411
 
 
412
 
 
413
class StatusTests(ExternalBase):
 
414
 
 
415
    def test_empty_dir(self):
 
416
        tree = self.make_branch_and_tree('.', format='git')
 
417
        self.build_tree(['a/', 'a/foo'])
 
418
        self.build_tree_contents([('.gitignore', 'foo\n')])
 
419
        tree.add(['.gitignore'])
 
420
        tree.commit('add ignore')
 
421
        output, error = self.run_bzr('st')
 
422
        self.assertEqual(output, '')
 
423
        self.assertEqual(error, '')
 
424
 
 
425
 
 
426
class StatsTests(ExternalBase):
 
427
 
 
428
    def test_simple_stats(self):
 
429
        self.requireFeature(PluginLoadedFeature('stats'))
 
430
        tree = self.make_branch_and_tree('.', format='git')
 
431
        self.build_tree_contents([('a', 'text for a\n')])
 
432
        tree.add(['a'])
 
433
        tree.commit('a commit', committer='Somebody <somebody@example.com>')
 
434
        output, error = self.run_bzr('stats')
 
435
        self.assertEqual(output, '   1 Somebody <somebody@example.com>\n')
 
436
 
 
437
 
 
438
class GitObjectsTests(ExternalBase):
 
439
 
 
440
    def run_simple(self, format):
 
441
        tree = self.make_branch_and_tree('.', format=format)
 
442
        self.build_tree(['a/', 'a/foo'])
 
443
        tree.add(['a'])
 
444
        tree.commit('add a')
 
445
        output, error = self.run_bzr('git-objects')
 
446
        shas = list(output.splitlines())
 
447
        self.assertEqual([40, 40], [len(s) for s in shas])
 
448
        self.assertEqual(error, '')
 
449
 
 
450
        output, error = self.run_bzr('git-object %s' % shas[0])
 
451
        self.assertEqual('', error)
 
452
 
 
453
    def test_in_native(self):
 
454
        self.run_simple(format='git')
 
455
 
 
456
    def test_in_bzr(self):
 
457
        self.run_simple(format='2a')
 
458
 
 
459
 
 
460
class GitApplyTests(ExternalBase):
 
461
 
 
462
    def test_apply(self):
 
463
        b = self.make_branch_and_tree('.')
 
464
 
 
465
        with open('foo.patch', 'w') as f:
 
466
            f.write("""\
 
467
From bdefb25fab801e6af0a70e965f60cb48f2b759fa Mon Sep 17 00:00:00 2001
 
468
From: Dmitry Bogatov <KAction@debian.org>
 
469
Date: Fri, 8 Feb 2019 23:28:30 +0000
 
470
Subject: [PATCH] Add fixed for out-of-date-standards-version
 
471
 
 
472
---
 
473
 message           | 3 +++
 
474
 1 files changed, 14 insertions(+)
 
475
 create mode 100644 message
 
476
 
 
477
diff --git a/message b/message
 
478
new file mode 100644
 
479
index 0000000..05ec0b1
 
480
--- /dev/null
 
481
+++ b/message
 
482
@@ -0,0 +1,3 @@
 
483
+Update standards version, no changes needed.
 
484
+Certainty: certain
 
485
+Fixed-Lintian-Tags: out-of-date-standards-version
 
486
""")
 
487
        output, error = self.run_bzr('git-apply foo.patch')
 
488
        self.assertContainsRe(
 
489
            error,
 
490
            'Committing to: .*\n'
 
491
            'Committed revision 1.\n')