[PATCH 0 of 1] avoid deleting symbolically linked directories on windows

Henrik Stuart henrik.stuart at edlund.dk
Mon May 11 14:01:41 UTC 2009


On Windows, it is possible to make symbolic linked directories or 
junction points (hardlinks) - together reparse points - to an entire 
hg repository including a working directory, e.g.:

  foo/
      .hg
      [files]

  bar/ [symlinkd:foo]

If you do a hg up null or hg up {revision with removed files} then
util.unlink will try to run os.removedirs(path), which will 
recursively remove directories until it fails. We expect that bar/
should not be deleted, but os.rmdir on a symlink or junction point
succeeds without further issues. A following branch state write will
then recreate the directory, as a directory rather than as a reparse
point, and users will be very confused.

This is solved by making a Windows-specific version of util.unlink
that uses a custom removedirs version that explicitly uses 
osutil.listdir to check that the directory is empty before it is
removed.

-- 
Kind regards,
  Henrik Stuart


More information about the Mercurial-devel mailing list