Show More
@@ -3366,56 +3366,3 b' class dirstateguard(object):' | |||||
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 |
|
@@ -1242,7 +1242,7 b' def bundle(ui, repo, fname, dest=None, *' | |||||
1242 | revs = scmutil.revrange(repo, opts['rev']) |
|
1242 | revs = scmutil.revrange(repo, opts['rev']) | |
1243 |
|
1243 | |||
1244 | bundletype = opts.get('type', 'bzip2').lower() |
|
1244 | bundletype = opts.get('type', 'bzip2').lower() | |
1245 |
cgversion, bcompression = |
|
1245 | cgversion, bcompression = exchange.parsebundlespec(repo, bundletype) | |
1246 |
|
1246 | |||
1247 | if opts.get('all'): |
|
1247 | if opts.get('all'): | |
1248 | base = ['null'] |
|
1248 | base = ['null'] |
@@ -15,6 +15,59 b' import streamclone' | |||||
15 | import tags |
|
15 | import tags | |
16 | import url as urlmod |
|
16 | import url as urlmod | |
17 |
|
17 | |||
|
18 | _bundlecompspecs = {'none': None, | |||
|
19 | 'bzip2': 'BZ', | |||
|
20 | 'gzip': 'GZ', | |||
|
21 | } | |||
|
22 | ||||
|
23 | _bundleversionspecs = {'v1': '01', | |||
|
24 | 'v2': '02', | |||
|
25 | 'bundle2': '02', #legacy | |||
|
26 | } | |||
|
27 | ||||
|
28 | def parsebundlespec(repo, spec): | |||
|
29 | """return the internal bundle type to use from a user input | |||
|
30 | ||||
|
31 | This is parsing user specified bundle type as accepted in: | |||
|
32 | ||||
|
33 | 'hg bundle --type TYPE'. | |||
|
34 | ||||
|
35 | It accept format in the form [compression][-version]|[version] | |||
|
36 | ||||
|
37 | Consensus about extensions of the format for various bundle2 feature | |||
|
38 | is to prefix any feature with "+". eg "+treemanifest" or "gzip+phases" | |||
|
39 | """ | |||
|
40 | comp, version = None, None | |||
|
41 | ||||
|
42 | if '-' in spec: | |||
|
43 | comp, version = spec.split('-', 1) | |||
|
44 | elif spec in _bundlecompspecs: | |||
|
45 | comp = spec | |||
|
46 | elif spec in _bundleversionspecs: | |||
|
47 | version = spec | |||
|
48 | else: | |||
|
49 | raise error.Abort(_('unknown bundle type specified with --type')) | |||
|
50 | ||||
|
51 | if comp is None: | |||
|
52 | comp = 'BZ' | |||
|
53 | else: | |||
|
54 | try: | |||
|
55 | comp = _bundlecompspecs[comp] | |||
|
56 | except KeyError: | |||
|
57 | raise error.Abort(_('unknown bundle type specified with --type')) | |||
|
58 | ||||
|
59 | if version is None: | |||
|
60 | version = '01' | |||
|
61 | if 'generaldelta' in repo.requirements: | |||
|
62 | version = '02' | |||
|
63 | else: | |||
|
64 | try: | |||
|
65 | version = _bundleversionspecs[version] | |||
|
66 | except KeyError: | |||
|
67 | raise error.Abort(_('unknown bundle type specified with --type')) | |||
|
68 | ||||
|
69 | return version, comp | |||
|
70 | ||||
18 | def readbundle(ui, fh, fname, vfs=None): |
|
71 | def readbundle(ui, fh, fname, vfs=None): | |
19 | header = changegroup.readexactly(fh, 4) |
|
72 | header = changegroup.readexactly(fh, 4) | |
20 |
|
73 |
General Comments 0
You need to be logged in to leave comments.
Login now