test-status-inprocess.py
50 lines
| 992 B
| text/x-python
|
PythonLexer
/ tests / test-status-inprocess.py
timeless
|
r28824 | #!/usr/bin/env python | ||
Robert Stanca
|
r28766 | from __future__ import absolute_import, print_function | ||
Yuya Nishihara
|
r28843 | |||
Augie Fackler
|
r37918 | import sys | ||
Yuya Nishihara
|
r28843 | from mercurial import ( | ||
commands, | ||||
localrepo, | ||||
ui as uimod, | ||||
Robert Stanca
|
r28765 | ) | ||
Ronny Pfannschmidt
|
r10838 | |||
Augie Fackler
|
r37918 | print_ = print | ||
Augie Fackler
|
r43346 | |||
Augie Fackler
|
r37918 | def print(*args, **kwargs): | ||
"""print() wrapper that flushes stdout buffers to avoid py3 buffer issues | ||||
We could also just write directly to sys.stdout.buffer the way the | ||||
ui object will, but this was easier for porting the test. | ||||
""" | ||||
print_(*args, **kwargs) | ||||
sys.stdout.flush() | ||||
Augie Fackler
|
r43346 | |||
Yuya Nishihara
|
r30559 | u = uimod.ui.load() | ||
Ronny Pfannschmidt
|
r10838 | |||
Robert Stanca
|
r28766 | print('% creating repo') | ||
Gregory Szorc
|
r39584 | repo = localrepo.instance(u, b'.', create=True) | ||
Ronny Pfannschmidt
|
r10838 | |||
f = open('test.py', 'w') | ||||
try: | ||||
f.write('foo\n') | ||||
finally: | ||||
f.close | ||||
Robert Stanca
|
r28766 | print('% add and commit') | ||
Pulkit Goyal
|
r37678 | commands.add(u, repo, b'test.py') | ||
commands.commit(u, repo, message=b'*') | ||||
Yuya Nishihara
|
r28843 | commands.status(u, repo, clean=True) | ||
Ronny Pfannschmidt
|
r10838 | |||
Robert Stanca
|
r28766 | print('% change') | ||
Ronny Pfannschmidt
|
r10838 | f = open('test.py', 'w') | ||
try: | ||||
f.write('bar\n') | ||||
finally: | ||||
f.close() | ||||
# this would return clean instead of changed before the fix | ||||
Yuya Nishihara
|
r28843 | commands.status(u, repo, clean=True, modified=True) | ||