# # # add_dir "tests/two_parent_workspace_annotate" # # add_file "tests/two_parent_workspace_annotate/__driver__.lua" # content [6cf020efb5377b79641fb655923731702df6c318] # # add_file "tests/two_parent_workspace_annotate/expected-annotation" # content [2432ae4e170b3b0ef37ad5c76f375b562656bdbb] # # add_file "tests/two_parent_workspace_annotate/left" # content [0ffe36a4ca2169de7543a67f92134ea93636b246] # # add_file "tests/two_parent_workspace_annotate/merged" # content [aed28f362beb27308db048db953a985fba45d8e7] # # add_file "tests/two_parent_workspace_annotate/right" # content [7478fc33b2476515959ea9be9306295a36a22d64] # # add_file "tests/two_parent_workspace_annotate/testfile" # content [c537e8ec248c6cd32e54cd6fa98ae15743f996b4] # # patch "ChangeLog" # from [f8a7477a5565d0a2ae1f442776fefbf57c84eac7] # to [5c091db4822c0b8ec06883e592b668a9d2364c0f] # # patch "cmd_files.cc" # from [bffec2cf6dda0e6bffd827733a5d21e906d1c8cd] # to [36fa0ae00f619ebe32d6e0ab31f84f639bfe15f1] # # patch "testsuite.lua" # from [f92a7dcff9079237855ae6c1f0c385a217b0873b] # to [6ba9c5da69a1e547e724616fecebdc09cf2cba72] # ============================================================ --- tests/two_parent_workspace_annotate/__driver__.lua 6cf020efb5377b79641fb655923731702df6c318 +++ tests/two_parent_workspace_annotate/__driver__.lua 6cf020efb5377b79641fb655923731702df6c318 @@ -0,0 +1,35 @@ +-- Test of annotation of merged but not committed files. +-- Does not currently work, see comments in cmd_files.cc. + +mtn_setup() + +check(get("testfile")) +check(get("left")) +check(get("right")) +check(get("merged")) +check(get("expected-annotation")) + +addfile("testfile") +commit() +anc = base_revision() + +revert_to(anc) +copy("left", "testfile") +commit() +left = base_revision() + +revert_to(anc) +copy("right", "testfile") +commit() +right = base_revision() + +check(mtn("merge_into_workspace", left), 0, false, false) + +-- testfile should be the same as merged +check(samefile("merged", "testfile")) + +-- annotate should do something sensible +xfail(mtn("annotate", "--brief", "testfile"), 0, {"expected-annotation"}, nil) + +-- a commit at this point should succeed +commit() ============================================================ --- tests/two_parent_workspace_annotate/expected-annotation 2432ae4e170b3b0ef37ad5c76f375b562656bdbb +++ tests/two_parent_workspace_annotate/expected-annotation 2432ae4e170b3b0ef37ad5c76f375b562656bdbb @@ -0,0 +1,5 @@ +5e2a549855d47ce5627e826265ef016bce093539: 1 blah +cb9caf566fa2b37ef60c38bd66de01092b610ffc: 2 left change +5e2a549855d47ce5627e826265ef016bce093539: 3 blah +eb8fe9e2675be830f566b7c199c8ecec069a0d4c: 4 right change +5e2a549855d47ce5627e826265ef016bce093539: 5 blah ============================================================ --- tests/two_parent_workspace_annotate/left 0ffe36a4ca2169de7543a67f92134ea93636b246 +++ tests/two_parent_workspace_annotate/left 0ffe36a4ca2169de7543a67f92134ea93636b246 @@ -0,0 +1,5 @@ +1 blah +2 left change +3 blah +4 blah +5 blah ============================================================ --- tests/two_parent_workspace_annotate/merged aed28f362beb27308db048db953a985fba45d8e7 +++ tests/two_parent_workspace_annotate/merged aed28f362beb27308db048db953a985fba45d8e7 @@ -0,0 +1,5 @@ +1 blah +2 left change +3 blah +4 right change +5 blah ============================================================ --- tests/two_parent_workspace_annotate/right 7478fc33b2476515959ea9be9306295a36a22d64 +++ tests/two_parent_workspace_annotate/right 7478fc33b2476515959ea9be9306295a36a22d64 @@ -0,0 +1,5 @@ +1 blah +2 blah +3 blah +4 right change +5 blah ============================================================ --- tests/two_parent_workspace_annotate/testfile c537e8ec248c6cd32e54cd6fa98ae15743f996b4 +++ tests/two_parent_workspace_annotate/testfile c537e8ec248c6cd32e54cd6fa98ae15743f996b4 @@ -0,0 +1,5 @@ +1 blah +2 blah +3 blah +4 blah +5 blah ============================================================ --- ChangeLog f8a7477a5565d0a2ae1f442776fefbf57c84eac7 +++ ChangeLog 5c091db4822c0b8ec06883e592b668a9d2364c0f @@ -1,3 +1,10 @@ +2007-02-09 Zack Weinberg + + * cmd_files.cc (annotate): Handle multi-parent workspaces gracefully. + Add lengthy comment about why multi-parent annotate doesn't work. + * tests/two_parent_workspace_annotate: New xfailed test. + * testsuite.lua: Update. + 2007-02-07 Zack Weinberg * work.cc (perform_rename): Work in a two-parent workspace. ============================================================ --- cmd_files.cc bffec2cf6dda0e6bffd827733a5d21e906d1c8cd +++ cmd_files.cc 36fa0ae00f619ebe32d6e0ab31f84f639bfe15f1 @@ -127,22 +127,47 @@ CMD(annotate, N_("informative"), N_("PAT split_path sp; file.split(sp); + L(FL("annotate file '%s'") % file); + + roster_t roster; if (app.opts.revision_selectors.size() == 0) - app.work.get_revision_id(rid); - else - complete(app, idx(app.opts.revision_selectors, 0)(), rid); + { + // What this _should_ do is calculate the current workspace roster + // and/or revision and hand that to do_annotate. This should just + // work, no matter how many parents the workspace has. However, + // do_annotate currently expects to be given a file_t and revision_id + // corresponding to items already in the database. This is a minor + // bug in the one-parent case (it means annotate will not show you + // changes in the working copy) but is fatal in the two-parent case. + // Thus, what we do instead is get the parent rosters, refuse to + // proceed if there's more than one, and give do_annotate what it + // wants. See tests/two_parent_workspace_annotate. - N(!null_id(rid), - F("no revision for file '%s' in database") % file); - N(app.db.revision_exists(rid), - F("no such revision '%s'") % rid); + revision_t rev; + app.work.get_work_rev(rev); + N(rev.edges.size() == 1, + F("with no revision selected, this command can only be used in " + "a single-parent workspace")); - L(FL("annotate file file_path '%s'") % file); + rid = edge_old_revision(rev.edges.begin()); + // this call will change to something else when the above bug is + // fixed, and so should not be merged with the identical call in + // the else branch. + app.db.get_roster(rid, roster); + } + else + { + complete(app, idx(app.opts.revision_selectors, 0)(), rid); + N(!null_id(rid), + F("no revision for file '%s' in database") % file); + N(app.db.revision_exists(rid), + F("no such revision '%s'") % rid); + + app.db.get_roster(rid, roster); + } + // find the version of the file requested - roster_t roster; - marking_map marks; - app.db.get_roster(rid, roster, marks); N(roster.has_node(sp), F("no such file '%s' in revision '%s'") % file % rid); node_t node = roster.get_node(sp); ============================================================ --- testsuite.lua f92a7dcff9079237855ae6c1f0c385a217b0873b +++ testsuite.lua 6ba9c5da69a1e547e724616fecebdc09cf2cba72 @@ -715,3 +715,4 @@ table.insert(tests, "two_parent_workspac table.insert(tests, "two_parent_workspace_add_drop_rename") table.insert(tests, "two_parent_workspace_attrs") table.insert(tests, "two_parent_workspace_pivot_root") +table.insert(tests, "two_parent_workspace_annotate")