# HG changeset patch # User Pierre-Yves David # Date 1677119324 -3600 # Node ID 39256bee2ed9ac9e48d851e9f360a56af65d2d2e # Parent f18e4608bb617e2c42a9fbedae4adb4cfd704b39 narrow: drop the dedicated backup code Now that the transaction manage the writes, we can simply use the transaction for backup. Some extra cleanup to ensure all changes happens within a transaction will be made in the next changesets. diff -r f18e4608bb61 -r 39256bee2ed9 mercurial/localrepo.py --- a/mercurial/localrepo.py Thu Feb 23 03:25:44 2023 +0100 +++ b/mercurial/localrepo.py Thu Feb 23 03:28:44 2023 +0100 @@ -2558,9 +2558,6 @@ else: # discard all changes (including ones already written # out) in this transaction - narrowspec.restorebackup(self, b'journal.narrowspec') - narrowspec.restorewcbackup(self, b'journal.narrowspec.dirstate') - repo.invalidate(clearfilecache=True) tr = transaction.transaction( @@ -2688,8 +2685,6 @@ def _journalfiles(self): return ( (self.svfs, b'journal'), - (self.svfs, b'journal.narrowspec'), - (self.vfs, b'journal.narrowspec.dirstate'), (self.vfs, b'journal.branch'), (self.vfs, b'journal.desc'), (bookmarks.bookmarksvfs(self), b'journal.bookmarks'), @@ -2701,8 +2696,6 @@ @unfilteredmethod def _writejournal(self, desc): - narrowspec.savewcbackup(self, b'journal.narrowspec.dirstate') - narrowspec.savebackup(self, b'journal.narrowspec') self.vfs.write( b"journal.branch", encoding.fromlocal(self.dirstate.branch()) ) @@ -2820,8 +2813,6 @@ self.dirstate.setparents(self.nullid) self.dirstate.clear() - narrowspec.restorebackup(self, b'undo.narrowspec') - narrowspec.restorewcbackup(self, b'undo.narrowspec.dirstate') try: branch = self.vfs.read(b'undo.branch') self.dirstate.setbranch(encoding.tolocal(branch)) diff -r f18e4608bb61 -r 39256bee2ed9 mercurial/narrowspec.py --- a/mercurial/narrowspec.py Thu Feb 23 03:25:44 2023 +0100 +++ b/mercurial/narrowspec.py Thu Feb 23 03:28:44 2023 +0100 @@ -14,7 +14,6 @@ match as matchmod, merge, mergestate as mergestatemod, - requirements, scmutil, sparse, util, @@ -242,46 +241,6 @@ ) -def savebackup(repo, backupname): - if requirements.NARROW_REQUIREMENT not in repo.requirements: - return - svfs = repo.svfs - svfs.tryunlink(backupname) - util.copyfile(svfs.join(FILENAME), svfs.join(backupname), hardlink=True) - - -def restorebackup(repo, backupname): - if requirements.NARROW_REQUIREMENT not in repo.requirements: - return - util.rename(repo.svfs.join(backupname), repo.svfs.join(FILENAME)) - - -def savewcbackup(repo, backupname): - if requirements.NARROW_REQUIREMENT not in repo.requirements: - return - vfs = repo.vfs - vfs.tryunlink(backupname) - # It may not exist in old repos - if vfs.exists(DIRSTATE_FILENAME): - util.copyfile( - vfs.join(DIRSTATE_FILENAME), vfs.join(backupname), hardlink=True - ) - - -def restorewcbackup(repo, backupname): - if requirements.NARROW_REQUIREMENT not in repo.requirements: - return - # It may not exist in old repos - if repo.vfs.exists(backupname): - util.rename(repo.vfs.join(backupname), repo.vfs.join(DIRSTATE_FILENAME)) - - -def clearwcbackup(repo, backupname): - if requirements.NARROW_REQUIREMENT not in repo.requirements: - return - repo.vfs.tryunlink(backupname) - - def restrictpatterns(req_includes, req_excludes, repo_includes, repo_excludes): r"""Restricts the patterns according to repo settings, results in a logical AND operation diff -r f18e4608bb61 -r 39256bee2ed9 tests/test-narrow-clone-stream.t --- a/tests/test-narrow-clone-stream.t Thu Feb 23 03:25:44 2023 +0100 +++ b/tests/test-narrow-clone-stream.t Thu Feb 23 03:28:44 2023 +0100 @@ -90,7 +90,6 @@ requires undo undo.backupfiles - undo.narrowspec undo.phaseroots Checking that repository has all the required data and not broken