views:

79

answers:

6

There are moments when I need to be sure that no one is committing to either a specific branch or to my trunk. Release builds and reintegration merges are an example.

SVN "locking" all the files is not realistic (very long since project is huge). I also don't believe that locking prevents someone from committing new files.

What would be a quick way to make sure no one commits anything to the folder until I'm done what I'm doing?

Thanks

A: 

The passwd file could be changed temporarily while work is being done. The downside is that this affects the entire repository, not just one folder.

Mr Grieves
Is this such a bad suggestion to warrant a downvote?
Mr Grieves
@Mr Grieves it's not. I wouldn't call this a 'brilliant' suggestion either, but it can be enough in certain situations, so it's a valid answer to the question.
jeroenh
+7  A: 

If you're making a release build, the first thing you do is check out a particular revision.

It doesn't really matter if someone commits something else during that time - it won't affect your build.

Anon.
It somewhat does. My build number contains the svn version. Running my automatic build generates a bunch of files which need to be committed. The last step of my build is therefore to check-in. I've tried just adding 1 to the revision number but sometimes I run into problems during my build and by the time I've fixed them someone has committed something to that folder.
Mr Grieves
You would be better of changing your process so that it doesn't require checking in generated files.Files that you generate automatically don't belong into source control.
oefe
Yes, I agree. It's a system I've inherited. We have plans to change it but for now, I'd just like a quick way to lock the trunk.
Mr Grieves
@oefe, I disagree. There are advantages to adding generated files to a repository (such as MSI or EXE installers). Can you guarantee that X years from now your build server will be able to compile the same version of your source code as it was originally compiled (and released). It is far *far* easier to have the source code and the MSI/EXE generated by the source code in the same place. Obviously this is in a branch or tag and not trunk.
Si
the problem with auto-generated files is that every time you build the program, these files become out of date in the repository, which very quickly becomes multi-user hell
Earlz
@Si it should be able to, any machine checking out the source should be able to compile it exactly the same. If it's not then whatever dependencies need to be added to source control.
Davy8
Why not just tag a copy rather than relying on the the build revision number? The copy is of a specific revision, and thus "atomic", and then you can check your generated artifacts back in to the tagged branch, without any regard to the actual revision. (You could name the tag "BUILD-REV-1234" if you like, to tell what version you cut it from).
Will Hartung
@Davy8 I agree, in theory. However, software is always getting upgraded, new compiler versions, new runtimes (.NET, Java VMs) new 3rd party libraries, etc. Unless you maintain the same version for all of these, how can you guarantee that you will have the same MSI/EXE as first released? (even though your source code is still the same)
Si
You could consider having everything necessary to build your code in the repository. Yes, even your compiler binaries if necessary.
Anon.
+1  A: 

We'll first, you might try performing those operations on specific revisions rather than the head.

If the revision isn't an option, I'd next suggest that you tag the revision you want to build or whatever and operate on that one. This obviously won't work for merges as it defeats the purpose.

But, to get to the crux of your question, the quickest way I can think of is to prevent incoming information is to halt the server itself. I am not an SVN expert however, I've admin'd a box for several years.

Frank V
+1  A: 

Interesting question. It sounds as though your development work-flow could do with some changes, since you're encountering this issue. In particular, on such a large project, you should consider a work-flow that is more controlled, so development changes aren't coming in at the same time, and on the same branch, as a release build that is in progress. You mentioned reintegration merges for example—surely you can coordinate the project so that reintegration merges aren't happening at the same time as a release build. And developers shouldn't be directly committing to the branch that a release build is being done on.

Possibilities:

  • Communicate effectively with the developers.
    • Announce what you're about to do.
    • Developers should at least know that they shouldn't commit to a branch on which a release build is in-progress.
  • Do builds in a branch. Then tag the branch when the build is complete.
  • Developers do development work on separate branches. Then integration merges are done into an integration branch (maybe trunk).
    • Developers should know that an integration shouldn't be done on a branch on which a release build is in-progress.
Craig McQueen
+1  A: 

We faced this problem when compiling our projects for release builds, where a build server property (CruiseControl.NET project label) is used as part of the assembly and installer version.

The solution is easy where you are branching (or tagging) the working copy, e.g. for release builds.

Workflow:

  1. Checkout fresh working copy of trunk (or branch).
  2. Build your release, this updates files leaving your working copy in a modified state.
  3. If your build succeeds, svn copy the working copy into your new branch or tag.

If you want to commit your working copy without branching, then as you say this will fail (or at the least be unreliable) if someone has modified that path of the repository.

A way to solve this would be to use svn authorization control, adding a build server user to svn and have different authz files for the repository.

Workflow:

  1. Replace authz with file granting write access for build server user and read access for all other users.
  2. Perform your build as per normal.
  3. Replace authz with file granting normal access for all users.

Note that svn authorization allows path-based control, so you could restrict this just to trunk (or wherever) to reduce impact on users.

Another way using a similar approach (same workflow) would be replacing pre-commit hook and checking the user; rejecting the commit (with appropriate error message) if it wasn't your build server user performing the commit. Again, this could be path based (with a little extra regex work) if needed.

Si
+1  A: 

Depending on how much access you have to the server, send an announcement telling no one to commit until some time.

If you can't do that, then checkout/checkin using the file:// or file+ssh:// for release builds and during that time shutdown the SVN server process. (be it apache, or svnserver) then restart it as soon as the build is done.

Also, be sure to rework this so it doesn't require locking the repo as soon as possible. (I realize this is just a temporary thing that you inherited)

Earlz