Show More
@@ -1199,12 +1199,12 b' def bundle(ui, repo, fname, dest=None, *' | |||||
1199 |
|
1199 | |||
1200 | bundletype = opts.get('type', 'bzip2').lower() |
|
1200 | bundletype = opts.get('type', 'bzip2').lower() | |
1201 | try: |
|
1201 | try: | |
1202 | bcompression, cgversion, params = exchange.parsebundlespec( |
|
1202 | bundlespec = exchange.parsebundlespec(repo, bundletype, strict=False) | |
1203 | repo, bundletype, strict=False) |
|
|||
1204 | except error.UnsupportedBundleSpecification as e: |
|
1203 | except error.UnsupportedBundleSpecification as e: | |
1205 | raise error.Abort(pycompat.bytestr(e), |
|
1204 | raise error.Abort(pycompat.bytestr(e), | |
1206 | hint=_("see 'hg help bundlespec' for supported " |
|
1205 | hint=_("see 'hg help bundlespec' for supported " | |
1207 | "values for --type")) |
|
1206 | "values for --type")) | |
|
1207 | cgversion = bundlespec.version | |||
1208 |
|
1208 | |||
1209 | # Packed bundles are a pseudo bundle format for now. |
|
1209 | # Packed bundles are a pseudo bundle format for now. | |
1210 | if cgversion == 's1': |
|
1210 | if cgversion == 's1': | |
@@ -1246,6 +1246,7 b' def bundle(ui, repo, fname, dest=None, *' | |||||
1246 | scmutil.nochangesfound(ui, repo, not base and outgoing.excluded) |
|
1246 | scmutil.nochangesfound(ui, repo, not base and outgoing.excluded) | |
1247 | return 1 |
|
1247 | return 1 | |
1248 |
|
1248 | |||
|
1249 | bcompression = bundlespec.compression | |||
1249 | if cgversion == '01': #bundle1 |
|
1250 | if cgversion == '01': #bundle1 | |
1250 | if bcompression is None: |
|
1251 | if bcompression is None: | |
1251 | bcompression = 'UN' |
|
1252 | bcompression = 'UN' |
@@ -17,6 +17,9 b' from .node import (' | |||||
17 | hex, |
|
17 | hex, | |
18 | nullid, |
|
18 | nullid, | |
19 | ) |
|
19 | ) | |
|
20 | from .thirdparty import ( | |||
|
21 | attr, | |||
|
22 | ) | |||
20 | from . import ( |
|
23 | from . import ( | |
21 | bookmarks as bookmod, |
|
24 | bookmarks as bookmod, | |
22 | bundle2, |
|
25 | bundle2, | |
@@ -52,6 +55,12 b' urlreq = util.urlreq' | |||||
52 | # Compression engines allowed in version 1. THIS SHOULD NEVER CHANGE. |
|
55 | # Compression engines allowed in version 1. THIS SHOULD NEVER CHANGE. | |
53 | _bundlespecv1compengines = {'gzip', 'bzip2', 'none'} |
|
56 | _bundlespecv1compengines = {'gzip', 'bzip2', 'none'} | |
54 |
|
57 | |||
|
58 | @attr.s | |||
|
59 | class bundlespec(object): | |||
|
60 | compression = attr.ib() | |||
|
61 | version = attr.ib() | |||
|
62 | params = attr.ib() | |||
|
63 | ||||
55 | def parsebundlespec(repo, spec, strict=True, externalnames=False): |
|
64 | def parsebundlespec(repo, spec, strict=True, externalnames=False): | |
56 | """Parse a bundle string specification into parts. |
|
65 | """Parse a bundle string specification into parts. | |
57 |
|
66 | |||
@@ -75,8 +84,9 b' def parsebundlespec(repo, spec, strict=T' | |||||
75 | If ``externalnames`` is False (the default), the human-centric names will |
|
84 | If ``externalnames`` is False (the default), the human-centric names will | |
76 | be converted to their internal representation. |
|
85 | be converted to their internal representation. | |
77 |
|
86 | |||
78 |
Returns a |
|
87 | Returns a bundlespec object of (compression, version, parameters). | |
79 |
be ``None`` if not in strict mode and a compression isn't |
|
88 | Compression will be ``None`` if not in strict mode and a compression isn't | |
|
89 | defined. | |||
80 |
|
90 | |||
81 | An ``InvalidBundleSpecification`` is raised when the specification is |
|
91 | An ``InvalidBundleSpecification`` is raised when the specification is | |
82 | not syntactically well formed. |
|
92 | not syntactically well formed. | |
@@ -172,7 +182,8 b' def parsebundlespec(repo, spec, strict=T' | |||||
172 | engine = util.compengines.forbundlename(compression) |
|
182 | engine = util.compengines.forbundlename(compression) | |
173 | compression = engine.bundletype()[1] |
|
183 | compression = engine.bundletype()[1] | |
174 | version = _bundlespeccgversions[version] |
|
184 | version = _bundlespeccgversions[version] | |
175 | return compression, version, params |
|
185 | ||
|
186 | return bundlespec(compression, version, params) | |||
176 |
|
187 | |||
177 | def readbundle(ui, fh, fname, vfs=None): |
|
188 | def readbundle(ui, fh, fname, vfs=None): | |
178 | header = changegroup.readexactly(fh, 4) |
|
189 | header = changegroup.readexactly(fh, 4) | |
@@ -2140,10 +2151,10 b' def parseclonebundlesmanifest(repo, s):' | |||||
2140 | # component of the BUNDLESPEC. |
|
2151 | # component of the BUNDLESPEC. | |
2141 | if key == 'BUNDLESPEC': |
|
2152 | if key == 'BUNDLESPEC': | |
2142 | try: |
|
2153 | try: | |
2143 |
|
|
2154 | bundlespec = parsebundlespec(repo, value, | |
2144 |
|
|
2155 | externalnames=True) | |
2145 | attrs['COMPRESSION'] = comp |
|
2156 | attrs['COMPRESSION'] = bundlespec.compression | |
2146 | attrs['VERSION'] = version |
|
2157 | attrs['VERSION'] = bundlespec.version | |
2147 | except error.InvalidBundleSpecification: |
|
2158 | except error.InvalidBundleSpecification: | |
2148 | pass |
|
2159 | pass | |
2149 | except error.UnsupportedBundleSpecification: |
|
2160 | except error.UnsupportedBundleSpecification: | |
@@ -2168,10 +2179,12 b' def filterclonebundleentries(repo, entri' | |||||
2168 | spec = entry.get('BUNDLESPEC') |
|
2179 | spec = entry.get('BUNDLESPEC') | |
2169 | if spec: |
|
2180 | if spec: | |
2170 | try: |
|
2181 | try: | |
2171 |
|
|
2182 | bundlespec = parsebundlespec(repo, spec, strict=True) | |
2172 |
|
2183 | |||
2173 | # If a stream clone was requested, filter out non-streamclone |
|
2184 | # If a stream clone was requested, filter out non-streamclone | |
2174 | # entries. |
|
2185 | # entries. | |
|
2186 | comp = bundlespec.compression | |||
|
2187 | version = bundlespec.version | |||
2175 | if streamclonerequested and (comp != 'UN' or version != 's1'): |
|
2188 | if streamclonerequested and (comp != 'UN' or version != 's1'): | |
2176 | repo.ui.debug('filtering %s because not a stream clone\n' % |
|
2189 | repo.ui.debug('filtering %s because not a stream clone\n' % | |
2177 | entry['URL']) |
|
2190 | entry['URL']) |
General Comments 0
You need to be logged in to leave comments.
Login now