The ShareExtension is great for reducing disk usage when several checkouts of the same repository are made: >> hg share Repo WC1 >> hg share Repo WC2 The resulting WC1 and WC2 will typically be a fraction of the size of the Repo, because the .hg/store is only kept once, in Repo. However, for subrepositories, this is not the case and the store folder is copied. So there is no WC1/.hg/store, but there is a WC1/SubRepo/.hg/store. Request: can the sharing also be applied to subrepositories?
Created attachment 1972 [details] Minimal example Added minimal example that shows that the main repository actually shares the storage, but not the subrepositories.
Maybe share can have -S/--subrepo option, which will make the subrepos (at tip) shared as well. This and -U/--noupdate will be mutually exclusive.
(In reply to Yuya Nishihara from comment #2) I'd like this feature too, but I think we should consider the current behavior broken, and skip the -S. Consider: $ hg clone https://... myclone $ hg share myclone myshare $ echo 'edits' > myshare/subrepo/file.txt $ hg -R myshare commit -S -m 'edits' At this point, 'myclone' is broken, because the commit to 'myshare' has a .hgsubstate reference that 'myclone' sees, but that aren't in its subrepos. If you push from 'myshare', it all goes out to the https://... location. The only fix is to push each subrepo individually. I can't imagine anyone relies on this behavior. We go to great lengths to ensure non-broken repos (see issue2314), and I know share + subrepos didn't work at all at some point, so I think this was an oversight. OP: You might want to look at "clone pooling" as an interim workaround. It's on my list of things to look at, so I'm not positive it will work, but see `hg help -e share`.
Fixed by https://mercurial-scm.org/repo/hg/rev/68e0bcb90357 Matt Harbison <matt_harbison@yahoo.com> subrepo: share instead of clone if the parent repo is shared (issue5675) (BC) Previously, only the top level repo was shared, and then any subrepos were cloned on demand. This is problematic because commits to the parent repo would write an updated .hgsubstate to the share source, but the corresponding subrepo commit would be stuck in the local subrepo. That would prevent an update in the source repo. We already go to great lengths to avoid having inconsistent repos (e.g., `hg push -r rev` will push _everything_ in a subrepo, even if it isn't referenced in one of the parent's outgoing commits). Therefore, this seems like a bug fix, and there's no option to get the old behavior. I can't imagine the previous behavior was useful to anybody. There shouldn't be an issue with svn, since it is centralized. Maybe --git-dir can be used for git subrepos, but I'll leave that to someone more familiar with git. An integer was previously being implicitly returned from commands.share(), which caused dispatch() to start crashing when changing over to returning the shared repo. All error paths appear to raise, so this can be hardcoded to success. The clone command checks for 'is None' in a similar pattern, but since hg.clone() always returns a tuple, that seems wrong? .. fix:: Issue 5675 Creating a share of a repository with a Mercurial subrepository will now share the subrepository. and .. bc:: Mercurial subrepositories are now shared instead of cloned when the parent repository is shared. This prevents dangling subrepository references in the share source. Previously shared repositories with cloned subrepositories will continue to function unchanged. (please test the fix)
With the minimal example, hg creates the file "Subrepo/.hg/sharedpath" instead of "Subrepo/.hg/store" directory. For a production repository, sub-repositories are correctly shared with their local source repositories, resulting in a lower disk usage. Note that sharing remote repositories makes no sense and results in a clear errormessage as expected.
Bug was set to TESTING for 7 days, resolving