All pastes #1917424 Raw Edit

nicdumz

public text v1 · immutable
#1917424 ·published 2010-08-15 14:46 UTC
rendered paste body
# HG changeset patch# User Nicolas Dumazet <nicdumz.commits@gmail.com># Date 1280239650 -32400# Node ID dc4e0898c5c0f197ebe3b4b922b7072a2fb6c325# Parent  e24edda8ec2975924226710bcc18002d51a50348filectx: 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@@ -542,6 +543,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):