What is the difference between copying a .hg folder and using a clone?

Let's say I need to create x repositories that can pop and pull from a central repository. Is there a practical difference between cloning all of these repositories compared to copying the .hg folder x times from the central repository to empty folders?

+4
source share
3 answers

One difference I can think of is that the copy is not an atomic operation:
you cannot be sure that the repo you are copying is not changing.


Edit: hg clone man page actually mentions:

In some cases, you can clone repositories and working directory using full hardlinks with

 $ cp -al REPO REPOCLONE 

This is the fastest way to clone, but it is not always safe.

  • The operation is not atomic (make sure that REPO does not change during the operation, it is up to you)
  • and you need to make sure your editor breaks hard links (Emacs and most Linux kernel tools do this).
  • Also, this is not compatible with some extensions that put their metadata in a .hg directory, such as mq .
+7
source

Another minor difference is that if you run a copy, the source and new repositories will have the same parent repository. With the clone, the new parent of the repository will be the original.

i.e. in the [paths] section of your .hg / hgrc file.

Original repository (/ repo / hg / original)

 [paths] default = /repo/hg/parent 

Copied repository

 [paths] default = /repo/hg/parent 

Cloned repository

 [paths] default = /repo/hg/original 
+3
source

Yes, there is one difference. Clone will try to create a hard link if both repositories are on the same file system. (Unfortunately this does not work on Windows)

+2
source

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


All Articles