Include file content

andybalholm
Mar 11, 2023, 11:02 PM
P2B4ZSO5YWG73KTDPO7KX5JNRNFDKF3UZEOJNGN22JRMAWQXFCSQC

Dependencies

  • [2] K23EJ6EJ Process commits in reverse
  • [3] 5ETDKF5F Start on data structures to represent fast-export stream
  • [*] Y7VFVY6E Initial dummy version
  • [*] RTQQLOCO Use real metadata, but no content yet

Change contents

  • edit in main.go at line 81
    [6.1212]
    [6.1212]
    }
    if changeIndex > 0 {
    if _, err := exec.Command("pijul", "unrecord", changes[changeIndex-1].Hash).Output(); err != nil {
    printErrorAndExit("Error unrecording change "+changes[changeIndex-1].Hash+":", err)
    }
    if _, err := exec.Command("pijul", "reset").Output(); err != nil {
    printErrorAndExit("Error from pijul reset:", err)
    }
  • edit in main.go at line 107
    [3.137]
    [3.137]
    // To specify the content for the commit, we remove everything
    // and then add back in all the files that are present after the change.
    commit.DeleteAll = true
    listing, err := exec.Command("pijul", "list").Output()
    if err != nil {
    printErrorAndExit("Error from pijul list:", err)
    }
    for _, f := range strings.Split(string(listing), "\n") {
    if f == "" {
    continue
    }
    info, err := os.Stat(f)
    if err != nil {
    printErrorAndExit("Error from Stat:", err)
    }
    if info.IsDir() {
    continue
    }
    data, err := os.ReadFile(f)
    if err != nil {
    printErrorAndExit("Error reading "+f+":", err)
    }
    b := stream.AddBlob(data)
    commit.Modifications = append(commit.Modifications, FileModify{Blob: b, Path: f})
    }
  • edit in fast-export.go at line 8
    [3.328]
    [3.328]
    type FileModify struct {
    Blob int
    Path string
    }
  • edit in fast-export.go at line 14
    [3.329]
    [3.329]
    func (f FileModify) WriteTo(w io.Writer) error {
    _, err := fmt.Fprintf(w, "M 644 :%d %s\n", f.Blob, f.Path)
    return err
    }
  • replacement in fast-export.go at line 20
    [3.350][3.350:422]()
    Mark int
    Committer string
    Timestamp time.Time
    Message string
    [3.350]
    [3.422]
    Mark int
    Committer string
    Timestamp time.Time
    Message string
    DeleteAll bool
    Modifications []FileModify
  • edit in fast-export.go at line 45
    [3.926]
    [3.926]
    }
    if c.DeleteAll {
    if _, err := fmt.Fprintln(w, "deleteall"); err != nil {
    return err
    }
    }
    for _, m := range c.Modifications {
    if err := m.WriteTo(w); err != nil {
    return err
    }
  • edit in fast-export.go at line 62
    [2.257]
    [2.257]
    type Blob struct {
    Mark int
    Data []byte
    }
    func (b Blob) WriteTo(w io.Writer) error {
    if _, err := fmt.Fprintln(w, "blob"); err != nil {
    return err
    }
    if b.Mark != 0 {
    if _, err := fmt.Fprintf(w, "mark :%d\n", b.Mark); err != nil {
    return err
    }
    }
    if _, err := fmt.Fprintln(w, "data", len(b.Data)); err != nil {
    return err
    }
    if _, err := w.Write(b.Data); err != nil {
    return err
    }
    if _, err := fmt.Fprintln(w); err != nil {
    return err
    }
    return nil
    }
  • edit in fast-export.go at line 91
    [2.384]
    [2.384]
    Blobs []Blob
  • edit in fast-export.go at line 111
    [2.760]
    [2.760]
    for _, b := range f.Blobs {
    if err := b.WriteTo(w); err != nil {
    return err
    }
    }
  • edit in fast-export.go at line 122
    [3.1001]
    [3.1001]
    }
    // AddBlob adds a blob to the stream and returns its mark.
    func (f *FastExportStream) AddBlob(data []byte) int {
    f.marks++
    b := Blob{
    Mark: f.marks,
    Data: data,
    }
    f.Blobs = append(f.Blobs, b)
    return b.Mark