changeset 50097:ca9d65d69c27 stable

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).
author Arseniy Alekseyev <aalekseyev@janestreet.com>
date Fri, 18 Nov 2022 13:51:40 +0000
parents 010a1e73f69e
children 889d2a2e9326
files mercurial/dirstatemap.py
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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