comparison mercurial/hg.py @ 41043:ce0bc2952e2a

narrow: detect if narrowspec was changed in a different share With this commit, `hg share` should be usable with narrow repos. Design explained on https://www.mercurial-scm.org/wiki/NarrowSharePlan I was running into cache invalidation problems when updating the narrowspec. After spending a day trying to figure out a good solution, I resorted to just assigning repo.narrowpats and repo._narrowmatch after invalidating them. Differential Revision: https://phab.mercurial-scm.org/D5278
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 21 Dec 2018 10:13:49 -0800
parents 6f2510b581a0
children 50ca531f1f24
comparison
equal deleted inserted replaced
41042:7db1619af061 41043:ce0bc2952e2a
36 logexchange, 36 logexchange,
37 merge as mergemod, 37 merge as mergemod,
38 narrowspec, 38 narrowspec,
39 node, 39 node,
40 phases, 40 phases,
41 repository as repositorymod,
41 scmutil, 42 scmutil,
42 sshpeer, 43 sshpeer,
43 statichttprepo, 44 statichttprepo,
44 ui as uimod, 45 ui as uimod,
45 unionrepo, 46 unionrepo,
329 default = defaultpath or sourcerepo.ui.config('paths', 'default') 330 default = defaultpath or sourcerepo.ui.config('paths', 'default')
330 if default: 331 if default:
331 template = ('[paths]\n' 332 template = ('[paths]\n'
332 'default = %s\n') 333 'default = %s\n')
333 destrepo.vfs.write('hgrc', util.tonativeeol(template % default)) 334 destrepo.vfs.write('hgrc', util.tonativeeol(template % default))
335 if repositorymod.NARROW_REQUIREMENT in sourcerepo.requirements:
336 with destrepo.wlock():
337 narrowspec.copytoworkingcopy(destrepo, None)
334 338
335 def _postshareupdate(repo, update, checkout=None): 339 def _postshareupdate(repo, update, checkout=None):
336 """Maybe perform a working directory update after a shared repo is created. 340 """Maybe perform a working directory update after a shared repo is created.
337 341
338 ``update`` can be a boolean or a revision to update to. 342 ``update`` can be a boolean or a revision to update to.
729 else: 733 else:
730 revs = None 734 revs = None
731 local = destpeer.local() 735 local = destpeer.local()
732 if local: 736 if local:
733 if narrow: 737 if narrow:
734 with local.lock(): 738 with local.wlock(), local.lock():
735 local.setnarrowpats(storeincludepats, storeexcludepats) 739 local.setnarrowpats(storeincludepats, storeexcludepats)
736 740
737 u = util.url(abspath) 741 u = util.url(abspath)
738 defaulturl = bytes(u) 742 defaulturl = bytes(u)
739 local.ui.setconfig('paths', 'default', defaulturl, 'clone') 743 local.ui.setconfig('paths', 'default', defaulturl, 'clone')