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).
--- 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