~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/groupcompress.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-05-18 13:02:52 UTC
  • mfrom: (5830.3.6 i18n-msgfmt)
  • Revision ID: pqm@pqm.ubuntu.com-20110518130252-ky96qcvzt6o0zg3f
(mbp) add build_mo command to setup.py (INADA Naoki)

Show diffs side-by-side

added added

removed removed

Lines of Context:
466
466
                # Grab and cache the raw bytes for this entry
467
467
                # and break the ref-cycle with _manager since we don't need it
468
468
                # anymore
469
 
                try:
470
 
                    self._manager._prepare_for_extract()
471
 
                except zlib.error as value:
472
 
                    raise errors.DecompressCorruption("zlib: " + str(value))
 
469
                self._manager._prepare_for_extract()
473
470
                block = self._manager._block
474
471
                self._bytes = block.extract(self.key, self._start, self._end)
475
472
                # There are code paths that first extract as fulltext, and then
988
985
 
989
986
    It contains code very similar to SequenceMatcher because of having a similar
990
987
    task. However some key differences apply:
991
 
 
992
 
    * there is no junk, we want a minimal edit not a human readable diff.
993
 
    * we don't filter very common lines (because we don't know where a good
994
 
      range will start, and after the first text we want to be emitting minmal
995
 
      edits only.
996
 
    * we chain the left side, not the right side
997
 
    * we incrementally update the adjacency matrix as new lines are provided.
998
 
    * we look for matches in all of the left side, so the routine which does
999
 
      the analagous task of find_longest_match does not need to filter on the
1000
 
      left side.
 
988
     - there is no junk, we want a minimal edit not a human readable diff.
 
989
     - we don't filter very common lines (because we don't know where a good
 
990
       range will start, and after the first text we want to be emitting minmal
 
991
       edits only.
 
992
     - we chain the left side, not the right side
 
993
     - we incrementally update the adjacency matrix as new lines are provided.
 
994
     - we look for matches in all of the left side, so the routine which does
 
995
       the analagous task of find_longest_match does not need to filter on the
 
996
       left side.
1001
997
    """
1002
998
 
1003
999
    def __init__(self, settings=None):
1259
1255
        :param key: The key tuple of the text to add.
1260
1256
        :param parents: The parents key tuples of the text to add.
1261
1257
        :param lines: A list of lines. Each line must be a bytestring. And all
1262
 
            of them except the last must be terminated with \\n and contain no
1263
 
            other \\n's. The last line may either contain no \\n's or a single
1264
 
            terminating \\n. If the lines list does meet this constraint the
1265
 
            add routine may error or may succeed - but you will be unable to
1266
 
            read the data back accurately. (Checking the lines have been split
 
1258
            of them except the last must be terminated with \n and contain no
 
1259
            other \n's. The last line may either contain no \n's or a single
 
1260
            terminating \n. If the lines list does meet this constraint the add
 
1261
            routine may error or may succeed - but you will be unable to read
 
1262
            the data back accurately. (Checking the lines have been split
1267
1263
            correctly is expensive and extremely unlikely to catch bugs so it
1268
1264
            is not done at runtime unless check_content is True.)
1269
1265
        :param parent_texts: An optional dictionary containing the opaque
1507
1503
 
1508
1504
        The returned objects should be in the order defined by 'ordering',
1509
1505
        which can weave between different sources.
1510
 
 
1511
1506
        :param ordering: Must be one of 'topological' or 'groupcompress'
1512
1507
        :return: List of [(source, [keys])] tuples, such that all keys are in
1513
1508
            the defined order, regardless of source.
2135
2130
        :param keys: An iterable of keys.
2136
2131
        :return: A dict of key:
2137
2132
            (index_memo, compression_parent, parents, record_details).
2138
 
 
2139
 
            * index_memo: opaque structure to pass to read_records to extract
2140
 
              the raw data
2141
 
            * compression_parent: Content that this record is built upon, may
2142
 
              be None
2143
 
            * parents: Logical parents of this node
2144
 
            * record_details: extra information about the content which needs
2145
 
              to be passed to Factory.parse_record
 
2133
            index_memo
 
2134
                opaque structure to pass to read_records to extract the raw
 
2135
                data
 
2136
            compression_parent
 
2137
                Content that this record is built upon, may be None
 
2138
            parents
 
2139
                Logical parents of this node
 
2140
            record_details
 
2141
                extra information about the content which needs to be passed to
 
2142
                Factory.parse_record
2146
2143
        """
2147
2144
        self._check_read()
2148
2145
        result = {}