##// END OF EJS Templates
style: run a patched black on a subset of mercurial...
style: run a patched black on a subset of mercurial This applied black to the 20 smallest files in mercurial/: ls -S1 mercurial/*.py | tail -n20 | xargs black --skip-string-normalization Note that a few files failed to format, presumably due to a bug in my patch. The intent is to be able to compare results to D5064 with https://github.com/python/black/pull/826 applied to black. I skipped string normalization on this patch for clarity - in reality I think we'd want one pass without string normalization, followed by another to normalize strings (which is basically replacing ' with " globally.) # skip-blame mass-reformatting only Differential Revision: https://phab.mercurial-scm.org/D6342

File last commit:

r37952:f71c97d9 default
r43345:57875cf4 default
Show More
test-filelog.py
63 lines | 1.6 KiB | text/x-python | PythonLexer
#!/usr/bin/env python
"""
Tests the behavior of filelog w.r.t. data starting with '\1\n'
"""
from __future__ import absolute_import, print_function
from mercurial.node import (
hex,
nullid,
)
from mercurial import (
hg,
ui as uimod,
)
myui = uimod.ui.load()
repo = hg.repository(myui, path=b'.', create=True)
fl = repo.file(b'foobar')
def addrev(text, renamed=False):
if renamed:
# data doesn't matter. Just make sure filelog.renamed() returns True
meta = {b'copyrev': hex(nullid), b'copy': b'bar'}
else:
meta = {}
lock = t = None
try:
lock = repo.lock()
t = repo.transaction(b'commit')
node = fl.add(text, meta, t, 0, nullid, nullid)
return node
finally:
if t:
t.close()
if lock:
lock.release()
def error(text):
print('ERROR: ' + text)
textwith = b'\1\nfoo'
without = b'foo'
node = addrev(textwith)
if not textwith == fl.read(node):
error('filelog.read for data starting with \\1\\n')
if fl.cmp(node, textwith) or not fl.cmp(node, without):
error('filelog.cmp for data starting with \\1\\n')
if fl.size(0) != len(textwith):
error('FIXME: This is a known failure of filelog.size for data starting '
'with \\1\\n')
node = addrev(textwith, renamed=True)
if not textwith == fl.read(node):
error('filelog.read for a renaming + data starting with \\1\\n')
if fl.cmp(node, textwith) or not fl.cmp(node, without):
error('filelog.cmp for a renaming + data starting with \\1\\n')
if fl.size(1) != len(textwith):
error('filelog.size for a renaming + data starting with \\1\\n')
print('OK.')