SliTaz GNU/Linux official and community documentation wiki.
.png
Translations of this page:

This is an old revision of the document!


Advanced usage of Mercurial

Use an external tool to merge

If you want to use tools presented on this page, particulary MQ, had a tool to manage merges (when several commits overwhrite each other and you have to edit the result manually) will probably usefull to you. SliTaz propose Meld, a light software which do that well. After installation, tell to Mercurial to use it if necessary by putting in ~/.hgrc :

[ui]
merge = meld

Usefull extensions

To add an extension, you can use the ~/.hgrc file; Syntax is:

[extensions]
name = adress

Some extensions are packed with Mercurial, so it's not necessary to give them adresse. It's the case of the four following:

color Add color in Mercurial. Usefull when displaying difference between several versions of a file.

hgext.fetch Add the command hg fetch, which regroup hg pull && hg merge && hg update.

hgext.graphlog Add the command glog, which display the revision tree along the log. It's advised to limit the lenght of the log with option -l (i.e.: -l 10). Option -p display the detail of differences introducted at each commit.

mq This tool his explained in details bellow. It allow to manage a patch-list for a Mercurial repository: apply them, unapply, update, etc. This extension add several commands, which generally start by 'q'. Some webpages details this tool, search: mercurial mq.

Base functionnalities of MQ

In a mercurial repository, create a patch repository with controled revision; It's a repository of patch into which the changes can be commited using Mercurial, like a repository in a repository:

hg qinit -c

Après avoir procédé à des modifications, les enregistrer en temps que patch plutôt que les commiter : After modifications, save them as a patch instead of commit them:

hg qnew nom_du_patch

List applied/unapplied patches:

hg qseries -v

Add changes to the current patch (the last one applied):

hg qrefresh

Apply the next patch from the queue:

hg qpush

Apply all patches:

hg qpush -a

Unapply current patch:

hg qpop

Unapply all patches:

hg qpop -a

Goto a given patch in the queue:

hg qgoto patch

Add a message to the current patch (before commit it):

hg qrefresh -m "Message"

Transform a patch into commit:

hg qfinish patch

Commit changes made in the patch repository:

hg qcommit -m "Message de commit"

Note: Patches are saved into .hg/patches. The file .hg/patches/series can be manually edited to change the application order of the patches; but take care if several patches having the same target file: it can create problems.

MQ & Merge

General idea

Patches can be updated using the merge tool of Mercurial: it's easier than edit them manually. To do this, it's necessary to have two heads in the repository. One being the repository with patches applied ontop; the other the repository with th new commits/update/etc:

o New repository revision
|
|
| o Patches
| |
| /
|
o Repository before patch application

The patches branch will next be merged into the new branch, and MQ will use the merge function from Mercurial to update the patches. Please note that using an external merge tool (as meld proposed previously) is highly recommended.

Create the head patches :

qpush -a
hg tags  # Remember/Note the number of the revision qparent
qsave -e -c # Save the status of the patches, this save will be used during the merge. (Remember/Note the number at the end of patches.N; it's generally 1)

Create the new head:

hg update -C <N°qparent> # Goto the revision noted before.

# Next, do what you planned to:
# Update:
hg pull -u
# Commiter new changes, make the modifications then:
hg commit -m "message"
# Edit a patch:
hg qgoto patch # Then do the modifications and:
hg qrefresh

To launch the merge:

hg qpush -a -m

Clean the repository:

hg qpop -a
hg qpop -a -n patches.N
rm -r .hg/patches.N

Save the changes made into the patch repository:

hg qcommit -m "Updated to match rev???"

Re-apply the patch queue:

hg qpush -a
 
en/cookbook/advancedhg.1295469563.txt.gz · Last modified: 2011/01/19 21:39 by gokhlayeh