What's the difference between copying a .hg folder and using clone? [duplicate]
Say I need to create x repositories that can push and pull from a central repository. Is there a practical difference between cloning all those repositories compared to copying the .hg folder x times from the central repository to empty folders?
One difference I can think of is that a copy isn't an atomic operation:
you can't be certain the repo you are copying isn't being modified.
Edit: the hg clone
man page actually mentions:
In some cases, you can clone repositories and the 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 (making sure
REPO
is not modified during the operation is up to you)- and you have to make sure your editor breaks hardlinks (Emacs and most Linux Kernel tools do so).
- Also, this is not compatible with certain extensions that place their metadata under the
.hg
directory, such asmq
.
Another minor difference - if you perform a copy both the original and new repository will have the same parent repository. With a clone the new repository's parent 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
Yes, there is one difference. Clone will attempt to create a hard link if both repository are on the same filesystem. (Unfortunately, this doesn't work on windows)
精彩评论