Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between copying a .hg folder and using clone? [duplicate]

Tags:

mercurial

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?

like image 273
MdaG Avatar asked Dec 16 '22 16:12

MdaG


2 Answers

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 as mq.
like image 167
VonC Avatar answered Mar 02 '23 00:03

VonC


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
like image 27
mtpettyp Avatar answered Mar 02 '23 00:03

mtpettyp