示例#1
0
func TestBuildManifest(t *testing.T) {
	defer removeTmpDirs(t)

	dir := createRepo(t, commands)

	repo, err := hgo.OpenRepository(dir)
	if err != nil {
		t.Fatal("Unable to open repository.")
	}

	s := repo.NewStore()
	if s == nil {
		t.Fatal("Unable to create new store")
	}

	cl, err := s.OpenChangeLog()
	if err != nil {
		t.Fatalf("Unable to open change log: %s", err)
	}

	rec, err := hg_revlog.NodeIdRevSpec(revision).Lookup(cl)
	if err != nil {
		t.Errorf("Unable to get revision spec: %s", err)
	}

	fb := hg_revlog.NewFileBuilder()
	ce, err := hg_changelog.BuildEntry(rec, fb)
	if err != nil {
		t.Errorf("Unable to build entry: %s", err)
	}

	mlog, err := s.OpenManifests()
	if err != nil {
		t.Errorf("Unable to open manifest: %s", err)
	}

	rec2, err := mlog.LookupRevision(int(ce.Linkrev), ce.ManifestNode)
	if err != nil {
		t.Errorf("Unable to lookup revision: %s", err)
	}

	_, err = hg_store.BuildManifest(rec2, fb)
	if err != nil {
		t.Errorf("Unable to build manifest: %s", err)
	}
}
示例#2
0
文件: repo.go 项目: shazow/go-vcs
func (fs *hgFSNative) getManifest(chgId hg_revlog.FileRevSpec) (m hg_store.Manifest, err error) {
	rec, err := chgId.Lookup(fs.cl)
	if err != nil {
		return
	}
	c, err := hg_changelog.BuildEntry(rec, fs.fb)
	if err != nil {
		return
	}

	// st := fs.repo.NewStore()
	mlog, err := fs.st.OpenManifests()
	if err != nil {
		return nil, err
	}

	rec2, err := mlog.LookupRevision(int(c.Linkrev), c.ManifestNode)
	if err != nil {
		return nil, err
	}

	return hg_store.BuildManifest(rec2, fs.fb)
}