Mercurial > public > mercurial-scm > hg
comparison mercurial/subrepo.py @ 34815:68e0bcb90357
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.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 15 Oct 2017 22:48:02 -0400 |
parents | 75979c8d4572 |
children | 7d51a7792f52 |
comparison
equal
deleted
inserted
replaced
34814:2d49d2eb1ff2 | 34815:68e0bcb90357 |
---|---|
855 self.ui.note(_('removing subrepo %s\n') % subrelpath(self)) | 855 self.ui.note(_('removing subrepo %s\n') % subrelpath(self)) |
856 hg.clean(self._repo, node.nullid, False) | 856 hg.clean(self._repo, node.nullid, False) |
857 | 857 |
858 def _get(self, state): | 858 def _get(self, state): |
859 source, revision, kind = state | 859 source, revision, kind = state |
860 parentrepo = self._repo._subparent | |
861 | |
860 if revision in self._repo.unfiltered(): | 862 if revision in self._repo.unfiltered(): |
861 return True | 863 # Allow shared subrepos tracked at null to setup the sharedpath |
864 if len(self._repo) != 0 or not parentrepo.shared(): | |
865 return True | |
862 self._repo._subsource = source | 866 self._repo._subsource = source |
863 srcurl = _abssource(self._repo) | 867 srcurl = _abssource(self._repo) |
864 other = hg.peer(self._repo, {}, srcurl) | 868 other = hg.peer(self._repo, {}, srcurl) |
865 if len(self._repo) == 0: | 869 if len(self._repo) == 0: |
866 self.ui.status(_('cloning subrepo %s from %s\n') | |
867 % (subrelpath(self), srcurl)) | |
868 parentrepo = self._repo._subparent | |
869 # use self._repo.vfs instead of self.wvfs to remove .hg only | 870 # use self._repo.vfs instead of self.wvfs to remove .hg only |
870 self._repo.vfs.rmtree() | 871 self._repo.vfs.rmtree() |
871 other, cloned = hg.clone(self._repo._subparent.baseui, {}, | 872 if parentrepo.shared(): |
872 other, self._repo.root, | 873 self.ui.status(_('sharing subrepo %s from %s\n') |
873 update=False) | 874 % (subrelpath(self), srcurl)) |
874 self._repo = cloned.local() | 875 shared = hg.share(self._repo._subparent.baseui, |
876 other, self._repo.root, | |
877 update=False, bookmarks=False) | |
878 self._repo = shared.local() | |
879 else: | |
880 self.ui.status(_('cloning subrepo %s from %s\n') | |
881 % (subrelpath(self), srcurl)) | |
882 other, cloned = hg.clone(self._repo._subparent.baseui, {}, | |
883 other, self._repo.root, | |
884 update=False) | |
885 self._repo = cloned.local() | |
875 self._initrepo(parentrepo, source, create=True) | 886 self._initrepo(parentrepo, source, create=True) |
876 self._cachestorehash(srcurl) | 887 self._cachestorehash(srcurl) |
877 else: | 888 else: |
878 self.ui.status(_('pulling subrepo %s from %s\n') | 889 self.ui.status(_('pulling subrepo %s from %s\n') |
879 % (subrelpath(self), srcurl)) | 890 % (subrelpath(self), srcurl)) |