# HG changeset patch # User Martin von Zweigbergk # Date 2021-01-07 22:54:56 # Node ID 2da2fecde96144d7856079ded4fa9043342d34ed # Parent 6f39aab28188fd1bdcfdb2eb8a8efb2eba1329f0 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 diff --git a/mercurial/shelve.py b/mercurial/shelve.py --- a/mercurial/shelve.py +++ b/mercurial/shelve.py @@ -110,9 +110,6 @@ class shelvedfile(object): 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 @@ class Shelf(object): 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 @@ def listshelves(repo): 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)