External Repositories as Subrepositories
Mads Kiilerich
mads at kiilerich.com
Wed Nov 10 16:07:21 UTC 2010
On 11/10/2010 10:01 AM, Matthias Goesswein wrote:
> Hello,
>
> I've upgraded from mercurial 1.6.x (i never remind the last version
> number) to mercurial 1.7 on windows, and i've trouble with subrepositories.
>
> I've tried to make two Repositories (MyRepo1 and MyRepo2)
> on the same directory level and use one MyRepo2 as a Subrepo of MyRepo1:
>
> That are the commands:
>
> hg init MyRepo2
> echo Test > MyRepo2/test.txt
> hg add MyRepo2
> hg commit MyRepo2 -m MyCommit
>
> hg init MyRepo1
> echo MyRepo2 = ../MyRepo2 > MyRepo1/.hgsub
> hg add MyRepo1
> hg commit MyRepo1 -m MyCommit
>
> I'll get that:
>
> + MyRepo1
> - .hg
> - .hgsub
> - .hgsubstate
> + MyRepo2 (as Subrepo)
> - .hg
> + MyRepo2
> - .hg
> - test.txt
>
> But if i want to call hg pull within the MyRepo1/MyRepo2 directory, i'll
> get an error message:
>
> cd MyRepo1/MyRepo2
> hg pull
> abort: repository default not found!
>
> So there is no default path for the subrepo set within the hgrc file.
>
> As i remind, within the old version the default path was set for subrepos.
Right. That's a change (regression?) I introduced in ef5eaf53f4f7 while
working on issue1852. I simply didn't consider this case - which however
explains why the old code defaulted to repo.root.
Before the change subrepositories with relative paths would usually get
a default path based on its parents default path, but in the case where
there was no default path it would be based on the local path of the top
repo.
Now we no longer use the local path. Instead we use the path specified
for push/pull (if any).
I'm not sure, but I think my opinion is that the old behavior was
confusing and wrong and that the new behavior in most cases is better.
We could also wrap commit with _subtoppath like I did in 5dbff89cf107,
but I don't think that is a good idea.
(Subrepos with non-trivial relative mappings are IMHO confusing and
should be avoided and deprecated. It do make some sense to have
different layouts on a central repository and on local clones, but I
think that is better solved with the new subpaths. Otherwise we end up
with clone no longer being a transitive operation - and cases like this...)
/Mads
More information about the Mercurial
mailing list