示例#1
0
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)
	}
}
示例#2
0
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())
}
示例#3
0
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
}
示例#4
0
文件: repo.go 项目: shazow/go-vcs
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
}
示例#5
0
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.")
	}
}
示例#6
0
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")
	}
}
示例#7
0
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)
	}
}
示例#8
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)
	}
}
示例#9
0
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")
	}
}
示例#10
0
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)
	}
}