Mercurial > hg
comparison hgext/narrow/narrowcommands.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 | c21aca51b392 |
children | 59fa3890d40a |
comparison
equal
deleted
inserted
replaced
45371:e58e234096de | 45372:77b8588dd84e |
---|---|
25 pathutil, | 25 pathutil, |
26 pycompat, | 26 pycompat, |
27 registrar, | 27 registrar, |
28 repair, | 28 repair, |
29 repoview, | 29 repoview, |
30 requirements, | |
30 sparse, | 31 sparse, |
31 util, | 32 util, |
32 wireprototypes, | 33 wireprototypes, |
33 ) | 34 ) |
34 from mercurial.interfaces import repository | |
35 | 35 |
36 table = {} | 36 table = {} |
37 command = registrar.command(table) | 37 command = registrar.command(table) |
38 | 38 |
39 | 39 |
131 | 131 |
132 | 132 |
133 def pullnarrowcmd(orig, ui, repo, *args, **opts): | 133 def pullnarrowcmd(orig, ui, repo, *args, **opts): |
134 """Wraps pull command to allow modifying narrow spec.""" | 134 """Wraps pull command to allow modifying narrow spec.""" |
135 wrappedextraprepare = util.nullcontextmanager() | 135 wrappedextraprepare = util.nullcontextmanager() |
136 if repository.NARROW_REQUIREMENT in repo.requirements: | 136 if requirements.NARROW_REQUIREMENT in repo.requirements: |
137 | 137 |
138 def pullbundle2extraprepare_widen(orig, pullop, kwargs): | 138 def pullbundle2extraprepare_widen(orig, pullop, kwargs): |
139 orig(pullop, kwargs) | 139 orig(pullop, kwargs) |
140 if opts.get('depth'): | 140 if opts.get('depth'): |
141 kwargs[b'depth'] = opts['depth'] | 141 kwargs[b'depth'] = opts['depth'] |
148 return orig(ui, repo, *args, **opts) | 148 return orig(ui, repo, *args, **opts) |
149 | 149 |
150 | 150 |
151 def archivenarrowcmd(orig, ui, repo, *args, **opts): | 151 def archivenarrowcmd(orig, ui, repo, *args, **opts): |
152 """Wraps archive command to narrow the default includes.""" | 152 """Wraps archive command to narrow the default includes.""" |
153 if repository.NARROW_REQUIREMENT in repo.requirements: | 153 if requirements.NARROW_REQUIREMENT in repo.requirements: |
154 repo_includes, repo_excludes = repo.narrowpats | 154 repo_includes, repo_excludes = repo.narrowpats |
155 includes = set(opts.get('include', [])) | 155 includes = set(opts.get('include', [])) |
156 excludes = set(opts.get('exclude', [])) | 156 excludes = set(opts.get('exclude', [])) |
157 includes, excludes, unused_invalid = narrowspec.restrictpatterns( | 157 includes, excludes, unused_invalid = narrowspec.restrictpatterns( |
158 includes, excludes, repo_includes, repo_excludes | 158 includes, excludes, repo_includes, repo_excludes |
164 return orig(ui, repo, *args, **opts) | 164 return orig(ui, repo, *args, **opts) |
165 | 165 |
166 | 166 |
167 def pullbundle2extraprepare(orig, pullop, kwargs): | 167 def pullbundle2extraprepare(orig, pullop, kwargs): |
168 repo = pullop.repo | 168 repo = pullop.repo |
169 if repository.NARROW_REQUIREMENT not in repo.requirements: | 169 if requirements.NARROW_REQUIREMENT not in repo.requirements: |
170 return orig(pullop, kwargs) | 170 return orig(pullop, kwargs) |
171 | 171 |
172 if wireprototypes.NARROWCAP not in pullop.remote.capabilities(): | 172 if wireprototypes.NARROWCAP not in pullop.remote.capabilities(): |
173 raise error.Abort(_(b"server does not support narrow clones")) | 173 raise error.Abort(_(b"server does not support narrow clones")) |
174 orig(pullop, kwargs) | 174 orig(pullop, kwargs) |
480 --import-rules accepts a path to a file containing rules, allowing you to | 480 --import-rules accepts a path to a file containing rules, allowing you to |
481 add --addinclude, --addexclude rules in bulk. Like the other include and | 481 add --addinclude, --addexclude rules in bulk. Like the other include and |
482 exclude switches, the changes are applied immediately. | 482 exclude switches, the changes are applied immediately. |
483 """ | 483 """ |
484 opts = pycompat.byteskwargs(opts) | 484 opts = pycompat.byteskwargs(opts) |
485 if repository.NARROW_REQUIREMENT not in repo.requirements: | 485 if requirements.NARROW_REQUIREMENT not in repo.requirements: |
486 raise error.Abort( | 486 raise error.Abort( |
487 _( | 487 _( |
488 b'the tracked command is only supported on ' | 488 b'the tracked command is only supported on ' |
489 b'repositories cloned with --narrow' | 489 b'repositories cloned with --narrow' |
490 ) | 490 ) |