func TestBuildEntry(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() _, err = hg_changelog.BuildEntry(rec, fb) if err != nil { t.Errorf("Unable to build entry: %s", err) } }
func (r *Repository) getRec(id vcs.CommitID) (*hg_revlog.Rec, error) { rec, err := hg_revlog.NodeIdRevSpec(id).Lookup(r.cl) if err == hg_revlog.ErrRevNotFound { err = vcs.ErrCommitNotFound } return rec, err }
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) } }
func (r *Repository) parseRevisionSpec(s string) hg_revlog.RevisionSpec { if s == "" { s = "tip" // TODO(sqs): determine per-repository default branch name (not always "default"?) } if s == "tip" { return hg_revlog.TipRevSpec{} } if s == "null" { return hg_revlog.NullRevSpec{} } if id, ok := r.allTags.IdByName[s]; ok { s = id } else if i, err := strconv.Atoi(s); err == nil { return hg_revlog.FileRevSpec(i) } return hg_revlog.NodeIdRevSpec(s) }
func parseRevisionSpec(s, dflt string) revlog.RevisionSpec { if s == "" { s = dflt } if s == "tip" { return revlog.TipRevSpec{} } if s == "null" { return revlog.NullRevSpec{} } if id, ok := allTags.IdByName[s]; ok { s = id } else if id, ok := branchHeads.IdByName[s]; ok { s = id } else if i, err := strconv.Atoi(s); err == nil { return revlog.FileRevSpec(i) } return revlog.NodeIdRevSpec(s) }