| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
import sys |
| 4 |
|
| 5 |
from mercurial import ( |
| 6 |
commands, |
| 7 |
localrepo, |
| 8 |
ui as uimod, |
| 9 |
) |
| 10 |
|
| 11 |
print_ = print |
| 12 |
|
| 13 |
|
| 14 |
def print(*args, **kwargs): |
| 15 |
"""print() wrapper that flushes stdout buffers to avoid py3 buffer issues |
| 16 |
|
| 17 |
We could also just write directly to sys.stdout.buffer the way the |
| 18 |
ui object will, but this was easier for porting the test. |
| 19 |
""" |
| 20 |
print_(*args, **kwargs) |
| 21 |
sys.stdout.flush() |
| 22 |
|
| 23 |
|
| 24 |
u = uimod.ui.load() |
| 25 |
|
| 26 |
print('% creating repo') |
| 27 |
repo = localrepo.instance(u, b'.', create=True) |
| 28 |
|
| 29 |
f = open('test.py', 'w') |
| 30 |
try: |
| 31 |
f.write('foo\n') |
| 32 |
finally: |
| 33 |
f.close |
| 34 |
|
| 35 |
print('% add and commit') |
| 36 |
commands.add(u, repo, b'test.py') |
| 37 |
commands.commit(u, repo, message=b'*') |
| 38 |
commands.status(u, repo, clean=True) |
| 39 |
|
| 40 |
|
| 41 |
print('% change') |
| 42 |
f = open('test.py', 'w') |
| 43 |
try: |
| 44 |
f.write('bar\n') |
| 45 |
finally: |
| 46 |
f.close() |
| 47 |
|
| 48 |
# this would return clean instead of changed before the fix |
| 49 |
commands.status(u, repo, clean=True, modified=True) |