Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 47674:ff97e793ed36
dirstate-v2: Introduce a docket file
.hg/dirstate now only contains some metadata to point to a separate data file
named .hg/dirstate.{}.d with a random hexadecimal identifier. For now every
update creates a new data file and removes the old one, but later we?ll
(usually) append to an existing file.
Separating into two files allows doing the "write to a temporary file then
atomically rename into destination" dance with only a small docket file,
without always rewriting a lot of data.
Differential Revision: https://phab.mercurial-scm.org/D11088
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Thu, 08 Jul 2021 12:18:21 +0200 |
parents | 85ce6ed51b9c |
children | 096ee2e260a3 |
comparison
equal
deleted
inserted
replaced
47673:37825a85d3b0 | 47674:ff97e793ed36 |
---|---|
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | 9 |
10 import binascii | |
10 import codecs | 11 import codecs |
11 import collections | 12 import collections |
12 import contextlib | 13 import contextlib |
13 import difflib | 14 import difflib |
14 import errno | 15 import errno |
985 for f in repo.dirstate.copies(): | 986 for f in repo.dirstate.copies(): |
986 ui.write(_(b"copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) | 987 ui.write(_(b"copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) |
987 | 988 |
988 | 989 |
989 @command( | 990 @command( |
991 b'debugdirstateignorepatternshash', | |
992 [], | |
993 _(b''), | |
994 ) | |
995 def debugdirstateignorepatternshash(ui, repo, **opts): | |
996 """show the hash of ignore patterns stored in dirstate if v2, | |
997 or nothing for dirstate-v2 | |
998 """ | |
999 if repo.dirstate._use_dirstate_v2: | |
1000 hash_offset = 16 # Four 32-bit integers before this field | |
1001 hash_len = 20 # 160 bits for SHA-1 | |
1002 data_filename = repo.dirstate._map.docket.data_filename() | |
1003 with repo.vfs(data_filename) as f: | |
1004 hash_bytes = f.read(hash_offset + hash_len)[-hash_len:] | |
1005 ui.write(binascii.hexlify(hash_bytes) + b'\n') | |
1006 | |
1007 | |
1008 @command( | |
990 b'debugdiscovery', | 1009 b'debugdiscovery', |
991 [ | 1010 [ |
992 (b'', b'old', None, _(b'use old-style discovery')), | 1011 (b'', b'old', None, _(b'use old-style discovery')), |
993 ( | 1012 ( |
994 b'', | 1013 b'', |