Appendix 1: The Mercurial version control system¶
Soon after you start writing your first code, you will face the problem of keeping track of all the versions of the file you create. In the beginning, this will probably not be a major issue. For example, every time you want to reuse some old file you could make a copy with a new name. However, this does not work well in the long run. You soon end up with files name myfile.py, myfile_new.py, myfile_new_new.py, myfile_test.py, and so on. Does this sounds familiar? In worst case, you forget to make a copy of the old version, and some of your old code sounds! If this sounds familiar, you are not alone. This is a major problem of almost all most researchers.
Keeping track of your code is an important issue. Coding needs a lot of effort and patience, and loosing one of your scripts can easily cost you several days of work. Equally importantly, your code is the best documentation of all your processing steps. If you lose some of your old code, or if you make changes that you don’t keep track, you will not be able to reproduce your research results in case a colleague, or reviewer, asks. Luckily, there are several established systems, called version control systems, that will help you to keep track of your ever-evolving code. In this section, we will briefly introduce one of the most popular such system call Mercurial.
Note
In this section we will focus on the Mercurial version control system, but this is by no means your only choice. Git, for example, is a very popular and powerful version control system used by many open source projects.
You can find more information about git, in the following links:
- https://git-scm.com/
- All the information you need about git.
- https://github.com/
- A web-based Git repository hosting service.
- https://try.github.io/levels/1/challenges/6
- A hands-on course on git.
- https://www.codecademy.com/learn/learn-git
- Another hands-on course.
Mercurial overview¶
Mercurial, often abbreviated as hg, is a software tool that can help you manage the version of your code, and also collaborate with others. Mercurial can be used from the command line, but there are several graphical user interfaces that can get you started. One excellent choice for beginners is EasyHg <http://easyhg.org/>_, that is designed to be easy to use and understand.
[TBD]
Setting up a repository¶
Committing some changes¶
Update to the previous version¶
Working with a remote repository¶
See also
- Hg init
- An introduction to Mercurial.
- EasyHg start video
- A short video showing you how to put your files in a repository using EasyHg.
- Version control intro video
- A simple introduction to version control systems. Not for Mercurial, but highlight the main concepts.