class documentation

Manages the rerere cache in .git/rr-cache/.

Class Method from_repo Create a RerereCache from a repository.
Method __init__ Initialize RerereCache.
Method apply_resolution Apply a recorded resolution to current conflict content.
Method clear Clear all recorded conflicts and resolutions.
Method diff Get the preimage and postimage for a conflict.
Method forget Forget a recorded conflict and its resolution.
Method gc Garbage collect old conflict resolutions.
Method get_resolution Get the recorded resolution for a conflict.
Method has_resolution Check if a resolution exists for a conflict.
Method record_conflict Record a conflict in the rerere cache.
Method record_resolution Record a resolution for a previously recorded conflict.
Method status Get the status of all conflicts in the cache.
Instance Variable rr_cache_dir Undocumented
Method _ensure_cache_dir Ensure the rr-cache directory exists.
Method _get_conflict_dir Get the directory path for a specific conflict.
Method _get_postimage_path Get the path to the postimage file for a conflict.
Method _get_preimage_path Get the path to the preimage file for a conflict.
def from_repo(cls, repo: Repo) -> RerereCache:

Create a RerereCache from a repository.

Parameters
repo:RepoA Dulwich repository object
Returns
RerereCacheRerereCache instance for the repository
def __init__(self, rr_cache_dir: bytes | str):

Initialize RerereCache.

Parameters
rr_cache_dir:bytes | strPath to the .git/rr-cache directory
def apply_resolution(self, conflict_id: str, content: bytes) -> bytes | None:

Apply a recorded resolution to current conflict content.

Parameters
conflict_id:strThe conflict ID
content:bytesCurrent file content with conflict markers
Returns
bytes | NoneResolved content, or None if resolution couldn't be applied
def clear(self):

Clear all recorded conflicts and resolutions.

def diff(self, conflict_id: str) -> tuple[bytes | None, bytes | None]:

Get the preimage and postimage for a conflict.

Parameters
conflict_id:strThe conflict ID
Returns
tuple[bytes | None, bytes | None]Tuple of (preimage, postimage), either may be None
def forget(self, conflict_id: str):

Forget a recorded conflict and its resolution.

Parameters
conflict_id:strThe conflict ID to forget
def gc(self, max_age_days: int = 60):

Garbage collect old conflict resolutions.

Parameters
max_age_days:intMaximum age in days for keeping resolutions
def get_resolution(self, conflict_id: str) -> bytes | None:

Get the recorded resolution for a conflict.

Parameters
conflict_id:strThe conflict ID
Returns
bytes | NoneThe resolution content, or None if not found
def has_resolution(self, conflict_id: str) -> bool:

Check if a resolution exists for a conflict.

Parameters
conflict_id:strThe conflict ID
Returns
boolTrue if a postimage exists for this conflict
def record_conflict(self, path: bytes, content: bytes) -> str | None:

Record a conflict in the rerere cache.

Parameters
path:bytesPath to the conflicted file
content:bytesFile content with conflict markers
Returns
str | NoneThe conflict ID if recorded, None if no conflict markers found
def record_resolution(self, conflict_id: str, content: bytes):

Record a resolution for a previously recorded conflict.

Parameters
conflict_id:strThe conflict ID to record resolution for
content:bytesResolved file content (without conflict markers)
def status(self) -> list[tuple[str, bool]]:

Get the status of all conflicts in the cache.

Returns
list[tuple[str, bool]]List of tuples (conflict_id, has_resolution)
rr_cache_dir =

Undocumented

def _ensure_cache_dir(self):

Ensure the rr-cache directory exists.

def _get_conflict_dir(self, conflict_id: str) -> str:

Get the directory path for a specific conflict.

Parameters
conflict_id:strThe conflict ID (SHA-1 hash)
Returns
strPath to the conflict directory
def _get_postimage_path(self, conflict_id: str) -> str:

Get the path to the postimage file for a conflict.

Parameters
conflict_id:strThe conflict ID
Returns
strPath to the postimage file
def _get_preimage_path(self, conflict_id: str) -> str:

Get the path to the preimage file for a conflict.

Parameters
conflict_id:strThe conflict ID
Returns
strPath to the preimage file