Uniqueness of Rev. Hex Id.s
Gregory Szorc
gregory.szorc at gmail.com
Wed Jan 22 17:49:34 UTC 2014
On 1/22/14, 9:06 AM, Pietro Moras wrote:
> I read that in a Revision identifier, such as: “3:1ff43bfdd8a2”, the
> integer No. is Working Directory unique, whereas the hexadecimal
> Identifier is global unique, that is unique for all cloned copies. Fine.
>
> Any idea what is the mathematical algorithm used to generate such global
> unique codes within distinct clones of a versioned Project? Thanks.
It is a SHA-1 based on the text content plus the hashes of the parent(s)
[1]. FWIW, the SHA-1 is generated when the entry is added to storage
(committed) and the SHA-1 is transferred as-is during clones, pushes,
pulls, etc, so it's not regenerated. But, the hash is verified when
entries are read [2]. If the underlying data changes, the hashes change,
and Mercurial aborts.
[1] http://selenic.com/repo/hg/file/dbf305f49961/mercurial/revlog.py#l57
[2] http://selenic.com/repo/hg/file/dbf305f49961/mercurial/revlog.py#l1005
More information about the Mercurial
mailing list