/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to breezy/tests/test_repository.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
from stat import S_ISDIR
26
26
 
27
 
import bzrlib
28
 
from bzrlib.errors import (
 
27
import breezy
 
28
from breezy.errors import (
29
29
    UnknownFormatError,
30
30
    UnsupportedFormatError,
31
31
    )
32
 
from bzrlib import (
 
32
from breezy import (
33
33
    btree_index,
34
34
    symbol_versioning,
35
35
    tests,
36
36
    transport,
37
37
    vf_search,
38
38
    )
39
 
from bzrlib.btree_index import BTreeBuilder, BTreeGraphIndex
40
 
from bzrlib.index import GraphIndex
41
 
from bzrlib.repository import RepositoryFormat
42
 
from bzrlib.tests import (
 
39
from breezy.btree_index import BTreeBuilder, BTreeGraphIndex
 
40
from breezy.index import GraphIndex
 
41
from breezy.repository import RepositoryFormat
 
42
from breezy.tests import (
43
43
    TestCase,
44
44
    TestCaseWithTransport,
45
45
    )
46
 
from bzrlib import (
 
46
from breezy import (
47
47
    bzrdir,
48
48
    controldir,
49
49
    errors,
56
56
    vf_repository,
57
57
    workingtree,
58
58
    )
59
 
from bzrlib.repofmt import (
 
59
from breezy.repofmt import (
60
60
    groupcompress_repo,
61
61
    knitrepo,
62
62
    knitpack_repo,
206
206
 
207
207
    def test_register_extra_lazy(self):
208
208
        self.assertEqual([], self.registry._get_all())
209
 
        self.registry.register_extra_lazy("bzrlib.tests.test_repository",
 
209
        self.registry.register_extra_lazy("breezy.tests.test_repository",
210
210
            "SampleExtraRepositoryFormat")
211
211
        formats = self.registry._get_all()
212
212
        self.assertEqual(1, len(formats))
471
471
        repo_dir = bzrdir.BzrDirMetaFormat1().initialize('repository')
472
472
        repo = TestRepositoryFormat1().initialize(repo_dir)
473
473
        converter = repository.CopyConverter(target_format)
474
 
        pb = bzrlib.ui.ui_factory.nested_progress_bar()
 
474
        pb = breezy.ui.ui_factory.nested_progress_bar()
475
475
        try:
476
476
            converter.convert(repo, pb)
477
477
        finally:
714
714
 
715
715
        # On a regular pass, getting the inventories and chk pages for rev-2
716
716
        # would only get the newly created chk pages
717
 
        search = vf_search.SearchResult(set(['rev-2']), set(['rev-1']), 1,
718
 
                                    set(['rev-2']))
 
717
        search = vf_search.SearchResult({'rev-2'}, {'rev-1'}, 1,
 
718
                                    {'rev-2'})
719
719
        simple_chk_records = []
720
720
        for vf_name, substream in source.get_stream(search):
721
721
            if vf_name == 'chk_bytes':
1021
1021
        obsolete_pack_trans.put_bytes('a-pack.iix', 'content\n')
1022
1022
        obsolete_pack_trans.put_bytes('another-pack.pack', 'foo\n')
1023
1023
        obsolete_pack_trans.put_bytes('not-a-pack.rix', 'foo\n')
1024
 
        res = packs._clear_obsolete_packs(preserve=set(['a-pack']))
 
1024
        res = packs._clear_obsolete_packs(preserve={'a-pack'})
1025
1025
        self.assertEqual(['a-pack', 'another-pack'], sorted(res))
1026
1026
        self.assertEqual(['a-pack.iix', 'a-pack.pack', 'a-pack.rix'],
1027
1027
                         sorted(obsolete_pack_trans.list_dir('.')))
1075
1075
                         sorted(packs._pack_transport.list_dir('.')))
1076
1076
        # names[0] should not be present in the index anymore
1077
1077
        self.assertEqual(names[1:],
1078
 
            sorted(set([osutils.splitext(n)[0] for n in
1079
 
                        packs._index_transport.list_dir('.')])))
 
1078
            sorted({osutils.splitext(n)[0] for n in
 
1079
                        packs._index_transport.list_dir('.')}))
1080
1080
 
1081
1081
    def test__obsolete_packs_missing_directory(self):
1082
1082
        tree, r, packs, revs = self.make_packs_and_alt_repo(write_lock=True)
1092
1092
                         sorted(packs._pack_transport.list_dir('.')))
1093
1093
        # names[0] should not be present in the index anymore
1094
1094
        self.assertEqual(names[1:],
1095
 
            sorted(set([osutils.splitext(n)[0] for n in
1096
 
                        packs._index_transport.list_dir('.')])))
 
1095
            sorted({osutils.splitext(n)[0] for n in
 
1096
                        packs._index_transport.list_dir('.')}))
1097
1097
 
1098
1098
    def test_pack_distribution_zero(self):
1099
1099
        packs = self.get_packs()
1289
1289
        packs._remove_pack_from_memory(removed_pack)
1290
1290
        names = packs.names()
1291
1291
        all_nodes, deleted_nodes, new_nodes, _ = packs._diff_pack_names()
1292
 
        new_names = set([x[0][0] for x in new_nodes])
 
1292
        new_names = {x[0][0] for x in new_nodes}
1293
1293
        self.assertEqual(names, sorted([x[0][0] for x in all_nodes]))
1294
1294
        self.assertEqual(set(names) - set(orig_names), new_names)
1295
 
        self.assertEqual(set([new_pack.name]), new_names)
 
1295
        self.assertEqual({new_pack.name}, new_names)
1296
1296
        self.assertEqual([to_remove_name],
1297
1297
                         sorted([x[0][0] for x in deleted_nodes]))
1298
1298
        packs.reload_pack_names()
1300
1300
        self.assertEqual(orig_at_load, packs._packs_at_load)
1301
1301
        self.assertEqual(names, reloaded_names)
1302
1302
        all_nodes, deleted_nodes, new_nodes, _ = packs._diff_pack_names()
1303
 
        new_names = set([x[0][0] for x in new_nodes])
 
1303
        new_names = {x[0][0] for x in new_nodes}
1304
1304
        self.assertEqual(names, sorted([x[0][0] for x in all_nodes]))
1305
1305
        self.assertEqual(set(names) - set(orig_names), new_names)
1306
 
        self.assertEqual(set([new_pack.name]), new_names)
 
1306
        self.assertEqual({new_pack.name}, new_names)
1307
1307
        self.assertEqual([to_remove_name],
1308
1308
                         sorted([x[0][0] for x in deleted_nodes]))
1309
1309
 
1349
1349
        self.assertEqual([n + '.pack' for n in names[1:]], sorted(cur_packs))
1350
1350
        # obsolete_packs will also have stuff like .rix and .iix present.
1351
1351
        obsolete_packs = packs.transport.list_dir('obsolete_packs')
1352
 
        obsolete_names = set([osutils.splitext(n)[0] for n in obsolete_packs])
 
1352
        obsolete_names = {osutils.splitext(n)[0] for n in obsolete_packs}
1353
1353
        self.assertEqual([pack.name], sorted(obsolete_names))
1354
1354
 
1355
1355
    def test__save_pack_names_already_obsoleted(self):
1367
1367
        # Note that while we set clear_obsolete_packs=True, it should not
1368
1368
        # delete a pack file that we have also scheduled for obsoletion.
1369
1369
        obsolete_packs = packs.transport.list_dir('obsolete_packs')
1370
 
        obsolete_names = set([osutils.splitext(n)[0] for n in obsolete_packs])
 
1370
        obsolete_names = {osutils.splitext(n)[0] for n in obsolete_packs}
1371
1371
        self.assertEqual([pack.name], sorted(obsolete_names))
1372
1372
 
1373
1373
    def test_pack_no_obsolete_packs_directory(self):
1697
1697
 
1698
1698
    def test__repr__(self):
1699
1699
        lazy = repository._LazyListJoin(['a'], ['b'])
1700
 
        self.assertEqual("bzrlib.repository._LazyListJoin((['a'], ['b']))",
 
1700
        self.assertEqual("breezy.repository._LazyListJoin((['a'], ['b']))",
1701
1701
                         repr(lazy))
1702
1702
 
1703
1703