Mercurial > hg
comparison hgext/narrow/narrowbundle2.py @ 45372:77b8588dd84e
requirements: introduce new requirements related module
It was not clear where all requirements should and related APIs should be, this
patch introduces a requirements module which will have all exitsing requirements
and related APIs.
Differential Revision: https://phab.mercurial-scm.org/D8917
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sat, 08 Aug 2020 16:24:12 +0530 |
parents | e58e234096de |
children | 10284ce3d5ed |
comparison
equal
deleted
inserted
replaced
45371:e58e234096de | 45372:77b8588dd84e |
---|---|
18 error, | 18 error, |
19 exchange, | 19 exchange, |
20 localrepo, | 20 localrepo, |
21 narrowspec, | 21 narrowspec, |
22 repair, | 22 repair, |
23 requirements, | |
23 scmutil, | 24 scmutil, |
24 util, | 25 util, |
25 wireprototypes, | 26 wireprototypes, |
26 ) | 27 ) |
27 from mercurial.interfaces import repository | |
28 from mercurial.utils import stringutil | 28 from mercurial.utils import stringutil |
29 | 29 |
30 _NARROWACL_SECTION = b'narrowacl' | 30 _NARROWACL_SECTION = b'narrowacl' |
31 _CHANGESPECPART = b'narrow:changespec' | 31 _CHANGESPECPART = b'narrow:changespec' |
32 _RESSPECS = b'narrow:responsespec' | 32 _RESSPECS = b'narrow:responsespec' |
106 ) | 106 ) |
107 cgdata = packer.generate(common, visitnodes, False, b'narrow_widen') | 107 cgdata = packer.generate(common, visitnodes, False, b'narrow_widen') |
108 | 108 |
109 part = bundler.newpart(b'changegroup', data=cgdata) | 109 part = bundler.newpart(b'changegroup', data=cgdata) |
110 part.addparam(b'version', version) | 110 part.addparam(b'version', version) |
111 if repository.TREEMANIFEST_REQUIREMENT in repo.requirements: | 111 if requirements.TREEMANIFEST_REQUIREMENT in repo.requirements: |
112 part.addparam(b'treemanifest', b'1') | 112 part.addparam(b'treemanifest', b'1') |
113 | 113 |
114 | 114 |
115 def generate_ellipses_bundle2_for_widening( | 115 def generate_ellipses_bundle2_for_widening( |
116 bundler, repo, oldmatch, newmatch, version, common, known, | 116 bundler, repo, oldmatch, newmatch, version, common, known, |
161 ) | 161 ) |
162 cgdata = packer.generate(common, newvisit, False, b'narrow_widen') | 162 cgdata = packer.generate(common, newvisit, False, b'narrow_widen') |
163 | 163 |
164 part = bundler.newpart(b'changegroup', data=cgdata) | 164 part = bundler.newpart(b'changegroup', data=cgdata) |
165 part.addparam(b'version', version) | 165 part.addparam(b'version', version) |
166 if repository.TREEMANIFEST_REQUIREMENT in repo.requirements: | 166 if requirements.TREEMANIFEST_REQUIREMENT in repo.requirements: |
167 part.addparam(b'treemanifest', b'1') | 167 part.addparam(b'treemanifest', b'1') |
168 | 168 |
169 | 169 |
170 @bundle2.parthandler(_SPECPART, (_SPECPART_INCLUDE, _SPECPART_EXCLUDE)) | 170 @bundle2.parthandler(_SPECPART, (_SPECPART_INCLUDE, _SPECPART_EXCLUDE)) |
171 def _handlechangespec_2(op, inpart): | 171 def _handlechangespec_2(op, inpart): |
176 includepats = set(inpart.params.get(_SPECPART_INCLUDE, b'').splitlines()) | 176 includepats = set(inpart.params.get(_SPECPART_INCLUDE, b'').splitlines()) |
177 excludepats = set(inpart.params.get(_SPECPART_EXCLUDE, b'').splitlines()) | 177 excludepats = set(inpart.params.get(_SPECPART_EXCLUDE, b'').splitlines()) |
178 narrowspec.validatepatterns(includepats) | 178 narrowspec.validatepatterns(includepats) |
179 narrowspec.validatepatterns(excludepats) | 179 narrowspec.validatepatterns(excludepats) |
180 | 180 |
181 if not repository.NARROW_REQUIREMENT in op.repo.requirements: | 181 if not requirements.NARROW_REQUIREMENT in op.repo.requirements: |
182 op.repo.requirements.add(repository.NARROW_REQUIREMENT) | 182 op.repo.requirements.add(requirements.NARROW_REQUIREMENT) |
183 scmutil.writereporequirements(op.repo) | 183 scmutil.writereporequirements(op.repo) |
184 op.repo.setnarrowpats(includepats, excludepats) | 184 op.repo.setnarrowpats(includepats, excludepats) |
185 narrowspec.copytoworkingcopy(op.repo) | 185 narrowspec.copytoworkingcopy(op.repo) |
186 | 186 |
187 | 187 |
192 includepats = set(inc.splitlines()) | 192 includepats = set(inc.splitlines()) |
193 excludepats = set(exc.splitlines()) | 193 excludepats = set(exc.splitlines()) |
194 narrowspec.validatepatterns(includepats) | 194 narrowspec.validatepatterns(includepats) |
195 narrowspec.validatepatterns(excludepats) | 195 narrowspec.validatepatterns(excludepats) |
196 | 196 |
197 if repository.NARROW_REQUIREMENT not in op.repo.requirements: | 197 if requirements.NARROW_REQUIREMENT not in op.repo.requirements: |
198 op.repo.requirements.add(repository.NARROW_REQUIREMENT) | 198 op.repo.requirements.add(requirements.NARROW_REQUIREMENT) |
199 scmutil.writereporequirements(op.repo) | 199 scmutil.writereporequirements(op.repo) |
200 op.repo.setnarrowpats(includepats, excludepats) | 200 op.repo.setnarrowpats(includepats, excludepats) |
201 narrowspec.copytoworkingcopy(op.repo) | 201 narrowspec.copytoworkingcopy(op.repo) |
202 | 202 |
203 | 203 |