Mercurial > hg
annotate mercurial/filelog.py @ 52245:d57d1606049c stable
clone: properly exclude rev-branch-cache from post clone cache warming
When adding "CACHE_REV_BRANCH" to "CACHES_ALL" in e51161b12c7e, I did not
expected it to impact the clone steps. However the "CACHES_POST_CLONE" set is
created rather creatively. (we should fix that, but not on stable)
The benchmark caught a quite significant slowdown one hardlink and ssh-stream
clones. Such slow down can be reduced to around ~5% by fully warming the cache
before the clone. However keeping this expensive step away from the clone
operation fully fix the slowdown and preserve the initial intend.
Example slowdow for hardlink clone
### benchmark.name = hg.command.clone
# bin-env-vars.hg.flavor = default
# bin-env-vars.hg.py-re2-module = default
# benchmark.variants.explicit-rev = none
# benchmark.variants.issue6528 = default
# benchmark.variants.protocol = local-hardlink
# benchmark.variants.pulled-delta-reuse-policy = default
# benchmark.variants.resource-usage = default
# benchmark.variants.validate = default
## data-env-vars.name = netbeans-2018-08-01-zstd-sparse-revlog
6.8.2: 19.799752
6.9rc0: 29.017493 (+46.55%, +9.22)
after: 19.929341
## data-env-vars.name = mercurial-public-2018-08-01-zstd-sparse-revlog
6.8.2: 0.468020
6.9rc0: 1.701294 (+263.51%, +1.23)
after: 0.471934
## data-env-vars.name = pypy-2024-03-22-zstd-sparse-revlog
6.8.2: 2.397564
6.9rc0: 5.666641 (+137.41%, +3.28)
after: 2.428085
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 13 Nov 2024 13:33:36 +0100 |
parents | 2876d077a796 |
children |
rev | line source |
---|---|
1089 | 1 # filelog.py - file history class for mercurial |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
2 # |
46819
d4ba4d51f85f
contributor: change mentions of mpm to olivia
Raphaël Gomès <rgomes@octobus.net>
parents:
46780
diff
changeset
|
3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com> |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
4 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
7634
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. |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
7 |
51863
f4733654f144
typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents:
51826
diff
changeset
|
8 from __future__ import annotations |
25948
34bd1a5eef5b
filelog: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24255
diff
changeset
|
9 |
51826
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51822
diff
changeset
|
10 from typing import ( |
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51822
diff
changeset
|
11 Iterable, |
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51822
diff
changeset
|
12 Iterator, |
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51822
diff
changeset
|
13 ) |
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51822
diff
changeset
|
14 |
40389
1b183edbb68e
repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40387
diff
changeset
|
15 from .i18n import _ |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46819
diff
changeset
|
16 from .node import nullrev |
25948
34bd1a5eef5b
filelog: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24255
diff
changeset
|
17 from . import ( |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
18 error, |
42813
268662aac075
interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
42720
diff
changeset
|
19 revlog, |
268662aac075
interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
42720
diff
changeset
|
20 ) |
268662aac075
interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
42720
diff
changeset
|
21 from .interfaces import ( |
37441
a3202fa83aff
filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35567
diff
changeset
|
22 repository, |
25948
34bd1a5eef5b
filelog: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24255
diff
changeset
|
23 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
24 from .utils import storageutil |
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
25 from .revlogutils import ( |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
26 constants as revlog_constants, |
47821
c30ca163b45e
issue6528: also filter delta on the fly when applying a changegroup
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47820
diff
changeset
|
27 rewrite, |
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
28 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
29 |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
30 |
52066
2876d077a796
filelog: drop the CamelCase name for `filelog.filelog`
Matt Harbison <matt_harbison@yahoo.com>
parents:
52065
diff
changeset
|
31 class filelog: # (repository.ifilestorage) |
51826
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51822
diff
changeset
|
32 _revlog: revlog.revlog |
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51822
diff
changeset
|
33 nullid: bytes |
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51822
diff
changeset
|
34 _fix_issue6528: bool |
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51822
diff
changeset
|
35 |
50316
87f0155d68aa
revlog: improve the robustness of the splitting process
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49766
diff
changeset
|
36 def __init__(self, opener, path, try_split=False): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
37 self._revlog = revlog.revlog( |
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
38 opener, |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
39 # XXX should use the unencoded path |
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
40 target=(revlog_constants.KIND_FILELOG, path), |
47150
8d3c2f9d4af7
revlog: use a "radix" to address revlog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47148
diff
changeset
|
41 radix=b'/'.join((b'data', path)), |
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
42 censorable=True, |
49012
5b65721a75eb
revlog: recommit 49fd21f32695 with a fix for issue6528
Joerg Sonnenberger <joerg@bec.de>
parents:
48946
diff
changeset
|
43 canonical_parent_order=False, # see comment in revlog.py |
50316
87f0155d68aa
revlog: improve the robustness of the splitting process
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49766
diff
changeset
|
44 try_split=try_split, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
45 ) |
39783
76f92d208f7a
filelog: record what's using attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39782
diff
changeset
|
46 # Full name of the user visible file, relative to the repository root. |
76f92d208f7a
filelog: record what's using attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39782
diff
changeset
|
47 # Used by LFS. |
39856
96838b620b9c
filelog: store filename directly on revlog instance
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39855
diff
changeset
|
48 self._revlog.filename = path |
46780
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46715
diff
changeset
|
49 self.nullid = self._revlog.nullid |
47822
2813d406b036
issue6528: add a config option to control the fixing on the fly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47821
diff
changeset
|
50 opts = opener.options |
2813d406b036
issue6528: add a config option to control the fixing on the fly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47821
diff
changeset
|
51 self._fix_issue6528 = opts.get(b'issue6528.fix-incoming', True) |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
52 |
51826
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51822
diff
changeset
|
53 def get_revlog(self) -> revlog.revlog: |
50637
32837c7e2e4b
revlog: add a `get_revlog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50316
diff
changeset
|
54 """return an actual revlog instance if any |
32837c7e2e4b
revlog: add a `get_revlog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50316
diff
changeset
|
55 |
32837c7e2e4b
revlog: add a `get_revlog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50316
diff
changeset
|
56 This exist because a lot of code leverage the fact the underlying |
32837c7e2e4b
revlog: add a `get_revlog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50316
diff
changeset
|
57 storage is a revlog for optimization, so giving simple way to access |
32837c7e2e4b
revlog: add a `get_revlog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50316
diff
changeset
|
58 the revlog instance helps such code. |
32837c7e2e4b
revlog: add a `get_revlog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50316
diff
changeset
|
59 """ |
32837c7e2e4b
revlog: add a `get_revlog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50316
diff
changeset
|
60 return self._revlog |
32837c7e2e4b
revlog: add a `get_revlog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50316
diff
changeset
|
61 |
51826
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51822
diff
changeset
|
62 def __len__(self) -> int: |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
63 return len(self._revlog) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
64 |
51826
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51822
diff
changeset
|
65 def __iter__(self) -> Iterator[int]: |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
66 return self._revlog.__iter__() |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
67 |
40387
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
68 def hasnode(self, node): |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46819
diff
changeset
|
69 if node in (self.nullid, nullrev): |
40387
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
70 return False |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
71 |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
72 try: |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
73 self._revlog.rev(node) |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
74 return True |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
75 except (TypeError, ValueError, IndexError, error.LookupError): |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
76 return False |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
77 |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
78 def revs(self, start=0, stop=None): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
79 return self._revlog.revs(start=start, stop=stop) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
80 |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
81 def parents(self, node): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
82 return self._revlog.parents(node) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
83 |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
84 def parentrevs(self, rev): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
85 return self._revlog.parentrevs(rev) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
86 |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
87 def rev(self, node): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
88 return self._revlog.rev(node) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
89 |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
90 def node(self, rev): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
91 return self._revlog.node(rev) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
92 |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
93 def lookup(self, node): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
94 return storageutil.fileidlookup( |
47155
96ee8ca99f5a
revlog: use revlog.display_id in LookupError
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47150
diff
changeset
|
95 self._revlog, node, self._revlog.display_id |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
96 ) |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
97 |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
98 def linkrev(self, rev): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
99 return self._revlog.linkrev(rev) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
100 |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
101 def commonancestorsheads(self, node1, node2): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
102 return self._revlog.commonancestorsheads(node1, node2) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
103 |
39783
76f92d208f7a
filelog: record what's using attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39782
diff
changeset
|
104 # Used by dagop.blockdescendants(). |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
105 def descendants(self, revs): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
106 return self._revlog.descendants(revs) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
107 |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
108 def heads(self, start=None, stop=None): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
109 return self._revlog.heads(start, stop) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
110 |
39783
76f92d208f7a
filelog: record what's using attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39782
diff
changeset
|
111 # Used by hgweb, children extension. |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
112 def children(self, node): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
113 return self._revlog.children(node) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
114 |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
115 def iscensored(self, rev): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
116 return self._revlog.iscensored(rev) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
117 |
51022
33d2f0164d0d
revlog: drop the df argument to `revision`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50637
diff
changeset
|
118 def revision(self, node): |
33d2f0164d0d
revlog: drop the df argument to `revision`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50637
diff
changeset
|
119 return self._revlog.revision(node) |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
120 |
51023
14de15825253
revlog: drop the df argument to `rawdata`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51022
diff
changeset
|
121 def rawdata(self, node): |
14de15825253
revlog: drop the df argument to `rawdata`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51022
diff
changeset
|
122 return self._revlog.rawdata(node) |
42720
bf1e8d2ab900
rawdata: forward the method call on `filelog` object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
123 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
124 def emitrevisions( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
125 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
126 nodes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
127 nodesorder=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
128 revisiondata=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
129 assumehaveparentrevisions=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
130 deltamode=repository.CG_DELTAMODE_STD, |
46715
45f0d5297698
changegroupv4: add sidedata helpers
Raphaël Gomès <rgomes@octobus.net>
parents:
46714
diff
changeset
|
131 sidedata_helpers=None, |
49609
9cac281eb9c0
debug: add an option to display statistic about a bundling operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49207
diff
changeset
|
132 debug_info=None, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
133 ): |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
134 return self._revlog.emitrevisions( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
135 nodes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
136 nodesorder=nodesorder, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
137 revisiondata=revisiondata, |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
138 assumehaveparentrevisions=assumehaveparentrevisions, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
139 deltamode=deltamode, |
46715
45f0d5297698
changegroupv4: add sidedata helpers
Raphaël Gomès <rgomes@octobus.net>
parents:
46714
diff
changeset
|
140 sidedata_helpers=sidedata_helpers, |
49609
9cac281eb9c0
debug: add an option to display statistic about a bundling operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49207
diff
changeset
|
141 debug_info=debug_info, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
142 ) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
143 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
144 def addrevision( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
145 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
146 revisiondata, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
147 transaction, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
148 linkrev, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
149 p1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
150 p2, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
151 node=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
152 flags=revlog.REVIDX_DEFAULT_FLAGS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
153 cachedelta=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
154 ): |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
155 return self._revlog.addrevision( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
156 revisiondata, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
157 transaction, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
158 linkrev, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
159 p1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
160 p2, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
161 node=node, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
162 flags=flags, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
163 cachedelta=cachedelta, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
164 ) |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
165 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
166 def addgroup( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
167 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
168 deltas, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
169 linkmapper, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
170 transaction, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
171 addrevisioncb=None, |
45788
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
43077
diff
changeset
|
172 duplicaterevisioncb=None, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
173 maybemissingparents=False, |
49610
35d4c2124073
debug: add an option to display statistic about a unbundling operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49609
diff
changeset
|
174 debug_info=None, |
49766
152d9c011bcd
changegroup: add `delta_base_reuse_policy` argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49610
diff
changeset
|
175 delta_base_reuse_policy=None, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
176 ): |
40389
1b183edbb68e
repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40387
diff
changeset
|
177 if maybemissingparents: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
178 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
179 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
180 b'revlog storage does not support missing ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
181 b'parents write mode' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
182 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
183 ) |
40389
1b183edbb68e
repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40387
diff
changeset
|
184 |
47820
436932c2cfaa
filelog: open the writing context a bit earlier in `addgroup`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47155
diff
changeset
|
185 with self._revlog._writing(transaction): |
47822
2813d406b036
issue6528: add a config option to control the fixing on the fly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47821
diff
changeset
|
186 if self._fix_issue6528: |
2813d406b036
issue6528: add a config option to control the fixing on the fly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47821
diff
changeset
|
187 deltas = rewrite.filter_delta_issue6528(self._revlog, deltas) |
47821
c30ca163b45e
issue6528: also filter delta on the fly when applying a changegroup
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47820
diff
changeset
|
188 |
47820
436932c2cfaa
filelog: open the writing context a bit earlier in `addgroup`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47155
diff
changeset
|
189 return self._revlog.addgroup( |
436932c2cfaa
filelog: open the writing context a bit earlier in `addgroup`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47155
diff
changeset
|
190 deltas, |
436932c2cfaa
filelog: open the writing context a bit earlier in `addgroup`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47155
diff
changeset
|
191 linkmapper, |
436932c2cfaa
filelog: open the writing context a bit earlier in `addgroup`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47155
diff
changeset
|
192 transaction, |
436932c2cfaa
filelog: open the writing context a bit earlier in `addgroup`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47155
diff
changeset
|
193 addrevisioncb=addrevisioncb, |
436932c2cfaa
filelog: open the writing context a bit earlier in `addgroup`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47155
diff
changeset
|
194 duplicaterevisioncb=duplicaterevisioncb, |
49610
35d4c2124073
debug: add an option to display statistic about a unbundling operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49609
diff
changeset
|
195 debug_info=debug_info, |
49766
152d9c011bcd
changegroup: add `delta_base_reuse_policy` argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49610
diff
changeset
|
196 delta_base_reuse_policy=delta_base_reuse_policy, |
47820
436932c2cfaa
filelog: open the writing context a bit earlier in `addgroup`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47155
diff
changeset
|
197 ) |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
198 |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
199 def getstrippoint(self, minlink): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
200 return self._revlog.getstrippoint(minlink) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
201 |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
202 def strip(self, minlink, transaction): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
203 return self._revlog.strip(minlink, transaction) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
204 |
39778
a6b3c4c1019f
revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39765
diff
changeset
|
205 def censorrevision(self, tr, node, tombstone=b''): |
40056
324b4b10351e
revlog: rewrite censoring logic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40007
diff
changeset
|
206 return self._revlog.censorrevision(tr, node, tombstone=tombstone) |
39778
a6b3c4c1019f
revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39765
diff
changeset
|
207 |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
208 def files(self): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
209 return self._revlog.files() |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
210 |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
211 def read(self, node): |
39880
1b65fb4d43d6
storageutil: new function for extracting metadata-less content from text
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39878
diff
changeset
|
212 return storageutil.filtermetadata(self.revision(node)) |
360 | 213 |
214 def add(self, text, meta, transaction, link, p1=None, p2=None): | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
215 if meta or text.startswith(b'\1\n'): |
39878
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39876
diff
changeset
|
216 text = storageutil.packmeta(meta, text) |
46508
f7b61ad3c64a
revlog: change addrevision to return the new revision, not node
Joerg Sonnenberger <joerg@bec.de>
parents:
45788
diff
changeset
|
217 rev = self.addrevision(text, transaction, link, p1, p2) |
f7b61ad3c64a
revlog: change addrevision to return the new revision, not node
Joerg Sonnenberger <joerg@bec.de>
parents:
45788
diff
changeset
|
218 return self.node(rev) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
219 |
1116 | 220 def renamed(self, node): |
40005
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
221 return storageutil.filerevisioncopied(self, node) |
1116 | 222 |
2898
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
223 def size(self, rev): |
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
224 """return the size of a given revision""" |
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
225 |
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
226 # for revisions with renames, we have to go the slow way |
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
227 node = self.node(rev) |
49166
77b5a190571c
censor: fix [hg update] away from a revision with censored files
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48529
diff
changeset
|
228 if self.iscensored(rev): |
77b5a190571c
censor: fix [hg update] away from a revision with censored files
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48529
diff
changeset
|
229 return 0 |
2898
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
230 if self.renamed(node): |
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
231 return len(self.read(node)) |
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
232 |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11539
diff
changeset
|
233 # XXX if self.read(node).startswith("\1\n"), this returns (size+4) |
49012
5b65721a75eb
revlog: recommit 49fd21f32695 with a fix for issue6528
Joerg Sonnenberger <joerg@bec.de>
parents:
48946
diff
changeset
|
234 # XXX See also basefilectx.cmp. |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
235 return self._revlog.size(rev) |
2898
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
236 |
2887
05257fd28591
filelog: add hash-based comparisons
Matt Mackall <mpm@selenic.com>
parents:
2859
diff
changeset
|
237 def cmp(self, node, text): |
11539
a463e3c50212
cmp: document the fact that we return True if content is different
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10706
diff
changeset
|
238 """compare text with a given file revision |
a463e3c50212
cmp: document the fact that we return True if content is different
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10706
diff
changeset
|
239 |
a463e3c50212
cmp: document the fact that we return True if content is different
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10706
diff
changeset
|
240 returns True if text is different than what is stored. |
a463e3c50212
cmp: document the fact that we return True if content is different
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10706
diff
changeset
|
241 """ |
40007
1470183068b8
storageutil: invert logic of file data comparison
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40006
diff
changeset
|
242 return not storageutil.filedataequivalent(self, node, text) |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
243 |
52065
9e94f9dbbbe8
revlog: drop the CamelCase name for `revlog.revlogproblem`
Matt Harbison <matt_harbison@yahoo.com>
parents:
51863
diff
changeset
|
244 def verifyintegrity(self, state) -> Iterable[revlog.revlogproblem]: |
39842
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
245 return self._revlog.verifyintegrity(state) |
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
246 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
247 def storageinfo( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
248 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
249 exclusivefiles=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
250 sharedfiles=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
251 revisionscount=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
252 trackedsize=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
253 storedsize=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
254 ): |
39869
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
255 return self._revlog.storageinfo( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
256 exclusivefiles=exclusivefiles, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
257 sharedfiles=sharedfiles, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
258 revisionscount=revisionscount, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
259 trackedsize=trackedsize, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
260 storedsize=storedsize, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
261 ) |
39869
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
262 |
39783
76f92d208f7a
filelog: record what's using attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39782
diff
changeset
|
263 # Used by repo upgrade. |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
264 def clone(self, tr, destrevlog, **kwargs): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
265 if not isinstance(destrevlog, filelog): |
49207
8960d8eb747b
filelog: show the passed argument on error
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49180
diff
changeset
|
266 msg = b'expected filelog to clone(), not %r' |
8960d8eb747b
filelog: show the passed argument on error
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49180
diff
changeset
|
267 msg %= destrevlog |
8960d8eb747b
filelog: show the passed argument on error
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49180
diff
changeset
|
268 raise error.ProgrammingError(msg) |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
269 |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
270 return self._revlog.clone(tr, destrevlog._revlog, **kwargs) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
271 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42814
diff
changeset
|
272 |
39765
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
273 class narrowfilelog(filelog): |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
274 """Filelog variation to be used with narrow stores.""" |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
275 |
50316
87f0155d68aa
revlog: improve the robustness of the splitting process
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49766
diff
changeset
|
276 def __init__(self, opener, path, narrowmatch, try_split=False): |
87f0155d68aa
revlog: improve the robustness of the splitting process
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49766
diff
changeset
|
277 super(narrowfilelog, self).__init__(opener, path, try_split=try_split) |
39765
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
278 self._narrowmatch = narrowmatch |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
279 |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
280 def renamed(self, node): |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
281 res = super(narrowfilelog, self).renamed(node) |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
282 |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
283 # Renames that come from outside the narrowspec are problematic |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
284 # because we may lack the base text for the rename. This can result |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
285 # in code attempting to walk the ancestry or compute a diff |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
286 # encountering a missing revision. We address this by silently |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
287 # removing rename metadata if the source file is outside the |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
288 # narrow spec. |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
289 # |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
290 # A better solution would be to see if the base revision is available, |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
291 # rather than assuming it isn't. |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
292 # |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
293 # An even better solution would be to teach all consumers of rename |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
294 # metadata that the base revision may not be available. |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
295 # |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
296 # TODO consider better ways of doing this. |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
297 if res and not self._narrowmatch(res[0]): |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
298 return None |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
299 |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
300 return res |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
301 |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
302 def size(self, rev): |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
303 # Because we have a custom renamed() that may lie, we need to call |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
304 # the base renamed() to report accurate results. |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
305 node = self.node(rev) |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
306 if super(narrowfilelog, self).renamed(node): |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
307 return len(self.read(node)) |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
308 else: |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
309 return super(narrowfilelog, self).size(rev) |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
310 |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
311 def cmp(self, node, text): |
46530
b994db7c4d1e
narrow: fix flaky behavior described in issue6150
Raphaël Gomès <rgomes@octobus.net>
parents:
45788
diff
changeset
|
312 # We don't call `super` because narrow parents can be buggy in case of a |
b994db7c4d1e
narrow: fix flaky behavior described in issue6150
Raphaël Gomès <rgomes@octobus.net>
parents:
45788
diff
changeset
|
313 # ambiguous dirstate. Always take the slow path until there is a better |
b994db7c4d1e
narrow: fix flaky behavior described in issue6150
Raphaël Gomès <rgomes@octobus.net>
parents:
45788
diff
changeset
|
314 # fix, see issue6150. |
39765
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
315 |
46530
b994db7c4d1e
narrow: fix flaky behavior described in issue6150
Raphaël Gomès <rgomes@octobus.net>
parents:
45788
diff
changeset
|
316 # Censored files compare against the empty file. |
b994db7c4d1e
narrow: fix flaky behavior described in issue6150
Raphaël Gomès <rgomes@octobus.net>
parents:
45788
diff
changeset
|
317 if self.iscensored(self.rev(node)): |
b994db7c4d1e
narrow: fix flaky behavior described in issue6150
Raphaël Gomès <rgomes@octobus.net>
parents:
45788
diff
changeset
|
318 return text != b'' |
39765
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
319 |
46530
b994db7c4d1e
narrow: fix flaky behavior described in issue6150
Raphaël Gomès <rgomes@octobus.net>
parents:
45788
diff
changeset
|
320 return self.read(node) != text |