mercurial/shelve.py
changeset 46295 f8c5e6ecd008
parent 46294 d3b226b6c8c6
child 46296 eec8899407f4
--- a/mercurial/shelve.py	Mon Jan 11 10:53:42 2021 -0800
+++ b/mercurial/shelve.py	Mon Jan 11 23:08:37 2021 -0800
@@ -86,6 +86,10 @@
     def open(repo, name):
         return Shelf(vfsmod.vfs(repo.vfs.join(shelvedir)), name)
 
+    @staticmethod
+    def open_backup(repo, name):
+        return Shelf(vfsmod.vfs(repo.vfs.join(backupdir)), name)
+
     def exists(self):
         return self.vfs.exists(self.name + b'.patch') and self.vfs.exists(
             self.name + b'.hg'
@@ -181,6 +185,10 @@
                     self._backupfilename(backupvfs, filename),
                 )
 
+    def delete(self):
+        for ext in shelvefileextensions:
+            self.vfs.tryunlink(self.name + b'.' + ext)
+
 
 class shelvedstate(object):
     """Handle persistence during unshelving operations.
@@ -332,8 +340,7 @@
         if mtime == bordermtime:
             # keep it, because timestamp can't decide exact order of backups
             continue
-        for ext in shelvefileextensions:
-            vfs.tryunlink(name + b'.' + ext)
+        Shelf.open_backup(repo, name).delete()
 
 
 def _backupactivebookmark(repo):