class_docstr: File-based Code Driver handles source control management for the project with files
      
class_docstr_tok: ["File-based","Code","Driver","handles","source","control","management","for","the","project","with","files"]
docstr: Checkout to specific commit
  
  Raises
  ------
  CodeNotInitialized
      error if not initialized (must initialize first)
  UnstagedChanges
      error if not there exists unstaged changes in code
docstr_tok: ["Checkout","to","specific","commit","Raises","--","--","--","CodeNotInitialized","error","if","not","initialized","(","must","initialize","first",")","UnstagedChanges","error","if","not","there","exists","unstaged","changes","in","code"]
code: def checkout_ref(self, commit_id):
      """Checkout to specific commit
  
      Raises
      ------
      CodeNotInitialized
          error if not initialized (must initialize first)
      UnstagedChanges
          error if not there exists unstaged changes in code
      """
      if not self.is_initialized:
          raise CodeNotInitialized()
      if not self.exists_ref(commit_id):
          raise FileIOError(
              __("error", "controller.code.driver.file.checkout_ref")
          )
      # Check if unstaged changes exist
      if self._has_unstaged_changes():
          raise UnstagedChanges()
      # Check if commit given is same as current
      tracked_filepaths = self._get_tracked_files()
      if self._calculate_commit_hash(tracked_filepaths) == commit_id:
          return True
      # Remove all tracked files from repository
      for tracked_filepath in self._get_tracked_files():
          absolute_filepath = os.path.join(self.root, tracked_filepath)
          os.remove(absolute_filepath)
      # Add in files from the commit
      commit_filepath = os.path.join(self._code_filepath, commit_id)
      with open(commit_filepath, "r") as f:
          for line in f:
              tracked_filepath, filehash = line.rstrip().split(",")
              source_absolute_filepath = os.path.join(
                  self._code_filepath, tracked_filepath, filehash
              )
              destination_absolute_filepath = os.path.join(
                  self.root, tracked_filepath
              )
              shutil.copy2(
                  source_absolute_filepath,
                  destination_absolute_filepath,
              )
      return True
  
imports: import os
  import shutil
  import errno
  import pathspec
  import tempfile
  import hashlib
  import checksumdir
  from datmo.core.util.misc_functions import list_all_filepaths
  from datmo.core.util.i18n import get
  from datmo.core.util.exceptions import PathDoesNotExist, FileIOError, UnstagedChanges, CodeNotInitialized, CommitDoesNotExist
  from datmo.core.controller.code.driver import CodeDriver
label_desc: Use image node_id 17 for calling the FileCodeDriver obj's underlying member method code with example usage: obj.checkout_ref(commit_id) and returns: True, True