0

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

4
  • I should also mention that Switch was suggested so that I dont have to have the local copy of the branch but im not sure i understand the implications of that well enough to want to do it. Commented Jan 8, 2014 at 18:12
  • You will have to consider what to do when you get merge conflicts. Commented Jan 8, 2014 at 18:35
  • I was just thinking i should commit my branch, then merge the trunk to my branch (and prompt the user for conflicts) and then merge back to trunk. that way if a poor choice is made with conflicting data a copy of my code is in my branch. thanks for the input ThisSuitlsBlackNot! Commented Jan 8, 2014 at 18:56
  • maybe you can find the following helpful github.com/liveperson/Auto-Merger you can configure on it multiple branches and for each branch to which branch further on to commit. Commented Jan 9, 2014 at 13:49

2 Answers 2

1

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 ..

Sign up to request clarification or add additional context in comments.

7 Comments

I was looking at prompting the user for the conflicts. The Lock part is a concern on the branch or trunk? Thanks!
@jrich523 the lock can happen to both $wc and $trunk. Note that while your running a script in Windows, the OS locks the script.
so then its going to be hard to put this script in to svn :) since it will act as a module it might be ok, but certain a good test case to look at!
@jrich523 if locking happens a lot due to heavy use, you can probably work around it by scheduling the auto-commits at more appropriate times, like in the middle of the night.
@jrich523 I thought of one more step that might be good in your script, svn add, see my updated post.
|
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.