Reputation: 348
I've previously (i.e. several changesets ago) committed a fairly big changeset that contains both good changes I'd like to keep, and some I'd like to undo. Yes, I shouldn't have packed so much into a single changeset anyway, but now the damage is done.
AFAIK, Mercurial's backout command can only work on an entire changeset. I can certainly figure out how to do this manually in a few steps, but I'm wondering: is there an easy way of getting only part of a changeset reversed?
(If it matters, the changes I'd like to undo are file deletions.)
Upvotes: 1
Views: 230
Reputation: 750
If you want to undo file deletions, then it would be better to use hg revert
instead of hg backout
:
hg status --change CSET --removed -n0 | xargs -0 hg revert --rev CSET^1
Upvotes: 0
Reputation: 97282
Depending from conditions (amount of "must-be-backout'ed" and "must be preserved" or file-patterns for both cases) you can use hg backout
with -I (include mask) or -X (exclude mask) option
hg backout -r CSET -I FILE
backout only changes for FILEhg backout -r CSET -X FILE
backout all changes except in FILEUpvotes: 1
Reputation: 348
I should have tried before posting, but this may be useful for others as well:
Backout doesn't automatically commit. So the approach that worked for me is to run hg backout, then simply revert the files that I don't want to be changed back.
Upvotes: 1