Mercurial > hg
view mercurial/lsprofcalltree.py @ 42209:280f7a095df8 stable
narrow: send specs as bundle2 data instead of param (issue5952) (issue6019)
Before this patch, when ACL is involved, narrowspecs are send as bundle2
parameter for narrow:spec bundle2 part. The limitation of bundle2 parts are they
cannot send data larger than 255 bytes. Includes and excludes in narrow are not
limited by size and they can grow over 255 bytes.
This patch introduces a new mandatory bundle2 part and send narrowspecs as data
of that. The new bundle2 part is introduced to keep things cleaner and easy to
distinguish related to backward compatibility.
The part is mandatory because without server's narrowspec, the local ACL narrow
repo won't work.
This patch makes clients compatible with servers which have older versions.
However I left a comment that we should drop the other bundle2 part soon as
that's broken and people should not rely on that.
I named the new bundle2 part 'Narrow:responsespec' because:
1) Capital 'N' to make it mandatory
2) 'Narrow:spec' cannot be used because bundle2 enforces that there should not
be two different parts which resolve to same name when lowercased.
3) reponsespec clears that they are specs which are send as reponse by the
server
While I was here, I renamed `narrowhgacl` section to `narrowacl` as suggested by
idlsoft@ and martinvonz@.
Differential Revision: https://phab.mercurial-scm.org/D6310
author | Pulkit Goyal <pulkit@yandex-team.ru> |
---|---|
date | Wed, 17 Apr 2019 15:06:41 +0300 |
parents | 720355c7b7c9 |
children | 2372284d9457 |
line wrap: on
line source
""" lsprofcalltree.py - lsprof output which is readable by kcachegrind Authors: * David Allouche <david <at> allouche.net> * Jp Calderone & Itamar Shtull-Trauring * Johan Dahlin This software may be used and distributed according to the terms of the GNU General Public License, incorporated herein by reference. """ from __future__ import absolute_import from . import ( pycompat, ) def label(code): if isinstance(code, str): # built-in functions ('~' sorts at the end) return '~' + pycompat.sysbytes(code) else: return '%s %s:%d' % (pycompat.sysbytes(code.co_name), pycompat.sysbytes(code.co_filename), code.co_firstlineno) class KCacheGrind(object): def __init__(self, profiler): self.data = profiler.getstats() self.out_file = None def output(self, out_file): self.out_file = out_file out_file.write(b'events: Ticks\n') self._print_summary() for entry in self.data: self._entry(entry) def _print_summary(self): max_cost = 0 for entry in self.data: totaltime = int(entry.totaltime * 1000) max_cost = max(max_cost, totaltime) self.out_file.write(b'summary: %d\n' % max_cost) def _entry(self, entry): out_file = self.out_file code = entry.code if isinstance(code, str): out_file.write(b'fi=~\n') else: out_file.write(b'fi=%s\n' % pycompat.sysbytes(code.co_filename)) out_file.write(b'fn=%s\n' % label(code)) inlinetime = int(entry.inlinetime * 1000) if isinstance(code, str): out_file.write(b'0 %d\n' % inlinetime) else: out_file.write(b'%d %d\n' % (code.co_firstlineno, inlinetime)) # recursive calls are counted in entry.calls if entry.calls: calls = entry.calls else: calls = [] if isinstance(code, str): lineno = 0 else: lineno = code.co_firstlineno for subentry in calls: self._subentry(lineno, subentry) out_file.write(b'\n') def _subentry(self, lineno, subentry): out_file = self.out_file code = subentry.code out_file.write(b'cfn=%s\n' % label(code)) if isinstance(code, str): out_file.write(b'cfi=~\n') out_file.write(b'calls=%d 0\n' % subentry.callcount) else: out_file.write(b'cfi=%s\n' % pycompat.sysbytes(code.co_filename)) out_file.write(b'calls=%d %d\n' % ( subentry.callcount, code.co_firstlineno)) totaltime = int(subentry.totaltime * 1000) out_file.write(b'%d %d\n' % (lineno, totaltime))