Someone was asking about changelists on IRC today and that led to a
discussion of committing just parts of a file as part of a changelist.
Here are some ideas regarding partial commits.
I haven't really used changelists, so I haven't considered how they
would impact my ideas below. But I'll leave that for you guys to work
out if you find anything useful in this email.
Also note that these fantasies deal purely with the command line
BTW, I just grabbed a recent commit to subversion that had multiple
hunks. There is no particular significance to this other than for
This fantasy pertains to "svn ci" only (where no message is specified
on the command line and you're place in the editor of your choice to
compose the commit message)
SVK has this interesting feature that the list of files that have been
changed that normally appears at the bottom of your editor window
*aren't* completely ignored as they are in svn. Rather, if you delete
one of these lines while using SVK, that file is not committed.
svn could adopt a similar strategy and also allow partial commits by
putting a summary of the diff below each file. So, for instance, if I
were committing a file that had lots of changes ...
[ log message here ]
=== Targets to commit (you may delete items from it) ===
@@ -13,9 +13,9 @@
@@ -27,11 +27,13 @@
@@ -52,8 +54,11 @@
@@ -62,7 +67,10 @@
@@ -78,7 +86,7 @@
@@ -99,30 +107,24 @@
@@ -152,12 +154,12 @@
@@ -185,8 +187,8 @@
@@ -185,8 +187,8 @@
@@ -212,16 +214,18 @@
@@ -246,7 +250,7 @@
I could only commit some of those changes by deleting the lines that I
did not want to commit.
Now obviously, I haven't fleshed out the mechanism by which that
happens, but it's doable I think. Maybe each hunk is tagged with some
unique identifier and only that particular diff is applied (for
Another similar mechanism could be to provide an option to "svn diff"
that lists the hunks that will be committed and an option to "svn ci"
that accepts a list of hunks to commit (and only those hunks). It
could look something like this:
$ svn diff --list-hunks
1: contrib/hook-scripts/svn2rss.py @@ -13,9 +13,9 @@
2: contrib/hook-scripts/svn2rss.py @@ -27,11 +27,13 @@
3: contrib/hook-scripts/svn2rss.py @@ -52,8 +54,11 @@
4: contrib/hook-scripts/svn2rss.py @@ -62,7 +67,10 @@
5: contrib/hook-scripts/svn2rss.py @@ -78,7 +86,7 @@
6: contrib/hook-scripts/svn2rss.py @@ -99,30 +107,24 @@
7: contrib/hook-scripts/svn2rss.py @@ -152,12 +154,12 @@
8: contrib/hook-scripts/svn2rss.py @@ -185,8 +187,8 @@
9: contrib/hook-scripts/svn2rss.py @@ -185,8 +187,8 @@
10: contrib/hook-scripts/svn2rss.py @@ -212,16 +214,18 @@
11: contrib/hook-scripts/svn2rss.py @@ -246,7 +250,7 @@
$ svn commit --hunks 1,2,7-11 -m 'Documentation changes'
That commit line would only commit hunks 1,2,7,8,9,10, and 11. The
other changes to that file would continue to only exist in the local
working copy (presumably for a future commit)
And finally, why not make the commit process interactive?
$ svn commit --interactive contrib/hook-scripts/svn2rss.py
--- contrib/hook-scripts/svn2rss.py (revision 20756)
+++ contrib/hook-scripts/svn2rss.py (revision 20757)
@@ -13,9 +13,9 @@
-h, --help Show this help message.
-f, --feed-file=PATH Store the feed in the file located at PATH, which
- will be created if it doesn't already exist. If not
- provided, the script will store the feed in the
- current working directory, in a file named
+ will be created if it does not exist, or overwritten if
+ it does. If not provided, the script will store the
+ feed in the current working directory, in a file named
REPOS_NAME.rss (where REPOS_NAME is the basename
of the REPOS_PATH command-line argument).
commit this hunk? (Yes/no/all/quit) >
After iterating over the hunks, the user would then be placed in their
favorite editor as usual, or if the -m command line switch was given
svn would just commit them. The "Yes/no/all/quit" options could
also include a way to back up if you screw up.
Jonathan Scott Duff
To unsubscribe, e-mail: email@example.com
For additional commands, e-mail: firstname.lastname@example.org
Received on Fri Jul 21 14:42:01 2006