Screenshots: Working with clients for Mercurial

First install Mercurial and TortoiseHg.

1. Initialize Repository

1.1. Command Line

With hg init you create a new repository.

  • Your project folder /project containing your wackowiki folder /wacko and source files is called Working Directory.
  • Mercurial adds subdirectory /project/.hg in your project folder. This new subdirectory is your new Repository, where all version data is kept.

$ cd /project 
$ hg init

1.2. TortoiseHg Workbench

Your new repository will be added to the Registry of your TortoiseHg workbench.

1. Step:
Open TortoiseHg: File > New Repository
TortoiseHg Create New (local) Repository

2. Step:
Provide destination path to your project and create project repository.

Commit Dialog: Toolbars, Repository Registry, graph pane, file list pane with four columns,

2. Add files

2.1. Command Line

Mercurial does not work with files unless you tell it to manage them. To do that use the add command.
With hg add you add tracking of existing files to your new repository.

  • all your files existing in folder: /project/wacko will be introduced to new repository
  • /project/.hg/dirstate will be added
  • the entry in the output of hg status changes from “?” to “A”

$ hg add

2.2. TortoiseHg Workbench

To add files, select them in explorer. To select all files use [Ctrl]+A.
Then right click and select + Add in the context menu.

Commit dialog:

3. Initial Commit

3.1. Command Line

With hg commit you create a new changeset.

  • enter a commit message
  • hg status will have remove added files from output

$ hg commit -m "inital commit to new repository"

3.2. TortoiseHg Workbench

Now you need to check in all files. Use the checkbox up top ( #### filter text #### ) to select all files.
By clicking the commit button in the explorer, you will be asked to enter a commit message.

Commit Dialog:

4. Clone given branch

4.1. Command Line

With hg clone, you easily make an identical (local) copy of a repository.

  • /project/.hg added to project root directory (new or existing)
  • for basic configuration you might want to add and edit /project/.hg/hgrc

$ cd /project (e.g. /home/user/WackoWiki/wacko-dev)
$ hg clone ./WackoWiki/wacko-dev

4.2. TortoiseHg Workbench

TortoiseHg: File > Clone Repository

TortoiseHg clone repository Step 1

2. Step
Source: (latest Development Version of WackoWiki)
Destination: ./WackoWiki/wacko-dev (local WackoWiki project folder)

TortoiseHg clone repository Step 2

You should now have a local project directory ( /home/username/WackoWiki/wacko-dev ).
Further Reading: Mercurial: The Definitive Guide – Working with a repository

TortoiseHg clone repository Step 4

5. Configuration

Create a Mercurial Configuration file

  • /project/.hgrc
  • Configure mercurial?

6. Pull and update

With hg pull you will easily download just the latest code changes.

1. Step:
Check for changes
TortoiseHg pull changes Sync Toolbar Check Changes

TortoiseHg pull changes Step 1

2. Step:
Pull changes
TortoiseHg pull changes Sync Toolbar Pull Changes

TortoiseHg pull changes Step 2

3. Step:
Update local repository
TortoiseHg pull changes Edit Toolbar update local repository

TortoiseHg pull changes Step 3

TortoiseHg pull changes Step 4

7. Committing changes

With hg commit making changes to your local repository is easy.

1. Step
Make your edits.

2. Step
(Re)Open TortoiseHg or refresh current repository. Commit your changes.
TortoiseHg commit to repository

8. Commit and Push

Check repository settings.
TortoiseHg syncronize repositories

Or find and edit your Mercurial.ini on Windows, /.hgrc on Unix, or .hg/hgrc inside a repo. /Org/Tools/Repository/Doc/HowTos#h1474-5?

Use two clones. Work in clone "main", push and merge in clone "sync", and pull back into clone "main".
Shared Repository Model?

  • /project/.hgignore can be used to exclude files from any command on the Working Directory
  • /WackoWiki/project/wacko (/home/user/WackoWiki/wackowiki-dev/wacko)

9. Links

10. ToDo

  • description of Windows Explorer context menu
  • description of configuration file .hgrc
  • description of hg-git plugin