Convert Hg to Git

I have several Bitbucket-hosted Mercurial repos for my binary baseline and some development projects. I started to use Mercurial because the syntax was easier. In the meantime I have been using Git at work and could not remember the Mercurial commands. Time to convert. How?

Thanks to this article, “Converting Mercurial to Git”, it is easy. Kind of. Had to install ActiveState Python, then install the Mercurial package

>pypm install mercurial

Then here are the basic instructions:

$ cd ~/Desktop
$ git clone git://repo.or.cz/fast-export.git
$ git init git_repo
$ cd git_repo
$ ~/Desktop/fast-export/hg-fast-export.sh -r /path/to/old/mercurial_repo
$ git checkout HEAD

Since I use the wonderful msysgit git-bash shell, the script worked, except the `dirname $0` failed for some reason. I just replaced the dynamically generated value with the actual location of the repo.

So mine was

 ~/Desktop/git_repo (master)
$ ~/Desktop/fast-export/hg-fast-export.sh -r /c/bin
ROOT=/c/Documents and Settings/Loaner/Desktop/fast-export
master: Exporting full revision 1/130 with 1/0/0 added/changed/removed files
master: Exporting simple delta revision 2/130 with 7118/0/0 added/changed/removed files
Exported 1000/7118 files
Exported 2000/7118 files
...
master: Exporting simple delta revision 127/130 with 0/1/0 added/changed/removed files
master: Exporting simple delta revision 128/130 with 1/0/0 added/changed/removed files
master: Exporting simple delta revision 129/130 with 3/9/0 added/changed/removed files
master: Exporting thorough delta revision 130/130 with 6/25/1 added/changed/removed files
Issued 130 commands

Everything was on master, so this was an easy test. So far so good. Of course, the EOL issues exist – so on the validation comparison, I set WinMerge to ignore line endings. We’ll see how that works out.

BTW make sure you update the source repo before you convert. I’m just sayin’.

OSX – show environment vars of a running process

jenkins$ ps -wwE -p 38654
 PID TTY TIME CMD
38654 ?? 67:40.42 /usr/bin/java -Dcom.sun.management.jmxremote -Xmx2048m -XX:MaxPermSize=512m -jar /Application
/Jenkins/jenkins.war SHELL=/bin/bash TMPDIR=/var/folders/5f/qnywwqmx3h5fxnwlcssp2sr00000gn/T/ USER=jenkins __CF
_USER_TEXT_ENCODING=0x1F5:0:0 JENKINS_HOME=/Users/Shared/Jenkins/Home PATH=/usr/bin:/bin:/usr/sbin:/sbin PWD=/
CATALINA_OPTS= -Dcom.sun.management.jmxremote SHLVL=0 HOME=/Users/jenkins LOGNAME=jenkins SECURITYSESSIONID=1c2
92 com.apple.java.jvmTask=CommandLine JAVA_ARCH=x

Ahhhhhhh.