Mercurial > public > mercurial-scm > hg
comparison hgext/fastannotate/protocol.py @ 39211:c8a40b33ce30
fastannotate: write out files from server in a predictable order
This is mostly for test output stabilization, but it *might* be
slightly better with a ton of annotate caches because we'll write to
one directory at a time rather than bouncing around randomly.
Differential Revision: https://phab.mercurial-scm.org/D3995
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 01 Aug 2018 11:10:41 -0400 |
parents | 1ddb296e0dee |
children | 303dae0136b0 |
comparison
equal
deleted
inserted
replaced
39210:1ddb296e0dee | 39211:c8a40b33ce30 |
---|---|
183 'getannotate', | 183 'getannotate', |
184 {'path': p, 'lastnode':lastnodemap.get(p)})) | 184 {'path': p, 'lastnode':lastnodemap.get(p)})) |
185 | 185 |
186 ui.debug('fastannotate: server returned\n') | 186 ui.debug('fastannotate: server returned\n') |
187 for result in results: | 187 for result in results: |
188 for path, content in result.result().iteritems(): | 188 r = result.result() |
189 for path in sorted(r): | |
189 # ignore malicious paths | 190 # ignore malicious paths |
190 if not path.startswith('fastannotate/') or '/../' in (path + '/'): | 191 if not path.startswith('fastannotate/') or '/../' in (path + '/'): |
191 ui.debug('fastannotate: ignored malicious path %s\n' % path) | 192 ui.debug('fastannotate: ignored malicious path %s\n' % path) |
192 continue | 193 continue |
194 content = r[path] | |
193 if ui.debugflag: | 195 if ui.debugflag: |
194 ui.debug('fastannotate: writing %d bytes to %s\n' | 196 ui.debug('fastannotate: writing %d bytes to %s\n' |
195 % (len(content), path)) | 197 % (len(content), path)) |
196 repo.vfs.makedirs(os.path.dirname(path)) | 198 repo.vfs.makedirs(os.path.dirname(path)) |
197 with repo.vfs(path, 'wb') as f: | 199 with repo.vfs(path, 'wb') as f: |