changeset 46274:a344ec05b99c

shelve: move method for writing .shelve to new shelf class Differential Revision: https://phab.mercurial-scm.org/D9701
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 07 Jan 2021 11:22:21 -0800
parents efc71bb71682
children 157305bf859f
files mercurial/shelve.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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]