Mercurial > hg-stable
changeset 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 | cc7eb0b558c0 |
files | mercurial/shelve.py tests/test-shelve.t |
diffstat | 2 files changed, 17 insertions(+), 10 deletions(-) [+] |
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)
--- a/tests/test-shelve.t Thu Jul 28 12:53:11 2022 -0400 +++ b/tests/test-shelve.t Thu Jul 28 13:17:36 2022 -0400 @@ -243,12 +243,12 @@ (this also tests that same timestamp prevents backups from being removed, even though there are more than 'maxbackups' backups) - $ f -t .hg/shelve-backup/default.patch - .hg/shelve-backup/default.patch: file - $ touch -t 200001010000 .hg/shelve-backup/default.patch - $ f -t .hg/shelve-backup/default-1.patch - .hg/shelve-backup/default-1.patch: file - $ touch -t 200001010000 .hg/shelve-backup/default-1.patch + $ f -t .hg/shelve-backup/default.shelve + .hg/shelve-backup/default.shelve: file + $ touch -t 200001010000 .hg/shelve-backup/default.shelve + $ f -t .hg/shelve-backup/default-1.shelve + .hg/shelve-backup/default-1.shelve: file + $ touch -t 200001010000 .hg/shelve-backup/default-1.shelve $ hg unshelve unshelving change 'default-01'