code: def dataset_merge_method(dataset, other, overwrite_vars, compat, join):
      
  
      # we are locked into supporting overwrite_vars for the Dataset.merge
      # method due for backwards compatibility
      # TODO: consider deprecating it?
  
      if isinstance(overwrite_vars, str):
          overwrite_vars = set([overwrite_vars])
      overwrite_vars = set(overwrite_vars)
  
      if not overwrite_vars:
          objs = [dataset, other]
          priority_arg = None
      elif overwrite_vars == set(other):
          objs = [dataset, other]
          priority_arg = 1
      else:
          other_overwrite = OrderedDict()
          other_no_overwrite = OrderedDict()
          for k, v in other.items():
              if k in overwrite_vars:
                  other_overwrite[k] = v
              else:
                  other_no_overwrite[k] = v
          objs = [dataset, other_no_overwrite, other_overwrite]
          priority_arg = 2
  
      return merge_core(objs, compat, join, priority_arg=priority_arg)
docs: Guts of the Dataset.merge method.