Mercurial is a bit tricky to get used to, especially when multiple developers are working in parallel.
It is recommended that developers commit often. Because each developers has its own repository, this means that multiple heads are created at the "same time". When pulling changes, these multiple heads are pulled into the local repository. For example, in this picture, a developer has committed local changes (L1, and L2) and pulled remote changes (R1, and R2).
The typical workflow is to:
- Pull changes
- Merge changes (effortless since most changes do not conflict)
- Commit the merge
- Proceed with a push or more work...
This is quite tedious. There is thus the possibility to merge the multiple heads into a linear stream when pulling the changes. This process is called rebase. For example, if instead of just pulling the changes, the developer had pulled and rebased the changes, the local history would now look like:
The workflow is now:
- Pull changes and select the rebase checkbox in hgeclipse
- Done! Proceed with push or more work...
The images were taken from this wonderful wiki page on rebase.
- Always commit before pulling and rebasing or updating. Mercurial will force you to do this anyway because it is always better to commit changes and be able to revert if a problem happens while merging/rebasing/updating.
- For some reasons, you sometimes need to manually refresh the projects after a rebase.
Corrupted Files (or how to recover from a crash)
If at some point your computer crashes in the middle of a push, it is possible that the local mercurial files become corrupted. Do not worry: all the files on the bitbucket server are safe (push are atomic) and provided that your source file did not get corrupted by a hard disk error, you did not lose anything except the incremental commits. Evidence of commits are error messages like: there is not .hg directory, there is no revlog for file X.
To recover from such situation, follow these steps:
- In a temporary folder, clone the current Qualyzer main repository.
- Close Eclipse.
- In the Eclipse workspace, delete the .hg directory of the main repository (usually located in workspace/main/.hg).
- Copy the .hg directory from the cloned repository
- Restart Eclipse.
- Commit the changes (hg will automatically determine which files are different from the current version of the repository).