equal
deleted
inserted
replaced
6 # GNU General Public License version 2 or any later version. |
6 # GNU General Public License version 2 or any later version. |
7 |
7 |
8 from __future__ import absolute_import |
8 from __future__ import absolute_import |
9 |
9 |
10 import errno |
10 import errno |
11 import urllib |
|
12 import urllib2 |
|
13 |
11 |
14 from .i18n import _ |
12 from .i18n import _ |
15 from .node import ( |
13 from .node import ( |
16 hex, |
14 hex, |
17 nullid, |
15 nullid, |
33 tags, |
31 tags, |
34 url as urlmod, |
32 url as urlmod, |
35 util, |
33 util, |
36 ) |
34 ) |
37 |
35 |
|
36 urlerr = util.urlerr |
|
37 urlreq = util.urlreq |
|
38 |
38 # Maps bundle compression human names to internal representation. |
39 # Maps bundle compression human names to internal representation. |
39 _bundlespeccompressions = {'none': None, |
40 _bundlespeccompressions = {'none': None, |
40 'bzip2': 'BZ', |
41 'bzip2': 'BZ', |
41 'gzip': 'GZ', |
42 'gzip': 'GZ', |
42 } |
43 } |
95 raise error.InvalidBundleSpecification( |
96 raise error.InvalidBundleSpecification( |
96 _('invalid bundle specification: ' |
97 _('invalid bundle specification: ' |
97 'missing "=" in parameter: %s') % p) |
98 'missing "=" in parameter: %s') % p) |
98 |
99 |
99 key, value = p.split('=', 1) |
100 key, value = p.split('=', 1) |
100 key = urllib.unquote(key) |
101 key = urlreq.unquote(key) |
101 value = urllib.unquote(value) |
102 value = urlreq.unquote(value) |
102 params[key] = value |
103 params[key] = value |
103 |
104 |
104 return version, params |
105 return version, params |
105 |
106 |
106 |
107 |
234 |
235 |
235 return '%s-%s' % (comp, version) |
236 return '%s-%s' % (comp, version) |
236 elif isinstance(b, streamclone.streamcloneapplier): |
237 elif isinstance(b, streamclone.streamcloneapplier): |
237 requirements = streamclone.readbundle1header(fh)[2] |
238 requirements = streamclone.readbundle1header(fh)[2] |
238 params = 'requirements=%s' % ','.join(sorted(requirements)) |
239 params = 'requirements=%s' % ','.join(sorted(requirements)) |
239 return 'none-packed1;%s' % urllib.quote(params) |
240 return 'none-packed1;%s' % urlreq.quote(params) |
240 else: |
241 else: |
241 raise error.Abort(_('unknown bundle type: %s') % b) |
242 raise error.Abort(_('unknown bundle type: %s') % b) |
242 |
243 |
243 def buildobsmarkerspart(bundler, markers): |
244 def buildobsmarkerspart(bundler, markers): |
244 """add an obsmarker part to the bundler with <markers> |
245 """add an obsmarker part to the bundler with <markers> |
1463 |
1464 |
1464 def caps20to10(repo): |
1465 def caps20to10(repo): |
1465 """return a set with appropriate options to use bundle20 during getbundle""" |
1466 """return a set with appropriate options to use bundle20 during getbundle""" |
1466 caps = set(['HG20']) |
1467 caps = set(['HG20']) |
1467 capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo)) |
1468 capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo)) |
1468 caps.add('bundle2=' + urllib.quote(capsblob)) |
1469 caps.add('bundle2=' + urlreq.quote(capsblob)) |
1469 return caps |
1470 return caps |
1470 |
1471 |
1471 # List of names of steps to perform for a bundle2 for getbundle, order matters. |
1472 # List of names of steps to perform for a bundle2 for getbundle, order matters. |
1472 getbundle2partsorder = [] |
1473 getbundle2partsorder = [] |
1473 |
1474 |
1529 |
1530 |
1530 # bundle20 case |
1531 # bundle20 case |
1531 b2caps = {} |
1532 b2caps = {} |
1532 for bcaps in bundlecaps: |
1533 for bcaps in bundlecaps: |
1533 if bcaps.startswith('bundle2='): |
1534 if bcaps.startswith('bundle2='): |
1534 blob = urllib.unquote(bcaps[len('bundle2='):]) |
1535 blob = urlreq.unquote(bcaps[len('bundle2='):]) |
1535 b2caps.update(bundle2.decodecaps(blob)) |
1536 b2caps.update(bundle2.decodecaps(blob)) |
1536 bundler = bundle2.bundle20(repo.ui, b2caps) |
1537 bundler = bundle2.bundle20(repo.ui, b2caps) |
1537 |
1538 |
1538 kwargs['heads'] = heads |
1539 kwargs['heads'] = heads |
1539 kwargs['common'] = common |
1540 kwargs['common'] = common |
1798 if not fields: |
1799 if not fields: |
1799 continue |
1800 continue |
1800 attrs = {'URL': fields[0]} |
1801 attrs = {'URL': fields[0]} |
1801 for rawattr in fields[1:]: |
1802 for rawattr in fields[1:]: |
1802 key, value = rawattr.split('=', 1) |
1803 key, value = rawattr.split('=', 1) |
1803 key = urllib.unquote(key) |
1804 key = urlreq.unquote(key) |
1804 value = urllib.unquote(value) |
1805 value = urlreq.unquote(value) |
1805 attrs[key] = value |
1806 attrs[key] = value |
1806 |
1807 |
1807 # Parse BUNDLESPEC into components. This makes client-side |
1808 # Parse BUNDLESPEC into components. This makes client-side |
1808 # preferences easier to specify since you can prefer a single |
1809 # preferences easier to specify since you can prefer a single |
1809 # component of the BUNDLESPEC. |
1810 # component of the BUNDLESPEC. |
1915 cg.apply(repo) |
1916 cg.apply(repo) |
1916 else: |
1917 else: |
1917 cg.apply(repo, 'clonebundles', url) |
1918 cg.apply(repo, 'clonebundles', url) |
1918 tr.close() |
1919 tr.close() |
1919 return True |
1920 return True |
1920 except urllib2.HTTPError as e: |
1921 except urlerr.httperror as e: |
1921 ui.warn(_('HTTP error fetching bundle: %s\n') % str(e)) |
1922 ui.warn(_('HTTP error fetching bundle: %s\n') % str(e)) |
1922 except urllib2.URLError as e: |
1923 except urlerr.urlerror as e: |
1923 ui.warn(_('error fetching bundle: %s\n') % e.reason[1]) |
1924 ui.warn(_('error fetching bundle: %s\n') % e.reason[1]) |
1924 |
1925 |
1925 return False |
1926 return False |
1926 finally: |
1927 finally: |
1927 tr.release() |
1928 tr.release() |