views:

398

answers:

6

Is there a way to tell subversion "update/merge unless it would cause a conflict"?

I know you can use --dry-run / status -u to check before running the update, but I often have others running updates and getting broken webpages because they don't notice the "C index.php" line.

I've also noticed that svn doesn't seem too unhappy about conflicts - it still says "updated to revision blah" and exits zero, regardless of conflicts. So I have to parse the line-by-line output to discover them. Surely there's a better way?

+1  A: 

Perhaps a better way is to use a graphical tool? Or write a script to do the update that redirects the output to a file and does a "cat svnupdate.log | grep "^C "" at the end to show you any conflicts?

With the graphical tools that I use (TortoiseSVN and Netbeans), they make a nasty noise at the end and present you with a merge selection dialog for dealing with them. I don't know of an equivalent with as much power for the command line tools.

jsight
+1  A: 

@jsight: TortoiseSVN is great, but I primarily develop in a *NIX environment, without X. So I'm usually using (restricted to) the command line.

In re your script suggestion, that's what I'm working on now - which is why I'm annoyed that I can't just check $?. Right now I'm skipping the "output to a file" and using a pipe, but otherwise exactly what you describe.

Peter Stone
+1  A: 

You could use the --diff3-cmd parameter to specify which merging tool to use (usually diff3 from diffutils).

Damien B
A: 

you could also use a pre-commit script to look for conflict markers in files and prevent commit when they are present.

Jean
+2  A: 

You can use the --accept parameter to indicate what should happen when a conflict occurs:

--accept ARG             : specify automatic conflict resolution action
                          ('postpone', 'base', 'mine-full', 'theirs-full',
                          'edit', 'launch')

See also the interactive conflict resolution page in the svnbook

Sander Rijken
A: 

Subversion 1.5 (recently released) adds some ability to specify what happens during an update conflict, with the "--accept" argument.

jackr