8

How can i check out only a sub directory from mercurial repository? It seems i can only check out the whole repository.

Chris Gerken
  • 16,221
  • 6
  • 44
  • 59
Benny
  • 8,547
  • 9
  • 60
  • 93

4 Answers4

8

No, you cannot. See the discussion here:

https://www.mercurial-scm.org/wiki/PartialClone

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
clee
  • 10,943
  • 6
  • 36
  • 28
  • 1
    One day that feature will exist. – Omnifarious Jan 22 '10 at 03:34
  • Hopefully! But considering how hg and git both store the repository history, it's unlikely to happen soon. – clee Jan 22 '10 at 03:37
  • 1
    ACtually, from what I know of how Mercurial does it vs. git, it should be easier to implement in Mercurial. Though all the ways I know of will still result in manifest files that are a lot bigger than they strictly need to be. – Omnifarious Jan 22 '10 at 03:40
2

You can't do it. The feature is planned, but not implemented. The previous person gave a nice link to where you can read a discussion about the partial clone feature.

For now, you should just be really careful to divide things up so a repository is a fairly small unit that makes logical sense to manage in one piece. The existence of the ability to have subrepos might help you organize and manage things until that feature exists.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
Omnifarious
  • 54,333
  • 19
  • 131
  • 194
0

The next best thing is using the Convert extension as discussed here: https://www.mercurial-scm.org/wiki/ConvertExtension

It's also useful to filter Mercurial repositories to get subsets of an existing one. For example to transform a subdirectory subfoo of a repository foo into a repository with its own life (while keeping its full history), do the following:

echo include subfoo > /tmp/myfilemap
echo rename subfoo . >> /tmp/myfilemap
hg convert --filemap /tmp/myfilemap /path/to/repo/foo /tmp/mysubfoo-repo
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
jv42
  • 8,521
  • 5
  • 40
  • 64
0

This is the same question as How do I clone a sub-folder of a repository in Mercurial? so the answers there and here are going to be same. I'll summarize them:

Terminology notwithstanding (the original question was asking about only "check out" which can only happen after cloning in Mercurial but Subversion doesn't really have the concept of cloning) the NarrowHG solution is arguably the closest to what was desired.

Community
  • 1
  • 1
Anon
  • 6,306
  • 2
  • 38
  • 56