makedirs() function for transports

Bug #120135 reported by Jonathan Lange
2
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Wishlist
Unassigned
Launchpad itself
Fix Released
Wishlist
Unassigned

Bug Description

It would be nice if bzrlib provided a makedirs() function that created a directory and all of its parent directories on a transport, ala os.makedirs().

I reckon add it as a module-level function in bzrlib.transport and make it something like 'makedirs(transport, path, mode=None)'

The code to do this could be extracted out of the bowels of cmd_push.

Revision history for this message
John A Meinel (jameinel) wrote :

This seems reasonable, though there is still one question.

Which is whether it should fail if the target directory already exists.

os.makedirs() will raise an exception if the target exists, while 'mkdir -p' will not.

Most of our current code just silently swallows the exception that is naturally raised by the mkdir() call, so I would tend to implement it that way. What did you have in mind?

Changed in bzr:
importance: Undecided → Wishlist
status: Unconfirmed → Confirmed
Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 120135] Re: makedirs() function for transports

I'd tend to think it should be like mkdir -p. There might be cases
with locking where we want to see the exception. But I believe that
on some transports or filesystems we can't reliably detect that the
directory already exists (nfs?), so there's no point defining the
interface to require it.

Revision history for this message
Jonathan Lange (jml) wrote :

I'd prefer 'mkdir -p' style behaviour. Most of the times I've ever wanted to do this sort of thing, I've just wanted to guarantee that the directory is there.

Curtis Hovey (sinzui)
tags: added: tech-debt
Revision history for this message
Martin Pool (mbp) wrote :

mwh points out this seems to be satisfied by Transport.create_prefix. Launchpad may want to make use of that (if you care) so I'll open a task there.

Changed in bzr:
status: Confirmed → Fix Released
Changed in launchpad-code:
status: New → Confirmed
importance: Undecided → Wishlist
Revision history for this message
Aaron Bentley (abentley) wrote :

Launchpad is already using create_prefix.

Changed in launchpad-code:
status: Confirmed → 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.