/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/git/roundtrip.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:
45
45
  * TreeSupplement
46
46
"""
47
47
 
48
 
from __future__ import absolute_import
49
 
 
50
48
from .. import osutils
51
49
 
52
50
from io import BytesIO
147
145
    if not isinstance(rt_data, bytes):
148
146
        raise TypeError(rt_data)
149
147
    return message + b"\n--BZR--\n" + rt_data
150
 
 
151
 
 
152
 
def serialize_fileid_map(file_ids):
153
 
    """Serialize a fileid map.
154
 
 
155
 
    :param file_ids: Path -> fileid map
156
 
    :return: Serialized fileid map, as sequence of chunks
157
 
    """
158
 
    lines = []
159
 
    for path in sorted(file_ids.keys()):
160
 
        lines.append(b"%s\0%s\n" % (path.encode('utf-8'), file_ids[path]))
161
 
    return lines
162
 
 
163
 
 
164
 
def deserialize_fileid_map(filetext):
165
 
    """Deserialize a file id map.
166
 
 
167
 
    :param file: File
168
 
    :return: Fileid map (path -> fileid)
169
 
    """
170
 
    ret = {}
171
 
    f = BytesIO(filetext)
172
 
    lines = f.readlines()
173
 
    for l in lines:
174
 
        (path, file_id) = l.rstrip(b"\n").split(b"\0")
175
 
        ret[path.decode('utf-8')] = file_id
176
 
    return ret