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 TestAddTag(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) } globalTags, allTags := repo.Tags() if globalTags == nil { t.Fatal("Unable to get global tags") } if allTags == nil { t.Fatal("Unable to get all tags") } globalTags.Sort() allTags.Sort() allTags.Add("tip", cl.Tip().Id().Node()) }
func openRepository(args []string) { if repoRoot == "" { arg0 := "." if len(args) > 0 { arg0 = args[0] } r, err := hgo.FindProjectRoot(arg0) if err != nil { fatalf("%s", err) } repoRoot = r } r, err := hgo.OpenRepository(repoRoot) if err != nil { fatalf("%s", err) } repo = r globalTags, allTags = repo.Tags() globalTags.Sort() allTags.Sort() branchHeads, err = repo.BranchHeads() if err != nil { fatalf("%s", err) } return }
func Open(dir string) (*Repository, error) { r, err := hgo.OpenRepository(dir) if err != nil { return nil, err } st := r.NewStore() cl, err := st.OpenChangeLog() if err != nil { return nil, err } globalTags, allTags := r.Tags() globalTags.Sort() allTags.Sort() allTags.Add("tip", cl.Tip().Id().Node()) bh, err := r.BranchHeads() if err != nil { return nil, err } cr, err := hgcmd.Open(dir) if err != nil { return nil, err } return &Repository{cr, r, st, cl, allTags, bh}, nil }
func TestOpenRepository(t *testing.T) { defer removeTmpDirs(t) dir := createRepo(t, commands) _, err := hgo.OpenRepository(dir) if err != nil { t.Fatal("Unable to open repository.") } }
func TestNewStore(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") } }
func TestBranchHeads(t *testing.T) { defer removeTmpDirs(t) dir := createRepo(t, commands) repo, err := hgo.OpenRepository(dir) if err != nil { t.Fatal("Unable to open repository.") } _, err = repo.BranchHeads() if err != nil { t.Errorf("Unable to get branch heads: %s", 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 TestTags(t *testing.T) { defer removeTmpDirs(t) dir := createRepo(t, commands) repo, err := hgo.OpenRepository(dir) if err != nil { t.Fatal("Unable to open repository.") } globalTags, allTags := repo.Tags() if globalTags == nil { t.Fatal("Unable to get global tags") } if allTags == nil { t.Fatal("Unable to get all tags") } }
func TestOpenChangeLog(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") } _, err = s.OpenChangeLog() if err != nil { t.Fatalf("Unable to open change log: %s", err) } }