pulkit created this revision. Herald added a reviewer: durin42. Herald added a reviewer: martinvonz. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers.
REVISION SUMMARY Previous patch while adding support for using narrow_widen wireproto command, complicated the code a bit. This patch refactors that. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D6437 AFFECTED FILES hgext/narrow/narrowcommands.py CHANGE DETAILS diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py --- a/hgext/narrow/narrowcommands.py +++ b/hgext/narrow/narrowcommands.py @@ -255,71 +255,48 @@ # functionality from an ellipses enabled server ellipsesremote = wireprototypes.ELLIPSESCAP in remote.capabilities() - def pullbundle2extraprepare_widen(orig, pullop, kwargs): - orig(pullop, kwargs) - # The old{in,ex}cludepats have already been set by orig() - kwargs['includepats'] = newincludes - kwargs['excludepats'] = newexcludes - wrappedextraprepare = extensions.wrappedfunction(exchange, - '_pullbundle2extraprepare', pullbundle2extraprepare_widen) - # define a function that narrowbundle2 can call after creating the # backup bundle, but before applying the bundle from the server def setnewnarrowpats(): repo.setnarrowpats(newincludes, newexcludes) repo.setnewnarrowpats = setnewnarrowpats # silence the devel-warning of applying an empty changegroup overrides = {('devel', 'all-warnings'): False} + bundle = None + known = [] + common = commoninc[0] with ui.uninterruptible(): - common = commoninc[0] if ellipsesremote: ds = repo.dirstate p1, p2 = ds.p1(), ds.p2() with ds.parentchange(): ds.setparents(node.nullid, node.nullid) - with wrappedextraprepare: - known = [node.hex(ctx.node()) for ctx in - repo.set('::%ln', common) - if ctx.node() != node.nullid] + known = [node.hex(ctx.node()) for ctx in + repo.set('::%ln', common) + if ctx.node() != node.nullid] - with remote.commandexecutor() as e: - bundle = e.callcommand('narrow_widen', { - 'oldincludes': oldincludes, - 'oldexcludes': oldexcludes, - 'newincludes': newincludes, - 'newexcludes': newexcludes, - 'cgversion': '03', - 'commonheads': common, - 'known': known, - 'ellipses': True, - }).result() - trmanager = exchange.transactionmanager(repo, 'widen', remote.url()) - with trmanager: - op = bundle2.bundleoperation(repo, - trmanager.transaction, source='widen') - bundle2.processbundle(repo, bundle, op=op) + with remote.commandexecutor() as e: + bundle = e.callcommand('narrow_widen', { + 'oldincludes': oldincludes, + 'oldexcludes': oldexcludes, + 'newincludes': newincludes, + 'newexcludes': newexcludes, + 'cgversion': '03', + 'commonheads': common, + 'known': known, + 'ellipses': ellipsesremote, + }).result() + trmanager = exchange.transactionmanager(repo, 'widen', remote.url()) + with trmanager, repo.ui.configoverride(overrides, 'widen'): + op = bundle2.bundleoperation(repo, trmanager.transaction, + source='widen') + # TODO: we should catch error.Abort here + bundle2.processbundle(repo, bundle, op=op) + if ellipsesremote: with ds.parentchange(): ds.setparents(p1, p2) - else: - with remote.commandexecutor() as e: - bundle = e.callcommand('narrow_widen', { - 'oldincludes': oldincludes, - 'oldexcludes': oldexcludes, - 'newincludes': newincludes, - 'newexcludes': newexcludes, - 'cgversion': '03', - 'commonheads': common, - 'known': [], - 'ellipses': False, - }).result() - - 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() To: pulkit, durin42, martinvonz, #hg-reviewers Cc: mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel