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 {0} as a valid remote '
                'remote URL. Perhaps it is missing \'.git\' at the '
                'end.'.format(self.id)
            )
            return False
        except __HOLE__:
            log.error(
                'Local repository cachedir \'{0}\' (corresponding '
                'remote: \'{1}\') 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.'
                .format(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
dataset/ETHPy150Open saltstack/salt/salt/utils/gitfs.py/Dulwich._fetch