Renaming an MQ patch with only a case difference can delete the patch
Created originally on Bitbucket by Anonymous
On Windows, renaming a patch in TortoiseHg can delete the patch.
To reproduce:
- Create a patch in TortoiseHg.
- Right-click the patch, select Modify History, Rename Patch..
- Rename the patch with a name that only varies in case.
- A warning dialog is displayed saying the patch already exists (unfortunately my coworker didn't read it too closely).
- Select overwrite existing patchfile.
- Thg displays "abort: the system cannot find the file specified". The patch is deleted. Work is lost.
From watching the filesystem with SysInternals Procmon, it looks like THG is deleting the "patch that already exists" not realizing that it is the original patch since Windows is case-insensitive. It then spawns hg.exe to rename the patch but it is gone.
On Windows, at least, checking that the old and new names don't match with a case-insensitive compare would prevent lost work.