-
Which damage could be caused when killing a Mercurial process? Might the working directory be left in an undefined state? Might the .hg/-admin area get corrupted in some way?
-
Are files written in some kind of “atomic” operation by Mercurial? (Working tree files, .hg/-internal files, configurations files, and so on …)
Which damage could be caused when killing a Mercurial process? Might the working directory
Share
It is safe. All writes are done such that the files on disk are always consistent. Either the transaction writes out entirely or it automatically rolls back when next found. Not just consistent when closed, but always consistent — whether it stops via SIGKILL or power failure.
You can sort of work out how that’s accomplished here: https://www.mercurial-scm.org/wiki/FileFormats . This is possible in part because all file writes are append only. Before anything is written file lengths are noted, and if things are found to be in an inconsistent state they automatically truncate the files back to the checkpointed, known good lengths.
Using something like dropbox (which syncs files in whatever order it likes) can throw this out the window, which is why it’s best to let hg be the only process writing to repositories.