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

  • Committer: Robert Collins
  • Date: 2007-09-04 04:12:07 UTC
  • mfrom: (2794 +trunk)
  • mto: (2592.3.126 repository)
  • mto: This revision was merged to the branch mainline in revision 2795.
  • Revision ID: robertc@robertcollins.net-20070904041207-zb3l8hfco0sp6hu8
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
from bzrlib.lazy_import import lazy_import
75
75
lazy_import(globals(), """
76
76
from bzrlib import (
 
77
    annotate,
77
78
    pack,
78
79
    trace,
79
80
    )
290
291
                       for origin, text in lines)
291
292
        return out
292
293
 
 
294
    def annotate_iter(self, knit, version_id):
 
295
        content = knit._get_content(version_id)
 
296
        return content.annotate_iter()
 
297
 
293
298
 
294
299
class KnitPlainFactory(_KnitFactory):
295
300
    """Factory for creating plain Content objects."""
345
350
            out.extend([text for origin, text in lines])
346
351
        return out
347
352
 
 
353
    def annotate_iter(self, knit, version_id):
 
354
        return annotate_knit(knit, version_id)
 
355
 
348
356
 
349
357
def make_empty_knit(transport, relpath):
350
358
    """Construct a empty knit at the specified location."""
1108
1116
    def annotate_iter(self, version_id):
1109
1117
        """See VersionedFile.annotate_iter."""
1110
1118
        version_id = osutils.safe_revision_id(version_id)
1111
 
        content = self._get_content(version_id)
1112
 
        for origin, text in content.annotate_iter():
1113
 
            yield origin, text
 
1119
        return self.factory.annotate_iter(self, version_id)
1114
1120
 
1115
1121
    def get_parents(self, version_id):
1116
1122
        """See VersionedFile.get_parents."""
2523
2529
        return besti, bestj, bestsize
2524
2530
 
2525
2531
 
 
2532
def annotate_knit(knit, revision_id):
 
2533
    """Annotate a knit with no cached annotations.
 
2534
 
 
2535
    This implementation is for knits with no cached annotations.
 
2536
    It will work for knits with cached annotations, but this is not
 
2537
    recommended.
 
2538
    """
 
2539
    ancestry = knit.get_ancestry(revision_id)
 
2540
    fulltext = dict(zip(ancestry, knit.get_line_list(ancestry)))
 
2541
    annotations = {}
 
2542
    for candidate in ancestry:
 
2543
        if candidate in annotations:
 
2544
            continue
 
2545
        parents = knit.get_parents(candidate)
 
2546
        if len(parents) == 0:
 
2547
            blocks = None
 
2548
        elif knit._index.get_method(candidate) != 'line-delta':
 
2549
            blocks = None
 
2550
        else:
 
2551
            parent, sha1, noeol, delta = knit.get_delta(candidate)
 
2552
            blocks = KnitContent.get_line_delta_blocks(delta,
 
2553
                fulltext[parents[0]], fulltext[candidate])
 
2554
        annotations[candidate] = list(annotate.reannotate([annotations[p]
 
2555
            for p in parents], fulltext[candidate], candidate, blocks))
 
2556
    return iter(annotations[revision_id])
 
2557
 
 
2558
 
2526
2559
try:
2527
2560
    from bzrlib._knit_load_data_c import _load_data_c as _load_data
2528
2561
except ImportError: