Patchwork [2,of,3] shelve: move changegroup generation inside write bundle

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 2, 2015, 2:44 a.m.
Message ID <4e7207b283fe09b167d1.1443753877@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/10725/
State Accepted
Headers show

Comments

Pierre-Yves David - Oct. 2, 2015, 2:44 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1443737372 25200
#      Thu Oct 01 15:09:32 2015 -0700
# Node ID 4e7207b283fe09b167d1c8ac0403e5e724963522
# Parent  a942f2084f9b8f7d4bb2b2fc14b8c7012a8a4619
shelve: move changegroup generation inside write bundle

We will generate different changegroup if general delta is enabled so we gather
this in the lower level function. There wasn't any good reasons to have it in
the main code anyway.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -103,11 +103,12 @@  class shelvedfile(object):
             fp.close()
 
     def bundlerepo(self):
         return bundlerepo.bundlerepository(self.repo.baseui, self.repo.root,
                                            self.vfs.join(self.fname))
-    def writebundle(self, cg):
+    def writebundle(self, bases, node):
+        cg = changegroup.changegroupsubset(self.repo, bases, [node], 'shelve')
         changegroup.writebundle(self.ui, cg, self.fname, 'HG10BZ', self.vfs)
 
 class shelvedstate(object):
     """Handle persistence during unshelving operations.
 
@@ -289,12 +290,11 @@  def createcmd(ui, repo, pats, opts):
             else:
                 ui.status(_("nothing changed\n"))
             return 1
 
         bases = list(publicancestors(repo[node]))
-        cg = changegroup.changegroupsubset(repo, bases, [node], 'shelve')
-        shelvedfile(repo, name, 'hg').writebundle(cg)
+        shelvedfile(repo, name, 'hg').writebundle(bases, node)
         cmdutil.export(repo, [node],
                        fp=shelvedfile(repo, name, 'patch').opener('wb'),
                        opts=mdiff.diffopts(git=True))