[PATCH] fix error: abort: path 'symlink/something' traverses symbolic link 'symlink'

Stepan Koltsov yozh at mx1.ru
Tue Aug 11 11:35:56 CDT 2009


hg add s/util/string.scala

actually adds src/main/scala/ru/yandex/mysqlDiff/util/string.scala

Use case is to avoid typing long path every time, that's why symlink
"s" created.

S.

On Tue, Aug 11, 2009 at 17:09, Simon Heimberg<simohe at besonet.ch> wrote:
> My understanding is that this should fail.
> You can add "src/main/scala/ru/yandex/mysqlDiff/util/string.scala" and
> the symlink "s".
> When you are able to add s/util/string.scala, then a clone will not look
> like the original. The clone will have the directory "s", but the
> original has a symlink. And what shall happen when you add the symlink s
> and s/util/string.scala to the repo? You cold even let s point to
> somewhere outside the repository, like /etc.
>
> Greetings,
> Simon
>
> Am Dienstag, den 11.08.2009, 13:55 +0400 schrieb Stepan Koltsov:
>> Hi, all.
>>
>> Please, review my patch I sent on Sunday. It is very simple, but
>> useful: it allows hg operations when path is specified with symlinks
>> inside. It is illustrated by test case included:
>>
>> ===
>> hg init repo
>> cd repo
>> mkdir -p src/main/scala/ru/yandex/mysqlDiff/util
>> echo "package ru.yandex.mysqlDiff.util"
>> >src/main/scala/ru/yandex/mysqlDiff/util/string.scala
>> ln -s src/main/scala/ru/yandex/mysqlDiff s
>> hg add s/util/string.scala
>> hg diff --nodates s/util
>> ===
>>
>> This works fine after patch applied and fails otherwise with message:
>> abort: path 's/util/string.scala' traverses symbolic link 's'
>>
>> S.
>>
>>
>> On Sun, Aug 9, 2009 at 17:58, <yozh at mx1.ru> wrote:
>> > # HG changeset patch
>> > # User Stepan Koltsov <stepancheg at yandex-team.ru>
>> > # Date 1249826258 -14400
>> > # Node ID 0babe001f432d5730952f6ba17f763a1511be2bf
>> > # Parent  e3d3dad805f9f7c5f17c7a80cd659ecf25238ca1
>> > fix error: abort: path 'symlink/something' traverses symbolic link 'symlink'
>> > test included
>> >
>> > diff -r e3d3dad805f9 -r 0babe001f432 mercurial/util.py
>> > --- a/mercurial/util.py Fri May 01 11:32:19 2009 +0200
>> > +++ b/mercurial/util.py Sun Aug 09 17:57:38 2009 +0400
>> > @@ -345,7 +345,7 @@
>> >     name = myname
>> >     if not os.path.isabs(name):
>> >         name = os.path.join(root, cwd, name)
>> > -    name = os.path.normpath(name)
>> > +    name = os.path.realpath(name)
>> >     audit_path = path_auditor(root)
>> >     if name != rootsep and name.startswith(rootsep):
>> >         name = name[len(rootsep):]
>> > diff -r e3d3dad805f9 -r 0babe001f432 tests/test-traverses-symlink
>> > --- /dev/null   Thu Jan 01 00:00:00 1970 +0000
>> > +++ b/tests/test-traverses-symlink      Sun Aug 09 17:57:38 2009 +0400
>> > @@ -0,0 +1,11 @@
>> > +#!/bin/sh -e
>> > +
>> > +hg init repo
>> > +cd repo
>> > +mkdir -p src/main/scala/ru/yandex/mysqlDiff/util
>> > +echo "package ru.yandex.mysqlDiff.util" > src/main/scala/ru/yandex/mysqlDiff/util/string.scala
>> > +ln -s src/main/scala/ru/yandex/mysqlDiff s
>> > +hg add s/util/string.scala
>> > +hg diff --nodates s/util
>> > +
>> > +# vim: set ts=4 sw=4 et:
>> > diff -r e3d3dad805f9 -r 0babe001f432 tests/test-traverses-symlink.out
>> > --- /dev/null   Thu Jan 01 00:00:00 1970 +0000
>> > +++ b/tests/test-traverses-symlink.out  Sun Aug 09 17:57:38 2009 +0400
>> > @@ -0,0 +1,5 @@
>> > +diff -r 000000000000 src/main/scala/ru/yandex/mysqlDiff/util/string.scala
>> > +--- /dev/null
>> > ++++ b/src/main/scala/ru/yandex/mysqlDiff/util/string.scala
>> > +@@ -0,0 +1,1 @@
>> > ++package ru.yandex.mysqlDiff.util
>> >
>>
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel
>



More information about the Mercurial-devel mailing list