[PATCH] keyword: only use expensive fctx.cmp when needed (improved)
Christian Ebert
blacktrash at gmx.net
Wed Oct 13 12:28:16 UTC 2010
# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1286972860 -3600
# Node ID 8fd35de5f7ad821f008b26ef4f29a663b85f9fe2
# Parent 52971985be14f12930a9809d375b97e1ee77d21a
keyword: only use expensive fctx.cmp when needed
Restrict expensive cmp only when:
- comparing against working dir
- path is configured for keyword expansion
Prefer filelog(), filenode() methods over filectx' internal
_filelog, _filenode attributes.
diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -594,9 +594,12 @@
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())
+ if (fctx.filerev() is None and
+ kwt.match(fctx.path()) and not 'l' in fctx.flags()):
+ return self.filelog().cmp(self.filenode(), fctx.data())
+ return orig(self, fctx)
+
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)
More information about the Mercurial-devel
mailing list