# # # patch "cert.cc" # from [eee49cf6d4d39afcca2cb2784b8b149a2d24f29b] # to [e86e9223c584511c756093339a13de5ad80f64c1] # # patch "cert.hh" # from [a0808b747d3c8574da04b342cd3afb8a65b89a17] # to [27ebea1da11b533c812ef27b1b8263098523c636] # # patch "cmd_merging.cc" # from [8b9559c4600262d3811521a912eb9e5fd3785854] # to [7a29c3e480f80cd4dd4ee83c3888069aa4331b77] # # patch "cmd_ws_commit.cc" # from [c9eb132742c9299d0f2852795ad704cfc730258e] # to [78f5120093456fd5a4fac92c7c26f39328ca3d83] # # patch "revision.cc" # from [2d2e18b196cfc6a18423605583d40a97fe831702] # to [82fd3fbadae41518da08611c887c7a323ebf4fdd] # # patch "roster.cc" # from [847ef45c176f4a373e96c766ffa638e26b02a5e0] # to [34ade0236725bce33c95e8625335f201f49528dd] # # patch "work.cc" # from [d7150dd4444a045a8e01a4436374cd21cf0f9757] # to [1e356c204ef655192b3960b899705bf05ce4e7de] # ============================================================ --- cert.cc eee49cf6d4d39afcca2cb2784b8b149a2d24f29b +++ cert.cc e86e9223c584511c756093339a13de5ad80f64c1 @@ -470,11 +470,15 @@ get_user_key(rsa_keypair_id & key, app_s key = all_privkeys[0]; } +// Guess which branch is appropriate for a commit below IDENT. +// APP may override. Branch name is returned in BRANCHNAME. +// Does not modify branch state in APP. void -guess_branch(revision_id const & ident, - app_state & app) +guess_branch(revision_id const & ident, app_state & app, utf8 & branchname) { - if ((app.opts.branch_name().empty()) || !app.opts.branch_given) + if (app.opts.branch_given && !app.opts.branch_name().empty()) + branchname = app.opts.branch_name; + else { N(!ident.inner()().empty(), F("no branch found for empty revision, " @@ -493,11 +497,20 @@ guess_branch(revision_id const & ident, set::iterator i = branches.begin(); I(i != branches.end()); - app.opts.branch_name = *i; + branchname = *i; } } +// As above, but set the branch name in the app state. void +guess_branch(revision_id const & ident, app_state & app) +{ + utf8 branchname; + guess_branch(ident, app, branchname); + app.opts.branch_name = branchname; +} + +void make_simple_cert(hexenc const & id, cert_name const & nm, cert_value const & cv, ============================================================ --- cert.hh a0808b747d3c8574da04b342cd3afb8a65b89a17 +++ cert.hh 27ebea1da11b533c812ef27b1b8263098523c636 @@ -111,8 +111,9 @@ void get_user_key(rsa_keypair_id & key, app_state & app); void -guess_branch(revision_id const & id, - app_state & app); +guess_branch(revision_id const & id, app_state & app, utf8 & branchname); +void +guess_branch(revision_id const & id, app_state & app); extern cert_name const date_cert_name; extern cert_name const author_cert_name; ============================================================ --- cmd_merging.cc 8b9559c4600262d3811521a912eb9e5fd3785854 +++ cmd_merging.cc 7a29c3e480f80cd4dd4ee83c3888069aa4331b77 @@ -109,7 +109,7 @@ pick_branch_for_update(revision_id chose else if (branches.size() == 1) { // one non-matching, inform and update - app.opts.branch_name = (*(branches.begin()))(); + app.opts.branch_name = *(branches.begin()); switched_branch = true; } else @@ -117,7 +117,7 @@ pick_branch_for_update(revision_id chose I(branches.size() == 0); W(F("target revision not in any branch\n" "next commit will use branch %s") - % app.opts.branch_name()); + % app.opts.branch_name); } } return switched_branch; @@ -596,7 +596,7 @@ CMD(merge_into_workspace, N_("tree"), "pending changes in the current workspace. Both OTHER-REVISION and " "the workspace's base revision will be recorded as parents on commit. " "The workspace's selected branch is not changed."), - option::none) + options::opts::none) { revision_id left_id, right_id; database::cached_roster left, right; @@ -942,7 +942,6 @@ CMD(get_roster, N_("debug"), N_("[REVID] "or the workspace if no REVID is given"), options::opts::none) { - revision_id rid; roster_t roster; marking_map mm; @@ -950,7 +949,7 @@ CMD(get_roster, N_("debug"), N_("[REVID] { parent_map parents; temp_node_id_source nis; - rid = fake_id(); + revision_id rid(fake_id()); app.require_workspace(); app.work.get_parent_rosters(parents); @@ -995,6 +994,7 @@ CMD(get_roster, N_("debug"), N_("[REVID] } else if (args.size() == 1) { + revision_id rid; complete(app, idx(args, 0)(), rid); I(!null_id(rid)); app.db.get_roster(rid, roster, mm); @@ -1002,7 +1002,6 @@ CMD(get_roster, N_("debug"), N_("[REVID] else throw usage(name); - roster_data dat; write_roster_and_marking(roster, mm, dat); cout << dat; ============================================================ --- cmd_ws_commit.cc c9eb132742c9299d0f2852795ad704cfc730258e +++ cmd_ws_commit.cc 78f5120093456fd5a4fac92c7c26f39328ca3d83 @@ -738,27 +738,25 @@ CMD(commit, N_("workspace"), N_("[PATH]. F("revision %s is already in the database\n" "(update and try again?)") % restricted_rev_id); - cert_value branchname; - if (app.branch_name() != "") - branchname = app.branch_name(); - else + utf8 branchname, bn_candidate; + + for (edge_map::iterator i = restricted_rev.edges.begin(); + i != restricted_rev.edges.end(); + i++) { - cert_value bn_candidate; - for (edge_map::iterator i = restricted_rev.edges.begin(); - i != restricted_rev.edges.end(); - i++) - { - guess_branch(edge_old_revision(i), app, bn_candidate); - N(branchname() == "" || branchname() == bn_candidate(), - F("parent revisions of this commit are in different branches:\n" - "'%s' and '%s'.\n" - "please specify a branch name for the commit, with --branch.") - % branchname % bn_candidate); - branchname = bn_candidate; - } + // this will prefer --branch if it was set + guess_branch(edge_old_revision(i), app, bn_candidate); + N(branchname() == "" || branchname == bn_candidate, + F("parent revisions of this commit are in different branches:\n" + "'%s' and '%s'.\n" + "please specify a branch name for the commit, with --branch.") + % branchname % bn_candidate); + branchname = bn_candidate; } + // make sure everyone's on the same page + app.opts.branch_name = branchname; - P(F("beginning commit on branch '%s'") % app.opts.branch_name); + P(F("beginning commit on branch '%s'") % branchname); L(FL("new manifest '%s'\n" "new revision '%s'\n") % restricted_rev.new_manifest @@ -808,7 +806,7 @@ CMD(commit, N_("workspace"), N_("[PATH]. // for the divergence check, below set heads; - get_branch_heads(branchname(), app, heads); + app.get_project().get_branch_heads(branchname, heads); unsigned int old_head_size = heads.size(); L(FL("inserting new revision %s") % restricted_rev_id); @@ -889,7 +887,7 @@ CMD(commit, N_("workspace"), N_("[PATH]. dbw.consume_revision_data(restricted_rev_id, rdat); app.get_project().put_standard_certs_from_options(restricted_rev_id, - app.opts.branch_name, + branchname, log_message, dbw); guard.commit(); ============================================================ --- revision.cc 2d2e18b196cfc6a18423605583d40a97fe831702 +++ revision.cc 82fd3fbadae41518da08611c887c7a323ebf4fdd @@ -755,7 +755,7 @@ make_revision_for_workspace(parent_map c } rev.edges = edges; - rev.new_manifest = fake_id(); + rev.new_manifest = manifest_id(fake_id()); rev.made_for = made_for_workspace; } ============================================================ --- roster.cc 847ef45c176f4a373e96c766ffa638e26b02a5e0 +++ roster.cc 34ade0236725bce33c95e8625335f201f49528dd @@ -4756,7 +4756,7 @@ create_random_unification_task(roster_t // be new in just the left, just the right, or both. editable_roster_base * left_er; editable_roster_base * right_er; - switch (uniform(2)) + switch (rng.uniform(2)) { case 0: left_er = &left_erm; right_er = &right_erm; break; case 1: left_er = &left_erb; right_er = &right_erm; break; ============================================================ --- work.cc d7150dd4444a045a8e01a4436374cd21cf0f9757 +++ work.cc 1e356c204ef655192b3960b899705bf05ce4e7de @@ -198,7 +198,7 @@ workspace::get_current_roster_shape(rost { revision_t rev; get_work_rev(rev); - revision_id new_rid = fake_id(); + revision_id new_rid(fake_id()); // If there is just one parent, it might be the null ID, which // make_roster_for_revision does not handle correctly.