sapling/tests/test-fsmonitor-filemerge.t
Jun Wu 68e346c962 fsmonitor: send state about filemerge
Summary:
The merge process could be interactive, and tools like Hack wants to
scan changed files when the user is resolving conflicts. There is a
"hg.update" watchman state and "state-enter", "state-exit" events that help
detect the "update" process. However, the interactive "ui.merge" process is
inside the "update" process and cannot be easily decoupled confidently (i.e.
hard to end "update" state before doing the merge).

It's also hard to have a general "merge" state due to the current watchman
design. Because a merge might be across multiple hg processes (ex.
non-interactive ui.merge, hg exits, returns to the shell, and the user invokes
`hg resolve --mark` to end the merge state), and the current watchman
implementation will force end all states associated with a watchman socket
connection. If a hg process exits, it will disconnect from the watchman socket
and the merge state will be forced terminated, although there is still
unresolved conflicts.  Previous attempt on this is D7286181.

This patch adds a "hg.filemerge" watchman state that could make watchman
users aware of ongoing interactive merge resolutions. The event fires when an
external merge tool is called, per conflicted file. It is strictly a sub
interval of an "update" state, which is within a single process. So it does not
have the problem that a "merge" state has.

Differential Revision: D7648929

fbshipit-source-id: 858beba1bff261e8da5bd4d8b08a388dcbc8a9ef
2018-04-19 13:17:08 -07:00

36 lines
1.8 KiB
Raku

#require fsmonitor
(Run this test using HGFSMONITOR_TESTS=1)
$ newrepo
$ hg debugdrawdag << EOS
> C # C/A=0\n1\n
> | # B/A=1\n2\n
> | B # C/2=1\n
> |/ # B/2=2\n
> A # A/A=1\n
> EOS
$ enable blackbox fsmonitor rebase
$ setconfig blackbox.track=merge-resolve,watchman-command
$ hg rebase -s B -d C --tool=false
rebasing 1:65f3e88a53bc "B" (B)
merging 2
merging A
merging 2 failed!
unresolved conflicts (see hg resolve, then hg rebase --continue)
[1]
$ hg blackbox -l 100 | egrep '(watchman.*state.*completed|resolving)' | python $RUNTESTDIR/sortdictfilter.py
*> watchman command ('state-enter', '$TESTTMP/repo1', {'metadata': {'distance': 3, 'merge': False, 'partial': False, 'rev': '0000000000000000000000000000000000000000', 'status': 'ok'}, 'name': 'hg.update'}) completed (glob)
*> watchman command ('state-leave', '$TESTTMP/repo1', {'metadata': {'distance': 3, 'merge': False, 'partial': False, 'rev': '2e2f27616b65209eecd4710c454df0f678f271d9', 'status': 'ok'}, 'name': 'hg.update'}) completed (glob)
*> watchman command ('state-enter', '$TESTTMP/repo1', {'metadata': {'distance': 3, 'merge': True, 'partial': False, 'rev': '2e2f27616b65209eecd4710c454df0f678f271d9', 'status': 'ok'}, 'name': 'hg.update'}) completed (glob)
*> resolving 2, preresolve = True (glob)
*> resolving A, preresolve = True (glob)
*> resolving 2, preresolve = False (glob)
*> watchman command ('state-enter', '$TESTTMP/repo1', {'metadata': {'path': '2'}, 'name': 'hg.filemerge'}) completed (glob)
*> watchman command ('state-leave', '$TESTTMP/repo1', {'metadata': {'path': '2'}, 'name': 'hg.filemerge'}) completed (glob)
*> watchman command ('state-leave', '$TESTTMP/repo1', {'metadata': {'distance': 3, 'merge': True, 'partial': False, 'rev': '65f3e88a53bc0f5183deea0cdbc46738777ec005', 'status': 'ok'}, 'name': 'hg.update'}) completed (glob)