예제 #1
0
파일: noms_log.go 프로젝트: Richardphp/noms
func writeDiffLines(node LogNode, db datas.Database, maxLines, lineno int, w io.Writer) (lineCnt int, err error) {
	mlw := &maxLineWriter{numLines: lineno, maxLines: maxLines, node: node, dest: w, needsPrefix: true, showGraph: showGraph}
	parents := node.commit.Get(datas.ParentsField).(types.Set)
	var parent types.Value = nil
	if parents.Len() > 0 {
		parent = parents.First()
	}
	if parent == nil {
		_, err = fmt.Fprint(mlw, "\n")
		return 1, err
	}

	parentCommit := parent.(types.Ref).TargetValue(db).(types.Struct)
	err = diff.Diff(mlw, parentCommit.Get(datas.ValueField), node.commit.Get(datas.ValueField))
	d.PanicIfNotType(err, MaxLinesErr)
	if err != nil {
		mlw.forceWrite([]byte("...\n"))
		mlw.numLines++
		err = nil
	}
	if !node.lastCommit {
		mlw.forceWrite([]byte("\n"))
	}
	return mlw.numLines, err
}
예제 #2
0
파일: noms_log.go 프로젝트: Richardphp/noms
func writeCommitLines(node LogNode, maxLines, lineno int, w io.Writer) (lineCnt int, err error) {
	mlw := &maxLineWriter{numLines: lineno, maxLines: maxLines, node: node, dest: w, needsPrefix: true, showGraph: showGraph}
	err = types.WriteEncodedValueWithTags(mlw, node.commit.Get(datas.ValueField))
	d.PanicIfNotType(err, MaxLinesErr)
	if err != nil {
		mlw.forceWrite([]byte("..."))
		mlw.numLines++
		err = nil
	}
	mlw.forceWrite([]byte("\n"))
	if !node.lastCommit {
		mlw.forceWrite([]byte("\n"))
	}
	return mlw.numLines, err
}