old_contents: """Helpers for vcspull."""
  import os
  
  
  class EnvironmentVarGuard(object):
  
      """Class to help protect the environment variable properly.
  
      May be used as context manager.
      Vendorize to fix issue with Anaconda Python 2 not
      including test module, see #121.
      """
  
      def __init__(self):
          self._environ = os.environ
          self._unset = set()
          self._reset = dict()
  
      def set(self, envvar, value):
          if envvar not in self._environ:
              self._unset.add(envvar)
          else:
              self._reset[envvar] = self._environ[envvar]
          self._environ[envvar] = value
  
      def unset(self, envvar):
          if envvar in self._environ:
              self._reset[envvar] = self._environ[envvar]
              del self._environ[envvar]
  
      def __enter__(self):
          return self
  
      def __exit__(self, *ignore_exc):
          for envvar, value in self._reset.items():
              self._environ[envvar] = value
          for unset in self._unset:
              del self._environ[unset]
  
new_contents: """Helpers for vcspull."""
  import os
  
  from _pytest.compat import LEGACY_PATH
  
  
  class EnvironmentVarGuard(object):
  
      """Class to help protect the environment variable properly.
  
      May be used as context manager.
      Vendorize to fix issue with Anaconda Python 2 not
      including test module, see #121.
      """
  
      def __init__(self):
          self._environ = os.environ
          self._unset = set()
          self._reset = dict()
  
      def set(self, envvar, value):
          if envvar not in self._environ:
              self._unset.add(envvar)
          else:
              self._reset[envvar] = self._environ[envvar]
          self._environ[envvar] = value
  
      def unset(self, envvar):
          if envvar in self._environ:
              self._reset[envvar] = self._environ[envvar]
              del self._environ[envvar]
  
      def __enter__(self):
          return self
  
      def __exit__(self, *ignore_exc):
          for envvar, value in self._reset.items():
              self._environ[envvar] = value
          for unset in self._unset:
              del self._environ[unset]
  
  
  def write_config(config_dir: LEGACY_PATH, filename: str, content: str):
      config = config_dir.join(filename)
      config.write(content)
      return config
  
subject: Add write_config