How to swap Mercurial Queues in and out of a repository

后端 未结 3 2056
说谎
说谎 2021-02-03 12:03

I have a platform neutral mercurial code repo called \"Simulator\"

and want to apply patches that target specific platform\'s optimizations before a build.

Acc

3条回答
  •  -上瘾入骨i
    2021-02-03 12:27

    Interesting use of Mercurial Queues :)

    I assume here that you are already versioning your mercurial queues somewhere. If you don't/for those that don't know how to do this, have a look at the relevant section from the hgbook: it's a great way to collaborate/save incrementally your work without applying the patches.

    Three named branches

    It should be possible to maintain three different named branches, one for each platform, in your MQ repository.

    To switch platform, just switch the active branch.

    (with alias mq='hg -R $(hg root)/.hg/patches')

    First create a windows branch:

    $ mq branch windows
    marked working directory as branch windows
    

    created, but not yet committed.

    Do some stuff, add patches:

    $ hg qnew windowspatch
    ... do some stuff
    

    Refresh, pop and commit:

    $ hg qref
    $ hg qpop -a
    $ mq ci -m 'new windows branch'
    

    You now have the default branch and the new windows branch:

    $ mq branches
    windows                       65:5fd4ef0b96c9
    default                       64:06c1a56a3c08 (inactive)
    

    Now create an Unix branch.

    First switch back to the base default branch:

    $ mq up default
    1 files updated, 0 files merged, 1 files removed, 0 files unresolved
    

    Create a new unix branch and add a unix-specific patch:

    $ mq branch unix
    marked working directory as branch unix
    $ hg qnew unixpatch
    ... blahblah
    $ hg qref
    $ hg qpop -a
    $ mq ci -m 'adding unix branch'
    $ mq branches
    unix                          66:c51bb2c7b413
    windows                       65:5fd4ef0b96c9
    default                       64:06c1a56a3c08 (inactive)
    

    Usage

    Don't forget to qpop -a before operating on the mq repos...

    Push all the windows patches

    $ mq up windows
    xx files updated, yy files merged, zz files removed, ww files unresolved
    $ hg qpush -a
    

    Three physical repos

    Maintaining three separate (mercurial queue) branches can look a bit scary. If so, you can just use three different MQ repositories: one for each platform, each of them versioned in a different place.

    For example :

    $ cd mqs
    $ hg qclone mq-windows windows
    $ hg qclone mq-unix unix
    $ hg qclone mq-mac mac
    

    To work on different platforms, just switch folders (repos). The concept is similar to the first approach. But instead of having three internal branches in one MQ repo, you use three separate MQ repos.

提交回复
热议问题