/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/repofmt/knitpack_repo.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from __future__ import absolute_import
20
20
 
21
 
from ..lazy_import import lazy_import
 
21
from bzrlib.lazy_import import lazy_import
22
22
lazy_import(globals(), """
 
23
from itertools import izip
23
24
import time
24
25
 
25
 
from breezy import (
 
26
from bzrlib import (
26
27
    controldir,
27
28
    debug,
28
29
    errors,
 
30
    knit,
29
31
    osutils,
 
32
    pack,
30
33
    revision as _mod_revision,
31
34
    trace,
32
35
    tsort,
33
36
    ui,
34
 
    )
35
 
from breezy.bzr import (
36
 
    knit,
37
 
    pack,
38
37
    xml5,
39
38
    xml6,
40
39
    xml7,
41
40
    )
42
 
from breezy.bzr.knit import (
 
41
from bzrlib.knit import (
43
42
    _KnitGraphIndex,
44
43
    KnitPlainFactory,
45
44
    KnitVersionedFiles,
46
45
    )
47
46
""")
48
47
 
49
 
from ..bzr import (
 
48
from bzrlib import (
50
49
    btree_index,
51
50
    )
52
 
from ..bzr.index import (
 
51
from bzrlib.index import (
53
52
    CombinedGraphIndex,
54
53
    GraphIndex,
55
54
    GraphIndexPrefixAdapter,
56
55
    InMemoryGraphIndex,
57
56
    )
58
 
from .knitrepo import (
 
57
from bzrlib.repofmt.knitrepo import (
59
58
    KnitRepository,
60
59
    )
61
 
from .pack_repo import (
 
60
from bzrlib.repofmt.pack_repo import (
62
61
    _DirectPackAccess,
63
62
    NewPack,
64
63
    RepositoryFormatPack,
69
68
    PackRootCommitBuilder,
70
69
    RepositoryPackCollection,
71
70
    )
72
 
from ..sixish import (
73
 
    viewitems,
74
 
    zip
75
 
    )
76
 
from ..bzr.vf_repository import (
 
71
from bzrlib.vf_repository import (
77
72
    StreamSource,
78
73
    )
79
74
 
80
75
 
81
76
class KnitPackRepository(PackRepository, KnitRepository):
82
77
 
83
 
    def __init__(self, _format, a_controldir, control_files, _commit_builder_class,
 
78
    def __init__(self, _format, a_bzrdir, control_files, _commit_builder_class,
84
79
        _serializer):
85
 
        PackRepository.__init__(self, _format, a_controldir, control_files,
 
80
        PackRepository.__init__(self, _format, a_bzrdir, control_files,
86
81
            _commit_builder_class, _serializer)
87
82
        if self._format.supports_chks:
88
83
            raise AssertionError("chk not supported")
160
155
    index_class = GraphIndex
161
156
 
162
157
    def _get_matching_bzrdir(self):
163
 
        return controldir.format_registry.make_controldir('pack-0.92')
 
158
        return controldir.format_registry.make_bzrdir('pack-0.92')
164
159
 
165
160
    def _ignore_setting_bzrdir(self, format):
166
161
        pass
167
162
 
168
 
    _matchingcontroldir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
163
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
169
164
 
170
165
    @classmethod
171
166
    def get_format_string(cls):
172
167
        """See RepositoryFormat.get_format_string()."""
173
 
        return b"Bazaar pack repository format 1 (needs bzr 0.92)\n"
 
168
        return "Bazaar pack repository format 1 (needs bzr 0.92)\n"
174
169
 
175
170
    def get_format_description(self):
176
171
        """See RepositoryFormat.get_format_description()."""
200
195
    index_class = GraphIndex
201
196
 
202
197
    def _get_matching_bzrdir(self):
203
 
        return controldir.format_registry.make_controldir(
 
198
        return controldir.format_registry.make_bzrdir(
204
199
            'pack-0.92-subtree')
205
200
 
206
201
    def _ignore_setting_bzrdir(self, format):
207
202
        pass
208
203
 
209
 
    _matchingcontroldir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
204
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
210
205
 
211
206
    @classmethod
212
207
    def get_format_string(cls):
213
208
        """See RepositoryFormat.get_format_string()."""
214
 
        return b"Bazaar pack repository format 1 with subtree support (needs bzr 0.92)\n"
 
209
        return "Bazaar pack repository format 1 with subtree support (needs bzr 0.92)\n"
215
210
 
216
211
    def get_format_description(self):
217
212
        """See RepositoryFormat.get_format_description()."""
239
234
    index_class = GraphIndex
240
235
 
241
236
    def _get_matching_bzrdir(self):
242
 
        return controldir.format_registry.make_controldir(
 
237
        return controldir.format_registry.make_bzrdir(
243
238
            'rich-root-pack')
244
239
 
245
240
    def _ignore_setting_bzrdir(self, format):
246
241
        pass
247
242
 
248
 
    _matchingcontroldir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
243
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
249
244
 
250
245
    @classmethod
251
246
    def get_format_string(cls):
252
247
        """See RepositoryFormat.get_format_string()."""
253
 
        return (b"Bazaar pack repository format 1 with rich root"
254
 
                b" (needs bzr 1.0)\n")
 
248
        return ("Bazaar pack repository format 1 with rich root"
 
249
                " (needs bzr 1.0)\n")
255
250
 
256
251
    def get_format_description(self):
257
252
        """See RepositoryFormat.get_format_description()."""
279
274
        return xml5.serializer_v5
280
275
 
281
276
    def _get_matching_bzrdir(self):
282
 
        return controldir.format_registry.make_controldir('1.6')
 
277
        return controldir.format_registry.make_bzrdir('1.6')
283
278
 
284
279
    def _ignore_setting_bzrdir(self, format):
285
280
        pass
286
281
 
287
 
    _matchingcontroldir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
282
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
288
283
 
289
284
    @classmethod
290
285
    def get_format_string(cls):
291
286
        """See RepositoryFormat.get_format_string()."""
292
 
        return b"Bazaar RepositoryFormatKnitPack5 (bzr 1.6)\n"
 
287
        return "Bazaar RepositoryFormatKnitPack5 (bzr 1.6)\n"
293
288
 
294
289
    def get_format_description(self):
295
290
        """See RepositoryFormat.get_format_description()."""
319
314
        return xml6.serializer_v6
320
315
 
321
316
    def _get_matching_bzrdir(self):
322
 
        return controldir.format_registry.make_controldir(
 
317
        return controldir.format_registry.make_bzrdir(
323
318
            '1.6.1-rich-root')
324
319
 
325
320
    def _ignore_setting_bzrdir(self, format):
326
321
        pass
327
322
 
328
 
    _matchingcontroldir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
323
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
329
324
 
330
325
    @classmethod
331
326
    def get_format_string(cls):
332
327
        """See RepositoryFormat.get_format_string()."""
333
 
        return b"Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6.1)\n"
 
328
        return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6.1)\n"
334
329
 
335
330
    def get_format_description(self):
336
331
        return "Packs 5 rich-root (adds stacking support, requires bzr 1.6.1)"
364
359
        return xml7.serializer_v7
365
360
 
366
361
    def _get_matching_bzrdir(self):
367
 
        matching = controldir.format_registry.make_controldir(
 
362
        matching = controldir.format_registry.make_bzrdir(
368
363
            '1.6.1-rich-root')
369
364
        matching.repository_format = self
370
365
        return matching
372
367
    def _ignore_setting_bzrdir(self, format):
373
368
        pass
374
369
 
375
 
    _matchingcontroldir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
370
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
376
371
 
377
372
    @classmethod
378
373
    def get_format_string(cls):
379
374
        """See RepositoryFormat.get_format_string()."""
380
 
        return b"Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6)\n"
 
375
        return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6)\n"
381
376
 
382
377
    def get_format_description(self):
383
378
        return ("Packs 5 rich-root (adds stacking support, requires bzr 1.6)"
406
401
        return xml5.serializer_v5
407
402
 
408
403
    def _get_matching_bzrdir(self):
409
 
        return controldir.format_registry.make_controldir('1.9')
 
404
        return controldir.format_registry.make_bzrdir('1.9')
410
405
 
411
406
    def _ignore_setting_bzrdir(self, format):
412
407
        pass
413
408
 
414
 
    _matchingcontroldir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
409
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
415
410
 
416
411
    @classmethod
417
412
    def get_format_string(cls):
418
413
        """See RepositoryFormat.get_format_string()."""
419
 
        return b"Bazaar RepositoryFormatKnitPack6 (bzr 1.9)\n"
 
414
        return "Bazaar RepositoryFormatKnitPack6 (bzr 1.9)\n"
420
415
 
421
416
    def get_format_description(self):
422
417
        """See RepositoryFormat.get_format_description()."""
443
438
        return xml6.serializer_v6
444
439
 
445
440
    def _get_matching_bzrdir(self):
446
 
        return controldir.format_registry.make_controldir(
 
441
        return controldir.format_registry.make_bzrdir(
447
442
            '1.9-rich-root')
448
443
 
449
444
    def _ignore_setting_bzrdir(self, format):
450
445
        pass
451
446
 
452
 
    _matchingcontroldir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
447
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
453
448
 
454
449
    @classmethod
455
450
    def get_format_string(cls):
456
451
        """See RepositoryFormat.get_format_string()."""
457
 
        return b"Bazaar RepositoryFormatKnitPack6RichRoot (bzr 1.9)\n"
 
452
        return "Bazaar RepositoryFormatKnitPack6RichRoot (bzr 1.9)\n"
458
453
 
459
454
    def get_format_description(self):
460
455
        return "Packs 6 rich-root (uses btree indexes, requires bzr 1.9)"
484
479
        return xml7.serializer_v7
485
480
 
486
481
    def _get_matching_bzrdir(self):
487
 
        return controldir.format_registry.make_controldir(
 
482
        return controldir.format_registry.make_bzrdir(
488
483
            'development5-subtree')
489
484
 
490
485
    def _ignore_setting_bzrdir(self, format):
491
486
        pass
492
487
 
493
 
    _matchingcontroldir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
488
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
494
489
 
495
490
    @classmethod
496
491
    def get_format_string(cls):
497
492
        """See RepositoryFormat.get_format_string()."""
498
 
        return (b"Bazaar development format 2 with subtree support "
499
 
                b"(needs bzr.dev from before 1.8)\n")
 
493
        return ("Bazaar development format 2 with subtree support "
 
494
            "(needs bzr.dev from before 1.8)\n")
500
495
 
501
496
    def get_format_description(self):
502
497
        """See RepositoryFormat.get_format_description()."""
620
615
 
621
616
        :param output_lines: Output full texts of copied items.
622
617
        """
623
 
        with ui.ui_factory.nested_progress_bar() as pb:
 
618
        pb = ui.ui_factory.nested_progress_bar()
 
619
        try:
624
620
            return self._do_copy_nodes(nodes, index_map, writer,
625
621
                write_index, pb, output_lines=output_lines)
 
622
        finally:
 
623
            pb.finished()
626
624
 
627
625
    def _do_copy_nodes(self, nodes, index_map, writer, write_index, pb,
628
626
        output_lines=None):
642
640
            request_groups[index].append((key, value))
643
641
        record_index = 0
644
642
        pb.update("Copied record", record_index, len(nodes))
645
 
        for index, items in viewitems(request_groups):
 
643
        for index, items in request_groups.iteritems():
646
644
            pack_readv_requests = []
647
645
            for key, value in items:
648
646
                # ---- KnitGraphIndex.get_position
661
659
                if self._reload_func is not None:
662
660
                    self._reload_func()
663
661
                raise
664
 
            for (names, read_func), (_1, _2, (key, eol_flag)) in zip(
665
 
                    reader.iter_records(), pack_readv_requests):
 
662
            for (names, read_func), (_1, _2, (key, eol_flag)) in \
 
663
                izip(reader.iter_records(), pack_readv_requests):
666
664
                raw_data = read_func(None)
667
665
                # check the header only
668
666
                if output_lines is not None:
682
680
        :param output_lines: Return lines present in the copied data as
683
681
            an iterator of line,version_id.
684
682
        """
685
 
        with ui.ui_factory.nested_progress_bar() as pb:
 
683
        pb = ui.ui_factory.nested_progress_bar()
 
684
        try:
686
685
            for result in self._do_copy_nodes_graph(index_map, writer,
687
686
                write_index, output_lines, pb, readv_group_iter, total_items):
688
687
                yield result
 
688
        except Exception:
 
689
            # Python 2.4 does not permit try:finally: in a generator.
 
690
            pb.finished()
 
691
            raise
 
692
        else:
 
693
            pb.finished()
689
694
 
690
695
    def _do_copy_nodes_graph(self, index_map, writer, write_index,
691
696
        output_lines, pb, readv_group_iter, total_items):
706
711
                if self._reload_func is not None:
707
712
                    self._reload_func()
708
713
                raise
709
 
            for (names, read_func), (key, eol_flag, references) in zip(
710
 
                    reader.iter_records(), node_vector):
 
714
            for (names, read_func), (key, eol_flag, references) in \
 
715
                izip(reader.iter_records(), node_vector):
711
716
                raw_data = read_func(None)
712
717
                if output_lines:
713
718
                    # read the entire thing
733
738
        fileid_revisions = repo._find_file_ids_from_xml_inventory_lines(
734
739
            inv_lines, self.revision_keys)
735
740
        text_filter = []
736
 
        for fileid, file_revids in viewitems(fileid_revisions):
 
741
        for fileid, file_revids in fileid_revisions.iteritems():
737
742
            text_filter.extend([(fileid, file_revid) for file_revid in file_revids])
738
743
        self._text_filter = text_filter
739
744
 
927
932
                request_groups[index] = []
928
933
            request_groups[index].append((key, value, references))
929
934
        result = []
930
 
        for index, items in viewitems(request_groups):
 
935
        for index, items in request_groups.iteritems():
931
936
            pack_readv_requests = []
932
937
            for key, value, references in items:
933
938
                # ---- KnitGraphIndex.get_position
956
961
class KnitReconcilePacker(KnitPacker):
957
962
    """A packer which regenerates indices etc as it copies.
958
963
 
959
 
    This is used by ``brz reconcile`` to cause parent text pointers to be
 
964
    This is used by ``bzr reconcile`` to cause parent text pointers to be
960
965
    regenerated.
961
966
    """
962
967