versioned_graph/commit
minor work on predicate naming and documentation
author | Jacco van Ossenbruggen |
---|---|
Mon Jun 23 10:43:35 2014 +0200 | |
committer | Jacco van Ossenbruggen |
Mon Jun 23 10:43:35 2014 +0200 | |
commit | 74721f22ab043d204ce5bb35dd6d0e0e60e15e46 |
tree | 332f9a9564be64d04a2b48641803c5e1ccbc8afd |
parent | a595554ff9a7f3204640bb6b80c40735981e31a9 |
Diff style: patch stat
diff --git a/lib/graph_version.pl b/lib/graph_version.pl index 6ed64c0..c3ee16d 100644 --- a/lib/graph_version.pl +++ b/lib/graph_version.pl @@ -189,7 +189,7 @@ gv_checkout(Commit) :- setting(gv_blob_store, BlobsStore), set_setting(gv_blob_store, git_only), - gv_load_blobs(TreeTriples, graph), + gv_restore_blobs(TreeTriples, graph), set_setting(gv_blob_store, BlobsStore). diff --git a/lib/gv_git_objects.pl b/lib/gv_git_objects.pl index 37f5cc0..ff5f03f 100644 --- a/lib/gv_git_objects.pl +++ b/lib/gv_git_objects.pl @@ -6,7 +6,7 @@ % do we need to export these? gv_graph_triples/2, gv_tree_triples/2, - gv_load_blobs/2, + gv_restore_blobs/2, gv_init_rdf/2, gv_move_head/3 ]). @@ -163,11 +163,36 @@ gv_copy_graph(Source, Target) :- gv_graph_triples(Target, Triples) ). +%% gv_restore_blobs(+TreeTriples, +Mode) is semidet. +% +% * Mode == graph: Restore Blobs into their associated named +% graphs identified by IRI as defined the Tree triples in +% TreeTriples. +% * Mode == hash: Restore Blobs into their associated named graphs +% identified by the Trusty (hash) URI by loading them from the git +% repo. (used when restoring the history from GIT). +gv_restore_blobs([], _) :- !. +gv_restore_blobs([rdf(_IRI, _P, Hash)|T], hash) :- + rdf_graph(Hash),!, + gv_restore_blobs(T, hash). +gv_restore_blobs([rdf(IRI,_P,Hash)|T], Mode) :- + gv_graph_triples(Hash, Triples), + ( Mode == graph + -> gv_graph_triples(IRI, Triples) + ; gv_graph_triples(Hash, Triples) + ), + gv_restore_blobs(T, Mode). + %% gv_graph_triples(+Graph, -Triples) is det. %% gv_graph_triples(+Graph, +Triples) is det. % -% When Triples are given, they are asserted to Graph, -% otherwise, Triples are unified with the triples in Graph. +% When Triples are given, they are asserted to Graph. +% +% When Graph is given, Triples are unified with the triples in +% Graph. If Graph is an existing Graph in the triple store and +% graph_version:gv_blob_store is not set to git_only, the Triples +% are copied from Graph. Otherwise, Graph is read back from the +% corresponding Blob object in the git repository. gv_graph_triples(Graph, Triples) :- nonvar(Triples), @@ -208,6 +233,14 @@ git_tree_pair_to_triple([hash(H),name(Senc)], rdf(Sdec,P,O)) :- gv_hash_uri(H,O). +%% gv_tree_store(+Tree, -Triples) is semidet. +% +% Unify Triples with the content of tree object Tree. +% If Tree is a named graph in the triple store, just +% unify with these triples. +% If not, read Tree back from the corresponding tree object in the +% git repository. + gv_tree_triples(null, []) :- !. gv_tree_triples(Tree, Triples) :- nonvar(Tree), @@ -222,20 +255,6 @@ gv_tree_triples(Tree, Triples) :- maplist(git_tree_pair_to_triple, TreeObject, Triples). -gv_load_blobs([], _) :- !. -gv_load_blobs([rdf(_IRI, _P, Hash)|T], hash) :- - rdf_graph(Hash),!, - gv_load_blobs(T, hash). -gv_load_blobs([rdf(IRI,_P,Hash)|T], Mode) :- - gv_graph_triples(Hash, Triples), - ( Mode == graph - -> gv_graph_triples(IRI, Triples) - ; gv_graph_triples(Hash, Triples) - ), - gv_load_blobs(T, Mode). - - - gv_init_rdf(Ref, Options) :- option(gv_refs_prefix(Refs), Options), atom_concat(Refs, 'HEAD', HEAD), diff --git a/lib/gv_replay.pl b/lib/gv_replay.pl index be861e5..250ed2a 100644 --- a/lib/gv_replay.pl +++ b/lib/gv_replay.pl @@ -103,7 +103,7 @@ tree_to_rdf(Tree, Options) :- ), ( option(blobs(ignore), Options) -> true - ; gv_load_blobs(Triples, hash) + ; gv_restore_blobs(Triples, hash) ). tree_to_git(Tree, Options) :-