/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 breezy/chunk_writer.py

  • Committer: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
        :param chunk_size: The total byte count to emit at the end of the
100
100
            chunk.
101
101
        :param reserved: How many bytes to allow for reserved data. reserved
102
 
            data space can only be written to via the write(..., reserved=True).
 
102
            data space can only be written to via the write(...,
 
103
            reserved=True).
103
104
        """
104
105
        self.chunk_size = chunk_size
105
106
        self.compressor = zlib.compressobj()
122
123
        bytes that did not fit in the chunk.
123
124
 
124
125
        :return: (compressed_bytes, unused_bytes, num_nulls_needed)
125
 
            compressed_bytes    a list of bytes that were output from the
126
 
                                compressor. If the compressed length was not
127
 
                                exactly chunk_size, the final string will be a
128
 
                                string of all null bytes to pad this to
129
 
                                chunk_size
130
 
            unused_bytes        None, or the last bytes that were added, which
131
 
                                we could not fit.
132
 
            num_nulls_needed    How many nulls are padded at the end
 
126
 
 
127
            * compressed_bytes: a list of bytes that were output from the
 
128
              compressor. If the compressed length was not exactly chunk_size,
 
129
              the final string will be a string of all null bytes to pad this
 
130
              to chunk_size
 
131
            * unused_bytes: None, or the last bytes that were added, which we
 
132
              could not fit.
 
133
            * num_nulls_needed: How many nulls are padded at the end
133
134
        """
134
 
        self.bytes_in = None # Free the data cached so far, we don't need it
 
135
        self.bytes_in = None  # Free the data cached so far, we don't need it
135
136
        out = self.compressor.flush(Z_FINISH)
136
137
        self.bytes_list.append(out)
137
138
        self.bytes_out_len += len(out)
142
143
                                 % (self.bytes_out_len, self.chunk_size))
143
144
        nulls_needed = self.chunk_size - self.bytes_out_len
144
145
        if nulls_needed:
145
 
            self.bytes_list.append("\x00" * nulls_needed)
 
146
            self.bytes_list.append(b"\x00" * nulls_needed)
146
147
        return self.bytes_list, self.unused_bytes, nulls_needed
147
148
 
148
149
    def set_optimize(self, for_size=True):
164
165
        :param extra_bytes: Optional, if supplied we will add it with
165
166
            Z_SYNC_FLUSH
166
167
        :return: (bytes_out, bytes_out_len, alt_compressed)
167
 
            bytes_out   is the compressed bytes returned from the compressor
168
 
            bytes_out_len the length of the compressed output
169
 
            compressor  An object with everything packed in so far, and
170
 
                        Z_SYNC_FLUSH called.
 
168
 
 
169
            * bytes_out: is the compressed bytes returned from the compressor
 
170
            * bytes_out_len: the length of the compressed output
 
171
            * compressor: An object with everything packed in so far, and
 
172
              Z_SYNC_FLUSH called.
171
173
        """
172
174
        compressor = zlib.compressobj()
173
175
        bytes_out = []
272
274
                    self.bytes_list = bytes_out
273
275
                    self.bytes_out_len = this_len
274
276
        return False
275