Patchwork D5506: narrow: copy store narrowspec to working copy immediately

login
register
mail settings
Submitter phabricator
Date Jan. 7, 2019, 9:19 a.m.
Message ID <7cb504ecf6b470625a048c526a6da6b8@localhost.localdomain>
Download mbox | patch
Permalink /patch/37516/
State Not Applicable
Headers show

Comments

phabricator - Jan. 7, 2019, 9:19 a.m.
martinvonz updated this revision to Diff 13035.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5506?vs=13028&id=13035

REVISION DETAIL
  https://phab.mercurial-scm.org/D5506

AFFECTED FILES
  hgext/narrow/narrowcommands.py
  mercurial/hg.py
  mercurial/localrepo.py
  mercurial/narrowspec.py

CHANGE DETAILS




To: martinvonz, durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py
--- a/mercurial/narrowspec.py
+++ b/mercurial/narrowspec.py
@@ -161,17 +161,9 @@ 
     spec = format(includepats, excludepats)
     repo.svfs.write(FILENAME, spec)
 
-def copytoworkingcopy(repo, tr):
-    if tr:
-        def write(file):
-            spec = repo.svfs.read(FILENAME)
-            file.write(spec)
-            file.close()
-        tr.addfilegenerator('narrowspec', (DIRSTATE_FILENAME,), write,
-                            location='plain')
-    else:
-        spec = repo.svfs.read(FILENAME)
-        repo.vfs.write(DIRSTATE_FILENAME, spec)
+def copytoworkingcopy(repo):
+    spec = repo.svfs.read(FILENAME)
+    repo.vfs.write(DIRSTATE_FILENAME, spec)
 
 def savebackup(repo, backupname):
     if repository.NARROW_REQUIREMENT not in repo.requirements:
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1252,7 +1252,7 @@ 
 
     def setnarrowpats(self, newincludes, newexcludes):
         narrowspec.save(self, newincludes, newexcludes)
-        narrowspec.copytoworkingcopy(self, self.currenttransaction())
+        narrowspec.copytoworkingcopy(self)
         self.invalidate(clearfilecache=True)
         # So the next access won't be considered a conflict
         # TODO: It seems like there should be a way of doing this that
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -334,7 +334,7 @@ 
         destrepo.vfs.write('hgrc', util.tonativeeol(template % default))
     if repositorymod.NARROW_REQUIREMENT in sourcerepo.requirements:
         with destrepo.wlock():
-            narrowspec.copytoworkingcopy(destrepo, None)
+            narrowspec.copytoworkingcopy(destrepo)
 
 def _postshareupdate(repo, update, checkout=None):
     """Maybe perform a working directory update after a shared repo is created.
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -434,7 +434,7 @@ 
     if update_working_copy:
         with repo.wlock(), repo.lock(), repo.transaction('narrow-wc') as tr:
             narrowspec.updateworkingcopy(repo, tr)
-            narrowspec.copytoworkingcopy(repo, tr)
+            narrowspec.copytoworkingcopy(repo)
         return 0
 
     if not widening and not narrowing: