rcs

package module
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2022 License: MIT Imports: 9 Imported by: 0

README

Golang RCS

Is a serializer and deserializer library for the RCS version control system https://en.wikipedia.org/wiki/Revision_Control_System

I couldn't find anything which would do what I wanted. Currently the code is usecase specific, but I'm happy to accept PRs.

Usage

The library is simple to use:

func ListHeads(fn string) {
	f, err := os.Open(fn)
	if err != nil {
		log.Panicf("Error with file: %s", err)
	}
	defer func() {
		if err = f.Close(); err != nil {
			log.Panicf("Error closing file; %s: %s", fn, err)
		}
	}()
	fmt.Println("Parsing: ", fn)
	r, err := rcs.ParseFile(f)
	if err != nil {
		log.Panicf("Error parsing: %s", err)
	}
	for _, rh := range r.RevisionHeads {
		fmt.Printf("%s on %s by %s\n", rh.Revision, rh.Date.In(time.Local), rh.Author)
	}
}

See the godoc for the structure.

Programs

I have produced 2 programs as part of this

List-heads

It's a simple program that lists the revisions etc, in the files specified:

> list-heads testinput.go,v
Parsing:  testinput.go,v
1.6 on 2022-03-23 13:22:51 +1100 AEDT by arran
1.5 on 2022-03-23 13:22:34 +1100 AEDT by arran
1.4 on 2022-03-23 13:22:03 +1100 AEDT by arran
1.3 on 2022-03-23 13:21:35 +1100 AEDT by arran
1.2 on 2022-03-23 13:20:39 +1100 AEDT by arran
1.1 on 2022-03-23 13:18:09 +1100 AEDT by arran

There are currently no arguments

normalize-revisions

The purpose of this program is that it lines up all the date times with revisions in multiple files. Ie;

Imagine these two files:

> list-heads file1.go,v
Parsing:  file1.go,v file2.go,v
1.2 on 2022-03-23 15:01:01 +1100 AEDT by arran
1.1 on 2022-03-23 13:01:01 +1100 AEDT by arran
> list-heads file2.go,v
Parsing:  file2.go,v
1.3 on 2022-03-23 15:01:01 +1100 AEDT by arran
1.2 on 2022-03-23 14:01:01 +1100 AEDT by arran
1.1 on 2022-03-23 13:01:01 +1100 AEDT by arran

Notice how revision 1.2 occurs at 14:00 while, revision 1.3 in file2 and 1.2 in file2 occur at the same time.

The idea is this program will align the revision numbers to match:

> normalize-revisions file1.go,v file2.go,v 
> list-heads file1.go,v
Parsing:  file1.go,v file2.go,v
1.3 on 2022-03-23 15:01:01 +1100 AEDT by arran
1.1 on 2022-03-23 13:01:01 +1100 AEDT by arran
> list-heads file2.go,v
Parsing:  file2.go,v
1.3 on 2022-03-23 15:01:01 +1100 AEDT by arran
1.2 on 2022-03-23 14:01:01 +1100 AEDT by arran
1.1 on 2022-03-23 13:01:01 +1100 AEDT by arran

There is no real purpose or reason for doing this.

License

MIT.

Documentation

Index

Constants

View Source
const DateFormat = "2006.01.02.15.04.05"

Variables

This section is empty.

Functions

func AtQuote

func AtQuote(s string) string

func IsNotFound

func IsNotFound(err error) bool

func ParseAtQuotedString

func ParseAtQuotedString(s *Scanner) (string, error)

func ParseDescription

func ParseDescription(s *Scanner) (string, error)

func ParseHeader

func ParseHeader(s *Scanner, f *File) error

func ParseHeaderComment

func ParseHeaderComment(s *Scanner, havePropertyName bool) (string, error)

func ParseHeaderHead

func ParseHeaderHead(s *Scanner, haveHead bool) (string, error)

func ParseMultiLineText

func ParseMultiLineText(s *Scanner, havePropertyName bool, propertyName string, scanEndNewline bool) (string, error)

func ParseProperty

func ParseProperty(s *Scanner, havePropertyName bool, propertyName string, line bool) (string, error)

func ParseRevisionContentLog

func ParseRevisionContentLog(s *Scanner) (string, error)

func ParseRevisionContentText

func ParseRevisionContentText(s *Scanner) (string, error)

func ParseRevisionHeaderBranches

func ParseRevisionHeaderBranches(s *Scanner, rh *RevisionHead, havePropertyName bool) error

func ParseRevisionHeaderDateLine

func ParseRevisionHeaderDateLine(s *Scanner, haveHead bool, rh *RevisionHead) error

func ParseRevisionHeaderNext

func ParseRevisionHeaderNext(s *Scanner, haveHead bool) (string, error)

func ParseTerminatorFieldLine

func ParseTerminatorFieldLine(s *Scanner) error

func ScanFieldTerminator

func ScanFieldTerminator(s *Scanner) error

func ScanNewLine

func ScanNewLine(s *Scanner, orEof bool) error

func ScanRunesUntil

func ScanRunesUntil(s *Scanner, minimum int, until func([]byte) bool, name string) (err error)

func ScanStrings

func ScanStrings(s *Scanner, strs ...string) (err error)

func ScanUntilFieldTerminator

func ScanUntilFieldTerminator(s *Scanner) error

func ScanUntilNewLine

func ScanUntilNewLine(s *Scanner) error

func ScanUntilStrings

func ScanUntilStrings(s *Scanner, strs ...string) (err error)

func ScanWhiteSpace

func ScanWhiteSpace(s *Scanner, minimum int) error

Types

type File

type File struct {
	Head             string
	Description      string
	Comment          string
	Access           bool
	Symbols          bool
	Locks            []*Lock
	RevisionHeads    []*RevisionHead
	RevisionContents []*RevisionContent
}

func ParseFile

func ParseFile(r io.Reader) (*File, error)

func (*File) String

func (f *File) String() string

type Lock

type Lock struct {
	User     string
	Revision string
	Strict   bool
}

func ParseHeaderLocks

func ParseHeaderLocks(s *Scanner, havePropertyName bool) ([]*Lock, error)

func ParseLockLine

func ParseLockLine(s *Scanner) (*Lock, error)

func (*Lock) String

func (l *Lock) String() string

type MaxBuffer added in v0.0.11

type MaxBuffer int

func (MaxBuffer) ScannerOpt added in v0.0.11

func (mb MaxBuffer) ScannerOpt(scanner *Scanner)

type Pos

type Pos struct {
	Line   int
	Offset int
}

func (*Pos) String

func (p *Pos) String() string

type RevisionContent

type RevisionContent struct {
	Revision string
	Log      string
	Text     string
}

func ParseRevisionContent

func ParseRevisionContent(s *Scanner) (*RevisionContent, bool, error)

func ParseRevisionContents

func ParseRevisionContents(s *Scanner) ([]*RevisionContent, error)

func (*RevisionContent) String

func (c *RevisionContent) String() string

type RevisionHead

type RevisionHead struct {
	Revision     string
	Date         time.Time
	Author       string
	State        string
	Branches     []string
	NextRevision string
}

func ParseRevisionHeader

func ParseRevisionHeader(s *Scanner) (*RevisionHead, bool, error)

func ParseRevisionHeaders

func ParseRevisionHeaders(s *Scanner) ([]*RevisionHead, error)

func (*RevisionHead) String

func (h *RevisionHead) String() string

type ScanNotFound

type ScanNotFound []string

func (ScanNotFound) Error

func (se ScanNotFound) Error() string

type ScanUntilNotFound

type ScanUntilNotFound string

func (ScanUntilNotFound) Error

func (se ScanUntilNotFound) Error() string

type Scanner

type Scanner struct {
	*bufio.Scanner
	// contains filtered or unexported fields
}

func NewScanner

func NewScanner(r io.Reader, opts ...ScannerOpt) *Scanner

func (*Scanner) Bytes added in v0.0.11

func (s *Scanner) Bytes() []byte

func (*Scanner) LastScan

func (s *Scanner) LastScan() bool

func (*Scanner) Scan

func (s *Scanner) Scan() bool

func (*Scanner) Split

func (s *Scanner) Split(split bufio.SplitFunc)

func (*Scanner) Text added in v0.0.11

func (s *Scanner) Text() string

type ScannerOpt added in v0.0.11

type ScannerOpt interface {
	ScannerOpt(scanner *Scanner)
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL