Default path in subrepos
Mads Kiilerich
mads at kiilerich.com
Thu Nov 18 22:21:30 UTC 2010
Georg Zetzsche wrote, On 11/18/2010 04:56 PM:
> Hi everyone,
>
> when creating a new subrepo by means of pull -u<src>, Mercurial
> sets the default path of the new subrepo to the address of
> the source (sub)repo. However, it seems that if<src> is a
> path expression relative to the parent repo, then the default
> path of the new subrepo is also made relative to the parent repo
> when it should be relative to the subrepo. Here's an example:
>
> ---------------------------------------------------------------
> vcstest at ultra20:~$ hg init repo
> vcstest at ultra20:~$ cd repo/
> vcstest at ultra20:~/repo$ hg init sub
> vcstest at ultra20:~/repo$ echo sub = sub> .hgsub
> vcstest at ultra20:~/repo$ hg add .hgsub
> vcstest at ultra20:~/repo$ hg ci -m "new subrepo"
> vcstest at ultra20:~/repo$ echo hello> sub/a
> vcstest at ultra20:~/repo$ cd sub/
> vcstest at ultra20:~/repo/sub$ hg add a
> vcstest at ultra20:~/repo/sub$ cd ..
> vcstest at ultra20:~/repo$ hg ci -m change
> vcstest at ultra20:~/repo$ cd ..
> vcstest at ultra20:~$ hg init repo2
> vcstest at ultra20:~$ cd repo2/
> vcstest at ultra20:~/repo2$ hg pull -u ../repo
> vcstest at ultra20:~/repo2$ cat sub/.hg/hgrc
> [paths]
> default = ../repo/sub
> ---------------------------------------------------------------
>
> I expected this to be ../../repo/sub, and indeed an "hg pull" vom
> within ~/repo2/sub fails.
I think you are right, and I think this the right way to fix it:
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -325,6 +325,8 @@
def addpathconfig(key, value):
if value:
+ if not os.path.isabs(value):
+ value = os.path.relpath(os.path.abspath(value),
root)
fp.write('%s = %s\n' % (key, value))
self._repo.ui.setconfig('paths', key, value)
Comments?
/Mads
More information about the Mercurial
mailing list