[MERGE] don't invoke os.rename on children with no contents

Aaron Bentley aaron.bentley at utoronto.ca
Wed Jun 6 02:48:07 BST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robert Collins wrote:
> On Tue, 2007-06-05 at 21:10 -0400, Aaron Bentley wrote:
> 
> You're good to merge without doing the below.

Okay, have done so.

>> Now what you could do is this:
>>
>>      for trans_id in trans_ids:
>>          if trans_id not in self._new_contents:
>>              del self._limbo_files[trans_id]
>>              continue
>>          old_path = self._limbo_files[trans_id]
>>          new_path = self._limbo_name(trans_id, from_scratch=True)
>>          os.rename(old_path, new_path)
>>
>> Deleting the self._limbo_files entry forces it to be generated from
>> scratch on the next usage, rather than generating it from scratch now.
> 
> This is not related to merging - a more general api discussion:
> Interesting. Which is it that removes it from _limbo_files?

del self._limbo_files[trans_id]

I think we miscommunicated.

self._limbo_name(trans_id, from_scratch=True) has the side effect of
storing a new value in self._limbo_files[trans_id], overwriting any
existing value.

Either del self._limbo_files[trans_id] or self._limbo_name(trans_id,
from_scratch=True) ensures that self._limbo_files does not contain a
stale value.

> the
> _limbo_name call? It just appears hard to guess at whats happening..

Perhaps it would be clearer to scrag the from_scratch parameter, and do
this:

     for trans_id in trans_ids:
         old_path = self._limbo_files[trans_id]
         del self._limbo_files[trans_id]
         if trans_id in self._new_contents:
             new_path = self._limbo_name(trans_id)
             os.rename(old_path, new_path)

What do you think?

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGZhJX0F+nu1YWqI0RAiTpAJ9tX4YcJnaemXPpmqMlJ7v7jvsBbQCfYD0L
LVZAXVt6HMjYCQWeYlvqXyA=
=C5s9
-----END PGP SIGNATURE-----



More information about the bazaar mailing list