code: def _apply_diff(environ, diff):
      
      original = {}
  
      if diff:
          for k, v in diff.iteritems():
  
              if v is None:
                  log.log(5, 'unset %s', k)
              else:
                  log.log(5, '%s="%s"', k, v)
  
              original[k] = environ.get(k)
  
              if original[k] is None:
                  log.log(1, '%s was not set', k)
              else:
                  log.log(1, '%s was "%s"', k, original[k])
  
              if v is None:
                  environ.pop(k, None)
              else:
                  environ[k] = v
      else:
          log.log(5, 'nothing to apply')
  
      return original
docs: Apply a frozen environment.
  
      :param dict diff: key-value pairs to apply to the environment.
      :returns: A dict of the key-value pairs that are being changed.