# HG changeset patch # User Nicolas Dumazet # Date 1280239650 -32400 # Node ID df93d61a7790e535f47b4d9c53862a1ad13bae16 # Parent 908f0742e2801cdfc2b795069fd465b7a1d5a18b filectx: use ctx.size comparisons to speed up ctx.cmp Comparing sizes is cheaper than comparing file contents, as it does not involve reading the file on disk or from the filelog. It is however not always possible: some extensions, or encode filters, change data when extracting it to the working directory. [ original upstream description ] diff -r 908f0742e280 -r df93d61a7790 hgkw/keyword.py --- a/hgkw/keyword.py Wed Oct 13 09:18:46 2010 +0100 +++ b/hgkw/keyword.py Tue Jul 27 23:07:30 2010 +0900 @@ -82,7 +82,7 @@ {desc}" expands to the first line of the changeset description. ''' -from mercurial import commands, cmdutil, dispatch, filelog, extensions +from mercurial import commands, context, cmdutil, dispatch, filelog, extensions from mercurial import localrepo, match, patch, templatefilters, templater, util from mercurial.hgweb import webcommands from mercurial.i18n import _ @@ -591,6 +591,12 @@ repo.__class__ = kwrepo + def kwfilectx_cmp(orig, self, fctx): + # keyword affects data size, comparing wdir and filelog size does + # not make sense + return self._filelog.cmp(self._filenode, fctx.data()) + extensions.wrapfunction(context.filectx, 'cmp', kwfilectx_cmp) + extensions.wrapfunction(patch.patchfile, '__init__', kwpatchfile_init) extensions.wrapfunction(patch, 'diff', kw_diff) extensions.wrapfunction(cmdutil, 'copy', kw_copy)