Mercurial > hg
changeset 41229:50ca531f1f24
narrow: copy store narrowspec to working copy immediately
We no longer need to delay it until the end of the transaction since
we now restore a backup if the transaction aborts.
Differential Revision: https://phab.mercurial-scm.org/D5506
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Sat, 29 Dec 2018 23:01:12 -0800 |
parents | 3b35ebdb9f8c |
children | d2d716cc0700 |
files | hgext/narrow/narrowcommands.py mercurial/hg.py mercurial/localrepo.py mercurial/narrowspec.py |
diffstat | 4 files changed, 7 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/narrow/narrowcommands.py Sat Dec 29 22:34:38 2018 -0800 +++ b/hgext/narrow/narrowcommands.py Sat Dec 29 23:01:12 2018 -0800 @@ -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:
--- a/mercurial/hg.py Sat Dec 29 22:34:38 2018 -0800 +++ b/mercurial/hg.py Sat Dec 29 23:01:12 2018 -0800 @@ -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.
--- a/mercurial/localrepo.py Sat Dec 29 22:34:38 2018 -0800 +++ b/mercurial/localrepo.py Sat Dec 29 23:01:12 2018 -0800 @@ -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
--- a/mercurial/narrowspec.py Sat Dec 29 22:34:38 2018 -0800 +++ b/mercurial/narrowspec.py Sat Dec 29 23:01:12 2018 -0800 @@ -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: