Debian Codegraph @

hgext/remotefilelog/remotefilectx.py

raw symbols SCIP
1 # remotefilectx.py - filectx/workingfilectx implementations for remotefilelog
2 #
3 # Copyright 2013 Facebook, Inc.
4 #
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
7
8 from __future__scip-python python python-stdlib 3.11 __future__/__init__: import annotationsscip-python python python-stdlib 3.11 __future__/annotations.annotations.
9
10 import collectionsscip-python python python-stdlib 3.11 collections/__init__:
11 import timescip-python python python-stdlib 3.11 time/__init__:
12
13 from typingscip-python python python-stdlib 3.11 typing/__init__: import (
14 Iteratorscip-python python python-stdlib 3.11 typing/Iterator#,
15 Protocolscip-python python python-stdlib 3.11 typing/Protocol.,
16 )
17
18 from mercurial.nodescip-python python mercurial 7.2.2 `mercurial.node`/__init__: import binscip-python python mercurial 7.2.2 `mercurial.node`/bin., hexscip-python python mercurial 7.2.2 `mercurial.node`/hex., nullrevscip-python python mercurial 7.2.2 `mercurial.node`/nullrev.
19 from mercurialscip-python python mercurial 7.2.2 mercurial/__init__: import (
20 contextscip-python python mercurial 7.2.2 `mercurial.context`/__init__:,
21 errorscip-python python mercurial 7.2.2 `mercurial.error`/__init__:,
22 phasesscip-python python mercurial 7.2.2 `mercurial.phases`/__init__:,
23 utilscip-python python mercurial 7.2.2 `mercurial.util`/__init__:,
24 )
25 from mercurial.interfacesscip-python python mercurial 7.2.2 `mercurial.interfaces`/__init__: import (
26 repositoryscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/__init__:,
27 )
28 from . import (
29 fileserverclientscip-python python mercurial 7.2.2 fileserverclient/__init__:,
30 shallowutilscip-python python mercurial 7.2.2 shallowutil/__init__:,
31 )
32
33 propertycachescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/propertycache. = utilscip-python python mercurial 7.2.2 `mercurial.util`/__init__:.propertycachescip-python python mercurial 7.2.2 `mercurial.util`/propertycache#
34 FASTLOG_TIMEOUT_IN_SECSscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/FASTLOG_TIMEOUT_IN_SECS. = 0.5
35
36
37 class RFLReposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/RFLRepo#(repositoryscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/__init__:.IReposcip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#, Protocolscip-python python python-stdlib 3.11 typing/Protocol.):
38 fileservicescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/RFLRepo#fileservice.: fileserverclientscip-python python mercurial 7.2.2 fileserverclient/__init__:.fileserverclientscip-python python mercurial 7.2.2 `hgext.remotefilelog.fileserverclient`/fileserverclient#
39
40
41 class remotefilectxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#(contextscip-python python mercurial 7.2.2 `mercurial.context`/__init__:.filectxscip-python python mercurial 7.2.2 `mercurial.context`/filectx#):
42 _reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo.: RFLReposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/RFLRepo#
43
44 def __init__scip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(
45 selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(self),
46 reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(repo),
47 pathscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(path),
48 changeidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(changeid)=None,
49 fileidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(fileid)=None,
50 filelogscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(filelog)=None,
51 changectxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(changectx)=None,
52 ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(ancestormap)=None,
53 ):
54 if fileidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(fileid) == nullrevscip-python python mercurial 7.2.2 `mercurial.node`/nullrev.:
55 fileidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(fileid) = reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(repo).nullid
56 if fileidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(fileid) and len(fileidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(fileid)) == 40:
57 fileidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(fileid) = binscip-python python mercurial 7.2.2 `mercurial.node`/bin.(fileidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(fileid))
58 superscip-python python python-stdlib 3.11 builtins/super#().__init__scip-python python mercurial 7.2.2 `mercurial.context`/filectx#__init__().(reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(repo), pathscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(path), changeidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(changeid), fileidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(fileid), filelogscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(filelog), changectxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(changectx))
59 selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(self)._ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_ancestormap. = ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(ancestormap)
60
61 def sizescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#size().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#size().(self)):
62 return selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#size().(self)._filelogscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_filelog()..size(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#size().(self)._filenodescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_filenode().)
63
64 @propertycachescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/propertycache.
65 def _changeidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_changeid().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_changeid().(self)):
66 if '_changeid' in selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_changeid().(self).__dict__scip-python python python-stdlib 3.11 builtins/__dict__#:
67 return selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_changeid().(self)._changeidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_changeid().
68 elif '_changectx' in selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_changeid().(self).__dict__scip-python python python-stdlib 3.11 builtins/__dict__#:
69 return selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_changeid().(self)._changectxscip-python python mercurial 7.2.2 `mercurial.context`/filectx#_changectx()..rev()
70 elif '_descendantrev' in selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_changeid().(self).__dict__scip-python python python-stdlib 3.11 builtins/__dict__#:
71 # this file context was created from a revision with a known
72 # descendant, we can (lazily) correct for linkrev aliases
73 linknode = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_changeid().(self)._adjustlinknodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(
74 selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_changeid().(self)._pathscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_path., selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_changeid().(self)._filelogscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_filelog()., selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_changeid().(self)._filenodescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_filenode()., selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_changeid().(self)._descendantrev
75 )
76 return selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_changeid().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo..unfilteredscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#unfiltered().().changelogscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#changelog..rev(linknode)
77 else:
78 return selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_changeid().(self).linkrevscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#linkrev().()
79
80 def filectxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#filectx().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#filectx().(self), fileidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#filectx().(fileid), changeidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#filectx().(changeid)=None):
81 """opens an arbitrary revision of the file without
82 opening a new filelog"""
83 return remotefilectxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#(
84 selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#filectx().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo.,
85 selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#filectx().(self)._pathscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_path.,
86 fileidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(fileid)=fileidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#filectx().(fileid),
87 filelogscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(filelog)=selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#filectx().(self)._filelogscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_filelog().,
88 changeidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(changeid)=changeidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#filectx().(changeid),
89 )
90
91 def linkrevscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#linkrev().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#linkrev().(self)):
92 return selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#linkrev().(self)._linkrevscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_linkrev().
93
94 @propertycachescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/propertycache.
95 def _linkrevscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_linkrev().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_linkrev().(self)):
96 if selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_linkrev().(self)._filenodescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_filenode(). == selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_linkrev().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo..nullidscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#nullid.:
97 return nullrevscip-python python mercurial 7.2.2 `mercurial.node`/nullrev.
98
99 ancestormap = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_linkrev().(self).ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestormap().()
100 p1, p2, linknode, copyfrom = ancestormap[selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_linkrev().(self)._filenodescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_filenode().]
101 rev = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_linkrev().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo..changelogscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#changelog..index.get_rev(linknode)
102 if rev is not None:
103 return rev
104
105 # Search all commits for the appropriate linkrev (slow, but uncommon)
106 path = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_linkrev().(self)._pathscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_path.
107 fileid = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_linkrev().(self)._filenodescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_filenode().
108 cl = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_linkrev().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo..unfilteredscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#unfiltered().().changelogscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#changelog.
109 mfl = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_linkrev().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo..manifestlogscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#manifestlog.
110
111 for rev in rangescip-python python python-stdlib 3.11 builtins/range#(len(cl) - 1, 0, -1):
112 node = cl.node(rev)
113 data = cl.read(
114 node
115 ) # get changeset data (we avoid object creation)
116 if path in data[3]: # checking the 'files' field.
117 # The file has been touched, check if the hash is what we're
118 # looking for.
119 #
120 # The change has to be against a parent, otherwise we might be
121 # missing linkrev worthy changes.
122 m = mfl[data[0]].read_delta_parents(exact=False)
123 if fileid == m.get(path):
124 return rev
125
126 # Couldn't find the linkrev. This should generally not happen, and will
127 # likely cause a crash.
128 return None
129
130 def introrevscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#introrev().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#introrev().(self)):
131 """return the rev of the changeset which introduced this file revision
132
133 This method is different from linkrev because it take into account the
134 changeset the filectx was created from. It ensures the returned
135 revision is one of its ancestors. This prevents bugs from
136 'linkrev-shadowing' when a file revision is used by multiple
137 changesets.
138 """
139 lkr = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#introrev().(self).linkrevscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#linkrev().()
140 attrs = varsscip-python python python-stdlib 3.11 builtins/vars().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#introrev().(self))
141 noctx = not ('_changeid' in attrs or r'_changectx' in attrs)
142 if noctx or selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#introrev().(self).revscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#rev().() == lkr:
143 return lkr
144 linknode = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#introrev().(self)._adjustlinknodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(
145 selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#introrev().(self)._pathscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_path.,
146 selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#introrev().(self)._filelogscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_filelog().,
147 selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#introrev().(self)._filenodescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_filenode().,
148 selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#introrev().(self).revscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#rev().(),
149 inclusivescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(inclusive)=True,
150 )
151 return selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#introrev().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo..changelogscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#changelog..rev(linknode)
152
153 def renamedscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#renamed().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#renamed().(self)):
154 """check if file was actually renamed in this changeset revision
155
156 If rename logged in file revision, we report copy for changeset only
157 if file revisions linkrev points back to the changeset in question
158 or both changeset parents contain different file revisions.
159 """
160 ancestormap = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#renamed().(self).ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestormap().()
161
162 p1, p2, linknode, copyfrom = ancestormap[selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#renamed().(self)._filenodescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_filenode().]
163 if not copyfrom:
164 return None
165
166 renamed = (copyfrom, p1)
167 if selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#renamed().(self).revscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#rev().() == selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#renamed().(self).linkrevscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#linkrev().():
168 return renamed
169
170 name = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#renamed().(self).pathscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#path().()
171 fnode = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#renamed().(self)._filenodescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_filenode().
172 for p in selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#renamed().(self)._changectxscip-python python mercurial 7.2.2 `mercurial.context`/filectx#_changectx()..parents():
173 try:
174 if fnode == p.filenode(name):
175 return None
176 except errorscip-python python mercurial 7.2.2 `mercurial.error`/__init__:.LookupErrorscip-python python python-stdlib 3.11 builtins/LookupError#:
177 pass
178 return renamed
179
180 def copysourcescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#copysource().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#copysource().(self)):
181 copy = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#copysource().(self).renamedscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#renamed().()
182 return copy and copy[0]
183
184 def ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestormap().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestormap().(self)):
185 if not selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestormap().(self)._ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_ancestormap.:
186 selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestormap().(self)._ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_ancestormap. = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestormap().(self).filelogscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#filelog().().ancestormap(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestormap().(self)._filenodescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_filenode().)
187
188 return selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestormap().(self)._ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_ancestormap.
189
190 def parentsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#parents().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#parents().(self)):
191 repo = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#parents().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo.
192 ancestormap = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#parents().(self).ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestormap().()
193
194 p1, p2, linknode, copyfrom = ancestormap[selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#parents().(self)._filenodescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_filenode().]
195 results = []
196 if p1 != repo.nullidscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#nullid.:
197 path = copyfrom or selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#parents().(self)._pathscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_path.
198 flog = repo.filescip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#file().(path)
199 p1ctx = remotefilectxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#(
200 repo, path, fileidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(fileid)=p1, filelogscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(filelog)=flog, ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(ancestormap)=ancestormap
201 )
202 p1ctx._descendantrev = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#parents().(self).revscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#rev().()
203 results.appendscip-python python python-stdlib 3.11 builtins/list#append().(p1ctx)
204
205 if p2 != repo.nullidscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#nullid.:
206 path = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#parents().(self)._pathscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_path.
207 flog = repo.filescip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#file().(path)
208 p2ctx = remotefilectxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#(
209 repo, path, fileidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(fileid)=p2, filelogscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(filelog)=flog, ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(ancestormap)=ancestormap
210 )
211 p2ctx._descendantrev = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#parents().(self).revscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#rev().()
212 results.appendscip-python python python-stdlib 3.11 builtins/list#append().(p2ctx)
213
214 return results
215
216 def _nodefromancrevscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_nodefromancrev().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_nodefromancrev().(self), ancrevscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_nodefromancrev().(ancrev), clscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_nodefromancrev().(cl), mflscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_nodefromancrev().(mfl), pathscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_nodefromancrev().(path), fnodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_nodefromancrev().(fnode)):
217 """returns the node for <path> in <ancrev> if content matches <fnode>"""
218 ancctx = clscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_nodefromancrev().(cl).read(ancrevscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_nodefromancrev().(ancrev)) # This avoids object creation.
219 manifestnode, files = ancctx[0], ancctx[3]
220 # If the file was touched in this ancestor, and the content is similar
221 # to the one we are searching for.
222 if pathscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_nodefromancrev().(path) in files:
223 m = mflscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_nodefromancrev().(mfl)[manifestnode].read_delta_parents(exact=False)
224 if fnodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_nodefromancrev().(fnode) == m.get(pathscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_nodefromancrev().(path)):
225 return clscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_nodefromancrev().(cl).node(ancrevscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_nodefromancrev().(ancrev))
226 return None
227
228 def _adjustlinknodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(self), pathscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(path), filelogscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(filelog), fnodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(fnode), srcrevscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(srcrev), inclusivescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(inclusive)=False):
229 """return the first ancestor of <srcrev> introducing <fnode>
230
231 If the linkrev of the file revision does not point to an ancestor of
232 srcrev, we'll walk down the ancestors until we find one introducing
233 this file revision.
234
235 :repo: a localrepository object (used to access changelog and manifest)
236 :path: the file path
237 :fnode: the nodeid of the file revision
238 :filelog: the filelog of this path
239 :srcrev: the changeset revision we search ancestors from
240 :inclusive: if true, the src revision will also be checked
241
242 Note: This is based on adjustlinkrev in core, but it's quite different.
243
244 adjustlinkrev depends on the fact that the linkrev is the bottom most
245 node, and uses that as a stopping point for the ancestor traversal. We
246 can't do that here because the linknode is not guaranteed to be the
247 bottom most one.
248
249 In our code here, we actually know what a bunch of potential ancestor
250 linknodes are, so instead of stopping the cheap-ancestor-traversal when
251 we get to a linkrev, we stop when we see any of the known linknodes.
252 """
253 repo = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo.
254 cl = repo.unfilteredscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#unfiltered().().changelogscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#changelog.
255 mfl = repo.manifestlogscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#manifestlog.
256 ancestormap = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(self).ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestormap().()
257 linknode = ancestormap[fnodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(fnode)][2]
258
259 if srcrevscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(srcrev) is None:
260 # wctx case, used by workingfilectx during mergecopy
261 revs = [p.rev() for p in selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo.[None].parents()]
262 inclusivescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(inclusive) = True # we skipped the real (revless) source
263 else:
264 revs = [srcrevscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(srcrev)]
265
266 if selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(self)._verifylinknodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_verifylinknode().(revs, linknode):
267 return linknode
268
269 commonlogkwargs = {
270 'revs': b' '.joinscip-python python python-stdlib 3.11 builtins/bytes#join().([hexscip-python python mercurial 7.2.2 `mercurial.node`/hex.(cl.node(rev)) for rev in revs]),
271 'fnode': hexscip-python python mercurial 7.2.2 `mercurial.node`/hex.(fnodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(fnode)),
272 'filepath': pathscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(path),
273 'user': shallowutilscip-python python mercurial 7.2.2 shallowutil/__init__:.getusernamescip-python python mercurial 7.2.2 `hgext.remotefilelog.shallowutil`/getusername().(repo.uiscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#ui.),
274 'reponame': shallowutilscip-python python mercurial 7.2.2 shallowutil/__init__:.getreponamescip-python python mercurial 7.2.2 `hgext.remotefilelog.shallowutil`/getreponame().(repo.uiscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#ui.),
275 }
276
277 repo.uiscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#ui..log(b'linkrevfixup', b'adjusting linknode\n', **commonlogkwargs)
278
279 pc = repo._phasecachescip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#_phasecache.
280 seenpublic = False
281 iteranc = cl.ancestors(revs, inclusive=inclusivescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(inclusive))
282 for ancrev in iteranc:
283 # First, check locally-available history.
284 lnode = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(self)._nodefromancrevscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_nodefromancrev().(ancrev, cl, mfl, pathscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(path), fnodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(fnode))
285 if lnode is not None:
286 return lnode
287
288 # adjusting linknode can be super-slow. To mitigate the issue
289 # we use two heuristics: calling fastlog and forcing remotefilelog
290 # prefetch
291 if not seenpublic and pc.phase(repo, ancrev) == phasesscip-python python mercurial 7.2.2 `mercurial.phases`/__init__:.publicscip-python python mercurial 7.2.2 `mercurial.phases`/public.public.:
292 # TODO: there used to be a codepath to fetch linknodes
293 # from a server as a fast path, but it appeared to
294 # depend on an API FB added to their phabricator.
295 lnode = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(self)._forceprefetchscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(
296 repo, pathscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(path), fnodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_adjustlinknode().(fnode), revs, commonlogkwargs
297 )
298 if lnode:
299 return lnode
300 seenpublic = True
301
302 return linknode
303
304 def _forceprefetchscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(self), reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(repo), pathscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(path), fnodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(fnode), revsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(revs), commonlogkwargsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(commonlogkwargs)):
305 # This next part is super non-obvious, so big comment block time!
306 #
307 # It is possible to get extremely bad performance here when a fairly
308 # common set of circumstances occur when this extension is combined
309 # with a server-side commit rewriting extension like pushrebase.
310 #
311 # First, an engineer creates Commit A and pushes it to the server.
312 # While the server's data structure will have the correct linkrev
313 # for the files touched in Commit A, the client will have the
314 # linkrev of the local commit, which is "invalid" because it's not
315 # an ancestor of the main line of development.
316 #
317 # The client will never download the remotefilelog with the correct
318 # linkrev as long as nobody else touches that file, since the file
319 # data and history hasn't changed since Commit A.
320 #
321 # After a long time (or a short time in a heavily used repo), if the
322 # same engineer returns to change the same file, some commands --
323 # such as amends of commits with file moves, logs, diffs, etc --
324 # can trigger this _adjustlinknode code. In those cases, finding
325 # the correct rev can become quite expensive, as the correct
326 # revision is far back in history and we need to walk back through
327 # history to find it.
328 #
329 # In order to improve this situation, we force a prefetch of the
330 # remotefilelog data blob for the file we were called on. We do this
331 # at most once, when we first see a public commit in the history we
332 # are traversing.
333 #
334 # Forcing the prefetch means we will download the remote blob even
335 # if we have the "correct" blob in the local store. Since the union
336 # store checks the remote store first, this means we are much more
337 # likely to get the correct linkrev at this point.
338 #
339 # In rare circumstances (such as the server having a suboptimal
340 # linkrev for our use case), we will fall back to the old slow path.
341 #
342 # We may want to add additional heuristics here in the future if
343 # the slow path is used too much. One promising possibility is using
344 # obsolescence markers to find a more-likely-correct linkrev.
345
346 logmsg = b''
347 start = timescip-python python python-stdlib 3.11 time/__init__:.timescip-python python python-stdlib 3.11 time/time().()
348 try:
349 reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(repo).fileservice.prefetch([(pathscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(path), hexscip-python python mercurial 7.2.2 `mercurial.node`/hex.(fnodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(fnode)))], force=True)
350
351 # Now that we've downloaded a new blob from the server,
352 # we need to rebuild the ancestor map to recompute the
353 # linknodes.
354 selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(self)._ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_ancestormap. = None
355 linknode = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(self).ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestormap().()[fnodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(fnode)][2] # 2 is linknode
356 if selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(self)._verifylinknodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_verifylinknode().(revsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(revs), linknode):
357 logmsg = b'remotefilelog prefetching succeeded'
358 return linknode
359 logmsg = b'remotefilelog prefetching not found'
360 return None
361 except Exceptionscip-python python python-stdlib 3.11 builtins/Exception# as e:
362 logmsg = b'remotefilelog prefetching failed (%s)' % e
363 return None
364 finally:
365 elapsed = timescip-python python python-stdlib 3.11 time/__init__:.timescip-python python python-stdlib 3.11 time/time().() - start
366 reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(repo).ui.log(
367 b'linkrevfixup',
368 logmsg + b'\n',
369 elapsed=elapsed * 1000,
370 **commonlogkwargsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_forceprefetch().(commonlogkwargs),
371 )
372
373 def _verifylinknodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_verifylinknode().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_verifylinknode().(self), revsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_verifylinknode().(revs), linknodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_verifylinknode().(linknode)):
374 """
375 Check if a linknode is correct one for the current history.
376
377 That is, return True if the linkrev is the ancestor of any of the
378 passed in revs, otherwise return False.
379
380 `revs` is a list that usually has one element -- usually the wdir parent
381 or the user-passed rev we're looking back from. It may contain two revs
382 when there is a merge going on, or zero revs when a root node with no
383 parents is being created.
384 """
385 if not revsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_verifylinknode().(revs):
386 return False
387 try:
388 # Use the C fastpath to check if the given linknode is correct.
389 cl = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_verifylinknode().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo..unfilteredscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#unfiltered().().changelogscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#changelog.
390 return any(cl.isancestor(linknodescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_verifylinknode().(linknode), cl.node(r)) for r in revsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_verifylinknode().(revs))
391 except errorscip-python python mercurial 7.2.2 `mercurial.error`/__init__:.LookupErrorscip-python python python-stdlib 3.11 builtins/LookupError#:
392 # The linknode read from the blob may have been stripped or
393 # otherwise not present in the repository anymore. Do not fail hard
394 # in this case. Instead, return false and continue the search for
395 # the correct linknode.
396 return False
397
398 def ancestorsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestors().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestors().(self), followfirstscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestors().(followfirst)=False) -> Iteratorscip-python python python-stdlib 3.11 typing/Iterator#[remotefilectxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#]:
399 ancestors = []
400 queue = collectionsscip-python python python-stdlib 3.11 collections/__init__:.dequescip-python python python-stdlib 3.11 collections/deque#((selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestors().(self),))
401 seen = setscip-python python python-stdlib 3.11 builtins/set#()
402 while queue:
403 current = queue.popscip-python python python-stdlib 3.11 collections/deque#pop().()
404 if current.filenodescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#filenode().() in seen:
405 continue
406 seen.addscip-python python python-stdlib 3.11 builtins/set#add().(current.filenodescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#filenode().())
407
408 ancestors.appendscip-python python python-stdlib 3.11 builtins/list#append().(current)
409
410 parents = current.parentsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#parents().()
411 first = True
412 for p in parents:
413 if first or not followfirstscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestors().(followfirst):
414 queue.appendscip-python python python-stdlib 3.11 collections/deque#append().(p)
415 first = False
416
417 # Remove self
418 ancestors.popscip-python python python-stdlib 3.11 builtins/list#pop().(0)
419
420 # Sort by linkrev
421 # The copy tracing algorithm depends on these coming out in order
422 ancestors = sortedscip-python python python-stdlib 3.11 builtins/sorted().(ancestors, reversescip-python python python-stdlib 3.11 builtins/sorted().(reverse)=True, keyscip-python python python-stdlib 3.11 builtins/sorted().(key)=lambda x: x.linkrev())
423
424 yield from ancestors
425
426 def ancestorscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(self), fc2scip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(fc2), actxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(actx)):
427 # the easy case: no (relevant) renames
428 if fc2scip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(fc2).path() == selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(self).pathscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#path().() and selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(self).pathscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#path().() in actxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(actx):
429 return actxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(actx)[selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(self).pathscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#path().()]
430
431 # the next easiest cases: unambiguous predecessor (name trumps
432 # history)
433 if selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(self).pathscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#path().() in actxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(actx) and fc2scip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(fc2).path() not in actxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(actx):
434 return actxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(actx)[selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(self).pathscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#path().()]
435 if fc2scip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(fc2).path() in actxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(actx) and selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(self).pathscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#path().() not in actxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(actx):
436 return actxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(actx)[fc2scip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#ancestor().(fc2).path()]
437
438 # the code handling this was "dead" since by over 10 years and was
439 # deleted. Check history if you need this to work again.
440 raise NotImplementedErrorscip-python python python-stdlib 3.11 builtins/NotImplementedError#
441
442 def annotatescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(self), *argsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(args), **kwargsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(kwargs)):
443 introctx = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(self)
444 prefetchskip = kwargsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(kwargs).popscip-python python python-stdlib 3.11 builtins/dict#pop().('prefetchskip', None)
445 if prefetchskip:
446 # use introrev so prefetchskip can be accurately tested
447 introrev = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(self).introrevscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#introrev().()
448 if selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(self).revscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#rev().() != introrev:
449 introctx = remotefilectxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#(
450 selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo.,
451 selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(self)._pathscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_path.,
452 changeidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(changeid)=introrev,
453 fileidscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(fileid)=selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(self)._filenodescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_filenode().,
454 filelogscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(filelog)=selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(self)._filelogscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_filelog().,
455 ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#__init__().(ancestormap)=selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(self)._ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_ancestormap.,
456 )
457
458 # like self.ancestors, but append to "fetch" and skip visiting parents
459 # of nodes in "prefetchskip".
460 fetch = []
461 seen = setscip-python python python-stdlib 3.11 builtins/set#()
462 queue = collectionsscip-python python python-stdlib 3.11 collections/__init__:.dequescip-python python python-stdlib 3.11 collections/deque#((introctx,))
463 seen.addscip-python python python-stdlib 3.11 builtins/set#add().(introctx.nodescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#node().())
464 while queue:
465 current = queue.popscip-python python python-stdlib 3.11 collections/deque#pop().()
466 if current.filenodescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#filenode().() != selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(self).filenodescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#filenode().():
467 # this is a "joint point". fastannotate needs contents of
468 # "joint point"s to calculate diffs for side branches.
469 fetch.appendscip-python python python-stdlib 3.11 builtins/list#append().((current.pathscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#path().(), hexscip-python python mercurial 7.2.2 `mercurial.node`/hex.(current.filenodescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#filenode().())))
470 if prefetchskip and current in prefetchskip:
471 continue
472 for parent in current.parentsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#parents().():
473 if parent.node() not in seen:
474 seen.addscip-python python python-stdlib 3.11 builtins/set#add().(parent.node())
475 queue.appendscip-python python python-stdlib 3.11 collections/deque#append().(parent)
476
477 selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo..uiscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#ui..debug(
478 b'remotefilelog: prefetching %d files '
479 b'for annotate\n' % len(fetch)
480 )
481 if fetch:
482 selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo..fileservicescip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/RFLRepo#fileservice..prefetchscip-python python mercurial 7.2.2 `hgext.remotefilelog.fileserverclient`/fileserverclient#prefetch().(fetch)
483 return superscip-python python python-stdlib 3.11 builtins/super#().annotatescip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#annotate().(*argsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(args), **kwargsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#annotate().(kwargs))
484
485 # Return empty set so that the hg serve and thg don't stack trace
486 def childrenscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#children().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#children().(self)):
487 return []
488
489
490 class remoteworkingfilectxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#(contextscip-python python mercurial 7.2.2 `mercurial.context`/__init__:.workingfilectxscip-python python mercurial 7.2.2 `mercurial.context`/workingfilectx#, remotefilectxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#):
491 def __init__scip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#__init__().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#__init__().(self), reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#__init__().(repo), pathscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#__init__().(path), filelogscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#__init__().(filelog)=None, workingctxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#__init__().(workingctx)=None):
492 selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#__init__().(self)._ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#_ancestormap. = None
493 superscip-python python python-stdlib 3.11 builtins/super#().__init__scip-python python mercurial 7.2.2 `mercurial.context`/workingfilectx#__init__().(reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#__init__().(repo), pathscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#__init__().(path), filelogscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#__init__().(filelog), workingctxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#__init__().(workingctx))
494
495 def parentsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#parents().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#parents().(self)):
496 return remotefilectxscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#.parentsscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#parents().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#parents().(self))
497
498 def ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#ancestormap().(selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#ancestormap().(self)):
499 if not selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#ancestormap().(self)._ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#_ancestormap.:
500 path = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#ancestormap().(self)._pathscip-python python mercurial 7.2.2 `mercurial.context`/basefilectx#_path.
501 pcl = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#ancestormap().(self)._changectxscip-python python mercurial 7.2.2 `mercurial.context`/workingfilectx#_changectx().._parents
502 renamed = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#ancestormap().(self).renamedscip-python python mercurial 7.2.2 `mercurial.context`/committablefilectx#renamed().()
503
504 if renamed:
505 p1 = renamed
506 else:
507 p1 = (path, pcl[0]._manifest.get(path, selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#ancestormap().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo..nullidscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#nullid.))
508
509 p2 = (path, selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#ancestormap().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo..nullidscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#nullid.)
510 if len(pcl) > 1:
511 p2 = (path, pcl[1]._manifest.get(path, selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#ancestormap().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo..nullidscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#nullid.))
512
513 m = {}
514 if p1[1] != selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#ancestormap().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo..nullidscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#nullid.:
515 p1ctx = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#ancestormap().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo..filectxscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#filectx().(p1[0], fileidscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#filectx().(fileid)=p1[1])
516 m.updatescip-python python python-stdlib 3.11 typing/MutableMapping#update().(p1ctx.filelog().ancestormap(p1[1]))
517
518 if p2[1] != selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#ancestormap().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo..nullidscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#nullid.:
519 p2ctx = selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#ancestormap().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo..filectxscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#filectx().(p2[0], fileidscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#filectx().(fileid)=p2[1])
520 m.updatescip-python python python-stdlib 3.11 typing/MutableMapping#update().(p2ctx.filelog().ancestormap(p2[1]))
521
522 copyfrom = b''
523 if renamed:
524 copyfrom = renamed[0]
525 m[None] = (p1[1], p2[1], selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#ancestormap().(self)._reposcip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remotefilectx#_repo..nullidscip-python python mercurial 7.2.2 `mercurial.interfaces.repository`/IRepo#nullid., copyfrom)
526 selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#ancestormap().(self)._ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#_ancestormap. = m
527
528 return selfscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#ancestormap().(self)._ancestormapscip-python python mercurial 7.2.2 `hgext.remotefilelog.remotefilectx`/remoteworkingfilectx#_ancestormap.