This post originated from an RSS feed registered with Ruby Buzz
by Jay Fields.
Original Post: Using patch as a subversion stash
Feed Title: Jay Fields Thoughts
Feed URL: http://blog.jayfields.com/rss.xml
Feed Description: Thoughts on Software Development
Being a consultant, I'm generally at the mercy of whatever source control system my current client is using. Luckily, Subversion has been the version control choice for every client I've worked for in the past 3 years.
A friend of mine, Kurt Schrader, recently posted The Power of Git: git-stash. I haven't gotten a chance to use git, but I am planning to give it a shot in the near future. However, I don't expect to being using git for daily development any time soon.
I've definitely needed a git-stash in the past. It's helpful for fixing a bug without committing your current changes, but it's also helpful if I ever get to work and I end up on a pairing station that has someone else's uncommitted changes.
In those cases I create a patch, revert the changes and move on.
In case you're unfamiliar with this type of thing, here's all you'll need to do (assuming you have patch available).
Creating the patch: svn diff > patch_name.patch
note: You'll want to add any new files before creating the patch, if you want them included in the patch.
Once you've created the patch you can revert everything and start fresh (svn revert -R . will recursively revert). You may also need to delete any new files that were created as part of the uncommitted changes (Paul Gross has a one liner for removing uncommitted files).
When you are ready to get your changes back you'll need to apply the patch that was previously created.
Applying a patch: patch -p0 < patch_name.patch
That's basically it for decent stash capabilities with Subversion, but there is one gotcha: patch will not capture Subversion metadata changes. Usually this isn't a problem, but it's always a good idea to look out for this situation when you create a patch.