From iDempiere en
(Redirected from Code Scratchpad: Mercurial)

This page contain obsolete information, iDempiere has moved to maven and git


# Ignore all files under bin

# use glob syntax.
syntax: glob


# switch to regexp syntax.
syntax: regexp

Replace file in same location as original

hg cat -r 71 src/org/compiere/model/ -o %p

Save to alternate location

hg cat -r 71 src/org/compiere/model/ -o /tmp/%s
hg cat -r tip src/org/compiere/ReportCustom/ZZ_Quotation.jrxml -o /tmp/%s

Get files as at specific revision

mkdir /tmp/test; hg cat -r 10469 org.adempiere.server-feature/ org.adempiere.server-feature/server.product.eventtest.launch -o /tmp/test/%s

Purge (remove untracked files)

Is there a way to delete all untracked files in a mercurial working area?  Yes, with the purge extension.

Installing Purge

This extension is shipped by default with mercurial but turned off.   To enable it, modify your config file (.hgrc on Unix, Mercurial.ini on  Windows) to add
purge = This activates the plugin.  You can now use
$ hg purge to delete all untracked files.


Mercurial can generate patch files in the unified diff format with the hg diff command.

Follow renames

hg log -f .classpath

Use extdiff to diff 2 revisions

hg extdiff -r tip -r 1000 src/org/compiere/model/

Enable extdiff extension and set Meld as the default diff tool


hgext.extdiff =

cmd.extdiff = meld

Resolving Conflicts

hg resolve -m file.txt

hg resolve -t {editor} file

Default paths

Edit hgrc file (under .hgrc):


default-push = ssh://


hg add / hg addremove (add specific, or add/remove all)

hg init

hg log (-v & --debug) -r : specific revision

hg clone

hg commit -m "A small change - for testing the tagging system"

hg push


Create new branch:

hg branch development

.. commit files ..

hg commit

Switch between branches:

hg update development

hg update default

Merging branches:

hg update development

hg merge default

... merges default into development


hg tags

hg tag -m "Second tag" "V1.01"

Clone the specified tag (exact copy)

hg clone -r "V1.00" TestProject TestProject1

hg clone -r "V1.0.4a_20140217" ssh://user@server://path/to destination

To pull (don't forget to update!)

hg pull

hg update

NB: Always use filesystem snapshots using tar (before doing any critical work) so that you can backout gracefully from bad pulls and bad commits.

Viewing revisions for a file

hg log src/org/compiere/model/ -v | more

Clone using non-default port

hg clone ssh://user@server:22227//path/to


Initial contribution by: nTier Software Services ngordon7000

Add your credit here.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.