equal
deleted
inserted
replaced
|
1 """utilities to assist in working with pygit2""" |
|
2 from __future__ import absolute_import |
|
3 |
|
4 from mercurial.node import bin, hex, nullid |
|
5 |
|
6 from mercurial import pycompat |
|
7 |
|
8 |
|
9 def togitnode(n): |
|
10 """Wrapper to convert a Mercurial binary node to a unicode hexlified node. |
|
11 |
|
12 pygit2 and sqlite both need nodes as strings, not bytes. |
|
13 """ |
|
14 assert len(n) == 20 |
|
15 return pycompat.sysstr(hex(n)) |
|
16 |
|
17 |
|
18 def fromgitnode(n): |
|
19 """Opposite of togitnode.""" |
|
20 assert len(n) == 40 |
|
21 if pycompat.ispy3: |
|
22 return bin(n.encode('ascii')) |
|
23 return bin(n) |
|
24 |
|
25 |
|
26 nullgit = togitnode(nullid) |