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

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-07-28 02:47:10 UTC
  • mfrom: (7519.1.1 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200728024710-a2ylds219f1lsl62
Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/388173

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2007, 2009-2012 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
#
17
17
 
18
 
"""Tests of the 'bzr pack' command."""
 
18
"""Tests of the 'brz pack' command."""
19
19
import os
20
20
 
21
 
from bzrlib import tests
 
21
from breezy import tests
22
22
 
23
23
 
24
24
class TestPack(tests.TestCaseWithTransport):
27
27
        self._make_file(path, line_prefix, total_lines, versioned=True)
28
28
 
29
29
    def _make_file(self, path, line_prefix, total_lines, versioned):
30
 
        text=''
 
30
        text = ''
31
31
        for i in range(total_lines):
32
 
            text += line_prefix + str(i+1) + "\n"
 
32
            text += line_prefix + str(i + 1) + "\n"
33
33
 
34
 
        open(path, 'w').write(text)
 
34
        with open(path, 'w') as f:
 
35
            f.write(text)
35
36
        if versioned:
36
37
            self.run_bzr(['add', path])
37
38
            self.run_bzr(['ci', '-m', '"' + path + '"'])
38
39
 
39
40
    def _update_file(self, path, text, checkin=True):
40
41
        """append text to file 'path' and check it in"""
41
 
        open(path, 'a').write(text)
 
42
        with open(path, 'a') as f:
 
43
            f.write(text)
 
44
 
42
45
        if checkin:
43
46
            self.run_bzr(['ci', path, '-m', '"' + path + '"'])
44
47
 
66
69
    def test_pack_clean_obsolete_packs(self):
67
70
        """Ensure --clean-obsolete-packs removes obsolete pack files
68
71
        """
69
 
        wd = 'foobar0'
70
 
        wt = self.make_branch_and_tree(wd)
71
 
        transport = wt.branch.repository.bzrdir.transport
72
 
        os.chdir(wd)
 
72
        wt = self.make_branch_and_tree('.')
 
73
        t = wt.branch.repository.controldir.transport
73
74
 
74
75
        # do multiple commits to ensure that obsolete packs are created
75
 
        # by 'bzr pack'
 
76
        # by 'brz pack'
76
77
        self._make_versioned_file('file0.txt')
77
78
        for i in range(5):
78
79
            self._update_file('file0.txt', 'HELLO %d\n' % i)
79
80
 
80
81
        out, err = self.run_bzr(['pack', '--clean-obsolete-packs'])
81
82
 
82
 
        pack_names = transport.list_dir('repository/obsolete_packs')
 
83
        pack_names = t.list_dir('repository/obsolete_packs')
83
84
        self.assertTrue(len(pack_names) == 0)