MCPcopy Create free account
hub / github.com/libgit2/pygit2 / test_diff_merge

Function test_diff_merge

test/test_diff.py:311–336  ·  view source on GitHub ↗
(barerepo: Repository)

Source from the content-addressed store, hash-verified

309
310
311def test_diff_merge(barerepo: Repository) -> None:
312 commit_a = barerepo[COMMIT_SHA1_1]
313 commit_b = barerepo[COMMIT_SHA1_2]
314 commit_c = barerepo[COMMIT_SHA1_3]
315
316 diff_b = commit_a.tree.diff_to_tree(commit_b.tree)
317 assert diff_b is not None
318
319 diff_c = commit_b.tree.diff_to_tree(commit_c.tree)
320 assert diff_c is not None
321 assert 'b' not in [patch.delta.new_file.path for patch in diff_safeiter(diff_b)]
322 assert 'b' in [patch.delta.new_file.path for patch in diff_safeiter(diff_c)]
323
324 diff_b.merge(diff_c)
325 assert 'b' in [patch.delta.new_file.path for patch in diff_safeiter(diff_b)]
326
327 patch = diff_b[0]
328 assert patch is not None
329 hunk = patch.hunks[0]
330 assert hunk.old_start == 1
331 assert hunk.old_lines == 1
332 assert hunk.new_start == 1
333 assert hunk.new_lines == 1
334
335 assert patch.delta.old_file.path == 'a'
336 assert patch.delta.new_file.path == 'a'
337
338
339def test_diff_patch(barerepo: Repository) -> None:

Callers

nothing calls this directly

Calls 3

diff_safeiterFunction · 0.85
diff_to_treeMethod · 0.80
mergeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…