diff mercurial/hg.py @ 41046: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
line wrap: on
line diff
--- a/mercurial/hg.py	Fri Jul 13 11:26:46 2018 -0700
+++ b/mercurial/hg.py	Fri Dec 21 10:13:49 2018 -0800
@@ -38,6 +38,7 @@
     narrowspec,
     node,
     phases,
+    repository as repositorymod,
     scmutil,
     sshpeer,
     statichttprepo,
@@ -331,6 +332,9 @@
         template = ('[paths]\n'
                     'default = %s\n')
         destrepo.vfs.write('hgrc', util.tonativeeol(template % default))
+    if repositorymod.NARROW_REQUIREMENT in sourcerepo.requirements:
+        with destrepo.wlock():
+            narrowspec.copytoworkingcopy(destrepo, None)
 
 def _postshareupdate(repo, update, checkout=None):
     """Maybe perform a working directory update after a shared repo is created.
@@ -731,7 +735,7 @@
             local = destpeer.local()
             if local:
                 if narrow:
-                    with local.lock():
+                    with local.wlock(), local.lock():
                         local.setnarrowpats(storeincludepats, storeexcludepats)
 
                 u = util.url(abspath)