I have a script which builds my application, uploads it to a remote machine, runs a performance test there and captures some metrics that I care about. The script creates a patc
To make svn diff
include all the unversioned files from your local working copy you have to add these files first. svn diff
outputs the same changeset that svn commit
would use.
If you know for sure that all unversioned files should be added here's what you could do.
Prepare a list of unversioned files by taking from the output of svn status
all the lines that start with a question mark:
svn status | grep ^? | sed -r 's/^\? +//' > ../unversioned_files_list.txt
You can then pass that list of files to svn add
using xargs
:
xargs -r -d '\n' svn add < ../unversioned_files_list.txt
And then produce the patch:
svn diff > ../my_patch.patch
If you don't want to keep those files added, use the list of files to unadd them:
xargs -r -d '\n' svn rm --keep-local < ../unversioned_files_list.txt
Thanks Alexandre. At first, his approach didn't work in my case. I was sure all new files were maked A
in svn status
, however, the diff file was still empty. Finally, I found the difference in svn status
outputs, the fourth columns in my case are all populated with +
, like:
$ svn st
M .
A + New.java
This means the item is scheduled for addition-with-history
[1]. This typically happens when you svn move
or svn copy
a file or directory[2]. In my case, the New.java
is svn merged
from another branch, including previous commit history in that branch. Let's removed these history information.
First, find all addition-with-history
items:
svn status | grep ^A | sed -r 's/^A[ +]+//' > /tmp/add_list
Optionally, remove directory paths in /tmp/add_list
to avoid warnings in next step.
Next, remove their history commit information by svn remove
:
xargs -r -d '\n' svn remove --keep-local --force < /tmp/add_list
Then, go back to Alexandre's solution to add them to subversion again and get the diff.
References:
[1]http://svnbook.red-bean.com/nightly/en/svn.ref.svn.c.status.html
[2]http://www.linuxtopia.org/online_books/programming_tool_guides/version_control_with_subversion/svn.ref.svn.c.status.html