/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/blackbox/test_pack.py

  • Committer: Marius Kruger
  • Date: 2010-07-10 21:28:56 UTC
  • mto: (5384.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5385.
  • Revision ID: marius.kruger@enerweb.co.za-20100710212856-uq4ji3go0u5se7hx
* Update documentation
* add NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2009-2012 Canonical Ltd
 
1
# Copyright (C) 2007, 2009, 2010 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 'brz pack' command."""
 
18
"""Tests of the 'bzr pack' command."""
19
19
import os
20
20
 
21
 
from breezy import tests
22
 
from breezy.tests.matchers import ContainsNoVfsCalls
 
21
from bzrlib import tests
23
22
 
24
23
 
25
24
class TestPack(tests.TestCaseWithTransport):
28
27
        self._make_file(path, line_prefix, total_lines, versioned=True)
29
28
 
30
29
    def _make_file(self, path, line_prefix, total_lines, versioned):
31
 
        text = ''
 
30
        text=''
32
31
        for i in range(total_lines):
33
 
            text += line_prefix + str(i + 1) + "\n"
 
32
            text += line_prefix + str(i+1) + "\n"
34
33
 
35
 
        with open(path, 'w') as f:
36
 
            f.write(text)
 
34
        open(path, 'w').write(text)
37
35
        if versioned:
38
36
            self.run_bzr(['add', path])
39
37
            self.run_bzr(['ci', '-m', '"' + path + '"'])
40
38
 
41
39
    def _update_file(self, path, text, checkin=True):
42
40
        """append text to file 'path' and check it in"""
43
 
        with open(path, 'a') as f:
44
 
            f.write(text)
45
 
 
 
41
        open(path, 'a').write(text)
46
42
        if checkin:
47
43
            self.run_bzr(['ci', path, '-m', '"' + path + '"'])
48
44
 
70
66
    def test_pack_clean_obsolete_packs(self):
71
67
        """Ensure --clean-obsolete-packs removes obsolete pack files
72
68
        """
73
 
        wt = self.make_branch_and_tree('.')
74
 
        t = wt.branch.repository.controldir.transport
 
69
        wd = 'foobar0'
 
70
        wt = self.make_branch_and_tree(wd)
 
71
        transport = wt.branch.repository.bzrdir.transport
 
72
        os.chdir(wd)
75
73
 
76
74
        # do multiple commits to ensure that obsolete packs are created
77
 
        # by 'brz pack'
 
75
        # by 'bzr pack'
78
76
        self._make_versioned_file('file0.txt')
79
77
        for i in range(5):
80
78
            self._update_file('file0.txt', 'HELLO %d\n' % i)
81
79
 
82
80
        out, err = self.run_bzr(['pack', '--clean-obsolete-packs'])
83
81
 
84
 
        pack_names = t.list_dir('repository/obsolete_packs')
 
82
        pack_names = transport.list_dir('repository/obsolete_packs')
85
83
        self.assertTrue(len(pack_names) == 0)
86
 
 
87
 
 
88
 
class TestSmartServerPack(tests.TestCaseWithTransport):
89
 
 
90
 
    def test_simple_pack(self):
91
 
        self.setup_smart_server_with_call_log()
92
 
        t = self.make_branch_and_tree('branch')
93
 
        self.build_tree_contents([('branch/foo', b'thecontents')])
94
 
        t.add("foo")
95
 
        t.commit("message")
96
 
        self.reset_smart_call_log()
97
 
        out, err = self.run_bzr(['pack', self.get_url('branch')])
98
 
        # This figure represent the amount of HPSS calls to perform this use
99
 
        # case. It is entirely ok to reduce this number if a test fails due to
100
 
        # rpc_count # being too low. If rpc_count increases, more network
101
 
        # roundtrips have become necessary for this use case. Please do not
102
 
        # adjust this number upwards without agreement from bzr's network
103
 
        # support maintainers.
104
 
        self.assertLength(6, self.hpss_calls)
105
 
        self.assertLength(1, self.hpss_connections)
106
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)