##// END OF EJS Templates
revlog: introduce an explicit tracking of what the revlog is about...
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

File last commit:

r47838:4c041c71 default
r47838:4c041c71 default
Show More
dumprevlog
55 lines | 1.2 KiB | text/plain | TextLexer
Gregory Szorc
global: use python3 in shebangs...
r46434 #!/usr/bin/env python3
Matt Mackall
add simple dump and undump scripts to contrib/
r6433 # Dump revlogs as raw data stream
# $ find .hg/store/ -name "*.i" | xargs dumprevlog > repo.dump
Pulkit Goyal
py3: make contrib/dumprevlog use print_function
r29166 from __future__ import absolute_import, print_function
Pulkit Goyal
py3: make contrib/dumprevlog use absolute_import
r29165
Matt Mackall
add simple dump and undump scripts to contrib/
r6433 import sys
Joerg Sonnenberger
node: import symbols explicitly...
r46729 from mercurial.node import hex
Pulkit Goyal
py3: make contrib/dumprevlog use absolute_import
r29165 from mercurial import (
Matt Harbison
py3: byteify contrib/dumprevlog
r39983 encoding,
pycompat,
Pulkit Goyal
py3: make contrib/dumprevlog use absolute_import
r29165 revlog,
Yuya Nishihara
procutil: bulk-replace function calls to point to new module
r37138 )
Gregory Szorc
black: blacken scripts...
r44058 from mercurial.utils import procutil
Adrian Buehlmann
contrib: fix binary file issues with dumprevlog on Windows...
r6466
revlog: introduce an explicit tracking of what the revlog is about...
r47838 from mercurial.revlogutils import (
constants as revlog_constants,
)
Adrian Buehlmann
contrib: fix binary file issues with dumprevlog on Windows...
r6466 for fp in (sys.stdin, sys.stdout, sys.stderr):
Yuya Nishihara
procutil: bulk-replace function calls to point to new module
r37138 procutil.setbinary(fp)
Matt Mackall
add simple dump and undump scripts to contrib/
r6433
Gregory Szorc
black: blacken scripts...
r44058
Matt Harbison
py3: byteify contrib/dumprevlog
r39983 def binopen(path, mode=b'rb'):
if b'b' not in mode:
mode = mode + b'b'
return open(path, pycompat.sysstr(mode))
Gregory Szorc
black: blacken scripts...
r44058
vfs: give all vfs an options attribute by default...
r43295 binopen.options = {}
Matt Harbison
py3: byteify contrib/dumprevlog
r39983
Gregory Szorc
black: blacken scripts...
r44058
Matt Harbison
py3: byteify contrib/dumprevlog
r39983 def printb(data, end=b'\n'):
sys.stdout.flush()
Manuel Jacob
pycompat: change users of pycompat.{stdin,stdout,stderr} to use procutil.std*...
r45598 procutil.stdout.write(data + end)
Boris Feld
dumprevlog: handle being passed a mode parameter...
r35982
Gregory Szorc
black: blacken scripts...
r44058
Matt Mackall
add simple dump and undump scripts to contrib/
r6433 for f in sys.argv[1:]:
revlog: introduce an explicit tracking of what the revlog is about...
r47838 r = revlog.revlog(
binopen,
target=(revlog_constants.KIND_OTHER, b'dump-revlog'),
indexfile=encoding.strtolocal(f),
)
Pulkit Goyal
py3: make contrib/dumprevlog use print_function
r29166 print("file:", f)
Matt Mackall
add __len__ and __iter__ methods to repo and revlog
r6750 for i in r:
Matt Mackall
add simple dump and undump scripts to contrib/
r6433 n = r.node(i)
p = r.parents(n)
d = r.revision(n)
Joerg Sonnenberger
node: import symbols explicitly...
r46729 printb(b"node: %s" % hex(n))
Matt Harbison
py3: byteify contrib/dumprevlog
r39983 printb(b"linkrev: %d" % r.linkrev(i))
Joerg Sonnenberger
node: import symbols explicitly...
r46729 printb(b"parents: %s %s" % (hex(p[0]), hex(p[1])))
Matt Harbison
py3: byteify contrib/dumprevlog
r39983 printb(b"length: %d" % len(d))
printb(b"-start-")
printb(d)
printb(b"-end-")