[MERGE] Implement hard-link support for branch and checkout

Matt Nordhoff mnordhoff at mattnordhoff.com
Thu Jan 3 08:46:54 GMT 2008


Matt Nordhoff wrote:
> Andrew Bennetts wrote:
>> Ian Clatworthy wrote:
>>> Aaron Bentley wrote:
>> [...]
>>>> +    def create_hardlink(self, path, trans_id):
>>>> +        """Schedule creation of a hard link"""
>>>> +        name = self._limbo_name(trans_id)
>>>> +        os.link(path, name)
>>>> +        try:
>>>> +            unique_add(self._new_contents, trans_id, 'file')
>>>> +        except:
>>>> +            # Clean up the file, it never got registered so
>>>> +            # TreeTransform.finalize() won't clean it up.
>>>> +            os.unlink(name)
>>>> +            raise
>>>> +
>>> Bare except clauses are considered bad. Please be explicit about the
>>> class of exceptions being caught.
>> This one is fine: it immediately re-raises the original exception.  It is just
>> making sure that things get cleaned up if an exception is raised, and it's about
>> as idiomatic as it can be.
>>
>> -Andrew.
> 
> finally block?

Err, right, never mind. That wouldn't work because you don't want to do
it if there isn't an exception. Sorry for the spam.

(I should write a Thunderbird extension that waits for 10 seconds after
hitting Send and lets me undo it.)
-- 



More information about the bazaar mailing list