Code review comment for lp:~mbp/bzr/340352-rename-lock

Revision history for this message
Martin Pool (mbp) wrote :

bzr internally expects DirectoryNotEmpty and relies on transports to translate it to that form.

=== modified file 'NEWS'
--- NEWS 2009-03-10 06:46:19 +0000
+++ NEWS 2009-03-10 07:28:23 +0000
@@ -114,6 +114,9 @@
     * Export now handles files that are not present in the tree.
       (James Westby, #174539)

+ * Fix problem of "directory not empty" when contending for a lock over
+ sftp. (Martin Pool, #340352)
+
     * Fixed "sprout() got an unexpected keyword argument 'source_branch'"
       error branching from old repositories.
       (Martin Pool, #321695)

=== modified file 'bzrlib/transport/sftp.py'
--- bzrlib/transport/sftp.py 2009-02-23 15:29:35 +0000
+++ bzrlib/transport/sftp.py 2009-03-10 07:24:55 +0000
@@ -692,6 +692,9 @@
         # paramiko seems to generate detailless errors.
         self._translate_error(e, path, raise_generic=False)
         if getattr(e, 'args', None) is not None:
+ # 29.993 Raising exception with args ('Directory not empty:
+ # "/srv/bazaar.launchpad.net/push-branches/00/00/94/67/.bzr/branch/lock/xrdlfxf6nl.tmp":
+ # [Errno 39] Directory not empty',)
             if (e.args == ('No such file or directory',) or
                 e.args == ('No such file',)):
                 raise NoSuchFile(path, str(e) + more_info)
@@ -701,6 +704,9 @@
             # strange but true, for the paramiko server.
             if (e.args == ('Failure',)):
                 raise failure_exc(path, str(e) + more_info)
+ if (e.args[0].startswith('Directory not empty: ')
+ or getattr(e, 'errno', None) == errno.ENOTEMPTY):
+ raise errors.DirectoryNotEmpty(path, str(e))
             mutter('Raising exception with args %s', e.args)
         if getattr(e, 'errno', None) is not None:
             mutter('Raising exception with errno %s', e.errno)

« Back to merge proposal