changeset 50188:39256bee2ed9

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 23 Feb 2023 03:28:44 +0100
parents f18e4608bb61
children 6065a8936b00
files mercurial/localrepo.py mercurial/narrowspec.py tests/test-narrow-clone-stream.t
diffstat 3 files changed, 0 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- 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))
--- 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
--- 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