monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-devel] Perhaps strange request: partial per-file commit


From: Ralf S. Engelschall
Subject: [Monotone-devel] Perhaps strange request: partial per-file commit
Date: Tue, 15 Jan 2008 16:10:34 +0100
User-agent: Mutt/1.5.17 OpenPKG/CURRENT (2007-11-01)

Sorry, in case this seems too strange for most of you, but it a
"problem" I'm faced with mostly every day and I really would appreciate
some additional support from Monotone. Let me describe...

While I'm in "wild hacking mode" I adjust many source files. Once
everthing works I have to decide on how to commit all my changes. Here
the general golden rule for me is that all logically separate changes
should be also committed separately. I usually never break this rule in
all of my projects. So, if the changes do not overlap on a file-basis at
all, it is trivial, of course:

    $ mtn ci -m "description of logical change1" file11 ... file1N
    $ mtn ci -m "description of logical change2" file21 ... file2N
    $ mtn ci -m "description of logical change3" file31 ... file3N

But what if change1 and change2 overlap in a file, say file11 == file21.
My solution since many many years (there just with "cvs" and "svn", now
with "mtn") is:

    $ mtn diff file11 >change2
    $ vi change2
    [...remove all hunks which correlate to change1...]
    $ patch -p0 -R <change2
    $ mtn ci -m "description of logical change1" file11 ... file1N
    $ patch -p0 <change2
    $ mtn ci -m "description of logical change2" file21 ... file2N
    $ mtn ci -m "description of logical change3" file31 ... file3N

Sure, this works just fine. But it is a little bit nasty and boring,
because the hunks theirself are usually at least in 99% of all cases
non-overlapping, so what I would like to have is (assuming that only
hunks 2 and 4 in file11==file21 are for change2) something like this:

    $ mtn ci -m "description of logical change1" file11:-2,-4 ... file1N
    $ mtn ci -m "description of logical change2" file21:+2,+4 ... file2N
    $ mtn ci -m "description of logical change3" file31       ... file3N

The particular syntax doesn't matter very much. Every syntax is better
than all the time having to do the manual dance mentioned above.

Keep in mind that the "restrict a file change to particular hunks only"
is also interesting for other purposes. For instance in the mod_ssl
project for many years we created separate annotated patch sets out of a
single patch set by doing something like the above "+M,-N,+X,.." syntax
in a Perl wrapper over "cvs diff" outputs. So, it would be also nice
to have the "hunk restriction" feature for "mtn diff":

    $ mtn diff file11:-2,-4

One final notice for the inclusion/exclusion syntax: it is a list of
comma-separated [+-]M[-N] parts where N (or M) is the Nth patch hunk
in the "mtn diff" output and "N-M" means all hunks from N to M (both
inclusive). If one starts with a positive/include +N, the initial set
of patch hunks is assumed to be empty (else the first +N would have no
meaning anyway). Vice versa: if one starts with a neative/exclude -N, te
initial set of patch hunks is assumed to be all hunks (else the first -N
again would have no meaning anyway). So, "+3-5,-4" means junks 3 and 5
only, "-3-5,+4" means hunks 1, 2 and 4, etc...

But, yes, as I said, perhaps it is a too strange request as it is just
me in fiddling around with individual hunks of a file change all the
time in order to be able to provide "clean commits"...

                                       Ralf S. Engelschall
                                       address@hidden
                                       www.engelschall.com





reply via email to

[Prev in Thread] Current Thread [Next in Thread]