diff --git a/cmd/debugtree/debugtree.go b/cmd/debugtree/debugtree.go index 7bcd4dd83..47d4841b9 100644 --- a/cmd/debugtree/debugtree.go +++ b/cmd/debugtree/debugtree.go @@ -51,7 +51,7 @@ func main() { importer := treearchive.NewTreeImporter(archive.ListStorage(), archive.TreeStorage()) st = time.Now() - err = importer.Import("") + err = importer.Import(*fromRoot, "") if err != nil { log.Fatal("can't import the tree", err) } @@ -82,7 +82,7 @@ func main() { } fmt.Println("Change:") fmt.Println(pbtypes.Sprint(ch.Model)) - err = importer.Import(ch.Id) + err = importer.Import(false, ch.Id) if err != nil { log.Fatal("can't import the tree before", ch.Id, err) } diff --git a/core/block/editor/state/test/buildfast_test.go b/core/block/editor/state/test/buildfast_test.go index 2cabaafb9..6b0846932 100644 --- a/core/block/editor/state/test/buildfast_test.go +++ b/core/block/editor/state/test/buildfast_test.go @@ -50,7 +50,7 @@ func testBuildFast(b *testing.T, filepath string) { importer := treearchive.NewTreeImporter(archive.ListStorage(), archive.TreeStorage()) - err = importer.Import("") + err = importer.Import(false, "") if err != nil { log.Fatal("can't import the tree", err) } @@ -64,7 +64,7 @@ func testBuildFast(b *testing.T, filepath string) { importer2 := treearchive.NewTreeImporter(archive.ListStorage(), archive.TreeStorage()) - err = importer2.Import("") + err = importer2.Import(false, "") if err != nil { log.Fatal("can't import the tree", err) } diff --git a/core/debug/service.go b/core/debug/service.go index 20a3478d0..33008a0eb 100644 --- a/core/debug/service.go +++ b/core/debug/service.go @@ -165,7 +165,7 @@ func (d *debug) TreeHeads(ctx context.Context, id string) (info TreeInfo, err er if err != nil { return } - tree, err := spc.TreeBuilder().BuildHistoryTree(ctx, id, objecttreebuilder.HistoryTreeOpts{}) + tree, err := spc.TreeBuilder().BuildHistoryTree(ctx, id, objecttreebuilder.HistoryTreeOpts{Heads: []string{""}}) if err != nil { return } diff --git a/core/debug/treearchive/treeimporter.go b/core/debug/treearchive/treeimporter.go index 025937939..82728b162 100644 --- a/core/debug/treearchive/treeimporter.go +++ b/core/debug/treearchive/treeimporter.go @@ -44,7 +44,7 @@ func (m MarshalledJsonChange) MarshalJSON() ([]byte, error) { type TreeImporter interface { ObjectTree() objecttree.ReadableObjectTree State() (*state.State, error) // set fullStateChain to true to get full state chain, otherwise only the last state will be returned - Import(beforeId string) error + Import(fromRoot bool, beforeId string) error Json() (TreeJson, error) ChangeAt(idx int) (IdChange, error) } @@ -83,15 +83,19 @@ func (t *treeImporter) State() (*state.State, error) { return st, nil } -func (t *treeImporter) Import(beforeId string) (err error) { +func (t *treeImporter) Import(fullTree bool, beforeId string) (err error) { aclList, err := list.BuildAclList(t.listStorage, list.NoOpAcceptorVerifier{}) if err != nil { return } + var heads []string + if !fullTree { + heads = []string{beforeId} + } t.objectTree, err = objecttree.BuildNonVerifiableHistoryTree(objecttree.HistoryTreeParams{ TreeStorage: t.treeStorage, AclList: aclList, - Heads: []string{beforeId}, + Heads: heads, IncludeBeforeId: true, })