repo.opener() no longer follows symlinks

Adrian Buehlmann adrian at cadifra.com
Fri Nov 26 17:53:35 CST 2010


On 2010-11-25 16:14, Greg Ward wrote:
> Hi all --
> 
> I have an extension that manages .hg/hgrc for my users.  Part of its
> contract is to *preserve* symlinks; we normally make .hg/hgrc in
> shared repos a symlink to the actual repo.  Up to *and including*
> Mercurial 1.7, this worked fine by using
> 
>   outfile = repo.opener('hgrc', 'w', text=True)
> 
> outfile ended up being the real file that the symlink .hg/hgrc points
> to, which is exactly what I wanted.
> 
> This broke in 1.7.1: repo.opener() now replaces the symlink with a
> real file.  I bisected and found:
> 
>   The first bad revision is:
>   changeset:   12922:6ff784de7c3a
>   branch:      stable
>   parent:      12913:ab93029ab622
>   user:        Adrian Buehlmann <adrian at cadifra.com>
>   date:        2010-11-04 09:04:37 +0100
>   summary:     util: refactor opener
> 
> I can obviously change my extension not to rely on this
> undocumented-and-no-longer-there feature.  But was this change
> intended?  Was it deliberate that repo.opener() would formerly follow
> symlinks, and no longer does?

The change was not intended but I'm not aware of anything in Mercurial
that depends on the old behavior.

The new behavior is, that the opener will replace symlinks with a normal
file if there is a 'w' in mode (w, wb, w+, w+b).

All other modes that modify the file (e.g. append) will follow the symlink.

I propose that we keep this new behavior for now, until we have a
compelling reason to change it back.


More information about the Mercurial-devel mailing list