diff mercurial/shelve.py @ 49457:c4417029e6c2

phase-shelve: honor and prefer obs shelves for existence and modified time
author Jason R. Coombs <jaraco@jaraco.com>
date Thu, 28 Jul 2022 13:17:36 -0400
parents 24ffd13893cc
children fa00c407d61c
line wrap: on
line diff
--- a/mercurial/shelve.py	Thu Jul 28 12:53:11 2022 -0400
+++ b/mercurial/shelve.py	Thu Jul 28 13:17:36 2022 -0400
@@ -112,12 +112,19 @@
         self.name = name
 
     def exists(self):
-        return self.vfs.exists(self.name + b'.patch') and self.vfs.exists(
-            self.name + b'.hg'
-        )
+        return self._exists(b'.shelve') or self._exists(b'.patch', b'.hg')
+
+    def _exists(self, *exts):
+        return all(self.vfs.exists(self.name + ext) for ext in exts)
 
     def mtime(self):
-        return self.vfs.stat(self.name + b'.patch')[stat.ST_MTIME]
+        try:
+            return self._stat(b'.shelve')[stat.ST_MTIME]
+        except FileNotFoundError:
+            return self._stat(b'.patch')[stat.ST_MTIME]
+
+    def _stat(self, ext):
+        return self.vfs.stat(self.name + ext)
 
     def writeinfo(self, info):
         scmutil.simplekeyvaluefile(self.vfs, self.name + b'.shelve').write(info)