Mercury Global Set Identifier Assignment

Mercurial seems to assign a global change identifier for each change. How do they guarantee that it is unique?

+3
source share
2 answers

As Zack says, the change set identifier is calculated using the SHA-1 hash function . This is an example of a cryptographically secure hash function. Cryptographic hash functions take an input string of arbitrary length and call a collection of fixed length from this string. In the case of SHA-1, the output length is fixed to 160 bits, of which, by default, Mercurial only shows the first 48 bits (12 hexadecimal digits).

- , , , .. x != y, H(x) == H(y). .

Mercurial SHA-1 , ( , ). , (x != y), ( ) - .

, , SHA-1! SHA-1, .


, - SHA-1 Mercurial. :

SHA-1 (. changelog.py revlog.py). - , .

, , Hello World! - ( ), .

+8

Mercurial changeset SHA-1 "" . , SHA-1. , , .

. gory.

+5

Source: https://habr.com/ru/post/1761425/


All Articles