dirstate-v2: complain early on docket name collision stable
authorArseniy Alekseyev <aalekseyev@janestreet.com>
Fri, 18 Nov 2022 13:51:40 +0000
branchstable
changeset 50097 ca9d65d69c27
parent 50092 010a1e73f69e
child 50098 889d2a2e9326
dirstate-v2: complain early on docket name collision The alternative is that the dirstate gets deleted so the corruption persists and is hard to investigate. This happened to me in tests, where the dirstate names are taken from file, since the file got reverted. I expect this can also happen in prod with non-trivial probability (1/4 billion).
mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py	Fri Feb 17 16:45:36 2023 +0100
+++ b/mercurial/dirstatemap.py	Fri Nov 18 13:51:40 2022 +0000
@@ -114,6 +114,8 @@
         new_docket = docketmod.DirstateDocket.with_new_uuid(
             self.parents(), len(packed), meta
         )
+        if old_docket.uuid == new_docket.uuid:
+            raise error.ProgrammingError(b'dirstate docket name collision')
         data_filename = new_docket.data_filename()
         self._opener.write(data_filename, packed)
         # Write the new docket after the new data file has been