/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

merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
193
193
        already present in file history."""
194
194
        new_version_id = osutils.safe_revision_id(new_version_id)
195
195
        old_version_id = osutils.safe_revision_id(old_version_id)
 
196
        parents = [osutils.safe_revision_id(v) for v in parents]
196
197
        self._check_write_ok()
197
198
        return self._clone_text(new_version_id, old_version_id, parents)
198
199
 
209
210
        """
210
211
        raise NotImplementedError(self.create_empty)
211
212
 
212
 
    def fix_parents(self, version_id, new_parents):
213
 
        """Fix the parents list for version.
214
 
        
215
 
        This is done by appending a new version to the index
216
 
        with identical data except for the parents list.
217
 
        the parents list must be a superset of the current
218
 
        list.
219
 
        """
220
 
        version_id = osutils.safe_revision_id(version_id)
221
 
        new_parents = [osutils.safe_revision_id(p) for p in new_parents]
222
 
        self._check_write_ok()
223
 
        return self._fix_parents(version_id, new_parents)
224
 
 
225
 
    def _fix_parents(self, version_id, new_parents):
226
 
        """Helper for fix_parents."""
227
 
        raise NotImplementedError(self.fix_parents)
228
 
 
229
213
    def get_format_signature(self):
230
214
        """Get a text description of the data encoding in this file.
231
215
        
232
 
        :since: 0.19
 
216
        :since: 0.90
233
217
        """
234
218
        raise NotImplementedError(self.get_format_signature)
235
219
 
236
220
    def make_mpdiffs(self, version_ids):
237
 
        """Create multiparent diffs for specified versions"""
 
221
        """Create multiparent diffs for specified versions."""
238
222
        knit_versions = set()
239
223
        for version_id in version_ids:
240
224
            knit_versions.add(version_id)
258
242
        return None
259
243
 
260
244
    def add_mpdiffs(self, records):
261
 
        """Add mpdiffs to this versionedfile
 
245
        """Add mpdiffs to this VersionedFile.
262
246
 
263
247
        Records should be iterables of version, parents, expected_sha1,
264
 
        mpdiff.  mpdiff should be a MultiParent instance.
 
248
        mpdiff. mpdiff should be a MultiParent instance.
265
249
        """
 
250
        # Does this need to call self._check_write_ok()? (IanC 20070919)
266
251
        vf_parents = {}
267
252
        mpvf = multiparent.MultiMemoryVersionedFile()
268
253
        versions = []
294
279
    def get_sha1(self, version_id):
295
280
        """Get the stored sha1 sum for the given revision.
296
281
        
297
 
        :param name: The name of the version to lookup
 
282
        :param version_id: The name of the version to lookup
298
283
        """
299
284
        raise NotImplementedError(self.get_sha1)
300
285
 
304
289
        :param version_ids: The names of the versions to lookup
305
290
        :return: a list of sha1s in order according to the version_ids
306
291
        """
307
 
        raise NotImplementedError(self.get_sha1)
 
292
        raise NotImplementedError(self.get_sha1s)
308
293
 
309
294
    def get_suffixes(self):
310
295
        """Return the file suffixes associated with this versioned file."""
416
401
        """Yield list of (version-id, line) pairs for the specified
417
402
        version.
418
403
 
419
 
        Must raise RevisionNotPresent if any of the given versions are
 
404
        Must raise RevisionNotPresent if the given version is
420
405
        not present in file history.
421
406
        """
422
407
        raise NotImplementedError(self.annotate_iter)
424
409
    def annotate(self, version_id):
425
410
        return list(self.annotate_iter(version_id))
426
411
 
427
 
    def _apply_delta(self, lines, delta):
428
 
        """Apply delta to lines."""
429
 
        lines = list(lines)
430
 
        offset = 0
431
 
        for start, end, count, delta_lines in delta:
432
 
            lines[offset+start:offset+end] = delta_lines
433
 
            offset = offset + (start - end) + count
434
 
        return lines
435
 
 
436
412
    def join(self, other, pb=None, msg=None, version_ids=None,
437
413
             ignore_missing=False):
438
414
        """Integrate versions from other into this versioned file.
441
417
        incorporated into this versioned file.
442
418
 
443
419
        Must raise RevisionNotPresent if any of the specified versions
444
 
        are not present in the other files history unless ignore_missing
445
 
        is supplied when they are silently skipped.
 
420
        are not present in the other file's history unless ignore_missing
 
421
        is supplied in which case they are silently skipped.
446
422
        """
447
423
        self._check_write_ok()
448
424
        return InterVersionedFile.get(other, self).join(
585
561
 
586
562
 
587
563
class WeaveMerge(PlanWeaveMerge):
588
 
    """Weave merge that takes a VersionedFile and two versions as its input"""
 
564
    """Weave merge that takes a VersionedFile and two versions as its input."""
589
565
 
590
566
    def __init__(self, versionedfile, ver_a, ver_b, 
591
567
        a_marker=PlanWeaveMerge.A_MARKER, b_marker=PlanWeaveMerge.B_MARKER):
594
570
 
595
571
 
596
572
class InterVersionedFile(InterObject):
597
 
    """This class represents operations taking place between two versionedfiles..
 
573
    """This class represents operations taking place between two VersionedFiles.
598
574
 
599
575
    Its instances have methods like join, and contain
600
576
    references to the source and target versionedfiles these operations can be 
615
591
        incorporated into this versioned file.
616
592
 
617
593
        Must raise RevisionNotPresent if any of the specified versions
618
 
        are not present in the other files history unless ignore_missing is 
619
 
        supplied when they are silently skipped.
 
594
        are not present in the other file's history unless ignore_missing is 
 
595
        supplied in which case they are silently skipped.
620
596
        """
621
597
        # the default join: 
622
598
        # - if the target is empty, just add all the versions from 
649
625
            # TODO: remove parent texts when they are not relevant any more for 
650
626
            # memory pressure reduction. RBC 20060313
651
627
            # pb.update('Converting versioned data', 0, len(order))
 
628
            total = len(order)
652
629
            for index, version in enumerate(order):
653
 
                pb.update('Converting versioned data', index, len(order))
 
630
                pb.update('Converting versioned data', index, total)
654
631
                _, _, parent_text = target.add_lines(version,
655
632
                                               self.source.get_parents(version),
656
633
                                               self.source.get_lines(version),
664
641
                                        msg,
665
642
                                        version_ids,
666
643
                                        ignore_missing)
 
644
            else:
 
645
                return total
667
646
        finally:
668
647
            pb.finished()
669
648