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

Stepan Koltsov yozh at mx1.ru
Tue Aug 11 04:55:19 CDT 2009


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
>



More information about the Mercurial-devel mailing list