Patchwork D9710: shelve: use listshelves() in cleanup function

login
register
mail settings
Submitter phabricator
Date Jan. 8, 2021, 8:37 p.m.
Message ID <differential-rev-PHID-DREV-alzuvuhnz64sropi3yc4-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48022/
State Superseded
Headers show

Comments

phabricator - Jan. 8, 2021, 8:37 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The point of this patch is to make it so all the callers of
  `shelvedfile.movetobackup()` look the same, so I can move it over to
  the new `Shelf` class next.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9710

AFFECTED FILES
  mercurial/shelve.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -602,10 +602,11 @@ 
     """subcommand that deletes all shelves"""
 
     with repo.wlock():
-        for (name, _type) in repo.vfs.readdir(shelvedir):
-            suffix = name.rsplit(b'.', 1)[-1]
-            if suffix in shelvefileextensions:
-                shelvedfile(repo, name).movetobackup()
+        for _mtime, name in listshelves(repo):
+            for suffix in shelvefileextensions:
+                shfile = shelvedfile(repo, name, suffix)
+                if shfile.exists():
+                    shfile.movetobackup()
             cleanupoldbackups(repo)