# HG changeset patch # User Pierre-Yves David # Date 2017-02-02 09:53:55 # Node ID c5bee6aa497106250350a3e5b4b9be1e1ecd275e # Parent 887de951613899949de9e3d58ae29eb13ad7cecb unbundle: swap conditional branches for clarity This is a small style update for clarity. The previous situation was: if foo: 50 lines else: 2 lines In such case I tend to invert these to get the simpler branch out of the way earlier: if not foo: 2 lines else: 50 lines This makes the conditional and various alternatives fit on the same screen, simpler to read overall. diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -1723,7 +1723,11 @@ def unbundle(repo, cg, heads, source, ur # 'check_heads' call wil be a no-op check_heads(repo, heads, 'uploading changes') # push can proceed - if util.safehasattr(cg, 'params'): + if not util.safehasattr(cg, 'params'): + # legacy case: bundle1 (changegroup 01) + lockandtr[1] = repo.lock() + r = cg.apply(repo, source, url) + else: r = None try: def gettransaction(): @@ -1762,10 +1766,6 @@ def unbundle(repo, cg, heads, source, ur mandatory=False) parts.append(part) raise - else: - # legacy case: bundle1 (changegroup 01) - lockandtr[1] = repo.lock() - r = cg.apply(repo, source, url) finally: lockmod.release(lockandtr[2], lockandtr[1], lockandtr[0]) if recordout is not None: