Mercurial > hg
annotate mercurial/bundlecaches.py @ 49056:7ea2bd2043d1
test: override default cipher selection when connecting to TLS 1.0/1.1 servers
The default set of ciphers on python 3.10 is incompatible with old TLS
versions.
Differential Revision: https://phab.mercurial-scm.org/D12490
author | Julien Cristau <jcristau@debian.org> |
---|---|
date | Sat, 09 Apr 2022 14:28:17 +0200 |
parents | 642e31cb55f0 |
children | c12c843f0db7 |
rev | line source |
---|---|
45784
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
1 # bundlecaches.py - utility to deal with pre-computed bundle for servers |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
2 # |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
3 # This software may be used and distributed according to the terms of the |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
4 # GNU General Public License version 2 or any later version. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
5 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
6 from .i18n import _ |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
7 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
8 from .thirdparty import attr |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
9 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
10 from . import ( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
11 error, |
46627
f4c325bf80fc
requirements: also add a generaldelta constant
Raphaël Gomès <rgomes@octobus.net>
parents:
45785
diff
changeset
|
12 requirements as requirementsmod, |
45784
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
13 sslutil, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
14 util, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
15 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
16 from .utils import stringutil |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
17 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
18 urlreq = util.urlreq |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
19 |
45785
80f32ec8653a
clonebundle: move the manifest filename to a constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45784
diff
changeset
|
20 CB_MANIFEST_FILE = b'clonebundles.manifest' |
80f32ec8653a
clonebundle: move the manifest filename to a constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45784
diff
changeset
|
21 |
45784
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
22 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
23 @attr.s |
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48601
diff
changeset
|
24 class bundlespec: |
45784
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
25 compression = attr.ib() |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
26 wirecompression = attr.ib() |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
27 version = attr.ib() |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
28 wireversion = attr.ib() |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
29 params = attr.ib() |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
30 contentopts = attr.ib() |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
31 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
32 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
33 # Maps bundle version human names to changegroup versions. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
34 _bundlespeccgversions = { |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
35 b'v1': b'01', |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
36 b'v2': b'02', |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
37 b'packed1': b's1', |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
38 b'bundle2': b'02', # legacy |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
39 } |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
40 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
41 # Maps bundle version with content opts to choose which part to bundle |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
42 _bundlespeccontentopts = { |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
43 b'v1': { |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
44 b'changegroup': True, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
45 b'cg.version': b'01', |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
46 b'obsolescence': False, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
47 b'phases': False, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
48 b'tagsfnodescache': False, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
49 b'revbranchcache': False, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
50 }, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
51 b'v2': { |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
52 b'changegroup': True, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
53 b'cg.version': b'02', |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
54 b'obsolescence': False, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
55 b'phases': False, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
56 b'tagsfnodescache': True, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
57 b'revbranchcache': True, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
58 }, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
59 b'packed1': {b'cg.version': b's1'}, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
60 } |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
61 _bundlespeccontentopts[b'bundle2'] = _bundlespeccontentopts[b'v2'] |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
62 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
63 _bundlespecvariants = { |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
64 b"streamv2": { |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
65 b"changegroup": False, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
66 b"streamv2": True, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
67 b"tagsfnodescache": False, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
68 b"revbranchcache": False, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
69 } |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
70 } |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
71 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
72 # Compression engines allowed in version 1. THIS SHOULD NEVER CHANGE. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
73 _bundlespecv1compengines = {b'gzip', b'bzip2', b'none'} |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
74 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
75 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
76 def parsebundlespec(repo, spec, strict=True): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
77 """Parse a bundle string specification into parts. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
78 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
79 Bundle specifications denote a well-defined bundle/exchange format. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
80 The content of a given specification should not change over time in |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
81 order to ensure that bundles produced by a newer version of Mercurial are |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
82 readable from an older version. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
83 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
84 The string currently has the form: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
85 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
86 <compression>-<type>[;<parameter0>[;<parameter1>]] |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
87 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
88 Where <compression> is one of the supported compression formats |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
89 and <type> is (currently) a version string. A ";" can follow the type and |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
90 all text afterwards is interpreted as URI encoded, ";" delimited key=value |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
91 pairs. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
92 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
93 If ``strict`` is True (the default) <compression> is required. Otherwise, |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
94 it is optional. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
95 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
96 Returns a bundlespec object of (compression, version, parameters). |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
97 Compression will be ``None`` if not in strict mode and a compression isn't |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
98 defined. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
99 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
100 An ``InvalidBundleSpecification`` is raised when the specification is |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
101 not syntactically well formed. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
102 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
103 An ``UnsupportedBundleSpecification`` is raised when the compression or |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
104 bundle type/version is not recognized. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
105 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
106 Note: this function will likely eventually return a more complex data |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
107 structure, including bundle2 part information. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
108 """ |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
109 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
110 def parseparams(s): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
111 if b';' not in s: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
112 return s, {} |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
113 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
114 params = {} |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
115 version, paramstr = s.split(b';', 1) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
116 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
117 for p in paramstr.split(b';'): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
118 if b'=' not in p: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
119 raise error.InvalidBundleSpecification( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
120 _( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
121 b'invalid bundle specification: ' |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
122 b'missing "=" in parameter: %s' |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
123 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
124 % p |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
125 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
126 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
127 key, value = p.split(b'=', 1) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
128 key = urlreq.unquote(key) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
129 value = urlreq.unquote(value) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
130 params[key] = value |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
131 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
132 return version, params |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
133 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
134 if strict and b'-' not in spec: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
135 raise error.InvalidBundleSpecification( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
136 _( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
137 b'invalid bundle specification; ' |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
138 b'must be prefixed with compression: %s' |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
139 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
140 % spec |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
141 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
142 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
143 if b'-' in spec: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
144 compression, version = spec.split(b'-', 1) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
145 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
146 if compression not in util.compengines.supportedbundlenames: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
147 raise error.UnsupportedBundleSpecification( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
148 _(b'%s compression is not supported') % compression |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
149 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
150 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
151 version, params = parseparams(version) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
152 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
153 if version not in _bundlespeccgversions: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
154 raise error.UnsupportedBundleSpecification( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
155 _(b'%s is not a recognized bundle version') % version |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
156 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
157 else: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
158 # Value could be just the compression or just the version, in which |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
159 # case some defaults are assumed (but only when not in strict mode). |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
160 assert not strict |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
161 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
162 spec, params = parseparams(spec) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
163 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
164 if spec in util.compengines.supportedbundlenames: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
165 compression = spec |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
166 version = b'v1' |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
167 # Generaldelta repos require v2. |
46627
f4c325bf80fc
requirements: also add a generaldelta constant
Raphaël Gomès <rgomes@octobus.net>
parents:
45785
diff
changeset
|
168 if requirementsmod.GENERALDELTA_REQUIREMENT in repo.requirements: |
45784
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
169 version = b'v2' |
47342
dc3800569157
revlogv2: make sure bundling pick a compatible bundle format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46627
diff
changeset
|
170 elif requirementsmod.REVLOGV2_REQUIREMENT in repo.requirements: |
dc3800569157
revlogv2: make sure bundling pick a compatible bundle format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46627
diff
changeset
|
171 version = b'v2' |
45784
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
172 # Modern compression engines require v2. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
173 if compression not in _bundlespecv1compengines: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
174 version = b'v2' |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
175 elif spec in _bundlespeccgversions: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
176 if spec == b'packed1': |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
177 compression = b'none' |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
178 else: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
179 compression = b'bzip2' |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
180 version = spec |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
181 else: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
182 raise error.UnsupportedBundleSpecification( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
183 _(b'%s is not a recognized bundle specification') % spec |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
184 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
185 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
186 # Bundle version 1 only supports a known set of compression engines. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
187 if version == b'v1' and compression not in _bundlespecv1compengines: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
188 raise error.UnsupportedBundleSpecification( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
189 _(b'compression engine %s is not supported on v1 bundles') |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
190 % compression |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
191 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
192 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
193 # The specification for packed1 can optionally declare the data formats |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
194 # required to apply it. If we see this metadata, compare against what the |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
195 # repo supports and error if the bundle isn't compatible. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
196 if version == b'packed1' and b'requirements' in params: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
197 requirements = set(params[b'requirements'].split(b',')) |
48601
baddab229b86
stream-clone: add a explicit set list requirements relevant to stream clone
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47342
diff
changeset
|
198 missingreqs = requirements - requirementsmod.STREAM_FIXED_REQUIREMENTS |
45784
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
199 if missingreqs: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
200 raise error.UnsupportedBundleSpecification( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
201 _(b'missing support for repository features: %s') |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
202 % b', '.join(sorted(missingreqs)) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
203 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
204 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
205 # Compute contentopts based on the version |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
206 contentopts = _bundlespeccontentopts.get(version, {}).copy() |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
207 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
208 # Process the variants |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
209 if b"stream" in params and params[b"stream"] == b"v2": |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
210 variant = _bundlespecvariants[b"streamv2"] |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
211 contentopts.update(variant) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
212 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
213 engine = util.compengines.forbundlename(compression) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
214 compression, wirecompression = engine.bundletype() |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
215 wireversion = _bundlespeccgversions[version] |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
216 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
217 return bundlespec( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
218 compression, wirecompression, version, wireversion, params, contentopts |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
219 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
220 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
221 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
222 def parseclonebundlesmanifest(repo, s): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
223 """Parses the raw text of a clone bundles manifest. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
224 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
225 Returns a list of dicts. The dicts have a ``URL`` key corresponding |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
226 to the URL and other keys are the attributes for the entry. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
227 """ |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
228 m = [] |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
229 for line in s.splitlines(): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
230 fields = line.split() |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
231 if not fields: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
232 continue |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
233 attrs = {b'URL': fields[0]} |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
234 for rawattr in fields[1:]: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
235 key, value = rawattr.split(b'=', 1) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
236 key = util.urlreq.unquote(key) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
237 value = util.urlreq.unquote(value) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
238 attrs[key] = value |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
239 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
240 # Parse BUNDLESPEC into components. This makes client-side |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
241 # preferences easier to specify since you can prefer a single |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
242 # component of the BUNDLESPEC. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
243 if key == b'BUNDLESPEC': |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
244 try: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
245 bundlespec = parsebundlespec(repo, value) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
246 attrs[b'COMPRESSION'] = bundlespec.compression |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
247 attrs[b'VERSION'] = bundlespec.version |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
248 except error.InvalidBundleSpecification: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
249 pass |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
250 except error.UnsupportedBundleSpecification: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
251 pass |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
252 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
253 m.append(attrs) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
254 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
255 return m |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
256 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
257 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
258 def isstreamclonespec(bundlespec): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
259 # Stream clone v1 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
260 if bundlespec.wirecompression == b'UN' and bundlespec.wireversion == b's1': |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
261 return True |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
262 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
263 # Stream clone v2 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
264 if ( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
265 bundlespec.wirecompression == b'UN' |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
266 and bundlespec.wireversion == b'02' |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
267 and bundlespec.contentopts.get(b'streamv2') |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
268 ): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
269 return True |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
270 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
271 return False |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
272 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
273 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
274 def filterclonebundleentries(repo, entries, streamclonerequested=False): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
275 """Remove incompatible clone bundle manifest entries. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
276 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
277 Accepts a list of entries parsed with ``parseclonebundlesmanifest`` |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
278 and returns a new list consisting of only the entries that this client |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
279 should be able to apply. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
280 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
281 There is no guarantee we'll be able to apply all returned entries because |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
282 the metadata we use to filter on may be missing or wrong. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
283 """ |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
284 newentries = [] |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
285 for entry in entries: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
286 spec = entry.get(b'BUNDLESPEC') |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
287 if spec: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
288 try: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
289 bundlespec = parsebundlespec(repo, spec, strict=True) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
290 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
291 # If a stream clone was requested, filter out non-streamclone |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
292 # entries. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
293 if streamclonerequested and not isstreamclonespec(bundlespec): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
294 repo.ui.debug( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
295 b'filtering %s because not a stream clone\n' |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
296 % entry[b'URL'] |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
297 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
298 continue |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
299 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
300 except error.InvalidBundleSpecification as e: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
301 repo.ui.debug(stringutil.forcebytestr(e) + b'\n') |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
302 continue |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
303 except error.UnsupportedBundleSpecification as e: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
304 repo.ui.debug( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
305 b'filtering %s because unsupported bundle ' |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
306 b'spec: %s\n' % (entry[b'URL'], stringutil.forcebytestr(e)) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
307 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
308 continue |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
309 # If we don't have a spec and requested a stream clone, we don't know |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
310 # what the entry is so don't attempt to apply it. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
311 elif streamclonerequested: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
312 repo.ui.debug( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
313 b'filtering %s because cannot determine if a stream ' |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
314 b'clone bundle\n' % entry[b'URL'] |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
315 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
316 continue |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
317 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
318 if b'REQUIRESNI' in entry and not sslutil.hassni: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
319 repo.ui.debug( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
320 b'filtering %s because SNI not supported\n' % entry[b'URL'] |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
321 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
322 continue |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
323 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
324 if b'REQUIREDRAM' in entry: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
325 try: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
326 requiredram = util.sizetoint(entry[b'REQUIREDRAM']) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
327 except error.ParseError: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
328 repo.ui.debug( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
329 b'filtering %s due to a bad REQUIREDRAM attribute\n' |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
330 % entry[b'URL'] |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
331 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
332 continue |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
333 actualram = repo.ui.estimatememory() |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
334 if actualram is not None and actualram * 0.66 < requiredram: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
335 repo.ui.debug( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
336 b'filtering %s as it needs more than 2/3 of system memory\n' |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
337 % entry[b'URL'] |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
338 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
339 continue |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
340 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
341 newentries.append(entry) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
342 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
343 return newentries |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
344 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
345 |
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48601
diff
changeset
|
346 class clonebundleentry: |
45784
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
347 """Represents an item in a clone bundles manifest. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
348 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
349 This rich class is needed to support sorting since sorted() in Python 3 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
350 doesn't support ``cmp`` and our comparison is complex enough that ``key=`` |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
351 won't work. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
352 """ |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
353 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
354 def __init__(self, value, prefers): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
355 self.value = value |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
356 self.prefers = prefers |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
357 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
358 def _cmp(self, other): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
359 for prefkey, prefvalue in self.prefers: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
360 avalue = self.value.get(prefkey) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
361 bvalue = other.value.get(prefkey) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
362 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
363 # Special case for b missing attribute and a matches exactly. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
364 if avalue is not None and bvalue is None and avalue == prefvalue: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
365 return -1 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
366 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
367 # Special case for a missing attribute and b matches exactly. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
368 if bvalue is not None and avalue is None and bvalue == prefvalue: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
369 return 1 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
370 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
371 # We can't compare unless attribute present on both. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
372 if avalue is None or bvalue is None: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
373 continue |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
374 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
375 # Same values should fall back to next attribute. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
376 if avalue == bvalue: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
377 continue |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
378 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
379 # Exact matches come first. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
380 if avalue == prefvalue: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
381 return -1 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
382 if bvalue == prefvalue: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
383 return 1 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
384 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
385 # Fall back to next attribute. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
386 continue |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
387 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
388 # If we got here we couldn't sort by attributes and prefers. Fall |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
389 # back to index order. |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
390 return 0 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
391 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
392 def __lt__(self, other): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
393 return self._cmp(other) < 0 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
394 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
395 def __gt__(self, other): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
396 return self._cmp(other) > 0 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
397 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
398 def __eq__(self, other): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
399 return self._cmp(other) == 0 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
400 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
401 def __le__(self, other): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
402 return self._cmp(other) <= 0 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
403 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
404 def __ge__(self, other): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
405 return self._cmp(other) >= 0 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
406 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
407 def __ne__(self, other): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
408 return self._cmp(other) != 0 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
409 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
410 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
411 def sortclonebundleentries(ui, entries): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
412 prefers = ui.configlist(b'ui', b'clonebundleprefers') |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
413 if not prefers: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
414 return list(entries) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
415 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
416 def _split(p): |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
417 if b'=' not in p: |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
418 hint = _(b"each comma separated item should be key=value pairs") |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
419 raise error.Abort( |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
420 _(b"invalid ui.clonebundleprefers item: %s") % p, hint=hint |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
421 ) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
422 return p.split(b'=', 1) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
423 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
424 prefers = [_split(p) for p in prefers] |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
425 |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
426 items = sorted(clonebundleentry(v, prefers) for v in entries) |
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
427 return [i.value for i in items] |