[PATCH 3 of 5] unbundle: swap conditional branches for clarity
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Thu Feb 2 11:21:33 EST 2017
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1486029235 -3600
# Thu Feb 02 10:53:55 2017 +0100
# Node ID f6028c7a59d4baeed0b52768bebf5076979578d9
# Parent 904a482f2d70cd8859d09fe35af7d3e125ce632b
# EXP-Topic pushcleanup
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 -r 904a482f2d70 -r f6028c7a59d4 mercurial/exchange.py
--- a/mercurial/exchange.py Thu Feb 02 10:55:38 2017 +0100
+++ b/mercurial/exchange.py Thu Feb 02 10:53:55 2017 +0100
@@ -1723,7 +1723,11 @@
# '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 @@
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:
More information about the Mercurial-devel
mailing list