diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2011-04-30 21:42:12 +0800 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2011-05-10 09:25:13 +0800 |
commit | 491b4c361f3a612835e76604fbd751e6e6905c3d (patch) | |
tree | 0fdb2e86fab5938bf171d23ef7cf23ccd555e531 /src/cli_bin.cpp | |
parent | 4c5199a11c951361934c7c5d4bd91e7e2ae8679a (diff) | |
download | vyatta-cfg-491b4c361f3a612835e76604fbd751e6e6905c3d.tar.gz vyatta-cfg-491b4c361f3a612835e76604fbd751e6e6905c3d.zip |
preliminary implementation of new commit
(cherry picked from commit 1b2a0fd1ae1e6dfc18e4f75f73cd7befb47cf538)
Diffstat (limited to 'src/cli_bin.cpp')
-rw-r--r-- | src/cli_bin.cpp | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/cli_bin.cpp b/src/cli_bin.cpp index 4d32c15..71c9fa9 100644 --- a/src/cli_bin.cpp +++ b/src/cli_bin.cpp @@ -23,6 +23,8 @@ #include <cli_cstore.h> #include <cstore/cstore.hpp> +#include <cnode/cnode.hpp> +#include <commit/commit-algorithm.hpp> using namespace cstore; @@ -37,6 +39,7 @@ static const char *op_bin_name[] = { "my_comment", "my_discard", "my_move", + "my_commit", NULL }; static const char *op_Str[] = { @@ -49,6 +52,7 @@ static const char *op_Str[] = { "Comment", "Discard", "Move", + "Commit", NULL }; static const char *op_str[] = { @@ -61,6 +65,7 @@ static const char *op_str[] = { "comment", "discard", "move", + "commit", NULL }; static const bool op_need_cfg_node_args[] = { @@ -73,11 +78,26 @@ static const bool op_need_cfg_node_args[] = { true, false, true, + false, + false // dummy +}; +static const bool op_use_edit_level[] = { + true, + true, + true, + true, + true, + true, + true, + true, + true, + false, false // dummy }; #define OP_Str op_Str[op_idx] #define OP_str op_str[op_idx] #define OP_need_cfg_node_args op_need_cfg_node_args[op_idx] +#define OP_use_edit_level op_use_edit_level[op_idx] static void doSet(Cstore& cstore, const Cpath& path_comps) @@ -173,6 +193,17 @@ doMove(Cstore& cstore, const Cpath& path_comps) } } +static void +doCommit(Cstore& cstore, const Cpath& path_comps) +{ + Cpath dummy; + cnode::CfgNode aroot(cstore, dummy, true, true); + cnode::CfgNode wroot(cstore, dummy, false, true); + if (!commit::doCommit(cstore, aroot, wroot)) { + exit(1); + } +} + typedef void (*OpFuncT)(Cstore& cstore, const Cpath& path_comps); OpFuncT OpFunc[] = { @@ -185,6 +216,7 @@ OpFuncT OpFunc[] = { &doComment, &doDiscard, &doMove, + &doCommit, NULL }; @@ -212,8 +244,7 @@ main(int argc, char **argv) bye("nothing to %s\n", OP_str); } - // actual CLI operations use the edit levels from environment, so pass true. - Cstore *cstore = Cstore::createCstore(true); + Cstore *cstore = Cstore::createCstore(OP_use_edit_level); Cpath path_comps(const_cast<const char **>(argv + 1), argc - 1); // call the op function |