Mercurial SliTaz 5.1

The wok, the SliTaz tools and the web sites live in Mercurial (hg) repositories on hg.slitaz.org. Cloning, committing, merging and pushing over SSH are explained on the Forge page of the site. This page goes further: reading the history, undoing, putting work aside, sending a patch without write access, and a few extensions. SliTaz 5.1 ships Mercurial 6.1.1; as root:

# spk-add mercurial

Run hg as your user, never as root. The examples use the wok.

Read the history

$ hg log -G -l 10
$ hg log -l 5 grep
$ hg log -k 'grep:'
$ hg log -p -l 1 grep
$ hg diff -c 29288
$ hg annotate -u -n grep/receipt

Colors and the pager are built in too: no extension to add for them.

Before you push

$ hg pull -u
$ hg outgoing
$ hg log -r 'draft()'

hg outgoing lists the changesets a push would send. Mercurial marks each changeset with a phase: draft until it is pushed, public after. Commands that rewrite history (rebase, histedit, strip) only touch draft changesets: what is public is shared, and stays as it is.

Undo

Put work aside: shelve

You are in the middle of a change and must fix something else first:

$ hg shelve
$ hg shelve --list
$ hg unshelve

hg shelve saves your uncommitted changes and gives you a clean working copy; hg unshelve brings them back.

Send a patch without write access

Commit locally, then export the changeset:

$ hg commit -m "grep: fix the lang split"
$ hg export tip > grep-lang.patch

The file holds your name, the message and the diff: post it on the forum or send it by mail. A developer applies it with its author and message:

$ hg import grep-lang.patch

hg import --no-commit applies it to the working copy only, to test it first.

Conflicts

When a merge or an unshelve touches the same lines as you, Mercurial asks what to do. To get both versions and their common ancestor written into the file, add to ~/.hgrc:

[ui]
merge = :merge3

Edit the file, keep the right lines, remove the <<<<<<<, |||||||, ======= and >>>>>>> markers, then:

$ hg resolve -l
$ hg resolve -m grep/receipt
$ hg commit -m "Merge"

hg resolve -l lists the files, U for unresolved and R for resolved. After a conflict in hg unshelve, finish with hg unshelve --continue instead of a commit. A graphical tool such as meld (package meld) can be set the same way: merge = meld.

Extensions

Extensions are turned on in ~/.hgrc. Those below ship with Mercurial: an empty value is enough.

[extensions]
rebase =
histedit =

fetch, once used to pull, merge and update in one command, is deprecated: use hg pull -u, or hg pull --rebase. hg help extensions lists all the extensions of your Mercurial.