def fmtline(line): l = len(line) if l <= 26: l = chr(ord("A") + l - 1) else: l = chr(l - 26 + ord("a") - 1) return "%c%s\n" % (l, base85.b85encode(line, True))
def fmtline(line): l = len(line) if l <= 26: l = chr(ord('A') + l - 1) else: l = chr(l - 26 + ord('a') - 1) return '%c%s\n' % (l, base85.b85encode(line, True))
def listmarkers(repo): """List markers over pushkey""" if not repo.obsstore: return {} keys = {} parts = [] currentlen = _maxpayload * 2 # ensure we create a new part for marker in repo.obsstore: nextdata = _encodeonemarker(marker) if (len(nextdata) + currentlen > _maxpayload): currentpart = [] currentlen = 0 parts.append(currentpart) currentpart.append(nextdata) currentlen += len(nextdata) for idx, part in enumerate(reversed(parts)): data = ''.join([_pack('>B', _fmversion)] + part) keys['dump%i' % idx] = base85.b85encode(data) return keys
def _pushkeyescape(markers): """encode markers into a dict suitable for pushkey exchange - binary data is base85 encoded - split in chunks smaller than 5300 bytes""" keys = {} parts = [] currentlen = _maxpayload * 2 # ensure we create a new part for marker in markers: nextdata = _encodeonemarker(marker) if (len(nextdata) + currentlen > _maxpayload): currentpart = [] currentlen = 0 parts.append(currentpart) currentpart.append(nextdata) currentlen += len(nextdata) for idx, part in enumerate(reversed(parts)): data = ''.join([_pack('>B', _fmversion)] + part) keys['dump%i' % idx] = base85.b85encode(data) return keys
def _pushkeyescape(markers): """encode markers into a dict suitable for pushkey exchange - binary data is base85 encoded - split in chunks smaller than 5300 bytes""" keys = {} parts = [] currentlen = _maxpayload * 2 # ensure we create a new part for marker in markers: nextdata = _fm0encodeonemarker(marker) if (len(nextdata) + currentlen > _maxpayload): currentpart = [] currentlen = 0 parts.append(currentpart) currentpart.append(nextdata) currentlen += len(nextdata) for idx, part in enumerate(reversed(parts)): data = ''.join([_pack('>B', _fm0version)] + part) keys['dump%i' % idx] = base85.b85encode(data) return keys
def ctxpvec(ctx): """construct a pvec for ctx while filling in the cache""" r = ctx.repo() if not util.safehasattr(r, "_pveccache"): r._pveccache = {} pvc = r._pveccache if ctx.rev() not in pvc: cl = r.changelog for n in xrange(ctx.rev() + 1): if n not in pvc: node = cl.node(n) p1, p2 = cl.parentrevs(n) if p1 == nullrev: # start with a 'random' vector at root pvc[n] = (0, _bin((node * 3)[:_vecbytes])) elif p2 == nullrev: d, v = pvc[p1] pvc[n] = (d + 1, _flipbit(v, node)) else: pvc[n] = _mergevec(pvc[p1], pvc[p2], node) bs = _join(*pvc[ctx.rev()]) return pvec(base85.b85encode(bs))
def ctxpvec(ctx): '''construct a pvec for ctx while filling in the cache''' r = ctx.repo() if not util.safehasattr(r, "_pveccache"): r._pveccache = {} pvc = r._pveccache if ctx.rev() not in pvc: cl = r.changelog for n in xrange(ctx.rev() + 1): if n not in pvc: node = cl.node(n) p1, p2 = cl.parentrevs(n) if p1 == nullrev: # start with a 'random' vector at root pvc[n] = (0, _bin((node * 3)[:_vecbytes])) elif p2 == nullrev: d, v = pvc[p1] pvc[n] = (d + 1, _flipbit(v, node)) else: pvc[n] = _mergevec(pvc[p1], pvc[p2], node) bs = _join(*pvc[ctx.rev()]) return pvec(base85.b85encode(bs))
def base85encode(importx, infilepath, outfilepath, inputformat, raw, exportx): if importx == 'file': f = open(infilepath, 'r') raw = f.read() f.close() elif importx == 'print': raw = raw else: print('\033[1;31m[-]\033[0m Unknown error.') return False inp = raw if inputformat == 'base64': iput = base64.b64decode(inp) elif inputformat == 'raw': iput = inp elif inputformat == 'base32': iput = base64.b32decode(inp) elif inputformat == 'base16': iput = base64.b16decode(inp) elif inputformat == 'base58': iput = base58.b58decode(inp) elif inputformat == 'base85': print('\033[1;31m[-]\033[0m Option not available yet') elif inputformat == 'hex': iput = inp.decode('hex') elif inputformat == 'dec': print('\033[1;31m[-]\033[0m Option not available yet') elif inputformat == 'octal': print('\033[1;31m[-]\033[0m Option not available yet') elif inputformat == 'binary': iput = text_from_bits(inp) else: print('\033[1;31m[-]\033[0m Unknown error.') return False output = b85encode(iput) if exportx == 'file': f = open(outfilepath, 'w') f.write(output) f.close() return True elif exportx == 'print': return output else: print('\033[1;31m[-]\033[0m Unknown error.') return False