~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/versionedfile.py

  • Committer: John Arbash Meinel
  • Date: 2006-10-11 00:23:23 UTC
  • mfrom: (2070 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2071.
  • Revision ID: john@arbash-meinel.com-20061011002323-82ba88c293d7caff
[merge] bzr.dev 2070

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
# it under the terms of the GNU General Public License as published by
8
8
# the Free Software Foundation; either version 2 of the License, or
9
9
# (at your option) any later version.
10
 
 
 
10
#
11
11
# This program is distributed in the hope that it will be useful,
12
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
14
# GNU General Public License for more details.
15
 
 
 
15
#
16
16
# You should have received a copy of the GNU General Public License
17
17
# along with this program; if not, write to the Free Software
18
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
19
 
20
20
"""Versioned text file storage api."""
21
21
 
22
 
 
 
22
from bzrlib.lazy_import import lazy_import
 
23
lazy_import(globals(), """
23
24
from copy import deepcopy
24
 
from unittest import TestSuite
25
 
 
26
 
 
27
 
import bzrlib.errors as errors
 
25
import unittest
 
26
 
 
27
from bzrlib import (
 
28
    errors,
 
29
    tsort,
 
30
    ui,
 
31
    )
 
32
from bzrlib.transport.memory import MemoryTransport
 
33
""")
 
34
 
28
35
from bzrlib.inter import InterObject
29
36
from bzrlib.textmerge import TextMerge
30
 
from bzrlib.transport.memory import MemoryTransport
31
 
from bzrlib.tsort import topo_sort
32
 
from bzrlib import ui
33
37
from bzrlib.symbol_versioning import (deprecated_function,
34
38
        deprecated_method,
35
39
        zero_eight,
57
61
    def copy_to(self, name, transport):
58
62
        """Copy this versioned file to name on transport."""
59
63
        raise NotImplementedError(self.copy_to)
60
 
    
 
64
 
61
65
    @deprecated_method(zero_eight)
62
66
    def names(self):
63
67
        """Return a list of all the versions in this versioned file.
173
177
        if self._access_mode != 'w':
174
178
            raise errors.ReadOnlyObjectDirtiedError(self)
175
179
 
 
180
    def enable_cache(self):
 
181
        """Tell this versioned file that it should cache any data it reads.
 
182
        
 
183
        This is advisory, implementations do not have to support caching.
 
184
        """
 
185
        pass
 
186
    
176
187
    def clear_cache(self):
177
 
        """Remove any data cached in the versioned file object."""
 
188
        """Remove any data cached in the versioned file object.
 
189
 
 
190
        This only needs to be supported if caches are supported
 
191
        """
 
192
        pass
178
193
 
179
194
    def clone_text(self, new_version_id, old_version_id, parents):
180
195
        """Add an identical text to old_version_id as new_version_id.
392
407
            version_ids,
393
408
            ignore_missing)
394
409
 
395
 
    def iter_lines_added_or_present_in_versions(self, version_ids=None):
 
410
    def iter_lines_added_or_present_in_versions(self, version_ids=None, 
 
411
                                                pb=None):
396
412
        """Iterate over the lines in the versioned file from version_ids.
397
413
 
398
414
        This may return lines from other versions, and does not return the
401
417
        thinks is relevant, but given that such hints are just guesses,
402
418
        its better not to have it if we don't need it.
403
419
 
 
420
        If a progress bar is supplied, it may be used to indicate progress.
 
421
        The caller is responsible for cleaning up progress bars (because this
 
422
        is an iterator).
 
423
 
404
424
        NOTES: Lines are normalised: they will all have \n terminators.
405
425
               Lines are returned in arbitrary order.
406
426
        """
457
477
        """
458
478
        raise NotImplementedError(VersionedFile.plan_merge)
459
479
        
460
 
    def weave_merge(self, plan, a_marker=TextMerge.A_MARKER, 
 
480
    def weave_merge(self, plan, a_marker=TextMerge.A_MARKER,
461
481
                    b_marker=TextMerge.B_MARKER):
462
482
        return PlanWeaveMerge(plan, a_marker, b_marker).merge_lines()[0]
463
483
 
547
567
    InterVersionedFile.get(other).method_name(parameters).
548
568
    """
549
569
 
550
 
    _optimisers = set()
 
570
    _optimisers = []
551
571
    """The available optimised InterVersionedFile types."""
552
572
 
553
573
    def join(self, pb=None, msg=None, version_ids=None, ignore_missing=False):
574
594
            target = temp_source
575
595
        version_ids = self._get_source_version_ids(version_ids, ignore_missing)
576
596
        graph = self.source.get_graph(version_ids)
577
 
        order = topo_sort(graph.items())
 
597
        order = tsort.topo_sort(graph.items())
578
598
        pb = ui.ui_factory.nested_progress_bar()
579
599
        parent_texts = {}
580
600
        try:
661
681
        self._formats = formats
662
682
    
663
683
    def adapt(self, test):
664
 
        result = TestSuite()
 
684
        result = unittest.TestSuite()
665
685
        for (interversionedfile_class,
666
686
             versionedfile_factory,
667
687
             versionedfile_factory_to) in self._formats: