qnew --parent

Ben Schmidt mail_ben_schmidt at yahoo.com.au
Wed Feb 10 09:01:49 UTC 2010


On 10/02/10 5:43 PM, Matt Mackall wrote:
> On Wed, 2010-02-10 at 14:23 +1100, Ben Schmidt wrote:
>> Hi,
>>
>> I hope this is the right place to raise this issue. Please let me know if not.
>> Happy to jump on a bug tracker or something if that's more appropriate.
>>
>> This is quite a minor change, but I think useful.
>>
>> I'd like to suggest adding a --parent option to qnew to allow it to create a patch
>> from a merged working directory by explicitly stating which parent of the merge
>> the patch should be based on.
>>
>> My reasoning comes from an experience I just had. I maintain a patch queue of
>> changes I regularly apply to Vim as I compile it. Each time I want to compile, I
>> unapply my patches, pull in all the upstream changes, and then reapply the
>> patches. Recently, though, an upstream change conflicted severely with a patch.
>> Not having time immediately to rework the patch, and not being all that interested
>> in the upstream change, I decided to create a new patch to back out the upstream
>> change, applying it before the conflicting patch. After a bunch of trying things,
>> I found I could do it with debugsetparent, but it would be better if I could just do
>>
>> hg backout -r BAD_REV
>> hg merge
>> [...resolve conflicts by hand...]
>> hg resolve -m --all
>> hg qnew --parent UPSTREAM_TIP -f backout_BAD.patch
>> hg strip BACKOUT_REV
>>
>> I'm keen to do it this way as the three-way merge of hg merge was a lot easier to
>> deal with than trying to reverse the changes made by BAD_REV with just a simple patch.
>>
>> It would probably make sense to allow qimport with the -r option to also work with
>> merge changesets by specifying --parent, too, though this is a bit more dangerous.
>
> Seems like a job for rebase to me.

Right you are, Matt. Rebase didn't exist when I learnt Mercurial, and I
haven't really followed development since, unfortunately, so I wasn't
aware of it or what it could do. But it handles this nicely. For the
record:

hg backout -r BAD_REV
hg update tip
hg rebase --dest UPSTREAM_TIP
[...resolve conflicts by hand...]
hg resolve -m --all
hg rebase --continue
hg qimport -r tip -n backout_BAD.patch

Ben.







More information about the Mercurial-devel mailing list