Cannot update to old revisions after converting a folder into a subrepo
Martin Geisler
mg at aragost.com
Mon May 23 06:53:11 UTC 2011
Didly <didlybom at gmail.com> writes:
> We have recently discovered that after converting a folder into a
> subrepo (with the same name) you are no longer able to update back to
> a revision before the subrepo was created (or at least it is not
> easy).
This is caveat nr 3 here:
http://mercurial.selenic.com/wiki/Subrepository#Caveats
While this problem has been known for a long time, it has not bothered
any of us core developers enough to make us come up with and implement a
solution.
> I believe that this is quite an easy problem to hit. The only reason
> we had not faced it ourselves so far is that when we converted some
> folders to subrepos we took the chance to reorganize our code,
> renaming some of the folders that were later converted into subrepos.
>
> From a regular (not too savvy) user point of view, this leaves the
> repo on a "broken" state, since it is no longer possible to access
> some repo revisions using just hg commands.
>
> I think that a (possibly silly) solution to this problem would be that
> mercurial "stored" a "copy" of the subrepo in its ".hg" folder (as it
> does for any regular file). It could do so when updating to a version
> of the repo that did not include the subrepo. Then, it would be safe
> for mercurial to delete the subrepo upon update, making this issue go
> away.
Instead of a copy, I think Mercurial could move the subrepo to a place
inside the .hg folder when you do an update to a revision without the
subrepo. Moving is much faster than copying and would keep state such as
the .hg/hgrc file in the subrepo and maybe even the working copy.
When you update back to a revision where the subrepo is needed, then
Mercurial should first look in its "subrepo cache" to see if there is a
matching subrepo, move it back in place and do any further pulls needed
to bring the subrepo up to the revision the .hgsubstate file asks for.
This is somewhat magical and would kind of turn the .hgsub file into a
file with hints for where to get a subrepo. It reminds me a little of
how I recently tried to make 'hg clone a b' use a/sub as a source of
changesets when creating b/sub -- since the changesets for sub were
already there on disk and so didn't need to be downloaded again.
--
Martin Geisler
aragost Trifork
Professional Mercurial support
http://mercurial.aragost.com/kick-start/
More information about the Mercurial
mailing list