comparison hgext/narrow/narrowbundle2.py @ 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 f66628c15e6f
comparison
equal deleted inserted replaced
42365:92f584065b4f 42366:21e77ede77ab
55 if v in changegroup.supportedoutgoingversions(repo)] 55 if v in changegroup.supportedoutgoingversions(repo)]
56 if not cgversions: 56 if not cgversions:
57 raise ValueError(_('no common changegroup version')) 57 raise ValueError(_('no common changegroup version'))
58 version = max(cgversions) 58 version = max(cgversions)
59 59
60 include = sorted(filter(bool, kwargs.get(r'includepats', []))) 60 oldinclude = sorted(filter(bool, kwargs.get(r'oldincludepats', [])))
61 exclude = sorted(filter(bool, kwargs.get(r'excludepats', []))) 61 oldexclude = sorted(filter(bool, kwargs.get(r'oldexcludepats', [])))
62 newmatch = narrowspec.match(repo.root, include=include, exclude=exclude) 62 newinclude = sorted(filter(bool, kwargs.get(r'includepats', [])))
63 63 newexclude = sorted(filter(bool, kwargs.get(r'excludepats', [])))
64 depth = kwargs.get(r'depth', None) 64 generateellipsesbundle2(bundler, repo, oldinclude, oldexclude, newinclude,
65 newexclude, version, common, kwargs.get('known', []),
66 kwargs.get(r'depth', None), heads)
67
68 def generateellipsesbundle2(bundler, repo, oldinclude, oldexclude, newinclude,
69 newexclude, version, common, known, depth, heads):
70 newmatch = narrowspec.match(repo.root, include=newinclude,
71 exclude=newexclude)
65 if depth is not None: 72 if depth is not None:
66 depth = int(depth) 73 depth = int(depth)
67 if depth < 1: 74 if depth < 1:
68 raise error.Abort(_('depth must be positive, got %d') % depth) 75 raise error.Abort(_('depth must be positive, got %d') % depth)
69 76
70 heads = set(heads or repo.heads()) 77 heads = set(heads or repo.heads())
71 common = set(common or [nullid]) 78 common = set(common or [nullid])
72 oldinclude = sorted(filter(bool, kwargs.get(r'oldincludepats', []))) 79 known = {bin(n) for n in known}
73 oldexclude = sorted(filter(bool, kwargs.get(r'oldexcludepats', []))) 80 if known and (oldinclude != newinclude or oldexclude != newexclude):
74 known = {bin(n) for n in kwargs.get(r'known', [])}
75 if known and (oldinclude != include or oldexclude != exclude):
76 # Steps: 81 # Steps:
77 # 1. Send kill for "$known & ::common" 82 # 1. Send kill for "$known & ::common"
78 # 83 #
79 # 2. Send changegroup for ::common 84 # 2. Send changegroup for ::common
80 # 85 #