cloning subrepos doesnt set default in hgrc

Saint Germain saintger at gmail.com
Fri Feb 5 22:00:58 UTC 2010



On Fri, 5 Feb 2010 20:46:28 +0000 (UTC), Johannes Totz
<jtotz at imperial.ac.uk> wrote :

> Johannes Totz wrote:
> 
> > Matt Mackall wrote:
> >
> >> On Thu, 2009-12-10 at 20:37 +0000, Johannes Totz wrote:
> >>> Hi!
> >>> 
> >>> Cloning a repo that has subrepos does not set the default path
> >>> inside the subrepo's hgrc.
> >>> It would be nice if it did though! E.g. set its value to what is
> >>> specified in .hgsub as its URL.
> >>> 
> >>> Is there any reason why this might be a bad idea?
> >>
> >> Nope. Try this:
> >>
> >> diff -r 359c56728257 mercurial/subrepo.py
> >> --- a/mercurial/subrepo.py	Thu Dec 10 17:01:21 2009 -0600
> >> +++ b/mercurial/subrepo.py	Thu Dec 10 19:48:39 2009 -0600
> >> @@ -175,6 +175,9 @@
> >>          else:
> >>              util.makedirs(root)
> >>              self._repo = hg.repository(r.ui, root, create=True)
> >> +            f = file(os.path.join(root, '.hg', 'hgrc'), 'w')
> >> +            f.write('[paths]\ndefault = %s\n' % state[0])
> >> +            f.close()
> >>          self._repo._subparent = r
> >>          self._repo._subsource = state[0]
> >
> > Thanks! I'll give it a try soon (I have the all-binary TortoiseHG
> > installation only, at the moment).
> 
> I still haven't got around to actually test that patch. But I believe
> it went into 1.4.2?
> 
> That particular feature of 1.4.2 doesn't work for me though. A
> default-path entry is added in the subrepo's hgrc but it's empty. I've
> tried various combinations of relative and absolute paths in .hgsub
> but that didn't change anything...
> 

Funny, I've struggled with this today...
Here are the lines which works for me:

        util.makedirs(root)
        self._repo = hg.repository(r.ui, root, create=True)
        f = file(os.path.join(root, '.hg', 'hgrc'), 'w')
        f.write('[paths]\ndefault = %s\n' %
                os.path.join(_abssource(ctx._repo),path))
        f.close()

However instead of putting the default path to the URL present
in master repository .hgsub, it seems for me more logic to put the path
to the subrepos of the master directory from which it has been cloned.

I'll try to test more this week end.

Regards,



More information about the Mercurial mailing list