[PATCH 1 of 1] context: cmp via filelog only when filename matches _encodefilterpats
Christian Ebert
blacktrash at gmx.net
Wed Oct 20 11:40:16 UTC 2010
# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1287574804 -3600
# Node ID 35a316fe68561cf402d0aaf6cf417e366718d475
# Parent 614f0d8724ab9cc49fba959a9f23845827f5c02b
context: cmp via filelog only when filename matches _encodefilterpats
Extra costs:
- no encode/decode filters configured:
1. fctx.path()
2. loop over empty _encodefilterpats list
- encode/decode filters configured:
at least 1 match function per file
The change therefore favours users who have a low ratio of
encode/decode enabled vs. disabled files configured.
Also do the same for hgext.keyword's monkeypatch.
diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -594,10 +594,16 @@
def kwfilectx_cmp(orig, self, fctx):
# keyword affects data size, comparing wdir and filelog size does
# not make sense
- if (fctx._filerev is None and
- (self._repo._encodefilterpats or
- kwt.match(fctx.path()) and not 'l' in fctx.flags()) or
- self.size() == fctx.size()):
+ fmatch = False
+ if fctx._filerev is None:
+ path = fctx.path()
+ for mf, fn, cmd in self._repo._encodefilterpats:
+ if mf(path):
+ fmatch = True
+ break
+ if not fmatch:
+ fmatch = kwt.match(path) and not 'l' in fctx.flags()
+ if fmatch or self.size() == fctx.size():
return self._filelog.cmp(self._filenode, fctx.data())
return True
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -357,8 +357,14 @@
returns True if different than fctx.
"""
- if (fctx._filerev is None and self._repo._encodefilterpats
- or self.size() == fctx.size()):
+ fmatch = False
+ if fctx._filerev is None:
+ path = fctx.path()
+ for mf, fn, cmd in self._repo._encodefilterpats:
+ if mf(path):
+ fmatch = True
+ break
+ if fmatch or self.size() == fctx.size():
return self._filelog.cmp(self._filenode, fctx.data())
return True
More information about the Mercurial-devel
mailing list