##// END OF EJS Templates
templatekw: deprecate p1rev/p2rev/p1node/p2node in favor of p1/p2
templatekw: deprecate p1rev/p2rev/p1node/p2node in favor of p1/p2

File last commit:

r37952:f71c97d9 default
r40511:592feb3f default
Show More
test-filelog.py
63 lines | 1.6 KiB | text/x-python | PythonLexer
Mads Kiilerich
tests: test test-filelog is python - rename to test-filelog.py
r16498 #!/usr/bin/env python
"""
timeless@mozdev.org
spelling: behaviour -> behavior
r26098 Tests the behavior of filelog w.r.t. data starting with '\1\n'
Mads Kiilerich
tests: test test-filelog is python - rename to test-filelog.py
r16498 """
Robert Stanca
py3: use print_function in test-filelog.py
r28744 from __future__ import absolute_import, print_function
Yuya Nishihara
py3: move up symbol imports to enforce import-checker rules...
r29205
from mercurial.node import (
hex,
nullid,
)
Robert Stanca
py3: use absolute_import in test-filelog.py
r28743 from mercurial import (
hg,
Yuya Nishihara
test-filelog: alias ui as uimod
r28805 ui as uimod,
Robert Stanca
py3: use absolute_import in test-filelog.py
r28743 )
Mads Kiilerich
tests: test test-filelog is python - rename to test-filelog.py
r16498
Yuya Nishihara
ui: factor out ui.load() to create a ui without loading configs (API)...
r30559 myui = uimod.ui.load()
Augie Fackler
tests: port test-filelog.py to Python 3...
r37952 repo = hg.repository(myui, path=b'.', create=True)
Mads Kiilerich
tests: test test-filelog is python - rename to test-filelog.py
r16498
Augie Fackler
tests: port test-filelog.py to Python 3...
r37952 fl = repo.file(b'foobar')
Mads Kiilerich
tests: test test-filelog is python - rename to test-filelog.py
r16498
def addrev(text, renamed=False):
if renamed:
timeless@mozdev.org
spelling: doesn't/does not
r17486 # data doesn't matter. Just make sure filelog.renamed() returns True
Augie Fackler
tests: port test-filelog.py to Python 3...
r37952 meta = {b'copyrev': hex(nullid), b'copy': b'bar'}
Mads Kiilerich
tests: test test-filelog is python - rename to test-filelog.py
r16498 else:
meta = {}
lock = t = None
try:
lock = repo.lock()
Augie Fackler
tests: port test-filelog.py to Python 3...
r37952 t = repo.transaction(b'commit')
Mads Kiilerich
tests: test test-filelog is python - rename to test-filelog.py
r16498 node = fl.add(text, meta, t, 0, nullid, nullid)
return node
finally:
if t:
t.close()
if lock:
lock.release()
def error(text):
Robert Stanca
py3: use print_function in test-filelog.py
r28744 print('ERROR: ' + text)
Mads Kiilerich
tests: test test-filelog is python - rename to test-filelog.py
r16498
Augie Fackler
tests: port test-filelog.py to Python 3...
r37952 textwith = b'\1\nfoo'
without = b'foo'
Mads Kiilerich
tests: test test-filelog is python - rename to test-filelog.py
r16498
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')
Robert Stanca
py3: use print_function in test-filelog.py
r28744 print('OK.')