Mercurial > hg-stable
comparison mercurial/hg.py @ 34878:9f7ecc5bbc28
share: move the implementation of 'unshare' to the 'hg' module
This will be used to setup unsharing subrepos. Usually cmdutil is used for
this purpose. But the implementation needs hg.copystore(), and the hg module
already imports cmdutil.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 17 Oct 2017 21:48:56 -0400 |
parents | 68e0bcb90357 |
children | 7d51a7792f52 |
comparison
equal
deleted
inserted
replaced
34877:eb24f1d1b50b | 34878:9f7ecc5bbc28 |
---|---|
254 | 254 |
255 r = repository(ui, destwvfs.base) | 255 r = repository(ui, destwvfs.base) |
256 postshare(srcrepo, r, bookmarks=bookmarks, defaultpath=defaultpath) | 256 postshare(srcrepo, r, bookmarks=bookmarks, defaultpath=defaultpath) |
257 _postshareupdate(r, update, checkout=checkout) | 257 _postshareupdate(r, update, checkout=checkout) |
258 return r | 258 return r |
259 | |
260 def unshare(ui, repo): | |
261 """convert a shared repository to a normal one | |
262 | |
263 Copy the store data to the repo and remove the sharedpath data. | |
264 """ | |
265 | |
266 destlock = lock = None | |
267 lock = repo.lock() | |
268 try: | |
269 # we use locks here because if we race with commit, we | |
270 # can end up with extra data in the cloned revlogs that's | |
271 # not pointed to by changesets, thus causing verify to | |
272 # fail | |
273 | |
274 destlock = copystore(ui, repo, repo.path) | |
275 | |
276 sharefile = repo.vfs.join('sharedpath') | |
277 util.rename(sharefile, sharefile + '.old') | |
278 | |
279 repo.requirements.discard('shared') | |
280 repo.requirements.discard('relshared') | |
281 repo._writerequirements() | |
282 finally: | |
283 destlock and destlock.release() | |
284 lock and lock.release() | |
285 | |
286 # update store, spath, svfs and sjoin of repo | |
287 repo.unfiltered().__init__(repo.baseui, repo.root) | |
259 | 288 |
260 def postshare(sourcerepo, destrepo, bookmarks=True, defaultpath=None): | 289 def postshare(sourcerepo, destrepo, bookmarks=True, defaultpath=None): |
261 """Called after a new shared repo is created. | 290 """Called after a new shared repo is created. |
262 | 291 |
263 The new repo only has a requirements file and pointer to the source. | 292 The new repo only has a requirements file and pointer to the source. |