all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Dan Nicolaescu <dann@ics.uci.edu>
Cc: "Óscar Fuentes" <ofv@wanadoo.es>, emacs-devel@gnu.org
Subject: Splitting changes (was: support for bzr shelve/unshelve in vc-dir)
Date: Thu, 03 Dec 2009 12:05:49 -0500	[thread overview]
Message-ID: <jwvhbs8812v.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <200912030907.nB39781X022853@godzilla.ics.uci.edu> (Dan Nicolaescu's message of "Thu, 3 Dec 2009 01:07:08 -0800 (PST)")

>> The implementation shelves all the changes on the current
>> branch. Although this is useful, an usual application of `shelve' is for
>> temporarily removing out of your way some changes (allowing to commit
>> only specific changes of the edited files, for example.) An ideal
>> implementation of `shelve' for vc would show the output of `bzr diff',
>> mark the hunks you want to shelve, and then run the command. Sadly, it
>> seems impossible to non-interactively indicate to bzr which hunks it
>> should shelve.

> That's exactly the reason for the current implementation.
> Patches to add other methods to create shelves (including an
> interactive) are surely welcome.

I've been interested in this issue for a while now: I've been using
a local patch to VC which adds a command
"vc-prepare-for-partial-commit", which allows to choose which part of
some local changes should be committed and which part should be kept
for later.

I've never installed it in the trunk for various reasons, but I've use
it extensively for many years.  In this time I noticed the following:
- selecting only by files is not a fine enough granularity.
- selecting only by hunks is sometimes sufficient, but even that is too
  coarse in my experience.  The typical problem is that I want to split
  a change into a cleanup part and an actual new feature, but in most
  cases all the cleanup changes touch the exact same code as the new
  feature, so many of the hunks mix both.

So the way my hack works is the following:
- it takes ("stashes") a copy of the current state.
- then it lets you make any changes you want (the intention is that
  you're going to revert the changes you want to keep for later).
  You can do this part at any granularity: files, hunks, or even
  by hand.
- when done, you commit, after which the saved files are re-instated.

This gives me great flexibility, and lets me use any tool I want to
select which parts to keep and which parts not.  So I really like it.
But it has some serious drawbacks:
- if the final commit fails because the tree is not uptodate (any more),
  the backend won't know that the update should apply to both the file
  and its "stashed" copy.  So you end up having to deal with updates
  missing from the stashed copy, or abort the partial commit
  (i.e. revert to the stashed copy), then update, then re-do the split
  by hand.
- when doing the split by hand, you can make any change you want.
  The intention is for those changes to "undo" part of the local
  changes, but nothing prevents you from adding new changes during this
  time (as you revisit the code to choose how to split your changes, you
  may bump into new opportunities for cleanup and it's sometimes
  difficult to refrain from doing them at that point).  And if you do
  add local changes, then these will be undone after commit when the
  saved files are re-instated.

So I'd like VC to support something like that, but in a way that is
a bit more robust.  The way I see it working ideally is something like
the following:
- the copy is taken by committing the local changes on a new temporary branch
  (IIUC, that's pretty much what "git stash" does).
- then revert to the original branch and reapply those same changes
  (without committing them).
- at this point the user can use any tool he likes to remove parts of
  those changes he doesn't want to commit yet.  She can also "update"
  her tree when needed.
- when she's ready, she can perform the "commit", after which VC will
  ask to merge the temporary branch (without committing the result),
  which will hopefully result in pretty much the same as the original
  code before this whle partial commit took place.

The advantage here, is that because we use branches rather than manually
copying files behind the VCS's back, the VCS has all the needed
meta-data to ensure that no change is accidentally lost or undone.

The disadvantage is that the final merge is likely to introduce spurious
conflicts since it will re-apply the parts of the changes that
were just committed.  But if "same change conflicts" are automatically
resolved by your merge tool, then all the changes that were selected at
the granularity of a hunk (or larger) should be merged
without conflict.  I.e. you should only see conflicts when you actually
take advantage of the extra flexibility.


        Stefan




  reply	other threads:[~2009-12-03 17:05 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-01 19:47 support for bzr shelve/unshelve in vc-dir Dan Nicolaescu
2009-12-01 20:48 ` Xavier Maillard
2009-12-02  5:43   ` Dan Nicolaescu
2009-12-02  6:37     ` Óscar Fuentes
2009-12-01 22:11 ` Stefan Monnier
2009-12-01 22:50   ` Óscar Fuentes
2009-12-01 23:18     ` Óscar Fuentes
2009-12-02  3:00       ` Dan Nicolaescu
2009-12-02  3:03   ` Dan Nicolaescu
2009-12-02  3:31     ` Óscar Fuentes
2009-12-02  4:35       ` Stefan Monnier
2009-12-02  5:06         ` Óscar Fuentes
2009-12-02  6:16         ` Stephen J. Turnbull
2009-12-02  6:42           ` Óscar Fuentes
2009-12-03  7:48   ` Dan Nicolaescu
2009-12-03  8:25     ` Óscar Fuentes
2009-12-03  8:32       ` Bojan Nikolic
2009-12-03  9:07       ` Dan Nicolaescu
2009-12-03 17:05         ` Stefan Monnier [this message]
2009-12-03 17:46           ` Splitting changes (was: support for bzr shelve/unshelve in vc-dir) Eli Zaretskii
2009-12-03 19:26             ` Splitting changes Stefan Monnier
2009-12-03 19:47           ` Óscar Fuentes
2009-12-03 20:50             ` Stefan Monnier
2009-12-03 17:24         ` support for bzr shelve/unshelve in vc-dir Óscar Fuentes
2009-12-03 18:18           ` Óscar Fuentes
2009-12-03 18:48             ` Dan Nicolaescu
2009-12-03 19:00               ` Óscar Fuentes
2009-12-03 19:17                 ` Dan Nicolaescu
2009-12-03 21:30                   ` Óscar Fuentes
2009-12-03 22:57                     ` Dan Nicolaescu
2009-12-04  0:42                       ` Stephen J. Turnbull
2009-12-04  1:47                         ` Dan Nicolaescu
2009-12-04  2:57                           ` Óscar Fuentes
2009-12-04  6:36                             ` Stephen J. Turnbull
2009-12-04 21:18                             ` Dan Nicolaescu
2009-12-04 21:59                               ` Óscar Fuentes
2009-12-04 22:57                                 ` Dan Nicolaescu
2009-12-04 23:52                                 ` Glenn Morris
2009-12-05  3:57                                   ` Stephen J. Turnbull
2009-12-05  6:49                                     ` Jan Djärv
2009-12-05  7:12                                       ` Miles Bader
2009-12-05 16:12                                         ` Stefan Monnier
2009-12-05 12:09                                       ` Stephen J. Turnbull
2009-12-05 19:59                                   ` Glenn Morris
2009-12-06 19:27                                   ` Richard Stallman
2009-12-06 20:11                                     ` GNU bzr [was Re: support for bzr shelve/unshelve in vc-dir] Glenn Morris
2009-12-09 13:20                                       ` Richard Stallman
2009-12-09 16:50                                         ` GNU bzr Karl Fogel
2009-12-15 23:11                                           ` Karl Fogel
2009-12-10  0:16                                   ` support for bzr shelve/unshelve in vc-dir Martin Pool
2009-12-10  3:46                                     ` Stefan Monnier
2009-12-10  4:19                                       ` Martin Pool
2009-12-10 14:02                                     ` Dan Nicolaescu
2009-12-11  4:02                                       ` Martin Pool
2009-12-18 15:39                                         ` Dan Nicolaescu
2009-12-21  1:49                                           ` Martin Pool
2009-12-11  5:53                                       ` Martin Pool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvhbs8812v.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=dann@ics.uci.edu \
    --cc=emacs-devel@gnu.org \
    --cc=ofv@wanadoo.es \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.