Patchwork D9701: shelve: move method for writing .shelve to new shelf class

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

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 writeinfo(self, info):
-        scmutil.simplekeyvaluefile(self.vfs, self.fname).write(info)
-
     def readinfo(self):
         return scmutil.simplekeyvaluefile(self.vfs, self.fname).read()
 
@@ -186,6 +183,9 @@ 
     def exists(self):
         return self.vfs.exists(self.name + b'.' + patchextension)
 
+    def writeinfo(self, info):
+        scmutil.simplekeyvaluefile(self.vfs, self.name + b'.shelve').write(info)
+
 
 class shelvedstate(object):
     """Handle persistence during unshelving operations.
@@ -471,7 +471,7 @@ 
 
 def _shelvecreatedcommit(repo, node, name, match):
     info = {b'node': hex(node)}
-    shelvedfile(repo, name, b'shelve').writeinfo(info)
+    Shelf(repo, name).writeinfo(info)
     bases = list(mutableancestors(repo[node]))
     shelvedfile(repo, name, b'hg').writebundle(bases, node)
     with shelvedfile(repo, name, patchextension).opener(b'wb') as fp:
@@ -902,7 +902,7 @@ 
         # the unshelve node in case we need to reuse it (eg: unshelve --keep)
         if node is None:
             info = {b'node': hex(shelvectx.node())}
-            shelvedfile(repo, basename, b'shelve').writeinfo(info)
+            Shelf(repo, basename).writeinfo(info)
     else:
         shelvectx = repo[node]