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

remove all trailing whitespace from bzr source

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
 
66
66
class ContentFactory(object):
67
67
    """Abstract interface for insertion and retrieval from a VersionedFile.
68
 
    
 
68
 
69
69
    :ivar sha1: None, or the sha1 of the content fulltext.
70
70
    :ivar storage_kind: The native storage kind of this factory. One of
71
71
        'mpdiff', 'knit-annotated-ft', 'knit-annotated-delta', 'knit-ft',
155
155
 
156
156
class AbsentContentFactory(ContentFactory):
157
157
    """A placeholder content factory for unavailable texts.
158
 
    
 
158
 
159
159
    :ivar sha1: None.
160
160
    :ivar storage_kind: 'absent'.
161
161
    :ivar key: The key of this content. Each key is a tuple with a single
197
197
 
198
198
class VersionedFile(object):
199
199
    """Versioned text file storage.
200
 
    
 
200
 
201
201
    A versioned file manages versions of line-based text files,
202
202
    keeping track of the originating version for each line.
203
203
 
241
241
    def insert_record_stream(self, stream):
242
242
        """Insert a record stream into this versioned file.
243
243
 
244
 
        :param stream: A stream of records to insert. 
 
244
        :param stream: A stream of records to insert.
245
245
        :return: None
246
246
        :seealso VersionedFile.get_record_stream:
247
247
        """
266
266
            the data back accurately. (Checking the lines have been split
267
267
            correctly is expensive and extremely unlikely to catch bugs so it
268
268
            is not done at runtime unless check_content is True.)
269
 
        :param parent_texts: An optional dictionary containing the opaque 
 
269
        :param parent_texts: An optional dictionary containing the opaque
270
270
            representations of some or all of the parents of version_id to
271
271
            allow delta optimisations.  VERY IMPORTANT: the texts must be those
272
272
            returned by add_lines or data corruption can be caused.
300
300
        parent_texts=None, nostore_sha=None, random_id=False,
301
301
        check_content=True, left_matching_blocks=None):
302
302
        """Add lines to the versioned file, allowing ghosts to be present.
303
 
        
 
303
 
304
304
        This takes the same parameters as add_lines and returns the same.
305
305
        """
306
306
        self._check_write_ok()
330
330
 
331
331
    def get_format_signature(self):
332
332
        """Get a text description of the data encoding in this file.
333
 
        
 
333
 
334
334
        :since: 0.90
335
335
        """
336
336
        raise NotImplementedError(self.get_format_signature)
457
457
        if isinstance(version_ids, basestring):
458
458
            version_ids = [version_ids]
459
459
        raise NotImplementedError(self.get_ancestry)
460
 
        
 
460
 
461
461
    def get_ancestry_with_ghosts(self, version_ids):
462
462
        """Return a list of all ancestors of given version(s). This
463
463
        will not include the null revision.
464
464
 
465
465
        Must raise RevisionNotPresent if any of the given versions are
466
466
        not present in file history.
467
 
        
 
467
 
468
468
        Ghosts that are known about will be included in ancestry list,
469
469
        but are not explicitly marked.
470
470
        """
471
471
        raise NotImplementedError(self.get_ancestry_with_ghosts)
472
 
    
 
472
 
473
473
    def get_parent_map(self, version_ids):
474
474
        """Get a map of the parents of version_ids.
475
475
 
538
538
        unchanged   Alive in both a and b (possibly created in both)
539
539
        new-a       Created in a
540
540
        new-b       Created in b
541
 
        ghost-a     Killed in a, unborn in b    
 
541
        ghost-a     Killed in a, unborn in b
542
542
        ghost-b     Killed in b, unborn in a
543
543
        irrelevant  Not in either revision
544
544
        """
545
545
        raise NotImplementedError(VersionedFile.plan_merge)
546
 
        
 
546
 
547
547
    def weave_merge(self, plan, a_marker=TextMerge.A_MARKER,
548
548
                    b_marker=TextMerge.B_MARKER):
549
549
        return PlanWeaveMerge(plan, a_marker, b_marker).merge_lines()[0]
551
551
 
552
552
class RecordingVersionedFilesDecorator(object):
553
553
    """A minimal versioned files that records calls made on it.
554
 
    
 
554
 
555
555
    Only enough methods have been added to support tests using it to date.
556
556
 
557
557
    :ivar calls: A list of the calls made; can be reset at any time by
560
560
 
561
561
    def __init__(self, backing_vf):
562
562
        """Create a RecordingVersionedFilesDecorator decorating backing_vf.
563
 
        
 
563
 
564
564
        :param backing_vf: The versioned file to answer all methods.
565
565
        """
566
566
        self._backing_vf = backing_vf
652
652
 
653
653
    def unmap(self, partition_id):
654
654
        """Map a partitioned storage id back to a key prefix.
655
 
        
 
655
 
656
656
        :param partition_id: The underlying partition id.
657
657
        :return: As much of a key (or prefix) as is derivable from the partition
658
658
            id.
690
690
 
691
691
class PrefixMapper(URLEscapeMapper):
692
692
    """A key mapper that extracts the first component of a key.
693
 
    
 
693
 
694
694
    This mapper is for use with a transport based backend.
695
695
    """
696
696
 
729
729
 
730
730
class HashEscapedPrefixMapper(HashPrefixMapper):
731
731
    """Combines the escaped first component of a key with a hash.
732
 
    
 
732
 
733
733
    This mapper is for use with a transport based backend.
734
734
    """
735
735
 
801
801
            the data back accurately. (Checking the lines have been split
802
802
            correctly is expensive and extremely unlikely to catch bugs so it
803
803
            is not done at runtime unless check_content is True.)
804
 
        :param parent_texts: An optional dictionary containing the opaque 
 
804
        :param parent_texts: An optional dictionary containing the opaque
805
805
            representations of some or all of the parents of version_id to
806
806
            allow delta optimisations.  VERY IMPORTANT: the texts must be those
807
807
            returned by add_lines or data corruption can be caused.
928
928
    def insert_record_stream(self, stream):
929
929
        """Insert a record stream into this container.
930
930
 
931
 
        :param stream: A stream of records to insert. 
 
931
        :param stream: A stream of records to insert.
932
932
        :return: None
933
933
        :seealso VersionedFile.get_record_stream:
934
934
        """
1162
1162
    def insert_record_stream(self, stream):
1163
1163
        """Insert a record stream into this container.
1164
1164
 
1165
 
        :param stream: A stream of records to insert. 
 
1165
        :param stream: A stream of records to insert.
1166
1166
        :return: None
1167
1167
        :seealso VersionedFile.get_record_stream:
1168
1168
        """
1325
1325
 
1326
1326
class PlanWeaveMerge(TextMerge):
1327
1327
    """Weave merge that takes a plan as its input.
1328
 
    
 
1328
 
1329
1329
    This exists so that VersionedFile.plan_merge is implementable.
1330
1330
    Most callers will want to use WeaveMerge instead.
1331
1331
    """
1352
1352
                yield(lines_a,)
1353
1353
            else:
1354
1354
                yield (lines_a, lines_b)
1355
 
       
 
1355
 
1356
1356
        # We previously considered either 'unchanged' or 'killed-both' lines
1357
1357
        # to be possible places to resynchronize.  However, assuming agreement
1358
1358
        # on killed-both lines may be too aggressive. -- mbp 20060324
1364
1364
                lines_a = []
1365
1365
                lines_b = []
1366
1366
                ch_a = ch_b = False
1367
 
                
 
1367
 
1368
1368
            if state == 'unchanged':
1369
1369
                if line:
1370
1370
                    yield ([line],)
1397
1397
class WeaveMerge(PlanWeaveMerge):
1398
1398
    """Weave merge that takes a VersionedFile and two versions as its input."""
1399
1399
 
1400
 
    def __init__(self, versionedfile, ver_a, ver_b, 
 
1400
    def __init__(self, versionedfile, ver_a, ver_b,
1401
1401
        a_marker=PlanWeaveMerge.A_MARKER, b_marker=PlanWeaveMerge.B_MARKER):
1402
1402
        plan = versionedfile.plan_merge(ver_a, ver_b)
1403
1403
        PlanWeaveMerge.__init__(self, plan, a_marker, b_marker)
1404
1404
 
1405
1405
 
1406
1406
class VirtualVersionedFiles(VersionedFiles):
1407
 
    """Dummy implementation for VersionedFiles that uses other functions for 
 
1407
    """Dummy implementation for VersionedFiles that uses other functions for
1408
1408
    obtaining fulltexts and parent maps.
1409
1409
 
1410
 
    This is always on the bottom of the stack and uses string keys 
 
1410
    This is always on the bottom of the stack and uses string keys
1411
1411
    (rather than tuples) internally.
1412
1412
    """
1413
1413
 
1415
1415
        """Create a VirtualVersionedFiles.
1416
1416
 
1417
1417
        :param get_parent_map: Same signature as Repository.get_parent_map.
1418
 
        :param get_lines: Should return lines for specified key or None if 
 
1418
        :param get_lines: Should return lines for specified key or None if
1419
1419
                          not available.
1420
1420
        """
1421
1421
        super(VirtualVersionedFiles, self).__init__()
1422
1422
        self._get_parent_map = get_parent_map
1423
1423
        self._get_lines = get_lines
1424
 
        
 
1424
 
1425
1425
    def check(self, progressbar=None):
1426
1426
        """See VersionedFiles.check.
1427
1427