Allow changing branch parent
Allow some way to restructure branch parentage. CLI or or other power-user way would suffice...
If it's true that child branches and top-level branches are identical types and the hierarchy is only for display purposes, I would want to have some way of changing the parentage of a branch (at least from the CLI).
Make child branch from top-level branch, and vice-versa.
There may have to be restrictions on this, like "parent can only be set to root or creation point"?
The practical use-case for us is that we have imported some top-level branches from SVN that logically should be children of the branches they were forked from, and we'd like to fix that. It would also be useful if deciding on another organization later on...
Closed thanks to Göran answer. It is a hacker way to do it but probably it is fine right now.
Sure, here's how to do it from command line, by using "advanced queries":
NOTE: You need to have "advancedquery" permissions on the repository server to run the "cm query" CLI command.
NOTE: You have to be admin/owner on the repository to perform the "execquery" sub-command.
First, cd into a workspace. (Alternatively, you could append " --repository=<repo@server:port>" to the command lines below.)
Now, suppose we have the following branch tree in our repo:
Issue this SQL query to see how the tree is represented internally:
> cm q "SELECT * FROM branch"
Example result (reformatted) :
iobjid, sname, fidparent, ssmart, ichangesetid
12, main, -1, F, 11
22, child, 12, F, 14
35, grandchild, 22, F, 17
43, myroot, -1, F, 4
64, test, 43, F, 5
The fidparent field refers to the iobjid of the parent branch. By modifying this field you can change the namespace/parentage of a branch.
Suppose we want to make "/myroot" be the parent of "/main" (not recommended!) and change "/myroot/test" into a top-level branch:
> cm q "execquery UPDATE branch SET fidparent=43 WHERE iobjid=12"
> cm q "execquery UPDATE branch SET fidparent=-1 WHERE iobjid=64"
After issuing the above commands we end up with the following branch tree:
So far, there's a hacker way to implement this... we discussed it by email. Would you mind sharing it here?
Further motivation: This other blog post talks about using [top-level vs child] to indicate [strategic vs tactical] use of branches: http://codicesoftware.blogspot.com/2012/05/using-first-level-branches-in-plastic.html
In adapting to such a pattern, one may need to be able to change the namespace of some branches...
Background: Starting with 4.0, all branches are "equal" (independently of whether they’re children or top-level branches). This is described in the following blog post: http://codicesoftware.blogspot.com/2012/01/evolution-of-plastic-scm-branches.html
The child branch hierarchy is to be considered as a "branching namespace". Thus, it would be very convenient if we could change the namespace of a branch, just like we can rename the branch itself.