changeset 46278:58ca94869287

shelve: move function for opening .patch file to new shelf class The `opener()` method was used specifically for the `.patch` file, and the new `Shelf` class deals with all files involved in a shelf, so I renamed the function in the process. Differential Revision: https://phab.mercurial-scm.org/D9705
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 07 Jan 2021 14:48:57 -0800
parents ed2f2150d57c
children 14ce2eb6e8a4
files mercurial/shelve.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/shelve.py	Thu Jan 07 13:57:21 2021 -0800
+++ b/mercurial/shelve.py	Thu Jan 07 14:48:57 2021 -0800
@@ -114,9 +114,6 @@
     def stat(self):
         return self.vfs.stat(self.fname)
 
-    def opener(self, mode=b'rb'):
-        return self.vfs(self.fname, mode)
-
 
 class Shelf(object):
     """Represents a shelf, including possibly multiple files storing it.
@@ -193,6 +190,9 @@
         finally:
             fp.close()
 
+    def open_patch(self, mode=b'rb'):
+        return self.vfs(self.name + b'.patch', mode)
+
 
 class shelvedstate(object):
     """Handle persistence during unshelving operations.
@@ -481,7 +481,7 @@
     Shelf(repo, name).writeinfo(info)
     bases = list(mutableancestors(repo[node]))
     Shelf(repo, name).writebundle(bases, node)
-    with shelvedfile(repo, name, patchextension).opener(b'wb') as fp:
+    with Shelf(repo, name).open_patch(b'wb') as fp:
         cmdutil.exportfile(
             repo, [node], fp, opts=mdiff.diffopts(git=True), match=match
         )