--- a/mercurial/hg.py Sat Oct 01 14:18:58 2016 +0100
+++ b/mercurial/hg.py Sun Oct 02 22:34:40 2016 -0700
@@ -195,7 +195,7 @@
return ''
return os.path.basename(os.path.normpath(path))
-def share(ui, source, dest=None, update=True, bookmarks=True):
+def share(ui, source, dest=None, update=True, bookmarks=True, defaultpath=None):
'''create a shared repository'''
if not islocal(source):
@@ -240,10 +240,10 @@
destvfs.write('sharedpath', sharedpath)
r = repository(ui, destwvfs.base)
- postshare(srcrepo, r, bookmarks=bookmarks)
+ postshare(srcrepo, r, bookmarks=bookmarks, defaultpath=defaultpath)
_postshareupdate(r, update, checkout=checkout)
-def postshare(sourcerepo, destrepo, bookmarks=True):
+def postshare(sourcerepo, destrepo, bookmarks=True, defaultpath=None):
"""Called after a new shared repo is created.
The new repo only has a requirements file and pointer to the source.
@@ -252,7 +252,7 @@
Extensions can wrap this function and write additional entries to
destrepo/.hg/shared to indicate additional pieces of data to be shared.
"""
- default = sourcerepo.ui.config('paths', 'default')
+ default = defaultpath or sourcerepo.ui.config('paths', 'default')
if default:
fp = destrepo.vfs("hgrc", "w", text=True)
fp.write("[paths]\n")
@@ -374,8 +374,15 @@
clone(ui, peeropts, source, dest=sharepath, pull=True,
rev=rev, update=False, stream=stream)
+ # Resolve the value to put in [paths] section for the source.
+ if islocal(source):
+ defaultpath = os.path.abspath(util.urllocalpath(source))
+ else:
+ defaultpath = source
+
sharerepo = repository(ui, path=sharepath)
- share(ui, sharerepo, dest=dest, update=False, bookmarks=False)
+ share(ui, sharerepo, dest=dest, update=False, bookmarks=False,
+ defaultpath=defaultpath)
# We need to perform a pull against the dest repo to fetch bookmarks
# and other non-store data that isn't shared by default. In the case of