mercurial/hg.py
changeset 39849 d3d4b4b5f725
parent 39848 4ece3cdfd907
child 40324 6637b079ae45
equal deleted inserted replaced
39848:4ece3cdfd907 39849:d3d4b4b5f725
   257         rev, checkout = addbranchrevs(srcrepo, srcrepo, branches, None)
   257         rev, checkout = addbranchrevs(srcrepo, srcrepo, branches, None)
   258     else:
   258     else:
   259         srcrepo = source.local()
   259         srcrepo = source.local()
   260         checkout = None
   260         checkout = None
   261 
   261 
       
   262     shareditems = set()
       
   263     if bookmarks:
       
   264         shareditems.add(sharedbookmarks)
       
   265 
   262     r = repository(ui, dest, create=True, createopts={
   266     r = repository(ui, dest, create=True, createopts={
   263         'sharedrepo': srcrepo,
   267         'sharedrepo': srcrepo,
   264         'sharedrelative': relative,
   268         'sharedrelative': relative,
       
   269         'shareditems': shareditems,
   265     })
   270     })
   266 
   271 
   267     postshare(srcrepo, r, bookmarks=bookmarks, defaultpath=defaultpath)
   272     postshare(srcrepo, r, defaultpath=defaultpath)
   268     _postshareupdate(r, update, checkout=checkout)
   273     _postshareupdate(r, update, checkout=checkout)
   269     return r
   274     return r
   270 
   275 
   271 def unshare(ui, repo):
   276 def unshare(ui, repo):
   272     """convert a shared repository to a normal one
   277     """convert a shared repository to a normal one
   313 
   318 
   314     localrepo.poisonrepository(repo)
   319     localrepo.poisonrepository(repo)
   315 
   320 
   316     return newrepo
   321     return newrepo
   317 
   322 
   318 def postshare(sourcerepo, destrepo, bookmarks=True, defaultpath=None):
   323 def postshare(sourcerepo, destrepo, defaultpath=None):
   319     """Called after a new shared repo is created.
   324     """Called after a new shared repo is created.
   320 
   325 
   321     The new repo only has a requirements file and pointer to the source.
   326     The new repo only has a requirements file and pointer to the source.
   322     This function configures additional shared data.
   327     This function configures additional shared data.
   323 
   328 
   327     default = defaultpath or sourcerepo.ui.config('paths', 'default')
   332     default = defaultpath or sourcerepo.ui.config('paths', 'default')
   328     if default:
   333     if default:
   329         template = ('[paths]\n'
   334         template = ('[paths]\n'
   330                     'default = %s\n')
   335                     'default = %s\n')
   331         destrepo.vfs.write('hgrc', util.tonativeeol(template % default))
   336         destrepo.vfs.write('hgrc', util.tonativeeol(template % default))
   332 
       
   333     with destrepo.wlock():
       
   334         if bookmarks:
       
   335             destrepo.vfs.write('shared', sharedbookmarks + '\n')
       
   336 
   337 
   337 def _postshareupdate(repo, update, checkout=None):
   338 def _postshareupdate(repo, update, checkout=None):
   338     """Maybe perform a working directory update after a shared repo is created.
   339     """Maybe perform a working directory update after a shared repo is created.
   339 
   340 
   340     ``update`` can be a boolean or a revision to update to.
   341     ``update`` can be a boolean or a revision to update to.