class BaseRepo:
Known subclasses: dulwich.repo.MemoryRepo, dulwich.repo.Repo
Constructor: BaseRepo(object_store, refs, object_format)
Base class for a git repository.
This base class is meant to be used for Repository implementations that e.g. work on top of a different transport than a standard filesystem path.
| Method | __contains__ |
Check if a specific Git object or ref is present. |
| Method | __delitem__ |
Remove a ref. |
| Method | __getitem__ |
Retrieve a Git object by SHA1 or ref. |
| Method | __init__ |
Open a repository. |
| Method | __setitem__ |
Set a ref. |
| Method | fetch |
Fetch objects into another repository. |
| Method | fetch |
Fetch the pack data required for a set of revisions. |
| Method | find |
Fetch the missing objects required for a set of revisions. |
| Method | generate |
Generate pack data objects for a set of wants/haves. |
| Method | get |
Return a BlobNormalizer object for checkin/checkout operations. |
| Method | get |
Retrieve the config object. |
| Method | get |
Return a config stack for this repository. |
| Method | get |
Retrieve the description for this repository. |
| Method | get |
Read gitattributes for the repository. |
| Method | get |
Retrieve a graph walker. |
| Method | get |
Get a file from the control dir with a specific name. |
| Method | get |
Retrieve the object with the specified SHA. |
| Method | get |
Retrieve the parents of a specific commit. |
| Method | get |
Get the peeled value of a ref. |
| Method | get |
Get the appropriate rebase state manager for this repository. |
| Method | get |
Get dictionary with all refs. |
| Method | get |
Get the set of shallow commits. |
| Method | get |
Obtain a walker for this repository. |
| Method | get |
Get the working tree for this repository. |
| Method | get |
Retrieve the worktree config object. |
| Method | head |
Return the SHA1 pointed at by HEAD. |
| Method | open |
Open the index for this repository. |
| Method | parents |
Get a parents provider for this repository. |
| Method | set |
Set the description for this repository. |
| Method | update |
Update the list of shallow objects. |
| Instance Variable | hooks |
Undocumented |
| Instance Variable | object |
Undocumented |
| Instance Variable | object |
Dictionary-like object for accessing the objects |
| Instance Variable | refs |
Dictionary-like object with the refs in this repository |
| Property | notes |
Access notes functionality for this repository. |
| Method | _add |
Add or modify graftpoints. |
| Method | _change |
Change the object format of this repository. |
| Method | _del |
Delete a file in the control directory with the given name. |
| Method | _determine |
Probe the file-system to determine whether permissions can be trusted. |
| Method | _determine |
Probe the filesystem to determine whether symlinks can be created. |
| Method | _get |
Undocumented |
| Method | _get |
Determine the identity to use for new commits. |
| Method | _init |
Initialize repository configuration. |
| Method | _init |
Initialize a default set of named files. |
| Method | _put |
Write a file to the control dir with the given name and contents. |
| Method | _read |
Undocumented |
| Method | _remove |
Remove graftpoints. |
| Instance Variable | _graftpoints |
Undocumented |
PackCapableObjectStore, refs: RefsContainer, object_format: ObjectFormat | None = None):
¶
dulwich.repo.MemoryRepo, dulwich.repo.RepoOpen a repository.
This shouldn't be called directly, but rather through one of the base classes, such as MemoryRepo or Repo.
| Parameters | |
objectPackCapableObjectStore | Object store to use |
refs:RefsContainer | Refs container to use |
objectObjectFormat | None | Hash algorithm to use (if None, will use object_store's format) |
BaseRepo, determine_wants: Callable[ [ Mapping[ Ref, ObjectID], (int | None)], list[ ObjectID]] | None = None, progress: Callable[ ..., None] | None = None, depth: int | None = None) -> dict[ Ref, ObjectID]:
¶
Fetch objects into another repository.
Returns: The local refs
| Parameters | |
target:BaseRepo | The target repository |
determineCallable[ | Optional function to determine what refs to fetch. |
progress:Callable[ | Optional progress function |
depth:int | None | Optional shallow fetch depth |
| Returns | |
dict[ | Undocumented |
Callable[ [ Mapping[ Ref, ObjectID], (int | None)], list[ ObjectID]], graph_walker: GraphWalker, progress: Callable[ [ bytes], None] | None, *, get_tagged: Callable[ [], dict[ ObjectID, ObjectID]] | None = None, depth: int | None = None) -> tuple[ int, Iterator[ UnpackedObject]]:
¶
Fetch the pack data required for a set of revisions.
Returns: count and iterator over pack data
| Parameters | |
determineCallable[ | Function that takes a dictionary with heads and returns the list of heads to fetch. |
graphGraphWalker | Object that can iterate over the list of revisions to fetch and has an "ack" method that will be called to acknowledge that a revision is present. |
progress:Callable[ | Simple progress function that will be called with updated progress strings. |
getCallable[ | Function that returns a dict of pointed-to sha -> tag sha for including tags. |
depth:int | None | Shallow fetch depth |
| Returns | |
tuple[ | Undocumented |
Callable[ [ Mapping[ Ref, ObjectID], (int | None)], list[ ObjectID]], graph_walker: GraphWalker, progress: Callable[ [ bytes], None] | None, *, get_tagged: Callable[ [], dict[ ObjectID, ObjectID]] | None = None, depth: int | None = None) -> MissingObjectFinder | None:
¶
Fetch the missing objects required for a set of revisions.
Returns: iterator over objects, with __len__ implemented
| Parameters | |
determineCallable[ | Function that takes a dictionary with heads and returns the list of heads to fetch. |
graphGraphWalker | Object that can iterate over the list of revisions to fetch and has an "ack" method that will be called to acknowledge that a revision is present. |
progress:Callable[ | Simple progress function that will be called with updated progress strings. |
getCallable[ | Function that returns a dict of pointed-to sha -> tag sha for including tags. |
depth:int | None | Shallow fetch depth |
| Returns | |
MissingObjectFinder | None | Undocumented |
set[ ObjectID], want: set[ ObjectID], *, shallow: set[ ObjectID] | None = None, progress: Callable[ [ str], None] | None = None, ofs_delta: bool | None = None) -> tuple[ int, Iterator[ UnpackedObject]]:
¶
Generate pack data objects for a set of wants/haves.
| Parameters | |
have:set[ | List of SHA1s of objects that should not be sent |
want:set[ | List of SHA1s of objects that should be sent |
shallow:set[ | Set of shallow commit SHA1s to skip (defaults to repo's shallow commits) |
progress:Callable[ | Optional progress reporting method |
ofsbool | None | Whether OFS deltas can be included |
| Returns | |
tuple[ | Undocumented |
dulwich.repo.MemoryRepo, dulwich.repo.RepoReturn a BlobNormalizer object for checkin/checkout operations.
Returns: BlobNormalizer instance
dulwich.repo.MemoryRepo, dulwich.repo.RepoRetrieve the config object.
Returns: ConfigFile object for the .git/config file.
Return a config stack for this repository.
This stack accesses the configuration for both this repository itself (.git/config) and the global configuration, which usually lives in ~/.gitconfig.
Returns: Config instance for this repository
dulwich.repo.MemoryRepo, dulwich.repo.RepoRetrieve the description for this repository.
- Returns: Bytes with the description of the repository
- as set by the user.
dulwich.repo.MemoryRepo, dulwich.repo.RepoRead gitattributes for the repository.
| Parameters | |
tree:bytes | None | Tree SHA to read .gitattributes from (defaults to HEAD) |
| Returns | |
GitAttributes | GitAttributes object that can be used to match paths |
Retrieve a graph walker.
A graph walker is used by a remote repository (or proxy) to find out which objects are present in this repository.
Returns: A graph walker object
| Parameters | |
heads:list[ | Repository heads to use (optional) |
| Returns | |
ObjectStoreGraphWalker | Undocumented |
dulwich.repo.MemoryRepo, dulwich.repo.RepoGet a file from the control dir with a specific name.
Although the filename should be interpreted as a filename relative to the control dir in a disk-based Repo, the object returned need not be pointing to a file in that location.
Returns: An open file object, or None if the file does not exist.
| Parameters | |
path:str | The path to the file, relative to the control dir. |
| Returns | |
BinaryIO | None | Undocumented |
Retrieve the object with the specified SHA.
Returns: A ShaFile object
| Parameters | |
sha:ObjectID | RawObjectID | SHA to retrieve |
| Returns | |
ShaFile | Undocumented |
| Raises | |
KeyError | when the object can not be found |
Retrieve the parents of a specific commit.
If the specific commit is a graftpoint, the graft parents will be returned instead.
Returns: List of parents
| Parameters | |
sha:ObjectID | SHA of the commit for which to retrieve the parents |
commit:Commit | None | Optional commit matching the sha |
| Returns | |
list[ | Undocumented |
dulwich.repo.MemoryRepo, dulwich.repo.RepoGet the appropriate rebase state manager for this repository.
Returns: RebaseStateManager instance
Sequence[ ObjectID] | None = None, exclude: Sequence[ ObjectID] | None = None, order: str = 'date', reverse: bool = False, max_entries: int | None = None, paths: Sequence[ bytes] | None = None, rename_detector: RenameDetector | None = None, follow: bool = False, since: int | None = None, until: int | None = None, queue_cls: type | None = None) -> Walker:
¶
Obtain a walker for this repository.
Returns: A Walker object
| Parameters | |
include:Sequence[ | Iterable of SHAs of commits to include along with their ancestors. Defaults to [HEAD] |
exclude:Sequence[ | Iterable of SHAs of commits to exclude along with their ancestors, overriding includes. |
order:str | ORDER_* constant specifying the order of results. Anything other than ORDER_DATE may result in O(n) memory usage. |
reverse:bool | If True, reverse the order of output, requiring O(n) memory. |
maxint | None | The maximum number of entries to yield, or None for no limit. |
paths:Sequence[ | Iterable of file or subtree paths to show entries for. |
renameRenameDetector | None | diff.RenameDetector object for detecting renames. |
follow:bool | If True, follow path across renames/copies. Forces a default rename_detector. |
since:int | None | Timestamp to list commits after. |
until:int | None | Timestamp to list commits before. |
queuetype | None | A class to use for a queue of commits, supporting the iterator protocol. The constructor takes a single argument, the Walker. |
| Returns | |
Walker | Undocumented |
dulwich.repo.RepoGet the working tree for this repository.
| Returns | |
WorkTree | WorkTree instance for performing working tree operations |
| Raises | |
NotImplementedError | If the repository doesn't support working trees |
dulwich.repo.MemoryRepo, dulwich.repo.RepoOpen the index for this repository.
Returns: The matching Index
| Raises | |
NoIndexPresent | If no index is present |
Get a parents provider for this repository.
| Returns | |
ParentsProvider | ParentsProvider instance configured with grafts and shallows |
dulwich.repo.MemoryRepo, dulwich.repo.RepoSet the description for this repository.
| Parameters | |
description:bytes | Text to set as description for this repository. |
Change the object format of this repository.
This can only be done if the object store is empty (no objects written yet).
| Parameters | |
objectstr | Name of the new object format (e.g., "sha1", "sha256") |
| Raises | |
AssertionError | If the object store is not empty |
dulwich.repo.MemoryRepo, dulwich.repo.RepoDelete a file in the control directory with the given name.
dulwich.repo.MemoryRepo, dulwich.repo.RepoProbe the file-system to determine whether permissions can be trusted.
Returns: True if permissions can be trusted, False otherwise.
dulwich.repo.MemoryRepo, dulwich.repo.RepoProbe the filesystem to determine whether symlinks can be created.
Returns: True if symlinks can be created, False otherwise.
dulwich.repo.MemoryRepoInitialize repository configuration.
This method can be overridden by subclasses to handle config initialization.
| Parameters | |
config:ConfigFile | The ConfigFile object that was just created |
bool, symlinks: bool | None = None, format: int | None = None, shared_repository: str | bool | None = None, object_format: str | None = None):
¶
Initialize a default set of named files.