diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py --- a/hgext/narrow/narrowcommands.py +++ b/hgext/narrow/narrowcommands.py @@ -432,9 +432,9 @@ return 0 if update_working_copy: - with repo.wlock(), repo.lock(), repo.transaction('narrow-wc') as tr: + with repo.wlock(), repo.lock(), repo.transaction('narrow-wc'): narrowspec.updateworkingcopy(repo) - narrowspec.copytoworkingcopy(repo, tr) + narrowspec.copytoworkingcopy(repo) return 0 if not widening and not narrowing: 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/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/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: