4

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?

MdaG
  • 2,680
  • 2
  • 34
  • 46

3 Answers3

7

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.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
3

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
mtpettyp
  • 5,533
  • 1
  • 33
  • 33
2

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)

gizmo
  • 11,819
  • 6
  • 44
  • 61
  • 1
    Actually, it does work on a recent-enough NTFS filesystem - I think NTFS 5 is required of the top of my head. Definitely works with Win7, pretty sure it works with Vista as well, but don't have it to test. – Tim Delaney Mar 09 '11 at 08:24