##// END OF EJS Templates
bundle: introduce an higher level function to write bundle on disk...
marmoute -
r32216:9dc36df7 default
parent child Browse files
Show More
@@ -1339,6 +1339,42 b' def obsmarkersversion(caps):'
1339 obscaps = caps.get('obsmarkers', ())
1339 obscaps = caps.get('obsmarkers', ())
1340 return [int(c[1:]) for c in obscaps if c.startswith('V')]
1340 return [int(c[1:]) for c in obscaps if c.startswith('V')]
1341
1341
1342 def writenewbundle(ui, repo, source, filename, bundletype, outgoing, opts,
1343 vfs=None, compression=None, compopts=None):
1344 if bundletype.startswith('HG10'):
1345 cg = changegroup.getchangegroup(repo, source, outgoing, version='01')
1346 return writebundle(ui, cg, filename, bundletype, vfs=vfs,
1347 compression=compression, compopts=compopts)
1348 elif not bundletype.startswith('HG20'):
1349 raise error.ProgrammingError('unknown bundle type: %s' % bundletype)
1350
1351 bundle = bundle20(ui)
1352 bundle.setcompression(compression, compopts)
1353 _addpartsfromopts(ui, repo, bundle, source, outgoing, opts)
1354 chunkiter = bundle.getchunks()
1355
1356 return changegroup.writechunks(ui, chunkiter, filename, vfs=vfs)
1357
1358 def _addpartsfromopts(ui, repo, bundler, source, outgoing, opts):
1359 # We should eventually reconcile this logic with the one behind
1360 # 'exchange.getbundle2partsgenerator'.
1361 #
1362 # The type of input from 'getbundle' and 'writenewbundle' are a bit
1363 # different right now. So we keep them separated for now for the sake of
1364 # simplicity.
1365
1366 # we always want a changegroup in such bundle
1367 cgversion = opts.get('cg.version')
1368 if cgversion is None:
1369 cgversion = changegroup.safeversion(repo)
1370 cg = changegroup.getchangegroup(repo, source, outgoing,
1371 version=cgversion)
1372 part = bundler.newpart('changegroup', data=cg.getchunks())
1373 part.addparam('version', cg.version)
1374 if 'clcount' in cg.extras:
1375 part.addparam('nbchanges', str(cg.extras['clcount']),
1376 mandatory=False)
1377
1342 def writebundle(ui, cg, filename, bundletype, vfs=None, compression=None,
1378 def writebundle(ui, cg, filename, bundletype, vfs=None, compression=None,
1343 compopts=None):
1379 compopts=None):
1344 """Write a bundle file and return its filename.
1380 """Write a bundle file and return its filename.
@@ -1393,10 +1393,11 b' def bundle(ui, repo, fname, dest=None, *'
1393 if complevel is not None:
1393 if complevel is not None:
1394 compopts['level'] = complevel
1394 compopts['level'] = complevel
1395
1395
1396 cg = changegroup.getchangegroup(repo, 'bundle', outgoing, version=cgversion)
1396
1397
1397 contentopts = {'cg.version': cgversion}
1398 bundle2.writebundle(ui, cg, fname, bversion, compression=bcompression,
1398 bundle2.writenewbundle(ui, repo, 'bundle', fname, bversion, outgoing,
1399 compopts=compopts)
1399 contentopts, compression=bcompression,
1400 compopts=compopts)
1400
1401
1401 @command('cat',
1402 @command('cat',
1402 [('o', 'output', '',
1403 [('o', 'output', '',
General Comments 0
You need to be logged in to leave comments. Login now