##// END OF EJS Templates
global: use python3 in shebangs...
global: use python3 in shebangs Python 3 is the future. We want Python scripts to be using Python 3 by default. This change updates all `#!/usr/bin/env python` shebangs to use `python3`. Does this mean all scripts use or require Python 3: no. In the test environment, the `PATH` environment variable in tests is updated to guarantee that the Python executable used to run run-tests.py is used. Since test scripts all now use `#!/usr/bin/env python3`, we had to update this code to install a `python3` symlink instead of `python`. It is possible there are some random scripts now executed with the incorrect Python interpreter in some contexts. However, I would argue that this was a pre-existing bug: we should almost always be executing new Python processes using the `sys.executable` from the originating Python script, as `python` or `python3` won't guarantee we'll use the same interpreter. Differential Revision: https://phab.mercurial-scm.org/D9273

File last commit:

r46434:c102b704 default
r46434:c102b704 default
Show More
test-filelog.py
68 lines | 1.6 KiB | text/x-python | PythonLexer
Gregory Szorc
global: use python3 in shebangs...
r46434 #!/usr/bin/env python3
Mads Kiilerich
tests: test test-filelog is python - rename to test-filelog.py
r16498 """
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
Augie Fackler
formatting: blacken the codebase...
r43346
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()
Augie Fackler
formatting: blacken the codebase...
r43346
Mads Kiilerich
tests: test test-filelog is python - rename to test-filelog.py
r16498 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
formatting: blacken the codebase...
r43346
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):
Augie Fackler
formatting: blacken the codebase...
r43346 error(
'FIXME: This is a known failure of filelog.size for data starting '
'with \\1\\n'
)
Mads Kiilerich
tests: test test-filelog is python - rename to test-filelog.py
r16498
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.')