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

Andrew Bennetts andrew at canonical.com
Thu Jan 3 07:41:33 GMT 2008


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.




More information about the bazaar mailing list