deck

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b string) int

Compare is the canonical comparator of draft-fossil-artifact-format-00 §4.5.3: a raw-byte comparison in which octets are compared as unsigned values, locale-independent, with no Unicode normalization and no case folding. A shorter string sorts before any extension of itself, an absent value (the empty string) sorts before any present value, and the directory separator '/' (0x2F) receives no special treatment. It returns a negative number, zero, or a positive number as a sorts before, equal to, or after b.

§4.5.3 defines one comparator shared by the F, J, M and T sort checks, the delta-baseline merge walk (§8.2) and single-name search (§8.4). A second copy anywhere is a correctness hazard, not a style issue: F ordering is what the baseline binary search and the delta-manifest merge walk will rely on, so two comparators that disagree resolve a delta manifest wrongly rather than merely failing validation. Route every such comparison through here.

func FossilDecode

func FossilDecode(s string) string

FossilDecode reverses FossilEncode, per §4.3. It mirrors canonical fossil's defossilize(): each recognized escape maps back to its raw byte, and an unrecognized escape drops the backslash and keeps the following byte literally. A lone trailing backslash (which a conforming encoder never emits) is left as-is rather than consuming a nonexistent following byte.

func FossilEncode

func FossilEncode(s string) string

FossilEncode escapes a string for use as an artifact/sync card field value, per §4.3 of the format spec. It mirrors canonical fossil's fossilize(): the eight bytes newline, space, tab, carriage return, vertical tab, form feed, NUL and backslash are each written as a two-character backslash escape; all other bytes pass through unchanged.

func User

func User(s string) *string

User returns a pointer to s for constructing Deck.U. Go forbids taking the address of a string literal directly, so composite literals go through this instead of Deck{U: &s}. Deliberately *string rather than a named struct type: passing *string straight to database/sql lets a nil argument bind SQL NULL and a non-nil one deref to its value automatically (see Deck.U), so crosslink/rebuild call sites need no special-casing.

func VerifyZ

func VerifyZ(data []byte) error

VerifyZ validates a control artifact's trailing Z-card checksum. The blob may arrive PGP/SSH clearsigned (historical artifacts, e.g. Fossil's own 2007-era check-ins); stripClearsign isolates the inner content the Z card is computed over so the last-35-byte check lands on the Z card and not on a trailing signature block. The artifact's content-addressed hash is computed over the raw blob elsewhere and is unaffected by this stripping.

Types

type ArtifactType

type ArtifactType int
const (
	Checkin ArtifactType = iota
	Wiki
	Ticket
	Event
	Cluster
	ForumPost
	Attachment
	Control
)

type AttachmentCard

type AttachmentCard struct {
	Filename string
	Target   string
	Source   string
}

type CherryPick

type CherryPick struct {
	IsBackout bool
	Target    string
	Baseline  string
}

type Deck

type Deck struct {
	Type ArtifactType
	A    *AttachmentCard
	B    string
	C    string
	D    time.Time
	E    *EventCard
	F    []FileCard
	G    string
	H    string
	I    string
	J    []TicketField
	K    string
	L    string
	M    []string
	N    string
	P    []string
	Q    []CherryPick
	R    string
	T    []TagCard
	// U tracks the check-in user with three distinct states, mirroring
	// fossil's src/manifest.c:1008-1016 U-card handling:
	//   - nil: no U-card in the manifest at all (SQL NULL at crosslink time)
	//   - non-nil, "anonymous": U-card present but empty (resolved at parse
	//     time, matching canonical fossil's own substitution)
	//   - non-nil, non-empty: U-card present with a login name
	// Deliberately *string rather than string: a bare "" cannot represent
	// "absent" and "present-but-empty" at once, which previously collapsed
	// both into the same stored value. See User for constructing literals.
	U *string
	W []byte
	Z string
}

func Parse

func Parse(data []byte) (*Deck, error)

func (*Deck) ComputeR

func (d *Deck) ComputeR(getContent func(uuid string) ([]byte, error)) (string, error)

func (*Deck) Marshal

func (d *Deck) Marshal() ([]byte, error)

type EventCard

type EventCard struct {
	Date time.Time
	UUID string
}

type FileCard

type FileCard struct {
	Name    string
	UUID    string
	Perm    string
	OldName string
}

type TagCard

type TagCard struct {
	Type  TagType
	Name  string
	UUID  string
	Value string
}

type TagType

type TagType byte
const (
	TagSingleton   TagType = '+'
	TagPropagating TagType = '*'
	TagCancel      TagType = '-'
)

type TicketField

type TicketField struct {
	Name  string
	Value string
}

Jump to

Keyboard shortcuts

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