changeset 42366:21e77ede77ab

narrow: factor out logic to build ellipses related b2parts in separate fn This will help us switch more cleanly to using wireprotocol commands instead of using exchange.pull() which exchanges more things then required. Differential Revision: https://phab.mercurial-scm.org/D6435
author Pulkit Goyal <7895pulkit@gmail.com>
date Tue, 21 May 2019 05:32:14 +0530
parents 92f584065b4f
children 96fc696a9cb2
files hgext/narrow/narrowbundle2.py
diffstat 1 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/narrow/narrowbundle2.py	Tue May 21 04:49:18 2019 +0530
+++ b/hgext/narrow/narrowbundle2.py	Tue May 21 05:32:14 2019 +0530
@@ -57,11 +57,18 @@
         raise ValueError(_('no common changegroup version'))
     version = max(cgversions)
 
-    include = sorted(filter(bool, kwargs.get(r'includepats', [])))
-    exclude = sorted(filter(bool, kwargs.get(r'excludepats', [])))
-    newmatch = narrowspec.match(repo.root, include=include, exclude=exclude)
+    oldinclude = sorted(filter(bool, kwargs.get(r'oldincludepats', [])))
+    oldexclude = sorted(filter(bool, kwargs.get(r'oldexcludepats', [])))
+    newinclude = sorted(filter(bool, kwargs.get(r'includepats', [])))
+    newexclude = sorted(filter(bool, kwargs.get(r'excludepats', [])))
+    generateellipsesbundle2(bundler, repo, oldinclude, oldexclude, newinclude,
+            newexclude, version, common, kwargs.get('known', []),
+            kwargs.get(r'depth', None), heads)
 
-    depth = kwargs.get(r'depth', None)
+def generateellipsesbundle2(bundler, repo, oldinclude, oldexclude, newinclude,
+                            newexclude, version, common, known, depth, heads):
+    newmatch = narrowspec.match(repo.root, include=newinclude,
+                                exclude=newexclude)
     if depth is not None:
         depth = int(depth)
         if depth < 1:
@@ -69,10 +76,8 @@
 
     heads = set(heads or repo.heads())
     common = set(common or [nullid])
-    oldinclude = sorted(filter(bool, kwargs.get(r'oldincludepats', [])))
-    oldexclude = sorted(filter(bool, kwargs.get(r'oldexcludepats', [])))
-    known = {bin(n) for n in kwargs.get(r'known', [])}
-    if known and (oldinclude != include or oldexclude != exclude):
+    known = {bin(n) for n in known}
+    if known and (oldinclude != newinclude or oldexclude != newexclude):
         # Steps:
         # 1. Send kill for "$known & ::common"
         #