##// END OF EJS Templates
shelve: move method for writing bundle to new shelf class...
Martin von Zweigbergk -
r46994:eb7b2929 default
parent child Browse files
Show More
@@ -84,7 +84,6 b' class shelvedfile(object):'
84 84 self.name = name
85 85 self.vfs = vfsmod.vfs(repo.vfs.join(shelvedir))
86 86 self.backupvfs = vfsmod.vfs(repo.vfs.join(backupdir))
87 self.ui = self.repo.ui
88 87 if filetype:
89 88 self.fname = name + b'.' + filetype
90 89 else:
@@ -143,26 +142,6 b' class shelvedfile(object):'
143 142 finally:
144 143 fp.close()
145 144
146 def writebundle(self, bases, node):
147 cgversion = changegroup.safeversion(self.repo)
148 if cgversion == b'01':
149 btype = b'HG10BZ'
150 compression = None
151 else:
152 btype = b'HG20'
153 compression = b'BZ'
154
155 repo = self.repo.unfiltered()
156
157 outgoing = discovery.outgoing(
158 repo, missingroots=bases, ancestorsof=[node]
159 )
160 cg = changegroup.makechangegroup(repo, outgoing, cgversion, b'shelve')
161
162 bundle2.writebundle(
163 self.ui, cg, self.fname, btype, self.vfs, compression=compression
164 )
165
166 145
167 146 class Shelf(object):
168 147 """Represents a shelf, including possibly multiple files storing it.
@@ -188,6 +167,32 b' class Shelf(object):'
188 167 self.vfs, self.name + b'.shelve'
189 168 ).read()
190 169
170 def writebundle(self, bases, node):
171 cgversion = changegroup.safeversion(self.repo)
172 if cgversion == b'01':
173 btype = b'HG10BZ'
174 compression = None
175 else:
176 btype = b'HG20'
177 compression = b'BZ'
178
179 repo = self.repo.unfiltered()
180
181 outgoing = discovery.outgoing(
182 repo, missingroots=bases, ancestorsof=[node]
183 )
184 cg = changegroup.makechangegroup(repo, outgoing, cgversion, b'shelve')
185
186 bundle_filename = self.vfs.join(self.name + b'.hg')
187 bundle2.writebundle(
188 self.repo.ui,
189 cg,
190 bundle_filename,
191 btype,
192 self.vfs,
193 compression=compression,
194 )
195
191 196
192 197 class shelvedstate(object):
193 198 """Handle persistence during unshelving operations.
@@ -475,7 +480,7 b' def _shelvecreatedcommit(repo, node, nam'
475 480 info = {b'node': hex(node)}
476 481 Shelf(repo, name).writeinfo(info)
477 482 bases = list(mutableancestors(repo[node]))
478 shelvedfile(repo, name, b'hg').writebundle(bases, node)
483 Shelf(repo, name).writebundle(bases, node)
479 484 with shelvedfile(repo, name, patchextension).opener(b'wb') as fp:
480 485 cmdutil.exportfile(
481 486 repo, [node], fp, opts=mdiff.diffopts(git=True), match=match
General Comments 0
You need to be logged in to leave comments. Login now