Revision 2 of 2026-11-25 20:31 UTC by tux, the current one. Current version - History
Mercurial
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
-Gdraws the revision graph next to the log (the oldgraphlogextension is built in now),-llimits the number of changesets.- A path limits the log to one package;
-ksearches the commit messages;-pshows the diff of each changeset. hg diff -c REVshows what one changeset changed.hg annotatetells, for each line, who changed it last and in which revision: handy to find why a line of a receipt is there.
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
hg revert grep/receiptthrows away your changes to a file;hg revert -ato all files.hg rollbackundoes the last local commit or pull, never a push: the changes stay in your files, ready to commit again.hg status -ulists the files Mercurial does not track (old patches, test files),hg purgedeletes them. It asks for confirmation;hg purge --no-confirmdoes not.
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 =
- rebase:
hg pull --rebasemoves your local, unpushed commits on top of what you pulled, instead of making a merge. The history stays a straight line. - histedit:
hg histeditopens the list of your draft changesets in an editor, to reorder them, fold several into one (fold) or change a message (mess) before you push. - mq: a queue of patches on top of the repository (
hg qnew,hg qrefresh,hg qpop,hg qpush,hg qfinish). It still works, but shelve, rebase and histedit now do most of what it was used for. - schemes: a short name for the SSH address of the repositories, see the Forge page.
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.
Links
- Forge: SSH account, clone, commit, merge and push.
- hg.slitaz.org: all the SliTaz repositories.
- Mercurial wiki: the guides and the extensions.