mercurial/debugcommands.py
changeset 47676 096ee2e260a3
parent 47674 ff97e793ed36
child 47682 78f7f0d490ee
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',