Mercurial > hg-stable
comparison mercurial/debugcommands.py @ 47676:096ee2e260a3
dirstate-v2: Rename Header to Root, move it to the end of the data file
Now that they don’t have to be at the start, a given data file may contain
multiple "roots". A docket only points to one of them, and previous ones
are left unused to allow allow append-only in-place writing to an existing
data file.
Differential Revision: https://phab.mercurial-scm.org/D11090
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 12 Jul 2021 23:05:56 +0200 |
parents | ff97e793ed36 |
children | 78f7f0d490ee |
comparison
equal
deleted
inserted
replaced
47675:48aec076b8fb | 47676:096ee2e260a3 |
---|---|
995 def debugdirstateignorepatternshash(ui, repo, **opts): | 995 def debugdirstateignorepatternshash(ui, repo, **opts): |
996 """show the hash of ignore patterns stored in dirstate if v2, | 996 """show the hash of ignore patterns stored in dirstate if v2, |
997 or nothing for dirstate-v2 | 997 or nothing for dirstate-v2 |
998 """ | 998 """ |
999 if repo.dirstate._use_dirstate_v2: | 999 if repo.dirstate._use_dirstate_v2: |
1000 hash_offset = 16 # Four 32-bit integers before this field | 1000 docket = repo.dirstate._map.docket |
1001 hash_len = 20 # 160 bits for SHA-1 | 1001 hash_len = 20 # 160 bits for SHA-1 |
1002 data_filename = repo.dirstate._map.docket.data_filename() | 1002 hash_offset = docket.data_size - hash_len # hash is at the end |
1003 data_filename = docket.data_filename() | |
1003 with repo.vfs(data_filename) as f: | 1004 with repo.vfs(data_filename) as f: |
1004 hash_bytes = f.read(hash_offset + hash_len)[-hash_len:] | 1005 f.seek(hash_offset) |
1006 hash_bytes = f.read(hash_len) | |
1005 ui.write(binascii.hexlify(hash_bytes) + b'\n') | 1007 ui.write(binascii.hexlify(hash_bytes) + b'\n') |
1006 | 1008 |
1007 | 1009 |
1008 @command( | 1010 @command( |
1009 b'debugdiscovery', | 1011 b'debugdiscovery', |