Create a set of copy commands from diff

Create a set of copy commands from diff

There’s probably a far better way of managing your Subversion working copies but I find this command is very useful.

I often diff two directories with the diff -wbur command

This produces a lot of output if there are many changes (pages of it).

To limit the output to the lines in the output which point out the changed files I would do:

diff -wbur /var/www/moodleupgrade/mod/vqpack/ svntrunks/moodle3modstrunk/mod/vqpack/ | grep diff

This produces an output like :

diff -wbur /var/www/moodleupgrade/mod/vqpack/view.php svntrunks/moodle3modstrunk/mod/vqpack/view.php
diff -wbur /var/www/moodleupgrade/mod/vqpack/lib.php svntrunks/moodle3modstrunk/mod/vqpack/lib.php

This only shows the files which have changed rather than all of the actual changes. I can automatically create copy commands from this output to place the altered file in my working copy folder like this:

diff -wbur /var/www/moodleupgrade/mod/vqpack/ svntrunks/moodle3modstrunk/mod/vqpack/ | grep diff | awk '{print "cp " $3 " " $4}' 

Which produces the output:

cp /var/www/moodleupgrade/mod/vqpack/view.php svntrunks/moodle3modstrunk/mod/vqpack/view.php
cp /var/www/moodleupgrade/mod/vqpack/lib.php svntrunks/moodle3modstrunk/mod/vqpack/lib.php

I can highlight and copy those commands to copy the files before doing an svn commit

Leave a Reply

Your email address will not be published. Required fields are marked *

For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.