views:

620

answers:

3

I am not an experimented user of SCM tools, even though I am convinced of their usefulness, of course. I used some obscure commercial tool in a former job, Perforce in the current one, and played a bit with TortoiseSVN for my little personal projects, but I disliked having lot of .svn folders all over the place, making searches, backups and such more difficult. Then I discovered the interest of distributed SCM and I chose to go the apparently simpler (than git) Mercurial way, still for my personal, individual needs. I am in the process of learning to use it properly, having read part of the wiki and being in the middle of the excellent PDF book.

I see often repeated, for example in Mercurial working practices, "don't hesitate to use multiple trees locally. Mercurial makes this fast and light-weight." and "for each feature you work on, create a new tree.". These are interesting and sensible advices, but they hurt a bit my little habits with centralized SCM, where we have a "holy" central repository where branches are carefully planned (and handled by administrators), changelists must be checked by (senior) peers and must not break the builds, etc. :-) Starting to work on a new branch takes quite some time...

So I have two questions in the light of above:

  • How practical is it to do lot of clones, in the context of IDEs and such? What if the project has configuration/settings files, makefiles or Ant scripts or shell scripts or whatever, needing path updates? (yes, probably a bad idea...) For example, in Eclipse, if I want to compile and run a clone, I have to do yet another project, tweaking the Java build path, the Run/Debug targets, and so on. Unless an Eclipse plugin ease that task. Do I miss some facility here?

  • How do that scale? I have read Hg is OK for large code bases, but I am perplex. At my job, we have a Java application (well, several around a big common kernel) of some 2 millions of lines, weighting some 110MB for code alone. Doing a clean compile on my old (2004) Windows workstation takes some 15 minutes to generate the 50MB of class files! I don't see myself cloning the whole project to change 3 files. So what are the practices here?

I haven't yet seen these questions addressed in my readings, so I hope this will make a useful thread.

+1  A: 

Question 1:

PIDA IDE has pretty good Mercurial integration. We also use Mercurial for development itself. Personally I have about 15 concurrent clones going of some projects, and the IDE copes fine. We don't have the trouble of tweaking build scripts etc, we can "clone and go".

It is so easy that in many cases I will clone to the bug number like:

hg clone http://pida.co.uk/hg pida-345

For bug #345, and I am ready to fix.

If you are having to tweak build scripts depending on the actual checkout directory of your application, I might consider that your build scripts should be using some kind of project-relative path, rather than hard-coded paths.

Ali A
Thanks for the interesting comment, I already visited the site, it seems, I should try it.Now, my question was generic: how well this scheme integrates with existing projects/IDEs? I agree with the need for relative paths, of course, but some IDEs might not comply.
PhiLho
+2  A: 

PhiLo: I'm new at this, but mercurial also has "internal branches" that you can use within a single repository instead of cloning it.

Instead of

hg clone toto toto-bug-434

you can do

cd toto
hg branch bug-434
hg update bug-434
...
hg commit
hg update default

to create a branch and switch back and forth. Your built files not under rev control won't go away when you switch branches, some of them will just go out of date as the underlying sources are modified. Your IDE will rebuild what's needed and no more. It works much like CVS or subversion.

You should still have clean 'incoming' and 'outgoing' repositories in addition to your 'work' repository. Just that your 'work' can serve multiple purposes.

That said, you should clone your work repo before attempting anything intricate. If anything goes wrong you can throw the clone away and start over.

problem is that you cannot remove such branch
rkj
you can remove a branch with the mq extention and strip command wich delete a revision and all the subsequence revisions. Its very good if you are not longer interested in the branch, and it leads to an innecesary head.
damian
you can also close a branch
Mike Caron
+2  A: 

You raise some good points!

  • How practical is it to do lot of clones, in the context of IDEs and such?

You're right that it can be difficult to manage many clones when IDEs and other tools depend on absolute paths. Part of it can be solved by always using relative paths in your configuration files -- making sure that a source checkout can compile from any location is a good goal in itself, no matter what revision control system you use :-)

But when you cannot or dont want to bother with several clones, then please note that a single clone can cope with multiple branches. The "hgbook" emphasizes many clones since this is a conceptually simple and very safe way of working. When you get more experience you'll see that you can use multiple heads in a single repository (perhaps with the bookmarks extension) to do the same.

  • How do that scale?

Cloning a 110 MB repository should be quite fast: it depends on how long it takes to write 110 MB to your disk. In a recent message to the Mercurial mailinglist it was reported that cloning 6.3 GB took 4 minutes -- scaling that down to 110 MB gives about 4 seconds. That should be fast enough that your tea is still warm :-) Part of the trick is that the history data are simply hard-linked (yes, also on Windows) and so it is only a matter of writing out the files in the working copy.

Martin Geisler