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

  • Committer: Ian Clatworthy
  • Date: 2008-12-15 06:18:29 UTC
  • mfrom: (3905 +trunk)
  • mto: (3586.1.23 views-ui)
  • mto: This revision was merged to the branch mainline in revision 4030.
  • Revision ID: ian.clatworthy@canonical.com-20081215061829-c8qwa93g71u9fsh5
merge bzr.dev 3905

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
from copy import copy
72
72
from cStringIO import StringIO
73
73
import os
74
 
import sha
75
74
import time
76
75
import warnings
77
76
 
 
77
from bzrlib.lazy_import import lazy_import
 
78
lazy_import(globals(), """
 
79
from bzrlib import tsort
 
80
""")
78
81
from bzrlib import (
 
82
    errors,
 
83
    osutils,
79
84
    progress,
80
85
    )
81
86
from bzrlib.errors import (WeaveError, WeaveFormatError, WeaveParentMismatch,
85
90
        WeaveRevisionAlreadyPresent,
86
91
        WeaveRevisionNotPresent,
87
92
        )
88
 
import bzrlib.errors as errors
89
 
from bzrlib.osutils import dirname, sha_strings, split_lines
 
93
from bzrlib.osutils import dirname, sha, sha_strings, split_lines
90
94
import bzrlib.patiencediff
91
95
from bzrlib.revision import NULL_REVISION
92
96
from bzrlib.symbol_versioning import *
93
97
from bzrlib.trace import mutter
94
 
from bzrlib.tsort import topo_sort
95
98
from bzrlib.versionedfile import (
96
99
    AbsentContentFactory,
97
100
    adapter_registry,
120
123
    def get_bytes_as(self, storage_kind):
121
124
        if storage_kind == 'fulltext':
122
125
            return self._weave.get_text(self.key[-1])
 
126
        elif storage_kind == 'chunked':
 
127
            return self._weave.get_lines(self.key[-1])
123
128
        else:
124
129
            raise UnavailableRepresentation(self.key, storage_kind, 'fulltext')
125
130
 
215
220
 
216
221
    __slots__ = ['_weave', '_parents', '_sha1s', '_names', '_name_map',
217
222
                 '_weave_name', '_matcher', '_allow_reserved']
218
 
    
 
223
 
219
224
    def __init__(self, weave_name=None, access_mode='w', matcher=None,
220
225
                 get_scope=None, allow_reserved=False):
221
226
        """Create a weave.
224
229
            for detecting when this weave goes out of scope (should stop
225
230
            answering requests or allowing mutation).
226
231
        """
227
 
        super(Weave, self).__init__(access_mode)
 
232
        super(Weave, self).__init__()
228
233
        self._weave = []
229
234
        self._parents = []
230
235
        self._sha1s = []
313
318
        versions = [version[-1] for version in versions]
314
319
        if ordering == 'topological':
315
320
            parents = self.get_parent_map(versions)
316
 
            new_versions = topo_sort(parents)
 
321
            new_versions = tsort.topo_sort(parents)
317
322
            new_versions.extend(set(versions).difference(set(parents)))
318
323
            versions = new_versions
319
324
        for version in versions:
355
360
                raise RevisionNotPresent([record.key[0]], self)
356
361
            # adapt to non-tuple interface
357
362
            parents = [parent[0] for parent in record.parents]
358
 
            if record.storage_kind == 'fulltext':
 
363
            if (record.storage_kind == 'fulltext'
 
364
                or record.storage_kind == 'chunked'):
359
365
                self.add_lines(record.key[0], parents,
360
 
                    split_lines(record.get_bytes_as('fulltext')))
 
366
                    osutils.chunks_to_lines(record.get_bytes_as('chunked')))
361
367
            else:
362
368
                adapter_key = record.storage_kind, 'fulltext'
363
369
                try:
799
805
            # For creating the ancestry, IntSet is much faster (3.7s vs 0.17s)
800
806
            # The problem is that set membership is much more expensive
801
807
            name = self._idx_to_name(i)
802
 
            sha1s[name] = sha.new()
 
808
            sha1s[name] = sha()
803
809
            texts[name] = []
804
810
            new_inc = set([name])
805
811
            for p in self._parents[i]:
995
1001
    # map from version name -> all parent names
996
1002
    combined_parents = _reweave_parent_graphs(wa, wb)
997
1003
    mutter("combined parents: %r", combined_parents)
998
 
    order = topo_sort(combined_parents.iteritems())
 
1004
    order = tsort.topo_sort(combined_parents.iteritems())
999
1005
    mutter("order to reweave: %r", order)
1000
1006
 
1001
1007
    if pb and not msg: