Known subclasses: dulwich.contrib.swift.SwiftRepo, dulwich.repo.MemoryRepo, dulwich.repo.Repo

Base class for a git repository.
Instance Variable object_store Dictionary-like object for accessing the objects
Instance Variable refs Dictionary-like object with the refs in this repository
Method __init__ Open a repository.
Method get_named_file Get a file from the control dir with a specific name.
Method open_index Open the index for this repository.
Method fetch Fetch objects into another repository.
Method fetch_pack_data Fetch the pack data required for a set of revisions.
Method fetch_objects Fetch the missing objects required for a set of revisions.
Method get_graph_walker Retrieve a graph walker.
Method get_refs Get dictionary with all refs.
Method head Return the SHA1 pointed at by HEAD.
Method get_object Retrieve the object with the specified SHA.
Method get_parents Retrieve the parents of a specific commit.
Method get_config Retrieve the config object.
Method get_description Retrieve the description for this repository.
Method set_description Set the description for this repository.
Method get_config_stack Return a config stack for this repository.
Method get_shallow Get the set of shallow commits.
Method update_shallow Update the list of shallow objects.
Method get_peeled Get the peeled value of a ref.
Method get_walker Obtain a walker for this repository.
Method __getitem__ Retrieve a Git object by SHA1 or ref.
Method __contains__ Check if a specific Git object or ref is present.
Method __setitem__ Set a ref.
Method __delitem__ Remove a ref.
Method do_commit Create a new commit.
Method _determine_file_mode Probe the file-system to determine whether permissions can be trusted.
Method _init_files Initialize a default set of named files.
Method _put_named_file Write a file to the control dir with the given name and contents.
Method _get_object Undocumented
Method _get_user_identity Determine the identity to use for new commits.
Method _add_graftpoints Add or modify graftpoints
Method _remove_graftpoints Remove graftpoints
object_store =
Dictionary-like object for accessing the objects
refs =
Dictionary-like object with the refs in this repository
def __init__(self, object_store, refs):

Open a repository.

This shouldn't be called directly, but rather through one of the base classes, such as MemoryRepo or Repo.

Parametersobject_storeObject store to use
refsRefs container to use
def _determine_file_mode(self):
Probe the file-system to determine whether permissions can be trusted.
ReturnsTrue if permissions can be trusted, False otherwise.
def _init_files(self, bare):
Initialize a default set of named files.
def get_named_file(self, path):

Get 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.

ParameterspathThe path to the file, relative to the control dir.
ReturnsAn open file object, or None if the file does not exist.
def _put_named_file(self, path, contents):
Write a file to the control dir with the given name and contents.
ParameterspathThe path to the file, relative to the control dir.
contentsA string to write to the file.
def open_index(self):
Open the index for this repository.
ReturnsThe matching Index
RaisesNoIndexPresentIf no index is present
def fetch(self, target, determine_wants=None, progress=None, depth=None):
Fetch objects into another repository.
ParameterstargetThe target repository
determine_wantsOptional function to determine what refs to fetch.
progressOptional progress function
depthOptional shallow fetch depth
ReturnsThe local refs
def fetch_pack_data(self, determine_wants, graph_walker, progress, get_tagged=None, depth=None):
Fetch the pack data required for a set of revisions.
Parametersdetermine_wantsFunction that takes a dictionary with heads and returns the list of heads to fetch.
graph_walkerObject 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.
progressSimple progress function that will be called with updated progress strings.
get_taggedFunction that returns a dict of pointed-to sha -> tag sha for including tags.
depthShallow fetch depth
Returnscount and iterator over pack data
def fetch_objects(self, determine_wants, graph_walker, progress, get_tagged=None, depth=None):
Fetch the missing objects required for a set of revisions.
Parametersdetermine_wantsFunction that takes a dictionary with heads and returns the list of heads to fetch.
graph_walkerObject 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.
progressSimple progress function that will be called with updated progress strings.
get_taggedFunction that returns a dict of pointed-to sha -> tag sha for including tags.
depthShallow fetch depth
Returnsiterator over objects, with __len__ implemented
def get_graph_walker(self, heads=None):

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.

ParametersheadsRepository heads to use (optional)
ReturnsA graph walker object
def get_refs(self):
Get dictionary with all refs.
ReturnsA dict mapping ref names to SHA1s
def head(self):
Return the SHA1 pointed at by HEAD.
def _get_object(self, sha, cls):
Undocumented
def get_object(self, sha):
Retrieve the object with the specified SHA.
ParametersshaSHA to retrieve
ReturnsA ShaFile object
RaisesKeyErrorwhen the object can not be found
def get_parents(self, sha, commit=None):

Retrieve the parents of a specific commit.

If the specific commit is a graftpoint, the graft parents will be returned instead.

ParametersshaSHA of the commit for which to retrieve the parents
commitOptional commit matching the sha
ReturnsList of parents
def get_config(self):
Retrieve the config object.
ReturnsConfigFile object for the .git/config file.
def get_description(self):
Retrieve the description for this repository.
ReturnsString with the description of the repository as set by the user.
def set_description(self, description):
Set the description for this repository.
ParametersdescriptionText to set as description for this repository.
def get_config_stack(self):

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.

ReturnsConfig instance for this repository
def get_shallow(self):
Get the set of shallow commits.
ReturnsSet of shallow commits.
def update_shallow(self, new_shallow, new_unshallow):
Update the list of shallow objects.
Parametersnew_shallowNewly shallow objects
new_unshallowNewly no longer shallow objects
def get_peeled(self, ref):
Get the peeled value of a ref.
ParametersrefThe refname to peel.
ReturnsThe fully-peeled SHA1 of a tag object, after peeling all intermediate tags; if the original ref does not point to a tag, this will equal the original SHA1.
def get_walker(self, *args, include=None, **kwargs):
Obtain a walker for this repository.
ParametersincludeIterable of SHAs of commits to include along with their ancestors. Defaults to [HEAD]
excludeIterable of SHAs of commits to exclude along with their ancestors, overriding includes.
orderORDER_* constant specifying the order of results. Anything other than ORDER_DATE may result in O(n) memory usage.
reverseIf True, reverse the order of output, requiring O(n) memory.
max_entriesThe maximum number of entries to yield, or None for no limit.
pathsIterable of file or subtree paths to show entries for.
rename_detectordiff.RenameDetector object for detecting renames.
followIf True, follow path across renames/copies. Forces a default rename_detector.
sinceTimestamp to list commits after.
untilTimestamp to list commits before.
queue_clsA class to use for a queue of commits, supporting the iterator protocol. The constructor takes a single argument, the Walker.
ReturnsA Walker object
def __getitem__(self, name):
Retrieve a Git object by SHA1 or ref.
ParametersnameA Git object SHA1 or a ref name
ReturnsA ShaFile object, such as a Commit or Blob
RaisesKeyErrorwhen the specified ref or object does not exist
def __contains__(self, name):
Check if a specific Git object or ref is present.
ParametersnameGit object SHA1 or ref name
def __setitem__(self, name, value):
Set a ref.
Parametersnameref name
valueRef value - either a ShaFile object, or a hex sha
def __delitem__(self, name):
Remove a ref.
ParametersnameName of the ref to remove
def _get_user_identity(self, config):
Determine the identity to use for new commits.
def _add_graftpoints(self, updated_graftpoints):
Add or modify graftpoints
Parametersupdated_graftpointsDict of commit shas to list of parent shas
def _remove_graftpoints(self, to_remove=[]):
Remove graftpoints
Parametersto_removeList of commit shas
def do_commit(self, message=None, committer=None, author=None, commit_timestamp=None, commit_timezone=None, author_timestamp=None, author_timezone=None, tree=None, encoding=None, ref='HEAD', merge_heads=None):
Create a new commit.
ParametersmessageCommit message
committerCommitter fullname
authorAuthor fullname (defaults to committer)
commit_timestampCommit timestamp (defaults to now)
commit_timezoneCommit timestamp timezone (defaults to GMT)
author_timestampAuthor timestamp (defaults to commit timestamp)
author_timezoneAuthor timestamp timezone (defaults to commit timestamp timezone)
treeSHA1 of the tree root to use (if not specified the current index will be committed).
encodingEncoding
refOptional ref to commit to (defaults to current branch)
merge_headsMerge heads (defaults to .git/MERGE_HEADS)
ReturnsNew commit SHA1
API Documentation for Dulwich, generated by pydoctor at 2018-11-17 19:05:54.