comparison mercurial/hg.py @ 36159:0fe7e39dc683

hg: move share._getsrcrepo into core The fact we were calling this from extensions was a sign that it should live in core. We were also able to remove some extra attribute aliases from the share extension. Differential Revision: https://phab.mercurial-scm.org/D2200
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 12 Feb 2018 16:15:34 -0800
parents 488e313954ea
children f659a407e5ee
comparison
equal deleted inserted replaced
36158:802742769680 36159:0fe7e39dc683
199 ''' 199 '''
200 path = util.url(source).path 200 path = util.url(source).path
201 if not path: 201 if not path:
202 return '' 202 return ''
203 return os.path.basename(os.path.normpath(path)) 203 return os.path.basename(os.path.normpath(path))
204
205 def sharedreposource(repo):
206 """Returns repository object for source repository of a shared repo.
207
208 If repo is not a shared repository, returns None.
209 """
210 if repo.sharedpath == repo.path:
211 return None
212
213 if util.safehasattr(repo, 'srcrepo') and repo.srcrepo:
214 return repo.srcrepo
215
216 # the sharedpath always ends in the .hg; we want the path to the repo
217 source = repo.vfs.split(repo.sharedpath)[0]
218 srcurl, branches = parseurl(source)
219 srcrepo = repository(repo.ui, srcurl)
220 repo.srcrepo = srcrepo
221 return srcrepo
204 222
205 def share(ui, source, dest=None, update=True, bookmarks=True, defaultpath=None, 223 def share(ui, source, dest=None, update=True, bookmarks=True, defaultpath=None,
206 relative=False): 224 relative=False):
207 '''create a shared repository''' 225 '''create a shared repository'''
208 226