diff hgext/shelve.py @ 26507:ae29cffa05db

shelve: bundle using bundle2 if repository is general delta (issue4862) This will prevent expensive delta computation on bundling and is similar to what we do for strip backup.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 01 Oct 2015 15:08:00 -0700
parents edecf059fda6
children 46dec89fe888
line wrap: on
line diff
--- a/hgext/shelve.py	Thu Oct 01 15:09:32 2015 -0700
+++ b/hgext/shelve.py	Thu Oct 01 15:08:00 2015 -0700
@@ -106,8 +106,18 @@
         return bundlerepo.bundlerepository(self.repo.baseui, self.repo.root,
                                            self.vfs.join(self.fname))
     def writebundle(self, bases, node):
-        cg = changegroup.changegroupsubset(self.repo, bases, [node], 'shelve')
-        changegroup.writebundle(self.ui, cg, self.fname, 'HG10BZ', self.vfs)
+        btype = 'HG10BZ'
+        cgversion = '01'
+        compression = None
+        if 'generaldelta' in self.repo.requirements:
+            btype = 'HG20'
+            cgversion = '02'
+            compression = 'BZ'
+
+        cg = changegroup.changegroupsubset(self.repo, bases, [node], 'shelve',
+                                           version=cgversion)
+        changegroup.writebundle(self.ui, cg, self.fname, btype, self.vfs,
+                                compression=compression)
 
 class shelvedstate(object):
     """Handle persistence during unshelving operations.