Mercurial > public > mercurial-scm > hg
comparison hgext/fastannotate/protocol.py @ 39213:303dae0136b0
fastannotate: rip out specialized support for remotefilelog
remotefilelog can choose to collaborate with fastannotate for now if
it needs to, and in the future when we make good on our longstanding
desire to move remotefilelog-like features in-house we'll make sure
things are well-supported via a reasonable interface.
Differential Revision: https://phab.mercurial-scm.org/D4201
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 09 Aug 2018 15:05:43 -0400 |
parents | c8a40b33ce30 |
children | 8da20fc9fc07 |
comparison
equal
deleted
inserted
replaced
39212:ca053fc7efc5 | 39213:303dae0136b0 |
---|---|
132 | 132 |
133 @contextlib.contextmanager | 133 @contextlib.contextmanager |
134 def annotatepeer(repo): | 134 def annotatepeer(repo): |
135 ui = repo.ui | 135 ui = repo.ui |
136 | 136 |
137 # fileservice belongs to remotefilelog | 137 remotepath = ui.expandpath( |
138 fileservice = getattr(repo, 'fileservice', None) | 138 ui.config('fastannotate', 'remotepath', 'default')) |
139 sharepeer = ui.configbool('fastannotate', 'clientsharepeer', True) | 139 peer = hg.peer(ui, {}, remotepath) |
140 | |
141 if sharepeer and fileservice: | |
142 ui.debug('fastannotate: using remotefilelog connection pool\n') | |
143 conn = repo.connectionpool.get(repo.fallbackpath) | |
144 peer = conn.peer | |
145 stolen = True | |
146 else: | |
147 remotepath = ui.expandpath( | |
148 ui.config('fastannotate', 'remotepath', 'default')) | |
149 peer = hg.peer(ui, {}, remotepath) | |
150 stolen = False | |
151 | 140 |
152 try: | 141 try: |
153 # Note: fastannotate requests should never trigger a remotefilelog | |
154 # "getfiles" request, because "getfiles" puts the stream into a state | |
155 # that does not exit. See "clientfetch": it does "getannotate" before | |
156 # any hg stuff that could potentially trigger a "getfiles". | |
157 yield peer | 142 yield peer |
158 finally: | 143 finally: |
159 if not stolen: | 144 peer.close() |
160 for i in ['close', 'cleanup']: | |
161 getattr(peer, i, lambda: None)() | |
162 else: | |
163 conn.__exit__(None, None, None) | |
164 | 145 |
165 def clientfetch(repo, paths, lastnodemap=None, peer=None): | 146 def clientfetch(repo, paths, lastnodemap=None, peer=None): |
166 """download annotate cache from the server for paths""" | 147 """download annotate cache from the server for paths""" |
167 if not paths: | 148 if not paths: |
168 return | 149 return |
207 if threshold <= 0: | 188 if threshold <= 0: |
208 return paths | 189 return paths |
209 | 190 |
210 master = repo.ui.config('fastannotate', 'mainbranch') or 'default' | 191 master = repo.ui.config('fastannotate', 'mainbranch') or 'default' |
211 | 192 |
212 if 'remotefilelog' in repo.requirements: | |
213 ctx = scmutil.revsingle(repo, master) | |
214 f = lambda path: len(ctx[path].ancestormap()) | |
215 else: | |
216 f = lambda path: len(repo.file(path)) | |
217 | |
218 result = [] | 193 result = [] |
219 for path in paths: | 194 for path in paths: |
220 try: | 195 try: |
221 if f(path) >= threshold: | 196 if len(repo.file(path)) >= threshold: |
222 result.append(path) | 197 result.append(path) |
223 except Exception: # file not found etc. | 198 except Exception: # file not found etc. |
224 result.append(path) | 199 result.append(path) |
225 | 200 |
226 return result | 201 return result |