Bug 4385 - add a --keep flag to `hg prune`
Summary: add a --keep flag to `hg prune`
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: evolution (show other bugs)
Version: unspecified
Hardware: PC Linux
: normal feature
Assignee: Bugzilla
URL:
Keywords: easy
Depends on:
Blocks:
 
Reported: 2014-09-27 17:22 UTC by Pierre-Yves David
Modified: 2015-12-07 19:00 UTC (History)
5 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pierre-Yves David 2014-09-27 17:22 UTC
`hg strip` have a --keep flag to not update the working copy when operating. It is handy and `hg prune should grow one.
Comment 1 Jordi Gutiérrez Hermoso 2014-10-16 20:06 UTC
Isn't this what uncommit does? I'd rather have 'uncommit --prune' or something like that.
Comment 2 Pierre-Yves David 2014-10-16 20:08 UTC
uncommit is not able to remove multiple changeset at the same time. philosophically uncommit have a different purpose and is more single changesets centric. For example it perserve metadata (commit description etc well).
Comment 3 Jordi Gutiérrez Hermoso 2014-10-17 09:32 UTC
I'm a bit troubled by having prune grow an option that does more or less the same thing as uncommit. I think getting rid of csets is one operation and moving changes from a cset back into the working directory is a different operation. If indeed these are different operations, then they should remain as different commands.

I know we combine commands sometimes, rarely, like `hg pull --update`, and following this combination of two commands in one, it still seems to me like `hg uncommit --prune` is the right combination.

I don't think, on the other hand, that `hg strip --keep` is the right model to follow. I also find the idea of combining different commits all into one working directory state to be odd. Is this a frequent use case?
Comment 4 Pierre-Yves David 2014-10-17 15:13 UTC
The point here is: "I would like to burn those commit to the ground but I want to preserve my local file" It seems reasonable to me and I've seem people doing that on a regular basis.
Comment 5 Matt Mackall 2015-03-03 15:24 UTC
Bulk change: standard priority for features is 'wish'.
Comment 6 Matt Mackall 2015-04-17 13:28 UTC
Bulk move open feature requests to wish priority.
Comment 7 Kevin Norris 2015-08-04 23:31 UTC
Here's a "real" use case.

I start working on a large scale change.  About halfway through, I realize that I want to fold the parent of the working directory into the next commit.  But the next commit doesn't exist yet.  I *could* do hg commit/fold/uncommit, but `hg prune --keep .` is faster and easier.
Comment 8 Jordi Gutiérrez Hermoso 2015-08-05 08:25 UTC
Kevin, I still think `hg uncommit` should be the command that does that. You in effect want to move the changes from the last commit into the working directory. That's an uncommit!
Comment 9 Pierre-Yves David 2015-08-05 14:33 UTC
Kevin, why don't you just use `hg amend` here?
Comment 10 Kevin Norris 2015-08-05 14:38 UTC
There are a lot of things I can do here.  But hg prune --keep is the simplest thing I can do *right now* which does not require me to remember to do anything *else* later.

If I do hg amend, I'll still have to amend again once I'm satisfied with the commit.  Worse, in the meantime I can't safely push (to a publishing server)!
Comment 11 Jordi Gutiérrez Hermoso 2015-08-05 14:40 UTC
My point is, `hg prune --keep` doesn't seem like the right name for this option. I think `hg uncommit` describes this operation better.
Comment 12 Kevin Norris 2015-08-05 14:47 UTC
Personally, I'm not attached to calling this "prune," though I can't speak for the reporter.  I just want to see the functionality included one way or another.

Perhaps hg uncommit --keep?  But then if the working directory is clean, it acts just like hg prune, so now we have the opposite problem.  Hrm.
Comment 13 Kevin Norris 2015-08-05 14:49 UTC
Wow, I'm getting really confused here.  It would *not* act just like hg prune, so that's not a problem after all.
Comment 14 Pierre-Yves David 2015-08-05 14:56 UTC
But hg prune --keep is going to break your evolution history (meta history of what changesets became what). So we are unlikely to push its usage forward to ensure `hg evolve` will work as best as possible.
Comment 15 Jordi Gutiérrez Hermoso 2015-08-05 15:13 UTC
`hg uncommit --all` already suggests that you might want to prune the cset, so why not add an option to make it stfu and jfdi?
Comment 16 liscju 2015-09-25 04:47 UTC
Issue can be closed, checked this in mercurial 3.5.1 and prune has keep option which works fine
Comment 17 Jordi Gutiérrez Hermoso 2015-09-25 09:46 UTC
I still think this is the wrong fix and uncommit should be the one that changes to have --all by default and also prunes the cset. That would make it exactly the opposite of `commit`. As it is now, the opposite of `commit` is `prune --keep`, which seems all sorts of wrong.

I will soon settle this matter with an arm wrestling match against Pierre-Yves.
Comment 18 Pierre-Yves David 2015-12-07 19:00 UTC
This is done