Child Pages

Converting Mercurial Repos To Git

Overview

Version control systems are designed for organising and retaining file information in a environment where the ‘watched’ files are constantly changing. They are used exetnsively in programming, project file management and general file management.

The primary functions of a SCM are:

  • Retaining all versions of a watched file
  • Ease of use (this is a big one!)
  • The capability of retaining only the changed data, as to make the amount of space an SCM uses up is kept to a minimum (you can imagine how big the SCM would get if it saved a new copy of a file every time you modified it slightly).
  • Multi-user capability, this has it’s own sub-functions
    - A checkout system for files
    - The ability to merge indvidual changes on one file together

Some of the best SCM’s are:

  • Mercurial – My favourite SCM! Mercurial is a SCM whoes main disguishing feature between it and SVN is that it handles entire projects rather than indivual files. Hence it only creates one folder in the root directory of your project (SVN creates one in every folder). TortoiseHG is an alsome Windows shell extension for Mercurial. I never get errors and irreversable lockouts with Mercurial as I did with SVN.
  • SVN – A very popular version control system that is well integrated into a fair amount of third party software. Manages on a file to file basis, which give the main benefit of a user being able to checkout a section of a project, work on it, and commit it back to the main repository. An annoying problem of SVN is the errors I keep getting. I am not sure if I use it right, but somewhere along the line of using  svn for project (be it a day, or a few weeks later), a clash arises from trying to merge to files together or accidently renaming a folder. This normally locks the directory and I can never get the clean up function to work properly, resulting in svn becoming useless. This is why I prefer Mercurial.

Mercurial

Mercurial will not copy folders into the repo if there are no files in them. Why would you have empty foler you ask? Well, one reason would be if you had a template folder structure for new projects that you wanted in the repo.

Mercurial Ignore Files

Ignore files are handy for excluding unwanted files from any mercurial repository, such as the ‘millions’ of junk files created by programming and design software. Below are ignore files I have made for certain software packages.

The ignore file has to be called .hgignore and be placed in the root folder location of the repo. It is versioned just like any other file in the repository, but is a special file that Mercurial parses to determine which files to ignore from the repo, using string matching with either the regexp (greater power, flexibility, but harder to understand), or glob syntax (less power, but easy to understand, syntax much like Windows path formats).

Regexp Syntax:

Glob Syntax (no longer maintained):

 Mercurial/Tortoise HG Error Messages

  • “Unknown Parent” – Occurs when trying to pull changesets from another repository. Normally means some part of your repo is corrupted. The only solution I have found is to delete your repo and clone a working one, after copying all the files you want to save of course…
  • “The system cannot find the file specified” error message occuring when you attempt to commit your repo. This is normally due to one of two reasons. The first one is if you deleted a file between clicking the ‘Refresh files’ button and clicking ‘Commit’. The second reason is if the absolute path name of the file exceeds 255 characters. Tortoise HG will recognise the file and display it, but will fail when trying to commit. There is an extension called ‘Win32LongFileNamesExtension’ (aka win32lfn) that is meant to fix this, but I have not be able to get it to work.
  •  ”abandoned transaction found – run hg recover” – This normally occurs if the connection between the local and remote repo is disconnected mid-way through a push/pull operation.
    mercurial-error-msg-abandoned-transaction-found

How To Make A Mercurial Repo Remember A Local Server Location To Push To

You need to add the path of the server to the hgrc file in the Mercurial .hg folder that it creates at the root location of your repo. It can also be done through the UI.

The syntax follows:

For example: