##// 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
dumprevlog
59 lines | 1.3 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 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: use a "radix" to address revlog...
r47921 localf = encoding.strtolocal(f)
if not localf.endswith(b'.i'):
print("file:", f, file=sys.stderr)
Raphaël Gomès
contrib: fix typo...
r47948 print(" invalid filename", file=sys.stderr)
revlog: use a "radix" to address revlog...
r47921
revlog: introduce an explicit tracking of what the revlog is about...
r47838 r = revlog.revlog(
binopen,
target=(revlog_constants.KIND_OTHER, b'dump-revlog'),
revlog: use a "radix" to address revlog...
r47921 radix=localf[:-2],
revlog: introduce an explicit tracking of what the revlog is about...
r47838 )
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-")