[MERGE] Faster LocalTransport.put() and append() methods.

Martin Pool mbp at canonical.com
Wed Jun 14 04:36:49 BST 2006


Nice speedup.

Caching the pid isn't awful but I wonder if we can just avoid it  
altogether.

> +        # This is 'broken' on NFS: it wmay collide with another  
> NFS client.
> +        # however, we use this to write files within a directory  
> that we have
> +        # locked, so it being racy on NFS is not a concern. The  
> only other
> +        # files we use this for are .bzr.ignore, which can race  
> anyhow.
> +        self.tmpfilename = '%s.%d.tmp' % (filename, _pid)

Having this comment is good; explaining the restrictions on safe use  
of the class in the docstring would also be good.

s//wmay/may

Since you're creating the file with O_EXCL I don't see any need to  
include the PID.  Instead, if that fails with EEXIST then just e.g.  
add a sequence number and try again.

To clarify - the point of chmod is to make sure that differing umasks  
don't lead to bzrdirs with inconsistent permissions between their  
files.  (e.g. most are 0660, some are 0600.)

>> I would be happy with that. Problem #1 is that I don't know of any  
>> way
>> to determine the current umask without setting it. (os.umask() will
>> return the old umask, but only after you set a new one).
>
> mask = os.umask(0)
> os.umask(mask)

If we're going to do that then perhaps we can just reset our umask  
entirely while updating the repository from a try/finally block.   
That is what we're logically trying to achieve.  The main problem is  
if we need to interleave access to different objects that should get  
different permissions.

-- 
Martin







More information about the bazaar mailing list