code: def ext_pillar(minion_id, pillar, repo, branch='default', root=None):
      '''
      Extract pillar from an hg repository
      '''
      with Repo(repo) as repo:
          repo.update(branch)
      envname = 'base' if branch == 'default' else branch
      if root:
          path = os.path.normpath(os.path.join(repo.working_dir, root))
      else:
          path = repo.working_dir
  
      opts = copy.deepcopy(__opts__)
      opts['pillar_roots'][envname] = [path]
      pil = salt.pillar.Pillar(opts, __grains__, minion_id, envname)
      return pil.compile_pillar(ext=Falsef ext_pillar(minion_id, pillar, repo, branch='default', root=None):
      '''
      Extract pillar from an hg repository
      '''
      with Repo(repo) as repo:
          repo.update(branch)
      envname = 'base' if branch == 'default' else branch
      if root:
          path = os.path.normpath(os.path.join(repo.working_dir, root))
      else:
          path = repo.working_dir
  
      opts = copy.deepcopy(__opts__)
      opts['pillar_roots'][envname] = [path]
      pil = salt.pillar.Pillar(opts, __grains__, minion_id, envname)
      return pil.compile_pillar(ext=False)
docs: Extract pillar from an hg repository