[PATCH 2 of 2] Prevent merged symlink targets from being modified
Alexis S. L. Carvalho
alexis at cecm.usp.br
Tue Oct 2 05:42:39 UTC 2007
Thus spake Steve Borho:
> # HG changeset patch
> # User Steve Borho <steve at borho.org>
> # Date 1191202867 18000
> # Node ID 426850ac5be89366496999b827be50775739f550
> # Parent f8b4e3545651be6e19adea9480e633d65813fd69
> Prevent merged symlink targets from being modified
>
> The merge logic tries to update the executable status of each file after it
> has been merged. util.set_exec() is not symlink aware, so it was modifying
> the link target.
It's better to just change util.set_exec to ignore symlinks - I don't
think we ever want to call chmod on a symlink, and set_exec already
calls lstat, so we have all the data we need there.
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -965,6 +965,9 @@ if os.name == 'nt':
> def set_link(f, mode):
> pass
>
> + def is_link(path):
> + return False
> +
> def set_binary(fd):
> msvcrt.setmode(fd.fileno(), os.O_BINARY)
>
> @@ -1123,6 +1126,9 @@ else:
> data = os.readlink(f)
> os.unlink(f)
> file(f, "w").write(data)
> +
> + def is_link(path):
> + return os.path.islink(path)
>
> def set_binary(fd):
> pass
(FWIW, os.path.islink is also available on windows)
Alexis
More information about the Mercurial-devel
mailing list