[PATCH 1 of 2 stable] keyword: do not monkeypatch diff when in restricted mode

Christian Ebert blacktrash at gmx.net
Tue Dec 22 16:55:32 CST 2009

# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1261521728 0
# Node ID bc047172eaa7db410be9e02737619e79453fa4a3
# Parent  f76984a27b3dfdfda17ef93683a3cb9a04e2dc43
keyword: do not monkeypatch diff when in restricted mode

kw_diff actually disabled restricted mode when 2 revisions were given,
because it effectively disables the extension in this case.

But the commands working with diff and patch need restricted mode
always enabled, i.e. expansion enabled when writing to the
working directory and - crucial for these commands - no expansion
when reading the filelog.

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -537,7 +537,8 @@
     repo.__class__ = kwrepo
     extensions.wrapfunction(patch.patchfile, '__init__', kwpatchfile_init)
-    extensions.wrapfunction(patch, 'diff', kw_diff)
+    if not kwt.restrict:
+        extensions.wrapfunction(patch, 'diff', kw_diff)
     for c in 'annotate changeset rev filediff diff'.split():
         extensions.wrapfunction(webcommands, c, kwweb_skip)

More information about the Mercurial-devel mailing list