pull log output: optimize to be readable by humans
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
// Code generated by "stringer -type=Conflict"; DO NOT EDIT.
|
||||
|
||||
package zfs
|
||||
|
||||
import "fmt"
|
||||
|
||||
const _Conflict_name = "ConflictIncrementalConflictAllRightConflictNoCommonAncestorConflictDiverged"
|
||||
|
||||
var _Conflict_index = [...]uint8{0, 19, 35, 59, 75}
|
||||
|
||||
func (i Conflict) String() string {
|
||||
if i < 0 || i >= Conflict(len(_Conflict_index)-1) {
|
||||
return fmt.Sprintf("Conflict(%d)", i)
|
||||
}
|
||||
return _Conflict_name[_Conflict_index[i]:_Conflict_index[i+1]]
|
||||
}
|
||||
+26
-4
@@ -17,13 +17,14 @@ func (l fsbyCreateTXG) Less(i, j int) bool {
|
||||
return l[i].CreateTXG < l[j].CreateTXG
|
||||
}
|
||||
|
||||
//go:generate stringer -type=Conflict
|
||||
type Conflict int
|
||||
|
||||
const (
|
||||
ConflictIncremental = 0 // no conflict, incremental repl possible
|
||||
ConflictAllRight = 1 // no conflict, initial repl possible
|
||||
ConflictNoCommonAncestor = 2
|
||||
ConflictDiverged = 3
|
||||
ConflictIncremental Conflict = iota // no conflict, incremental repl possible
|
||||
ConflictAllRight // no conflict, initial repl possible
|
||||
ConflictNoCommonAncestor
|
||||
ConflictDiverged
|
||||
)
|
||||
|
||||
/* The receiver (left) wants to know if the sender (right) has more recent versions
|
||||
@@ -73,6 +74,27 @@ type FilesystemDiff struct {
|
||||
MRCAPathRight []FilesystemVersion
|
||||
}
|
||||
|
||||
func (f FilesystemDiff) String() (str string) {
|
||||
var b bytes.Buffer
|
||||
|
||||
fmt.Fprintf(&b, "%s, ", f.Conflict)
|
||||
|
||||
switch f.Conflict {
|
||||
case ConflictIncremental:
|
||||
fmt.Fprintf(&b, "incremental path length %v, common ancestor at %s", len(f.IncrementalPath)-1, f.IncrementalPath[0])
|
||||
case ConflictAllRight:
|
||||
fmt.Fprintf(&b, "%v versions, most recent is %s", len(f.MRCAPathRight)-1, f.MRCAPathRight[len(f.MRCAPathRight)-1])
|
||||
case ConflictDiverged:
|
||||
fmt.Fprintf(&b, "diverged at %s", f.MRCAPathRight[0]) // right always has at least one snap...?
|
||||
case ConflictNoCommonAncestor:
|
||||
fmt.Fprintf(&b, "no diff to show")
|
||||
default:
|
||||
fmt.Fprintf(&b, "unknown conflict type, likely a bug")
|
||||
}
|
||||
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// we must assume left and right are ordered ascendingly by ZFS_PROP_CREATETXG and that
|
||||
// names are unique (bas ZFS_PROP_GUID replacement)
|
||||
func MakeFilesystemDiff(left, right []FilesystemVersion) (diff FilesystemDiff) {
|
||||
|
||||
@@ -45,6 +45,10 @@ type FilesystemVersion struct {
|
||||
Creation time.Time
|
||||
}
|
||||
|
||||
func (v FilesystemVersion) String() string {
|
||||
return fmt.Sprintf("%s%s", v.Type.DelimiterChar(), v.Name)
|
||||
}
|
||||
|
||||
func (v FilesystemVersion) ToAbsPath(p *DatasetPath) string {
|
||||
var b bytes.Buffer
|
||||
b.WriteString(p.ToString())
|
||||
|
||||
Reference in New Issue
Block a user