Patchwork D9707: shelve: move method for getting stat (mtime) to new shelf class

login
register
mail settings
Submitter phabricator
Date Jan. 8, 2021, 8:37 p.m.
Message ID <differential-rev-PHID-DREV-2fanhryix5y4xoz4uuuw-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48018/
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
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -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)