code: def test_update_volatile_subds(
      originpath=None, otherpath=None, destpath=None
  ):
      origin = Dataset(originpath).create()
      repo = origin.repo
      if (
          repo.is_managed_branch()
          and repo.git_annex_version <= "8.20201129"
      ):
          # Fails before git-annex's fd161da2c (adjustTree: Consider submodule
          # deletions, 2021-01-06).
          raise SkipTest(
              "On adjusted branch, test requires fix in more recent git-annex"
          )
      ds = install(
          source=originpath,
          path=destpath,
          result_xfm="datasets",
          return_type="item-or-list",
      )
      # as a submodule
      sname = "subm 1"
      osm1 = origin.create(sname)
      assert_result_count(ds.update(), 1, status="ok", type="dataset")
      # nothing without a merge, no inappropriate magic
      assert_not_in(sname, ds.subdatasets(result_xfm="relpaths"))
      assert_result_count(
          ds.update(merge=True),
          1,
          action="update",
          status="ok",
          type="dataset",
      )
      # and we should be able to do update with recursive invocation
      assert_result_count(
          ds.update(merge=True, recursive=True),
          1,
          action="update",
          status="ok",
          type="dataset",
      )
      # known, and placeholder exists
      assert_in(sname, ds.subdatasets(result_xfm="relpaths"))
      ok_(exists(opj(ds.path, sname)))
  
      # remove from origin
      origin.remove(sname, reckless="availability")
      assert_result_count(
          ds.update(merge=True),
          1,
          action="update",
          status="ok",
          type="dataset",
      )
      # gone locally, wasn't checked out
      assert_not_in(sname, ds.subdatasets(result_xfm="relpaths"))
      assert_false(exists(opj(ds.path, sname)))
  
      # re-introduce at origin
      osm1 = origin.create(sname)
      create_tree(osm1.path, {"load.dat": "heavy"})
      origin.save(opj(osm1.path, "load.dat"))
      assert_result_count(
          ds.update(merge=True),
          1,
          action="update",
          status="ok",
          type="dataset",
      )
      # grab new content of uninstall subdataset, right away
      ds.get(opj(ds.path, sname, "load.dat"))
      ok_file_has_content(opj(ds.path, sname, "load.dat"), "heavy")
  
      # modify ds and subds at origin
      create_tree(
          origin.path, {"mike": "this", sname: {"probe": "little"}}
      )
      origin.save(recursive=True)
      assert_repo_status(origin.path)
  
      # updates for both datasets should come down the pipe
      assert_result_count(
          ds.update(merge=True, recursive=True),
          2,
          action="update",
          status="ok",
          type="dataset",
      )
      assert_repo_status(ds.path)
  
      # now remove just-installed subdataset from origin again
      origin.remove(sname, reckless="kill")
      assert_not_in(sname, origin.subdatasets(result_xfm="relpaths"))
      assert_in(sname, ds.subdatasets(result_xfm="relpaths"))
      # merge should disconnect the installed subdataset, but leave the actual
      # ex-subdataset alone
      assert_result_count(
          ds.update(merge=True, recursive=True),
          1,
          action="update",
          type="dataset",
      )
      assert_not_in(sname, ds.subdatasets(result_xfm="relpaths"))
      ok_file_has_content(opj(ds.path, sname, "load.dat"), "heavy")
      ok_(Dataset(opj(ds.path, sname)).is_installed())
  
      # now remove the now disconnected subdataset for further tests
      remove(dataset=op.join(ds.path, sname), reckless="kill")
      assert_repo_status(ds.path)
  
      # new separate subdataset, not within the origin dataset
      otherds = Dataset(otherpath).create()
      # install separate dataset as a submodule
      ds.install(source=otherds.path, path="other")
      create_tree(otherds.path, {"brand": "new"})
      otherds.save()
      assert_repo_status(otherds.path)
      # pull in changes
      res = ds.update(merge=True, recursive=True)
      assert_result_count(
          res, 2, status="ok", action="update", type="dataset"
      )
      # the next is to check for #2858
      assert_repo_status(ds.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 5 for calling a global function with example usage: test_update_volatile_subds(originpath, otherpath, destpath) without return types