Try a new approach to deletion

andybalholm
Apr 10, 2023, 6:46 PM
4JR6O4JTKSYR2AU6AMEJDMDYNGTYDGTF7PEPSEGOLUGRYZ5POE4AC

Dependencies

  • [2] OMRSTWPY Update edges instead of replacing them
  • [3] 7VXK6DMJ Refine definition of deleted vertexes
  • [4] KMLCXD5D Handle both types of root directory
  • [5] FWGMIVUZ Add tijo-cat command
  • [6] XJAW762U Add tijo-export command
  • [7] 7D7CMNN3 Handle Edit hunks
  • [8] DF5RFSLH Read directory entries
  • [9] YGCYIX6C Handle Replacement hunks
  • [10] AYLFNM5C Add the ability to output the contents of a file.
  • [11] EYPCPIP7 Apply changes and build a graph

Change contents

  • edit in pristine.go at line 18
    [5.338]
    [5.338]
    DeletedBy []Hash
  • edit in pristine.go at line 114
    [5.972]
    [5.972]
    if len(oldBlock.DeletedBy) > 0 {
    newBlock.DeletedBy = make([]Hash, len(oldBlock.DeletedBy))
    copy(newBlock.DeletedBy, oldBlock.DeletedBy)
    }
  • edit in pristine.go at line 148
    [5.310][5.310:335](),[5.335][5.1837:1838](),[5.1837][5.1837:1838]()
    var deletions []NewEdge
  • replacement in pristine.go at line 180
    [5.385][5.385:492](),[5.492][5.492:524](),[5.524][5.524:572]()
    if e.Flag&EdgeFlagsDeleted == EdgeFlagsDeleted {
    deletions = append(deletions, e)
    } else {
    err := g.putNewEdge(h, e)
    if err != nil {
    return err
    }
    [5.385]
    [5.572]
    err := g.putNewEdge(h, e)
    if err != nil {
    return err
  • edit in pristine.go at line 189
    [5.3011][5.586:617](),[5.617][5.617:645](),[5.645][5.645:685]()
    for _, e := range deletions {
    err := g.putNewEdge(h, e)
    if err != nil {
    return err
    }
    }
  • edit in pristine.go at line 193
    [5.746][5.746:952]()
    source := g.blockEnding(coalesceHash(ne.From.Change, change), ne.From.Pos)
    if source == nil {
    return fmt.Errorf("not found: block ending at %v:%d", coalesceHash(ne.From.Change, change), ne.From.Pos)
    }
  • edit in pristine.go at line 196
    [5.1155][5.1155:1159](),[5.1159][5.1159:1222]()
    }
    if target.End > ne.To.End {
    g.splitBlock(target, ne.To.End)
  • replacement in pristine.go at line 200
    [5.1282][2.0:106](),[2.106][5.1360:1430](),[5.1360][5.1360:1430](),[5.1430][2.107:164]()
    found := false
    // Look for the old edge and update it if it is found.
    for _, e := range source.Edges {
    if e.Change == introducedBy && e.From == source && e.To == target {
    found = true
    e.Change = change
    e.Flag = ne.Flag
    [5.1282]
    [5.1496]
    for {
    if target.End > ne.To.End {
    g.splitBlock(target, ne.To.End)
    }
    if ne.Flag&EdgeFlagsDeleted != 0 {
    // This is a deletion, so we'll add this change to the DeletedBy list if it
    // isn't there already.
    found := false
    for _, h := range target.DeletedBy {
    if h == change {
    found = true
    break
    }
    }
    if !found {
    target.DeletedBy = append(target.DeletedBy, change)
    }
    } else {
    // This is an undeletion, so we'll remove the change that did the deletion
    // from the DeletedBy list.
    for i, h := range target.DeletedBy {
    if h == introducedBy {
    target.DeletedBy = append(target.DeletedBy[:i], target.DeletedBy[i+1:]...)
    break
    }
    }
    }
    if target.End == ne.To.End {
  • edit in pristine.go at line 232
    [5.1509][5.1509:1512]()
    }
  • replacement in pristine.go at line 233
    [2.166][2.166:223]()
    if !found {
    makeEdge(change, ne.Flag, source, target)
    [2.166]
    [5.1723]
    newTarget := g.blockStarting(target.Change, target.End)
    if newTarget == nil {
    return fmt.Errorf("not found: block to follow %v:%d:%d", target.Change, target.Start, target.End)
    }
    target = newTarget
  • replacement in pristine.go at line 273
    [4.444][4.444:480]()
    if e.Flag&EdgeFlagsDeleted != 0 {
    [4.444]
    [4.480]
    if len(e.To.DeletedBy) > 0 {
  • replacement in pristine.go at line 285
    [4.743][4.743:780]()
    if f.Flag&EdgeFlagsDeleted != 0 {
    [4.743]
    [5.427]
    if len(f.To.DeletedBy) > 0 {
  • edit in output.go at line 46
    [5.929][5.929:967]()
    deleted := make([]bool, len(blocks))
  • edit in output.go at line 48
    [5.1010][3.0:185](),[3.185][3.185:215](),[3.215][5.1062:1087](),[5.1062][5.1062:1087]()
    var dead, alive int
    for _, e := range b.ReverseEdges {
    if e.Flag&EdgeFlagsBlock != 0 {
    if e.Flag&EdgeFlagsDeleted != 0 {
    dead++
    } else {
    alive++
    }
    }
    }
    if dead > 0 && alive == 0 {
    deleted[i] = true
    }
  • replacement in output.go at line 94
    [5.2277][5.2277:2298]()
    if !deleted[j] {
    [5.2277]
    [5.2298]
    if len(blocks[j].DeletedBy) == 0 {
  • replacement in output.go at line 101
    [5.2406][5.2406:2427]()
    if !deleted[j] {
    [5.2406]
    [5.2427]
    if len(blocks[j].DeletedBy) == 0 {
  • replacement in output.go at line 126
    [5.2907][5.2907:2925]()
    if deleted[i] {
    [5.2907]
    [5.2925]
    if len(b.DeletedBy) > 0 {
  • edit in output.go at line 136
    [5.3016]
    [5.3016]
    for j := 0; j < conflictEnd[len(blocks)]; j++ {
    fmt.Fprintf(dest, ">>>>>>>\n")
    }
  • replacement in output.go at line 180
    [5.757][5.757:793]()
    if e.Flag&EdgeFlagsDeleted != 0 {
    [5.757]
    [5.793]
    if len(e.To.DeletedBy) > 0 {
  • replacement in output.go at line 192
    [5.1117][5.1117:1162]()
    if inodeEdge.Flag&EdgeFlagsDeleted != 0 {
    [5.1117]
    [5.1162]
    if len(inodeEdge.To.DeletedBy) > 0 {
  • edit in output.go at line 200
    [5.1365]
    [5.1365]
    }
    if entry.Inode == nil && len(b.Edges) > 0 {
    // All the potential inodes are deleted.
    // But there has to be one.
    // So we'll just pick the first one.
    entry.Inode = b.Edges[0].To