func (t *repoTree) fillFromSlothFS(dir string) error {
	c, err := ioutil.ReadFile(filepath.Join(dir, ".slothfs", "tree.json"))
	if err != nil {
		return err
	}
	var tree gitiles.Tree
	if err := json.Unmarshal(c, &tree); err != nil {
		return err
	}
	for _, e := range tree.Entries {
		fi := &fileInfo{}
		fi.sha1, err = parseID(e.ID)
		if err != nil {
			return err
		}
		t.entries[e.Name] = fi
	}
	return nil
}
fillFromSlothFS reads tree.json to fill Entries for this repoTree
node only, and does not recurse.
package populate
import (
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"os"
	"path/filepath"
	"sort"
	"strings"
	"gopkg.in/src-d/go-git.v4/plumbing"
	"github.com/google/slothfs/gitiles"
	"github.com/google/slothfs/manifest"
)
type fileInfo struct {
	sha1 *plumbing.Hash
}
type repoTree struct {
	children map[string]*repoTree
	entries map[string]*fileInfo
	copied []string
}
func (t *repoTree) findParentRepo(path string) (*repoTree, string) {
	for k, ch := range t.children {
		if strings.HasPrefix(path, k+"/") {
			return ch.findParentRepo(path[len(k+"/"):])
		}
	}
	return t, path
}
func (t *repoTree) write(w io.Writer, indent string) {
	for nm, ch := range t.children {
		fmt.Fprintf(w, "%s%s:\n", indent, nm)
		ch.write(w, indent+" ")
	}
}
func repoTreeFromManifest(xmlFile string) (*repoTree, error) {
	mf, err := manifest.ParseFile(xmlFile)
	if err != nil {
		return nil, err
	}
	var byDepth [][]*manifest.Project
	for i, p := range mf.Project {
		l := len(strings.Split(p.GetPath(), "/"))
		for len(byDepth) <= l {
			byDepth = append(byDepth, nil)
		}
		byDepth[l] = append(byDepth[l], &mf.Project[i])
	}
	root := makeRepoTree()
	treesByPath := map[string]*repoTree{
		"": root,
	}
	for _, projs := range byDepth {
		for _, p := range projs {
			childTree := makeRepoTree()
			treesByPath[p.GetPath()] = childTree
			parent, key := root.findParentRepo(p.GetPath())
			parent.children[key] = childTree
		}
	}
	for _, p := range mf.Project {
		for _, c := range p.Copyfile {
			root.copied = append(root.copied, c.Dest)
		}
		for _, c := range p.Linkfile {
			root.copied = append(root.copied, c.Dest)
		}
	}
	sort.Strings(root.copied)
	return root, nil
}