views:

2194

answers:

3

I want to commit a large amount of XML files which have been modified. However, within the directory that I want to recursively search through, there are many folders/files which have been added locally, these I do not want to commit.

Is there a way to do this on the command line?

Update: I should have included the SVN version info: svn, version 1.4.6 (r28521), compiled Mar 11 2008, 08:26:35

P.S. I'd be interested in answers which include how to force the commit, e.g. even if files have been locked.

+4  A: 

Have you tried using an svn:ignore property on the local files/folders? But unless you svn add them, they won't get committed...

typically --force will allow you to steal the file lock.

whoisjake
--force gave me an error, saying it was unrecognised for the svn commit command. 'svn help commit' only mentions a force-log option, which I assume is not what I want.
Grundlefleck
+2  A: 

EDIT: I'm rewriting this answer based on some of the information you updated in your questions.

First, to forcibly unlock files it's not enough to simply --force the commit. You use --force with the unlock command and you have to use it on the exact URL that you want to unlock. Unfortunately, this is the only way to do it unless you have access to the repository. If you can access the repository directly, you can use the svnadmin command as displayed here:

svnadmin lslocks /path/to/repository

This will display the locked files. To unlock:

svnadmin rmlocks /path/to/repository /project/path/to/locked/file

If you don't have direct access to the repository, you remove the locks one at a time like so:

svn --force unlock svn://url.to.repository/project/path/to/locked/file

Once you're ready to check in, you can list the files directly that you want checked in instead of just doing the default directory. This will allow you to check in only the modified XML files while ignoring directory structure changes, additions, or whatever else it is that you don't want checked in (added unlock example too):

svn --force unlock svn;//url.to.repository/project/janes_subdir/jane.xml
svn ci -m "Whatever Log" foo.xml junk.xml my_subdir/*.xml janes_subdir/jane.xml
Jason Coco
I wouldn't normally, but the holders have packed up and went home for the night. :-)
Grundlefleck
Ah ok, that makes sense then :)
Jason Coco
+1  A: 

You didn't specify which command-line, so assuming UNIX or cygwin.

A few options:

  1. find . -name '*.xml' -print0 | xargs -0 svn ci
  2. svn status | egrep '^M.*\.xml$' | sed -e 's/^. *//' > tmp.txt && svn ci --targets tmp.txt
  3. svn status > tmp.txt && $EDITOR tmp.txt && sed -e 's/^. *//' < tmp.txt > tmp2.txt && svn ci --targets tmp2.txt

NOTE: I haven't tested the commands.

The first one will commit all XML files (including those that you've recently added - not a problem if you haven't added new xml files).

The second commits all modified xml-files.

The third one will allow you to modify the file list before committing. Simply remove all lines you don't want to commit. You might be more comfortable doing each command on it's own rather than chaining them all together like I did (split on &&).

As for locking there was another comment that seemed to cover most of it.