Re: PATCHES: start adding Mercurial backend (HgOutputOption)
Michael Haggerty <[email protected]> Sun, 04 Oct 2009 22:08:39 +0200
| Newsgroups | gmane.comp.version-control.subversion.cvs2svn.devel |
|---|---|
| Message-ID | <[email protected]> |
Greg Ward wrote: > [from my patches] >> txn = self.repo.transaction() >> try: >> node = self.repo.commitctx(mctx) >> txn.close() >> finally: >> del txn >> return node > > [Michael inquires] >> I don't understand the point of the try...finally here. "del txn" does >> not force txn.__del__() to be run; it only unbinds the local "txn" >> variable > > [I plead ignorance] >> I'll ask on mercurial-devel about this idiom. > > Got the answer. Without the "finally: del txn", an exception thrown > from the "try" clause creates a traceback object that retains > references to every stack frame. That includes references to all > local variables in each stack frame. So in that case, the txn > destructor is invoked much later and far away from here. The "del > txn" removes it from the current stack frame, ensuring that it's not > kept around in case of an exception. Yes, good point. Thanks for researching this. Michael ------------------------------------------------------ http://cvs2svn.tigris.org/ds/viewMessage.do?dsForumId=1667&dsMessageId=2403387 To unsubscribe from this discussion, e-mail: [[email protected]].