def archivenarrowcmd(orig, ui, repo, *args, **opts): """Wraps archive command to narrow the default includes.""" if repository.NARROW_REQUIREMENT in repo.requirements: repo_includes, repo_excludes = repo.narrowpats includes = set(opts.get(r'include', [])) excludes = set(opts.get(r'exclude', [])) includes, excludes, unused_invalid = narrowspec.restrictpatterns( includes, excludes, repo_includes, repo_excludes) if includes: opts[r'include'] = includes if excludes: opts[r'exclude'] = excludes return orig(ui, repo, *args, **opts)
def applyacl_narrow(repo, kwargs): ui = repo.ui username = ui.shortuser(ui.environ.get('REMOTE_USER') or ui.username()) user_includes = ui.configlist( _NARROWACL_SECTION, username + '.includes', ui.configlist(_NARROWACL_SECTION, 'default.includes')) user_excludes = ui.configlist( _NARROWACL_SECTION, username + '.excludes', ui.configlist(_NARROWACL_SECTION, 'default.excludes')) if not user_includes: raise error.Abort( _("{} configuration for user {} is empty").format( _NARROWACL_SECTION, username)) user_includes = [ 'path:.' if p == '*' else 'path:' + p for p in user_includes ] user_excludes = [ 'path:.' if p == '*' else 'path:' + p for p in user_excludes ] req_includes = set(kwargs.get(r'includepats', [])) req_excludes = set(kwargs.get(r'excludepats', [])) req_includes, req_excludes, invalid_includes = narrowspec.restrictpatterns( req_includes, req_excludes, user_includes, user_excludes) if invalid_includes: raise error.Abort( _("The following includes are not accessible for {}: {}").format( username, invalid_includes)) new_args = {} new_args.update(kwargs) new_args['includepats'] = req_includes if req_excludes: new_args['excludepats'] = req_excludes return new_args