[PATCH 0 of 1] Add qpush --exact

Steve Losh steve at stevelosh.com
Wed Nov 17 20:18:54 CST 2010


We've been writing '# Parent abc123...' headers into MQ patches (as long as
mq.plain isn't set) for two full versions now, but we haven't done anything
special/useful with them yet.

A common problem I encounter is this:

1. Someone sends me some MQ patches, or I make some.
2. I want to rebase them to the tip of a repo.
3. I run 'head' on the first patch file to see where I'm supposed to apply it.
4. I apply it, then rebase as normal to use the merge machinery to update the
   patches.

I want to eliminate step 3.

See the patch message for the low-level details.

This cuts out the ugly step of looking up the parent revision manually.

I added a '-e' short option even though 'hg import's '--exact' option doesn't
have one. I did this because it's fairly safe, and those of us interested in
this option will probably use it constantly. I'm not too attached to it though,
if others decide it's not worth it I'll just make an alias and not worry about
it.

Bonus: we can now use a shell alias to make this a one-step operation:

    [alias]
    # hg qrebase [SOURCEPATCH [DESTREV]]
    qrebase = !HG_CUR_REV="`$HG id -q .`" && \¬
               HG_TARGET_REV="`$HG id -r $(test -n '$2' && \¬
                                            echo '$2' || \¬
                                            echo '.') -q`" && \¬
               $HG qpush --exact $1 && \¬
               $HG rebase -s qbase -d "$HG_TARGET_REV"

    $ hg qrebase bugfixpatch1
    $ hg qrebase -a
    $ hg qrebase bugfixpatch1 140d94183ce1
    $ hg qrebase -a 140d94183ce1




More information about the Mercurial-devel mailing list