Patchwork D9705: shelve: move function for opening .patch 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-22nflmxmdxudbxbdoulg-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48016/
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.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -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
         )