##// END OF EJS Templates
memfilectx: make changectx argument mandatory in constructor (API)...
memfilectx: make changectx argument mandatory in constructor (API) committablefilectx has three subclasses: workingfilectx, memfilectx, and overlayfilectx. committablefilectx takes an optional (change) ctx instance to its constructor. If it's provided, it's set on the instance as self._changectx. If not, that property is supposed to be defined by the class. However, only workingfilectx does that. The other two will have the property undefined if it's not passed in the constructor. That seems bad to me. This patch makes the changectx argument to the memfilectx constructor mandatory because that fixes the failure I ran into. It seems like we should also fix the overlayfilectx case. Differential Revision: https://phab.mercurial-scm.org/D1658

File last commit:

r28562:2b585677 default
r35401:8a0cac20 default
Show More
python-hook-examples.py
26 lines | 630 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
def diffstat(ui, repo, **kwargs):
Benoit Boissinot
Change wording in example hook
r7918 '''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
'''
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:
last = repo['tip'].node()
else:
last = node
diff = patch.diff(repo, first, last)
ui.write(patch.diffstat(util.iterlines(diff)))