Mercurial

From iDempiere en
(Redirected from Code Scratchpad: Mercurial)

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

.hgignore

# Ignore all files under bin
bin

# use glob syntax.
syntax: glob

*.class

# switch to regexp syntax.
syntax: regexp

Replace file in same location as original

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

Save to alternate location

hg cat -r 71 src/org/compiere/model/I_AD_Client.java -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/buckminster_linux_gtk_x86_64.properties 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
[extensions] 
purge = This activates the plugin.  You can now use
$ hg purge to delete all untracked files.

Patches

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/MShippingInstr.java

Enable extdiff extension and set Meld as the default diff tool

.hgrc:

[extensions]
hgext.extdiff =

[extdiff]
cmd.extdiff = meld

Resolving Conflicts

hg resolve -m file.txt

hg resolve -t {editor} file

Default paths

Edit hgrc file (under .hgrc):

[paths]
default=ssh://user@server://path/to

[paths]
default-push = ssh://hg@example.com/path

Basics

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

Branches

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

Tagging

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/MShippingInstr.java -v | more

Clone using non-default port

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

Credits

Initial contribution by: nTier Software Services http://www.ntier.co.za ngordon7000

Add your credit here.

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