aboutsummaryrefslogtreecommitdiffstats
path: root/difftree/internal/merkletrie/frame.go
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2016-12-14 23:12:44 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-12-14 23:12:44 +0100
commit0af572dd21c0aa79d13745b633ee24ba6c4d6cf1 (patch)
tree49e81e74e82d84fd88b2fc1e4b0dc7c7bfe9c40f /difftree/internal/merkletrie/frame.go
parentdf0f38af83f972f026d7e14150f3d37b95f13484 (diff)
downloadgo-git-0af572dd21c0aa79d13745b633ee24ba6c4d6cf1.tar.gz
move plumbing from top level package to plumbing (#183)
* plumbing: rename Object -> EncodedObject. * plumbing/storer: rename ObjectStorer -> EncodedObjectStorer. * move difftree to plumbing/difftree. * move diff -> utils/diff * make Object/Tag/Blob/Tree/Commit/File depend on storer. * Object and its implementations now depend only on storer.EncodedObjectStorer, not git.Repository. * Tests are decoupled accordingly. * move Object/Commit/File/Tag/Tree to plumbing/object. * move Object/Commit/File/Tag/Tree to plumbing/object. * move checkClose to utils/ioutil. * move RevListObjects to plumbing/revlist.Objects. * move DiffTree to plumbing/difftree package. * rename files with plural nouns to singular * plumbing/object: add GetBlob/GetCommit/GetTag/GetTree.
Diffstat (limited to 'difftree/internal/merkletrie/frame.go')
-rw-r--r--difftree/internal/merkletrie/frame.go79
1 files changed, 0 insertions, 79 deletions
diff --git a/difftree/internal/merkletrie/frame.go b/difftree/internal/merkletrie/frame.go
deleted file mode 100644
index a40c6ad..0000000
--- a/difftree/internal/merkletrie/frame.go
+++ /dev/null
@@ -1,79 +0,0 @@
-package merkletrie
-
-import (
- "bytes"
- "fmt"
-)
-
-const sep = "/"
-
-// A frame represents siblings in a trie, along with the path to get to
-// them. For example the frame for the node with key `b` in this trie:
-//
-// a
-// / \
-// / \
-// / \
-// b c
-// /|\ / \
-// y z x d e
-// |
-// g
-//
-// would be:
-//
-// f := frame{
-// base: "a/b", // path to the siblings
-// stack: []Node{z, y, x} // in reverse alphabetical order
-// }
-type frame struct {
- base string // absolute key of their parents
- stack []Noder // siblings, sorted in reverse alphabetical order by key
-}
-
-// newFrame returns a frame for the children of a node n.
-func newFrame(parentAbsoluteKey string, n Noder) *frame {
- return &frame{
- base: parentAbsoluteKey + sep + n.Key(),
- stack: n.Children(),
- }
-}
-
-func (f *frame) String() string {
- var buf bytes.Buffer
- _, _ = buf.WriteString(fmt.Sprintf("base=%q, stack=[", f.base))
-
- sep := ""
- for _, e := range f.stack {
- _, _ = buf.WriteString(sep)
- sep = ", "
- _, _ = buf.WriteString(fmt.Sprintf("%q", e.Key()))
- }
-
- _ = buf.WriteByte(']')
-
- return buf.String()
-}
-
-func (f *frame) top() (Noder, bool) {
- if len(f.stack) == 0 {
- return nil, false
- }
-
- top := len(f.stack) - 1
-
- return f.stack[top], true
-}
-
-func (f *frame) pop() (Noder, bool) {
- if len(f.stack) == 0 {
- return nil, false
- }
-
- top := len(f.stack) - 1
- ret := f.stack[top]
- f.stack[top] = nil
- f.stack = f.stack[:top]
-
- return ret, true
-}