Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revlogutils/nodemap.py @ 47322:5bc6d2fc1cfc
persistent-nodemap: use the intended uuid size
I overlooked this in the initial implementation. The format already supporting
any uuid size so, nothing horrible should happens.
Differential Revision: https://phab.mercurial-scm.org/D10754
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 19 May 2021 17:12:06 +0200 |
parents | 9a3aa54774ff |
children | 7ea39d633cf3 |
line wrap: on
line diff
--- a/mercurial/revlogutils/nodemap.py Wed May 19 17:19:46 2021 +0200 +++ b/mercurial/revlogutils/nodemap.py Wed May 19 17:12:06 2021 +0200 @@ -288,7 +288,9 @@ """return a new unique identifier. The identifier is random and composed of ascii characters.""" - return hex(os.urandom(ID_SIZE)) + # size we "hex" the result we need half the number of bits to have a final + # uuid of size ID_SIZE + return hex(os.urandom(ID_SIZE // 2)) # some special test logic to avoid anoying random output in the test @@ -321,9 +323,9 @@ else: r.seed(int_seed) # once we drop python 3.8 support we can simply use r.randbytes - raw = r.getrandbits(ID_SIZE * 8) + raw = r.getrandbits(ID_SIZE * 4) assert ID_SIZE == 8 - p = struct.pack('>Q', raw) + p = struct.pack('>L', raw) new = hex(p) with open(stable_docket_file, 'wb') as f: f.write(new)