Details
Details
- Reviewers
indygreg - Group Reviewers
hg-reviewers - Commits
- rHG8c31187b6717: narrow: mark requirement as a constant
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
indygreg |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/narrow/__init__.py (4 lines) | |||
M | hgext/narrow/narrowbundle2.py (4 lines) | |||
M | hgext/narrow/narrowchangegroup.py (2 lines) | |||
M | hgext/narrow/narrowcommands.py (10 lines) | |||
M | hgext/narrow/narrowrepo.py (6 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 |
configitem('experimental', 'narrowservebrokenellipses', | configitem('experimental', 'narrowservebrokenellipses', | ||||
default=False, | default=False, | ||||
alias=[('narrow', 'serveellipses')], | alias=[('narrow', 'serveellipses')], | ||||
) | ) | ||||
# Export the commands table for Mercurial to see. | # Export the commands table for Mercurial to see. | ||||
cmdtable = narrowcommands.table | cmdtable = narrowcommands.table | ||||
localrepo.localrepository._basesupported.add(narrowrepo.requirement) | localrepo.localrepository._basesupported.add(narrowrepo.REQUIREMENT) | ||||
def uisetup(ui): | def uisetup(ui): | ||||
"""Wraps user-facing mercurial commands with narrow-aware versions.""" | """Wraps user-facing mercurial commands with narrow-aware versions.""" | ||||
narrowrevlog.setup() | narrowrevlog.setup() | ||||
narrowbundle2.setup() | narrowbundle2.setup() | ||||
narrowmerge.setup() | narrowmerge.setup() | ||||
narrowtemplates.setup() | narrowtemplates.setup() | ||||
narrowcommands.setup() | narrowcommands.setup() | ||||
narrowchangegroup.setup() | narrowchangegroup.setup() | ||||
narrowwirepeer.uisetup() | narrowwirepeer.uisetup() | ||||
def reposetup(ui, repo): | def reposetup(ui, repo): | ||||
"""Wraps local repositories with narrow repo support.""" | """Wraps local repositories with narrow repo support.""" | ||||
if not isinstance(repo, localrepo.localrepository): | if not isinstance(repo, localrepo.localrepository): | ||||
return | return | ||||
if narrowrepo.requirement in repo.requirements: | if narrowrepo.REQUIREMENT in repo.requirements: | ||||
narrowrepo.wraprepo(repo, True) | narrowrepo.wraprepo(repo, True) | ||||
narrowcopies.setup(repo) | narrowcopies.setup(repo) | ||||
narrowdirstate.setup(repo) | narrowdirstate.setup(repo) | ||||
narrowpatch.setup(repo) | narrowpatch.setup(repo) | ||||
narrowwirepeer.reposetup(repo) | narrowwirepeer.reposetup(repo) | ||||
def _verifierinit(orig, self, repo, matcher=None): | def _verifierinit(orig, self, repo, matcher=None): | ||||
# The verifier's matcher argument was desgined for narrowhg, so it should | # The verifier's matcher argument was desgined for narrowhg, so it should |
new_args['excludepats'] = req_excludes | new_args['excludepats'] = req_excludes | ||||
return new_args | return new_args | ||||
@bundle2.parthandler(_SPECPART, (_SPECPART_INCLUDE, _SPECPART_EXCLUDE)) | @bundle2.parthandler(_SPECPART, (_SPECPART_INCLUDE, _SPECPART_EXCLUDE)) | ||||
def _handlechangespec_2(op, inpart): | def _handlechangespec_2(op, inpart): | ||||
includepats = set(inpart.params.get(_SPECPART_INCLUDE, '').splitlines()) | includepats = set(inpart.params.get(_SPECPART_INCLUDE, '').splitlines()) | ||||
excludepats = set(inpart.params.get(_SPECPART_EXCLUDE, '').splitlines()) | excludepats = set(inpart.params.get(_SPECPART_EXCLUDE, '').splitlines()) | ||||
narrowspec.save(op.repo, includepats, excludepats) | narrowspec.save(op.repo, includepats, excludepats) | ||||
if not narrowrepo.requirement in op.repo.requirements: | if not narrowrepo.REQUIREMENT in op.repo.requirements: | ||||
op.repo.requirements.add(narrowrepo.requirement) | op.repo.requirements.add(narrowrepo.REQUIREMENT) | ||||
op.repo._writerequirements() | op.repo._writerequirements() | ||||
op.repo.invalidate(clearfilecache=True) | op.repo.invalidate(clearfilecache=True) | ||||
@bundle2.parthandler(_CHANGESPECPART) | @bundle2.parthandler(_CHANGESPECPART) | ||||
def _handlechangespec(op, inpart): | def _handlechangespec(op, inpart): | ||||
repo = op.repo | repo = op.repo | ||||
cl = repo.changelog | cl = repo.changelog | ||||
narrowrepo, | narrowrepo, | ||||
narrowrevlog, | narrowrevlog, | ||||
) | ) | ||||
def setup(): | def setup(): | ||||
def supportedoutgoingversions(orig, repo): | def supportedoutgoingversions(orig, repo): | ||||
versions = orig(repo) | versions = orig(repo) | ||||
if narrowrepo.requirement in repo.requirements: | if narrowrepo.REQUIREMENT in repo.requirements: | ||||
versions.discard('01') | versions.discard('01') | ||||
versions.discard('02') | versions.discard('02') | ||||
return versions | return versions | ||||
extensions.wrapfunction(changegroup, 'supportedoutgoingversions', | extensions.wrapfunction(changegroup, 'supportedoutgoingversions', | ||||
supportedoutgoingversions) | supportedoutgoingversions) | ||||
def prune(orig, self, revlog, missing, commonrevs): | def prune(orig, self, revlog, missing, commonrevs): |
'_pullbundle2extraprepare', pullbundle2extraprepare_widen) | '_pullbundle2extraprepare', pullbundle2extraprepare_widen) | ||||
def pullnarrow(orig, repo, *args, **kwargs): | def pullnarrow(orig, repo, *args, **kwargs): | ||||
narrowrepo.wraprepo(repo.unfiltered(), opts_narrow) | narrowrepo.wraprepo(repo.unfiltered(), opts_narrow) | ||||
if isinstance(repo, repoview.repoview): | if isinstance(repo, repoview.repoview): | ||||
repo.__class__.__bases__ = (repo.__class__.__bases__[0], | repo.__class__.__bases__ = (repo.__class__.__bases__[0], | ||||
repo.unfiltered().__class__) | repo.unfiltered().__class__) | ||||
if opts_narrow: | if opts_narrow: | ||||
repo.requirements.add(narrowrepo.requirement) | repo.requirements.add(narrowrepo.REQUIREMENT) | ||||
repo._writerequirements() | repo._writerequirements() | ||||
return orig(repo, *args, **kwargs) | return orig(repo, *args, **kwargs) | ||||
wrappedpull = extensions.wrappedfunction(exchange, 'pull', pullnarrow) | wrappedpull = extensions.wrappedfunction(exchange, 'pull', pullnarrow) | ||||
with wrappedextraprepare, wrappedpull: | with wrappedextraprepare, wrappedpull: | ||||
return orig(ui, repo, *args, **opts) | return orig(ui, repo, *args, **opts) | ||||
def pullnarrowcmd(orig, ui, repo, *args, **opts): | def pullnarrowcmd(orig, ui, repo, *args, **opts): | ||||
"""Wraps pull command to allow modifying narrow spec.""" | """Wraps pull command to allow modifying narrow spec.""" | ||||
wrappedextraprepare = util.nullcontextmanager() | wrappedextraprepare = util.nullcontextmanager() | ||||
if narrowrepo.requirement in repo.requirements: | if narrowrepo.REQUIREMENT in repo.requirements: | ||||
def pullbundle2extraprepare_widen(orig, pullop, kwargs): | def pullbundle2extraprepare_widen(orig, pullop, kwargs): | ||||
orig(pullop, kwargs) | orig(pullop, kwargs) | ||||
if opts.get('depth'): | if opts.get('depth'): | ||||
kwargs['depth'] = opts['depth'] | kwargs['depth'] = opts['depth'] | ||||
wrappedextraprepare = extensions.wrappedfunction(exchange, | wrappedextraprepare = extensions.wrappedfunction(exchange, | ||||
'_pullbundle2extraprepare', pullbundle2extraprepare_widen) | '_pullbundle2extraprepare', pullbundle2extraprepare_widen) | ||||
with wrappedextraprepare: | with wrappedextraprepare: | ||||
return orig(ui, repo, *args, **opts) | return orig(ui, repo, *args, **opts) | ||||
def archivenarrowcmd(orig, ui, repo, *args, **opts): | def archivenarrowcmd(orig, ui, repo, *args, **opts): | ||||
"""Wraps archive command to narrow the default includes.""" | """Wraps archive command to narrow the default includes.""" | ||||
if narrowrepo.requirement in repo.requirements: | if narrowrepo.REQUIREMENT in repo.requirements: | ||||
repo_includes, repo_excludes = repo.narrowpats | repo_includes, repo_excludes = repo.narrowpats | ||||
includes = set(opts.get('include', [])) | includes = set(opts.get('include', [])) | ||||
excludes = set(opts.get('exclude', [])) | excludes = set(opts.get('exclude', [])) | ||||
includes, excludes = narrowspec.restrictpatterns( | includes, excludes = narrowspec.restrictpatterns( | ||||
includes, excludes, repo_includes, repo_excludes) | includes, excludes, repo_includes, repo_excludes) | ||||
if includes: | if includes: | ||||
opts['include'] = includes | opts['include'] = includes | ||||
if excludes: | if excludes: | ||||
opts['exclude'] = excludes | opts['exclude'] = excludes | ||||
return orig(ui, repo, *args, **opts) | return orig(ui, repo, *args, **opts) | ||||
def pullbundle2extraprepare(orig, pullop, kwargs): | def pullbundle2extraprepare(orig, pullop, kwargs): | ||||
repo = pullop.repo | repo = pullop.repo | ||||
if narrowrepo.requirement not in repo.requirements: | if narrowrepo.REQUIREMENT not in repo.requirements: | ||||
return orig(pullop, kwargs) | return orig(pullop, kwargs) | ||||
if narrowbundle2.NARROWCAP not in pullop.remotebundle2caps: | if narrowbundle2.NARROWCAP not in pullop.remotebundle2caps: | ||||
raise error.Abort(_("server doesn't support narrow clones")) | raise error.Abort(_("server doesn't support narrow clones")) | ||||
orig(pullop, kwargs) | orig(pullop, kwargs) | ||||
kwargs['narrow'] = True | kwargs['narrow'] = True | ||||
include, exclude = repo.narrowpats | include, exclude = repo.narrowpats | ||||
kwargs['oldincludepats'] = include | kwargs['oldincludepats'] = include | ||||
The options allow you to add or remove included and excluded expressions. | The options allow you to add or remove included and excluded expressions. | ||||
If --clear is specified, then all previous includes and excludes are DROPPED | If --clear is specified, then all previous includes and excludes are DROPPED | ||||
and replaced by the new ones specified to --addinclude and --addexclude. | and replaced by the new ones specified to --addinclude and --addexclude. | ||||
If --clear is specified without any further options, the narrowspec will be | If --clear is specified without any further options, the narrowspec will be | ||||
empty and will not match any files. | empty and will not match any files. | ||||
""" | """ | ||||
if narrowrepo.requirement not in repo.requirements: | if narrowrepo.REQUIREMENT not in repo.requirements: | ||||
ui.warn(_('The narrow command is only supported on respositories cloned' | ui.warn(_('The narrow command is only supported on respositories cloned' | ||||
' with --narrow.\n')) | ' with --narrow.\n')) | ||||
return 1 | return 1 | ||||
# Before supporting, decide whether it "hg tracked --clear" should mean | # Before supporting, decide whether it "hg tracked --clear" should mean | ||||
# tracking no paths or all paths. | # tracking no paths or all paths. | ||||
if opts['clear']: | if opts['clear']: | ||||
ui.warn(_('The --clear option is not yet supported.\n')) | ui.warn(_('The --clear option is not yet supported.\n')) |
share, | share, | ||||
) | ) | ||||
from . import ( | from . import ( | ||||
narrowrevlog, | narrowrevlog, | ||||
narrowspec, | narrowspec, | ||||
) | ) | ||||
requirement = 'narrowhg' | REQUIREMENT = 'narrowhg' | ||||
def wrappostshare(orig, sourcerepo, destrepo, **kwargs): | def wrappostshare(orig, sourcerepo, destrepo, **kwargs): | ||||
orig(sourcerepo, destrepo, **kwargs) | orig(sourcerepo, destrepo, **kwargs) | ||||
if requirement in sourcerepo.requirements: | if REQUIREMENT in sourcerepo.requirements: | ||||
with destrepo.wlock(): | with destrepo.wlock(): | ||||
with destrepo.vfs('shared', 'a') as fp: | with destrepo.vfs('shared', 'a') as fp: | ||||
fp.write(narrowspec.FILENAME + '\n') | fp.write(narrowspec.FILENAME + '\n') | ||||
def unsharenarrowspec(orig, ui, repo, repopath): | def unsharenarrowspec(orig, ui, repo, repopath): | ||||
if (requirement in repo.requirements | if (REQUIREMENT in repo.requirements | ||||
and repo.path == repopath and repo.shared()): | and repo.path == repopath and repo.shared()): | ||||
srcrepo = share._getsrcrepo(repo) | srcrepo = share._getsrcrepo(repo) | ||||
with srcrepo.vfs(narrowspec.FILENAME) as f: | with srcrepo.vfs(narrowspec.FILENAME) as f: | ||||
spec = f.read() | spec = f.read() | ||||
with repo.vfs(narrowspec.FILENAME, 'w') as f: | with repo.vfs(narrowspec.FILENAME, 'w') as f: | ||||
f.write(spec) | f.write(spec) | ||||
return orig(ui, repo, repopath) | return orig(ui, repo, repopath) | ||||