##// END OF EJS Templates
contrib: add a partial-merge tool for sorted lists (such as Python imports)...
contrib: add a partial-merge tool for sorted lists (such as Python imports) This is a pretty naive tool that uses a regular expression for matching lines. It is based on a Google-internal tool that worked in a similar way. For now, the regular expression is hard-coded to attempt to match single-line Python imports. The only commit I've found in the hg core repo where the tool helped was commit 9cd6292abfdf. I think that's because we often use multiple imports per import statement. I think this tool is still a decent first step (especially once the regex is made configurable in the next patch). The merging should ideally use a proper Python parser and do the merge at the AST (or CST?) level, but that's significantly harder, especially if you want to preserve comments and whitespace. It's also less generic. Differential Revision: https://phab.mercurial-scm.org/D12380

File last commit:

r49730:6000f5b2 default
r49874:681b25ea default
Show More
undumprevlog
56 lines | 1.4 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 # Undump a dump from dumprevlog
# $ hg init
# $ undumprevlog < repo.dump
Pulkit Goyal
py3: make contrib/undumprevlog use absolute_import
r29167
Matt Mackall
add simple dump and undump scripts to contrib/
r6433 import sys
Joerg Sonnenberger
node: import symbols explicitly...
r46729 from mercurial.node import bin
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 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 )
Gregory Szorc
black: blacken scripts...
r44058 from mercurial.utils import procutil
Matt Mackall
add simple dump and undump scripts to contrib/
r6433
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)
Adrian Buehlmann
contrib: fix binary file issues with dumprevlog on Windows...
r6466
Matt Harbison
py3: byteify contrib/dumprevlog
r39983 opener = vfsmod.vfs(b'.', False)
Gregory Szorc
black: blacken scripts...
r44058 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])
revlog: use a "radix" to address revlog...
r47921 assert f.endswith(b'.i')
revlog: introduce an explicit tracking of what the revlog is about...
r47838 r = revlog.revlog(
opener,
target=(revlog_constants.KIND_OTHER, b'undump-revlog'),
revlog: use a "radix" to address revlog...
r47921 radix=f[:-2],
revlog: introduce an explicit tracking of what the revlog is about...
r47838 )
Manuel Jacob
pycompat: change users of pycompat.{stdin,stdout,stderr} to use procutil.std*...
r45598 procutil.stdout.write(b'%s\n' % f)
Matt Mackall
add simple dump and undump scripts to contrib/
r6433 elif l.startswith("node:"):
Joerg Sonnenberger
node: import symbols explicitly...
r46729 n = bin(l[6:-1])
Matt Mackall
add simple dump and undump scripts to contrib/
r6433 elif l.startswith("linkrev:"):
lr = int(l[9:-1])
elif l.startswith("parents:"):
p = l[9:-1].split()
Joerg Sonnenberger
node: import symbols explicitly...
r46729 p1 = bin(p[0])
p2 = bin(p[1])
Matt Mackall
add simple dump and undump scripts to contrib/
r6433 elif l.startswith("length:"):
length = int(l[8:-1])
Gregory Szorc
black: blacken scripts...
r44058 sys.stdin.readline() # start marker
Matt Harbison
py3: byteify contrib/dumprevlog
r39983 d = encoding.strtolocal(sys.stdin.read(length))
Gregory Szorc
black: blacken scripts...
r44058 sys.stdin.readline() # end marker
Matt Mackall
add simple dump and undump scripts to contrib/
r6433 r.addrevision(d, tr, lr, p1, p2)
tr.close()