equal
deleted
inserted
replaced
3 # Copyright 2005, 2006 Olivia Mackall <olivia@selenic.com> |
3 # Copyright 2005, 2006 Olivia Mackall <olivia@selenic.com> |
4 # |
4 # |
5 # This software may be used and distributed according to the terms of the |
5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. |
6 # GNU General Public License version 2 or any later version. |
7 |
7 |
8 from __future__ import absolute_import |
|
9 |
8 |
10 import binascii |
9 import binascii |
11 |
10 |
12 # This ugly style has a noticeable effect in manifest parsing |
11 # This ugly style has a noticeable effect in manifest parsing |
13 hex = binascii.hexlify |
12 hex = binascii.hexlify |
14 # Adapt to Python 3 API changes. If this ends up showing up in |
13 bin = binascii.unhexlify |
15 # profiles, we can use this version only on Python 3, and forward |
|
16 # binascii.unhexlify like we used to on Python 2. |
|
17 def bin(s): |
|
18 try: |
|
19 return binascii.unhexlify(s) |
|
20 except binascii.Error as e: |
|
21 raise TypeError(e) |
|
22 |
14 |
23 |
15 |
24 def short(node): |
16 def short(node): |
25 return hex(node[:6]) |
17 return hex(node[:6]) |
26 |
18 |
30 # pseudo identifier for working directory |
22 # pseudo identifier for working directory |
31 # (experimental, so don't add too many dependencies on it) |
23 # (experimental, so don't add too many dependencies on it) |
32 wdirrev = 0x7FFFFFFF |
24 wdirrev = 0x7FFFFFFF |
33 |
25 |
34 |
26 |
35 class sha1nodeconstants(object): |
27 class sha1nodeconstants: |
36 nodelen = 20 |
28 nodelen = 20 |
37 |
29 |
38 # In hex, this is '0000000000000000000000000000000000000000' |
30 # In hex, this is '0000000000000000000000000000000000000000' |
39 nullid = b"\0" * nodelen |
31 nullid = b"\0" * nodelen |
40 nullhex = hex(nullid) |
32 nullhex = hex(nullid) |