Mercurial > hg
annotate mercurial/bundlerepo.py @ 52282:51a350a22d0c
branching: merge stable into default
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Wed, 20 Nov 2024 15:53:19 +0100 |
parents | cfd30df0f8e4 |
children |
rev | line source |
---|---|
8226
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
1 # bundlerepo.py - repository class for viewing uncompressed bundles |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
2 # |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
3 # Copyright 2006, 2007 Benoit Boissinot <bboissin@gmail.com> |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
4 # |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
7 |
8227
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
8 """Repository class for viewing uncompressed bundles. |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
9 |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
10 This provides a read-only repository interface to bundles as if they |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
11 were part of the actual repository. |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
12 """ |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
13 |
51863
f4733654f144
typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents:
51703
diff
changeset
|
14 from __future__ import annotations |
25920
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
15 |
51012
3470a39fb66b
revlog: adapt the `reading` check for `bundlerepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50928
diff
changeset
|
16 import contextlib |
25920
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
17 import os |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
18 import shutil |
51870
9d4ad05bc91c
typing: make `bundlerepository` subclass `localrepository` while type checking
Matt Harbison <matt_harbison@yahoo.com>
parents:
51863
diff
changeset
|
19 import typing |
25920
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
20 |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
21 from .i18n import _ |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
22 from .node import ( |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
23 hex, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
24 nullrev, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
25 ) |
25920
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
26 |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
27 from . import ( |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
28 bundle2, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
29 changegroup, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
30 changelog, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
31 cmdutil, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
32 discovery, |
39818
24e493ec2229
py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
39763
diff
changeset
|
33 encoding, |
25920
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
34 error, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
35 exchange, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
36 filelog, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
37 localrepo, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
38 manifest, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
39 mdiff, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
40 pathutil, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
41 phases, |
30519
20a42325fdef
py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30375
diff
changeset
|
42 pycompat, |
25920
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
43 revlog, |
47394
ac60a1366a49
revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47256
diff
changeset
|
44 revlogutils, |
25920
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
45 util, |
31240
5f68e7341ada
vfs: use 'vfs' module directly in 'mercurial.bundlerepo'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30924
diff
changeset
|
46 vfs as vfsmod, |
25920
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
47 ) |
46907
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46780
diff
changeset
|
48 from .utils import ( |
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46780
diff
changeset
|
49 urlutil, |
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46780
diff
changeset
|
50 ) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
51 |
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
52 from .revlogutils import ( |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
53 constants as revlog_constants, |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
54 ) |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
55 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
56 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
57 class bundlerevlog(revlog.revlog): |
51871
cfd30df0f8e4
bundlerepo: fix mismatches with repository and revlog classes
Matt Harbison <matt_harbison@yahoo.com>
parents:
51870
diff
changeset
|
58 def __init__( |
cfd30df0f8e4
bundlerepo: fix mismatches with repository and revlog classes
Matt Harbison <matt_harbison@yahoo.com>
parents:
51870
diff
changeset
|
59 self, opener: typing.Any, target, radix, cgunpacker, linkmapper |
cfd30df0f8e4
bundlerepo: fix mismatches with repository and revlog classes
Matt Harbison <matt_harbison@yahoo.com>
parents:
51870
diff
changeset
|
60 ): |
cfd30df0f8e4
bundlerepo: fix mismatches with repository and revlog classes
Matt Harbison <matt_harbison@yahoo.com>
parents:
51870
diff
changeset
|
61 # TODO: figure out real type of opener |
cfd30df0f8e4
bundlerepo: fix mismatches with repository and revlog classes
Matt Harbison <matt_harbison@yahoo.com>
parents:
51870
diff
changeset
|
62 # |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
63 # How it works: |
18410
de7dac2a58e8
bundlerepo: fix outdated comment
Mads Kiilerich <madski@unity3d.com>
parents:
18216
diff
changeset
|
64 # To retrieve a revision, we need to know the offset of the revision in |
de7dac2a58e8
bundlerepo: fix outdated comment
Mads Kiilerich <madski@unity3d.com>
parents:
18216
diff
changeset
|
65 # the bundle (an unbundle object). We store this offset in the index |
18643
cc28a84db8c9
bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents:
18568
diff
changeset
|
66 # (start). The base of the delta is stored in the base field. |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
67 # |
18410
de7dac2a58e8
bundlerepo: fix outdated comment
Mads Kiilerich <madski@unity3d.com>
parents:
18216
diff
changeset
|
68 # To differentiate a rev in the bundle from a rev in the revlog, we |
18643
cc28a84db8c9
bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents:
18568
diff
changeset
|
69 # check revision against repotiprev. |
31240
5f68e7341ada
vfs: use 'vfs' module directly in 'mercurial.bundlerepo'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30924
diff
changeset
|
70 opener = vfsmod.readonlyvfs(opener) |
47150
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47148
diff
changeset
|
71 revlog.revlog.__init__(self, opener, target=target, radix=radix) |
35076
90609be10891
bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35075
diff
changeset
|
72 self.bundle = cgunpacker |
6750
fb42030d79d6
add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents:
6647
diff
changeset
|
73 n = len(self) |
18643
cc28a84db8c9
bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents:
18568
diff
changeset
|
74 self.repotiprev = n - 1 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
75 self.bundlerevs = set() # used by 'bundle()' revset expression |
35076
90609be10891
bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35075
diff
changeset
|
76 for deltadata in cgunpacker.deltaiter(): |
46711
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46113
diff
changeset
|
77 node, p1, p2, cs, deltabase, delta, flags, sidedata = deltadata |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
78 |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
79 size = len(delta) |
35076
90609be10891
bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35075
diff
changeset
|
80 start = cgunpacker.tell() - size |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
81 |
43542
5f347567589b
index: use `index.has_node` in `bundlerepo.bundlerevlog`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43533
diff
changeset
|
82 if self.index.has_node(node): |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
83 # this can happen if two branches make the same change |
43564
698e11f7be6a
index: use `index.rev` in `bundlerepo.bundlerevlog`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43542
diff
changeset
|
84 self.bundlerevs.add(self.index.rev(node)) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
85 continue |
45814
88d5abec8f61
bundlerepo: don't insert index tuples with full nodes as linkrev
Joerg Sonnenberger <joerg@bec.de>
parents:
43564
diff
changeset
|
86 if cs == node: |
88d5abec8f61
bundlerepo: don't insert index tuples with full nodes as linkrev
Joerg Sonnenberger <joerg@bec.de>
parents:
43564
diff
changeset
|
87 linkrev = nullrev |
88d5abec8f61
bundlerepo: don't insert index tuples with full nodes as linkrev
Joerg Sonnenberger <joerg@bec.de>
parents:
43564
diff
changeset
|
88 else: |
88d5abec8f61
bundlerepo: don't insert index tuples with full nodes as linkrev
Joerg Sonnenberger <joerg@bec.de>
parents:
43564
diff
changeset
|
89 linkrev = linkmapper(cs) |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
90 |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
91 for p in (p1, p2): |
43542
5f347567589b
index: use `index.has_node` in `bundlerepo.bundlerevlog`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43533
diff
changeset
|
92 if not self.index.has_node(p): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
93 raise error.LookupError( |
47155
96ee8ca99f5a
revlog: use revlog.display_id in LookupError
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47150
diff
changeset
|
94 p, self.display_id, _(b"unknown parent") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
95 ) |
18416
87f370c5fef5
bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents:
18415
diff
changeset
|
96 |
43542
5f347567589b
index: use `index.has_node` in `bundlerepo.bundlerevlog`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43533
diff
changeset
|
97 if not self.index.has_node(deltabase): |
49975
562f7da122b5
bundlerepo: raise `error.LookupError` instead of `LookupError`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49972
diff
changeset
|
98 raise error.LookupError( |
47155
96ee8ca99f5a
revlog: use revlog.display_id in LookupError
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47150
diff
changeset
|
99 deltabase, self.display_id, _(b'unknown delta base') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
100 ) |
18416
87f370c5fef5
bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents:
18415
diff
changeset
|
101 |
87f370c5fef5
bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents:
18415
diff
changeset
|
102 baserev = self.rev(deltabase) |
47143
47ffc754989a
revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47072
diff
changeset
|
103 # start, size, full unc. size, base (unused), link, p1, p2, node, sidedata_offset (unused), sidedata_size (unused) |
47398
53289d02037a
revlog: use the `entry` function in bundlerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47394
diff
changeset
|
104 e = revlogutils.entry( |
53289d02037a
revlog: use the `entry` function in bundlerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47394
diff
changeset
|
105 flags=flags, |
53289d02037a
revlog: use the `entry` function in bundlerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47394
diff
changeset
|
106 data_offset=start, |
53289d02037a
revlog: use the `entry` function in bundlerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47394
diff
changeset
|
107 data_compressed_length=size, |
53289d02037a
revlog: use the `entry` function in bundlerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47394
diff
changeset
|
108 data_delta_base=baserev, |
53289d02037a
revlog: use the `entry` function in bundlerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47394
diff
changeset
|
109 link_rev=linkrev, |
53289d02037a
revlog: use the `entry` function in bundlerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47394
diff
changeset
|
110 parent_rev_1=self.rev(p1), |
53289d02037a
revlog: use the `entry` function in bundlerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47394
diff
changeset
|
111 parent_rev_2=self.rev(p2), |
53289d02037a
revlog: use the `entry` function in bundlerepo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47394
diff
changeset
|
112 node_id=node, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
113 ) |
38850
6104b203bec8
index: replace insert(-1, e) method by append(e) method
Martin von Zweigbergk <martinvonz@google.com>
parents:
38165
diff
changeset
|
114 self.index.append(e) |
18411
8b0f0dd56cec
bundlerepo: improve performance for bundle() revset expression
Mads Kiilerich <madski@unity3d.com>
parents:
18410
diff
changeset
|
115 self.bundlerevs.add(n) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
116 n += 1 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
117 |
51012
3470a39fb66b
revlog: adapt the `reading` check for `bundlerepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50928
diff
changeset
|
118 @contextlib.contextmanager |
3470a39fb66b
revlog: adapt the `reading` check for `bundlerepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50928
diff
changeset
|
119 def reading(self): |
3470a39fb66b
revlog: adapt the `reading` check for `bundlerepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50928
diff
changeset
|
120 if self.repotiprev < 0: |
3470a39fb66b
revlog: adapt the `reading` check for `bundlerepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50928
diff
changeset
|
121 yield |
3470a39fb66b
revlog: adapt the `reading` check for `bundlerepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50928
diff
changeset
|
122 else: |
3470a39fb66b
revlog: adapt the `reading` check for `bundlerepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50928
diff
changeset
|
123 with super().reading() as x: |
3470a39fb66b
revlog: adapt the `reading` check for `bundlerepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50928
diff
changeset
|
124 yield x |
3470a39fb66b
revlog: adapt the `reading` check for `bundlerepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50928
diff
changeset
|
125 |
51026
8520db304f01
revlog: drop more file description passing between private function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51012
diff
changeset
|
126 def _chunk(self, rev): |
18643
cc28a84db8c9
bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents:
18568
diff
changeset
|
127 # Warning: in case of bundle, the diff is against what we stored as |
cc28a84db8c9
bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents:
18568
diff
changeset
|
128 # delta base, not against rev - 1 |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
129 # XXX: could use some caching |
18643
cc28a84db8c9
bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents:
18568
diff
changeset
|
130 if rev <= self.repotiprev: |
51871
cfd30df0f8e4
bundlerepo: fix mismatches with repository and revlog classes
Matt Harbison <matt_harbison@yahoo.com>
parents:
51870
diff
changeset
|
131 return super(bundlerevlog, self)._inner._chunk(rev) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
132 self.bundle.seek(self.start(rev)) |
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
133 return self.bundle.read(self.length(rev)) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
134 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
135 def revdiff(self, rev1, rev2): |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
136 """return or calculate a delta between two revisions""" |
18643
cc28a84db8c9
bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents:
18568
diff
changeset
|
137 if rev1 > self.repotiprev and rev2 > self.repotiprev: |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
138 # hot path for bundle |
18643
cc28a84db8c9
bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents:
18568
diff
changeset
|
139 revb = self.index[rev2][3] |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
140 if revb == rev1: |
9676
48bf28d3c8dd
bundlerepo: keep the bundlerevlog interface in sync with revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9650
diff
changeset
|
141 return self._chunk(rev2) |
18643
cc28a84db8c9
bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents:
18568
diff
changeset
|
142 elif rev1 <= self.repotiprev and rev2 <= self.repotiprev: |
4028
540d1059c802
bundlerepo: it was meant to be revdiff() instead of chunk()
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3791
diff
changeset
|
143 return revlog.revlog.revdiff(self, rev1, rev2) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
144 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
145 return mdiff.textdiff(self.rawdata(rev1), self.rawdata(rev2)) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
146 |
51026
8520db304f01
revlog: drop more file description passing between private function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51012
diff
changeset
|
147 def _rawtext(self, node, rev): |
42821
c070ca6ed86d
bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42770
diff
changeset
|
148 if rev is None: |
16375
d7d64b89a65c
revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents:
16195
diff
changeset
|
149 rev = self.rev(node) |
42821
c070ca6ed86d
bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42770
diff
changeset
|
150 validated = False |
31836
4598e8f43e20
bundlerepo: fix raw handling in revision()
Jun Wu <quark@fb.com>
parents:
31835
diff
changeset
|
151 rawtext = None |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
152 chain = [] |
18415
95b8629fd2de
bundlerepo: use rev instead of node for iteration in revision()
Mads Kiilerich <madski@unity3d.com>
parents:
18414
diff
changeset
|
153 iterrev = rev |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
154 # reconstruct the revision if it is from a changegroup |
18643
cc28a84db8c9
bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents:
18568
diff
changeset
|
155 while iterrev > self.repotiprev: |
51096
8ec2de9c6770
revlog: move the_revisioncache on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51047
diff
changeset
|
156 if ( |
8ec2de9c6770
revlog: move the_revisioncache on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51047
diff
changeset
|
157 self._inner._revisioncache |
8ec2de9c6770
revlog: move the_revisioncache on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51047
diff
changeset
|
158 and self._inner._revisioncache[1] == iterrev |
8ec2de9c6770
revlog: move the_revisioncache on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51047
diff
changeset
|
159 ): |
8ec2de9c6770
revlog: move the_revisioncache on the inner object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51047
diff
changeset
|
160 rawtext = self._inner._revisioncache[2] |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
161 break |
18415
95b8629fd2de
bundlerepo: use rev instead of node for iteration in revision()
Mads Kiilerich <madski@unity3d.com>
parents:
18414
diff
changeset
|
162 chain.append(iterrev) |
18643
cc28a84db8c9
bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents:
18568
diff
changeset
|
163 iterrev = self.index[iterrev][3] |
42821
c070ca6ed86d
bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42770
diff
changeset
|
164 if iterrev == nullrev: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
165 rawtext = b'' |
42821
c070ca6ed86d
bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42770
diff
changeset
|
166 elif rawtext is None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
167 r = super(bundlerevlog, self)._rawtext( |
51026
8520db304f01
revlog: drop more file description passing between private function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51012
diff
changeset
|
168 self.node(iterrev), |
8520db304f01
revlog: drop more file description passing between private function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51012
diff
changeset
|
169 iterrev, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
170 ) |
42821
c070ca6ed86d
bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42770
diff
changeset
|
171 __, rawtext, validated = r |
c070ca6ed86d
bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42770
diff
changeset
|
172 if chain: |
c070ca6ed86d
bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42770
diff
changeset
|
173 validated = False |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
174 while chain: |
9676
48bf28d3c8dd
bundlerepo: keep the bundlerevlog interface in sync with revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9650
diff
changeset
|
175 delta = self._chunk(chain.pop()) |
31836
4598e8f43e20
bundlerepo: fix raw handling in revision()
Jun Wu <quark@fb.com>
parents:
31835
diff
changeset
|
176 rawtext = mdiff.patches(rawtext, [delta]) |
42821
c070ca6ed86d
bundlerepo: simplify code to take advantage of `_rawtext`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42770
diff
changeset
|
177 return rev, rawtext, validated |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
178 |
35047
32d079f37207
bundlerepo: make methods agree with base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35011
diff
changeset
|
179 def addrevision(self, *args, **kwargs): |
32d079f37207
bundlerepo: make methods agree with base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35011
diff
changeset
|
180 raise NotImplementedError |
32d079f37207
bundlerepo: make methods agree with base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35011
diff
changeset
|
181 |
32d079f37207
bundlerepo: make methods agree with base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35011
diff
changeset
|
182 def addgroup(self, *args, **kwargs): |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
183 raise NotImplementedError |
35047
32d079f37207
bundlerepo: make methods agree with base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35011
diff
changeset
|
184 |
32d079f37207
bundlerepo: make methods agree with base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35011
diff
changeset
|
185 def strip(self, *args, **kwargs): |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
186 raise NotImplementedError |
35047
32d079f37207
bundlerepo: make methods agree with base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35011
diff
changeset
|
187 |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
188 def checksize(self): |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
189 raise NotImplementedError |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
190 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
191 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
192 class bundlechangelog(bundlerevlog, changelog.changelog): |
35076
90609be10891
bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35075
diff
changeset
|
193 def __init__(self, opener, cgunpacker): |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
194 changelog.changelog.__init__(self, opener) |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
195 linkmapper = lambda x: x |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
196 bundlerevlog.__init__( |
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
197 self, |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
198 opener, |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
199 (revlog_constants.KIND_CHANGELOG, None), |
47150
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47148
diff
changeset
|
200 self.radix, |
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
201 cgunpacker, |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
202 linkmapper, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
203 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
204 |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
205 |
30373
31de088945cd
manifest: add bundlemanifestlog support
Durham Goode <durham@fb.com>
parents:
30218
diff
changeset
|
206 class bundlemanifest(bundlerevlog, manifest.manifestrevlog): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
207 def __init__( |
46780
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46711
diff
changeset
|
208 self, |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46711
diff
changeset
|
209 nodeconstants, |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46711
diff
changeset
|
210 opener, |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46711
diff
changeset
|
211 cgunpacker, |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46711
diff
changeset
|
212 linkmapper, |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46711
diff
changeset
|
213 dirlogstarts=None, |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46711
diff
changeset
|
214 dir=b'', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
215 ): |
51028
f70ce1aedbcb
manifestrevlog: flag some inconsistency in bundle/union repo inheritance
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51026
diff
changeset
|
216 # XXX manifestrevlog is not actually a revlog , so mixing it with |
f70ce1aedbcb
manifestrevlog: flag some inconsistency in bundle/union repo inheritance
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51026
diff
changeset
|
217 # bundlerevlog is not a good idea. |
46780
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46711
diff
changeset
|
218 manifest.manifestrevlog.__init__(self, nodeconstants, opener, tree=dir) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
219 bundlerevlog.__init__( |
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
220 self, |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
221 opener, |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
222 (revlog_constants.KIND_MANIFESTLOG, dir), |
47150
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47148
diff
changeset
|
223 self._revlog.radix, |
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
224 cgunpacker, |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
225 linkmapper, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
226 ) |
29715
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
227 if dirlogstarts is None: |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
228 dirlogstarts = {} |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
229 if self.bundle.version == b"03": |
29715
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
230 dirlogstarts = _getfilestarts(self.bundle) |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
231 self._dirlogstarts = dirlogstarts |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
232 self._linkmapper = linkmapper |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
233 |
29715
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
234 def dirlog(self, d): |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
235 if d in self._dirlogstarts: |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
236 self.bundle.seek(self._dirlogstarts[d]) |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
237 return bundlemanifest( |
46780
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46711
diff
changeset
|
238 self.nodeconstants, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
239 self.opener, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
240 self.bundle, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
241 self._linkmapper, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
242 self._dirlogstarts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
243 dir=d, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
244 ) |
29715
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
245 return super(bundlemanifest, self).dirlog(d) |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
246 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
247 |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37331
diff
changeset
|
248 class bundlefilelog(filelog.filelog): |
35076
90609be10891
bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35075
diff
changeset
|
249 def __init__(self, opener, path, cgunpacker, linkmapper): |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
250 filelog.filelog.__init__(self, opener, path) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
251 self._revlog = bundlerevlog( |
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
252 opener, |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
253 # XXX should use the unencoded path |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
254 target=(revlog_constants.KIND_FILELOG, path), |
47150
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47148
diff
changeset
|
255 radix=self._revlog.radix, |
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
256 cgunpacker=cgunpacker, |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
257 linkmapper=linkmapper, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
258 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
259 |
14287
7c231754a621
filelog: add file function to open other filelogs
Sune Foldager <cryo@cyanite.org>
parents:
14190
diff
changeset
|
260 |
17193
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
261 class bundlepeer(localrepo.localpeer): |
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
262 def canpush(self): |
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
263 return False |
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
264 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
265 |
23631
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
266 class bundlephasecache(phases.phasecache): |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
267 def __init__(self, *args, **kwargs): |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
268 super(bundlephasecache, self).__init__(*args, **kwargs) |
50928
d718eddf01d9
safehasattr: drop usage in favor of hasattr
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50440
diff
changeset
|
269 if hasattr(self, 'opener'): |
31240
5f68e7341ada
vfs: use 'vfs' module directly in 'mercurial.bundlerepo'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30924
diff
changeset
|
270 self.opener = vfsmod.readonlyvfs(self.opener) |
23631
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
271 |
51871
cfd30df0f8e4
bundlerepo: fix mismatches with repository and revlog classes
Matt Harbison <matt_harbison@yahoo.com>
parents:
51870
diff
changeset
|
272 def write(self, repo): |
23631
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
273 raise NotImplementedError |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
274 |
51871
cfd30df0f8e4
bundlerepo: fix mismatches with repository and revlog classes
Matt Harbison <matt_harbison@yahoo.com>
parents:
51870
diff
changeset
|
275 def _write(self, repo, fp): |
23631
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
276 raise NotImplementedError |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
277 |
51420
ac1c75188440
phases: invalidate the phases set less often on retract boundary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51404
diff
changeset
|
278 def _updateroots(self, repo, phase, newroots, tr, invalidate=True): |
51403
68289ed170c7
phases: mark `phasecache.phaseroots` private
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51096
diff
changeset
|
279 self._phaseroots[phase] = newroots |
51420
ac1c75188440
phases: invalidate the phases set less often on retract boundary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51404
diff
changeset
|
280 if invalidate: |
ac1c75188440
phases: invalidate the phases set less often on retract boundary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51404
diff
changeset
|
281 self.invalidate() |
23631
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
282 self.dirty = True |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
283 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
284 |
35076
90609be10891
bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35075
diff
changeset
|
285 def _getfilestarts(cgunpacker): |
35077
cd4cd7b94ff1
bundlerepo: rename "bundlefilespos" variable and attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35076
diff
changeset
|
286 filespos = {} |
35076
90609be10891
bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35075
diff
changeset
|
287 for chunkdata in iter(cgunpacker.filelogheader, {}): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
288 fname = chunkdata[b'filename'] |
35077
cd4cd7b94ff1
bundlerepo: rename "bundlefilespos" variable and attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35076
diff
changeset
|
289 filespos[fname] = cgunpacker.tell() |
35076
90609be10891
bundlerepo: rename "bundle" arguments to "cgunpacker"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35075
diff
changeset
|
290 for chunk in iter(lambda: cgunpacker.deltachunk(None), {}): |
29712
9e88077f972c
bundlerepo: introduce method to find file starts and use it
Augie Fackler <augie@google.com>
parents:
29711
diff
changeset
|
291 pass |
35077
cd4cd7b94ff1
bundlerepo: rename "bundlefilespos" variable and attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35076
diff
changeset
|
292 return filespos |
29712
9e88077f972c
bundlerepo: introduce method to find file starts and use it
Augie Fackler <augie@google.com>
parents:
29711
diff
changeset
|
293 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
294 |
51870
9d4ad05bc91c
typing: make `bundlerepository` subclass `localrepository` while type checking
Matt Harbison <matt_harbison@yahoo.com>
parents:
51863
diff
changeset
|
295 _bundle_repo_baseclass = object |
9d4ad05bc91c
typing: make `bundlerepository` subclass `localrepository` while type checking
Matt Harbison <matt_harbison@yahoo.com>
parents:
51863
diff
changeset
|
296 |
9d4ad05bc91c
typing: make `bundlerepository` subclass `localrepository` while type checking
Matt Harbison <matt_harbison@yahoo.com>
parents:
51863
diff
changeset
|
297 if typing.TYPE_CHECKING: |
9d4ad05bc91c
typing: make `bundlerepository` subclass `localrepository` while type checking
Matt Harbison <matt_harbison@yahoo.com>
parents:
51863
diff
changeset
|
298 _bundle_repo_baseclass = localrepo.localrepository |
9d4ad05bc91c
typing: make `bundlerepository` subclass `localrepository` while type checking
Matt Harbison <matt_harbison@yahoo.com>
parents:
51863
diff
changeset
|
299 |
9d4ad05bc91c
typing: make `bundlerepository` subclass `localrepository` while type checking
Matt Harbison <matt_harbison@yahoo.com>
parents:
51863
diff
changeset
|
300 |
9d4ad05bc91c
typing: make `bundlerepository` subclass `localrepository` while type checking
Matt Harbison <matt_harbison@yahoo.com>
parents:
51863
diff
changeset
|
301 class bundlerepository(_bundle_repo_baseclass): |
35050
d2458ba810c5
bundlerepo: add docstring for bundlerepository class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35049
diff
changeset
|
302 """A repository instance that is a union of a local repo and a bundle. |
d2458ba810c5
bundlerepo: add docstring for bundlerepository class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35049
diff
changeset
|
303 |
d2458ba810c5
bundlerepo: add docstring for bundlerepository class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35049
diff
changeset
|
304 Instances represent a read-only repository composed of a local repository |
d2458ba810c5
bundlerepo: add docstring for bundlerepository class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35049
diff
changeset
|
305 with the contents of a bundle file applied. The repository instance is |
d2458ba810c5
bundlerepo: add docstring for bundlerepository class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35049
diff
changeset
|
306 conceptually similar to the state of a repository after an |
d2458ba810c5
bundlerepo: add docstring for bundlerepository class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35049
diff
changeset
|
307 ``hg unbundle`` operation. However, the contents of the bundle are never |
d2458ba810c5
bundlerepo: add docstring for bundlerepository class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35049
diff
changeset
|
308 applied to the actual base repository. |
39604
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
309 |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
310 Instances constructed directly are not usable as repository objects. |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
311 Use instance() or makebundlerepository() to create instances. |
35050
d2458ba810c5
bundlerepo: add docstring for bundlerepository class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35049
diff
changeset
|
312 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
313 |
39604
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
314 def __init__(self, bundlepath, url, tempparent): |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
315 self._tempparent = tempparent |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
316 self._url = url |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
317 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
318 self.ui.setconfig(b'phases', b'publish', False, b'bundlerepo') |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
319 |
50198
a6a8946d5173
bundlerepo: move most attribute declaration earlier in __init__
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50197
diff
changeset
|
320 # dict with the mapping 'filename' -> position in the changegroup. |
a6a8946d5173
bundlerepo: move most attribute declaration earlier in __init__
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50197
diff
changeset
|
321 self._cgfilespos = {} |
a6a8946d5173
bundlerepo: move most attribute declaration earlier in __init__
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50197
diff
changeset
|
322 self._bundlefile = None |
a6a8946d5173
bundlerepo: move most attribute declaration earlier in __init__
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50197
diff
changeset
|
323 self._cgunpacker = None |
2273
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
324 self.tempfile = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
325 f = util.posixfile(bundlepath, b"rb") |
39604
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
326 bundle = exchange.readbundle(self.ui, f, bundlepath) |
12044
bcc7139521b7
bundlerepo: remove duplication of bundle decompressors
Matt Mackall <mpm@selenic.com>
parents:
11154
diff
changeset
|
327 |
35053
495fcff10124
bundlerepo: assign bundle attributes in bundle type blocks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35052
diff
changeset
|
328 if isinstance(bundle, bundle2.unbundle20): |
495fcff10124
bundlerepo: assign bundle attributes in bundle type blocks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35052
diff
changeset
|
329 self._bundlefile = bundle |
495fcff10124
bundlerepo: assign bundle attributes in bundle type blocks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35052
diff
changeset
|
330 |
35115
2b72bc88043f
bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35077
diff
changeset
|
331 cgpart = None |
35116
da91e7309daf
bundle2: don't use seekable bundle2 parts by default (issue5691)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35115
diff
changeset
|
332 for part in bundle.iterparts(seekable=True): |
50200
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
333 if part.type == b'phase-heads': |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
334 self._handle_bundle2_phase_part(bundle, part) |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
335 elif part.type == b'changegroup': |
35115
2b72bc88043f
bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35077
diff
changeset
|
336 if cgpart: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
337 raise NotImplementedError( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43115
diff
changeset
|
338 b"can't process multiple changegroups" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
339 ) |
35115
2b72bc88043f
bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35077
diff
changeset
|
340 cgpart = part |
50196
2a7e8471782c
bundlerepo: expliclty handing cg part from bundle2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49975
diff
changeset
|
341 self._handle_bundle2_cg_part(bundle, part) |
24073
ff5caa8dfd99
bundlerepo: basic bundle2 support
Eric Sumner <ericsumner@fb.com>
parents:
24072
diff
changeset
|
342 |
35115
2b72bc88043f
bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35077
diff
changeset
|
343 if not cgpart: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
344 raise error.Abort(_(b"No changegroups found")) |
35115
2b72bc88043f
bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35077
diff
changeset
|
345 |
2b72bc88043f
bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35077
diff
changeset
|
346 # This is required to placate a later consumer, which expects |
2b72bc88043f
bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35077
diff
changeset
|
347 # the payload offset to be at the beginning of the changegroup. |
2b72bc88043f
bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35077
diff
changeset
|
348 # We need to do this after the iterparts() generator advances |
2b72bc88043f
bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35077
diff
changeset
|
349 # because iterparts() will seek to end of payload after the |
2b72bc88043f
bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35077
diff
changeset
|
350 # generator returns control to iterparts(). |
2b72bc88043f
bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35077
diff
changeset
|
351 cgpart.seek(0, os.SEEK_SET) |
2b72bc88043f
bundle2: only seek to beginning of part in bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35077
diff
changeset
|
352 |
35053
495fcff10124
bundlerepo: assign bundle attributes in bundle type blocks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35052
diff
changeset
|
353 elif isinstance(bundle, changegroup.cg1unpacker): |
50197
c493cb859158
bundlerepo: move the handling of bundl1 in its own method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50196
diff
changeset
|
354 self._handle_bundle1(bundle, bundlepath) |
35051
4f04c9207a76
bundlerepo: don't assume there are only two bundle classes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35050
diff
changeset
|
355 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
356 raise error.Abort( |
50201
149f09ffef46
bundlerepo: fix string interpolation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50200
diff
changeset
|
357 _(b'bundle type %r cannot be read') % type(bundle) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
358 ) |
26801
73bf76bf6f14
bundlerepo: uncompress changegroup in bundle1 case only
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26800
diff
changeset
|
359 |
50199
21f876895dfe
bundlerepo: handle changegroup induced phase movement in the associated method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50198
diff
changeset
|
360 def _handle_bundle1(self, bundle, bundlepath): |
21f876895dfe
bundlerepo: handle changegroup induced phase movement in the associated method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50198
diff
changeset
|
361 if bundle.compressed(): |
21f876895dfe
bundlerepo: handle changegroup induced phase movement in the associated method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50198
diff
changeset
|
362 f = self._writetempbundle(bundle.read, b'.hg10un', header=b'HG10UN') |
21f876895dfe
bundlerepo: handle changegroup induced phase movement in the associated method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50198
diff
changeset
|
363 bundle = exchange.readbundle(self.ui, f, bundlepath, self.vfs) |
21f876895dfe
bundlerepo: handle changegroup induced phase movement in the associated method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50198
diff
changeset
|
364 |
21f876895dfe
bundlerepo: handle changegroup induced phase movement in the associated method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50198
diff
changeset
|
365 self._bundlefile = bundle |
21f876895dfe
bundlerepo: handle changegroup induced phase movement in the associated method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50198
diff
changeset
|
366 self._cgunpacker = bundle |
21f876895dfe
bundlerepo: handle changegroup induced phase movement in the associated method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50198
diff
changeset
|
367 |
23632
e7fcf58acd71
bundlerepo: retract phase boundary
Eric Sumner <ericsumner@fb.com>
parents:
23631
diff
changeset
|
368 self.firstnewrev = self.changelog.repotiprev + 1 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
369 phases.retractboundary( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
370 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
371 None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
372 phases.draft, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
373 [ctx.node() for ctx in self[self.firstnewrev :]], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
374 ) |
23632
e7fcf58acd71
bundlerepo: retract phase boundary
Eric Sumner <ericsumner@fb.com>
parents:
23631
diff
changeset
|
375 |
50196
2a7e8471782c
bundlerepo: expliclty handing cg part from bundle2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49975
diff
changeset
|
376 def _handle_bundle2_cg_part(self, bundle, part): |
2a7e8471782c
bundlerepo: expliclty handing cg part from bundle2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49975
diff
changeset
|
377 assert part.type == b'changegroup' |
35075
3eeb0a3eeaed
bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35054
diff
changeset
|
378 cgstream = part |
50200
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
379 targetphase = part.params.get(b'targetphase') |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
380 try: |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
381 targetphase = int(targetphase) |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
382 except TypeError: |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
383 pass |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
384 if targetphase is None: |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
385 targetphase = phases.draft |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
386 if targetphase not in phases.allphases: |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
387 m = _(b'unsupported targetphase: %d') |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
388 m %= targetphase |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
389 raise error.Abort(m) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
390 version = part.params.get(b'version', b'01') |
35075
3eeb0a3eeaed
bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35054
diff
changeset
|
391 legalcgvers = changegroup.supportedincomingversions(self) |
3eeb0a3eeaed
bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35054
diff
changeset
|
392 if version not in legalcgvers: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
393 msg = _(b'Unsupported changegroup version: %s') |
35075
3eeb0a3eeaed
bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35054
diff
changeset
|
394 raise error.Abort(msg % version) |
3eeb0a3eeaed
bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35054
diff
changeset
|
395 if bundle.compressed(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
396 cgstream = self._writetempbundle(part.read, b'.cg%sun' % version) |
35075
3eeb0a3eeaed
bundlerepo: use early return
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35054
diff
changeset
|
397 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
398 self._cgunpacker = changegroup.getunbundler(version, cgstream, b'UN') |
33889
f672d060a931
bundlerepo: move bundle2 part handling out to a function
Durham Goode <durham@fb.com>
parents:
33888
diff
changeset
|
399 |
50199
21f876895dfe
bundlerepo: handle changegroup induced phase movement in the associated method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50198
diff
changeset
|
400 self.firstnewrev = self.changelog.repotiprev + 1 |
21f876895dfe
bundlerepo: handle changegroup induced phase movement in the associated method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50198
diff
changeset
|
401 phases.retractboundary( |
21f876895dfe
bundlerepo: handle changegroup induced phase movement in the associated method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50198
diff
changeset
|
402 self, |
21f876895dfe
bundlerepo: handle changegroup induced phase movement in the associated method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50198
diff
changeset
|
403 None, |
50200
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
404 targetphase, |
50199
21f876895dfe
bundlerepo: handle changegroup induced phase movement in the associated method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50198
diff
changeset
|
405 [ctx.node() for ctx in self[self.firstnewrev :]], |
21f876895dfe
bundlerepo: handle changegroup induced phase movement in the associated method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50198
diff
changeset
|
406 ) |
21f876895dfe
bundlerepo: handle changegroup induced phase movement in the associated method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50198
diff
changeset
|
407 |
50200
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
408 def _handle_bundle2_phase_part(self, bundle, part): |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
409 assert part.type == b'phase-heads' |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
410 |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
411 unfi = self.unfiltered() |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
412 headsbyphase = phases.binarydecode(part) |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
413 phases.updatephases(unfi, lambda: None, headsbyphase) |
197204dba8a2
bundlerepo: apply phase data stored in the bundle instead of assuming `draft`
Matt Harbison <matt_harbison@yahoo.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50199
diff
changeset
|
414 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
415 def _writetempbundle(self, readfn, suffix, header=b''): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45814
diff
changeset
|
416 """Write a temporary file to disk""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
417 fdtemp, temp = self.vfs.mkstemp(prefix=b"hg-bundle-", suffix=suffix) |
33887
702a26fec3e2
bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents:
33182
diff
changeset
|
418 self.tempfile = temp |
702a26fec3e2
bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents:
33182
diff
changeset
|
419 |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43117
diff
changeset
|
420 with os.fdopen(fdtemp, 'wb') as fptemp: |
33887
702a26fec3e2
bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents:
33182
diff
changeset
|
421 fptemp.write(header) |
702a26fec3e2
bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents:
33182
diff
changeset
|
422 while True: |
51703
ca7bde5dbafb
black: format the codebase with 23.3.0
Raphaël Gomès <rgomes@octobus.net>
parents:
51700
diff
changeset
|
423 chunk = readfn(2**18) |
33887
702a26fec3e2
bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents:
33182
diff
changeset
|
424 if not chunk: |
702a26fec3e2
bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents:
33182
diff
changeset
|
425 break |
702a26fec3e2
bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents:
33182
diff
changeset
|
426 fptemp.write(chunk) |
702a26fec3e2
bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents:
33182
diff
changeset
|
427 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
428 return self.vfs.open(self.tempfile, mode=b"rb") |
33887
702a26fec3e2
bundlerepo: move temp bundle creation to a separate function
Durham Goode <durham@fb.com>
parents:
33182
diff
changeset
|
429 |
18014
a39fe76c4c65
clfilter: ensure that filecache on localrepo is unfiltered
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17913
diff
changeset
|
430 @localrepo.unfilteredpropertycache |
23631
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
431 def _phasecache(self): |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
432 return bundlephasecache(self, self._phasedefaults) |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
433 |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
434 @localrepo.unfilteredpropertycache |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
435 def changelog(self): |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14142
diff
changeset
|
436 # consume the header if it exists |
35054
3f393e4593f2
bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35053
diff
changeset
|
437 self._cgunpacker.changelogheader() |
3f393e4593f2
bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35053
diff
changeset
|
438 c = bundlechangelog(self.svfs, self._cgunpacker) |
3f393e4593f2
bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35053
diff
changeset
|
439 self.manstart = self._cgunpacker.tell() |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
440 return c |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
441 |
42510
3472a3f9d785
localrepo: introduce a `_refreshchangelog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41038
diff
changeset
|
442 def _refreshchangelog(self): |
3472a3f9d785
localrepo: introduce a `_refreshchangelog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41038
diff
changeset
|
443 # changelog for bundle repo are not filecache, this method is not |
3472a3f9d785
localrepo: introduce a `_refreshchangelog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41038
diff
changeset
|
444 # applicable. |
3472a3f9d785
localrepo: introduce a `_refreshchangelog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41038
diff
changeset
|
445 pass |
3472a3f9d785
localrepo: introduce a `_refreshchangelog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41038
diff
changeset
|
446 |
39763
5ccd791344f3
localrepo: pass root manifest into manifestlog.__init__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39604
diff
changeset
|
447 @localrepo.unfilteredpropertycache |
5ccd791344f3
localrepo: pass root manifest into manifestlog.__init__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39604
diff
changeset
|
448 def manifestlog(self): |
35054
3f393e4593f2
bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35053
diff
changeset
|
449 self._cgunpacker.seek(self.manstart) |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14142
diff
changeset
|
450 # consume the header if it exists |
35054
3f393e4593f2
bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35053
diff
changeset
|
451 self._cgunpacker.manifestheader() |
28221
7a8c44844f57
bundlerepo: properly handle hidden linkrev in manifestlog (issue4945)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28186
diff
changeset
|
452 linkmapper = self.unfiltered().changelog.rev |
46780
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46711
diff
changeset
|
453 rootstore = bundlemanifest( |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46711
diff
changeset
|
454 self.nodeconstants, self.svfs, self._cgunpacker, linkmapper |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46711
diff
changeset
|
455 ) |
35054
3f393e4593f2
bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35053
diff
changeset
|
456 self.filestart = self._cgunpacker.tell() |
39763
5ccd791344f3
localrepo: pass root manifest into manifestlog.__init__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39604
diff
changeset
|
457 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
458 return manifest.manifestlog( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
459 self.svfs, self, rootstore, self.narrowmatch() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
460 ) |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
461 |
35011
a2dfc723b6b5
bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents:
34293
diff
changeset
|
462 def _consumemanifest(self): |
a2dfc723b6b5
bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents:
34293
diff
changeset
|
463 """Consumes the manifest portion of the bundle, setting filestart so the |
a2dfc723b6b5
bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents:
34293
diff
changeset
|
464 file portion can be read.""" |
35054
3f393e4593f2
bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35053
diff
changeset
|
465 self._cgunpacker.seek(self.manstart) |
3f393e4593f2
bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35053
diff
changeset
|
466 self._cgunpacker.manifestheader() |
3f393e4593f2
bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35053
diff
changeset
|
467 for delta in self._cgunpacker.deltaiter(): |
35011
a2dfc723b6b5
bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents:
34293
diff
changeset
|
468 pass |
35054
3f393e4593f2
bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35053
diff
changeset
|
469 self.filestart = self._cgunpacker.tell() |
35011
a2dfc723b6b5
bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents:
34293
diff
changeset
|
470 |
18014
a39fe76c4c65
clfilter: ensure that filecache on localrepo is unfiltered
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17913
diff
changeset
|
471 @localrepo.unfilteredpropertycache |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
472 def manstart(self): |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
473 self.changelog |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
474 return self.manstart |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
475 |
18014
a39fe76c4c65
clfilter: ensure that filecache on localrepo is unfiltered
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17913
diff
changeset
|
476 @localrepo.unfilteredpropertycache |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
477 def filestart(self): |
30375
11b8b740d54a
manifest: remove last uses of repo.manifest
Durham Goode <durham@fb.com>
parents:
30373
diff
changeset
|
478 self.manifestlog |
35011
a2dfc723b6b5
bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents:
34293
diff
changeset
|
479 |
a2dfc723b6b5
bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents:
34293
diff
changeset
|
480 # If filestart was not set by self.manifestlog, that means the |
a2dfc723b6b5
bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents:
34293
diff
changeset
|
481 # manifestlog implementation did not consume the manifests from the |
a2dfc723b6b5
bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents:
34293
diff
changeset
|
482 # changegroup (ex: it might be consuming trees from a separate bundle2 |
a2dfc723b6b5
bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents:
34293
diff
changeset
|
483 # part instead). So we need to manually consume it. |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43117
diff
changeset
|
484 if 'filestart' not in self.__dict__: |
35011
a2dfc723b6b5
bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents:
34293
diff
changeset
|
485 self._consumemanifest() |
a2dfc723b6b5
bundle: allow bundlerepo to support alternative manifest implementations
Durham Goode <durham@fb.com>
parents:
34293
diff
changeset
|
486 |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
487 return self.filestart |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
488 |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
489 def url(self): |
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
490 return self._url |
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
491 |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
492 def file(self, f): |
35077
cd4cd7b94ff1
bundlerepo: rename "bundlefilespos" variable and attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35076
diff
changeset
|
493 if not self._cgfilespos: |
35054
3f393e4593f2
bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35053
diff
changeset
|
494 self._cgunpacker.seek(self.filestart) |
35077
cd4cd7b94ff1
bundlerepo: rename "bundlefilespos" variable and attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35076
diff
changeset
|
495 self._cgfilespos = _getfilestarts(self._cgunpacker) |
5262 | 496 |
35077
cd4cd7b94ff1
bundlerepo: rename "bundlefilespos" variable and attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35076
diff
changeset
|
497 if f in self._cgfilespos: |
cd4cd7b94ff1
bundlerepo: rename "bundlefilespos" variable and attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35076
diff
changeset
|
498 self._cgunpacker.seek(self._cgfilespos[f]) |
28186
5ab6f0fde75f
bundlerepo: properly handle hidden linkrev in filelog (issue4945)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27953
diff
changeset
|
499 linkmapper = self.unfiltered().changelog.rev |
35054
3f393e4593f2
bundlerepo: rename _bundle to _cgunpacker
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35053
diff
changeset
|
500 return bundlefilelog(self.svfs, f, self._cgunpacker, linkmapper) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
501 else: |
37331
c68262401c8c
bundlerepo: use super() when calling file()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36835
diff
changeset
|
502 return super(bundlerepository, self).file(f) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
503 |
12347
6277a9469dff
bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents:
12335
diff
changeset
|
504 def close(self): |
6277a9469dff
bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents:
12335
diff
changeset
|
505 """Close assigned bundle file immediately.""" |
35052
df2a676a2e9e
bundlerepo: make bundle and bundlefile attributes private
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35051
diff
changeset
|
506 self._bundlefile.close() |
12962
ff083040a555
bundlerepository: get rid of temporary bundle files (issue2478)
Klaus Koch <kuk42@gmx.net>
parents:
12961
diff
changeset
|
507 if self.tempfile is not None: |
20981
4fdd1172d37e
bundlerepo: treat temporarily extracted bundle file via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20790
diff
changeset
|
508 self.vfs.unlink(self.tempfile) |
6314
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
509 if self._tempparent: |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
510 shutil.rmtree(self._tempparent, True) |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
511 |
6315 | 512 def cancopy(self): |
513 return False | |
514 | |
50440
3a2df812e1c7
pull: add --remote-hidden option and pass it through peer creation
Manuel Jacob <me@manueljacob.de>
parents:
50201
diff
changeset
|
515 def peer(self, path=None, remotehidden=False): |
3a2df812e1c7
pull: add --remote-hidden option and pass it through peer creation
Manuel Jacob <me@manueljacob.de>
parents:
50201
diff
changeset
|
516 return bundlepeer(self, path=path, remotehidden=remotehidden) |
17193
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
517 |
7435
5e13df32fb74
bundlerepo doesn't really have a dirstate, throw AttributeError if requested
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6953
diff
changeset
|
518 def getcwd(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
519 return encoding.getcwd() # always outside the repo |
7435
5e13df32fb74
bundlerepo doesn't really have a dirstate, throw AttributeError if requested
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6953
diff
changeset
|
520 |
28714
dac81729fea4
bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents:
28666
diff
changeset
|
521 # Check if parents exist in localrepo before setting |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46907
diff
changeset
|
522 def setparents(self, p1, p2=None): |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46907
diff
changeset
|
523 if p2 is None: |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46907
diff
changeset
|
524 p2 = self.nullid |
28714
dac81729fea4
bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents:
28666
diff
changeset
|
525 p1rev = self.changelog.rev(p1) |
dac81729fea4
bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents:
28666
diff
changeset
|
526 p2rev = self.changelog.rev(p2) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
527 msg = _(b"setting parent to node %s that only exists in the bundle\n") |
28714
dac81729fea4
bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents:
28666
diff
changeset
|
528 if self.changelog.repotiprev < p1rev: |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
529 self.ui.warn(msg % hex(p1)) |
28714
dac81729fea4
bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents:
28666
diff
changeset
|
530 if self.changelog.repotiprev < p2rev: |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
531 self.ui.warn(msg % hex(p2)) |
28714
dac81729fea4
bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents:
28666
diff
changeset
|
532 return super(bundlerepository, self).setparents(p1, p2) |
15597
bc0778f5619a
bundlerepo: don't write branch cache to disk
Sune Foldager <cryo@cyanite.org>
parents:
15091
diff
changeset
|
533 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
534 |
39549
089fc0db0954
hg: allow extra arguments to be passed to repo creation (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39243
diff
changeset
|
535 def instance(ui, path, create, intents=None, createopts=None): |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
536 if create: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
537 raise error.Abort(_(b'cannot create new bundle repository')) |
25830
5418dd5be8ac
bundlerepo: mark internal-only config variable
Matt Mackall <mpm@selenic.com>
parents:
24921
diff
changeset
|
538 # internal config: bundle.mainreporoot |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
539 parentpath = ui.config(b"bundle", b"mainreporoot") |
16042
4b7aa1c899dc
bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents:
15597
diff
changeset
|
540 if not parentpath: |
4b7aa1c899dc
bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents:
15597
diff
changeset
|
541 # try to find the correct path to the working directory repo |
39818
24e493ec2229
py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
39763
diff
changeset
|
542 parentpath = cmdutil.findrepo(encoding.getcwd()) |
16042
4b7aa1c899dc
bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents:
15597
diff
changeset
|
543 if parentpath is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
544 parentpath = b'' |
5664
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
545 if parentpath: |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
546 # Try to make the full path relative so we get a nice, short URL. |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
547 # In particular, we don't want temp dir names in test outputs. |
39818
24e493ec2229
py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
39763
diff
changeset
|
548 cwd = encoding.getcwd() |
5664
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
549 if parentpath == cwd: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
550 parentpath = b'' |
5664
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
551 else: |
24834
6e31e1274080
bundlerepo: use pathutil.normasprefix to ensure os.sep at the end of cwd
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24686
diff
changeset
|
552 cwd = pathutil.normasprefix(cwd) |
5664
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
553 if parentpath.startswith(cwd): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
554 parentpath = parentpath[len(cwd) :] |
46907
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46780
diff
changeset
|
555 u = urlutil.url(path) |
13826
e574207e3bcd
url: refactor util.drop_scheme() and hg.localpath() into url.localpath()
Brodie Rao <brodie@bitheap.org>
parents:
13742
diff
changeset
|
556 path = u.localpath() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
557 if u.scheme == b'bundle': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
558 s = path.split(b"+", 1) |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
559 if len(s) == 1: |
5664
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
560 repopath, bundlename = parentpath, s[0] |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
561 else: |
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
562 repopath, bundlename = s |
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
563 else: |
5664
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
564 repopath, bundlename = parentpath, path |
39603
a8d2faeca49e
bundlerepo: factor out code for instantiating a bundle repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39602
diff
changeset
|
565 |
a8d2faeca49e
bundlerepo: factor out code for instantiating a bundle repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39602
diff
changeset
|
566 return makebundlerepository(ui, repopath, bundlename) |
a8d2faeca49e
bundlerepo: factor out code for instantiating a bundle repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39602
diff
changeset
|
567 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
568 |
39603
a8d2faeca49e
bundlerepo: factor out code for instantiating a bundle repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39602
diff
changeset
|
569 def makebundlerepository(ui, repopath, bundlepath): |
a8d2faeca49e
bundlerepo: factor out code for instantiating a bundle repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39602
diff
changeset
|
570 """Make a bundle repository object based on repo and bundle paths.""" |
39604
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
571 if repopath: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
572 url = b'bundle:%s+%s' % (util.expandpath(repopath), bundlepath) |
39604
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
573 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
574 url = b'bundle:%s' % bundlepath |
39604
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
575 |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
576 # Because we can't make any guarantees about the type of the base |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
577 # repository, we can't have a static class representing the bundle |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
578 # repository. We also can't make any guarantees about how to even |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
579 # call the base repository's constructor! |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
580 # |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
581 # So, our strategy is to go through ``localrepo.instance()`` to construct |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
582 # a repo instance. Then, we dynamically create a new type derived from |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
583 # both it and our ``bundlerepository`` class which overrides some |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
584 # functionality. We then change the type of the constructed repository |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
585 # to this new type and initialize the bundle-specific bits of it. |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
586 |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
587 try: |
39944
75b53b809e87
bundlerepo: remove a variable alias
Martin von Zweigbergk <martinvonz@google.com>
parents:
39818
diff
changeset
|
588 repo = localrepo.instance(ui, repopath, create=False) |
39604
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
589 tempparent = None |
49969
84680c003d44
bundlerepo: enforce the requirements declared by the underlying repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
48946
diff
changeset
|
590 except error.RequirementError: |
84680c003d44
bundlerepo: enforce the requirements declared by the underlying repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
48946
diff
changeset
|
591 raise # no fallback if the backing repo is unsupported |
39604
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
592 except error.RepoError: |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
593 tempparent = pycompat.mkdtemp() |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
594 try: |
39944
75b53b809e87
bundlerepo: remove a variable alias
Martin von Zweigbergk <martinvonz@google.com>
parents:
39818
diff
changeset
|
595 repo = localrepo.instance(ui, tempparent, create=True) |
39604
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
596 except Exception: |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
597 shutil.rmtree(tempparent) |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
598 raise |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
599 |
39944
75b53b809e87
bundlerepo: remove a variable alias
Martin von Zweigbergk <martinvonz@google.com>
parents:
39818
diff
changeset
|
600 class derivedbundlerepository(bundlerepository, repo.__class__): |
39604
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
601 pass |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
602 |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
603 repo.__class__ = derivedbundlerepository |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
604 bundlerepository.__init__(repo, bundlepath, url, tempparent) |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
605 |
335ae4d0a552
bundlerepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39603
diff
changeset
|
606 return repo |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
607 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
608 |
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
609 class bundletransactionmanager: |
23633
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
610 def transaction(self): |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
611 return None |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
612 |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
613 def close(self): |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
614 raise NotImplementedError |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
615 |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
616 def release(self): |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
617 raise NotImplementedError |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
618 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
619 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
620 def getremotechanges( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
621 ui, repo, peer, onlyheads=None, bundlename=None, force=False |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
622 ): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45814
diff
changeset
|
623 """obtains a bundle of changes incoming from peer |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
624 |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
625 "onlyheads" restricts the returned changes to those reachable from the |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
626 specified heads. |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
627 "bundlename", if given, stores the bundle to this file path permanently; |
14190
8aab5a82685f
bundlerepo: fix closing and docstring of getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14161
diff
changeset
|
628 otherwise it's stored to a temp file and gets deleted again when you call |
8aab5a82685f
bundlerepo: fix closing and docstring of getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14161
diff
changeset
|
629 the returned "cleanupfn". |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
630 "force" indicates whether to proceed on unrelated repos. |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
631 |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
632 Returns a tuple (local, csets, cleanupfn): |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
633 |
16683 | 634 "local" is a local repo from which to obtain the actual incoming |
635 changesets; it is a bundlerepo for the obtained bundle when the | |
37642
d959277ff1b5
bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
636 original "peer" is remote. |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
637 "csets" lists the incoming changeset node ids. |
16683 | 638 "cleanupfn" must be called without arguments when you're done processing |
37642
d959277ff1b5
bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
639 the changes; it closes both the original "peer" and the one returned |
16683 | 640 here. |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45814
diff
changeset
|
641 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
642 tmp = discovery.findcommonincoming(repo, peer, heads=onlyheads, force=force) |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
643 common, incoming, rheads = tmp |
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
644 if not incoming: |
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
645 try: |
15091
106f89299da6
bundlerepo: add argument check before unlink
Sune Foldager <cryo@cyanite.org>
parents:
14494
diff
changeset
|
646 if bundlename: |
21694
c08a22bfa16e
bundlerepo: backout dbf292f65b09
Matt Mackall <mpm@selenic.com>
parents:
21562
diff
changeset
|
647 os.unlink(bundlename) |
14004
97ed99d1f419
eliminate various naked except clauses
Idan Kamara <idankk86@gmail.com>
parents:
13826
diff
changeset
|
648 except OSError: |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
649 pass |
37642
d959277ff1b5
bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
650 return repo, [], peer.close |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
651 |
22182
510cafe72004
incoming: don't request heads that already are common
Mads Kiilerich <madski@unity3d.com>
parents:
21694
diff
changeset
|
652 commonset = set(common) |
510cafe72004
incoming: don't request heads that already are common
Mads Kiilerich <madski@unity3d.com>
parents:
21694
diff
changeset
|
653 rheads = [x for x in rheads if x not in commonset] |
510cafe72004
incoming: don't request heads that already are common
Mads Kiilerich <madski@unity3d.com>
parents:
21694
diff
changeset
|
654 |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
655 bundle = None |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
656 bundlerepo = None |
37642
d959277ff1b5
bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
657 localrepo = peer.local() |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
16686
diff
changeset
|
658 if bundlename or not localrepo: |
37642
d959277ff1b5
bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
659 # create a bundle (uncompressed if peer repo is not local) |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
660 |
29684
ff5d5751fc1b
bundlerepo: also read the 'devel.legacy.exchange' config
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29389
diff
changeset
|
661 # developer config: devel.legacy.exchange |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
662 legexc = ui.configlist(b'devel', b'legacy.exchange') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
663 forcebundle1 = b'bundle2' not in legexc and b'bundle1' in legexc |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
664 canbundle2 = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
665 not forcebundle1 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
666 and peer.capable(b'getbundle') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
667 and peer.capable(b'bundle2') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
668 ) |
26544
1e8e0b01faba
incoming: request a bundle2 when possible (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26543
diff
changeset
|
669 if canbundle2: |
37643
1aa4d646d0de
bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37642
diff
changeset
|
670 with peer.commandexecutor() as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
671 b2 = e.callcommand( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
672 b'getbundle', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
673 { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
674 b'source': b'incoming', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
675 b'common': common, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
676 b'heads': rheads, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
677 b'bundlecaps': exchange.caps20to10( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
678 repo, role=b'client' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
679 ), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
680 b'cg': True, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
681 }, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
682 ).result() |
37643
1aa4d646d0de
bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37642
diff
changeset
|
683 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
684 fname = bundle = changegroup.writechunks( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
685 ui, b2._forwardchunks(), bundlename |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
686 ) |
26544
1e8e0b01faba
incoming: request a bundle2 when possible (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26543
diff
changeset
|
687 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
688 if peer.capable(b'getbundle'): |
37643
1aa4d646d0de
bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37642
diff
changeset
|
689 with peer.commandexecutor() as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
690 cg = e.callcommand( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
691 b'getbundle', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
692 { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
693 b'source': b'incoming', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
694 b'common': common, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
695 b'heads': rheads, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
696 }, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
697 ).result() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
698 elif onlyheads is None and not peer.capable(b'changegroupsubset'): |
26543
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
699 # compat with older servers when pulling all remote heads |
37635
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37497
diff
changeset
|
700 |
37642
d959277ff1b5
bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
701 with peer.commandexecutor() as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
702 cg = e.callcommand( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
703 b'changegroup', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45814
diff
changeset
|
704 { |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45814
diff
changeset
|
705 b'nodes': incoming, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45814
diff
changeset
|
706 b'source': b'incoming', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45814
diff
changeset
|
707 }, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
708 ).result() |
37635
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37497
diff
changeset
|
709 |
26543
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
710 rheads = None |
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
711 else: |
37642
d959277ff1b5
bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
712 with peer.commandexecutor() as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
713 cg = e.callcommand( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
714 b'changegroupsubset', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
715 { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
716 b'bases': incoming, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
717 b'heads': rheads, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
718 b'source': b'incoming', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
719 }, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
720 ).result() |
37635
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37497
diff
changeset
|
721 |
26543
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
722 if localrepo: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
723 bundletype = b"HG10BZ" |
26543
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
724 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
725 bundletype = b"HG10UN" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
726 fname = bundle = bundle2.writebundle(ui, cg, bundlename, bundletype) |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
727 # keep written bundle? |
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
728 if bundlename: |
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
729 bundle = None |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
16686
diff
changeset
|
730 if not localrepo: |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
731 # use the created uncompressed bundlerepo |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
732 localrepo = bundlerepo = makebundlerepository( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
733 repo.baseui, repo.root, fname |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
734 ) |
39603
a8d2faeca49e
bundlerepo: factor out code for instantiating a bundle repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39602
diff
changeset
|
735 |
37642
d959277ff1b5
bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
736 # this repo contains local and peer now, so filter out local again |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
737 common = repo.heads() |
18568
cd403d6d96ef
incoming: fix incoming when a local head is remotely filtered (issue3805)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18418
diff
changeset
|
738 if localrepo: |
cd403d6d96ef
incoming: fix incoming when a local head is remotely filtered (issue3805)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18418
diff
changeset
|
739 # Part of common may be remotely filtered |
cd403d6d96ef
incoming: fix incoming when a local head is remotely filtered (issue3805)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18418
diff
changeset
|
740 # So use an unfiltered version |
cd403d6d96ef
incoming: fix incoming when a local head is remotely filtered (issue3805)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18418
diff
changeset
|
741 # The discovery process probably need cleanup to avoid that |
cd403d6d96ef
incoming: fix incoming when a local head is remotely filtered (issue3805)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18418
diff
changeset
|
742 localrepo = localrepo.unfiltered() |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
743 |
14412
9ac479758d3b
bundlerepo: make getremotechanges support filtering of incoming
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14287
diff
changeset
|
744 csets = localrepo.changelog.findmissing(common, rheads) |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
745 |
23633
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
746 if bundlerepo: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
747 reponodes = [ctx.node() for ctx in bundlerepo[bundlerepo.firstnewrev :]] |
37643
1aa4d646d0de
bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37642
diff
changeset
|
748 |
1aa4d646d0de
bundlerepo: use command executor for wire protocol commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37642
diff
changeset
|
749 with peer.commandexecutor() as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
750 remotephases = e.callcommand( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45814
diff
changeset
|
751 b'listkeys', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45814
diff
changeset
|
752 { |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45814
diff
changeset
|
753 b'namespace': b'phases', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45814
diff
changeset
|
754 }, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
755 ).result() |
23633
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
756 |
48241
7d1e60244561
path: keep the path instance in the `pulloperation`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47398
diff
changeset
|
757 pullop = exchange.pulloperation( |
7d1e60244561
path: keep the path instance in the `pulloperation`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47398
diff
changeset
|
758 bundlerepo, peer, path=None, heads=reponodes |
7d1e60244561
path: keep the path instance in the `pulloperation`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47398
diff
changeset
|
759 ) |
23633
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
760 pullop.trmanager = bundletransactionmanager() |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
761 exchange._pullapplyphases(pullop, remotephases) |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
762 |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
763 def cleanup(): |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
764 if bundlerepo: |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
765 bundlerepo.close() |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
766 if bundle: |
21694
c08a22bfa16e
bundlerepo: backout dbf292f65b09
Matt Mackall <mpm@selenic.com>
parents:
21562
diff
changeset
|
767 os.unlink(bundle) |
37642
d959277ff1b5
bundlerepo: rename "other" to "peer"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
768 peer.close() |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
769 |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
770 return (localrepo, csets, cleanup) |