views:

60

answers:

1

If I have a rather large Mercurial project locally, and wish to experiment, can I safely just make a local copy of everything and work there?

For instance, let's say I do this:

  1. Clone the repository from a central server to a local directory
  2. Make some changes, commit them locally, do not push
  3. Make a copy of the directory locally
  4. Make some changes in both copies locally, commit, do not push
  5. Push original copy
  6. Push second copy

Will this be safe? Or is there some unique ID's being generated when I clone?

One project is rather large, and the server has a rather slow connection, or so it seems, so it takes ages to do a full clone from the central server.

+4  A: 

Yup, that's perfectly safe.

The only differences I can think of between cloning a repository locally, hg clone a/ b/, and copying the repository, cp -r a/ b/, are:

  • Cloning will use hard links, if possible, so less disk space will be used
  • Repository-specific configuration (eg, a/.hg/hgrc) will not be coppied by hg clone
  • If you clone, the default push/pull path of b/ will be set to a/

So, yea — no problem with simply copying the repo.

David Wolever
Thanks, I was hoping it was but not entirely sure.
Lasse V. Karlsen
That 'hard links' item can be a big deal space wise. If you clone the underlying .hg files are hardlinks so they take up no additional space until changes. In face a 'clone -U' which creates no working copy, takes up no new space at all (give or take). So you might want to do a clone -U and then copy over the modified and uncommited working dir. Then you'll get your workflow plus the space savings.
Ry4an
This is on Windows, so I doubt hard links will be an issue for me :) Sorry for not mentioning that in my question.
Lasse V. Karlsen
hard links are also used on Windows (when available, i.e. on NTFS)
Idan K