120

Does anyone know an SVN command to list current conflicts between the repo and the working copy?

Thanks

azz0r
  • 3,283
  • 7
  • 42
  • 85

9 Answers9

173

On Linux, if you want to see only the conflicts, pipe the status through grep.

svn status | grep -P '^(?=.{0,6}C)'
2240
  • 1,547
  • 2
  • 12
  • 30
nshew13
  • 3,052
  • 5
  • 25
  • 39
  • 7
    Adding `-A 1` to the grep arguments will show you the line after the conflict line, which is sometimes related to the conflict. – Wesley Hartford Oct 08 '13 at 15:34
  • @N13 +1 for the answer. It would be better if you describe it in detail. Like what is -P '^(?=.{0,6}C)'. – Workonphp Nov 22 '13 at 09:43
  • 4
    -P tells [grep](http://unixhelp.ed.ac.uk/CGI/man-cgi?grep) to use perl regex, ^ = start of string, (?=) enclose the [lookahead](http://www.regular-expressions.info/lookaround.html) pattern which is .{0,6} any 0 to 6 characters and the letter C, which is the indicator for conflicts – Pete Nov 22 '13 at 21:56
  • Pete's right. At a higher level, and unlike the other "^C" answers given, the lookahead lets the C appear anywhere in the first 7 columns/characters. It also implicitly allows more than one conflict per file. The columns are explained in the documentation for the status subcommand. – nshew13 Nov 25 '13 at 16:07
  • I keep referring to this answer. It should be printed at the top of relevant Google searches, like a definition. – Grault May 05 '14 at 18:48
  • Thanks, Jes. I actually put it in a bash alias so I wouldn't have to remember it. `alias svnconf="svn status | grep -P '^(?=.{0,6}C)'"`. – nshew13 May 05 '14 at 22:40
  • 5
    What is the point of using the lookahead part? Couldn't `'^.{0,6}C'` work as well? – hans_meine Aug 25 '14 at 12:47
  • I think they are the same, in this case. Feel free to edit the answer. – nshew13 Aug 25 '14 at 13:25
  • 2
    To use this same command on OSX, you need to install GNU grep because the BSD grep doesn't have the perl regex flag (-P) – G.Rassovsky Jun 15 '15 at 12:13
  • `'^.{0,6}[C>]'` will include the descriptions of tree conflicts ("local file edit, incoming file delete on merge" etc) as well as the list of files, if you want that. (This improves on the `-A 1` suggested by @WesleyHartford by only showing the following line if it's relevant) – Andy Mortimer Dec 18 '15 at 16:33
  • 5
    On Windows the Powershell version of this is `(svn status) -Match '^(?=.{0,6}C)'` – bstoney Jan 28 '16 at 03:46
  • @G.Rassovsky there's absolutely no need to install GNU tools when you can just use BSD grep for the same exact task. – anddam Feb 18 '16 at 20:26
31

Just use grep!

svn st | grep '^C'
Joseph Lust
  • 19,340
  • 7
  • 85
  • 83
11

You could try svn merge -r <revision> --dry-run and see what happens that way.

corsiKa
  • 81,495
  • 25
  • 153
  • 204
  • Doesn't seem to work on Windows with svn 1.7.8. Error log: svn: E205001: Try 'svn help' for more info svn: E205001: Merge source required – kakyo Feb 06 '14 at 13:28
5

If you have already merged you can use

svn status

and see an uppercase "C" for conflict, but usually you shouldn't see such kind in your working copy.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
5

For Windows PowerShell use:

svn status | sls -Pattern '^(?=.{0,6}C)'
Ayo I
  • 7,722
  • 5
  • 30
  • 40
4

If you have ack from http://betterthangrep.com/, you can do the following

svn st | ack '^C'
bananaaus
  • 771
  • 1
  • 9
  • 10
1

It's maybe possible to use svn merge --dryrun while specifying the repository URL with all revisions after the latest one you updated with.

E.g. if your current WC is based on revision 147 this could do it:

svn merge -r 148:HEAD http://url.to.repo/repo/

It's nothing I've done myself though, so you'll have to try it yourself.

Anders Abel
  • 67,989
  • 17
  • 150
  • 217
0

If you haven't merged or updated files then use below command

svn status --show-updates | grep -P '.*(?=.*M)(?=.*\*).*'

For short

svn st -u | grep -P '.*(?=.*M)(?=.*\*).*'

Details
SVN don't mark conflict(C) status until you update the file(s) using svn update.
Until then statuses are shown like below

+---+------+---------------+---------------+
| M |      |               | 23246   file1 |
+---+------+---------------+---------------+
|   |      | *             | 23233   file2 |
+---+------+---------------+---------------+
| M |    * | 23233   file3 |               |
+---+------+---------------+---------------+

M - Modified in local
* - Updates/Incoming from remote
M and * - Modified in local, as well as in remote - This is a conflict but svn haven't marked yet

Sameer
  • 4,758
  • 3
  • 20
  • 41
-2

on mac

$ svn status | grep -e '^!'

did the job

here is the man for grep:

usage: grep [-abcDEFGHhIiJLlmnOoqRSsUVvwxZ] [-A num] [-B num] [-C[num]] [-e pattern] [-f file] [--binary-files=value] [--color=when] [--context[=num]] [--directories=action] [--label] [--line-buffered] [--null] [pattern] [file ...]

geekay
  • 1,655
  • 22
  • 31