3364 msg = (_("can't release already inactivated backup:" |
3364 msg = (_("can't release already inactivated backup:" |
3365 " dirstate%s") |
3365 " dirstate%s") |
3366 % self._suffix) |
3366 % self._suffix) |
3367 raise error.Abort(msg) |
3367 raise error.Abort(msg) |
3368 self._abort() |
3368 self._abort() |
3369 |
|
3370 _bundlecompspecs = {'none': None, |
|
3371 'bzip2': 'BZ', |
|
3372 'gzip': 'GZ', |
|
3373 } |
|
3374 |
|
3375 _bundleversionspecs = {'v1': '01', |
|
3376 'v2': '02', |
|
3377 'bundle2': '02', #legacy |
|
3378 } |
|
3379 |
|
3380 def parsebundletype(repo, spec): |
|
3381 """return the internal bundle type to use from a user input |
|
3382 |
|
3383 This is parsing user specified bundle type as accepted in: |
|
3384 |
|
3385 'hg bundle --type TYPE'. |
|
3386 |
|
3387 It accept format in the form [compression][-version]|[version] |
|
3388 |
|
3389 Consensus about extensions of the format for various bundle2 feature |
|
3390 is to prefix any feature with "+". eg "+treemanifest" or "gzip+phases" |
|
3391 """ |
|
3392 comp, version = None, None |
|
3393 |
|
3394 if '-' in spec: |
|
3395 comp, version = spec.split('-', 1) |
|
3396 elif spec in _bundlecompspecs: |
|
3397 comp = spec |
|
3398 elif spec in _bundleversionspecs: |
|
3399 version = spec |
|
3400 else: |
|
3401 raise error.Abort(_('unknown bundle type specified with --type')) |
|
3402 |
|
3403 if comp is None: |
|
3404 comp = 'BZ' |
|
3405 else: |
|
3406 try: |
|
3407 comp = _bundlecompspecs[comp] |
|
3408 except KeyError: |
|
3409 raise error.Abort(_('unknown bundle type specified with --type')) |
|
3410 |
|
3411 if version is None: |
|
3412 version = '01' |
|
3413 if 'generaldelta' in repo.requirements: |
|
3414 version = '02' |
|
3415 else: |
|
3416 try: |
|
3417 version = _bundleversionspecs[version] |
|
3418 except KeyError: |
|
3419 raise error.Abort(_('unknown bundle type specified with --type')) |
|
3420 |
|
3421 return version, comp |
|