[PATCH] context: narrow down filter special case in filectx.cmp()
Nicolas Dumazet
nicdumz at gmail.com
Thu Oct 14 03:44:35 CDT 2010
2010/10/13 Christian Ebert <blacktrash at gmx.net>:
> # HG changeset patch
> # User Christian Ebert <blacktrash at gmx.net>
> # Date 1286989850 -3600
> # Node ID afb71f62df61bf63b4fc2a22fb770bd8481c00db
> # Parent a7140e18f8317309f830818383cf99c1d6443e98
> context: narrow down filter special case in filectx.cmp()
>
> cmp via filelog when encode filters are present, but only when
> actually comparing to the working directory.
Thanks, the idea looks good.
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -357,10 +357,11 @@
>
> returns True if different than fctx.
> """
> - if not self._repo._encodefilterpats and self.size() != fctx.size():
> - return True
> + if (self._repo._encodefilterpats and fctx.filenode() is None or
> + self.size() == fctx.size()):
> + return self._filelog.cmp(self._filenode, fctx.data())
But isinstance(fctx, workingfilectx) would be clearer.
And since this test is cheap, I would rather have:
if (isinstance(fctx, workingfilectx) and self._repo._encodefilterpats or ...)
If it's fine with you, I can queue a modified version of the patch.
>
> - return self._filelog.cmp(self._filenode, fctx.data())
> + return True
>
> def renamed(self):
> """check if file was actually renamed in this changeset revision
>
--
Nicolas Dumazet — NicDumZ
More information about the Mercurial-devel
mailing list