bzr revert fails when reverting from a subdirectory where an item has the same name as the subdirectory

Bug #56549 reported by Andrew King
2
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Medium
John A Meinel

Bug Description

When trying to revert a file from a subdirectory, if there is another file in the subdirectory with the same name as the name of the subdirectory, the revert fails with the error message:

bzr: ERROR: [Errno 20] Not a directory: 'subdir/myFile'

Steps to reproduce:

In a new repo:

mkdir foo; touch foo/bar; bzr add foo; bzr ci; cd foo; touch foo; <change bar>; bzr revert bar

Reverting from the root level of the repository still works correctly.

Related branches

Revision history for this message
Robert Collins (lifeless) wrote :

Looks plausible, shouldnt affect to many users and there is a workaround -> medium priority.

Changed in bzr:
importance: Untriaged → Medium
Revision history for this message
John A Meinel (jameinel) wrote :

The bug is that Transform._set_mode() is stating the wrong file.

Specifically, it is not calling 'self._tree.abspath()' on the path, which means when you are sitting in a subdirectory, it stats paths below that, rather than stat-ing the real path. It just turns out that because you have a file that matches a parent path, it gets confused and raises a weird error.

Anyway, the fix is simple, I'll work out a test case and submit a patch for 0.11.

=== modified file 'bzrlib/transform.py'
--- bzrlib/transform.py 2006-09-10 23:42:17 +0000
+++ bzrlib/transform.py 2006-09-21 18:20:30 +0000
@@ -292,7 +292,7 @@
         except KeyError:
             return
         try:
- mode = os.stat(old_path).st_mode
+ mode = os.stat(self._tree.abspath(old_path)).st_mode
         except OSError, e:
             if e.errno == errno.ENOENT:
                 return

Changed in bzr:
assignee: nobody → jameinel
Revision history for this message
John A Meinel (jameinel) wrote :

The associated branch has the fix and a test case.

Changed in bzr:
status: Unconfirmed → Fix Committed
John A Meinel (jameinel)
Changed in bzr:
status: Fix Committed → Fix Released
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.