sapling/eden
Michael Bolin b4f3c70c6a Distinguish between "renaming" and "replacing" a file in the journal.
Summary:
Historically, we have seen a number of messages like the following in the Eden
logs:

```
Journal for .hg/blackbox.log holds invalid Created, Created sequence
```

Apparently we were getting these invalid sequences because we were not always
recording a "rename" correctly. The "rename" constructor for a `JournalDelta`
assumed that the source path should be included in the list of "removed" files
while the destination path should be included in the list of "created" files.
However, that is not accurate if the destination path already existed before
the user ran `mv`.

Fortunately, we already check whether the destination file exists in
`TreeInode::doRename()`, so it is straightforward to determine whether the
action is a "rename" (destination does not exist) or an "replace" (destination
already exists) and then classify the destination path accordingly.

As demonstrated by the new test introduced in this commit
(`JournalUpdateTest::moveFileReplace`), in the old implementation,
a file that was removed after it was overwritten would not show up as
removed in the merged `JournalDelta`. Because Watchman relies on
`JournalDelta::merge()` via the Thrift method `getFilesChangedSince()`,
this would cause Watchman to report such a file as still existing even
though it was removed.

This definitely caused bugs in Nuclide. It is likely that other tools that rely
on Watchman in Eden (such as Buck) may have also done incorrect things
because of this bug, so this could explain past reported issues.

Reviewed By: simpkins

Differential Revision: D7888249

fbshipit-source-id: 3e57963f27c5421a6175d1a759db8d9597ed76f3
2018-05-07 14:23:13 -07:00
..
cli Catch subprocess.CalledProcessError instead of OSError in eden doctor. 2018-05-07 11:24:20 -07:00
docs storage documentation tweaks 2018-04-13 12:37:53 -07:00
fs Distinguish between "renaming" and "replacing" a file in the journal. 2018-05-07 14:23:13 -07:00
hooks Remove TARGETS files 2018-02-20 19:57:45 -08:00
integration Thrift API change: deprecate glob() in favor of globFiles(). 2018-05-02 15:19:44 -07:00
py refactor CLI subcommand definitions 2018-04-19 17:59:51 -07:00
scripts unmount stale edenfs mounts in eden doctor 2018-01-19 11:06:51 -08:00
third-party Remove TARGETS files 2018-02-20 19:57:45 -08:00
AUTODEPS Set up arc lint to run autodeps automatically for Eden. 2017-11-21 18:23:41 -08:00
DEFS rename the CLI rule from cli to eden 2018-04-18 21:00:39 -07:00
Eden.project.toml Eden.project.toml file for Nuclide 2018-04-26 11:05:23 -07:00