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

Function test_transaction_nested_same_ref_conflict

test/test_transaction.py:307–327  ·  view source on GitHub ↗

Test that nested transactions fail when trying to lock the same ref.

(testrepo: Repository)

Source from the content-addressed store, hash-verified

305
306
307def test_transaction_nested_same_ref_conflict(testrepo: Repository) -> None:
308 """Test that nested transactions fail when trying to lock the same ref."""
309 ref_name = 'refs/heads/nested-conflict-test'
310 target = Oid(hex='5ebeeebb320790caf276b9fc8b24546d63316533')
311 new_target = Oid(hex='2be5719152d4f82c7302b1c0932d8e5f0a4a0e98')
312 testrepo.create_reference(ref_name, target)
313
314 with testrepo.transaction() as txn1:
315 txn1.lock_ref(ref_name)
316
317 # Inner transaction should fail to lock the same ref
318 with pytest.raises(GitError):
319 with testrepo.transaction() as txn2:
320 txn2.lock_ref(ref_name)
321
322 # Outer transaction should still be able to complete
323 txn1.set_target(ref_name, new_target, message='Outer transaction')
324
325 # Outer transaction's update should have been applied
326 ref = testrepo.lookup_reference(ref_name)
327 assert ref.target == new_target

Callers

nothing calls this directly

Calls 4

create_referenceMethod · 0.80
transactionMethod · 0.80
lock_refMethod · 0.80
set_targetMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…