##// END OF EJS Templates
rust: module policy with importrust...
rust: module policy with importrust We introduce two rust+c module policies and a new `policy.importrust()` that makes use of them. This simple approach provides runtime switching of implementations, which is crucial for the performance measurements such as those Octobus does with ASV. It can also be useful for bug analysis. It also has the advantage of making conditionals in Rust callers more uniform, in particular abstracting over specifics like `demandimport` At this point, the build stays unchanged, with the rust-cpython based `rustext` module being built if HGWITHRUSTEXT=cpython. More transparency for the callers, i.e., just using `policy.importmod` would be a much longer term and riskier effort for the following reasons: 1. It would require to define common module boundaries for the three or four cases (pure, c, rust+ext, cffi) and that is premature with the Rust extension currently under heavy development in areas that are outside the scope of the C extensions. 2. It would imply internal API changes that are not currently wished, as the case of ancestors demonstrates. 3. The lack of data or property-like attributes (tp_member and tp_getset) in current `rust-cpython` makes it impossible to achieve direct transparent replacement of pure Python classes by Rust extension code, meaning that the caller sometimes has to be able to make adjustments or provide additional wrapping.

File last commit:

r39983:a063b84c default
r42651:810f66b4 default
Show More
undumprevlog
50 lines | 1.2 KiB | text/plain | TextLexer
Matt Mackall
add simple dump and undump scripts to contrib/
r6433 #!/usr/bin/env python
# Undump a dump from dumprevlog
# $ hg init
# $ undumprevlog < repo.dump
Augie Fackler
undumprevlog: update to valid Python 3 syntax...
r33874 from __future__ import absolute_import, print_function
Pulkit Goyal
py3: make contrib/undumprevlog use absolute_import
r29167
Matt Mackall
add simple dump and undump scripts to contrib/
r6433 import sys
Pulkit Goyal
py3: make contrib/undumprevlog use absolute_import
r29167 from mercurial import (
Matt Harbison
py3: byteify contrib/dumprevlog
r39983 encoding,
Pulkit Goyal
py3: make contrib/undumprevlog use absolute_import
r29167 node,
Matt Harbison
py3: byteify contrib/dumprevlog
r39983 pycompat,
Pulkit Goyal
py3: make contrib/undumprevlog use absolute_import
r29167 revlog,
transaction,
Pierre-Yves David
vfs: use 'vfs' module directly in 'contrib/undumprevlog'...
r31248 vfs as vfsmod,
Pulkit Goyal
py3: make contrib/undumprevlog use absolute_import
r29167 )
Yuya Nishihara
procutil: bulk-replace function calls to point to new module
r37138 from mercurial.utils import (
procutil,
)
Matt Mackall
add simple dump and undump scripts to contrib/
r6433
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)
Adrian Buehlmann
contrib: fix binary file issues with dumprevlog on Windows...
r6466
Matt Harbison
py3: byteify contrib/dumprevlog
r39983 opener = vfsmod.vfs(b'.', False)
tr = transaction.transaction(sys.stderr.write, opener, {b'store': opener},
b"undump.journal")
Mads Kiilerich
tests: run check-code on Python files without .py extension
r19022 while True:
Matt Mackall
add simple dump and undump scripts to contrib/
r6433 l = sys.stdin.readline()
if not l:
break
if l.startswith("file:"):
Matt Harbison
py3: byteify contrib/dumprevlog
r39983 f = encoding.strtolocal(l[6:-1])
Matt Mackall
add simple dump and undump scripts to contrib/
r6433 r = revlog.revlog(opener, f)
Matt Harbison
py3: byteify contrib/dumprevlog
r39983 pycompat.stdout.write(b'%s\n' % f)
Matt Mackall
add simple dump and undump scripts to contrib/
r6433 elif l.startswith("node:"):
n = node.bin(l[6:-1])
elif l.startswith("linkrev:"):
lr = int(l[9:-1])
elif l.startswith("parents:"):
p = l[9:-1].split()
p1 = node.bin(p[0])
p2 = node.bin(p[1])
elif l.startswith("length:"):
length = int(l[8:-1])
sys.stdin.readline() # start marker
Matt Harbison
py3: byteify contrib/dumprevlog
r39983 d = encoding.strtolocal(sys.stdin.read(length))
Matt Mackall
add simple dump and undump scripts to contrib/
r6433 sys.stdin.readline() # end marker
r.addrevision(d, tr, lr, p1, p2)
tr.close()