RFE: hg import --bypass target should be customizable

Marc Strapetz marc.strapetz at syntevo.com
Tue Nov 22 17:51:31 UTC 2011


I'm trying to import a self-created patch into an existing Mercurial
repository with "hg import". Goal is to not touch the working copy, so
I'm using --bypass. Unfortunately, --bypass will always use the working
copy parent which is in general not the target changeset to which the
patch should be applied. --exact would allow to specify the target
"Parent" in the patch, but unfortunately it performs a final check
whether "Node ID" from the patch matches resulting changeset ID, which
isn't the case because it's self-created and it would be (too) hard to
calculate the correct SHA.

Motivation for this RFE: I'm trying to find a procedure which allows me
to squash two commits into one (working copy commit + its immediate
parent), then update to the newly created commit. Basically, this is the
foundation for a "git --amend"-like command. I got a couple of
suggestions, but none of them would work as every approach requires to
have a clean working copy at a certain point:

http://stackoverflow.com/questions/8182858/mercurial-how-to-amend-the-last-commit

The approach I've in mind now which currently fails due to the mentioned
import problem is:

- have changeset C1
- commit what should be amended as separate changeset C2
- create combined diff for C1 and C2
- prepend Mercurial patch comments to that patch ("# HG changeset patch
...")
- import combined patch as new commit C3
- update working directory to C3 (this won't require to touch any
working copy file because C1 + C2 = C3)
- strip C1 and C2

Is there a more sane solution?

--
Best regards,
Marc Strapetz
=============
syntevo GmbH
http://www.syntevo.com
http://blog.syntevo.com




More information about the Mercurial-devel mailing list