changeset 46280:7e300d297547

shelve: move method for getting stat (mtime) to new shelf class Only the mtime was needed, so I made it restricted to that in the move. The new `Shelf` class expects its argument to be a shelf name (not a arbitrary filename like `shelvedfile` would accept), so only the shelf name is now passed in. Differential Revision: https://phab.mercurial-scm.org/D9707
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 07 Jan 2021 14:54:56 -0800
parents 14ce2eb6e8a4
children a34607b6d320
files mercurial/shelve.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/shelve.py	Thu Jan 07 15:24:15 2021 -0800
+++ b/mercurial/shelve.py	Thu Jan 07 14:54:56 2021 -0800
@@ -110,9 +110,6 @@
             self.backupvfs.makedir()
         util.rename(self.filename(), self.backupfilename())
 
-    def stat(self):
-        return self.vfs.stat(self.fname)
-
 
 class Shelf(object):
     """Represents a shelf, including possibly multiple files storing it.
@@ -130,6 +127,9 @@
     def exists(self):
         return self.vfs.exists(self.name + b'.' + patchextension)
 
+    def mtime(self):
+        return self.vfs.stat(self.name + b'.' + patchextension)[stat.ST_MTIME]
+
     def writeinfo(self, info):
         scmutil.simplekeyvaluefile(self.vfs, self.name + b'.shelve').write(info)
 
@@ -642,8 +642,8 @@
         pfx, sfx = name.rsplit(b'.', 1)
         if not pfx or sfx != patchextension:
             continue
-        st = shelvedfile(repo, name).stat()
-        info.append((st[stat.ST_MTIME], shelvedfile(repo, pfx).filename()))
+        mtime = Shelf(repo, pfx).mtime()
+        info.append((mtime, shelvedfile(repo, pfx).filename()))
     return sorted(info, reverse=True)