Menu

Source code under Mercurial

Arjo Segers

Tutorials

For an introduction to Mercurial, some useful tutorials are:

For the impatient, some basics related to the TM5 code are listed below.

Identification

To ensure that the right person is blamed for introducing bug,
identify yourself to Mercurial by including the following lines in a file
named '~/.hgrc' :

[ui]
username = Your Name <your.name@some.where>

Cloning

To obtain a complete copy, use the clone command as shown on the SourceForge site:

hg  clone  ssh://yourname@hg.code.sf.net/p/tm5/code-0  tm5-default

Note the last name is the (new created) destination directory; here we choose to have the branch name "default" in it.

To obtain a specific branch only, use the '-b' option (or '-u' in older versions), and change the destination name if necessary:

hg  clone  -b 'sander'  ssh://yourname@hg.code.sf.net/p/tm5/code-0  tm5-sander

If somebody wants you to clone a specific snapshot and sends you a changeset id (see below), you can clone the corresponding version using the '-r' option:

hg  clone  -r 'a28c13d81cdf'  ssh://yourname@hg.code.sf.net/p/tm5/code-0  tm5-test

Which branch is this ?

Use the 'branch' command to see in which branch you are:

tm5-default>  hg  branch
default

tm5-test>  hg branch
sourish

Which changeset is this ?

A specific snapshot of the code is called a changeset, identified by a cryptic 12-digit hexa-decimal number such as 'a28c13d81cdf' . Use the 'tip' command to see the specific changeset you are using (ignore the number for the double colon), as well as other useful information:

tm5-test>  hg  tipp
changeset:   228:a28c13d81cdf
branch:      sourish
tag:         tip
user:        Sourish Basu <sourish.basu@gmail.com>
date:        Wed Jul 09 14:33:20 2014 +0000
summary:     Modifications to scripts

Current status

To see which files you changed, use:

hg status

To avoid that this also list all kind of temporary files, these can be ignored by creating a file '.hgignore' in the root folder with sample content:

syntax: glob
*.o
*.mod
*.so
*.pyc
*.out
*.err

Any updates available ?

To see which updates are available for your current changeset, use the 'incoming' command;
eventually limit to your current branch if you are not too interested in what other users are doing:

tm5-test> hg incoming -b sourish

changeset:   229:27d597eee7f3
branch:      sourish
user:        Sourish B.
date:        Thu Jul 10 02:59:05 2014 +0000
summary:     Adjoint test coded up

changeset:   230:689c39d01c16
branch:      sourish
user:        Sourish B.
date:        Thu Jul 10 21:28:23 2014 +0000
summary:     rc file for Arjo

...

Branch switching

If you cloned the "default" branch, and you want to switch it to branch "sander", use the following command:

tm5-default>  hg  update  sander
...
tm5-default>  hg  branch
sander

Creating a new branch

Suppose we want to start a new branch "jrc".

First an ounce that from now on all commits should be made to this branch (does not physically exist yet):

tm5-test>  hg  branch  jrc
marked working directory as branch jrc

For convenience, collect all the files present at the start of this branch in a new changeset, by committing everything using a descriptive name:

tm5-test>  hg  commit  -m 'Start of new branch "jrc", created from "sourish" branch.'

(Note that hg might ask you to provide a user name if this is your first commit, just follow the instructions.)

To make this new branch available to the rest of the community, push it to the repository under notice that a new branch should be created:

tm5-test>  hg  push  --new-branch

Related

Wiki: Home
Wiki: Obtain source code

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.