fsmonitor: write state with wlock held and dirstate unchanged (
issue5581)
This means that the state will not be written if:
(1) either the wlock can't be obtained
(2) something else came along and changed the dirstate while we were in the
middle of a status run.
workingctx: add a way for extensions to run code at status fixup time
Some extensions like fsmonitor need to run code after dirstate.status is
called, but while the wlock is held. The extensions could grab the wlock again,
but that has its own peculiar race issues. For example, fsmonitor would not
like its state to be written out if the dirstate has changed underneath (see
issue5581 for what can go wrong in that sort of case).
To protect against these sorts of issues, allow extensions to declare that they
would like to run some code to run at fixup time.
fsmonitor will switch to using this in the next patch in the series.
workingctx: also pass status tuple into poststatusfixup
fsmonitor is going to need this to compute its set of notable files to persist.
workingctx: factor out post-status dirstate fixup
We want to allow extensions to be able to add code to run inside the wlock.
profile: properly propagate exception from the sub-context manager
Context manager has a mechanism to control extension propagation. It is not
used by profiling right now, but making the code correct will help prevent bug
in the future.
profile: close 'fp' in all cases
There are no way for this to happen today, but better be safe than sorry, no
one know how the code will evolve. We now make sure the file pointer is closed
even is profiler is None.
profile: close 'fp' on error within '__enter__'
Previously, error when initialying the profiler would forgot to explicitly
close the file. Thank goes to Yuya Nishihara for spotting this.
profile: indent part of '__enter__'
We are about to introduce a try except. We start with adding the indent to make
the next patch clearer.
profile: remove now useless indent
We no longer rely on the value of '_output' so we can remove this conditional.
profile: use explicit logic to control file closing
We make the decision to close 'fp' more explicit instead of relying on the
implication of other variable. This makes the overall logic more robust.
profiling: move 'fp' closing logic into its own function
We are about to make the logic more robust and reuse it in more place, we start
by isolating what we have.
py3: use python3 hg in test-py3-commands.t at places where py2 hg was used
This patch fixes my mistakes where I added test in test-py3-commands.t as
`hg ...` where I forgot hg here refers to Python 2 mercurial.
test-dirstate-race: back out changeset
c82fa7efcbc8
This is non-deterministic. In any case, I switched to using
debugrebuilddirstate in my WIP patches, which makes this moot.