~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: Robert Collins
  • Date: 2009-03-27 04:10:25 UTC
  • mfrom: (4208 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4216.
  • Revision ID: robertc@robertcollins.net-20090327041025-rgutx4q03xo4pq6l
Resolve NEWS conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Knit versionedfile implementation.
18
18
 
1609
1609
                # KnitVersionedFiles doesn't permit deltas (_max_delta_chain ==
1610
1610
                # 0) or because it depends on a base only present in the
1611
1611
                # fallback kvfs.
 
1612
                self._access.flush()
1612
1613
                try:
1613
1614
                    # Try getting a fulltext directly from the record.
1614
1615
                    bytes = record.get_bytes_as('fulltext')
3049
3050
            result.append((key, base, size))
3050
3051
        return result
3051
3052
 
 
3053
    def flush(self):
 
3054
        """Flush pending writes on this access object.
 
3055
        
 
3056
        For .knit files this is a no-op.
 
3057
        """
 
3058
        pass
 
3059
 
3052
3060
    def get_raw_records(self, memos_for_retrieval):
3053
3061
        """Get the raw bytes for a records.
3054
3062
 
3079
3087
class _DirectPackAccess(object):
3080
3088
    """Access to data in one or more packs with less translation."""
3081
3089
 
3082
 
    def __init__(self, index_to_packs, reload_func=None):
 
3090
    def __init__(self, index_to_packs, reload_func=None, flush_func=None):
3083
3091
        """Create a _DirectPackAccess object.
3084
3092
 
3085
3093
        :param index_to_packs: A dict mapping index objects to the transport
3092
3100
        self._write_index = None
3093
3101
        self._indices = index_to_packs
3094
3102
        self._reload_func = reload_func
 
3103
        self._flush_func = flush_func
3095
3104
 
3096
3105
    def add_raw_records(self, key_sizes, raw_data):
3097
3106
        """Add raw knit bytes to a storage area.
3119
3128
            result.append((self._write_index, p_offset, p_length))
3120
3129
        return result
3121
3130
 
 
3131
    def flush(self):
 
3132
        """Flush pending writes on this access object.
 
3133
 
 
3134
        This will flush any buffered writes to a NewPack.
 
3135
        """
 
3136
        if self._flush_func is not None:
 
3137
            self._flush_func()
 
3138
            
3122
3139
    def get_raw_records(self, memos_for_retrieval):
3123
3140
        """Get the raw bytes for a records.
3124
3141