# # add_file "tests/t_merge_lca.at" # # patch "ChangeLog" # from [fbf57c7c14ead2a49facb984e69619cdce902243] # to [96d733329bf930205f319adea167c9b7f67ff818] # # patch "app_state.cc" # from [414019cdae9443eaf3d71170e6af2e20fda97759] # to [1352a5df1824518d6d38a3267746a6afa57cb239] # # patch "app_state.hh" # from [0e88fe54c292dc993d06deb421c01c560ab1739c] # to [ca251afc3129d7d5d530a4f96a97abe925fa3841] # # patch "commands.cc" # from [b5528455d426bb0c337f39f491cbf287a0df87ab] # to [19c0c8f86e9828ac94dcd8fc0d1c733715501d1a] # # patch "monotone.cc" # from [0fb2807f0fcfd0a9710a6b83e1344627f58fd9cd] # to [25377c90318075893420d6062e3471d6c14cd084] # # patch "monotone.texi" # from [5cfe07d5483a24d398fb7766bfebeb6702308f6a] # to [9605fc4307f18598ac349768f136f6f4a708bfc0] # # patch "netsync.cc" # from [3be43c22b543685088cbedf9d3c9947abc5bbd1e] # to [e84864cf7c21fe27115481a4c465f2df78dcf1b8] # # patch "options.hh" # from [814c3c354201a830e7bce20f0a8dc48d79b9cf8c] # to [60f0ccc51cf1a34aff43215840ec24e42cae6374] # # patch "revision.cc" # from [79e7c4cd1a2b6e7b735515a9cb7d42702002f275] # to [c101902d74cfb7895e97353079610a8ac824ce52] # # patch "tests/t_merge_lca.at" # from [] # to [b3836fc9531f92a6fb429e97c0c3076dadc80aeb] # # patch "testsuite.at" # from [7d6278fa857ee6c7324eaa5cde6ed5d86d033aae] # to [0cdcecc517caab0d82b22920ffade5dcd8107b52] # =============================================== --- ChangeLog fbf57c7c14ead2a49facb984e69619cdce902243 +++ ChangeLog 96d733329bf930205f319adea167c9b7f67ff818 @@ -1,5 +1,17 @@ 2005-08-08 Nathaniel Smith + * commands.cc (merge, propagate): Take --lca. + * options.hh: Add OPT_LCA. + * monotone.cc (coptions, cpp_main): Support it it. + * app_state.{hh,cc} (app_state::usa_lca): New variable. + * revision.cc (find_common_ancestor_for_merge): Use LCA if user + passed --lca. + * tests/t_merge_lca.at: New test. + * testsuite.at: Add it. + * monotone.texi (Tree): Document --lca. + +2005-08-08 Nathaniel Smith + * NEWS: First-pass for 0.22 release. * UPGRADE: Likewise. =============================================== --- app_state.cc 414019cdae9443eaf3d71170e6af2e20fda97759 +++ app_state.cc 1352a5df1824518d6d38a3267746a6afa57cb239 @@ -34,7 +34,8 @@ app_state::app_state() : branch_name(""), db(""), stdhooks(true), rcfiles(true), diffs(false), no_merges(false), set_default(false), verbose(false), search_root("/"), - depth(-1), last(-1), diff_format(unified_diff), diff_args_provided(false) + depth(-1), last(-1), diff_format(unified_diff), diff_args_provided(false), + use_lca(false) { db.set_app(this); } =============================================== --- app_state.hh 0e88fe54c292dc993d06deb421c01c560ab1739c +++ app_state.hh ca251afc3129d7d5d530a4f96a97abe925fa3841 @@ -57,6 +57,7 @@ diff_type diff_format; bool diff_args_provided; utf8 diff_args; + bool use_lca; =============================================== --- commands.cc b5528455d426bb0c337f39f491cbf287a0df87ab +++ commands.cc 19c0c8f86e9828ac94dcd8fc0d1c733715501d1a @@ -3199,7 +3199,7 @@ CMD(merge, "tree", "", "merge unmerged heads of branch", - OPT_BRANCH_NAME % OPT_DATE % OPT_AUTHOR) + OPT_BRANCH_NAME % OPT_DATE % OPT_AUTHOR % OPT_LCA) { set heads; @@ -3249,7 +3249,7 @@ CMD(propagate, "tree", "SOURCE-BRANCH DEST-BRANCH", "merge from one branch to another asymmetrically", - OPT_DATE % OPT_AUTHOR) + OPT_DATE % OPT_AUTHOR % OPT_LCA) { // this is a special merge operator, but very useful for people maintaining // "slightly disparate but related" trees. it does a one-way merge; less =============================================== --- monotone.cc 0fb2807f0fcfd0a9710a6b83e1344627f58fd9cd +++ monotone.cc 25377c90318075893420d6062e3471d6c14cd084 @@ -65,6 +65,7 @@ {"context", 0, POPT_ARG_NONE, NULL, OPT_CONTEXT_DIFF, "Use context diff format", NULL}, {"external", 0, POPT_ARG_NONE, NULL, OPT_EXTERNAL_DIFF, "Use external diff hook for generating diffs", NULL}, {"diff-args", 0, POPT_ARG_STRING, &argstr, OPT_EXTERNAL_DIFF_ARGS, "Argument to pass external diff hook", NULL}, + {"lca", 0, POPT_ARG_NONE, NULL, OPT_LCA, "Use least common ancestor as ancestor for merge", NULL}, { NULL, 0, 0, NULL, 0, NULL, NULL } }; @@ -434,6 +435,10 @@ app.set_diff_args(utf8(string(argstr))); break; + case OPT_LCA: + app.use_lca = true; + break; + case OPT_HELP: default: requested_help = true; =============================================== --- monotone.texi 5cfe07d5483a24d398fb7766bfebeb6702308f6a +++ monotone.texi 9605fc4307f18598ac349768f136f6f4a708bfc0 @@ -3388,7 +3388,8 @@ computer clocks is not reliable, so monotone usually ignores time. address@hidden monotone merge address@hidden address@hidden monotone merge address@hidden address@hidden monotone merge --lca address@hidden This command merges the ``heads'' of @var{branchname}, if there are multiple heads, and commits the results to the database, marking the resulting merged revision as a member of @var{branchname}. The merged @@ -3400,8 +3401,17 @@ algorithm. The process then repeats for each additional head, using the result of each previous merge as an input to the next. +The @option{--lca} option is provided as a temporary workaround for some +inherent problems with 3-way merging; if you encounter a huge number of +spurious conflicts, or get an invariant failure, then you may wish to +try using @option{--lca}. Using it @emph{can}, in certain +circumstances, cause some edits that should be conflicts to merge +cleanly instead, which is why it is not the default; but these cases are +rare, and until we can find something better than 3-way merging to use, +you may find this option more convenient than @command{explicit_merge} @item monotone propagate @var{sourcebranch} @var{destbranch} address@hidden monotone propagate --lca @var{sourcebranch} @var{destbranch} This command takes a unique head from @var{sourcebranch} and merges it with a unique head of @var{destbranch}, using the least common ancestor of the two heads for a 3-way merge. The resulting revision is @@ -3417,6 +3427,14 @@ branches, public contribution branches, or branches devoted to the development of a single module within a larger project. +The @option{--lca} option is provided as a temporary workaround for some +inherent problems with 3-way merging; if you encounter a huge number of +spurious conflicts, or get an invariant failure, then you may wish to +try using @option{--lca}. Using it @emph{can}, in certain +circumstances, cause some edits that should be conflicts to merge +cleanly instead, which is why it is not the default; but these cases are +rare, and until we can find something better than 3-way merging to use, +you may find this option more convenient than @command{explicit_merge} @item monotone explicit_merge @var{id} @var{id} @var{destbranch} @itemx monotone explicit_merge @var{id} @var{id} @var{ancestor} @var{destbranch} =============================================== --- netsync.cc 3be43c22b543685088cbedf9d3c9947abc5bbd1e +++ netsync.cc e84864cf7c21fe27115481a4c465f2df78dcf1b8 @@ -3618,7 +3618,7 @@ session::rebuild_merkle_trees(app_state & app, set const & branchnames) { - P(F("finding items to be synchronized:\n")); + P(F("finding items to synchronize:\n")); for (set::const_iterator i = branchnames.begin(); i != branchnames.end(); ++i) L(F("including branch %s") % *i); =============================================== --- options.hh 814c3c354201a830e7bce20f0a8dc48d79b9cf8c +++ options.hh 60f0ccc51cf1a34aff43215840ec24e42cae6374 @@ -41,3 +41,4 @@ #define OPT_CONTEXT_DIFF 32 #define OPT_EXTERNAL_DIFF 33 #define OPT_EXTERNAL_DIFF_ARGS 34 +#define OPT_LCA 35 =============================================== --- revision.cc 79e7c4cd1a2b6e7b735515a9cb7d42702002f275 +++ revision.cc c101902d74cfb7895e97353079610a8ac824ce52 @@ -502,6 +502,11 @@ revision_id & anc, app_state & app) { + // Temporary workaround until we figure out how to clean up the whole + // ancestor selection mess: + if (app.use_lca) + return find_least_common_ancestor(left, right, anc, app); + interner intern; std::map< ctx, shared_bitmap > parents, ancestors, dominators; =============================================== --- tests/t_merge_lca.at +++ tests/t_merge_lca.at b3836fc9531f92a6fb429e97c0c3076dadc80aeb @@ -0,0 +1,51 @@ +AT_SETUP([merge --lca]) +MONOTONE_SETUP + +# --lca is a temporary workaround for 3-way merge suckiness. So this +# test should go away eventually. + +# A +# / \ +# B C +# |\ /| +# D X | +# |/ \| +# E F + +ADD_FILE(testfile, [foo bar +]) +COMMIT(testbranch) +A=`BASE_REVISION` + +ADD_FILE(otherfile1, [blah blah +]) +COMMIT(testbranch) +B=`BASE_REVISION` + +REVERT_TO($A) + +SET_FILE(testfile, [new stuff +]) +COMMIT(testbranch) +C=`BASE_REVISION` + +AT_CHECK(MONOTONE merge, [], [ignore], [ignore]) +AT_CHECK(MONOTONE update, [], [ignore], [ignore]) +F=`BASE_REVISION` + +REVERT_TO($B) + +ADD_FILE(otherfile2, [blah blah +]) +COMMIT(testbranch) +D=`BASE_REVISION` + +AT_CHECK(MONOTONE explicit_merge $D $C testbranch, [], [ignore], [ignore]) +AT_CHECK(MONOTONE update, [], [ignore], [ignore]) +E=`BASE_REVISION` + +AT_CHECK(MONOTONE merge --lca, [], [ignore], [stderr]) +AT_CHECK(grep -q $A stderr, [1]) +AT_CHECK(grep -q $B stderr || grep -q $C stderr, []) + +AT_CLEANUP =============================================== --- testsuite.at 7d6278fa857ee6c7324eaa5cde6ed5d86d033aae +++ testsuite.at 0cdcecc517caab0d82b22920ffade5dcd8107b52 @@ -682,3 +682,4 @@ m4_include(tests/t_merge_add_rename_add.at) m4_include(tests/t_update_branch.at) m4_include(tests/t_commit_cancelled.at) +m4_include(tests/t_merge_lca.at)