jrich523
jrich523

Reputation: 590

Automating SVN merge with PowerShell

I have a PowerShell script repo and each user has a branch. Im looking to write a script that will (balancing a line of automation and safety) automatically update things. Currently im the only one using it, but the end goal is that each user has a branch, that branch will be merged to the trunk once its been reviewed (lets assume im the only one who can merge to trunk)

So the first task im looking to do, is for me, which will take my local branch and merge it.

I have my Working copy located at d:\ps\wc ($wc variable) and a local copy of the trunk at d:\ps\scripts ($trunk) and i have the branch url stored in $branchURL

what im thinking i should probably do is the following SVN commands.

svn commit $wc -m "AutoCommit"
svn update $trunk
svn merge $branchurl $trunk
svn commit $trunk -m "AutoCommit"

there is a bit more to this, but i want to make sure I have the right idea (resonable amount of safety) when it comes to doing a push button commit.

I'll just state that im a sysadmin who is good at powershell, SVN is all new to me but have been told enough about the dangers that i wanted to run this by some folks

Upvotes: 0

Views: 1357

Answers (2)

Jas
Jas

Reputation: 15103

maybe you can find the following helpful automerger you can configure on it multiple branches and for each branch to which branch further on to commit.

Upvotes: 1

janos
janos

Reputation: 124646

Your commands look basically fine, except that you should make sure that every step is successful. If any of the steps fail, the script should exit without executing the next step.

For example, you can have failures if the directories you're working with are being used by somebody, as files may be locked. Or even if you can ensure that nobody will be using the files in these directories when your script is running, the svn merge step may fail due to conflicts. You may be able to come up with automated solutions to file locking issues, but you will not be able to automate handling conflicts.

Finally, what about if new scripts are added in $wc? If you want to automatically add files, you can do this:

svn add $wc --force

Without the --force, svn would fail, because of the other files in $wc that are already under version control. With the --force flag it will effective add all unknown files to version control. It may seem strange, because usually the --force flag is for dangerous thing, but this is an exception. svn add --force is like git add ..

Upvotes: 1

Related Questions