# HG changeset patch # User Arseniy Alekseyev # Date 2022-11-18 13:51:40 # Node ID ca9d65d69c274551d46770af2d8aa7012e24d356 # Parent 010a1e73f69e094f89e548dbc181ed6b48a13c84 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). diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py --- a/mercurial/dirstatemap.py +++ b/mercurial/dirstatemap.py @@ -114,6 +114,8 @@ class _dirstatemapcommon: 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