예제 #1
0
 def extract(self, fp):
     line = fp.readline()
     self.hunk.append(line)
     while line and not line.startswith('literal '):
         line = fp.readline()
         self.hunk.append(line)
     if not line:
         raise PatchError(_('could not extract binary patch'))
     size = int(line[8:].rstrip())
     dec = []
     line = fp.readline()
     self.hunk.append(line)
     while len(line) > 1:
         l = line[0]
         if l <= 'Z' and l >= 'A':
             l = ord(l) - ord('A') + 1
         else:
             l = ord(l) - ord('a') + 27
         dec.append(base85.b85decode(line[1:-1])[:l])
         line = fp.readline()
         self.hunk.append(line)
     text = zlib.decompress(''.join(dec))
     if len(text) != size:
         raise PatchError(_('binary patch is %d bytes, not %d') %
                          len(text), size)
     self.text = text
예제 #2
0
def debugbase85obsmarkers(ui, markers):
    """Print information about base85 obsolescence markers."""
    data = base85.b85decode(markers)
    version, markers = obsolete._readmarkers(data)

    out = []
    for precursor, successors, flags, metadata, date, parents in markers:
        if parents:
            parents = [hex(n) for n in parents]

        out.append({
            'precursor': hex(precursor),
            'successors': [hex(n) for n in successors],
            'flags': flags,
            'metadata': metadata,
            'date': date,
            'parents': parents,
        })

    # Ideally we'd use the templater. But we only need machine readable output.
    ui.write(json.dumps(out, indent=4, sort_keys=True, separators=(',', ': ')))