test-status-inprocess.py
50 lines
| 992 B
| text/x-python
|
PythonLexer
/ tests / test-status-inprocess.py
r48294 | #!/usr/bin/env python | |||
|
r28766 | from __future__ import absolute_import, print_function | ||
|
r28843 | |||
|
r37918 | import sys | ||
|
r28843 | from mercurial import ( | ||
commands, | ||||
localrepo, | ||||
ui as uimod, | ||||
|
r28765 | ) | ||
|
r10838 | |||
|
r37918 | print_ = print | ||
|
r43346 | |||
|
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() | ||||
|
r43346 | |||
|
r30559 | u = uimod.ui.load() | ||
|
r10838 | |||
|
r28766 | print('% creating repo') | ||
|
r39584 | repo = localrepo.instance(u, b'.', create=True) | ||
|
r10838 | |||
f = open('test.py', 'w') | ||||
try: | ||||
f.write('foo\n') | ||||
finally: | ||||
f.close | ||||
|
r28766 | print('% add and commit') | ||
|
r37678 | commands.add(u, repo, b'test.py') | ||
commands.commit(u, repo, message=b'*') | ||||
|
r28843 | commands.status(u, repo, clean=True) | ||
|
r10838 | |||
|
r28766 | print('% change') | ||
|
r10838 | f = open('test.py', 'w') | ||
try: | ||||
f.write('bar\n') | ||||
finally: | ||||
f.close() | ||||
# this would return clean instead of changed before the fix | ||||
|
r28843 | commands.status(u, repo, clean=True, modified=True) | ||