Show More
@@ -1,42 +1,47 b'' | |||||
1 | # node.py - basic nodeid manipulation for mercurial |
|
1 | # node.py - basic nodeid manipulation for mercurial | |
2 | # |
|
2 | # | |
3 | # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> |
|
3 | # Copyright 2005, 2006 Matt Mackall <mpm@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 |
|
8 | from __future__ import absolute_import | |
9 |
|
9 | |||
10 | import binascii |
|
10 | import binascii | |
11 |
|
11 | |||
12 | # This ugly style has a noticeable effect in manifest parsing |
|
12 | # This ugly style has a noticeable effect in manifest parsing | |
13 | hex = binascii.hexlify |
|
13 | hex = binascii.hexlify | |
14 | # Adapt to Python 3 API changes. If this ends up showing up in |
|
14 | # Adapt to Python 3 API changes. If this ends up showing up in | |
15 | # profiles, we can use this version only on Python 3, and forward |
|
15 | # profiles, we can use this version only on Python 3, and forward | |
16 | # binascii.unhexlify like we used to on Python 2. |
|
16 | # binascii.unhexlify like we used to on Python 2. | |
17 | def bin(s): |
|
17 | def bin(s): | |
18 | try: |
|
18 | try: | |
19 | return binascii.unhexlify(s) |
|
19 | return binascii.unhexlify(s) | |
20 | except binascii.Error as e: |
|
20 | except binascii.Error as e: | |
21 | raise TypeError(e) |
|
21 | raise TypeError(e) | |
22 |
|
22 | |||
23 | nullrev = -1 |
|
23 | nullrev = -1 | |
|
24 | # In hex, this is '0000000000000000000000000000000000000000' | |||
24 | nullid = b"\0" * 20 |
|
25 | nullid = b"\0" * 20 | |
25 | nullhex = hex(nullid) |
|
26 | nullhex = hex(nullid) | |
26 |
|
27 | |||
27 | # Phony node value to stand-in for new files in some uses of |
|
28 | # Phony node value to stand-in for new files in some uses of | |
28 | # manifests. |
|
29 | # manifests. | |
29 | newnodeid = '!' * 20 |
|
30 | # In hex, this is '2121212121212121212121212121212121212121' | |
30 | addednodeid = ('0' * 15) + 'added' |
|
31 | newnodeid = '!!!!!!!!!!!!!!!!!!!!' | |
31 | modifiednodeid = ('0' * 12) + 'modified' |
|
32 | # In hex, this is '0000000000000000000000000000006164646564' | |
|
33 | addednodeid = '000000000000000added' | |||
|
34 | # In hex, this is '0000000000000000000000006d6f646966696564' | |||
|
35 | modifiednodeid = '000000000000modified' | |||
32 |
|
36 | |||
33 | wdirfilenodeids = {newnodeid, addednodeid, modifiednodeid} |
|
37 | wdirfilenodeids = {newnodeid, addednodeid, modifiednodeid} | |
34 |
|
38 | |||
35 | # pseudo identifiers for working directory |
|
39 | # pseudo identifiers for working directory | |
36 | # (they are experimental, so don't add too many dependencies on them) |
|
40 | # (they are experimental, so don't add too many dependencies on them) | |
37 | wdirrev = 0x7fffffff |
|
41 | wdirrev = 0x7fffffff | |
|
42 | # In hex, this is 'ffffffffffffffffffffffffffffffffffffffff' | |||
38 | wdirid = b"\xff" * 20 |
|
43 | wdirid = b"\xff" * 20 | |
39 | wdirhex = hex(wdirid) |
|
44 | wdirhex = hex(wdirid) | |
40 |
|
45 | |||
41 | def short(node): |
|
46 | def short(node): | |
42 | return hex(node[:6]) |
|
47 | return hex(node[:6]) |
General Comments 0
You need to be logged in to leave comments.
Login now