shelve: move method for writing .shelve to new shelf class
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 07 Jan 2021 11:22:21 -0800
changeset 46274 a344ec05b99c
parent 46273 efc71bb71682
child 46275 157305bf859f
shelve: move method for writing .shelve to new shelf class Differential Revision: https://phab.mercurial-scm.org/D9701
mercurial/shelve.py
--- a/mercurial/shelve.py	Thu Jan 07 11:07:21 2021 -0800
+++ b/mercurial/shelve.py	Thu Jan 07 11:22:21 2021 -0800
@@ -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]