Traversing symlinks

Martin Geisler mg at aragost.com
Fri May 20 04:38:11 CDT 2011


Adrian Buehlmann <adrian at cadifra.com> writes:

> On 2011-05-16 19:57, Martin Geisler wrote:
>> Hi guys,
>> 
>> Way back in 2007, this changeset was added:
>> 
>>   http://selenic.com/hg/rev/d316124ebbea
>> 
>> It makes Mercurial abort when it encounters a symlink on the way to a
>> file -- even when the symlink points inside the repository:
>> 
>>   $ ln -s contrib extra
>>   $ hg status extra/mq.el
>>   abort: path 'extra/mq.el' traverses symbolic link 'extra'
>> 
>> This seems a tad too restrictive to me, and Bryan did also flag this
>> in the test and commit message.
>> 
>> Would anybody object to me lifting this restriction?
>
> Is this for the case where the symlinkdir ('extra' in your example) is
> under the same repo root as where it points to?

Yes, I was talking about a symlink in the working directory that points
to another place in the working directory.

But it could be implemented differently: we could let the path auditor
keep doing what it does today, and then merely start by resolving all
command line arguments. So

  $ hg status extra/mq.py

would be translated into

  $ hg status hgext/mq.py

as the first thing -- and from that point on Mercurial operates on
symlink-free paths only, like today. As if you had executed

  $ hg status $(readlink --canonicalize extra/mq.py)

> Does that mean mercurial would have to track (i.e. recording in
> history) the fact that 'extra' is a directory symlink to contrib?
>
> If not, who creates 'extra' and for what purpose?

Maybe someone wants to make a deep path shorter by making a symlink. The
symlink may or may not be tracked, the point was just that Mercurial
behaves in an atypical way here compared to other Unix tools.

-- 
Martin Geisler

aragost Trifork
Professional Mercurial support
http://mercurial.aragost.com/kick-start/


More information about the Mercurial-devel mailing list