D5994: cleanup: prefer nested context managers to \-continuations
durin42 (Augie Fackler)
phabricator at mercurial-scm.org
Thu Feb 21 16:29:26 EST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG1eb2fc21da12: cleanup: prefer nested context managers to \-continuations (authored by durin42, committed by ).
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D5994?vs=14164&id=14179
REVISION DETAIL
https://phab.mercurial-scm.org/D5994
AFFECTED FILES
hgext/largefiles/overrides.py
hgext/narrow/narrowcommands.py
mercurial/exchange.py
CHANGE DETAILS
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -556,18 +556,18 @@
% stringutil.forcebytestr(err))
pushop.ui.debug(msg)
- with wlock or util.nullcontextmanager(), \
- lock or util.nullcontextmanager(), \
- pushop.trmanager or util.nullcontextmanager():
- pushop.repo.checkpush(pushop)
- _checkpublish(pushop)
- _pushdiscovery(pushop)
- if not _forcebundle1(pushop):
- _pushbundle2(pushop)
- _pushchangeset(pushop)
- _pushsyncphase(pushop)
- _pushobsolete(pushop)
- _pushbookmark(pushop)
+ with wlock or util.nullcontextmanager():
+ with lock or util.nullcontextmanager():
+ with pushop.trmanager or util.nullcontextmanager():
+ pushop.repo.checkpush(pushop)
+ _checkpublish(pushop)
+ _pushdiscovery(pushop)
+ if not _forcebundle1(pushop):
+ _pushbundle2(pushop)
+ _pushchangeset(pushop)
+ _pushsyncphase(pushop)
+ _pushobsolete(pushop)
+ _pushbookmark(pushop)
if repo.ui.configbool('experimental', 'remotenames'):
logexchange.pullremotenames(repo, remote)
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -278,9 +278,9 @@
p1, p2 = ds.p1(), ds.p2()
with ds.parentchange():
ds.setparents(node.nullid, node.nullid)
- with wrappedextraprepare,\
- repo.ui.configoverride(overrides, 'widen'):
- exchange.pull(repo, remote, heads=common)
+ with wrappedextraprepare:
+ with repo.ui.configoverride(overrides, 'widen'):
+ exchange.pull(repo, remote, heads=common)
with ds.parentchange():
ds.setparents(p1, p2)
else:
@@ -296,11 +296,11 @@
'ellipses': False,
}).result()
- with repo.transaction('widening') as tr,\
- repo.ui.configoverride(overrides, 'widen'):
- tgetter = lambda: tr
- bundle2.processbundle(repo, bundle,
- transactiongetter=tgetter)
+ with repo.transaction('widening') as tr:
+ with repo.ui.configoverride(overrides, 'widen'):
+ tgetter = lambda: tr
+ bundle2.processbundle(repo, bundle,
+ transactiongetter=tgetter)
with repo.transaction('widening'):
repo.setnewnarrowpats()
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -664,9 +664,9 @@
_('destination largefile already exists'))
copiedfiles.append((src, dest))
orig(src, dest, *args, **kwargs)
- with extensions.wrappedfunction(util, 'copyfile', overridecopyfile), \
- extensions.wrappedfunction(scmutil, 'match', overridematch):
- result += orig(ui, repo, listpats, opts, rename)
+ with extensions.wrappedfunction(util, 'copyfile', overridecopyfile):
+ with extensions.wrappedfunction(scmutil, 'match', overridematch):
+ result += orig(ui, repo, listpats, opts, rename)
lfdirstate = lfutil.openlfdirstate(ui, repo)
for (src, dest) in copiedfiles:
To: durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list