docs: def patch(self, container: Container, p: Patch) -> bool:
          """
          Attempts to apply a given patch to the source code for a program inside
          a given container. All patch applications are guaranteed to be atomic;
          if the patch fails to apply, no changes will be made to the relevant
          source code files.
  
          Returns true if the patch application was successful, and false if
          the attempt was unsuccessful.
          """
          assert isinstance(p, Patch)
          file_container = None
          dockerc = self.__dockerc[container.uid]
          bug = self.__installation.bugs[container.bug]
          logger.debug("Applying patch to container [%s]:\n%s",
                       container.uid,
                       str(p))
  
          try:
              file_host = NamedTemporaryFile(mode='w', suffix='bugzoo')
              file_host.write(str(p))
              file_host.flush()
  
              # copy contents to a temporary file on the container
              (retcode, file_container) = dockerc.exec_run('mktemp')
              assert retcode == 0
              file_container = file_container.decode(sys.stdout.encoding).strip()
  
              self.copy_to(container, file_host.name, file_container)
  
              # run patch command inside the source directory
              cmd = 'sudo chown $(whoami) "{}" && patch -p0 < "{}"'
              cmd = cmd.format(file_container, file_container)
              outcome = self.command(container, cmd, context=bug.source_dir)
              logger.debug("Patch application outcome [%s]: (retcode=%d)\n%s",
                           container.uid,
                           outcome.code,
                           outcome.output)
              return outcome.code == 0
  
          finally:
              if file_container:
                  dockerc.exec_run('rm "{}"'.format(file_container))