Patchwork [3,of,9] keyword: make comparison webcommand suppress keyword expansion

login
register
mail settings
Submitter Katsunori FUJIWARA
Date June 25, 2017, 7:09 p.m.
Message ID <9422af09fb1ad4ccbd01.1498417776@speaknoevil>
Download mbox | patch
Permalink /patch/21704/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - June 25, 2017, 7:09 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1498416012 -32400
#      Mon Jun 26 03:40:12 2017 +0900
# Node ID 9422af09fb1ad4ccbd0132c4796eef2fcb83e002
# Parent  0d030855f6427dcb13e0deefe84de6181b692a29
keyword: make comparison webcommand suppress keyword expansion

Before this patch, diff in "comparison" webcommand doesn't suppress
keyword expansion as same as diff output of other webcommands.

Patch

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -121,6 +121,9 @@  testedwith = 'ships-with-hg-core'
 nokwcommands = ('add addremove annotate bundle export grep incoming init log'
                 ' outgoing push tip verify convert email glog')
 
+# webcommands that do not act on keywords
+nokwwebcommands = ('annotate changeset rev filediff diff comparison')
+
 # hg commands that trigger expansion only when writing to working dir,
 # not when reading filelog, and unexpand when reading from working dir
 restricted = ('merge kwexpand kwshrink record qrecord resolve transplant'
@@ -763,6 +766,6 @@  def reposetup(ui, repo):
     extensions.wrapfunction(cmdutil, 'amend', kw_amend)
     extensions.wrapfunction(cmdutil, 'copy', kw_copy)
     extensions.wrapfunction(cmdutil, 'dorecord', kw_dorecord)
-    for c in 'annotate changeset rev filediff diff'.split():
+    for c in nokwwebcommands.split():
         extensions.wrapfunction(webcommands, c, kwweb_skip)
     repo.__class__ = kwrepo
diff --git a/tests/test-keyword.t b/tests/test-keyword.t
--- a/tests/test-keyword.t
+++ b/tests/test-keyword.t
@@ -1018,7 +1018,7 @@  kwexpand nonexistent
 #if serve
 hg serve
  - expand with hgweb file
- - no expansion with hgweb annotate/changeset/filediff
+ - no expansion with hgweb annotate/changeset/filediff/comparison
  - expand with hgweb file, again
  - check errors
 
@@ -1079,6 +1079,12 @@  hg serve
   
   
   
+  $ get-with-headers.py localhost:$HGPORT 'comparison/bb948857c743/a' | grep '\$[a-zA-Z]'
+  <td class="source equal"><a href="#l1r1">     1</a> expand $Id$</td>
+  <td class="source equal"><a href="#l1r1">     1</a> expand $Id$</td>
+  <td class="source equal"><a href="#l2r2">     2</a> do not process $Id:</td>
+  <td class="source equal"><a href="#l2r2">     2</a> do not process $Id:</td>
+  <td class="source insert"><a href="#r4">     4</a> $Xinfo$</td>
 
 (check "kwweb_skip"-ed webcommand doesn't suppress expanding keywords
 at subsequent webcommands)