comparison contrib/undumprevlog @ 47072:4c041c71ec01

revlog: introduce an explicit tracking of what the revlog is about Since the dawn of time, people have been forced to rely to lossy introspection of the index filename to determine what the purpose and role of the revlog they encounter is. This is hacky, error prone, inflexible, abstraction-leaky, <insert-your-own-complaints-here>. In f63299ee7e4d Raphaël introduced a new attribute to track this information: `revlog_kind`. However it is initialized in an odd place and various instances end up not having it set. In addition is only tracking some of the information we end up having to introspect in various pieces of code. So we add a new attribute that holds more data and is more strictly enforced. This work is done in collaboration with Raphaël. The `revlog_kind` one will be removed/adapted in the next changeset. We expect to be able to clean up various existing piece of code and to simplify coming work around the newer revlog format. Differential Revision: https://phab.mercurial-scm.org/D10352
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 06 Apr 2021 05:20:24 +0200
parents 59fa3890d40a
children 8d3c2f9d4af7
comparison
equal deleted inserted replaced
47071:3e381eb557f3 47072:4c041c71ec01
13 transaction, 13 transaction,
14 vfs as vfsmod, 14 vfs as vfsmod,
15 ) 15 )
16 from mercurial.utils import procutil 16 from mercurial.utils import procutil
17 17
18 from mercurial.revlogutils import (
19 constants as revlog_constants,
20 )
21
18 for fp in (sys.stdin, sys.stdout, sys.stderr): 22 for fp in (sys.stdin, sys.stdout, sys.stderr):
19 procutil.setbinary(fp) 23 procutil.setbinary(fp)
20 24
21 opener = vfsmod.vfs(b'.', False) 25 opener = vfsmod.vfs(b'.', False)
22 tr = transaction.transaction( 26 tr = transaction.transaction(
26 l = sys.stdin.readline() 30 l = sys.stdin.readline()
27 if not l: 31 if not l:
28 break 32 break
29 if l.startswith("file:"): 33 if l.startswith("file:"):
30 f = encoding.strtolocal(l[6:-1]) 34 f = encoding.strtolocal(l[6:-1])
31 r = revlog.revlog(opener, f) 35 r = revlog.revlog(
36 opener,
37 target=(revlog_constants.KIND_OTHER, b'undump-revlog'),
38 indexfile=f,
39 )
32 procutil.stdout.write(b'%s\n' % f) 40 procutil.stdout.write(b'%s\n' % f)
33 elif l.startswith("node:"): 41 elif l.startswith("node:"):
34 n = bin(l[6:-1]) 42 n = bin(l[6:-1])
35 elif l.startswith("linkrev:"): 43 elif l.startswith("linkrev:"):
36 lr = int(l[9:-1]) 44 lr = int(l[9:-1])