adding files below symlink causes error

Bug #173944 reported by Will Lentz
2
Affects Status Importance Assigned to Milestone
Bazaar
In Progress
Medium
Martin Pool

Bug Description

I got the error below with bzr 0.92 on Linux. To reproduce the problem just do:
  mkdir dir1
  ln -s dir1 sym1
  echo "hi" > dir1/test.txt
  bzr init .
  bzr add */*.txt
   (this effectively does "bzr add dir1/test.txt sym1/test.txt")
  bzr ci

Then I got the error listed at the end of this bug report.

John Arbash Meinel commented about a potential fix:
>
> I suppose we could call "os.realpath()" on all user supplied
> paths? I'm not
> sure if that will dereference "symlink" (I believe it does.)
>

So, if I make the following change:
--- ../../bzr-0.92/bzrlib/mutabletree.py 2007-11-09 05:19:24.000000000 -0800
+++ mutabletree.py 2007-11-29 16:06:45.000000000 -0800
@@ -291,7 +291,7 @@
         # relative : it's cheaper to make a tree relative path an abspath
         # than to convert an abspath to tree relative.
         for filepath in file_list:
- rf = _FastPath(self.relpath(filepath))
+ rf = _FastPath(self.relpath(osutils.realpath(filepath)))
             # validate user parameters. Our recursive code avoids adding new files
             # that need such validation
             if self.is_control_filename(rf.raw_path):

then the test case above passes. I don't know if this is a good fix, so I'm filing a bug to keep track of this problem.

Here's the full error message for reference:
added dir1
added sym1
added dir1/test.txt
bzr: ERROR: exceptions.AttributeError: children

Traceback (most recent call last):
  File "/usr/local/lib/python2.4/site-packages/bzrlib/commands.py", line 802, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/local/lib/python2.4/site-packages/bzrlib/commands.py", line 758, in run_bzr
    ret = run(*run_argv)
  File "/usr/local/lib/python2.4/site-packages/bzrlib/commands.py", line 492, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/local/lib/python2.4/site-packages/bzrlib/builtins.py", line 2315, in run
    author=author)
  File "/usr/local/lib/python2.4/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/local/lib/python2.4/site-packages/bzrlib/workingtree_4.py", line 244, in commit
    result = WorkingTree3.commit(self, message, revprops, *args, **kwargs)
  File "/usr/local/lib/python2.4/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/local/lib/python2.4/site-packages/bzrlib/mutabletree.py", line 187, in commit
    revprops=revprops, *args, **kwargs)
  File "/usr/local/lib/python2.4/site-packages/bzrlib/commit.py", line 344, in commit
    self._update_builder_with_changes()
  File "/usr/local/lib/python2.4/site-packages/bzrlib/commit.py", line 652, in _update_builder_with_changes
    self._populate_from_inventory(specific_files)
  File "/usr/local/lib/python2.4/site-packages/bzrlib/commit.py", line 760, in _populate_from_inventory
    content_summary)
  File "/usr/local/lib/python2.4/site-packages/bzrlib/commit.py", line 802, in _record_entry
    self.parent_invs, path, self.work_tree, content_summary)
  File "/usr/local/lib/python2.4/site-packages/bzrlib/repository.py", line 256, in record_entry_contents
    self.new_inventory.add(ie)
  File "/usr/local/lib/python2.4/site-packages/bzrlib/inventory.py", line 1188, in add
    if entry.name in parent.children:
AttributeError: children

bzr 0.92.0 on python 2.4.2.final.0 (linux2)
arguments: ['/usr/local/bin/bzr', 'ci']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'en_US.UTF-8'
plugins:
  launchpad /usr/local/lib/python2.4/site-packages/bzrlib/plugins/launchpad [unknown]
  multiparent /usr/local/lib/python2.4/site-packages/bzrlib/plugins/multiparent.pyc [unknown]

John A Meinel (jameinel)
Changed in bzr:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
James Westby (james-w) wrote :

Hi,

Does anyone want to evaluate the suitability of the proposed
fix?

Will, would you like to turn it in to a patch with test case to move forward
on getting this fixed?

Thanks,

James

Revision history for this message
Will Lentz (will-lentz) wrote :

The above change breaks a couple other blackbox tests. I'll look around a little and see if there's a better fix...

Thanks,
Will

Revision history for this message
Will Lentz (will-lentz) wrote :

OK - I sent a patch to the mailing list.

Martin Pool (mbp)
Changed in bzr:
status: Triaged → Confirmed
Martin Pool (mbp)
Changed in bzr:
status: Confirmed → In Progress
assignee: nobody → Martin Pool (mbp)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.