From 1b2a0fd1ae1e6dfc18e4f75f73cd7befb47cf538 Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Sat, 30 Apr 2011 21:42:12 +0800 Subject: preliminary implementation of new commit --- src/cli_bin.cpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'src/cli_bin.cpp') 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 #include +#include +#include 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(argv + 1), argc - 1); // call the op function -- cgit v1.2.3