Rev 3589: * Deleting directories by hand before running ``bzr rm`` will not in http://people.ubuntu.com/~robertc/baz2.0/150438

Robert Collins robertc at robertcollins.net
Wed Jul 30 10:50:36 BST 2008


At http://people.ubuntu.com/~robertc/baz2.0/150438

------------------------------------------------------------
revno: 3589
revision-id: robertc at robertcollins.net-20080730095022-4tc7ij34c0tmejb5
parent: robertc at robertcollins.net-20080730085510-1qnn946mganbu2bd
committer: Robert Collins <robertc at robertcollins.net>
branch nick: 150438
timestamp: Wed 2008-07-30 19:50:22 +1000
message:
   * Deleting directories by hand before running ``bzr rm`` will not
     cause subsequent errors in ``bzr st`` and ``bzr commit``.
     (Robert Collins, #150438)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/osutils.py              osutils.py-20050309040759-eeaff12fbf77ac86
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
=== modified file 'NEWS'
--- a/NEWS	2008-07-29 00:30:54 +0000
+++ b/NEWS	2008-07-30 09:50:22 +0000
@@ -48,6 +48,9 @@
       smart server protocol to or from Windows.
       (Andrew Bennetts, #246180)
 
+    * Deleting directories by hand before running ``bzr rm`` will not
+      cause subsequent errors in ``bzr st`` and ``bzr commit``.
+      (Robert Collins, #150438)
 
   DOCUMENTATION:
 

=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py	2008-07-17 20:16:43 +0000
+++ b/bzrlib/osutils.py	2008-07-30 09:50:22 +0000
@@ -1168,11 +1168,20 @@
 
         dirblock = []
         append = dirblock.append
-        for name in sorted(_listdir(top)):
-            abspath = top_slash + name
-            statvalue = _lstat(abspath)
-            kind = _kind_from_mode(statvalue.st_mode & 0170000, 'unknown')
-            append((relprefix + name, name, kind, statvalue, abspath))
+        try:
+            names = sorted(_listdir(top))
+        except OSError, e:
+            if getattr(e, 'errno', None) == errno.ENOTDIR:
+                # We have been asked to examine a file, this is fine.
+                pass
+            else:
+                raise
+        else:
+            for name in names:
+                abspath = top_slash + name
+                statvalue = _lstat(abspath)
+                kind = _kind_from_mode(statvalue.st_mode & 0170000, 'unknown')
+                append((relprefix + name, name, kind, statvalue, abspath))
         yield (relroot, top), dirblock
 
         # push the user specified dirs from dirblock

=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py	2008-07-08 14:55:19 +0000
+++ b/bzrlib/workingtree.py	2008-07-30 09:50:22 +0000
@@ -1859,9 +1859,8 @@
             # Recurse directory and add all files
             # so we can check if they have changed.
             for parent_info, file_infos in\
-                osutils.walkdirs(self.abspath(directory),
-                    directory):
-                for relpath, basename, kind, lstat, abspath in file_infos:
+                self.walkdirs(directory):
+                for relpath, basename, kind, lstat, fileid, kind in file_infos:
                     # Is it versioned or ignored?
                     if self.path2id(relpath) or self.is_ignored(relpath):
                         # Add nested content for deletion.
@@ -1877,8 +1876,7 @@
             filename = self.relpath(abspath)
             if len(filename) > 0:
                 new_files.add(filename)
-                if osutils.isdir(abspath):
-                    recurse_directory_to_add_files(filename)
+                recurse_directory_to_add_files(filename)
 
         files = list(new_files)
 
@@ -2418,10 +2416,11 @@
                 relroot = ""
             # FIXME: stash the node in pending
             entry = inv[top_id]
-            for name, child in entry.sorted_children():
-                dirblock.append((relroot + name, name, child.kind, None,
-                    child.file_id, child.kind
-                    ))
+            if entry.kind == 'directory':
+                for name, child in entry.sorted_children():
+                    dirblock.append((relroot + name, name, child.kind, None,
+                        child.file_id, child.kind
+                        ))
             yield (currentdir[0], entry.file_id), dirblock
             # push the user specified dirs from dirblock
             for dir in reversed(dirblock):




More information about the bazaar-commits mailing list