DVCS PEP

Alexander Solovyov piranha at piranha.org.ua
Sat Jan 24 05:07:59 CST 2009


On 2009-01-24, Alexandre Vassalotti wrote:

> On Fri, Jan 23, 2009 at 4:54 AM, Alexander Solovyov
> <piranha at piranha.org.ua> wrote:
>> Separation of Issue Dependencies:

>> While there are mentioned bzr's shelve and loom, there is no
>> mentioning about hg's shelve, mq and pbranch. I can write command log
>> for each of them, should I do that?

> Yes, please do. Personally, I am not yet satisfied with the example I
> gave for this scenario.  So, I welcome any suggestion to improve it.

That's what I've got now. I myself use mostly shelve or record (depends
on if I have forgotten to shelve changes or not) for simple cases and mq
for complex, but pbranch is rather new here.

============

There are few ways to make a fix changeset while you have spare changes
in your repo, first is by using shelve[1] extension:

hg clone trunk issue0000
cd issue0000
# edit some code: fix1
hg shelve
# edit some code: fix2
hg ci -m "fix2"
hg unshelve
# complete fix1

Another way is to use record extension, bundled with Mercurial. It
allows you to commit only desired changes, selecting them chunk by
chunk:

hg clone trunk issue0000
cd issue0000
# edit some code: fix1
# edit some code: fix2
hg record # commit only fix2
# complete fix1

Also there is approach using mq (Mercurial Queues), a patch management
extension (bundled with hg). It lets you work with a stack of patches in
a Mercurial repository, simplifying various complex scenarios:

hg clone trunk issue0000
cd issue0000
# edit some code: fix1
hg qnew -fm "fix1" # create new patch
hg qpop # pop the current patch from the repository
# edit some code: fix2
hg ci -m "fix2"
hg qpush # apply first patch from the stack to the repository
# edit some code: fix1
hg qrefresh # update the patch
hg qfinish tip # convert patch to a usual changeset

While this scenario requires more actions than previous, it brings more
flexibility, so it is more appropriate for complex cases. For example,
you can create as many patches as you want - by sequential editing of
code and using "hg qnew" or by using "hg qrecord" (if you have record
extension enabled). Additionally you can create a repository from your
patch queues and share it with other developers.

And next approach is by using pbranch[2] extension, which is better
suited for long-term patch development and collaboration. It is somewhat
similar to Bazaar's loom plugin.

hg clone trunk issue0000
cd issue 0000
hg pnew --text "fix1" fix1
# edit some code
hg ci
hg up default
hg pnew --text "fix2" fix2
sed -i 's/fix1: default/fix1: fix2/' .hg/pgraph # make fix1 depend on fix2
# edit some code
hg ci
hg up fix1
hg pmerge # syncronize patch branches
hg pexport # will export your fixes

[1]: http://www.selenic.com/mercurial/wiki/index.cgi/ShelveExtension
[2]: http://arrenbrecht.ch/mercurial/pbranch/

-- 
Alexander


More information about the Mercurial mailing list