📜 ⬆️ ⬇️

Hard links for repository cloning in mercurial

When cloning a repository using the command
hg clone AB 
mercurial first tries to create hard links for files inside the .hg folder in the new repository. This speeds up cloning and saves hard disk space.

Hard links are supported by Linux and Windows NTFS file systems. For file systems that do not support hard links (for example, Windows FAT), as well as when cloning via http / https or ssh from a remote server, mercurial completely copies all files.

In order for mercurial to create an independent repository clone, you can manually specify the --pull parameter:
 hg clone --pull AB 

When committing or sending changes (push) to the repository, mercurial checks the number of hard links for each file in the .hg folder. If there are two or more links, before recording a hard link for this file “breaks” (the XXX file with a hard link is copied into a temporary file, the XXX file is deleted, the temporary file is renamed to XXX).

Cloning on Windows Shares

On computers running Windows, when you receive the number of hard links to files located on shared resources, 1 is always returned, even if in fact there are more.
')
This means that mercurial when committing to a repository located on shared resources can break other repositories whose files are tightly linked to your repository files. Moreover, there will be no error message during a commit, because the repository in which the commit occurred will be intact. You can check the repository with the command
 hg verify 

It says that starting from version 1.6.3 to prevent such situations, mercurial always commits “breaks” hard links when the repository is located on a Windows share.

Now I have version 2.2.1, but when I commit to the repository for a shared resource, other repositories tied to it still break. The problem was solved only after all the repositories were cloned with the --pull parameter.

In this default behavior, there is some magic, due to which you can snip off a certain amount of headaches, which I successfully grabbed. Therefore, I decided to transfer this information here. I hope someone will save her time and nerves.

Original: http://mercurial.selenic.com/wiki/HardlinkedClones
Repair broken repositories: http://mercurial.selenic.com/wiki/RepositoryCorruption

Source: https://habr.com/ru/post/143691/


All Articles