##// END OF EJS Templates
localrepo: support writing shared file (API)...
Gregory Szorc -
r39885:d3d4b4b5 default
parent child Browse files
Show More
@@ -905,8 +905,8 b' def hgclone(orig, ui, opts, *args, **kwa'
905
905
906 return result
906 return result
907
907
908 def hgpostshare(orig, sourcerepo, destrepo, bookmarks=True, defaultpath=None):
908 def hgpostshare(orig, sourcerepo, destrepo, defaultpath=None):
909 orig(sourcerepo, destrepo, bookmarks, defaultpath)
909 orig(sourcerepo, destrepo, defaultpath=defaultpath)
910
910
911 # If largefiles is required for this repo, permanently enable it locally
911 # If largefiles is required for this repo, permanently enable it locally
912 if 'largefiles' in destrepo.requirements:
912 if 'largefiles' in destrepo.requirements:
@@ -240,8 +240,8 b' def hgclone(orig, ui, opts, *args, **kwa'
240
240
241 return result
241 return result
242
242
243 def hgpostshare(orig, sourcerepo, destrepo, bookmarks=True, defaultpath=None):
243 def hgpostshare(orig, sourcerepo, destrepo, defaultpath=None):
244 orig(sourcerepo, destrepo, bookmarks, defaultpath)
244 orig(sourcerepo, destrepo, defaultpath=defaultpath)
245
245
246 # If lfs is required for this repo, permanently enable it locally
246 # If lfs is required for this repo, permanently enable it locally
247 if 'lfs' in destrepo.requirements:
247 if 'lfs' in destrepo.requirements:
@@ -259,12 +259,17 b' def share(ui, source, dest=None, update='
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
@@ -315,7 +320,7 b' def unshare(ui, 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.
@@ -330,10 +335,6 b' def postshare(sourcerepo, destrepo, book'
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
337
333 with destrepo.wlock():
334 if bookmarks:
335 destrepo.vfs.write('shared', sharedbookmarks + '\n')
336
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
@@ -2786,6 +2786,7 b' def filterknowncreateopts(ui, createopts'
2786 'narrowfiles',
2786 'narrowfiles',
2787 'sharedrepo',
2787 'sharedrepo',
2788 'sharedrelative',
2788 'sharedrelative',
2789 'shareditems',
2789 }
2790 }
2790
2791
2791 return {k: v for k, v in createopts.items() if k not in known}
2792 return {k: v for k, v in createopts.items() if k not in known}
@@ -2806,6 +2807,8 b' def createrepository(ui, path, createopt'
2806 Boolean indicating if the path to the shared repo should be
2807 Boolean indicating if the path to the shared repo should be
2807 stored as relative. By default, the pointer to the "parent" repo
2808 stored as relative. By default, the pointer to the "parent" repo
2808 is stored as an absolute path.
2809 is stored as an absolute path.
2810 shareditems
2811 Set of items to share to the new repository (in addition to storage).
2809 """
2812 """
2810 createopts = createopts or {}
2813 createopts = createopts or {}
2811
2814
@@ -2867,6 +2870,10 b' def createrepository(ui, path, createopt'
2867 if 'sharedrepo' in createopts:
2870 if 'sharedrepo' in createopts:
2868 hgvfs.write(b'sharedpath', sharedpath)
2871 hgvfs.write(b'sharedpath', sharedpath)
2869
2872
2873 if createopts.get('shareditems'):
2874 shared = b'\n'.join(sorted(createopts['shareditems'])) + b'\n'
2875 hgvfs.write(b'shared', shared)
2876
2870 def poisonrepository(repo):
2877 def poisonrepository(repo):
2871 """Poison a repository instance so it can no longer be used."""
2878 """Poison a repository instance so it can no longer be used."""
2872 # Perform any cleanup on the instance.
2879 # Perform any cleanup on the instance.
General Comments 0
You need to be logged in to leave comments. Login now