comparison mercurial/cmdutil.py @ 47089: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 45dcb63f8ead
children 5ffc6c18fb96
comparison
equal deleted inserted replaced
47088:3e381eb557f3 47089:4c041c71ec01
57 ) 57 )
58 58
59 from .utils import ( 59 from .utils import (
60 dateutil, 60 dateutil,
61 stringutil, 61 stringutil,
62 )
63
64 from .revlogutils import (
65 constants as revlog_constants,
62 ) 66 )
63 67
64 if pycompat.TYPE_CHECKING: 68 if pycompat.TYPE_CHECKING:
65 from typing import ( 69 from typing import (
66 Any, 70 Any,
1426 1430
1427 if not file_: 1431 if not file_:
1428 raise error.CommandError(cmd, _(b'invalid arguments')) 1432 raise error.CommandError(cmd, _(b'invalid arguments'))
1429 if not os.path.isfile(file_): 1433 if not os.path.isfile(file_):
1430 raise error.InputError(_(b"revlog '%s' not found") % file_) 1434 raise error.InputError(_(b"revlog '%s' not found") % file_)
1435
1436 target = (revlog_constants.KIND_OTHER, b'free-form:%s' % file_)
1431 r = revlog.revlog( 1437 r = revlog.revlog(
1432 vfsmod.vfs(encoding.getcwd(), audit=False), file_[:-2] + b".i" 1438 vfsmod.vfs(encoding.getcwd(), audit=False),
1439 target=target,
1440 indexfile=file_[:-2] + b".i",
1433 ) 1441 )
1434 return r 1442 return r
1435 1443
1436 1444
1437 def openrevlog(repo, cmd, file_, opts): 1445 def openrevlog(repo, cmd, file_, opts):