views:

117

answers:

2

So, I'm trying to checkout just the TestNG plugin from the Netbeans contrib repository. (Or is it module? I'm new to Mercurial, so I don't really know the lingo yet.)

When I run the following command...

hg clone http://hg.netbeans.org/main/contrib/

...I get the entire repository, which contains all of the the contrib plug-ins. Is it possible to just pull this location?

http://hg.netbeans.org/main/contrib/file/tip/testng/

Thanks!

A: 

I'm not sure, but I think the answer in the general case is "probably not".

If the repository is local (it doesn't sound like it is in your case), you can do something like:

hg archive -R /path/to/my/repo -I /path/to/my/repo/folder/i/want export-folder-name

(The command would need to be something that exports non-VC'd files, rather than creating a partial repo, since the .hg stuff is stored once at the toplevel, rather than in pieces in each folder as SVN does.)

It doesn't work on remote repositories, though. Neither does "hg log", and the hg folks explained why:

Imagine I send a log -p command to http://www.kernel.org/hg/linux-2.6, which is approaching 100k changesets. At one diff per second (lots of seeking), this will take about 3 hours of CPU/disk time on the server, nevermind metric tons of bandwidth. It would be faster and simpler for everyone just to clone the repo and do the log locally.

I suspect hg archive can't work remotely for the same reason.

Ken
It takes a bit over 10 minutes to clone the contrib repository over my connection, and I don't care about anything inside of it except for the TestNG plugin. It's not a big deal since it's a one time thing, but I was just curious about whether or not it was possible to pull the metadata for the entire repo in one step, and pull the actual files for a portion of the repository in another step. I think the answer is no.
braveterry
Interestingly, GIT appears to have the same limitation. I imagine that designing a DVCS designed for efficiency in the common case (i.e., storing changesets instead of files) makes this hard.
Ken
+3  A: 

This concept is called "narrow cloning" and no, it's not possible at the moment in Mercurial.

It's on the radar of some of us that contribute to Mercurial but it's a hard problem to solve. For example:

  • How do you calculate the hash of any new commits you make if you don't have all of the files in the repo?
  • What happens if you try to view the history of a file in contrib/testng if that file was moved from another folder?
Steve Losh