[PATCH] subrepo: look for local pull source first
Mads Kiilerich
mads at kiilerich.com
Fri Mar 25 21:46:45 CDT 2011
Martin Geisler wrote, On 03/25/2011 09:36 AM:
> You ask an awful lot of questions :) -- let me go through them.
I was too lazy to make it short ;-)
>> This will effectively change non-trivial relative paths to trivial
>> paths, right? I'm all for deprecating and discouraging use of
>> non-trivial and absolute paths, but why should we change the semantics
>> of them? Why can't people just start using trivial paths?
> You cannot use trivial 'sub = sub' paths on a service like Bitbucket.
I heard that kiln now supports nested subrepos. Congratulations! That
means that either bitbucket (and googlecode) or their users has to get
moving!
It doesn't make sense that we add complexity to Mercurial 1.9 when the
real solution is that the hosting sites start supporting nested
subrepos. When they do it properly it will (in principle) work with
Mercurial since 1.3.
...
So ... the real problem you are trying to solve is clone (with update)
and subrepos. I agree that that is a case that it could make sense to
optimize. It can already almost be done with a simple "cp -arl", but it
only works on unix and it is a bit tricky to avoid hardlinks in the
working directory.
Why not just focus on cloning the subrepos while cloning, before the
update kicks in? It could be argued that cloning already is a special
case, especially when it is local, and it might thus be justified to use
trivial relative paths no matter what .hgsub says.
A lightly tested ugly proof of concept could be:
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -350,6 +350,13 @@
dest_repo.ui.setconfig('paths', 'default', abspath)
if update:
+ try:
+ for p, (a, b, t) in src_repo[None].substate.items():
+ if t == 'hg':
+ clone(ui, source + '/' + p, dest + '/' + p,
+ update=True)
+ except Exception: pass
+
if update is not True:
checkout = update
if src_repo.local():
test-subrepo.t shows that it kind of works and has consequences.
It might fail if the source repo isn't at the tip revision and thus not
necessarily has the subrepos that tip specifies.
It would perhaps make sense to consider the exact revisions when
cloning, but the real update done a few lines later will correct "all"
mistakes.
/Mads
More information about the Mercurial-devel
mailing list