[Updated] [+- ] D9713: shelve: teach new shelf class to check if .shelve file exists

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue Jan 12 22:49:23 UTC 2021


martinvonz updated this revision to Diff 24736.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D9713?vs=24669&id=24736

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D9713/new/

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

AFFECTED FILES
  mercurial/shelve.py

CHANGE DETAILS

diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -72,24 +72,6 @@
 shelveuser = b'shelve at localhost'
 
 
-class shelvedfile(object):
-    """Helper for the file storing a single shelve
-
-    Handles common functions on shelve files (.hg/.patch) using
-    the vfs layer"""
-
-    def __init__(self, repo, name, filetype=None):
-        self.name = name
-        self.vfs = vfsmod.vfs(repo.vfs.join(shelvedir))
-        if filetype:
-            self.fname = name + b'.' + filetype
-        else:
-            self.fname = name
-
-    def exists(self):
-        return self.vfs.exists(self.fname)
-
-
 class Shelf(object):
     """Represents a shelf, including possibly multiple files storing it.
 
@@ -113,6 +95,9 @@
     def writeinfo(self, info):
         scmutil.simplekeyvaluefile(self.vfs, self.name + b'.shelve').write(info)
 
+    def hasinfo(self):
+        return self.vfs.exists(self.name + b'.shelve')
+
     def readinfo(self):
         return scmutil.simplekeyvaluefile(
             self.vfs, self.name + b'.shelve'
@@ -890,7 +875,7 @@
     """Recreate commit in the repository during the unshelve"""
     repo = repo.unfiltered()
     node = None
-    if shelvedfile(repo, basename, b'shelve').exists():
+    if Shelf(repo, basename).hasinfo():
         node = Shelf(repo, basename).readinfo()[b'node']
     if node is None or node not in repo:
         with ui.configoverride({(b'ui', b'quiet'): True}):



To: martinvonz, #hg-reviewers
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210112/c84a063f/attachment-0002.html>


More information about the Mercurial-patches mailing list