Skip to content
Tags

, ,

Separate commits at Subversion

29/12/2011

In this article of Ryan Tomayko I’ve found a nice trick for Subversion. when there are changes at current working directory that belong to at least 2 different changesets. What is easily achieved in Git using the git add -i (or the more straightforward and short git add -p) command, in Subversion another approach is necessary.

Here are the steps that Ryan suggests:

$ svn diff | vi - > hunks.diff    # remove unwanted chunks
$ patch -p0 -R < hunks.diff
$ svn ci
$ patch -p0 < hunks.diff
$ svn st

At first step we create a whole changeset with all the changes that subversion finds. We send the output to vim and delete the unwanted to commit changes. We save at file hunks.diff.

At 2nd step we remove these changes from working directory using patch and the -R switch. The changes left at working directory are the ones to be committed (step 3). Then, we apply again the saved changes at step 4, and we can see these differences at step 5 (optional). Now we can proceed to another commit or branch or whatever we want with these.

Update: Arabesque has a great demonstration of the above situation in Subversion, and presents a nice example of how to resolve it with Git.

Advertisements

From → Programming

Leave a Comment

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: