You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Jonathan Scott Duff <du...@pobox.com> on 2006/07/19 21:56:06 UTC

Submitted for your perusal: partial commits

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
interfaces.

BTW, I just grabbed a recent commit to subversion that had multiple
hunks.  There is no particular significance to this other than for
illustrative purposes.

Fantasy #1

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) ===
M   contrib/hook-scripts/svn2rss.py
    @@ -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
instance).


Fantasy #2

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)

Fantasy #3

And finally, why not make the commit process interactive?

$ svn commit --interactive contrib/hook-scripts/svn2rss.py
Index: 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.

__END__


-Scott
-- 
Jonathan Scott Duff
duff@pobox.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Submitted for your perusal: partial commits

Posted by Molle Bestefich <mo...@gmail.com>.
Peter Samuelson wrote:
> What you're asking for is the 'quilt' program.  It manages a stack of
> patches in your working copy and lets you cycle up and down them.  I
> haven't checked to see if it is aware of subversion - if not, it'd need
> to be fixed at the least to ignore .svn directories - but other than
> that, it does pretty much exactly what you describe.

Quilt is, AFAIK, a unix shell script, and as such not particularly
well suited for me, since I do most of my development on Windows.

Another would-be option is the 'changeset' functionality added to
TortoiseSVN by Aniruddha Apte.  Screenshots here:
http://svn.haxx.se/tsvn/archive-2005-10/0464.shtml

The changes were never integrated into mainline TSVN for one reason or
another, it only lived as a separate build of the relevant binaries
(downloadable from the main file area, though).  Users had various
issues with that, like it wouldn't link properly if you weren't using
the exact right version of TSVN against the modified TortoiseProc.exe.

Many people were probably very worried about the fact that the
solution was not officially endorsed by the core Subversion
developers, and so didn't try it / use it.

AFAIK, it's now stale, at least as far as the downloadable version
from the official TSVN site goes - it's probably still in use
privately, if I were to guess.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Submitted for your perusal: partial commits

Posted by Peter Samuelson <pe...@p12n.org>.
[Molle Bestefich]
> Would it not be more fun if you could set a check point in your local
> working copy every time you start working on a new logical change?

What you're asking for is the 'quilt' program.  It manages a stack of
patches in your working copy and lets you cycle up and down them.  I
haven't checked to see if it is aware of subversion - if not, it'd need
to be fixed at the least to ignore .svn directories - but other than
that, it does pretty much exactly what you describe.

Re: Submitted for your perusal: partial commits

Posted by Molle Bestefich <mo...@gmail.com>.
Jonathan Scott Duff wrote:
> Fantasy #2
>
> 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)

Would it not be more fun if you could set a check point in your local
working copy every time you start working on a new logical change?

... working on adding feature XYZ, suddenly discovers a bug ...
$ svn mark -m "adding feature XYZ"
... fix the bug ...
$ svn mark -m "fixed a bug ABC"
... next, switch back to previous flag / check point ...
$ svn switch-to-mark "adding feature XYZ"
... work some more ...

And come commit time:

$ svn switch-to-mark "fixed a bug ABC"
$ svn ci
$ svn switch-to-mark "adding feature XYZ"
$ svn ci

Or am I trying to solve a different problem?

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Submitted for your perusal: partial commits

Posted by David Glasser <gl...@mit.edu>.
Jonathan Scott Duff <duff <at> pobox.com> writes:

> And finally, why not make the commit process interactive?
> 
> $ svn commit --interactive contrib/hook-scripts/svn2rss.py
...
> commit this hunk?  (Yes/no/all/quit) >

Subversion developers may wish to take a look for comparison at SVK's "svk
commit --interactive" feature, which does exactly this. (I do not believe that
interactive commit is in the SVK 1.0 releases, but it can be found in the
current SVK trunk.)

--dave

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Submitted for your perusal: partial commits

Posted by Julian Foad <ju...@btopenworld.com>.
Jonathan Scott Duff wrote:
> 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.

This sort of ability could certainly be useful but I think it definitely falls 
outside the scope of what the "svn" command-line client should do, and belongs 
in a separate Subversion client program.

- Julian


> Fantasy #1
> 
> === Targets to commit (you may delete items from it) ===
> M   contrib/hook-scripts/svn2rss.py
>     @@ -13,9 +13,9 @@
>     @@ -27,11 +27,13 @@
>     @@ -52,8 +54,11 @@
[...]
> Fantasy #2
[...]
> $ svn commit --hunks 1,2,7-11 -m 'Documentation changes'
[...]
> Fantasy #3
> 
> And finally, why not make the commit process interactive?
[...]
> commit this hunk?  (Yes/no/all/quit) >

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org