code: def test_merge_conflict(path=None):
      path = Path(path)
      ds_src = Dataset(path / "src").create()
      ds_src_s0 = ds_src.create("s0")
      ds_src_s1 = ds_src.create("s1")
      ds_src.save()
  
      ds_clone = install(
          source=ds_src.path,
          path=path / "clone",
          recursive=True,
          result_xfm="datasets",
      )
      ds_clone_s0 = Dataset(path / "clone" / "s0")
      ds_clone_s1 = Dataset(path / "clone" / "s1")
  
      (ds_src.pathobj / "foo").write_text("src content")
      ds_src.save(to_git=True)
  
      (ds_clone.pathobj / "foo").write_text("clone content")
      ds_clone.save(to_git=True)
  
      # Top-level merge failure
      res = ds_clone.update(merge=True, on_failure="ignore")
      assert_in_results(res, action="merge", status="error")
      assert_in_results(res, action="update", status="error")
      # Deal with the conflicts. Note that save() won't handle this gracefully
      # because it will try to commit with a pathspec, which git doesn't allow
      # during a merge.
      ds_clone.repo.call_git(["checkout", "--theirs", "--", "foo"])
      ds_clone.repo.call_git(["add", "--", "foo"])
      ds_clone.repo.call_git(["commit", "--no-edit"])
      assert_repo_status(ds_clone.path)
  
      # Top-level and subdataset merge failure
      (ds_src_s0.pathobj / "foo").write_text("src s0 content")
      (ds_src_s1.pathobj / "foo").write_text("no conflict")
      ds_src.save(recursive=True, to_git=True)
  
      (ds_clone_s0.pathobj / "foo").write_text("clone s0 content")
      ds_clone.save(recursive=True, to_git=True)
      res = ds_clone.update(
          merge=True, recursive=True, on_failure="ignore"
      )
      assert_result_count(res, 2, action="merge", status="error")
      assert_result_count(res, 2, action="update", status="error")
      assert_in_results(
          res, action="merge", status="ok", path=ds_clone_s1.path
      )
      assert_in_results(
          res, action="update", status="ok", path=ds_clone_s1.path
      )
      # No saving happens if there's a top-level conflict.
      assert_repo_status(
          ds_clone.path, modified=[ds_clone_s0.path, ds_clone_s1.path]
      )
  
imports: import os
  import os.path
  from os.path import exists
  from os.path import join
  from unittest.mock import patch
  import pytest
  from datalad import cfg
  from datalad.api import clone, install, remove, update
  from datalad.distribution.update import _process_how_args
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.external_versions import external_versions
  from datalad.support.gitrepo import GitRepo
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, DEFAULT_REMOTE, SkipTest, assert_false, assert_in, assert_in_results, assert_is_instance, assert_not_in, assert_raises, assert_repo_status, assert_result_count, assert_status, create_tree, eq_, known_failure_windows, maybe_adjust_repo, neq_, ok_, ok_file_has_content, skip_if_adjusted_branch, slow, with_tempfile
  from datalad.utils import Path, chpwd, knows_annex, rmtree
  from ..dataset import Dataset
label_desc: Use image node_id 10 for calling a global function with example usage: test_merge_conflict(path) without return types