##// END OF EJS Templates
clone: process 'lookup' return as an arbitrary symbol...
clone: process 'lookup' return as an arbitrary symbol In theory, checkout is expected to be a node here because it was returned by peer.lookup. In practice, multiple important extensions (like hg-git, hg-subversion) use peers not backed by a mercurial repository where lookup cannot return a node. Allowing arbitrary symbols is necessary to make these extensions working with 4.7. We should probably introduce a new API in Core to have these extensions to work without abusing the lookup API. In the meantime, a small change to restore compatibility in 4.7 seems in order.

File last commit:

r28562:2b585677 default
r39013:e06a10d3 @93 stable
Show More
python-hook-examples.py
26 lines | 630 B | text/x-python | PythonLexer
/ contrib / python-hook-examples.py
'''
Examples of useful python hooks for Mercurial.
'''
from __future__ import absolute_import
from mercurial import (
patch,
util,
)
def diffstat(ui, repo, **kwargs):
'''Example usage:
[hooks]
commit.diffstat = python:/path/to/this/file.py:diffstat
changegroup.diffstat = python:/path/to/this/file.py:diffstat
'''
if kwargs.get('parent2'):
return
node = kwargs['node']
first = repo[node].p1().node()
if 'url' in kwargs:
last = repo['tip'].node()
else:
last = node
diff = patch.diff(repo, first, last)
ui.write(patch.diffstat(util.iterlines(diff)))