original_docstring: 
          Fetch the repo. If the local copy was updated, return True. If the
          local copy was already up-to-date, return False.
          
docstring: Fetch the repo. If the local copy was updated, return True. If the
  local copy was already up-to-date, return False.
docstring_tokens: Fetch the repo . If the local copy was updated return True . If the local copy was already up - to - date return False .
code: def _fetch(self):
          '''
          Fetch the repo. If the local copy was updated, return True. If the
          local copy was already up-to-date, return False.
          '''
          # origin is just a url here, there is no origin object
          origin = self.url
          client, path = \
              dulwich.client.get_transport_and_path_from_url(
                  origin, thin_packs=True
              )
          refs_pre = self.repo.get_refs()
          try:
              refs_post = client.fetch(path, self.repo)
          except dulwich.errors.NotGitRepository:
              log.error(
                  'Dulwich does not recognize %s as a valid remote '
                  'remote URL. Perhaps it is missing \'.git\' at the '
                  'end.', self.id, exc_info_on_loglevel=logging.DEBUG
              )
              return False
          except KeyError:
              log.error(
                  'Local repository cachedir \'%s\' (corresponding '
                  'remote: \'%s\') has been corrupted. Salt will now '
                  'attempt to remove the local checkout to allow it to '
                  'be re-initialized in the next fileserver cache '
                  'update.', self.cachedir, self.id
              )
              try:
                  salt.utils.rm_rf(self.cachedir)
              except OSError as exc:
                  log.error(
                      'Unable to remove {0}: {1}'.format(self.cachedir, exc)
                  )
              return False
          else:
              # Dulwich does not write fetched references to the gitdir, that is
              # done manually below (see the "Update local refs" comment). Since
              # A) gitfs doesn't check out any local branches, B) both Pygit2 and
              # GitPython set remote refs when fetching instead of head refs, and
              # C) Dulwich is not supported for git_pillar or winrepo, there is
              # no harm in simply renaming the head refs from the fetch results
              # to remote refs. This allows the same logic (see the
              # "_get_envs_from_ref_paths()" function) to be used for all three
              # GitProvider subclasses to derive available envs.
              for ref in [x for x in refs_post if x.startswith('refs/heads/')]:
                  val = refs_post.pop(ref)
                  key = ref.replace('refs/heads/', 'refs/remotes/origin/', 1)
                  refs_post[key] = val
  
          if refs_post is None:
              # Empty repository
              log.warning(
                  '{0} remote \'{1}\' is an empty repository and will '
                  'be skipped.'.format(self.role, self.id)
              )
              return False
          if refs_pre != refs_post:
              # Update local refs
              for ref in self.get_env_refs(refs_post):
                  self.repo[ref] = refs_post[ref]
              # Prune stale refs
              for ref in refs_pre:
                  if ref not in refs_post:
                      del self.repo[ref]
              return True
          return False
code_tokens: def _fetch ( self ) : origin = self . url client , path = dulwich . client . get_transport_and_path_from_url ( origin , thin_packs = True ) refs_pre = self . repo . get_refs ( ) try : refs_post = client . fetch ( path , self . repo ) except dulwich . errors . NotGitRepository : log . error ( 'Dulwich does not recognize %s as a valid remote ' 'remote URL. Perhaps it is missing \'.git\' at the ' 'end.' , self . id , exc_info_on_loglevel = logging . DEBUG ) return False except KeyError : log . error ( 'Local repository cachedir \'%s\' (corresponding ' 'remote: \'%s\') has been corrupted. Salt will now ' 'attempt to remove the local checkout to allow it to ' 'be re-initialized in the next fileserver cache ' 'update.' , self . cachedir , self . id ) try : salt . utils . rm_rf ( self . cachedir ) except OSError as exc : log . error ( 'Unable to remove {0}: {1}' . format ( self . cachedir , exc ) ) return False else : for ref in [ x for x in refs_post if x . startswith ( 'refs/heads/' ) ] : val = refs_post . pop ( ref ) key = ref . replace ( 'refs/heads/' , 'refs/remotes/origin/' , 1 ) refs_post [ key ] = val if refs_post is None : log . warning ( '{0} remote \'{1}\' is an empty repository and will ' 'be skipped.' . format ( self . role , self . id ) ) return False if refs_pre != refs_post : for ref in self . get_env_refs ( refs_post ) : self . repo [ ref ] = refs_post [ ref ] for ref in refs_pre : if ref not in refs_post : del self . repo [ ref ] return True return False
short_docstring: Fetch the repo.
short_docstring_tokens: Fetch the repo .
comment: '''
          Fetch the repo. If the local copy was updated, return True. If the
          local copy was already up-to-date, return False.
          '''$SEP$# origin is just a url here, there is no origin object$SEP$# Dulwich does not write fetched references to the gitdir, that is$SEP$# done manually below (see the "Update local refs" comment). Since$SEP$# A) gitfs doesn't check out any local branches, B) both Pygit2 and$SEP$# GitPython set remote refs when fetching instead of head refs, and$SEP$# C) Dulwich is not supported for git_pillar or winrepo, there is$SEP$# no harm in simply renaming the head refs from the fetch results$SEP$# to remote refs. This allows the same logic (see the$SEP$# "_get_envs_from_ref_paths()" function) to be used for all three$SEP$# GitProvider subclasses to derive available envs.$SEP$# Empty repository$SEP$# Update local refs$SEP$# Prune stale refs