# HG changeset patch# User Nicolas Dumazet <nicdumz.commits@gmail.com># Date 1280239650 -32400# Node ID 1e13a2b8c4d47f1f629b4a8146348f883b4b23ea# Parent 476daa23b8c7a351249145b70eff466c0fc93b88filectx: use ctx.size comparisons to speed up ctx.cmpComparing sizes is cheaper than comparing file contents, as it does notinvolve 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.A _loadfilter call should be cheap, as localrepo caches the result inrepo.filterpats, but in the future we might want to cache a _cancomparesizein localrepo.diff --git a/hgext/keyword.py b/hgext/keyword.py--- a/hgext/keyword.py+++ b/hgext/keyword.py@@ -80,6 +80,7 @@ from mercurial import commands, cmdutil, dispatch, filelog, revlog, extensions from mercurial import patch, localrepo, templater, templatefilters, util, match+from mercurial import context from mercurial.hgweb import webcommands from mercurial.i18n import _ import re, shutil, tempfile@@ -543,6 +544,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) if not kwt.restrict: extensions.wrapfunction(patch, 'diff', kw_diff)diff --git a/mercurial/context.py b/mercurial/context.py--- a/mercurial/context.py+++ b/mercurial/context.py@@ -357,6 +357,10 @@ returns True if different than fctx. """+ self._repo._loadfilter('encode')+ if not self._repo.filterpats['encode'] and self.size() != fctx.size():+ return True+ return self._filelog.cmp(self._filenode, fctx.data()) def renamed(self):