# # # patch "wiki/BranchRenaming.mdwn" # from [60e51900d07ca77b75c4a144d2bddce4f7dbdc7d] # to [e5d4bcdc4cdac2362f0798697f68c7d9f39b21b8] # ============================================================ --- wiki/BranchRenaming.mdwn 60e51900d07ca77b75c4a144d2bddce4f7dbdc7d +++ wiki/BranchRenaming.mdwn e5d4bcdc4cdac2362f0798697f68c7d9f39b21b8 @@ -12,14 +12,12 @@ The following commands can be used to re mtn cert $REV branch NEWBRANCH done mtn db kill_branch_certs_locally OLDBRANCH - If your branch names contain '/' characters, either escape the '/' characters or use the shell snippet below. for REV in `mtn db execute "SELECT id FROM revision_certs WHERE name = 'branch' AND value LIKE 'OLDBRANCH'" | grep ^[0123456789abcdef]*$`; do mtn cert $REV branch NEWBRANCH done mtn db kill_branch_certs_locally OLDBRANCH - Basically this issues new branch certs for the branch you specifiy, and then the old branch certs are deleted. Be sure that the rename was successful (check with `mtn log`, `mtn list branches`, etc.) before issuing the `mtn db kill_branch_certs_locally` command. Note: You will have to enter your password once for every branch cert. To avoid this you can create a password hook in your `.monotonerc` file or use `yes PASSWORD | mtn cert...`, although that is not very secure (users can use ps aux or read your .bash_history to get your password). The ssh-agent integration available since mtn 0.34 is probably a solution to this, too. @@ -27,11 +25,9 @@ CraigLennox: These may fail with an "`ar CraigLennox: These may fail with an "`argument list too long`" error if the branch contains a very large number (i.e. thousands) of revisions. You can get around that limitation by replacing instances of for REV in `mtn cmd args...`; do - with mtn cmd args... | while read REV; do - # Branch Renaming Script Here is a script that can be used to rename branches, including names branch with `/` characters in them. Be sure to backup your database before using it. You must set the MTN_DB environment variable to the location of your database. @@ -58,7 +54,6 @@ Here is a script that can be used to ren done mtn -d $MTN_DB db kill_branch_certs_locally $1 - # Using A Ruby Shell To Manipulate Branches Using a ruby (or perl or python) shell can be a very convienient way to solve problems. @@ -71,5 +66,4 @@ Using a ruby (or perl or python) shell c system "mtn cert #{c} branch com.kiatoa.matt.rails2" end end - This allowed me to make a new branch with a head removed that I couldn't figure out how any other way to resolve.