Classes for dealing with git am-style patches.

These patches are basically unified diffs with some extra metadata tacked on.

Function write_commit_patch Write a individual file patch.
Function get_summary Determine the summary line for use in a filename.
Function unified_diff difflib.unified_diff that can detect "No newline at end of file" as original "git diff" does.
Function is_binary See if the first few bytes contain any null characters.
Function shortid Undocumented
Function patch_filename Undocumented
Function write_object_diff Write the diff for an object.
Function gen_diff_header Write a blob diff header.
Function write_blob_diff Write blob diff.
Function write_tree_diff Write tree diff.
Function git_am_patch_split Parse a git-am-style patch and split it up into bits.
Function parse_patch_message Extract a Commit object and patch from an e-mail message.
Function _format_range_unified Convert range to the "ed" format
def write_commit_patch(f, commit, contents, progress, version=None, encoding=None):
Write a individual file patch.
ParameterscommitCommit object
progressTuple with current patch number and total.
Returnstuple with filename and contents
def get_summary(commit):
Determine the summary line for use in a filename.
ParameterscommitCommit
ReturnsSummary string
def _format_range_unified(start, stop):
Convert range to the "ed" format
def unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n'):

difflib.unified_diff that can detect "No newline at end of file" as original "git diff" does.

Based on the same function in Python2.7 difflib.py

def is_binary(content):
See if the first few bytes contain any null characters.
ParameterscontentBytestring to check for binary content
def shortid(hexsha):
Undocumented
def patch_filename(p, root):
Undocumented
def write_object_diff(f, store, old_file, new_file, diff_binary=False):
Write the diff for an object.
ParametersfFile-like object to write to
storeStore to retrieve objects from, if necessary
old_file(path, mode, hexsha) tuple
new_file(path, mode, hexsha) tuple
diff_binaryWhether to diff files even if they are considered binary files by is_binary().
Notethe tuple elements should be None for nonexistant files
def gen_diff_header(paths, modes, shas):
Write a blob diff header.
ParameterspathsTuple with old and new path
modesTuple with old and new modes
shasTuple with old and new shas
def write_blob_diff(f, old_file, new_file):
Write blob diff.
ParametersfFile-like object to write to
old_file(path, mode, hexsha) tuple (None if nonexisting)
new_file(path, mode, hexsha) tuple (None if nonexisting)
NoteThe use of write_object_diff is recommended over this function.
def write_tree_diff(f, store, old_tree, new_tree, diff_binary=False):
Write tree diff.
ParametersfFile-like object to write to.
old_treeOld tree id
new_treeNew tree id
diff_binaryWhether to diff files even if they are considered binary files by is_binary().
def git_am_patch_split(f, encoding=None):
Parse a git-am-style patch and split it up into bits.
ParametersfFile-like object to parse
encodingEncoding to use when creating Git objects
ReturnsTuple with commit object, diff contents and git version
def parse_patch_message(msg, encoding=None):
Extract a Commit object and patch from an e-mail message.
ParametersmsgAn email message (email.message.Message)
encodingEncoding to use to encode Git commits
ReturnsTuple with commit object, diff contents and git version
API Documentation for Dulwich, generated by pydoctor at 2018-11-17 19:05:54.