Posts in Category: Mercurial

Export Mercurial into Git  

Categories: Git Mercurial

How sad that I have to write this post... proves once more that it's all about the marketing and communication, not so much the product.

Anyway, here how you can import your hg history into git using TortoiseHg

  • TortoiseHg > Global Settings > Extensions > Enable hggit
  • create a new git repo : git init --bare .git OR  git clone --bare https://git.ken.be/my-new-repo
  • cd to your hg repository and you might create a bookmark : hg bookmarks hg
  • hg push c:/path/to/your/new/git/repo
  • cd to your git repo
  • if you used init before: git config --bool core.bare false (when you used bare command before)
  • if you used a bookmark merge hg branch into master
  • push changes to remote repository
  • delete local version and get a normal clone.

And you have a new git repo with all your hg history in it. Awesome.

Or not so awesome: https://www.youtube.com/watch?v=CDeG4S-mJts 

Practical Mercurial - Notes 

Categories: Mercurial

Practical Mercurial by Rob Conery

Mastering mercurial

  • Only merge when you are ready.
  • Git's hostile and unfriendly! GUI Wanker vs l33t snob!
  • Team Foundation Server enforces workflow and needs licenses
  • Subversion needs centralized administrator.


  • Github made git popular
  • Git more powerful but more complex to use
  • You need to tell git to remember an added file
  • More opiniated
  • Allows to alter history more
  • Pluralsight - Git Fundamentals by James Kovacs
  • Git in your browser: http://try.github.com
  • Pro Git Book by Scott Chacon: http://www.git-scm.com/book


  • Http-friendly
  • Visual tools
  • CodePlex
  • Google Code
  • Bitbucket.org
  • Hg is build on top python
  • TortoiseHg
  • VisualHg or Mercurial SCC

Create repository
Settings: merge tool, username (name <email>)
.hgignore (https://gist.github.com/314082)

Connect to remote repo
Sync - Configure - Add (alias)

Webserver select ssl required.

Commit - Open a new named branch
Commit all changes in branch
Select branch you want to merge into (eg. default)
Make sure the current working directory is set to branch you want to merge into
Merge with


syntax: glob

  • Settings - Changelog - Author Coloring
  • Settings - Sync - After pull do update

hgrc are the local repository settings that override your global settings
username = Ken <mail@ken.be>

authorcolor = True
postpull = update

The working directory

  • Use Update to switch between revisions

Fixing mistakes

  • You added a password or connectionstring to the repository
  • Undo last commit
  • There are extensions that allow you to change the history
  • Use revert when not commited

Sharing with google code
Add remote as alias
Allows to add comments inline on the web
Side by side clone (vs github fork)
Naming: author-feature
Push changes to clone
Maintainer needs to pull clone and merge into main repository
All alias for repositories you want to pull from (make sure no update is done in those cases)

Merge conflicts

  • When you edit the conflict in winmerge the tortoisehg will think the merge is done.
  • If not you should click undo after returning from winmerge.
  • Then commit
  • All much faster then reintegrating a branch with subversion.

Working on a team

  • Setup smtp
  • Email patch (or export patch)
  • The patch is not mercurial dependend (hg import)
  • Hg Server (start webserver on port 8000)

Setup on your own iis

  • Download mercurial source + binaries
  • Download python (correct release for mercurial)
  • Install tortoisehg on server (optional)
  • Create directory for mercurial
  • Extract library.zip from source into this folder
  • Copy templates directory into this folder
  • copy hgweb.cgi & hgwebdir.cgi from binaries into this folder
  • Add correct read and execute for these files
  • Create sub directory repositories
  • Add write permissions to repositories directory for the user
  • Add hgweb.config: [paths] projects = \bla\bla\mercurial\repositories\**
  • IIS - Add website
  • Add handler mapping
  • CGI-exe *.exe
  • ISAPI-dll *.dll
  • *.cgi (normally *.py) to python.exe -u %s %s
  • Restrictions - Access - Execute
  • Edit Feature Permissions - Check Execute
  • Default document - hgwebdir.cgi
  • Basic Authentication Enable (disable anonymous)


hg status
hg commit -m "Added another comment"
hg branch
hg branch "Issue13"
hg status
hg commit -m "Fixed 13"
hg update default
hg merge Issue13
hg commit -m "Merged 13"
hgtk log
hg revert --all
hg rollback

Use hg & hgtk as an external tool in visual studio this works easier then visualhg

Check-in notifications

  • Mostly done on the central repository
  • Edit hgrc file
  • Set smtp settings


changegroup.notify = python:hgext.notify.hook

baseurl = http://repo.foo.bar

sources = push
test = False
template = Subject: [webroot|basename]: {desc|strip|firstline}\ndetails: {baseurl}...

config = /notify.config
rob@lala.com = *

* = rob@lala.com


  • will graft the branch onto another, so it is no longer existing.

Add extensions to hgrc

hg help rebase
hg update home_page (goto branch you want to attach)
hg branch (will show the branch you are in)
hg rebase -d default


Mercurial - Notes 

Categories: Mercurial Notes

Mercurial - HG


  • Created by Matt Mackall at same time Git started.
  • DVCS written in Python
  • No partial commits (only atomic commits)
  • Three-way merging

Source control for tracking and sharing
Terms: Source, revision, version controlling
Types: Manual merging, File locking, Version merging
Architecture: Centralized, Distributed (no central server, appointed central server or lieutenants/commander)

Install TortoiseHg
Global settings
Username: firstname lastname <email address> (is mostly used as a convention)
Extensions: graphlog
-> updates the mercurial.ini file in each users root (c:/users/user/mercurial.ini)

hg help
hg init / hg ci (.hg folder is repository for all subfolders)
hg status
hg add
hg add foo.txt
hg commit (will prompt for change message, will commit all folders, emty folders will not be added !)
hg commit -m "your message" / hg ci -m "message"
hg log --limit 5 / hg -l 5 (will show last 5 changes)
hg glog

hg diff
hg revert --all
hg revert foo.txt (will create a copy of your discarded file in same folder with .orig extension)
hg revert foo.txt --no-backup

Ignore files for adding:

  • create .hgignore in root 
syntax: glob

syntax: regexp

You can only undo the most recent commit and when it has not yet been shared with another repository.
hg rollback

hg update 1 (locally: revision number of the changeset)
hg update e99fffee (globally: changeset identifier)

del foo.txt
hg remove foo.txt

Working with a server

md repository
hg init
hg serve (will run http server on localhost:8000)
cd .hg

  • create file hgrc

hg clone http://localhost:8000 hgclientfolder
hg push
hg out (compare local outgoing with server version)
hg incoming (compare local incoming from server)

Pulling changes from server, will update your local repository but not your working copy!
hg pull
hg update

Implicit branches
Created by a commit
Keep time of changes short


  • Can be used if we need to bugfix something quickly and we are in the middle of a development we can not yet check in.
  • Although multiple clones on one machine is not advised.
  • Fork if you want to create a new flavor and do not have the intention to commit back
  • Fork if you want to contribute on open source project, do all your changes and when finished you request a pull request to the main repository.

Named branches

  • we always start in default
  • branch name stored with changeset
  • mostly we create a branch for releases to other environments

hg update -r 6
hg branch
hg branches
hg identify -n
hg branch production (use bookmark feature if you want same branching strategy as git)
hg ci -m "quickfix"
hg update default

hg up branchtobeclosed
hg ci --close-branch -m"no longer needed"
hg up default

hg heads
hg up default (make sure you are in branch you want to merge to)
hg merge production
hg ci -m "merge"

hg parent (show the changeset that's in the working directory)
hg paths (shows a list of known remote repositories)
hg tag version-1.0 (marks the hex number of the changeset)
hg tag -r . Version-1.1
.hgtags sometimes needs merging too :)

VisualHG install on Visual Studio 2012 issue 

Categories: Mercurial Visual Studio

After installation you need a “C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv/setup, this will bring the VisualHG to your Options - SourceControl - Current Source Control in Visual Studio 2012.

More about Devenv Command Line Switches at Microsoft.

Devenv Command Line Switches

Remember TortoiseHg login and password 

Categories: Mercurial
If you do not mind to have the password stored on the computer (otherwise you should use http://mercurial.selenic.com/wiki/KeyringExtension) it is normally enought to put the auth tag into your .hg/hgrc text file. I added the other tags, in case your need authorization on some of the other aspects too.
example.prefix = https://yourdomain.be/yourerpository/
example.username = Userke
example.password = Paswoordje
default = https://yourdomain.be/yourerpository/
user = Userke
passwd = Paswoordje
username = Userke
user = Userke
password = Paswoordje
Page 1 of 2 1 2 > >>