I have a rather complicated deploy setup for our Drupal site that is a combination of CVS and SVN. We use CVS to get the newest versions of modules, and we deploy with SVN. Unfortunately, when CVS updates remove files, Subversions complains because they weren't removed in SVN. I am trying to do some shell scripting and Perl to run an svn rm
command on all these files that have already been deleted from the filesystem, but I have not gotten far. What I have so far is this:
svn st | grep !
This outputs a list of all the files deleted from the filesystem like so:
! panels_views/panels_views.info
! panels_views/panels_views.admin.inc
! contexts/term.inc
! contexts/vocabulary.inc
! contexts/terms.inc
! contexts/node_edit_form.inc
! contexts/user.inc
! contexts/node_add_form.inc
! contexts/node.inc
etc. . .
However, I want to somehow run an svn del
on each of these lines. How can I get this output into my Perl script, or alternatively, how can I run svn del
on each of these lines?
Edit: The exact command I used, with some help from all, was
svn st | grep ^! | cut -c 9- | xargs svn del
Try using xargs
, like this:
svn st | grep ^! | cut -f2 | xargs svn rm
The xargs
command takes lines on its standard input, and turns them around and uses those lines as command line parameters on the svn rm
. By default, xargs
uses multiple lines with each invocation of its command, which in the case of svm rm
is fine.
You may also have to experiment with the cut
command to get it just right. By default, cut
uses a tab as a delimiter and Subversion may output spaces there. In that case, you may have to use cut -d' ' -f6
or something.
As always when building such a command pipeline, run portions at a time to make sure things look right. So run everything up to the cut
command to ensure that you have the list of file names you expect, before running it again with "| xargs svn rm"
on the end.
svn st | egrep ^! | cut -b 9- | xargs svn del
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With