Patchwork D6437: narrow: refactor code around widening complicated by previous patch

login
register
mail settings
Submitter phabricator
Date June 4, 2019, 5:52 p.m.
Message ID <008efc3fc16a6fe6ec126f9100953dc5@localhost.localdomain>
Download mbox | patch
Permalink /patch/40313/
State Not Applicable
Headers show

Comments

phabricator - June 4, 2019, 5:52 p.m.
pulkit updated this revision to Diff 15337.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6437?vs=15335&id=15337

REVISION DETAIL
  https://phab.mercurial-scm.org/D6437

AFFECTED FILES
  hgext/narrow/narrowcommands.py

CHANGE DETAILS




To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -278,59 +278,44 @@ 
     # silence the devel-warning of applying an empty changegroup
     overrides = {('devel', 'all-warnings'): False}
 
+    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)
+        if isoldellipses:
             with wrappedextraprepare:
-                if isoldellipses:
-                    exchange.pull(repo, remote, heads=common)
-                else:
-                    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 ds.parentchange():
-                ds.setparents(p1, p2)
+                exchange.pull(repo, remote, heads=common)
         else:
+            known = []
+            if ellipsesremote:
+                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': [],
-                    'ellipses': False,
+                    'known': known,
+                    'ellipses': ellipsesremote,
                 }).result()
 
-            with repo.transaction('widening') as tr:
-                with repo.ui.configoverride(overrides, 'widen'):
-                    tgetter = lambda: tr
-                    bundle2.processbundle(repo, bundle,
-                            transactiongetter=tgetter)
+            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)
 
         with repo.transaction('widening'):
             repo.setnewnarrowpats()