Re: PATCHES: start adding Mercurial backend (HgOutputOption)
Greg Ward <[email protected]> Sun, 4 Oct 2009 10:26:23 -0400
| Newsgroups | gmane.comp.version-control.subversion.cvs2svn.devel |
|---|---|
| Message-ID | <[email protected]> |
[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. The full thread is here: http://www.selenic.com/pipermail/mercurial-devel/2009-October/015771.html . Greg ------------------------------------------------------ http://cvs2svn.tigris.org/ds/viewMessage.do?dsForumId=1667&dsMessageId=2403343 To unsubscribe from this discussion, e-mail: [[email protected]].