code: def custom_environment(self, **kwargs):
          
          old_env = self.update_environment(**kwargs)
          try:
              yield
          finally:
              self.update_environment(**old_env)
docs: A context manager around the above ``update_environment`` method to restore the
          environment back to its previous state after operation.
  
          ``Examples``::
  
              with self.custom_environment(GIT_SSH='/bin/ssh_wrapper'):
                  repo.remotes.origin.fetch()
  
          :param kwargs: see update_environment