Mercurial > public > mercurial-scm > hg
diff mercurial/exchange.py @ 21187:bcfd44abad93 stable
bundle2: gracefully handle hook abort
We make sure any exceptions raised during the whole span of handling bundle2
processing are decorated. This let us catch exceptions raised by hooks prior to
transaction commit.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 21 Apr 2014 16:13:15 -0700 |
parents | 28d76afa1568 |
children | 541b2b08f323 |
line wrap: on
line diff
--- a/mercurial/exchange.py Mon Apr 21 17:51:58 2014 -0700 +++ b/mercurial/exchange.py Mon Apr 21 16:13:15 2014 -0700 @@ -738,16 +738,20 @@ check_heads(repo, heads, 'uploading changes') # push can proceed if util.safehasattr(cg, 'params'): - tr = repo.transaction('unbundle') - tr.hookargs['bundle2-exp'] = '1' - r = bundle2.processbundle(repo, cg, lambda: tr).reply - cl = repo.unfiltered().changelog - p = cl.writepending() and repo.root or "" - repo.hook('b2x-pretransactionclose', throw=True, source=source, - url=url, pending=p, **tr.hookargs) - tr.close() - repo.hook('b2x-transactionclose', source=source, url=url, - **tr.hookargs) + try: + tr = repo.transaction('unbundle') + tr.hookargs['bundle2-exp'] = '1' + r = bundle2.processbundle(repo, cg, lambda: tr).reply + cl = repo.unfiltered().changelog + p = cl.writepending() and repo.root or "" + repo.hook('b2x-pretransactionclose', throw=True, source=source, + url=url, pending=p, **tr.hookargs) + tr.close() + repo.hook('b2x-transactionclose', source=source, url=url, + **tr.hookargs) + except Exception, exc: + exc.duringunbundle2 = True + raise else: r = changegroup.addchangegroup(repo, cg, source, url) finally: