equal
deleted
inserted
replaced
1 """utilities to assist in working with pygit2""" |
1 """utilities to assist in working with pygit2""" |
2 |
2 |
3 from mercurial.node import bin, hex, sha1nodeconstants |
3 from mercurial.node import bin, sha1nodeconstants |
4 |
|
5 from mercurial import pycompat |
|
6 |
4 |
7 pygit2_module = None |
5 pygit2_module = None |
8 |
6 |
9 |
7 |
10 def get_pygit2(): |
8 def get_pygit2(): |
36 """Wrapper to convert a Mercurial binary node to a unicode hexlified node. |
34 """Wrapper to convert a Mercurial binary node to a unicode hexlified node. |
37 |
35 |
38 pygit2 and sqlite both need nodes as strings, not bytes. |
36 pygit2 and sqlite both need nodes as strings, not bytes. |
39 """ |
37 """ |
40 assert len(n) == 20 |
38 assert len(n) == 20 |
41 return pycompat.sysstr(hex(n)) |
39 return n.hex() |
42 |
40 |
43 |
41 |
44 def fromgitnode(n): |
42 def fromgitnode(n): |
45 """Opposite of togitnode.""" |
43 """Opposite of togitnode.""" |
46 assert len(n) == 40 |
44 assert len(n) == 40 |