Пример #1
0
Файл: repo.go Проект: sombr/ccat
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
}
Пример #2
0
func BenchmarkFileSystem_HgCmd(b *testing.B) {
	defer func() {
		b.StopTimer()
		b.StartTimer()
	}()

	cmds, files := makeHgCommandsAndFiles(benchFileSystemCommits)
	r, err := hgcmd.Open(initHgRepository(b, cmds...))
	if err != nil {
		b.Fatal(err)
	}

	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		benchFileSystem(b, r, "mytag", files)
	}
}
Пример #3
0
func BenchmarkCommits_HgCmd(b *testing.B) {
	defer func() {
		b.StopTimer()
		b.StartTimer()
	}()

	cmds, _ := makeHgCommandsAndFiles(benchCommitsCommits)
	openRepo := func() benchRepository {
		r, err := hgcmd.Open(initHgRepository(b, cmds...))
		if err != nil {
			b.Fatal(err)
		}
		return r
	}

	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		benchCommits(b, openRepo, "mytag")
	}
}