# # # patch "cmd_ws_commit.cc" # from [a81d478bf4c7ef569dd8ae9ccc4d745772005eae] # to [5c4576edd5b77a135b612ca40f93c963f778a755] # # patch "monotone.texi" # from [bbff183c888f5900c9c7ecf998f94629a46c6595] # to [793db2d57f83bf90d75569d5e16e0fc5adf83681] # ============================================================ --- cmd_ws_commit.cc a81d478bf4c7ef569dd8ae9ccc4d745772005eae +++ cmd_ws_commit.cc 5c4576edd5b77a135b612ca40f93c963f778a755 @@ -679,11 +679,27 @@ CMD(attr, N_("workspace"), N_("set PATH throw usage(name); } +CMD(branch, N_("workspace"), N_("BRANCHNAME"), + N_("changes the branch of the current workspace"), options::opts::none) +{ + if (args.size() != 1) + throw usage(name); + + branch_name branch(idx(args, 0)()); + + // check if the branch cert is already known and refuse if this is right + // TODO!! + + // leave the other parameters empty so they won't get changed + system_path path; + rsa_keypair_id key; + + app.work.set_ws_options(path, branch, key, path); +} - CMD(commit, N_("workspace"), N_("[PATH]..."), N_("commit workspace to database"), - options::opts::branch | options::opts::message | options::opts::msgfile + options::opts::message | options::opts::msgfile | options::opts::date | options::opts::author | options::opts::depth | options::opts::exclude) { @@ -703,7 +719,6 @@ CMD(commit, N_("workspace"), N_("[PATH]. get_user_key(key, app); } - app.make_branch_sticky(); app.work.get_parent_rosters(old_rosters); app.work.get_current_roster_shape(new_roster, nis); @@ -721,10 +736,25 @@ CMD(commit, N_("workspace"), N_("[PATH]. revision_id restricted_rev_id; calculate_ident(restricted_rev, restricted_rev_id); - // We need the 'if' because guess_branch will try to override any branch - // picked up from _MTN/options. + // + // FIXME: Obviously this command no longer accepts a --branch option, + // app.opts.branchname is set to _MTN/options branchname by default in + // app_state::process_options (which is called before the command is executed). + // + // While it would certainly be cleaner here to read app.work.get_ws_options() + // I hesistate to do that _again_ because it has already been done. Also + // referencing the branchname via app.opts.branchname is a bit backwards + // since it was never an option for this command actually. Still, I'm open + // for ideas how to clean up this mess =) + // + // So in the end only if no branch is set in _MTN/options we try to detect a + // valid one here by looking at the ancestor revisions of the workspace. + // if (app.opts.branchname().empty()) { + W(F("workspace has no branch name set; trying to detect one " + "by looking at the parent revisions")); + branch_name branchname, bn_candidate; for (edge_map::iterator i = restricted_rev.edges.begin(); i != restricted_rev.edges.end(); @@ -733,14 +763,16 @@ CMD(commit, N_("workspace"), N_("[PATH]. // 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" + F("parent revisions of this workspace are in different branches:\n" "'%s' and '%s'.\n" - "please specify a branch name for the commit, with --branch.") - % branchname % bn_candidate); + "please specify a branch name with '%s branch BRANCHNAME'.") + % branchname % bn_candidate % ui.prog_name); branchname = bn_candidate; } app.opts.branchname = branchname; + // write out the new branch name + app.make_branch_sticky(); } ============================================================ --- monotone.texi bbff183c888f5900c9c7ecf998f94629a46c6595 +++ monotone.texi 793db2d57f83bf90d75569d5e16e0fc5adf83681 @@ -2207,12 +2207,13 @@ @section Branching and Merging She decides that since main development is in branch @code{jp.co.juicebot.jb7}, she will use branch @code{jp.co.juicebot.jb7.muffins}. So, she makes the first few edits to -the new muffins code, and commits it on a new branch by simply passing address@hidden to commit: +the new muffins code, changes the branch of the workspace and commits it +the changes to the new branch: @smallexample @group -$ mtn commit --branch=jp.co.juicebot.jb7.muffins --message='autobake framework' +$ mtn branch jp.co.juicebot.jb7.muffins +$ mtn commit --message='autobake framework' mtn: beginning commit on branch 'jp.co.juicebot.jb7.muffins' mtn: committed revision d33caefd61823ecbb605c39ffb84705dec449857 @end group @@ -4329,6 +4330,21 @@ @section Workspace rename operations in the filesystem. It will ignore missing source files and will not overwrite existing destination files. address@hidden mtn branch @var{branchname} + +This command changes the branch name of your current workspace. It does that +by overwriting any previous branch setting in @file{_MTN/options} so that its +guaranteed that the next commit gets this new branch as cert attached. + +Please note that you can't set a branch name which already exists in your +database. To rebase your workspace to a different branch, please use the address@hidden command: + address@hidden +$ mtn update --revision h:other-branch address@hidden smallexample + + @item mtn commit @item mtn ci @itemx mtn commit address@hidden address@hidden @@ -4390,10 +4406,6 @@ @section Workspace successful, the @file{_MTN/log} file is cleared of all content making it ready for another edit/commit cycle. -If a @option{--branch} option is specified, the @command{commit} command -commits to this branch (creating it if necessary). The branch becomes -the new default branch of the workspace. - The @command{commit} command also synthesizes a number of certificates, which it attaches to the new manifest version and copies into your database: