diff mercurial/dirstatemap.py @ 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 302dd8ae2745
children 0f0880c8a7e5 1891086f6c7f
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