# # # patch "cmd_diff_log.cc" # from [1595b889561fe5cd2f14fb0ad37acfa1483949a0] # to [133708639a89bb2a4c169bb37e37ed1e62c80613] # # patch "monotone.texi" # from [faf359c7d44bb4922b5487495cda7da5d784e2bf] # to [fdcd86a553ac81c3f29f0379e8e03d558b5a251b] # # patch "tests/automate_content_diff/__driver__.lua" # from [274e9b78eab4715e2d793b1db848bc872b0ad173] # to [6d2be4f00fad578908aa61590702d6a074203c00] # ============================================================ --- cmd_diff_log.cc 1595b889561fe5cd2f14fb0ad37acfa1483949a0 +++ cmd_diff_log.cc 133708639a89bb2a4c169bb37e37ed1e62c80613 @@ -238,6 +238,7 @@ dump_diffs(lua_hooks & lua, std::ostream & output, diff_type diff_format, bool new_is_archived, + bool old_is_archived, bool show_encloser, bool limit_paths = false) { @@ -299,8 +300,16 @@ dump_diffs(lua_hooks & lua, output << patch_sep << '\n'; - db.get_file_version(delta_entry_src(i), f_old); - data_old = f_old.inner(); + if (old_is_archived) + { + db.get_file_version(delta_entry_src(i), f_old); + data_old = f_old.inner(); + } + else + { + I(new_is_archived); + read_data(delta_entry_path(i), data_old); + } if (new_is_archived) { @@ -310,6 +319,7 @@ dump_diffs(lua_hooks & lua, } else { + I(old_is_archived); read_data(delta_entry_path(i), data_new); } @@ -340,11 +350,12 @@ dump_diffs(lua_hooks & lua, std::ostream & output, diff_type diff_format, bool new_is_archived, + bool old_is_archived, bool show_encloser) { set dummy; dump_diffs(lua, db, cs, dummy, output, - diff_format, new_is_archived, show_encloser); + diff_format, new_is_archived, old_is_archived, show_encloser); } // common functionality for diff and automate content_diff to determine @@ -356,14 +367,13 @@ prepare_diff(app_state & app, cset & included, args_vector args, bool & new_is_archived, + bool & old_is_archived, std::string & revheader) { temp_node_id_source nis; ostringstream header; - cset excluded; - // The resulting diff is output in 'included'. Not clear what 'excluded' - // is for. + // The resulting diff is output in 'included'. // initialize before transaction so we have a database to work with. project_t project(db); @@ -403,9 +413,9 @@ prepare_diff(app_state & app, mask); make_cset(old_roster, restricted_roster, included); - make_cset(restricted_roster, new_roster, excluded); new_is_archived = false; + old_is_archived = true; header << "# old_revision [" << old_rid << "]\n"; } else if (app.opts.revision_selectors.size() == 1) @@ -431,17 +441,17 @@ prepare_diff(app_state & app, if (app.opts.reverse) { - // FIXME: this breaks something in graph.cc - make_cset(new_roster, restricted_roster, excluded); make_cset(restricted_roster, old_roster, included); + new_is_archived = true; + old_is_archived = false; } else { make_cset(old_roster, restricted_roster, included); - make_cset(restricted_roster, new_roster, excluded); + new_is_archived = false; + old_is_archived = true; } - new_is_archived = false; header << "# old_revision [" << r_old_id << "]\n"; } else if (app.opts.revision_selectors.size() == 2) @@ -486,9 +496,10 @@ prepare_diff(app_state & app, mask); make_cset(old_roster, restricted_roster, included); - make_cset(restricted_roster, new_roster, excluded); new_is_archived = true; + old_is_archived = true; + } else { @@ -544,9 +555,10 @@ CMD(diff, "diff", "di", CMD_REF(informat cset included; std::string revs; bool new_is_archived; + bool old_is_archived; database db(app); - prepare_diff(app, db, included, args, new_is_archived, revs); + prepare_diff(app, db, included, args, new_is_archived, old_is_archived, revs); if (!app.opts.without_header) { @@ -560,7 +572,7 @@ CMD(diff, "diff", "di", CMD_REF(informat else { dump_diffs(app.lua, db, included, cout, - app.opts.diff_format, new_is_archived, + app.opts.diff_format, new_is_archived, old_is_archived, !app.opts.no_show_encloser); } } @@ -580,14 +592,15 @@ CMD_AUTOMATE(content_diff, N_("[FILE [.. "", options::opts::with_header | options::opts::without_header | options::opts::revision | options::opts::depth | - options::opts::exclude) + options::opts::exclude | options::opts::reverse) { cset included; std::string dummy_header; bool new_is_archived; + bool old_is_archived; database db(app); - prepare_diff(app, db, included, args, new_is_archived, dummy_header); + prepare_diff(app, db, included, args, new_is_archived, old_is_archived, dummy_header); if (app.opts.with_header) @@ -596,7 +609,7 @@ CMD_AUTOMATE(content_diff, N_("[FILE [.. } dump_diffs(app.lua, db, included, output, - app.opts.diff_format, new_is_archived, !app.opts.no_show_encloser); + app.opts.diff_format, new_is_archived, old_is_archived, !app.opts.no_show_encloser); } ============================================================ --- monotone.texi faf359c7d44bb4922b5487495cda7da5d784e2bf +++ monotone.texi fdcd86a553ac81c3f29f0379e8e03d558b5a251b @@ -8231,7 +8231,7 @@ @section Automation @end table address@hidden mtn automate content_diff address@hidden address@hidden address@hidden ...] address@hidden mtn automate content_diff address@hidden address@hidden [--reverse] address@hidden ...] @table @strong @item Arguments: @@ -8244,13 +8244,14 @@ @section Automation @itemize @item -no revision: the diff is done between the workspace revision and the -parent (base) revision of this workspace +no revision: the diff is done from the parent (base) revision of this +workspace to the workspace revision. @item -one revision: the diff is done between the workspace revision and the -given revision @option{id1}, +one revision: if @option{--reverse} is not given, the diff is done +from the given revision @option{id1} to the workspace revision. If address@hidden is not given, the order is reversed. @item -two revisions: the diff is done between @option{id1} and @option{id2}; no +two revisions: the diff is done from @option{id1} to @option{id2}; no workspace is needed in this case. @end itemize ============================================================ --- tests/automate_content_diff/__driver__.lua 274e9b78eab4715e2d793b1db848bc872b0ad173 +++ tests/automate_content_diff/__driver__.lua 6d2be4f00fad578908aa61590702d6a074203c00 @@ -30,13 +30,23 @@ check(fsize("stdout") ~= 0) -- one and two revisions should work check(mtn("automate", "content_diff", "-r", R1), 0, true, true) check(fsize("stdout") ~= 0) +-- compare output order to --reverse below +check(qgrep("\\+\\+\\+ existing.*27f121005fcb075744d0c869183263c5b4814cb8", "stdout")) +check(qgrep("--- existing.*3773dea65156909838fa6c22825cafe090ff8030", "stdout")) + check(mtn("automate", "content_diff", "-r", R1, "-r", R2), 0, true, true) check(fsize("stdout") ~= 0) check(not qgrep("# patch", "stdout")) + check(mtn("automate", "content_diff", "-r", R1, "-r", R2, "--with-header"), 0, true, true) check(fsize("stdout") ~= 0) check(qgrep("# patch", "stdout")) +-- --reverse with one revision +check(mtn("automate", "content_diff", "-r", R1), 0, true, true) +check(qgrep("--- existing.*3773dea65156909838fa6c22825cafe090ff8030", "stdout")) +check(qgrep("\\+\\+\\+ existing.*27f121005fcb075744d0c869183263c5b4814cb8", "stdout")) + -- three and more should not check(mtn("automate", "content_diff", "-r", R1, "-r", R2, "-r", R3), 1, true, true)