Mercurial > hg-stable
annotate mercurial/unionrepo.py @ 51901:f4733654f144
typing: add `from __future__ import annotations` to most files
Now that py36 is no longer supported, we can postpone annotation evaluation.
This means that the quoting is usually optional (for things imported under the
guard of `if typing.TYPE_CHECKING:` to avoid circular imports), and there's less
overhead on startup[1].
There may be some missing here. I backed out 6000f5b25c9b (which removed the
`from __future__ import ...` that was supporting py2), reverted the changes in
`contrib/`, `doc/`, and `tests/`, and then ran:
$ hg status -n --change . | \
xargs sed -i -e 's/from __future__ import .*$/from __future__ import annotations/'
There were some minor tweaks needed when reviewing (mostly making the spacing
around the import consistent, and `mercurial/testing/__init__.py` had a
multiline import that wasn't fully rewritten.
[1] https://docs.python.org/3/whatsnew/3.7.html#pep-563-postponed-evaluation-of-annotations
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 16 Sep 2024 15:36:44 +0200 |
parents | 0338fb200a30 |
children | 1b17309cdaab |
rev | line source |
---|---|
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
1 # unionrepo.py - repository class for viewing union of repository changesets |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
2 # |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
3 # Derived from bundlerepo.py |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
4 # Copyright 2006, 2007 Benoit Boissinot <bboissin@gmail.com> |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
5 # Copyright 2013 Unity Technologies, Mads Kiilerich <madski@unity3d.com> |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
6 # |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
7 # This software may be used and distributed according to the terms of the |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
8 # GNU General Public License version 2 or any later version. |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
9 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
10 """Repository class for "in-memory pull" of one local repository to another, |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
11 allowing operations like diff and log with revsets. |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
12 """ |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
13 |
51901
f4733654f144
typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents:
51868
diff
changeset
|
14 from __future__ import annotations |
f4733654f144
typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents:
51868
diff
changeset
|
15 |
51018
93a44c1ba0c6
revlog: adapt the `reading` check for `unionrepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50952
diff
changeset
|
16 import contextlib |
93a44c1ba0c6
revlog: adapt the `reading` check for `unionrepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50952
diff
changeset
|
17 |
25988
83f220c7d6f0
unionrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24835
diff
changeset
|
18 |
83f220c7d6f0
unionrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24835
diff
changeset
|
19 from .i18n import _ |
83f220c7d6f0
unionrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24835
diff
changeset
|
20 |
83f220c7d6f0
unionrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24835
diff
changeset
|
21 from . import ( |
83f220c7d6f0
unionrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24835
diff
changeset
|
22 changelog, |
83f220c7d6f0
unionrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24835
diff
changeset
|
23 cmdutil, |
39823
24e493ec2229
py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
39779
diff
changeset
|
24 encoding, |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26230
diff
changeset
|
25 error, |
25988
83f220c7d6f0
unionrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24835
diff
changeset
|
26 filelog, |
83f220c7d6f0
unionrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24835
diff
changeset
|
27 localrepo, |
83f220c7d6f0
unionrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24835
diff
changeset
|
28 manifest, |
83f220c7d6f0
unionrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24835
diff
changeset
|
29 mdiff, |
83f220c7d6f0
unionrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24835
diff
changeset
|
30 pathutil, |
83f220c7d6f0
unionrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24835
diff
changeset
|
31 revlog, |
83f220c7d6f0
unionrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24835
diff
changeset
|
32 util, |
31252
854f9188e354
vfs: use 'vfs' module directly in 'mercurial.unionrepo'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30743
diff
changeset
|
33 vfs as vfsmod, |
25988
83f220c7d6f0
unionrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24835
diff
changeset
|
34 ) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
35 |
47260
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47164
diff
changeset
|
36 from .revlogutils import ( |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47164
diff
changeset
|
37 constants as revlog_constants, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47164
diff
changeset
|
38 ) |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47164
diff
changeset
|
39 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
40 |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
41 class unionrevlog(revlog.revlog): |
47164
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47162
diff
changeset
|
42 def __init__(self, opener, radix, revlog2, linkmapper): |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
43 # How it works: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
44 # To retrieve a revision, we just need to know the node id so we can |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
45 # look it up in revlog2. |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
46 # |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
47 # To differentiate a rev in the second revlog from a rev in the revlog, |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
48 # we check revision against repotiprev. |
31252
854f9188e354
vfs: use 'vfs' module directly in 'mercurial.unionrepo'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30743
diff
changeset
|
49 opener = vfsmod.readonlyvfs(opener) |
47089
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46793
diff
changeset
|
50 target = getattr(revlog2, 'target', None) |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46793
diff
changeset
|
51 if target is None: |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46793
diff
changeset
|
52 # a revlog wrapper, eg: the manifestlog that is not an actual revlog |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46793
diff
changeset
|
53 target = revlog2._revlog.target |
47164
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47162
diff
changeset
|
54 revlog.revlog.__init__(self, opener, target=target, radix=radix) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
55 self.revlog2 = revlog2 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
56 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
57 n = len(self) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
58 self.repotiprev = n - 1 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
59 self.bundlerevs = set() # used by 'bundle()' revset expression |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
60 for rev2 in self.revlog2: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
61 rev = self.revlog2.index[rev2] |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
62 # rev numbers - in revlog2, very different from self.rev |
47156
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47089
diff
changeset
|
63 ( |
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47089
diff
changeset
|
64 _start, |
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47089
diff
changeset
|
65 _csize, |
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47089
diff
changeset
|
66 rsize, |
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47089
diff
changeset
|
67 base, |
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47089
diff
changeset
|
68 linkrev, |
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47089
diff
changeset
|
69 p1rev, |
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47089
diff
changeset
|
70 p2rev, |
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47089
diff
changeset
|
71 node, |
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47089
diff
changeset
|
72 _sdo, |
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47089
diff
changeset
|
73 _sds, |
47260
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47164
diff
changeset
|
74 _dcm, |
47267
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47260
diff
changeset
|
75 _sdcm, |
48536
52034c42c09d
rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47267
diff
changeset
|
76 rank, |
47156
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47089
diff
changeset
|
77 ) = rev |
27433
12f727a5b434
changegroup: add flags field to cg3 delta header
Mike Edgar <adgar@google.com>
parents:
26587
diff
changeset
|
78 flags = _start & 0xFFFF |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
79 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
80 if linkmapper is None: # link is to same revlog |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
81 assert linkrev == rev2 # we never link back |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
82 link = n |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
83 else: # rev must be mapped from repo2 cl to unified cl by linkmapper |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
84 link = linkmapper(linkrev) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
85 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
86 if linkmapper is not None: # link is to same revlog |
26230
6b16a3538c20
unionrepo: take delta base in account with building unified revlog
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25988
diff
changeset
|
87 base = linkmapper(base) |
6b16a3538c20
unionrepo: take delta base in account with building unified revlog
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25988
diff
changeset
|
88 |
43613
f212cc5ffceb
index: use `index.get_rev` in `unionrepo.unionrevlog`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43581
diff
changeset
|
89 this_rev = self.index.get_rev(node) |
f212cc5ffceb
index: use `index.get_rev` in `unionrepo.unionrevlog`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43581
diff
changeset
|
90 if this_rev is not None: |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
91 # this happens for the common revlog revisions |
43613
f212cc5ffceb
index: use `index.get_rev` in `unionrepo.unionrevlog`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43581
diff
changeset
|
92 self.bundlerevs.add(this_rev) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
93 continue |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
94 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
95 p1node = self.revlog2.node(p1rev) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
96 p2node = self.revlog2.node(p2rev) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
97 |
45834
b6f4a1df91bd
unionrepo: don't insert index tuples with None as int field
Joerg Sonnenberger <joerg@bec.de>
parents:
45811
diff
changeset
|
98 # TODO: it's probably wrong to set compressed length to -1, but |
38209
df5f6881cebd
unionrepo: fill in uncompressed length of revlog entry
Yuya Nishihara <yuya@tcha.org>
parents:
37717
diff
changeset
|
99 # I have no idea if csize is valid in the base revlog context. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
100 e = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
101 flags, |
45834
b6f4a1df91bd
unionrepo: don't insert index tuples with None as int field
Joerg Sonnenberger <joerg@bec.de>
parents:
45811
diff
changeset
|
102 -1, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
103 rsize, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
104 base, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
105 link, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
106 self.rev(p1node), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
107 self.rev(p2node), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
108 node, |
47157
47ffc754989a
revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47156
diff
changeset
|
109 0, # sidedata offset |
47ffc754989a
revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47156
diff
changeset
|
110 0, # sidedata size |
47260
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47164
diff
changeset
|
111 revlog_constants.COMP_MODE_INLINE, |
47267
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47260
diff
changeset
|
112 revlog_constants.COMP_MODE_INLINE, |
48536
52034c42c09d
rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47267
diff
changeset
|
113 rank, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
114 ) |
38889
6104b203bec8
index: replace insert(-1, e) method by append(e) method
Martin von Zweigbergk <martinvonz@google.com>
parents:
38209
diff
changeset
|
115 self.index.append(e) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
116 self.bundlerevs.add(n) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
117 n += 1 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
118 |
51018
93a44c1ba0c6
revlog: adapt the `reading` check for `unionrepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50952
diff
changeset
|
119 @contextlib.contextmanager |
93a44c1ba0c6
revlog: adapt the `reading` check for `unionrepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50952
diff
changeset
|
120 def reading(self): |
93a44c1ba0c6
revlog: adapt the `reading` check for `unionrepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50952
diff
changeset
|
121 if 0 <= len(self.bundlerevs) < len(self.index): |
93a44c1ba0c6
revlog: adapt the `reading` check for `unionrepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50952
diff
changeset
|
122 read_1 = super().reading |
93a44c1ba0c6
revlog: adapt the `reading` check for `unionrepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50952
diff
changeset
|
123 else: |
93a44c1ba0c6
revlog: adapt the `reading` check for `unionrepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50952
diff
changeset
|
124 read_1 = util.nullcontextmanager |
93a44c1ba0c6
revlog: adapt the `reading` check for `unionrepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50952
diff
changeset
|
125 if 0 < len(self.bundlerevs): |
93a44c1ba0c6
revlog: adapt the `reading` check for `unionrepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50952
diff
changeset
|
126 read_2 = self.revlog2.reading |
93a44c1ba0c6
revlog: adapt the `reading` check for `unionrepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50952
diff
changeset
|
127 else: |
93a44c1ba0c6
revlog: adapt the `reading` check for `unionrepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50952
diff
changeset
|
128 read_2 = util.nullcontextmanager |
93a44c1ba0c6
revlog: adapt the `reading` check for `unionrepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50952
diff
changeset
|
129 with read_1(), read_2(): |
93a44c1ba0c6
revlog: adapt the `reading` check for `unionrepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50952
diff
changeset
|
130 yield |
93a44c1ba0c6
revlog: adapt the `reading` check for `unionrepo`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50952
diff
changeset
|
131 |
51031
8520db304f01
revlog: drop more file description passing between private function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51018
diff
changeset
|
132 def _chunk(self, rev): |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
133 if rev <= self.repotiprev: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
134 return revlog.revlog._chunk(self, rev) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
135 return self.revlog2._chunk(self.node(rev)) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
136 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
137 def revdiff(self, rev1, rev2): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
138 """return or calculate a delta between two revisions""" |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
139 if rev1 > self.repotiprev and rev2 > self.repotiprev: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
140 return self.revlog2.revdiff( |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
141 self.revlog2.rev(self.node(rev1)), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
142 self.revlog2.rev(self.node(rev2)), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
143 ) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
144 elif rev1 <= self.repotiprev and rev2 <= self.repotiprev: |
42837
a61a8f78da28
unionrepo: use normal inheritance scheme to call revdiff
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42836
diff
changeset
|
145 return super(unionrevlog, self).revdiff(rev1, rev2) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
146 |
42836
3e2520acf17b
unionrepo: fix `revdiff` implementation to use `rawdata`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42835
diff
changeset
|
147 return mdiff.textdiff(self.rawdata(rev1), self.rawdata(rev2)) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
148 |
51031
8520db304f01
revlog: drop more file description passing between private function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51018
diff
changeset
|
149 def _revisiondata(self, nodeorrev, raw=False): |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
150 if isinstance(nodeorrev, int): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
151 rev = nodeorrev |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
152 node = self.node(rev) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
153 else: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
154 node = nodeorrev |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
155 rev = self.rev(node) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
156 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
157 if rev > self.repotiprev: |
42834
64c3db458d08
unionrepo: use a lower level overide in unionrepo too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42743
diff
changeset
|
158 # work around manifestrevlog NOT being a revlog |
64c3db458d08
unionrepo: use a lower level overide in unionrepo too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42743
diff
changeset
|
159 revlog2 = getattr(self.revlog2, '_revlog', self.revlog2) |
64c3db458d08
unionrepo: use a lower level overide in unionrepo too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42743
diff
changeset
|
160 func = revlog2._revisiondata |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
161 else: |
42834
64c3db458d08
unionrepo: use a lower level overide in unionrepo too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42743
diff
changeset
|
162 func = super(unionrevlog, self)._revisiondata |
51031
8520db304f01
revlog: drop more file description passing between private function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51018
diff
changeset
|
163 return func(node, raw=raw) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
164 |
50031
90f047edab4f
unionrepo: resync several methods to actually override superclass methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
49865
diff
changeset
|
165 def addrevision( |
90f047edab4f
unionrepo: resync several methods to actually override superclass methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
49865
diff
changeset
|
166 self, |
90f047edab4f
unionrepo: resync several methods to actually override superclass methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
49865
diff
changeset
|
167 text, |
90f047edab4f
unionrepo: resync several methods to actually override superclass methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
49865
diff
changeset
|
168 transaction, |
90f047edab4f
unionrepo: resync several methods to actually override superclass methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
49865
diff
changeset
|
169 link, |
90f047edab4f
unionrepo: resync several methods to actually override superclass methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
49865
diff
changeset
|
170 p1, |
90f047edab4f
unionrepo: resync several methods to actually override superclass methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
49865
diff
changeset
|
171 p2, |
90f047edab4f
unionrepo: resync several methods to actually override superclass methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
49865
diff
changeset
|
172 cachedelta=None, |
90f047edab4f
unionrepo: resync several methods to actually override superclass methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
49865
diff
changeset
|
173 node=None, |
90f047edab4f
unionrepo: resync several methods to actually override superclass methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
49865
diff
changeset
|
174 flags=revlog.REVIDX_DEFAULT_FLAGS, |
90f047edab4f
unionrepo: resync several methods to actually override superclass methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
49865
diff
changeset
|
175 deltacomputer=None, |
90f047edab4f
unionrepo: resync several methods to actually override superclass methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
49865
diff
changeset
|
176 sidedata=None, |
90f047edab4f
unionrepo: resync several methods to actually override superclass methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
49865
diff
changeset
|
177 ): |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
178 raise NotImplementedError |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
179 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
180 def addgroup( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
181 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
182 deltas, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
183 linkmapper, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
184 transaction, |
46445
711ba0f1057e
revlog: decouple caching from addrevision callback for addgroup
Joerg Sonnenberger <joerg@bec.de>
parents:
45834
diff
changeset
|
185 alwayscache=False, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
186 addrevisioncb=None, |
45811
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
43613
diff
changeset
|
187 duplicaterevisioncb=None, |
50031
90f047edab4f
unionrepo: resync several methods to actually override superclass methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
49865
diff
changeset
|
188 debug_info=None, |
90f047edab4f
unionrepo: resync several methods to actually override superclass methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
49865
diff
changeset
|
189 delta_base_reuse_policy=None, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
190 ): |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
191 raise NotImplementedError |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
192 |
42231
94e2f8437f6b
unionrepo: sync with repository API
Joerg Sonnenberger <joerg@bec.de>
parents:
41041
diff
changeset
|
193 def strip(self, minlink, transaction): |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
194 raise NotImplementedError |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
195 |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
196 def checksize(self): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
197 raise NotImplementedError |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
198 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
199 |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
200 class unionchangelog(unionrevlog, changelog.changelog): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
201 def __init__(self, opener, opener2): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
202 changelog.changelog.__init__(self, opener) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
203 linkmapper = None |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
204 changelog2 = changelog.changelog(opener2) |
47164
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47162
diff
changeset
|
205 unionrevlog.__init__(self, opener, self.radix, changelog2, linkmapper) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
206 |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
207 |
30384
f2d146d1e8d6
manifest: add unionmanifestlog support
Durham Goode <durham@fb.com>
parents:
30218
diff
changeset
|
208 class unionmanifest(unionrevlog, manifest.manifestrevlog): |
51868
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51052
diff
changeset
|
209 repotiprev: int |
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51052
diff
changeset
|
210 revlog2: manifest.ManifestRevlog |
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51052
diff
changeset
|
211 |
46793
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46445
diff
changeset
|
212 def __init__(self, nodeconstants, opener, opener2, linkmapper): |
51033
f70ce1aedbcb
manifestrevlog: flag some inconsistency in bundle/union repo inheritance
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51031
diff
changeset
|
213 # XXX manifestrevlog is not actually a revlog , so mixing it with |
f70ce1aedbcb
manifestrevlog: flag some inconsistency in bundle/union repo inheritance
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51031
diff
changeset
|
214 # bundlerevlog is not a good idea. |
46793
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46445
diff
changeset
|
215 manifest.manifestrevlog.__init__(self, nodeconstants, opener) |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46445
diff
changeset
|
216 manifest2 = manifest.manifestrevlog(nodeconstants, opener2) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
217 unionrevlog.__init__( |
47164
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47162
diff
changeset
|
218 self, opener, self._revlog.radix, manifest2, linkmapper |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
219 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
220 |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
221 |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34226
diff
changeset
|
222 class unionfilelog(filelog.filelog): |
51868
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51052
diff
changeset
|
223 _revlog: unionrevlog |
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51052
diff
changeset
|
224 repotiprev: int |
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51052
diff
changeset
|
225 revlog2: revlog.revlog |
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51052
diff
changeset
|
226 |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
227 def __init__(self, opener, path, opener2, linkmapper, repo): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
228 filelog.filelog.__init__(self, opener, path) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
229 filelog2 = filelog.filelog(opener2, path) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
230 self._revlog = unionrevlog( |
47164
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47162
diff
changeset
|
231 opener, self._revlog.radix, filelog2._revlog, linkmapper |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
232 ) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
233 self._repo = repo |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34226
diff
changeset
|
234 self.repotiprev = self._revlog.repotiprev |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34226
diff
changeset
|
235 self.revlog2 = self._revlog.revlog2 |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
236 |
24118
76f6ae06ddf5
revlog: add "iscensored()" to revlog public API
Mike Edgar <adgar@google.com>
parents:
24003
diff
changeset
|
237 def iscensored(self, rev): |
76f6ae06ddf5
revlog: add "iscensored()" to revlog public API
Mike Edgar <adgar@google.com>
parents:
24003
diff
changeset
|
238 """Check if a revision is censored.""" |
76f6ae06ddf5
revlog: add "iscensored()" to revlog public API
Mike Edgar <adgar@google.com>
parents:
24003
diff
changeset
|
239 if rev <= self.repotiprev: |
76f6ae06ddf5
revlog: add "iscensored()" to revlog public API
Mike Edgar <adgar@google.com>
parents:
24003
diff
changeset
|
240 return filelog.filelog.iscensored(self, rev) |
27723
bf86e3e87123
unionrepo: fix wrong rev being checked in iscensored (issue5024)
Sean Farley <sean@farley.io>
parents:
26587
diff
changeset
|
241 node = self.node(rev) |
bf86e3e87123
unionrepo: fix wrong rev being checked in iscensored (issue5024)
Sean Farley <sean@farley.io>
parents:
26587
diff
changeset
|
242 return self.revlog2.iscensored(self.revlog2.rev(node)) |
24118
76f6ae06ddf5
revlog: add "iscensored()" to revlog public API
Mike Edgar <adgar@google.com>
parents:
24003
diff
changeset
|
243 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
244 |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
245 class unionpeer(localrepo.localpeer): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
246 def canpush(self): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
247 return False |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
248 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
249 |
49037
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48966
diff
changeset
|
250 class unionrepository: |
39621
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
251 """Represents the union of data in 2 repositories. |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
252 |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
253 Instances are not usable if constructed directly. Use ``instance()`` |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
254 or ``makeunionrepository()`` to create a usable instance. |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
255 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
256 |
39621
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
257 def __init__(self, repo2, url): |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
258 self.repo2 = repo2 |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
259 self._url = url |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
260 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
261 self.ui.setconfig(b'phases', b'publish', False, b'unionrepo') |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
262 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
263 @localrepo.unfilteredpropertycache |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
264 def changelog(self): |
23878
37a92908a382
localrepo: remove all external users of localrepo.sopener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20790
diff
changeset
|
265 return unionchangelog(self.svfs, self.repo2.svfs) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
266 |
39779
5ccd791344f3
localrepo: pass root manifest into manifestlog.__init__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39621
diff
changeset
|
267 @localrepo.unfilteredpropertycache |
5ccd791344f3
localrepo: pass root manifest into manifestlog.__init__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39621
diff
changeset
|
268 def manifestlog(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
269 rootstore = unionmanifest( |
46793
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46445
diff
changeset
|
270 self.nodeconstants, |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46445
diff
changeset
|
271 self.svfs, |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46445
diff
changeset
|
272 self.repo2.svfs, |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46445
diff
changeset
|
273 self.unfiltered()._clrev, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
274 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
275 return manifest.manifestlog( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
276 self.svfs, self, rootstore, self.narrowmatch() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
277 ) |
39779
5ccd791344f3
localrepo: pass root manifest into manifestlog.__init__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39621
diff
changeset
|
278 |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
279 def _clrev(self, rev2): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
280 """map from repo2 changelog rev to temporary rev in self.changelog""" |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
281 node = self.repo2.changelog.node(rev2) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
282 return self.changelog.rev(node) |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
283 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
284 def url(self): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
285 return self._url |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
286 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
287 def file(self, f): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
288 return unionfilelog( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
289 self.svfs, f, self.repo2.svfs, self.unfiltered()._clrev, self |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
290 ) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
291 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
292 def close(self): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
293 self.repo2.close() |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
294 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
295 def cancopy(self): |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
296 return False |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
297 |
50474
3a2df812e1c7
pull: add --remote-hidden option and pass it through peer creation
Manuel Jacob <me@manueljacob.de>
parents:
50031
diff
changeset
|
298 def peer(self, path=None, remotehidden=False): |
3a2df812e1c7
pull: add --remote-hidden option and pass it through peer creation
Manuel Jacob <me@manueljacob.de>
parents:
50031
diff
changeset
|
299 return unionpeer(self, path=None, remotehidden=remotehidden) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
300 |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
301 def getcwd(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
302 return encoding.getcwd() # always outside the repo |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
303 |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
304 |
39565
089fc0db0954
hg: allow extra arguments to be passed to repo creation (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38889
diff
changeset
|
305 def instance(ui, path, create, intents=None, createopts=None): |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
306 if create: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
307 raise error.Abort(_(b'cannot create new union repository')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
308 parentpath = ui.config(b"bundle", b"mainreporoot") |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
309 if not parentpath: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
310 # try to find the correct path to the working directory repo |
39823
24e493ec2229
py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
39779
diff
changeset
|
311 parentpath = cmdutil.findrepo(encoding.getcwd()) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
312 if parentpath is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
313 parentpath = b'' |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
314 if parentpath: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
315 # Try to make the full path relative so we get a nice, short URL. |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
316 # In particular, we don't want temp dir names in test outputs. |
39823
24e493ec2229
py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
39779
diff
changeset
|
317 cwd = encoding.getcwd() |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
318 if parentpath == cwd: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
319 parentpath = b'' |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
320 else: |
24835
e4f75c93f073
unionrepo: use pathutil.normasprefix to ensure os.sep at the end of cwd
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24118
diff
changeset
|
321 cwd = pathutil.normasprefix(cwd) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
322 if parentpath.startswith(cwd): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
323 parentpath = parentpath[len(cwd) :] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
324 if path.startswith(b'union:'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
325 s = path.split(b":", 1)[1].split(b"+", 1) |
18944
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
326 if len(s) == 1: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
327 repopath, repopath2 = parentpath, s[0] |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
328 else: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
329 repopath, repopath2 = s |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
330 else: |
a9c443b3b240
unionrepo: read-only operations on a union of two localrepos
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
331 repopath, repopath2 = parentpath, path |
39621
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
332 |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
333 return makeunionrepository(ui, repopath, repopath2) |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
334 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
335 |
39621
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
336 def makeunionrepository(ui, repopath1, repopath2): |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
337 """Make a union repository object from 2 local repo paths.""" |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
338 repo1 = localrepo.instance(ui, repopath1, create=False) |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
339 repo2 = localrepo.instance(ui, repopath2, create=False) |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
340 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
341 url = b'union:%s+%s' % ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
342 util.expandpath(repopath1), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
343 util.expandpath(repopath2), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42839
diff
changeset
|
344 ) |
39621
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
345 |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
346 class derivedunionrepository(unionrepository, repo1.__class__): |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
347 pass |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
348 |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
349 repo = repo1 |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
350 repo.__class__ = derivedunionrepository |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
351 unionrepository.__init__(repo1, repo2, url) |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
352 |
23f2299e9e53
unionrepo: dynamically create repository type from base repository
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39565
diff
changeset
|
353 return repo |