# # # patch "ChangeLog" # from [35e146a9c36218f8f55750f957fb14bc489cccbf] # to [e49d9cea0ea66e2c20628a77999e4d622930ced5] # # patch "cmd_diff_log.cc" # from [eea68109f73eb58ad1488bc454e10182c28bafe5] # to [769806240271dce3dc01c5af4e55d74821a2ef6d] # # patch "tests/two_parent_workspace_commands_that_fail/__driver__.lua" # from [a1b540beddc4f9c24881c22e9fd26f9f6e88a706] # to [4ac3985a30348b3d51c911af46749ba9e30ddca8] # ============================================================ --- ChangeLog 35e146a9c36218f8f55750f957fb14bc489cccbf +++ ChangeLog e49d9cea0ea66e2c20628a77999e4d622930ced5 @@ -1,5 +1,8 @@ 2007-02-07 Zack Weinberg + * cmd_diff_log.cc (prepare_diff): Handle multi-parent workspaces + gracefully. + * tests/two_parent_workspace_commands_that_fail * tests/two_parent_workspace_pluck: New tests (expected to fail). * testsuite.lua: Add them. ============================================================ --- cmd_diff_log.cc eea68109f73eb58ad1488bc454e10182c28bafe5 +++ cmd_diff_log.cc 769806240271dce3dc01c5af4e55d74821a2ef6d @@ -359,10 +359,19 @@ prepare_diff(cset & included, { roster_t new_roster, old_roster; revision_id old_rid; + parent_map parents; - app.work.get_base_and_current_roster_shape(old_roster, new_roster, nis); - app.work.get_revision_id(old_rid); + app.work.get_parent_rosters(parents); + // With no arguments, which parent should we diff against? + N(parents.size() == 1, + F("this workspace has more than one parent\n" + "(specify a revision to diff against with --revision)")); + + old_rid = parents.begin()->first; + old_roster = *(parents.begin()->second.first); + app.work.get_current_roster_shape(new_roster, nis); + node_restriction mask(args_to_paths(args), args_to_paths(app.opts.exclude_patterns), app.opts.depth, @@ -385,13 +394,9 @@ prepare_diff(cset & included, N(app.db.revision_exists(r_old_id), F("no such revision '%s'") % r_old_id); - app.work.get_base_and_current_roster_shape(old_roster, new_roster, nis); - // Clobber old_roster with the one specified app.db.get_roster(r_old_id, old_roster); + app.work.get_current_roster_shape(new_roster, nis); - // FIXME: handle no ancestor case - // N(r_new.edges.size() == 1, F("current revision has no ancestor")); - node_restriction mask(args_to_paths(args), args_to_paths(app.opts.exclude_patterns), app.opts.depth, @@ -480,7 +485,7 @@ CMD(diff, N_("informative"), N_("[PATH]. bool new_is_archived; prepare_diff(included, app, args, new_is_archived, revs); - + data summary; write_cset(included, summary); ============================================================ --- tests/two_parent_workspace_commands_that_fail/__driver__.lua a1b540beddc4f9c24881c22e9fd26f9f6e88a706 +++ tests/two_parent_workspace_commands_that_fail/__driver__.lua 4ac3985a30348b3d51c911af46749ba9e30ddca8 @@ -24,10 +24,19 @@ diag = "mtn: misuse: this command can on check(not qgrep("ancestor", "testfile")) diag = "mtn: misuse: this command can only be used in a single-parent workspace\n" +diffdiag = ("mtn: misuse: this workspace has more than one parent\n".. + "mtn: misuse: (specify a revision to diff against with --revision)\n") check(mtn("merge_into_workspace", anc), 1, nil, diag) -xfail(mtn("diff"), 1, nil, diag) +-- diff with no arguments: what parent? +check(mtn("diff"), 1, nil, diffdiag) +check(mtn("automate", "content_diff"), 1, nil, diffdiag) + +-- diff can do something sensible if you specify a parent +check(mtn("diff", "-r", left), 0, false, nil) +check(mtn("automate", "content_diff", "-r", right), 0, false, nil) + xfail(mtn("revert"), 1, nil, diag) xfail(mtn("update"), 1, nil, diag)