# # # patch "cmd_ws_commit.cc" # from [f56c86fb606208b856d05aa0a6b16f82f3d193bd] # to [5218eb26b6116453488ce41ac38244e2fea9e331] # ============================================================ --- cmd_ws_commit.cc f56c86fb606208b856d05aa0a6b16f82f3d193bd +++ cmd_ws_commit.cc 5218eb26b6116453488ce41ac38244e2fea9e331 @@ -1026,24 +1026,29 @@ CMD(branch, "branch", "", CMD_REF(worksp } } - // if this is an existing branch, check if this branch's head revs and - // the current workspace parent share any common ancestors, if not warn - // the user about it - if (existing_branch) + parent_map parents; + app.work.get_parent_rosters(parents); + + set parent_revisions; + for (parent_map::iterator i = parents.begin(); + i != parents.end(); i++) { - set revs, common_ancestors; - app.get_project().get_branch_heads(branch, revs); + if (!null_id(i->first)) + parent_revisions.insert(i->first); + } - // FIXME: is there an easier way to just get the revids of the parent(s) - // of the current workspace? - revision_t work_rev; - app.work.get_work_rev(work_rev); - for (edge_map::iterator i = work_rev.edges.begin(); - i != work_rev.edges.end(); i++) - { - revs.insert(i->first); - } + // if this is an existing branch (and we're not inside a freshly created + // workspace), check if this branch's head revs and the current workspace + // parent share any common ancestors, if not warn the user about it + if (existing_branch && parent_revisions.size() > 0) + { + set branch_heads, revs, common_ancestors; + app.get_project().get_branch_heads(branch, branch_heads); + set_union(parent_revisions.begin(), parent_revisions.end(), + branch_heads.begin(), branch_heads.end(), + inserter(revs, revs.begin())); + app.db.get_common_ancestors(revs, common_ancestors); if (common_ancestors.size() == 0)