tests/test-status-inprocess.py
author Siddharth Agarwal <sid0@fb.com>
Mon, 16 Nov 2015 11:27:27 -0800
changeset 26978 9b9d4bcc915e
parent 10905 13a1b2fb7ef2
child 28765 7779f9dfd938
permissions -rwxr-xr-x
filectx: add isabsent method This will indicate whether this filectx represents a file that is *not* in a changectx. This will be used by merge and filemerge code to know about when a conflict is a change/delete conflict. While this is kind of hacky, it is the least bad of all the alternatives. Other options considered but rejected include: - isinstance(fctx, ...) -- not very Pythonic, doesn't support duck typing - fctx.size() is None -- the 'size()' call on workingfilectxes causes a disk stat - fctx.filenode() == nullid -- the semantics around filenode are incredibly confusing. In particular, for workingfilectxes, filenode() is always None no matter whether the file is present on disk or in either parent. Having different behavior for None versus nullid in the merge code is just asking for pain. Thanks to Pierre-Yves David for early review feedback here.

#!/usr/bin/python
from mercurial.ui import ui
from mercurial.localrepo import localrepository
from mercurial.commands import add, commit, status

u = ui()

print '% creating repo'
repo = localrepository(u, '.', create=True)

f = open('test.py', 'w')
try:
    f.write('foo\n')
finally:
    f.close

print '% add and commit'
add(u, repo, 'test.py')
commit(u, repo, message='*')
status(u, repo, clean=True)


print '% change'
f = open('test.py', 'w')
try:
    f.write('bar\n')
finally:
    f.close()

# this would return clean instead of changed before the fix
status(u, repo, clean=True, modified=True)