简体   繁体   中英

Is it possible to checkout a single directory from a Mercurial (HG) repository?

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!

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM