# # # delete "cmd_merging.hh" # # rename "tests/automate_show_conflicts" # to "tests/automate_show_conflicts_options" # # patch "automate.cc" # from [030a79236cf0806d7487779badd6573eda088c94] # to [800df447462ea5a7d62883acd3c8afc0e4c262ba] # # patch "cmd_merging.cc" # from [9816ce8c4366109fa56ecc47ebfa6fb9c661524b] # to [d88f56759e102e0e0f4bba4730d14cbbb637307b] # # patch "monotone.texi" # from [5179a73b50747a8bf47b842250caf0917bfe341b] # to [615e8a075b5e30913dd84b73a9499dd77ce9346f] # # patch "tests/automate_show_conflicts_options/__driver__.lua" # from [55184339895e15080a5885a6ff5536a36acbb310] # to [ec85dcf4237ebbfac06f4b9fdd2c6ae61e8f9775] # ============================================================ --- automate.cc 030a79236cf0806d7487779badd6573eda088c94 +++ automate.cc 800df447462ea5a7d62883acd3c8afc0e4c262ba @@ -1,5 +1,5 @@ -// Copyright (C) 2007 - 2008 Stephen Leake // Copyright (C) 2004, 2007 Nathaniel Smith +// Copyright (C) 2007 - 2008 Stephen Leake // // This program is made available under the GNU GPL version 2.0 or // greater. See the accompanying file COPYING for details. @@ -25,7 +25,6 @@ #include "basic_io.hh" #include "cert.hh" #include "cmd.hh" -#include "cmd_merging.hh" #include "commands.hh" #include "constants.hh" #include "inodeprint.hh" @@ -2252,54 +2251,6 @@ CMD_AUTOMATE(drop_db_variables, N_("DOMA } } -// Name: show_conflicts -// Arguments: -// Two revision ids (optional, determined from the workspace if not given; there must be exactly two heads) -// Added in: 7.1 -// Purpose: Prints the conflicts between two revisions, to aid in merging them. -// -// Output format: see monotone.texi -// -// Error conditions: -// -// If the revision IDs are unknown or invalid prints an error message to -// stderr and exits with status 1. -// -// If revision ids are not given, and the current workspace does not have -// two heads, prints an error message to stderr and exits with status 1. -// -CMD_AUTOMATE(show_conflicts, N_("[REVID, REVID]"), - N_("Shows the conflicts between two revisions (default two heads of current workspace)"), - "", - options::opts::none) -{ - database db(app); - project_t project(db); - revision_id l_id, r_id; - - if (args.size() == 0) - { - // get ids from heads - set heads; - project.get_branch_heads(app.opts.branchname, heads, - app.opts.ignore_suspend_certs); - - N(heads.size() == 2, F("branch '%s' has %d heads; must be exactly 2 for show_conflicts") % app.opts.branchname % heads.size()); - l_id = *heads.begin(); - r_id = *heads.rbegin(); - } - else if (args.size() == 2) - { - // get ids from args - complete(app.opts, app.lua, project, idx(args,0)(), l_id); - complete(app.opts, app.lua, project, idx(args,1)(), r_id); - } - else - throw usage(execid); - - show_conflicts_core(db, l_id, r_id, true, output); -} - // Local Variables: // mode: C++ // fill-column: 76 ============================================================ --- cmd_merging.cc 9816ce8c4366109fa56ecc47ebfa6fb9c661524b +++ cmd_merging.cc d88f56759e102e0e0f4bba4730d14cbbb637307b @@ -15,7 +15,6 @@ #include "basic_io.hh" #include "cmd.hh" -#include "cmd_merging.hh" #include "diff_patch.hh" #include "merge.hh" #include "restrictions.hh" @@ -807,24 +806,6 @@ CMD(explicit_merge, "explicit_merge", "" std::cout, false); } -CMD(show_conflicts, "show_conflicts", "", CMD_REF(informative), N_("REV REV"), - N_("Shows what conflicts need resolution between two revisions"), - N_("The conflicts are calculated based on the two revisions given in " - "the REV parameters."), - options::opts::none) -{ - database db(app); - project_t project(db); - - if (args.size() != 2) - throw usage(execid); - revision_id l_id, r_id; - complete(app.opts, app.lua, project, idx(args,0)(), l_id); - complete(app.opts, app.lua, project, idx(args,1)(), r_id); - - show_conflicts_core(db, l_id, r_id, false, std::cout); -} - namespace { namespace syms @@ -895,6 +876,72 @@ show_conflicts_core (database & db, revi } } +CMD(show_conflicts, "show_conflicts", "", CMD_REF(informative), N_("REV REV"), + N_("Shows what conflicts need resolution between two revisions"), + N_("The conflicts are calculated based on the two revisions given in " + "the REV parameters."), + options::opts::none) +{ + database db(app); + project_t project(db); + + if (args.size() != 2) + throw usage(execid); + revision_id l_id, r_id; + complete(app.opts, app.lua, project, idx(args,0)(), l_id); + complete(app.opts, app.lua, project, idx(args,1)(), r_id); + + show_conflicts_core(db, l_id, r_id, false, std::cout); +} + +// Name: show_conflicts +// Arguments: +// Two revision ids (optional, determined from the workspace if not given; there must be exactly two heads) +// Added in: 7.1 +// Purpose: Prints the conflicts between two revisions, to aid in merging them. +// +// Output format: see monotone.texi +// +// Error conditions: +// +// If the revision IDs are unknown or invalid prints an error message to +// stderr and exits with status 1. +// +// If revision ids are not given, and the current workspace does not have +// two heads, prints an error message to stderr and exits with status 1. +// +CMD_AUTOMATE(show_conflicts, N_("[REVID, REVID]"), + N_("Shows the conflicts between two revisions (default two heads of current workspace)"), + "", + options::opts::none) +{ + database db(app); + project_t project(db); + revision_id l_id, r_id; + + if (args.size() == 0) + { + // get ids from heads + set heads; + project.get_branch_heads(app.opts.branchname, heads, + app.opts.ignore_suspend_certs); + + N(heads.size() == 2, F("branch '%s' has %d heads; must be exactly 2 for show_conflicts") % app.opts.branchname % heads.size()); + l_id = *heads.begin(); + r_id = *heads.rbegin(); + } + else if (args.size() == 2) + { + // get ids from args + complete(app.opts, app.lua, project, idx(args,0)(), l_id); + complete(app.opts, app.lua, project, idx(args,1)(), r_id); + } + else + throw usage(execid); + + show_conflicts_core(db, l_id, r_id, true, output); +} + CMD(pluck, "pluck", "", CMD_REF(workspace), N_("[-r FROM] -r TO [PATH...]"), N_("Applies changes made at arbitrary places in history"), N_("This command takes changes made at any point in history, and " ============================================================ --- monotone.texi 5179a73b50747a8bf47b842250caf0917bfe341b +++ monotone.texi 615e8a075b5e30913dd84b73a9499dd77ce9346f @@ -8571,6 +8571,10 @@ @section Automation change in future revisions, except that the first line will always be @code{conflict}. +When the conflicts involve files, the file ids are output, so the file +contents can be retrieved efficiently via @code{automate get_file}, +to aid in conflict resolution. + @item Error conditions: If the revision IDs are gvien, but either is unknown or ============================================================ --- tests/automate_show_conflicts_options/__driver__.lua 55184339895e15080a5885a6ff5536a36acbb310 +++ tests/automate_show_conflicts_options/__driver__.lua ec85dcf4237ebbfac06f4b9fdd2c6ae61e8f9775 @@ -1,4 +1,8 @@ --- Test 'automate show_conflicts' +-- Test 'automate show_conflicts' options and arguments +-- +-- options and arguments determine between which revisions conflicts are shown +-- +-- See automate_show_conflicts for all conflict cases mtn_setup() @@ -24,6 +28,7 @@ beth_1 = base_revision() commit() beth_1 = base_revision() +-- No options or args; must be two heads (same as typical merge case) check(mtn("automate", "show_conflicts"), 0, true, false) canonicalize("stdout") check(readfile("expected-1.stdout") == readfile("stdout"))