Repository navigation
Closes #1472: Implement in-memory config backend for config overrides in context manager - #1473
beamerblvd wants to merge 13 commits into
Conversation
`Config` now has two subclasses: `DefaultConfig` and `RepositoryConfig`: - `DefaultConfig` represents the total sum config of program, system, XDG, and global (user) configurations as obtained from `git_config_open_default`. Even if none of those files exist, one can still create an empty `DefaultConfig`. - `RepositoryConfig` represents repository configurations and is the type now returned by `Repository.config` and `Repository.config_snapshot`. - `RepositoryConfig` contains the ability to enter/exit as a context manager, enabling an in-memory config backend with level `GIT_CONFIG_LEVEL_APP`. This allows users to add temporary, in-memory overrides to the repository config that affect repository operations without persisting permanently to the repository's config file.
|
Thanks @beamerblvd This PR is fairly big, would you be willing to split it into smaller PRs? For example:
That would make each piece much easier to review and merge incrementally. |
I have moved the first subset of changes to #1499. I'll do the next two after that one merges. |
I have moved the second subset of changes to #1501. I'll do the last one after that one merges. |
…errides in context manager- libgit2#1473 This implements libgit2#1472. When `DefaultConfig` and `RepositoryConfig` are constructed, they now construct an in-memory config backend with level `ConfigLevel.APP` that, initially, is unused. When instances of these classes are entered as a context manager, that in-memory backend is given sole write priority. When instances of these classes are exited as a context manager, that in-memory backend in cleared, and the default write priority is restored.
I have moved the final subset of changes to #1503, so I will now close this pull request. |
This implements #1472. It makes several changes to configs in pygit2, and includes substantial documentation improvements to explain the new classes and methods:
Confighas several internal changes, but externally, its use and behavior is the same.DefaultConfigis a new class that extendsConfigand wrapsgit_config_open_default, which previously was not accessible in pygit2.RepositoryConfigis a new class that extendsConfigand wrapsgit_repository_config/git_repository_config_snapshot(previously these were wrapped directly byConfig).DefaultConfigandRepositoryConfigare constructed, they construct an in-memory config backend with levelConfigLevel.APPthat, initially, is unused. When instances of these classes are entered as a context manager, that in-memory backend is given sole write priority. When instances of these classes are exited as a context manager, that in-memory backend in cleared, and the default write priority is restored.ConfigEntryhas been refactored.