##// END OF EJS Templates
git: make {shortest()} return shortest *unique* prefix...
git: make {shortest()} return shortest *unique* prefix It used to return the prefix of the specified length as long as the full node was unique (i.e. always). Differential Revision: https://phab.mercurial-scm.org/D8256

File last commit:

r44946:7e69ff57 default
r44962:6d953b3f default
Show More
gitutil.py
26 lines | 581 B | text/x-python | PythonLexer
"""utilities to assist in working with pygit2"""
from __future__ import absolute_import
from mercurial.node import bin, hex, nullid
from mercurial import pycompat
def togitnode(n):
"""Wrapper to convert a Mercurial binary node to a unicode hexlified node.
pygit2 and sqlite both need nodes as strings, not bytes.
"""
assert len(n) == 20
return pycompat.sysstr(hex(n))
def fromgitnode(n):
"""Opposite of togitnode."""
assert len(n) == 40
if pycompat.ispy3:
return bin(n.encode('ascii'))
return bin(n)
nullgit = togitnode(nullid)