hgext/narrow/narrowcommands.py
changeset 36126 8c31187b6717
parent 36124 bc01f48c18cc
child 36138 8fd0a9e2d7e9
equal deleted inserted replaced
36125:844f253dad5e 36126:8c31187b6717
   101         narrowrepo.wraprepo(repo.unfiltered(), opts_narrow)
   101         narrowrepo.wraprepo(repo.unfiltered(), opts_narrow)
   102         if isinstance(repo, repoview.repoview):
   102         if isinstance(repo, repoview.repoview):
   103             repo.__class__.__bases__ = (repo.__class__.__bases__[0],
   103             repo.__class__.__bases__ = (repo.__class__.__bases__[0],
   104                                         repo.unfiltered().__class__)
   104                                         repo.unfiltered().__class__)
   105         if opts_narrow:
   105         if opts_narrow:
   106             repo.requirements.add(narrowrepo.requirement)
   106             repo.requirements.add(narrowrepo.REQUIREMENT)
   107             repo._writerequirements()
   107             repo._writerequirements()
   108 
   108 
   109         return orig(repo, *args, **kwargs)
   109         return orig(repo, *args, **kwargs)
   110 
   110 
   111     wrappedpull = extensions.wrappedfunction(exchange, 'pull', pullnarrow)
   111     wrappedpull = extensions.wrappedfunction(exchange, 'pull', pullnarrow)
   114         return orig(ui, repo, *args, **opts)
   114         return orig(ui, repo, *args, **opts)
   115 
   115 
   116 def pullnarrowcmd(orig, ui, repo, *args, **opts):
   116 def pullnarrowcmd(orig, ui, repo, *args, **opts):
   117     """Wraps pull command to allow modifying narrow spec."""
   117     """Wraps pull command to allow modifying narrow spec."""
   118     wrappedextraprepare = util.nullcontextmanager()
   118     wrappedextraprepare = util.nullcontextmanager()
   119     if narrowrepo.requirement in repo.requirements:
   119     if narrowrepo.REQUIREMENT in repo.requirements:
   120 
   120 
   121         def pullbundle2extraprepare_widen(orig, pullop, kwargs):
   121         def pullbundle2extraprepare_widen(orig, pullop, kwargs):
   122             orig(pullop, kwargs)
   122             orig(pullop, kwargs)
   123             if opts.get('depth'):
   123             if opts.get('depth'):
   124                 kwargs['depth'] = opts['depth']
   124                 kwargs['depth'] = opts['depth']
   128     with wrappedextraprepare:
   128     with wrappedextraprepare:
   129         return orig(ui, repo, *args, **opts)
   129         return orig(ui, repo, *args, **opts)
   130 
   130 
   131 def archivenarrowcmd(orig, ui, repo, *args, **opts):
   131 def archivenarrowcmd(orig, ui, repo, *args, **opts):
   132     """Wraps archive command to narrow the default includes."""
   132     """Wraps archive command to narrow the default includes."""
   133     if narrowrepo.requirement in repo.requirements:
   133     if narrowrepo.REQUIREMENT in repo.requirements:
   134         repo_includes, repo_excludes = repo.narrowpats
   134         repo_includes, repo_excludes = repo.narrowpats
   135         includes = set(opts.get('include', []))
   135         includes = set(opts.get('include', []))
   136         excludes = set(opts.get('exclude', []))
   136         excludes = set(opts.get('exclude', []))
   137         includes, excludes = narrowspec.restrictpatterns(
   137         includes, excludes = narrowspec.restrictpatterns(
   138             includes, excludes, repo_includes, repo_excludes)
   138             includes, excludes, repo_includes, repo_excludes)
   142             opts['exclude'] = excludes
   142             opts['exclude'] = excludes
   143     return orig(ui, repo, *args, **opts)
   143     return orig(ui, repo, *args, **opts)
   144 
   144 
   145 def pullbundle2extraprepare(orig, pullop, kwargs):
   145 def pullbundle2extraprepare(orig, pullop, kwargs):
   146     repo = pullop.repo
   146     repo = pullop.repo
   147     if narrowrepo.requirement not in repo.requirements:
   147     if narrowrepo.REQUIREMENT not in repo.requirements:
   148         return orig(pullop, kwargs)
   148         return orig(pullop, kwargs)
   149 
   149 
   150     if narrowbundle2.NARROWCAP not in pullop.remotebundle2caps:
   150     if narrowbundle2.NARROWCAP not in pullop.remotebundle2caps:
   151         raise error.Abort(_("server doesn't support narrow clones"))
   151         raise error.Abort(_("server doesn't support narrow clones"))
   152     orig(pullop, kwargs)
   152     orig(pullop, kwargs)
   328     If --clear is specified, then all previous includes and excludes are DROPPED
   328     If --clear is specified, then all previous includes and excludes are DROPPED
   329     and replaced by the new ones specified to --addinclude and --addexclude.
   329     and replaced by the new ones specified to --addinclude and --addexclude.
   330     If --clear is specified without any further options, the narrowspec will be
   330     If --clear is specified without any further options, the narrowspec will be
   331     empty and will not match any files.
   331     empty and will not match any files.
   332     """
   332     """
   333     if narrowrepo.requirement not in repo.requirements:
   333     if narrowrepo.REQUIREMENT not in repo.requirements:
   334         ui.warn(_('The narrow command is only supported on respositories cloned'
   334         ui.warn(_('The narrow command is only supported on respositories cloned'
   335                   ' with --narrow.\n'))
   335                   ' with --narrow.\n'))
   336         return 1
   336         return 1
   337 
   337 
   338     # Before supporting, decide whether it "hg tracked --clear" should mean
   338     # Before supporting, decide whether it "hg tracked --clear" should mean