Mercurial > hg
annotate mercurial/bundlerepo.py @ 32076:d7b698ae153b stable
help: explain how to access subtopics in internals
author | Matt DeVore <matvore@google.com> |
---|---|
date | Wed, 19 Apr 2017 17:04:22 -0700 |
parents | 37e793918c07 |
children | 634997248c97 |
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 |
25920
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
14 from __future__ import absolute_import |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
15 |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
16 import os |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
17 import shutil |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
18 import tempfile |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
19 |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
20 from .i18n import _ |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
21 from .node import nullid |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
22 |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
23 from . import ( |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
24 bundle2, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
25 changegroup, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
26 changelog, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
27 cmdutil, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
28 discovery, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
29 error, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
30 exchange, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
31 filelog, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
32 localrepo, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
33 manifest, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
34 mdiff, |
28714
dac81729fea4
bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents:
28666
diff
changeset
|
35 node as nodemod, |
25920
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
36 pathutil, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
37 phases, |
30519
20a42325fdef
py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30375
diff
changeset
|
38 pycompat, |
25920
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
39 revlog, |
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
40 util, |
31240
5f68e7341ada
vfs: use 'vfs' module directly in 'mercurial.bundlerepo'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30924
diff
changeset
|
41 vfs as vfsmod, |
25920
5aaf51c14fea
bundlerepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25830
diff
changeset
|
42 ) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
43 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
44 class bundlerevlog(revlog.revlog): |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
45 def __init__(self, opener, indexfile, bundle, 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
|
46 # How it works: |
18410
de7dac2a58e8
bundlerepo: fix outdated comment
Mads Kiilerich <madski@unity3d.com>
parents:
18216
diff
changeset
|
47 # 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
|
48 # 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
|
49 # (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
|
50 # |
18410
de7dac2a58e8
bundlerepo: fix outdated comment
Mads Kiilerich <madski@unity3d.com>
parents:
18216
diff
changeset
|
51 # 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
|
52 # 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
|
53 opener = vfsmod.readonlyvfs(opener) |
4257
1b5c38e9d7aa
revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents:
4029
diff
changeset
|
54 revlog.revlog.__init__(self, opener, indexfile) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
55 self.bundle = bundle |
6750
fb42030d79d6
add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents:
6647
diff
changeset
|
56 n = len(self) |
18643
cc28a84db8c9
bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents:
18568
diff
changeset
|
57 self.repotiprev = n - 1 |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
58 chain = None |
18411
8b0f0dd56cec
bundlerepo: improve performance for bundle() revset expression
Mads Kiilerich <madski@unity3d.com>
parents:
18410
diff
changeset
|
59 self.bundlerevs = set() # used by 'bundle()' revset expression |
29711
ac5f6b11aa91
bundlerevlog: use for loop over iterator instead of while True
Augie Fackler <augie@google.com>
parents:
29710
diff
changeset
|
60 getchunk = lambda: bundle.deltachunk(chain) |
ac5f6b11aa91
bundlerevlog: use for loop over iterator instead of while True
Augie Fackler <augie@google.com>
parents:
29710
diff
changeset
|
61 for chunkdata in iter(getchunk, {}): |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
62 node = chunkdata['node'] |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
63 p1 = chunkdata['p1'] |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
64 p2 = chunkdata['p2'] |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
65 cs = chunkdata['cs'] |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
66 deltabase = chunkdata['deltabase'] |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
67 delta = chunkdata['delta'] |
31835
4bafc80f827e
bundlerepo: build revlog index with flags
Jun Wu <quark@fb.com>
parents:
31834
diff
changeset
|
68 flags = chunkdata['flags'] |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
69 |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
70 size = len(delta) |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
71 start = bundle.tell() - size |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
72 |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
73 link = linkmapper(cs) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
74 if node in self.nodemap: |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
75 # this can happen if two branches make the same change |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
76 chain = node |
18411
8b0f0dd56cec
bundlerepo: improve performance for bundle() revset expression
Mads Kiilerich <madski@unity3d.com>
parents:
18410
diff
changeset
|
77 self.bundlerevs.add(self.nodemap[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
|
78 continue |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
79 |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
80 for p in (p1, p2): |
16686
67964cda8701
cleanup: "not x in y" -> "x not in y"
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
81 if p not in self.nodemap: |
9650
1ad02c04356c
bundlerepo: fix small bug in exception raising
Sune Foldager <cryo@cyanite.org>
parents:
9198
diff
changeset
|
82 raise error.LookupError(p, self.indexfile, |
7633 | 83 _("unknown parent")) |
18416
87f370c5fef5
bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents:
18415
diff
changeset
|
84 |
87f370c5fef5
bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents:
18415
diff
changeset
|
85 if deltabase not in self.nodemap: |
87f370c5fef5
bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents:
18415
diff
changeset
|
86 raise LookupError(deltabase, self.indexfile, |
87f370c5fef5
bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents:
18415
diff
changeset
|
87 _('unknown delta base')) |
87f370c5fef5
bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents:
18415
diff
changeset
|
88 |
87f370c5fef5
bundlerepo: store validated deltabase rev in basemap instead of node
Mads Kiilerich <madski@unity3d.com>
parents:
18415
diff
changeset
|
89 baserev = self.rev(deltabase) |
5167
aba624d2301d
fix bundlerepo broken by 4205f626dc05
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4989
diff
changeset
|
90 # start, size, full unc. size, base (unused), link, p1, p2, node |
31835
4bafc80f827e
bundlerepo: build revlog index with flags
Jun Wu <quark@fb.com>
parents:
31834
diff
changeset
|
91 e = (revlog.offset_type(start, flags), size, -1, baserev, link, |
4979
06abdaf78788
revlog: add a magic null revision to our index
Matt Mackall <mpm@selenic.com>
parents:
4918
diff
changeset
|
92 self.rev(p1), self.rev(p2), node) |
06abdaf78788
revlog: add a magic null revision to our index
Matt Mackall <mpm@selenic.com>
parents:
4918
diff
changeset
|
93 self.index.insert(-1, e) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
94 self.nodemap[node] = n |
18411
8b0f0dd56cec
bundlerepo: improve performance for bundle() revset expression
Mads Kiilerich <madski@unity3d.com>
parents:
18410
diff
changeset
|
95 self.bundlerevs.add(n) |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
96 chain = 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
|
97 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
|
98 |
9676
48bf28d3c8dd
bundlerepo: keep the bundlerevlog interface in sync with revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9650
diff
changeset
|
99 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
|
100 # 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
|
101 # 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
|
102 # 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
|
103 if rev <= self.repotiprev: |
9676
48bf28d3c8dd
bundlerepo: keep the bundlerevlog interface in sync with revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9650
diff
changeset
|
104 return revlog.revlog._chunk(self, rev) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
105 self.bundle.seek(self.start(rev)) |
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
106 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
|
107 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
108 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
|
109 """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
|
110 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
|
111 # 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
|
112 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
|
113 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
|
114 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
|
115 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
|
116 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
|
117 |
31837
37e793918c07
bundlerepo: use raw revision in revdiff()
Jun Wu <quark@fb.com>
parents:
31836
diff
changeset
|
118 return mdiff.textdiff(self.revision(rev1, raw=True), |
37e793918c07
bundlerepo: use raw revision in revdiff()
Jun Wu <quark@fb.com>
parents:
31836
diff
changeset
|
119 self.revision(rev2, raw=True)) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
120 |
30743
2df983125d37
revlog: add 'raw' argument to revision and _addrevision
Remi Chaintron <remi@fb.com>
parents:
30584
diff
changeset
|
121 def revision(self, nodeorrev, raw=False): |
16435
df347129305d
revlog: fix partial revision() docstring (from d7d64b89a65c)
Patrick Mezard <patrick@mezard.eu>
parents:
16375
diff
changeset
|
122 """return an uncompressed revision of a given node or revision |
df347129305d
revlog: fix partial revision() docstring (from d7d64b89a65c)
Patrick Mezard <patrick@mezard.eu>
parents:
16375
diff
changeset
|
123 number. |
df347129305d
revlog: fix partial revision() docstring (from d7d64b89a65c)
Patrick Mezard <patrick@mezard.eu>
parents:
16375
diff
changeset
|
124 """ |
16375
d7d64b89a65c
revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents:
16195
diff
changeset
|
125 if isinstance(nodeorrev, int): |
d7d64b89a65c
revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents:
16195
diff
changeset
|
126 rev = nodeorrev |
d7d64b89a65c
revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents:
16195
diff
changeset
|
127 node = self.node(rev) |
d7d64b89a65c
revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents:
16195
diff
changeset
|
128 else: |
d7d64b89a65c
revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents:
16195
diff
changeset
|
129 node = nodeorrev |
d7d64b89a65c
revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents:
16195
diff
changeset
|
130 rev = self.rev(node) |
d7d64b89a65c
revlog: allow retrieving contents by revision number
Matt Mackall <mpm@selenic.com>
parents:
16195
diff
changeset
|
131 |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
132 if node == nullid: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
133 return "" |
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 |
31836
4598e8f43e20
bundlerepo: fix raw handling in revision()
Jun Wu <quark@fb.com>
parents:
31835
diff
changeset
|
135 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
|
136 chain = [] |
18415
95b8629fd2de
bundlerepo: use rev instead of node for iteration in revision()
Mads Kiilerich <madski@unity3d.com>
parents:
18414
diff
changeset
|
137 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
|
138 # 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
|
139 while iterrev > self.repotiprev: |
18415
95b8629fd2de
bundlerepo: use rev instead of node for iteration in revision()
Mads Kiilerich <madski@unity3d.com>
parents:
18414
diff
changeset
|
140 if self._cache and self._cache[1] == iterrev: |
31836
4598e8f43e20
bundlerepo: fix raw handling in revision()
Jun Wu <quark@fb.com>
parents:
31835
diff
changeset
|
141 rawtext = self._cache[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
|
142 break |
18415
95b8629fd2de
bundlerepo: use rev instead of node for iteration in revision()
Mads Kiilerich <madski@unity3d.com>
parents:
18414
diff
changeset
|
143 chain.append(iterrev) |
18643
cc28a84db8c9
bundlerepo: replace basemap with the base field in the index
Mads Kiilerich <mads@kiilerich.com>
parents:
18568
diff
changeset
|
144 iterrev = self.index[iterrev][3] |
31836
4598e8f43e20
bundlerepo: fix raw handling in revision()
Jun Wu <quark@fb.com>
parents:
31835
diff
changeset
|
145 if rawtext is None: |
4598e8f43e20
bundlerepo: fix raw handling in revision()
Jun Wu <quark@fb.com>
parents:
31835
diff
changeset
|
146 rawtext = self.baserevision(iterrev) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
147 |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
148 while chain: |
9676
48bf28d3c8dd
bundlerepo: keep the bundlerevlog interface in sync with revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9650
diff
changeset
|
149 delta = self._chunk(chain.pop()) |
31836
4598e8f43e20
bundlerepo: fix raw handling in revision()
Jun Wu <quark@fb.com>
parents:
31835
diff
changeset
|
150 rawtext = mdiff.patches(rawtext, [delta]) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
151 |
31836
4598e8f43e20
bundlerepo: fix raw handling in revision()
Jun Wu <quark@fb.com>
parents:
31835
diff
changeset
|
152 text, validatehash = self._processflags(rawtext, self.flags(rev), |
30745 | 153 'read', raw=raw) |
154 if validatehash: | |
155 self.checkhash(text, node, rev=rev) | |
31836
4598e8f43e20
bundlerepo: fix raw handling in revision()
Jun Wu <quark@fb.com>
parents:
31835
diff
changeset
|
156 self._cache = (node, rev, rawtext) |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
157 return text |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
158 |
19629
81241f978fd2
bundlerevlog: extract 'baserevision' method
Wojciech Lopata <lopek@fb.com>
parents:
18825
diff
changeset
|
159 def baserevision(self, nodeorrev): |
81241f978fd2
bundlerevlog: extract 'baserevision' method
Wojciech Lopata <lopek@fb.com>
parents:
18825
diff
changeset
|
160 # Revlog subclasses may override 'revision' method to modify format of |
81241f978fd2
bundlerevlog: extract 'baserevision' method
Wojciech Lopata <lopek@fb.com>
parents:
18825
diff
changeset
|
161 # content retrieved from revlog. To use bundlerevlog with such class one |
81241f978fd2
bundlerevlog: extract 'baserevision' method
Wojciech Lopata <lopek@fb.com>
parents:
18825
diff
changeset
|
162 # needs to override 'baserevision' and make more specific call here. |
31834
433ab46f6bb4
bundlerepo: make baserevision return raw text
Jun Wu <quark@fb.com>
parents:
31723
diff
changeset
|
163 return revlog.revlog.revision(self, nodeorrev, raw=True) |
19629
81241f978fd2
bundlerevlog: extract 'baserevision' method
Wojciech Lopata <lopek@fb.com>
parents:
18825
diff
changeset
|
164 |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
165 def addrevision(self, text, transaction, link, p1=None, p2=None, d=None): |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
166 raise NotImplementedError |
6647
602f7c1ab954
drop superfluous param from revlog.addgroup()
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
6569
diff
changeset
|
167 def addgroup(self, revs, linkmapper, transaction): |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
168 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
|
169 def strip(self, rev, minlink): |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
170 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
|
171 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
|
172 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
|
173 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
174 class bundlechangelog(bundlerevlog, changelog.changelog): |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
175 def __init__(self, opener, bundle): |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
176 changelog.changelog.__init__(self, opener) |
14142
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
177 linkmapper = lambda x: x |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
178 bundlerevlog.__init__(self, opener, self.indexfile, bundle, |
cb91ea6af733
bundlerepo: port to new bundle API
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14076
diff
changeset
|
179 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
|
180 |
19629
81241f978fd2
bundlerevlog: extract 'baserevision' method
Wojciech Lopata <lopek@fb.com>
parents:
18825
diff
changeset
|
181 def baserevision(self, nodeorrev): |
81241f978fd2
bundlerevlog: extract 'baserevision' method
Wojciech Lopata <lopek@fb.com>
parents:
18825
diff
changeset
|
182 # Although changelog doesn't override 'revision' method, some extensions |
81241f978fd2
bundlerevlog: extract 'baserevision' method
Wojciech Lopata <lopek@fb.com>
parents:
18825
diff
changeset
|
183 # may replace this class with another that does. Same story with |
81241f978fd2
bundlerevlog: extract 'baserevision' method
Wojciech Lopata <lopek@fb.com>
parents:
18825
diff
changeset
|
184 # manifest and filelog classes. |
24882
995003a324da
bundlerepo: disable filtering of changelog while constructing revision text
Yuya Nishihara <yuya@tcha.org>
parents:
24834
diff
changeset
|
185 |
995003a324da
bundlerepo: disable filtering of changelog while constructing revision text
Yuya Nishihara <yuya@tcha.org>
parents:
24834
diff
changeset
|
186 # This bypasses filtering on changelog.node() and rev() because we need |
995003a324da
bundlerepo: disable filtering of changelog while constructing revision text
Yuya Nishihara <yuya@tcha.org>
parents:
24834
diff
changeset
|
187 # revision text of the bundle base even if it is hidden. |
995003a324da
bundlerepo: disable filtering of changelog while constructing revision text
Yuya Nishihara <yuya@tcha.org>
parents:
24834
diff
changeset
|
188 oldfilter = self.filteredrevs |
995003a324da
bundlerepo: disable filtering of changelog while constructing revision text
Yuya Nishihara <yuya@tcha.org>
parents:
24834
diff
changeset
|
189 try: |
995003a324da
bundlerepo: disable filtering of changelog while constructing revision text
Yuya Nishihara <yuya@tcha.org>
parents:
24834
diff
changeset
|
190 self.filteredrevs = () |
31834
433ab46f6bb4
bundlerepo: make baserevision return raw text
Jun Wu <quark@fb.com>
parents:
31723
diff
changeset
|
191 return changelog.changelog.revision(self, nodeorrev, raw=True) |
24882
995003a324da
bundlerepo: disable filtering of changelog while constructing revision text
Yuya Nishihara <yuya@tcha.org>
parents:
24834
diff
changeset
|
192 finally: |
995003a324da
bundlerepo: disable filtering of changelog while constructing revision text
Yuya Nishihara <yuya@tcha.org>
parents:
24834
diff
changeset
|
193 self.filteredrevs = oldfilter |
19629
81241f978fd2
bundlerevlog: extract 'baserevision' method
Wojciech Lopata <lopek@fb.com>
parents:
18825
diff
changeset
|
194 |
30373
31de088945cd
manifest: add bundlemanifestlog support
Durham Goode <durham@fb.com>
parents:
30218
diff
changeset
|
195 class bundlemanifest(bundlerevlog, manifest.manifestrevlog): |
29715
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
196 def __init__(self, opener, bundle, linkmapper, dirlogstarts=None, dir=''): |
30373
31de088945cd
manifest: add bundlemanifestlog support
Durham Goode <durham@fb.com>
parents:
30218
diff
changeset
|
197 manifest.manifestrevlog.__init__(self, opener, dir=dir) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
198 bundlerevlog.__init__(self, opener, self.indexfile, bundle, |
4257
1b5c38e9d7aa
revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents:
4029
diff
changeset
|
199 linkmapper) |
29715
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
200 if dirlogstarts is None: |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
201 dirlogstarts = {} |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
202 if self.bundle.version == "03": |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
203 dirlogstarts = _getfilestarts(self.bundle) |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
204 self._dirlogstarts = dirlogstarts |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
205 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
|
206 |
19629
81241f978fd2
bundlerevlog: extract 'baserevision' method
Wojciech Lopata <lopek@fb.com>
parents:
18825
diff
changeset
|
207 def baserevision(self, nodeorrev): |
26399
1f0e78f8f55f
bundlerepo: let bundle repo look in the _mancache
Durham Goode <durham@fb.com>
parents:
25920
diff
changeset
|
208 node = nodeorrev |
1f0e78f8f55f
bundlerepo: let bundle repo look in the _mancache
Durham Goode <durham@fb.com>
parents:
25920
diff
changeset
|
209 if isinstance(node, int): |
1f0e78f8f55f
bundlerepo: let bundle repo look in the _mancache
Durham Goode <durham@fb.com>
parents:
25920
diff
changeset
|
210 node = self.node(node) |
1f0e78f8f55f
bundlerepo: let bundle repo look in the _mancache
Durham Goode <durham@fb.com>
parents:
25920
diff
changeset
|
211 |
29925
1619efcde9a4
manifest: make one use of _mancache avoid manifestctxs
Durham Goode <durham@fb.com>
parents:
29916
diff
changeset
|
212 if node in self.fulltextcache: |
31346
2a18e9e6ca43
py3: use bytearray() instead of array('c', ...) constructions
Augie Fackler <augie@google.com>
parents:
31240
diff
changeset
|
213 result = '%s' % self.fulltextcache[node] |
26399
1f0e78f8f55f
bundlerepo: let bundle repo look in the _mancache
Durham Goode <durham@fb.com>
parents:
25920
diff
changeset
|
214 else: |
31834
433ab46f6bb4
bundlerepo: make baserevision return raw text
Jun Wu <quark@fb.com>
parents:
31723
diff
changeset
|
215 result = manifest.manifestrevlog.revision(self, nodeorrev, raw=True) |
26399
1f0e78f8f55f
bundlerepo: let bundle repo look in the _mancache
Durham Goode <durham@fb.com>
parents:
25920
diff
changeset
|
216 return result |
19629
81241f978fd2
bundlerevlog: extract 'baserevision' method
Wojciech Lopata <lopek@fb.com>
parents:
18825
diff
changeset
|
217 |
29715
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
218 def dirlog(self, d): |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
219 if d in self._dirlogstarts: |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
220 self.bundle.seek(self._dirlogstarts[d]) |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
221 return bundlemanifest( |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
222 self.opener, self.bundle, self._linkmapper, |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
223 self._dirlogstarts, dir=d) |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
224 return super(bundlemanifest, self).dirlog(d) |
55d341877316
bundlerepo: add support for treemanifests in cg3 bundles
Augie Fackler <augie@google.com>
parents:
29713
diff
changeset
|
225 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
226 class bundlefilelog(bundlerevlog, filelog.filelog): |
24921
86c0b5c09ee6
bundlerepo: remove unused 'repo' parameter
Martin von Zweigbergk <martinvonz@google.com>
parents:
24882
diff
changeset
|
227 def __init__(self, opener, path, bundle, linkmapper): |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
228 filelog.filelog.__init__(self, opener, path) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
229 bundlerevlog.__init__(self, opener, self.indexfile, bundle, |
4257
1b5c38e9d7aa
revlog: don't pass datafile as an argument
Matt Mackall <mpm@selenic.com>
parents:
4029
diff
changeset
|
230 linkmapper) |
14287
7c231754a621
filelog: add file function to open other filelogs
Sune Foldager <cryo@cyanite.org>
parents:
14190
diff
changeset
|
231 |
19629
81241f978fd2
bundlerevlog: extract 'baserevision' method
Wojciech Lopata <lopek@fb.com>
parents:
18825
diff
changeset
|
232 def baserevision(self, nodeorrev): |
31834
433ab46f6bb4
bundlerepo: make baserevision return raw text
Jun Wu <quark@fb.com>
parents:
31723
diff
changeset
|
233 return filelog.filelog.revision(self, nodeorrev, raw=True) |
19629
81241f978fd2
bundlerevlog: extract 'baserevision' method
Wojciech Lopata <lopek@fb.com>
parents:
18825
diff
changeset
|
234 |
17193
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
235 class bundlepeer(localrepo.localpeer): |
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
236 def canpush(self): |
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
237 return False |
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
238 |
23631
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
239 class bundlephasecache(phases.phasecache): |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
240 def __init__(self, *args, **kwargs): |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
241 super(bundlephasecache, self).__init__(*args, **kwargs) |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
242 if util.safehasattr(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
|
243 self.opener = vfsmod.readonlyvfs(self.opener) |
23631
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
244 |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
245 def write(self): |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
246 raise NotImplementedError |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
247 |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
248 def _write(self, fp): |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
249 raise NotImplementedError |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
250 |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
251 def _updateroots(self, phase, newroots, tr): |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
252 self.phaseroots[phase] = newroots |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
253 self.invalidate() |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
254 self.dirty = True |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
255 |
29712
9e88077f972c
bundlerepo: introduce method to find file starts and use it
Augie Fackler <augie@google.com>
parents:
29711
diff
changeset
|
256 def _getfilestarts(bundle): |
9e88077f972c
bundlerepo: introduce method to find file starts and use it
Augie Fackler <augie@google.com>
parents:
29711
diff
changeset
|
257 bundlefilespos = {} |
9e88077f972c
bundlerepo: introduce method to find file starts and use it
Augie Fackler <augie@google.com>
parents:
29711
diff
changeset
|
258 for chunkdata in iter(bundle.filelogheader, {}): |
9e88077f972c
bundlerepo: introduce method to find file starts and use it
Augie Fackler <augie@google.com>
parents:
29711
diff
changeset
|
259 fname = chunkdata['filename'] |
9e88077f972c
bundlerepo: introduce method to find file starts and use it
Augie Fackler <augie@google.com>
parents:
29711
diff
changeset
|
260 bundlefilespos[fname] = bundle.tell() |
9e88077f972c
bundlerepo: introduce method to find file starts and use it
Augie Fackler <augie@google.com>
parents:
29711
diff
changeset
|
261 for chunk in iter(lambda: bundle.deltachunk(None), {}): |
9e88077f972c
bundlerepo: introduce method to find file starts and use it
Augie Fackler <augie@google.com>
parents:
29711
diff
changeset
|
262 pass |
9e88077f972c
bundlerepo: introduce method to find file starts and use it
Augie Fackler <augie@google.com>
parents:
29711
diff
changeset
|
263 return bundlefilespos |
9e88077f972c
bundlerepo: introduce method to find file starts and use it
Augie Fackler <augie@google.com>
parents:
29711
diff
changeset
|
264 |
1946
9fee186f7f0d
bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1942
diff
changeset
|
265 class bundlerepository(localrepo.localrepository): |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
266 def __init__(self, ui, path, bundlename): |
26800
7cac6ee41be7
bundlerepo: move temp-bundle writing logic into a closure
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
267 def _writetempbundle(read, suffix, header=''): |
7cac6ee41be7
bundlerepo: move temp-bundle writing logic into a closure
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
268 """Write a temporary file to disk |
7cac6ee41be7
bundlerepo: move temp-bundle writing logic into a closure
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
269 |
7cac6ee41be7
bundlerepo: move temp-bundle writing logic into a closure
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
270 This is closure because we need to make sure this tracked by |
7cac6ee41be7
bundlerepo: move temp-bundle writing logic into a closure
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
271 self.tempfile for cleanup purposes.""" |
7cac6ee41be7
bundlerepo: move temp-bundle writing logic into a closure
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
272 fdtemp, temp = self.vfs.mkstemp(prefix="hg-bundle-", |
7cac6ee41be7
bundlerepo: move temp-bundle writing logic into a closure
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
273 suffix=".hg10un") |
7cac6ee41be7
bundlerepo: move temp-bundle writing logic into a closure
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
274 self.tempfile = temp |
7cac6ee41be7
bundlerepo: move temp-bundle writing logic into a closure
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
275 |
30924
48dea083f66d
py3: convert the mode argument of os.fdopen to unicodes (1 of 2)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30745
diff
changeset
|
276 with os.fdopen(fdtemp, pycompat.sysstr('wb')) as fptemp: |
26800
7cac6ee41be7
bundlerepo: move temp-bundle writing logic into a closure
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
277 fptemp.write(header) |
7cac6ee41be7
bundlerepo: move temp-bundle writing logic into a closure
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
278 while True: |
7cac6ee41be7
bundlerepo: move temp-bundle writing logic into a closure
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
279 chunk = read(2**18) |
7cac6ee41be7
bundlerepo: move temp-bundle writing logic into a closure
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
280 if not chunk: |
7cac6ee41be7
bundlerepo: move temp-bundle writing logic into a closure
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
281 break |
7cac6ee41be7
bundlerepo: move temp-bundle writing logic into a closure
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
282 fptemp.write(chunk) |
7cac6ee41be7
bundlerepo: move temp-bundle writing logic into a closure
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
283 |
7cac6ee41be7
bundlerepo: move temp-bundle writing logic into a closure
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
284 return self.vfs.open(self.tempfile, mode="rb") |
6314
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
285 self._tempparent = None |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
286 try: |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
287 localrepo.localrepository.__init__(self, ui, path) |
7637 | 288 except error.RepoError: |
6314
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
289 self._tempparent = tempfile.mkdtemp() |
9198
061eeb602354
coding style: use a space after comma
Martin Geisler <mg@lazybytes.net>
parents:
8312
diff
changeset
|
290 localrepo.instance(ui, self._tempparent, 1) |
6314
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
291 localrepo.localrepository.__init__(self, ui, self._tempparent) |
20790
49f2d5644f04
config: set a 'source' in most cases where config don't come from file but code
Mads Kiilerich <madski@unity3d.com>
parents:
19629
diff
changeset
|
292 self.ui.setconfig('phases', 'publish', False, 'bundlerepo') |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
293 |
6129
3d666e8e6398
bundlerepo: fix inconsistency of parsed and internal name (issue #821)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5664
diff
changeset
|
294 if path: |
11154
17031fea4e95
expand paths to local repository or bundle in appropriate classes
Alexander Solovyov <piranha@piranha.org.ua>
parents:
10282
diff
changeset
|
295 self._url = 'bundle:' + util.expandpath(path) + '+' + bundlename |
6129
3d666e8e6398
bundlerepo: fix inconsistency of parsed and internal name (issue #821)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5664
diff
changeset
|
296 else: |
3d666e8e6398
bundlerepo: fix inconsistency of parsed and internal name (issue #821)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5664
diff
changeset
|
297 self._url = 'bundle:' + bundlename |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
298 |
2273
f116ddea537f
add support for compressed bundle repositories
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2257
diff
changeset
|
299 self.tempfile = None |
13274
57d433f632b7
bundlerepo: use less intrusive util.posixfile to open bundle
Adrian Buehlmann <adrian@cadifra.com>
parents:
12962
diff
changeset
|
300 f = util.posixfile(bundlename, "rb") |
24072
145b823f5ce7
bundlerepo: keep track of the original bundle object
Eric Sumner <ericsumner@fb.com>
parents:
24003
diff
changeset
|
301 self.bundlefile = self.bundle = exchange.readbundle(ui, f, bundlename) |
12044
bcc7139521b7
bundlerepo: remove duplication of bundle decompressors
Matt Mackall <mpm@selenic.com>
parents:
11154
diff
changeset
|
302 |
24073
ff5caa8dfd99
bundlerepo: basic bundle2 support
Eric Sumner <ericsumner@fb.com>
parents:
24072
diff
changeset
|
303 if isinstance(self.bundle, bundle2.unbundle20): |
26803
ed41ce89822d
bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26801
diff
changeset
|
304 cgstream = None |
ed41ce89822d
bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26801
diff
changeset
|
305 for part in self.bundle.iterparts(): |
ed41ce89822d
bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26801
diff
changeset
|
306 if part.type == 'changegroup': |
ed41ce89822d
bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26801
diff
changeset
|
307 if cgstream is not None: |
ed41ce89822d
bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26801
diff
changeset
|
308 raise NotImplementedError("can't process " |
ed41ce89822d
bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26801
diff
changeset
|
309 "multiple changegroups") |
ed41ce89822d
bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26801
diff
changeset
|
310 cgstream = part |
ed41ce89822d
bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26801
diff
changeset
|
311 version = part.params.get('version', '01') |
29713
43924f3a55fa
bundlerepo: use supportedincomingversions instead of allsupportedversions
Augie Fackler <augie@google.com>
parents:
29712
diff
changeset
|
312 legalcgvers = changegroup.supportedincomingversions(self) |
43924f3a55fa
bundlerepo: use supportedincomingversions instead of allsupportedversions
Augie Fackler <augie@google.com>
parents:
29712
diff
changeset
|
313 if version not in legalcgvers: |
26803
ed41ce89822d
bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26801
diff
changeset
|
314 msg = _('Unsupported changegroup version: %s') |
ed41ce89822d
bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26801
diff
changeset
|
315 raise error.Abort(msg % version) |
ed41ce89822d
bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26801
diff
changeset
|
316 if self.bundle.compressed(): |
ed41ce89822d
bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26801
diff
changeset
|
317 cgstream = _writetempbundle(part.read, |
ed41ce89822d
bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26801
diff
changeset
|
318 ".cg%sun" % version) |
24073
ff5caa8dfd99
bundlerepo: basic bundle2 support
Eric Sumner <ericsumner@fb.com>
parents:
24072
diff
changeset
|
319 |
26803
ed41ce89822d
bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26801
diff
changeset
|
320 if cgstream is None: |
29389
98e8313dcd9e
i18n: translate abort messages
liscju <piotr.listkiewicz@gmail.com>
parents:
28714
diff
changeset
|
321 raise error.Abort(_('No changegroups found')) |
26803
ed41ce89822d
bundlerepo: properly extract compressed changegroup from bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26801
diff
changeset
|
322 cgstream.seek(0) |
24073
ff5caa8dfd99
bundlerepo: basic bundle2 support
Eric Sumner <ericsumner@fb.com>
parents:
24072
diff
changeset
|
323 |
27751
a40e2f7fe49d
changegroup: hide packermap behind methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
26803
diff
changeset
|
324 self.bundle = changegroup.getunbundler(version, cgstream, 'UN') |
24073
ff5caa8dfd99
bundlerepo: basic bundle2 support
Eric Sumner <ericsumner@fb.com>
parents:
24072
diff
changeset
|
325 |
26801
73bf76bf6f14
bundlerepo: uncompress changegroup in bundle1 case only
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26800
diff
changeset
|
326 elif self.bundle.compressed(): |
73bf76bf6f14
bundlerepo: uncompress changegroup in bundle1 case only
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26800
diff
changeset
|
327 f = _writetempbundle(self.bundle.read, '.hg10un', header='HG10UN') |
73bf76bf6f14
bundlerepo: uncompress changegroup in bundle1 case only
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26800
diff
changeset
|
328 self.bundlefile = self.bundle = exchange.readbundle(ui, f, |
73bf76bf6f14
bundlerepo: uncompress changegroup in bundle1 case only
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26800
diff
changeset
|
329 bundlename, |
73bf76bf6f14
bundlerepo: uncompress changegroup in bundle1 case only
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26800
diff
changeset
|
330 self.vfs) |
73bf76bf6f14
bundlerepo: uncompress changegroup in bundle1 case only
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26800
diff
changeset
|
331 |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
332 # dict with the mapping 'filename' -> position in the bundle |
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
333 self.bundlefilespos = {} |
5262 | 334 |
23632
e7fcf58acd71
bundlerepo: retract phase boundary
Eric Sumner <ericsumner@fb.com>
parents:
23631
diff
changeset
|
335 self.firstnewrev = self.changelog.repotiprev + 1 |
e7fcf58acd71
bundlerepo: retract phase boundary
Eric Sumner <ericsumner@fb.com>
parents:
23631
diff
changeset
|
336 phases.retractboundary(self, None, phases.draft, |
e7fcf58acd71
bundlerepo: retract phase boundary
Eric Sumner <ericsumner@fb.com>
parents:
23631
diff
changeset
|
337 [ctx.node() for ctx in self[self.firstnewrev:]]) |
e7fcf58acd71
bundlerepo: retract phase boundary
Eric Sumner <ericsumner@fb.com>
parents:
23631
diff
changeset
|
338 |
18014
a39fe76c4c65
clfilter: ensure that filecache on localrepo is unfiltered
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17913
diff
changeset
|
339 @localrepo.unfilteredpropertycache |
23631
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
340 def _phasecache(self): |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
341 return bundlephasecache(self, self._phasedefaults) |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
342 |
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
22182
diff
changeset
|
343 @localrepo.unfilteredpropertycache |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
344 def changelog(self): |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14142
diff
changeset
|
345 # consume the header if it exists |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14142
diff
changeset
|
346 self.bundle.changelogheader() |
23878
37a92908a382
localrepo: remove all external users of localrepo.sopener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23633
diff
changeset
|
347 c = bundlechangelog(self.svfs, self.bundle) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
348 self.manstart = self.bundle.tell() |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
349 return c |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
350 |
30218
1767723f71cf
manifest: move manifest creation to a helper function
Durham Goode <durham@fb.com>
parents:
29925
diff
changeset
|
351 def _constructmanifest(self): |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
352 self.bundle.seek(self.manstart) |
14144
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14142
diff
changeset
|
353 # consume the header if it exists |
3c3c53d8343a
unbundler: separate delta and header parsing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
14142
diff
changeset
|
354 self.bundle.manifestheader() |
28221
7a8c44844f57
bundlerepo: properly handle hidden linkrev in manifestlog (issue4945)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28186
diff
changeset
|
355 linkmapper = self.unfiltered().changelog.rev |
7a8c44844f57
bundlerepo: properly handle hidden linkrev in manifestlog (issue4945)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28186
diff
changeset
|
356 m = bundlemanifest(self.svfs, self.bundle, linkmapper) |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
357 self.filestart = self.bundle.tell() |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
358 return m |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
359 |
18014
a39fe76c4c65
clfilter: ensure that filecache on localrepo is unfiltered
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17913
diff
changeset
|
360 @localrepo.unfilteredpropertycache |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
361 def manstart(self): |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
362 self.changelog |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
363 return self.manstart |
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
364 |
18014
a39fe76c4c65
clfilter: ensure that filecache on localrepo is unfiltered
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17913
diff
changeset
|
365 @localrepo.unfilteredpropertycache |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
366 def filestart(self): |
30375
11b8b740d54a
manifest: remove last uses of repo.manifest
Durham Goode <durham@fb.com>
parents:
30373
diff
changeset
|
367 self.manifestlog |
8260
54a4b520bd7d
localrepo: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
368 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
|
369 |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
370 def url(self): |
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
371 return self._url |
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2273
diff
changeset
|
372 |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
373 def file(self, f): |
5262 | 374 if not self.bundlefilespos: |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
375 self.bundle.seek(self.filestart) |
29712
9e88077f972c
bundlerepo: introduce method to find file starts and use it
Augie Fackler <augie@google.com>
parents:
29711
diff
changeset
|
376 self.bundlefilespos = _getfilestarts(self.bundle) |
5262 | 377 |
1942
9da45de3118d
add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
378 if f in self.bundlefilespos: |
12332
680fe77ab5b8
bundlerepo: use bundle objects everywhere
Matt Mackall <mpm@selenic.com>
parents:
12331
diff
changeset
|
379 self.bundle.seek(self.bundlefilespos[f]) |
28186
5ab6f0fde75f
bundlerepo: properly handle hidden linkrev in filelog (issue4945)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27953
diff
changeset
|
380 linkmapper = self.unfiltered().changelog.rev |
5ab6f0fde75f
bundlerepo: properly handle hidden linkrev in filelog (issue4945)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27953
diff
changeset
|
381 return bundlefilelog(self.svfs, f, self.bundle, 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
|
382 else: |
23878
37a92908a382
localrepo: remove all external users of localrepo.sopener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23633
diff
changeset
|
383 return filelog.filelog(self.svfs, 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
|
384 |
12347
6277a9469dff
bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents:
12335
diff
changeset
|
385 def close(self): |
6277a9469dff
bundlerepo: restore close() method
Matt Mackall <mpm@selenic.com>
parents:
12335
diff
changeset
|
386 """Close assigned bundle file immediately.""" |
24072
145b823f5ce7
bundlerepo: keep track of the original bundle object
Eric Sumner <ericsumner@fb.com>
parents:
24003
diff
changeset
|
387 self.bundlefile.close() |
12962
ff083040a555
bundlerepository: get rid of temporary bundle files (issue2478)
Klaus Koch <kuk42@gmx.net>
parents:
12961
diff
changeset
|
388 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
|
389 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
|
390 if self._tempparent: |
9a1c59283ad3
Add ability to directly clone from all-history bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
6312
diff
changeset
|
391 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
|
392 |
6315 | 393 def cancopy(self): |
394 return False | |
395 | |
17193
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
396 def peer(self): |
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
397 return bundlepeer(self) |
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17191
diff
changeset
|
398 |
7435
5e13df32fb74
bundlerepo doesn't really have a dirstate, throw AttributeError if requested
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6953
diff
changeset
|
399 def getcwd(self): |
30519
20a42325fdef
py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30375
diff
changeset
|
400 return pycompat.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
|
401 |
28714
dac81729fea4
bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents:
28666
diff
changeset
|
402 # Check if parents exist in localrepo before setting |
dac81729fea4
bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents:
28666
diff
changeset
|
403 def setparents(self, p1, p2=nullid): |
dac81729fea4
bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents:
28666
diff
changeset
|
404 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
|
405 p2rev = self.changelog.rev(p2) |
dac81729fea4
bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents:
28666
diff
changeset
|
406 msg = _("setting parent to node %s that only exists in the bundle\n") |
dac81729fea4
bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents:
28666
diff
changeset
|
407 if self.changelog.repotiprev < p1rev: |
dac81729fea4
bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents:
28666
diff
changeset
|
408 self.ui.warn(msg % nodemod.hex(p1)) |
dac81729fea4
bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents:
28666
diff
changeset
|
409 if self.changelog.repotiprev < p2rev: |
dac81729fea4
bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents:
28666
diff
changeset
|
410 self.ui.warn(msg % nodemod.hex(p2)) |
dac81729fea4
bundle: warn when update to revision existing only in a bundle (issue5004)
liscju <piotr.listkiewicz@gmail.com>
parents:
28666
diff
changeset
|
411 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
|
412 |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
413 def instance(ui, path, create): |
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
414 if create: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26544
diff
changeset
|
415 raise error.Abort(_('cannot create new bundle repository')) |
25830
5418dd5be8ac
bundlerepo: mark internal-only config variable
Matt Mackall <mpm@selenic.com>
parents:
24921
diff
changeset
|
416 # internal config: bundle.mainreporoot |
5664
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
417 parentpath = ui.config("bundle", "mainreporoot", "") |
16042
4b7aa1c899dc
bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents:
15597
diff
changeset
|
418 if not parentpath: |
4b7aa1c899dc
bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents:
15597
diff
changeset
|
419 # try to find the correct path to the working directory repo |
30519
20a42325fdef
py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30375
diff
changeset
|
420 parentpath = cmdutil.findrepo(pycompat.getcwd()) |
16042
4b7aa1c899dc
bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents:
15597
diff
changeset
|
421 if parentpath is None: |
4b7aa1c899dc
bundlerepo: try to find containing repo on creation (issue1812)
Matt Mackall <mpm@selenic.com>
parents:
15597
diff
changeset
|
422 parentpath = '' |
5664
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
423 if parentpath: |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
424 # 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
|
425 # In particular, we don't want temp dir names in test outputs. |
30519
20a42325fdef
py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30375
diff
changeset
|
426 cwd = pycompat.getcwd() |
5664
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
427 if parentpath == cwd: |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
428 parentpath = '' |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
429 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
|
430 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
|
431 if parentpath.startswith(cwd): |
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
432 parentpath = parentpath[len(cwd):] |
14076
924c82157d46
url: move URL parsing functions into util to improve startup time
Brodie Rao <brodie@bitheap.org>
parents:
14073
diff
changeset
|
433 u = util.url(path) |
13826
e574207e3bcd
url: refactor util.drop_scheme() and hg.localpath() into url.localpath()
Brodie Rao <brodie@bitheap.org>
parents:
13742
diff
changeset
|
434 path = u.localpath() |
e574207e3bcd
url: refactor util.drop_scheme() and hg.localpath() into url.localpath()
Brodie Rao <brodie@bitheap.org>
parents:
13742
diff
changeset
|
435 if u.scheme == 'bundle': |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
436 s = path.split("+", 1) |
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
437 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
|
438 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
|
439 else: |
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
440 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
|
441 else: |
5664
da72b4d24797
Fix income/pull with bundle and -R (issue 820).
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5558
diff
changeset
|
442 repopath, bundlename = parentpath, path |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
443 return bundlerepository(ui, repopath, bundlename) |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
444 |
23633
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
445 class bundletransactionmanager(object): |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
446 def transaction(self): |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
447 return None |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
448 |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
449 def close(self): |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
450 raise NotImplementedError |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
451 |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
452 def release(self): |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
453 raise NotImplementedError |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
454 |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
455 def getremotechanges(ui, repo, other, onlyheads=None, bundlename=None, |
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14004
diff
changeset
|
456 force=False): |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
457 '''obtains a bundle of changes incoming from other |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
458 |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
459 "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
|
460 specified heads. |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
461 "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
|
462 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
|
463 the returned "cleanupfn". |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
464 "force" indicates whether to proceed on unrelated repos. |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
465 |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
466 Returns a tuple (local, csets, cleanupfn): |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
467 |
16683 | 468 "local" is a local repo from which to obtain the actual incoming |
469 changesets; it is a bundlerepo for the obtained bundle when the | |
470 original "other" is remote. | |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
471 "csets" lists the incoming changeset node ids. |
16683 | 472 "cleanupfn" must be called without arguments when you're done processing |
473 the changes; it closes both the original "other" and the one returned | |
474 here. | |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
475 ''' |
16683 | 476 tmp = discovery.findcommonincoming(repo, other, heads=onlyheads, |
477 force=force) | |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
478 common, incoming, rheads = tmp |
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
479 if not incoming: |
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
480 try: |
15091
106f89299da6
bundlerepo: add argument check before unlink
Sune Foldager <cryo@cyanite.org>
parents:
14494
diff
changeset
|
481 if bundlename: |
21694
c08a22bfa16e
bundlerepo: backout dbf292f65b09
Matt Mackall <mpm@selenic.com>
parents:
21562
diff
changeset
|
482 os.unlink(bundlename) |
14004
97ed99d1f419
eliminate various naked except clauses
Idan Kamara <idankk86@gmail.com>
parents:
13826
diff
changeset
|
483 except OSError: |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
484 pass |
18138
8ab0640c3090
bundlerepo: don't return the peer without bundlerepo from getremotechanges
Mads Kiilerich <madski@unity3d.com>
parents:
17193
diff
changeset
|
485 return repo, [], other.close |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
486 |
22182
510cafe72004
incoming: don't request heads that already are common
Mads Kiilerich <madski@unity3d.com>
parents:
21694
diff
changeset
|
487 commonset = set(common) |
510cafe72004
incoming: don't request heads that already are common
Mads Kiilerich <madski@unity3d.com>
parents:
21694
diff
changeset
|
488 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
|
489 |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
490 bundle = None |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
491 bundlerepo = None |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
16686
diff
changeset
|
492 localrepo = other.local() |
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
16686
diff
changeset
|
493 if bundlename or not localrepo: |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
494 # create a bundle (uncompressed if other repo is not local) |
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
495 |
29684
ff5d5751fc1b
bundlerepo: also read the 'devel.legacy.exchange' config
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29389
diff
changeset
|
496 # developer config: devel.legacy.exchange |
ff5d5751fc1b
bundlerepo: also read the 'devel.legacy.exchange' config
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29389
diff
changeset
|
497 legexc = ui.configlist('devel', 'legacy.exchange') |
29689
39537bc64442
bundle2: remove 'experimental.bundle2-exp' boolean config (BC)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29684
diff
changeset
|
498 forcebundle1 = 'bundle2' not in legexc and 'bundle1' in legexc |
29684
ff5d5751fc1b
bundlerepo: also read the 'devel.legacy.exchange' config
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29389
diff
changeset
|
499 canbundle2 = (not forcebundle1 |
26544
1e8e0b01faba
incoming: request a bundle2 when possible (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26543
diff
changeset
|
500 and other.capable('getbundle') |
1e8e0b01faba
incoming: request a bundle2 when possible (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26543
diff
changeset
|
501 and other.capable('bundle2')) |
1e8e0b01faba
incoming: request a bundle2 when possible (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26543
diff
changeset
|
502 if canbundle2: |
1e8e0b01faba
incoming: request a bundle2 when possible (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26543
diff
changeset
|
503 kwargs = {} |
1e8e0b01faba
incoming: request a bundle2 when possible (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26543
diff
changeset
|
504 kwargs['common'] = common |
1e8e0b01faba
incoming: request a bundle2 when possible (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26543
diff
changeset
|
505 kwargs['heads'] = rheads |
1e8e0b01faba
incoming: request a bundle2 when possible (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26543
diff
changeset
|
506 kwargs['bundlecaps'] = exchange.caps20to10(repo) |
1e8e0b01faba
incoming: request a bundle2 when possible (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26543
diff
changeset
|
507 kwargs['cg'] = True |
1e8e0b01faba
incoming: request a bundle2 when possible (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26543
diff
changeset
|
508 b2 = other.getbundle('incoming', **kwargs) |
1e8e0b01faba
incoming: request a bundle2 when possible (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26543
diff
changeset
|
509 fname = bundle = changegroup.writechunks(ui, b2._forwardchunks(), |
1e8e0b01faba
incoming: request a bundle2 when possible (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26543
diff
changeset
|
510 bundlename) |
1e8e0b01faba
incoming: request a bundle2 when possible (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26543
diff
changeset
|
511 else: |
26543
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
512 if other.capable('getbundle'): |
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
513 cg = other.getbundle('incoming', common=common, heads=rheads) |
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
514 elif onlyheads is None and not other.capable('changegroupsubset'): |
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
515 # compat with older servers when pulling all remote heads |
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
516 cg = other.changegroup(incoming, "incoming") |
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
517 rheads = None |
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
518 else: |
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
519 cg = other.changegroupsubset(incoming, rheads, 'incoming') |
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
520 if localrepo: |
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
521 bundletype = "HG10BZ" |
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
522 else: |
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
523 bundletype = "HG10UN" |
28666
ae53ecc47414
bundle: move writebundle() from changegroup.py to bundle2.py (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
28221
diff
changeset
|
524 fname = bundle = bundle2.writebundle(ui, cg, bundlename, |
26543
a018cbabdb51
bundlerepo: indent some code to prepare next patch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26399
diff
changeset
|
525 bundletype) |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
526 # keep written bundle? |
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
527 if bundlename: |
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
528 bundle = None |
17191
5884812686f7
peer: introduce peer methods to prepare for peer classes
Sune Foldager <cryo@cyanite.org>
parents:
16686
diff
changeset
|
529 if not localrepo: |
12734
5dfd1c49dcc5
bundlerepo: unify common code into a new getremotechanges
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
12347
diff
changeset
|
530 # use the created uncompressed bundlerepo |
18825
f0564402d059
repo: repo isolation, do not pass on repo.ui for creating new repos
Simon Heimberg <simohe@besonet.ch>
parents:
18643
diff
changeset
|
531 localrepo = bundlerepo = bundlerepository(repo.baseui, repo.root, |
f0564402d059
repo: repo isolation, do not pass on repo.ui for creating new repos
Simon Heimberg <simohe@besonet.ch>
parents:
18643
diff
changeset
|
532 fname) |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
533 # this repo contains local and other now, so filter out local again |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
534 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
|
535 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
|
536 # 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
|
537 # 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
|
538 # 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
|
539 localrepo = localrepo.unfiltered() |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
540 |
14412
9ac479758d3b
bundlerepo: make getremotechanges support filtering of incoming
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14287
diff
changeset
|
541 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
|
542 |
23633
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
543 if bundlerepo: |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
544 reponodes = [ctx.node() for ctx in bundlerepo[bundlerepo.firstnewrev:]] |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
545 remotephases = other.listkeys('phases') |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
546 |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
547 pullop = exchange.pulloperation(bundlerepo, other, heads=reponodes) |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
548 pullop.trmanager = bundletransactionmanager() |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
549 exchange._pullapplyphases(pullop, remotephases) |
96c3cbec006f
incoming: handle phases the same as pull
Eric Sumner <ericsumner@fb.com>
parents:
23632
diff
changeset
|
550 |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
551 def cleanup(): |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
552 if bundlerepo: |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
553 bundlerepo.close() |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
554 if bundle: |
21694
c08a22bfa16e
bundlerepo: backout dbf292f65b09
Matt Mackall <mpm@selenic.com>
parents:
21562
diff
changeset
|
555 os.unlink(bundle) |
14190
8aab5a82685f
bundlerepo: fix closing and docstring of getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14161
diff
changeset
|
556 other.close() |
14161
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
557 |
8a0fca925992
bundlerepo: fix and improve getremotechanges
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14158
diff
changeset
|
558 return (localrepo, csets, cleanup) |