Patchwork D9702: shelve: move method for reading .shelve file to new shelf class

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -163,9 +163,6 @@ 
             self.ui, cg, self.fname, btype, self.vfs, compression=compression
         )
 
-    def readinfo(self):
-        return scmutil.simplekeyvaluefile(self.vfs, self.fname).read()
-
 
 class Shelf(object):
     """Represents a shelf, including possibly multiple files storing it.
@@ -186,6 +183,11 @@ 
     def writeinfo(self, info):
         scmutil.simplekeyvaluefile(self.vfs, self.name + b'.shelve').write(info)
 
+    def readinfo(self):
+        return scmutil.simplekeyvaluefile(
+            self.vfs, self.name + b'.shelve'
+        ).read()
+
 
 class shelvedstate(object):
     """Handle persistence during unshelving operations.
@@ -894,7 +896,7 @@ 
     repo = repo.unfiltered()
     node = None
     if shelvedfile(repo, basename, b'shelve').exists():
-        node = shelvedfile(repo, basename, b'shelve').readinfo()[b'node']
+        node = Shelf(repo, basename).readinfo()[b'node']
     if node is None or node not in repo:
         with ui.configoverride({(b'ui', b'quiet'): True}):
             shelvectx = shelvedfile(repo, basename, b'hg').applybundle(tr)