D708: bundle2: remove unnecessary try finally
This revision was automatically updated to reflect the committed changes. Closed by commit rHGcc7b37c90616: bundle2: remove unnecessary try finally (authored by durham, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D708?vs=1820=1875 REVISION DETAIL https://phab.mercurial-scm.org/D708 AFFECTED FILES mercurial/bundle2.py CHANGE DETAILS diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -505,32 +505,28 @@ The part is guaranteed to have been fully consumed when the function exits (even if an exception is raised).""" -try: -handler = _gethandler(op, part) -if handler is None: -return +handler = _gethandler(op, part) +if handler is None: +return -# handler is called outside the above try block so that we don't -# risk catching KeyErrors from anything other than the -# parthandlermapping lookup (any KeyError raised by handler() -# itself represents a defect of a different variety). -output = None -if op.captureoutput and op.reply is not None: -op.ui.pushbuffer(error=True, subproc=True) -output = '' -try: -handler(op, part) -finally: -if output is not None: -output = op.ui.popbuffer() -if output: -outpart = op.reply.newpart('output', data=output, - mandatory=False) -outpart.addparam( -'in-reply-to', pycompat.bytestr(part.id), mandatory=False) +# handler is called outside the above try block so that we don't +# risk catching KeyErrors from anything other than the +# parthandlermapping lookup (any KeyError raised by handler() +# itself represents a defect of a different variety). +output = None +if op.captureoutput and op.reply is not None: +op.ui.pushbuffer(error=True, subproc=True) +output = '' +try: +handler(op, part) finally: -pass - +if output is not None: +output = op.ui.popbuffer() +if output: +outpart = op.reply.newpart('output', data=output, + mandatory=False) +outpart.addparam( +'in-reply-to', pycompat.bytestr(part.id), mandatory=False) def decodecaps(blob): """decode a bundle2 caps bytes blob into a dictionary To: durham, #hg-reviewers, indygreg, krbullock Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D708: bundle2: remove unnecessary try finally
durham updated this revision to Diff 1820. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D708?vs=1804=1820 REVISION DETAIL https://phab.mercurial-scm.org/D708 AFFECTED FILES mercurial/bundle2.py CHANGE DETAILS diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -505,32 +505,28 @@ The part is guaranteed to have been fully consumed when the function exits (even if an exception is raised).""" -try: -handler = _gethandler(op, part) -if handler is None: -return +handler = _gethandler(op, part) +if handler is None: +return -# handler is called outside the above try block so that we don't -# risk catching KeyErrors from anything other than the -# parthandlermapping lookup (any KeyError raised by handler() -# itself represents a defect of a different variety). -output = None -if op.captureoutput and op.reply is not None: -op.ui.pushbuffer(error=True, subproc=True) -output = '' -try: -handler(op, part) -finally: -if output is not None: -output = op.ui.popbuffer() -if output: -outpart = op.reply.newpart('output', data=output, - mandatory=False) -outpart.addparam( -'in-reply-to', pycompat.bytestr(part.id), mandatory=False) +# handler is called outside the above try block so that we don't +# risk catching KeyErrors from anything other than the +# parthandlermapping lookup (any KeyError raised by handler() +# itself represents a defect of a different variety). +output = None +if op.captureoutput and op.reply is not None: +op.ui.pushbuffer(error=True, subproc=True) +output = '' +try: +handler(op, part) finally: -pass - +if output is not None: +output = op.ui.popbuffer() +if output: +outpart = op.reply.newpart('output', data=output, + mandatory=False) +outpart.addparam( +'in-reply-to', pycompat.bytestr(part.id), mandatory=False) def decodecaps(blob): """decode a bundle2 caps bytes blob into a dictionary To: durham, #hg-reviewers, indygreg Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D708: bundle2: remove unnecessary try finally
indygreg requested changes to this revision. indygreg added a comment. This revision now requires changes to proceed. Let's wait for a new version of https://phab.mercurial-scm.org/D706 before looking at this. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D708 To: durham, #hg-reviewers, indygreg Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D708: bundle2: remove unnecessary try finally
durham created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This is no longer needed. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D708 AFFECTED FILES mercurial/bundle2.py CHANGE DETAILS diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -505,32 +505,28 @@ The part is guaranteed to have been fully consumed when the function exits (even if an exception is raised).""" -try: -handler = _gethandler(op, part) -if handler is None: -return +handler = _gethandler(op, part) +if handler is None: +return -# handler is called outside the above try block so that we don't -# risk catching KeyErrors from anything other than the -# parthandlermapping lookup (any KeyError raised by handler() -# itself represents a defect of a different variety). -output = None -if op.captureoutput and op.reply is not None: -op.ui.pushbuffer(error=True, subproc=True) -output = '' -try: -handler(op, part) -finally: -if output is not None: -output = op.ui.popbuffer() -if output: -outpart = op.reply.newpart('output', data=output, - mandatory=False) -outpart.addparam( -'in-reply-to', pycompat.bytestr(part.id), mandatory=False) +# handler is called outside the above try block so that we don't +# risk catching KeyErrors from anything other than the +# parthandlermapping lookup (any KeyError raised by handler() +# itself represents a defect of a different variety). +output = None +if op.captureoutput and op.reply is not None: +op.ui.pushbuffer(error=True, subproc=True) +output = '' +try: +handler(op, part) finally: -pass - +if output is not None: +output = op.ui.popbuffer() +if output: +outpart = op.reply.newpart('output', data=output, + mandatory=False) +outpart.addparam( +'in-reply-to', pycompat.bytestr(part.id), mandatory=False) def decodecaps(blob): """decode a bundle2 caps bytes blob into a dictionary To: durham, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel