Ggit.Patch¶
Fields¶
None
Methods¶
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class Ggit.Patch¶
Represents a patch object.
- classmethod new_from_blobs(old_blob, old_as_path, new_blob, new_as_path, diff_options)¶
- Parameters:
old_as_path (
str
orNone
) – treat old_blob as if it had this filename, orNone
,new_as_path (
str
orNone
) – treat new_blob as if it had this filename, orNone
,diff_options (
Ggit.DiffOptions
orNone
) – aGgit.DiffOptions
, orNone
.
- Raises:
- Returns:
a newly created
Ggit.Patch
orNone
.- Return type:
Ggit.Patch
orNone
Directly generate a patch from the difference between two blobs.
This is just like
Ggit.Diff.blobs
() except it generates a patch object for the difference instead of directly making callbacks. You can use the standard ggit_patch accessor functions to read the patch data, and you must callGgit.Patch.unref
on the patch when done.
- classmethod new_from_diff(diff, idx)¶
- Parameters:
- Raises:
- Returns:
a newly created
Ggit.Patch
orNone
.- Return type:
Ggit.Patch
orNone
The
Ggit.Patch
is a newly created object contains the text diffs for the delta. You have to callGgit.Patch.unref
() when you are done with it. You can use the patch object to loop over all the hunks and lines in the diff of the one delta.
- get_delta()¶
- Returns:
the
Ggit.DiffDelta
of the patch orNone
.- Return type:
Get the diff delta corresponding to the patch.
- get_hunk(idx)¶
- Parameters:
idx (
int
) – the hunk index.- Raises:
- Returns:
a new
Ggit.DiffHunk
orNone
on error.- Return type:
Get the idx'th hunk in the patch.
- get_line_stats()¶
- Raises:
- Returns:
True
if successfull,False
otherwise.- total_context:
return value for the number of context lines.
- total_additions:
return value for the number of added lines.
- total_deletions:
return value for the number of deleted lines.
- Return type:
(
bool
, total_context:int
, total_additions:int
, total_deletions:int
)
Get the line statistics of the patch.
- get_num_hunks()¶
- Returns:
the number of hunks.
- Return type:
Get the number of hunks in the patch.
- get_num_lines_in_hunk(hunk)¶
-
Get the number of lines in hunk.
- ref()¶
- Returns:
a
Ggit.Patch
orNone
.- Return type:
Ggit.Patch
orNone
Atomically increments the reference count of self by one. This function is MT-safe and may be called from any thread.
- to_stream(stream)¶
- Parameters:
stream (
Gio.OutputStream
) – aGio.OutputStream
.- Raises:
- Returns:
True
if the patch was written successfully,False
otherwise.- Return type:
Write the contents of a patch to the provided stream.
- to_string()¶
- Raises:
- Returns:
the content of a patch as a single diff text or
None
.- Return type:
Gets the content of a patch as a single diff text.
- unref()¶
Atomically decrements the reference count of self by one. If the reference count drops to 0, self is freed.