Esempio n. 1
0
func getChangeset(rs revlog.RevisionSpec, b *revlog.FileBuilder) (c *changelog.Entry, err error) {
	st := repo.NewStore()
	clIndex, err := st.OpenChangeLog()
	if err != nil {
		return
	}
	r, err := rs.Lookup(clIndex)
	if err != nil {
		return
	}
	c, err = changelog.BuildEntry(r, b)
	if err == nil {
		c.Rec = r
	}
	return
}
Esempio n. 2
0
func (ra *repoAccess) manifestEntry(chgId int, fileName string) (me *store.ManifestEnt, err error) {
	r, err := ra.clRec(revlog.FileRevSpec(chgId))
	if err != nil {
		return
	}
	c, err := changelog.BuildEntry(r, ra.fb)
	if err != nil {
		return
	}
	m, err := getManifest(int(c.Linkrev), c.ManifestNode, ra.fb)
	if err != nil {
		return
	}
	me = m.Map()[fileName]
	if me == nil {
		err = errors.New("file does not exist in given revision")
	}
	return
}
Esempio n. 3
0
func printChangelog(w io.Writer, rFrom, rTo *revlog.Rec, logIndex *revlog.Index, tags map[string][]string, wantDirPrefix, wantFile string) (err error) {
	var clr *revlog.Rec

	match := func([]string) bool { return true }
	if wantFile != "" {
		match = func(files []string) (ok bool) {
			for _, f := range files {
				if f == wantFile {
					ok = true
					return
				}
			}
			return
		}
	} else if wantDirPrefix != "" {
		match = func(files []string) (ok bool) {
			for _, f := range files {
				if strings.HasPrefix(f, wantDirPrefix) {
					ok = true
					return
				}
			}
			return
		}
	}

	fb := revlog.NewFileBuilder()
	fb.SetDataCache(&dc)
	fb.KeepDataOpen()
	defer fb.CloseData()
	t, err := setupLogTemplate(logTemplate, tags)
	if err != nil {
		return
	}
	ch := make(chan *changelog.Entry, 16)
	errch := make(chan error, 0)
	go func() {
		errch <- t.Execute(w, ch)
	}()
	r := rFrom
	target := rTo.FileRev()
	var next func()
	if rFrom.FileRev() > target {
		next = func() { r = r.Prev() }
	} else {
		next = func() { r = r.Next() }
	}
	i := 0
	for {
		if logIndex == nil {
			clr = r
		} else {
			clr, err = revlog.FileRevSpec(r.Linkrev).Lookup(logIndex)
			if err != nil {
				return
			}
		}
		c, err1 := changelog.BuildEntry(clr, fb)
		if err1 != nil {
			err = err1
			return
		}
		c.Rec = clr

		if match(c.Files) {
			select {
			case ch <- c:
				i++
			case err = <-errch:
				return
			}
		}
		if r.FileRev() == target {
			break
		}
		next()
		if r.FileRev() == -1 {
			break
		}
		if *logL != 0 && i == *logL {
			break
		}
	}
	close(ch)
	err = <-errch
	return
}