Mercurial > hg
comparison mercurial/commands.py @ 26531:15ce78517d4b
bundle: extend the format of --type to support version and compression
We had some basic undocumented support for uncompressed bundle2 support. We now
have an official extensible syntax to specify both format type and compression
(eg: bzip2-v2).
In practice, this changeset introduce the 'v1' and 'v2' identifier to make it
possible to combine format and compression. The default format is still 'v1'.
We'll care about picking 'v1' or 'v2' in regard with general delta in the next
changesets.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 01 Oct 2015 19:16:00 -0700 |
parents | 77c13f3c01ca |
children | 3e61b325e79a |
comparison
equal
deleted
inserted
replaced
26530:52642e12e7b3 | 26531:15ce78517d4b |
---|---|
1217 If you omit the destination repository, then hg assumes the | 1217 If you omit the destination repository, then hg assumes the |
1218 destination will have all the nodes you specify with --base | 1218 destination will have all the nodes you specify with --base |
1219 parameters. To create a bundle containing all changesets, use | 1219 parameters. To create a bundle containing all changesets, use |
1220 -a/--all (or --base null). | 1220 -a/--all (or --base null). |
1221 | 1221 |
1222 You can change compression method with the -t/--type option. | 1222 You can change bundle format with the -t/--type option. You can |
1223 The available compression methods are: none, bzip2, and | 1223 specify a compression, a bundle version or both using a dash |
1224 gzip (by default, bundles are compressed using bzip2). | 1224 (comp-version). The available compression methods are: none, bzip2, |
1225 and gzip (by default, bundles are compressed using bzip2). The | |
1226 available format are: v1, v2 (default to v1). | |
1225 | 1227 |
1226 The bundle file can then be transferred using conventional means | 1228 The bundle file can then be transferred using conventional means |
1227 and applied to another repository with the unbundle or pull | 1229 and applied to another repository with the unbundle or pull |
1228 command. This is useful when direct push and pull are not | 1230 command. This is useful when direct push and pull are not |
1229 available or when exporting an entire repository is undesirable. | 1231 available or when exporting an entire repository is undesirable. |
1236 revs = None | 1238 revs = None |
1237 if 'rev' in opts: | 1239 if 'rev' in opts: |
1238 revs = scmutil.revrange(repo, opts['rev']) | 1240 revs = scmutil.revrange(repo, opts['rev']) |
1239 | 1241 |
1240 bundletype = opts.get('type', 'bzip2').lower() | 1242 bundletype = opts.get('type', 'bzip2').lower() |
1241 bundletype = cmdutil.parsebundletype(bundletype) | 1243 cgversion, bcompression = cmdutil.parsebundletype(repo, bundletype) |
1242 | 1244 |
1243 if opts.get('all'): | 1245 if opts.get('all'): |
1244 base = ['null'] | 1246 base = ['null'] |
1245 else: | 1247 else: |
1246 base = scmutil.revrange(repo, opts.get('base')) | 1248 base = scmutil.revrange(repo, opts.get('base')) |
1251 raise util.Abort(_("--base is incompatible with specifying " | 1253 raise util.Abort(_("--base is incompatible with specifying " |
1252 "a destination")) | 1254 "a destination")) |
1253 common = [repo.lookup(rev) for rev in base] | 1255 common = [repo.lookup(rev) for rev in base] |
1254 heads = revs and map(repo.lookup, revs) or revs | 1256 heads = revs and map(repo.lookup, revs) or revs |
1255 cg = changegroup.getchangegroup(repo, 'bundle', heads=heads, | 1257 cg = changegroup.getchangegroup(repo, 'bundle', heads=heads, |
1256 common=common, bundlecaps=bundlecaps) | 1258 common=common, bundlecaps=bundlecaps, |
1259 version=cgversion) | |
1257 outgoing = None | 1260 outgoing = None |
1258 else: | 1261 else: |
1259 dest = ui.expandpath(dest or 'default-push', dest or 'default') | 1262 dest = ui.expandpath(dest or 'default-push', dest or 'default') |
1260 dest, branches = hg.parseurl(dest, opts.get('branch')) | 1263 dest, branches = hg.parseurl(dest, opts.get('branch')) |
1261 other = hg.peer(repo, opts, dest) | 1264 other = hg.peer(repo, opts, dest) |
1264 outgoing = discovery.findcommonoutgoing(repo, other, | 1267 outgoing = discovery.findcommonoutgoing(repo, other, |
1265 onlyheads=heads, | 1268 onlyheads=heads, |
1266 force=opts.get('force'), | 1269 force=opts.get('force'), |
1267 portable=True) | 1270 portable=True) |
1268 cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing, | 1271 cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing, |
1269 bundlecaps) | 1272 bundlecaps, version=cgversion) |
1270 if not cg: | 1273 if not cg: |
1271 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded) | 1274 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded) |
1272 return 1 | 1275 return 1 |
1273 | 1276 |
1274 changegroup.writebundle(ui, cg, fname, bundletype) | 1277 if cgversion == '01': #bundle1 |
1278 if bcompression is None: | |
1279 bcompression = 'UN' | |
1280 bversion = 'HG10' + bcompression | |
1281 bcompression = None | |
1282 else: | |
1283 assert cgversion == '02' | |
1284 bversion = 'HG20' | |
1285 | |
1286 | |
1287 changegroup.writebundle(ui, cg, fname, bversion, compression=bcompression) | |
1275 | 1288 |
1276 @command('cat', | 1289 @command('cat', |
1277 [('o', 'output', '', | 1290 [('o', 'output', '', |
1278 _('print output to file with formatted name'), _('FORMAT')), | 1291 _('print output to file with formatted name'), _('FORMAT')), |
1279 ('r', 'rev', '', _('print the given revision'), _('REV')), | 1292 ('r', 'rev', '', _('print the given revision'), _('REV')), |