sapling/tests/test-treestate-needcheck.t
Jun Wu 149eab7b65 treestate: add a test demostrating NEED_CHECK is removed for files outside sparse
Summary:
Add a test about NEED_CHECK cleanup for files outside sparse. It does not
demostrate anything wrong, unfortunately.

Reviewed By: DurhamG

Differential Revision: D12906651

fbshipit-source-id: 6e9e690ba431e141666ffdb431f62280e86bbf0b
2018-12-10 17:52:04 -08:00

74 lines
1.5 KiB
Perl

Emulate situations where NEED_CHECK was added to normal files and there should
be a way to remove them.
$ newrepo
$ drawdag << 'EOS'
> B
> |
> A
> EOS
$ hg up $B -q
Write mtime to treestate
$ sleep 1
$ hg status
$ hg debugtree list
A: 0100644 1 + EXIST_P1 EXIST_NEXT
B: 0100644 1 + EXIST_P1 EXIST_NEXT
Force the files to have NEED_CHECK bits
$ hg debugshell -c "
> with repo.lock(), repo.transaction('needcheck') as tr:
> d = repo.dirstate
> d.needcheck('A')
> d.needcheck('B')
> d.write(tr)
> "
$ hg debugtree list
A: 0100644 1 + EXIST_P1 EXIST_NEXT NEED_CHECK
B: 0100644 1 + EXIST_P1 EXIST_NEXT NEED_CHECK
Run status again. NEED_CHECK will disappear.
$ hg status
$ hg debugtree list
A: 0100644 1 + EXIST_P1 EXIST_NEXT
B: 0100644 1 + EXIST_P1 EXIST_NEXT
Enable sparse
$ enable sparse
$ hg sparse include A
When removing "B", fsmonitor+treestate will mark it as "NEED_CHECK" instead
$ hg debugtree list
A: 0100644 1 + EXIST_P1 EXIST_NEXT
B: 0100644 1 + NEED_CHECK (fsmonitor !)
Force NEED_CHECK on files outside sparse
$ printf B > B
$ hg debugshell --config extensions.sparse=! -c "
> with repo.lock(), repo.transaction('needcheck') as tr:
> d = repo.dirstate
> d.needcheck('A')
> d.normal('B')
> d.needcheck('B')
> d.write(tr)
> "
Run "hg status" and NEED_CHECK can be removed:
$ sleep 1
$ hg status
$ hg debugtree list
A: 0100644 1 + EXIST_P1 EXIST_NEXT
B: 0100644 1 + EXIST_P1 EXIST_NEXT