/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: Jelmer Vernooij
  • Date: 2019-08-11 13:21:03 UTC
  • mfrom: (7379 work)
  • mto: This revision was merged to the branch mainline in revision 7388.
  • Revision ID: jelmer@jelmer.uk-20190811132103-u3ne03yf37c1h57n
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
    if not isinstance(rt_data, bytes):
148
148
        raise TypeError(rt_data)
149
149
    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