Given the case I made two independent changes in one file: eg. added a new method and changed another method.
I often don't want to commit both changes as one commit, but as two independent commits.
On a git repository I would use the Interactive Mode of git-add(1) to split the hunk into smaller ones:
git add --patch
What's the easiest way to do this with Subversion? (Maybe even using an Eclipse plug-in)
Update:
In The Thing About Git, Ryan calls it: “The Tangled Working Copy Problem.”
Try using
svn diff > out.patch
then copy theout.patch
file toout.patch.add
andout.patch.modify
Only when you have a working patch file revert the original file using
svn revert out.c
.Edit the patch files by hand so that they only contain the hunks for adding or modifying. Apply them to the original file using the
patch
command, test if the addition worked, thensvn commit
the addition.Wash rinse repeat for the
out.patch.modify
patch.If the changes are separate in the file as your initial question stated - added a new method, changed an existing method - this will work
This is a very tedious solution - although I'm not convinced you should have any reason to separate your commits.
You also could have checked out multiple working copies of the same source to apply your work against:
Be sure to
svn up
and test to make sure all is well.I think an easier option than generating diff files, reverting, etc, would be to have two copies of the repository checked out, and use a visual diff tool like DeltaWalker to copy hunks from one to the other.
The first copy would be the one you actually work off of, and the second would just be for this purpose. Once you've made a ton of changes to the first, you can copy one section over to the second, commit it, copy another section, commit it, etc.
This is possible using TortoiseSvn (Windows) since v1.8.
On Linux, I would give http://webstaff.itn.liu.se/~karlu20/div/blog/2013-05-31_SVNPartialCommit.php a try. Haven't tried it out myself, though.
svn diff
.svn revert
.patch
tool, or by manual editing, or whatever.diff
afterwards to compare your working copy with your back-up to be sure you applied the patch-parts correctly.It's a little riskier than Spike's full suggestion but can be easier to do. Also make sure you try it on something else first as some editors will refuse to save over a file that has changed out from under them unless you reload that file (losing all your changes)