Bug 5818 - Abort: path 'lib/app.py' traverses symbolic link 'lib' on ArchLinux, by in-memory rebase
Summary: Abort: path 'lib/app.py' traverses symbolic link 'lib' on ArchLinux, by in-me...
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: rebase (show other bugs)
Version: 4.5.2
Hardware: PC Linux
: normal bug
Assignee: Bugzilla
URL:
Keywords:
: 6027 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-03-14 20:54 UTC by Alain
Modified: 2018-12-12 00:00 UTC (History)
4 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alain 2018-03-14 20:54 UTC
On ArchLinux (and maybe others) `/lib` is a symbolic link.

This breaks mercurial when the repository contains a folder named `lib` in the repository root.

Here how you can reproduce the bug:

cd /tmp

# !!!!!!!!!! clean up things for the test !!!!!!!!!!!!!!!!
rm -r lib lib_ repo

# Create a symbolic link that will cause troubles
mkdir lib_
ln -s lib_ lib

# Create a repository with a similar structure than /tmp/lib → tmp/lib
# In my case, I just have a directory named `lib`.
hg init repo
cd repo
mkdir -p tmp/lib
touch tmp/lib/a
hg add tmp/lib/a
hg ci -m 'a'

# Prepare something to rebase
touch tmp/lib/b
hg add tmp/lib/b
hg ci -m 'b'
hg up .^
touch tmp/lib/c
hg add tmp/lib/c
hg ci -m 'c'

# The following fails with
# "abort: path 'tmp/lib/b' traverses symbolic link 'tmp/lib'"
# because of matchmod.match('/', '', [path + '/'], default=b'relpath')
# in mercurial/context.py(2143)

hg rebase -s 1 -d .
Comment 1 Yuya Nishihara 2018-03-15 10:50 UTC
Confirmed with rebase.experimental.inmemory=True.

Maybe we'll need to specify a pathauditor of realfs=False explicitly?

  $ cat <<'EOF' > "$HGRCPATH"
  > [extensions]
  > rebase =
  > [rebase]
  > experimental.inmemory = True
  > EOF

Create a symbolic link that will cause troubles

  $ mkdir lib_
  $ ln -s lib_ lib

Create a repository with a similar structure than /tmp/lib -> tmp/lib
In my case, I just have a directory named `lib`.

  $ hg init repo
  $ cd repo
  $ mkdir -p ".$TESTTMP/lib"
  $ touch ".$TESTTMP/lib/a"
  $ hg add ".$TESTTMP/lib/a"
  $ hg ci -m 'a'

Prepare something to rebase

  $ touch ".$TESTTMP/lib/b"
  $ hg add ".$TESTTMP/lib/b"
  $ hg ci -m 'b'

  $ hg up -q '.^'
  $ touch ".$TESTTMP/lib/c"
  $ hg add ".$TESTTMP/lib/c"
  $ hg ci -m 'c'
  created new head

XXX The following fails

  $ hg rebase -s 1 -d .
  rebasing 1:* "b" (glob)
  abort: path '*/b' traverses symbolic link '*/lib' (glob)
  [255]
Comment 2 Phil Cohen 2018-03-15 13:21 UTC
That entire function can actually be replaced by a config override of `experimental.merge.checkpathconflicts=Tru8e` around in-memory merge.
Comment 3 Bugzilla 2018-08-13 00:00 UTC
Bug was inactive for 150 days, archiving
Comment 4 Yuya Nishihara 2018-11-29 06:30 UTC
*** Bug 6027 has been marked as a duplicate of this bug. ***
Comment 5 HG Bot 2018-12-04 17:30 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/1c8c54cf9725
Martin von Zweigbergk <martinvonz@google.com>
rebase: fix path auditing to audit path relative to repo root (issue5818)

Before this patch, when rebasing a file called "foo/bar", we would
check e.g. if "/foo" (i.e. rooted at the file system root) was a
symlink.

Differential Revision: https://phab.mercurial-scm.org/D5361

(please test the fix)
Comment 6 Bugzilla 2018-12-12 00:00 UTC
Bug was set to TESTING for 7 days, resolving