views:

112

answers:

1

Is copying the .hg directory to another directory the same as cloning in Mercurial (using TortoiseHg although I think that's irrelevant) or does the cloning command in Mercurial do something special during that process?

+8  A: 

It's almost the same. Cloning does a few things different, none of which are required, but some of which are cool:

  • clones get a working directory too (which you can avoid with -U)
  • clones get the source repo set as default for push/pull in the .hg/hgrc file
  • clones can get just a subset of the original (clone -r X gets revision X and all ancestors only)
  • clones use hardlinks when the file system supports it

That last one is pretty cool. It means that if I have a 200GB repo and I do a clone -U src dest I get a full clone that uses no diskspace at all! If I skip the -U I get a working copy that takes up space, and as the two clones start to diverge the new one starts taking up space, but a basic clone -U is instantaneous and disk-space-free on modern file systems. That's not true of a copy (which does work just fine too).

Ry4an
+1 for mentioning the hard link benefits
Sam Post