Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When I do a Svn up in a file with a local modification that can produce a conflict.

Is it possible to cancel svn update with a hook and write a message?

Thanks

share|improve this question
    
I don't understand why you would want to do this, why not just catch the conflict when it happens? –  kaerast Jan 11 '10 at 11:38
    
@kaerast I worked at a place where the boss liked to edit in the working copy that we used as the production document root. Having conflicts in that would be embarrassing! See blog.joopp.com/2008/12/15/flickr-version-control –  David M May 13 '10 at 1:10

3 Answers 3

If you just want to ignore any changes that would cause a particular file to be conflicted, then you probably want svn update --accept=mine-full. This means that if a change would cause a conflict, discard the incoming changes.

http://svnbook.red-bean.com/en/1.5/svn.tour.cycle.html#svn.tour.cycle.resolve

If you want to decide whether a change to any file would cause a conflict, use svn status -u to determine what changes you're going to get.

share|improve this answer

I don't think you'll be able to do it server side.

However, as of version 1.5, TortoiseSVN supports client-side hooks, including pre-update and post-update. I'm not sure if any other clients do.

That, in combination with

  svn status --show-updates --verbose 

and some scripting, may let you do what you want.

According to the documentation, svn status --show-updates --verbose will give you a status list like this example:

  $ svn status --show-updates --verbose
  M      *        44        23    sally     README
  M               44        20    harry     bar.c
         *        44        35    harry     stuff/trout.c
  D               44        19    ira       stuff/fish.c
  A                0         ?     ?        stuff/things/bloo.h
  Status against revision:   46

If I understand this correctly, any time you see M (for Modified locally) and * (changed in the repository) for the same file, you're going to have a conflict.

So all you should need to do is parse that output and abort the update if it looks like you'll have a conflict.

Hope that helps.

share|improve this answer

You will want a pre-commit hook, in your svn repository directory there is a hooks directory, containing something like pre-commit.bat (on windows, or pre-commit.sh). SVN will execute this before you commit, so just replace this with a script you wish to run and you will be able to halt the commit to SVN.

share|improve this answer
    
Is this question for you, or for your users? –  James B Jan 11 '10 at 11:54
    
it an anwser to this anwser, i delete it. I want a "pre-update" or "post-update" because i work with SVN in production, if a file is in conflit it will be corrupt and will not work. So i must cancel the update and don't corrupt file. –  Schubhan Jan 11 '10 at 12:09
    
I mean, are you a sysadmin trying to solve this problem for your users, or are you one of a number of developers working with subversion? –  James B Jan 11 '10 at 12:19
    
developer, but i sysadmin for Subversion server. –  Schubhan Jan 11 '10 at 13:39
    
I'm not sure you can do exactly what you want to do. The file in subversion should never be corrupted by what is checked in by someone else. –  James B Jan 11 '10 at 14:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.