patch

package
v0.0.0-...-3e59e0e Latest Latest
Warning

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

Go to latest
Published: May 21, 2014 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

The patch package provides support for calculating and applying revlog patches

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(w io.Writer, orig []byte, pos int, patch []Hunk) (n int, err error)

Apply a patch to a slice of original bytes, writing the output to an io.Writer. The number of bytes written, i.e. the size of the resulting file, is returned.

Types

type Hunk

type Hunk struct {
	// contains filtered or unexported fields
}

A hunk describes how a certain region of original data is to be modified.

func Parse

func Parse(data []byte) (hunks []Hunk, err error)

Parse converts a patch from its binary representation into a slice of Hunks.

func (*Hunk) Adjust

func (h *Hunk) Adjust(f func(begin, end int, data []byte) []byte)

func (*Hunk) Dump

func (h *Hunk) Dump(w io.Writer)

Dump prints the information stored in a Hunk for debug purposes.

type Joiner

type Joiner struct {
	// contains filtered or unexported fields
}

A Joiner is a patch buffer that is the target of usually many calls to its method JoinPatches.

func NewJoiner

func NewJoiner(preAlloc int) *Joiner

Creates a new Joiner. To avoid reallocations of the patch buffer as the patch grows, an initial size may be stated.

func (*Joiner) JoinPatches

func (j *Joiner) JoinPatches(left, right []Hunk) []Hunk

With ‘left’ and ‘right’ being patches of two adjacent revlog revisions, JoinPatches propagates hunk by hunk from the right to the left side, probably intersecting hunks one or more times. The resulting patch will be stored into the Joiner. Both right and left hunks may be altered.

Jump to

Keyboard shortcuts

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