##// END OF EJS Templates
chg: pass --no-profile to disable profiling when starting hg serve...
chg: pass --no-profile to disable profiling when starting hg serve If profiling is enabled via global/user config (as far as I can tell, this doesn't affect use of the --profile flag, but it probably does affect --config profiling.enabled=1), then the profiling data can be *cumulative* for the lifetime of the chg process. This leads to some "interesting" results where hg claims the walltime is something like 200s on a command that took only a second or two to run. Worse, however, is that with at least some profilers (such as the default "stat" profiler), this can cause a large slowdown while generating the profiler output. Differential Revision: https://phab.mercurial-scm.org/D10470

File last commit:

r46554:89a2afe3 default
r47788:8138092f default
Show More
python-hook-examples.py
27 lines | 633 B | text/x-python | PythonLexer
/ contrib / python-hook-examples.py
Alexander Solovyov
diffstat hook example
r7917 '''
Benoit Boissinot
Change wording in example hook
r7918 Examples of useful python hooks for Mercurial.
Alexander Solovyov
diffstat hook example
r7917 '''
Pulkit Goyal
contrib: python-hook-examples use absolute_import
r28562 from __future__ import absolute_import
from mercurial import (
patch,
util,
)
Alexander Solovyov
diffstat hook example
r7917
Augie Fackler
formatting: blacken the codebase...
r43346
Alexander Solovyov
diffstat hook example
r7917 def diffstat(ui, repo, **kwargs):
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 """Example usage:
Alexander Solovyov
diffstat hook example
r7917
[hooks]
commit.diffstat = python:/path/to/this/file.py:diffstat
changegroup.diffstat = python:/path/to/this/file.py:diffstat
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 """
Alexander Solovyov
diffstat hook example
r7917 if kwargs.get('parent2'):
return
node = kwargs['node']
Matt Mackall
misc: replace .parents()[0] with p1()
r13878 first = repo[node].p1().node()
Alexander Solovyov
diffstat hook example
r7917 if 'url' in kwargs:
Martin von Zweigbergk
repo: don't look up context for tip node if it's not needed...
r39931 last = repo.changelog.tip()
Alexander Solovyov
diffstat hook example
r7917 else:
last = node
diff = patch.diff(repo, first, last)
ui.write(patch.diffstat(util.iterlines(diff)))