def _config_parser(self, read_only): if read_only: parser = self.repo.config_reader() else: parser = self.repo.config_writer() # END handle parser instance return SectionConstraint(parser, 'branch "%s"' % self.name)
def _set_cache_(self, attr: str) -> None: if attr == "_config_reader": # NOTE: This is cached as __getattr__ is overridden to return remote config values implicitly, such as # in print(r.pushurl) self._config_reader = SectionConstraint( self.repo.config_reader("repository"), self._config_section_name()) else: super(Remote, self)._set_cache_(attr)
def config_writer(self) -> SectionConstraint: """ :return: GitConfigParser compatible object able to write options for this remote. :note: You can only own one writer at a time - delete it to release the configuration file and make it usable by others. To assure consistent results, you should only query options through the writer. Once you are done writing, you are free to use the config reader once again.""" writer = self.repo.config_writer() # clear our cache to assure we re-read the possibly changed configuration self._clear_cache() return SectionConstraint(writer, self._config_section_name())
def _config_parser_constrained(self, read_only): """:return: Config Parser constrained to our submodule in read or write mode""" parser = self._config_parser(self.repo, self._parent_commit, read_only) parser.set_submodule(self) return SectionConstraint(parser, sm_section(self.name))